better-sqlite3-multiple-ciphers 8.2.0 → 8.2.1-beta.1

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
@@ -23,10 +23,10 @@ The fastest and simplest library for SQLite3 in Node.js. This particular fork su
23
23
  - **SQLite3 Multiple Ciphers** - [`1.6.0`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.6.0)
24
24
 
25
25
  - ### Beta
26
- - **better-sqlite3-multiple-ciphers** - [`8.1.1-beta.0`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v8.1.1-beta.0)
27
- - **better-sqlite3** - [`8.1.0`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v8.1.0)
28
- - **SQLite** - [`3.41.0`](https://www.sqlite.org/releaselog/3_41_0.html)
29
- - **SQLite3 Multiple Ciphers** - [`1.6.0`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.6.0)
26
+ - **better-sqlite3-multiple-ciphers** - [`8.2.1-beta.1`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v8.2.1-beta.1)
27
+ - **better-sqlite3** - [`8.2.0`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v8.2.0)
28
+ - **SQLite** - [`3.41.2`](https://www.sqlite.org/releaselog/3_41_2.html)
29
+ - **SQLite3 Multiple Ciphers** - [`1.6.2`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.6.2)
30
30
 
31
31
  ## Help this project stay strong! 💪
32
32
 
package/deps/setup.ps1 CHANGED
@@ -2,7 +2,7 @@
2
2
  $ErrorActionPreference = "Stop"
3
3
 
4
4
  # SQLite Info
5
- $SQLITEMC_VER = "v1.6.0"
5
+ $SQLITEMC_VER = "v1.6.2"
6
6
  $API_URL = "https://api.github.com/repos/utelle/SQLite3MultipleCiphers/releases/tags/" + $SQLITEMC_VER
7
7
 
8
8
  # Paths
@@ -92,7 +92,7 @@ extern SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
92
92
  /*** Begin of #include "sqlite3patched.c" ***/
93
93
  /******************************************************************************
94
94
  ** This file is an amalgamation of many separate C source files from SQLite
95
- ** version 3.41.0. By combining all the individual C code files into this
95
+ ** version 3.41.2. By combining all the individual C code files into this
96
96
  ** single large file, the entire code can be compiled as a single translation
97
97
  ** unit. This allows many compilers to do optimizations that would not be
98
98
  ** possible if the files were compiled separately. Performance improvements
@@ -544,9 +544,9 @@ extern "C" {
544
544
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
545
545
  ** [sqlite_version()] and [sqlite_source_id()].
546
546
  */
547
- #define SQLITE_VERSION "3.41.0"
548
- #define SQLITE_VERSION_NUMBER 3041000
549
- #define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d"
547
+ #define SQLITE_VERSION "3.41.2"
548
+ #define SQLITE_VERSION_NUMBER 3041002
549
+ #define SQLITE_SOURCE_ID "2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da"
550
550
 
551
551
  /*
552
552
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -16692,7 +16692,7 @@ struct PgHdr {
16692
16692
  ** private to pcache.c and should not be accessed by other modules.
16693
16693
  ** pCache is grouped with the public elements for efficiency.
16694
16694
  */
16695
- i16 nRef; /* Number of users of this page */
16695
+ i64 nRef; /* Number of users of this page */
16696
16696
  PgHdr *pDirtyNext; /* Next element in list of dirty pages */
16697
16697
  PgHdr *pDirtyPrev; /* Previous element in list of dirty pages */
16698
16698
  /* NB: pDirtyNext and pDirtyPrev are undefined if the
@@ -16773,12 +16773,12 @@ SQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *);
16773
16773
  SQLITE_PRIVATE void sqlite3PcacheClear(PCache*);
16774
16774
 
16775
16775
  /* Return the total number of outstanding page references */
16776
- SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache*);
16776
+ SQLITE_PRIVATE i64 sqlite3PcacheRefCount(PCache*);
16777
16777
 
16778
16778
  /* Increment the reference count of an existing page */
16779
16779
  SQLITE_PRIVATE void sqlite3PcacheRef(PgHdr*);
16780
16780
 
16781
- SQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr*);
16781
+ SQLITE_PRIVATE i64 sqlite3PcachePageRefcount(PgHdr*);
16782
16782
 
16783
16783
  /* Return the total number of pages stored in the cache */
16784
16784
  SQLITE_PRIVATE int sqlite3PcachePagecount(PCache*);
