Fossil SCM

Update the built-in SQLite to the latest 3.33 alpha for testing.

drh 2020-09-30 21:11 trunk
Commit 02c6b07eab4a148be17923c4f02efe06a7685a3f3f7f957ff0cfd7ff9a69109c
3 files changed +6 -3 +449 -254 +1 -1
+6 -3
--- src/shell.c
+++ src/shell.c
@@ -20939,15 +20939,18 @@
2093920939
sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
2094020940
#else
2094120941
(void)cmdline_option_value(argc, argv, ++i);
2094220942
#endif
2094320943
}else if( strcmp(z,"-pagecache")==0 ){
20944
- int n, sz;
20945
- sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
20944
+ sqlite3_int64 n, sz;
20945
+ sz = integerValue(cmdline_option_value(argc,argv,++i));
2094620946
if( sz>70000 ) sz = 70000;
2094720947
if( sz<0 ) sz = 0;
20948
- n = (int)integerValue(cmdline_option_value(argc,argv,++i));
20948
+ n = integerValue(cmdline_option_value(argc,argv,++i));
20949
+ if( sz>0 && n>0 && 0xffffffffffffLL/sz<n ){
20950
+ n = 0xffffffffffffLL/sz;
20951
+ }
2094920952
sqlite3_config(SQLITE_CONFIG_PAGECACHE,
2095020953
(n>0 && sz>0) ? malloc(n*sz) : 0, sz, n);
2095120954
data.shellFlgs |= SHFLG_Pagecache;
2095220955
}else if( strcmp(z,"-lookaside")==0 ){
2095320956
int n, sz;
2095420957
--- src/shell.c
+++ src/shell.c
@@ -20939,15 +20939,18 @@
20939 sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
20940 #else
20941 (void)cmdline_option_value(argc, argv, ++i);
20942 #endif
20943 }else if( strcmp(z,"-pagecache")==0 ){
20944 int n, sz;
20945 sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
20946 if( sz>70000 ) sz = 70000;
20947 if( sz<0 ) sz = 0;
20948 n = (int)integerValue(cmdline_option_value(argc,argv,++i));
 
 
 
20949 sqlite3_config(SQLITE_CONFIG_PAGECACHE,
20950 (n>0 && sz>0) ? malloc(n*sz) : 0, sz, n);
20951 data.shellFlgs |= SHFLG_Pagecache;
20952 }else if( strcmp(z,"-lookaside")==0 ){
20953 int n, sz;
20954
--- src/shell.c
+++ src/shell.c
@@ -20939,15 +20939,18 @@
20939 sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
20940 #else
20941 (void)cmdline_option_value(argc, argv, ++i);
20942 #endif
20943 }else if( strcmp(z,"-pagecache")==0 ){
20944 sqlite3_int64 n, sz;
20945 sz = integerValue(cmdline_option_value(argc,argv,++i));
20946 if( sz>70000 ) sz = 70000;
20947 if( sz<0 ) sz = 0;
20948 n = integerValue(cmdline_option_value(argc,argv,++i));
20949 if( sz>0 && n>0 && 0xffffffffffffLL/sz<n ){
20950 n = 0xffffffffffffLL/sz;
20951 }
20952 sqlite3_config(SQLITE_CONFIG_PAGECACHE,
20953 (n>0 && sz>0) ? malloc(n*sz) : 0, sz, n);
20954 data.shellFlgs |= SHFLG_Pagecache;
20955 }else if( strcmp(z,"-lookaside")==0 ){
20956 int n, sz;
20957
+449 -254
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1171,11 +1171,11 @@
11711171
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11721172
** [sqlite_version()] and [sqlite_source_id()].
11731173
*/
11741174
#define SQLITE_VERSION "3.34.0"
11751175
#define SQLITE_VERSION_NUMBER 3034000
1176
-#define SQLITE_SOURCE_ID "2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8afa3"
1176
+#define SQLITE_SOURCE_ID "2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c402e5"
11771177
11781178
/*
11791179
** CAPI3REF: Run-Time Library Version Numbers
11801180
** KEYWORDS: sqlite3_version sqlite3_sourceid
11811181
**
@@ -15133,16 +15133,25 @@
1513315133
SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
1513415134
SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
1513515135
SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, Pgno*, int flags);
1513615136
SQLITE_PRIVATE int sqlite3BtreeTxnState(Btree*);
1513715137
SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*);
15138
+
1513815139
SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
1513915140
SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree);
1514015141
#ifndef SQLITE_OMIT_SHARED_CACHE
1514115142
SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);
1514215143
#endif
15144
+
15145
+/* Savepoints are named, nestable SQL transactions mostly implemented */
15146
+/* in vdbe.c and pager.c See https://sqlite.org/lang_savepoint.html */
1514315147
SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int);
15148
+
15149
+/* "Checkpoint" only refers to WAL. See https://sqlite.org/wal.html#ckpt */
15150
+#ifndef SQLITE_OMIT_WAL
15151
+SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);
15152
+#endif
1514415153
1514515154
SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *);
1514615155
SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *);
1514715156
SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);
1514815157
@@ -15735,68 +15744,69 @@
1573515744
#define OP_SequenceTest 113 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
1573615745
#define OP_OpenPseudo 114 /* synopsis: P3 columns in r[P2] */
1573715746
#define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */
1573815747
#define OP_Close 116
1573915748
#define OP_ColumnsUsed 117
15740
-#define OP_SeekHit 118 /* synopsis: set P2<=seekHit<=P3 */
15741
-#define OP_Sequence 119 /* synopsis: r[P2]=cursor[P1].ctr++ */
15742
-#define OP_NewRowid 120 /* synopsis: r[P2]=rowid */
15743
-#define OP_Insert 121 /* synopsis: intkey=r[P3] data=r[P2] */
15744
-#define OP_Delete 122
15745
-#define OP_ResetCount 123
15746
-#define OP_SorterCompare 124 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15747
-#define OP_SorterData 125 /* synopsis: r[P2]=data */
15748
-#define OP_RowData 126 /* synopsis: r[P2]=data */
15749
-#define OP_Rowid 127 /* synopsis: r[P2]=rowid */
15750
-#define OP_NullRow 128
15751
-#define OP_SeekEnd 129
15752
-#define OP_IdxInsert 130 /* synopsis: key=r[P2] */
15753
-#define OP_SorterInsert 131 /* synopsis: key=r[P2] */
15754
-#define OP_IdxDelete 132 /* synopsis: key=r[P2@P3] */
15755
-#define OP_DeferredSeek 133 /* synopsis: Move P3 to P1.rowid if needed */
15756
-#define OP_IdxRowid 134 /* synopsis: r[P2]=rowid */
15757
-#define OP_FinishSeek 135
15758
-#define OP_Destroy 136
15759
-#define OP_Clear 137
15760
-#define OP_ResetSorter 138
15761
-#define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15762
-#define OP_SqlExec 140
15763
-#define OP_ParseSchema 141
15764
-#define OP_LoadAnalysis 142
15765
-#define OP_DropTable 143
15766
-#define OP_DropIndex 144
15767
-#define OP_DropTrigger 145
15768
-#define OP_IntegrityCk 146
15769
-#define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */
15770
-#define OP_Param 148
15771
-#define OP_FkCounter 149 /* synopsis: fkctr[P1]+=P2 */
15749
+#define OP_SeekScan 118 /* synopsis: Scan-ahead up to P1 rows */
15750
+#define OP_SeekHit 119 /* synopsis: set P2<=seekHit<=P3 */
15751
+#define OP_Sequence 120 /* synopsis: r[P2]=cursor[P1].ctr++ */
15752
+#define OP_NewRowid 121 /* synopsis: r[P2]=rowid */
15753
+#define OP_Insert 122 /* synopsis: intkey=r[P3] data=r[P2] */
15754
+#define OP_Delete 123
15755
+#define OP_ResetCount 124
15756
+#define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15757
+#define OP_SorterData 126 /* synopsis: r[P2]=data */
15758
+#define OP_RowData 127 /* synopsis: r[P2]=data */
15759
+#define OP_Rowid 128 /* synopsis: r[P2]=rowid */
15760
+#define OP_NullRow 129
15761
+#define OP_SeekEnd 130
15762
+#define OP_IdxInsert 131 /* synopsis: key=r[P2] */
15763
+#define OP_SorterInsert 132 /* synopsis: key=r[P2] */
15764
+#define OP_IdxDelete 133 /* synopsis: key=r[P2@P3] */
15765
+#define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */
15766
+#define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */
15767
+#define OP_FinishSeek 136
15768
+#define OP_Destroy 137
15769
+#define OP_Clear 138
15770
+#define OP_ResetSorter 139
15771
+#define OP_CreateBtree 140 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15772
+#define OP_SqlExec 141
15773
+#define OP_ParseSchema 142
15774
+#define OP_LoadAnalysis 143
15775
+#define OP_DropTable 144
15776
+#define OP_DropIndex 145
15777
+#define OP_DropTrigger 146
15778
+#define OP_IntegrityCk 147
15779
+#define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */
15780
+#define OP_Param 149
1577215781
#define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15773
-#define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15774
-#define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15775
-#define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15776
-#define OP_AggStep 154 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15777
-#define OP_AggStep1 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15778
-#define OP_AggValue 156 /* synopsis: r[P3]=value N=P2 */
15779
-#define OP_AggFinal 157 /* synopsis: accum=r[P1] N=P2 */
15780
-#define OP_Expire 158
15781
-#define OP_CursorLock 159
15782
-#define OP_CursorUnlock 160
15783
-#define OP_TableLock 161 /* synopsis: iDb=P1 root=P2 write=P3 */
15784
-#define OP_VBegin 162
15785
-#define OP_VCreate 163
15786
-#define OP_VDestroy 164
15787
-#define OP_VOpen 165
15788
-#define OP_VColumn 166 /* synopsis: r[P3]=vcolumn(P2) */
15789
-#define OP_VRename 167
15790
-#define OP_Pagecount 168
15791
-#define OP_MaxPgcnt 169
15792
-#define OP_Trace 170
15793
-#define OP_CursorHint 171
15794
-#define OP_ReleaseReg 172 /* synopsis: release r[P1@P2] mask P3 */
15795
-#define OP_Noop 173
15796
-#define OP_Explain 174
15797
-#define OP_Abortable 175
15782
+#define OP_FkCounter 151 /* synopsis: fkctr[P1]+=P2 */
15783
+#define OP_MemMax 152 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15784
+#define OP_OffsetLimit 153 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15785
+#define OP_AggInverse 154 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15786
+#define OP_AggStep 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15787
+#define OP_AggStep1 156 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15788
+#define OP_AggValue 157 /* synopsis: r[P3]=value N=P2 */
15789
+#define OP_AggFinal 158 /* synopsis: accum=r[P1] N=P2 */
15790
+#define OP_Expire 159
15791
+#define OP_CursorLock 160
15792
+#define OP_CursorUnlock 161
15793
+#define OP_TableLock 162 /* synopsis: iDb=P1 root=P2 write=P3 */
15794
+#define OP_VBegin 163
15795
+#define OP_VCreate 164
15796
+#define OP_VDestroy 165
15797
+#define OP_VOpen 166
15798
+#define OP_VColumn 167 /* synopsis: r[P3]=vcolumn(P2) */
15799
+#define OP_VRename 168
15800
+#define OP_Pagecount 169
15801
+#define OP_MaxPgcnt 170
15802
+#define OP_Trace 171
15803
+#define OP_CursorHint 172
15804
+#define OP_ReleaseReg 173 /* synopsis: release r[P1@P2] mask P3 */
15805
+#define OP_Noop 174
15806
+#define OP_Explain 175
15807
+#define OP_Abortable 176
1579815808
1579915809
/* Properties such as "out2" or "jump" that are specified in
1580015810
** comments following the "case" for each opcode in the vdbe.c
1580115811
** are encoded into bitvectors as follows:
1580215812
*/
@@ -15819,19 +15829,19 @@
1581915829
/* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\
1582015830
/* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12,\
1582115831
/* 88 */ 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
1582215832
/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\
1582315833
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
15824
-/* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,\
15825
-/* 120 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
15826
-/* 128 */ 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00,\
15827
-/* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15828
-/* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x10, 0x04,\
15829
-/* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15834
+/* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15835
+/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15836
+/* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15837
+/* 136 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
15838
+/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00,\
15839
+/* 152 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
1583015840
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15831
-/* 168 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15832
-}
15841
+/* 168 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15842
+/* 176 */ 0x00,}
1583315843
1583415844
/* The sqlite3P2Values() routine is able to run faster if it knows
1583515845
** the value of the largest JUMP opcode. The smaller the maximum
1583615846
** JUMP opcode the better, so the mkopcodeh.tcl script that
1583715847
** generated this include file strives to group all JUMP opcodes
@@ -33339,68 +33349,69 @@
3333933349
/* 113 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
3334033350
/* 114 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
3334133351
/* 115 */ "String8" OpHelp("r[P2]='P4'"),
3334233352
/* 116 */ "Close" OpHelp(""),
3334333353
/* 117 */ "ColumnsUsed" OpHelp(""),
33344
- /* 118 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
33345
- /* 119 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
33346
- /* 120 */ "NewRowid" OpHelp("r[P2]=rowid"),
33347
- /* 121 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
33348
- /* 122 */ "Delete" OpHelp(""),
33349
- /* 123 */ "ResetCount" OpHelp(""),
33350
- /* 124 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
33351
- /* 125 */ "SorterData" OpHelp("r[P2]=data"),
33352
- /* 126 */ "RowData" OpHelp("r[P2]=data"),
33353
- /* 127 */ "Rowid" OpHelp("r[P2]=rowid"),
33354
- /* 128 */ "NullRow" OpHelp(""),
33355
- /* 129 */ "SeekEnd" OpHelp(""),
33356
- /* 130 */ "IdxInsert" OpHelp("key=r[P2]"),
33357
- /* 131 */ "SorterInsert" OpHelp("key=r[P2]"),
33358
- /* 132 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
33359
- /* 133 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
33360
- /* 134 */ "IdxRowid" OpHelp("r[P2]=rowid"),
33361
- /* 135 */ "FinishSeek" OpHelp(""),
33362
- /* 136 */ "Destroy" OpHelp(""),
33363
- /* 137 */ "Clear" OpHelp(""),
33364
- /* 138 */ "ResetSorter" OpHelp(""),
33365
- /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
33366
- /* 140 */ "SqlExec" OpHelp(""),
33367
- /* 141 */ "ParseSchema" OpHelp(""),
33368
- /* 142 */ "LoadAnalysis" OpHelp(""),
33369
- /* 143 */ "DropTable" OpHelp(""),
33370
- /* 144 */ "DropIndex" OpHelp(""),
33371
- /* 145 */ "DropTrigger" OpHelp(""),
33372
- /* 146 */ "IntegrityCk" OpHelp(""),
33373
- /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
33374
- /* 148 */ "Param" OpHelp(""),
33375
- /* 149 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
33354
+ /* 118 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
33355
+ /* 119 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
33356
+ /* 120 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
33357
+ /* 121 */ "NewRowid" OpHelp("r[P2]=rowid"),
33358
+ /* 122 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
33359
+ /* 123 */ "Delete" OpHelp(""),
33360
+ /* 124 */ "ResetCount" OpHelp(""),
33361
+ /* 125 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
33362
+ /* 126 */ "SorterData" OpHelp("r[P2]=data"),
33363
+ /* 127 */ "RowData" OpHelp("r[P2]=data"),
33364
+ /* 128 */ "Rowid" OpHelp("r[P2]=rowid"),
33365
+ /* 129 */ "NullRow" OpHelp(""),
33366
+ /* 130 */ "SeekEnd" OpHelp(""),
33367
+ /* 131 */ "IdxInsert" OpHelp("key=r[P2]"),
33368
+ /* 132 */ "SorterInsert" OpHelp("key=r[P2]"),
33369
+ /* 133 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
33370
+ /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
33371
+ /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"),
33372
+ /* 136 */ "FinishSeek" OpHelp(""),
33373
+ /* 137 */ "Destroy" OpHelp(""),
33374
+ /* 138 */ "Clear" OpHelp(""),
33375
+ /* 139 */ "ResetSorter" OpHelp(""),
33376
+ /* 140 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
33377
+ /* 141 */ "SqlExec" OpHelp(""),
33378
+ /* 142 */ "ParseSchema" OpHelp(""),
33379
+ /* 143 */ "LoadAnalysis" OpHelp(""),
33380
+ /* 144 */ "DropTable" OpHelp(""),
33381
+ /* 145 */ "DropIndex" OpHelp(""),
33382
+ /* 146 */ "DropTrigger" OpHelp(""),
33383
+ /* 147 */ "IntegrityCk" OpHelp(""),
33384
+ /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
33385
+ /* 149 */ "Param" OpHelp(""),
3337633386
/* 150 */ "Real" OpHelp("r[P2]=P4"),
33377
- /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
33378
- /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
33379
- /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
33380
- /* 154 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
33381
- /* 155 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
33382
- /* 156 */ "AggValue" OpHelp("r[P3]=value N=P2"),
33383
- /* 157 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
33384
- /* 158 */ "Expire" OpHelp(""),
33385
- /* 159 */ "CursorLock" OpHelp(""),
33386
- /* 160 */ "CursorUnlock" OpHelp(""),
33387
- /* 161 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
33388
- /* 162 */ "VBegin" OpHelp(""),
33389
- /* 163 */ "VCreate" OpHelp(""),
33390
- /* 164 */ "VDestroy" OpHelp(""),
33391
- /* 165 */ "VOpen" OpHelp(""),
33392
- /* 166 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
33393
- /* 167 */ "VRename" OpHelp(""),
33394
- /* 168 */ "Pagecount" OpHelp(""),
33395
- /* 169 */ "MaxPgcnt" OpHelp(""),
33396
- /* 170 */ "Trace" OpHelp(""),
33397
- /* 171 */ "CursorHint" OpHelp(""),
33398
- /* 172 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
33399
- /* 173 */ "Noop" OpHelp(""),
33400
- /* 174 */ "Explain" OpHelp(""),
33401
- /* 175 */ "Abortable" OpHelp(""),
33387
+ /* 151 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
33388
+ /* 152 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
33389
+ /* 153 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
33390
+ /* 154 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
33391
+ /* 155 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
33392
+ /* 156 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
33393
+ /* 157 */ "AggValue" OpHelp("r[P3]=value N=P2"),
33394
+ /* 158 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
33395
+ /* 159 */ "Expire" OpHelp(""),
33396
+ /* 160 */ "CursorLock" OpHelp(""),
33397
+ /* 161 */ "CursorUnlock" OpHelp(""),
33398
+ /* 162 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
33399
+ /* 163 */ "VBegin" OpHelp(""),
33400
+ /* 164 */ "VCreate" OpHelp(""),
33401
+ /* 165 */ "VDestroy" OpHelp(""),
33402
+ /* 166 */ "VOpen" OpHelp(""),
33403
+ /* 167 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
33404
+ /* 168 */ "VRename" OpHelp(""),
33405
+ /* 169 */ "Pagecount" OpHelp(""),
33406
+ /* 170 */ "MaxPgcnt" OpHelp(""),
33407
+ /* 171 */ "Trace" OpHelp(""),
33408
+ /* 172 */ "CursorHint" OpHelp(""),
33409
+ /* 173 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
33410
+ /* 174 */ "Noop" OpHelp(""),
33411
+ /* 175 */ "Explain" OpHelp(""),
33412
+ /* 176 */ "Abortable" OpHelp(""),
3340233413
};
3340333414
return azName[i];
3340433415
}
3340533416
#endif
3340633417
@@ -70343,11 +70354,11 @@
7034370354
}
7034470355
}
7034570356
7034670357
pPage = pCur->pPage;
7034770358
idx = ++pCur->ix;
70348
- if( !pPage->isInit ){
70359
+ if( !pPage->isInit || sqlite3FaultSim(412) ){
7034970360
/* The only known way for this to happen is for there to be a
7035070361
** recursive SQL function that does a DELETE operation as part of a
7035170362
** SELECT which deletes content out from under an active cursor
7035270363
** in a corrupt database file where the table being DELETE-ed from
7035370364
** has pages in common with the table being queried. See TH3
@@ -89829,10 +89840,147 @@
8982989840
assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
8983089841
pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
8983189842
}
8983289843
break;
8983389844
}
89845
+
89846
+
89847
+/* Opcode: SeekScan P1 * * * *
89848
+** Synopsis: Scan-ahead up to P1 rows
89849
+**
89850
+** This opcode is a prefix opcode to OP_SeekGE. In other words, this
89851
+** opcode must be immediately followed by OP_SeekGE. Furthermore, the
89852
+** OP_SeekGE must be followed by OP_IdxGT. These constraints are
89853
+** checked by assert() statements.
89854
+**
89855
+** This opcode uses the P1 through P4 operands of the subsequent
89856
+** OP_SeekGE. In the text that follows, the operands of the subsequent
89857
+** OP_SeekGE opcode are denoted as SeekOP.P1 through SeekOP.P4. Only
89858
+** the P1 operand of this opcode is used, and it is denoted as This.P1.
89859
+**
89860
+** This opcode helps to optimize IN operators on a multi-column index
89861
+** where the IN operator is on the later terms of the index by avoiding
89862
+** unnecessary seeks on the btree, substituting steps to the next row
89863
+** of the b-tree instead. A correct answer is obtained if this opcode
89864
+** is omitted or is a no-op.
89865
+**
89866
+** The SeekGE.P3 and SeekGE.P4 operands identify an unpacked key which
89867
+** is the desired entry that we want the cursor SeekGE.P1 to be pointing
89868
+** to. Call this SeekGE.P4/P5 row the "target".
89869
+**
89870
+** If the SeekGE.P1 cursor is not currently pointing to a valid row,
89871
+** then this opcode is a no-op and control passes through into the OP_SeekGE.
89872
+**
89873
+** If the SeekGE.P1 cursor is pointing to a valid row, then that row
89874
+** might be the target row, or it might be near and slightly before the
89875
+** target row. This opcode attempts to position the cursor on the target
89876
+** row by, perhaps stepping by invoking sqlite3BtreeStep() on the cursor
89877
+** between 0 and This.P1 times.
89878
+**
89879
+** There are three possible outcomes from this opcode:<ol>
89880
+**
89881
+** <li> If after This.P1 steps, the cursor is still point to a place that
89882
+** is earlier in the btree than the target row,
89883
+** then fall through into the subsquence OP_SeekGE opcode.
89884
+**
89885
+** <li> If the cursor is successfully moved to the target row by 0 or more
89886
+** sqlite3BtreeNext() calls, then jump to the first instruction after the
89887
+** OP_IdxGT opcode - or in other words, skip the next two opcodes.
89888
+**
89889
+** <li> If the cursor ends up past the target row (indicating the the target
89890
+** row does not exist in the btree) then jump to SeekOP.P2.
89891
+** </ol>
89892
+*/
89893
+case OP_SeekScan: {
89894
+ VdbeCursor *pC;
89895
+ int res;
89896
+ int n;
89897
+ UnpackedRecord r;
89898
+
89899
+ assert( pOp[1].opcode==OP_SeekGE );
89900
+ assert( pOp[2].opcode==OP_IdxGT );
89901
+ assert( pOp[1].p1==pOp[2].p1 );
89902
+ assert( pOp[1].p2==pOp[2].p2 );
89903
+ assert( pOp[1].p3==pOp[2].p3 );
89904
+ assert( pOp[1].p4.i==pOp[2].p4.i );
89905
+ assert( pOp->p1>0 );
89906
+ pC = p->apCsr[pOp[1].p1];
89907
+ assert( pC!=0 );
89908
+ assert( pC->eCurType==CURTYPE_BTREE );
89909
+ assert( !pC->isTable );
89910
+ if( !sqlite3BtreeCursorIsValidNN(pC->uc.pCursor) ){
89911
+#ifdef SQLITE_DEBUG
89912
+ if( db->flags&SQLITE_VdbeTrace ){
89913
+ printf("... cursor not valid - fall through\n");
89914
+ }
89915
+#endif
89916
+ break;
89917
+ }
89918
+ n = pOp->p1;
89919
+ assert( n>=1 );
89920
+ r.pKeyInfo = pC->pKeyInfo;
89921
+ r.nField = (u16)pOp[1].p4.i;
89922
+ r.default_rc = 0;
89923
+ r.aMem = &aMem[pOp[1].p3];
89924
+#ifdef SQLITE_DEBUG
89925
+ {
89926
+ int i;
89927
+ for(i=0; i<r.nField; i++){
89928
+ assert( memIsValid(&r.aMem[i]) );
89929
+ REGISTER_TRACE(pOp[1].p3+i, &aMem[pOp[1].p3+i]);
89930
+ }
89931
+ }
89932
+#endif
89933
+ res = 0; /* Not needed. Only used to silence a warning. */
89934
+ while(1){
89935
+ rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
89936
+ if( rc ) goto abort_due_to_error;
89937
+ if( res>0 ){
89938
+ seekscan_search_fail:
89939
+#ifdef SQLITE_DEBUG
89940
+ if( db->flags&SQLITE_VdbeTrace ){
89941
+ printf("... %d steps and then skip\n", pOp->p1 - n);
89942
+ }
89943
+#endif
89944
+ VdbeBranchTaken(1,3);
89945
+ pOp++;
89946
+ goto jump_to_p2;
89947
+ }
89948
+ if( res==0 ){
89949
+#ifdef SQLITE_DEBUG
89950
+ if( db->flags&SQLITE_VdbeTrace ){
89951
+ printf("... %d steps and then success\n", pOp->p1 - n);
89952
+ }
89953
+#endif
89954
+ VdbeBranchTaken(2,3);
89955
+ pOp += 2;
89956
+ break;
89957
+ }
89958
+ if( n<=0 ){
89959
+#ifdef SQLITE_DEBUG
89960
+ if( db->flags&SQLITE_VdbeTrace ){
89961
+ printf("... fall through after %d steps\n", pOp->p1);
89962
+ }
89963
+#endif
89964
+ VdbeBranchTaken(0,3);
89965
+ break;
89966
+ }
89967
+ n--;
89968
+ rc = sqlite3BtreeNext(pC->uc.pCursor, 0);
89969
+ if( rc ){
89970
+ if( rc==SQLITE_DONE ){
89971
+ rc = SQLITE_OK;
89972
+ goto seekscan_search_fail;
89973
+ }else{
89974
+ goto abort_due_to_error;
89975
+ }
89976
+ }
89977
+ }
89978
+
89979
+ break;
89980
+}
89981
+
8983489982
8983589983
/* Opcode: SeekHit P1 P2 P3 * *
8983689984
** Synopsis: set P2<=seekHit<=P3
8983789985
**
8983889986
** Increase or decrease the seekHit value for cursor P1, if necessary,
@@ -91361,22 +91509,45 @@
9136191509
assert( memIsValid(&r.aMem[i]) );
9136291510
REGISTER_TRACE(pOp->p3+i, &aMem[pOp->p3+i]);
9136391511
}
9136491512
}
9136591513
#endif
91366
- res = 0; /* Not needed. Only used to silence a warning. */
91367
- rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
91514
+
91515
+ /* Inlined version of sqlite3VdbeIdxKeyCompare() */
91516
+ {
91517
+ i64 nCellKey = 0;
91518
+ BtCursor *pCur;
91519
+ Mem m;
91520
+
91521
+ assert( pC->eCurType==CURTYPE_BTREE );
91522
+ pCur = pC->uc.pCursor;
91523
+ assert( sqlite3BtreeCursorIsValid(pCur) );
91524
+ nCellKey = sqlite3BtreePayloadSize(pCur);
91525
+ /* nCellKey will always be between 0 and 0xffffffff because of the way
91526
+ ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
91527
+ if( nCellKey<=0 || nCellKey>0x7fffffff ){
91528
+ rc = SQLITE_CORRUPT_BKPT;
91529
+ goto abort_due_to_error;
91530
+ }
91531
+ sqlite3VdbeMemInit(&m, db, 0);
91532
+ rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
91533
+ if( rc ) goto abort_due_to_error;
91534
+ res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0);
91535
+ sqlite3VdbeMemRelease(&m);
91536
+ }
91537
+ /* End of inlined sqlite3VdbeIdxKeyCompare() */
91538
+
9136891539
assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
9136991540
if( (pOp->opcode&1)==(OP_IdxLT&1) ){
9137091541
assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );
9137191542
res = -res;
9137291543
}else{
9137391544
assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );
9137491545
res++;
9137591546
}
9137691547
VdbeBranchTaken(res>0,2);
91377
- if( rc ) goto abort_due_to_error;
91548
+ assert( rc==SQLITE_OK );
9137891549
if( res>0 ) goto jump_to_p2;
9137991550
break;
9138091551
}
9138191552
9138291553
/* Opcode: Destroy P1 P2 P3 * *
@@ -132969,12 +133140,11 @@
132969133140
pNew = sqlite3ExprDup(db, pCopy, 0);
132970133141
if( pNew && pSubst->isLeftJoin ){
132971133142
ExprSetProperty(pNew, EP_CanBeNull);
132972133143
}
132973133144
if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
132974
- pNew->iRightJoinTable = pExpr->iRightJoinTable;
132975
- ExprSetProperty(pNew, EP_FromJoin);
133145
+ sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
132976133146
}
132977133147
sqlite3ExprDelete(db, pExpr);
132978133148
pExpr = pNew;
132979133149
132980133150
/* Ensure that the expression now has an implicit collation sequence,
@@ -141334,13 +141504,15 @@
141334141504
u16 eOperator; /* A WO_xx value describing <op> */
141335141505
u8 nChild; /* Number of children that must disable us */
141336141506
u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */
141337141507
int iParent; /* Disable pWC->a[iParent] when this term disabled */
141338141508
int leftCursor; /* Cursor number of X in "X <op> <expr>" */
141339
- int iField; /* Field in (?,?,?) IN (SELECT...) vector */
141340141509
union {
141341
- int leftColumn; /* Column number of X in "X <op> <expr>" */
141510
+ struct {
141511
+ int leftColumn; /* Column number of X in "X <op> <expr>" */
141512
+ int iField; /* Field in (?,?,?) IN (SELECT...) vector */
141513
+ } x; /* Opcode other than OP_OR or OP_AND */
141342141514
WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
141343141515
WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
141344141516
} u;
141345141517
Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
141346141518
Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
@@ -141690,10 +141862,11 @@
141690141862
#define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
141691141863
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
141692141864
#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
141693141865
#define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
141694141866
#define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
141867
+#define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
141695141868
141696141869
#endif /* !defined(SQLITE_WHEREINT_H) */
141697141870
141698141871
/************** End of whereInt.h ********************************************/
141699141872
/************** Continuing where we left off in wherecode.c ******************/
@@ -142103,11 +142276,11 @@
142103142276
int i; /* Loop counter */
142104142277
Select *pSelect; /* Pointer to the SELECT on the RHS */
142105142278
142106142279
for(i=iEq; i<pLoop->nLTerm; i++){
142107142280
if( pLoop->aLTerm[i]->pExpr==pX ){
142108
- int iField = pLoop->aLTerm[i]->iField - 1;
142281
+ int iField = pLoop->aLTerm[i]->u.x.iField - 1;
142109142282
if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */
142110142283
pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
142111142284
pOrigRhs->a[iField].pExpr = 0;
142112142285
assert( pOrigLhs->a[iField].pExpr!=0 );
142113142286
pLhs = sqlite3ExprListAppend(pParse, pLhs, pOrigLhs->a[iField].pExpr);
@@ -142246,11 +142419,11 @@
142246142419
142247142420
pLoop->wsFlags |= WHERE_IN_ABLE;
142248142421
if( pLevel->u.in.nIn==0 ){
142249142422
pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
142250142423
}
142251
- if( iEq>0 ){
142424
+ if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){
142252142425
pLoop->wsFlags |= WHERE_IN_EARLYOUT;
142253142426
}
142254142427
142255142428
i = pLevel->u.in.nIn;
142256142429
pLevel->u.in.nIn += nEq;
@@ -142284,11 +142457,11 @@
142284142457
pIn->eEndLoopOp = OP_Noop;
142285142458
}
142286142459
pIn++;
142287142460
}
142288142461
}
142289
- if( iEq>0 ){
142462
+ if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){
142290142463
sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq);
142291142464
}
142292142465
}else{
142293142466
pLevel->u.in.nIn = 0;
142294142467
}
@@ -143439,12 +143612,11 @@
143439143612
nConstraint = nEq;
143440143613
if( pRangeStart ){
143441143614
Expr *pRight = pRangeStart->pExpr->pRight;
143442143615
codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);
143443143616
whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
143444
- if( !bRev
143445
- && (pRangeStart->wtFlags & TERM_VNULL)==0
143617
+ if( (pRangeStart->wtFlags & TERM_VNULL)==0
143446143618
&& sqlite3ExprCanBeNull(pRight)
143447143619
){
143448143620
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
143449143621
VdbeCoverage(v);
143450143622
}
@@ -143480,10 +143652,24 @@
143480143652
VdbeComment((v, "NULL-scan pass ctr"));
143481143653
}
143482143654
143483143655
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
143484143656
assert( op!=0 );
143657
+ if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 ){
143658
+ assert( op==OP_SeekGE );
143659
+ assert( regBignull==0 );
143660
+ /* TUNING: The OP_SeekScan opcode seeks to reduce the number
143661
+ ** of expensive seek operations by replacing a single seek with
143662
+ ** 1 or more step operations. The question is, how many steps
143663
+ ** should we try before giving up and going with a seek. The cost
143664
+ ** of a seek is proportional to the logarithm of the of the number
143665
+ ** of entries in the tree, so basing the number of steps to try
143666
+ ** on the estimated number of rows in the btree seems like a good
143667
+ ** guess. */
143668
+ sqlite3VdbeAddOp1(v, OP_SeekScan, (pIdx->aiRowLogEst[0]+9)/10);
143669
+ VdbeCoverage(v);
143670
+ }
143485143671
sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
143486143672
VdbeCoverage(v);
143487143673
VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
143488143674
VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
143489143675
VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT );
@@ -143515,12 +143701,11 @@
143515143701
nConstraint = nEq;
143516143702
if( pRangeEnd ){
143517143703
Expr *pRight = pRangeEnd->pExpr->pRight;
143518143704
codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
143519143705
whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
143520
- if( bRev
143521
- && (pRangeEnd->wtFlags & TERM_VNULL)==0
143706
+ if( (pRangeEnd->wtFlags & TERM_VNULL)==0
143522143707
&& sqlite3ExprCanBeNull(pRight)
143523143708
){
143524143709
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
143525143710
VdbeCoverage(v);
143526143711
}
@@ -143582,11 +143767,11 @@
143582143767
testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
143583143768
testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
143584143769
testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
143585143770
}
143586143771
143587
- if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
143772
+ if( (pLoop->wsFlags & WHERE_IN_EARLYOUT)!=0 ){
143588143773
sqlite3VdbeAddOp3(v, OP_SeekHit, iIdxCur, nEq, nEq);
143589143774
}
143590143775
143591143776
/* Seek the table cursor, if required */
143592143777
omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
@@ -144090,11 +144275,11 @@
144090144275
sqlite3WhereTermPrint(pTerm, pWC->nTerm-j);
144091144276
}
144092144277
#endif
144093144278
assert( !ExprHasProperty(pE, EP_FromJoin) );
144094144279
assert( (pTerm->prereqRight & pLevel->notReady)!=0 );
144095
- pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady,
144280
+ pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.x.leftColumn, notReady,
144096144281
WO_EQ|WO_IN|WO_IS, 0);
144097144282
if( pAlt==0 ) continue;
144098144283
if( pAlt->wtFlags & (TERM_CODED) ) continue;
144099144284
if( (pAlt->eOperator & WO_IN)
144100144285
&& (pAlt->pExpr->flags & EP_xIsSelect)
@@ -144946,11 +145131,11 @@
144946145131
testcase( pOrTerm->wtFlags & TERM_COPIED );
144947145132
testcase( pOrTerm->wtFlags & TERM_VIRTUAL );
144948145133
assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );
144949145134
continue;
144950145135
}
144951
- iColumn = pOrTerm->u.leftColumn;
145136
+ iColumn = pOrTerm->u.x.leftColumn;
144952145137
iCursor = pOrTerm->leftCursor;
144953145138
pLeft = pOrTerm->pExpr->pLeft;
144954145139
break;
144955145140
}
144956145141
if( i<0 ){
@@ -144968,11 +145153,11 @@
144968145153
okToChngToIN = 1;
144969145154
for(; i>=0 && okToChngToIN; i--, pOrTerm++){
144970145155
assert( pOrTerm->eOperator & WO_EQ );
144971145156
if( pOrTerm->leftCursor!=iCursor ){
144972145157
pOrTerm->wtFlags &= ~TERM_OR_OK;
144973
- }else if( pOrTerm->u.leftColumn!=iColumn || (iColumn==XN_EXPR
145158
+ }else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR
144974145159
&& sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
144975145160
)){
144976145161
okToChngToIN = 0;
144977145162
}else{
144978145163
int affLeft, affRight;
@@ -145003,11 +145188,11 @@
145003145188
145004145189
for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
145005145190
if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
145006145191
assert( pOrTerm->eOperator & WO_EQ );
145007145192
assert( pOrTerm->leftCursor==iCursor );
145008
- assert( pOrTerm->u.leftColumn==iColumn );
145193
+ assert( pOrTerm->u.x.leftColumn==iColumn );
145009145194
pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);
145010145195
pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup);
145011145196
pLeft = pOrTerm->pExpr->pLeft;
145012145197
}
145013145198
assert( pLeft!=0 );
@@ -145239,29 +145424,29 @@
145239145424
int aiCurCol[2];
145240145425
Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);
145241145426
Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
145242145427
u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;
145243145428
145244
- if( pTerm->iField>0 ){
145429
+ if( pTerm->u.x.iField>0 ){
145245145430
assert( op==TK_IN );
145246145431
assert( pLeft->op==TK_VECTOR );
145247
- pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;
145432
+ pLeft = pLeft->x.pList->a[pTerm->u.x.iField-1].pExpr;
145248145433
}
145249145434
145250145435
if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){
145251145436
pTerm->leftCursor = aiCurCol[0];
145252
- pTerm->u.leftColumn = aiCurCol[1];
145437
+ pTerm->u.x.leftColumn = aiCurCol[1];
145253145438
pTerm->eOperator = operatorMask(op) & opMask;
145254145439
}
145255145440
if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
145256145441
if( pRight
145257145442
&& exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)
145258145443
){
145259145444
WhereTerm *pNew;
145260145445
Expr *pDup;
145261145446
u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
145262
- assert( pTerm->iField==0 );
145447
+ assert( pTerm->u.x.iField==0 );
145263145448
if( pTerm->leftCursor>=0 ){
145264145449
int idxNew;
145265145450
pDup = sqlite3ExprDup(db, pExpr, 0);
145266145451
if( db->mallocFailed ){
145267145452
sqlite3ExprDelete(db, pDup);
@@ -145283,11 +145468,11 @@
145283145468
pDup = pExpr;
145284145469
pNew = pTerm;
145285145470
}
145286145471
pNew->wtFlags |= exprCommute(pParse, pDup);
145287145472
pNew->leftCursor = aiCurCol[0];
145288
- pNew->u.leftColumn = aiCurCol[1];
145473
+ pNew->u.x.leftColumn = aiCurCol[1];
145289145474
testcase( (prereqLeft | extraRight) != prereqLeft );
145290145475
pNew->prereqRight = prereqLeft | extraRight;
145291145476
pNew->prereqAll = prereqAll;
145292145477
pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;
145293145478
}
@@ -145457,11 +145642,11 @@
145457145642
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
145458145643
testcase( idxNew==0 );
145459145644
pNewTerm = &pWC->a[idxNew];
145460145645
pNewTerm->prereqRight = prereqExpr;
145461145646
pNewTerm->leftCursor = pLeft->iTable;
145462
- pNewTerm->u.leftColumn = pLeft->iColumn;
145647
+ pNewTerm->u.x.leftColumn = pLeft->iColumn;
145463145648
pNewTerm->eOperator = WO_AUX;
145464145649
pNewTerm->eMatchOp = eOp2;
145465145650
markTermAsChild(pWC, idxNew, idxTerm);
145466145651
pTerm = &pWC->a[idxTerm];
145467145652
pTerm->wtFlags |= TERM_COPIED;
@@ -145504,17 +145689,17 @@
145504145689
}
145505145690
145506145691
/* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
145507145692
** a virtual term for each vector component. The expression object
145508145693
** used by each such virtual term is pExpr (the full vector IN(...)
145509
- ** expression). The WhereTerm.iField variable identifies the index within
145694
+ ** expression). The WhereTerm.u.x.iField variable identifies the index within
145510145695
** the vector on the LHS that the virtual term represents.
145511145696
**
145512145697
** This only works if the RHS is a simple SELECT (not a compound) that does
145513145698
** not use window functions.
145514145699
*/
145515
- if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
145700
+ if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->u.x.iField==0
145516145701
&& pExpr->pLeft->op==TK_VECTOR
145517145702
&& pExpr->x.pSelect->pPrior==0
145518145703
#ifndef SQLITE_OMIT_WINDOWFUNC
145519145704
&& pExpr->x.pSelect->pWin==0
145520145705
#endif
@@ -145521,11 +145706,11 @@
145521145706
){
145522145707
int i;
145523145708
for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
145524145709
int idxNew;
145525145710
idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
145526
- pWC->a[idxNew].iField = i+1;
145711
+ pWC->a[idxNew].u.x.iField = i+1;
145527145712
exprAnalyze(pSrc, pWC, idxNew);
145528145713
markTermAsChild(pWC, idxNew, idxTerm);
145529145714
}
145530145715
}
145531145716
@@ -145556,11 +145741,11 @@
145556145741
TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);
145557145742
if( idxNew ){
145558145743
pNewTerm = &pWC->a[idxNew];
145559145744
pNewTerm->prereqRight = 0;
145560145745
pNewTerm->leftCursor = pLeft->iTable;
145561
- pNewTerm->u.leftColumn = pLeft->iColumn;
145746
+ pNewTerm->u.x.leftColumn = pLeft->iColumn;
145562145747
pNewTerm->eOperator = WO_GT;
145563145748
markTermAsChild(pWC, idxNew, idxTerm);
145564145749
pTerm = &pWC->a[idxTerm];
145565145750
pTerm->wtFlags |= TERM_COPIED;
145566145751
pNewTerm->prereqAll = pTerm->prereqAll;
@@ -146020,11 +146205,11 @@
146020146205
iCur = pScan->aiCur[pScan->iEquiv-1];
146021146206
assert( pWC!=0 );
146022146207
do{
146023146208
for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
146024146209
if( pTerm->leftCursor==iCur
146025
- && pTerm->u.leftColumn==iColumn
146210
+ && pTerm->u.x.leftColumn==iColumn
146026146211
&& (iColumn!=XN_EXPR
146027146212
|| sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
146028146213
pScan->pIdxExpr,iCur)==0)
146029146214
&& (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
146030146215
){
@@ -146442,12 +146627,12 @@
146442146627
** the RHS of a LEFT JOIN. Such a term can only be used if it is from
146443146628
** the ON clause. */
146444146629
return 0;
146445146630
}
146446146631
if( (pTerm->prereqRight & notReady)!=0 ) return 0;
146447
- if( pTerm->u.leftColumn<0 ) return 0;
146448
- aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;
146632
+ if( pTerm->u.x.leftColumn<0 ) return 0;
146633
+ aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity;
146449146634
if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
146450146635
testcase( pTerm->pExpr->op==TK_IS );
146451146636
return 1;
146452146637
}
146453146638
#endif
@@ -146514,11 +146699,11 @@
146514146699
&& sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
146515146700
pPartial = sqlite3ExprAnd(pParse, pPartial,
146516146701
sqlite3ExprDup(pParse->db, pExpr, 0));
146517146702
}
146518146703
if( termCanDriveIndex(pTerm, pSrc, notReady) ){
146519
- int iCol = pTerm->u.leftColumn;
146704
+ int iCol = pTerm->u.x.leftColumn;
146520146705
Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
146521146706
testcase( iCol==BMS );
146522146707
testcase( iCol==BMS-1 );
146523146708
if( !sentWarning ){
146524146709
sqlite3_log(SQLITE_WARNING_AUTOINDEX,
@@ -146567,18 +146752,18 @@
146567146752
pIdx->pTable = pTable;
146568146753
n = 0;
146569146754
idxCols = 0;
146570146755
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
146571146756
if( termCanDriveIndex(pTerm, pSrc, notReady) ){
146572
- int iCol = pTerm->u.leftColumn;
146757
+ int iCol = pTerm->u.x.leftColumn;
146573146758
Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
146574146759
testcase( iCol==BMS-1 );
146575146760
testcase( iCol==BMS );
146576146761
if( (idxCols & cMask)==0 ){
146577146762
Expr *pX = pTerm->pExpr;
146578146763
idxCols |= cMask;
146579
- pIdx->aiColumn[n] = pTerm->u.leftColumn;
146764
+ pIdx->aiColumn[n] = pTerm->u.x.leftColumn;
146580146765
pColl = sqlite3ExprCompareCollSeq(pParse, pX);
146581146766
assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */
146582146767
pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
146583146768
n++;
146584146769
}
@@ -146695,11 +146880,11 @@
146695146880
testcase( pTerm->eOperator & WO_ISNULL );
146696146881
testcase( pTerm->eOperator & WO_IS );
146697146882
testcase( pTerm->eOperator & WO_ALL );
146698146883
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
146699146884
if( pTerm->wtFlags & TERM_VNULL ) continue;
146700
- assert( pTerm->u.leftColumn>=(-1) );
146885
+ assert( pTerm->u.x.leftColumn>=(-1) );
146701146886
nTerm++;
146702146887
}
146703146888
146704146889
/* If the ORDER BY clause contains only columns in the current
146705146890
** virtual table then allocate space for the aOrderBy part of
@@ -146755,12 +146940,12 @@
146755146940
if( (pSrc->fg.jointype & JT_LEFT)!=0
146756146941
&& !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
146757146942
){
146758146943
continue;
146759146944
}
146760
- assert( pTerm->u.leftColumn>=(-1) );
146761
- pIdxCons[j].iColumn = pTerm->u.leftColumn;
146945
+ assert( pTerm->u.x.leftColumn>=(-1) );
146946
+ pIdxCons[j].iColumn = pTerm->u.x.leftColumn;
146762146947
pIdxCons[j].iTermOffset = i;
146763146948
op = pTerm->eOperator & WO_ALL;
146764146949
if( op==WO_IN ) op = WO_EQ;
146765146950
if( op==WO_AUX ){
146766146951
pIdxCons[j].op = pTerm->eMatchOp;
@@ -147519,11 +147704,11 @@
147519147704
if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
147520147705
if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
147521147706
if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C';
147522147707
if( pTerm->eOperator & WO_SINGLE ){
147523147708
sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
147524
- pTerm->leftCursor, pTerm->u.leftColumn);
147709
+ pTerm->leftCursor, pTerm->u.x.leftColumn);
147525147710
}else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
147526147711
sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
147527147712
pTerm->u.pOrInfo->indexable);
147528147713
}else{
147529147714
sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
@@ -147535,12 +147720,12 @@
147535147720
** shown about each Term */
147536147721
if( sqlite3WhereTrace & 0x10000 ){
147537147722
sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx",
147538147723
pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight);
147539147724
}
147540
- if( pTerm->iField ){
147541
- sqlite3DebugPrintf(" iField=%d", pTerm->iField);
147725
+ if( pTerm->u.x.iField ){
147726
+ sqlite3DebugPrintf(" iField=%d", pTerm->u.x.iField);
147542147727
}
147543147728
if( pTerm->iParent>=0 ){
147544147729
sqlite3DebugPrintf(" iParent=%d", pTerm->iParent);
147545147730
}
147546147731
sqlite3DebugPrintf("\n");
@@ -148327,11 +148512,11 @@
148327148512
safetyMargin = 10; /* TUNING: extra weight for indexed IN */
148328148513
if( M + logK + safetyMargin < nIn + rLogSize ){
148329148514
WHERETRACE(0x40,
148330148515
("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
148331148516
saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
148332
- continue;
148517
+ pNew->wsFlags |= WHERE_IN_SEEKSCAN;
148333148518
}else{
148334148519
WHERETRACE(0x40,
148335148520
("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
148336148521
saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
148337148522
}
@@ -150960,10 +151145,11 @@
150960151145
sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
150961151146
sqlite3VdbeSetP4KeyInfo(pParse, pIx);
150962151147
if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
150963151148
&& (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
150964151149
&& (pLoop->wsFlags & WHERE_BIGNULL_SORT)==0
151150
+ && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0
150965151151
&& (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
150966151152
&& pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED
150967151153
){
150968151154
sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ);
150969151155
}
@@ -151122,11 +151308,13 @@
151122151308
sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
151123151309
for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
151124151310
sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
151125151311
if( pIn->eEndLoopOp!=OP_Noop ){
151126151312
if( pIn->nPrefix ){
151127
- assert( pLoop->wsFlags & WHERE_IN_EARLYOUT );
151313
+ int bEarlyOut =
151314
+ (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
151315
+ && (pLoop->wsFlags & WHERE_IN_EARLYOUT)!=0;
151128151316
if( pLevel->iLeftJoin ){
151129151317
/* For LEFT JOIN queries, cursor pIn->iCur may not have been
151130151318
** opened yet. This occurs for WHERE clauses such as
151131151319
** "a = ? AND b IN (...)", where the index is on (a, b). If
151132151320
** the RHS of the (a=?) is NULL, then the "b IN (...)" may
@@ -151133,16 +151321,14 @@
151133151321
** never have been coded, but the body of the loop run to
151134151322
** return the null-row. So, if the cursor is not open yet,
151135151323
** jump over the OP_Next or OP_Prev instruction about to
151136151324
** be coded. */
151137151325
sqlite3VdbeAddOp2(v, OP_IfNotOpen, pIn->iCur,
151138
- sqlite3VdbeCurrentAddr(v) + 2 +
151139
- ((pLoop->wsFlags & WHERE_VIRTUALTABLE)==0)
151140
- );
151326
+ sqlite3VdbeCurrentAddr(v) + 2 + bEarlyOut);
151141151327
VdbeCoverage(v);
151142151328
}
151143
- if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
151329
+ if( bEarlyOut ){
151144151330
sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
151145151331
sqlite3VdbeCurrentAddr(v)+2,
151146151332
pIn->iBase, pIn->nPrefix);
151147151333
VdbeCoverage(v);
151148151334
}
@@ -157827,12 +158013,13 @@
157827158013
int yysize; /* Amount to pop the stack */
157828158014
sqlite3ParserARG_FETCH
157829158015
(void)yyLookahead;
157830158016
(void)yyLookaheadToken;
157831158017
yymsp = yypParser->yytos;
158018
+ assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
157832158019
#ifndef NDEBUG
157833
- if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
158020
+ if( yyTraceFILE ){
157834158021
yysize = yyRuleInfoNRhs[yyruleno];
157835158022
if( yysize ){
157836158023
fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
157837158024
yyTracePrompt,
157838158025
yyruleno, yyRuleName[yyruleno],
@@ -209390,11 +209577,11 @@
209390209577
static int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int);
209391209578
209392209579
/*
209393209580
** Functions called by the storage module as part of integrity-check.
209394209581
*/
209395
-static int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum);
209582
+static int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum, int bUseCksum);
209396209583
209397209584
/*
209398209585
** Called during virtual module initialization to register UDF
209399209586
** fts5_decode() with SQLite
209400209587
*/
@@ -209545,11 +209732,11 @@
209545209732
209546209733
static int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**);
209547209734
static int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);
209548209735
static int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);
209549209736
209550
-static int sqlite3Fts5StorageIntegrity(Fts5Storage *p);
209737
+static int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg);
209551209738
209552209739
static int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);
209553209740
static void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*);
209554209741
209555209742
static int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol);
@@ -210735,12 +210922,13 @@
210735210922
int fts5yysize; /* Amount to pop the stack */
210736210923
sqlite3Fts5ParserARG_FETCH
210737210924
(void)fts5yyLookahead;
210738210925
(void)fts5yyLookaheadToken;
210739210926
fts5yymsp = fts5yypParser->fts5yytos;
210927
+ assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) );
210740210928
#ifndef NDEBUG
210741
- if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
210929
+ if( fts5yyTraceFILE ){
210742210930
fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
210743210931
if( fts5yysize ){
210744210932
fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
210745210933
fts5yyTracePrompt,
210746210934
fts5yyruleno, fts5yyRuleName[fts5yyruleno],
@@ -222842,11 +223030,11 @@
222842223030
** Return SQLITE_CORRUPT if any of the internal checks fail, or if the
222843223031
** checksum does not match. Return SQLITE_OK if all checks pass without
222844223032
** error, or some other SQLite error code if another error (e.g. OOM)
222845223033
** occurs.
222846223034
*/
222847
-static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){
223035
+static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum){
222848223036
int eDetail = p->pConfig->eDetail;
222849223037
u64 cksum2 = 0; /* Checksum based on contents of indexes */
222850223038
Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */
222851223039
Fts5Iter *pIter; /* Used to iterate through entire index */
222852223040
Fts5Structure *pStruct; /* Index structure */
@@ -222913,11 +223101,11 @@
222913223101
}
222914223102
}
222915223103
fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);
222916223104
222917223105
fts5MultiIterFree(pIter);
222918
- if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
223106
+ if( p->rc==SQLITE_OK && bUseCksum && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
222919223107
222920223108
fts5StructureRelease(pStruct);
222921223109
#ifdef SQLITE_DEBUG
222922223110
fts5BufferFree(&term);
222923223111
#endif
@@ -224921,11 +225109,12 @@
224921225109
rc = sqlite3Fts5StorageOptimize(pTab->pStorage);
224922225110
}else if( 0==sqlite3_stricmp("merge", zCmd) ){
224923225111
int nMerge = sqlite3_value_int(pVal);
224924225112
rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge);
224925225113
}else if( 0==sqlite3_stricmp("integrity-check", zCmd) ){
224926
- rc = sqlite3Fts5StorageIntegrity(pTab->pStorage);
225114
+ int iArg = sqlite3_value_int(pVal);
225115
+ rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, iArg);
224927225116
#ifdef SQLITE_DEBUG
224928225117
}else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){
224929225118
pConfig->bPrefixIndex = sqlite3_value_int(pVal);
224930225119
#endif
224931225120
}else{
@@ -226155,11 +226344,11 @@
226155226344
int nArg, /* Number of args */
226156226345
sqlite3_value **apUnused /* Function arguments */
226157226346
){
226158226347
assert( nArg==0 );
226159226348
UNUSED_PARAM2(nArg, apUnused);
226160
- sqlite3_result_text(pCtx, "fts5: 2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8afa3", -1, SQLITE_TRANSIENT);
226349
+ sqlite3_result_text(pCtx, "fts5: 2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c402e5", -1, SQLITE_TRANSIENT);
226161226350
}
226162226351
226163226352
/*
226164226353
** Return true if zName is the extension on one of the shadow tables used
226165226354
** by this module.
@@ -227170,102 +227359,108 @@
227170227359
** Check that the contents of the FTS index match that of the %_content
227171227360
** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return
227172227361
** some other SQLite error code if an error occurs while attempting to
227173227362
** determine this.
227174227363
*/
227175
-static int sqlite3Fts5StorageIntegrity(Fts5Storage *p){
227364
+static int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg){
227176227365
Fts5Config *pConfig = p->pConfig;
227177
- int rc; /* Return code */
227366
+ int rc = SQLITE_OK; /* Return code */
227178227367
int *aColSize; /* Array of size pConfig->nCol */
227179227368
i64 *aTotalSize; /* Array of size pConfig->nCol */
227180227369
Fts5IntegrityCtx ctx;
227181227370
sqlite3_stmt *pScan;
227371
+ int bUseCksum;
227182227372
227183227373
memset(&ctx, 0, sizeof(Fts5IntegrityCtx));
227184227374
ctx.pConfig = p->pConfig;
227185227375
aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));
227186227376
if( !aTotalSize ) return SQLITE_NOMEM;
227187227377
aColSize = (int*)&aTotalSize[pConfig->nCol];
227188227378
memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);
227189227379
227190
- /* Generate the expected index checksum based on the contents of the
227191
- ** %_content table. This block stores the checksum in ctx.cksum. */
227192
- rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);
227193
- if( rc==SQLITE_OK ){
227194
- int rc2;
227195
- while( SQLITE_ROW==sqlite3_step(pScan) ){
227196
- int i;
227197
- ctx.iRowid = sqlite3_column_int64(pScan, 0);
227198
- ctx.szCol = 0;
227199
- if( pConfig->bColumnsize ){
227200
- rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);
227201
- }
227202
- if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){
227203
- rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227204
- }
227205
- for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227206
- if( pConfig->abUnindexed[i] ) continue;
227207
- ctx.iCol = i;
227208
- ctx.szCol = 0;
227209
- if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227210
- rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227211
- }
227212
- if( rc==SQLITE_OK ){
227213
- const char *zText = (const char*)sqlite3_column_text(pScan, i+1);
227214
- int nText = sqlite3_column_bytes(pScan, i+1);
227215
- rc = sqlite3Fts5Tokenize(pConfig,
227216
- FTS5_TOKENIZE_DOCUMENT,
227217
- zText, nText,
227218
- (void*)&ctx,
227219
- fts5StorageIntegrityCallback
227220
- );
227221
- }
227222
- if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
227223
- rc = FTS5_CORRUPT;
227224
- }
227225
- aTotalSize[i] += ctx.szCol;
227226
- if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227227
- sqlite3Fts5TermsetFree(ctx.pTermset);
227228
- ctx.pTermset = 0;
227229
- }
227230
- }
227231
- sqlite3Fts5TermsetFree(ctx.pTermset);
227232
- ctx.pTermset = 0;
227233
-
227234
- if( rc!=SQLITE_OK ) break;
227235
- }
227236
- rc2 = sqlite3_reset(pScan);
227237
- if( rc==SQLITE_OK ) rc = rc2;
227238
- }
227239
-
227240
- /* Test that the "totals" (sometimes called "averages") record looks Ok */
227241
- if( rc==SQLITE_OK ){
227242
- int i;
227243
- rc = fts5StorageLoadTotals(p, 0);
227244
- for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227245
- if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;
227246
- }
227247
- }
227248
-
227249
- /* Check that the %_docsize and %_content tables contain the expected
227250
- ** number of rows. */
227251
- if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){
227252
- i64 nRow = 0;
227253
- rc = fts5StorageCount(p, "content", &nRow);
227254
- if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
227255
- }
227256
- if( rc==SQLITE_OK && pConfig->bColumnsize ){
227257
- i64 nRow = 0;
227258
- rc = fts5StorageCount(p, "docsize", &nRow);
227259
- if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
227380
+ bUseCksum = (pConfig->eContent==FTS5_CONTENT_NORMAL
227381
+ || (pConfig->eContent==FTS5_CONTENT_EXTERNAL && iArg)
227382
+ );
227383
+ if( bUseCksum ){
227384
+ /* Generate the expected index checksum based on the contents of the
227385
+ ** %_content table. This block stores the checksum in ctx.cksum. */
227386
+ rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);
227387
+ if( rc==SQLITE_OK ){
227388
+ int rc2;
227389
+ while( SQLITE_ROW==sqlite3_step(pScan) ){
227390
+ int i;
227391
+ ctx.iRowid = sqlite3_column_int64(pScan, 0);
227392
+ ctx.szCol = 0;
227393
+ if( pConfig->bColumnsize ){
227394
+ rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);
227395
+ }
227396
+ if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){
227397
+ rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227398
+ }
227399
+ for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227400
+ if( pConfig->abUnindexed[i] ) continue;
227401
+ ctx.iCol = i;
227402
+ ctx.szCol = 0;
227403
+ if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227404
+ rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227405
+ }
227406
+ if( rc==SQLITE_OK ){
227407
+ const char *zText = (const char*)sqlite3_column_text(pScan, i+1);
227408
+ int nText = sqlite3_column_bytes(pScan, i+1);
227409
+ rc = sqlite3Fts5Tokenize(pConfig,
227410
+ FTS5_TOKENIZE_DOCUMENT,
227411
+ zText, nText,
227412
+ (void*)&ctx,
227413
+ fts5StorageIntegrityCallback
227414
+ );
227415
+ }
227416
+ if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
227417
+ rc = FTS5_CORRUPT;
227418
+ }
227419
+ aTotalSize[i] += ctx.szCol;
227420
+ if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227421
+ sqlite3Fts5TermsetFree(ctx.pTermset);
227422
+ ctx.pTermset = 0;
227423
+ }
227424
+ }
227425
+ sqlite3Fts5TermsetFree(ctx.pTermset);
227426
+ ctx.pTermset = 0;
227427
+
227428
+ if( rc!=SQLITE_OK ) break;
227429
+ }
227430
+ rc2 = sqlite3_reset(pScan);
227431
+ if( rc==SQLITE_OK ) rc = rc2;
227432
+ }
227433
+
227434
+ /* Test that the "totals" (sometimes called "averages") record looks Ok */
227435
+ if( rc==SQLITE_OK ){
227436
+ int i;
227437
+ rc = fts5StorageLoadTotals(p, 0);
227438
+ for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227439
+ if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;
227440
+ }
227441
+ }
227442
+
227443
+ /* Check that the %_docsize and %_content tables contain the expected
227444
+ ** number of rows. */
227445
+ if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){
227446
+ i64 nRow = 0;
227447
+ rc = fts5StorageCount(p, "content", &nRow);
227448
+ if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
227449
+ }
227450
+ if( rc==SQLITE_OK && pConfig->bColumnsize ){
227451
+ i64 nRow = 0;
227452
+ rc = fts5StorageCount(p, "docsize", &nRow);
227453
+ if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
227454
+ }
227260227455
}
227261227456
227262227457
/* Pass the expected checksum down to the FTS index module. It will
227263227458
** verify, amongst other things, that it matches the checksum generated by
227264227459
** inspecting the index itself. */
227265227460
if( rc==SQLITE_OK ){
227266
- rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum);
227461
+ rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum, bUseCksum);
227267227462
}
227268227463
227269227464
sqlite3_free(aTotalSize);
227270227465
return rc;
227271227466
}
@@ -230945,12 +231140,12 @@
230945231140
}
230946231141
#endif /* SQLITE_CORE */
230947231142
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
230948231143
230949231144
/************** End of stmt.c ************************************************/
230950
-#if __LINE__!=230950
231145
+#if __LINE__!=231145
230951231146
#undef SQLITE_SOURCE_ID
230952
-#define SQLITE_SOURCE_ID "2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8alt2"
231147
+#define SQLITE_SOURCE_ID "2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c4alt2"
230953231148
#endif
230954231149
/* Return the source-id for this library */
230955231150
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
230956231151
/************************** End of sqlite3.c ******************************/
230957231152
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1171,11 +1171,11 @@
1171 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1172 ** [sqlite_version()] and [sqlite_source_id()].
1173 */
1174 #define SQLITE_VERSION "3.34.0"
1175 #define SQLITE_VERSION_NUMBER 3034000
1176 #define SQLITE_SOURCE_ID "2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8afa3"
1177
1178 /*
1179 ** CAPI3REF: Run-Time Library Version Numbers
1180 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1181 **
@@ -15133,16 +15133,25 @@
15133 SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
15134 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
15135 SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, Pgno*, int flags);
15136 SQLITE_PRIVATE int sqlite3BtreeTxnState(Btree*);
15137 SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*);
 
15138 SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
15139 SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree);
15140 #ifndef SQLITE_OMIT_SHARED_CACHE
15141 SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);
15142 #endif
 
 
 
15143 SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int);
 
 
 
 
 
15144
15145 SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *);
15146 SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *);
15147 SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);
15148
@@ -15735,68 +15744,69 @@
15735 #define OP_SequenceTest 113 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15736 #define OP_OpenPseudo 114 /* synopsis: P3 columns in r[P2] */
15737 #define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */
15738 #define OP_Close 116
15739 #define OP_ColumnsUsed 117
15740 #define OP_SeekHit 118 /* synopsis: set P2<=seekHit<=P3 */
15741 #define OP_Sequence 119 /* synopsis: r[P2]=cursor[P1].ctr++ */
15742 #define OP_NewRowid 120 /* synopsis: r[P2]=rowid */
15743 #define OP_Insert 121 /* synopsis: intkey=r[P3] data=r[P2] */
15744 #define OP_Delete 122
15745 #define OP_ResetCount 123
15746 #define OP_SorterCompare 124 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15747 #define OP_SorterData 125 /* synopsis: r[P2]=data */
15748 #define OP_RowData 126 /* synopsis: r[P2]=data */
15749 #define OP_Rowid 127 /* synopsis: r[P2]=rowid */
15750 #define OP_NullRow 128
15751 #define OP_SeekEnd 129
15752 #define OP_IdxInsert 130 /* synopsis: key=r[P2] */
15753 #define OP_SorterInsert 131 /* synopsis: key=r[P2] */
15754 #define OP_IdxDelete 132 /* synopsis: key=r[P2@P3] */
15755 #define OP_DeferredSeek 133 /* synopsis: Move P3 to P1.rowid if needed */
15756 #define OP_IdxRowid 134 /* synopsis: r[P2]=rowid */
15757 #define OP_FinishSeek 135
15758 #define OP_Destroy 136
15759 #define OP_Clear 137
15760 #define OP_ResetSorter 138
15761 #define OP_CreateBtree 139 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15762 #define OP_SqlExec 140
15763 #define OP_ParseSchema 141
15764 #define OP_LoadAnalysis 142
15765 #define OP_DropTable 143
15766 #define OP_DropIndex 144
15767 #define OP_DropTrigger 145
15768 #define OP_IntegrityCk 146
15769 #define OP_RowSetAdd 147 /* synopsis: rowset(P1)=r[P2] */
15770 #define OP_Param 148
15771 #define OP_FkCounter 149 /* synopsis: fkctr[P1]+=P2 */
15772 #define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15773 #define OP_MemMax 151 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15774 #define OP_OffsetLimit 152 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15775 #define OP_AggInverse 153 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15776 #define OP_AggStep 154 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15777 #define OP_AggStep1 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15778 #define OP_AggValue 156 /* synopsis: r[P3]=value N=P2 */
15779 #define OP_AggFinal 157 /* synopsis: accum=r[P1] N=P2 */
15780 #define OP_Expire 158
15781 #define OP_CursorLock 159
15782 #define OP_CursorUnlock 160
15783 #define OP_TableLock 161 /* synopsis: iDb=P1 root=P2 write=P3 */
15784 #define OP_VBegin 162
15785 #define OP_VCreate 163
15786 #define OP_VDestroy 164
15787 #define OP_VOpen 165
15788 #define OP_VColumn 166 /* synopsis: r[P3]=vcolumn(P2) */
15789 #define OP_VRename 167
15790 #define OP_Pagecount 168
15791 #define OP_MaxPgcnt 169
15792 #define OP_Trace 170
15793 #define OP_CursorHint 171
15794 #define OP_ReleaseReg 172 /* synopsis: release r[P1@P2] mask P3 */
15795 #define OP_Noop 173
15796 #define OP_Explain 174
15797 #define OP_Abortable 175
 
