Skip to content

Commit

Permalink
add ifdefs so we do not need to manually modify the libsql fork after…
Browse files Browse the repository at this point in the history
… sync
  • Loading branch information
tantaman committed Nov 6, 2023
1 parent a60e37c commit 7cacc5e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/src/changes-vtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,5 @@ sqlite3_module crsql_changesModule = {
/* xSavepoint */ 0,
/* xRelease */ 0,
/* xRollbackTo */ 0,
/* xShadowName */ 0};
/* xShadowName */ 0,
/* xPreparedSql */ 0};
20 changes: 19 additions & 1 deletion core/src/crsqlite.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,32 @@ 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);

#ifdef _WIN32
__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
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion libsql-sync.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 7cacc5e

Please sign in to comment.