Skip to content

Commit

Permalink
set up libsql loadable extension methods and call them
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Oct 11, 2023
1 parent ecb5e1f commit bdfc389
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/crr/src/crsqlite.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "crsqlite.h"
SQLITE_EXTENSION_INIT1
LIBSQL_EXTENSION_INIT1

#include <assert.h>
#include <ctype.h>
Expand Down Expand Up @@ -364,10 +365,12 @@ int sqlite3_crsqlrustbundle_init(sqlite3 *db, char **pzErrMsg,
__declspec(dllexport)
#endif
int sqlite3_crsqlite_init(sqlite3 *db, char **pzErrMsg,
const sqlite3_api_routines *pApi) {
const sqlite3_api_routines *pApi,
const libsql_api_routines *pLibsqlApi) {
int rc = SQLITE_OK;

SQLITE_EXTENSION_INIT2(pApi);
LIBSQL_EXTENSION_INIT2(pLibsqlApi)

// TODO: should be moved lower once we finish migrating to rust.
// RN it is safe here since the rust bundle init is largely just reigstering
Expand Down
1 change: 1 addition & 0 deletions ext/crr/src/crsqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT3
LIBSQL_EXTENSION_INIT3

#include <stdint.h>

Expand Down
1 change: 1 addition & 0 deletions src/sqlite3ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ struct libsql_api_routines {
struct libsql_wal_methods *(*wal_methods_find)(const char *);
int (*wal_methods_register)(struct libsql_wal_methods*);
int (*wal_methods_unregister)(struct libsql_wal_methods*);
/* libSQL 0.2.3 */
void *(*close_hook)(sqlite3*, void(*)(void*,sqlite3*), void *pArg);
};

Expand Down

0 comments on commit bdfc389

Please sign in to comment.