Skip to content

Commit a43ba20

Browse files
committed
wal: add autoinitialization to libsql_wal_methods* methods
These are customarily run early, before a call to libsql_open, so it makes sense to auto-initialize.
1 parent 4960a71 commit a43ba20

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/wal.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4096,6 +4096,13 @@ libsql_wal_methods *libsql_wal_methods_find(const char *zName) {
40964096
static libsql_wal_methods methods;
40974097
static libsql_wal_methods *methods_head = NULL;
40984098

4099+
#ifndef SQLITE_OMIT_AUTOINIT
4100+
int rc = sqlite3_initialize();
4101+
if (rc != SQLITE_OK) {
4102+
return NULL;
4103+
}
4104+
#endif
4105+
40994106
if (!zName || *zName == '\0') {
41004107
zName = "default";
41014108
}
@@ -4159,6 +4166,13 @@ libsql_wal_methods *libsql_wal_methods_find(const char *zName) {
41594166
}
41604167

41614168
int libsql_wal_methods_register(libsql_wal_methods* pWalMethods) {
4169+
#ifndef SQLITE_OMIT_AUTOINIT
4170+
int rc = sqlite3_initialize();
4171+
if (rc != SQLITE_OK) {
4172+
return rc;
4173+
}
4174+
#endif
4175+
41624176
if (strncmp(pWalMethods->zName, "default", 7) == 0) {
41634177
return SQLITE_MISUSE;
41644178
}

0 commit comments

Comments
 (0)