@@ -18937,7 +18937,7 @@ struct NameContext {
18937
18937
  #define NC_HasAgg 0x000010 /* One or more aggregate functions seen */
18938
18938
  #define NC_IdxExpr 0x000020 /* True if resolving columns of CREATE INDEX */
18939
18939
  #define NC_SelfRef 0x00002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
18940
- #define NC_VarSelect 0x000040 /* A correlated subquery has been seen */
18940
+ #define NC_Subquery 0x000040 /* A subquery has been seen */
18941
18941
  #define NC_UEList 0x000080 /* True if uNC.pEList is used */
18942
18942
  #define NC_UAggInfo 0x000100 /* True if uNC.pAggInfo is used */
18943
18943
  #define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */
@@ -19256,6 +19256,7 @@ struct IndexedExpr {
19256
19256
  int iIdxCur; /* The index cursor */
19257
19257
  int iIdxCol; /* The index column that contains value of pExpr */
19258
19258
  u8 bMaybeNullRow; /* True if we need an OP_IfNullRow check */
19259
+ u8 aff; /* Affinity of the pExpr expression */
19259
19260
  IndexedExpr *pIENext; /* Next in a list of all indexed expressions */
19260
19261
  #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
19261
19262
  const char *zIdxName; /* Name of index, used only for bytecode comments */
@@ -19307,6 +19308,9 @@ struct Parse {
19307
19308
  u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
19308
19309
  #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
19309
19310
  u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */
19311
+ #endif
19312
+ #ifdef SQLITE_DEBUG
19313
+ u8 ifNotExists; /* Might be true if IF NOT EXISTS. Assert()s only */
19310
19314
  #endif
19311
19315
  int nRangeReg; /* Size of the temporary register block */
19312
19316
  int iRangeReg; /* First register in temporary register block */
@@ -37189,7 +37193,11 @@ SQLITE_PRIVATE int sqlite3KvvfsInit(void){
37189
37193
  /*
37190
37194
  ** Maximum supported path-length.
37191
37195
  */
37196
+ #if SQLITE3MC_MAX_PATHNAME > 512
37197
+ #define MAX_PATHNAME SQLITE3MC_MAX_PATHNAME
37198
+ #else
37192
37199
  #define MAX_PATHNAME 512
37200
+ #endif
37193
37201
 
37194
37202
  /*
37195
37203
  ** Maximum supported symbolic links
@@ -52753,7 +52761,7 @@ bitvec_end:
52753
52761
  struct PCache {
52754
52762
  PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */
52755
52763
  PgHdr *pSynced; /* Last synced page in dirty page list */
52756
- int nRefSum; /* Sum of ref counts over all pages */
52764
+ i64 nRefSum; /* Sum of ref counts over all pages */
52757
52765
  int szCache; /* Configured cache size */
52758
52766
  int szSpill; /* Size before spilling occurs */
52759
52767
  int szPage; /* Size of every page in this cache */
@@ -52783,7 +52791,7 @@ struct PCache {
52783
52791
  unsigned char *a;
52784
52792
  int j;
52785
52793
  pPg = (PgHdr*)pLower->pExtra;
52786
- printf("%3d: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags);
52794
+ printf("%3lld: nRef %2d flgs %02x data ", i, pPg->nRef, pPg->flags);
52787
52795
  a = (unsigned char *)pLower->pBuf;
52788
52796
  for(j=0; j<12; j++) printf("%02x", a[j]);
52789
52797
  printf(" ptr %p\n", pPg);
@@ -53527,14 +53535,14 @@ SQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache *pCache){
53527
53535
  ** This is not the total number of pages referenced, but the sum of the
53528
53536
  ** reference count for all pages.
53529
53537
  */
53530
- SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){
53538
+ SQLITE_PRIVATE i64 sqlite3PcacheRefCount(PCache *pCache){
53531
53539
  return pCache->nRefSum;
53532
53540
  }
53533
53541
 
53534
53542
  /*
53535
53543
  ** Return the number of references to the page supplied as an argument.
53536
53544
  */
53537
- SQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr *p){
53545
+ SQLITE_PRIVATE i64 sqlite3PcachePageRefcount(PgHdr *p){
53538
53546
  return p->nRef;
53539
53547
  }
53540
53548
 
@@ -74604,7 +74612,7 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){
74604
74612
 
74605
74613
  pPage = pCur->pPage;
74606
74614
  idx = ++pCur->ix;
74607
- if( NEVER(!pPage->isInit) || sqlite3FaultSim(412) ){
74615
+ if( !pPage->isInit || sqlite3FaultSim(412) ){
74608
74616
  return SQLITE_CORRUPT_BKPT;
74609
74617
  }
74610
74618
 
@@ -77733,6 +77741,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
77733
77741
  assert( szNew==pPage->xCellSize(pPage, newCell) );
77734
77742
  assert( szNew <= MX_CELL_SIZE(p->pBt) );
77735
77743
  idx = pCur->ix;
77744
+ pCur->info.nSize = 0;
77736
77745
  if( loc==0 ){
77737
77746
  CellInfo info;
77738
77747
  assert( idx>=0 );
@@ -77805,7 +77814,6 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
77805
77814
  ** larger than the largest existing key, it is possible to insert the
77806
77815
  ** row without seeking the cursor. This can be a big performance boost.
77807
77816
  */
77808
- pCur->info.nSize = 0;
77809
77817
  if( pPage->nOverflow ){
77810
77818
  assert( rc==SQLITE_OK );
77811
77819
  pCur->curFlags &= ~(BTCF_ValidNKey);
@@ -91015,8 +91023,7 @@ static u64 filterHash(const Mem *aMem, const Op *pOp){
91015
91023
  }else if( p->flags & MEM_Real ){
91016
91024
  h += sqlite3VdbeIntValue(p);
91017
91025
  }else if( p->flags & (MEM_Str|MEM_Blob) ){
91018
- h += p->n;
91019
- if( p->flags & MEM_Zero ) h += p->u.nZero;
91026
+ /* no-op */
91020
91027
  }
91021
91028
  }
91022
91029
  return h;
@@ -104595,14 +104602,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
104595
104602
  if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){
104596
104603
  testcase( ExprHasProperty(pExpr, EP_OuterON) );
104597
104604
  assert( !ExprHasProperty(pExpr, EP_IntValue) );
104598
- if( pExpr->op==TK_NOTNULL ){
104599
- pExpr->u.zToken = "true";
104600
- ExprSetProperty(pExpr, EP_IsTrue);
104601
- }else{
104602
- pExpr->u.zToken = "false";
104603
- ExprSetProperty(pExpr, EP_IsFalse);
104604
- }
104605
- pExpr->op = TK_TRUEFALSE;
104605
+ pExpr->u.iValue = (pExpr->op==TK_NOTNULL);
104606
+ pExpr->flags |= EP_IntValue;
104607
+ pExpr->op = TK_INTEGER;
104608
+
104606
104609
  for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){
104607
104610
  p->nRef = anRef[i];
104608
104611
  }
@@ -104904,8 +104907,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
104904
104907
  assert( pNC->nRef>=nRef );
104905
104908
  if( nRef!=pNC->nRef ){
104906
104909
  ExprSetProperty(pExpr, EP_VarSelect);
104907
- pNC->ncFlags |= NC_VarSelect;
104908
104910
  }
104911
+ pNC->ncFlags |= NC_Subquery;
104909
104912
  }
104910
104913
  break;
104911
104914
  }
@@ -109654,6 +109657,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(
109654
109657
  ){
109655
109658
  int iAddr;
109656
109659
  Vdbe *v = pParse->pVdbe;
109660
+ int nErr = pParse->nErr;
109657
109661
  assert( v!=0 );
109658
109662
  assert( pParse->iSelfTab!=0 );
109659
109663
  if( pParse->iSelfTab>0 ){
@@ -109666,6 +109670,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(
109666
109670
  sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1);
109667
109671
  }
109668
109672
  if( iAddr ) sqlite3VdbeJumpHere(v, iAddr);
109673
+ if( pParse->nErr>nErr ) pParse->db->errByteOffset = -1;
109669
109674
  }
109670
109675
  #endif /* SQLITE_OMIT_GENERATED_COLUMNS */
109671
109676
 
@@ -109682,6 +109687,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(
109682
109687
  Column *pCol;
109683
109688
  assert( v!=0 );
109684
109689
  assert( pTab!=0 );
109690
+ assert( iCol!=XN_EXPR );
109685
109691
  if( iCol<0 || iCol==pTab->iPKey ){
109686
109692
  sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut);
109687
109693
  VdbeComment((v, "%s.rowid", pTab->zName));
@@ -109948,6 +109954,7 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup(
109948
109954
  IndexedExpr *p;
109949
109955
  Vdbe *v;
109950
109956
  for(p=pParse->pIdxEpr; p; p=p->pIENext){
109957
+ u8 exprAff;
109951
109958
  int iDataCur = p->iDataCur;
109952
109959
  if( iDataCur<0 ) continue;
109953
109960
  if( pParse->iSelfTab ){
@@ -109955,6 +109962,16 @@ static SQLITE_NOINLINE int sqlite3IndexedExprLookup(
109955
109962
  iDataCur = -1;
109956
109963
  }
109957
109964
  if( sqlite3ExprCompare(0, pExpr, p->pExpr, iDataCur)!=0 ) continue;
109965
+ assert( p->aff>=SQLITE_AFF_BLOB && p->aff<=SQLITE_AFF_NUMERIC );
109966
+ exprAff = sqlite3ExprAffinity(pExpr);
109967
+ if( (exprAff<=SQLITE_AFF_BLOB && p->aff!=SQLITE_AFF_BLOB)
109968
+ || (exprAff==SQLITE_AFF_TEXT && p->aff!=SQLITE_AFF_TEXT)
109969
+ || (exprAff>=SQLITE_AFF_NUMERIC && p->aff!=SQLITE_AFF_NUMERIC)
109970
+ ){
109971
+ /* Affinity mismatch on a generated column */
109972
+ continue;
109973
+ }
109974
+
109958
109975
  v = pParse->pVdbe;
109959
109976
  assert( v!=0 );
109960
109977
  if( p->bMaybeNullRow ){
@@ -110534,10 +110551,13 @@ expr_code_doover:
110534
110551
  return target;
110535
110552
  }
110536
110553
  case TK_COLLATE: {
110537
- if( !ExprHasProperty(pExpr, EP_Collate)
110538
- && ALWAYS(pExpr->pLeft)
110539
- && pExpr->pLeft->op==TK_FUNCTION
110540
- ){
110554
+ if( !ExprHasProperty(pExpr, EP_Collate) ){
110555
+ /* A TK_COLLATE Expr node without the EP_Collate tag is a so-called
110556
+ ** "SOFT-COLLATE" that is added to constraints that are pushed down
110557
+ ** from outer queries into sub-queries by the push-down optimization.
110558
+ ** Clear subtypes as subtypes may not cross a subquery boundary.
110559
+ */
110560
+ assert( pExpr->pLeft );
110541
110561
  inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
110542
110562
  if( inReg!=target ){
110543
110563
  sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
@@ -110645,16 +110665,22 @@ expr_code_doover:
110645
110665
  break;
110646
110666
  }
110647
110667
  }
110648
- addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable);
110649
- /* Temporarily disable factoring of constant expressions, since
110650
- ** even though expressions may appear to be constant, they are not
110651
- ** really constant because they originate from the right-hand side
110652
- ** of a LEFT JOIN. */
110653
- pParse->okConstFactor = 0;
110668
+ addrINR = sqlite3VdbeAddOp3(v, OP_IfNullRow, pExpr->iTable, 0, target);
110669
+ /* The OP_IfNullRow opcode above can overwrite the result register with
110670
+ ** NULL. So we have to ensure that the result register is not a value
110671
+ ** that is suppose to be a constant. Two defenses are needed:
110672
+ ** (1) Temporarily disable factoring of constant expressions
110673
+ ** (2) Make sure the computed value really is stored in register
110674
+ ** "target" and not someplace else.
110675
+ */
110676
+ pParse->okConstFactor = 0; /* note (1) above */
110654
110677
  inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target);
110655
110678
  pParse->okConstFactor = okConstFactor;
110679
+ if( inReg!=target ){ /* note (2) above */
110680
+ sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target);
110681
+ inReg = target;
110682
+ }
110656
110683
  sqlite3VdbeJumpHere(v, addrINR);
110657
- sqlite3VdbeChangeP3(v, addrINR, inReg);
110658
110684
  break;
110659
110685
  }
110660
110686
 
@@ -119022,7 +119048,7 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){
119022
119048
  if( pParse->pNewTrigger ){
119023
119049
  sqlite3ErrorMsg(pParse, "cannot use RETURNING in a trigger");
119024
119050
  }else{
119025
- assert( pParse->bReturning==0 );
119051
+ assert( pParse->bReturning==0 || pParse->ifNotExists );
119026
119052
  }
119027
119053
  pParse->bReturning = 1;
119028
119054
  pRet = sqlite3DbMallocZero(db, sizeof(*pRet));
@@ -119048,7 +119074,8 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){
119048
119074
  pRet->retTStep.pTrig = &pRet->retTrig;
119049
119075
  pRet->retTStep.pExprList = pList;
119050
119076
  pHash = &(db->aDb[1].pSchema->trigHash);
119051
- assert( sqlite3HashFind(pHash, RETURNING_TRIGGER_NAME)==0 || pParse->nErr );
119077
+ assert( sqlite3HashFind(pHash, RETURNING_TRIGGER_NAME)==0
119078
+ || pParse->nErr || pParse->ifNotExists );
119052
119079
  if( sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, &pRet->retTrig)
119053
119080
  ==&pRet->retTrig ){
119054
119081
  sqlite3OomFault(db);
@@ -119583,6 +119610,7 @@ SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType
119583
119610
  ** turn it into one by adding a unary "+" operator. */
119584
119611
  pExpr = sqlite3PExpr(pParse, TK_UPLUS, pExpr, 0);
119585
119612
  }
119613
+ if( pExpr && pExpr->op!=TK_RAISE ) pExpr->affExpr = pCol->affinity;
119586
119614
  sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr);
119587
119615
  pExpr = 0;
119588
119616
  goto generated_done;
@@ -124289,7 +124317,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
124289
124317
  #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */
124290
124318
  {
124291
124319
  u16 wcf = WHERE_ONEPASS_DESIRED|WHERE_DUPLICATES_OK;
124292
- if( sNC.ncFlags & NC_VarSelect ) bComplex = 1;
124320
+ if( sNC.ncFlags & NC_Subquery ) bComplex = 1;
124293
124321
  wcf |= (bComplex ? 0 : WHERE_ONEPASS_MULTIROW);
124294
124322
  if( HasRowid(pTab) ){
124295
124323
  /* For a rowid table, initialize the RowSet to an empty set */
@@ -126986,6 +127014,18 @@ static void ceilingFunc(
126986
127014
  static double xCeil(double x){ return ceil(x); }
126987
127015
  static double xFloor(double x){ return floor(x); }
126988
127016
 
127017
+ /*
127018
+ ** Some systems do not have log2() and log10() in their standard math
127019
+ ** libraries.
127020
+ */
127021
+ #if defined(HAVE_LOG10) && HAVE_LOG10==0
127022
+ # define log10(X) (0.4342944819032517867*log(X))
127023
+ #endif
127024
+ #if defined(HAVE_LOG2) && HAVE_LOG2==0
127025
+ # define log2(X) (1.442695040888963456*log(X))
127026
+ #endif
127027
+
127028
+
126989
127029
  /*
126990
127030
  ** Implementation of SQL functions:
126991
127031
  **
@@ -136365,6 +136405,23 @@ SQLITE_PRIVATE void sqlite3Pragma(
136365
136405
  jmp4 = integrityCheckResultRow(v);
136366
136406
  sqlite3VdbeJumpHere(v, jmp2);
136367
136407
 
136408
+ /* The OP_IdxRowid opcode is an optimized version of OP_Column
136409
+ ** that extracts the rowid off the end of the index record.
136410
+ ** But it only works correctly if index record does not have
136411
+ ** any extra bytes at the end. Verify that this is the case. */
136412
+ if( HasRowid(pTab) ){
136413
+ int jmp7;
136414
+ sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur+j, 3);
136415
+ jmp7 = sqlite3VdbeAddOp3(v, OP_Eq, 3, 0, r1+pIdx->nColumn-1);
136416
+ VdbeCoverage(v);
136417
+ sqlite3VdbeLoadString(v, 3,
136418
+ "rowid not at end-of-record for row ");
136419
+ sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
136420
+ sqlite3VdbeLoadString(v, 4, " of index ");
136421
+ sqlite3VdbeGoto(v, jmp5-1);
136422
+ sqlite3VdbeJumpHere(v, jmp7);
136423
+ }
136424
+
136368
136425
  /* Any indexed columns with non-BINARY collations must still hold
136369
136426
  ** the exact same text value as the table. */
136370
136427
  label6 = 0;
@@ -140660,8 +140717,6 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
140660
140717
  pCol->affinity = sqlite3ExprAffinity(p);
140661
140718
  if( pCol->affinity<=SQLITE_AFF_NONE ){
140662
140719
  pCol->affinity = aff;
140663
- }else if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){
140664
- pCol->affinity = SQLITE_AFF_FLEXNUM;
140665
140720
  }
140666
140721
  if( pCol->affinity>=SQLITE_AFF_TEXT && pSelect->pNext ){
140667
140722
  int m = 0;
@@ -140675,6 +140730,9 @@ SQLITE_PRIVATE void sqlite3SubqueryColumnTypes(
140675
140730
  if( pCol->affinity>=SQLITE_AFF_NUMERIC && (m&0x02)!=0 ){
140676
140731
  pCol->affinity = SQLITE_AFF_BLOB;
140677
140732
  }
140733
+ if( pCol->affinity>=SQLITE_AFF_NUMERIC && p->op==TK_CAST ){
140734
+ pCol->affinity = SQLITE_AFF_FLEXNUM;
140735
+ }
140678
140736
  }
140679
140737
  zType = columnType(&sNC, p, 0, 0, 0);
140680
140738
  if( zType==0 || pCol->affinity!=sqlite3AffinityType(zType, 0) ){
@@ -142189,7 +142247,9 @@ static Expr *substExpr(
142189
142247
  sqlite3VectorErrorMsg(pSubst->pParse, pCopy);
142190
142248
  }else{
142191
142249
  sqlite3 *db = pSubst->pParse->db;
142192
- if( pSubst->isOuterJoin && pCopy->op!=TK_COLUMN ){
142250
+ if( pSubst->isOuterJoin
142251
+ && (pCopy->op!=TK_COLUMN || pCopy->iTable!=pSubst->iNewTable)
142252
+ ){
142193
142253
  memset(&ifNullRow, 0, sizeof(ifNullRow));
142194
142254
  ifNullRow.op = TK_IF_NULL_ROW;
142195
142255
  ifNullRow.pLeft = pCopy;
@@ -144705,10 +144765,12 @@ static void optimizeAggregateUseOfIndexedExpr(
144705
144765
  NameContext *pNC /* Name context used to resolve agg-func args */
144706
144766
  ){
144707
144767
  assert( pAggInfo->iFirstReg==0 );
144768
+ assert( pSelect!=0 );
144769
+ assert( pSelect->pGroupBy!=0 );
144708
144770
  pAggInfo->nColumn = pAggInfo->nAccumulator;
144709
144771
  if( ALWAYS(pAggInfo->nSortingColumn>0) ){
144710
144772
  if( pAggInfo->nColumn==0 ){
144711
- pAggInfo->nSortingColumn = 0;
144773
+ pAggInfo->nSortingColumn = pSelect->pGroupBy->nExpr;
144712
144774
  }else{
144713
144775
  pAggInfo->nSortingColumn =
144714
144776
  pAggInfo->aCol[pAggInfo->nColumn-1].iSorterColumn+1;
@@ -145133,6 +145195,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
145133
145195
  if( p->pEList->nExpr!=1 ) return 0; /* Single result column */
145134
145196
  if( p->pWhere ) return 0;
145135
145197
  if( p->pGroupBy ) return 0;
145198
+ if( p->pOrderBy ) return 0;
145136
145199
  pExpr = p->pEList->a[0].pExpr;
145137
145200
  if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */
145138
145201
  assert( ExprUseUToken(pExpr) );
@@ -145143,7 +145206,8 @@ static int countOfViewOptimization(Parse *pParse, Select *p){
145143
145206
  if( ExprHasProperty(pExpr, EP_WinFunc) ) return 0;/* Not a window function */
145144
145207
  pSub = p->pSrc->a[0].pSelect;
145145
145208
  if( pSub==0 ) return 0; /* The FROM is a subquery */
145146
- if( pSub->pPrior==0 ) return 0; /* Must be a compound ry */
145209
+ if( pSub->pPrior==0 ) return 0; /* Must be a compound */
145210
+ if( pSub->selFlags & SF_CopyCte ) return 0; /* Not a CTE */
145147
145211
  do{
145148
145212
  if( pSub->op!=TK_ALL && pSub->pPrior ) return 0; /* Must be UNION ALL */
145149
145213
  if( pSub->pWhere ) return 0; /* No WHERE clause */
@@ -145586,7 +145650,6 @@ SQLITE_PRIVATE int sqlite3Select(
145586
145650
  && countOfViewOptimization(pParse, p)
145587
145651
  ){
145588
145652
  if( db->mallocFailed ) goto select_end;
145589
- pEList = p->pEList;
145590
145653
  pTabList = p->pSrc;
145591
145654
  }
145592
145655
  #endif
@@ -146948,6 +147011,7 @@ SQLITE_PRIVATE void sqlite3BeginTrigger(
146948
147011
  }else{
146949
147012
  assert( !db->init.busy );
146950
147013
  sqlite3CodeVerifySchema(pParse, iDb);
147014
+ VVA_ONLY( pParse->ifNotExists = 1; )
146951
147015
  }
146952
147016
  goto trigger_cleanup;
146953
147017
  }
@@ -147729,7 +147793,7 @@ static void codeReturningTrigger(
147729
147793
  }
147730
147794
  sqlite3ExprListDelete(db, sSelect.pEList);
147731
147795
  pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
147732
- if( !db->mallocFailed ){
147796
+ if( pParse->nErr==0 ){
147733
147797
  NameContext sNC;
147734
147798
  memset(&sNC, 0, sizeof(sNC));
147735
147799
  if( pReturning->nRetCol==0 ){
@@ -148951,12 +149015,22 @@ SQLITE_PRIVATE void sqlite3Update(
148951
149015
  /* Begin the database scan.
148952
149016
  **
148953
149017
  ** Do not consider a single-pass strategy for a multi-row update if
148954
- ** there are any triggers or foreign keys to process, or rows may
148955
- ** be deleted as a result of REPLACE conflict handling. Any of these
148956
- ** things might disturb a cursor being used to scan through the table
148957
- ** or index, causing a single-pass approach to malfunction. */
149018
+ ** there is anything that might disrupt the cursor being used to do
149019
+ ** the UPDATE:
149020
+ ** (1) This is a nested UPDATE
149021
+ ** (2) There are triggers
149022
+ ** (3) There are FOREIGN KEY constraints
149023
+ ** (4) There are REPLACE conflict handlers
149024
+ ** (5) There are subqueries in the WHERE clause
149025
+ */
148958
149026
  flags = WHERE_ONEPASS_DESIRED;
148959
- if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
149027
+ if( !pParse->nested
149028
+ && !pTrigger
149029
+ && !hasFK
149030
+ && !chngKey
149031
+ && !bReplace
149032
+ && (sNC.ncFlags & NC_Subquery)==0
149033
+ ){
148960
149034
  flags |= WHERE_ONEPASS_MULTIROW;
148961
149035
  }
148962
149036
  pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,0,0,flags,iIdxCur);
@@ -150921,7 +150995,9 @@ static int vtabCallConstructor(
150921
150995
  sCtx.pPrior = db->pVtabCtx;
150922
150996
  sCtx.bDeclared = 0;
150923
150997
  db->pVtabCtx = &sCtx;
150998
+ pTab->nTabRef++;
150924
150999
  rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
151000
+ sqlite3DeleteTable(db, pTab);
150925
151001
  db->pVtabCtx = sCtx.pPrior;
150926
151002
  if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
150927
151003
  assert( sCtx.pTab==pTab );
@@ -156953,7 +157029,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(
156953
157029
  pRhs = sqlite3PExpr(pParse, TK_UPLUS,
156954
157030
  sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
156955
157031
  pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
156956
- if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ) ){
157032
+ if( pItem->fg.jointype & (JT_LEFT|JT_LTORJ|JT_RIGHT) ){
156957
157033
  joinType = EP_OuterON;
156958
157034
  }else{
156959
157035
  joinType = EP_InnerON;
@@ -158090,6 +158166,10 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
158090
158166
  Vdbe *v = pParse->pVdbe; /* VDBE under construction */
158091
158167
  WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */
158092
158168
  int iCur; /* Cursor for table getting the filter */
158169
+ IndexedExpr *saved_pIdxEpr; /* saved copy of Parse.pIdxEpr */
158170
+
158171
+ saved_pIdxEpr = pParse->pIdxEpr;
158172
+ pParse->pIdxEpr = 0;
158093
158173
 
158094
158174
  assert( pLoop!=0 );
158095
158175
  assert( v!=0 );
@@ -158146,9 +158226,8 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
158146
158226
  int r1 = sqlite3GetTempRange(pParse, n);
158147
158227
  int jj;
158148
158228
  for(jj=0; jj<n; jj++){
158149
- int iCol = pIdx->aiColumn[jj];
158150
158229
  assert( pIdx->pTable==pItem->pTab );
158151
- sqlite3ExprCodeGetColumnOfTable(v, pIdx->pTable, iCur, iCol,r1+jj);
158230
+ sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iCur, jj, r1+jj);
158152
158231
  }
158153
158232
  sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, n);
158154
158233
  sqlite3ReleaseTempRange(pParse, r1, n);
@@ -158179,6 +158258,7 @@ static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
158179
158258
  }
158180
158259
  }while( iLevel < pWInfo->nLevel );
158181
158260
  sqlite3VdbeJumpHere(v, addrOnce);
158261
+ pParse->pIdxEpr = saved_pIdxEpr;
158182
158262
  }
158183
158263
 
158184
158264
 
@@ -158478,6 +158558,7 @@ static int whereKeyStats(
158478
158558
  assert( pIdx->nSample>0 );
158479
158559
  assert( pRec->nField>0 );
158480
158560
 
158561
+
158481
158562
  /* Do a binary search to find the first sample greater than or equal
158482
158563
  ** to pRec. If pRec contains a single field, the set of samples to search
158483
158564
  ** is simply the aSample[] array. If the samples in aSample[] contain more
@@ -158522,7 +158603,12 @@ static int whereKeyStats(
158522
158603
  ** it is extended to two fields. The duplicates that this creates do not
158523
158604
  ** cause any problems.
158524
158605
  */
158525
- nField = MIN(pRec->nField, pIdx->nSample);
158606
+ if( !HasRowid(pIdx->pTable) && IsPrimaryKeyIndex(pIdx) ){
158607
+ nField = pIdx->nKeyCol;
158608
+ }else{
158609
+ nField = pIdx->nColumn;
158610
+ }
158611
+ nField = MIN(pRec->nField, nField);
158526
158612
  iCol = 0;
158527
158613
  iSample = pIdx->nSample * nField;
158528
158614
  do{
@@ -162250,6 +162336,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
162250
162336
  if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){
162251
162337
  pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
162252
162338
  }
162339
+ if( pWInfo->pSelect->pOrderBy
162340
+ && pWInfo->nOBSat > pWInfo->pSelect->pOrderBy->nExpr ){
162341
+ pWInfo->nOBSat = pWInfo->pSelect->pOrderBy->nExpr;
162342
+ }
162253
162343
  }else{
162254
162344
  pWInfo->revMask = pFrom->revLoop;
162255
162345
  if( pWInfo->nOBSat<=0 ){
@@ -162661,6 +162751,9 @@ static SQLITE_NOINLINE void whereAddIndexedExpr(
162661
162751
  p->iIdxCur = iIdxCur;
162662
162752
  p->iIdxCol = i;
162663
162753
  p->bMaybeNullRow = bMaybeNullRow;
162754
+ if( sqlite3IndexAffinityStr(pParse->db, pIdx) ){
162755
+ p->aff = pIdx->zColAff[i];
162756
+ }
162664
162757
  #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
162665
162758
  p->zIdxName = pIdx->zName;
162666
162759
  #endif
@@ -193131,16 +193224,18 @@ static int fts3MsrBufferData(
193131
193224
  char *pList,
193132
193225
  i64 nList
193133
193226
  ){
193134
- if( nList>pMsr->nBuffer ){
193227
+ if( (nList+FTS3_NODE_PADDING)>pMsr->nBuffer ){
193135
193228
  char *pNew;
193136
- pMsr->nBuffer = nList*2;
193137
- pNew = (char *)sqlite3_realloc64(pMsr->aBuffer, pMsr->nBuffer);
193229
+ int nNew = nList*2 + FTS3_NODE_PADDING;
193230
+ pNew = (char *)sqlite3_realloc64(pMsr->aBuffer, nNew);
193138
193231
  if( !pNew ) return SQLITE_NOMEM;
193139
193232
  pMsr->aBuffer = pNew;
193233
+ pMsr->nBuffer = nNew;
193140
193234
  }
193141
193235
 
193142
193236
  assert( nList>0 );
193143
193237
  memcpy(pMsr->aBuffer, pList, nList);
193238
+ memset(&pMsr->aBuffer[nList], 0, FTS3_NODE_PADDING);
193144
193239
  return SQLITE_OK;
193145
193240
  }
193146
193241
 
@@ -240284,7 +240379,7 @@ static void fts5SourceIdFunc(
240284
240379
  ){
240285
240380
  assert( nArg==0 );
240286
240381
  UNUSED_PARAM2(nArg, apUnused);
240287
- sqlite3_result_text(pCtx, "fts5: 2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d", -1, SQLITE_TRANSIENT);
240382
+ sqlite3_result_text(pCtx, "fts5: 2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da", -1, SQLITE_TRANSIENT);
240288
240383
  }
240289
240384
 
240290
240385
  /*
@@ -245482,9 +245577,9 @@ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
245482
245577
 
245483
245578
  #define SQLITE3MC_VERSION_MAJOR 1
245484
245579
  #define SQLITE3MC_VERSION_MINOR 6
245485
- #define SQLITE3MC_VERSION_RELEASE 0
245580
+ #define SQLITE3MC_VERSION_RELEASE 2
245486
245581
  #define SQLITE3MC_VERSION_SUBRELEASE 0
245487
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.6.0"
245582
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.6.2"
245488
245583
 
245489
245584
  #endif /* SQLITE3MC_VERSION_H_ */
245490
245585
  /*** End of #include "sqlite3mc_version.h" ***/
@@ -245643,9 +245738,9 @@ extern "C" {
245643
245738
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
245644
245739
  ** [sqlite_version()] and [sqlite_source_id()].
245645
245740
  */
245646
- #define SQLITE_VERSION "3.41.0"
245647
- #define SQLITE_VERSION_NUMBER 3041000
245648
- #define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d"
245741
+ #define SQLITE_VERSION "3.41.2"
245742
+ #define SQLITE_VERSION_NUMBER 3041002
245743
+ #define SQLITE_SOURCE_ID "2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da"
245649
245744
 
245650
245745
  /*
245651
245746
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -268772,7 +268867,7 @@ sqlite3mcBtreeSetPageSize(Btree* p, int pageSize, int nReserve, int iFix)
268772
268867
  ** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database
268773
268868
  ** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes)
268774
268869
  **
268775
- ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.41.0 amalgamation.
268870
+ ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.41.2 amalgamation.
268776
268871
  */
268777
268872
  SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey(
268778
268873
  char **pzErrMsg, /* Write error message here */
@@ -292607,7 +292702,7 @@ sqlite3mcCheckVfs(const char* zVfs)
292607
292702
  if (pVfs == NULL)
292608
292703
  {
292609
292704
  /* VFS not found */
292610
- int prefixLen = strlen(SQLITE3MC_VFS_NAME);
292705
+ int prefixLen = (int) strlen(SQLITE3MC_VFS_NAME);
292611
292706
  if (strncmp(zVfs, SQLITE3MC_VFS_NAME, prefixLen) == 0)
292612
292707
  {
292613
292708
  /* VFS name starts with prefix. */
@@ -31,9 +31,9 @@
31
31
 
32
32
  #define SQLITE3MC_VERSION_MAJOR 1
33
33
  #define SQLITE3MC_VERSION_MINOR 6
34
- #define SQLITE3MC_VERSION_RELEASE 0
34
+ #define SQLITE3MC_VERSION_RELEASE 2
35
35
  #define SQLITE3MC_VERSION_SUBRELEASE 0
36
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.6.0"
36
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.6.2"
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.41.0"
196
- #define SQLITE_VERSION_NUMBER 3041000
197
- #define SQLITE_SOURCE_ID "2023-02-21 18:09:37 05941c2a04037fc3ed2ffae11f5d2260706f89431f463518740f72ada350866d"
195
+ #define SQLITE_VERSION "3.41.2"
196
+ #define SQLITE_VERSION_NUMBER 3041002
197
+ #define SQLITE_SOURCE_ID "2023-03-22 11:56:21 0d1fc92f94cb6b76bffe3ec34d69cffde2924203304e8ffc4155597af0c191da"
198
198
 
199
199
  /*
200
200
  ** CAPI3REF: Run-Time Library Version Numbers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-sqlite3-multiple-ciphers",
3
- "version": "8.2.0",
3
+ "version": "8.2.1-beta.1",
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>",