OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 Apple Inc. All rights reserved. | 3 * Copyright (C) 2013 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 PassRefPtr<SQLResultSet> SQLTransactionBackendSync::executeSQL(const String& sql
Statement, const Vector<SQLValue>& arguments, ExceptionState& exceptionState) | 72 PassRefPtr<SQLResultSet> SQLTransactionBackendSync::executeSQL(const String& sql
Statement, const Vector<SQLValue>& arguments, ExceptionState& exceptionState) |
73 { | 73 { |
74 ASSERT(m_database->executionContext()->isContextThread()); | 74 ASSERT(m_database->executionContext()->isContextThread()); |
75 | 75 |
76 m_database->setLastErrorMessage(""); | 76 m_database->setLastErrorMessage(""); |
77 | 77 |
78 if (!m_database->opened()) { | 78 if (!m_database->opened()) { |
79 m_database->setLastErrorMessage("cannot executeSQL because the database
is not open"); | 79 m_database->setLastErrorMessage("cannot executeSQL because the database
is not open"); |
80 exceptionState.throwDOMException(UnknownError, SQLError::unknownErrorMes
sage); | 80 exceptionState.throwDOMException(UnknownError, SQLError::unknownErrorMes
sage); |
81 return 0; | 81 return nullptr; |
82 } | 82 } |
83 | 83 |
84 if (m_hasVersionMismatch) { | 84 if (m_hasVersionMismatch) { |
85 m_database->setLastErrorMessage("cannot executeSQL because there is a ve
rsion mismatch"); | 85 m_database->setLastErrorMessage("cannot executeSQL because there is a ve
rsion mismatch"); |
86 exceptionState.throwDOMException(VersionError, SQLError::versionErrorMes
sage); | 86 exceptionState.throwDOMException(VersionError, SQLError::versionErrorMes
sage); |
87 return 0; | 87 return nullptr; |
88 } | 88 } |
89 | 89 |
90 if (sqlStatement.isEmpty()) | 90 if (sqlStatement.isEmpty()) |
91 return 0; | 91 return nullptr; |
92 | 92 |
93 int permissions = DatabaseAuthorizer::ReadWriteMask; | 93 int permissions = DatabaseAuthorizer::ReadWriteMask; |
94 if (!m_database->databaseContext()->allowDatabaseAccess()) | 94 if (!m_database->databaseContext()->allowDatabaseAccess()) |
95 permissions |= DatabaseAuthorizer::NoAccessMask; | 95 permissions |= DatabaseAuthorizer::NoAccessMask; |
96 else if (m_readOnly) | 96 else if (m_readOnly) |
97 permissions |= DatabaseAuthorizer::ReadOnlyMask; | 97 permissions |= DatabaseAuthorizer::ReadOnlyMask; |
98 | 98 |
99 SQLStatementSync statement(sqlStatement, arguments, permissions); | 99 SQLStatementSync statement(sqlStatement, arguments, permissions); |
100 | 100 |
101 m_database->resetAuthorizer(); | 101 m_database->resetAuthorizer(); |
102 bool retryStatement = true; | 102 bool retryStatement = true; |
103 RefPtr<SQLResultSet> resultSet; | 103 RefPtr<SQLResultSet> resultSet; |
104 while (retryStatement) { | 104 while (retryStatement) { |
105 retryStatement = false; | 105 retryStatement = false; |
106 resultSet = statement.execute(m_database.get(), exceptionState); | 106 resultSet = statement.execute(m_database.get(), exceptionState); |
107 if (!resultSet) { | 107 if (!resultSet) { |
108 if (m_sqliteTransaction->wasRolledBackBySqlite()) | 108 if (m_sqliteTransaction->wasRolledBackBySqlite()) |
109 return 0; | 109 return nullptr; |
110 | 110 |
111 if (exceptionState.code() == QuotaExceededError) { | 111 if (exceptionState.code() == QuotaExceededError) { |
112 if (m_transactionClient->didExceedQuota(database())) { | 112 if (m_transactionClient->didExceedQuota(database())) { |
113 exceptionState.clearException(); | 113 exceptionState.clearException(); |
114 retryStatement = true; | 114 retryStatement = true; |
115 } else { | 115 } else { |
116 m_database->setLastErrorMessage("there was not enough remain
ing storage space"); | 116 m_database->setLastErrorMessage("there was not enough remain
ing storage space"); |
117 return 0; | 117 return nullptr; |
118 } | 118 } |
119 } | 119 } |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 if (m_database->lastActionChangedDatabase()) | 123 if (m_database->lastActionChangedDatabase()) |
124 m_modifiedDatabase = true; | 124 m_modifiedDatabase = true; |
125 | 125 |
126 return resultSet.release(); | 126 return resultSet.release(); |
127 } | 127 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (m_sqliteTransaction) { | 236 if (m_sqliteTransaction) { |
237 m_sqliteTransaction->rollback(); | 237 m_sqliteTransaction->rollback(); |
238 m_sqliteTransaction.clear(); | 238 m_sqliteTransaction.clear(); |
239 } | 239 } |
240 m_database->enableAuthorizer(); | 240 m_database->enableAuthorizer(); |
241 | 241 |
242 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); | 242 ASSERT(!m_database->sqliteDatabase().transactionInProgress()); |
243 } | 243 } |
244 | 244 |
245 } // namespace WebCore | 245 } // namespace WebCore |
OLD | NEW |