Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -14224,7 +14224,7 @@ typedef struct wal_impl wal_impl;
typedef struct wal_manager_impl wal_manager_impl;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility */
int iVersion; /* Current version is 2, versioning is here for backward compatibility */

/* Set the limiting size of a WAL file. */
void (*xLimit)(wal_impl* pWal, long long limit);
Expand Down Expand Up @@ -14326,6 +14326,9 @@ typedef struct libsql_wal_methods {
int (*xWriteLock)(wal_impl* pWal, int bLock);

void (*xDb)(wal_impl* pWal, sqlite3 *db);

/* Forget a previously opened savepoint that SQLite no longer needs. */
void (*xSavepointForget)(wal_impl* pWal, unsigned int *aWalData);
} libsql_wal_methods;


Expand Down Expand Up @@ -57825,7 +57828,7 @@ typedef struct wal_impl wal_impl;
typedef struct wal_manager_impl wal_manager_impl;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility */
int iVersion; /* Current version is 2, versioning is here for backward compatibility */

/* Set the limiting size of a WAL file. */
void (*xLimit)(wal_impl* pWal, long long limit);
Expand Down Expand Up @@ -57927,6 +57930,9 @@ typedef struct libsql_wal_methods {
int (*xWriteLock)(wal_impl* pWal, int bLock);

void (*xDb)(wal_impl* pWal, sqlite3 *db);

/* Forget a previously opened savepoint that SQLite no longer needs. */
void (*xSavepointForget)(wal_impl* pWal, unsigned int *aWalData);
} libsql_wal_methods;


Expand Down Expand Up @@ -65086,6 +65092,14 @@ SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
*/
nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);
for(ii=nNew; ii<pPager->nSavepoint; ii++){
if( pagerUseWal(pPager)
&& pPager->wal->methods.iVersion>=2
&& pPager->wal->methods.xSavepointForget
){
pPager->wal->methods.xSavepointForget(
pPager->wal->pData, pPager->aSavepoint[ii].aWalData
);
}
sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);
}
pPager->nSavepoint = nNew;
Expand Down Expand Up @@ -69661,6 +69675,15 @@ static int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
return rc;
}

/*
** Forget a WAL savepoint context that SQLite has destroyed. The built-in WAL
** implementation does not retain any external state per savepoint.
*/
static void sqlite3WalSavepointForget(Wal *pWal, u32 *aWalData){
UNUSED_PARAMETER(pWal);
UNUSED_PARAMETER(aWalData);
}

/*
** This function is called just before writing a set of frames to the log
** file (see sqlite3WalFrames()). It checks to see if, instead of appending
Expand Down Expand Up @@ -70614,7 +70637,7 @@ static int sqlite3WalOpen(
}

out->pData = (wal_impl*) pRet;
out->methods.iVersion = 1;
out->methods.iVersion = 2;
out->methods.xLimit = (void (*)(wal_impl *, long long))sqlite3WalLimit;
out->methods.xBeginReadTransaction = (int (*)(wal_impl *, int *))sqlite3WalBeginReadTransaction;
out->methods.xEndReadTransaction = (void (*)(wal_impl *))sqlite3WalEndReadTransaction;
Expand Down Expand Up @@ -70651,6 +70674,7 @@ static int sqlite3WalOpen(
outWal->methods.xWriteLock = sqlite3WalWriteLock;
#endif
out->methods.xDb = (void (*)(wal_impl *, sqlite3 *))sqlite3WalDb;
out->methods.xSavepointForget = (void (*)(wal_impl *, unsigned int *))sqlite3WalSavepointForget;

WALTRACE(("WAL%d: opened\n", pRet));
}
Expand Down
5 changes: 4 additions & 1 deletion libsql-ffi/bundled/SQLite3MultipleCiphers/src/sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -13829,7 +13829,7 @@ typedef struct wal_impl wal_impl;
typedef struct wal_manager_impl wal_manager_impl;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility */
int iVersion; /* Current version is 2, versioning is here for backward compatibility */

/* Set the limiting size of a WAL file. */
void (*xLimit)(wal_impl* pWal, long long limit);
Expand Down Expand Up @@ -13931,6 +13931,9 @@ typedef struct libsql_wal_methods {
int (*xWriteLock)(wal_impl* pWal, int bLock);

void (*xDb)(wal_impl* pWal, sqlite3 *db);

/* Forget a previously opened savepoint that SQLite no longer needs. */
void (*xSavepointForget)(wal_impl* pWal, unsigned int *aWalData);
} libsql_wal_methods;


