diff options
author | Steve Block <steveblock@google.com> | 2009-10-08 17:19:54 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2009-10-20 00:41:58 +0100 |
commit | 231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch) | |
tree | a6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebCore/platform/sql/SQLiteTransaction.cpp | |
parent | e196732677050bd463301566a68a643b6d14b907 (diff) | |
download | external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2 |
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebCore/platform/sql/SQLiteTransaction.cpp')
-rw-r--r-- | WebCore/platform/sql/SQLiteTransaction.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/WebCore/platform/sql/SQLiteTransaction.cpp b/WebCore/platform/sql/SQLiteTransaction.cpp index 0a236be..a4b2ac8 100644 --- a/WebCore/platform/sql/SQLiteTransaction.cpp +++ b/WebCore/platform/sql/SQLiteTransaction.cpp @@ -30,9 +30,10 @@ namespace WebCore { -SQLiteTransaction::SQLiteTransaction(SQLiteDatabase& db) +SQLiteTransaction::SQLiteTransaction(SQLiteDatabase& db, bool readOnly) : m_db(db) , m_inProgress(false) + , m_readOnly(readOnly) { } @@ -46,7 +47,17 @@ void SQLiteTransaction::begin() { if (!m_inProgress) { ASSERT(!m_db.m_transactionInProgress); - m_inProgress = m_db.executeCommand("BEGIN;"); + // Call BEGIN IMMEDIATE for a write transaction to acquire + // a RESERVED lock on the DB file. Otherwise, another write + // transaction (on another connection) could make changes + // to the same DB file before this transaction gets to execute + // any statements. If that happens, this transaction will fail. + // http://www.sqlite.org/lang_transaction.html + // http://www.sqlite.org/lockingv3.html#locking + if (m_readOnly) + m_inProgress = m_db.executeCommand("BEGIN;"); + else + m_inProgress = m_db.executeCommand("BEGIN IMMEDIATE;"); m_db.m_transactionInProgress = m_inProgress; } } |