15798
15799 /* Properties such as "out2" or "jump" that are specified in
15800 ** comments following the "case" for each opcode in the vdbe.c
15801 ** are encoded into bitvectors as follows:
15802 */
@@ -15819,19 +15829,19 @@
15819 /* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\
15820 /* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12,\
15821 /* 88 */ 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15822 /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\
15823 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
15824 /* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,\
15825 /* 120 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
15826 /* 128 */ 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00,\
15827 /* 136 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15828 /* 144 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x10, 0x04,\
15829 /* 152 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15830 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15831 /* 168 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15832 }
15833
15834 /* The sqlite3P2Values() routine is able to run faster if it knows
15835 ** the value of the largest JUMP opcode. The smaller the maximum
15836 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15837 ** generated this include file strives to group all JUMP opcodes
@@ -33339,68 +33349,69 @@
33339 /* 113 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
33340 /* 114 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
33341 /* 115 */ "String8" OpHelp("r[P2]='P4'"),
33342 /* 116 */ "Close" OpHelp(""),
33343 /* 117 */ "ColumnsUsed" OpHelp(""),
33344 /* 118 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
33345 /* 119 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
33346 /* 120 */ "NewRowid" OpHelp("r[P2]=rowid"),
33347 /* 121 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
33348 /* 122 */ "Delete" OpHelp(""),
33349 /* 123 */ "ResetCount" OpHelp(""),
33350 /* 124 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
33351 /* 125 */ "SorterData" OpHelp("r[P2]=data"),
33352 /* 126 */ "RowData" OpHelp("r[P2]=data"),
33353 /* 127 */ "Rowid" OpHelp("r[P2]=rowid"),
33354 /* 128 */ "NullRow" OpHelp(""),
33355 /* 129 */ "SeekEnd" OpHelp(""),
33356 /* 130 */ "IdxInsert" OpHelp("key=r[P2]"),
33357 /* 131 */ "SorterInsert" OpHelp("key=r[P2]"),
33358 /* 132 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
33359 /* 133 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
33360 /* 134 */ "IdxRowid" OpHelp("r[P2]=rowid"),
33361 /* 135 */ "FinishSeek" OpHelp(""),
33362 /* 136 */ "Destroy" OpHelp(""),
33363 /* 137 */ "Clear" OpHelp(""),
33364 /* 138 */ "ResetSorter" OpHelp(""),
33365 /* 139 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
33366 /* 140 */ "SqlExec" OpHelp(""),
33367 /* 141 */ "ParseSchema" OpHelp(""),
33368 /* 142 */ "LoadAnalysis" OpHelp(""),
33369 /* 143 */ "DropTable" OpHelp(""),
33370 /* 144 */ "DropIndex" OpHelp(""),
33371 /* 145 */ "DropTrigger" OpHelp(""),
33372 /* 146 */ "IntegrityCk" OpHelp(""),
33373 /* 147 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
33374 /* 148 */ "Param" OpHelp(""),
33375 /* 149 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
33376 /* 150 */ "Real" OpHelp("r[P2]=P4"),
33377 /* 151 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
33378 /* 152 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
33379 /* 153 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
33380 /* 154 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
33381 /* 155 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
33382 /* 156 */ "AggValue" OpHelp("r[P3]=value N=P2"),
33383 /* 157 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
33384 /* 158 */ "Expire" OpHelp(""),
33385 /* 159 */ "CursorLock" OpHelp(""),
33386 /* 160 */ "CursorUnlock" OpHelp(""),
33387 /* 161 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
33388 /* 162 */ "VBegin" OpHelp(""),
33389 /* 163 */ "VCreate" OpHelp(""),
33390 /* 164 */ "VDestroy" OpHelp(""),
33391 /* 165 */ "VOpen" OpHelp(""),
33392 /* 166 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
33393 /* 167 */ "VRename" OpHelp(""),
33394 /* 168 */ "Pagecount" OpHelp(""),
33395 /* 169 */ "MaxPgcnt" OpHelp(""),
33396 /* 170 */ "Trace" OpHelp(""),
33397 /* 171 */ "CursorHint" OpHelp(""),
33398 /* 172 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
33399 /* 173 */ "Noop" OpHelp(""),
33400 /* 174 */ "Explain" OpHelp(""),
33401 /* 175 */ "Abortable" OpHelp(""),
 
