Skip to content

Commit

Permalink
Fix SQLiteDatabase::turnOnIncrementalAutoVacuum()
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259284
rdar://112475480

Reviewed by Chris Dumez.

PulkoMandy from the Haiku port found that turnOnIncrementalAutoVacuum is broken again on trunk due
to 258673@main. (It was previously fixed in 241334@main.)

The issue is that we need to call lastError() immediately after the call to columnInt. What we were
doing was calling it immediatley after the destructor for the PRAGMA auto_vacuum statement. So
instead of checking the return code for the statement running, we were checking the return code for
finalizing the statement.

* Source/WebCore/platform/sql/SQLiteDatabase.cpp:
(WebCore::SQLiteDatabase::turnOnIncrementalAutoVacuum):

Canonical link: https://commits.webkit.org/266139@main
  • Loading branch information
bnham committed Jul 18, 2023
1 parent e9f264d commit a448508
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Source/WebCore/platform/sql/SQLiteDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,16 +673,21 @@ bool SQLiteDatabase::turnOnIncrementalAutoVacuum()
if (!statement)
return false;
autoVacuumMode = statement->columnInt(0);
}

// Check if we got an error while trying to get the value of the auto_vacuum flag.
// If we got a SQLITE_BUSY error, then there's probably another transaction in
// progress on this database. In this case, keep the current value of the
// auto_vacuum flag and try to set it to INCREMENTAL the next time we open this
// database. If the error is not SQLITE_BUSY, then we probably ran into a more
// serious problem and should return false (to log an error message).
if (lastError() != SQLITE_ROW)
return false;
// Check if we got an error while trying to get the value of the auto_vacuum flag.
// If we got a SQLITE_BUSY error, then there's probably another transaction in
// progress on this database. In this case, keep the current value of the
// auto_vacuum flag and try to set it to INCREMENTAL the next time we open this
// database. If the error is not SQLITE_BUSY, then we probably ran into a more
// serious problem and should return false (to log an error message).
//
// The call to lastError() here MUST be made immediately after the call to columnInt
// and before the destructor of the PRAGMA auto_vacuum statement. This is because we
// want to get the return value of the sqlite3_step issued by columnInt, not the
// return value of the sqlite3_finalize issued by the statement destructor.
if (lastError() != SQLITE_ROW)
return false;
}

switch (autoVacuumMode) {
case AutoVacuumIncremental:
Expand Down

0 comments on commit a448508

Please sign in to comment.