Expand Down
3 changes: 3 additions & 0 deletions libsql-ffi/bundled/bindings/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3526,6 +3526,9 @@ pub struct libsql_wal_methods {
) -> ::std::os::raw::c_int,
>,
pub xDb: ::std::option::Option<unsafe extern "C" fn(pWal: *mut wal_impl, db: *mut sqlite3)>,
pub xSavepointForget: ::std::option::Option<
unsafe extern "C" fn(pWal: *mut wal_impl, aWalData: *mut ::std::os::raw::c_uint),
>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
3 changes: 3 additions & 0 deletions libsql-ffi/bundled/bindings/session_bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4044,6 +4044,9 @@ pub struct libsql_wal_methods {
) -> ::std::os::raw::c_int,
>,
pub xDb: ::std::option::Option<unsafe extern "C" fn(pWal: *mut wal_impl, db: *mut sqlite3)>,
pub xSavepointForget: ::std::option::Option<
unsafe extern "C" fn(pWal: *mut wal_impl, aWalData: *mut ::std::os::raw::c_uint),
>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
Expand Down
30 changes: 27 additions & 3 deletions libsql-ffi/bundled/src/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -14224,7 +14224,7 @@ typedef struct wal_impl wal_impl;
typedef struct wal_manager_impl wal_manager_impl;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility */
int iVersion; /* Current version is 2, versioning is here for backward compatibility */

/* Set the limiting size of a WAL file. */
void (*xLimit)(wal_impl* pWal, long long limit);
Expand Down Expand Up @@ -14326,6 +14326,9 @@ typedef struct libsql_wal_methods {
int (*xWriteLock)(wal_impl* pWal, int bLock);

void (*xDb)(wal_impl* pWal, sqlite3 *db);

/* Forget a previously opened savepoint that SQLite no longer needs. */
void (*xSavepointForget)(wal_impl* pWal, unsigned int *aWalData);
} libsql_wal_methods;


Expand Down Expand Up @@ -57825,7 +57828,7 @@ typedef struct wal_impl wal_impl;
typedef struct wal_manager_impl wal_manager_impl;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility */
int iVersion; /* Current version is 2, versioning is here for backward compatibility */

/* Set the limiting size of a WAL file. */
void (*xLimit)(wal_impl* pWal, long long limit);
Expand Down Expand Up @@ -57927,6 +57930,9 @@ typedef struct libsql_wal_methods {
int (*xWriteLock)(wal_impl* pWal, int bLock);

void (*xDb)(wal_impl* pWal, sqlite3 *db);

/* Forget a previously opened savepoint that SQLite no longer needs. */
void (*xSavepointForget)(wal_impl* pWal, unsigned int *aWalData);
} libsql_wal_methods;


Expand Down Expand Up @@ -65086,6 +65092,14 @@ SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
*/
nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);
for(ii=nNew; ii<pPager->nSavepoint; ii++){
if( pagerUseWal(pPager)
&& pPager->wal->methods.iVersion>=2
&& pPager->wal->methods.xSavepointForget
){
pPager->wal->methods.xSavepointForget(
pPager->wal->pData, pPager->aSavepoint[ii].aWalData
);
}
sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);
}
pPager->nSavepoint = nNew;
Expand Down Expand Up @@ -69661,6 +69675,15 @@ static int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
return rc;
}

/*
** Forget a WAL savepoint context that SQLite has destroyed. The built-in WAL
** implementation does not retain any external state per savepoint.
*/
static void sqlite3WalSavepointForget(Wal *pWal, u32 *aWalData){
UNUSED_PARAMETER(pWal);
UNUSED_PARAMETER(aWalData);
}

/*
** This function is called just before writing a set of frames to the log
** file (see sqlite3WalFrames()). It checks to see if, instead of appending
Expand Down Expand Up @@ -70614,7 +70637,7 @@ static int sqlite3WalOpen(
}

out->pData = (wal_impl*) pRet;
out->methods.iVersion = 1;
out->methods.iVersion = 2;
out->methods.xLimit = (void (*)(wal_impl *, long long))sqlite3WalLimit;
out->methods.xBeginReadTransaction = (int (*)(wal_impl *, int *))sqlite3WalBeginReadTransaction;
out->methods.xEndReadTransaction = (void (*)(wal_impl *))sqlite3WalEndReadTransaction;
Expand Down Expand Up @@ -70651,6 +70674,7 @@ static int sqlite3WalOpen(
outWal->methods.xWriteLock = sqlite3WalWriteLock;
#endif
out->methods.xDb = (void (*)(wal_impl *, sqlite3 *))sqlite3WalDb;
out->methods.xSavepointForget = (void (*)(wal_impl *, unsigned int *))sqlite3WalSavepointForget;

WALTRACE(("WAL%d: opened\n", pRet));
}
Expand Down
5 changes: 4 additions & 1 deletion libsql-ffi/bundled/src/sqlite3.h
Original file line number Diff line number Diff line change
Expand Up @@ -13829,7 +13829,7 @@ typedef struct wal_impl wal_impl;
typedef struct wal_manager_impl wal_manager_impl;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility */
int iVersion; /* Current version is 2, versioning is here for backward compatibility */

