Skip to content

Commit

Permalink
vwal: introduce iVersion for being future-proof
Browse files Browse the repository at this point in the history
Similarly to how other interfaces work, the version number in WAL methods
lets the user know which functions are supported, and which aren't yet.
  • Loading branch information
psarna committed Dec 13, 2022
1 parent 07f0c58 commit 904c7bf
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/vwal/vwal.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static void v_get_wal_pathname(char *buf, const char *orig, int orig_len) {
__attribute__((__visibility__("default")))
void libsql_register_vwal() {
static libsql_wal_methods methods = {
.iVersion = 1,
.xOpen = v_open,
.xClose = v_close,
.xLimit = v_limit,
Expand Down
1 change: 1 addition & 0 deletions src/wal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4111,6 +4111,7 @@ libsql_wal_methods *libsql_wal_methods_find(const char *zName) {
zName = "default";
}
if (methods_head == NULL && strncmp(zName, "default", 7) == 0) {
methods.iVersion = 1;
methods.xOpen = sqlite3WalOpen;
methods.xClose = sqlite3WalClose;
methods.xLimit = sqlite3WalLimit;
Expand Down
1 change: 1 addition & 0 deletions src/wal.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
typedef struct Wal Wal;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility *.
/* Open and close a connection to a write-ahead log. */
int (*xOpen)(sqlite3_vfs*, sqlite3_file* , const char*, int no_shm_mode, i64 max_size, struct libsql_wal_methods*, Wal**);
int (*xClose)(Wal*, sqlite3* db, int sync_flags, int nBuf, u8 *zBuf);
Expand Down

0 comments on commit 904c7bf

Please sign in to comment.