33402 };
33403 return azName[i];
33404 }
33405 #endif
33406
@@ -70343,11 +70354,11 @@
70343 }
70344 }
70345
70346 pPage = pCur->pPage;
70347 idx = ++pCur->ix;
70348 if( !pPage->isInit ){
70349 /* The only known way for this to happen is for there to be a
70350 ** recursive SQL function that does a DELETE operation as part of a
70351 ** SELECT which deletes content out from under an active cursor
70352 ** in a corrupt database file where the table being DELETE-ed from
70353 ** has pages in common with the table being queried. See TH3
@@ -89829,10 +89840,147 @@
89829 assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
89830 pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
89831 }
89832 break;
89833 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89834
89835 /* Opcode: SeekHit P1 P2 P3 * *
89836 ** Synopsis: set P2<=seekHit<=P3
89837 **
89838 ** Increase or decrease the seekHit value for cursor P1, if necessary,
@@ -91361,22 +91509,45 @@
91361 assert( memIsValid(&r.aMem[i]) );
91362 REGISTER_TRACE(pOp->p3+i, &aMem[pOp->p3+i]);
91363 }
91364 }
91365 #endif
91366 res = 0; /* Not needed. Only used to silence a warning. */
91367 rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91368 assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
91369 if( (pOp->opcode&1)==(OP_IdxLT&1) ){
91370 assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );
91371 res = -res;
91372 }else{
91373 assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );
91374 res++;
91375 }
91376 VdbeBranchTaken(res>0,2);
91377 if( rc ) goto abort_due_to_error;
91378 if( res>0 ) goto jump_to_p2;
91379 break;
91380 }
91381
91382 /* Opcode: Destroy P1 P2 P3 * *
@@ -132969,12 +133140,11 @@
132969 pNew = sqlite3ExprDup(db, pCopy, 0);
132970 if( pNew && pSubst->isLeftJoin ){
132971 ExprSetProperty(pNew, EP_CanBeNull);
132972 }
132973 if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
132974 pNew->iRightJoinTable = pExpr->iRightJoinTable;
132975 ExprSetProperty(pNew, EP_FromJoin);
132976 }
132977 sqlite3ExprDelete(db, pExpr);
132978 pExpr = pNew;
132979
132980 /* Ensure that the expression now has an implicit collation sequence,
@@ -141334,13 +141504,15 @@
141334 u16 eOperator; /* A WO_xx value describing <op> */
141335 u8 nChild; /* Number of children that must disable us */
141336 u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */
141337 int iParent; /* Disable pWC->a[iParent] when this term disabled */
141338 int leftCursor; /* Cursor number of X in "X <op> <expr>" */
141339 int iField; /* Field in (?,?,?) IN (SELECT...) vector */
141340 union {
141341 int leftColumn; /* Column number of X in "X <op> <expr>" */
 
 
 
141342 WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
141343 WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
141344 } u;
141345 Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
141346 Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
@@ -141690,10 +141862,11 @@
141690 #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
141691 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
141692 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
141693 #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
141694 #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
 