/* Set the limiting size of a WAL file. */
void (*xLimit)(wal_impl* pWal, long long limit);
Expand Down Expand Up @@ -13931,6 +13931,9 @@ typedef struct libsql_wal_methods {
int (*xWriteLock)(wal_impl* pWal, int bLock);

void (*xDb)(wal_impl* pWal, sqlite3 *db);

/* Forget a previously opened savepoint that SQLite no longer needs. */
void (*xSavepointForget)(wal_impl* pWal, unsigned int *aWalData);
} libsql_wal_methods;


Expand Down
8 changes: 8 additions & 0 deletions libsql-sqlite3/src/pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -7065,6 +7065,14 @@ int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
*/
nNew = iSavepoint + (( op==SAVEPOINT_RELEASE ) ? 0 : 1);
for(ii=nNew; ii<pPager->nSavepoint; ii++){
if( pagerUseWal(pPager)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it bit more safer to cal xSavepointForget before any destruction from SQLite? Just worry that if SQLite will add some sqlite3DataDestroy(pPager->aSavepoint[ii].aWalData) later here - we will screw up with ordering

&& pPager->wal->methods.iVersion>=2
&& pPager->wal->methods.xSavepointForget
){
pPager->wal->methods.xSavepointForget(
pPager->wal->pData, pPager->aSavepoint[ii].aWalData
);
}
sqlite3BitvecDestroy(pPager->aSavepoint[ii].pInSavepoint);
}
pPager->nSavepoint = nNew;
Expand Down
12 changes: 11 additions & 1 deletion libsql-sqlite3/src/wal.c
Original file line number Diff line number Diff line change
Expand Up @@ -3609,6 +3609,15 @@ static int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
return rc;
}

/*
** Forget a WAL savepoint context that SQLite has destroyed. The built-in WAL
** implementation does not retain any external state per savepoint.
*/
static void sqlite3WalSavepointForget(Wal *pWal, u32 *aWalData){
UNUSED_PARAMETER(pWal);
UNUSED_PARAMETER(aWalData);
}

/*
** This function is called just before writing a set of frames to the log
** file (see sqlite3WalFrames()). It checks to see if, instead of appending
Expand Down Expand Up @@ -4562,7 +4571,7 @@ static int sqlite3WalOpen(
}

out->pData = (wal_impl*) pRet;
out->methods.iVersion = 1;
out->methods.iVersion = 2;
out->methods.xLimit = (void (*)(wal_impl *, long long))sqlite3WalLimit;
out->methods.xBeginReadTransaction = (int (*)(wal_impl *, int *))sqlite3WalBeginReadTransaction;
out->methods.xEndReadTransaction = (void (*)(wal_impl *))sqlite3WalEndReadTransaction;
Expand Down Expand Up @@ -4599,6 +4608,7 @@ static int sqlite3WalOpen(
outWal->methods.xWriteLock = sqlite3WalWriteLock;
#endif
out->methods.xDb = (void (*)(wal_impl *, sqlite3 *))sqlite3WalDb;
out->methods.xSavepointForget = (void (*)(wal_impl *, unsigned int *))sqlite3WalSavepointForget;

WALTRACE(("WAL%d: opened\n", pRet));
}
Expand Down
5 changes: 4 additions & 1 deletion libsql-sqlite3/src/wal.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ typedef struct wal_impl wal_impl;
typedef struct wal_manager_impl wal_manager_impl;

typedef struct libsql_wal_methods {
int iVersion; /* Current version is 1, versioning is here for backward compatibility */
int iVersion; /* Current version is 2, versioning is here for backward compatibility */

/* Set the limiting size of a WAL file. */
void (*xLimit)(wal_impl* pWal, long long limit);
Expand Down Expand Up @@ -140,6 +140,9 @@ typedef struct libsql_wal_methods {
int (*xWriteLock)(wal_impl* pWal, int bLock);

void (*xDb)(wal_impl* pWal, sqlite3 *db);

/* Forget a previously opened savepoint that SQLite no longer needs. */
void (*xSavepointForget)(wal_impl* pWal, unsigned int *aWalData);
} libsql_wal_methods;


Expand Down
Loading
Loading