| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sql/connection.h" | 5 #include "sql/connection.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 AssertIOAllowed(); | 718 AssertIOAllowed(); |
| 719 | 719 |
| 720 // Return inactive statement. | 720 // Return inactive statement. |
| 721 if (!db_) | 721 if (!db_) |
| 722 return new StatementRef(NULL, NULL, poisoned_); | 722 return new StatementRef(NULL, NULL, poisoned_); |
| 723 | 723 |
| 724 sqlite3_stmt* stmt = NULL; | 724 sqlite3_stmt* stmt = NULL; |
| 725 int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL); | 725 int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL); |
| 726 if (rc != SQLITE_OK) { | 726 if (rc != SQLITE_OK) { |
| 727 // This is evidence of a syntax error in the incoming SQL. | 727 // This is evidence of a syntax error in the incoming SQL. |
| 728 DLOG_IF(FATAL, !ShouldIgnoreSqliteError(rc)) | 728 if (!ShouldIgnoreSqliteError(rc)) |
| 729 << "SQL compile error " << GetErrorMessage(); | 729 DLOG(FATAL) << "SQL compile error " << GetErrorMessage(); |
| 730 | 730 |
| 731 // It could also be database corruption. | 731 // It could also be database corruption. |
| 732 OnSqliteError(rc, NULL, sql); | 732 OnSqliteError(rc, NULL, sql); |
| 733 return new StatementRef(NULL, NULL, false); | 733 return new StatementRef(NULL, NULL, false); |
| 734 } | 734 } |
| 735 return new StatementRef(this, stmt, true); | 735 return new StatementRef(this, stmt, true); |
| 736 } | 736 } |
| 737 | 737 |
| 738 scoped_refptr<Connection::StatementRef> Connection::GetUntrackedStatement( | 738 scoped_refptr<Connection::StatementRef> Connection::GetUntrackedStatement( |
| 739 const char* sql) const { | 739 const char* sql) const { |
| 740 // Return inactive statement. | 740 // Return inactive statement. |
| 741 if (!db_) | 741 if (!db_) |
| 742 return new StatementRef(NULL, NULL, poisoned_); | 742 return new StatementRef(NULL, NULL, poisoned_); |
| 743 | 743 |
| 744 sqlite3_stmt* stmt = NULL; | 744 sqlite3_stmt* stmt = NULL; |
| 745 int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL); | 745 int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL); |
| 746 if (rc != SQLITE_OK) { | 746 if (rc != SQLITE_OK) { |
| 747 // This is evidence of a syntax error in the incoming SQL. | 747 // This is evidence of a syntax error in the incoming SQL. |
| 748 DLOG_IF(FATAL, !ShouldIgnoreSqliteError(rc)) | 748 if (!ShouldIgnoreSqliteError(rc)) |
| 749 << "SQL compile error " << GetErrorMessage(); | 749 DLOG(FATAL) << "SQL compile error " << GetErrorMessage(); |
| 750 return new StatementRef(NULL, NULL, false); | 750 return new StatementRef(NULL, NULL, false); |
| 751 } | 751 } |
| 752 return new StatementRef(NULL, stmt, true); | 752 return new StatementRef(NULL, stmt, true); |
| 753 } | 753 } |
| 754 | 754 |
| 755 std::string Connection::GetSchema() const { | 755 std::string Connection::GetSchema() const { |
| 756 // The ORDER BY should not be necessary, but relying on organic | 756 // The ORDER BY should not be necessary, but relying on organic |
| 757 // order for something like this is questionable. | 757 // order for something like this is questionable. |
| 758 const char* kSql = | 758 const char* kSql = |
| 759 "SELECT type, name, tbl_name, sql " | 759 "SELECT type, name, tbl_name, sql " |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 // Best effort to put things back as they were before. | 1133 // Best effort to put things back as they were before. |
| 1134 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; | 1134 const char kNoWritableSchema[] = "PRAGMA writable_schema = OFF"; |
| 1135 ignore_result(Execute(kNoWritableSchema)); | 1135 ignore_result(Execute(kNoWritableSchema)); |
| 1136 | 1136 |
| 1137 return ret; | 1137 return ret; |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 } // namespace sql | 1140 } // namespace sql |
| OLD | NEW |