141695
141696 #endif /* !defined(SQLITE_WHEREINT_H) */
141697
141698 /************** End of whereInt.h ********************************************/
141699 /************** Continuing where we left off in wherecode.c ******************/
@@ -142103,11 +142276,11 @@
142103 int i; /* Loop counter */
142104 Select *pSelect; /* Pointer to the SELECT on the RHS */
142105
142106 for(i=iEq; i<pLoop->nLTerm; i++){
142107 if( pLoop->aLTerm[i]->pExpr==pX ){
142108 int iField = pLoop->aLTerm[i]->iField - 1;
142109 if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */
142110 pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
142111 pOrigRhs->a[iField].pExpr = 0;
142112 assert( pOrigLhs->a[iField].pExpr!=0 );
142113 pLhs = sqlite3ExprListAppend(pParse, pLhs, pOrigLhs->a[iField].pExpr);
@@ -142246,11 +142419,11 @@
142246
142247 pLoop->wsFlags |= WHERE_IN_ABLE;
142248 if( pLevel->u.in.nIn==0 ){
142249 pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
142250 }
142251 if( iEq>0 ){
142252 pLoop->wsFlags |= WHERE_IN_EARLYOUT;
142253 }
142254
142255 i = pLevel->u.in.nIn;
142256 pLevel->u.in.nIn += nEq;
@@ -142284,11 +142457,11 @@
142284 pIn->eEndLoopOp = OP_Noop;
142285 }
142286 pIn++;
142287 }
142288 }
142289 if( iEq>0 ){
142290 sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq);
142291 }
142292 }else{
142293 pLevel->u.in.nIn = 0;
142294 }
@@ -143439,12 +143612,11 @@
143439 nConstraint = nEq;
143440 if( pRangeStart ){
143441 Expr *pRight = pRangeStart->pExpr->pRight;
143442 codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);
143443 whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
143444 if( !bRev
143445 && (pRangeStart->wtFlags & TERM_VNULL)==0
143446 && sqlite3ExprCanBeNull(pRight)
143447 ){
143448 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
143449 VdbeCoverage(v);
143450 }
@@ -143480,10 +143652,24 @@
143480 VdbeComment((v, "NULL-scan pass ctr"));
143481 }
143482
143483 op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
143484 assert( op!=0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143485 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
143486 VdbeCoverage(v);
143487 VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
143488 VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
143489 VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT );
@@ -143515,12 +143701,11 @@
143515 nConstraint = nEq;
143516 if( pRangeEnd ){
143517 Expr *pRight = pRangeEnd->pExpr->pRight;
143518 codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
143519 whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
143520 if( bRev
143521 && (pRangeEnd->wtFlags & TERM_VNULL)==0
143522 && sqlite3ExprCanBeNull(pRight)
143523 ){
143524 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
143525 VdbeCoverage(v);
143526 }
@@ -143582,11 +143767,11 @@
143582 testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
143583 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
143584 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
143585 }
143586
143587 if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){
143588 sqlite3VdbeAddOp3(v, OP_SeekHit, iIdxCur, nEq, nEq);
143589 }
143590
143591 /* Seek the table cursor, if required */
143592 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
@@ -144090,11 +144275,11 @@
144090 sqlite3WhereTermPrint(pTerm, pWC->nTerm-j);
144091 }
144092 #endif
144093 assert( !ExprHasProperty(pE, EP_FromJoin) );
144094 assert( (pTerm->prereqRight & pLevel->notReady)!=0 );
144095 pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.leftColumn, notReady,
144096 WO_EQ|WO_IN|WO_IS, 0);
144097 if( pAlt==0 ) continue;
144098 if( pAlt->wtFlags & (TERM_CODED) ) continue;
144099 if( (pAlt->eOperator & WO_IN)
144100 && (pAlt->pExpr->flags & EP_xIsSelect)
@@ -144946,11 +145131,11 @@
144946 testcase( pOrTerm->wtFlags & TERM_COPIED );
144947 testcase( pOrTerm->wtFlags & TERM_VIRTUAL );
144948 assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );
144949 continue;
144950 }
144951 iColumn = pOrTerm->u.leftColumn;
144952 iCursor = pOrTerm->leftCursor;
144953 pLeft = pOrTerm->pExpr->pLeft;
144954 break;
144955 }
144956 if( i<0 ){
@@ -144968,11 +145153,11 @@
144968 okToChngToIN = 1;
144969 for(; i>=0 && okToChngToIN; i--, pOrTerm++){
144970 assert( pOrTerm->eOperator & WO_EQ );
144971 if( pOrTerm->leftCursor!=iCursor ){
144972 pOrTerm->wtFlags &= ~TERM_OR_OK;
144973 }else if( pOrTerm->u.leftColumn!=iColumn || (iColumn==XN_EXPR
144974 && sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
144975 )){
144976 okToChngToIN = 0;
144977 }else{
144978 int affLeft, affRight;
@@ -145003,11 +145188,11 @@
145003
145004 for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
145005 if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
145006 assert( pOrTerm->eOperator & WO_EQ );
145007 assert( pOrTerm->leftCursor==iCursor );
145008 assert( pOrTerm->u.leftColumn==iColumn );
145009 pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);
145010 pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup);
145011 pLeft = pOrTerm->pExpr->pLeft;
145012 }
145013 assert( pLeft!=0 );
@@ -145239,29 +145424,29 @@
145239 int aiCurCol[2];
145240 Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);
145241 Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
145242 u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;
145243
145244 if( pTerm->iField>0 ){
145245 assert( op==TK_IN );
145246 assert( pLeft->op==TK_VECTOR );
145247 pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr;
145248 }
145249
145250 if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){
145251 pTerm->leftCursor = aiCurCol[0];
145252 pTerm->u.leftColumn = aiCurCol[1];
145253 pTerm->eOperator = operatorMask(op) & opMask;
145254 }
145255 if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
145256 if( pRight
145257 && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)
145258 ){
145259 WhereTerm *pNew;
145260 Expr *pDup;
145261 u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
145262 assert( pTerm->iField==0 );
145263 if( pTerm->leftCursor>=0 ){
145264 int idxNew;
145265 pDup = sqlite3ExprDup(db, pExpr, 0);
145266 if( db->mallocFailed ){
145267 sqlite3ExprDelete(db, pDup);
@@ -145283,11 +145468,11 @@
145283 pDup = pExpr;
145284 pNew = pTerm;
145285 }
145286 pNew->wtFlags |= exprCommute(pParse, pDup);
145287 pNew->leftCursor = aiCurCol[0];
145288 pNew->u.leftColumn = aiCurCol[1];
145289 testcase( (prereqLeft | extraRight) != prereqLeft );
145290 pNew->prereqRight = prereqLeft | extraRight;
145291 pNew->prereqAll = prereqAll;
145292 pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;
145293 }
@@ -145457,11 +145642,11 @@
145457 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
145458 testcase( idxNew==0 );
145459 pNewTerm = &pWC->a[idxNew];
145460 pNewTerm->prereqRight = prereqExpr;
145461 pNewTerm->leftCursor = pLeft->iTable;
145462 pNewTerm->u.leftColumn = pLeft->iColumn;
145463 pNewTerm->eOperator = WO_AUX;
145464 pNewTerm->eMatchOp = eOp2;
145465 markTermAsChild(pWC, idxNew, idxTerm);
145466 pTerm = &pWC->a[idxTerm];
145467 pTerm->wtFlags |= TERM_COPIED;
@@ -145504,17 +145689,17 @@
145504 }
145505
145506 /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
145507 ** a virtual term for each vector component. The expression object
145508 ** used by each such virtual term is pExpr (the full vector IN(...)
145509 ** expression). The WhereTerm.iField variable identifies the index within
145510 ** the vector on the LHS that the virtual term represents.
145511 **
145512 ** This only works if the RHS is a simple SELECT (not a compound) that does
145513 ** not use window functions.
145514 */
145515 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->iField==0
145516 && pExpr->pLeft->op==TK_VECTOR
145517 && pExpr->x.pSelect->pPrior==0
145518 #ifndef SQLITE_OMIT_WINDOWFUNC
145519 && pExpr->x.pSelect->pWin==0
145520 #endif
@@ -145521,11 +145706,11 @@
145521 ){
145522 int i;
145523 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
145524 int idxNew;
145525 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
145526 pWC->a[idxNew].iField = i+1;
145527 exprAnalyze(pSrc, pWC, idxNew);
145528 markTermAsChild(pWC, idxNew, idxTerm);
145529 }
145530 }
145531
@@ -145556,11 +145741,11 @@
145556 TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);
145557 if( idxNew ){
145558 pNewTerm = &pWC->a[idxNew];
145559 pNewTerm->prereqRight = 0;
145560 pNewTerm->leftCursor = pLeft->iTable;
145561 pNewTerm->u.leftColumn = pLeft->iColumn;
145562 pNewTerm->eOperator = WO_GT;
145563 markTermAsChild(pWC, idxNew, idxTerm);
145564 pTerm = &pWC->a[idxTerm];
145565 pTerm->wtFlags |= TERM_COPIED;
145566 pNewTerm->prereqAll = pTerm->prereqAll;
@@ -146020,11 +146205,11 @@
146020 iCur = pScan->aiCur[pScan->iEquiv-1];
146021 assert( pWC!=0 );
146022 do{
146023 for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
146024 if( pTerm->leftCursor==iCur
146025 && pTerm->u.leftColumn==iColumn
146026 && (iColumn!=XN_EXPR
146027 || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
146028 pScan->pIdxExpr,iCur)==0)
146029 && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
146030 ){
@@ -146442,12 +146627,12 @@
146442 ** the RHS of a LEFT JOIN. Such a term can only be used if it is from
146443 ** the ON clause. */
146444 return 0;
146445 }
146446 if( (pTerm->prereqRight & notReady)!=0 ) return 0;
146447 if( pTerm->u.leftColumn<0 ) return 0;
146448 aff = pSrc->pTab->aCol[pTerm->u.leftColumn].affinity;
146449 if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
146450 testcase( pTerm->pExpr->op==TK_IS );
146451 return 1;
146452 }
146453 #endif
@@ -146514,11 +146699,11 @@
146514 && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
146515 pPartial = sqlite3ExprAnd(pParse, pPartial,
146516 sqlite3ExprDup(pParse->db, pExpr, 0));
146517 }
146518 if( termCanDriveIndex(pTerm, pSrc, notReady) ){
146519 int iCol = pTerm->u.leftColumn;
146520 Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
146521 testcase( iCol==BMS );
146522 testcase( iCol==BMS-1 );
146523 if( !sentWarning ){
146524 sqlite3_log(SQLITE_WARNING_AUTOINDEX,
@@ -146567,18 +146752,18 @@
146567 pIdx->pTable = pTable;
146568 n = 0;
146569 idxCols = 0;
146570 for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
146571 if( termCanDriveIndex(pTerm, pSrc, notReady) ){
146572 int iCol = pTerm->u.leftColumn;
146573 Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
146574 testcase( iCol==BMS-1 );
146575 testcase( iCol==BMS );
146576 if( (idxCols & cMask)==0 ){
146577 Expr *pX = pTerm->pExpr;
146578 idxCols |= cMask;
146579 pIdx->aiColumn[n] = pTerm->u.leftColumn;
146580 pColl = sqlite3ExprCompareCollSeq(pParse, pX);
146581 assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */
146582 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
146583 n++;
146584 }
@@ -146695,11 +146880,11 @@
146695 testcase( pTerm->eOperator & WO_ISNULL );
146696 testcase( pTerm->eOperator & WO_IS );
146697 testcase( pTerm->eOperator & WO_ALL );
146698 if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
146699 if( pTerm->wtFlags & TERM_VNULL ) continue;
146700 assert( pTerm->u.leftColumn>=(-1) );
146701 nTerm++;
146702 }
146703
146704 /* If the ORDER BY clause contains only columns in the current
146705 ** virtual table then allocate space for the aOrderBy part of
@@ -146755,12 +146940,12 @@
146755 if( (pSrc->fg.jointype & JT_LEFT)!=0
146756 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
146757 ){
146758 continue;
146759 }
146760 assert( pTerm->u.leftColumn>=(-1) );
146761 pIdxCons[j].iColumn = pTerm->u.leftColumn;
146762 pIdxCons[j].iTermOffset = i;
146763 op = pTerm->eOperator & WO_ALL;
146764 if( op==WO_IN ) op = WO_EQ;
146765 if( op==WO_AUX ){
146766 pIdxCons[j].op = pTerm->eMatchOp;
@@ -147519,11 +147704,11 @@
147519 if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
147520 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
147521 if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C';
147522 if( pTerm->eOperator & WO_SINGLE ){
147523 sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
147524 pTerm->leftCursor, pTerm->u.leftColumn);
147525 }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
147526 sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
147527 pTerm->u.pOrInfo->indexable);
147528 }else{
147529 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
@@ -147535,12 +147720,12 @@
147535 ** shown about each Term */
147536 if( sqlite3WhereTrace & 0x10000 ){
147537 sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx",
147538 pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight);
147539 }
147540 if( pTerm->iField ){
147541 sqlite3DebugPrintf(" iField=%d", pTerm->iField);
147542 }
147543 if( pTerm->iParent>=0 ){
147544 sqlite3DebugPrintf(" iParent=%d", pTerm->iParent);
147545 }
147546 sqlite3DebugPrintf("\n");
@@ -148327,11 +148512,11 @@
148327 safetyMargin = 10; /* TUNING: extra weight for indexed IN */
148328 if( M + logK + safetyMargin < nIn + rLogSize ){
148329 WHERETRACE(0x40,
148330 ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
148331 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
148332 continue;
148333 }else{
148334 WHERETRACE(0x40,
148335 ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
148336 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
148337 }
@@ -150960,10 +151145,11 @@
150960 sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
150961 sqlite3VdbeSetP4KeyInfo(pParse, pIx);
150962 if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
150963 && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
150964 && (pLoop->wsFlags & WHERE_BIGNULL_SORT)==0
 
150965 && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
150966 && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED
150967 ){
150968 sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ);
150969 }
@@ -151122,11 +151308,13 @@
151122 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
151123 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
151124 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
151125 if( pIn->eEndLoopOp!=OP_Noop ){
151126 if( pIn->nPrefix ){
151127 assert( pLoop->wsFlags & WHERE_IN_EARLYOUT );
 
 
151128 if( pLevel->iLeftJoin ){
151129 /* For LEFT JOIN queries, cursor pIn->iCur may not have been
151130 ** opened yet. This occurs for WHERE clauses such as
151131 ** "a = ? AND b IN (...)", where the index is on (a, b). If
151132 ** the RHS of the (a=?) is NULL, then the "b IN (...)" may
@@ -151133,16 +151321,14 @@
151133 ** never have been coded, but the body of the loop run to
151134 ** return the null-row. So, if the cursor is not open yet,
151135 ** jump over the OP_Next or OP_Prev instruction about to
151136 ** be coded. */
151137 sqlite3VdbeAddOp2(v, OP_IfNotOpen, pIn->iCur,
151138 sqlite3VdbeCurrentAddr(v) + 2 +
151139 ((pLoop->wsFlags & WHERE_VIRTUALTABLE)==0)
151140 );
151141 VdbeCoverage(v);
151142 }
151143 if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 ){
151144 sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
151145 sqlite3VdbeCurrentAddr(v)+2,
151146 pIn->iBase, pIn->nPrefix);
151147 VdbeCoverage(v);
151148 }
@@ -157827,12 +158013,13 @@
157827 int yysize; /* Amount to pop the stack */
157828 sqlite3ParserARG_FETCH
157829 (void)yyLookahead;
157830 (void)yyLookaheadToken;
157831 yymsp = yypParser->yytos;
 
157832 #ifndef NDEBUG
157833 if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
157834 yysize = yyRuleInfoNRhs[yyruleno];
157835 if( yysize ){
157836 fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
157837 yyTracePrompt,
157838 yyruleno, yyRuleName[yyruleno],
@@ -209390,11 +209577,11 @@
209390 static int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int);
209391
209392 /*
209393 ** Functions called by the storage module as part of integrity-check.
209394 */
209395 static int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum);
209396
209397 /*
209398 ** Called during virtual module initialization to register UDF
209399 ** fts5_decode() with SQLite
209400 */
@@ -209545,11 +209732,11 @@
209545
209546 static int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**);
209547 static int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);
209548 static int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);
209549
209550 static int sqlite3Fts5StorageIntegrity(Fts5Storage *p);
209551
209552 static int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);
209553 static void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*);
209554
209555 static int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol);
@@ -210735,12 +210922,13 @@
210735 int fts5yysize; /* Amount to pop the stack */
210736 sqlite3Fts5ParserARG_FETCH
210737 (void)fts5yyLookahead;
210738 (void)fts5yyLookaheadToken;
210739 fts5yymsp = fts5yypParser->fts5yytos;
 
