From 7cacc5e102643aee37a9ded807e80866ecf967a1 Mon Sep 17 00:00:00 2001 From: Matt <1009003+tantaman@users.noreply.github.com> Date: Mon, 6 Nov 2023 09:10:49 -0500 Subject: [PATCH] add ifdefs so we do not need to manually modify the libsql fork after sync --- core/src/changes-vtab.c | 3 ++- core/src/crsqlite.c | 20 +++++++++++++++++++- libsql-sync.sh | 8 +++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/core/src/changes-vtab.c b/core/src/changes-vtab.c index f088a664d..ac089d101 100644 --- a/core/src/changes-vtab.c +++ b/core/src/changes-vtab.c @@ -176,4 +176,5 @@ sqlite3_module crsql_changesModule = { /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ 0, - /* xShadowName */ 0}; + /* xShadowName */ 0, + /* xPreparedSql */ 0}; diff --git a/core/src/crsqlite.c b/core/src/crsqlite.c index fd7197df6..b764410f4 100644 --- a/core/src/crsqlite.c +++ b/core/src/crsqlite.c @@ -287,6 +287,13 @@ static void rollbackHook(void *pUserData) { pExtData->readDbVersionThisTx = 0; } +#ifdef LIBSQL +static void closeHook(void *pUserData, sqlite3 *db) { + crsql_ExtData *pExtData = (crsql_ExtData *)pUserData; + crsql_finalize(pExtData); +} +#endif + int sqlite3_crsqlrustbundle_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi); @@ -294,10 +301,18 @@ 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 +#ifdef LIBSQL + , + const libsql_api_routines *pLibsqlApi +#endif + ) { int rc = SQLITE_OK; SQLITE_EXTENSION_INIT2(pApi); +#ifdef LIBSQL + LIBSQL_EXTENSION_INIT2(pLibsqlApi); +#endif // 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 @@ -432,6 +447,9 @@ __declspec(dllexport) } if (rc == SQLITE_OK) { +#ifdef LIBSQL + libsql_close_hook(db, closeHook, pExtData); +#endif // TODO: get the prior callback so we can call it rather than replace // it? sqlite3_commit_hook(db, commitHook, pExtData); diff --git a/libsql-sync.sh b/libsql-sync.sh index e1b4d5f12..a50a593ec 100755 --- a/libsql-sync.sh +++ b/libsql-sync.sh @@ -1 +1,7 @@ -rsync -vhra ./core/ ../libsql/libsql-sqlite3/ext/crr/ --include='**.gitignore' --exclude='**.git' --filter=':- .gitignore' --delete-after +rsync -vhra ./core/ ../libsql/libsql-sqlite3/ext/crr/ \ + --include='**.gitignore' \ + --exclude='**.git' \ + --exclude='sqlite3.h' \ + --exclude='sqlite3ext.h' \ + --filter=':- .gitignore' \ + --delete-after