| 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 * | 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #if SQLITE_VERSION_NUMBER < 3006016 | 37 #if SQLITE_VERSION_NUMBER < 3006016 |
| 38 #error SQLite version 3.6.16 or newer is required | 38 #error SQLite version 3.6.16 or newer is required |
| 39 #endif | 39 #endif |
| 40 | 40 |
| 41 namespace WebCore { | 41 namespace WebCore { |
| 42 | 42 |
| 43 SQLiteStatement::SQLiteStatement(SQLiteDatabase& db, const String& sql) | 43 SQLiteStatement::SQLiteStatement(SQLiteDatabase& db, const String& sql) |
| 44 : m_database(db) | 44 : m_database(db) |
| 45 , m_query(sql) | 45 , m_query(sql) |
| 46 , m_statement(0) | 46 , m_statement(0) |
| 47 #ifndef NDEBUG | 47 #if ENABLE(ASSERT) |
| 48 , m_isPrepared(false) | 48 , m_isPrepared(false) |
| 49 #endif | 49 #endif |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 SQLiteStatement::~SQLiteStatement() | 53 SQLiteStatement::~SQLiteStatement() |
| 54 { | 54 { |
| 55 finalize(); | 55 finalize(); |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 73 size_t lengthIncludingNullCharacter = query.length() + 1; | 73 size_t lengthIncludingNullCharacter = query.length() + 1; |
| 74 | 74 |
| 75 const char* tail = 0; | 75 const char* tail = 0; |
| 76 int error = sqlite3_prepare_v2(m_database.sqlite3Handle(), query.data(), len
gthIncludingNullCharacter, &m_statement, &tail); | 76 int error = sqlite3_prepare_v2(m_database.sqlite3Handle(), query.data(), len
gthIncludingNullCharacter, &m_statement, &tail); |
| 77 | 77 |
| 78 if (error != SQLITE_OK) | 78 if (error != SQLITE_OK) |
| 79 WTF_LOG(SQLDatabase, "sqlite3_prepare16 failed (%i)\n%s\n%s", error, que
ry.data(), sqlite3_errmsg(m_database.sqlite3Handle())); | 79 WTF_LOG(SQLDatabase, "sqlite3_prepare16 failed (%i)\n%s\n%s", error, que
ry.data(), sqlite3_errmsg(m_database.sqlite3Handle())); |
| 80 else if (tail && *tail) | 80 else if (tail && *tail) |
| 81 error = SQLITE_ERROR; | 81 error = SQLITE_ERROR; |
| 82 | 82 |
| 83 #ifndef NDEBUG | 83 #if ENABLE(ASSERT) |
| 84 m_isPrepared = error == SQLITE_OK; | 84 m_isPrepared = error == SQLITE_OK; |
| 85 #endif | 85 #endif |
| 86 return error; | 86 return error; |
| 87 } | 87 } |
| 88 | 88 |
| 89 int SQLiteStatement::step() | 89 int SQLiteStatement::step() |
| 90 { | 90 { |
| 91 ThreadState::SafePointScope scope(ThreadState::HeapPointersOnStack); | 91 ThreadState::SafePointScope scope(ThreadState::HeapPointersOnStack); |
| 92 MutexLocker databaseLock(m_database.databaseMutex()); | 92 MutexLocker databaseLock(m_database.databaseMutex()); |
| 93 if (m_database.isInterrupted()) | 93 if (m_database.isInterrupted()) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 106 if (error != SQLITE_DONE && error != SQLITE_ROW) { | 106 if (error != SQLITE_DONE && error != SQLITE_ROW) { |
| 107 WTF_LOG(SQLDatabase, "sqlite3_step failed (%i)\nQuery - %s\nError - %s", | 107 WTF_LOG(SQLDatabase, "sqlite3_step failed (%i)\nQuery - %s\nError - %s", |
| 108 error, m_query.ascii().data(), sqlite3_errmsg(m_database.sqlite3Hand
le())); | 108 error, m_query.ascii().data(), sqlite3_errmsg(m_database.sqlite3Hand
le())); |
| 109 } | 109 } |
| 110 | 110 |
| 111 return error; | 111 return error; |
| 112 } | 112 } |
| 113 | 113 |
| 114 int SQLiteStatement::finalize() | 114 int SQLiteStatement::finalize() |
| 115 { | 115 { |
| 116 #ifndef NDEBUG | 116 #if ENABLE(ASSERT) |
| 117 m_isPrepared = false; | 117 m_isPrepared = false; |
| 118 #endif | 118 #endif |
| 119 if (!m_statement) | 119 if (!m_statement) |
| 120 return SQLITE_OK; | 120 return SQLITE_OK; |
| 121 WTF_LOG(SQLDatabase, "SQL - finalize - %s", m_query.ascii().data()); | 121 WTF_LOG(SQLDatabase, "SQL - finalize - %s", m_query.ascii().data()); |
| 122 int result = sqlite3_finalize(m_statement); | 122 int result = sqlite3_finalize(m_statement); |
| 123 m_statement = 0; | 123 m_statement = 0; |
| 124 return result; | 124 return result; |
| 125 } | 125 } |
| 126 | 126 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 ASSERT(col >= 0); | 267 ASSERT(col >= 0); |
| 268 if (!m_statement) | 268 if (!m_statement) |
| 269 if (prepareAndStep() != SQLITE_ROW) | 269 if (prepareAndStep() != SQLITE_ROW) |
| 270 return 0; | 270 return 0; |
| 271 if (columnCount() <= col) | 271 if (columnCount() <= col) |
| 272 return 0; | 272 return 0; |
| 273 return sqlite3_column_int64(m_statement, col); | 273 return sqlite3_column_int64(m_statement, col); |
| 274 } | 274 } |
| 275 | 275 |
| 276 } // namespace WebCore | 276 } // namespace WebCore |
| OLD | NEW |