Skip to content

Commit 9671efd

Browse files
committed
conditionally compile released SQLite on ifndef SQLITE_TRUNK
Also log a warning when SQLite trunk detects when the WAL is wrapped after the header was read for a checkpoint. Updates tailscale/corp#37997 Signed-off-by: Percy Wegmann <percy@tailscale.com>
1 parent 6aefa1d commit 9671efd

4 files changed

Lines changed: 3 additions & 3 deletions

File tree

cgosqlite/cgosqlite.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package cgosqlite
88
// One exception is we do not use SQLITE_OMIT_DECLTYPE, as the design
99
// of the database/sql driver seems to require it.
1010
11-
#cgo !sqlite_trunk CFLAGS: -DSQLITE_RELEASE
1211
#cgo sqlite_trunk CFLAGS: -DSQLITE_TRUNK
1312
#cgo CFLAGS: -DSQLITE_THREADSAFE=2
1413
#cgo CFLAGS: -DSQLITE_DQS=0

cgosqlite/sqlite3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#ifdef SQLITE_RELEASE
1+
#ifndef SQLITE_TRUNK
22

33
/******************************************************************************
44
** This file is an amalgamation of many separate C source files from SQLite

cgosqlite/sqlite3_trunk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69164,6 +69164,7 @@ static int walCheckpoint(
6916469164
** the wal file. It would also be dangerous to proceed, as there may be
6916569165
** fewer than pWal->hdr.mxFrame valid frames in the wal file. */
6916669166
int bChg = memcmp(pLive->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt));
69167+
if( bChg ) sqlite3_log(SQLITE_WARNING, "wal wrapped after header was read for this checkpoint");
6916769168
if( 0==bChg ){
6916869169
pInfo->nBackfillAttempted = mxSafeFrame; SEH_INJECT_FAULT;
6916969170

update-sqlite.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ unzip "$filename" || fatal "Unzip of $filename failed"
4242
mv "$dirname"/*.{c,h} .
4343
mv shell.c shell.c.disabled
4444
mv sqlite3.c sqlite3.c_partial
45-
printf "#ifdef SQLITE_RELEASE\n\n" > sqlite3.c
45+
printf "#ifndef SQLITE_TRUNK\n\n" > sqlite3.c
4646
cat sqlite3.c_partial >> sqlite3.c
4747
printf "\n\n#endif\n" >> sqlite3.c
4848
rm sqlite3.c_partial

0 commit comments

Comments
 (0)