210740 #ifndef NDEBUG
210741 if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
210742 fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
210743 if( fts5yysize ){
210744 fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
210745 fts5yyTracePrompt,
210746 fts5yyruleno, fts5yyRuleName[fts5yyruleno],
@@ -222842,11 +223030,11 @@
222842 ** Return SQLITE_CORRUPT if any of the internal checks fail, or if the
222843 ** checksum does not match. Return SQLITE_OK if all checks pass without
222844 ** error, or some other SQLite error code if another error (e.g. OOM)
222845 ** occurs.
222846 */
222847 static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum){
222848 int eDetail = p->pConfig->eDetail;
222849 u64 cksum2 = 0; /* Checksum based on contents of indexes */
222850 Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */
222851 Fts5Iter *pIter; /* Used to iterate through entire index */
222852 Fts5Structure *pStruct; /* Index structure */
@@ -222913,11 +223101,11 @@
222913 }
222914 }
222915 fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);
222916
222917 fts5MultiIterFree(pIter);
222918 if( p->rc==SQLITE_OK && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
222919
222920 fts5StructureRelease(pStruct);
222921 #ifdef SQLITE_DEBUG
222922 fts5BufferFree(&term);
222923 #endif
@@ -224921,11 +225109,12 @@
224921 rc = sqlite3Fts5StorageOptimize(pTab->pStorage);
224922 }else if( 0==sqlite3_stricmp("merge", zCmd) ){
224923 int nMerge = sqlite3_value_int(pVal);
224924 rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge);
224925 }else if( 0==sqlite3_stricmp("integrity-check", zCmd) ){
224926 rc = sqlite3Fts5StorageIntegrity(pTab->pStorage);
 
224927 #ifdef SQLITE_DEBUG
224928 }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){
224929 pConfig->bPrefixIndex = sqlite3_value_int(pVal);
224930 #endif
224931 }else{
@@ -226155,11 +226344,11 @@
226155 int nArg, /* Number of args */
226156 sqlite3_value **apUnused /* Function arguments */
226157 ){
226158 assert( nArg==0 );
226159 UNUSED_PARAM2(nArg, apUnused);
226160 sqlite3_result_text(pCtx, "fts5: 2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8afa3", -1, SQLITE_TRANSIENT);
226161 }
226162
226163 /*
226164 ** Return true if zName is the extension on one of the shadow tables used
226165 ** by this module.
@@ -227170,102 +227359,108 @@
227170 ** Check that the contents of the FTS index match that of the %_content
227171 ** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return
227172 ** some other SQLite error code if an error occurs while attempting to
227173 ** determine this.
227174 */
227175 static int sqlite3Fts5StorageIntegrity(Fts5Storage *p){
227176 Fts5Config *pConfig = p->pConfig;
227177 int rc; /* Return code */
227178 int *aColSize; /* Array of size pConfig->nCol */
227179 i64 *aTotalSize; /* Array of size pConfig->nCol */
227180 Fts5IntegrityCtx ctx;
227181 sqlite3_stmt *pScan;
 
227182
227183 memset(&ctx, 0, sizeof(Fts5IntegrityCtx));
227184 ctx.pConfig = p->pConfig;
227185 aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));
227186 if( !aTotalSize ) return SQLITE_NOMEM;
227187 aColSize = (int*)&aTotalSize[pConfig->nCol];
227188 memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);
227189
227190 /* Generate the expected index checksum based on the contents of the
227191 ** %_content table. This block stores the checksum in ctx.cksum. */
227192 rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);
227193 if( rc==SQLITE_OK ){
227194 int rc2;
227195 while( SQLITE_ROW==sqlite3_step(pScan) ){
227196 int i;
227197 ctx.iRowid = sqlite3_column_int64(pScan, 0);
227198 ctx.szCol = 0;
227199 if( pConfig->bColumnsize ){
227200 rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);
227201 }
227202 if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){
227203 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227204 }
227205 for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227206 if( pConfig->abUnindexed[i] ) continue;
227207 ctx.iCol = i;
227208 ctx.szCol = 0;
227209 if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227210 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227211 }
227212 if( rc==SQLITE_OK ){
227213 const char *zText = (const char*)sqlite3_column_text(pScan, i+1);
227214 int nText = sqlite3_column_bytes(pScan, i+1);
227215 rc = sqlite3Fts5Tokenize(pConfig,
227216 FTS5_TOKENIZE_DOCUMENT,
227217 zText, nText,
227218 (void*)&ctx,
227219 fts5StorageIntegrityCallback
227220 );
227221 }
227222 if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
227223 rc = FTS5_CORRUPT;
227224 }
227225 aTotalSize[i] += ctx.szCol;
227226 if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227227 sqlite3Fts5TermsetFree(ctx.pTermset);
227228 ctx.pTermset = 0;
227229 }
227230 }
227231 sqlite3Fts5TermsetFree(ctx.pTermset);
227232 ctx.pTermset = 0;
227233
227234 if( rc!=SQLITE_OK ) break;
227235 }
227236 rc2 = sqlite3_reset(pScan);
227237 if( rc==SQLITE_OK ) rc = rc2;
227238 }
227239
227240 /* Test that the "totals" (sometimes called "averages") record looks Ok */
227241 if( rc==SQLITE_OK ){
227242 int i;
227243 rc = fts5StorageLoadTotals(p, 0);
227244 for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227245 if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;
227246 }
227247 }
227248
227249 /* Check that the %_docsize and %_content tables contain the expected
227250 ** number of rows. */
227251 if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){
227252 i64 nRow = 0;
227253 rc = fts5StorageCount(p, "content", &nRow);
227254 if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
227255 }
227256 if( rc==SQLITE_OK && pConfig->bColumnsize ){
227257 i64 nRow = 0;
227258 rc = fts5StorageCount(p, "docsize", &nRow);
227259 if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
 
 
 
 
 
227260 }
227261
227262 /* Pass the expected checksum down to the FTS index module. It will
227263 ** verify, amongst other things, that it matches the checksum generated by
227264 ** inspecting the index itself. */
227265 if( rc==SQLITE_OK ){
227266 rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum);
227267 }
227268
227269 sqlite3_free(aTotalSize);
227270 return rc;
227271 }
@@ -230945,12 +231140,12 @@
230945 }
230946 #endif /* SQLITE_CORE */
230947 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
230948
230949 /************** End of stmt.c ************************************************/
230950 #if __LINE__!=230950
230951 #undef SQLITE_SOURCE_ID
230952 #define SQLITE_SOURCE_ID "2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8alt2"
230953 #endif
230954 /* Return the source-id for this library */
230955 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
230956 /************************** End of sqlite3.c ******************************/
230957
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1171,11 +1171,11 @@
1171 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1172 ** [sqlite_version()] and [sqlite_source_id()].
1173 */
1174 #define SQLITE_VERSION "3.34.0"
1175 #define SQLITE_VERSION_NUMBER 3034000
1176 #define SQLITE_SOURCE_ID "2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c402e5"
1177
1178 /*
1179 ** CAPI3REF: Run-Time Library Version Numbers
1180 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1181 **
@@ -15133,16 +15133,25 @@
15133 SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*,int,int);
15134 SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int);
15135 SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, Pgno*, int flags);
15136 SQLITE_PRIVATE int sqlite3BtreeTxnState(Btree*);
15137 SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*);
15138
15139 SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
15140 SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree);
15141 #ifndef SQLITE_OMIT_SHARED_CACHE
15142 SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock);
15143 #endif
15144
15145 /* Savepoints are named, nestable SQL transactions mostly implemented */
15146 /* in vdbe.c and pager.c See https://sqlite.org/lang_savepoint.html */
15147 SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int);
15148
15149 /* "Checkpoint" only refers to WAL. See https://sqlite.org/wal.html#ckpt */
15150 #ifndef SQLITE_OMIT_WAL
15151 SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree*, int, int *, int *);
15152 #endif
15153
15154 SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *);
15155 SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *);
15156 SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *);
15157
@@ -15735,68 +15744,69 @@
15744 #define OP_SequenceTest 113 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
15745 #define OP_OpenPseudo 114 /* synopsis: P3 columns in r[P2] */
15746 #define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */
15747 #define OP_Close 116
15748 #define OP_ColumnsUsed 117
15749 #define OP_SeekScan 118 /* synopsis: Scan-ahead up to P1 rows */
15750 #define OP_SeekHit 119 /* synopsis: set P2<=seekHit<=P3 */
15751 #define OP_Sequence 120 /* synopsis: r[P2]=cursor[P1].ctr++ */
15752 #define OP_NewRowid 121 /* synopsis: r[P2]=rowid */
15753 #define OP_Insert 122 /* synopsis: intkey=r[P3] data=r[P2] */
15754 #define OP_Delete 123
15755 #define OP_ResetCount 124
15756 #define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
15757 #define OP_SorterData 126 /* synopsis: r[P2]=data */
15758 #define OP_RowData 127 /* synopsis: r[P2]=data */
15759 #define OP_Rowid 128 /* synopsis: r[P2]=rowid */
15760 #define OP_NullRow 129
15761 #define OP_SeekEnd 130
15762 #define OP_IdxInsert 131 /* synopsis: key=r[P2] */
15763 #define OP_SorterInsert 132 /* synopsis: key=r[P2] */
15764 #define OP_IdxDelete 133 /* synopsis: key=r[P2@P3] */
15765 #define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */
15766 #define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */
15767 #define OP_FinishSeek 136
15768 #define OP_Destroy 137
15769 #define OP_Clear 138
15770 #define OP_ResetSorter 139
15771 #define OP_CreateBtree 140 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
15772 #define OP_SqlExec 141
15773 #define OP_ParseSchema 142
15774 #define OP_LoadAnalysis 143
15775 #define OP_DropTable 144
15776 #define OP_DropIndex 145
15777 #define OP_DropTrigger 146
15778 #define OP_IntegrityCk 147
15779 #define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */
15780 #define OP_Param 149
15781 #define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
15782 #define OP_FkCounter 151 /* synopsis: fkctr[P1]+=P2 */
15783 #define OP_MemMax 152 /* synopsis: r[P1]=max(r[P1],r[P2]) */
15784 #define OP_OffsetLimit 153 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
15785 #define OP_AggInverse 154 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
15786 #define OP_AggStep 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15787 #define OP_AggStep1 156 /* synopsis: accum=r[P3] step(r[P2@P5]) */
15788 #define OP_AggValue 157 /* synopsis: r[P3]=value N=P2 */
15789 #define OP_AggFinal 158 /* synopsis: accum=r[P1] N=P2 */
15790 #define OP_Expire 159
15791 #define OP_CursorLock 160
15792 #define OP_CursorUnlock 161
15793 #define OP_TableLock 162 /* synopsis: iDb=P1 root=P2 write=P3 */
15794 #define OP_VBegin 163
15795 #define OP_VCreate 164
15796 #define OP_VDestroy 165
15797 #define OP_VOpen 166
15798 #define OP_VColumn 167 /* synopsis: r[P3]=vcolumn(P2) */
15799 #define OP_VRename 168
15800 #define OP_Pagecount 169
15801 #define OP_MaxPgcnt 170
15802 #define OP_Trace 171
15803 #define OP_CursorHint 172
15804 #define OP_ReleaseReg 173 /* synopsis: release r[P1@P2] mask P3 */
15805 #define OP_Noop 174
15806 #define OP_Explain 175
15807 #define OP_Abortable 176
15808
15809 /* Properties such as "out2" or "jump" that are specified in
15810 ** comments following the "case" for each opcode in the vdbe.c
15811 ** are encoded into bitvectors as follows:
15812 */
@@ -15819,19 +15829,19 @@
15829 /* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\
15830 /* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12,\
15831 /* 88 */ 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
15832 /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\
15833 /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
15834 /* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
15835 /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15836 /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\
15837 /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
15838 /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00,\
15839 /* 152 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15840 /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
15841 /* 168 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
15842 /* 176 */ 0x00,}
15843
15844 /* The sqlite3P2Values() routine is able to run faster if it knows
15845 ** the value of the largest JUMP opcode. The smaller the maximum
15846 ** JUMP opcode the better, so the mkopcodeh.tcl script that
15847 ** generated this include file strives to group all JUMP opcodes
@@ -33339,68 +33349,69 @@
33349 /* 113 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
33350 /* 114 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
33351 /* 115 */ "String8" OpHelp("r[P2]='P4'"),
33352 /* 116 */ "Close" OpHelp(""),
33353 /* 117 */ "ColumnsUsed" OpHelp(""),
33354 /* 118 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
33355 /* 119 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
33356 /* 120 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
33357 /* 121 */ "NewRowid" OpHelp("r[P2]=rowid"),
33358 /* 122 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
33359 /* 123 */ "Delete" OpHelp(""),
33360 /* 124 */ "ResetCount" OpHelp(""),
33361 /* 125 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
33362 /* 126 */ "SorterData" OpHelp("r[P2]=data"),
33363 /* 127 */ "RowData" OpHelp("r[P2]=data"),
33364 /* 128 */ "Rowid" OpHelp("r[P2]=rowid"),
33365 /* 129 */ "NullRow" OpHelp(""),
33366 /* 130 */ "SeekEnd" OpHelp(""),
33367 /* 131 */ "IdxInsert" OpHelp("key=r[P2]"),
33368 /* 132 */ "SorterInsert" OpHelp("key=r[P2]"),
33369 /* 133 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
33370 /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
33371 /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"),
33372 /* 136 */ "FinishSeek" OpHelp(""),
33373 /* 137 */ "Destroy" OpHelp(""),
33374 /* 138 */ "Clear" OpHelp(""),
33375 /* 139 */ "ResetSorter" OpHelp(""),
33376 /* 140 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
33377 /* 141 */ "SqlExec" OpHelp(""),
33378 /* 142 */ "ParseSchema" OpHelp(""),
33379 /* 143 */ "LoadAnalysis" OpHelp(""),
33380 /* 144 */ "DropTable" OpHelp(""),
33381 /* 145 */ "DropIndex" OpHelp(""),
33382 /* 146 */ "DropTrigger" OpHelp(""),
33383 /* 147 */ "IntegrityCk" OpHelp(""),
33384 /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
33385 /* 149 */ "Param" OpHelp(""),
33386 /* 150 */ "Real" OpHelp("r[P2]=P4"),
33387 /* 151 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
33388 /* 152 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
33389 /* 153 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
33390 /* 154 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
33391 /* 155 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
33392 /* 156 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
33393 /* 157 */ "AggValue" OpHelp("r[P3]=value N=P2"),
33394 /* 158 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
33395 /* 159 */ "Expire" OpHelp(""),
33396 /* 160 */ "CursorLock" OpHelp(""),
33397 /* 161 */ "CursorUnlock" OpHelp(""),
33398 /* 162 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
33399 /* 163 */ "VBegin" OpHelp(""),
33400 /* 164 */ "VCreate" OpHelp(""),
33401 /* 165 */ "VDestroy" OpHelp(""),
33402 /* 166 */ "VOpen" OpHelp(""),
33403 /* 167 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
33404 /* 168 */ "VRename" OpHelp(""),
33405 /* 169 */ "Pagecount" OpHelp(""),
33406 /* 170 */ "MaxPgcnt" OpHelp(""),
33407 /* 171 */ "Trace" OpHelp(""),
33408 /* 172 */ "CursorHint" OpHelp(""),
33409 /* 173 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
33410 /* 174 */ "Noop" OpHelp(""),
33411 /* 175 */ "Explain" OpHelp(""),
33412 /* 176 */ "Abortable" OpHelp(""),
33413 };
33414 return azName[i];
33415 }
33416 #endif
33417
@@ -70343,11 +70354,11 @@
70354 }
70355 }
70356
70357 pPage = pCur->pPage;
70358 idx = ++pCur->ix;
70359 if( !pPage->isInit || sqlite3FaultSim(412) ){
70360 /* The only known way for this to happen is for there to be a
70361 ** recursive SQL function that does a DELETE operation as part of a
70362 ** SELECT which deletes content out from under an active cursor
70363 ** in a corrupt database file where the table being DELETE-ed from
70364 ** has pages in common with the table being queried. See TH3
@@ -89829,10 +89840,147 @@
89840 assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
89841 pOp++; /* Skip the OP_IdxLt or OP_IdxGT that follows */
89842 }
89843 break;
89844 }
89845
89846
89847 /* Opcode: SeekScan P1 * * * *
89848 ** Synopsis: Scan-ahead up to P1 rows
89849 **
89850 ** This opcode is a prefix opcode to OP_SeekGE. In other words, this
89851 ** opcode must be immediately followed by OP_SeekGE. Furthermore, the
89852 ** OP_SeekGE must be followed by OP_IdxGT. These constraints are
89853 ** checked by assert() statements.
89854 **
89855 ** This opcode uses the P1 through P4 operands of the subsequent
89856 ** OP_SeekGE. In the text that follows, the operands of the subsequent
89857 ** OP_SeekGE opcode are denoted as SeekOP.P1 through SeekOP.P4. Only
89858 ** the P1 operand of this opcode is used, and it is denoted as This.P1.
89859 **
89860 ** This opcode helps to optimize IN operators on a multi-column index
89861 ** where the IN operator is on the later terms of the index by avoiding
89862 ** unnecessary seeks on the btree, substituting steps to the next row
89863 ** of the b-tree instead. A correct answer is obtained if this opcode
89864 ** is omitted or is a no-op.
89865 **
89866 ** The SeekGE.P3 and SeekGE.P4 operands identify an unpacked key which
89867 ** is the desired entry that we want the cursor SeekGE.P1 to be pointing
89868 ** to. Call this SeekGE.P4/P5 row the "target".
89869 **
89870 ** If the SeekGE.P1 cursor is not currently pointing to a valid row,
89871 ** then this opcode is a no-op and control passes through into the OP_SeekGE.
89872 **
89873 ** If the SeekGE.P1 cursor is pointing to a valid row, then that row
89874 ** might be the target row, or it might be near and slightly before the
89875 ** target row. This opcode attempts to position the cursor on the target
89876 ** row by, perhaps stepping by invoking sqlite3BtreeStep() on the cursor
89877 ** between 0 and This.P1 times.
89878 **
89879 ** There are three possible outcomes from this opcode:<ol>
89880 **
89881 ** <li> If after This.P1 steps, the cursor is still point to a place that
89882 ** is earlier in the btree than the target row,
89883 ** then fall through into the subsquence OP_SeekGE opcode.
89884 **
89885 ** <li> If the cursor is successfully moved to the target row by 0 or more
89886 ** sqlite3BtreeNext() calls, then jump to the first instruction after the
89887 ** OP_IdxGT opcode - or in other words, skip the next two opcodes.
89888 **
89889 ** <li> If the cursor ends up past the target row (indicating the the target
89890 ** row does not exist in the btree) then jump to SeekOP.P2.
89891 ** </ol>
89892 */
89893 case OP_SeekScan: {
89894 VdbeCursor *pC;
89895 int res;
89896 int n;
89897 UnpackedRecord r;
89898
89899 assert( pOp[1].opcode==OP_SeekGE );
89900 assert( pOp[2].opcode==OP_IdxGT );
89901 assert( pOp[1].p1==pOp[2].p1 );
89902 assert( pOp[1].p2==pOp[2].p2 );
89903 assert( pOp[1].p3==pOp[2].p3 );
89904 assert( pOp[1].p4.i==pOp[2].p4.i );
89905 assert( pOp->p1>0 );
89906 pC = p->apCsr[pOp[1].p1];
89907 assert( pC!=0 );
89908 assert( pC->eCurType==CURTYPE_BTREE );
89909 assert( !pC->isTable );
89910 if( !sqlite3BtreeCursorIsValidNN(pC->uc.pCursor) ){
89911 #ifdef SQLITE_DEBUG
89912 if( db->flags&SQLITE_VdbeTrace ){
89913 printf("... cursor not valid - fall through\n");
89914 }
89915 #endif
89916 break;
89917 }
89918 n = pOp->p1;
89919 assert( n>=1 );
89920 r.pKeyInfo = pC->pKeyInfo;
89921 r.nField = (u16)pOp[1].p4.i;
89922 r.default_rc = 0;
89923 r.aMem = &aMem[pOp[1].p3];
89924 #ifdef SQLITE_DEBUG
89925 {
89926 int i;
89927 for(i=0; i<r.nField; i++){
89928 assert( memIsValid(&r.aMem[i]) );
89929 REGISTER_TRACE(pOp[1].p3+i, &aMem[pOp[1].p3+i]);
89930 }
89931 }
89932 #endif
89933 res = 0; /* Not needed. Only used to silence a warning. */
89934 while(1){
89935 rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
89936 if( rc ) goto abort_due_to_error;
89937 if( res>0 ){
89938 seekscan_search_fail:
89939 #ifdef SQLITE_DEBUG
89940 if( db->flags&SQLITE_VdbeTrace ){
89941 printf("... %d steps and then skip\n", pOp->p1 - n);
89942 }
89943 #endif
89944 VdbeBranchTaken(1,3);
89945 pOp++;
89946 goto jump_to_p2;
89947 }
89948 if( res==0 ){
89949 #ifdef SQLITE_DEBUG
89950 if( db->flags&SQLITE_VdbeTrace ){
89951 printf("... %d steps and then success\n", pOp->p1 - n);
89952 }
89953 #endif
89954 VdbeBranchTaken(2,3);
89955 pOp += 2;
89956 break;
89957 }
89958 if( n<=0 ){
89959 #ifdef SQLITE_DEBUG
89960 if( db->flags&SQLITE_VdbeTrace ){
89961 printf("... fall through after %d steps\n", pOp->p1);
89962 }
89963 #endif
89964 VdbeBranchTaken(0,3);
89965 break;
89966 }
89967 n--;
89968 rc = sqlite3BtreeNext(pC->uc.pCursor, 0);
89969 if( rc ){
89970 if( rc==SQLITE_DONE ){
89971 rc = SQLITE_OK;
89972 goto seekscan_search_fail;
89973 }else{
89974 goto abort_due_to_error;
89975 }
89976 }
89977 }
89978
89979 break;
89980 }
89981
89982
89983 /* Opcode: SeekHit P1 P2 P3 * *
89984 ** Synopsis: set P2<=seekHit<=P3
89985 **
89986 ** Increase or decrease the seekHit value for cursor P1, if necessary,
@@ -91361,22 +91509,45 @@
91509 assert( memIsValid(&r.aMem[i]) );
91510 REGISTER_TRACE(pOp->p3+i, &aMem[pOp->p3+i]);
91511 }
91512 }
91513 #endif
91514
91515 /* Inlined version of sqlite3VdbeIdxKeyCompare() */
91516 {
91517 i64 nCellKey = 0;
91518 BtCursor *pCur;
91519 Mem m;
91520
91521 assert( pC->eCurType==CURTYPE_BTREE );
91522 pCur = pC->uc.pCursor;
91523 assert( sqlite3BtreeCursorIsValid(pCur) );
91524 nCellKey = sqlite3BtreePayloadSize(pCur);
91525 /* nCellKey will always be between 0 and 0xffffffff because of the way
91526 ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
91527 if( nCellKey<=0 || nCellKey>0x7fffffff ){
91528 rc = SQLITE_CORRUPT_BKPT;
91529 goto abort_due_to_error;
91530 }
91531 sqlite3VdbeMemInit(&m, db, 0);
91532 rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
91533 if( rc ) goto abort_due_to_error;
91534 res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0);
91535 sqlite3VdbeMemRelease(&m);
91536 }
91537 /* End of inlined sqlite3VdbeIdxKeyCompare() */
91538
91539 assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
91540 if( (pOp->opcode&1)==(OP_IdxLT&1) ){
91541 assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );
91542 res = -res;
91543 }else{
91544 assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );
91545 res++;
91546 }
91547 VdbeBranchTaken(res>0,2);
91548 assert( rc==SQLITE_OK );
91549 if( res>0 ) goto jump_to_p2;
91550 break;
91551 }
91552
91553 /* Opcode: Destroy P1 P2 P3 * *
@@ -132969,12 +133140,11 @@
133140 pNew = sqlite3ExprDup(db, pCopy, 0);
133141 if( pNew && pSubst->isLeftJoin ){
133142 ExprSetProperty(pNew, EP_CanBeNull);
133143 }
133144 if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
133145 sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
 
133146 }
133147 sqlite3ExprDelete(db, pExpr);
133148 pExpr = pNew;
133149
133150 /* Ensure that the expression now has an implicit collation sequence,
@@ -141334,13 +141504,15 @@
141504 u16 eOperator; /* A WO_xx value describing <op> */
141505 u8 nChild; /* Number of children that must disable us */
141506 u8 eMatchOp; /* Op for vtab MATCH/LIKE/GLOB/REGEXP terms */
141507 int iParent; /* Disable pWC->a[iParent] when this term disabled */
141508 int leftCursor; /* Cursor number of X in "X <op> <expr>" */
 
