Skip to content

Commit

Permalink
Ensure no user checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
marco6 committed Oct 4, 2024
1 parent ad09b6a commit 7a1fc34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/leader.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ static int openConnection(const char *filename,
goto err;
}

rc = sqlite3_exec(*conn, "PRAGMA wal_autocheckpoint=0", NULL, NULL,
&msg);
rc = sqlite3_wal_autocheckpoint(*conn, 0);
if (rc != SQLITE_OK) {
tracef("wal autocheckpoint off failed %d", rc);
goto err;
Expand Down
8 changes: 6 additions & 2 deletions src/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ static int vfsFileControlPragma(struct vfsFile *f, char **fnctl)

assert(left != NULL);

if (strcmp(left, "page_size") == 0 && right) {
if (sqlite3_stricmp(left, "page_size") == 0 && right) {
/* When the user executes 'PRAGMA page_size=N' we save the
* size internally.
*
Expand All @@ -1266,14 +1266,18 @@ static int vfsFileControlPragma(struct vfsFile *f, char **fnctl)
return SQLITE_IOERR;
}
}
} else if (strcmp(left, "journal_mode") == 0 && right) {
} else if (sqlite3_stricmp(left, "journal_mode") == 0 && right) {
/* When the user executes 'PRAGMA journal_mode=x' we ensure
* that the desired mode is 'wal'. */
if (strcasecmp(right, "wal") != 0) {
fnctl[0] =
sqlite3_mprintf("only WAL mode is supported");
return SQLITE_IOERR;
}
} else if (sqlite3_stricmp(left, "wal_checkpoint") == 0
|| (sqlite3_stricmp(left, "wal_autocheckpoint") == 0 && right)) {
fnctl[0] = sqlite3_mprintf("custom checkpoint not allowed");
return SQLITE_IOERR;

Check warning on line 1280 in src/vfs.c

View check run for this annotation

Codecov / codecov/patch

src/vfs.c#L1279-L1280

Added lines #L1279 - L1280 were not covered by tests
}

/* We're returning NOTFOUND here to tell SQLite that we wish it to go on
Expand Down

0 comments on commit 7a1fc34

Please sign in to comment.