better-sqlite3-multiple-ciphers 11.2.1 → 11.3.0

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
@@ -17,10 +17,10 @@ The fastest and simplest library for SQLite3 in Node.js. This particular fork su
17
17
  ## Current versions
18
18
 
19
19
  - ### Stable
20
- - **better-sqlite3-multiple-ciphers** - [`11.2.1`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v11.2.1)
21
- - **better-sqlite3** - [`11.2.1`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v11.2.1)
22
- - **SQLite** - [`3.46.0`](https://www.sqlite.org/releaselog/3_46_0.html)
23
- - **SQLite3 Multiple Ciphers** - [`1.8.6`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.8.6)
20
+ - **better-sqlite3-multiple-ciphers** - [`11.3.0`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v11.3.0)
21
+ - **better-sqlite3** - [`11.3.0`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v11.3.0)
22
+ - **SQLite** - [`3.46.1`](https://www.sqlite.org/releaselog/3_46_1.html)
23
+ - **SQLite3 Multiple Ciphers** - [`1.8.7`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.8.7)
24
24
 
25
25
  - ### Beta
26
26
  - **better-sqlite3-multiple-ciphers** - [`11.0.0-beta.0`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v11.0.0-beta.0)
package/deps/setup.ps1 CHANGED
@@ -2,7 +2,7 @@
2
2
  $ErrorActionPreference = "Stop"
3
3
 
4
4
  # SQLite Info
5
- $SQLITEMC_VER = "v1.8.6"
5
+ $SQLITEMC_VER = "v1.8.7"
6
6
  $API_URL = "https://api.github.com/repos/utelle/SQLite3MultipleCiphers/releases/tags/" + $SQLITEMC_VER
7
7
 
8
8
  # Paths
@@ -136,7 +136,7 @@ SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
136
136
  /*** Begin of #include "sqlite3patched.c" ***/
137
137
  /******************************************************************************
138
138
  ** This file is an amalgamation of many separate C source files from SQLite
139
- ** version 3.46.0. By combining all the individual C code files into this
139
+ ** version 3.46.1. By combining all the individual C code files into this
140
140
  ** single large file, the entire code can be compiled as a single translation
141
141
  ** unit. This allows many compilers to do optimizations that would not be
142
142
  ** possible if the files were compiled separately. Performance improvements
@@ -154,7 +154,7 @@ SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
154
154
  ** separate file. This file contains only code for the core SQLite library.
155
155
  **
156
156
  ** The content in this amalgamation comes from Fossil check-in
157
- ** 96c92aba00c8375bc32fafcdf12429c58bd8.
157
+ ** c9c2ab54ba1f5f46360f1b4f35d849cd3f08.
158
158
  */
159
159
  #define SQLITE_CORE 1
160
160
  #define SQLITE_AMALGAMATION 1
@@ -595,9 +595,9 @@ extern "C" {
595
595
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
596
596
  ** [sqlite_version()] and [sqlite_source_id()].
597
597
  */
598
- #define SQLITE_VERSION "3.46.0"
599
- #define SQLITE_VERSION_NUMBER 3046000
600
- #define SQLITE_SOURCE_ID "2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e"
598
+ #define SQLITE_VERSION "3.46.1"
599
+ #define SQLITE_VERSION_NUMBER 3046001
600
+ #define SQLITE_SOURCE_ID "2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33"
601
601
 
602
602
  /*
603
603
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -19509,7 +19509,7 @@ struct SrcList {
19509
19509
  #define WHERE_AGG_DISTINCT 0x0400 /* Query is "SELECT agg(DISTINCT ...)" */
19510
19510
  #define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */
19511
19511
  #define WHERE_RIGHT_JOIN 0x1000 /* Processing a RIGHT JOIN */
19512
- /* 0x2000 not currently used */
19512
+ #define WHERE_KEEP_ALL_JOINS 0x2000 /* Do not do the omit-noop-join opt */
19513
19513
  #define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */
19514
19514
  /* 0x8000 not currently used */
19515
19515
 
@@ -90338,7 +90338,8 @@ SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff
90338
90338
  assert( iVar>0 );
90339
90339
  if( v ){
90340
90340
  Mem *pMem = &v->aVar[iVar-1];
90341
- assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
90341
+ assert( (v->db->flags & SQLITE_EnableQPSG)==0
90342
+ || (v->db->mDbFlags & DBFLAG_InternalFunc)!=0 );
90342
90343
  if( 0==(pMem->flags & MEM_Null) ){
90343
90344
  sqlite3_value *pRet = sqlite3ValueNew(v->db);
90344
90345
  if( pRet ){
@@ -90358,7 +90359,8 @@ SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff
90358
90359
  */
90359
90360
  SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
90360
90361
  assert( iVar>0 );
90361
- assert( (v->db->flags & SQLITE_EnableQPSG)==0 );
90362
+ assert( (v->db->flags & SQLITE_EnableQPSG)==0
90363
+ || (v->db->mDbFlags & DBFLAG_InternalFunc)!=0 );
90362
90364
  if( iVar>=32 ){
90363
90365
  v->expmask |= 0x80000000;
90364
90366
  }else{
@@ -107115,7 +107117,7 @@ static void extendFJMatch(
107115
107117
  static SQLITE_NOINLINE int isValidSchemaTableName(
107116
107118
  const char *zTab, /* Name as it appears in the SQL */
107117
107119
  Table *pTab, /* The schema table we are trying to match */
107118
- Schema *pSchema /* non-NULL if a database qualifier is present */
107120
+ const char *zDb /* non-NULL if a database qualifier is present */
107119
107121
  ){
107120
107122
  const char *zLegacy;
107121
107123
  assert( pTab!=0 );
@@ -107126,7 +107128,7 @@ static SQLITE_NOINLINE int isValidSchemaTableName(
107126
107128
  if( sqlite3StrICmp(zTab+7, &PREFERRED_TEMP_SCHEMA_TABLE[7])==0 ){
107127
107129
  return 1;
107128
107130
  }
107129
- if( pSchema==0 ) return 0;
107131
+ if( zDb==0 ) return 0;
107130
107132
  if( sqlite3StrICmp(zTab+7, &LEGACY_SCHEMA_TABLE[7])==0 ) return 1;
107131
107133
  if( sqlite3StrICmp(zTab+7, &PREFERRED_SCHEMA_TABLE[7])==0 ) return 1;
107132
107134
  }else{
@@ -107309,7 +107311,7 @@ static int lookupName(
107309
107311
  }
107310
107312
  }else if( sqlite3StrICmp(zTab, pTab->zName)!=0 ){
107311
107313
  if( pTab->tnum!=1 ) continue;
107312
- if( !isValidSchemaTableName(zTab, pTab, pSchema) ) continue;
107314
+ if( !isValidSchemaTableName(zTab, pTab, zDb) ) continue;
107313
107315
  }
107314
107316
  assert( ExprUseYTab(pExpr) );
107315
107317
  if( IN_RENAME_OBJECT && pItem->zAlias ){
@@ -109041,6 +109043,9 @@ SQLITE_PRIVATE int sqlite3ResolveExprNames(
109041
109043
  ** Resolve all names for all expression in an expression list. This is
109042
109044
  ** just like sqlite3ResolveExprNames() except that it works for an expression
109043
109045
  ** list rather than a single expression.
109046
+ **
109047
+ ** The return value is SQLITE_OK (0) for success or SQLITE_ERROR (1) for a
109048
+ ** failure.
109044
109049
  */
109045
109050
  SQLITE_PRIVATE int sqlite3ResolveExprListNames(
109046
109051
  NameContext *pNC, /* Namespace to resolve expressions in. */
@@ -109049,7 +109054,7 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames(
109049
109054
  int i;
109050
109055
  int savedHasAgg = 0;
109051
109056
  Walker w;
109052
- if( pList==0 ) return WRC_Continue;
109057
+ if( pList==0 ) return SQLITE_OK;
109053
109058
  w.pParse = pNC->pParse;
109054
109059
  w.xExprCallback = resolveExprStep;
109055
109060
  w.xSelectCallback = resolveSelectStep;
@@ -109063,7 +109068,7 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames(
109063
109068
  #if SQLITE_MAX_EXPR_DEPTH>0
109064
109069
  w.pParse->nHeight += pExpr->nHeight;
109065
109070
  if( sqlite3ExprCheckHeight(w.pParse, w.pParse->nHeight) ){
109066
- return WRC_Abort;
109071
+ return SQLITE_ERROR;
109067
109072
  }
109068
109073
  #endif
109069
109074
  sqlite3WalkExprNN(&w, pExpr);
@@ -109080,10 +109085,10 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames(
109080
109085
  (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109081
109086
  pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
109082
109087
  }
109083
- if( w.pParse->nErr>0 ) return WRC_Abort;
109088
+ if( w.pParse->nErr>0 ) return SQLITE_ERROR;
109084
109089
  }
109085
109090
  pNC->ncFlags |= savedHasAgg;
109086
- return WRC_Continue;
109091
+ return SQLITE_OK;
109087
109092
  }
109088
109093
 
109089
109094
  /*
@@ -117622,7 +117627,7 @@ static int renameResolveTrigger(Parse *pParse){
117622
117627
  /* ALWAYS() because if the table of the trigger does not exist, the
117623
117628
  ** error would have been hit before this point */
117624
117629
  if( ALWAYS(pParse->pTriggerTab) ){
117625
- rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab);
117630
+ rc = sqlite3ViewGetColumnNames(pParse, pParse->pTriggerTab)!=0;
117626
117631
  }
117627
117632
 
117628
117633
  /* Resolve symbols in WHEN clause */
@@ -124596,8 +124601,9 @@ create_view_fail:
124596
124601
  #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
124597
124602
  /*
124598
124603
  ** The Table structure pTable is really a VIEW. Fill in the names of
124599
- ** the columns of the view in the pTable structure. Return the number
124600
- ** of errors. If an error is seen leave an error message in pParse->zErrMsg.
124604
+ ** the columns of the view in the pTable structure. Return non-zero if
124605
+ ** there are errors. If an error is seen an error message is left
124606
+ ** in pParse->zErrMsg.
124601
124607
  */
124602
124608
  static SQLITE_NOINLINE int viewGetColumnNames(Parse *pParse, Table *pTable){
124603
124609
  Table *pSelTab; /* A fake table from which we get the result set */
@@ -124720,7 +124726,7 @@ static SQLITE_NOINLINE int viewGetColumnNames(Parse *pParse, Table *pTable){
124720
124726
  sqlite3DeleteColumnNames(db, pTable);
124721
124727
  }
124722
124728
  #endif /* SQLITE_OMIT_VIEW */
124723
- return nErr;
124729
+ return nErr + pParse->nErr;
124724
124730
  }
124725
124731
  SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
124726
124732
  assert( pTable!=0 );
@@ -131018,6 +131024,8 @@ static void groupConcatValue(sqlite3_context *context){
131018
131024
  sqlite3_result_error_toobig(context);
131019
131025
  }else if( pAccum->accError==SQLITE_NOMEM ){
131020
131026
  sqlite3_result_error_nomem(context);
131027
+ }else if( pGCC->nAccum>0 && pAccum->nChar==0 ){
131028
+ sqlite3_result_text(context, "", 1, SQLITE_STATIC);
131021
131029
  }else{
131022
131030
  const char *zText = sqlite3_str_value(pAccum);
131023
131031
  sqlite3_result_text(context, zText, pAccum->nChar, SQLITE_TRANSIENT);
@@ -133772,6 +133780,7 @@ SQLITE_PRIVATE Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList
133772
133780
  pRet->pSrc->nSrc = 1;
133773
133781
  pRet->pPrior = pLeft->pPrior;
133774
133782
  pRet->op = pLeft->op;
133783
+ if( pRet->pPrior ) pRet->selFlags |= SF_Values;
133775
133784
  pLeft->pPrior = 0;
133776
133785
  pLeft->op = TK_SELECT;
133777
133786
  assert( pLeft->pNext==0 );
@@ -166237,7 +166246,9 @@ static int whereLoopAddBtree(
166237
166246
  " according to whereIsCoveringIndex()\n", pProbe->zName));
166238
166247
  }
166239
166248
  }
166240
- }else if( m==0 ){
166249
+ }else if( m==0
166250
+ && (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700))
166251
+ ){
166241
166252
  WHERETRACE(0x200,
166242
166253
  ("-> %s a covering index according to bitmasks\n",
166243
166254
  pProbe->zName, m==0 ? "is" : "is not"));
@@ -168126,6 +168137,10 @@ static void showAllWhereLoops(WhereInfo *pWInfo, WhereClause *pWC){
168126
168137
  ** the right-most table of a subquery that was flattened into the
168127
168138
  ** main query and that subquery was the right-hand operand of an
168128
168139
  ** inner join that held an ON or USING clause.
168140
+ ** 6) The ORDER BY clause has 63 or fewer terms
168141
+ ** 7) The omit-noop-join optimization is enabled.
168142
+ **
168143
+ ** Items (1), (6), and (7) are checked by the caller.
168129
168144
  **
168130
168145
  ** For example, given:
168131
168146
  **
@@ -168539,6 +168554,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
168539
168554
  if( pOrderBy && pOrderBy->nExpr>=BMS ){
168540
168555
  pOrderBy = 0;
168541
168556
  wctrlFlags &= ~WHERE_WANT_DISTINCT;
168557
+ wctrlFlags |= WHERE_KEEP_ALL_JOINS; /* Disable omit-noop-join opt */
168542
168558
  }
168543
168559
 
168544
168560
  /* The number of tables in the FROM clause is limited by the number of
@@ -168839,10 +168855,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
168839
168855
  ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons.
168840
168856
  */
168841
168857
  notReady = ~(Bitmask)0;
168842
- if( pWInfo->nLevel>=2
168843
- && pResultSet!=0 /* these two combine to guarantee */
168844
- && 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */
168845
- && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
168858
+ if( pWInfo->nLevel>=2 /* Must be a join, or this opt8n is pointless */
168859
+ && pResultSet!=0 /* Condition (1) */
168860
+ && 0==(wctrlFlags & (WHERE_AGG_DISTINCT|WHERE_KEEP_ALL_JOINS)) /* (1),(6) */
168861
+ && OptimizationEnabled(db, SQLITE_OmitNoopJoin) /* (7) */
168846
168862
  ){
168847
168863
  notReady = whereOmitNoopJoin(pWInfo, notReady);
168848
168864
  nTabList = pWInfo->nLevel;
@@ -169162,26 +169178,6 @@ whereBeginError:
169162
169178
  }
169163
169179
  #endif
169164
169180
 
169165
- #ifdef SQLITE_DEBUG
169166
- /*
169167
- ** Return true if cursor iCur is opened by instruction k of the
169168
- ** bytecode. Used inside of assert() only.
169169
- */
169170
- static int cursorIsOpen(Vdbe *v, int iCur, int k){
169171
- while( k>=0 ){
169172
- VdbeOp *pOp = sqlite3VdbeGetOp(v,k--);
169173
- if( pOp->p1!=iCur ) continue;
169174
- if( pOp->opcode==OP_Close ) return 0;
169175
- if( pOp->opcode==OP_OpenRead ) return 1;
169176
- if( pOp->opcode==OP_OpenWrite ) return 1;
169177
- if( pOp->opcode==OP_OpenDup ) return 1;
169178
- if( pOp->opcode==OP_OpenAutoindex ) return 1;
169179
- if( pOp->opcode==OP_OpenEphemeral ) return 1;
169180
- }
169181
- return 0;
169182
- }
169183
- #endif /* SQLITE_DEBUG */
169184
-
169185
169181
  /*
169186
169182
  ** Generate the end of the WHERE loop. See comments on
169187
169183
  ** sqlite3WhereBegin() for additional information.
@@ -169481,16 +169477,10 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
169481
169477
  ** reference. Verify that this is harmless - that the
169482
169478
  ** table being referenced really is open.
169483
169479
  */
169484
- #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
169485
- assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
169486
- || cursorIsOpen(v,pOp->p1,k)
169487
- || pOp->opcode==OP_Offset
169488
- );
169489
- #else
169490
- assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
169491
- || cursorIsOpen(v,pOp->p1,k)
169492
- );
169493
- #endif
169480
+ if( pLoop->wsFlags & WHERE_IDX_ONLY ){
169481
+ sqlite3ErrorMsg(pParse, "internal query planner error");
169482
+ pParse->rc = SQLITE_INTERNAL;
169483
+ }
169494
169484
  }
169495
169485
  }else if( pOp->opcode==OP_Rowid ){
169496
169486
  pOp->p1 = pLevel->iIdxCur;
@@ -172761,9 +172751,9 @@ static void updateDeleteLimitError(
172761
172751
  break;
172762
172752
  }
172763
172753
  }
172764
- if( (p->selFlags & SF_MultiValue)==0 &&
172765
- (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&
172766
- cnt>mxSelect
172754
+ if( (p->selFlags & (SF_MultiValue|SF_Values))==0
172755
+ && (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0
172756
+ && cnt>mxSelect
172767
172757
  ){
172768
172758
  sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
172769
172759
  }
@@ -237182,7 +237172,11 @@ static int sqlite3Fts5ExprNew(
237182
237172
  }
237183
237173
 
237184
237174
  sqlite3_free(sParse.apPhrase);
237185
- *pzErr = sParse.zErr;
237175
+ if( 0==*pzErr ){
237176
+ *pzErr = sParse.zErr;
237177
+ }else{
237178
+ sqlite3_free(sParse.zErr);
237179
+ }
237186
237180
  return sParse.rc;
237187
237181
  }
237188
237182
 
@@ -239310,6 +239304,7 @@ static Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(
239310
239304
  assert( pRight->eType==FTS5_STRING
239311
239305
  || pRight->eType==FTS5_TERM
239312
239306
  || pRight->eType==FTS5_EOF
239307
+ || (pRight->eType==FTS5_AND && pParse->bPhraseToAnd)
239313
239308
  );
239314
239309
 
239315
239310
  if( pLeft->eType==FTS5_AND ){
@@ -251477,6 +251472,7 @@ static int fts5UpdateMethod(
251477
251472
  rc = SQLITE_ERROR;
251478
251473
  }else{
251479
251474
  rc = fts5SpecialDelete(pTab, apVal);
251475
+ bUpdateOrDelete = 1;
251480
251476
  }
251481
251477
  }else{
251482
251478
  rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
@@ -252651,14 +252647,16 @@ static int sqlite3Fts5GetTokenizer(
252651
252647
  if( pMod==0 ){
252652
252648
  assert( nArg>0 );
252653
252649
  rc = SQLITE_ERROR;
252654
- *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]);
252650
+ if( pzErr ) *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]);
252655
252651
  }else{
252656
252652
  rc = pMod->x.xCreate(
252657
252653
  pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->pTok
252658
252654
  );
252659
252655
  pConfig->pTokApi = &pMod->x;
252660
252656
  if( rc!=SQLITE_OK ){
252661
- if( pzErr ) *pzErr = sqlite3_mprintf("error in tokenizer constructor");
252657
+ if( pzErr && rc!=SQLITE_NOMEM ){
252658
+ *pzErr = sqlite3_mprintf("error in tokenizer constructor");
252659
+ }
252662
252660
  }else{
252663
252661
  pConfig->ePattern = sqlite3Fts5TokenizerPattern(
252664
252662
  pMod->x.xCreate, pConfig->pTok
@@ -252717,7 +252715,7 @@ static void fts5SourceIdFunc(
252717
252715
  ){
252718
252716
  assert( nArg==0 );
252719
252717
  UNUSED_PARAM2(nArg, apUnused);
252720
- sqlite3_result_text(pCtx, "fts5: 2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e", -1, SQLITE_TRANSIENT);
252718
+ sqlite3_result_text(pCtx, "fts5: 2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33", -1, SQLITE_TRANSIENT);
252721
252719
  }
252722
252720
 
252723
252721
  /*
@@ -252752,17 +252750,23 @@ static int fts5IntegrityMethod(
252752
252750
 
252753
252751
  assert( pzErr!=0 && *pzErr==0 );
252754
252752
  UNUSED_PARAM(isQuick);
252753
+ assert( pTab->p.pConfig->pzErrmsg==0 );
252754
+ pTab->p.pConfig->pzErrmsg = pzErr;
252755
252755
  rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, 0);
252756
- if( (rc&0xff)==SQLITE_CORRUPT ){
252757
- *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s",
252758
- zSchema, zTabname);
252759
- rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM;
252760
- }else if( rc!=SQLITE_OK ){
252761
- *pzErr = sqlite3_mprintf("unable to validate the inverted index for"
252762
- " FTS5 table %s.%s: %s",
252763
- zSchema, zTabname, sqlite3_errstr(rc));
252756
+ if( *pzErr==0 && rc!=SQLITE_OK ){
252757
+ if( (rc&0xff)==SQLITE_CORRUPT ){
252758
+ *pzErr = sqlite3_mprintf("malformed inverted index for FTS5 table %s.%s",
252759
+ zSchema, zTabname);
252760
+ rc = (*pzErr) ? SQLITE_OK : SQLITE_NOMEM;
252761
+ }else{
252762
+ *pzErr = sqlite3_mprintf("unable to validate the inverted index for"
252763
+ " FTS5 table %s.%s: %s",
252764
+ zSchema, zTabname, sqlite3_errstr(rc));
252765
+ }
252764
252766
  }
252767
+
252765
252768
  sqlite3Fts5IndexCloseReader(pTab->p.pIndex);
252769
+ pTab->p.pConfig->pzErrmsg = 0;
252766
252770
 
252767
252771
  return rc;
252768
252772
  }
@@ -254196,7 +254200,7 @@ static int fts5AsciiCreate(
254196
254200
  int i;
254197
254201
  memset(p, 0, sizeof(AsciiTokenizer));
254198
254202
  memcpy(p->aTokenChar, aAsciiTokenChar, sizeof(aAsciiTokenChar));
254199
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254203
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254200
254204
  const char *zArg = azArg[i+1];
254201
254205
  if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
254202
254206
  fts5AsciiAddExceptions(p, zArg, 1);
@@ -254207,6 +254211,7 @@ static int fts5AsciiCreate(
254207
254211
  rc = SQLITE_ERROR;
254208
254212
  }
254209
254213
  }
254214
+ if( rc==SQLITE_OK && i<nArg ) rc = SQLITE_ERROR;
254210
254215
  if( rc!=SQLITE_OK ){
254211
254216
  fts5AsciiDelete((Fts5Tokenizer*)p);
254212
254217
  p = 0;
@@ -254498,17 +254503,16 @@ static int fts5UnicodeCreate(
254498
254503
  }
254499
254504
 
254500
254505
  /* Search for a "categories" argument */
254501
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254506
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254502
254507
  if( 0==sqlite3_stricmp(azArg[i], "categories") ){
254503
254508
  zCat = azArg[i+1];
254504
254509
  }
254505
254510
  }
254506
-
254507
254511
  if( rc==SQLITE_OK ){
254508
254512
  rc = unicodeSetCategories(p, zCat);
254509
254513
  }
254510
254514
 
254511
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
254515
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
254512
254516
  const char *zArg = azArg[i+1];
254513
254517
  if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
254514
254518
  if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){
@@ -254533,6 +254537,7 @@ static int fts5UnicodeCreate(
254533
254537
  rc = SQLITE_ERROR;
254534
254538
  }
254535
254539
  }
254540
+ if( i<nArg && rc==SQLITE_OK ) rc = SQLITE_ERROR;
254536
254541
 
254537
254542
  }else{
254538
254543
  rc = SQLITE_NOMEM;
@@ -255415,7 +255420,7 @@ static int fts5TriCreate(
255415
255420
  int i;
255416
255421
  pNew->bFold = 1;
255417
255422
  pNew->iFoldParam = 0;
255418
- for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
255423
+ for(i=0; rc==SQLITE_OK && i<nArg-1; i+=2){
255419
255424
  const char *zArg = azArg[i+1];
255420
255425
  if( 0==sqlite3_stricmp(azArg[i], "case_sensitive") ){
255421
255426
  if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
@@ -255433,6 +255438,7 @@ static int fts5TriCreate(
255433
255438
  rc = SQLITE_ERROR;
255434
255439
  }
255435
255440
  }
255441
+ if( i<nArg && rc==SQLITE_OK ) rc = SQLITE_ERROR;
255436
255442
 
255437
255443
  if( pNew->iFoldParam!=0 && pNew->bFold==0 ){
255438
255444
  rc = SQLITE_ERROR;
@@ -258066,9 +258072,9 @@ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
258066
258072
 
258067
258073
  #define SQLITE3MC_VERSION_MAJOR 1
258068
258074
  #define SQLITE3MC_VERSION_MINOR 8
258069
- #define SQLITE3MC_VERSION_RELEASE 6
258075
+ #define SQLITE3MC_VERSION_RELEASE 7
258070
258076
  #define SQLITE3MC_VERSION_SUBRELEASE 0
258071
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.8.6"
258077
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.8.7"
258072
258078
 
258073
258079
  #endif /* SQLITE3MC_VERSION_H_ */
258074
258080
  /*** End of #include "sqlite3mc_version.h" ***/
@@ -258227,9 +258233,9 @@ extern "C" {
258227
258233
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
258228
258234
  ** [sqlite_version()] and [sqlite_source_id()].
258229
258235
  */
258230
- #define SQLITE_VERSION "3.46.0"
258231
- #define SQLITE_VERSION_NUMBER 3046000
258232
- #define SQLITE_SOURCE_ID "2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e"
258236
+ #define SQLITE_VERSION "3.46.1"
258237
+ #define SQLITE_VERSION_NUMBER 3046001
258238
+ #define SQLITE_SOURCE_ID "2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33"
258233
258239
 
258234
258240
  /*
258235
258241
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -283598,7 +283604,7 @@ sqlite3mcBtreeSetPageSize(Btree* p, int pageSize, int nReserve, int iFix)
283598
283604
  ** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database
283599
283605
  ** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes)
283600
283606
  **
283601
- ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.46.0 amalgamation.
283607
+ ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.46.1 amalgamation.
283602
283608
  */
283603
283609
  SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey(
283604
283610
  char **pzErrMsg, /* Write error message here */
@@ -31,9 +31,9 @@
31
31
 
32
32
  #define SQLITE3MC_VERSION_MAJOR 1
33
33
  #define SQLITE3MC_VERSION_MINOR 8
34
- #define SQLITE3MC_VERSION_RELEASE 6
34
+ #define SQLITE3MC_VERSION_RELEASE 7
35
35
  #define SQLITE3MC_VERSION_SUBRELEASE 0
36
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.8.6"
36
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.8.7"
37
37
 
38
38
  #endif /* SQLITE3MC_VERSION_H_ */
39
39
  /*** End of #include "sqlite3mc_version.h" ***/
@@ -192,9 +192,9 @@ extern "C" {
192
192
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
193
193
  ** [sqlite_version()] and [sqlite_source_id()].
194
194
  */
195
- #define SQLITE_VERSION "3.46.0"
196
- #define SQLITE_VERSION_NUMBER 3046000
197
- #define SQLITE_SOURCE_ID "2024-05-23 13:25:27 96c92aba00c8375bc32fafcdf12429c58bd8aabfcadab6683e35bbb9cdebf19e"
195
+ #define SQLITE_VERSION "3.46.1"
196
+ #define SQLITE_VERSION_NUMBER 3046001
197
+ #define SQLITE_SOURCE_ID "2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33"
198
198
 
199
199
  /*
200
200
  ** CAPI3REF: Run-Time Library Version Numbers
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for better-sqlite3-multiple-ciphers 8.5.0
1
+ // Type definitions for better-sqlite3-multiple-ciphers 11.2.1
2
2
  // Project: https://github.com/m4heshd/better-sqlite3-multiple-ciphers
3
3
  // Definitions by: Ben Davies <https://github.com/Morfent>
4
4
  // Mathew Rumsey <https://github.com/matrumz>
@@ -19,7 +19,7 @@ type ArgumentTypes<F extends VariableArgFunction> = F extends (...args: infer A)
19
19
  type ElementOf<T> = T extends Array<infer E> ? E : T;
20
20
 
21
21
  declare namespace BetterSqlite3MultipleCiphers {
22
- interface Statement<BindParameters extends unknown[]> {
22
+ interface Statement<BindParameters extends unknown[], Result = unknown> {
23
23
  database: Database;
24
24
  source: string;
25
25
  reader: boolean;
@@ -27,9 +27,9 @@ declare namespace BetterSqlite3MultipleCiphers {
27
27
  busy: boolean;
28
28
 
29
29
  run(...params: BindParameters): Database.RunResult;
30
- get(...params: BindParameters): unknown;
31
- all(...params: BindParameters): unknown[];
32
- iterate(...params: BindParameters): IterableIterator<unknown>;
30
+ get(...params: BindParameters): Result | undefined;
31
+ all(...params: BindParameters): Result[];
32
+ iterate(...params: BindParameters): IterableIterator<Result>;
33
33
  pluck(toggleState?: boolean): this;
34
34
  expand(toggleState?: boolean): this;
35
35
  raw(toggleState?: boolean): this;
@@ -55,7 +55,7 @@ declare namespace BetterSqlite3MultipleCiphers {
55
55
  }
56
56
 
57
57
  interface VirtualTableOptions {
58
- rows: () => Generator;
58
+ rows: (...params: unknown[]) => Generator;
59
59
  columns: string[];
60
60
  parameters?: string[] | undefined;
61
61
  safeIntegers?: boolean | undefined;
@@ -69,9 +69,9 @@ declare namespace BetterSqlite3MultipleCiphers {
69
69
  open: boolean;
70
70
  inTransaction: boolean;
71
71
 
72
- prepare<BindParameters extends unknown[] | {} = unknown[]>(
72
+ prepare<BindParameters extends unknown[] | {} = unknown[], Result = unknown>(
73
73
  source: string,
74
- ): BindParameters extends unknown[] ? Statement<BindParameters> : Statement<[BindParameters]>;
74
+ ): BindParameters extends unknown[] ? Statement<BindParameters, Result> : Statement<[BindParameters], Result>;
75
75
  transaction<F extends VariableArgFunction>(fn: F): Transaction<F>;
76
76
  exec(source: string): this;
77
77
  key(key: Buffer): number;
@@ -79,12 +79,16 @@ declare namespace BetterSqlite3MultipleCiphers {
79
79
  pragma(source: string, options?: Database.PragmaOptions): unknown;
80
80
  function(name: string, cb: (...params: unknown[]) => unknown): this;
81
81
  function(name: string, options: Database.RegistrationOptions, cb: (...params: unknown[]) => unknown): this;
82
- aggregate<T>(name: string, options: Database.RegistrationOptions & {
83
- start?: T | (() => T);
84
- step: (total: T, next: ElementOf<T>) => T | void;
85
- inverse?: ((total: T, dropped: T) => T) | undefined;
86
- result?: ((total: T) => unknown) | undefined;
87
- }): this;
82
+ aggregate<T>(
83
+ name: string,
84
+ options: Database.RegistrationOptions & {
85
+ start?: T | (() => T);
86
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
87
+ step: (total: T, next: ElementOf<T>) => T | void;
88
+ inverse?: ((total: T, dropped: T) => T) | undefined;
89
+ result?: ((total: T) => unknown) | undefined;
90
+ },
91
+ ): this;
88
92
  loadExtension(path: string): this;
89
93
  close(): this;
90
94
  defaultSafeIntegers(toggleState?: boolean): this;
@@ -95,8 +99,8 @@ declare namespace BetterSqlite3MultipleCiphers {
95
99
  }
96
100
 
97
101
  interface DatabaseConstructor {
98
- new (filename: string | Buffer, options?: Database.Options): Database;
99
- (filename: string, options?: Database.Options): Database;
102
+ new(filename?: string | Buffer, options?: Database.Options): Database;
103
+ (filename?: string, options?: Database.Options): Database;
100
104
  prototype: Database;
101
105
 
102
106
  SqliteError: typeof SqliteError;
@@ -150,10 +154,9 @@ declare namespace Database {
150
154
  }
151
155
 
152
156
  type SqliteError = typeof SqliteError;
153
- type Statement<BindParameters extends unknown[] | {} = unknown[]> = BindParameters extends unknown[]
154
- ? BetterSqlite3MultipleCiphers.Statement<BindParameters>
155
- : BetterSqlite3MultipleCiphers.Statement<[BindParameters]>;
156
- type ColumnDefinition = BetterSqlite3MultipleCiphers.ColumnDefinition;
157
+ type Statement<BindParameters extends unknown[] | {} = unknown[], Result = unknown> = BindParameters extends unknown[] ?
158
+ BetterSqlite3MultipleCiphers.Statement<BindParameters, Result> :
159
+ BetterSqlite3MultipleCiphers.Statement<[BindParameters], Result>;
157
160
  type Transaction<T extends VariableArgFunction = VariableArgFunction> = BetterSqlite3MultipleCiphers.Transaction<T>;
158
161
  type Database = BetterSqlite3MultipleCiphers.Database;
159
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-sqlite3-multiple-ciphers",
3
- "version": "11.2.1",
3
+ "version": "11.3.0",
4
4
  "description": "better-sqlite3 with multiple-cipher encryption support",
5
5
  "homepage": "https://github.com/m4heshd/better-sqlite3-multiple-ciphers",
6
6
  "author": "Mahesh Bandara Wijerathna (m4heshd) <m4heshd@gmail.com>",