mirror of
https://github.com/sqlite/sqlite.git
synced 2026-10-23 21:49:02 +03:00
Have API functions sqlite3_serialize(), sqlite3_limit(), sqlite3_busy_timeout() and sqlite3_error_offset() take the database mutex.
FossilOrigin-Name: fff2c37b9fabbbad20ace60a00e521d198a53125e371f8956275d89eb3c0f32f
This commit is contained in:
19
manifest
19
manifest
@@ -1,5 +1,5 @@
|
||||
C Change\sthe\sundocumented\sand\sunsupported\ssqlite_log()\sSQL\sfunction\sso\sthat\nit\sis\smarked\sas\sunsafe\sand\sdirect-only.\n[bugs:/info/3311f8d5b8|Bug\s2026-06-25T10:19:43Z].
|
||||
D 2026-06-25T15:17:15.511
|
||||
C Have\sAPI\sfunctions\ssqlite3_serialize(),\ssqlite3_limit(),\ssqlite3_busy_timeout()\sand\ssqlite3_error_offset()\stake\sthe\sdatabase\smutex.
|
||||
D 2026-06-25T15:47:42.978
|
||||
F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
@@ -701,14 +701,14 @@ F src/insert.c e6e9b574b4863649e2c433f2260f226183e697df1ab73fcb8da9a85d5abcd390
|
||||
F src/json.c 74e903d4b84171b674727edc67eb8e89190eee0e7b737210f2af5b79db2f3bff
|
||||
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
|
||||
F src/loadext.c 5cd4cd7ec6e1a46416806899086363fbf95eecd3bfb9a388b436c9a77243c902
|
||||
F src/main.c 25e0dc6888cf5da157768511c381ac87bb2313e0ff50c25b6ff35e034f99546c
|
||||
F src/main.c 51ad8e3eff03cc0a28088f1f84f661ca790c00b708ea9364597524863fac6581
|
||||
F src/malloc.c 422f7e0498e1c9ef967f06283b6f2c0b16db6b905d8e06f6dbc8baaa3e4e6c5a
|
||||
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
|
||||
F src/mem1.c 3bb59158c38e05f6270e761a9f435bf19827a264c13d1631c58b84bdc96d73b2
|
||||
F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75
|
||||
F src/mem3.c 30301196cace2a085cbedee1326a49f4b26deff0af68774ca82c1f7c06fda4f6
|
||||
F src/mem5.c b7da5c10a726aacacc9ad7cdcb0667deec643e117591cc69cf9b4b9e7f3e96ff
|
||||
F src/memdb.c 0a0e827311cec57fdea2ed3142d6684704a1b90e7995b286f74fd7d1a6c5a62c
|
||||
F src/memdb.c 290a67488b83fccb0ca9c637342043466e0b16c945ef7d68e0f91679661ff315
|
||||
F src/memjournal.c c283c6c95d940eb9dc70f1863eef3ee40382dbd35e5a1108026e7817c206e8a0
|
||||
F src/msvc.h 80b35f95d93bf996ccb3e498535255f2ef1118c78764719a7cd15ab4106ccac9
|
||||
F src/mutex.c 00b8cee206a67fd764d001f3a148494331d8d0b3b9c3974ecd69ff29bb444462
|
||||
@@ -2208,8 +2208,11 @@ F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee
|
||||
F tool/warnings.sh a554d13f6e5cf3760f041b87939e3d616ec6961859c3245e8ef701d1eafc2ca2
|
||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||
F tool/winmain.c 00c8fb88e365c9017db14c73d3c78af62194d9644feaf60e220ab0f411f3604c
|
||||
P d7e4b2a85f81dacfee497d806bbc9f8c262624bd618aa27d4d238191643a4f5d
|
||||
R 2d15f89d56bbd2cc947e7e3db3d23683
|
||||
U drh
|
||||
Z 0bc74c0ac0ee666f537b9b3999e40f52
|
||||
P c30ea3cefe346a3d87b57710a51b059371543c5abc75d08c4ca827bbe3b3f622
|
||||
R cde34dd32c83a77d0f2642a4a0667957
|
||||
T *branch * db-mutex-fixes
|
||||
T *sym-db-mutex-fixes *
|
||||
T -sym-trunk *
|
||||
U dan
|
||||
Z bf63ed98cf5c872642d27a48f0fea1ff
|
||||
# Remove this line to create a well-formed Fossil manifest.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
branch trunk
|
||||
tag trunk
|
||||
branch db-mutex-fixes
|
||||
tag db-mutex-fixes
|
||||
|
||||
@@ -1 +1 @@
|
||||
c30ea3cefe346a3d87b57710a51b059371543c5abc75d08c4ca827bbe3b3f622
|
||||
fff2c37b9fabbbad20ace60a00e521d198a53125e371f8956275d89eb3c0f32f
|
||||
|
||||
10
src/main.c
10
src/main.c
@@ -1845,6 +1845,7 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
|
||||
#endif
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
if( ms>0 ){
|
||||
sqlite3_busy_handler(db, (int(*)(void*,int))sqliteDefaultBusyCallback,
|
||||
(void*)db);
|
||||
@@ -1855,6 +1856,7 @@ int sqlite3_busy_timeout(sqlite3 *db, int ms){
|
||||
}else{
|
||||
sqlite3_busy_handler(db, 0, 0);
|
||||
}
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
@@ -2760,9 +2762,11 @@ int sqlite3_set_errmsg(sqlite3 *db, int errcode, const char *zMsg){
|
||||
*/
|
||||
int sqlite3_error_offset(sqlite3 *db){
|
||||
int iOffset = -1;
|
||||
if( db && sqlite3SafetyCheckSickOrOk(db) && db->errCode ){
|
||||
if( db && sqlite3SafetyCheckSickOrOk(db) ){
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
iOffset = db->errByteOffset;
|
||||
if( db->errCode ){
|
||||
iOffset = db->errByteOffset;
|
||||
}
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
}
|
||||
return iOffset;
|
||||
@@ -3029,6 +3033,7 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
|
||||
if( limitId<0 || limitId>=SQLITE_N_LIMIT ){
|
||||
return -1;
|
||||
}
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
oldLimit = db->aLimit[limitId];
|
||||
if( newLimit>=0 ){ /* IMP: R-52476-28732 */
|
||||
if( newLimit>aHardLimit[limitId] ){
|
||||
@@ -3038,6 +3043,7 @@ int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
|
||||
}
|
||||
db->aLimit[limitId] = newLimit;
|
||||
}
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return oldLimit; /* IMP: R-53341-35419 */
|
||||
}
|
||||
|
||||
|
||||
18
src/memdb.c
18
src/memdb.c
@@ -759,7 +759,7 @@ unsigned char *sqlite3_serialize(
|
||||
sqlite3_int64 sz;
|
||||
int szPage = 0;
|
||||
sqlite3_stmt *pStmt = 0;
|
||||
unsigned char *pOut;
|
||||
unsigned char *pOut = 0;
|
||||
char *zSql;
|
||||
int rc;
|
||||
|
||||
@@ -769,12 +769,13 @@ unsigned char *sqlite3_serialize(
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
|
||||
if( zSchema==0 ) zSchema = db->aDb[0].zDbSName;
|
||||
p = memdbFromDbSchema(db, zSchema);
|
||||
iDb = sqlite3FindDbName(db, zSchema);
|
||||
if( piSize ) *piSize = -1;
|
||||
if( iDb<0 ) return 0;
|
||||
if( iDb<0 ) goto serialize_out;
|
||||
if( p ){
|
||||
MemStore *pStore = p->pStore;
|
||||
assert( pStore->pMutex==0 );
|
||||
@@ -785,19 +786,17 @@ unsigned char *sqlite3_serialize(
|
||||
pOut = sqlite3_malloc64( pStore->sz );
|
||||
if( pOut ) memcpy(pOut, pStore->aData, pStore->sz);
|
||||
}
|
||||
return pOut;
|
||||
goto serialize_out;
|
||||
}
|
||||
pBt = db->aDb[iDb].pBt;
|
||||
if( pBt==0 ) return 0;
|
||||
if( pBt==0 ) goto serialize_out;
|
||||
szPage = sqlite3BtreeGetPageSize(pBt);
|
||||
zSql = sqlite3_mprintf("PRAGMA \"%w\".page_count", zSchema);
|
||||
rc = zSql ? sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0) : SQLITE_NOMEM;
|
||||
sqlite3_free(zSql);
|
||||
if( rc ) return 0;
|
||||
if( rc ) goto serialize_out;
|
||||
rc = sqlite3_step(pStmt);
|
||||
if( rc!=SQLITE_ROW ){
|
||||
pOut = 0;
|
||||
}else{
|
||||
if( rc==SQLITE_ROW ){
|
||||
sz = sqlite3_column_int64(pStmt, 0)*szPage;
|
||||
if( sz==0 ){
|
||||
sqlite3_reset(pStmt);
|
||||
@@ -831,6 +830,9 @@ unsigned char *sqlite3_serialize(
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(pStmt);
|
||||
|
||||
serialize_out:
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return pOut;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user