Skip to content

Commit

Permalink
wal: add autoinitialization to libsql_wal_methods* methods
Browse files Browse the repository at this point in the history
These are customarily run early, before a call to libsql_open,
so it makes sense to auto-initialize.
  • Loading branch information
psarna committed Nov 29, 2022
1 parent 4960a71 commit a43ba20
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/wal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4096,6 +4096,13 @@ libsql_wal_methods *libsql_wal_methods_find(const char *zName) {
static libsql_wal_methods methods;
static libsql_wal_methods *methods_head = NULL;

#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
if (rc != SQLITE_OK) {
return NULL;
}
#endif

if (!zName || *zName == '\0') {
zName = "default";
}
Expand Down Expand Up @@ -4159,6 +4166,13 @@ libsql_wal_methods *libsql_wal_methods_find(const char *zName) {
}

int libsql_wal_methods_register(libsql_wal_methods* pWalMethods) {
#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
if (rc != SQLITE_OK) {
return rc;
}
#endif

if (strncmp(pWalMethods->zName, "default", 7) == 0) {
return SQLITE_MISUSE;
}
Expand Down

0 comments on commit a43ba20

Please sign in to comment.