From 904c7bf488b23ca5496b55260f8cfa997fcc3e90 Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Tue, 13 Dec 2022 10:57:47 +0100 Subject: [PATCH] vwal: introduce iVersion for being future-proof 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. --- ext/vwal/vwal.c | 1 + src/wal.c | 1 + src/wal.h | 1 + 3 files changed, 3 insertions(+) diff --git a/ext/vwal/vwal.c b/ext/vwal/vwal.c index 619770d602..4a1537363b 100644 --- a/ext/vwal/vwal.c +++ b/ext/vwal/vwal.c @@ -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, diff --git a/src/wal.c b/src/wal.c index bc751ae823..43d0d65189 100644 --- a/src/wal.c +++ b/src/wal.c @@ -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; diff --git a/src/wal.h b/src/wal.h index 6383fb5e6a..82fda26609 100644 --- a/src/wal.h +++ b/src/wal.h @@ -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);