141509 union {
141510 struct {
141511 int leftColumn; /* Column number of X in "X <op> <expr>" */
141512 int iField; /* Field in (?,?,?) IN (SELECT...) vector */
141513 } x; /* Opcode other than OP_OR or OP_AND */
141514 WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */
141515 WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */
141516 } u;
141517 Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
141518 Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */
@@ -141690,10 +141862,11 @@
141862 #define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
141863 #define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
141864 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
141865 #define WHERE_IN_EARLYOUT 0x00040000 /* Perhaps quit IN loops early */
141866 #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
141867 #define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
141868
141869 #endif /* !defined(SQLITE_WHEREINT_H) */
141870
141871 /************** End of whereInt.h ********************************************/
141872 /************** Continuing where we left off in wherecode.c ******************/
@@ -142103,11 +142276,11 @@
142276 int i; /* Loop counter */
142277 Select *pSelect; /* Pointer to the SELECT on the RHS */
142278
142279 for(i=iEq; i<pLoop->nLTerm; i++){
142280 if( pLoop->aLTerm[i]->pExpr==pX ){
142281 int iField = pLoop->aLTerm[i]->u.x.iField - 1;
142282 if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */
142283 pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr);
142284 pOrigRhs->a[iField].pExpr = 0;
142285 assert( pOrigLhs->a[iField].pExpr!=0 );
142286 pLhs = sqlite3ExprListAppend(pParse, pLhs, pOrigLhs->a[iField].pExpr);
@@ -142246,11 +142419,11 @@
142419
142420 pLoop->wsFlags |= WHERE_IN_ABLE;
142421 if( pLevel->u.in.nIn==0 ){
142422 pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
142423 }
142424 if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){
142425 pLoop->wsFlags |= WHERE_IN_EARLYOUT;
142426 }
142427
142428 i = pLevel->u.in.nIn;
142429 pLevel->u.in.nIn += nEq;
@@ -142284,11 +142457,11 @@
142457 pIn->eEndLoopOp = OP_Noop;
142458 }
142459 pIn++;
142460 }
142461 }
142462 if( iEq>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0 ){
142463 sqlite3VdbeAddOp3(v, OP_SeekHit, pLevel->iIdxCur, 0, iEq);
142464 }
142465 }else{
142466 pLevel->u.in.nIn = 0;
142467 }
@@ -143439,12 +143612,11 @@
143612 nConstraint = nEq;
143613 if( pRangeStart ){
143614 Expr *pRight = pRangeStart->pExpr->pRight;
143615 codeExprOrVector(pParse, pRight, regBase+nEq, nBtm);
143616 whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
143617 if( (pRangeStart->wtFlags & TERM_VNULL)==0
 
143618 && sqlite3ExprCanBeNull(pRight)
143619 ){
143620 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
143621 VdbeCoverage(v);
143622 }
@@ -143480,10 +143652,24 @@
143652 VdbeComment((v, "NULL-scan pass ctr"));
143653 }
143654
143655 op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
143656 assert( op!=0 );
143657 if( (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 ){
143658 assert( op==OP_SeekGE );
143659 assert( regBignull==0 );
143660 /* TUNING: The OP_SeekScan opcode seeks to reduce the number
143661 ** of expensive seek operations by replacing a single seek with
143662 ** 1 or more step operations. The question is, how many steps
143663 ** should we try before giving up and going with a seek. The cost
143664 ** of a seek is proportional to the logarithm of the of the number
143665 ** of entries in the tree, so basing the number of steps to try
143666 ** on the estimated number of rows in the btree seems like a good
143667 ** guess. */
143668 sqlite3VdbeAddOp1(v, OP_SeekScan, (pIdx->aiRowLogEst[0]+9)/10);
143669 VdbeCoverage(v);
143670 }
143671 sqlite3VdbeAddOp4Int(v, op, iIdxCur, addrNxt, regBase, nConstraint);
143672 VdbeCoverage(v);
143673 VdbeCoverageIf(v, op==OP_Rewind); testcase( op==OP_Rewind );
143674 VdbeCoverageIf(v, op==OP_Last); testcase( op==OP_Last );
143675 VdbeCoverageIf(v, op==OP_SeekGT); testcase( op==OP_SeekGT );
@@ -143515,12 +143701,11 @@
143701 nConstraint = nEq;
143702 if( pRangeEnd ){
143703 Expr *pRight = pRangeEnd->pExpr->pRight;
143704 codeExprOrVector(pParse, pRight, regBase+nEq, nTop);
143705 whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
143706 if( (pRangeEnd->wtFlags & TERM_VNULL)==0
 
143707 && sqlite3ExprCanBeNull(pRight)
143708 ){
143709 sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt);
143710 VdbeCoverage(v);
143711 }
@@ -143582,11 +143767,11 @@
143767 testcase( op==OP_IdxGE ); VdbeCoverageIf(v, op==OP_IdxGE );
143768 testcase( op==OP_IdxLT ); VdbeCoverageIf(v, op==OP_IdxLT );
143769 testcase( op==OP_IdxLE ); VdbeCoverageIf(v, op==OP_IdxLE );
143770 }
143771
143772 if( (pLoop->wsFlags & WHERE_IN_EARLYOUT)!=0 ){
143773 sqlite3VdbeAddOp3(v, OP_SeekHit, iIdxCur, nEq, nEq);
143774 }
143775
143776 /* Seek the table cursor, if required */
143777 omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
@@ -144090,11 +144275,11 @@
144275 sqlite3WhereTermPrint(pTerm, pWC->nTerm-j);
144276 }
144277 #endif
144278 assert( !ExprHasProperty(pE, EP_FromJoin) );
144279 assert( (pTerm->prereqRight & pLevel->notReady)!=0 );
144280 pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.x.leftColumn, notReady,
144281 WO_EQ|WO_IN|WO_IS, 0);
144282 if( pAlt==0 ) continue;
144283 if( pAlt->wtFlags & (TERM_CODED) ) continue;
144284 if( (pAlt->eOperator & WO_IN)
144285 && (pAlt->pExpr->flags & EP_xIsSelect)
@@ -144946,11 +145131,11 @@
145131 testcase( pOrTerm->wtFlags & TERM_COPIED );
145132 testcase( pOrTerm->wtFlags & TERM_VIRTUAL );
145133 assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) );
145134 continue;
145135 }
145136 iColumn = pOrTerm->u.x.leftColumn;
145137 iCursor = pOrTerm->leftCursor;
145138 pLeft = pOrTerm->pExpr->pLeft;
145139 break;
145140 }
145141 if( i<0 ){
@@ -144968,11 +145153,11 @@
145153 okToChngToIN = 1;
145154 for(; i>=0 && okToChngToIN; i--, pOrTerm++){
145155 assert( pOrTerm->eOperator & WO_EQ );
145156 if( pOrTerm->leftCursor!=iCursor ){
145157 pOrTerm->wtFlags &= ~TERM_OR_OK;
145158 }else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR
145159 && sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
145160 )){
145161 okToChngToIN = 0;
145162 }else{
145163 int affLeft, affRight;
@@ -145003,11 +145188,11 @@
145188
145189 for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
145190 if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
145191 assert( pOrTerm->eOperator & WO_EQ );
145192 assert( pOrTerm->leftCursor==iCursor );
145193 assert( pOrTerm->u.x.leftColumn==iColumn );
145194 pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0);
145195 pList = sqlite3ExprListAppend(pWInfo->pParse, pList, pDup);
145196 pLeft = pOrTerm->pExpr->pLeft;
145197 }
145198 assert( pLeft!=0 );
@@ -145239,29 +145424,29 @@
145424 int aiCurCol[2];
145425 Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft);
145426 Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight);
145427 u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV;
145428
145429 if( pTerm->u.x.iField>0 ){
145430 assert( op==TK_IN );
145431 assert( pLeft->op==TK_VECTOR );
145432 pLeft = pLeft->x.pList->a[pTerm->u.x.iField-1].pExpr;
145433 }
145434
145435 if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){
145436 pTerm->leftCursor = aiCurCol[0];
145437 pTerm->u.x.leftColumn = aiCurCol[1];
145438 pTerm->eOperator = operatorMask(op) & opMask;
145439 }
145440 if( op==TK_IS ) pTerm->wtFlags |= TERM_IS;
145441 if( pRight
145442 && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op)
145443 ){
145444 WhereTerm *pNew;
145445 Expr *pDup;
145446 u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */
145447 assert( pTerm->u.x.iField==0 );
145448 if( pTerm->leftCursor>=0 ){
145449 int idxNew;
145450 pDup = sqlite3ExprDup(db, pExpr, 0);
145451 if( db->mallocFailed ){
145452 sqlite3ExprDelete(db, pDup);
@@ -145283,11 +145468,11 @@
145468 pDup = pExpr;
145469 pNew = pTerm;
145470 }
145471 pNew->wtFlags |= exprCommute(pParse, pDup);
145472 pNew->leftCursor = aiCurCol[0];
145473 pNew->u.x.leftColumn = aiCurCol[1];
145474 testcase( (prereqLeft | extraRight) != prereqLeft );
145475 pNew->prereqRight = prereqLeft | extraRight;
145476 pNew->prereqAll = prereqAll;
145477 pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;
145478 }
@@ -145457,11 +145642,11 @@
145642 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
145643 testcase( idxNew==0 );
145644 pNewTerm = &pWC->a[idxNew];
145645 pNewTerm->prereqRight = prereqExpr;
145646 pNewTerm->leftCursor = pLeft->iTable;
145647 pNewTerm->u.x.leftColumn = pLeft->iColumn;
145648 pNewTerm->eOperator = WO_AUX;
145649 pNewTerm->eMatchOp = eOp2;
145650 markTermAsChild(pWC, idxNew, idxTerm);
145651 pTerm = &pWC->a[idxTerm];
145652 pTerm->wtFlags |= TERM_COPIED;
@@ -145504,17 +145689,17 @@
145689 }
145690
145691 /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
145692 ** a virtual term for each vector component. The expression object
145693 ** used by each such virtual term is pExpr (the full vector IN(...)
145694 ** expression). The WhereTerm.u.x.iField variable identifies the index within
145695 ** the vector on the LHS that the virtual term represents.
145696 **
145697 ** This only works if the RHS is a simple SELECT (not a compound) that does
145698 ** not use window functions.
145699 */
145700 if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->u.x.iField==0
145701 && pExpr->pLeft->op==TK_VECTOR
145702 && pExpr->x.pSelect->pPrior==0
145703 #ifndef SQLITE_OMIT_WINDOWFUNC
145704 && pExpr->x.pSelect->pWin==0
145705 #endif
@@ -145521,11 +145706,11 @@
145706 ){
145707 int i;
145708 for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
145709 int idxNew;
145710 idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
145711 pWC->a[idxNew].u.x.iField = i+1;
145712 exprAnalyze(pSrc, pWC, idxNew);
145713 markTermAsChild(pWC, idxNew, idxTerm);
145714 }
145715 }
145716
@@ -145556,11 +145741,11 @@
145741 TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL);
145742 if( idxNew ){
145743 pNewTerm = &pWC->a[idxNew];
145744 pNewTerm->prereqRight = 0;
145745 pNewTerm->leftCursor = pLeft->iTable;
145746 pNewTerm->u.x.leftColumn = pLeft->iColumn;
145747 pNewTerm->eOperator = WO_GT;
145748 markTermAsChild(pWC, idxNew, idxTerm);
145749 pTerm = &pWC->a[idxTerm];
145750 pTerm->wtFlags |= TERM_COPIED;
145751 pNewTerm->prereqAll = pTerm->prereqAll;
@@ -146020,11 +146205,11 @@
146205 iCur = pScan->aiCur[pScan->iEquiv-1];
146206 assert( pWC!=0 );
146207 do{
146208 for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
146209 if( pTerm->leftCursor==iCur
146210 && pTerm->u.x.leftColumn==iColumn
146211 && (iColumn!=XN_EXPR
146212 || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
146213 pScan->pIdxExpr,iCur)==0)
146214 && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
146215 ){
@@ -146442,12 +146627,12 @@
146627 ** the RHS of a LEFT JOIN. Such a term can only be used if it is from
146628 ** the ON clause. */
146629 return 0;
146630 }
146631 if( (pTerm->prereqRight & notReady)!=0 ) return 0;
146632 if( pTerm->u.x.leftColumn<0 ) return 0;
146633 aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity;
146634 if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0;
146635 testcase( pTerm->pExpr->op==TK_IS );
146636 return 1;
146637 }
146638 #endif
@@ -146514,11 +146699,11 @@
146699 && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
146700 pPartial = sqlite3ExprAnd(pParse, pPartial,
146701 sqlite3ExprDup(pParse->db, pExpr, 0));
146702 }
146703 if( termCanDriveIndex(pTerm, pSrc, notReady) ){
146704 int iCol = pTerm->u.x.leftColumn;
146705 Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
146706 testcase( iCol==BMS );
146707 testcase( iCol==BMS-1 );
146708 if( !sentWarning ){
146709 sqlite3_log(SQLITE_WARNING_AUTOINDEX,
@@ -146567,18 +146752,18 @@
146752 pIdx->pTable = pTable;
146753 n = 0;
146754 idxCols = 0;
146755 for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
146756 if( termCanDriveIndex(pTerm, pSrc, notReady) ){
146757 int iCol = pTerm->u.x.leftColumn;
146758 Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
146759 testcase( iCol==BMS-1 );
146760 testcase( iCol==BMS );
146761 if( (idxCols & cMask)==0 ){
146762 Expr *pX = pTerm->pExpr;
146763 idxCols |= cMask;
146764 pIdx->aiColumn[n] = pTerm->u.x.leftColumn;
146765 pColl = sqlite3ExprCompareCollSeq(pParse, pX);
146766 assert( pColl!=0 || pParse->nErr>0 ); /* TH3 collate01.800 */
146767 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
146768 n++;
146769 }
@@ -146695,11 +146880,11 @@
146880 testcase( pTerm->eOperator & WO_ISNULL );
146881 testcase( pTerm->eOperator & WO_IS );
146882 testcase( pTerm->eOperator & WO_ALL );
146883 if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
146884 if( pTerm->wtFlags & TERM_VNULL ) continue;
146885 assert( pTerm->u.x.leftColumn>=(-1) );
146886 nTerm++;
146887 }
146888
146889 /* If the ORDER BY clause contains only columns in the current
146890 ** virtual table then allocate space for the aOrderBy part of
@@ -146755,12 +146940,12 @@
146940 if( (pSrc->fg.jointype & JT_LEFT)!=0
146941 && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
146942 ){
146943 continue;
146944 }
146945 assert( pTerm->u.x.leftColumn>=(-1) );
146946 pIdxCons[j].iColumn = pTerm->u.x.leftColumn;
146947 pIdxCons[j].iTermOffset = i;
146948 op = pTerm->eOperator & WO_ALL;
146949 if( op==WO_IN ) op = WO_EQ;
146950 if( op==WO_AUX ){
146951 pIdxCons[j].op = pTerm->eMatchOp;
@@ -147519,11 +147704,11 @@
147704 if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E';
147705 if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L';
147706 if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C';
147707 if( pTerm->eOperator & WO_SINGLE ){
147708 sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}",
147709 pTerm->leftCursor, pTerm->u.x.leftColumn);
147710 }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){
147711 sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld",
147712 pTerm->u.pOrInfo->indexable);
147713 }else{
147714 sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor);
@@ -147535,12 +147720,12 @@
147720 ** shown about each Term */
147721 if( sqlite3WhereTrace & 0x10000 ){
147722 sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx",
147723 pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight);
147724 }
147725 if( pTerm->u.x.iField ){
147726 sqlite3DebugPrintf(" iField=%d", pTerm->u.x.iField);
147727 }
147728 if( pTerm->iParent>=0 ){
147729 sqlite3DebugPrintf(" iParent=%d", pTerm->iParent);
147730 }
147731 sqlite3DebugPrintf("\n");
@@ -148327,11 +148512,11 @@
148512 safetyMargin = 10; /* TUNING: extra weight for indexed IN */
148513 if( M + logK + safetyMargin < nIn + rLogSize ){
148514 WHERETRACE(0x40,
148515 ("Scan preferred over IN operator on column %d of \"%s\" (%d<%d)\n",
148516 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
148517 pNew->wsFlags |= WHERE_IN_SEEKSCAN;
148518 }else{
148519 WHERETRACE(0x40,
148520 ("IN operator preferred on column %d of \"%s\" (%d>=%d)\n",
148521 saved_nEq, pProbe->zName, M+logK+10, nIn+rLogSize));
148522 }
@@ -150960,10 +151145,11 @@
151145 sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
151146 sqlite3VdbeSetP4KeyInfo(pParse, pIx);
151147 if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
151148 && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
151149 && (pLoop->wsFlags & WHERE_BIGNULL_SORT)==0
151150 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)==0
151151 && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
151152 && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED
151153 ){
151154 sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ);
151155 }
@@ -151122,11 +151308,13 @@
151308 sqlite3VdbeResolveLabel(v, pLevel->addrNxt);
151309 for(j=pLevel->u.in.nIn, pIn=&pLevel->u.in.aInLoop[j-1]; j>0; j--, pIn--){
151310 sqlite3VdbeJumpHere(v, pIn->addrInTop+1);
151311 if( pIn->eEndLoopOp!=OP_Noop ){
151312 if( pIn->nPrefix ){
151313 int bEarlyOut =
151314 (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0
151315 && (pLoop->wsFlags & WHERE_IN_EARLYOUT)!=0;
151316 if( pLevel->iLeftJoin ){
151317 /* For LEFT JOIN queries, cursor pIn->iCur may not have been
151318 ** opened yet. This occurs for WHERE clauses such as
151319 ** "a = ? AND b IN (...)", where the index is on (a, b). If
151320 ** the RHS of the (a=?) is NULL, then the "b IN (...)" may
@@ -151133,16 +151321,14 @@
151321 ** never have been coded, but the body of the loop run to
151322 ** return the null-row. So, if the cursor is not open yet,
151323 ** jump over the OP_Next or OP_Prev instruction about to
151324 ** be coded. */
151325 sqlite3VdbeAddOp2(v, OP_IfNotOpen, pIn->iCur,
151326 sqlite3VdbeCurrentAddr(v) + 2 + bEarlyOut);
 
 
151327 VdbeCoverage(v);
151328 }
151329 if( bEarlyOut ){
151330 sqlite3VdbeAddOp4Int(v, OP_IfNoHope, pLevel->iIdxCur,
151331 sqlite3VdbeCurrentAddr(v)+2,
151332 pIn->iBase, pIn->nPrefix);
151333 VdbeCoverage(v);
151334 }
@@ -157827,12 +158013,13 @@
158013 int yysize; /* Amount to pop the stack */
158014 sqlite3ParserARG_FETCH
158015 (void)yyLookahead;
158016 (void)yyLookaheadToken;
158017 yymsp = yypParser->yytos;
158018 assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) );
158019 #ifndef NDEBUG
158020 if( yyTraceFILE ){
158021 yysize = yyRuleInfoNRhs[yyruleno];
158022 if( yysize ){
158023 fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
158024 yyTracePrompt,
158025 yyruleno, yyRuleName[yyruleno],
@@ -209390,11 +209577,11 @@
209577 static int sqlite3Fts5IndexSetAverages(Fts5Index *p, const u8*, int);
209578
209579 /*
209580 ** Functions called by the storage module as part of integrity-check.
209581 */
209582 static int sqlite3Fts5IndexIntegrityCheck(Fts5Index*, u64 cksum, int bUseCksum);
209583
209584 /*
209585 ** Called during virtual module initialization to register UDF
209586 ** fts5_decode() with SQLite
209587 */
@@ -209545,11 +209732,11 @@
209732
209733 static int sqlite3Fts5StorageDelete(Fts5Storage *p, i64, sqlite3_value**);
209734 static int sqlite3Fts5StorageContentInsert(Fts5Storage *p, sqlite3_value**, i64*);
209735 static int sqlite3Fts5StorageIndexInsert(Fts5Storage *p, sqlite3_value**, i64);
209736
209737 static int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg);
209738
209739 static int sqlite3Fts5StorageStmt(Fts5Storage *p, int eStmt, sqlite3_stmt**, char**);
209740 static void sqlite3Fts5StorageStmtRelease(Fts5Storage *p, int eStmt, sqlite3_stmt*);
209741
209742 static int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol);
@@ -210735,12 +210922,13 @@
210922 int fts5yysize; /* Amount to pop the stack */
210923 sqlite3Fts5ParserARG_FETCH
210924 (void)fts5yyLookahead;
210925 (void)fts5yyLookaheadToken;
210926 fts5yymsp = fts5yypParser->fts5yytos;
210927 assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) );
210928 #ifndef NDEBUG
210929 if( fts5yyTraceFILE ){
210930 fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
210931 if( fts5yysize ){
210932 fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n",
210933 fts5yyTracePrompt,
210934 fts5yyruleno, fts5yyRuleName[fts5yyruleno],
@@ -222842,11 +223030,11 @@
223030 ** Return SQLITE_CORRUPT if any of the internal checks fail, or if the
223031 ** checksum does not match. Return SQLITE_OK if all checks pass without
223032 ** error, or some other SQLite error code if another error (e.g. OOM)
223033 ** occurs.
223034 */
223035 static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum){
223036 int eDetail = p->pConfig->eDetail;
223037 u64 cksum2 = 0; /* Checksum based on contents of indexes */
223038 Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */
223039 Fts5Iter *pIter; /* Used to iterate through entire index */
223040 Fts5Structure *pStruct; /* Index structure */
@@ -222913,11 +223101,11 @@
223101 }
223102 }
223103 fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);
223104
223105 fts5MultiIterFree(pIter);
223106 if( p->rc==SQLITE_OK && bUseCksum && cksum!=cksum2 ) p->rc = FTS5_CORRUPT;
223107
223108 fts5StructureRelease(pStruct);
223109 #ifdef SQLITE_DEBUG
223110 fts5BufferFree(&term);
223111 #endif
@@ -224921,11 +225109,12 @@
225109 rc = sqlite3Fts5StorageOptimize(pTab->pStorage);
225110 }else if( 0==sqlite3_stricmp("merge", zCmd) ){
225111 int nMerge = sqlite3_value_int(pVal);
225112 rc = sqlite3Fts5StorageMerge(pTab->pStorage, nMerge);
225113 }else if( 0==sqlite3_stricmp("integrity-check", zCmd) ){
225114 int iArg = sqlite3_value_int(pVal);
225115 rc = sqlite3Fts5StorageIntegrity(pTab->pStorage, iArg);
225116 #ifdef SQLITE_DEBUG
225117 }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){
225118 pConfig->bPrefixIndex = sqlite3_value_int(pVal);
225119 #endif
225120 }else{
@@ -226155,11 +226344,11 @@
226344 int nArg, /* Number of args */
226345 sqlite3_value **apUnused /* Function arguments */
226346 ){
226347 assert( nArg==0 );
226348 UNUSED_PARAM2(nArg, apUnused);
226349 sqlite3_result_text(pCtx, "fts5: 2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c402e5", -1, SQLITE_TRANSIENT);
226350 }
226351
226352 /*
226353 ** Return true if zName is the extension on one of the shadow tables used
226354 ** by this module.
@@ -227170,102 +227359,108 @@
227359 ** Check that the contents of the FTS index match that of the %_content
227360 ** table. Return SQLITE_OK if they do, or SQLITE_CORRUPT if not. Return
227361 ** some other SQLite error code if an error occurs while attempting to
227362 ** determine this.
227363 */
227364 static int sqlite3Fts5StorageIntegrity(Fts5Storage *p, int iArg){
227365 Fts5Config *pConfig = p->pConfig;
227366 int rc = SQLITE_OK; /* Return code */
227367 int *aColSize; /* Array of size pConfig->nCol */
227368 i64 *aTotalSize; /* Array of size pConfig->nCol */
227369 Fts5IntegrityCtx ctx;
227370 sqlite3_stmt *pScan;
227371 int bUseCksum;
227372
227373 memset(&ctx, 0, sizeof(Fts5IntegrityCtx));
227374 ctx.pConfig = p->pConfig;
227375 aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));
227376 if( !aTotalSize ) return SQLITE_NOMEM;
227377 aColSize = (int*)&aTotalSize[pConfig->nCol];
227378 memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);
227379
227380 bUseCksum = (pConfig->eContent==FTS5_CONTENT_NORMAL
227381 || (pConfig->eContent==FTS5_CONTENT_EXTERNAL && iArg)
227382 );
227383 if( bUseCksum ){
227384 /* Generate the expected index checksum based on the contents of the
227385 ** %_content table. This block stores the checksum in ctx.cksum. */
227386 rc = fts5StorageGetStmt(p, FTS5_STMT_SCAN, &pScan, 0);
227387 if( rc==SQLITE_OK ){
227388 int rc2;
227389 while( SQLITE_ROW==sqlite3_step(pScan) ){
227390 int i;
227391 ctx.iRowid = sqlite3_column_int64(pScan, 0);
227392 ctx.szCol = 0;
227393 if( pConfig->bColumnsize ){
227394 rc = sqlite3Fts5StorageDocsize(p, ctx.iRowid, aColSize);
227395 }
227396 if( rc==SQLITE_OK && pConfig->eDetail==FTS5_DETAIL_NONE ){
227397 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227398 }
227399 for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227400 if( pConfig->abUnindexed[i] ) continue;
227401 ctx.iCol = i;
227402 ctx.szCol = 0;
227403 if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227404 rc = sqlite3Fts5TermsetNew(&ctx.pTermset);
227405 }
227406 if( rc==SQLITE_OK ){
227407 const char *zText = (const char*)sqlite3_column_text(pScan, i+1);
227408 int nText = sqlite3_column_bytes(pScan, i+1);
227409 rc = sqlite3Fts5Tokenize(pConfig,
227410 FTS5_TOKENIZE_DOCUMENT,
227411 zText, nText,
227412 (void*)&ctx,
227413 fts5StorageIntegrityCallback
227414 );
227415 }
227416 if( rc==SQLITE_OK && pConfig->bColumnsize && ctx.szCol!=aColSize[i] ){
227417 rc = FTS5_CORRUPT;
227418 }
227419 aTotalSize[i] += ctx.szCol;
227420 if( pConfig->eDetail==FTS5_DETAIL_COLUMNS ){
227421 sqlite3Fts5TermsetFree(ctx.pTermset);
227422 ctx.pTermset = 0;
227423 }
227424 }
227425 sqlite3Fts5TermsetFree(ctx.pTermset);
227426 ctx.pTermset = 0;
227427
227428 if( rc!=SQLITE_OK ) break;
227429 }
227430 rc2 = sqlite3_reset(pScan);
227431 if( rc==SQLITE_OK ) rc = rc2;
227432 }
227433
227434 /* Test that the "totals" (sometimes called "averages") record looks Ok */
227435 if( rc==SQLITE_OK ){
227436 int i;
227437 rc = fts5StorageLoadTotals(p, 0);
227438 for(i=0; rc==SQLITE_OK && i<pConfig->nCol; i++){
227439 if( p->aTotalSize[i]!=aTotalSize[i] ) rc = FTS5_CORRUPT;
227440 }
227441 }
227442
227443 /* Check that the %_docsize and %_content tables contain the expected
227444 ** number of rows. */
227445 if( rc==SQLITE_OK && pConfig->eContent==FTS5_CONTENT_NORMAL ){
227446 i64 nRow = 0;
227447 rc = fts5StorageCount(p, "content", &nRow);
227448 if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
227449 }
227450 if( rc==SQLITE_OK && pConfig->bColumnsize ){
227451 i64 nRow = 0;
227452 rc = fts5StorageCount(p, "docsize", &nRow);
227453 if( rc==SQLITE_OK && nRow!=p->nTotalRow ) rc = FTS5_CORRUPT;
227454 }
227455 }
227456
227457 /* Pass the expected checksum down to the FTS index module. It will
227458 ** verify, amongst other things, that it matches the checksum generated by
227459 ** inspecting the index itself. */
227460 if( rc==SQLITE_OK ){
227461 rc = sqlite3Fts5IndexIntegrityCheck(p->pIndex, ctx.cksum, bUseCksum);
227462 }
227463
227464 sqlite3_free(aTotalSize);
227465 return rc;
227466 }
@@ -230945,12 +231140,12 @@
231140 }
231141 #endif /* SQLITE_CORE */
231142 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
231143
231144 /************** End of stmt.c ************************************************/
231145 #if __LINE__!=231145
231146 #undef SQLITE_SOURCE_ID
231147 #define SQLITE_SOURCE_ID "2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c4alt2"
231148 #endif
231149 /* Return the source-id for this library */
231150 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
231151 /************************** End of sqlite3.c ******************************/
231152
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.34.0"
127127
#define SQLITE_VERSION_NUMBER 3034000
128
-#define SQLITE_SOURCE_ID "2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8afa3"
128
+#define SQLITE_SOURCE_ID "2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c402e5"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
134134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.34.0"
127 #define SQLITE_VERSION_NUMBER 3034000
128 #define SQLITE_SOURCE_ID "2020-09-17 21:11:25 4542d194e2fef5e21e1c3679914bd9e21fab31cfb111cf640524fb3514a8afa3"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.34.0"
127 #define SQLITE_VERSION_NUMBER 3034000
128 #define SQLITE_SOURCE_ID "2020-09-30 18:06:51 4a43430fd23f88352c33b29c4c105b72f6dc821f94bf362040c41a1648c402e5"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button