| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2013 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return false; | 120 return false; |
| 121 | 121 |
| 122 db->setAuthorizerPermissions(m_permissions); | 122 db->setAuthorizerPermissions(m_permissions); |
| 123 | 123 |
| 124 SQLiteDatabase* database = &db->sqliteDatabase(); | 124 SQLiteDatabase* database = &db->sqliteDatabase(); |
| 125 | 125 |
| 126 SQLiteStatement statement(*database, m_statement); | 126 SQLiteStatement statement(*database, m_statement); |
| 127 int result = statement.prepare(); | 127 int result = statement.prepare(); |
| 128 | 128 |
| 129 if (result != SQLResultOk) { | 129 if (result != SQLResultOk) { |
| 130 LOG(StorageAPI, "Unable to verify correctness of statement %s - error %i
(%s)", m_statement.ascii().data(), result, database->lastErrorMsg()); | 130 LOG_INFO(StorageAPI, "Unable to verify correctness of statement %s - err
or %i (%s)", m_statement.ascii().data(), result, database->lastErrorMsg()); |
| 131 if (result == SQLResultInterrupt) | 131 if (result == SQLResultInterrupt) |
| 132 m_error = SQLError::create(SQLError::DATABASE_ERR, "could not prepar
e statement", result, "interrupted"); | 132 m_error = SQLError::create(SQLError::DATABASE_ERR, "could not prepar
e statement", result, "interrupted"); |
| 133 else | 133 else |
| 134 m_error = SQLError::create(SQLError::SYNTAX_ERR, "could not prepare
statement", result, database->lastErrorMsg()); | 134 m_error = SQLError::create(SQLError::SYNTAX_ERR, "could not prepare
statement", result, database->lastErrorMsg()); |
| 135 db->reportExecuteStatementResult(1, m_error->code(), result); | 135 db->reportExecuteStatementResult(1, m_error->code(), result); |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // FIXME: If the statement uses the ?### syntax supported by sqlite, the bin
d parameter count is very likely off from the number of question marks. | 139 // FIXME: If the statement uses the ?### syntax supported by sqlite, the bin
d parameter count is very likely off from the number of question marks. |
| 140 // If this is the case, they might be trying to do something fishy or malici
ous | 140 // If this is the case, they might be trying to do something fishy or malici
ous |
| 141 if (statement.bindParameterCount() != m_arguments.size()) { | 141 if (statement.bindParameterCount() != m_arguments.size()) { |
| 142 LOG(StorageAPI, "Bind parameter count doesn't match number of question m
arks"); | 142 LOG_INFO(StorageAPI, "Bind parameter count doesn't match number of quest
ion marks"); |
| 143 m_error = SQLError::create(db->isInterrupted() ? SQLError::DATABASE_ERR
: SQLError::SYNTAX_ERR, "number of '?'s in statement string does not match argum
ent count"); | 143 m_error = SQLError::create(db->isInterrupted() ? SQLError::DATABASE_ERR
: SQLError::SYNTAX_ERR, "number of '?'s in statement string does not match argum
ent count"); |
| 144 db->reportExecuteStatementResult(2, m_error->code(), 0); | 144 db->reportExecuteStatementResult(2, m_error->code(), 0); |
| 145 return false; | 145 return false; |
| 146 } | 146 } |
| 147 | 147 |
| 148 for (unsigned i = 0; i < m_arguments.size(); ++i) { | 148 for (unsigned i = 0; i < m_arguments.size(); ++i) { |
| 149 result = statement.bindValue(i + 1, m_arguments[i]); | 149 result = statement.bindValue(i + 1, m_arguments[i]); |
| 150 if (result == SQLResultFull) { | 150 if (result == SQLResultFull) { |
| 151 setFailureDueToQuota(db); | 151 setFailureDueToQuota(db); |
| 152 return false; | 152 return false; |
| 153 } | 153 } |
| 154 | 154 |
| 155 if (result != SQLResultOk) { | 155 if (result != SQLResultOk) { |
| 156 LOG(StorageAPI, "Failed to bind value index %i to statement for quer
y '%s'", i + 1, m_statement.ascii().data()); | 156 LOG_INFO(StorageAPI, "Failed to bind value index %i to statement for
query '%s'", i + 1, m_statement.ascii().data()); |
| 157 db->reportExecuteStatementResult(3, SQLError::DATABASE_ERR, result); | 157 db->reportExecuteStatementResult(3, SQLError::DATABASE_ERR, result); |
| 158 m_error = SQLError::create(SQLError::DATABASE_ERR, "could not bind v
alue", result, database->lastErrorMsg()); | 158 m_error = SQLError::create(SQLError::DATABASE_ERR, "could not bind v
alue", result, database->lastErrorMsg()); |
| 159 return false; | 159 return false; |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 RefPtr<SQLResultSet> resultSet = SQLResultSet::create(); | 163 RefPtr<SQLResultSet> resultSet = SQLResultSet::create(); |
| 164 | 164 |
| 165 // Step so we can fetch the column names. | 165 // Step so we can fetch the column names. |
| 166 result = statement.step(); | 166 result = statement.step(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 } | 239 } |
| 240 | 240 |
| 241 bool SQLStatementBackend::lastExecutionFailedDueToQuota() const | 241 bool SQLStatementBackend::lastExecutionFailedDueToQuota() const |
| 242 { | 242 { |
| 243 return m_error && m_error->code() == SQLError::QUOTA_ERR; | 243 return m_error && m_error->code() == SQLError::QUOTA_ERR; |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace WebCore | 246 } // namespace WebCore |
| 247 | 247 |
| 248 #endif // ENABLE(SQL_DATABASE) | 248 #endif // ENABLE(SQL_DATABASE) |
| OLD | NEW |