| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
| 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 | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "modules/webdatabase/sqlite/SQLiteDatabase.h" | 27 #include "modules/webdatabase/sqlite/SQLiteDatabase.h" |
| 28 | 28 |
| 29 #include "platform/Logging.h" | 29 #include "modules/webdatabase/sqlite/SQLLog.h" |
| 30 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h" | 30 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h" |
| 31 #include "modules/webdatabase/sqlite/SQLiteStatement.h" | 31 #include "modules/webdatabase/sqlite/SQLiteStatement.h" |
| 32 #include "modules/webdatabase/DatabaseAuthorizer.h" | 32 #include "modules/webdatabase/DatabaseAuthorizer.h" |
| 33 #include "third_party/sqlite/sqlite3.h" | 33 #include "third_party/sqlite/sqlite3.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 const int SQLResultDone = SQLITE_DONE; | 37 const int SQLResultDone = SQLITE_DONE; |
| 38 const int SQLResultOk = SQLITE_OK; | 38 const int SQLResultOk = SQLITE_OK; |
| 39 const int SQLResultRow = SQLITE_ROW; | 39 const int SQLResultRow = SQLITE_ROW; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 return pageCount * pageSize(); | 186 return pageCount * pageSize(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void SQLiteDatabase::setBusyTimeout(int ms) | 189 void SQLiteDatabase::setBusyTimeout(int ms) |
| 190 { | 190 { |
| 191 if (m_db) | 191 if (m_db) |
| 192 sqlite3_busy_timeout(m_db, ms); | 192 sqlite3_busy_timeout(m_db, ms); |
| 193 else | 193 else |
| 194 WTF_LOG(SQLDatabase, "BusyTimeout set on non-open database"); | 194 SQL_DVLOG(1) << "BusyTimeout set on non-open database"; |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool SQLiteDatabase::executeCommand(const String& sql) | 197 bool SQLiteDatabase::executeCommand(const String& sql) |
| 198 { | 198 { |
| 199 return SQLiteStatement(*this, sql).executeCommand(); | 199 return SQLiteStatement(*this, sql).executeCommand(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool SQLiteDatabase::tableExists(const String& tablename) | 202 bool SQLiteDatabase::tableExists(const String& tablename) |
| 203 { | 203 { |
| 204 if (!isOpen()) | 204 if (!isOpen()) |
| 205 return false; | 205 return false; |
| 206 | 206 |
| 207 String statement = "SELECT name FROM sqlite_master WHERE type = 'table' AND
name = '" + tablename + "';"; | 207 String statement = "SELECT name FROM sqlite_master WHERE type = 'table' AND
name = '" + tablename + "';"; |
| 208 | 208 |
| 209 SQLiteStatement sql(*this, statement); | 209 SQLiteStatement sql(*this, statement); |
| 210 sql.prepare(); | 210 sql.prepare(); |
| 211 return sql.step() == SQLITE_ROW; | 211 return sql.step() == SQLITE_ROW; |
| 212 } | 212 } |
| 213 | 213 |
| 214 int SQLiteDatabase::runVacuumCommand() | 214 int SQLiteDatabase::runVacuumCommand() |
| 215 { | 215 { |
| 216 if (!executeCommand("VACUUM;")) | 216 if (!executeCommand("VACUUM;")) |
| 217 WTF_LOG(SQLDatabase, "Unable to vacuum database - %s", lastErrorMsg()); | 217 SQL_DVLOG(1) << "Unable to vacuum database -" << lastErrorMsg(); |
| 218 return lastError(); | 218 return lastError(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 int SQLiteDatabase::runIncrementalVacuumCommand() | 221 int SQLiteDatabase::runIncrementalVacuumCommand() |
| 222 { | 222 { |
| 223 MutexLocker locker(m_authorizerLock); | 223 MutexLocker locker(m_authorizerLock); |
| 224 enableAuthorizer(false); | 224 enableAuthorizer(false); |
| 225 | 225 |
| 226 if (!executeCommand("PRAGMA incremental_vacuum")) | 226 if (!executeCommand("PRAGMA incremental_vacuum")) |
| 227 WTF_LOG(SQLDatabase, "Unable to run incremental vacuum - %s", lastErrorM
sg()); | 227 SQL_DVLOG(1) << "Unable to run incremental vacuum - " << lastErrorMsg(); |
| 228 | 228 |
| 229 enableAuthorizer(true); | 229 enableAuthorizer(true); |
| 230 return lastError(); | 230 return lastError(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 int64_t SQLiteDatabase::lastInsertRowID() | 233 int64_t SQLiteDatabase::lastInsertRowID() |
| 234 { | 234 { |
| 235 if (!m_db) | 235 if (!m_db) |
| 236 return 0; | 236 return 0; |
| 237 return sqlite3_last_insert_rowid(m_db); | 237 return sqlite3_last_insert_rowid(m_db); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 default: | 395 default: |
| 396 if (!executeCommand("PRAGMA auto_vacuum = 2")) | 396 if (!executeCommand("PRAGMA auto_vacuum = 2")) |
| 397 return false; | 397 return false; |
| 398 runVacuumCommand(); | 398 runVacuumCommand(); |
| 399 error = lastError(); | 399 error = lastError(); |
| 400 return (error == SQLITE_OK); | 400 return (error == SQLITE_OK); |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 | 403 |
| 404 } // namespace blink | 404 } // namespace blink |
| OLD | NEW |