@homeofthings/sqlite3 7.0.1 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,7 +18,7 @@ Asynchronous, non-blocking [SQLite3](https://sqlite.org/) bindings for [Node.js]
18
18
 
19
19
  # Features
20
20
 
21
- - Bundles SQLite v3.53.0, or you can build using a local SQLite (or SqlCipher,...)
21
+ - Bundles SQLite v3.53.1, or you can build using a local SQLite (or SqlCipher,...)
22
22
  - Straightforward query and parameter binding interface
23
23
  - Full Buffer/Blob support
24
24
  - Extensive debugging support via [verbose mode](docs/API.md#verbose-mode)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  'variables': {
3
- 'sqlite_version%':'3530000',
3
+ 'sqlite_version%':'3530100',
4
4
  "toolset%":'',
5
5
  },
6
6
  'target_defaults': {
@@ -21218,18 +21218,39 @@ static void recoverFinalize(sqlite3_recover *p, sqlite3_stmt *pStmt){
21218
21218
  }
21219
21219
  }
21220
21220
 
21221
+ /*
21222
+ ** Run a single SQL statement in zSql. If zSql contains two or more
21223
+ ** SQL statements separated by ';', only the first is run.
21224
+ **
21225
+ ** Return the sqlite3_finalizer() or sqlite3_prepare() result code
21226
+ ** from running the zSql statement.
21227
+ */
21228
+ static int recoverOneStmt(sqlite3 *db, const char *zSql){
21229
+ sqlite3_stmt *pStmt = 0;
21230
+ int rc;
21231
+ if( zSql==0 ) return SQLITE_OK;
21232
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
21233
+ if( rc ){
21234
+ sqlite3_finalize(pStmt);
21235
+ return rc;
21236
+ }
21237
+ while( SQLITE_ROW==sqlite3_step(pStmt) ){}
21238
+ return sqlite3_finalize(pStmt);
21239
+ }
21240
+
21221
21241
  /*
21222
21242
  ** This function is a no-op if recover handle p already contains an error
21223
21243
  ** (if p->errCode!=SQLITE_OK). A copy of p->errCode is returned in this
21224
21244
  ** case.
21225
21245
  **
21226
- ** Otherwise, execute SQL script zSql. If successful, return SQLITE_OK.
21227
- ** Or, if an error occurs, leave an error code and message in the recover
21228
- ** handle and return a copy of the error code.
21246
+ ** Otherwise, execute a single SQL statment in zSql. Even if zSql contains
21247
+ ** two or more SQL statements separated by ';', only execute the first one.
21248
+ ** If successful, return SQLITE_OK. Or, if an error occurs, leave an error
21249
+ ** code and message in the recover handle and return a copy of the error code.
21229
21250
  */
21230
21251
  static int recoverExec(sqlite3_recover *p, sqlite3 *db, const char *zSql){
21231
21252
  if( p->errCode==SQLITE_OK ){
21232
- int rc = sqlite3_exec(db, zSql, 0, 0, 0);
21253
+ int rc = recoverOneStmt(db, zSql);
21233
21254
  if( rc ){
21234
21255
  recoverDbError(p, db);
21235
21256
  }
@@ -21629,7 +21650,8 @@ static void recoverTransferSettings(sqlite3_recover *p){
21629
21650
  }
21630
21651
  recoverFinalize(p, p1);
21631
21652
  }
21632
- recoverExec(p, db2, "CREATE TABLE t1(a); DROP TABLE t1;");
21653
+ recoverExec(p, db2, "CREATE TABLE t1(a)");
21654
+ recoverExec(p, db2, "DROP TABLE t1");
21633
21655
 
21634
21656
  if( p->errCode==SQLITE_OK ){
21635
21657
  sqlite3 *db = p->dbOut;
@@ -21711,12 +21733,12 @@ static int recoverOpenOutput(sqlite3_recover *p){
21711
21733
  static void recoverOpenRecovery(sqlite3_recover *p){
21712
21734
  char *zSql = recoverMPrintf(p, "ATTACH %Q AS recovery;", p->zStateDb);
21713
21735
  recoverExec(p, p->dbOut, zSql);
21714
- recoverExec(p, p->dbOut,
21715
- "PRAGMA writable_schema = 1;"
21716
- "CREATE TABLE recovery.map(pgno INTEGER PRIMARY KEY, parent INT);"
21717
- "CREATE TABLE recovery.schema(type, name, tbl_name, rootpage, sql);"
21718
- );
21719
21736
  sqlite3_free(zSql);
21737
+ recoverExec(p, p->dbOut, "PRAGMA writable_schema = 1");
21738
+ recoverExec(p, p->dbOut,
21739
+ "CREATE TABLE recovery.map(pgno INTEGER PRIMARY KEY, parent INT)");
21740
+ recoverExec(p, p->dbOut,
21741
+ "CREATE TABLE recovery.schema(type, name, tbl_name, rootpage, sql)");
21720
21742
  }
21721
21743
 
21722
21744
 
@@ -21856,7 +21878,7 @@ static int recoverWriteSchema1(sqlite3_recover *p){
21856
21878
  ")"
21857
21879
  "SELECT rootpage, tbl, isVirtual, name, sql"
21858
21880
  " FROM dbschema "
21859
- " WHERE tbl OR isIndex"
21881
+ " WHERE (tbl OR isIndex) AND sql GLOB 'CREATE *'"
21860
21882
  " ORDER BY tbl DESC, name=='sqlite_sequence' DESC"
21861
21883
  );
21862
21884
 
@@ -21882,7 +21904,7 @@ static int recoverWriteSchema1(sqlite3_recover *p){
21882
21904
  zName, zName, zSql
21883
21905
  ));
21884
21906
  }
21885
- rc = sqlite3_exec(p->dbOut, zSql, 0, 0, 0);
21907
+ rc = recoverOneStmt(p->dbOut, zSql);
21886
21908
  if( rc==SQLITE_OK ){
21887
21909
  recoverSqlCallback(p, zSql);
21888
21910
  if( bTable && !bVirtual ){
@@ -21924,15 +21946,17 @@ static int recoverWriteSchema2(sqlite3_recover *p){
21924
21946
  p->bSlowIndexes ?
21925
21947
  "SELECT rootpage, sql FROM recovery.schema "
21926
21948
  " WHERE type!='table' AND type!='index'"
21949
+ " AND sql GLOB 'CREATE *'"
21927
21950
  :
21928
21951
  "SELECT rootpage, sql FROM recovery.schema "
21929
21952
  " WHERE type!='table' AND (type!='index' OR sql NOT LIKE '%unique%')"
21953
+ " AND sql GLOB 'CREATE *'"
21930
21954
  );
21931
21955
 
21932
21956
  if( pSelect ){
21933
21957
  while( sqlite3_step(pSelect)==SQLITE_ROW ){
21934
21958
  const char *zSql = (const char*)sqlite3_column_text(pSelect, 1);
21935
- int rc = sqlite3_exec(p->dbOut, zSql, 0, 0, 0);
21959
+ int rc = recoverOneStmt(p->dbOut, zSql);
21936
21960
  if( rc==SQLITE_OK ){
21937
21961
  recoverSqlCallback(p, zSql);
21938
21962
  }else if( rc!=SQLITE_ERROR ){
@@ -23310,7 +23334,7 @@ static void recoverStep(sqlite3_recover *p){
23310
23334
  if( bUseWrapper ) recoverUninstallWrapper(p);
23311
23335
  }while( p->errCode==SQLITE_NOTADB
23312
23336
  && (bUseWrapper--)
23313
- && SQLITE_OK==sqlite3_exec(p->dbIn, "ROLLBACK", 0, 0, 0)
23337
+ && SQLITE_OK==recoverOneStmt(p->dbIn, "ROLLBACK")
23314
23338
  );
23315
23339
  }
23316
23340
 
@@ -23375,7 +23399,7 @@ static void recoverStep(sqlite3_recover *p){
23375
23399
  ** database. Regardless of whether or not an error has occurred, make
23376
23400
  ** an attempt to end the read transaction on the input database. */
23377
23401
  recoverExec(p, p->dbOut, "COMMIT");
23378
- rc = sqlite3_exec(p->dbIn, "END", 0, 0, 0);
23402
+ rc = recoverOneStmt(p->dbIn, "END");
23379
23403
  if( p->errCode==SQLITE_OK ) p->errCode = rc;
23380
23404
 
23381
23405
  recoverSqlCallback(p, "PRAGMA writable_schema = off");
@@ -23571,7 +23595,7 @@ int sqlite3_recover_finish(sqlite3_recover *p){
23571
23595
  }else{
23572
23596
  recoverFinalCleanup(p);
23573
23597
  if( p->bCloseTransaction && sqlite3_get_autocommit(p->dbIn)==0 ){
23574
- rc = sqlite3_exec(p->dbIn, "END", 0, 0, 0);
23598
+ rc = recoverOneStmt(p->dbIn, "END");
23575
23599
  if( p->errCode==SQLITE_OK ) p->errCode = rc;
23576
23600
  }
23577
23601
  rc = p->errCode;
@@ -27064,7 +27088,7 @@ static const char *(azHelp[]) = {
27064
27088
  " --schema SCHEMA Use SCHEMA instead of \"main\"",
27065
27089
  " --help Show CMD details",
27066
27090
  ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
27067
- ",headers on|off Turn display of headers on or off",
27091
+ ".headers on|off Turn display of headers on or off",
27068
27092
  ".help ?-all? ?PATTERN? Show help text for PATTERN",
27069
27093
  #ifndef SQLITE_SHELL_FIDDLE
27070
27094
  ".import FILE TABLE Import data from FILE into TABLE",
@@ -32032,8 +32056,7 @@ static int dotCmdOutput(ShellState *p){
32032
32056
  zBom = zBomUtf8;
32033
32057
  }else if( cli_strcmp(z,"-plain")==0 ){
32034
32058
  bPlain = 1;
32035
- }else if( c=='o' && z[0]=='1' && z[1]!=0 && z[2]==0
32036
- && (z[1]=='x' || z[1]=='e' || z[1]=='w') ){
32059
+ }else if( c=='o' && sqlite3_strglob("-[ewx]",z)==0 ){
32037
32060
  if( bKeep || eMode ){
32038
32061
  dotCmdError(p, i, "incompatible with prior options",0);
32039
32062
  goto dotCmdOutput_error;
@@ -35778,7 +35801,9 @@ static int runOneSqlLine(
35778
35801
  rc = shell_exec(p, zSql, &zErrMsg);
35779
35802
  END_TIMER(p);
35780
35803
  if( rc || zErrMsg ){
35781
- char zPrefix[100];
35804
+ char zPrefix[2048
35805
+ /* must be relatively large:
35806
+ ** https://sqlite.org/forum/forumpost/205f73db1b2806f5 */];
35782
35807
  const char *zErrorTail;
35783
35808
  const char *zErrorType;
35784
35809
  if( zErrMsg==0 ){
@@ -36750,7 +36775,7 @@ int SQLITE_CDECL main(int argc, char **argv){
36750
36775
  #ifndef SQLITE_SHELL_FIDDLE
36751
36776
  sqlite3_appendvfs_init(0,0,0);
36752
36777
  #ifdef SQLITE_DEBUG
36753
- sqlite3_auto_extension( (void (*)())auto_ext_leak_tester );
36778
+ sqlite3_auto_extension( (void (*)(void))auto_ext_leak_tester );
36754
36779
  #endif
36755
36780
  #endif
36756
36781
  modeDefault(&data);
@@ -37017,6 +37042,10 @@ int SQLITE_CDECL main(int argc, char **argv){
37017
37042
  modePop(&data);
37018
37043
  data.nPopMode = 0;
37019
37044
  }
37045
+ if( rc ){
37046
+ goto shell_main_exit;
37047
+ }
37048
+
37020
37049
  }
37021
37050
  if( data.nPopOutput && azCmd[i][0]!='.' ){
37022
37051
  output_reset(&data);
@@ -1,6 +1,6 @@
1
1
  /******************************************************************************
2
2
  ** This file is an amalgamation of many separate C source files from SQLite
3
- ** version 3.53.0. By combining all the individual C code files into this
3
+ ** version 3.53.1. By combining all the individual C code files into this
4
4
  ** single large file, the entire code can be compiled as a single translation
5
5
  ** unit. This allows many compilers to do optimizations that would not be
6
6
  ** possible if the files were compiled separately. Performance improvements
@@ -18,7 +18,7 @@
18
18
  ** separate file. This file contains only code for the core SQLite library.
19
19
  **
20
20
  ** The content in this amalgamation comes from Fossil check-in
21
- ** 4525003a53a7fc63ca75c59b22c79608659c with changes in files:
21
+ ** c88b22011a54b4f6fbd149e9f8e4de77658c with changes in files:
22
22
  **
23
23
  **
24
24
  */
@@ -467,12 +467,12 @@ extern "C" {
467
467
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468
468
  ** [sqlite_version()] and [sqlite_source_id()].
469
469
  */
470
- #define SQLITE_VERSION "3.53.0"
471
- #define SQLITE_VERSION_NUMBER 3053000
472
- #define SQLITE_SOURCE_ID "2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b"
473
- #define SQLITE_SCM_BRANCH "trunk"
474
- #define SQLITE_SCM_TAGS "release major-release version-3.53.0"
475
- #define SQLITE_SCM_DATETIME "2026-04-09T11:41:38.498Z"
470
+ #define SQLITE_VERSION "3.53.1"
471
+ #define SQLITE_VERSION_NUMBER 3053001
472
+ #define SQLITE_SOURCE_ID "2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9"
473
+ #define SQLITE_SCM_BRANCH "branch-3.53"
474
+ #define SQLITE_SCM_TAGS "release version-3.53.1"
475
+ #define SQLITE_SCM_DATETIME "2026-05-05T10:34:17.344Z"
476
476
 
477
477
  /*
478
478
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -32513,7 +32513,7 @@ static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
32513
32513
  sqlite3StrAccumSetError(pAccum, SQLITE_TOOBIG);
32514
32514
  return 0;
32515
32515
  }
32516
- z = sqlite3DbMallocRaw(pAccum->db, n);
32516
+ z = sqlite3_malloc(n);
32517
32517
  if( z==0 ){
32518
32518
  sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
32519
32519
  }
@@ -32971,11 +32971,27 @@ SQLITE_API void sqlite3_str_vappendf(
32971
32971
 
32972
32972
  szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+10;
32973
32973
  if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32974
- if( sqlite3StrAccumEnlargeIfNeeded(pAccum, szBufNeeded) ){
32975
- width = length = 0;
32976
- break;
32974
+ if( szBufNeeded + pAccum->nChar >= pAccum->nAlloc ){
32975
+ if( pAccum->mxAlloc==0 && pAccum->accError==0 ){
32976
+ /* Unable to allocate space in pAccum, perhaps because it
32977
+ ** is coming from sqlite3_snprintf() or similar. We'll have
32978
+ ** to render into temporary space and the memcpy() it over. */
32979
+ bufpt = sqlite3_malloc(szBufNeeded);
32980
+ if( bufpt==0 ){
32981
+ sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
32982
+ return;
32983
+ }
32984
+ zExtra = bufpt;
32985
+ }else if( sqlite3StrAccumEnlarge(pAccum, szBufNeeded)<szBufNeeded ){
32986
+ width = length = 0;
32987
+ break;
32988
+ }else{
32989
+ bufpt = pAccum->zText + pAccum->nChar;
32990
+ }
32991
+ }else{
32992
+ bufpt = pAccum->zText + pAccum->nChar;
32977
32993
  }
32978
- bufpt = zOut = pAccum->zText + pAccum->nChar;
32994
+ zOut = bufpt;
32979
32995
 
32980
32996
  flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
32981
32997
  /* The sign in front of the number */
@@ -33076,14 +33092,22 @@ SQLITE_API void sqlite3_str_vappendf(
33076
33092
  }
33077
33093
  length = width;
33078
33094
  }
33079
- pAccum->nChar += length;
33080
- zOut[length] = 0;
33081
33095
 
33082
- /* Floating point conversions render directly into the output
33083
- ** buffer. Hence, don't just break out of the switch(). Bypass the
33084
- ** output buffer writing that occurs after the switch() by continuing
33085
- ** to the next character in the format string. */
33086
- continue;
33096
+ if( zExtra==0 ){
33097
+ /* The result is being rendered directory into pAccum. This
33098
+ ** is the command and fast case */
33099
+ pAccum->nChar += length;
33100
+ zOut[length] = 0;
33101
+ continue;
33102
+ }else{
33103
+ /* We were unable to render directly into pAccum because we
33104
+ ** couldn't allocate sufficient memory. We need to memcpy()
33105
+ ** the rendering (or some prefix thereof) into the output
33106
+ ** buffer. */
33107
+ bufpt[0] = 0;
33108
+ bufpt = zExtra;
33109
+ break;
33110
+ }
33087
33111
  }
33088
33112
  case etSIZE:
33089
33113
  if( !bArgList ){
@@ -33130,7 +33154,7 @@ SQLITE_API void sqlite3_str_vappendf(
33130
33154
  if( sqlite3StrAccumEnlargeIfNeeded(pAccum, nCopyBytes) ){
33131
33155
  break;
33132
33156
  }
33133
- sqlite3_str_append(pAccum,
33157
+ sqlite3_str_append(pAccum,
33134
33158
  &pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
33135
33159
  precision -= nPrior;
33136
33160
  nPrior *= 2;
@@ -33646,7 +33670,7 @@ SQLITE_API void sqlite3_str_reset(StrAccum *p){
33646
33670
  ** of its content, all in one call.
33647
33671
  */
33648
33672
  SQLITE_API void sqlite3_str_free(sqlite3_str *p){
33649
- if( p ){
33673
+ if( p!=0 && p!=&sqlite3OomStr ){
33650
33674
  sqlite3_str_reset(p);
33651
33675
  sqlite3_free(p);
33652
33676
  }
@@ -36792,15 +36816,20 @@ SQLITE_PRIVATE u8 sqlite3StrIHash(const char *z){
36792
36816
  return h;
36793
36817
  }
36794
36818
 
36819
+ #if !defined(SQLITE_DISABLE_INTRINSIC) \
36820
+ && (defined(__GNUC__) || defined(__clang__)) \
36821
+ && (defined(__x86_64__) || defined(__aarch64__) || \
36822
+ (defined(__riscv) && defined(__riscv_xlen) && (__riscv_xlen>32)))
36823
+ #define SQLITE_USE_UINT128
36824
+ #endif
36825
+
36795
36826
  /*
36796
36827
  ** Two inputs are multiplied to get a 128-bit result. Write the
36797
36828
  ** lower 64-bits of the result into *pLo, and return the high-order
36798
36829
  ** 64 bits.
36799
36830
  */
36800
36831
  static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
36801
- #if (defined(__GNUC__) || defined(__clang__)) \
36802
- && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36803
- && !defined(SQLITE_DISABLE_INTRINSIC)
36832
+ #if defined(SQLITE_USE_UINT128)
36804
36833
  __uint128_t r = (__uint128_t)a * b;
36805
36834
  *pLo = (u64)r;
36806
36835
  return (u64)(r>>64);
@@ -36834,9 +36863,7 @@ static u64 sqlite3Multiply128(u64 a, u64 b, u64 *pLo){
36834
36863
  ** The lower 64 bits of A*B are discarded.
36835
36864
  */
36836
36865
  static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36837
- #if (defined(__GNUC__) || defined(__clang__)) \
36838
- && (defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)) \
36839
- && !defined(SQLITE_DISABLE_INTRINSIC)
36866
+ #if defined(SQLITE_USE_UINT128)
36840
36867
  __uint128_t r = (__uint128_t)a * b;
36841
36868
  r += ((__uint128_t)aLo * b) >> 32;
36842
36869
  *pLo = (r>>32)&0xffffffff;
@@ -36874,6 +36901,8 @@ static u64 sqlite3Multiply160(u64 a, u32 aLo, u64 b, u32 *pLo){
36874
36901
  #endif
36875
36902
  }
36876
36903
 
36904
+ #undef SQLITE_USE_UINT128
36905
+
36877
36906
  /*
36878
36907
  ** Return a u64 with the N-th bit set.
36879
36908
  */
@@ -56108,10 +56137,10 @@ SQLITE_API int sqlite3_deserialize(
56108
56137
  if( rc ) goto end_deserialize;
56109
56138
  db->init.iDb = (u8)iDb;
56110
56139
  db->init.reopenMemdb = 1;
56111
- rc = sqlite3_step(pStmt);
56140
+ sqlite3_step(pStmt);
56112
56141
  db->init.reopenMemdb = 0;
56113
- if( rc!=SQLITE_DONE ){
56114
- rc = SQLITE_ERROR;
56142
+ rc = sqlite3_finalize(pStmt);
56143
+ if( rc!=SQLITE_OK ){
56115
56144
  goto end_deserialize;
56116
56145
  }
56117
56146
  p = memdbFromDbSchema(db, zSchema);
@@ -56132,7 +56161,6 @@ SQLITE_API int sqlite3_deserialize(
56132
56161
  }
56133
56162
 
56134
56163
  end_deserialize:
56135
- sqlite3_finalize(pStmt);
56136
56164
  if( pData && (mFlags & SQLITE_DESERIALIZE_FREEONCLOSE)!=0 ){
56137
56165
  sqlite3_free(pData);
56138
56166
  }
@@ -123122,7 +123150,9 @@ SQLITE_PRIVATE void sqlite3AlterDropConstraint(
123122
123150
  if( !pTab ) return;
123123
123151
 
123124
123152
  if( pCons ){
123125
- zArg = sqlite3MPrintf(db, "%.*Q", pCons->n, pCons->z);
123153
+ char *z = sqlite3NameFromToken(db, pCons);
123154
+ zArg = sqlite3MPrintf(db, "%Q", z);
123155
+ sqlite3DbFree(db, z);
123126
123156
  }else{
123127
123157
  int iCol;
123128
123158
  if( alterFindCol(pParse, pTab, pCol, &iCol) ) return;
@@ -125504,6 +125534,16 @@ static void attachFunc(
125504
125534
  ** from sqlite3_deserialize() to close database db->init.iDb and
125505
125535
  ** reopen it as a MemDB */
125506
125536
  Btree *pNewBt = 0;
125537
+
125538
+ pNew = &db->aDb[db->init.iDb];
125539
+ assert( pNew->pBt!=0 );
125540
+ if( sqlite3BtreeTxnState(pNew->pBt)!=SQLITE_TXN_NONE
125541
+ || sqlite3BtreeIsInBackup(pNew->pBt)
125542
+ ){
125543
+ rc = SQLITE_BUSY;
125544
+ goto attach_error;
125545
+ }
125546
+
125507
125547
  pVfs = sqlite3_vfs_find("memdb");
125508
125548
  if( pVfs==0 ) return;
125509
125549
  rc = sqlite3BtreeOpen(pVfs, "x\0", db, &pNewBt, 0, SQLITE_OPEN_MAIN_DB);
@@ -125513,8 +125553,7 @@ static void attachFunc(
125513
125553
  /* Both the Btree and the new Schema were allocated successfully.
125514
125554
  ** Close the old db and update the aDb[] slot with the new memdb
125515
125555
  ** values. */
125516
- pNew = &db->aDb[db->init.iDb];
125517
- if( ALWAYS(pNew->pBt) ) sqlite3BtreeClose(pNew->pBt);
125556
+ sqlite3BtreeClose(pNew->pBt);
125518
125557
  pNew->pBt = pNewBt;
125519
125558
  pNew->pSchema = pNewSchema;
125520
125559
  }else{
@@ -156057,6 +156096,7 @@ static SQLITE_NOINLINE void existsToJoin(
156057
156096
  && !ExprHasProperty(pWhere, EP_OuterON|EP_InnerON)
156058
156097
  && ALWAYS(p->pSrc!=0)
156059
156098
  && p->pSrc->nSrc<BMS
156099
+ && (p->pLimit==0 || p->pLimit->pRight==0)
156060
156100
  ){
156061
156101
  if( pWhere->op==TK_AND ){
156062
156102
  Expr *pRight = pWhere->pRight;
@@ -156104,7 +156144,6 @@ static SQLITE_NOINLINE void existsToJoin(
156104
156144
  sqlite3TreeViewSelect(0, p, 0);
156105
156145
  }
156106
156146
  #endif
156107
- existsToJoin(pParse, p, pSubWhere);
156108
156147
  }
156109
156148
  }
156110
156149
  }
@@ -165946,7 +165985,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
165946
165985
  ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
165947
165986
  ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().
165948
165987
  */
165949
- if( pWInfo->nLevel>1 ){
165988
+ if( pWInfo->nLevel>1 || pTabItem->fg.fromExists ){
165950
165989
  int nNotReady; /* The number of notReady tables */
165951
165990
  SrcItem *origSrc; /* Original list of tables */
165952
165991
  nNotReady = pWInfo->nLevel - iLevel - 1;
@@ -165959,6 +165998,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
165959
165998
  for(k=1; k<=nNotReady; k++){
165960
165999
  memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));
165961
166000
  }
166001
+
166002
+ /* Clear the fromExists flag on the OR-optimized table entry so that
166003
+ ** the calls to sqlite3WhereEnd() do not code early-exits after the
166004
+ ** first row is visited. The early exit applies to this table's
166005
+ ** overall loop - including the multiple OR branches and any WHERE
166006
+ ** conditions not passed to the sub-loops - not to the sub-loops. */
166007
+ pOrTab->a[0].fg.fromExists = 0;
165962
166008
  }else{
165963
166009
  pOrTab = pWInfo->pTabList;
165964
166010
  }
@@ -166202,7 +166248,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
166202
166248
  assert( pLevel->op==OP_Return );
166203
166249
  pLevel->p2 = sqlite3VdbeCurrentAddr(v);
166204
166250
 
166205
- if( pWInfo->nLevel>1 ){ sqlite3DbFreeNN(db, pOrTab); }
166251
+ if( pWInfo->pTabList!=pOrTab ){ sqlite3DbFreeNN(db, pOrTab); }
166206
166252
  if( !untestedTerms ) disableTerm(pLevel, pTerm);
166207
166253
  }else
166208
166254
  #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
@@ -176127,27 +176173,11 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
176127
176173
  }
176128
176174
  #endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */
176129
176175
  }
176130
- if( pTabList->a[pLevel->iFrom].fg.fromExists
176131
- && (i==pWInfo->nLevel-1
176132
- || pTabList->a[pWInfo->a[i+1].iFrom].fg.fromExists==0)
176133
- ){
176134
- /* This is an EXISTS-to-JOIN optimization which is either the
176135
- ** inner-most loop, or the inner-most of a group of nested
176136
- ** EXISTS-to-JOIN optimization loops. If this loop sees a successful
176137
- ** row, it should break out of itself as well as other EXISTS-to-JOIN
176138
- ** loops in which is is directly nested. */
176139
- int nOuter = 0; /* Nr of outer EXISTS that this one is nested within */
176140
- while( nOuter<i ){
176141
- if( !pTabList->a[pLevel[-nOuter-1].iFrom].fg.fromExists ) break;
176142
- nOuter++;
176143
- }
176144
- testcase( nOuter>0 );
176145
- sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel[-nOuter].addrBrk);
176146
- if( nOuter ){
176147
- VdbeComment((v, "EXISTS break %d..%d", i-nOuter, i));
176148
- }else{
176149
- VdbeComment((v, "EXISTS break %d", i));
176150
- }
176176
+ if( pTabList->a[pLevel->iFrom].fg.fromExists ){
176177
+ /* This is an EXISTS-to-JOIN optimization loop. If this loop sees a
176178
+ ** successful row, it should break out of itself. */
176179
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
176180
+ VdbeComment((v, "EXISTS break %d", i));
176151
176181
  }
176152
176182
  sqlite3VdbeResolveLabel(v, pLevel->addrCont);
176153
176183
  if( pLevel->op!=OP_Noop ){
@@ -184334,6 +184364,7 @@ static YYACTIONTYPE yy_reduce(
184334
184364
  yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
184335
184365
  if( yymsp[-4].minor.yy454 ){
184336
184366
  yymsp[-4].minor.yy454->x.pList = pList;
184367
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
184337
184368
  }else{
184338
184369
  sqlite3ExprListDelete(pParse->db, pList);
184339
184370
  }
@@ -233951,10 +233982,11 @@ static int sessionSerialLen(const u8 *a){
233951
233982
  int n;
233952
233983
  assert( a!=0 );
233953
233984
  e = *a;
233954
- if( e==0 || e==0xFF ) return 1;
233955
- if( e==SQLITE_NULL ) return 1;
233956
233985
  if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9;
233957
- return sessionVarintGet(&a[1], &n) + 1 + n;
233986
+ if( e==SQLITE_TEXT || e==SQLITE_BLOB ){
233987
+ return sessionVarintGet(&a[1], &n) + 1 + n;
233988
+ }
233989
+ return 1;
233958
233990
  }
233959
233991
 
233960
233992
  /*
@@ -233977,17 +234009,17 @@ static unsigned int sessionChangeHash(
233977
234009
  u8 *a = aRecord; /* Used to iterate through change record */
233978
234010
 
233979
234011
  for(i=0; i<pTab->nCol; i++){
233980
- int eType = *a;
233981
234012
  int isPK = pTab->abPK[i];
233982
234013
  if( bPkOnly && isPK==0 ) continue;
233983
234014
 
233984
- assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT
233985
- || eType==SQLITE_TEXT || eType==SQLITE_BLOB
233986
- || eType==SQLITE_NULL || eType==0
233987
- );
233988
-
233989
234015
  if( isPK ){
233990
- a++;
234016
+ int eType = *a++;
234017
+
234018
+ assert( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT
234019
+ || eType==SQLITE_TEXT || eType==SQLITE_BLOB
234020
+ || eType==SQLITE_NULL || eType==0
234021
+ );
234022
+
233991
234023
  h = sessionHashAppendType(h, eType);
233992
234024
  if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
233993
234025
  h = sessionHashAppendI64(h, sessionGetI64(a));
@@ -237015,9 +237047,11 @@ static int sessionChangesetBufferRecord(
237015
237047
  rc = sessionInputBuffer(pIn, nByte);
237016
237048
  }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
237017
237049
  nByte += 8;
237050
+ }else if( eType!=0 && eType!=SQLITE_NULL ){
237051
+ rc = SQLITE_CORRUPT_BKPT;
237018
237052
  }
237019
237053
  }
237020
- if( (pIn->iNext+nByte)>pIn->nData ){
237054
+ if( rc==SQLITE_OK && (pIn->iNext+nByte)>pIn->nData ){
237021
237055
  rc = SQLITE_CORRUPT_BKPT;
237022
237056
  }
237023
237057
  }
@@ -263222,7 +263256,7 @@ static void fts5SourceIdFunc(
263222
263256
  ){
263223
263257
  assert( nArg==0 );
263224
263258
  UNUSED_PARAM2(nArg, apUnused);
263225
- sqlite3_result_text(pCtx, "fts5: 2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b", -1, SQLITE_TRANSIENT);
263259
+ sqlite3_result_text(pCtx, "fts5: 2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9", -1, SQLITE_TRANSIENT);
263226
263260
  }
263227
263261
 
263228
263262
  /*
@@ -146,12 +146,12 @@ extern "C" {
146
146
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
147
  ** [sqlite_version()] and [sqlite_source_id()].
148
148
  */
149
- #define SQLITE_VERSION "3.53.0"
150
- #define SQLITE_VERSION_NUMBER 3053000
151
- #define SQLITE_SOURCE_ID "2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b"
152
- #define SQLITE_SCM_BRANCH "trunk"
153
- #define SQLITE_SCM_TAGS "release major-release version-3.53.0"
154
- #define SQLITE_SCM_DATETIME "2026-04-09T11:41:38.498Z"
149
+ #define SQLITE_VERSION "3.53.1"
150
+ #define SQLITE_VERSION_NUMBER 3053001
151
+ #define SQLITE_SOURCE_ID "2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9"
152
+ #define SQLITE_SCM_BRANCH "branch-3.53"
153
+ #define SQLITE_SCM_TAGS "release version-3.53.1"
154
+ #define SQLITE_SCM_DATETIME "2026-05-05T10:34:17.344Z"
155
155
 
156
156
  /*
157
157
  ** CAPI3REF: Run-Time Library Version Numbers
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@homeofthings/sqlite3",
3
3
  "description": "Asynchronous, non-blocking SQLite3 bindings",
4
- "version": "7.0.1",
4
+ "version": "7.0.2",
5
5
  "homepage": "https://github.com/gms1/node-sqlite3",
6
6
  "author": {
7
7
  "name": "Mapbox",
@@ -45,12 +45,12 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "@eslint/js": "^10.0.1",
48
- "eslint": "^10.2.0",
49
- "globals": "^17.5.0",
48
+ "eslint": "^10.3.0",
49
+ "globals": "^17.6.0",
50
50
  "mocha": "11.7.5",
51
51
  "nyc": "^18.0.0",
52
52
  "prebuildify": "^6.0.1",
53
- "tinybench": "^6.0.0"
53
+ "tinybench": "^6.0.1"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "node-gyp": "12.x"