Fossil SCM

Have Fossil use the new "PRAGMA optimize" feature of SQLite 3.18.0 alpha.

drh 2017-03-10 17:30 trunk merge
Commit 7815d015f3b5a663cdbfd140b0573f94c3aed1ea79a3344413c0986067b30b45
4 files changed +1 +1464 -950 +36 -16 +64 -2
+1
--- src/db.c
+++ src/db.c
@@ -1662,10 +1662,11 @@
16621662
while( db.pAllStmt ){
16631663
db_finalize(db.pAllStmt);
16641664
}
16651665
db_end_transaction(1);
16661666
pStmt = 0;
1667
+ sqlite3_exec(g.db, "PRAGMA optimize", 0, 0, 0);
16671668
db_close_config();
16681669
16691670
/* If the localdb has a lot of unused free space,
16701671
** then VACUUM it as we shut down.
16711672
*/
16721673
--- src/db.c
+++ src/db.c
@@ -1662,10 +1662,11 @@
1662 while( db.pAllStmt ){
1663 db_finalize(db.pAllStmt);
1664 }
1665 db_end_transaction(1);
1666 pStmt = 0;
 
1667 db_close_config();
1668
1669 /* If the localdb has a lot of unused free space,
1670 ** then VACUUM it as we shut down.
1671 */
1672
--- src/db.c
+++ src/db.c
@@ -1662,10 +1662,11 @@
1662 while( db.pAllStmt ){
1663 db_finalize(db.pAllStmt);
1664 }
1665 db_end_transaction(1);
1666 pStmt = 0;
1667 sqlite3_exec(g.db, "PRAGMA optimize", 0, 0, 0);
1668 db_close_config();
1669
1670 /* If the localdb has a lot of unused free space,
1671 ** then VACUUM it as we shut down.
1672 */
1673
+1464 -950
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.17.0. By combining all the individual C code files into this
3
+** version 3.18.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -396,13 +396,13 @@
396396
**
397397
** See also: [sqlite3_libversion()],
398398
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399399
** [sqlite_version()] and [sqlite_source_id()].
400400
*/
401
-#define SQLITE_VERSION "3.17.0"
402
-#define SQLITE_VERSION_NUMBER 3017000
403
-#define SQLITE_SOURCE_ID "2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c"
401
+#define SQLITE_VERSION "3.18.0"
402
+#define SQLITE_VERSION_NUMBER 3018000
403
+#define SQLITE_SOURCE_ID "2017-03-06 17:33:58 137aeb2b160888100bc1e871b00860149e5f6196"
404404
405405
/*
406406
** CAPI3REF: Run-Time Library Version Numbers
407407
** KEYWORDS: sqlite3_version sqlite3_sourceid
408408
**
@@ -2315,24 +2315,34 @@
23152315
** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
23162316
** names are not also used by explicitly declared columns. ^If
23172317
** the table has a column of type [INTEGER PRIMARY KEY] then that column
23182318
** is another alias for the rowid.
23192319
**
2320
-** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
2321
-** most recent successful [INSERT] into a rowid table or [virtual table]
2322
-** on database connection D.
2323
-** ^Inserts into [WITHOUT ROWID] tables are not recorded.
2324
-** ^If no successful [INSERT]s into rowid tables
2325
-** have ever occurred on the database connection D,
2326
-** then sqlite3_last_insert_rowid(D) returns zero.
2320
+** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of
2321
+** the most recent successful [INSERT] into a rowid table or [virtual table]
2322
+** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not
2323
+** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred
2324
+** on the database connection D, then sqlite3_last_insert_rowid(D) returns
2325
+** zero.
23272326
**
2328
-** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
2329
-** method, then this routine will return the [rowid] of the inserted
2330
-** row as long as the trigger or virtual table method is running.
2331
-** But once the trigger or virtual table method ends, the value returned
2332
-** by this routine reverts to what it was before the trigger or virtual
2333
-** table method began.)^
2327
+** As well as being set automatically as rows are inserted into database
2328
+** tables, the value returned by this function may be set explicitly by
2329
+** [sqlite3_set_last_insert_rowid()]
2330
+**
2331
+** Some virtual table implementations may INSERT rows into rowid tables as
2332
+** part of committing a transaction (e.g. to flush data accumulated in memory
2333
+** to disk). In this case subsequent calls to this function return the rowid
2334
+** associated with these internal INSERT operations, which leads to
2335
+** unintuitive results. Virtual table implementations that do write to rowid
2336
+** tables in this way can avoid this problem by restoring the original
2337
+** rowid value using [sqlite3_set_last_insert_rowid()] before returning
2338
+** control to the user.
2339
+**
2340
+** ^(If an [INSERT] occurs within a trigger then this routine will
2341
+** return the [rowid] of the inserted row as long as the trigger is
2342
+** running. Once the trigger program ends, the value returned
2343
+** by this routine reverts to what it was before the trigger was fired.)^
23342344
**
23352345
** ^An [INSERT] that fails due to a constraint violation is not a
23362346
** successful [INSERT] and does not change the value returned by this
23372347
** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
23382348
** and INSERT OR ABORT make no changes to the return value of this
@@ -2355,10 +2365,20 @@
23552365
** unpredictable and might not equal either the old or the new
23562366
** last insert [rowid].
23572367
*/
23582368
SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
23592369
2370
+/*
2371
+** CAPI3REF: Set the Last Insert Rowid value.
2372
+** METHOD: sqlite3
2373
+**
2374
+** The sqlite3_set_last_insert_rowid(D, R) method allows the application to
2375
+** set the value returned by calling sqlite3_last_insert_rowid(D) to R
2376
+** without inserting a row into the database.
2377
+*/
2378
+SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2379
+
23602380
/*
23612381
** CAPI3REF: Count The Number Of Rows Modified
23622382
** METHOD: sqlite3
23632383
**
23642384
** ^This function returns the number of rows modified, inserted or
@@ -12457,10 +12477,11 @@
1245712477
SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
1245812478
SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
1245912479
1246012480
SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
1246112481
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
12482
+SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
1246212483
1246312484
#ifndef SQLITE_OMIT_INCRBLOB
1246412485
SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);
1246512486
SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
1246612487
SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
@@ -12757,117 +12778,119 @@
1275712778
#define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
1275812779
#define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
1275912780
#define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
1276012781
#define OP_Last 53
1276112782
#define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12762
-#define OP_SorterSort 55
12763
-#define OP_Sort 56
12764
-#define OP_Rewind 57
12765
-#define OP_IdxLE 58 /* synopsis: key=r[P3@P4] */
12766
-#define OP_IdxGT 59 /* synopsis: key=r[P3@P4] */
12767
-#define OP_IdxLT 60 /* synopsis: key=r[P3@P4] */
12768
-#define OP_IdxGE 61 /* synopsis: key=r[P3@P4] */
12769
-#define OP_RowSetRead 62 /* synopsis: r[P3]=rowset(P1) */
12770
-#define OP_RowSetTest 63 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12771
-#define OP_Program 64
12772
-#define OP_FkIfZero 65 /* synopsis: if fkctr[P1]==0 goto P2 */
12773
-#define OP_IfPos 66 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12774
-#define OP_IfNotZero 67 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
12775
-#define OP_DecrJumpZero 68 /* synopsis: if (--r[P1])==0 goto P2 */
12776
-#define OP_IncrVacuum 69
12777
-#define OP_VNext 70
12778
-#define OP_Init 71 /* synopsis: Start at P2 */
12779
-#define OP_Return 72
12780
-#define OP_EndCoroutine 73
12781
-#define OP_HaltIfNull 74 /* synopsis: if r[P3]=null halt */
12782
-#define OP_Halt 75
12783
-#define OP_Integer 76 /* synopsis: r[P2]=P1 */
12784
-#define OP_Int64 77 /* synopsis: r[P2]=P4 */
12785
-#define OP_String 78 /* synopsis: r[P2]='P4' (len=P1) */
12786
-#define OP_Null 79 /* synopsis: r[P2..P3]=NULL */
12787
-#define OP_SoftNull 80 /* synopsis: r[P1]=NULL */
12788
-#define OP_Blob 81 /* synopsis: r[P2]=P4 (len=P1) */
12789
-#define OP_Variable 82 /* synopsis: r[P2]=parameter(P1,P4) */
12790
-#define OP_Move 83 /* synopsis: r[P2@P3]=r[P1@P3] */
12791
-#define OP_Copy 84 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12792
-#define OP_SCopy 85 /* synopsis: r[P2]=r[P1] */
12793
-#define OP_IntCopy 86 /* synopsis: r[P2]=r[P1] */
12794
-#define OP_ResultRow 87 /* synopsis: output=r[P1@P2] */
12795
-#define OP_CollSeq 88
12796
-#define OP_Function0 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12797
-#define OP_Function 90 /* synopsis: r[P3]=func(r[P2@P5]) */
12798
-#define OP_AddImm 91 /* synopsis: r[P1]=r[P1]+P2 */
12799
-#define OP_RealAffinity 92
12800
-#define OP_Cast 93 /* synopsis: affinity(r[P1]) */
12801
-#define OP_Permutation 94
12802
-#define OP_Compare 95 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12803
-#define OP_Column 96 /* synopsis: r[P3]=PX */
12783
+#define OP_IfSmaller 55
12784
+#define OP_SorterSort 56
12785
+#define OP_Sort 57
12786
+#define OP_Rewind 58
12787
+#define OP_IdxLE 59 /* synopsis: key=r[P3@P4] */
12788
+#define OP_IdxGT 60 /* synopsis: key=r[P3@P4] */
12789
+#define OP_IdxLT 61 /* synopsis: key=r[P3@P4] */
12790
+#define OP_IdxGE 62 /* synopsis: key=r[P3@P4] */
12791
+#define OP_RowSetRead 63 /* synopsis: r[P3]=rowset(P1) */
12792
+#define OP_RowSetTest 64 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12793
+#define OP_Program 65
12794
+#define OP_FkIfZero 66 /* synopsis: if fkctr[P1]==0 goto P2 */
12795
+#define OP_IfPos 67 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12796
+#define OP_IfNotZero 68 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
12797
+#define OP_DecrJumpZero 69 /* synopsis: if (--r[P1])==0 goto P2 */
12798
+#define OP_IncrVacuum 70
12799
+#define OP_VNext 71
12800
+#define OP_Init 72 /* synopsis: Start at P2 */
12801
+#define OP_Return 73
12802
+#define OP_EndCoroutine 74
12803
+#define OP_HaltIfNull 75 /* synopsis: if r[P3]=null halt */
12804
+#define OP_Halt 76
12805
+#define OP_Integer 77 /* synopsis: r[P2]=P1 */
12806
+#define OP_Int64 78 /* synopsis: r[P2]=P4 */
12807
+#define OP_String 79 /* synopsis: r[P2]='P4' (len=P1) */
12808
+#define OP_Null 80 /* synopsis: r[P2..P3]=NULL */
12809
+#define OP_SoftNull 81 /* synopsis: r[P1]=NULL */
12810
+#define OP_Blob 82 /* synopsis: r[P2]=P4 (len=P1) */
12811
+#define OP_Variable 83 /* synopsis: r[P2]=parameter(P1,P4) */
12812
+#define OP_Move 84 /* synopsis: r[P2@P3]=r[P1@P3] */
12813
+#define OP_Copy 85 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12814
+#define OP_SCopy 86 /* synopsis: r[P2]=r[P1] */
12815
+#define OP_IntCopy 87 /* synopsis: r[P2]=r[P1] */
12816
+#define OP_ResultRow 88 /* synopsis: output=r[P1@P2] */
12817
+#define OP_CollSeq 89
12818
+#define OP_Function0 90 /* synopsis: r[P3]=func(r[P2@P5]) */
12819
+#define OP_Function 91 /* synopsis: r[P3]=func(r[P2@P5]) */
12820
+#define OP_AddImm 92 /* synopsis: r[P1]=r[P1]+P2 */
12821
+#define OP_RealAffinity 93
12822
+#define OP_Cast 94 /* synopsis: affinity(r[P1]) */
12823
+#define OP_Permutation 95
12824
+#define OP_Compare 96 /* synopsis: r[P1@P3] <-> r[P2@P3] */
1280412825
#define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12805
-#define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */
12806
-#define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12807
-#define OP_Count 100 /* synopsis: r[P2]=count() */
12808
-#define OP_ReadCookie 101
12809
-#define OP_SetCookie 102
12810
-#define OP_ReopenIdx 103 /* synopsis: root=P2 iDb=P3 */
12811
-#define OP_OpenRead 104 /* synopsis: root=P2 iDb=P3 */
12812
-#define OP_OpenWrite 105 /* synopsis: root=P2 iDb=P3 */
12813
-#define OP_OpenAutoindex 106 /* synopsis: nColumn=P2 */
12814
-#define OP_OpenEphemeral 107 /* synopsis: nColumn=P2 */
12815
-#define OP_SorterOpen 108
12816
-#define OP_SequenceTest 109 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12817
-#define OP_OpenPseudo 110 /* synopsis: P3 columns in r[P2] */
12818
-#define OP_Close 111
12819
-#define OP_ColumnsUsed 112
12820
-#define OP_Sequence 113 /* synopsis: r[P2]=cursor[P1].ctr++ */
12821
-#define OP_NewRowid 114 /* synopsis: r[P2]=rowid */
12822
-#define OP_Insert 115 /* synopsis: intkey=r[P3] data=r[P2] */
12823
-#define OP_InsertInt 116 /* synopsis: intkey=P3 data=r[P2] */
12824
-#define OP_Delete 117
12825
-#define OP_ResetCount 118
12826
-#define OP_SorterCompare 119 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12827
-#define OP_SorterData 120 /* synopsis: r[P2]=data */
12828
-#define OP_RowData 121 /* synopsis: r[P2]=data */
12829
-#define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12830
-#define OP_NullRow 123
12831
-#define OP_SorterInsert 124 /* synopsis: key=r[P2] */
12832
-#define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12833
-#define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12834
-#define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12835
-#define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12836
-#define OP_Destroy 129
12837
-#define OP_Clear 130
12838
-#define OP_ResetSorter 131
12826
+#define OP_Column 98 /* synopsis: r[P3]=PX */
12827
+#define OP_Affinity 99 /* synopsis: affinity(r[P1@P2]) */
12828
+#define OP_MakeRecord 100 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12829
+#define OP_Count 101 /* synopsis: r[P2]=count() */
12830
+#define OP_ReadCookie 102
12831
+#define OP_SetCookie 103
12832
+#define OP_ReopenIdx 104 /* synopsis: root=P2 iDb=P3 */
12833
+#define OP_OpenRead 105 /* synopsis: root=P2 iDb=P3 */
12834
+#define OP_OpenWrite 106 /* synopsis: root=P2 iDb=P3 */
12835
+#define OP_OpenAutoindex 107 /* synopsis: nColumn=P2 */
12836
+#define OP_OpenEphemeral 108 /* synopsis: nColumn=P2 */
12837
+#define OP_SorterOpen 109
12838
+#define OP_SequenceTest 110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12839
+#define OP_OpenPseudo 111 /* synopsis: P3 columns in r[P2] */
12840
+#define OP_Close 112
12841
+#define OP_ColumnsUsed 113
12842
+#define OP_Sequence 114 /* synopsis: r[P2]=cursor[P1].ctr++ */
12843
+#define OP_NewRowid 115 /* synopsis: r[P2]=rowid */
12844
+#define OP_Insert 116 /* synopsis: intkey=r[P3] data=r[P2] */
12845
+#define OP_InsertInt 117 /* synopsis: intkey=P3 data=r[P2] */
12846
+#define OP_Delete 118
12847
+#define OP_ResetCount 119
12848
+#define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12849
+#define OP_SorterData 121 /* synopsis: r[P2]=data */
12850
+#define OP_RowData 122 /* synopsis: r[P2]=data */
12851
+#define OP_Rowid 123 /* synopsis: r[P2]=rowid */
12852
+#define OP_NullRow 124
12853
+#define OP_SorterInsert 125 /* synopsis: key=r[P2] */
12854
+#define OP_IdxInsert 126 /* synopsis: key=r[P2] */
12855
+#define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
12856
+#define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
12857
+#define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
12858
+#define OP_Destroy 130
12859
+#define OP_Clear 131
1283912860
#define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12840
-#define OP_CreateIndex 133 /* synopsis: r[P2]=root iDb=P1 */
12841
-#define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12842
-#define OP_ParseSchema 135
12843
-#define OP_LoadAnalysis 136
12844
-#define OP_DropTable 137
12845
-#define OP_DropIndex 138
12846
-#define OP_DropTrigger 139
12847
-#define OP_IntegrityCk 140
12848
-#define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12849
-#define OP_Param 142
12850
-#define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12851
-#define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12852
-#define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12853
-#define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12854
-#define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12855
-#define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12856
-#define OP_Expire 149
12857
-#define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12858
-#define OP_VBegin 151
12859
-#define OP_VCreate 152
12860
-#define OP_VDestroy 153
12861
-#define OP_VOpen 154
12862
-#define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12863
-#define OP_VRename 156
12864
-#define OP_Pagecount 157
12865
-#define OP_MaxPgcnt 158
12866
-#define OP_CursorHint 159
12867
-#define OP_Noop 160
12868
-#define OP_Explain 161
12861
+#define OP_ResetSorter 133
12862
+#define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */
12863
+#define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */
12864
+#define OP_SqlExec 136
12865
+#define OP_ParseSchema 137
12866
+#define OP_LoadAnalysis 138
12867
+#define OP_DropTable 139
12868
+#define OP_DropIndex 140
12869
+#define OP_DropTrigger 141
12870
+#define OP_IntegrityCk 142
12871
+#define OP_RowSetAdd 143 /* synopsis: rowset(P1)=r[P2] */
12872
+#define OP_Param 144
12873
+#define OP_FkCounter 145 /* synopsis: fkctr[P1]+=P2 */
12874
+#define OP_MemMax 146 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12875
+#define OP_OffsetLimit 147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12876
+#define OP_AggStep0 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12877
+#define OP_AggStep 149 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12878
+#define OP_AggFinal 150 /* synopsis: accum=r[P1] N=P2 */
12879
+#define OP_Expire 151
12880
+#define OP_TableLock 152 /* synopsis: iDb=P1 root=P2 write=P3 */
12881
+#define OP_VBegin 153
12882
+#define OP_VCreate 154
12883
+#define OP_VDestroy 155
12884
+#define OP_VOpen 156
12885
+#define OP_VColumn 157 /* synopsis: r[P3]=vcolumn(P2) */
12886
+#define OP_VRename 158
12887
+#define OP_Pagecount 159
12888
+#define OP_MaxPgcnt 160
12889
+#define OP_CursorHint 161
12890
+#define OP_Noop 162
12891
+#define OP_Explain 163
1286912892
1287012893
/* Properties such as "out2" or "jump" that are specified in
1287112894
** comments following the "case" for each opcode in the vdbe.c
1287212895
** are encoded into bitvectors as follows:
1287312896
*/
@@ -12883,32 +12906,32 @@
1288312906
/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
1288412907
/* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
1288512908
/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
1288612909
/* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
1288712910
/* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12888
-/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b,\
12889
-/* 64 */ 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01,\
12890
-/* 72 */ 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10,\
12891
-/* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00,\
12892
-/* 88 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
12893
-/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12911
+/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23,\
12912
+/* 64 */ 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01,\
12913
+/* 72 */ 0x01, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\
12914
+/* 80 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\
12915
+/* 88 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\
12916
+/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
1289412917
/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12895
-/* 112 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
12896
-/* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12897
-/* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12898
-/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12899
-/* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12900
-/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12901
-/* 160 */ 0x00, 0x00,}
12918
+/* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
12919
+/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\
12920
+/* 128 */ 0x00, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
12921
+/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\
12922
+/* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\
12923
+/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
12924
+/* 160 */ 0x10, 0x00, 0x00, 0x00,}
1290212925
1290312926
/* The sqlite3P2Values() routine is able to run faster if it knows
1290412927
** the value of the largest JUMP opcode. The smaller the maximum
1290512928
** JUMP opcode the better, so the mkopcodeh.tcl script that
1290612929
** generated this include file strives to group all JUMP opcodes
1290712930
** together near the beginning of the list.
1290812931
*/
12909
-#define SQLITE_MX_JUMP_OPCODE 71 /* Maximum JUMP opcode */
12932
+#define SQLITE_MX_JUMP_OPCODE 72 /* Maximum JUMP opcode */
1291012933
1291112934
/************** End of opcodes.h *********************************************/
1291212935
/************** Continuing where we left off in vdbe.h ***********************/
1291312936
1291412937
/*
@@ -14074,10 +14097,11 @@
1407414097
u8 suppressErr; /* Do not issue error messages if true */
1407514098
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
1407614099
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
1407714100
u8 mTrace; /* zero or more SQLITE_TRACE flags */
1407814101
u8 skipBtreeMutex; /* True if no shared-cache backends */
14102
+ u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
1407914103
int nextPagesize; /* Pagesize after VACUUM if >0 */
1408014104
u32 magic; /* Magic number for detect library misuse */
1408114105
int nChange; /* Value returned by sqlite3_changes() */
1408214106
int nTotalChange; /* Value returned by sqlite3_total_changes() */
1408314107
int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -14589,18 +14613,18 @@
1458914613
char *zColAff; /* String defining the affinity of each column */
1459014614
ExprList *pCheck; /* All CHECK constraints */
1459114615
/* ... also used as column name list in a VIEW */
1459214616
int tnum; /* Root BTree page for this table */
1459314617
u32 nTabRef; /* Number of pointers to this Table */
14618
+ u32 tabFlags; /* Mask of TF_* values */
1459414619
i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
1459514620
i16 nCol; /* Number of columns in this table */
1459614621
LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
1459714622
LogEst szTabRow; /* Estimated size of each table row in bytes */
1459814623
#ifdef SQLITE_ENABLE_COSTMULT
1459914624
LogEst costMult; /* Cost multiplier for using this table */
1460014625
#endif
14601
- u8 tabFlags; /* Mask of TF_* values */
1460214626
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
1460314627
#ifndef SQLITE_OMIT_ALTERTABLE
1460414628
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
1460514629
#endif
1460614630
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -14620,27 +14644,29 @@
1462014644
** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
1462114645
** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
1462214646
** the TF_OOOHidden attribute would apply in this case. Such tables require
1462314647
** special handling during INSERT processing.
1462414648
*/
14625
-#define TF_Readonly 0x01 /* Read-only system table */
14626
-#define TF_Ephemeral 0x02 /* An ephemeral table */
14627
-#define TF_HasPrimaryKey 0x04 /* Table has a primary key */
14628
-#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */
14629
-#define TF_Virtual 0x10 /* Is a virtual table */
14630
-#define TF_WithoutRowid 0x20 /* No rowid. PRIMARY KEY is the key */
14631
-#define TF_NoVisibleRowid 0x40 /* No user-visible "rowid" column */
14632
-#define TF_OOOHidden 0x80 /* Out-of-Order hidden columns */
14633
-
14649
+#define TF_Readonly 0x0001 /* Read-only system table */
14650
+#define TF_Ephemeral 0x0002 /* An ephemeral table */
14651
+#define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
14652
+#define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
14653
+#define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
14654
+#define TF_WithoutRowid 0x0020 /* No rowid. PRIMARY KEY is the key */
14655
+#define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
14656
+#define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
14657
+#define TF_StatsUsed 0x0100 /* Query planner decisions affected by
14658
+ ** Index.aiRowLogEst[] values */
14659
+#define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
1463414660
1463514661
/*
1463614662
** Test to see whether or not a table is a virtual table. This is
1463714663
** done as a macro so that it will be optimized out when virtual
1463814664
** table support is omitted from the build.
1463914665
*/
1464014666
#ifndef SQLITE_OMIT_VIRTUALTABLE
14641
-# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0)
14667
+# define IsVirtual(X) ((X)->nModuleArg)
1464214668
#else
1464314669
# define IsVirtual(X) 0
1464414670
#endif
1464514671
1464614672
/*
@@ -14871,10 +14897,11 @@
1487114897
unsigned bUnordered:1; /* Use this index for == or IN queries only */
1487214898
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
1487314899
unsigned isResized:1; /* True if resizeIndexObject() has been called */
1487414900
unsigned isCovering:1; /* True if this is a covering index */
1487514901
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
14902
+ unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
1487614903
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
1487714904
int nSample; /* Number of elements in aSample[] */
1487814905
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
1487914906
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
1488014907
IndexSample *aSample; /* Samples of the left-most key */
@@ -15181,11 +15208,11 @@
1518115208
** form is used for name resolution with nested FROM clauses.
1518215209
*/
1518315210
struct ExprList {
1518415211
int nExpr; /* Number of expressions on the list */
1518515212
struct ExprList_item { /* For each expression in the list */
15186
- Expr *pExpr; /* The list of expressions */
15213
+ Expr *pExpr; /* The parse tree for this expression */
1518715214
char *zName; /* Token associated with this expression */
1518815215
char *zSpan; /* Original text of the expression */
1518915216
u8 sortOrder; /* 1 for DESC or 0 for ASC */
1519015217
unsigned done :1; /* A flag to indicate when processing is finished */
1519115218
unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
@@ -16504,10 +16531,11 @@
1650416531
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
1650516532
SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
1650616533
SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
1650716534
SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
1650816535
SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
16536
+SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
1650916537
SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
1651016538
SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
1651116539
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
1651216540
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
1651316541
SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
@@ -17450,11 +17478,11 @@
1745017478
"COMPILER=gcc-" __VERSION__,
1745117479
#endif
1745217480
#if SQLITE_COVERAGE_TEST
1745317481
"COVERAGE_TEST",
1745417482
#endif
17455
-#if SQLITE_DEBUG
17483
+#ifdef SQLITE_DEBUG
1745617484
"DEBUG",
1745717485
#endif
1745817486
#if SQLITE_DEFAULT_LOCKING_MODE
1745917487
"DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
1746017488
#endif
@@ -19505,22 +19533,23 @@
1950519533
**
1950619534
** Move the date backwards to the beginning of the current day,
1950719535
** or month or year.
1950819536
*/
1950919537
if( sqlite3_strnicmp(z, "start of ", 9)!=0 ) break;
19538
+ if( !p->validJD && !p->validYMD && !p->validHMS ) break;
1951019539
z += 9;
1951119540
computeYMD(p);
1951219541
p->validHMS = 1;
1951319542
p->h = p->m = 0;
1951419543
p->s = 0.0;
19544
+ p->rawS = 0;
1951519545
p->validTZ = 0;
1951619546
p->validJD = 0;
1951719547
if( sqlite3_stricmp(z,"month")==0 ){
1951819548
p->D = 1;
1951919549
rc = 0;
1952019550
}else if( sqlite3_stricmp(z,"year")==0 ){
19521
- computeYMD(p);
1952219551
p->M = 1;
1952319552
p->D = 1;
1952419553
rc = 0;
1952519554
}else if( sqlite3_stricmp(z,"day")==0 ){
1952619555
rc = 0;
@@ -24050,12 +24079,12 @@
2405024079
#ifdef SQLITE_DEBUG
2405124080
assert( p->nRef>0 || p->owner==0 );
2405224081
p->owner = tid;
2405324082
p->nRef++;
2405424083
if( p->trace ){
24055
- OSTRACE(("ENTER-MUTEX tid=%lu, mutex=%p (%d), nRef=%d\n",
24056
- tid, p, p->trace, p->nRef));
24084
+ OSTRACE(("ENTER-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\n",
24085
+ tid, p->id, p, p->trace, p->nRef));
2405724086
}
2405824087
#endif
2405924088
}
2406024089
2406124090
static int winMutexTry(sqlite3_mutex *p){
@@ -24093,12 +24122,12 @@
2409324122
#else
2409424123
UNUSED_PARAMETER(p);
2409524124
#endif
2409624125
#ifdef SQLITE_DEBUG
2409724126
if( p->trace ){
24098
- OSTRACE(("TRY-MUTEX tid=%lu, mutex=%p (%d), owner=%lu, nRef=%d, rc=%s\n",
24099
- tid, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));
24127
+ OSTRACE(("TRY-MUTEX tid=%lu, mutex(%d)=%p (%d), owner=%lu, nRef=%d, rc=%s\n",
24128
+ tid, p->id, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));
2410024129
}
2410124130
#endif
2410224131
return rc;
2410324132
}
2410424133
@@ -24122,12 +24151,12 @@
2412224151
#endif
2412324152
assert( winMutex_isInit==1 );
2412424153
LeaveCriticalSection(&p->mutex);
2412524154
#ifdef SQLITE_DEBUG
2412624155
if( p->trace ){
24127
- OSTRACE(("LEAVE-MUTEX tid=%lu, mutex=%p (%d), nRef=%d\n",
24128
- tid, p, p->trace, p->nRef));
24156
+ OSTRACE(("LEAVE-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\n",
24157
+ tid, p->id, p, p->trace, p->nRef));
2412924158
}
2413024159
#endif
2413124160
}
2413224161
2413324162
SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
@@ -24572,11 +24601,11 @@
2457224601
return sqlite3GlobalConfig.m.xSize(p);
2457324602
}
2457424603
SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
2457524604
assert( p!=0 );
2457624605
if( db==0 || !isLookaside(db,p) ){
24577
-#if SQLITE_DEBUG
24606
+#ifdef SQLITE_DEBUG
2457824607
if( db==0 ){
2457924608
assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
2458024609
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
2458124610
}else{
2458224611
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
@@ -24633,11 +24662,11 @@
2463324662
measureAllocationSize(db, p);
2463424663
return;
2463524664
}
2463624665
if( isLookaside(db, p) ){
2463724666
LookasideSlot *pBuf = (LookasideSlot*)p;
24638
-#if SQLITE_DEBUG
24667
+#ifdef SQLITE_DEBUG
2463924668
/* Trash all content in the buffer being freed */
2464024669
memset(p, 0xaa, db->lookaside.sz);
2464124670
#endif
2464224671
pBuf->pNext = db->lookaside.pFree;
2464324672
db->lookaside.pFree = pBuf;
@@ -25002,11 +25031,11 @@
2500225031
2500325032
/*
2500425033
** Conversion types fall into various categories as defined by the
2500525034
** following enumeration.
2500625035
*/
25007
-#define etRADIX 0 /* Integer types. %d, %x, %o, and so forth */
25036
+#define etRADIX 0 /* non-decimal integer types. %x %o */
2500825037
#define etFLOAT 1 /* Floating point. %f */
2500925038
#define etEXP 2 /* Exponentional notation. %e and %E */
2501025039
#define etGENERIC 3 /* Floating or exponential, depending on exponent. %g */
2501125040
#define etSIZE 4 /* Return number of characters processed so far. %n */
2501225041
#define etSTRING 5 /* Strings. %s */
@@ -25020,12 +25049,13 @@
2502025049
#define etTOKEN 11 /* a pointer to a Token structure */
2502125050
#define etSRCLIST 12 /* a pointer to a SrcList */
2502225051
#define etPOINTER 13 /* The %p conversion */
2502325052
#define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */
2502425053
#define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */
25054
+#define etDECIMAL 16 /* %d or %u, but not %x, %o */
2502525055
25026
-#define etINVALID 16 /* Any unrecognized conversion type */
25056
+#define etINVALID 17 /* Any unrecognized conversion type */
2502725057
2502825058
2502925059
/*
2503025060
** An "etByte" is an 8-bit unsigned value.
2503125061
*/
@@ -25045,40 +25075,40 @@
2504525075
} et_info;
2504625076
2504725077
/*
2504825078
** Allowed values for et_info.flags
2504925079
*/
25050
-#define FLAG_SIGNED 1 /* True if the value to convert is signed */
25051
-#define FLAG_STRING 4 /* Allow infinity precision */
25080
+#define FLAG_SIGNED 1 /* True if the value to convert is signed */
25081
+#define FLAG_STRING 4 /* Allow infinite precision */
2505225082
2505325083
2505425084
/*
2505525085
** The following table is searched linearly, so it is good to put the
2505625086
** most frequently used conversion types first.
2505725087
*/
2505825088
static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
2505925089
static const char aPrefix[] = "-x0\000X0";
2506025090
static const et_info fmtinfo[] = {
25061
- { 'd', 10, 1, etRADIX, 0, 0 },
25091
+ { 'd', 10, 1, etDECIMAL, 0, 0 },
2506225092
{ 's', 0, 4, etSTRING, 0, 0 },
2506325093
{ 'g', 0, 1, etGENERIC, 30, 0 },
2506425094
{ 'z', 0, 4, etDYNSTRING, 0, 0 },
2506525095
{ 'q', 0, 4, etSQLESCAPE, 0, 0 },
2506625096
{ 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
2506725097
{ 'w', 0, 4, etSQLESCAPE3, 0, 0 },
2506825098
{ 'c', 0, 0, etCHARX, 0, 0 },
2506925099
{ 'o', 8, 0, etRADIX, 0, 2 },
25070
- { 'u', 10, 0, etRADIX, 0, 0 },
25100
+ { 'u', 10, 0, etDECIMAL, 0, 0 },
2507125101
{ 'x', 16, 0, etRADIX, 16, 1 },
2507225102
{ 'X', 16, 0, etRADIX, 0, 4 },
2507325103
#ifndef SQLITE_OMIT_FLOATING_POINT
2507425104
{ 'f', 0, 1, etFLOAT, 0, 0 },
2507525105
{ 'e', 0, 1, etEXP, 30, 0 },
2507625106
{ 'E', 0, 1, etEXP, 14, 0 },
2507725107
{ 'G', 0, 1, etGENERIC, 14, 0 },
2507825108
#endif
25079
- { 'i', 10, 1, etRADIX, 0, 0 },
25109
+ { 'i', 10, 1, etDECIMAL, 0, 0 },
2508025110
{ 'n', 0, 0, etSIZE, 0, 0 },
2508125111
{ '%', 0, 0, etPERCENT, 0, 0 },
2508225112
{ 'p', 16, 0, etPOINTER, 0, 1 },
2508325113
2508425114
/* All the rest are undocumented and are for internal use only */
@@ -25166,18 +25196,17 @@
2516625196
int precision; /* Precision of the current field */
2516725197
int length; /* Length of the field */
2516825198
int idx; /* A general purpose loop counter */
2516925199
int width; /* Width of the current field */
2517025200
etByte flag_leftjustify; /* True if "-" flag is present */
25171
- etByte flag_plussign; /* True if "+" flag is present */
25172
- etByte flag_blanksign; /* True if " " flag is present */
25201
+ etByte flag_prefix; /* '+' or ' ' or 0 for prefix */
2517325202
etByte flag_alternateform; /* True if "#" flag is present */
2517425203
etByte flag_altform2; /* True if "!" flag is present */
2517525204
etByte flag_zeropad; /* True if field width constant starts with zero */
25176
- etByte flag_long; /* True if "l" flag is present */
25177
- etByte flag_longlong; /* True if the "ll" flag is present */
25205
+ etByte flag_long; /* 1 for the "l" flag, 2 for "ll", 0 by default */
2517825206
etByte done; /* Loop termination flag */
25207
+ etByte cThousand; /* Thousands separator for %d and %u */
2517925208
etByte xtype = etINVALID; /* Conversion paradigm */
2518025209
u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */
2518125210
char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
2518225211
sqlite_uint64 longvalue; /* Value for integer types */
2518325212
LONGDOUBLE_TYPE realvalue; /* Value for real types */
@@ -25216,21 +25245,22 @@
2521625245
if( (c=(*++fmt))==0 ){
2521725246
sqlite3StrAccumAppend(pAccum, "%", 1);
2521825247
break;
2521925248
}
2522025249
/* Find out what flags are present */
25221
- flag_leftjustify = flag_plussign = flag_blanksign =
25250
+ flag_leftjustify = flag_prefix = cThousand =
2522225251
flag_alternateform = flag_altform2 = flag_zeropad = 0;
2522325252
done = 0;
2522425253
do{
2522525254
switch( c ){
2522625255
case '-': flag_leftjustify = 1; break;
25227
- case '+': flag_plussign = 1; break;
25228
- case ' ': flag_blanksign = 1; break;
25256
+ case '+': flag_prefix = '+'; break;
25257
+ case ' ': flag_prefix = ' '; break;
2522925258
case '#': flag_alternateform = 1; break;
2523025259
case '!': flag_altform2 = 1; break;
2523125260
case '0': flag_zeropad = 1; break;
25261
+ case ',': cThousand = ','; break;
2523225262
default: done = 1; break;
2523325263
}
2523425264
}while( !done && (c=(*++fmt))!=0 );
2523525265
/* Get the field width */
2523625266
if( c=='*' ){
@@ -25296,17 +25326,15 @@
2529625326
/* Get the conversion type modifier */
2529725327
if( c=='l' ){
2529825328
flag_long = 1;
2529925329
c = *++fmt;
2530025330
if( c=='l' ){
25301
- flag_longlong = 1;
25331
+ flag_long = 2;
2530225332
c = *++fmt;
25303
- }else{
25304
- flag_longlong = 0;
2530525333
}
2530625334
}else{
25307
- flag_long = flag_longlong = 0;
25335
+ flag_long = 0;
2530825336
}
2530925337
/* Fetch the info entry for the field */
2531025338
infop = &fmtinfo[0];
2531125339
xtype = etINVALID;
2531225340
for(idx=0; idx<ArraySize(fmtinfo); idx++){
@@ -25320,41 +25348,42 @@
2532025348
/*
2532125349
** At this point, variables are initialized as follows:
2532225350
**
2532325351
** flag_alternateform TRUE if a '#' is present.
2532425352
** flag_altform2 TRUE if a '!' is present.
25325
- ** flag_plussign TRUE if a '+' is present.
25353
+ ** flag_prefix '+' or ' ' or zero
2532625354
** flag_leftjustify TRUE if a '-' is present or if the
2532725355
** field width was negative.
2532825356
** flag_zeropad TRUE if the width began with 0.
25329
- ** flag_long TRUE if the letter 'l' (ell) prefixed
25330
- ** the conversion character.
25331
- ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed
25332
- ** the conversion character.
25333
- ** flag_blanksign TRUE if a ' ' is present.
25357
+ ** flag_long 1 for "l", 2 for "ll"
2533425358
** width The specified field width. This is
2533525359
** always non-negative. Zero is the default.
2533625360
** precision The specified precision. The default
2533725361
** is -1.
2533825362
** xtype The class of the conversion.
2533925363
** infop Pointer to the appropriate info struct.
2534025364
*/
2534125365
switch( xtype ){
2534225366
case etPOINTER:
25343
- flag_longlong = sizeof(char*)==sizeof(i64);
25344
- flag_long = sizeof(char*)==sizeof(long int);
25367
+ flag_long = sizeof(char*)==sizeof(i64) ? 2 :
25368
+ sizeof(char*)==sizeof(long int) ? 1 : 0;
2534525369
/* Fall through into the next case */
2534625370
case etORDINAL:
25347
- case etRADIX:
25371
+ case etRADIX:
25372
+ cThousand = 0;
25373
+ /* Fall through into the next case */
25374
+ case etDECIMAL:
2534825375
if( infop->flags & FLAG_SIGNED ){
2534925376
i64 v;
2535025377
if( bArgList ){
2535125378
v = getIntArg(pArgList);
25352
- }else if( flag_longlong ){
25353
- v = va_arg(ap,i64);
2535425379
}else if( flag_long ){
25355
- v = va_arg(ap,long int);
25380
+ if( flag_long==2 ){
25381
+ v = va_arg(ap,i64) ;
25382
+ }else{
25383
+ v = va_arg(ap,long int);
25384
+ }
2535625385
}else{
2535725386
v = va_arg(ap,int);
2535825387
}
2535925388
if( v<0 ){
2536025389
if( v==SMALLEST_INT64 ){
@@ -25363,35 +25392,35 @@
2536325392
longvalue = -v;
2536425393
}
2536525394
prefix = '-';
2536625395
}else{
2536725396
longvalue = v;
25368
- if( flag_plussign ) prefix = '+';
25369
- else if( flag_blanksign ) prefix = ' ';
25370
- else prefix = 0;
25397
+ prefix = flag_prefix;
2537125398
}
2537225399
}else{
2537325400
if( bArgList ){
2537425401
longvalue = (u64)getIntArg(pArgList);
25375
- }else if( flag_longlong ){
25376
- longvalue = va_arg(ap,u64);
2537725402
}else if( flag_long ){
25378
- longvalue = va_arg(ap,unsigned long int);
25403
+ if( flag_long==2 ){
25404
+ longvalue = va_arg(ap,u64);
25405
+ }else{
25406
+ longvalue = va_arg(ap,unsigned long int);
25407
+ }
2537925408
}else{
2538025409
longvalue = va_arg(ap,unsigned int);
2538125410
}
2538225411
prefix = 0;
2538325412
}
2538425413
if( longvalue==0 ) flag_alternateform = 0;
2538525414
if( flag_zeropad && precision<width-(prefix!=0) ){
2538625415
precision = width-(prefix!=0);
2538725416
}
25388
- if( precision<etBUFSIZE-10 ){
25417
+ if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
2538925418
nOut = etBUFSIZE;
2539025419
zOut = buf;
2539125420
}else{
25392
- nOut = precision + 10;
25421
+ nOut = precision + 10 + precision/3;
2539325422
zOut = zExtra = sqlite3Malloc( nOut );
2539425423
if( zOut==0 ){
2539525424
setStrAccumError(pAccum, STRACCUM_NOMEM);
2539625425
return;
2539725426
}
@@ -25413,12 +25442,27 @@
2541325442
*(--bufpt) = cset[longvalue%base];
2541425443
longvalue = longvalue/base;
2541525444
}while( longvalue>0 );
2541625445
}
2541725446
length = (int)(&zOut[nOut-1]-bufpt);
25418
- for(idx=precision-length; idx>0; idx--){
25447
+ while( precision>length ){
2541925448
*(--bufpt) = '0'; /* Zero pad */
25449
+ length++;
25450
+ }
25451
+ if( cThousand ){
25452
+ int nn = (length - 1)/3; /* Number of "," to insert */
25453
+ int ix = (length - 1)%3 + 1;
25454
+ bufpt -= nn;
25455
+ for(idx=0; nn>0; idx++){
25456
+ bufpt[idx] = bufpt[idx+nn];
25457
+ ix--;
25458
+ if( ix==0 ){
25459
+ bufpt[++idx] = cThousand;
25460
+ nn--;
25461
+ ix = 3;
25462
+ }
25463
+ }
2542025464
}
2542125465
if( prefix ) *(--bufpt) = prefix; /* Add sign */
2542225466
if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
2542325467
const char *pre;
2542425468
char x;
@@ -25441,13 +25485,11 @@
2544125485
if( precision<0 ) precision = 6; /* Set default precision */
2544225486
if( realvalue<0.0 ){
2544325487
realvalue = -realvalue;
2544425488
prefix = '-';
2544525489
}else{
25446
- if( flag_plussign ) prefix = '+';
25447
- else if( flag_blanksign ) prefix = ' ';
25448
- else prefix = 0;
25490
+ prefix = flag_prefix;
2544925491
}
2545025492
if( xtype==etGENERIC && precision>0 ) precision--;
2545125493
testcase( precision>0xfff );
2545225494
for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
2545325495
if( xtype==etFLOAT ) realvalue += rounder;
@@ -29464,117 +29506,119 @@
2946429506
/* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
2946529507
/* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
2946629508
/* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
2946729509
/* 53 */ "Last" OpHelp(""),
2946829510
/* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
29469
- /* 55 */ "SorterSort" OpHelp(""),
29470
- /* 56 */ "Sort" OpHelp(""),
29471
- /* 57 */ "Rewind" OpHelp(""),
29472
- /* 58 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29473
- /* 59 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29474
- /* 60 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29475
- /* 61 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29476
- /* 62 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29477
- /* 63 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29478
- /* 64 */ "Program" OpHelp(""),
29479
- /* 65 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29480
- /* 66 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29481
- /* 67 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
29482
- /* 68 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29483
- /* 69 */ "IncrVacuum" OpHelp(""),
29484
- /* 70 */ "VNext" OpHelp(""),
29485
- /* 71 */ "Init" OpHelp("Start at P2"),
29486
- /* 72 */ "Return" OpHelp(""),
29487
- /* 73 */ "EndCoroutine" OpHelp(""),
29488
- /* 74 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29489
- /* 75 */ "Halt" OpHelp(""),
29490
- /* 76 */ "Integer" OpHelp("r[P2]=P1"),
29491
- /* 77 */ "Int64" OpHelp("r[P2]=P4"),
29492
- /* 78 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29493
- /* 79 */ "Null" OpHelp("r[P2..P3]=NULL"),
29494
- /* 80 */ "SoftNull" OpHelp("r[P1]=NULL"),
29495
- /* 81 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29496
- /* 82 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29497
- /* 83 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29498
- /* 84 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29499
- /* 85 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29500
- /* 86 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29501
- /* 87 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29502
- /* 88 */ "CollSeq" OpHelp(""),
29503
- /* 89 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29504
- /* 90 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29505
- /* 91 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29506
- /* 92 */ "RealAffinity" OpHelp(""),
29507
- /* 93 */ "Cast" OpHelp("affinity(r[P1])"),
29508
- /* 94 */ "Permutation" OpHelp(""),
29509
- /* 95 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29510
- /* 96 */ "Column" OpHelp("r[P3]=PX"),
29511
+ /* 55 */ "IfSmaller" OpHelp(""),
29512
+ /* 56 */ "SorterSort" OpHelp(""),
29513
+ /* 57 */ "Sort" OpHelp(""),
29514
+ /* 58 */ "Rewind" OpHelp(""),
29515
+ /* 59 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29516
+ /* 60 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29517
+ /* 61 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29518
+ /* 62 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29519
+ /* 63 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29520
+ /* 64 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29521
+ /* 65 */ "Program" OpHelp(""),
29522
+ /* 66 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29523
+ /* 67 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29524
+ /* 68 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
29525
+ /* 69 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29526
+ /* 70 */ "IncrVacuum" OpHelp(""),
29527
+ /* 71 */ "VNext" OpHelp(""),
29528
+ /* 72 */ "Init" OpHelp("Start at P2"),
29529
+ /* 73 */ "Return" OpHelp(""),
29530
+ /* 74 */ "EndCoroutine" OpHelp(""),
29531
+ /* 75 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29532
+ /* 76 */ "Halt" OpHelp(""),
29533
+ /* 77 */ "Integer" OpHelp("r[P2]=P1"),
29534
+ /* 78 */ "Int64" OpHelp("r[P2]=P4"),
29535
+ /* 79 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29536
+ /* 80 */ "Null" OpHelp("r[P2..P3]=NULL"),
29537
+ /* 81 */ "SoftNull" OpHelp("r[P1]=NULL"),
29538
+ /* 82 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29539
+ /* 83 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29540
+ /* 84 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29541
+ /* 85 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29542
+ /* 86 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29543
+ /* 87 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29544
+ /* 88 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29545
+ /* 89 */ "CollSeq" OpHelp(""),
29546
+ /* 90 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29547
+ /* 91 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29548
+ /* 92 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29549
+ /* 93 */ "RealAffinity" OpHelp(""),
29550
+ /* 94 */ "Cast" OpHelp("affinity(r[P1])"),
29551
+ /* 95 */ "Permutation" OpHelp(""),
29552
+ /* 96 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
2951129553
/* 97 */ "String8" OpHelp("r[P2]='P4'"),
29512
- /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29513
- /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29514
- /* 100 */ "Count" OpHelp("r[P2]=count()"),
29515
- /* 101 */ "ReadCookie" OpHelp(""),
29516
- /* 102 */ "SetCookie" OpHelp(""),
29517
- /* 103 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29518
- /* 104 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29519
- /* 105 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29520
- /* 106 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29521
- /* 107 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29522
- /* 108 */ "SorterOpen" OpHelp(""),
29523
- /* 109 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29524
- /* 110 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29525
- /* 111 */ "Close" OpHelp(""),
29526
- /* 112 */ "ColumnsUsed" OpHelp(""),
29527
- /* 113 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29528
- /* 114 */ "NewRowid" OpHelp("r[P2]=rowid"),
29529
- /* 115 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29530
- /* 116 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29531
- /* 117 */ "Delete" OpHelp(""),
29532
- /* 118 */ "ResetCount" OpHelp(""),
29533
- /* 119 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29534
- /* 120 */ "SorterData" OpHelp("r[P2]=data"),
29535
- /* 121 */ "RowData" OpHelp("r[P2]=data"),
29536
- /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29537
- /* 123 */ "NullRow" OpHelp(""),
29538
- /* 124 */ "SorterInsert" OpHelp("key=r[P2]"),
29539
- /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29540
- /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29541
- /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29542
- /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29543
- /* 129 */ "Destroy" OpHelp(""),
29544
- /* 130 */ "Clear" OpHelp(""),
29545
- /* 131 */ "ResetSorter" OpHelp(""),
29554
+ /* 98 */ "Column" OpHelp("r[P3]=PX"),
29555
+ /* 99 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29556
+ /* 100 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29557
+ /* 101 */ "Count" OpHelp("r[P2]=count()"),
29558
+ /* 102 */ "ReadCookie" OpHelp(""),
29559
+ /* 103 */ "SetCookie" OpHelp(""),
29560
+ /* 104 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29561
+ /* 105 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29562
+ /* 106 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29563
+ /* 107 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29564
+ /* 108 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29565
+ /* 109 */ "SorterOpen" OpHelp(""),
29566
+ /* 110 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29567
+ /* 111 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29568
+ /* 112 */ "Close" OpHelp(""),
29569
+ /* 113 */ "ColumnsUsed" OpHelp(""),
29570
+ /* 114 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29571
+ /* 115 */ "NewRowid" OpHelp("r[P2]=rowid"),
29572
+ /* 116 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29573
+ /* 117 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29574
+ /* 118 */ "Delete" OpHelp(""),
29575
+ /* 119 */ "ResetCount" OpHelp(""),
29576
+ /* 120 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29577
+ /* 121 */ "SorterData" OpHelp("r[P2]=data"),
29578
+ /* 122 */ "RowData" OpHelp("r[P2]=data"),
29579
+ /* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
29580
+ /* 124 */ "NullRow" OpHelp(""),
29581
+ /* 125 */ "SorterInsert" OpHelp("key=r[P2]"),
29582
+ /* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
29583
+ /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29584
+ /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29585
+ /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29586
+ /* 130 */ "Destroy" OpHelp(""),
29587
+ /* 131 */ "Clear" OpHelp(""),
2954629588
/* 132 */ "Real" OpHelp("r[P2]=P4"),
29547
- /* 133 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29548
- /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29549
- /* 135 */ "ParseSchema" OpHelp(""),
29550
- /* 136 */ "LoadAnalysis" OpHelp(""),
29551
- /* 137 */ "DropTable" OpHelp(""),
29552
- /* 138 */ "DropIndex" OpHelp(""),
29553
- /* 139 */ "DropTrigger" OpHelp(""),
29554
- /* 140 */ "IntegrityCk" OpHelp(""),
29555
- /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29556
- /* 142 */ "Param" OpHelp(""),
29557
- /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29558
- /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29559
- /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29560
- /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29561
- /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29562
- /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29563
- /* 149 */ "Expire" OpHelp(""),
29564
- /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29565
- /* 151 */ "VBegin" OpHelp(""),
29566
- /* 152 */ "VCreate" OpHelp(""),
29567
- /* 153 */ "VDestroy" OpHelp(""),
29568
- /* 154 */ "VOpen" OpHelp(""),
29569
- /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29570
- /* 156 */ "VRename" OpHelp(""),
29571
- /* 157 */ "Pagecount" OpHelp(""),
29572
- /* 158 */ "MaxPgcnt" OpHelp(""),
29573
- /* 159 */ "CursorHint" OpHelp(""),
29574
- /* 160 */ "Noop" OpHelp(""),
29575
- /* 161 */ "Explain" OpHelp(""),
29589
+ /* 133 */ "ResetSorter" OpHelp(""),
29590
+ /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29591
+ /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29592
+ /* 136 */ "SqlExec" OpHelp(""),
29593
+ /* 137 */ "ParseSchema" OpHelp(""),
29594
+ /* 138 */ "LoadAnalysis" OpHelp(""),
29595
+ /* 139 */ "DropTable" OpHelp(""),
29596
+ /* 140 */ "DropIndex" OpHelp(""),
29597
+ /* 141 */ "DropTrigger" OpHelp(""),
29598
+ /* 142 */ "IntegrityCk" OpHelp(""),
29599
+ /* 143 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29600
+ /* 144 */ "Param" OpHelp(""),
29601
+ /* 145 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29602
+ /* 146 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29603
+ /* 147 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29604
+ /* 148 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29605
+ /* 149 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29606
+ /* 150 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29607
+ /* 151 */ "Expire" OpHelp(""),
29608
+ /* 152 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29609
+ /* 153 */ "VBegin" OpHelp(""),
29610
+ /* 154 */ "VCreate" OpHelp(""),
29611
+ /* 155 */ "VDestroy" OpHelp(""),
29612
+ /* 156 */ "VOpen" OpHelp(""),
29613
+ /* 157 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29614
+ /* 158 */ "VRename" OpHelp(""),
29615
+ /* 159 */ "Pagecount" OpHelp(""),
29616
+ /* 160 */ "MaxPgcnt" OpHelp(""),
29617
+ /* 161 */ "CursorHint" OpHelp(""),
29618
+ /* 162 */ "Noop" OpHelp(""),
29619
+ /* 163 */ "Explain" OpHelp(""),
2957629620
};
2957729621
return azName[i];
2957829622
}
2957929623
#endif
2958029624
@@ -37952,46 +37996,84 @@
3795237996
* be freed immediately and any attempt to access any of that freed
3795337997
* data will almost certainly result in an immediate access violation.
3795437998
******************************************************************************
3795537999
*/
3795638000
#ifndef SQLITE_WIN32_HEAP_CREATE
37957
-# define SQLITE_WIN32_HEAP_CREATE (TRUE)
38001
+# define SQLITE_WIN32_HEAP_CREATE (TRUE)
38002
+#endif
38003
+
38004
+/*
38005
+ * This is the maximum possible initial size of the Win32-specific heap, in
38006
+ * bytes.
38007
+ */
38008
+#ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE
38009
+# define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U)
38010
+#endif
38011
+
38012
+/*
38013
+ * This is the extra space for the initial size of the Win32-specific heap,
38014
+ * in bytes. This value may be zero.
38015
+ */
38016
+#ifndef SQLITE_WIN32_HEAP_INIT_EXTRA
38017
+# define SQLITE_WIN32_HEAP_INIT_EXTRA (4194304)
38018
+#endif
38019
+
38020
+/*
38021
+ * Calculate the maximum legal cache size, in pages, based on the maximum
38022
+ * possible initial heap size and the default page size, setting aside the
38023
+ * needed extra space.
38024
+ */
38025
+#ifndef SQLITE_WIN32_MAX_CACHE_SIZE
38026
+# define SQLITE_WIN32_MAX_CACHE_SIZE (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \
38027
+ (SQLITE_WIN32_HEAP_INIT_EXTRA)) / \
38028
+ (SQLITE_DEFAULT_PAGE_SIZE))
3795838029
#endif
3795938030
3796038031
/*
3796138032
* This is cache size used in the calculation of the initial size of the
3796238033
* Win32-specific heap. It cannot be negative.
3796338034
*/
3796438035
#ifndef SQLITE_WIN32_CACHE_SIZE
3796538036
# if SQLITE_DEFAULT_CACHE_SIZE>=0
37966
-# define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE)
38037
+# define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE)
3796738038
# else
37968
-# define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE))
38039
+# define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE))
3796938040
# endif
3797038041
#endif
3797138042
38043
+/*
38044
+ * Make sure that the calculated cache size, in pages, cannot cause the
38045
+ * initial size of the Win32-specific heap to exceed the maximum amount
38046
+ * of memory that can be specified in the call to HeapCreate.
38047
+ */
38048
+#if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE
38049
+# undef SQLITE_WIN32_CACHE_SIZE
38050
+# define SQLITE_WIN32_CACHE_SIZE (2000)
38051
+#endif
38052
+
3797238053
/*
3797338054
* The initial size of the Win32-specific heap. This value may be zero.
3797438055
*/
3797538056
#ifndef SQLITE_WIN32_HEAP_INIT_SIZE
37976
-# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \
37977
- (SQLITE_DEFAULT_PAGE_SIZE) + 4194304)
38057
+# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \
38058
+ (SQLITE_DEFAULT_PAGE_SIZE) + \
38059
+ (SQLITE_WIN32_HEAP_INIT_EXTRA))
3797838060
#endif
3797938061
3798038062
/*
3798138063
* The maximum size of the Win32-specific heap. This value may be zero.
3798238064
*/
3798338065
#ifndef SQLITE_WIN32_HEAP_MAX_SIZE
37984
-# define SQLITE_WIN32_HEAP_MAX_SIZE (0)
38066
+# define SQLITE_WIN32_HEAP_MAX_SIZE (0)
3798538067
#endif
3798638068
3798738069
/*
3798838070
* The extra flags to use in calls to the Win32 heap APIs. This value may be
3798938071
* zero for the default behavior.
3799038072
*/
3799138073
#ifndef SQLITE_WIN32_HEAP_FLAGS
37992
-# define SQLITE_WIN32_HEAP_FLAGS (0)
38074
+# define SQLITE_WIN32_HEAP_FLAGS (0)
3799338075
#endif
3799438076
3799538077
3799638078
/*
3799738079
** The winMemData structure stores information required by the Win32-specific
@@ -44084,11 +44166,11 @@
4408444166
** This routine is for use inside of assert() statements only. For
4408544167
** example:
4408644168
**
4408744169
** assert( sqlite3PcachePageSanity(pPg) );
4408844170
*/
44089
-#if SQLITE_DEBUG
44171
+#ifdef SQLITE_DEBUG
4409044172
SQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){
4409144173
PCache *pCache;
4409244174
assert( pPg!=0 );
4409344175
assert( pPg->pgno>0 || pPg->pPager==0 ); /* Page number is 1 or more */
4409444176
pCache = pPg->pCache;
@@ -60177,21 +60259,22 @@
6017760259
}
6017860260
#endif
6017960261
6018060262
6018160263
/*
60182
-** Defragment the page given. All Cells are moved to the
60183
-** end of the page and all free space is collected into one
60184
-** big FreeBlk that occurs in between the header and cell
60185
-** pointer array and the cell content area.
60264
+** Defragment the page given. This routine reorganizes cells within the
60265
+** page so that there are no free-blocks on the free-block list.
60266
+**
60267
+** Parameter nMaxFrag is the maximum amount of fragmented space that may be
60268
+** present in the page after this routine returns.
6018660269
**
6018760270
** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a
6018860271
** b-tree page so that there are no freeblocks or fragment bytes, all
6018960272
** unused bytes are contained in the unallocated space region, and all
6019060273
** cells are packed tightly at the end of the page.
6019160274
*/
60192
-static int defragmentPage(MemPage *pPage){
60275
+static int defragmentPage(MemPage *pPage, int nMaxFrag){
6019360276
int i; /* Loop counter */
6019460277
int pc; /* Address of the i-th cell */
6019560278
int hdr; /* Offset to the page header */
6019660279
int size; /* Size of a cell */
6019760280
int usableSize; /* Number of usable bytes on a page */
@@ -60202,11 +60285,10 @@
6020260285
unsigned char *temp; /* Temp area for cell content */
6020360286
unsigned char *src; /* Source of content */
6020460287
int iCellFirst; /* First allowable cell index */
6020560288
int iCellLast; /* Last possible cell index */
6020660289
60207
-
6020860290
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
6020960291
assert( pPage->pBt!=0 );
6021060292
assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
6021160293
assert( pPage->nOverflow==0 );
6021260294
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
@@ -60214,13 +60296,60 @@
6021460296
src = data = pPage->aData;
6021560297
hdr = pPage->hdrOffset;
6021660298
cellOffset = pPage->cellOffset;
6021760299
nCell = pPage->nCell;
6021860300
assert( nCell==get2byte(&data[hdr+3]) );
60301
+ iCellFirst = cellOffset + 2*nCell;
6021960302
usableSize = pPage->pBt->usableSize;
60303
+
60304
+ /* This block handles pages with two or fewer free blocks and nMaxFrag
60305
+ ** or fewer fragmented bytes. In this case it is faster to move the
60306
+ ** two (or one) blocks of cells using memmove() and add the required
60307
+ ** offsets to each pointer in the cell-pointer array than it is to
60308
+ ** reconstruct the entire page. */
60309
+ if( (int)data[hdr+7]<=nMaxFrag ){
60310
+ int iFree = get2byte(&data[hdr+1]);
60311
+ if( iFree ){
60312
+ int iFree2 = get2byte(&data[iFree]);
60313
+
60314
+ /* pageFindSlot() has already verified that free blocks are sorted
60315
+ ** in order of offset within the page, and that no block extends
60316
+ ** past the end of the page. Provided the two free slots do not
60317
+ ** overlap, this guarantees that the memmove() calls below will not
60318
+ ** overwrite the usableSize byte buffer, even if the database page
60319
+ ** is corrupt. */
60320
+ assert( iFree2==0 || iFree2>iFree );
60321
+ assert( iFree+get2byte(&data[iFree+2]) <= usableSize );
60322
+ assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize );
60323
+
60324
+ if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
60325
+ u8 *pEnd = &data[cellOffset + nCell*2];
60326
+ u8 *pAddr;
60327
+ int sz2 = 0;
60328
+ int sz = get2byte(&data[iFree+2]);
60329
+ int top = get2byte(&data[hdr+5]);
60330
+ if( iFree2 ){
60331
+ if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_BKPT;
60332
+ sz2 = get2byte(&data[iFree2+2]);
60333
+ assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
60334
+ memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
60335
+ sz += sz2;
60336
+ }
60337
+ cbrk = top+sz;
60338
+ assert( cbrk+(iFree-top) <= usableSize );
60339
+ memmove(&data[cbrk], &data[top], iFree-top);
60340
+ for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){
60341
+ pc = get2byte(pAddr);
60342
+ if( pc<iFree ){ put2byte(pAddr, pc+sz); }
60343
+ else if( pc<iFree2 ){ put2byte(pAddr, pc+sz2); }
60344
+ }
60345
+ goto defragment_out;
60346
+ }
60347
+ }
60348
+ }
60349
+
6022060350
cbrk = usableSize;
60221
- iCellFirst = cellOffset + 2*nCell;
6022260351
iCellLast = usableSize - 4;
6022360352
for(i=0; i<nCell; i++){
6022460353
u8 *pAddr; /* The i-th cell pointer */
6022560354
pAddr = &data[cellOffset + i*2];
6022660355
pc = get2byte(pAddr);
@@ -60250,20 +60379,22 @@
6025060379
memcpy(&temp[x], &data[x], (cbrk+size) - x);
6025160380
src = temp;
6025260381
}
6025360382
memcpy(&data[cbrk], &src[pc], size);
6025460383
}
60384
+ data[hdr+7] = 0;
60385
+
60386
+ defragment_out:
60387
+ if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){
60388
+ return SQLITE_CORRUPT_BKPT;
60389
+ }
6025560390
assert( cbrk>=iCellFirst );
6025660391
put2byte(&data[hdr+5], cbrk);
6025760392
data[hdr+1] = 0;
6025860393
data[hdr+2] = 0;
60259
- data[hdr+7] = 0;
6026060394
memset(&data[iCellFirst], 0, cbrk-iCellFirst);
6026160395
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
60262
- if( cbrk-iCellFirst!=pPage->nFree ){
60263
- return SQLITE_CORRUPT_BKPT;
60264
- }
6026560396
return SQLITE_OK;
6026660397
}
6026760398
6026860399
/*
6026960400
** Search the free-list on page pPg for space to store a cell nByte bytes in
@@ -60397,14 +60528,14 @@
6039760528
** to see if defragmentation is necessary.
6039860529
*/
6039960530
testcase( gap+2+nByte==top );
6040060531
if( gap+2+nByte>top ){
6040160532
assert( pPage->nCell>0 || CORRUPT_DB );
60402
- rc = defragmentPage(pPage);
60533
+ rc = defragmentPage(pPage, MIN(4, pPage->nFree - (2+nByte)));
6040360534
if( rc ) return rc;
6040460535
top = get2byteNotZero(&data[hdr+5]);
60405
- assert( gap+nByte<=top );
60536
+ assert( gap+2+nByte<=top );
6040660537
}
6040760538
6040860539
6040960540
/* Allocate memory from the gap in between the cell pointer array
6041060541
** and the cell content area. The btreeInitPage() call has already
@@ -63636,11 +63767,11 @@
6363663767
pCur->aiIdx[pCur->iPage] = 0;
6363763768
return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage],
6363863769
pCur, pCur->curPagerFlags);
6363963770
}
6364063771
63641
-#if SQLITE_DEBUG
63772
+#ifdef SQLITE_DEBUG
6364263773
/*
6364363774
** Page pParent is an internal (non-leaf) tree page. This function
6364463775
** asserts that page number iChild is the left-child if the iIdx'th
6364563776
** cell in page pParent. Or, if iIdx is equal to the total number of
6364663777
** cells in pParent, that page number iChild is the right-child of
@@ -64178,10 +64309,34 @@
6417864309
** have been deleted? This API will need to change to return an error code
6417964310
** as well as the boolean result value.
6418064311
*/
6418164312
return (CURSOR_VALID!=pCur->eState);
6418264313
}
64314
+
64315
+/*
64316
+** Return an estimate for the number of rows in the table that pCur is
64317
+** pointing to. Return a negative number if no estimate is currently
64318
+** available.
64319
+*/
64320
+SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor *pCur){
64321
+ i64 n;
64322
+ u8 i;
64323
+
64324
+ assert( cursorOwnsBtShared(pCur) );
64325
+ assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
64326
+
64327
+ /* Currently this interface is only called by the OP_IfSmaller
64328
+ ** opcode, and it that case the cursor will always be valid and
64329
+ ** will always point to a leaf node. */
64330
+ if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1;
64331
+ if( NEVER(pCur->apPage[pCur->iPage]->leaf==0) ) return -1;
64332
+
64333
+ for(n=1, i=0; i<=pCur->iPage; i++){
64334
+ n *= pCur->apPage[i]->nCell;
64335
+ }
64336
+ return n;
64337
+}
6418364338
6418464339
/*
6418564340
** Advance the cursor to the next entry in the database. If
6418664341
** successful then set *pRes=0. If the cursor
6418764342
** was already pointing to the last entry in the database before
@@ -65023,11 +65178,11 @@
6502365178
** pPrior Where to write the pgno of the first overflow page
6502465179
**
6502565180
** Use a call to btreeParseCellPtr() to verify that the values above
6502665181
** were computed correctly.
6502765182
*/
65028
-#if SQLITE_DEBUG
65183
+#ifdef SQLITE_DEBUG
6502965184
{
6503065185
CellInfo info;
6503165186
pPage->xParseCell(pPage, pCell, &info);
6503265187
assert( nHeader==(int)(info.pPayload - pCell) );
6503365188
assert( info.nKey==pX->nKey );
@@ -66549,11 +66704,11 @@
6654966704
** copied into the parent, because if the parent is page 1 then it will
6655066705
** by smaller than the child due to the database header, and so all the
6655166706
** free space needs to be up front.
6655266707
*/
6655366708
assert( nNew==1 || CORRUPT_DB );
66554
- rc = defragmentPage(apNew[0]);
66709
+ rc = defragmentPage(apNew[0], -1);
6655566710
testcase( rc!=SQLITE_OK );
6655666711
assert( apNew[0]->nFree ==
6655766712
(get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)
6655866713
|| rc!=SQLITE_OK
6655966714
);
@@ -71201,10 +71356,11 @@
7120171356
** Remember the SQL string for a prepared statement.
7120271357
*/
7120371358
SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
7120471359
assert( isPrepareV2==1 || isPrepareV2==0 );
7120571360
if( p==0 ) return;
71361
+ if( !isPrepareV2 ) p->expmask = 0;
7120671362
#if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
7120771363
if( !isPrepareV2 ) return;
7120871364
#endif
7120971365
assert( p->zSql==0 );
7121071366
p->zSql = sqlite3DbStrNDup(p->db, z, n);
@@ -71229,10 +71385,11 @@
7122971385
pB->pPrev = pTmp;
7123071386
zTmp = pA->zSql;
7123171387
pA->zSql = pB->zSql;
7123271388
pB->zSql = zTmp;
7123371389
pB->isPrepareV2 = pA->isPrepareV2;
71390
+ pB->expmask = pA->expmask;
7123471391
}
7123571392
7123671393
/*
7123771394
** Resize the Vdbe.aOp array so that it is at least nOp elements larger
7123871395
** than its current size. nOp is guaranteed to be less than or equal
@@ -73753,17 +73910,17 @@
7375373910
** Then the internal cache might have been left in an inconsistent
7375473911
** state. We need to rollback the statement transaction, if there is
7375573912
** one, or the complete transaction if there is no statement transaction.
7375673913
*/
7375773914
73915
+ if( p->magic!=VDBE_MAGIC_RUN ){
73916
+ return SQLITE_OK;
73917
+ }
7375873918
if( db->mallocFailed ){
7375973919
p->rc = SQLITE_NOMEM_BKPT;
7376073920
}
7376173921
closeAllCursors(p);
73762
- if( p->magic!=VDBE_MAGIC_RUN ){
73763
- return SQLITE_OK;
73764
- }
7376573922
checkActiveVdbeCnt(db);
7376673923
7376773924
/* No commit or rollback needed if the program never started or if the
7376873925
** SQL statement does not read or write a database file. */
7376973926
if( p->pc>=0 && p->bIsReader ){
@@ -74706,11 +74863,11 @@
7470674863
}
7470774864
assert( u<=pKeyInfo->nField + 1 );
7470874865
p->nField = u;
7470974866
}
7471074867
74711
-#if SQLITE_DEBUG
74868
+#ifdef SQLITE_DEBUG
7471274869
/*
7471374870
** This function compares two index or table record keys in the same way
7471474871
** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(),
7471574872
** this function deserializes and compares values using the
7471674873
** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used
@@ -74811,11 +74968,11 @@
7481174968
if( pKeyInfo->db->mallocFailed ) return 1;
7481274969
return 0;
7481374970
}
7481474971
#endif
7481574972
74816
-#if SQLITE_DEBUG
74973
+#ifdef SQLITE_DEBUG
7481774974
/*
7481874975
** Count the number of fields (a.k.a. columns) in the record given by
7481974976
** pKey,nKey. The verify that this count is less than or equal to the
7482074977
** limit given by pKeyInfo->nField + pKeyInfo->nXField.
7482174978
**
@@ -75694,12 +75851,12 @@
7569475851
** to sqlite3_reoptimize() that re-preparing the statement may result
7569575852
** in a better query plan.
7569675853
*/
7569775854
SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
7569875855
assert( iVar>0 );
75699
- if( iVar>32 ){
75700
- v->expmask = 0xffffffff;
75856
+ if( iVar>=32 ){
75857
+ v->expmask |= 0x80000000;
7570175858
}else{
7570275859
v->expmask |= ((u32)1 << (iVar-1));
7570375860
}
7570475861
}
7570575862
@@ -75965,11 +76122,12 @@
7596576122
sqlite3_mutex_enter(mutex);
7596676123
for(i=0; i<p->nVar; i++){
7596776124
sqlite3VdbeMemRelease(&p->aVar[i]);
7596876125
p->aVar[i].flags = MEM_Null;
7596976126
}
75970
- if( p->isPrepareV2 && p->expmask ){
76127
+ assert( p->isPrepareV2 || p->expmask==0 );
76128
+ if( p->expmask ){
7597176129
p->expired = 1;
7597276130
}
7597376131
sqlite3_mutex_leave(mutex);
7597476132
return rc;
7597576133
}
@@ -77069,13 +77227,12 @@
7706977227
** parameter in the WHERE clause might influence the choice of query plan
7707077228
** for a statement, then the statement will be automatically recompiled,
7707177229
** as if there had been a schema change, on the first sqlite3_step() call
7707277230
** following any change to the bindings of that parameter.
7707377231
*/
77074
- if( p->isPrepareV2 &&
77075
- ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff)
77076
- ){
77232
+ assert( p->isPrepareV2 || p->expmask==0 );
77233
+ if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
7707777234
p->expired = 1;
7707877235
}
7707977236
return SQLITE_OK;
7708077237
}
7708177238
@@ -77334,14 +77491,16 @@
7733477491
Vdbe *pFrom = (Vdbe*)pFromStmt;
7733577492
Vdbe *pTo = (Vdbe*)pToStmt;
7733677493
if( pFrom->nVar!=pTo->nVar ){
7733777494
return SQLITE_ERROR;
7733877495
}
77339
- if( pTo->isPrepareV2 && pTo->expmask ){
77496
+ assert( pTo->isPrepareV2 || pTo->expmask==0 );
77497
+ if( pTo->expmask ){
7734077498
pTo->expired = 1;
7734177499
}
77342
- if( pFrom->isPrepareV2 && pFrom->expmask ){
77500
+ assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
77501
+ if( pFrom->expmask ){
7734377502
pFrom->expired = 1;
7734477503
}
7734577504
return sqlite3TransferBindings(pFromStmt, pToStmt);
7734677505
}
7734777506
#endif
@@ -79658,39 +79817,39 @@
7965879817
if( pCtx->pOut != pOut ){
7965979818
pCtx->pOut = pOut;
7966079819
for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
7966179820
}
7966279821
79663
- memAboutToChange(p, pCtx->pOut);
79822
+ memAboutToChange(p, pOut);
7966479823
#ifdef SQLITE_DEBUG
7966579824
for(i=0; i<pCtx->argc; i++){
7966679825
assert( memIsValid(pCtx->argv[i]) );
7966779826
REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);
7966879827
}
7966979828
#endif
79670
- MemSetTypeFlag(pCtx->pOut, MEM_Null);
79829
+ MemSetTypeFlag(pOut, MEM_Null);
7967179830
pCtx->fErrorOrAux = 0;
7967279831
(*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */
7967379832
7967479833
/* If the function returned an error, throw an exception */
7967579834
if( pCtx->fErrorOrAux ){
7967679835
if( pCtx->isError ){
79677
- sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
79836
+ sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut));
7967879837
rc = pCtx->isError;
7967979838
}
7968079839
sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);
7968179840
if( rc ) goto abort_due_to_error;
7968279841
}
7968379842
7968479843
/* Copy the result of the function into register P3 */
7968579844
if( pOut->flags & (MEM_Str|MEM_Blob) ){
79686
- sqlite3VdbeChangeEncoding(pCtx->pOut, encoding);
79687
- if( sqlite3VdbeMemTooBig(pCtx->pOut) ) goto too_big;
79845
+ sqlite3VdbeChangeEncoding(pOut, encoding);
79846
+ if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;
7968879847
}
7968979848
79690
- REGISTER_TRACE(pOp->p3, pCtx->pOut);
79691
- UPDATE_MAX_BLOBSIZE(pCtx->pOut);
79849
+ REGISTER_TRACE(pOp->p3, pOut);
79850
+ UPDATE_MAX_BLOBSIZE(pOut);
7969279851
break;
7969379852
}
7969479853
7969579854
/* Opcode: BitAnd P1 P2 P3 * *
7969679855
** Synopsis: r[P3]=r[P1]&r[P2]
@@ -80187,11 +80346,11 @@
8018780346
pKeyInfo = pOp->p4.pKeyInfo;
8018880347
assert( n>0 );
8018980348
assert( pKeyInfo!=0 );
8019080349
p1 = pOp->p1;
8019180350
p2 = pOp->p2;
80192
-#if SQLITE_DEBUG
80351
+#ifdef SQLITE_DEBUG
8019380352
if( aPermute ){
8019480353
int k, mx = 0;
8019580354
for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];
8019680355
assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );
8019780356
assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );
@@ -82836,10 +82995,37 @@
8283682995
assert( pOp->p2==0 );
8283782996
}
8283882997
break;
8283982998
}
8284082999
83000
+/* Opcode: IfSmaller P1 P2 P3 * *
83001
+**
83002
+** Estimate the number of rows in the table P1. Jump to P2 if that
83003
+** estimate is less than approximately 2**(0.1*P3).
83004
+*/
83005
+case OP_IfSmaller: { /* jump */
83006
+ VdbeCursor *pC;
83007
+ BtCursor *pCrsr;
83008
+ int res;
83009
+ i64 sz;
83010
+
83011
+ assert( pOp->p1>=0 && pOp->p1<p->nCursor );
83012
+ pC = p->apCsr[pOp->p1];
83013
+ assert( pC!=0 );
83014
+ pCrsr = pC->uc.pCursor;
83015
+ assert( pCrsr );
83016
+ rc = sqlite3BtreeFirst(pCrsr, &res);
83017
+ if( rc ) goto abort_due_to_error;
83018
+ if( res==0 ){
83019
+ sz = sqlite3BtreeRowCountEst(pCrsr);
83020
+ if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1;
83021
+ }
83022
+ VdbeBranchTaken(res!=0,2);
83023
+ if( res ) goto jump_to_p2;
83024
+ break;
83025
+}
83026
+
8284183027
8284283028
/* Opcode: SorterSort P1 P2 * * *
8284383029
**
8284483030
** After all records have been inserted into the Sorter object
8284583031
** identified by P1, invoke this opcode to actually do the sorting.
@@ -83479,10 +83665,22 @@
8347983665
rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, flags);
8348083666
if( rc ) goto abort_due_to_error;
8348183667
pOut->u.i = pgno;
8348283668
break;
8348383669
}
83670
+
83671
+/* Opcode: SqlExec * * * P4 *
83672
+**
83673
+** Run the SQL statement or statements specified in the P4 string.
83674
+*/
83675
+case OP_SqlExec: {
83676
+ db->nSqlExec++;
83677
+ rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);
83678
+ db->nSqlExec--;
83679
+ if( rc ) goto abort_due_to_error;
83680
+ break;
83681
+}
8348483682
8348583683
/* Opcode: ParseSchema P1 * * P4 *
8348683684
**
8348783685
** Read and parse all entries from the SQLITE_MASTER table of database P1
8348883686
** that match the WHERE clause P4.
@@ -83600,11 +83798,11 @@
8360083798
**
8360183799
** Do an analysis of the currently open database. Store in
8360283800
** register P1 the text of an error message describing any problems.
8360383801
** If no problems are found, store a NULL in register P1.
8360483802
**
83605
-** The register P3 contains the maximum number of allowed errors.
83803
+** The register P3 contains one less than the maximum number of allowed errors.
8360683804
** At most reg(P3) errors will be reported.
8360783805
** In other words, the analysis stops as soon as reg(P1) errors are
8360883806
** seen. Reg(P1) is updated with the number of errors remaining.
8360983807
**
8361083808
** The root page numbers of all tables in the database are integers
@@ -83633,18 +83831,18 @@
8363383831
assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
8363483832
pIn1 = &aMem[pOp->p1];
8363583833
assert( pOp->p5<db->nDb );
8363683834
assert( DbMaskTest(p->btreeMask, pOp->p5) );
8363783835
z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot,
83638
- (int)pnErr->u.i, &nErr);
83639
- pnErr->u.i -= nErr;
83836
+ (int)pnErr->u.i+1, &nErr);
8364083837
sqlite3VdbeMemSetNull(pIn1);
8364183838
if( nErr==0 ){
8364283839
assert( z==0 );
8364383840
}else if( z==0 ){
8364483841
goto no_mem;
8364583842
}else{
83843
+ pnErr->u.i -= nErr-1;
8364683844
sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);
8364783845
}
8364883846
UPDATE_MAX_BLOBSIZE(pIn1);
8364983847
sqlite3VdbeChangeEncoding(pIn1, encoding);
8365083848
break;
@@ -92833,11 +93031,11 @@
9283393031
int nVal = sqlite3ExprVectorSize(pLeft);
9283493032
Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
9283593033
char *zRet;
9283693034
9283793035
assert( pExpr->op==TK_IN );
92838
- zRet = sqlite3DbMallocZero(pParse->db, nVal+1);
93036
+ zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);
9283993037
if( zRet ){
9284093038
int i;
9284193039
for(i=0; i<nVal; i++){
9284293040
Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
9284393041
char a = sqlite3ExprAffinity(pA);
@@ -93738,11 +93936,11 @@
9373893936
** Clear all column cache entries.
9373993937
*/
9374093938
SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
9374193939
int i;
9374293940
93743
-#if SQLITE_DEBUG
93941
+#ifdef SQLITE_DEBUG
9374493942
if( pParse->db->flags & SQLITE_VdbeAddopTrace ){
9374593943
printf("CLEAR\n");
9374693944
}
9374793945
#endif
9374893946
for(i=0; i<pParse->nColCache; i++){
@@ -95145,10 +95343,21 @@
9514595343
if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
9514695344
if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
9514795345
}
9514895346
return 0;
9514995347
}
95348
+
95349
+/*
95350
+** Like sqlite3ExprCompare() except COLLATE operators at the top-level
95351
+** are ignored.
95352
+*/
95353
+SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
95354
+ return sqlite3ExprCompare(
95355
+ sqlite3ExprSkipCollate(pA),
95356
+ sqlite3ExprSkipCollate(pB),
95357
+ iTab);
95358
+}
9515095359
9515195360
/*
9515295361
** Return true if we can prove the pE2 will always be true if pE1 is
9515395362
** true. Return false if we cannot complete the proof or if pE2 might
9515495363
** be false. Examples:
@@ -96698,10 +96907,11 @@
9669896907
Stat4Sample current; /* Current row as a Stat4Sample */
9669996908
u32 iPrn; /* Pseudo-random number used for sampling */
9670096909
Stat4Sample *aBest; /* Array of nCol best samples */
9670196910
int iMin; /* Index in a[] of entry with minimum score */
9670296911
int nSample; /* Current number of samples */
96912
+ int nMaxEqZero; /* Max leading 0 in anEq[] for any a[] entry */
9670396913
int iGet; /* Index of current sample accessed by stat_get() */
9670496914
Stat4Sample *a; /* Array of mxSample Stat4Sample objects */
9670596915
sqlite3 *db; /* Database connection, for malloc() */
9670696916
};
9670796917
@@ -96962,10 +97172,17 @@
9696297172
int i;
9696397173
9696497174
assert( IsStat4 || nEqZero==0 );
9696597175
9696697176
#ifdef SQLITE_ENABLE_STAT4
97177
+ /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0
97178
+ ** values in the anEq[] array of any sample in Stat4Accum.a[]. In
97179
+ ** other words, if nMaxEqZero is n, then it is guaranteed that there
97180
+ ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */
97181
+ if( nEqZero>p->nMaxEqZero ){
97182
+ p->nMaxEqZero = nEqZero;
97183
+ }
9696797184
if( pNew->isPSample==0 ){
9696897185
Stat4Sample *pUpgrade = 0;
9696997186
assert( pNew->anEq[pNew->iCol]>0 );
9697097187
9697197188
/* This sample is being added because the prefix that ends in column
@@ -97059,16 +97276,26 @@
9705997276
if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){
9706097277
sampleInsert(p, pBest, i);
9706197278
}
9706297279
}
9706397280
97064
- /* Update the anEq[] fields of any samples already collected. */
97281
+ /* Check that no sample contains an anEq[] entry with an index of
97282
+ ** p->nMaxEqZero or greater set to zero. */
9706597283
for(i=p->nSample-1; i>=0; i--){
9706697284
int j;
97067
- for(j=iChng; j<p->nCol; j++){
97068
- if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];
97285
+ for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 );
97286
+ }
97287
+
97288
+ /* Update the anEq[] fields of any samples already collected. */
97289
+ if( iChng<p->nMaxEqZero ){
97290
+ for(i=p->nSample-1; i>=0; i--){
97291
+ int j;
97292
+ for(j=iChng; j<p->nCol; j++){
97293
+ if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];
97294
+ }
9706997295
}
97296
+ p->nMaxEqZero = iChng;
9707097297
}
9707197298
#endif
9707297299
9707397300
#if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)
9707497301
if( iChng==0 ){
@@ -97778,44 +98005,32 @@
9777898005
/* Form 1: Analyze everything */
9777998006
for(i=0; i<db->nDb; i++){
9778098007
if( i==1 ) continue; /* Do not analyze the TEMP database */
9778198008
analyzeDatabase(pParse, i);
9778298009
}
97783
- }else if( pName2->n==0 ){
97784
- /* Form 2: Analyze the database or table named */
97785
- iDb = sqlite3FindDb(db, pName1);
97786
- if( iDb>=0 ){
97787
- analyzeDatabase(pParse, iDb);
97788
- }else{
97789
- z = sqlite3NameFromToken(db, pName1);
97790
- if( z ){
97791
- if( (pIdx = sqlite3FindIndex(db, z, 0))!=0 ){
97792
- analyzeTable(pParse, pIdx->pTable, pIdx);
97793
- }else if( (pTab = sqlite3LocateTable(pParse, 0, z, 0))!=0 ){
97794
- analyzeTable(pParse, pTab, 0);
97795
- }
97796
- sqlite3DbFree(db, z);
97797
- }
97798
- }
97799
- }else{
97800
- /* Form 3: Analyze the fully qualified table name */
98010
+ }else if( pName2->n==0 && (iDb = sqlite3FindDb(db, pName1))>=0 ){
98011
+ /* Analyze the schema named as the argument */
98012
+ analyzeDatabase(pParse, iDb);
98013
+ }else{
98014
+ /* Form 3: Analyze the table or index named as an argument */
9780198015
iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);
9780298016
if( iDb>=0 ){
97803
- zDb = db->aDb[iDb].zDbSName;
98017
+ zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;
9780498018
z = sqlite3NameFromToken(db, pTableName);
9780598019
if( z ){
9780698020
if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){
9780798021
analyzeTable(pParse, pIdx->pTable, pIdx);
9780898022
}else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){
9780998023
analyzeTable(pParse, pTab, 0);
9781098024
}
9781198025
sqlite3DbFree(db, z);
9781298026
}
97813
- }
98027
+ }
9781498028
}
97815
- v = sqlite3GetVdbe(pParse);
97816
- if( v ) sqlite3VdbeAddOp0(v, OP_Expire);
98029
+ if( db->nSqlExec==0 && (v = sqlite3GetVdbe(pParse))!=0 ){
98030
+ sqlite3VdbeAddOp0(v, OP_Expire);
98031
+ }
9781798032
}
9781898033
9781998034
/*
9782098035
** Used to pass information from the analyzer reader through to the
9782198036
** callback routine.
@@ -97940,19 +98155,24 @@
9794098155
}
9794198156
aiRowEst = pIndex->aiRowEst;
9794298157
#endif
9794398158
pIndex->bUnordered = 0;
9794498159
decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
97945
- if( pIndex->pPartIdxWhere==0 ) pTable->nRowLogEst = pIndex->aiRowLogEst[0];
98160
+ pIndex->hasStat1 = 1;
98161
+ if( pIndex->pPartIdxWhere==0 ){
98162
+ pTable->nRowLogEst = pIndex->aiRowLogEst[0];
98163
+ pTable->tabFlags |= TF_HasStat1;
98164
+ }
9794698165
}else{
9794798166
Index fakeIdx;
9794898167
fakeIdx.szIdxRow = pTable->szTabRow;
9794998168
#ifdef SQLITE_ENABLE_COSTMULT
9795098169
fakeIdx.pTable = pTable;
9795198170
#endif
9795298171
decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx);
9795398172
pTable->szTabRow = fakeIdx.szIdxRow;
98173
+ pTable->tabFlags |= TF_HasStat1;
9795498174
}
9795598175
9795698176
return 0;
9795798177
}
9795898178
@@ -98243,19 +98463,24 @@
9824398463
SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
9824498464
analysisInfo sInfo;
9824598465
HashElem *i;
9824698466
char *zSql;
9824798467
int rc = SQLITE_OK;
98468
+ Schema *pSchema = db->aDb[iDb].pSchema;
9824898469
9824998470
assert( iDb>=0 && iDb<db->nDb );
9825098471
assert( db->aDb[iDb].pBt!=0 );
9825198472
9825298473
/* Clear any prior statistics */
9825398474
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
98254
- for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
98475
+ for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){
98476
+ Table *pTab = sqliteHashData(i);
98477
+ pTab->tabFlags &= ~TF_HasStat1;
98478
+ }
98479
+ for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
9825598480
Index *pIdx = sqliteHashData(i);
98256
- pIdx->aiRowLogEst[0] = 0;
98481
+ pIdx->hasStat1 = 0;
9825798482
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
9825898483
sqlite3DeleteIndexSamples(db, pIdx);
9825998484
pIdx->aSample = 0;
9826098485
#endif
9826198486
}
@@ -98274,23 +98499,23 @@
9827498499
}
9827598500
}
9827698501
9827798502
/* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
9827898503
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
98279
- for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
98504
+ for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
9828098505
Index *pIdx = sqliteHashData(i);
98281
- if( pIdx->aiRowLogEst[0]==0 ) sqlite3DefaultRowEst(pIdx);
98506
+ if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
9828298507
}
9828398508
9828498509
/* Load the statistics from the sqlite_stat4 table. */
9828598510
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
9828698511
if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
9828798512
db->lookaside.bDisable++;
9828898513
rc = loadStat4(db, sInfo.zDatabase);
9828998514
db->lookaside.bDisable--;
9829098515
}
98291
- for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
98516
+ for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
9829298517
Index *pIdx = sqliteHashData(i);
9829398518
sqlite3_free(pIdx->aiRowEst);
9829498519
pIdx->aiRowEst = 0;
9829598520
}
9829698521
#endif
@@ -100271,10 +100496,11 @@
100271100496
SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
100272100497
Table *p;
100273100498
p = pParse->pNewTable;
100274100499
if( p==0 || NEVER(p->nCol<1) ) return;
100275100500
p->aCol[p->nCol-1].notNull = (u8)onError;
100501
+ p->tabFlags |= TF_HasNotNull;
100276100502
}
100277100503
100278100504
/*
100279100505
** Scan the column type name zType (length nType) and return the
100280100506
** associated affinity type.
@@ -102609,10 +102835,13 @@
102609102835
/* 10, 9, 8, 7, 6 */
102610102836
LogEst aVal[] = { 33, 32, 30, 28, 26 };
102611102837
LogEst *a = pIdx->aiRowLogEst;
102612102838
int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
102613102839
int i;
102840
+
102841
+ /* Indexes with default row estimates should not have stat1 data */
102842
+ assert( !pIdx->hasStat1 );
102614102843
102615102844
/* Set the first entry (number of rows in the index) to the estimated
102616102845
** number of rows in the table, or half the number of rows in the table
102617102846
** for a partial index. But do not let the estimate drop below 10. */
102618102847
a[0] = pIdx->pTable->nRowLogEst;
@@ -109798,10 +110027,13 @@
109798110027
VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
109799110028
}
109800110029
}
109801110030
sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
109802110031
VdbeComment((v, "for %s", pIdx->zName));
110032
+#ifdef SQLITE_ENABLE_NULL_TRIM
110033
+ if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);
110034
+#endif
109803110035
109804110036
/* In an UPDATE operation, if this index is the PRIMARY KEY index
109805110037
** of a WITHOUT ROWID table and there has been no change the
109806110038
** primary key, then no collision is possible. The collision detection
109807110039
** logic below can all be skipped. */
@@ -109953,12 +110185,15 @@
109953110185
109954110186
/* Records with omitted columns are only allowed for schema format
109955110187
** version 2 and later (SQLite version 3.1.4, 2005-02-20). */
109956110188
if( pTab->pSchema->file_format<2 ) return;
109957110189
109958
- for(i=pTab->nCol; i>1 && pTab->aCol[i-1].pDflt==0; i--){}
109959
- sqlite3VdbeChangeP5(v, i);
110190
+ for(i=pTab->nCol-1; i>0; i--){
110191
+ if( pTab->aCol[i].pDflt!=0 ) break;
110192
+ if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break;
110193
+ }
110194
+ sqlite3VdbeChangeP5(v, i+1);
109960110195
}
109961110196
#endif
109962110197
109963110198
/*
109964110199
** This routine generates code to finish the INSERT or UPDATE operation
@@ -110244,11 +110479,11 @@
110244110479
}
110245110480
if( sqlite3TriggerList(pParse, pDest) ){
110246110481
return 0; /* tab1 must not have triggers */
110247110482
}
110248110483
#ifndef SQLITE_OMIT_VIRTUALTABLE
110249
- if( pDest->tabFlags & TF_Virtual ){
110484
+ if( IsVirtual(pDest) ){
110250110485
return 0; /* tab1 must not be a virtual table */
110251110486
}
110252110487
#endif
110253110488
if( onError==OE_Default ){
110254110489
if( pDest->iPKey>=0 ) onError = pDest->keyConf;
@@ -110306,11 +110541,11 @@
110306110541
}
110307110542
if( HasRowid(pDest)!=HasRowid(pSrc) ){
110308110543
return 0; /* source and destination must both be WITHOUT ROWID or not */
110309110544
}
110310110545
#ifndef SQLITE_OMIT_VIRTUALTABLE
110311
- if( pSrc->tabFlags & TF_Virtual ){
110546
+ if( IsVirtual(pSrc) ){
110312110547
return 0; /* tab2 must not be a virtual table */
110313110548
}
110314110549
#endif
110315110550
if( pSrc->pSelect ){
110316110551
return 0; /* tab2 may not be a view */
@@ -110603,11 +110838,11 @@
110603110838
/* Invoke the callback function if required */
110604110839
if( xCallback && (SQLITE_ROW==rc ||
110605110840
(SQLITE_DONE==rc && !callbackIsInit
110606110841
&& db->flags&SQLITE_NullCallback)) ){
110607110842
if( !callbackIsInit ){
110608
- azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1);
110843
+ azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
110609110844
if( azCols==0 ){
110610110845
goto exec_out;
110611110846
}
110612110847
for(i=0; i<nCol; i++){
110613110848
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
@@ -110624,10 +110859,11 @@
110624110859
if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){
110625110860
sqlite3OomFault(db);
110626110861
goto exec_out;
110627110862
}
110628110863
}
110864
+ azVals[i] = 0;
110629110865
}
110630110866
if( xCallback(pArg, nCol, azVals, azCols) ){
110631110867
/* EVIDENCE-OF: R-38229-40159 If the callback function to
110632110868
** sqlite3_exec() returns non-zero, then sqlite3_exec() will
110633110869
** return SQLITE_ABORT. */
@@ -112094,15 +112330,15 @@
112094112330
#define PragTyp_JOURNAL_SIZE_LIMIT 20
112095112331
#define PragTyp_LOCK_PROXY_FILE 21
112096112332
#define PragTyp_LOCKING_MODE 22
112097112333
#define PragTyp_PAGE_COUNT 23
112098112334
#define PragTyp_MMAP_SIZE 24
112099
-#define PragTyp_PAGE_SIZE 25
112100
-#define PragTyp_SECURE_DELETE 26
112101
-#define PragTyp_SHRINK_MEMORY 27
112102
-#define PragTyp_SOFT_HEAP_LIMIT 28
112103
-#define PragTyp_STATS 29
112335
+#define PragTyp_OPTIMIZE 25
112336
+#define PragTyp_PAGE_SIZE 26
112337
+#define PragTyp_SECURE_DELETE 27
112338
+#define PragTyp_SHRINK_MEMORY 28
112339
+#define PragTyp_SOFT_HEAP_LIMIT 29
112104112340
#define PragTyp_SYNCHRONOUS 30
112105112341
#define PragTyp_TABLE_INFO 31
112106112342
#define PragTyp_TEMP_STORE 32
112107112343
#define PragTyp_TEMP_STORE_DIRECTORY 33
112108112344
#define PragTyp_THREADS 34
@@ -112112,10 +112348,11 @@
112112112348
#define PragTyp_HEXKEY 38
112113112349
#define PragTyp_KEY 39
112114112350
#define PragTyp_REKEY 40
112115112351
#define PragTyp_LOCK_STATUS 41
112116112352
#define PragTyp_PARSER_TRACE 42
112353
+#define PragTyp_STATS 43
112117112354
112118112355
/* Property flags associated with various pragma. */
112119112356
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
112120112357
#define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
112121112358
#define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -112135,51 +112372,52 @@
112135112372
/* 2 */ "name",
112136112373
/* 3 */ "type",
112137112374
/* 4 */ "notnull",
112138112375
/* 5 */ "dflt_value",
112139112376
/* 6 */ "pk",
112140
- /* 7 */ "table", /* Used by: stats */
112141
- /* 8 */ "index",
112142
- /* 9 */ "width",
112143
- /* 10 */ "height",
112144
- /* 11 */ "seqno", /* Used by: index_info */
112145
- /* 12 */ "cid",
112146
- /* 13 */ "name",
112147
- /* 14 */ "seqno", /* Used by: index_xinfo */
112148
- /* 15 */ "cid",
112149
- /* 16 */ "name",
112150
- /* 17 */ "desc",
112151
- /* 18 */ "coll",
112152
- /* 19 */ "key",
112153
- /* 20 */ "seq", /* Used by: index_list */
112154
- /* 21 */ "name",
112155
- /* 22 */ "unique",
112156
- /* 23 */ "origin",
112157
- /* 24 */ "partial",
112158
- /* 25 */ "seq", /* Used by: database_list */
112159
- /* 26 */ "name",
112160
- /* 27 */ "file",
112161
- /* 28 */ "seq", /* Used by: collation_list */
112162
- /* 29 */ "name",
112163
- /* 30 */ "id", /* Used by: foreign_key_list */
112164
- /* 31 */ "seq",
112165
- /* 32 */ "table",
112166
- /* 33 */ "from",
112167
- /* 34 */ "to",
112168
- /* 35 */ "on_update",
112169
- /* 36 */ "on_delete",
112170
- /* 37 */ "match",
112171
- /* 38 */ "table", /* Used by: foreign_key_check */
112172
- /* 39 */ "rowid",
112173
- /* 40 */ "parent",
112174
- /* 41 */ "fkid",
112175
- /* 42 */ "busy", /* Used by: wal_checkpoint */
112176
- /* 43 */ "log",
112177
- /* 44 */ "checkpointed",
112178
- /* 45 */ "timeout", /* Used by: busy_timeout */
112179
- /* 46 */ "database", /* Used by: lock_status */
112180
- /* 47 */ "status",
112377
+ /* 7 */ "tbl", /* Used by: stats */
112378
+ /* 8 */ "idx",
112379
+ /* 9 */ "wdth",
112380
+ /* 10 */ "hght",
112381
+ /* 11 */ "flgs",
112382
+ /* 12 */ "seqno", /* Used by: index_info */
112383
+ /* 13 */ "cid",
112384
+ /* 14 */ "name",
112385
+ /* 15 */ "seqno", /* Used by: index_xinfo */
112386
+ /* 16 */ "cid",
112387
+ /* 17 */ "name",
112388
+ /* 18 */ "desc",
112389
+ /* 19 */ "coll",
112390
+ /* 20 */ "key",
112391
+ /* 21 */ "seq", /* Used by: index_list */
112392
+ /* 22 */ "name",
112393
+ /* 23 */ "unique",
112394
+ /* 24 */ "origin",
112395
+ /* 25 */ "partial",
112396
+ /* 26 */ "seq", /* Used by: database_list */
112397
+ /* 27 */ "name",
112398
+ /* 28 */ "file",
112399
+ /* 29 */ "seq", /* Used by: collation_list */
112400
+ /* 30 */ "name",
112401
+ /* 31 */ "id", /* Used by: foreign_key_list */
112402
+ /* 32 */ "seq",
112403
+ /* 33 */ "table",
112404
+ /* 34 */ "from",
112405
+ /* 35 */ "to",
112406
+ /* 36 */ "on_update",
112407
+ /* 37 */ "on_delete",
112408
+ /* 38 */ "match",
112409
+ /* 39 */ "table", /* Used by: foreign_key_check */
112410
+ /* 40 */ "rowid",
112411
+ /* 41 */ "parent",
112412
+ /* 42 */ "fkid",
112413
+ /* 43 */ "busy", /* Used by: wal_checkpoint */
112414
+ /* 44 */ "log",
112415
+ /* 45 */ "checkpointed",
112416
+ /* 46 */ "timeout", /* Used by: busy_timeout */
112417
+ /* 47 */ "database", /* Used by: lock_status */
112418
+ /* 48 */ "status",
112181112419
};
112182112420
112183112421
/* Definitions of all built-in pragmas */
112184112422
typedef struct PragmaName {
112185112423
const char *const zName; /* Name of pragma */
@@ -112221,11 +112459,11 @@
112221112459
#endif
112222112460
#endif
112223112461
{/* zName: */ "busy_timeout",
112224112462
/* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
112225112463
/* ePragFlg: */ PragFlg_Result0,
112226
- /* ColNames: */ 45, 1,
112464
+ /* ColNames: */ 46, 1,
112227112465
/* iArg: */ 0 },
112228112466
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112229112467
{/* zName: */ "cache_size",
112230112468
/* ePragTyp: */ PragTyp_CACHE_SIZE,
112231112469
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -112258,11 +112496,11 @@
112258112496
#endif
112259112497
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112260112498
{/* zName: */ "collation_list",
112261112499
/* ePragTyp: */ PragTyp_COLLATION_LIST,
112262112500
/* ePragFlg: */ PragFlg_Result0,
112263
- /* ColNames: */ 28, 2,
112501
+ /* ColNames: */ 29, 2,
112264112502
/* iArg: */ 0 },
112265112503
#endif
112266112504
#if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
112267112505
{/* zName: */ "compile_options",
112268112506
/* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -112293,11 +112531,11 @@
112293112531
#endif
112294112532
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112295112533
{/* zName: */ "database_list",
112296112534
/* ePragTyp: */ PragTyp_DATABASE_LIST,
112297112535
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
112298
- /* ColNames: */ 25, 3,
112536
+ /* ColNames: */ 26, 3,
112299112537
/* iArg: */ 0 },
112300112538
#endif
112301112539
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
112302112540
{/* zName: */ "default_cache_size",
112303112541
/* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
@@ -112330,18 +112568,18 @@
112330112568
#endif
112331112569
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
112332112570
{/* zName: */ "foreign_key_check",
112333112571
/* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
112334112572
/* ePragFlg: */ PragFlg_NeedSchema,
112335
- /* ColNames: */ 38, 4,
112573
+ /* ColNames: */ 39, 4,
112336112574
/* iArg: */ 0 },
112337112575
#endif
112338112576
#if !defined(SQLITE_OMIT_FOREIGN_KEY)
112339112577
{/* zName: */ "foreign_key_list",
112340112578
/* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
112341112579
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112342
- /* ColNames: */ 30, 8,
112580
+ /* ColNames: */ 31, 8,
112343112581
/* iArg: */ 0 },
112344112582
#endif
112345112583
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
112346112584
#if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
112347112585
{/* zName: */ "foreign_keys",
@@ -112400,21 +112638,21 @@
112400112638
#endif
112401112639
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112402112640
{/* zName: */ "index_info",
112403112641
/* ePragTyp: */ PragTyp_INDEX_INFO,
112404112642
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112405
- /* ColNames: */ 11, 3,
112643
+ /* ColNames: */ 12, 3,
112406112644
/* iArg: */ 0 },
112407112645
{/* zName: */ "index_list",
112408112646
/* ePragTyp: */ PragTyp_INDEX_LIST,
112409112647
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112410
- /* ColNames: */ 20, 5,
112648
+ /* ColNames: */ 21, 5,
112411112649
/* iArg: */ 0 },
112412112650
{/* zName: */ "index_xinfo",
112413112651
/* ePragTyp: */ PragTyp_INDEX_INFO,
112414112652
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112415
- /* ColNames: */ 14, 6,
112653
+ /* ColNames: */ 15, 6,
112416112654
/* iArg: */ 1 },
112417112655
#endif
112418112656
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
112419112657
{/* zName: */ "integrity_check",
112420112658
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
@@ -112457,11 +112695,11 @@
112457112695
#endif
112458112696
#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
112459112697
{/* zName: */ "lock_status",
112460112698
/* ePragTyp: */ PragTyp_LOCK_STATUS,
112461112699
/* ePragFlg: */ PragFlg_Result0,
112462
- /* ColNames: */ 46, 2,
112700
+ /* ColNames: */ 47, 2,
112463112701
/* iArg: */ 0 },
112464112702
#endif
112465112703
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112466112704
{/* zName: */ "locking_mode",
112467112705
/* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -112476,10 +112714,17 @@
112476112714
{/* zName: */ "mmap_size",
112477112715
/* ePragTyp: */ PragTyp_MMAP_SIZE,
112478112716
/* ePragFlg: */ 0,
112479112717
/* ColNames: */ 0, 0,
112480112718
/* iArg: */ 0 },
112719
+#endif
112720
+ {/* zName: */ "optimize",
112721
+ /* ePragTyp: */ PragTyp_OPTIMIZE,
112722
+ /* ePragFlg: */ PragFlg_Result1,
112723
+ /* ColNames: */ 0, 0,
112724
+ /* iArg: */ 0 },
112725
+#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112481112726
{/* zName: */ "page_count",
112482112727
/* ePragTyp: */ PragTyp_PAGE_COUNT,
112483112728
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
112484112729
/* ColNames: */ 0, 0,
112485112730
/* iArg: */ 0 },
@@ -112574,15 +112819,15 @@
112574112819
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
112575112820
/* ColNames: */ 0, 0,
112576112821
/* iArg: */ SQLITE_SqlTrace },
112577112822
#endif
112578112823
#endif
112579
-#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112824
+#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
112580112825
{/* zName: */ "stats",
112581112826
/* ePragTyp: */ PragTyp_STATS,
112582112827
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
112583
- /* ColNames: */ 7, 4,
112828
+ /* ColNames: */ 7, 5,
112584112829
/* iArg: */ 0 },
112585112830
#endif
112586112831
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112587112832
{/* zName: */ "synchronous",
112588112833
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -112657,11 +112902,11 @@
112657112902
/* ColNames: */ 0, 0,
112658112903
/* iArg: */ 0 },
112659112904
{/* zName: */ "wal_checkpoint",
112660112905
/* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
112661112906
/* ePragFlg: */ PragFlg_NeedSchema,
112662
- /* ColNames: */ 42, 3,
112907
+ /* ColNames: */ 43, 3,
112663112908
/* iArg: */ 0 },
112664112909
#endif
112665112910
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
112666112911
{/* zName: */ "writable_schema",
112667112912
/* ePragTyp: */ PragTyp_FLAG,
@@ -112668,11 +112913,11 @@
112668112913
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
112669112914
/* ColNames: */ 0, 0,
112670112915
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
112671112916
#endif
112672112917
};
112673
-/* Number of pragmas: 60 on by default, 73 total. */
112918
+/* Number of pragmas: 60 on by default, 74 total. */
112674112919
112675112920
/************** End of pragma.h **********************************************/
112676112921
/************** Continuing where we left off in pragma.c *********************/
112677112922
112678112923
/*
@@ -112937,10 +113182,26 @@
112937113182
lwr = mid + 1;
112938113183
}
112939113184
}
112940113185
return lwr>upr ? 0 : &aPragmaName[mid];
112941113186
}
113187
+
113188
+/*
113189
+** Helper subroutine for PRAGMA integrity_check:
113190
+**
113191
+** Generate code to output a single-column result row with the result
113192
+** held in register regResult. Decrement the result count and halt if
113193
+** the maximum number of result rows have been issued.
113194
+*/
113195
+static int integrityCheckResultRow(Vdbe *v, int regResult){
113196
+ int addr;
113197
+ sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 1);
113198
+ addr = sqlite3VdbeAddOp3(v, OP_IfPos, 1, sqlite3VdbeCurrentAddr(v)+2, 1);
113199
+ VdbeCoverage(v);
113200
+ sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
113201
+ return addr;
113202
+}
112942113203
112943113204
/*
112944113205
** Process a pragma statement.
112945113206
**
112946113207
** Pragmas are of this form:
@@ -113741,33 +114002,37 @@
113741114002
}
113742114003
}
113743114004
}
113744114005
break;
113745114006
114007
+#ifdef SQLITE_DEBUG
113746114008
case PragTyp_STATS: {
113747114009
Index *pIdx;
113748114010
HashElem *i;
113749
- pParse->nMem = 4;
114011
+ pParse->nMem = 5;
113750114012
sqlite3CodeVerifySchema(pParse, iDb);
113751114013
for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
113752114014
Table *pTab = sqliteHashData(i);
113753
- sqlite3VdbeMultiLoad(v, 1, "ssii",
114015
+ sqlite3VdbeMultiLoad(v, 1, "ssiii",
113754114016
pTab->zName,
113755114017
0,
113756114018
pTab->szTabRow,
113757
- pTab->nRowLogEst);
113758
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
114019
+ pTab->nRowLogEst,
114020
+ pTab->tabFlags);
114021
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
113759114022
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
113760
- sqlite3VdbeMultiLoad(v, 2, "sii",
114023
+ sqlite3VdbeMultiLoad(v, 2, "siii",
113761114024
pIdx->zName,
113762114025
pIdx->szIdxRow,
113763
- pIdx->aiRowLogEst[0]);
113764
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
114026
+ pIdx->aiRowLogEst[0],
114027
+ pIdx->hasStat1);
114028
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
113765114029
}
113766114030
}
113767114031
}
113768114032
break;
114033
+#endif
113769114034
113770114035
case PragTyp_INDEX_INFO: if( zRight ){
113771114036
Index *pIdx;
113772114037
Table *pTab;
113773114038
pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -114020,13 +114285,21 @@
114020114285
#ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX
114021114286
# define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100
114022114287
#endif
114023114288
114024114289
#ifndef SQLITE_OMIT_INTEGRITY_CHECK
114025
- /* Pragma "quick_check" is reduced version of
114290
+ /* PRAGMA integrity_check
114291
+ ** PRAGMA integrity_check(N)
114292
+ ** PRAGMA quick_check
114293
+ ** PRAGMA quick_check(N)
114294
+ **
114295
+ ** Verify the integrity of the database.
114296
+ **
114297
+ ** The "quick_check" is reduced version of
114026114298
** integrity_check designed to detect most database corruption
114027
- ** without most of the overhead of a full integrity-check.
114299
+ ** without the overhead of cross-checking indexes. Quick_check
114300
+ ** is linear time wherease integrity_check is O(NlogN).
114028114301
*/
114029114302
case PragTyp_INTEGRITY_CHECK: {
114030114303
int i, j, addr, mxErr;
114031114304
114032114305
int isQuick = (sqlite3Tolower(zLeft[0])=='q');
@@ -114053,11 +114326,11 @@
114053114326
sqlite3GetInt32(zRight, &mxErr);
114054114327
if( mxErr<=0 ){
114055114328
mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
114056114329
}
114057114330
}
114058
- sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1); /* reg[1] holds errors left */
114331
+ sqlite3VdbeAddOp2(v, OP_Integer, mxErr-1, 1); /* reg[1] holds errors left */
114059114332
114060114333
/* Do an integrity check on each database file */
114061114334
for(i=0; i<db->nDb; i++){
114062114335
HashElem *x;
114063114336
Hash *pTbls;
@@ -114068,14 +114341,10 @@
114068114341
114069114342
if( OMIT_TEMPDB && i==1 ) continue;
114070114343
if( iDb>=0 && i!=iDb ) continue;
114071114344
114072114345
sqlite3CodeVerifySchema(pParse, i);
114073
- addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */
114074
- VdbeCoverage(v);
114075
- sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
114076
- sqlite3VdbeJumpHere(v, addr);
114077114346
114078114347
/* Do an integrity check of the B-Tree
114079114348
**
114080114349
** Begin by finding the root pages numbers
114081114350
** for all tables and indices in the database.
@@ -114111,29 +114380,30 @@
114111114380
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
114112114381
sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
114113114382
P4_DYNAMIC);
114114114383
sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1);
114115114384
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2);
114116
- sqlite3VdbeAddOp2(v, OP_ResultRow, 2, 1);
114385
+ integrityCheckResultRow(v, 2);
114117114386
sqlite3VdbeJumpHere(v, addr);
114118114387
114119114388
/* Make sure all the indices are constructed correctly.
114120114389
*/
114121
- for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){
114390
+ for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
114122114391
Table *pTab = sqliteHashData(x);
114123114392
Index *pIdx, *pPk;
114124114393
Index *pPrior = 0;
114125114394
int loopTop;
114126114395
int iDataCur, iIdxCur;
114127114396
int r1 = -1;
114128114397
114129
- if( pTab->pIndex==0 ) continue;
114398
+ if( pTab->pCheck==0
114399
+ && (pTab->tabFlags & TF_HasNotNull)==0
114400
+ && (pTab->pIndex==0 || isQuick)
114401
+ ){
114402
+ continue; /* No additional checks needed for this table */
114403
+ }
114130114404
pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
114131
- addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
114132
- VdbeCoverage(v);
114133
- sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
114134
- sqlite3VdbeJumpHere(v, addr);
114135114405
sqlite3ExprCacheClear(pParse);
114136114406
sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,
114137114407
1, 0, &iDataCur, &iIdxCur);
114138114408
sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
114139114409
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
@@ -114144,28 +114414,46 @@
114144114414
sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
114145114415
loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
114146114416
/* Verify that all NOT NULL columns really are NOT NULL */
114147114417
for(j=0; j<pTab->nCol; j++){
114148114418
char *zErr;
114149
- int jmp2, jmp3;
114419
+ int jmp2;
114150114420
if( j==pTab->iPKey ) continue;
114151114421
if( pTab->aCol[j].notNull==0 ) continue;
114152114422
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
114153114423
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
114154114424
jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
114155
- sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
114156114425
zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
114157114426
pTab->aCol[j].zName);
114158114427
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
114159
- sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);
114160
- jmp3 = sqlite3VdbeAddOp1(v, OP_IfPos, 1); VdbeCoverage(v);
114161
- sqlite3VdbeAddOp0(v, OP_Halt);
114428
+ integrityCheckResultRow(v, 3);
114162114429
sqlite3VdbeJumpHere(v, jmp2);
114163
- sqlite3VdbeJumpHere(v, jmp3);
114430
+ }
114431
+ /* Verify CHECK constraints */
114432
+ if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
114433
+ int addrCkFault = sqlite3VdbeMakeLabel(v);
114434
+ int addrCkOk = sqlite3VdbeMakeLabel(v);
114435
+ ExprList *pCheck = pTab->pCheck;
114436
+ char *zErr;
114437
+ int k;
114438
+ pParse->iSelfTab = iDataCur;
114439
+ sqlite3ExprCachePush(pParse);
114440
+ for(k=pCheck->nExpr-1; k>0; k--){
114441
+ sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
114442
+ }
114443
+ sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
114444
+ SQLITE_JUMPIFNULL);
114445
+ sqlite3VdbeResolveLabel(v, addrCkFault);
114446
+ zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
114447
+ pTab->zName);
114448
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
114449
+ integrityCheckResultRow(v, 3);
114450
+ sqlite3VdbeResolveLabel(v, addrCkOk);
114451
+ sqlite3ExprCachePop(pParse);
114164114452
}
114165114453
/* Validate index entries for the current row */
114166
- for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
114454
+ for(j=0, pIdx=pTab->pIndex; pIdx && !isQuick; pIdx=pIdx->pNext, j++){
114167114455
int jmp2, jmp3, jmp4, jmp5;
114168114456
int ckUniq = sqlite3VdbeMakeLabel(v);
114169114457
if( pPk==pIdx ) continue;
114170114458
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
114171114459
pPrior, r1);
@@ -114172,20 +114460,17 @@
114172114460
pPrior = pIdx;
114173114461
sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */
114174114462
/* Verify that an index entry exists for the current table row */
114175114463
jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
114176114464
pIdx->nColumn); VdbeCoverage(v);
114177
- sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
114178114465
sqlite3VdbeLoadString(v, 3, "row ");
114179114466
sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
114180114467
sqlite3VdbeLoadString(v, 4, " missing from index ");
114181114468
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
114182114469
jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
114183114470
sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
114184
- sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);
114185
- jmp4 = sqlite3VdbeAddOp1(v, OP_IfPos, 1); VdbeCoverage(v);
114186
- sqlite3VdbeAddOp0(v, OP_Halt);
114471
+ jmp4 = integrityCheckResultRow(v, 3);
114187114472
sqlite3VdbeJumpHere(v, jmp2);
114188114473
/* For UNIQUE indexes, verify that only one entry exists with the
114189114474
** current key. The entry is unique if (1) any column is NULL
114190114475
** or (2) the next entry has a different key */
114191114476
if( IsUniqueIndex(pIdx) ){
@@ -114202,11 +114487,10 @@
114202114487
jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);
114203114488
sqlite3VdbeGoto(v, uniqOk);
114204114489
sqlite3VdbeJumpHere(v, jmp6);
114205114490
sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,
114206114491
pIdx->nKeyCol); VdbeCoverage(v);
114207
- sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
114208114492
sqlite3VdbeLoadString(v, 3, "non-unique entry in index ");
114209114493
sqlite3VdbeGoto(v, jmp5);
114210114494
sqlite3VdbeResolveLabel(v, uniqOk);
114211114495
}
114212114496
sqlite3VdbeJumpHere(v, jmp4);
@@ -114213,40 +114497,39 @@
114213114497
sqlite3ResolvePartIdxLabel(pParse, jmp3);
114214114498
}
114215114499
sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
114216114500
sqlite3VdbeJumpHere(v, loopTop-1);
114217114501
#ifndef SQLITE_OMIT_BTREECOUNT
114218
- sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
114219
- for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
114220
- if( pPk==pIdx ) continue;
114221
- addr = sqlite3VdbeCurrentAddr(v);
114222
- sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2); VdbeCoverage(v);
114223
- sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
114224
- sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
114225
- sqlite3VdbeAddOp3(v, OP_Eq, 8+j, addr+8, 3); VdbeCoverage(v);
114226
- sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
114227
- sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
114228
- sqlite3VdbeLoadString(v, 3, pIdx->zName);
114229
- sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
114230
- sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
114502
+ if( !isQuick ){
114503
+ sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
114504
+ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
114505
+ if( pPk==pIdx ) continue;
114506
+ sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
114507
+ addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);
114508
+ sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
114509
+ sqlite3VdbeLoadString(v, 3, pIdx->zName);
114510
+ sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
114511
+ integrityCheckResultRow(v, 7);
114512
+ sqlite3VdbeJumpHere(v, addr);
114513
+ }
114231114514
}
114232114515
#endif /* SQLITE_OMIT_BTREECOUNT */
114233114516
}
114234114517
}
114235114518
{
114236114519
static const int iLn = VDBE_OFFSET_LINENO(2);
114237114520
static const VdbeOpList endCode[] = {
114238114521
{ OP_AddImm, 1, 0, 0}, /* 0 */
114239
- { OP_If, 1, 4, 0}, /* 1 */
114522
+ { OP_IfNotZero, 1, 4, 0}, /* 1 */
114240114523
{ OP_String8, 0, 3, 0}, /* 2 */
114241114524
{ OP_ResultRow, 3, 1, 0}, /* 3 */
114242114525
};
114243114526
VdbeOp *aOp;
114244114527
114245114528
aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn);
114246114529
if( aOp ){
114247
- aOp[0].p2 = -mxErr;
114530
+ aOp[0].p2 = 1-mxErr;
114248114531
aOp[2].p4type = P4_STATIC;
114249114532
aOp[2].p4.z = "ok";
114250114533
}
114251114534
}
114252114535
}
@@ -114466,10 +114749,122 @@
114466114749
*/
114467114750
case PragTyp_SHRINK_MEMORY: {
114468114751
sqlite3_db_release_memory(db);
114469114752
break;
114470114753
}
114754
+
114755
+ /*
114756
+ ** PRAGMA optimize
114757
+ ** PRAGMA optimize(MASK)
114758
+ ** PRAGMA schema.optimize
114759
+ ** PRAGMA schema.optimize(MASK)
114760
+ **
114761
+ ** Attempt to optimize the database. All schemas are optimized in the first
114762
+ ** two forms, and only the specified schema is optimized in the latter two.
114763
+ **
114764
+ ** The details of optimizations performed by this pragma does are expected
114765
+ ** to change and improve over time. Applications should anticipate that
114766
+ ** this pragma will perform new optimizations in future releases.
114767
+ **
114768
+ ** The optional argument is a bitmask of optimizations to perform:
114769
+ **
114770
+ ** 0x0001 Debugging mode. Do not actually perform any optimizations
114771
+ ** but instead return one line of text for each optimization
114772
+ ** that would have been done. Off by default.
114773
+ **
114774
+ ** 0x0002 Run ANALYZE on tables that might benefit. On by default.
114775
+ ** See below for additional information.
114776
+ **
114777
+ ** 0x0004 (Not yet implemented) Record usage and performance
114778
+ ** information from the current session in the
114779
+ ** database file so that it will be available to "optimize"
114780
+ ** pragmas run by future database connections.
114781
+ **
114782
+ ** 0x0008 (Not yet implemented) Create indexes that might have
114783
+ ** been helpful to recent queries
114784
+ **
114785
+ ** The default MASK is 0x000e, which means perform all of the optimizations
114786
+ ** listed above except do not set Debug Mode. New optimizations may be
114787
+ ** added in future releases but they will be turned off by default. The
114788
+ ** default MASK will always be 0x0e.
114789
+ **
114790
+ ** DETERMINATION OF WHEN TO RUN ANALYZE
114791
+ **
114792
+ ** In the current implementation, a table is analyzed if only if all of
114793
+ ** the following are true:
114794
+ **
114795
+ ** (1) MASK bit 0x02 is set.
114796
+ **
114797
+ ** (2) The query planner used sqlite_stat1-style statistics for one or
114798
+ ** more indexes of the table at some point during the lifetime of
114799
+ ** the current connection.
114800
+ **
114801
+ ** (3) One or more indexes of the table are currently unanalyzed OR
114802
+ ** the number of rows in the table has increased by 25 times or more
114803
+ ** since the last time ANALYZE was run.
114804
+ **
114805
+ ** The rules for when tables are analyzed are likely to change in
114806
+ ** future releases.
114807
+ */
114808
+ case PragTyp_OPTIMIZE: {
114809
+ int iDbLast; /* Loop termination point for the schema loop */
114810
+ int iTabCur; /* Cursor for a table whose size needs checking */
114811
+ HashElem *k; /* Loop over tables of a schema */
114812
+ Schema *pSchema; /* The current schema */
114813
+ Table *pTab; /* A table in the schema */
114814
+ Index *pIdx; /* An index of the table */
114815
+ LogEst szThreshold; /* Size threshold above which reanalysis is needd */
114816
+ char *zSubSql; /* SQL statement for the OP_SqlExec opcode */
114817
+ u32 opMask; /* Mask of operations to perform */
114818
+
114819
+ if( zRight ){
114820
+ opMask = (u32)sqlite3Atoi(zRight);
114821
+ if( (opMask & 0x02)==0 ) break;
114822
+ }else{
114823
+ opMask = 0xe;
114824
+ }
114825
+ iTabCur = pParse->nTab++;
114826
+ for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){
114827
+ if( iDb==1 ) continue;
114828
+ sqlite3CodeVerifySchema(pParse, iDb);
114829
+ pSchema = db->aDb[iDb].pSchema;
114830
+ for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){
114831
+ pTab = (Table*)sqliteHashData(k);
114832
+
114833
+ /* If table pTab has not been used in a way that would benefit from
114834
+ ** having analysis statistics during the current session, then skip it.
114835
+ ** This also has the effect of skipping virtual tables and views */
114836
+ if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue;
114837
+
114838
+ /* Reanalyze if the table is 25 times larger than the last analysis */
114839
+ szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 );
114840
+ for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
114841
+ if( !pIdx->hasStat1 ){
114842
+ szThreshold = 0; /* Always analyze if any index lacks statistics */
114843
+ break;
114844
+ }
114845
+ }
114846
+ if( szThreshold ){
114847
+ sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);
114848
+ sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur,
114849
+ sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold);
114850
+ VdbeCoverage(v);
114851
+ }
114852
+ zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"",
114853
+ db->aDb[iDb].zDbSName, pTab->zName);
114854
+ if( opMask & 0x01 ){
114855
+ int r1 = sqlite3GetTempReg(pParse);
114856
+ sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC);
114857
+ sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1);
114858
+ }else{
114859
+ sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC);
114860
+ }
114861
+ }
114862
+ }
114863
+ sqlite3VdbeAddOp0(v, OP_Expire);
114864
+ break;
114865
+ }
114471114866
114472114867
/*
114473114868
** PRAGMA busy_timeout
114474114869
** PRAGMA busy_timeout = N
114475114870
**
@@ -123782,12 +124177,29 @@
123782124177
** transient would cause the database file to appear to be deleted
123783124178
** following reboot.
123784124179
*/
123785124180
SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){
123786124181
Vdbe *v = sqlite3GetVdbe(pParse);
123787
- int iDb = pNm ? sqlite3TwoPartName(pParse, pNm, pNm, &pNm) : 0;
123788
- if( v && (iDb>=2 || iDb==0) ){
124182
+ int iDb = 0;
124183
+ if( v==0 ) return;
124184
+ if( pNm ){
124185
+#ifndef SQLITE_BUG_COMPATIBLE_20160819
124186
+ /* Default behavior: Report an error if the argument to VACUUM is
124187
+ ** not recognized */
124188
+ iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);
124189
+ if( iDb<0 ) return;
124190
+#else
124191
+ /* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments
124192
+ ** to VACUUM are silently ignored. This is a back-out of a bug fix that
124193
+ ** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270).
124194
+ ** The buggy behavior is required for binary compatibility with some
124195
+ ** legacy applications. */
124196
+ iDb = sqlite3FindDb(pParse->db, pNm);
124197
+ if( iDb<0 ) iDb = 0;
124198
+#endif
124199
+ }
124200
+ if( iDb!=1 ){
123789124201
sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);
123790124202
sqlite3VdbeUsesBtree(v, iDb);
123791124203
}
123792124204
return;
123793124205
}
@@ -124377,12 +124789,11 @@
124377124789
124378124790
db = pParse->db;
124379124791
iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
124380124792
assert( iDb>=0 );
124381124793
124382
- pTable->tabFlags |= TF_Virtual;
124383
- pTable->nModuleArg = 0;
124794
+ assert( pTable->nModuleArg==0 );
124384124795
addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
124385124796
addModuleArgument(db, pTable, 0);
124386124797
addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
124387124798
assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)
124388124799
|| (pParse->sNameToken.z==pName1->z && pName2->z==0)
@@ -124666,11 +125077,11 @@
124666125077
const char *zMod;
124667125078
Module *pMod;
124668125079
int rc;
124669125080
124670125081
assert( pTab );
124671
- if( (pTab->tabFlags & TF_Virtual)==0 || sqlite3GetVTable(db, pTab) ){
125082
+ if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){
124672125083
return SQLITE_OK;
124673125084
}
124674125085
124675125086
/* Locate the required virtual table module */
124676125087
zMod = pTab->azModuleArg[0];
@@ -124736,11 +125147,11 @@
124736125147
Table *pTab;
124737125148
Module *pMod;
124738125149
const char *zMod;
124739125150
124740125151
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
124741
- assert( pTab && (pTab->tabFlags & TF_Virtual)!=0 && !pTab->pVTable );
125152
+ assert( pTab && IsVirtual(pTab) && !pTab->pVTable );
124742125153
124743125154
/* Locate the required virtual table module */
124744125155
zMod = pTab->azModuleArg[0];
124745125156
pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);
124746125157
@@ -124790,11 +125201,11 @@
124790125201
sqlite3Error(db, SQLITE_MISUSE);
124791125202
sqlite3_mutex_leave(db->mutex);
124792125203
return SQLITE_MISUSE_BKPT;
124793125204
}
124794125205
pTab = pCtx->pTab;
124795
- assert( (pTab->tabFlags & TF_Virtual)!=0 );
125206
+ assert( IsVirtual(pTab) );
124796125207
124797125208
pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
124798125209
if( pParse==0 ){
124799125210
rc = SQLITE_NOMEM_BKPT;
124800125211
}else{
@@ -124804,11 +125215,11 @@
124804125215
124805125216
if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr)
124806125217
&& pParse->pNewTable
124807125218
&& !db->mallocFailed
124808125219
&& !pParse->pNewTable->pSelect
124809
- && (pParse->pNewTable->tabFlags & TF_Virtual)==0
125220
+ && !IsVirtual(pParse->pNewTable)
124810125221
){
124811125222
if( !pTab->aCol ){
124812125223
Table *pNew = pParse->pNewTable;
124813125224
Index *pIdx;
124814125225
pTab->aCol = pNew->aCol;
@@ -125093,11 +125504,11 @@
125093125504
/* Check to see the left operand is a column in a virtual table */
125094125505
if( NEVER(pExpr==0) ) return pDef;
125095125506
if( pExpr->op!=TK_COLUMN ) return pDef;
125096125507
pTab = pExpr->pTab;
125097125508
if( NEVER(pTab==0) ) return pDef;
125098
- if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef;
125509
+ if( !IsVirtual(pTab) ) return pDef;
125099125510
pVtab = sqlite3GetVTable(db, pTab)->pVtab;
125100125511
assert( pVtab!=0 );
125101125512
assert( pVtab->pModule!=0 );
125102125513
pMod = (sqlite3_module *)pVtab->pModule;
125103125514
if( pMod->xFindFunction==0 ) return pDef;
@@ -125188,12 +125599,11 @@
125188125599
return 0;
125189125600
}
125190125601
pMod->pEpoTab = pTab;
125191125602
pTab->nTabRef = 1;
125192125603
pTab->pSchema = db->aDb[0].pSchema;
125193
- pTab->tabFlags |= TF_Virtual;
125194
- pTab->nModuleArg = 0;
125604
+ assert( pTab->nModuleArg==0 );
125195125605
pTab->iPKey = -1;
125196125606
addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
125197125607
addModuleArgument(db, pTab, 0);
125198125608
addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
125199125609
rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
@@ -125260,11 +125670,11 @@
125260125670
case SQLITE_VTAB_CONSTRAINT_SUPPORT: {
125261125671
VtabCtx *p = db->pVtabCtx;
125262125672
if( !p ){
125263125673
rc = SQLITE_MISUSE_BKPT;
125264125674
}else{
125265
- assert( p->pTab==0 || (p->pTab->tabFlags & TF_Virtual)!=0 );
125675
+ assert( p->pTab==0 || IsVirtual(p->pTab) );
125266125676
p->pVTable->bConstraint = (u8)va_arg(ap, int);
125267125677
}
125268125678
break;
125269125679
}
125270125680
default:
@@ -125699,12 +126109,17 @@
125699126109
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
125700126110
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
125701126111
UnpackedRecord *pRec; /* Probe for stat4 (if required) */
125702126112
int nRecValid; /* Number of valid fields currently in pRec */
125703126113
#endif
126114
+ unsigned int bldFlags; /* SQLITE_BLDF_* flags */
125704126115
};
125705126116
126117
+/* Allowed values for WhereLoopBuider.bldFlags */
126118
+#define SQLITE_BLDF_INDEXED 0x0001 /* An index is used */
126119
+#define SQLITE_BLDF_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
126120
+
125706126121
/*
125707126122
** The WHERE clause processing routine has two halves. The
125708126123
** first part does the start of the WHERE loop and the second
125709126124
** half does the tail of the WHERE loop. An instance of
125710126125
** this structure is returned by the first half and passed
@@ -125715,11 +126130,11 @@
125715126130
*/
125716126131
struct WhereInfo {
125717126132
Parse *pParse; /* Parsing and code generating context */
125718126133
SrcList *pTabList; /* List of tables in the join */
125719126134
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
125720
- ExprList *pDistinctSet; /* DISTINCT over all these values */
126135
+ ExprList *pResultSet; /* Result set of the query */
125721126136
LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */
125722126137
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
125723126138
int iContinue; /* Jump here to continue with next record */
125724126139
int iBreak; /* Jump here to break out of the loop */
125725126140
int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
@@ -126899,10 +127314,11 @@
126899127314
Parse *pParse; /* Parsing context */
126900127315
sqlite3 *db; /* Database connection */
126901127316
Vdbe *v; /* The prepared stmt under constructions */
126902127317
struct SrcList_item *pTabItem; /* FROM clause term being coded */
126903127318
int addrBrk; /* Jump here to break out of the loop */
127319
+ int addrHalt; /* addrBrk for the outermost loop */
126904127320
int addrCont; /* Jump here to continue with next cycle */
126905127321
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
126906127322
int iReleaseReg = 0; /* Temp register to free before returning */
126907127323
126908127324
pParse = pWInfo->pParse;
@@ -126939,10 +127355,15 @@
126939127355
if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
126940127356
pLevel->iLeftJoin = ++pParse->nMem;
126941127357
sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
126942127358
VdbeComment((v, "init LEFT JOIN no-match flag"));
126943127359
}
127360
+
127361
+ /* Compute a safe address to jump to if we discover that the table for
127362
+ ** this loop is empty and can never contribute content. */
127363
+ for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){}
127364
+ addrHalt = pWInfo->a[j].addrBrk;
126944127365
126945127366
/* Special case of a FROM clause subquery implemented as a co-routine */
126946127367
if( pTabItem->fg.viaCoroutine ){
126947127368
int regYield = pTabItem->regReturn;
126948127369
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
@@ -127124,11 +127545,11 @@
127124127545
VdbeCoverageIf(v, pX->op==TK_LT);
127125127546
VdbeCoverageIf(v, pX->op==TK_GE);
127126127547
sqlite3ExprCacheAffinityChange(pParse, r1, 1);
127127127548
sqlite3ReleaseTempReg(pParse, rTemp);
127128127549
}else{
127129
- sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk);
127550
+ sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);
127130127551
VdbeCoverageIf(v, bRev==0);
127131127552
VdbeCoverageIf(v, bRev!=0);
127132127553
}
127133127554
if( pEnd ){
127134127555
Expr *pX;
@@ -127770,11 +128191,11 @@
127770128191
pLevel->op = OP_Noop;
127771128192
}else{
127772128193
codeCursorHint(pTabItem, pWInfo, pLevel, 0);
127773128194
pLevel->op = aStep[bRev];
127774128195
pLevel->p1 = iCur;
127775
- pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
128196
+ pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);
127776128197
VdbeCoverageIf(v, bRev==0);
127777128198
VdbeCoverageIf(v, bRev!=0);
127778128199
pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
127779128200
}
127780128201
}
@@ -128095,19 +128516,10 @@
128095128516
#ifdef SQLITE_EBCDIC
128096128517
if( *pnoCase ) return 0;
128097128518
#endif
128098128519
pList = pExpr->x.pList;
128099128520
pLeft = pList->a[1].pExpr;
128100
- if( pLeft->op!=TK_COLUMN
128101
- || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
128102
- || IsVirtual(pLeft->pTab) /* Value might be numeric */
128103
- ){
128104
- /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
128105
- ** be the name of an indexed column with TEXT affinity. */
128106
- return 0;
128107
- }
128108
- assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
128109128521
128110128522
pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
128111128523
op = pRight->op;
128112128524
if( op==TK_VARIABLE ){
128113128525
Vdbe *pReprepare = pParse->pReprepare;
@@ -128120,10 +128532,27 @@
128120128532
assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
128121128533
}else if( op==TK_STRING ){
128122128534
z = pRight->u.zToken;
128123128535
}
128124128536
if( z ){
128537
+
128538
+ /* If the RHS begins with a digit or a minus sign, then the LHS must
128539
+ ** be an ordinary column (not a virtual table column) with TEXT affinity.
128540
+ ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false
128541
+ ** even though "lhs LIKE rhs" is true. But if the RHS does not start
128542
+ ** with a digit or '-', then "lhs LIKE rhs" will always be false if
128543
+ ** the LHS is numeric and so the optimization still works.
128544
+ */
128545
+ if( sqlite3Isdigit(z[0]) || z[0]=='-' ){
128546
+ if( pLeft->op!=TK_COLUMN
128547
+ || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
128548
+ || IsVirtual(pLeft->pTab) /* Value might be numeric */
128549
+ ){
128550
+ sqlite3ValueFree(pVal);
128551
+ return 0;
128552
+ }
128553
+ }
128125128554
cnt = 0;
128126128555
while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
128127128556
cnt++;
128128128557
}
128129128558
if( cnt!=0 && 255!=(u8)z[cnt-1] ){
@@ -128748,11 +129177,11 @@
128748129177
iCur = pFrom->a[i].iCursor;
128749129178
for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
128750129179
if( pIdx->aColExpr==0 ) continue;
128751129180
for(i=0; i<pIdx->nKeyCol; i++){
128752129181
if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
128753
- if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
129182
+ if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
128754129183
*piCur = iCur;
128755129184
*piColumn = XN_EXPR;
128756129185
return 1;
128757129186
}
128758129187
}
@@ -129539,11 +129968,12 @@
129539129968
do{
129540129969
for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
129541129970
if( pTerm->leftCursor==iCur
129542129971
&& pTerm->u.leftColumn==iColumn
129543129972
&& (iColumn!=XN_EXPR
129544
- || sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0)
129973
+ || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
129974
+ pScan->pIdxExpr,iCur)==0)
129545129975
&& (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
129546129976
){
129547129977
if( (pTerm->eOperator & WO_EQUIV)!=0
129548129978
&& pScan->nEquiv<ArraySize(pScan->aiCur)
129549129979
&& (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
@@ -131716,10 +132146,15 @@
131716132146
testcase( eOp & WO_IS );
131717132147
testcase( eOp & WO_ISNULL );
131718132148
continue;
131719132149
}
131720132150
132151
+ if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){
132152
+ pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;
132153
+ }else{
132154
+ pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;
132155
+ }
131721132156
pNew->wsFlags = saved_wsFlags;
131722132157
pNew->u.btree.nEq = saved_nEq;
131723132158
pNew->u.btree.nBtm = saved_nBtm;
131724132159
pNew->u.btree.nTop = saved_nTop;
131725132160
pNew->nLTerm = saved_nLTerm;
@@ -132263,11 +132698,19 @@
132263132698
pNew->nOut = rSize;
132264132699
if( rc ) break;
132265132700
}
132266132701
}
132267132702
132703
+ pBuilder->bldFlags = 0;
132268132704
rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
132705
+ if( pBuilder->bldFlags==SQLITE_BLDF_INDEXED ){
132706
+ /* If a non-unique index is used, or if a prefix of the key for
132707
+ ** unique index is used (making the index functionally non-unique)
132708
+ ** then the sqlite_stat1 data becomes important for scoring the
132709
+ ** plan */
132710
+ pTab->tabFlags |= TF_StatsUsed;
132711
+ }
132269132712
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
132270132713
sqlite3Stat4ProbeFree(pBuilder->pRec);
132271132714
pBuilder->nRecValid = 0;
132272132715
pBuilder->pRec = 0;
132273132716
#endif
@@ -133443,13 +133886,13 @@
133443133886
&& (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
133444133887
&& pWInfo->eDistinct==WHERE_DISTINCT_NOOP
133445133888
&& nRowEst
133446133889
){
133447133890
Bitmask notUsed;
133448
- int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pDistinctSet, pFrom,
133891
+ int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,
133449133892
WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
133450
- if( rc==pWInfo->pDistinctSet->nExpr ){
133893
+ if( rc==pWInfo->pResultSet->nExpr ){
133451133894
pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
133452133895
}
133453133896
}
133454133897
if( pWInfo->pOrderBy ){
133455133898
if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
@@ -133682,11 +134125,11 @@
133682134125
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
133683134126
Parse *pParse, /* The parser context */
133684134127
SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
133685134128
Expr *pWhere, /* The WHERE clause */
133686134129
ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
133687
- ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
134130
+ ExprList *pResultSet, /* Query result set. Req'd for DISTINCT */
133688134131
u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
133689134132
int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
133690134133
** If WHERE_USE_LIMIT, then the limit amount */
133691134134
){
133692134135
int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
@@ -133758,11 +134201,11 @@
133758134201
goto whereBeginError;
133759134202
}
133760134203
pWInfo->pParse = pParse;
133761134204
pWInfo->pTabList = pTabList;
133762134205
pWInfo->pOrderBy = pOrderBy;
133763
- pWInfo->pDistinctSet = pDistinctSet;
134206
+ pWInfo->pResultSet = pResultSet;
133764134207
pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
133765134208
pWInfo->nLevel = nTabList;
133766134209
pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);
133767134210
pWInfo->wctrlFlags = wctrlFlags;
133768134211
pWInfo->iLimit = iAuxArg;
@@ -133836,17 +134279,17 @@
133836134279
/* Analyze all of the subexpressions. */
133837134280
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
133838134281
if( db->mallocFailed ) goto whereBeginError;
133839134282
133840134283
if( wctrlFlags & WHERE_WANT_DISTINCT ){
133841
- if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pDistinctSet) ){
134284
+ if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
133842134285
/* The DISTINCT marking is pointless. Ignore it. */
133843134286
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
133844134287
}else if( pOrderBy==0 ){
133845134288
/* Try to ORDER BY the result set to make distinct processing easier */
133846134289
pWInfo->wctrlFlags |= WHERE_DISTINCTBY;
133847
- pWInfo->pOrderBy = pDistinctSet;
134290
+ pWInfo->pOrderBy = pResultSet;
133848134291
}
133849134292
}
133850134293
133851134294
/* Construct the WhereLoop objects */
133852134295
#if defined(WHERETRACE_ENABLED)
@@ -133918,14 +134361,14 @@
133918134361
}
133919134362
}
133920134363
#endif
133921134364
/* Attempt to omit tables from the join that do not effect the result */
133922134365
if( pWInfo->nLevel>=2
133923
- && pDistinctSet!=0
134366
+ && pResultSet!=0
133924134367
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
133925134368
){
133926
- Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pDistinctSet);
134369
+ Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);
133927134370
if( sWLB.pOrderBy ){
133928134371
tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
133929134372
}
133930134373
while( pWInfo->nLevel>=2 ){
133931134374
WhereTerm *pTerm, *pEnd;
@@ -134704,166 +135147,166 @@
134704135147
**
134705135148
*********** Begin parsing tables **********************************************/
134706135149
#define YY_ACTTAB_COUNT (1567)
134707135150
static const YYACTIONTYPE yy_action[] = {
134708135151
/* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100,
134709
- /* 10 */ 90, 842, 842, 854, 857, 846, 846, 97, 97, 98,
135152
+ /* 10 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98,
134710135153
/* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95,
134711
- /* 30 */ 94, 94, 94, 93, 351, 325, 977, 977, 824, 824,
134712
- /* 40 */ 826, 947, 354, 99, 100, 90, 842, 842, 854, 857,
134713
- /* 50 */ 846, 846, 97, 97, 98, 98, 98, 98, 338, 96,
135154
+ /* 30 */ 94, 94, 94, 93, 351, 325, 976, 976, 824, 824,
135155
+ /* 40 */ 826, 946, 354, 99, 100, 90, 978, 978, 853, 856,
135156
+ /* 50 */ 845, 845, 97, 97, 98, 98, 98, 98, 338, 96,
134714135157
/* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
134715
- /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 977, 977,
135158
+ /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 976, 976,
134716135159
/* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100,
134717
- /* 90 */ 90, 842, 842, 854, 857, 846, 846, 97, 97, 98,
135160
+ /* 90 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98,
134718135161
/* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95,
134719135162
/* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325,
134720135163
/* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90,
134721
- /* 130 */ 842, 842, 854, 857, 846, 846, 97, 97, 98, 98,
135164
+ /* 130 */ 978, 978, 853, 856, 845, 845, 97, 97, 98, 98,
134722135165
/* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94,
134723
- /* 150 */ 94, 94, 93, 351, 958, 958, 325, 268, 428, 413,
134724
- /* 160 */ 411, 61, 752, 752, 99, 100, 90, 842, 842, 854,
134725
- /* 170 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 60,
135166
+ /* 150 */ 94, 94, 93, 351, 957, 957, 325, 268, 428, 413,
135167
+ /* 160 */ 411, 61, 752, 752, 99, 100, 90, 978, 978, 853,
135168
+ /* 170 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 60,
134726135169
/* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134727
- /* 190 */ 351, 325, 270, 329, 273, 277, 959, 960, 250, 99,
134728
- /* 200 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
135170
+ /* 190 */ 351, 325, 270, 329, 273, 277, 958, 959, 250, 99,
135171
+ /* 200 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
134729135172
/* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95,
134730
- /* 220 */ 95, 94, 94, 94, 93, 351, 325, 938, 1326, 698,
134731
- /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 842, 842, 854,
134732
- /* 240 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 347,
135173
+ /* 220 */ 95, 94, 94, 94, 93, 351, 325, 937, 1326, 698,
135174
+ /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 978, 978, 853,
135175
+ /* 240 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 347,
134733135176
/* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134734
- /* 260 */ 351, 325, 938, 1327, 384, 699, 1327, 381, 379, 99,
134735
- /* 270 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
135177
+ /* 260 */ 351, 325, 937, 1327, 384, 699, 1327, 381, 379, 99,
135178
+ /* 270 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
134736135179
/* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95,
134737135180
/* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178,
134738
- /* 300 */ 833, 936, 373, 700, 99, 100, 90, 842, 842, 854,
134739
- /* 310 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 375,
135181
+ /* 300 */ 833, 935, 373, 700, 99, 100, 90, 978, 978, 853,
135182
+ /* 310 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 375,
134740135183
/* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134741
- /* 330 */ 351, 325, 1276, 947, 354, 818, 936, 739, 739, 99,
134742
- /* 340 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
135184
+ /* 330 */ 351, 325, 1275, 946, 354, 818, 935, 739, 739, 99,
135185
+ /* 340 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
134743135186
/* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95,
134744
- /* 360 */ 95, 94, 94, 94, 93, 351, 325, 969, 227, 92,
134745
- /* 370 */ 89, 178, 373, 300, 99, 100, 90, 842, 842, 854,
134746
- /* 380 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 921,
135187
+ /* 360 */ 95, 94, 94, 94, 93, 351, 325, 968, 227, 92,
135188
+ /* 370 */ 89, 178, 373, 300, 99, 100, 90, 978, 978, 853,
135189
+ /* 380 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 920,
134747135190
/* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134748135191
/* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99,
134749
- /* 410 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
135192
+ /* 410 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
134750135193
/* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95,
134751
- /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 958,
134752
- /* 440 */ 958, 158, 25, 422, 99, 100, 90, 842, 842, 854,
134753
- /* 450 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 450,
135194
+ /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 957,
135195
+ /* 440 */ 957, 158, 25, 422, 99, 100, 90, 978, 978, 853,
135196
+ /* 450 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 450,
134754135197
/* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134755
- /* 470 */ 351, 443, 224, 224, 420, 958, 958, 962, 325, 52,
134756
- /* 480 */ 52, 959, 960, 176, 415, 78, 99, 100, 90, 842,
134757
- /* 490 */ 842, 854, 857, 846, 846, 97, 97, 98, 98, 98,
135198
+ /* 470 */ 351, 443, 224, 224, 420, 957, 957, 961, 325, 52,
135199
+ /* 480 */ 52, 958, 959, 176, 415, 78, 99, 100, 90, 978,
135200
+ /* 490 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98,
134758135201
/* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94,
134759
- /* 510 */ 94, 93, 351, 325, 428, 418, 298, 959, 960, 962,
134760
- /* 520 */ 81, 99, 88, 90, 842, 842, 854, 857, 846, 846,
135202
+ /* 510 */ 94, 93, 351, 325, 428, 418, 298, 958, 959, 961,
135203
+ /* 520 */ 81, 99, 88, 90, 978, 978, 853, 856, 845, 845,
134761135204
/* 530 */ 97, 97, 98, 98, 98, 98, 717, 96, 96, 96,
134762
- /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 843,
134763
- /* 550 */ 843, 855, 858, 996, 318, 343, 379, 100, 90, 842,
134764
- /* 560 */ 842, 854, 857, 846, 846, 97, 97, 98, 98, 98,
135205
+ /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 842,
135206
+ /* 550 */ 842, 854, 857, 996, 318, 343, 379, 100, 90, 978,
135207
+ /* 560 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98,
134765135208
/* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94,
134766135209
/* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340,
134767
- /* 590 */ 929, 52, 52, 90, 842, 842, 854, 857, 846, 846,
135210
+ /* 590 */ 928, 52, 52, 90, 978, 978, 853, 856, 845, 845,
134768135211
/* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96,
134769135212
/* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445,
134770
- /* 620 */ 847, 3, 1203, 361, 360, 378, 344, 813, 958, 958,
134771
- /* 630 */ 1300, 86, 445, 729, 3, 212, 169, 287, 405, 282,
135213
+ /* 620 */ 846, 3, 1202, 361, 360, 378, 344, 813, 957, 957,
135214
+ /* 630 */ 1299, 86, 445, 729, 3, 212, 169, 287, 405, 282,
134772135215
/* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245,
134773135216
/* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83,
134774135217
/* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246,
134775
- /* 670 */ 959, 960, 194, 455, 670, 402, 399, 398, 448, 243,
135218
+ /* 670 */ 958, 959, 194, 455, 670, 402, 399, 398, 448, 243,
134776135219
/* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224,
134777135220
/* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427,
134778135221
/* 700 */ 819, 415, 734, 713, 132, 52, 52, 832, 268, 452,
134779
- /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1271,
134780
- /* 720 */ 1271, 23, 958, 958, 86, 445, 397, 3, 228, 429,
134781
- /* 730 */ 895, 824, 824, 826, 827, 19, 203, 720, 52, 52,
135222
+ /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1270,
135223
+ /* 720 */ 1270, 23, 957, 957, 86, 445, 397, 3, 228, 429,
135224
+ /* 730 */ 894, 824, 824, 826, 827, 19, 203, 720, 52, 52,
134782135225
/* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229,
134783135226
/* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85,
134784
- /* 760 */ 352, 352, 120, 157, 959, 960, 58, 977, 409, 355,
135227
+ /* 760 */ 352, 352, 120, 157, 958, 959, 58, 976, 409, 355,
134785135228
/* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86,
134786135229
/* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96,
134787135230
/* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
134788
- /* 800 */ 832, 120, 452, 451, 813, 887, 819, 83, 84, 977,
134789
- /* 810 */ 813, 132, 410, 920, 85, 352, 352, 132, 407, 789,
134790
- /* 820 */ 958, 958, 92, 89, 178, 917, 448, 262, 370, 261,
134791
- /* 830 */ 82, 914, 80, 262, 370, 261, 776, 824, 824, 826,
134792
- /* 840 */ 827, 19, 934, 434, 96, 96, 96, 96, 95, 95,
134793
- /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 958,
134794
- /* 860 */ 958, 819, 959, 960, 120, 92, 89, 178, 945, 2,
134795
- /* 870 */ 918, 965, 268, 1, 976, 76, 445, 762, 3, 708,
134796
- /* 880 */ 901, 901, 387, 958, 958, 757, 919, 371, 740, 778,
135231
+ /* 800 */ 832, 120, 452, 451, 813, 886, 819, 83, 84, 976,
135232
+ /* 810 */ 813, 132, 410, 919, 85, 352, 352, 132, 407, 789,
135233
+ /* 820 */ 957, 957, 92, 89, 178, 916, 448, 262, 370, 261,
135234
+ /* 830 */ 82, 913, 80, 262, 370, 261, 776, 824, 824, 826,
135235
+ /* 840 */ 827, 19, 933, 434, 96, 96, 96, 96, 95, 95,
135236
+ /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 957,
135237
+ /* 860 */ 957, 819, 958, 959, 120, 92, 89, 178, 944, 2,
135238
+ /* 870 */ 917, 964, 268, 1, 975, 76, 445, 762, 3, 708,
135239
+ /* 880 */ 900, 900, 387, 957, 957, 757, 918, 371, 740, 778,
134797135240
/* 890 */ 756, 257, 824, 824, 826, 827, 19, 417, 741, 450,
134798
- /* 900 */ 24, 959, 960, 83, 84, 369, 958, 958, 177, 226,
134799
- /* 910 */ 85, 352, 352, 885, 315, 314, 313, 215, 311, 10,
134800
- /* 920 */ 10, 683, 448, 349, 348, 959, 960, 909, 777, 157,
134801
- /* 930 */ 120, 958, 958, 337, 776, 416, 711, 310, 450, 434,
134802
- /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 959, 960,
134803
- /* 950 */ 908, 832, 792, 452, 451, 9, 9, 819, 10, 10,
135241
+ /* 900 */ 24, 958, 959, 83, 84, 369, 957, 957, 177, 226,
135242
+ /* 910 */ 85, 352, 352, 884, 315, 314, 313, 215, 311, 10,
135243
+ /* 920 */ 10, 683, 448, 349, 348, 958, 959, 908, 777, 157,
135244
+ /* 930 */ 120, 957, 957, 337, 776, 416, 711, 310, 450, 434,
135245
+ /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 958, 959,
135246
+ /* 950 */ 907, 832, 792, 452, 451, 9, 9, 819, 10, 10,
134804135247
/* 960 */ 52, 52, 51, 51, 180, 716, 248, 10, 10, 171,
134805
- /* 970 */ 170, 167, 339, 959, 960, 247, 984, 702, 702, 450,
134806
- /* 980 */ 715, 233, 686, 982, 889, 983, 182, 914, 824, 824,
135248
+ /* 970 */ 170, 167, 339, 958, 959, 247, 984, 702, 702, 450,
135249
+ /* 980 */ 715, 233, 686, 982, 888, 983, 182, 913, 824, 824,
134807135250
/* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10,
134808
- /* 1000 */ 10, 889, 891, 749, 958, 958, 917, 268, 985, 198,
135251
+ /* 1000 */ 10, 888, 890, 749, 957, 957, 916, 268, 985, 198,
134809135252
/* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825,
134810135253
/* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91,
134811135254
/* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134812
- /* 1040 */ 351, 157, 810, 371, 382, 359, 959, 960, 358, 268,
134813
- /* 1050 */ 450, 918, 368, 324, 824, 824, 826, 450, 709, 450,
134814
- /* 1060 */ 264, 380, 889, 450, 877, 746, 253, 919, 255, 433,
135255
+ /* 1040 */ 351, 157, 810, 371, 382, 359, 958, 959, 358, 268,
135256
+ /* 1050 */ 450, 917, 368, 324, 824, 824, 826, 450, 709, 450,
135257
+ /* 1060 */ 264, 380, 888, 450, 876, 746, 253, 918, 255, 433,
134815135258
/* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12,
134816135259
/* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162,
134817135260
/* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450,
134818
- /* 1100 */ 709, 1210, 450, 132, 450, 39, 39, 450, 40, 40,
135261
+ /* 1100 */ 709, 1209, 450, 132, 450, 39, 39, 450, 40, 40,
134819135262
/* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28,
134820135263
/* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450,
134821135264
/* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767,
134822135265
/* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47,
134823135266
/* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172,
134824135267
/* 1160 */ 49, 49, 450, 50, 50, 34, 34, 274, 122, 122,
134825
- /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 898, 56, 56,
134826
- /* 1180 */ 450, 897, 35, 35, 450, 267, 450, 817, 450, 817,
135268
+ /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 897, 56, 56,
135269
+ /* 1180 */ 450, 896, 35, 35, 450, 267, 450, 817, 450, 817,
134827135270
/* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817,
134828135271
/* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119,
134829135272
/* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111,
134830
- /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 912,
135273
+ /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 911,
134831135274
/* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331,
134832
- /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 937, 197,
135275
+ /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 936, 197,
134833135276
/* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436,
134834
- /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 933,
135277
+ /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 932,
134835135278
/* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202,
134836
- /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 884,
135279
+ /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 883,
134837135280
/* 1290 */ 120, 120, 120, 120, 120, 754, 278, 828, 77, 74,
134838
- /* 1300 */ 726, 727, 785, 783, 880, 202, 999, 208, 894, 893,
134839
- /* 1310 */ 894, 893, 694, 816, 763, 116, 774, 1290, 431, 432,
135281
+ /* 1300 */ 726, 727, 785, 783, 879, 202, 999, 208, 893, 892,
135282
+ /* 1310 */ 893, 892, 694, 816, 763, 116, 774, 1289, 431, 432,
134840135283
/* 1320 */ 302, 999, 390, 303, 823, 697, 691, 680, 159, 289,
134841
- /* 1330 */ 679, 884, 681, 952, 291, 218, 293, 7, 316, 828,
134842
- /* 1340 */ 173, 805, 259, 364, 252, 911, 376, 713, 295, 435,
134843
- /* 1350 */ 308, 168, 955, 993, 135, 400, 990, 284, 882, 881,
134844
- /* 1360 */ 205, 928, 926, 59, 333, 62, 144, 156, 130, 72,
135284
+ /* 1330 */ 679, 883, 681, 951, 291, 218, 293, 7, 316, 828,
135285
+ /* 1340 */ 173, 805, 259, 364, 252, 910, 376, 713, 295, 435,
135286
+ /* 1350 */ 308, 168, 954, 993, 135, 400, 990, 284, 881, 880,
135287
+ /* 1360 */ 205, 927, 925, 59, 333, 62, 144, 156, 130, 72,
134845135288
/* 1370 */ 802, 366, 367, 393, 137, 185, 189, 160, 139, 383,
134846
- /* 1380 */ 67, 896, 140, 141, 142, 148, 389, 812, 775, 266,
134847
- /* 1390 */ 219, 190, 154, 391, 913, 876, 271, 406, 191, 322,
135289
+ /* 1380 */ 67, 895, 140, 141, 142, 148, 389, 812, 775, 266,
135290
+ /* 1390 */ 219, 190, 154, 391, 912, 875, 271, 406, 191, 322,
134848135291
/* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421,
134849135292
/* 1410 */ 705, 71, 323, 6, 204, 771, 288, 79, 297, 346,
134850
- /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 967, 239,
134851
- /* 1430 */ 769, 102, 862, 438, 426, 240, 424, 442, 73, 213,
134852
- /* 1440 */ 688, 238, 22, 453, 953, 214, 217, 216, 454, 677,
135293
+ /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 966, 239,
135294
+ /* 1430 */ 769, 102, 861, 438, 426, 240, 424, 442, 73, 213,
135295
+ /* 1440 */ 688, 238, 22, 453, 952, 214, 217, 216, 454, 677,
134853135296
/* 1450 */ 676, 671, 753, 125, 115, 235, 126, 669, 353, 166,
134854
- /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 892,
134855
- /* 1470 */ 327, 890, 811, 328, 134, 128, 136, 138, 743, 258,
134856
- /* 1480 */ 907, 184, 143, 129, 910, 186, 63, 64, 145, 187,
134857
- /* 1490 */ 906, 65, 8, 66, 13, 188, 202, 899, 265, 149,
135297
+ /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 891,
135298
+ /* 1470 */ 327, 889, 811, 328, 134, 128, 136, 138, 743, 258,
135299
+ /* 1480 */ 906, 184, 143, 129, 909, 186, 63, 64, 145, 187,
135300
+ /* 1490 */ 905, 65, 8, 66, 13, 188, 202, 898, 265, 149,
134858135301
/* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396,
134859135302
/* 1510 */ 151, 401, 68, 14, 15, 722, 69, 236, 831, 131,
134860
- /* 1520 */ 830, 860, 70, 751, 16, 414, 755, 4, 174, 220,
134861
- /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 875,
134862
- /* 1540 */ 861, 859, 916, 864, 915, 207, 206, 942, 163, 437,
134863
- /* 1550 */ 948, 943, 164, 209, 1002, 441, 863, 165, 210, 829,
134864
- /* 1560 */ 695, 87, 312, 211, 1292, 1291, 309,
135303
+ /* 1520 */ 830, 859, 70, 751, 16, 414, 755, 4, 174, 220,
135304
+ /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 874,
135305
+ /* 1540 */ 860, 858, 915, 863, 914, 207, 206, 941, 163, 437,
135306
+ /* 1550 */ 947, 942, 164, 209, 1002, 441, 862, 165, 210, 829,
135307
+ /* 1560 */ 695, 87, 312, 211, 1291, 1290, 309,
134865135308
};
134866135309
static const YYCODETYPE yy_lookahead[] = {
134867135310
/* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
134868135311
/* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
134869135312
/* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
@@ -135112,55 +135555,55 @@
135112135555
/* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278,
135113135556
/* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228,
135114135557
/* 320 */ 1288, 1291, 1276, 1277, 1295,
135115135558
};
135116135559
static const YYACTIONTYPE yy_default[] = {
135117
- /* 0 */ 1281, 1271, 1271, 1271, 1203, 1203, 1203, 1203, 1271, 1096,
135118
- /* 10 */ 1125, 1125, 1255, 1332, 1332, 1332, 1332, 1332, 1332, 1202,
135119
- /* 20 */ 1332, 1332, 1332, 1332, 1271, 1100, 1131, 1332, 1332, 1332,
135120
- /* 30 */ 1332, 1204, 1205, 1332, 1332, 1332, 1254, 1256, 1141, 1140,
135121
- /* 40 */ 1139, 1138, 1237, 1112, 1136, 1129, 1133, 1204, 1198, 1199,
135122
- /* 50 */ 1197, 1201, 1205, 1332, 1132, 1167, 1182, 1166, 1332, 1332,
135560
+ /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096,
135561
+ /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201,
135562
+ /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332,
135563
+ /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140,
135564
+ /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198,
135565
+ /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332,
135123135566
/* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135124135567
/* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135125135568
/* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135126135569
/* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135127
- /* 100 */ 1332, 1332, 1332, 1332, 1176, 1181, 1188, 1180, 1177, 1169,
135570
+ /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169,
135128135571
/* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
135129
- /* 120 */ 1332, 1173, 1185, 1184, 1183, 1262, 1289, 1288, 1332, 1332,
135572
+ /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332,
135130135573
/* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135131135574
/* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135132
- /* 150 */ 1332, 1332, 1332, 1332, 1332, 1281, 1271, 1025, 1025, 1332,
135133
- /* 160 */ 1271, 1271, 1271, 1271, 1271, 1271, 1267, 1100, 1091, 1332,
135575
+ /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332,
135576
+ /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332,
135134135577
/* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135135
- /* 180 */ 1259, 1257, 1332, 1218, 1332, 1332, 1332, 1332, 1332, 1332,
135578
+ /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332,
135136135579
/* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135137135580
/* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
135138
- /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1283, 1332, 1232,
135581
+ /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231,
135139135582
/* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
135140
- /* 230 */ 1321, 1135, 1321, 1042, 1303, 1039, 1125, 1114, 1200, 1125,
135583
+ /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125,
135141135584
/* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
135142135585
/* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
135143
- /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1236, 1318, 1105, 1105,
135144
- /* 270 */ 1016, 1211, 1105, 1016, 1105, 1016, 1211, 1068, 1068, 1068,
135145
- /* 280 */ 1057, 1211, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
135146
- /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1206, 1105, 1332,
135147
- /* 300 */ 1211, 1215, 1215, 1211, 1130, 1119, 1128, 1126, 1135, 1022,
135148
- /* 310 */ 1060, 1286, 1286, 1282, 1282, 1282, 1282, 1329, 1329, 1267,
135149
- /* 320 */ 1298, 1298, 1044, 1044, 1298, 1332, 1332, 1332, 1332, 1332,
135150
- /* 330 */ 1332, 1293, 1332, 1220, 1332, 1332, 1332, 1332, 1332, 1332,
135586
+ /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105,
135587
+ /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068,
135588
+ /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
135589
+ /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332,
135590
+ /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022,
135591
+ /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266,
135592
+ /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332,
135593
+ /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332,
135151135594
/* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135152
- /* 350 */ 1332, 1332, 1152, 1332, 1000, 1264, 1332, 1332, 1263, 1332,
135595
+ /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332,
135153135596
/* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135154135597
/* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
135155
- /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1235, 1234, 1332, 1332,
135598
+ /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332,
135156135599
/* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135157135600
/* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135158
- /* 410 */ 1332, 1082, 1332, 1332, 1332, 1307, 1332, 1332, 1332, 1332,
135601
+ /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332,
135159135602
/* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
135160
- /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1273,
135161
- /* 440 */ 1332, 1332, 1332, 1272, 1332, 1332, 1332, 1332, 1332, 1154,
135603
+ /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272,
135604
+ /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154,
135162135605
/* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
135163135606
};
135164135607
/********** End of lemon-generated parsing tables *****************************/
135165135608
135166135609
/* The next table maps tokens (terminal symbols) into fallback tokens.
@@ -135602,147 +136045,147 @@
135602136045
/* 169 */ "expr ::= expr EQ|NE expr",
135603136046
/* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
135604136047
/* 171 */ "expr ::= expr PLUS|MINUS expr",
135605136048
/* 172 */ "expr ::= expr STAR|SLASH|REM expr",
135606136049
/* 173 */ "expr ::= expr CONCAT expr",
135607
- /* 174 */ "likeop ::= LIKE_KW|MATCH",
135608
- /* 175 */ "likeop ::= NOT LIKE_KW|MATCH",
135609
- /* 176 */ "expr ::= expr likeop expr",
135610
- /* 177 */ "expr ::= expr likeop expr ESCAPE expr",
135611
- /* 178 */ "expr ::= expr ISNULL|NOTNULL",
135612
- /* 179 */ "expr ::= expr NOT NULL",
135613
- /* 180 */ "expr ::= expr IS expr",
135614
- /* 181 */ "expr ::= expr IS NOT expr",
135615
- /* 182 */ "expr ::= NOT expr",
135616
- /* 183 */ "expr ::= BITNOT expr",
135617
- /* 184 */ "expr ::= MINUS expr",
135618
- /* 185 */ "expr ::= PLUS expr",
135619
- /* 186 */ "between_op ::= BETWEEN",
135620
- /* 187 */ "between_op ::= NOT BETWEEN",
135621
- /* 188 */ "expr ::= expr between_op expr AND expr",
135622
- /* 189 */ "in_op ::= IN",
135623
- /* 190 */ "in_op ::= NOT IN",
135624
- /* 191 */ "expr ::= expr in_op LP exprlist RP",
135625
- /* 192 */ "expr ::= LP select RP",
135626
- /* 193 */ "expr ::= expr in_op LP select RP",
135627
- /* 194 */ "expr ::= expr in_op nm dbnm paren_exprlist",
135628
- /* 195 */ "expr ::= EXISTS LP select RP",
135629
- /* 196 */ "expr ::= CASE case_operand case_exprlist case_else END",
135630
- /* 197 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
135631
- /* 198 */ "case_exprlist ::= WHEN expr THEN expr",
135632
- /* 199 */ "case_else ::= ELSE expr",
135633
- /* 200 */ "case_else ::=",
135634
- /* 201 */ "case_operand ::= expr",
135635
- /* 202 */ "case_operand ::=",
135636
- /* 203 */ "exprlist ::=",
135637
- /* 204 */ "nexprlist ::= nexprlist COMMA expr",
135638
- /* 205 */ "nexprlist ::= expr",
135639
- /* 206 */ "paren_exprlist ::=",
135640
- /* 207 */ "paren_exprlist ::= LP exprlist RP",
135641
- /* 208 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
135642
- /* 209 */ "uniqueflag ::= UNIQUE",
135643
- /* 210 */ "uniqueflag ::=",
135644
- /* 211 */ "eidlist_opt ::=",
135645
- /* 212 */ "eidlist_opt ::= LP eidlist RP",
135646
- /* 213 */ "eidlist ::= eidlist COMMA nm collate sortorder",
135647
- /* 214 */ "eidlist ::= nm collate sortorder",
135648
- /* 215 */ "collate ::=",
135649
- /* 216 */ "collate ::= COLLATE ID|STRING",
135650
- /* 217 */ "cmd ::= DROP INDEX ifexists fullname",
135651
- /* 218 */ "cmd ::= VACUUM",
135652
- /* 219 */ "cmd ::= VACUUM nm",
135653
- /* 220 */ "cmd ::= PRAGMA nm dbnm",
135654
- /* 221 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
135655
- /* 222 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
135656
- /* 223 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
135657
- /* 224 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
135658
- /* 225 */ "plus_num ::= PLUS INTEGER|FLOAT",
135659
- /* 226 */ "minus_num ::= MINUS INTEGER|FLOAT",
135660
- /* 227 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
135661
- /* 228 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
135662
- /* 229 */ "trigger_time ::= BEFORE",
135663
- /* 230 */ "trigger_time ::= AFTER",
135664
- /* 231 */ "trigger_time ::= INSTEAD OF",
135665
- /* 232 */ "trigger_time ::=",
135666
- /* 233 */ "trigger_event ::= DELETE|INSERT",
135667
- /* 234 */ "trigger_event ::= UPDATE",
135668
- /* 235 */ "trigger_event ::= UPDATE OF idlist",
135669
- /* 236 */ "when_clause ::=",
135670
- /* 237 */ "when_clause ::= WHEN expr",
135671
- /* 238 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
135672
- /* 239 */ "trigger_cmd_list ::= trigger_cmd SEMI",
135673
- /* 240 */ "trnm ::= nm DOT nm",
135674
- /* 241 */ "tridxby ::= INDEXED BY nm",
135675
- /* 242 */ "tridxby ::= NOT INDEXED",
135676
- /* 243 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
135677
- /* 244 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
135678
- /* 245 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
135679
- /* 246 */ "trigger_cmd ::= select",
135680
- /* 247 */ "expr ::= RAISE LP IGNORE RP",
135681
- /* 248 */ "expr ::= RAISE LP raisetype COMMA nm RP",
135682
- /* 249 */ "raisetype ::= ROLLBACK",
135683
- /* 250 */ "raisetype ::= ABORT",
135684
- /* 251 */ "raisetype ::= FAIL",
135685
- /* 252 */ "cmd ::= DROP TRIGGER ifexists fullname",
135686
- /* 253 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
135687
- /* 254 */ "cmd ::= DETACH database_kw_opt expr",
135688
- /* 255 */ "key_opt ::=",
135689
- /* 256 */ "key_opt ::= KEY expr",
135690
- /* 257 */ "cmd ::= REINDEX",
135691
- /* 258 */ "cmd ::= REINDEX nm dbnm",
135692
- /* 259 */ "cmd ::= ANALYZE",
135693
- /* 260 */ "cmd ::= ANALYZE nm dbnm",
135694
- /* 261 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
135695
- /* 262 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
135696
- /* 263 */ "add_column_fullname ::= fullname",
135697
- /* 264 */ "cmd ::= create_vtab",
135698
- /* 265 */ "cmd ::= create_vtab LP vtabarglist RP",
135699
- /* 266 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
135700
- /* 267 */ "vtabarg ::=",
135701
- /* 268 */ "vtabargtoken ::= ANY",
135702
- /* 269 */ "vtabargtoken ::= lp anylist RP",
135703
- /* 270 */ "lp ::= LP",
135704
- /* 271 */ "with ::=",
135705
- /* 272 */ "with ::= WITH wqlist",
135706
- /* 273 */ "with ::= WITH RECURSIVE wqlist",
135707
- /* 274 */ "wqlist ::= nm eidlist_opt AS LP select RP",
135708
- /* 275 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
135709
- /* 276 */ "input ::= cmdlist",
135710
- /* 277 */ "cmdlist ::= cmdlist ecmd",
135711
- /* 278 */ "cmdlist ::= ecmd",
135712
- /* 279 */ "ecmd ::= SEMI",
135713
- /* 280 */ "ecmd ::= explain cmdx SEMI",
135714
- /* 281 */ "explain ::=",
135715
- /* 282 */ "trans_opt ::=",
135716
- /* 283 */ "trans_opt ::= TRANSACTION",
135717
- /* 284 */ "trans_opt ::= TRANSACTION nm",
135718
- /* 285 */ "savepoint_opt ::= SAVEPOINT",
135719
- /* 286 */ "savepoint_opt ::=",
135720
- /* 287 */ "cmd ::= create_table create_table_args",
135721
- /* 288 */ "columnlist ::= columnlist COMMA columnname carglist",
135722
- /* 289 */ "columnlist ::= columnname carglist",
135723
- /* 290 */ "nm ::= ID|INDEXED",
135724
- /* 291 */ "nm ::= STRING",
135725
- /* 292 */ "nm ::= JOIN_KW",
135726
- /* 293 */ "typetoken ::= typename",
135727
- /* 294 */ "typename ::= ID|STRING",
135728
- /* 295 */ "signed ::= plus_num",
135729
- /* 296 */ "signed ::= minus_num",
135730
- /* 297 */ "carglist ::= carglist ccons",
135731
- /* 298 */ "carglist ::=",
135732
- /* 299 */ "ccons ::= NULL onconf",
135733
- /* 300 */ "conslist_opt ::= COMMA conslist",
135734
- /* 301 */ "conslist ::= conslist tconscomma tcons",
135735
- /* 302 */ "conslist ::= tcons",
135736
- /* 303 */ "tconscomma ::=",
135737
- /* 304 */ "defer_subclause_opt ::= defer_subclause",
135738
- /* 305 */ "resolvetype ::= raisetype",
135739
- /* 306 */ "selectnowith ::= oneselect",
135740
- /* 307 */ "oneselect ::= values",
135741
- /* 308 */ "sclp ::= selcollist COMMA",
135742
- /* 309 */ "as ::= ID|STRING",
135743
- /* 310 */ "expr ::= term",
136050
+ /* 174 */ "likeop ::= NOT LIKE_KW|MATCH",
136051
+ /* 175 */ "expr ::= expr likeop expr",
136052
+ /* 176 */ "expr ::= expr likeop expr ESCAPE expr",
136053
+ /* 177 */ "expr ::= expr ISNULL|NOTNULL",
136054
+ /* 178 */ "expr ::= expr NOT NULL",
136055
+ /* 179 */ "expr ::= expr IS expr",
136056
+ /* 180 */ "expr ::= expr IS NOT expr",
136057
+ /* 181 */ "expr ::= NOT expr",
136058
+ /* 182 */ "expr ::= BITNOT expr",
136059
+ /* 183 */ "expr ::= MINUS expr",
136060
+ /* 184 */ "expr ::= PLUS expr",
136061
+ /* 185 */ "between_op ::= BETWEEN",
136062
+ /* 186 */ "between_op ::= NOT BETWEEN",
136063
+ /* 187 */ "expr ::= expr between_op expr AND expr",
136064
+ /* 188 */ "in_op ::= IN",
136065
+ /* 189 */ "in_op ::= NOT IN",
136066
+ /* 190 */ "expr ::= expr in_op LP exprlist RP",
136067
+ /* 191 */ "expr ::= LP select RP",
136068
+ /* 192 */ "expr ::= expr in_op LP select RP",
136069
+ /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist",
136070
+ /* 194 */ "expr ::= EXISTS LP select RP",
136071
+ /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END",
136072
+ /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
136073
+ /* 197 */ "case_exprlist ::= WHEN expr THEN expr",
136074
+ /* 198 */ "case_else ::= ELSE expr",
136075
+ /* 199 */ "case_else ::=",
136076
+ /* 200 */ "case_operand ::= expr",
136077
+ /* 201 */ "case_operand ::=",
136078
+ /* 202 */ "exprlist ::=",
136079
+ /* 203 */ "nexprlist ::= nexprlist COMMA expr",
136080
+ /* 204 */ "nexprlist ::= expr",
136081
+ /* 205 */ "paren_exprlist ::=",
136082
+ /* 206 */ "paren_exprlist ::= LP exprlist RP",
136083
+ /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
136084
+ /* 208 */ "uniqueflag ::= UNIQUE",
136085
+ /* 209 */ "uniqueflag ::=",
136086
+ /* 210 */ "eidlist_opt ::=",
136087
+ /* 211 */ "eidlist_opt ::= LP eidlist RP",
136088
+ /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder",
136089
+ /* 213 */ "eidlist ::= nm collate sortorder",
136090
+ /* 214 */ "collate ::=",
136091
+ /* 215 */ "collate ::= COLLATE ID|STRING",
136092
+ /* 216 */ "cmd ::= DROP INDEX ifexists fullname",
136093
+ /* 217 */ "cmd ::= VACUUM",
136094
+ /* 218 */ "cmd ::= VACUUM nm",
136095
+ /* 219 */ "cmd ::= PRAGMA nm dbnm",
136096
+ /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
136097
+ /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
136098
+ /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
136099
+ /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
136100
+ /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
136101
+ /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
136102
+ /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
136103
+ /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
136104
+ /* 228 */ "trigger_time ::= BEFORE",
136105
+ /* 229 */ "trigger_time ::= AFTER",
136106
+ /* 230 */ "trigger_time ::= INSTEAD OF",
136107
+ /* 231 */ "trigger_time ::=",
136108
+ /* 232 */ "trigger_event ::= DELETE|INSERT",
136109
+ /* 233 */ "trigger_event ::= UPDATE",
136110
+ /* 234 */ "trigger_event ::= UPDATE OF idlist",
136111
+ /* 235 */ "when_clause ::=",
136112
+ /* 236 */ "when_clause ::= WHEN expr",
136113
+ /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
136114
+ /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
136115
+ /* 239 */ "trnm ::= nm DOT nm",
136116
+ /* 240 */ "tridxby ::= INDEXED BY nm",
136117
+ /* 241 */ "tridxby ::= NOT INDEXED",
136118
+ /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
136119
+ /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
136120
+ /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
136121
+ /* 245 */ "trigger_cmd ::= select",
136122
+ /* 246 */ "expr ::= RAISE LP IGNORE RP",
136123
+ /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
136124
+ /* 248 */ "raisetype ::= ROLLBACK",
136125
+ /* 249 */ "raisetype ::= ABORT",
136126
+ /* 250 */ "raisetype ::= FAIL",
136127
+ /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
136128
+ /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
136129
+ /* 253 */ "cmd ::= DETACH database_kw_opt expr",
136130
+ /* 254 */ "key_opt ::=",
136131
+ /* 255 */ "key_opt ::= KEY expr",
136132
+ /* 256 */ "cmd ::= REINDEX",
136133
+ /* 257 */ "cmd ::= REINDEX nm dbnm",
136134
+ /* 258 */ "cmd ::= ANALYZE",
136135
+ /* 259 */ "cmd ::= ANALYZE nm dbnm",
136136
+ /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
136137
+ /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
136138
+ /* 262 */ "add_column_fullname ::= fullname",
136139
+ /* 263 */ "cmd ::= create_vtab",
136140
+ /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
136141
+ /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
136142
+ /* 266 */ "vtabarg ::=",
136143
+ /* 267 */ "vtabargtoken ::= ANY",
136144
+ /* 268 */ "vtabargtoken ::= lp anylist RP",
136145
+ /* 269 */ "lp ::= LP",
136146
+ /* 270 */ "with ::=",
136147
+ /* 271 */ "with ::= WITH wqlist",
136148
+ /* 272 */ "with ::= WITH RECURSIVE wqlist",
136149
+ /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
136150
+ /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
136151
+ /* 275 */ "input ::= cmdlist",
136152
+ /* 276 */ "cmdlist ::= cmdlist ecmd",
136153
+ /* 277 */ "cmdlist ::= ecmd",
136154
+ /* 278 */ "ecmd ::= SEMI",
136155
+ /* 279 */ "ecmd ::= explain cmdx SEMI",
136156
+ /* 280 */ "explain ::=",
136157
+ /* 281 */ "trans_opt ::=",
136158
+ /* 282 */ "trans_opt ::= TRANSACTION",
136159
+ /* 283 */ "trans_opt ::= TRANSACTION nm",
136160
+ /* 284 */ "savepoint_opt ::= SAVEPOINT",
136161
+ /* 285 */ "savepoint_opt ::=",
136162
+ /* 286 */ "cmd ::= create_table create_table_args",
136163
+ /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
136164
+ /* 288 */ "columnlist ::= columnname carglist",
136165
+ /* 289 */ "nm ::= ID|INDEXED",
136166
+ /* 290 */ "nm ::= STRING",
136167
+ /* 291 */ "nm ::= JOIN_KW",
136168
+ /* 292 */ "typetoken ::= typename",
136169
+ /* 293 */ "typename ::= ID|STRING",
136170
+ /* 294 */ "signed ::= plus_num",
136171
+ /* 295 */ "signed ::= minus_num",
136172
+ /* 296 */ "carglist ::= carglist ccons",
136173
+ /* 297 */ "carglist ::=",
136174
+ /* 298 */ "ccons ::= NULL onconf",
136175
+ /* 299 */ "conslist_opt ::= COMMA conslist",
136176
+ /* 300 */ "conslist ::= conslist tconscomma tcons",
136177
+ /* 301 */ "conslist ::= tcons",
136178
+ /* 302 */ "tconscomma ::=",
136179
+ /* 303 */ "defer_subclause_opt ::= defer_subclause",
136180
+ /* 304 */ "resolvetype ::= raisetype",
136181
+ /* 305 */ "selectnowith ::= oneselect",
136182
+ /* 306 */ "oneselect ::= values",
136183
+ /* 307 */ "sclp ::= selcollist COMMA",
136184
+ /* 308 */ "as ::= ID|STRING",
136185
+ /* 309 */ "expr ::= term",
136186
+ /* 310 */ "likeop ::= LIKE_KW|MATCH",
135744136187
/* 311 */ "exprlist ::= nexprlist",
135745136188
/* 312 */ "nmnum ::= plus_num",
135746136189
/* 313 */ "nmnum ::= nm",
135747136190
/* 314 */ "nmnum ::= ON",
135748136191
/* 315 */ "nmnum ::= DELETE",
@@ -136375,11 +136818,10 @@
136375136818
{ 173, 3 },
136376136819
{ 173, 3 },
136377136820
{ 173, 3 },
136378136821
{ 173, 3 },
136379136822
{ 173, 3 },
136380
- { 221, 1 },
136381136823
{ 221, 2 },
136382136824
{ 173, 3 },
136383136825
{ 173, 5 },
136384136826
{ 173, 2 },
136385136827
{ 173, 3 },
@@ -136512,10 +136954,11 @@
136512136954
{ 194, 1 },
136513136955
{ 195, 1 },
136514136956
{ 209, 2 },
136515136957
{ 210, 1 },
136516136958
{ 173, 1 },
136959
+ { 221, 1 },
136517136960
{ 208, 1 },
136518136961
{ 230, 1 },
136519136962
{ 230, 1 },
136520136963
{ 230, 1 },
136521136964
{ 230, 1 },
@@ -136654,11 +137097,11 @@
136654137097
case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
136655137098
case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
136656137099
case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
136657137100
case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
136658137101
case 90: /* distinct ::= */ yytestcase(yyruleno==90);
136659
- case 215: /* collate ::= */ yytestcase(yyruleno==215);
137102
+ case 214: /* collate ::= */ yytestcase(yyruleno==214);
136660137103
{yymsp[1].minor.yy194 = 0;}
136661137104
break;
136662137105
case 17: /* ifnotexists ::= IF NOT EXISTS */
136663137106
{yymsp[-2].minor.yy194 = 1;}
136664137107
break;
@@ -136798,13 +137241,13 @@
136798137241
case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
136799137242
{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
136800137243
break;
136801137244
case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
136802137245
case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
136803
- case 187: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==187);
136804
- case 190: /* in_op ::= NOT IN */ yytestcase(yyruleno==190);
136805
- case 216: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==216);
137246
+ case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186);
137247
+ case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189);
137248
+ case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215);
136806137249
{yymsp[-1].minor.yy194 = 1;}
136807137250
break;
136808137251
case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
136809137252
{yymsp[-1].minor.yy194 = 0;}
136810137253
break;
@@ -136964,13 +137407,13 @@
136964137407
{yymsp[0].minor.yy194 = SF_All;}
136965137408
break;
136966137409
case 91: /* sclp ::= */
136967137410
case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
136968137411
case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
136969
- case 203: /* exprlist ::= */ yytestcase(yyruleno==203);
136970
- case 206: /* paren_exprlist ::= */ yytestcase(yyruleno==206);
136971
- case 211: /* eidlist_opt ::= */ yytestcase(yyruleno==211);
137412
+ case 202: /* exprlist ::= */ yytestcase(yyruleno==202);
137413
+ case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205);
137414
+ case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210);
136972137415
{yymsp[1].minor.yy148 = 0;}
136973137416
break;
136974137417
case 92: /* selcollist ::= sclp expr as */
136975137418
{
136976137419
yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
@@ -136992,12 +137435,12 @@
136992137435
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
136993137436
}
136994137437
break;
136995137438
case 95: /* as ::= AS nm */
136996137439
case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
136997
- case 225: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
136998
- case 226: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==226);
137440
+ case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
137441
+ case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
136999137442
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
137000137443
break;
137001137444
case 97: /* from ::= */
137002137445
{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
137003137446
break;
@@ -137076,18 +137519,18 @@
137076137519
{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
137077137520
break;
137078137521
case 112: /* on_opt ::= ON expr */
137079137522
case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
137080137523
case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
137081
- case 199: /* case_else ::= ELSE expr */ yytestcase(yyruleno==199);
137524
+ case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198);
137082137525
{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
137083137526
break;
137084137527
case 113: /* on_opt ::= */
137085137528
case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
137086137529
case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
137087
- case 200: /* case_else ::= */ yytestcase(yyruleno==200);
137088
- case 202: /* case_operand ::= */ yytestcase(yyruleno==202);
137530
+ case 199: /* case_else ::= */ yytestcase(yyruleno==199);
137531
+ case 201: /* case_operand ::= */ yytestcase(yyruleno==201);
137089137532
{yymsp[1].minor.yy72 = 0;}
137090137533
break;
137091137534
case 115: /* indexed_opt ::= INDEXED BY nm */
137092137535
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
137093137536
break;
@@ -137320,17 +137763,14 @@
137320137763
case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171);
137321137764
case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172);
137322137765
case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173);
137323137766
{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
137324137767
break;
137325
- case 174: /* likeop ::= LIKE_KW|MATCH */
137326
-{yymsp[0].minor.yy0=yymsp[0].minor.yy0;/*A-overwrites-X*/}
137327
- break;
137328
- case 175: /* likeop ::= NOT LIKE_KW|MATCH */
137768
+ case 174: /* likeop ::= NOT LIKE_KW|MATCH */
137329137769
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
137330137770
break;
137331
- case 176: /* expr ::= expr likeop expr */
137771
+ case 175: /* expr ::= expr likeop expr */
137332137772
{
137333137773
ExprList *pList;
137334137774
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
137335137775
yymsp[-1].minor.yy0.n &= 0x7fffffff;
137336137776
pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
@@ -137339,11 +137779,11 @@
137339137779
exprNot(pParse, bNot, &yymsp[-2].minor.yy190);
137340137780
yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137341137781
if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
137342137782
}
137343137783
break;
137344
- case 177: /* expr ::= expr likeop expr ESCAPE expr */
137784
+ case 176: /* expr ::= expr likeop expr ESCAPE expr */
137345137785
{
137346137786
ExprList *pList;
137347137787
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
137348137788
yymsp[-3].minor.yy0.n &= 0x7fffffff;
137349137789
pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
@@ -137353,43 +137793,43 @@
137353137793
exprNot(pParse, bNot, &yymsp[-4].minor.yy190);
137354137794
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137355137795
if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
137356137796
}
137357137797
break;
137358
- case 178: /* expr ::= expr ISNULL|NOTNULL */
137798
+ case 177: /* expr ::= expr ISNULL|NOTNULL */
137359137799
{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
137360137800
break;
137361
- case 179: /* expr ::= expr NOT NULL */
137801
+ case 178: /* expr ::= expr NOT NULL */
137362137802
{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
137363137803
break;
137364
- case 180: /* expr ::= expr IS expr */
137804
+ case 179: /* expr ::= expr IS expr */
137365137805
{
137366137806
spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
137367137807
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
137368137808
}
137369137809
break;
137370
- case 181: /* expr ::= expr IS NOT expr */
137810
+ case 180: /* expr ::= expr IS NOT expr */
137371137811
{
137372137812
spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
137373137813
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
137374137814
}
137375137815
break;
137376
- case 182: /* expr ::= NOT expr */
137377
- case 183: /* expr ::= BITNOT expr */ yytestcase(yyruleno==183);
137816
+ case 181: /* expr ::= NOT expr */
137817
+ case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182);
137378137818
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137379137819
break;
137380
- case 184: /* expr ::= MINUS expr */
137820
+ case 183: /* expr ::= MINUS expr */
137381137821
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137382137822
break;
137383
- case 185: /* expr ::= PLUS expr */
137823
+ case 184: /* expr ::= PLUS expr */
137384137824
{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137385137825
break;
137386
- case 186: /* between_op ::= BETWEEN */
137387
- case 189: /* in_op ::= IN */ yytestcase(yyruleno==189);
137826
+ case 185: /* between_op ::= BETWEEN */
137827
+ case 188: /* in_op ::= IN */ yytestcase(yyruleno==188);
137388137828
{yymsp[0].minor.yy194 = 0;}
137389137829
break;
137390
- case 188: /* expr ::= expr between_op expr AND expr */
137830
+ case 187: /* expr ::= expr between_op expr AND expr */
137391137831
{
137392137832
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137393137833
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
137394137834
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
137395137835
if( yymsp[-4].minor.yy190.pExpr ){
@@ -137399,11 +137839,11 @@
137399137839
}
137400137840
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137401137841
yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137402137842
}
137403137843
break;
137404
- case 191: /* expr ::= expr in_op LP exprlist RP */
137844
+ case 190: /* expr ::= expr in_op LP exprlist RP */
137405137845
{
137406137846
if( yymsp[-1].minor.yy148==0 ){
137407137847
/* Expressions of the form
137408137848
**
137409137849
** expr1 IN ()
@@ -137452,26 +137892,26 @@
137452137892
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137453137893
}
137454137894
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
137455137895
}
137456137896
break;
137457
- case 192: /* expr ::= LP select RP */
137897
+ case 191: /* expr ::= LP select RP */
137458137898
{
137459137899
spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
137460137900
yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
137461137901
sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137462137902
}
137463137903
break;
137464
- case 193: /* expr ::= expr in_op LP select RP */
137904
+ case 192: /* expr ::= expr in_op LP select RP */
137465137905
{
137466137906
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
137467137907
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137468137908
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137469137909
yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
137470137910
}
137471137911
break;
137472
- case 194: /* expr ::= expr in_op nm dbnm paren_exprlist */
137912
+ case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */
137473137913
{
137474137914
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
137475137915
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
137476137916
if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
137477137917
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
@@ -137478,19 +137918,19 @@
137478137918
sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
137479137919
exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137480137920
yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
137481137921
}
137482137922
break;
137483
- case 195: /* expr ::= EXISTS LP select RP */
137923
+ case 194: /* expr ::= EXISTS LP select RP */
137484137924
{
137485137925
Expr *p;
137486137926
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
137487137927
p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
137488137928
sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
137489137929
}
137490137930
break;
137491
- case 196: /* expr ::= CASE case_operand case_exprlist case_else END */
137931
+ case 195: /* expr ::= CASE case_operand case_exprlist case_else END */
137492137932
{
137493137933
spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
137494137934
yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
137495137935
if( yymsp[-4].minor.yy190.pExpr ){
137496137936
yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -137499,313 +137939,314 @@
137499137939
sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
137500137940
sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
137501137941
}
137502137942
}
137503137943
break;
137504
- case 197: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
137944
+ case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
137505137945
{
137506137946
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
137507137947
yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
137508137948
}
137509137949
break;
137510
- case 198: /* case_exprlist ::= WHEN expr THEN expr */
137950
+ case 197: /* case_exprlist ::= WHEN expr THEN expr */
137511137951
{
137512137952
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137513137953
yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
137514137954
}
137515137955
break;
137516
- case 201: /* case_operand ::= expr */
137956
+ case 200: /* case_operand ::= expr */
137517137957
{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
137518137958
break;
137519
- case 204: /* nexprlist ::= nexprlist COMMA expr */
137959
+ case 203: /* nexprlist ::= nexprlist COMMA expr */
137520137960
{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
137521137961
break;
137522
- case 205: /* nexprlist ::= expr */
137962
+ case 204: /* nexprlist ::= expr */
137523137963
{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
137524137964
break;
137525
- case 207: /* paren_exprlist ::= LP exprlist RP */
137526
- case 212: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==212);
137965
+ case 206: /* paren_exprlist ::= LP exprlist RP */
137966
+ case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211);
137527137967
{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
137528137968
break;
137529
- case 208: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
137969
+ case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
137530137970
{
137531137971
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
137532137972
sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
137533137973
&yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
137534137974
}
137535137975
break;
137536
- case 209: /* uniqueflag ::= UNIQUE */
137537
- case 250: /* raisetype ::= ABORT */ yytestcase(yyruleno==250);
137976
+ case 208: /* uniqueflag ::= UNIQUE */
137977
+ case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
137538137978
{yymsp[0].minor.yy194 = OE_Abort;}
137539137979
break;
137540
- case 210: /* uniqueflag ::= */
137980
+ case 209: /* uniqueflag ::= */
137541137981
{yymsp[1].minor.yy194 = OE_None;}
137542137982
break;
137543
- case 213: /* eidlist ::= eidlist COMMA nm collate sortorder */
137983
+ case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */
137544137984
{
137545137985
yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
137546137986
}
137547137987
break;
137548
- case 214: /* eidlist ::= nm collate sortorder */
137988
+ case 213: /* eidlist ::= nm collate sortorder */
137549137989
{
137550137990
yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
137551137991
}
137552137992
break;
137553
- case 217: /* cmd ::= DROP INDEX ifexists fullname */
137993
+ case 216: /* cmd ::= DROP INDEX ifexists fullname */
137554137994
{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
137555137995
break;
137556
- case 218: /* cmd ::= VACUUM */
137996
+ case 217: /* cmd ::= VACUUM */
137557137997
{sqlite3Vacuum(pParse,0);}
137558137998
break;
137559
- case 219: /* cmd ::= VACUUM nm */
137999
+ case 218: /* cmd ::= VACUUM nm */
137560138000
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
137561138001
break;
137562
- case 220: /* cmd ::= PRAGMA nm dbnm */
138002
+ case 219: /* cmd ::= PRAGMA nm dbnm */
137563138003
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
137564138004
break;
137565
- case 221: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
138005
+ case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
137566138006
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
137567138007
break;
137568
- case 222: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
138008
+ case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
137569138009
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
137570138010
break;
137571
- case 223: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
138011
+ case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
137572138012
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
137573138013
break;
137574
- case 224: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
138014
+ case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
137575138015
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
137576138016
break;
137577
- case 227: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
138017
+ case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
137578138018
{
137579138019
Token all;
137580138020
all.z = yymsp[-3].minor.yy0.z;
137581138021
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
137582138022
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
137583138023
}
137584138024
break;
137585
- case 228: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
138025
+ case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
137586138026
{
137587138027
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
137588138028
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
137589138029
}
137590138030
break;
137591
- case 229: /* trigger_time ::= BEFORE */
138031
+ case 228: /* trigger_time ::= BEFORE */
137592138032
{ yymsp[0].minor.yy194 = TK_BEFORE; }
137593138033
break;
137594
- case 230: /* trigger_time ::= AFTER */
138034
+ case 229: /* trigger_time ::= AFTER */
137595138035
{ yymsp[0].minor.yy194 = TK_AFTER; }
137596138036
break;
137597
- case 231: /* trigger_time ::= INSTEAD OF */
138037
+ case 230: /* trigger_time ::= INSTEAD OF */
137598138038
{ yymsp[-1].minor.yy194 = TK_INSTEAD;}
137599138039
break;
137600
- case 232: /* trigger_time ::= */
138040
+ case 231: /* trigger_time ::= */
137601138041
{ yymsp[1].minor.yy194 = TK_BEFORE; }
137602138042
break;
137603
- case 233: /* trigger_event ::= DELETE|INSERT */
137604
- case 234: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==234);
138043
+ case 232: /* trigger_event ::= DELETE|INSERT */
138044
+ case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
137605138045
{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
137606138046
break;
137607
- case 235: /* trigger_event ::= UPDATE OF idlist */
138047
+ case 234: /* trigger_event ::= UPDATE OF idlist */
137608138048
{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
137609138049
break;
137610
- case 236: /* when_clause ::= */
137611
- case 255: /* key_opt ::= */ yytestcase(yyruleno==255);
138050
+ case 235: /* when_clause ::= */
138051
+ case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
137612138052
{ yymsp[1].minor.yy72 = 0; }
137613138053
break;
137614
- case 237: /* when_clause ::= WHEN expr */
137615
- case 256: /* key_opt ::= KEY expr */ yytestcase(yyruleno==256);
138054
+ case 236: /* when_clause ::= WHEN expr */
138055
+ case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
137616138056
{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
137617138057
break;
137618
- case 238: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
138058
+ case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
137619138059
{
137620138060
assert( yymsp[-2].minor.yy145!=0 );
137621138061
yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
137622138062
yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
137623138063
}
137624138064
break;
137625
- case 239: /* trigger_cmd_list ::= trigger_cmd SEMI */
138065
+ case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
137626138066
{
137627138067
assert( yymsp[-1].minor.yy145!=0 );
137628138068
yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
137629138069
}
137630138070
break;
137631
- case 240: /* trnm ::= nm DOT nm */
138071
+ case 239: /* trnm ::= nm DOT nm */
137632138072
{
137633138073
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
137634138074
sqlite3ErrorMsg(pParse,
137635138075
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
137636138076
"statements within triggers");
137637138077
}
137638138078
break;
137639
- case 241: /* tridxby ::= INDEXED BY nm */
138079
+ case 240: /* tridxby ::= INDEXED BY nm */
137640138080
{
137641138081
sqlite3ErrorMsg(pParse,
137642138082
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
137643138083
"within triggers");
137644138084
}
137645138085
break;
137646
- case 242: /* tridxby ::= NOT INDEXED */
138086
+ case 241: /* tridxby ::= NOT INDEXED */
137647138087
{
137648138088
sqlite3ErrorMsg(pParse,
137649138089
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
137650138090
"within triggers");
137651138091
}
137652138092
break;
137653
- case 243: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
138093
+ case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
137654138094
{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
137655138095
break;
137656
- case 244: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
138096
+ case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
137657138097
{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
137658138098
break;
137659
- case 245: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
138099
+ case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
137660138100
{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
137661138101
break;
137662
- case 246: /* trigger_cmd ::= select */
138102
+ case 245: /* trigger_cmd ::= select */
137663138103
{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
137664138104
break;
137665
- case 247: /* expr ::= RAISE LP IGNORE RP */
138105
+ case 246: /* expr ::= RAISE LP IGNORE RP */
137666138106
{
137667138107
spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
137668138108
yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
137669138109
if( yymsp[-3].minor.yy190.pExpr ){
137670138110
yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
137671138111
}
137672138112
}
137673138113
break;
137674
- case 248: /* expr ::= RAISE LP raisetype COMMA nm RP */
138114
+ case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
137675138115
{
137676138116
spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
137677138117
yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
137678138118
if( yymsp[-5].minor.yy190.pExpr ) {
137679138119
yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
137680138120
}
137681138121
}
137682138122
break;
137683
- case 249: /* raisetype ::= ROLLBACK */
138123
+ case 248: /* raisetype ::= ROLLBACK */
137684138124
{yymsp[0].minor.yy194 = OE_Rollback;}
137685138125
break;
137686
- case 251: /* raisetype ::= FAIL */
138126
+ case 250: /* raisetype ::= FAIL */
137687138127
{yymsp[0].minor.yy194 = OE_Fail;}
137688138128
break;
137689
- case 252: /* cmd ::= DROP TRIGGER ifexists fullname */
138129
+ case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
137690138130
{
137691138131
sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
137692138132
}
137693138133
break;
137694
- case 253: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
138134
+ case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
137695138135
{
137696138136
sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
137697138137
}
137698138138
break;
137699
- case 254: /* cmd ::= DETACH database_kw_opt expr */
138139
+ case 253: /* cmd ::= DETACH database_kw_opt expr */
137700138140
{
137701138141
sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
137702138142
}
137703138143
break;
137704
- case 257: /* cmd ::= REINDEX */
138144
+ case 256: /* cmd ::= REINDEX */
137705138145
{sqlite3Reindex(pParse, 0, 0);}
137706138146
break;
137707
- case 258: /* cmd ::= REINDEX nm dbnm */
138147
+ case 257: /* cmd ::= REINDEX nm dbnm */
137708138148
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
137709138149
break;
137710
- case 259: /* cmd ::= ANALYZE */
138150
+ case 258: /* cmd ::= ANALYZE */
137711138151
{sqlite3Analyze(pParse, 0, 0);}
137712138152
break;
137713
- case 260: /* cmd ::= ANALYZE nm dbnm */
138153
+ case 259: /* cmd ::= ANALYZE nm dbnm */
137714138154
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
137715138155
break;
137716
- case 261: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
138156
+ case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
137717138157
{
137718138158
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
137719138159
}
137720138160
break;
137721
- case 262: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
138161
+ case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
137722138162
{
137723138163
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
137724138164
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
137725138165
}
137726138166
break;
137727
- case 263: /* add_column_fullname ::= fullname */
138167
+ case 262: /* add_column_fullname ::= fullname */
137728138168
{
137729138169
disableLookaside(pParse);
137730138170
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
137731138171
}
137732138172
break;
137733
- case 264: /* cmd ::= create_vtab */
138173
+ case 263: /* cmd ::= create_vtab */
137734138174
{sqlite3VtabFinishParse(pParse,0);}
137735138175
break;
137736
- case 265: /* cmd ::= create_vtab LP vtabarglist RP */
138176
+ case 264: /* cmd ::= create_vtab LP vtabarglist RP */
137737138177
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
137738138178
break;
137739
- case 266: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
138179
+ case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
137740138180
{
137741138181
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
137742138182
}
137743138183
break;
137744
- case 267: /* vtabarg ::= */
138184
+ case 266: /* vtabarg ::= */
137745138185
{sqlite3VtabArgInit(pParse);}
137746138186
break;
137747
- case 268: /* vtabargtoken ::= ANY */
137748
- case 269: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==269);
137749
- case 270: /* lp ::= LP */ yytestcase(yyruleno==270);
138187
+ case 267: /* vtabargtoken ::= ANY */
138188
+ case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
138189
+ case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
137750138190
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
137751138191
break;
137752
- case 271: /* with ::= */
138192
+ case 270: /* with ::= */
137753138193
{yymsp[1].minor.yy285 = 0;}
137754138194
break;
137755
- case 272: /* with ::= WITH wqlist */
138195
+ case 271: /* with ::= WITH wqlist */
137756138196
{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
137757138197
break;
137758
- case 273: /* with ::= WITH RECURSIVE wqlist */
138198
+ case 272: /* with ::= WITH RECURSIVE wqlist */
137759138199
{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
137760138200
break;
137761
- case 274: /* wqlist ::= nm eidlist_opt AS LP select RP */
138201
+ case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
137762138202
{
137763138203
yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
137764138204
}
137765138205
break;
137766
- case 275: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
138206
+ case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
137767138207
{
137768138208
yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
137769138209
}
137770138210
break;
137771138211
default:
137772
- /* (276) input ::= cmdlist */ yytestcase(yyruleno==276);
137773
- /* (277) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==277);
137774
- /* (278) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=278);
137775
- /* (279) ecmd ::= SEMI */ yytestcase(yyruleno==279);
137776
- /* (280) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==280);
137777
- /* (281) explain ::= */ yytestcase(yyruleno==281);
137778
- /* (282) trans_opt ::= */ yytestcase(yyruleno==282);
137779
- /* (283) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==283);
137780
- /* (284) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==284);
137781
- /* (285) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==285);
137782
- /* (286) savepoint_opt ::= */ yytestcase(yyruleno==286);
137783
- /* (287) cmd ::= create_table create_table_args */ yytestcase(yyruleno==287);
137784
- /* (288) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==288);
137785
- /* (289) columnlist ::= columnname carglist */ yytestcase(yyruleno==289);
137786
- /* (290) nm ::= ID|INDEXED */ yytestcase(yyruleno==290);
137787
- /* (291) nm ::= STRING */ yytestcase(yyruleno==291);
137788
- /* (292) nm ::= JOIN_KW */ yytestcase(yyruleno==292);
137789
- /* (293) typetoken ::= typename */ yytestcase(yyruleno==293);
137790
- /* (294) typename ::= ID|STRING */ yytestcase(yyruleno==294);
137791
- /* (295) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
137792
- /* (296) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=296);
137793
- /* (297) carglist ::= carglist ccons */ yytestcase(yyruleno==297);
137794
- /* (298) carglist ::= */ yytestcase(yyruleno==298);
137795
- /* (299) ccons ::= NULL onconf */ yytestcase(yyruleno==299);
137796
- /* (300) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==300);
137797
- /* (301) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==301);
137798
- /* (302) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=302);
137799
- /* (303) tconscomma ::= */ yytestcase(yyruleno==303);
137800
- /* (304) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=304);
137801
- /* (305) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=305);
137802
- /* (306) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=306);
137803
- /* (307) oneselect ::= values */ yytestcase(yyruleno==307);
137804
- /* (308) sclp ::= selcollist COMMA */ yytestcase(yyruleno==308);
137805
- /* (309) as ::= ID|STRING */ yytestcase(yyruleno==309);
137806
- /* (310) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=310);
138212
+ /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
138213
+ /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
138214
+ /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
138215
+ /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
138216
+ /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
138217
+ /* (280) explain ::= */ yytestcase(yyruleno==280);
138218
+ /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
138219
+ /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
138220
+ /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
138221
+ /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
138222
+ /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
138223
+ /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
138224
+ /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
138225
+ /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
138226
+ /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
138227
+ /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
138228
+ /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
138229
+ /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
138230
+ /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
138231
+ /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
138232
+ /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
138233
+ /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
138234
+ /* (297) carglist ::= */ yytestcase(yyruleno==297);
138235
+ /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
138236
+ /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
138237
+ /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
138238
+ /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
138239
+ /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
138240
+ /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
138241
+ /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
138242
+ /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
138243
+ /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
138244
+ /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
138245
+ /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
138246
+ /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
138247
+ /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
137807138248
/* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
137808138249
/* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
137809138250
/* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
137810138251
/* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
137811138252
/* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
@@ -140301,10 +140742,25 @@
140301140742
return 0;
140302140743
}
140303140744
#endif
140304140745
return db->lastRowid;
140305140746
}
140747
+
140748
+/*
140749
+** Set the value returned by the sqlite3_last_insert_rowid() API function.
140750
+*/
140751
+SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *db, sqlite3_int64 iRowid){
140752
+#ifdef SQLITE_ENABLE_API_ARMOR
140753
+ if( !sqlite3SafetyCheckOk(db) ){
140754
+ (void)SQLITE_MISUSE_BKPT;
140755
+ return;
140756
+ }
140757
+#endif
140758
+ sqlite3_mutex_enter(db->mutex);
140759
+ db->lastRowid = iRowid;
140760
+ sqlite3_mutex_leave(db->mutex);
140761
+}
140306140762
140307140763
/*
140308140764
** Return the number of changes in the most recent call to sqlite3_exec().
140309140765
*/
140310140766
SQLITE_API int sqlite3_changes(sqlite3 *db){
@@ -148111,12 +148567,14 @@
148111148567
** segments.
148112148568
*/
148113148569
const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */
148114148570
148115148571
Fts3Table *p = (Fts3Table*)pVtab;
148116
- int rc = sqlite3Fts3PendingTermsFlush(p);
148572
+ int rc;
148573
+ i64 iLastRowid = sqlite3_last_insert_rowid(p->db);
148117148574
148575
+ rc = sqlite3Fts3PendingTermsFlush(p);
148118148576
if( rc==SQLITE_OK
148119148577
&& p->nLeafAdd>(nMinMerge/16)
148120148578
&& p->nAutoincrmerge && p->nAutoincrmerge!=0xff
148121148579
){
148122148580
int mxLevel = 0; /* Maximum relative level value in db */
@@ -148127,10 +148585,11 @@
148127148585
A = p->nLeafAdd * mxLevel;
148128148586
A += (A/2);
148129148587
if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge);
148130148588
}
148131148589
sqlite3Fts3SegmentsClose(p);
148590
+ sqlite3_set_last_insert_rowid(p->db, iLastRowid);
148132148591
return rc;
148133148592
}
148134148593
148135148594
/*
148136148595
** If it is currently unknown whether or not the FTS table has an %_stat
@@ -168462,10 +168921,11 @@
168462168921
int nStep; /* Rows processed for current object */
168463168922
int nProgress; /* Rows processed for all objects */
168464168923
RbuObjIter objiter; /* Iterator for skipping through tbl/idx */
168465168924
const char *zVfsName; /* Name of automatically created rbu vfs */
168466168925
rbu_file *pTargetFd; /* File handle open on target db */
168926
+ int nPagePerSector; /* Pages per sector for pTargetFd */
168467168927
i64 iOalSz;
168468168928
i64 nPhaseOneStep;
168469168929
168470168930
/* The following state variables are used as part of the incremental
168471168931
** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding
@@ -170726,10 +171186,27 @@
170726171186
170727171187
if( p->rc==SQLITE_OK ){
170728171188
if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){
170729171189
p->rc = SQLITE_DONE;
170730171190
p->eStage = RBU_STAGE_DONE;
171191
+ }else{
171192
+ int nSectorSize;
171193
+ sqlite3_file *pDb = p->pTargetFd->pReal;
171194
+ sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;
171195
+ assert( p->nPagePerSector==0 );
171196
+ nSectorSize = pDb->pMethods->xSectorSize(pDb);
171197
+ if( nSectorSize>p->pgsz ){
171198
+ p->nPagePerSector = nSectorSize / p->pgsz;
171199
+ }else{
171200
+ p->nPagePerSector = 1;
171201
+ }
171202
+
171203
+ /* Call xSync() on the wal file. This causes SQLite to sync the
171204
+ ** directory in which the target database and the wal file reside, in
171205
+ ** case it has not been synced since the rename() call in
171206
+ ** rbuMoveOalFile(). */
171207
+ p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL);
170731171208
}
170732171209
}
170733171210
}
170734171211
170735171212
/*
@@ -171381,13 +171858,30 @@
171381171858
if( p->rc==SQLITE_OK ){
171382171859
p->eStage = RBU_STAGE_DONE;
171383171860
p->rc = SQLITE_DONE;
171384171861
}
171385171862
}else{
171386
- RbuFrame *pFrame = &p->aFrame[p->nStep];
171387
- rbuCheckpointFrame(p, pFrame);
171388
- p->nStep++;
171863
+ /* At one point the following block copied a single frame from the
171864
+ ** wal file to the database file. So that one call to sqlite3rbu_step()
171865
+ ** checkpointed a single frame.
171866
+ **
171867
+ ** However, if the sector-size is larger than the page-size, and the
171868
+ ** application calls sqlite3rbu_savestate() or close() immediately
171869
+ ** after this step, then rbu_step() again, then a power failure occurs,
171870
+ ** then the database page written here may be damaged. Work around
171871
+ ** this by checkpointing frames until the next page in the aFrame[]
171872
+ ** lies on a different disk sector to the current one. */
171873
+ u32 iSector;
171874
+ do{
171875
+ RbuFrame *pFrame = &p->aFrame[p->nStep];
171876
+ iSector = (pFrame->iDbPage-1) / p->nPagePerSector;
171877
+ rbuCheckpointFrame(p, pFrame);
171878
+ p->nStep++;
171879
+ }while( p->nStep<p->nFrame
171880
+ && iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector)
171881
+ && p->rc==SQLITE_OK
171882
+ );
171389171883
}
171390171884
p->nProgress++;
171391171885
}
171392171886
break;
171393171887
}
@@ -171823,10 +172317,16 @@
171823172317
171824172318
/* Commit the transaction to the *-oal file. */
171825172319
if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
171826172320
p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg);
171827172321
}
172322
+
172323
+ /* Sync the db file if currently doing an incremental checkpoint */
172324
+ if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
172325
+ sqlite3_file *pDb = p->pTargetFd->pReal;
172326
+ p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
172327
+ }
171828172328
171829172329
rbuSaveState(p, p->eStage);
171830172330
171831172331
if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
171832172332
p->rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, &p->zErrmsg);
@@ -171947,10 +172447,16 @@
171947172447
assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
171948172448
if( p->eStage==RBU_STAGE_OAL ){
171949172449
assert( rc!=SQLITE_DONE );
171950172450
if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0);
171951172451
}
172452
+
172453
+ /* Sync the db file */
172454
+ if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
172455
+ sqlite3_file *pDb = p->pTargetFd->pReal;
172456
+ rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
172457
+ }
171952172458
171953172459
p->rc = rc;
171954172460
rbuSaveState(p, p->eStage);
171955172461
rc = p->rc;
171956172462
@@ -181079,11 +181585,13 @@
181079181585
typedef unsigned short u16;
181080181586
typedef short i16;
181081181587
typedef sqlite3_int64 i64;
181082181588
typedef sqlite3_uint64 u64;
181083181589
181084
-#define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
181590
+#ifndef ArraySize
181591
+# define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
181592
+#endif
181085181593
181086181594
#define testcase(x)
181087181595
#define ALWAYS(x) 1
181088181596
#define NEVER(x) 0
181089181597
@@ -186302,11 +186810,14 @@
186302186810
if( p1->bEof==0 ){
186303186811
if( (p1->iRowid==iLast)
186304186812
|| (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)
186305186813
){
186306186814
int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);
186307
- if( rc!=SQLITE_OK ) return rc;
186815
+ if( rc!=SQLITE_OK ){
186816
+ pNode->bNomatch = 0;
186817
+ return rc;
186818
+ }
186308186819
}
186309186820
}
186310186821
}
186311186822
186312186823
fts5ExprNodeTest_OR(pExpr, pNode);
@@ -186333,11 +186844,14 @@
186333186844
Fts5ExprNode *pChild = pAnd->apChild[iChild];
186334186845
int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);
186335186846
if( cmp>0 ){
186336186847
/* Advance pChild until it points to iLast or laster */
186337186848
rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);
186338
- if( rc!=SQLITE_OK ) return rc;
186849
+ if( rc!=SQLITE_OK ){
186850
+ pAnd->bNomatch = 0;
186851
+ return rc;
186852
+ }
186339186853
}
186340186854
186341186855
/* If the child node is now at EOF, so is the parent AND node. Otherwise,
186342186856
** the child node is guaranteed to have advanced at least as far as
186343186857
** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the
@@ -186372,10 +186886,12 @@
186372186886
i64 iFrom
186373186887
){
186374186888
int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
186375186889
if( rc==SQLITE_OK ){
186376186890
rc = fts5ExprNodeTest_AND(pExpr, pNode);
186891
+ }else{
186892
+ pNode->bNomatch = 0;
186377186893
}
186378186894
return rc;
186379186895
}
186380186896
186381186897
static int fts5ExprNodeTest_NOT(
@@ -186414,10 +186930,13 @@
186414186930
){
186415186931
int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
186416186932
if( rc==SQLITE_OK ){
186417186933
rc = fts5ExprNodeTest_NOT(pExpr, pNode);
186418186934
}
186935
+ if( rc!=SQLITE_OK ){
186936
+ pNode->bNomatch = 0;
186937
+ }
186419186938
return rc;
186420186939
}
186421186940
186422186941
/*
186423186942
** If pNode currently points to a match, this function returns SQLITE_OK
@@ -197534,11 +198053,11 @@
197534198053
int nArg, /* Number of args */
197535198054
sqlite3_value **apUnused /* Function arguments */
197536198055
){
197537198056
assert( nArg==0 );
197538198057
UNUSED_PARAM2(nArg, apUnused);
197539
- sqlite3_result_text(pCtx, "fts5: 2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c", -1, SQLITE_TRANSIENT);
198058
+ sqlite3_result_text(pCtx, "fts5: 2017-03-03 16:51:46 915a9a28783fbb2f4c0794eb4264ce8c0b9d42f7", -1, SQLITE_TRANSIENT);
197540198059
}
197541198060
197542198061
static int fts5Init(sqlite3 *db){
197543198062
static const sqlite3_module fts5Mod = {
197544198063
/* iVersion */ 2,
@@ -198197,15 +198716,10 @@
198197198716
sqlite3_step(pDel);
198198198717
rc = sqlite3_reset(pDel);
198199198718
}
198200198719
}
198201198720
198202
- /* Write the averages record */
198203
- if( rc==SQLITE_OK ){
198204
- rc = fts5StorageSaveTotals(p);
198205
- }
198206
-
198207198721
return rc;
198208198722
}
198209198723
198210198724
/*
198211198725
** Delete all entries in the FTS5 index.
@@ -198405,15 +198919,10 @@
198405198919
if( rc==SQLITE_OK ){
198406198920
rc = fts5StorageInsertDocsize(p, iRowid, &buf);
198407198921
}
198408198922
sqlite3_free(buf.p);
198409198923
198410
- /* Write the averages record */
198411
- if( rc==SQLITE_OK ){
198412
- rc = fts5StorageSaveTotals(p);
198413
- }
198414
-
198415198924
return rc;
198416198925
}
198417198926
198418198927
static int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){
198419198928
Fts5Config *pConfig = p->pConfig;
@@ -198744,16 +199253,21 @@
198744199253
198745199254
/*
198746199255
** Flush any data currently held in-memory to disk.
198747199256
*/
198748199257
static int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit){
198749
- if( bCommit && p->bTotalsValid ){
198750
- int rc = fts5StorageSaveTotals(p);
198751
- p->bTotalsValid = 0;
198752
- if( rc!=SQLITE_OK ) return rc;
199258
+ int rc = SQLITE_OK;
199259
+ i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db);
199260
+ if( p->bTotalsValid ){
199261
+ rc = fts5StorageSaveTotals(p);
199262
+ if( bCommit ) p->bTotalsValid = 0;
198753199263
}
198754
- return sqlite3Fts5IndexSync(p->pIndex, bCommit);
199264
+ if( rc==SQLITE_OK ){
199265
+ rc = sqlite3Fts5IndexSync(p->pIndex, bCommit);
199266
+ }
199267
+ sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid);
199268
+ return rc;
198755199269
}
198756199270
198757199271
static int sqlite3Fts5StorageRollback(Fts5Storage *p){
198758199272
p->bTotalsValid = 0;
198759199273
return sqlite3Fts5IndexRollback(p->pIndex);
198760199274
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.17.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -396,13 +396,13 @@
396 **
397 ** See also: [sqlite3_libversion()],
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.17.0"
402 #define SQLITE_VERSION_NUMBER 3017000
403 #define SQLITE_SOURCE_ID "2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -2315,24 +2315,34 @@
2315 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
2316 ** names are not also used by explicitly declared columns. ^If
2317 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
2318 ** is another alias for the rowid.
2319 **
2320 ** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
2321 ** most recent successful [INSERT] into a rowid table or [virtual table]
2322 ** on database connection D.
2323 ** ^Inserts into [WITHOUT ROWID] tables are not recorded.
2324 ** ^If no successful [INSERT]s into rowid tables
2325 ** have ever occurred on the database connection D,
2326 ** then sqlite3_last_insert_rowid(D) returns zero.
2327 **
2328 ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
2329 ** method, then this routine will return the [rowid] of the inserted
2330 ** row as long as the trigger or virtual table method is running.
2331 ** But once the trigger or virtual table method ends, the value returned
2332 ** by this routine reverts to what it was before the trigger or virtual
2333 ** table method began.)^
 
 
 
 
 
 
 
 
 
 
 
2334 **
2335 ** ^An [INSERT] that fails due to a constraint violation is not a
2336 ** successful [INSERT] and does not change the value returned by this
2337 ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
2338 ** and INSERT OR ABORT make no changes to the return value of this
@@ -2355,10 +2365,20 @@
2355 ** unpredictable and might not equal either the old or the new
2356 ** last insert [rowid].
2357 */
2358 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2359
 
 
 
 
 
 
 
 
 
 
2360 /*
2361 ** CAPI3REF: Count The Number Of Rows Modified
2362 ** METHOD: sqlite3
2363 **
2364 ** ^This function returns the number of rows modified, inserted or
@@ -12457,10 +12477,11 @@
12457 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
12458 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
12459
12460 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
12461 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
 
12462
12463 #ifndef SQLITE_OMIT_INCRBLOB
12464 SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);
12465 SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
12466 SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
@@ -12757,117 +12778,119 @@
12757 #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
12758 #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
12759 #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12760 #define OP_Last 53
12761 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12762 #define OP_SorterSort 55
12763 #define OP_Sort 56
12764 #define OP_Rewind 57
12765 #define OP_IdxLE 58 /* synopsis: key=r[P3@P4] */
12766 #define OP_IdxGT 59 /* synopsis: key=r[P3@P4] */
12767 #define OP_IdxLT 60 /* synopsis: key=r[P3@P4] */
12768 #define OP_IdxGE 61 /* synopsis: key=r[P3@P4] */
12769 #define OP_RowSetRead 62 /* synopsis: r[P3]=rowset(P1) */
12770 #define OP_RowSetTest 63 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12771 #define OP_Program 64
12772 #define OP_FkIfZero 65 /* synopsis: if fkctr[P1]==0 goto P2 */
12773 #define OP_IfPos 66 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12774 #define OP_IfNotZero 67 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
12775 #define OP_DecrJumpZero 68 /* synopsis: if (--r[P1])==0 goto P2 */
12776 #define OP_IncrVacuum 69
12777 #define OP_VNext 70
12778 #define OP_Init 71 /* synopsis: Start at P2 */
12779 #define OP_Return 72
12780 #define OP_EndCoroutine 73
12781 #define OP_HaltIfNull 74 /* synopsis: if r[P3]=null halt */
12782 #define OP_Halt 75
12783 #define OP_Integer 76 /* synopsis: r[P2]=P1 */
12784 #define OP_Int64 77 /* synopsis: r[P2]=P4 */
12785 #define OP_String 78 /* synopsis: r[P2]='P4' (len=P1) */
12786 #define OP_Null 79 /* synopsis: r[P2..P3]=NULL */
12787 #define OP_SoftNull 80 /* synopsis: r[P1]=NULL */
12788 #define OP_Blob 81 /* synopsis: r[P2]=P4 (len=P1) */
12789 #define OP_Variable 82 /* synopsis: r[P2]=parameter(P1,P4) */
12790 #define OP_Move 83 /* synopsis: r[P2@P3]=r[P1@P3] */
12791 #define OP_Copy 84 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12792 #define OP_SCopy 85 /* synopsis: r[P2]=r[P1] */
12793 #define OP_IntCopy 86 /* synopsis: r[P2]=r[P1] */
12794 #define OP_ResultRow 87 /* synopsis: output=r[P1@P2] */
12795 #define OP_CollSeq 88
12796 #define OP_Function0 89 /* synopsis: r[P3]=func(r[P2@P5]) */
12797 #define OP_Function 90 /* synopsis: r[P3]=func(r[P2@P5]) */
12798 #define OP_AddImm 91 /* synopsis: r[P1]=r[P1]+P2 */
12799 #define OP_RealAffinity 92
12800 #define OP_Cast 93 /* synopsis: affinity(r[P1]) */
12801 #define OP_Permutation 94
12802 #define OP_Compare 95 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12803 #define OP_Column 96 /* synopsis: r[P3]=PX */
12804 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12805 #define OP_Affinity 98 /* synopsis: affinity(r[P1@P2]) */
12806 #define OP_MakeRecord 99 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12807 #define OP_Count 100 /* synopsis: r[P2]=count() */
12808 #define OP_ReadCookie 101
12809 #define OP_SetCookie 102
12810 #define OP_ReopenIdx 103 /* synopsis: root=P2 iDb=P3 */
12811 #define OP_OpenRead 104 /* synopsis: root=P2 iDb=P3 */
12812 #define OP_OpenWrite 105 /* synopsis: root=P2 iDb=P3 */
12813 #define OP_OpenAutoindex 106 /* synopsis: nColumn=P2 */
12814 #define OP_OpenEphemeral 107 /* synopsis: nColumn=P2 */
12815 #define OP_SorterOpen 108
12816 #define OP_SequenceTest 109 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12817 #define OP_OpenPseudo 110 /* synopsis: P3 columns in r[P2] */
12818 #define OP_Close 111
12819 #define OP_ColumnsUsed 112
12820 #define OP_Sequence 113 /* synopsis: r[P2]=cursor[P1].ctr++ */
12821 #define OP_NewRowid 114 /* synopsis: r[P2]=rowid */
12822 #define OP_Insert 115 /* synopsis: intkey=r[P3] data=r[P2] */
12823 #define OP_InsertInt 116 /* synopsis: intkey=P3 data=r[P2] */
12824 #define OP_Delete 117
12825 #define OP_ResetCount 118
12826 #define OP_SorterCompare 119 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12827 #define OP_SorterData 120 /* synopsis: r[P2]=data */
12828 #define OP_RowData 121 /* synopsis: r[P2]=data */
12829 #define OP_Rowid 122 /* synopsis: r[P2]=rowid */
12830 #define OP_NullRow 123
12831 #define OP_SorterInsert 124 /* synopsis: key=r[P2] */
12832 #define OP_IdxInsert 125 /* synopsis: key=r[P2] */
12833 #define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */
12834 #define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */
12835 #define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */
12836 #define OP_Destroy 129
12837 #define OP_Clear 130
12838 #define OP_ResetSorter 131
12839 #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12840 #define OP_CreateIndex 133 /* synopsis: r[P2]=root iDb=P1 */
12841 #define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */
12842 #define OP_ParseSchema 135
12843 #define OP_LoadAnalysis 136
12844 #define OP_DropTable 137
12845 #define OP_DropIndex 138
12846 #define OP_DropTrigger 139
12847 #define OP_IntegrityCk 140
12848 #define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */
12849 #define OP_Param 142
12850 #define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */
12851 #define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12852 #define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12853 #define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12854 #define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12855 #define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */
12856 #define OP_Expire 149
12857 #define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */
12858 #define OP_VBegin 151
12859 #define OP_VCreate 152
12860 #define OP_VDestroy 153
12861 #define OP_VOpen 154
12862 #define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */
12863 #define OP_VRename 156
12864 #define OP_Pagecount 157
12865 #define OP_MaxPgcnt 158
12866 #define OP_CursorHint 159
12867 #define OP_Noop 160
12868 #define OP_Explain 161
 
 
12869
12870 /* Properties such as "out2" or "jump" that are specified in
12871 ** comments following the "case" for each opcode in the vdbe.c
12872 ** are encoded into bitvectors as follows:
12873 */
@@ -12883,32 +12906,32 @@
12883 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
12884 /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12885 /* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12886 /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
12887 /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12888 /* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b,\
12889 /* 64 */ 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01,\
12890 /* 72 */ 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10,\
12891 /* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00,\
12892 /* 88 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\
12893 /* 96 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
12894 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12895 /* 112 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
12896 /* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\
12897 /* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\
12898 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\
12899 /* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12900 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12901 /* 160 */ 0x00, 0x00,}
12902
12903 /* The sqlite3P2Values() routine is able to run faster if it knows
12904 ** the value of the largest JUMP opcode. The smaller the maximum
12905 ** JUMP opcode the better, so the mkopcodeh.tcl script that
12906 ** generated this include file strives to group all JUMP opcodes
12907 ** together near the beginning of the list.
12908 */
12909 #define SQLITE_MX_JUMP_OPCODE 71 /* Maximum JUMP opcode */
12910
12911 /************** End of opcodes.h *********************************************/
12912 /************** Continuing where we left off in vdbe.h ***********************/
12913
12914 /*
@@ -14074,10 +14097,11 @@
14074 u8 suppressErr; /* Do not issue error messages if true */
14075 u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
14076 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
14077 u8 mTrace; /* zero or more SQLITE_TRACE flags */
14078 u8 skipBtreeMutex; /* True if no shared-cache backends */
 
14079 int nextPagesize; /* Pagesize after VACUUM if >0 */
14080 u32 magic; /* Magic number for detect library misuse */
14081 int nChange; /* Value returned by sqlite3_changes() */
14082 int nTotalChange; /* Value returned by sqlite3_total_changes() */
14083 int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -14589,18 +14613,18 @@
14589 char *zColAff; /* String defining the affinity of each column */
14590 ExprList *pCheck; /* All CHECK constraints */
14591 /* ... also used as column name list in a VIEW */
14592 int tnum; /* Root BTree page for this table */
14593 u32 nTabRef; /* Number of pointers to this Table */
 
14594 i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
14595 i16 nCol; /* Number of columns in this table */
14596 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
14597 LogEst szTabRow; /* Estimated size of each table row in bytes */
14598 #ifdef SQLITE_ENABLE_COSTMULT
14599 LogEst costMult; /* Cost multiplier for using this table */
14600 #endif
14601 u8 tabFlags; /* Mask of TF_* values */
14602 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
14603 #ifndef SQLITE_OMIT_ALTERTABLE
14604 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
14605 #endif
14606 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -14620,27 +14644,29 @@
14620 ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
14621 ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
14622 ** the TF_OOOHidden attribute would apply in this case. Such tables require
14623 ** special handling during INSERT processing.
14624 */
14625 #define TF_Readonly 0x01 /* Read-only system table */
14626 #define TF_Ephemeral 0x02 /* An ephemeral table */
14627 #define TF_HasPrimaryKey 0x04 /* Table has a primary key */
14628 #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */
14629 #define TF_Virtual 0x10 /* Is a virtual table */
14630 #define TF_WithoutRowid 0x20 /* No rowid. PRIMARY KEY is the key */
14631 #define TF_NoVisibleRowid 0x40 /* No user-visible "rowid" column */
14632 #define TF_OOOHidden 0x80 /* Out-of-Order hidden columns */
14633
 
 
14634
14635 /*
14636 ** Test to see whether or not a table is a virtual table. This is
14637 ** done as a macro so that it will be optimized out when virtual
14638 ** table support is omitted from the build.
14639 */
14640 #ifndef SQLITE_OMIT_VIRTUALTABLE
14641 # define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0)
14642 #else
14643 # define IsVirtual(X) 0
14644 #endif
14645
14646 /*
@@ -14871,10 +14897,11 @@
14871 unsigned bUnordered:1; /* Use this index for == or IN queries only */
14872 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
14873 unsigned isResized:1; /* True if resizeIndexObject() has been called */
14874 unsigned isCovering:1; /* True if this is a covering index */
14875 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
 
14876 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
14877 int nSample; /* Number of elements in aSample[] */
14878 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
14879 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
14880 IndexSample *aSample; /* Samples of the left-most key */
@@ -15181,11 +15208,11 @@
15181 ** form is used for name resolution with nested FROM clauses.
15182 */
15183 struct ExprList {
15184 int nExpr; /* Number of expressions on the list */
15185 struct ExprList_item { /* For each expression in the list */
15186 Expr *pExpr; /* The list of expressions */
15187 char *zName; /* Token associated with this expression */
15188 char *zSpan; /* Original text of the expression */
15189 u8 sortOrder; /* 1 for DESC or 0 for ASC */
15190 unsigned done :1; /* A flag to indicate when processing is finished */
15191 unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
@@ -16504,10 +16531,11 @@
16504 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
16505 SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
16506 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
16507 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
16508 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
 
16509 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
16510 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
16511 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
16512 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
16513 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
@@ -17450,11 +17478,11 @@
17450 "COMPILER=gcc-" __VERSION__,
17451 #endif
17452 #if SQLITE_COVERAGE_TEST
17453 "COVERAGE_TEST",
17454 #endif
17455 #if SQLITE_DEBUG
17456 "DEBUG",
17457 #endif
17458 #if SQLITE_DEFAULT_LOCKING_MODE
17459 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17460 #endif
@@ -19505,22 +19533,23 @@
19505 **
19506 ** Move the date backwards to the beginning of the current day,
19507 ** or month or year.
19508 */
19509 if( sqlite3_strnicmp(z, "start of ", 9)!=0 ) break;
 
19510 z += 9;
19511 computeYMD(p);
19512 p->validHMS = 1;
19513 p->h = p->m = 0;
19514 p->s = 0.0;
 
19515 p->validTZ = 0;
19516 p->validJD = 0;
19517 if( sqlite3_stricmp(z,"month")==0 ){
19518 p->D = 1;
19519 rc = 0;
19520 }else if( sqlite3_stricmp(z,"year")==0 ){
19521 computeYMD(p);
19522 p->M = 1;
19523 p->D = 1;
19524 rc = 0;
19525 }else if( sqlite3_stricmp(z,"day")==0 ){
19526 rc = 0;
@@ -24050,12 +24079,12 @@
24050 #ifdef SQLITE_DEBUG
24051 assert( p->nRef>0 || p->owner==0 );
24052 p->owner = tid;
24053 p->nRef++;
24054 if( p->trace ){
24055 OSTRACE(("ENTER-MUTEX tid=%lu, mutex=%p (%d), nRef=%d\n",
24056 tid, p, p->trace, p->nRef));
24057 }
24058 #endif
24059 }
24060
24061 static int winMutexTry(sqlite3_mutex *p){
@@ -24093,12 +24122,12 @@
24093 #else
24094 UNUSED_PARAMETER(p);
24095 #endif
24096 #ifdef SQLITE_DEBUG
24097 if( p->trace ){
24098 OSTRACE(("TRY-MUTEX tid=%lu, mutex=%p (%d), owner=%lu, nRef=%d, rc=%s\n",
24099 tid, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));
24100 }
24101 #endif
24102 return rc;
24103 }
24104
@@ -24122,12 +24151,12 @@
24122 #endif
24123 assert( winMutex_isInit==1 );
24124 LeaveCriticalSection(&p->mutex);
24125 #ifdef SQLITE_DEBUG
24126 if( p->trace ){
24127 OSTRACE(("LEAVE-MUTEX tid=%lu, mutex=%p (%d), nRef=%d\n",
24128 tid, p, p->trace, p->nRef));
24129 }
24130 #endif
24131 }
24132
24133 SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
@@ -24572,11 +24601,11 @@
24572 return sqlite3GlobalConfig.m.xSize(p);
24573 }
24574 SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
24575 assert( p!=0 );
24576 if( db==0 || !isLookaside(db,p) ){
24577 #if SQLITE_DEBUG
24578 if( db==0 ){
24579 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
24580 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
24581 }else{
24582 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
@@ -24633,11 +24662,11 @@
24633 measureAllocationSize(db, p);
24634 return;
24635 }
24636 if( isLookaside(db, p) ){
24637 LookasideSlot *pBuf = (LookasideSlot*)p;
24638 #if SQLITE_DEBUG
24639 /* Trash all content in the buffer being freed */
24640 memset(p, 0xaa, db->lookaside.sz);
24641 #endif
24642 pBuf->pNext = db->lookaside.pFree;
24643 db->lookaside.pFree = pBuf;
@@ -25002,11 +25031,11 @@
25002
25003 /*
25004 ** Conversion types fall into various categories as defined by the
25005 ** following enumeration.
25006 */
25007 #define etRADIX 0 /* Integer types. %d, %x, %o, and so forth */
25008 #define etFLOAT 1 /* Floating point. %f */
25009 #define etEXP 2 /* Exponentional notation. %e and %E */
25010 #define etGENERIC 3 /* Floating or exponential, depending on exponent. %g */
25011 #define etSIZE 4 /* Return number of characters processed so far. %n */
25012 #define etSTRING 5 /* Strings. %s */
@@ -25020,12 +25049,13 @@
25020 #define etTOKEN 11 /* a pointer to a Token structure */
25021 #define etSRCLIST 12 /* a pointer to a SrcList */
25022 #define etPOINTER 13 /* The %p conversion */
25023 #define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */
25024 #define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */
 
25025
25026 #define etINVALID 16 /* Any unrecognized conversion type */
25027
25028
25029 /*
25030 ** An "etByte" is an 8-bit unsigned value.
25031 */
@@ -25045,40 +25075,40 @@
25045 } et_info;
25046
25047 /*
25048 ** Allowed values for et_info.flags
25049 */
25050 #define FLAG_SIGNED 1 /* True if the value to convert is signed */
25051 #define FLAG_STRING 4 /* Allow infinity precision */
25052
25053
25054 /*
25055 ** The following table is searched linearly, so it is good to put the
25056 ** most frequently used conversion types first.
25057 */
25058 static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
25059 static const char aPrefix[] = "-x0\000X0";
25060 static const et_info fmtinfo[] = {
25061 { 'd', 10, 1, etRADIX, 0, 0 },
25062 { 's', 0, 4, etSTRING, 0, 0 },
25063 { 'g', 0, 1, etGENERIC, 30, 0 },
25064 { 'z', 0, 4, etDYNSTRING, 0, 0 },
25065 { 'q', 0, 4, etSQLESCAPE, 0, 0 },
25066 { 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
25067 { 'w', 0, 4, etSQLESCAPE3, 0, 0 },
25068 { 'c', 0, 0, etCHARX, 0, 0 },
25069 { 'o', 8, 0, etRADIX, 0, 2 },
25070 { 'u', 10, 0, etRADIX, 0, 0 },
25071 { 'x', 16, 0, etRADIX, 16, 1 },
25072 { 'X', 16, 0, etRADIX, 0, 4 },
25073 #ifndef SQLITE_OMIT_FLOATING_POINT
25074 { 'f', 0, 1, etFLOAT, 0, 0 },
25075 { 'e', 0, 1, etEXP, 30, 0 },
25076 { 'E', 0, 1, etEXP, 14, 0 },
25077 { 'G', 0, 1, etGENERIC, 14, 0 },
25078 #endif
25079 { 'i', 10, 1, etRADIX, 0, 0 },
25080 { 'n', 0, 0, etSIZE, 0, 0 },
25081 { '%', 0, 0, etPERCENT, 0, 0 },
25082 { 'p', 16, 0, etPOINTER, 0, 1 },
25083
25084 /* All the rest are undocumented and are for internal use only */
@@ -25166,18 +25196,17 @@
25166 int precision; /* Precision of the current field */
25167 int length; /* Length of the field */
25168 int idx; /* A general purpose loop counter */
25169 int width; /* Width of the current field */
25170 etByte flag_leftjustify; /* True if "-" flag is present */
25171 etByte flag_plussign; /* True if "+" flag is present */
25172 etByte flag_blanksign; /* True if " " flag is present */
25173 etByte flag_alternateform; /* True if "#" flag is present */
25174 etByte flag_altform2; /* True if "!" flag is present */
25175 etByte flag_zeropad; /* True if field width constant starts with zero */
25176 etByte flag_long; /* True if "l" flag is present */
25177 etByte flag_longlong; /* True if the "ll" flag is present */
25178 etByte done; /* Loop termination flag */
 
25179 etByte xtype = etINVALID; /* Conversion paradigm */
25180 u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */
25181 char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
25182 sqlite_uint64 longvalue; /* Value for integer types */
25183 LONGDOUBLE_TYPE realvalue; /* Value for real types */
@@ -25216,21 +25245,22 @@
25216 if( (c=(*++fmt))==0 ){
25217 sqlite3StrAccumAppend(pAccum, "%", 1);
25218 break;
25219 }
25220 /* Find out what flags are present */
25221 flag_leftjustify = flag_plussign = flag_blanksign =
25222 flag_alternateform = flag_altform2 = flag_zeropad = 0;
25223 done = 0;
25224 do{
25225 switch( c ){
25226 case '-': flag_leftjustify = 1; break;
25227 case '+': flag_plussign = 1; break;
25228 case ' ': flag_blanksign = 1; break;
25229 case '#': flag_alternateform = 1; break;
25230 case '!': flag_altform2 = 1; break;
25231 case '0': flag_zeropad = 1; break;
 
25232 default: done = 1; break;
25233 }
25234 }while( !done && (c=(*++fmt))!=0 );
25235 /* Get the field width */
25236 if( c=='*' ){
@@ -25296,17 +25326,15 @@
25296 /* Get the conversion type modifier */
25297 if( c=='l' ){
25298 flag_long = 1;
25299 c = *++fmt;
25300 if( c=='l' ){
25301 flag_longlong = 1;
25302 c = *++fmt;
25303 }else{
25304 flag_longlong = 0;
25305 }
25306 }else{
25307 flag_long = flag_longlong = 0;
25308 }
25309 /* Fetch the info entry for the field */
25310 infop = &fmtinfo[0];
25311 xtype = etINVALID;
25312 for(idx=0; idx<ArraySize(fmtinfo); idx++){
@@ -25320,41 +25348,42 @@
25320 /*
25321 ** At this point, variables are initialized as follows:
25322 **
25323 ** flag_alternateform TRUE if a '#' is present.
25324 ** flag_altform2 TRUE if a '!' is present.
25325 ** flag_plussign TRUE if a '+' is present.
25326 ** flag_leftjustify TRUE if a '-' is present or if the
25327 ** field width was negative.
25328 ** flag_zeropad TRUE if the width began with 0.
25329 ** flag_long TRUE if the letter 'l' (ell) prefixed
25330 ** the conversion character.
25331 ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed
25332 ** the conversion character.
25333 ** flag_blanksign TRUE if a ' ' is present.
25334 ** width The specified field width. This is
25335 ** always non-negative. Zero is the default.
25336 ** precision The specified precision. The default
25337 ** is -1.
25338 ** xtype The class of the conversion.
25339 ** infop Pointer to the appropriate info struct.
25340 */
25341 switch( xtype ){
25342 case etPOINTER:
25343 flag_longlong = sizeof(char*)==sizeof(i64);
25344 flag_long = sizeof(char*)==sizeof(long int);
25345 /* Fall through into the next case */
25346 case etORDINAL:
25347 case etRADIX:
 
 
 
25348 if( infop->flags & FLAG_SIGNED ){
25349 i64 v;
25350 if( bArgList ){
25351 v = getIntArg(pArgList);
25352 }else if( flag_longlong ){
25353 v = va_arg(ap,i64);
25354 }else if( flag_long ){
25355 v = va_arg(ap,long int);
 
 
 
 
25356 }else{
25357 v = va_arg(ap,int);
25358 }
25359 if( v<0 ){
25360 if( v==SMALLEST_INT64 ){
@@ -25363,35 +25392,35 @@
25363 longvalue = -v;
25364 }
25365 prefix = '-';
25366 }else{
25367 longvalue = v;
25368 if( flag_plussign ) prefix = '+';
25369 else if( flag_blanksign ) prefix = ' ';
25370 else prefix = 0;
25371 }
25372 }else{
25373 if( bArgList ){
25374 longvalue = (u64)getIntArg(pArgList);
25375 }else if( flag_longlong ){
25376 longvalue = va_arg(ap,u64);
25377 }else if( flag_long ){
25378 longvalue = va_arg(ap,unsigned long int);
 
 
 
 
25379 }else{
25380 longvalue = va_arg(ap,unsigned int);
25381 }
25382 prefix = 0;
25383 }
25384 if( longvalue==0 ) flag_alternateform = 0;
25385 if( flag_zeropad && precision<width-(prefix!=0) ){
25386 precision = width-(prefix!=0);
25387 }
25388 if( precision<etBUFSIZE-10 ){
25389 nOut = etBUFSIZE;
25390 zOut = buf;
25391 }else{
25392 nOut = precision + 10;
25393 zOut = zExtra = sqlite3Malloc( nOut );
25394 if( zOut==0 ){
25395 setStrAccumError(pAccum, STRACCUM_NOMEM);
25396 return;
25397 }
@@ -25413,12 +25442,27 @@
25413 *(--bufpt) = cset[longvalue%base];
25414 longvalue = longvalue/base;
25415 }while( longvalue>0 );
25416 }
25417 length = (int)(&zOut[nOut-1]-bufpt);
25418 for(idx=precision-length; idx>0; idx--){
25419 *(--bufpt) = '0'; /* Zero pad */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25420 }
25421 if( prefix ) *(--bufpt) = prefix; /* Add sign */
25422 if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
25423 const char *pre;
25424 char x;
@@ -25441,13 +25485,11 @@
25441 if( precision<0 ) precision = 6; /* Set default precision */
25442 if( realvalue<0.0 ){
25443 realvalue = -realvalue;
25444 prefix = '-';
25445 }else{
25446 if( flag_plussign ) prefix = '+';
25447 else if( flag_blanksign ) prefix = ' ';
25448 else prefix = 0;
25449 }
25450 if( xtype==etGENERIC && precision>0 ) precision--;
25451 testcase( precision>0xfff );
25452 for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
25453 if( xtype==etFLOAT ) realvalue += rounder;
@@ -29464,117 +29506,119 @@
29464 /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
29465 /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
29466 /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
29467 /* 53 */ "Last" OpHelp(""),
29468 /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
29469 /* 55 */ "SorterSort" OpHelp(""),
29470 /* 56 */ "Sort" OpHelp(""),
29471 /* 57 */ "Rewind" OpHelp(""),
29472 /* 58 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29473 /* 59 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29474 /* 60 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29475 /* 61 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29476 /* 62 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29477 /* 63 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29478 /* 64 */ "Program" OpHelp(""),
29479 /* 65 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29480 /* 66 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29481 /* 67 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
29482 /* 68 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29483 /* 69 */ "IncrVacuum" OpHelp(""),
29484 /* 70 */ "VNext" OpHelp(""),
29485 /* 71 */ "Init" OpHelp("Start at P2"),
29486 /* 72 */ "Return" OpHelp(""),
29487 /* 73 */ "EndCoroutine" OpHelp(""),
29488 /* 74 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29489 /* 75 */ "Halt" OpHelp(""),
29490 /* 76 */ "Integer" OpHelp("r[P2]=P1"),
29491 /* 77 */ "Int64" OpHelp("r[P2]=P4"),
29492 /* 78 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29493 /* 79 */ "Null" OpHelp("r[P2..P3]=NULL"),
29494 /* 80 */ "SoftNull" OpHelp("r[P1]=NULL"),
29495 /* 81 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29496 /* 82 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29497 /* 83 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29498 /* 84 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29499 /* 85 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29500 /* 86 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29501 /* 87 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29502 /* 88 */ "CollSeq" OpHelp(""),
29503 /* 89 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29504 /* 90 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29505 /* 91 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29506 /* 92 */ "RealAffinity" OpHelp(""),
29507 /* 93 */ "Cast" OpHelp("affinity(r[P1])"),
29508 /* 94 */ "Permutation" OpHelp(""),
29509 /* 95 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29510 /* 96 */ "Column" OpHelp("r[P3]=PX"),
29511 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
29512 /* 98 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29513 /* 99 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29514 /* 100 */ "Count" OpHelp("r[P2]=count()"),
29515 /* 101 */ "ReadCookie" OpHelp(""),
29516 /* 102 */ "SetCookie" OpHelp(""),
29517 /* 103 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29518 /* 104 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29519 /* 105 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29520 /* 106 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29521 /* 107 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29522 /* 108 */ "SorterOpen" OpHelp(""),
29523 /* 109 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29524 /* 110 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29525 /* 111 */ "Close" OpHelp(""),
29526 /* 112 */ "ColumnsUsed" OpHelp(""),
29527 /* 113 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29528 /* 114 */ "NewRowid" OpHelp("r[P2]=rowid"),
29529 /* 115 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29530 /* 116 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29531 /* 117 */ "Delete" OpHelp(""),
29532 /* 118 */ "ResetCount" OpHelp(""),
29533 /* 119 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29534 /* 120 */ "SorterData" OpHelp("r[P2]=data"),
29535 /* 121 */ "RowData" OpHelp("r[P2]=data"),
29536 /* 122 */ "Rowid" OpHelp("r[P2]=rowid"),
29537 /* 123 */ "NullRow" OpHelp(""),
29538 /* 124 */ "SorterInsert" OpHelp("key=r[P2]"),
29539 /* 125 */ "IdxInsert" OpHelp("key=r[P2]"),
29540 /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29541 /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29542 /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29543 /* 129 */ "Destroy" OpHelp(""),
29544 /* 130 */ "Clear" OpHelp(""),
29545 /* 131 */ "ResetSorter" OpHelp(""),
29546 /* 132 */ "Real" OpHelp("r[P2]=P4"),
29547 /* 133 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29548 /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29549 /* 135 */ "ParseSchema" OpHelp(""),
29550 /* 136 */ "LoadAnalysis" OpHelp(""),
29551 /* 137 */ "DropTable" OpHelp(""),
29552 /* 138 */ "DropIndex" OpHelp(""),
29553 /* 139 */ "DropTrigger" OpHelp(""),
29554 /* 140 */ "IntegrityCk" OpHelp(""),
29555 /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29556 /* 142 */ "Param" OpHelp(""),
29557 /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29558 /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29559 /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29560 /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29561 /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29562 /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29563 /* 149 */ "Expire" OpHelp(""),
29564 /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29565 /* 151 */ "VBegin" OpHelp(""),
29566 /* 152 */ "VCreate" OpHelp(""),
29567 /* 153 */ "VDestroy" OpHelp(""),
29568 /* 154 */ "VOpen" OpHelp(""),
29569 /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29570 /* 156 */ "VRename" OpHelp(""),
29571 /* 157 */ "Pagecount" OpHelp(""),
29572 /* 158 */ "MaxPgcnt" OpHelp(""),
29573 /* 159 */ "CursorHint" OpHelp(""),
29574 /* 160 */ "Noop" OpHelp(""),
29575 /* 161 */ "Explain" OpHelp(""),
 
 
29576 };
29577 return azName[i];
29578 }
29579 #endif
29580
@@ -37952,46 +37996,84 @@
37952 * be freed immediately and any attempt to access any of that freed
37953 * data will almost certainly result in an immediate access violation.
37954 ******************************************************************************
37955 */
37956 #ifndef SQLITE_WIN32_HEAP_CREATE
37957 # define SQLITE_WIN32_HEAP_CREATE (TRUE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37958 #endif
37959
37960 /*
37961 * This is cache size used in the calculation of the initial size of the
37962 * Win32-specific heap. It cannot be negative.
37963 */
37964 #ifndef SQLITE_WIN32_CACHE_SIZE
37965 # if SQLITE_DEFAULT_CACHE_SIZE>=0
37966 # define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE)
37967 # else
37968 # define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE))
37969 # endif
37970 #endif
37971
 
 
 
 
 
 
 
 
 
 
37972 /*
37973 * The initial size of the Win32-specific heap. This value may be zero.
37974 */
37975 #ifndef SQLITE_WIN32_HEAP_INIT_SIZE
37976 # define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \
37977 (SQLITE_DEFAULT_PAGE_SIZE) + 4194304)
 
37978 #endif
37979
37980 /*
37981 * The maximum size of the Win32-specific heap. This value may be zero.
37982 */
37983 #ifndef SQLITE_WIN32_HEAP_MAX_SIZE
37984 # define SQLITE_WIN32_HEAP_MAX_SIZE (0)
37985 #endif
37986
37987 /*
37988 * The extra flags to use in calls to the Win32 heap APIs. This value may be
37989 * zero for the default behavior.
37990 */
37991 #ifndef SQLITE_WIN32_HEAP_FLAGS
37992 # define SQLITE_WIN32_HEAP_FLAGS (0)
37993 #endif
37994
37995
37996 /*
37997 ** The winMemData structure stores information required by the Win32-specific
@@ -44084,11 +44166,11 @@
44084 ** This routine is for use inside of assert() statements only. For
44085 ** example:
44086 **
44087 ** assert( sqlite3PcachePageSanity(pPg) );
44088 */
44089 #if SQLITE_DEBUG
44090 SQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){
44091 PCache *pCache;
44092 assert( pPg!=0 );
44093 assert( pPg->pgno>0 || pPg->pPager==0 ); /* Page number is 1 or more */
44094 pCache = pPg->pCache;
@@ -60177,21 +60259,22 @@
60177 }
60178 #endif
60179
60180
60181 /*
60182 ** Defragment the page given. All Cells are moved to the
60183 ** end of the page and all free space is collected into one
60184 ** big FreeBlk that occurs in between the header and cell
60185 ** pointer array and the cell content area.
 
60186 **
60187 ** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a
60188 ** b-tree page so that there are no freeblocks or fragment bytes, all
60189 ** unused bytes are contained in the unallocated space region, and all
60190 ** cells are packed tightly at the end of the page.
60191 */
60192 static int defragmentPage(MemPage *pPage){
60193 int i; /* Loop counter */
60194 int pc; /* Address of the i-th cell */
60195 int hdr; /* Offset to the page header */
60196 int size; /* Size of a cell */
60197 int usableSize; /* Number of usable bytes on a page */
@@ -60202,11 +60285,10 @@
60202 unsigned char *temp; /* Temp area for cell content */
60203 unsigned char *src; /* Source of content */
60204 int iCellFirst; /* First allowable cell index */
60205 int iCellLast; /* Last possible cell index */
60206
60207
60208 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
60209 assert( pPage->pBt!=0 );
60210 assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
60211 assert( pPage->nOverflow==0 );
60212 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
@@ -60214,13 +60296,60 @@
60214 src = data = pPage->aData;
60215 hdr = pPage->hdrOffset;
60216 cellOffset = pPage->cellOffset;
60217 nCell = pPage->nCell;
60218 assert( nCell==get2byte(&data[hdr+3]) );
 
60219 usableSize = pPage->pBt->usableSize;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60220 cbrk = usableSize;
60221 iCellFirst = cellOffset + 2*nCell;
60222 iCellLast = usableSize - 4;
60223 for(i=0; i<nCell; i++){
60224 u8 *pAddr; /* The i-th cell pointer */
60225 pAddr = &data[cellOffset + i*2];
60226 pc = get2byte(pAddr);
@@ -60250,20 +60379,22 @@
60250 memcpy(&temp[x], &data[x], (cbrk+size) - x);
60251 src = temp;
60252 }
60253 memcpy(&data[cbrk], &src[pc], size);
60254 }
 
 
 
 
 
 
60255 assert( cbrk>=iCellFirst );
60256 put2byte(&data[hdr+5], cbrk);
60257 data[hdr+1] = 0;
60258 data[hdr+2] = 0;
60259 data[hdr+7] = 0;
60260 memset(&data[iCellFirst], 0, cbrk-iCellFirst);
60261 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
60262 if( cbrk-iCellFirst!=pPage->nFree ){
60263 return SQLITE_CORRUPT_BKPT;
60264 }
60265 return SQLITE_OK;
60266 }
60267
60268 /*
60269 ** Search the free-list on page pPg for space to store a cell nByte bytes in
@@ -60397,14 +60528,14 @@
60397 ** to see if defragmentation is necessary.
60398 */
60399 testcase( gap+2+nByte==top );
60400 if( gap+2+nByte>top ){
60401 assert( pPage->nCell>0 || CORRUPT_DB );
60402 rc = defragmentPage(pPage);
60403 if( rc ) return rc;
60404 top = get2byteNotZero(&data[hdr+5]);
60405 assert( gap+nByte<=top );
60406 }
60407
60408
60409 /* Allocate memory from the gap in between the cell pointer array
60410 ** and the cell content area. The btreeInitPage() call has already
@@ -63636,11 +63767,11 @@
63636 pCur->aiIdx[pCur->iPage] = 0;
63637 return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage],
63638 pCur, pCur->curPagerFlags);
63639 }
63640
63641 #if SQLITE_DEBUG
63642 /*
63643 ** Page pParent is an internal (non-leaf) tree page. This function
63644 ** asserts that page number iChild is the left-child if the iIdx'th
63645 ** cell in page pParent. Or, if iIdx is equal to the total number of
63646 ** cells in pParent, that page number iChild is the right-child of
@@ -64178,10 +64309,34 @@
64178 ** have been deleted? This API will need to change to return an error code
64179 ** as well as the boolean result value.
64180 */
64181 return (CURSOR_VALID!=pCur->eState);
64182 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64183
64184 /*
64185 ** Advance the cursor to the next entry in the database. If
64186 ** successful then set *pRes=0. If the cursor
64187 ** was already pointing to the last entry in the database before
@@ -65023,11 +65178,11 @@
65023 ** pPrior Where to write the pgno of the first overflow page
65024 **
65025 ** Use a call to btreeParseCellPtr() to verify that the values above
65026 ** were computed correctly.
65027 */
65028 #if SQLITE_DEBUG
65029 {
65030 CellInfo info;
65031 pPage->xParseCell(pPage, pCell, &info);
65032 assert( nHeader==(int)(info.pPayload - pCell) );
65033 assert( info.nKey==pX->nKey );
@@ -66549,11 +66704,11 @@
66549 ** copied into the parent, because if the parent is page 1 then it will
66550 ** by smaller than the child due to the database header, and so all the
66551 ** free space needs to be up front.
66552 */
66553 assert( nNew==1 || CORRUPT_DB );
66554 rc = defragmentPage(apNew[0]);
66555 testcase( rc!=SQLITE_OK );
66556 assert( apNew[0]->nFree ==
66557 (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)
66558 || rc!=SQLITE_OK
66559 );
@@ -71201,10 +71356,11 @@
71201 ** Remember the SQL string for a prepared statement.
71202 */
71203 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
71204 assert( isPrepareV2==1 || isPrepareV2==0 );
71205 if( p==0 ) return;
 
71206 #if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
71207 if( !isPrepareV2 ) return;
71208 #endif
71209 assert( p->zSql==0 );
71210 p->zSql = sqlite3DbStrNDup(p->db, z, n);
@@ -71229,10 +71385,11 @@
71229 pB->pPrev = pTmp;
71230 zTmp = pA->zSql;
71231 pA->zSql = pB->zSql;
71232 pB->zSql = zTmp;
71233 pB->isPrepareV2 = pA->isPrepareV2;
 
71234 }
71235
71236 /*
71237 ** Resize the Vdbe.aOp array so that it is at least nOp elements larger
71238 ** than its current size. nOp is guaranteed to be less than or equal
@@ -73753,17 +73910,17 @@
73753 ** Then the internal cache might have been left in an inconsistent
73754 ** state. We need to rollback the statement transaction, if there is
73755 ** one, or the complete transaction if there is no statement transaction.
73756 */
73757
 
 
 
73758 if( db->mallocFailed ){
73759 p->rc = SQLITE_NOMEM_BKPT;
73760 }
73761 closeAllCursors(p);
73762 if( p->magic!=VDBE_MAGIC_RUN ){
73763 return SQLITE_OK;
73764 }
73765 checkActiveVdbeCnt(db);
73766
73767 /* No commit or rollback needed if the program never started or if the
73768 ** SQL statement does not read or write a database file. */
73769 if( p->pc>=0 && p->bIsReader ){
@@ -74706,11 +74863,11 @@
74706 }
74707 assert( u<=pKeyInfo->nField + 1 );
74708 p->nField = u;
74709 }
74710
74711 #if SQLITE_DEBUG
74712 /*
74713 ** This function compares two index or table record keys in the same way
74714 ** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(),
74715 ** this function deserializes and compares values using the
74716 ** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used
@@ -74811,11 +74968,11 @@
74811 if( pKeyInfo->db->mallocFailed ) return 1;
74812 return 0;
74813 }
74814 #endif
74815
74816 #if SQLITE_DEBUG
74817 /*
74818 ** Count the number of fields (a.k.a. columns) in the record given by
74819 ** pKey,nKey. The verify that this count is less than or equal to the
74820 ** limit given by pKeyInfo->nField + pKeyInfo->nXField.
74821 **
@@ -75694,12 +75851,12 @@
75694 ** to sqlite3_reoptimize() that re-preparing the statement may result
75695 ** in a better query plan.
75696 */
75697 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
75698 assert( iVar>0 );
75699 if( iVar>32 ){
75700 v->expmask = 0xffffffff;
75701 }else{
75702 v->expmask |= ((u32)1 << (iVar-1));
75703 }
75704 }
75705
@@ -75965,11 +76122,12 @@
75965 sqlite3_mutex_enter(mutex);
75966 for(i=0; i<p->nVar; i++){
75967 sqlite3VdbeMemRelease(&p->aVar[i]);
75968 p->aVar[i].flags = MEM_Null;
75969 }
75970 if( p->isPrepareV2 && p->expmask ){
 
75971 p->expired = 1;
75972 }
75973 sqlite3_mutex_leave(mutex);
75974 return rc;
75975 }
@@ -77069,13 +77227,12 @@
77069 ** parameter in the WHERE clause might influence the choice of query plan
77070 ** for a statement, then the statement will be automatically recompiled,
77071 ** as if there had been a schema change, on the first sqlite3_step() call
77072 ** following any change to the bindings of that parameter.
77073 */
77074 if( p->isPrepareV2 &&
77075 ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff)
77076 ){
77077 p->expired = 1;
77078 }
77079 return SQLITE_OK;
77080 }
77081
@@ -77334,14 +77491,16 @@
77334 Vdbe *pFrom = (Vdbe*)pFromStmt;
77335 Vdbe *pTo = (Vdbe*)pToStmt;
77336 if( pFrom->nVar!=pTo->nVar ){
77337 return SQLITE_ERROR;
77338 }
77339 if( pTo->isPrepareV2 && pTo->expmask ){
 
77340 pTo->expired = 1;
77341 }
77342 if( pFrom->isPrepareV2 && pFrom->expmask ){
 
77343 pFrom->expired = 1;
77344 }
77345 return sqlite3TransferBindings(pFromStmt, pToStmt);
77346 }
77347 #endif
@@ -79658,39 +79817,39 @@
79658 if( pCtx->pOut != pOut ){
79659 pCtx->pOut = pOut;
79660 for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
79661 }
79662
79663 memAboutToChange(p, pCtx->pOut);
79664 #ifdef SQLITE_DEBUG
79665 for(i=0; i<pCtx->argc; i++){
79666 assert( memIsValid(pCtx->argv[i]) );
79667 REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);
79668 }
79669 #endif
79670 MemSetTypeFlag(pCtx->pOut, MEM_Null);
79671 pCtx->fErrorOrAux = 0;
79672 (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */
79673
79674 /* If the function returned an error, throw an exception */
79675 if( pCtx->fErrorOrAux ){
79676 if( pCtx->isError ){
79677 sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut));
79678 rc = pCtx->isError;
79679 }
79680 sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);
79681 if( rc ) goto abort_due_to_error;
79682 }
79683
79684 /* Copy the result of the function into register P3 */
79685 if( pOut->flags & (MEM_Str|MEM_Blob) ){
79686 sqlite3VdbeChangeEncoding(pCtx->pOut, encoding);
79687 if( sqlite3VdbeMemTooBig(pCtx->pOut) ) goto too_big;
79688 }
79689
79690 REGISTER_TRACE(pOp->p3, pCtx->pOut);
79691 UPDATE_MAX_BLOBSIZE(pCtx->pOut);
79692 break;
79693 }
79694
79695 /* Opcode: BitAnd P1 P2 P3 * *
79696 ** Synopsis: r[P3]=r[P1]&r[P2]
@@ -80187,11 +80346,11 @@
80187 pKeyInfo = pOp->p4.pKeyInfo;
80188 assert( n>0 );
80189 assert( pKeyInfo!=0 );
80190 p1 = pOp->p1;
80191 p2 = pOp->p2;
80192 #if SQLITE_DEBUG
80193 if( aPermute ){
80194 int k, mx = 0;
80195 for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];
80196 assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );
80197 assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );
@@ -82836,10 +82995,37 @@
82836 assert( pOp->p2==0 );
82837 }
82838 break;
82839 }
82840
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82841
82842 /* Opcode: SorterSort P1 P2 * * *
82843 **
82844 ** After all records have been inserted into the Sorter object
82845 ** identified by P1, invoke this opcode to actually do the sorting.
@@ -83479,10 +83665,22 @@
83479 rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, flags);
83480 if( rc ) goto abort_due_to_error;
83481 pOut->u.i = pgno;
83482 break;
83483 }
 
 
 
 
 
 
 
 
 
 
 
 
83484
83485 /* Opcode: ParseSchema P1 * * P4 *
83486 **
83487 ** Read and parse all entries from the SQLITE_MASTER table of database P1
83488 ** that match the WHERE clause P4.
@@ -83600,11 +83798,11 @@
83600 **
83601 ** Do an analysis of the currently open database. Store in
83602 ** register P1 the text of an error message describing any problems.
83603 ** If no problems are found, store a NULL in register P1.
83604 **
83605 ** The register P3 contains the maximum number of allowed errors.
83606 ** At most reg(P3) errors will be reported.
83607 ** In other words, the analysis stops as soon as reg(P1) errors are
83608 ** seen. Reg(P1) is updated with the number of errors remaining.
83609 **
83610 ** The root page numbers of all tables in the database are integers
@@ -83633,18 +83831,18 @@
83633 assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
83634 pIn1 = &aMem[pOp->p1];
83635 assert( pOp->p5<db->nDb );
83636 assert( DbMaskTest(p->btreeMask, pOp->p5) );
83637 z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot,
83638 (int)pnErr->u.i, &nErr);
83639 pnErr->u.i -= nErr;
83640 sqlite3VdbeMemSetNull(pIn1);
83641 if( nErr==0 ){
83642 assert( z==0 );
83643 }else if( z==0 ){
83644 goto no_mem;
83645 }else{
 
83646 sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);
83647 }
83648 UPDATE_MAX_BLOBSIZE(pIn1);
83649 sqlite3VdbeChangeEncoding(pIn1, encoding);
83650 break;
@@ -92833,11 +93031,11 @@
92833 int nVal = sqlite3ExprVectorSize(pLeft);
92834 Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
92835 char *zRet;
92836
92837 assert( pExpr->op==TK_IN );
92838 zRet = sqlite3DbMallocZero(pParse->db, nVal+1);
92839 if( zRet ){
92840 int i;
92841 for(i=0; i<nVal; i++){
92842 Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
92843 char a = sqlite3ExprAffinity(pA);
@@ -93738,11 +93936,11 @@
93738 ** Clear all column cache entries.
93739 */
93740 SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
93741 int i;
93742
93743 #if SQLITE_DEBUG
93744 if( pParse->db->flags & SQLITE_VdbeAddopTrace ){
93745 printf("CLEAR\n");
93746 }
93747 #endif
93748 for(i=0; i<pParse->nColCache; i++){
@@ -95145,10 +95343,21 @@
95145 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
95146 if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
95147 }
95148 return 0;
95149 }
 
 
 
 
 
 
 
 
 
 
 
95150
95151 /*
95152 ** Return true if we can prove the pE2 will always be true if pE1 is
95153 ** true. Return false if we cannot complete the proof or if pE2 might
95154 ** be false. Examples:
@@ -96698,10 +96907,11 @@
96698 Stat4Sample current; /* Current row as a Stat4Sample */
96699 u32 iPrn; /* Pseudo-random number used for sampling */
96700 Stat4Sample *aBest; /* Array of nCol best samples */
96701 int iMin; /* Index in a[] of entry with minimum score */
96702 int nSample; /* Current number of samples */
 
96703 int iGet; /* Index of current sample accessed by stat_get() */
96704 Stat4Sample *a; /* Array of mxSample Stat4Sample objects */
96705 sqlite3 *db; /* Database connection, for malloc() */
96706 };
96707
@@ -96962,10 +97172,17 @@
96962 int i;
96963
96964 assert( IsStat4 || nEqZero==0 );
96965
96966 #ifdef SQLITE_ENABLE_STAT4
 
 
 
 
 
 
 
96967 if( pNew->isPSample==0 ){
96968 Stat4Sample *pUpgrade = 0;
96969 assert( pNew->anEq[pNew->iCol]>0 );
96970
96971 /* This sample is being added because the prefix that ends in column
@@ -97059,16 +97276,26 @@
97059 if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){
97060 sampleInsert(p, pBest, i);
97061 }
97062 }
97063
97064 /* Update the anEq[] fields of any samples already collected. */
 
97065 for(i=p->nSample-1; i>=0; i--){
97066 int j;
97067 for(j=iChng; j<p->nCol; j++){
97068 if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];
 
 
 
 
 
 
 
 
97069 }
 
97070 }
97071 #endif
97072
97073 #if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)
97074 if( iChng==0 ){
@@ -97778,44 +98005,32 @@
97778 /* Form 1: Analyze everything */
97779 for(i=0; i<db->nDb; i++){
97780 if( i==1 ) continue; /* Do not analyze the TEMP database */
97781 analyzeDatabase(pParse, i);
97782 }
97783 }else if( pName2->n==0 ){
97784 /* Form 2: Analyze the database or table named */
97785 iDb = sqlite3FindDb(db, pName1);
97786 if( iDb>=0 ){
97787 analyzeDatabase(pParse, iDb);
97788 }else{
97789 z = sqlite3NameFromToken(db, pName1);
97790 if( z ){
97791 if( (pIdx = sqlite3FindIndex(db, z, 0))!=0 ){
97792 analyzeTable(pParse, pIdx->pTable, pIdx);
97793 }else if( (pTab = sqlite3LocateTable(pParse, 0, z, 0))!=0 ){
97794 analyzeTable(pParse, pTab, 0);
97795 }
97796 sqlite3DbFree(db, z);
97797 }
97798 }
97799 }else{
97800 /* Form 3: Analyze the fully qualified table name */
97801 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);
97802 if( iDb>=0 ){
97803 zDb = db->aDb[iDb].zDbSName;
97804 z = sqlite3NameFromToken(db, pTableName);
97805 if( z ){
97806 if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){
97807 analyzeTable(pParse, pIdx->pTable, pIdx);
97808 }else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){
97809 analyzeTable(pParse, pTab, 0);
97810 }
97811 sqlite3DbFree(db, z);
97812 }
97813 }
97814 }
97815 v = sqlite3GetVdbe(pParse);
97816 if( v ) sqlite3VdbeAddOp0(v, OP_Expire);
 
97817 }
97818
97819 /*
97820 ** Used to pass information from the analyzer reader through to the
97821 ** callback routine.
@@ -97940,19 +98155,24 @@
97940 }
97941 aiRowEst = pIndex->aiRowEst;
97942 #endif
97943 pIndex->bUnordered = 0;
97944 decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
97945 if( pIndex->pPartIdxWhere==0 ) pTable->nRowLogEst = pIndex->aiRowLogEst[0];
 
 
 
 
97946 }else{
97947 Index fakeIdx;
97948 fakeIdx.szIdxRow = pTable->szTabRow;
97949 #ifdef SQLITE_ENABLE_COSTMULT
97950 fakeIdx.pTable = pTable;
97951 #endif
97952 decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx);
97953 pTable->szTabRow = fakeIdx.szIdxRow;
 
97954 }
97955
97956 return 0;
97957 }
97958
@@ -98243,19 +98463,24 @@
98243 SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
98244 analysisInfo sInfo;
98245 HashElem *i;
98246 char *zSql;
98247 int rc = SQLITE_OK;
 
98248
98249 assert( iDb>=0 && iDb<db->nDb );
98250 assert( db->aDb[iDb].pBt!=0 );
98251
98252 /* Clear any prior statistics */
98253 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
98254 for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
 
 
 
 
98255 Index *pIdx = sqliteHashData(i);
98256 pIdx->aiRowLogEst[0] = 0;
98257 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
98258 sqlite3DeleteIndexSamples(db, pIdx);
98259 pIdx->aSample = 0;
98260 #endif
98261 }
@@ -98274,23 +98499,23 @@
98274 }
98275 }
98276
98277 /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
98278 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
98279 for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
98280 Index *pIdx = sqliteHashData(i);
98281 if( pIdx->aiRowLogEst[0]==0 ) sqlite3DefaultRowEst(pIdx);
98282 }
98283
98284 /* Load the statistics from the sqlite_stat4 table. */
98285 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
98286 if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
98287 db->lookaside.bDisable++;
98288 rc = loadStat4(db, sInfo.zDatabase);
98289 db->lookaside.bDisable--;
98290 }
98291 for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){
98292 Index *pIdx = sqliteHashData(i);
98293 sqlite3_free(pIdx->aiRowEst);
98294 pIdx->aiRowEst = 0;
98295 }
98296 #endif
@@ -100271,10 +100496,11 @@
100271 SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
100272 Table *p;
100273 p = pParse->pNewTable;
100274 if( p==0 || NEVER(p->nCol<1) ) return;
100275 p->aCol[p->nCol-1].notNull = (u8)onError;
 
100276 }
100277
100278 /*
100279 ** Scan the column type name zType (length nType) and return the
100280 ** associated affinity type.
@@ -102609,10 +102835,13 @@
102609 /* 10, 9, 8, 7, 6 */
102610 LogEst aVal[] = { 33, 32, 30, 28, 26 };
102611 LogEst *a = pIdx->aiRowLogEst;
102612 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
102613 int i;
 
 
 
102614
102615 /* Set the first entry (number of rows in the index) to the estimated
102616 ** number of rows in the table, or half the number of rows in the table
102617 ** for a partial index. But do not let the estimate drop below 10. */
102618 a[0] = pIdx->pTable->nRowLogEst;
@@ -109798,10 +110027,13 @@
109798 VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
109799 }
109800 }
109801 sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
109802 VdbeComment((v, "for %s", pIdx->zName));
 
 
 
109803
109804 /* In an UPDATE operation, if this index is the PRIMARY KEY index
109805 ** of a WITHOUT ROWID table and there has been no change the
109806 ** primary key, then no collision is possible. The collision detection
109807 ** logic below can all be skipped. */
@@ -109953,12 +110185,15 @@
109953
109954 /* Records with omitted columns are only allowed for schema format
109955 ** version 2 and later (SQLite version 3.1.4, 2005-02-20). */
109956 if( pTab->pSchema->file_format<2 ) return;
109957
109958 for(i=pTab->nCol; i>1 && pTab->aCol[i-1].pDflt==0; i--){}
109959 sqlite3VdbeChangeP5(v, i);
 
 
 
109960 }
109961 #endif
109962
109963 /*
109964 ** This routine generates code to finish the INSERT or UPDATE operation
@@ -110244,11 +110479,11 @@
110244 }
110245 if( sqlite3TriggerList(pParse, pDest) ){
110246 return 0; /* tab1 must not have triggers */
110247 }
110248 #ifndef SQLITE_OMIT_VIRTUALTABLE
110249 if( pDest->tabFlags & TF_Virtual ){
110250 return 0; /* tab1 must not be a virtual table */
110251 }
110252 #endif
110253 if( onError==OE_Default ){
110254 if( pDest->iPKey>=0 ) onError = pDest->keyConf;
@@ -110306,11 +110541,11 @@
110306 }
110307 if( HasRowid(pDest)!=HasRowid(pSrc) ){
110308 return 0; /* source and destination must both be WITHOUT ROWID or not */
110309 }
110310 #ifndef SQLITE_OMIT_VIRTUALTABLE
110311 if( pSrc->tabFlags & TF_Virtual ){
110312 return 0; /* tab2 must not be a virtual table */
110313 }
110314 #endif
110315 if( pSrc->pSelect ){
110316 return 0; /* tab2 may not be a view */
@@ -110603,11 +110838,11 @@
110603 /* Invoke the callback function if required */
110604 if( xCallback && (SQLITE_ROW==rc ||
110605 (SQLITE_DONE==rc && !callbackIsInit
110606 && db->flags&SQLITE_NullCallback)) ){
110607 if( !callbackIsInit ){
110608 azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1);
110609 if( azCols==0 ){
110610 goto exec_out;
110611 }
110612 for(i=0; i<nCol; i++){
110613 azCols[i] = (char *)sqlite3_column_name(pStmt, i);
@@ -110624,10 +110859,11 @@
110624 if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){
110625 sqlite3OomFault(db);
110626 goto exec_out;
110627 }
110628 }
 
110629 }
110630 if( xCallback(pArg, nCol, azVals, azCols) ){
110631 /* EVIDENCE-OF: R-38229-40159 If the callback function to
110632 ** sqlite3_exec() returns non-zero, then sqlite3_exec() will
110633 ** return SQLITE_ABORT. */
@@ -112094,15 +112330,15 @@
112094 #define PragTyp_JOURNAL_SIZE_LIMIT 20
112095 #define PragTyp_LOCK_PROXY_FILE 21
112096 #define PragTyp_LOCKING_MODE 22
112097 #define PragTyp_PAGE_COUNT 23
112098 #define PragTyp_MMAP_SIZE 24
112099 #define PragTyp_PAGE_SIZE 25
112100 #define PragTyp_SECURE_DELETE 26
112101 #define PragTyp_SHRINK_MEMORY 27
112102 #define PragTyp_SOFT_HEAP_LIMIT 28
112103 #define PragTyp_STATS 29
112104 #define PragTyp_SYNCHRONOUS 30
112105 #define PragTyp_TABLE_INFO 31
112106 #define PragTyp_TEMP_STORE 32
112107 #define PragTyp_TEMP_STORE_DIRECTORY 33
112108 #define PragTyp_THREADS 34
@@ -112112,10 +112348,11 @@
112112 #define PragTyp_HEXKEY 38
112113 #define PragTyp_KEY 39
112114 #define PragTyp_REKEY 40
112115 #define PragTyp_LOCK_STATUS 41
112116 #define PragTyp_PARSER_TRACE 42
 
112117
112118 /* Property flags associated with various pragma. */
112119 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
112120 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
112121 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -112135,51 +112372,52 @@
112135 /* 2 */ "name",
112136 /* 3 */ "type",
112137 /* 4 */ "notnull",
112138 /* 5 */ "dflt_value",
112139 /* 6 */ "pk",
112140 /* 7 */ "table", /* Used by: stats */
112141 /* 8 */ "index",
112142 /* 9 */ "width",
112143 /* 10 */ "height",
112144 /* 11 */ "seqno", /* Used by: index_info */
112145 /* 12 */ "cid",
112146 /* 13 */ "name",
112147 /* 14 */ "seqno", /* Used by: index_xinfo */
112148 /* 15 */ "cid",
112149 /* 16 */ "name",
112150 /* 17 */ "desc",
112151 /* 18 */ "coll",
112152 /* 19 */ "key",
112153 /* 20 */ "seq", /* Used by: index_list */
112154 /* 21 */ "name",
112155 /* 22 */ "unique",
112156 /* 23 */ "origin",
112157 /* 24 */ "partial",
112158 /* 25 */ "seq", /* Used by: database_list */
112159 /* 26 */ "name",
112160 /* 27 */ "file",
112161 /* 28 */ "seq", /* Used by: collation_list */
112162 /* 29 */ "name",
112163 /* 30 */ "id", /* Used by: foreign_key_list */
112164 /* 31 */ "seq",
112165 /* 32 */ "table",
112166 /* 33 */ "from",
112167 /* 34 */ "to",
112168 /* 35 */ "on_update",
112169 /* 36 */ "on_delete",
112170 /* 37 */ "match",
112171 /* 38 */ "table", /* Used by: foreign_key_check */
112172 /* 39 */ "rowid",
112173 /* 40 */ "parent",
112174 /* 41 */ "fkid",
112175 /* 42 */ "busy", /* Used by: wal_checkpoint */
112176 /* 43 */ "log",
112177 /* 44 */ "checkpointed",
112178 /* 45 */ "timeout", /* Used by: busy_timeout */
112179 /* 46 */ "database", /* Used by: lock_status */
112180 /* 47 */ "status",
 
112181 };
112182
112183 /* Definitions of all built-in pragmas */
112184 typedef struct PragmaName {
112185 const char *const zName; /* Name of pragma */
@@ -112221,11 +112459,11 @@
112221 #endif
112222 #endif
112223 {/* zName: */ "busy_timeout",
112224 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
112225 /* ePragFlg: */ PragFlg_Result0,
112226 /* ColNames: */ 45, 1,
112227 /* iArg: */ 0 },
112228 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112229 {/* zName: */ "cache_size",
112230 /* ePragTyp: */ PragTyp_CACHE_SIZE,
112231 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -112258,11 +112496,11 @@
112258 #endif
112259 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112260 {/* zName: */ "collation_list",
112261 /* ePragTyp: */ PragTyp_COLLATION_LIST,
112262 /* ePragFlg: */ PragFlg_Result0,
112263 /* ColNames: */ 28, 2,
112264 /* iArg: */ 0 },
112265 #endif
112266 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
112267 {/* zName: */ "compile_options",
112268 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -112293,11 +112531,11 @@
112293 #endif
112294 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112295 {/* zName: */ "database_list",
112296 /* ePragTyp: */ PragTyp_DATABASE_LIST,
112297 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
112298 /* ColNames: */ 25, 3,
112299 /* iArg: */ 0 },
112300 #endif
112301 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
112302 {/* zName: */ "default_cache_size",
112303 /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
@@ -112330,18 +112568,18 @@
112330 #endif
112331 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
112332 {/* zName: */ "foreign_key_check",
112333 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
112334 /* ePragFlg: */ PragFlg_NeedSchema,
112335 /* ColNames: */ 38, 4,
112336 /* iArg: */ 0 },
112337 #endif
112338 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
112339 {/* zName: */ "foreign_key_list",
112340 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
112341 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112342 /* ColNames: */ 30, 8,
112343 /* iArg: */ 0 },
112344 #endif
112345 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
112346 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
112347 {/* zName: */ "foreign_keys",
@@ -112400,21 +112638,21 @@
112400 #endif
112401 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112402 {/* zName: */ "index_info",
112403 /* ePragTyp: */ PragTyp_INDEX_INFO,
112404 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112405 /* ColNames: */ 11, 3,
112406 /* iArg: */ 0 },
112407 {/* zName: */ "index_list",
112408 /* ePragTyp: */ PragTyp_INDEX_LIST,
112409 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112410 /* ColNames: */ 20, 5,
112411 /* iArg: */ 0 },
112412 {/* zName: */ "index_xinfo",
112413 /* ePragTyp: */ PragTyp_INDEX_INFO,
112414 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112415 /* ColNames: */ 14, 6,
112416 /* iArg: */ 1 },
112417 #endif
112418 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
112419 {/* zName: */ "integrity_check",
112420 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
@@ -112457,11 +112695,11 @@
112457 #endif
112458 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
112459 {/* zName: */ "lock_status",
112460 /* ePragTyp: */ PragTyp_LOCK_STATUS,
112461 /* ePragFlg: */ PragFlg_Result0,
112462 /* ColNames: */ 46, 2,
112463 /* iArg: */ 0 },
112464 #endif
112465 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112466 {/* zName: */ "locking_mode",
112467 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -112476,10 +112714,17 @@
112476 {/* zName: */ "mmap_size",
112477 /* ePragTyp: */ PragTyp_MMAP_SIZE,
112478 /* ePragFlg: */ 0,
112479 /* ColNames: */ 0, 0,
112480 /* iArg: */ 0 },
 
 
 
 
 
 
 
112481 {/* zName: */ "page_count",
112482 /* ePragTyp: */ PragTyp_PAGE_COUNT,
112483 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
112484 /* ColNames: */ 0, 0,
112485 /* iArg: */ 0 },
@@ -112574,15 +112819,15 @@
112574 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
112575 /* ColNames: */ 0, 0,
112576 /* iArg: */ SQLITE_SqlTrace },
112577 #endif
112578 #endif
112579 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112580 {/* zName: */ "stats",
112581 /* ePragTyp: */ PragTyp_STATS,
112582 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
112583 /* ColNames: */ 7, 4,
112584 /* iArg: */ 0 },
112585 #endif
112586 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112587 {/* zName: */ "synchronous",
112588 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -112657,11 +112902,11 @@
112657 /* ColNames: */ 0, 0,
112658 /* iArg: */ 0 },
112659 {/* zName: */ "wal_checkpoint",
112660 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
112661 /* ePragFlg: */ PragFlg_NeedSchema,
112662 /* ColNames: */ 42, 3,
112663 /* iArg: */ 0 },
112664 #endif
112665 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
112666 {/* zName: */ "writable_schema",
112667 /* ePragTyp: */ PragTyp_FLAG,
@@ -112668,11 +112913,11 @@
112668 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
112669 /* ColNames: */ 0, 0,
112670 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
112671 #endif
112672 };
112673 /* Number of pragmas: 60 on by default, 73 total. */
112674
112675 /************** End of pragma.h **********************************************/
112676 /************** Continuing where we left off in pragma.c *********************/
112677
112678 /*
@@ -112937,10 +113182,26 @@
112937 lwr = mid + 1;
112938 }
112939 }
112940 return lwr>upr ? 0 : &aPragmaName[mid];
112941 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112942
112943 /*
112944 ** Process a pragma statement.
112945 **
112946 ** Pragmas are of this form:
@@ -113741,33 +114002,37 @@
113741 }
113742 }
113743 }
113744 break;
113745
 
113746 case PragTyp_STATS: {
113747 Index *pIdx;
113748 HashElem *i;
113749 pParse->nMem = 4;
113750 sqlite3CodeVerifySchema(pParse, iDb);
113751 for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
113752 Table *pTab = sqliteHashData(i);
113753 sqlite3VdbeMultiLoad(v, 1, "ssii",
113754 pTab->zName,
113755 0,
113756 pTab->szTabRow,
113757 pTab->nRowLogEst);
113758 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
 
113759 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
113760 sqlite3VdbeMultiLoad(v, 2, "sii",
113761 pIdx->zName,
113762 pIdx->szIdxRow,
113763 pIdx->aiRowLogEst[0]);
113764 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
 
113765 }
113766 }
113767 }
113768 break;
 
113769
113770 case PragTyp_INDEX_INFO: if( zRight ){
113771 Index *pIdx;
113772 Table *pTab;
113773 pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -114020,13 +114285,21 @@
114020 #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX
114021 # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100
114022 #endif
114023
114024 #ifndef SQLITE_OMIT_INTEGRITY_CHECK
114025 /* Pragma "quick_check" is reduced version of
 
 
 
 
 
 
 
114026 ** integrity_check designed to detect most database corruption
114027 ** without most of the overhead of a full integrity-check.
 
114028 */
114029 case PragTyp_INTEGRITY_CHECK: {
114030 int i, j, addr, mxErr;
114031
114032 int isQuick = (sqlite3Tolower(zLeft[0])=='q');
@@ -114053,11 +114326,11 @@
114053 sqlite3GetInt32(zRight, &mxErr);
114054 if( mxErr<=0 ){
114055 mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
114056 }
114057 }
114058 sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1); /* reg[1] holds errors left */
114059
114060 /* Do an integrity check on each database file */
114061 for(i=0; i<db->nDb; i++){
114062 HashElem *x;
114063 Hash *pTbls;
@@ -114068,14 +114341,10 @@
114068
114069 if( OMIT_TEMPDB && i==1 ) continue;
114070 if( iDb>=0 && i!=iDb ) continue;
114071
114072 sqlite3CodeVerifySchema(pParse, i);
114073 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */
114074 VdbeCoverage(v);
114075 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
114076 sqlite3VdbeJumpHere(v, addr);
114077
114078 /* Do an integrity check of the B-Tree
114079 **
114080 ** Begin by finding the root pages numbers
114081 ** for all tables and indices in the database.
@@ -114111,29 +114380,30 @@
114111 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
114112 sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
114113 P4_DYNAMIC);
114114 sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1);
114115 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2);
114116 sqlite3VdbeAddOp2(v, OP_ResultRow, 2, 1);
114117 sqlite3VdbeJumpHere(v, addr);
114118
114119 /* Make sure all the indices are constructed correctly.
114120 */
114121 for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){
114122 Table *pTab = sqliteHashData(x);
114123 Index *pIdx, *pPk;
114124 Index *pPrior = 0;
114125 int loopTop;
114126 int iDataCur, iIdxCur;
114127 int r1 = -1;
114128
114129 if( pTab->pIndex==0 ) continue;
 
 
 
 
 
114130 pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
114131 addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */
114132 VdbeCoverage(v);
114133 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
114134 sqlite3VdbeJumpHere(v, addr);
114135 sqlite3ExprCacheClear(pParse);
114136 sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,
114137 1, 0, &iDataCur, &iIdxCur);
114138 sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
114139 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
@@ -114144,28 +114414,46 @@
114144 sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
114145 loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
114146 /* Verify that all NOT NULL columns really are NOT NULL */
114147 for(j=0; j<pTab->nCol; j++){
114148 char *zErr;
114149 int jmp2, jmp3;
114150 if( j==pTab->iPKey ) continue;
114151 if( pTab->aCol[j].notNull==0 ) continue;
114152 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
114153 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
114154 jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
114155 sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
114156 zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
114157 pTab->aCol[j].zName);
114158 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
114159 sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);
114160 jmp3 = sqlite3VdbeAddOp1(v, OP_IfPos, 1); VdbeCoverage(v);
114161 sqlite3VdbeAddOp0(v, OP_Halt);
114162 sqlite3VdbeJumpHere(v, jmp2);
114163 sqlite3VdbeJumpHere(v, jmp3);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114164 }
114165 /* Validate index entries for the current row */
114166 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
114167 int jmp2, jmp3, jmp4, jmp5;
114168 int ckUniq = sqlite3VdbeMakeLabel(v);
114169 if( pPk==pIdx ) continue;
114170 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
114171 pPrior, r1);
@@ -114172,20 +114460,17 @@
114172 pPrior = pIdx;
114173 sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */
114174 /* Verify that an index entry exists for the current table row */
114175 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
114176 pIdx->nColumn); VdbeCoverage(v);
114177 sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
114178 sqlite3VdbeLoadString(v, 3, "row ");
114179 sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
114180 sqlite3VdbeLoadString(v, 4, " missing from index ");
114181 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
114182 jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
114183 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
114184 sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1);
114185 jmp4 = sqlite3VdbeAddOp1(v, OP_IfPos, 1); VdbeCoverage(v);
114186 sqlite3VdbeAddOp0(v, OP_Halt);
114187 sqlite3VdbeJumpHere(v, jmp2);
114188 /* For UNIQUE indexes, verify that only one entry exists with the
114189 ** current key. The entry is unique if (1) any column is NULL
114190 ** or (2) the next entry has a different key */
114191 if( IsUniqueIndex(pIdx) ){
@@ -114202,11 +114487,10 @@
114202 jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);
114203 sqlite3VdbeGoto(v, uniqOk);
114204 sqlite3VdbeJumpHere(v, jmp6);
114205 sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,
114206 pIdx->nKeyCol); VdbeCoverage(v);
114207 sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */
114208 sqlite3VdbeLoadString(v, 3, "non-unique entry in index ");
114209 sqlite3VdbeGoto(v, jmp5);
114210 sqlite3VdbeResolveLabel(v, uniqOk);
114211 }
114212 sqlite3VdbeJumpHere(v, jmp4);
@@ -114213,40 +114497,39 @@
114213 sqlite3ResolvePartIdxLabel(pParse, jmp3);
114214 }
114215 sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
114216 sqlite3VdbeJumpHere(v, loopTop-1);
114217 #ifndef SQLITE_OMIT_BTREECOUNT
114218 sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
114219 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
114220 if( pPk==pIdx ) continue;
114221 addr = sqlite3VdbeCurrentAddr(v);
114222 sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2); VdbeCoverage(v);
114223 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
114224 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
114225 sqlite3VdbeAddOp3(v, OP_Eq, 8+j, addr+8, 3); VdbeCoverage(v);
114226 sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
114227 sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1);
114228 sqlite3VdbeLoadString(v, 3, pIdx->zName);
114229 sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
114230 sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1);
114231 }
114232 #endif /* SQLITE_OMIT_BTREECOUNT */
114233 }
114234 }
114235 {
114236 static const int iLn = VDBE_OFFSET_LINENO(2);
114237 static const VdbeOpList endCode[] = {
114238 { OP_AddImm, 1, 0, 0}, /* 0 */
114239 { OP_If, 1, 4, 0}, /* 1 */
114240 { OP_String8, 0, 3, 0}, /* 2 */
114241 { OP_ResultRow, 3, 1, 0}, /* 3 */
114242 };
114243 VdbeOp *aOp;
114244
114245 aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn);
114246 if( aOp ){
114247 aOp[0].p2 = -mxErr;
114248 aOp[2].p4type = P4_STATIC;
114249 aOp[2].p4.z = "ok";
114250 }
114251 }
114252 }
@@ -114466,10 +114749,122 @@
114466 */
114467 case PragTyp_SHRINK_MEMORY: {
114468 sqlite3_db_release_memory(db);
114469 break;
114470 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114471
114472 /*
114473 ** PRAGMA busy_timeout
114474 ** PRAGMA busy_timeout = N
114475 **
@@ -123782,12 +124177,29 @@
123782 ** transient would cause the database file to appear to be deleted
123783 ** following reboot.
123784 */
123785 SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){
123786 Vdbe *v = sqlite3GetVdbe(pParse);
123787 int iDb = pNm ? sqlite3TwoPartName(pParse, pNm, pNm, &pNm) : 0;
123788 if( v && (iDb>=2 || iDb==0) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123789 sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);
123790 sqlite3VdbeUsesBtree(v, iDb);
123791 }
123792 return;
123793 }
@@ -124377,12 +124789,11 @@
124377
124378 db = pParse->db;
124379 iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
124380 assert( iDb>=0 );
124381
124382 pTable->tabFlags |= TF_Virtual;
124383 pTable->nModuleArg = 0;
124384 addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
124385 addModuleArgument(db, pTable, 0);
124386 addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
124387 assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)
124388 || (pParse->sNameToken.z==pName1->z && pName2->z==0)
@@ -124666,11 +125077,11 @@
124666 const char *zMod;
124667 Module *pMod;
124668 int rc;
124669
124670 assert( pTab );
124671 if( (pTab->tabFlags & TF_Virtual)==0 || sqlite3GetVTable(db, pTab) ){
124672 return SQLITE_OK;
124673 }
124674
124675 /* Locate the required virtual table module */
124676 zMod = pTab->azModuleArg[0];
@@ -124736,11 +125147,11 @@
124736 Table *pTab;
124737 Module *pMod;
124738 const char *zMod;
124739
124740 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
124741 assert( pTab && (pTab->tabFlags & TF_Virtual)!=0 && !pTab->pVTable );
124742
124743 /* Locate the required virtual table module */
124744 zMod = pTab->azModuleArg[0];
124745 pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);
124746
@@ -124790,11 +125201,11 @@
124790 sqlite3Error(db, SQLITE_MISUSE);
124791 sqlite3_mutex_leave(db->mutex);
124792 return SQLITE_MISUSE_BKPT;
124793 }
124794 pTab = pCtx->pTab;
124795 assert( (pTab->tabFlags & TF_Virtual)!=0 );
124796
124797 pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
124798 if( pParse==0 ){
124799 rc = SQLITE_NOMEM_BKPT;
124800 }else{
@@ -124804,11 +125215,11 @@
124804
124805 if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr)
124806 && pParse->pNewTable
124807 && !db->mallocFailed
124808 && !pParse->pNewTable->pSelect
124809 && (pParse->pNewTable->tabFlags & TF_Virtual)==0
124810 ){
124811 if( !pTab->aCol ){
124812 Table *pNew = pParse->pNewTable;
124813 Index *pIdx;
124814 pTab->aCol = pNew->aCol;
@@ -125093,11 +125504,11 @@
125093 /* Check to see the left operand is a column in a virtual table */
125094 if( NEVER(pExpr==0) ) return pDef;
125095 if( pExpr->op!=TK_COLUMN ) return pDef;
125096 pTab = pExpr->pTab;
125097 if( NEVER(pTab==0) ) return pDef;
125098 if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef;
125099 pVtab = sqlite3GetVTable(db, pTab)->pVtab;
125100 assert( pVtab!=0 );
125101 assert( pVtab->pModule!=0 );
125102 pMod = (sqlite3_module *)pVtab->pModule;
125103 if( pMod->xFindFunction==0 ) return pDef;
@@ -125188,12 +125599,11 @@
125188 return 0;
125189 }
125190 pMod->pEpoTab = pTab;
125191 pTab->nTabRef = 1;
125192 pTab->pSchema = db->aDb[0].pSchema;
125193 pTab->tabFlags |= TF_Virtual;
125194 pTab->nModuleArg = 0;
125195 pTab->iPKey = -1;
125196 addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
125197 addModuleArgument(db, pTab, 0);
125198 addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
125199 rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
@@ -125260,11 +125670,11 @@
125260 case SQLITE_VTAB_CONSTRAINT_SUPPORT: {
125261 VtabCtx *p = db->pVtabCtx;
125262 if( !p ){
125263 rc = SQLITE_MISUSE_BKPT;
125264 }else{
125265 assert( p->pTab==0 || (p->pTab->tabFlags & TF_Virtual)!=0 );
125266 p->pVTable->bConstraint = (u8)va_arg(ap, int);
125267 }
125268 break;
125269 }
125270 default:
@@ -125699,12 +126109,17 @@
125699 WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
125700 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
125701 UnpackedRecord *pRec; /* Probe for stat4 (if required) */
125702 int nRecValid; /* Number of valid fields currently in pRec */
125703 #endif
 
125704 };
125705
 
 
 
 
125706 /*
125707 ** The WHERE clause processing routine has two halves. The
125708 ** first part does the start of the WHERE loop and the second
125709 ** half does the tail of the WHERE loop. An instance of
125710 ** this structure is returned by the first half and passed
@@ -125715,11 +126130,11 @@
125715 */
125716 struct WhereInfo {
125717 Parse *pParse; /* Parsing and code generating context */
125718 SrcList *pTabList; /* List of tables in the join */
125719 ExprList *pOrderBy; /* The ORDER BY clause or NULL */
125720 ExprList *pDistinctSet; /* DISTINCT over all these values */
125721 LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */
125722 int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
125723 int iContinue; /* Jump here to continue with next record */
125724 int iBreak; /* Jump here to break out of the loop */
125725 int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
@@ -126899,10 +127314,11 @@
126899 Parse *pParse; /* Parsing context */
126900 sqlite3 *db; /* Database connection */
126901 Vdbe *v; /* The prepared stmt under constructions */
126902 struct SrcList_item *pTabItem; /* FROM clause term being coded */
126903 int addrBrk; /* Jump here to break out of the loop */
 
126904 int addrCont; /* Jump here to continue with next cycle */
126905 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
126906 int iReleaseReg = 0; /* Temp register to free before returning */
126907
126908 pParse = pWInfo->pParse;
@@ -126939,10 +127355,15 @@
126939 if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
126940 pLevel->iLeftJoin = ++pParse->nMem;
126941 sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
126942 VdbeComment((v, "init LEFT JOIN no-match flag"));
126943 }
 
 
 
 
 
126944
126945 /* Special case of a FROM clause subquery implemented as a co-routine */
126946 if( pTabItem->fg.viaCoroutine ){
126947 int regYield = pTabItem->regReturn;
126948 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
@@ -127124,11 +127545,11 @@
127124 VdbeCoverageIf(v, pX->op==TK_LT);
127125 VdbeCoverageIf(v, pX->op==TK_GE);
127126 sqlite3ExprCacheAffinityChange(pParse, r1, 1);
127127 sqlite3ReleaseTempReg(pParse, rTemp);
127128 }else{
127129 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk);
127130 VdbeCoverageIf(v, bRev==0);
127131 VdbeCoverageIf(v, bRev!=0);
127132 }
127133 if( pEnd ){
127134 Expr *pX;
@@ -127770,11 +128191,11 @@
127770 pLevel->op = OP_Noop;
127771 }else{
127772 codeCursorHint(pTabItem, pWInfo, pLevel, 0);
127773 pLevel->op = aStep[bRev];
127774 pLevel->p1 = iCur;
127775 pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk);
127776 VdbeCoverageIf(v, bRev==0);
127777 VdbeCoverageIf(v, bRev!=0);
127778 pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
127779 }
127780 }
@@ -128095,19 +128516,10 @@
128095 #ifdef SQLITE_EBCDIC
128096 if( *pnoCase ) return 0;
128097 #endif
128098 pList = pExpr->x.pList;
128099 pLeft = pList->a[1].pExpr;
128100 if( pLeft->op!=TK_COLUMN
128101 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
128102 || IsVirtual(pLeft->pTab) /* Value might be numeric */
128103 ){
128104 /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
128105 ** be the name of an indexed column with TEXT affinity. */
128106 return 0;
128107 }
128108 assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
128109
128110 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
128111 op = pRight->op;
128112 if( op==TK_VARIABLE ){
128113 Vdbe *pReprepare = pParse->pReprepare;
@@ -128120,10 +128532,27 @@
128120 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
128121 }else if( op==TK_STRING ){
128122 z = pRight->u.zToken;
128123 }
128124 if( z ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128125 cnt = 0;
128126 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
128127 cnt++;
128128 }
128129 if( cnt!=0 && 255!=(u8)z[cnt-1] ){
@@ -128748,11 +129177,11 @@
128748 iCur = pFrom->a[i].iCursor;
128749 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
128750 if( pIdx->aColExpr==0 ) continue;
128751 for(i=0; i<pIdx->nKeyCol; i++){
128752 if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
128753 if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
128754 *piCur = iCur;
128755 *piColumn = XN_EXPR;
128756 return 1;
128757 }
128758 }
@@ -129539,11 +129968,12 @@
129539 do{
129540 for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
129541 if( pTerm->leftCursor==iCur
129542 && pTerm->u.leftColumn==iColumn
129543 && (iColumn!=XN_EXPR
129544 || sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0)
 
129545 && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
129546 ){
129547 if( (pTerm->eOperator & WO_EQUIV)!=0
129548 && pScan->nEquiv<ArraySize(pScan->aiCur)
129549 && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
@@ -131716,10 +132146,15 @@
131716 testcase( eOp & WO_IS );
131717 testcase( eOp & WO_ISNULL );
131718 continue;
131719 }
131720
 
 
 
 
 
131721 pNew->wsFlags = saved_wsFlags;
131722 pNew->u.btree.nEq = saved_nEq;
131723 pNew->u.btree.nBtm = saved_nBtm;
131724 pNew->u.btree.nTop = saved_nTop;
131725 pNew->nLTerm = saved_nLTerm;
@@ -132263,11 +132698,19 @@
132263 pNew->nOut = rSize;
132264 if( rc ) break;
132265 }
132266 }
132267
 
132268 rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
 
 
 
 
 
 
 
132269 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
132270 sqlite3Stat4ProbeFree(pBuilder->pRec);
132271 pBuilder->nRecValid = 0;
132272 pBuilder->pRec = 0;
132273 #endif
@@ -133443,13 +133886,13 @@
133443 && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
133444 && pWInfo->eDistinct==WHERE_DISTINCT_NOOP
133445 && nRowEst
133446 ){
133447 Bitmask notUsed;
133448 int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pDistinctSet, pFrom,
133449 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
133450 if( rc==pWInfo->pDistinctSet->nExpr ){
133451 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
133452 }
133453 }
133454 if( pWInfo->pOrderBy ){
133455 if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
@@ -133682,11 +134125,11 @@
133682 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
133683 Parse *pParse, /* The parser context */
133684 SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
133685 Expr *pWhere, /* The WHERE clause */
133686 ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
133687 ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */
133688 u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
133689 int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
133690 ** If WHERE_USE_LIMIT, then the limit amount */
133691 ){
133692 int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
@@ -133758,11 +134201,11 @@
133758 goto whereBeginError;
133759 }
133760 pWInfo->pParse = pParse;
133761 pWInfo->pTabList = pTabList;
133762 pWInfo->pOrderBy = pOrderBy;
133763 pWInfo->pDistinctSet = pDistinctSet;
133764 pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
133765 pWInfo->nLevel = nTabList;
133766 pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);
133767 pWInfo->wctrlFlags = wctrlFlags;
133768 pWInfo->iLimit = iAuxArg;
@@ -133836,17 +134279,17 @@
133836 /* Analyze all of the subexpressions. */
133837 sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
133838 if( db->mallocFailed ) goto whereBeginError;
133839
133840 if( wctrlFlags & WHERE_WANT_DISTINCT ){
133841 if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pDistinctSet) ){
133842 /* The DISTINCT marking is pointless. Ignore it. */
133843 pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
133844 }else if( pOrderBy==0 ){
133845 /* Try to ORDER BY the result set to make distinct processing easier */
133846 pWInfo->wctrlFlags |= WHERE_DISTINCTBY;
133847 pWInfo->pOrderBy = pDistinctSet;
133848 }
133849 }
133850
133851 /* Construct the WhereLoop objects */
133852 #if defined(WHERETRACE_ENABLED)
@@ -133918,14 +134361,14 @@
133918 }
133919 }
133920 #endif
133921 /* Attempt to omit tables from the join that do not effect the result */
133922 if( pWInfo->nLevel>=2
133923 && pDistinctSet!=0
133924 && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
133925 ){
133926 Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pDistinctSet);
133927 if( sWLB.pOrderBy ){
133928 tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
133929 }
133930 while( pWInfo->nLevel>=2 ){
133931 WhereTerm *pTerm, *pEnd;
@@ -134704,166 +135147,166 @@
134704 **
134705 *********** Begin parsing tables **********************************************/
134706 #define YY_ACTTAB_COUNT (1567)
134707 static const YYACTIONTYPE yy_action[] = {
134708 /* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100,
134709 /* 10 */ 90, 842, 842, 854, 857, 846, 846, 97, 97, 98,
134710 /* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95,
134711 /* 30 */ 94, 94, 94, 93, 351, 325, 977, 977, 824, 824,
134712 /* 40 */ 826, 947, 354, 99, 100, 90, 842, 842, 854, 857,
134713 /* 50 */ 846, 846, 97, 97, 98, 98, 98, 98, 338, 96,
134714 /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
134715 /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 977, 977,
134716 /* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100,
134717 /* 90 */ 90, 842, 842, 854, 857, 846, 846, 97, 97, 98,
134718 /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95,
134719 /* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325,
134720 /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90,
134721 /* 130 */ 842, 842, 854, 857, 846, 846, 97, 97, 98, 98,
134722 /* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94,
134723 /* 150 */ 94, 94, 93, 351, 958, 958, 325, 268, 428, 413,
134724 /* 160 */ 411, 61, 752, 752, 99, 100, 90, 842, 842, 854,
134725 /* 170 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 60,
134726 /* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134727 /* 190 */ 351, 325, 270, 329, 273, 277, 959, 960, 250, 99,
134728 /* 200 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
134729 /* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95,
134730 /* 220 */ 95, 94, 94, 94, 93, 351, 325, 938, 1326, 698,
134731 /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 842, 842, 854,
134732 /* 240 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 347,
134733 /* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134734 /* 260 */ 351, 325, 938, 1327, 384, 699, 1327, 381, 379, 99,
134735 /* 270 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
134736 /* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95,
134737 /* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178,
134738 /* 300 */ 833, 936, 373, 700, 99, 100, 90, 842, 842, 854,
134739 /* 310 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 375,
134740 /* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134741 /* 330 */ 351, 325, 1276, 947, 354, 818, 936, 739, 739, 99,
134742 /* 340 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
134743 /* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95,
134744 /* 360 */ 95, 94, 94, 94, 93, 351, 325, 969, 227, 92,
134745 /* 370 */ 89, 178, 373, 300, 99, 100, 90, 842, 842, 854,
134746 /* 380 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 921,
134747 /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134748 /* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99,
134749 /* 410 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97,
134750 /* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95,
134751 /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 958,
134752 /* 440 */ 958, 158, 25, 422, 99, 100, 90, 842, 842, 854,
134753 /* 450 */ 857, 846, 846, 97, 97, 98, 98, 98, 98, 450,
134754 /* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134755 /* 470 */ 351, 443, 224, 224, 420, 958, 958, 962, 325, 52,
134756 /* 480 */ 52, 959, 960, 176, 415, 78, 99, 100, 90, 842,
134757 /* 490 */ 842, 854, 857, 846, 846, 97, 97, 98, 98, 98,
134758 /* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94,
134759 /* 510 */ 94, 93, 351, 325, 428, 418, 298, 959, 960, 962,
134760 /* 520 */ 81, 99, 88, 90, 842, 842, 854, 857, 846, 846,
134761 /* 530 */ 97, 97, 98, 98, 98, 98, 717, 96, 96, 96,
134762 /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 843,
134763 /* 550 */ 843, 855, 858, 996, 318, 343, 379, 100, 90, 842,
134764 /* 560 */ 842, 854, 857, 846, 846, 97, 97, 98, 98, 98,
134765 /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94,
134766 /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340,
134767 /* 590 */ 929, 52, 52, 90, 842, 842, 854, 857, 846, 846,
134768 /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96,
134769 /* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445,
134770 /* 620 */ 847, 3, 1203, 361, 360, 378, 344, 813, 958, 958,
134771 /* 630 */ 1300, 86, 445, 729, 3, 212, 169, 287, 405, 282,
134772 /* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245,
134773 /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83,
134774 /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246,
134775 /* 670 */ 959, 960, 194, 455, 670, 402, 399, 398, 448, 243,
134776 /* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224,
134777 /* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427,
134778 /* 700 */ 819, 415, 734, 713, 132, 52, 52, 832, 268, 452,
134779 /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1271,
134780 /* 720 */ 1271, 23, 958, 958, 86, 445, 397, 3, 228, 429,
134781 /* 730 */ 895, 824, 824, 826, 827, 19, 203, 720, 52, 52,
134782 /* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229,
134783 /* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85,
134784 /* 760 */ 352, 352, 120, 157, 959, 960, 58, 977, 409, 355,
134785 /* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86,
134786 /* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96,
134787 /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
134788 /* 800 */ 832, 120, 452, 451, 813, 887, 819, 83, 84, 977,
134789 /* 810 */ 813, 132, 410, 920, 85, 352, 352, 132, 407, 789,
134790 /* 820 */ 958, 958, 92, 89, 178, 917, 448, 262, 370, 261,
134791 /* 830 */ 82, 914, 80, 262, 370, 261, 776, 824, 824, 826,
134792 /* 840 */ 827, 19, 934, 434, 96, 96, 96, 96, 95, 95,
134793 /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 958,
134794 /* 860 */ 958, 819, 959, 960, 120, 92, 89, 178, 945, 2,
134795 /* 870 */ 918, 965, 268, 1, 976, 76, 445, 762, 3, 708,
134796 /* 880 */ 901, 901, 387, 958, 958, 757, 919, 371, 740, 778,
134797 /* 890 */ 756, 257, 824, 824, 826, 827, 19, 417, 741, 450,
134798 /* 900 */ 24, 959, 960, 83, 84, 369, 958, 958, 177, 226,
134799 /* 910 */ 85, 352, 352, 885, 315, 314, 313, 215, 311, 10,
134800 /* 920 */ 10, 683, 448, 349, 348, 959, 960, 909, 777, 157,
134801 /* 930 */ 120, 958, 958, 337, 776, 416, 711, 310, 450, 434,
134802 /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 959, 960,
134803 /* 950 */ 908, 832, 792, 452, 451, 9, 9, 819, 10, 10,
134804 /* 960 */ 52, 52, 51, 51, 180, 716, 248, 10, 10, 171,
134805 /* 970 */ 170, 167, 339, 959, 960, 247, 984, 702, 702, 450,
134806 /* 980 */ 715, 233, 686, 982, 889, 983, 182, 914, 824, 824,
134807 /* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10,
134808 /* 1000 */ 10, 889, 891, 749, 958, 958, 917, 268, 985, 198,
134809 /* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825,
134810 /* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91,
134811 /* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
134812 /* 1040 */ 351, 157, 810, 371, 382, 359, 959, 960, 358, 268,
134813 /* 1050 */ 450, 918, 368, 324, 824, 824, 826, 450, 709, 450,
134814 /* 1060 */ 264, 380, 889, 450, 877, 746, 253, 919, 255, 433,
134815 /* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12,
134816 /* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162,
134817 /* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450,
134818 /* 1100 */ 709, 1210, 450, 132, 450, 39, 39, 450, 40, 40,
134819 /* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28,
134820 /* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450,
134821 /* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767,
134822 /* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47,
134823 /* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172,
134824 /* 1160 */ 49, 49, 450, 50, 50, 34, 34, 274, 122, 122,
134825 /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 898, 56, 56,
134826 /* 1180 */ 450, 897, 35, 35, 450, 267, 450, 817, 450, 817,
134827 /* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817,
134828 /* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119,
134829 /* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111,
134830 /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 912,
134831 /* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331,
134832 /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 937, 197,
134833 /* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436,
134834 /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 933,
134835 /* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202,
134836 /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 884,
134837 /* 1290 */ 120, 120, 120, 120, 120, 754, 278, 828, 77, 74,
134838 /* 1300 */ 726, 727, 785, 783, 880, 202, 999, 208, 894, 893,
134839 /* 1310 */ 894, 893, 694, 816, 763, 116, 774, 1290, 431, 432,
134840 /* 1320 */ 302, 999, 390, 303, 823, 697, 691, 680, 159, 289,
134841 /* 1330 */ 679, 884, 681, 952, 291, 218, 293, 7, 316, 828,
134842 /* 1340 */ 173, 805, 259, 364, 252, 911, 376, 713, 295, 435,
134843 /* 1350 */ 308, 168, 955, 993, 135, 400, 990, 284, 882, 881,
134844 /* 1360 */ 205, 928, 926, 59, 333, 62, 144, 156, 130, 72,
134845 /* 1370 */ 802, 366, 367, 393, 137, 185, 189, 160, 139, 383,
134846 /* 1380 */ 67, 896, 140, 141, 142, 148, 389, 812, 775, 266,
134847 /* 1390 */ 219, 190, 154, 391, 913, 876, 271, 406, 191, 322,
134848 /* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421,
134849 /* 1410 */ 705, 71, 323, 6, 204, 771, 288, 79, 297, 346,
134850 /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 967, 239,
134851 /* 1430 */ 769, 102, 862, 438, 426, 240, 424, 442, 73, 213,
134852 /* 1440 */ 688, 238, 22, 453, 953, 214, 217, 216, 454, 677,
134853 /* 1450 */ 676, 671, 753, 125, 115, 235, 126, 669, 353, 166,
134854 /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 892,
134855 /* 1470 */ 327, 890, 811, 328, 134, 128, 136, 138, 743, 258,
134856 /* 1480 */ 907, 184, 143, 129, 910, 186, 63, 64, 145, 187,
134857 /* 1490 */ 906, 65, 8, 66, 13, 188, 202, 899, 265, 149,
134858 /* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396,
134859 /* 1510 */ 151, 401, 68, 14, 15, 722, 69, 236, 831, 131,
134860 /* 1520 */ 830, 860, 70, 751, 16, 414, 755, 4, 174, 220,
134861 /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 875,
134862 /* 1540 */ 861, 859, 916, 864, 915, 207, 206, 942, 163, 437,
134863 /* 1550 */ 948, 943, 164, 209, 1002, 441, 863, 165, 210, 829,
134864 /* 1560 */ 695, 87, 312, 211, 1292, 1291, 309,
134865 };
134866 static const YYCODETYPE yy_lookahead[] = {
134867 /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
134868 /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
134869 /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
@@ -135112,55 +135555,55 @@
135112 /* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278,
135113 /* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228,
135114 /* 320 */ 1288, 1291, 1276, 1277, 1295,
135115 };
135116 static const YYACTIONTYPE yy_default[] = {
135117 /* 0 */ 1281, 1271, 1271, 1271, 1203, 1203, 1203, 1203, 1271, 1096,
135118 /* 10 */ 1125, 1125, 1255, 1332, 1332, 1332, 1332, 1332, 1332, 1202,
135119 /* 20 */ 1332, 1332, 1332, 1332, 1271, 1100, 1131, 1332, 1332, 1332,
135120 /* 30 */ 1332, 1204, 1205, 1332, 1332, 1332, 1254, 1256, 1141, 1140,
135121 /* 40 */ 1139, 1138, 1237, 1112, 1136, 1129, 1133, 1204, 1198, 1199,
135122 /* 50 */ 1197, 1201, 1205, 1332, 1132, 1167, 1182, 1166, 1332, 1332,
135123 /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135124 /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135125 /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135126 /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135127 /* 100 */ 1332, 1332, 1332, 1332, 1176, 1181, 1188, 1180, 1177, 1169,
135128 /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
135129 /* 120 */ 1332, 1173, 1185, 1184, 1183, 1262, 1289, 1288, 1332, 1332,
135130 /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135131 /* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135132 /* 150 */ 1332, 1332, 1332, 1332, 1332, 1281, 1271, 1025, 1025, 1332,
135133 /* 160 */ 1271, 1271, 1271, 1271, 1271, 1271, 1267, 1100, 1091, 1332,
135134 /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135135 /* 180 */ 1259, 1257, 1332, 1218, 1332, 1332, 1332, 1332, 1332, 1332,
135136 /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135137 /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
135138 /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1283, 1332, 1232,
135139 /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
135140 /* 230 */ 1321, 1135, 1321, 1042, 1303, 1039, 1125, 1114, 1200, 1125,
135141 /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
135142 /* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
135143 /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1236, 1318, 1105, 1105,
135144 /* 270 */ 1016, 1211, 1105, 1016, 1105, 1016, 1211, 1068, 1068, 1068,
135145 /* 280 */ 1057, 1211, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
135146 /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1206, 1105, 1332,
135147 /* 300 */ 1211, 1215, 1215, 1211, 1130, 1119, 1128, 1126, 1135, 1022,
135148 /* 310 */ 1060, 1286, 1286, 1282, 1282, 1282, 1282, 1329, 1329, 1267,
135149 /* 320 */ 1298, 1298, 1044, 1044, 1298, 1332, 1332, 1332, 1332, 1332,
135150 /* 330 */ 1332, 1293, 1332, 1220, 1332, 1332, 1332, 1332, 1332, 1332,
135151 /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135152 /* 350 */ 1332, 1332, 1152, 1332, 1000, 1264, 1332, 1332, 1263, 1332,
135153 /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135154 /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
135155 /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1235, 1234, 1332, 1332,
135156 /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135157 /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135158 /* 410 */ 1332, 1082, 1332, 1332, 1332, 1307, 1332, 1332, 1332, 1332,
135159 /* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
135160 /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1273,
135161 /* 440 */ 1332, 1332, 1332, 1272, 1332, 1332, 1332, 1332, 1332, 1154,
135162 /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
135163 };
135164 /********** End of lemon-generated parsing tables *****************************/
135165
135166 /* The next table maps tokens (terminal symbols) into fallback tokens.
@@ -135602,147 +136045,147 @@
135602 /* 169 */ "expr ::= expr EQ|NE expr",
135603 /* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
135604 /* 171 */ "expr ::= expr PLUS|MINUS expr",
135605 /* 172 */ "expr ::= expr STAR|SLASH|REM expr",
135606 /* 173 */ "expr ::= expr CONCAT expr",
135607 /* 174 */ "likeop ::= LIKE_KW|MATCH",
135608 /* 175 */ "likeop ::= NOT LIKE_KW|MATCH",
135609 /* 176 */ "expr ::= expr likeop expr",
135610 /* 177 */ "expr ::= expr likeop expr ESCAPE expr",
135611 /* 178 */ "expr ::= expr ISNULL|NOTNULL",
135612 /* 179 */ "expr ::= expr NOT NULL",
135613 /* 180 */ "expr ::= expr IS expr",
135614 /* 181 */ "expr ::= expr IS NOT expr",
135615 /* 182 */ "expr ::= NOT expr",
135616 /* 183 */ "expr ::= BITNOT expr",
135617 /* 184 */ "expr ::= MINUS expr",
135618 /* 185 */ "expr ::= PLUS expr",
135619 /* 186 */ "between_op ::= BETWEEN",
135620 /* 187 */ "between_op ::= NOT BETWEEN",
135621 /* 188 */ "expr ::= expr between_op expr AND expr",
135622 /* 189 */ "in_op ::= IN",
135623 /* 190 */ "in_op ::= NOT IN",
135624 /* 191 */ "expr ::= expr in_op LP exprlist RP",
135625 /* 192 */ "expr ::= LP select RP",
135626 /* 193 */ "expr ::= expr in_op LP select RP",
135627 /* 194 */ "expr ::= expr in_op nm dbnm paren_exprlist",
135628 /* 195 */ "expr ::= EXISTS LP select RP",
135629 /* 196 */ "expr ::= CASE case_operand case_exprlist case_else END",
135630 /* 197 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
135631 /* 198 */ "case_exprlist ::= WHEN expr THEN expr",
135632 /* 199 */ "case_else ::= ELSE expr",
135633 /* 200 */ "case_else ::=",
135634 /* 201 */ "case_operand ::= expr",
135635 /* 202 */ "case_operand ::=",
135636 /* 203 */ "exprlist ::=",
135637 /* 204 */ "nexprlist ::= nexprlist COMMA expr",
135638 /* 205 */ "nexprlist ::= expr",
135639 /* 206 */ "paren_exprlist ::=",
135640 /* 207 */ "paren_exprlist ::= LP exprlist RP",
135641 /* 208 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
135642 /* 209 */ "uniqueflag ::= UNIQUE",
135643 /* 210 */ "uniqueflag ::=",
135644 /* 211 */ "eidlist_opt ::=",
135645 /* 212 */ "eidlist_opt ::= LP eidlist RP",
135646 /* 213 */ "eidlist ::= eidlist COMMA nm collate sortorder",
135647 /* 214 */ "eidlist ::= nm collate sortorder",
135648 /* 215 */ "collate ::=",
135649 /* 216 */ "collate ::= COLLATE ID|STRING",
135650 /* 217 */ "cmd ::= DROP INDEX ifexists fullname",
135651 /* 218 */ "cmd ::= VACUUM",
135652 /* 219 */ "cmd ::= VACUUM nm",
135653 /* 220 */ "cmd ::= PRAGMA nm dbnm",
135654 /* 221 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
135655 /* 222 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
135656 /* 223 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
135657 /* 224 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
135658 /* 225 */ "plus_num ::= PLUS INTEGER|FLOAT",
135659 /* 226 */ "minus_num ::= MINUS INTEGER|FLOAT",
135660 /* 227 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
135661 /* 228 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
135662 /* 229 */ "trigger_time ::= BEFORE",
135663 /* 230 */ "trigger_time ::= AFTER",
135664 /* 231 */ "trigger_time ::= INSTEAD OF",
135665 /* 232 */ "trigger_time ::=",
135666 /* 233 */ "trigger_event ::= DELETE|INSERT",
135667 /* 234 */ "trigger_event ::= UPDATE",
135668 /* 235 */ "trigger_event ::= UPDATE OF idlist",
135669 /* 236 */ "when_clause ::=",
135670 /* 237 */ "when_clause ::= WHEN expr",
135671 /* 238 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
135672 /* 239 */ "trigger_cmd_list ::= trigger_cmd SEMI",
135673 /* 240 */ "trnm ::= nm DOT nm",
135674 /* 241 */ "tridxby ::= INDEXED BY nm",
135675 /* 242 */ "tridxby ::= NOT INDEXED",
135676 /* 243 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
135677 /* 244 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
135678 /* 245 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
135679 /* 246 */ "trigger_cmd ::= select",
135680 /* 247 */ "expr ::= RAISE LP IGNORE RP",
135681 /* 248 */ "expr ::= RAISE LP raisetype COMMA nm RP",
135682 /* 249 */ "raisetype ::= ROLLBACK",
135683 /* 250 */ "raisetype ::= ABORT",
135684 /* 251 */ "raisetype ::= FAIL",
135685 /* 252 */ "cmd ::= DROP TRIGGER ifexists fullname",
135686 /* 253 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
135687 /* 254 */ "cmd ::= DETACH database_kw_opt expr",
135688 /* 255 */ "key_opt ::=",
135689 /* 256 */ "key_opt ::= KEY expr",
135690 /* 257 */ "cmd ::= REINDEX",
135691 /* 258 */ "cmd ::= REINDEX nm dbnm",
135692 /* 259 */ "cmd ::= ANALYZE",
135693 /* 260 */ "cmd ::= ANALYZE nm dbnm",
135694 /* 261 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
135695 /* 262 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
135696 /* 263 */ "add_column_fullname ::= fullname",
135697 /* 264 */ "cmd ::= create_vtab",
135698 /* 265 */ "cmd ::= create_vtab LP vtabarglist RP",
135699 /* 266 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
135700 /* 267 */ "vtabarg ::=",
135701 /* 268 */ "vtabargtoken ::= ANY",
135702 /* 269 */ "vtabargtoken ::= lp anylist RP",
135703 /* 270 */ "lp ::= LP",
135704 /* 271 */ "with ::=",
135705 /* 272 */ "with ::= WITH wqlist",
135706 /* 273 */ "with ::= WITH RECURSIVE wqlist",
135707 /* 274 */ "wqlist ::= nm eidlist_opt AS LP select RP",
135708 /* 275 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
135709 /* 276 */ "input ::= cmdlist",
135710 /* 277 */ "cmdlist ::= cmdlist ecmd",
135711 /* 278 */ "cmdlist ::= ecmd",
135712 /* 279 */ "ecmd ::= SEMI",
135713 /* 280 */ "ecmd ::= explain cmdx SEMI",
135714 /* 281 */ "explain ::=",
135715 /* 282 */ "trans_opt ::=",
135716 /* 283 */ "trans_opt ::= TRANSACTION",
135717 /* 284 */ "trans_opt ::= TRANSACTION nm",
135718 /* 285 */ "savepoint_opt ::= SAVEPOINT",
135719 /* 286 */ "savepoint_opt ::=",
135720 /* 287 */ "cmd ::= create_table create_table_args",
135721 /* 288 */ "columnlist ::= columnlist COMMA columnname carglist",
135722 /* 289 */ "columnlist ::= columnname carglist",
135723 /* 290 */ "nm ::= ID|INDEXED",
135724 /* 291 */ "nm ::= STRING",
135725 /* 292 */ "nm ::= JOIN_KW",
135726 /* 293 */ "typetoken ::= typename",
135727 /* 294 */ "typename ::= ID|STRING",
135728 /* 295 */ "signed ::= plus_num",
135729 /* 296 */ "signed ::= minus_num",
135730 /* 297 */ "carglist ::= carglist ccons",
135731 /* 298 */ "carglist ::=",
135732 /* 299 */ "ccons ::= NULL onconf",
135733 /* 300 */ "conslist_opt ::= COMMA conslist",
135734 /* 301 */ "conslist ::= conslist tconscomma tcons",
135735 /* 302 */ "conslist ::= tcons",
135736 /* 303 */ "tconscomma ::=",
135737 /* 304 */ "defer_subclause_opt ::= defer_subclause",
135738 /* 305 */ "resolvetype ::= raisetype",
135739 /* 306 */ "selectnowith ::= oneselect",
135740 /* 307 */ "oneselect ::= values",
135741 /* 308 */ "sclp ::= selcollist COMMA",
135742 /* 309 */ "as ::= ID|STRING",
135743 /* 310 */ "expr ::= term",
135744 /* 311 */ "exprlist ::= nexprlist",
135745 /* 312 */ "nmnum ::= plus_num",
135746 /* 313 */ "nmnum ::= nm",
135747 /* 314 */ "nmnum ::= ON",
135748 /* 315 */ "nmnum ::= DELETE",
@@ -136375,11 +136818,10 @@
136375 { 173, 3 },
136376 { 173, 3 },
136377 { 173, 3 },
136378 { 173, 3 },
136379 { 173, 3 },
136380 { 221, 1 },
136381 { 221, 2 },
136382 { 173, 3 },
136383 { 173, 5 },
136384 { 173, 2 },
136385 { 173, 3 },
@@ -136512,10 +136954,11 @@
136512 { 194, 1 },
136513 { 195, 1 },
136514 { 209, 2 },
136515 { 210, 1 },
136516 { 173, 1 },
 
136517 { 208, 1 },
136518 { 230, 1 },
136519 { 230, 1 },
136520 { 230, 1 },
136521 { 230, 1 },
@@ -136654,11 +137097,11 @@
136654 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
136655 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
136656 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
136657 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
136658 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
136659 case 215: /* collate ::= */ yytestcase(yyruleno==215);
136660 {yymsp[1].minor.yy194 = 0;}
136661 break;
136662 case 17: /* ifnotexists ::= IF NOT EXISTS */
136663 {yymsp[-2].minor.yy194 = 1;}
136664 break;
@@ -136798,13 +137241,13 @@
136798 case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
136799 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
136800 break;
136801 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
136802 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
136803 case 187: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==187);
136804 case 190: /* in_op ::= NOT IN */ yytestcase(yyruleno==190);
136805 case 216: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==216);
136806 {yymsp[-1].minor.yy194 = 1;}
136807 break;
136808 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
136809 {yymsp[-1].minor.yy194 = 0;}
136810 break;
@@ -136964,13 +137407,13 @@
136964 {yymsp[0].minor.yy194 = SF_All;}
136965 break;
136966 case 91: /* sclp ::= */
136967 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
136968 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
136969 case 203: /* exprlist ::= */ yytestcase(yyruleno==203);
136970 case 206: /* paren_exprlist ::= */ yytestcase(yyruleno==206);
136971 case 211: /* eidlist_opt ::= */ yytestcase(yyruleno==211);
136972 {yymsp[1].minor.yy148 = 0;}
136973 break;
136974 case 92: /* selcollist ::= sclp expr as */
136975 {
136976 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
@@ -136992,12 +137435,12 @@
136992 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
136993 }
136994 break;
136995 case 95: /* as ::= AS nm */
136996 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
136997 case 225: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
136998 case 226: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==226);
136999 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
137000 break;
137001 case 97: /* from ::= */
137002 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
137003 break;
@@ -137076,18 +137519,18 @@
137076 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
137077 break;
137078 case 112: /* on_opt ::= ON expr */
137079 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
137080 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
137081 case 199: /* case_else ::= ELSE expr */ yytestcase(yyruleno==199);
137082 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
137083 break;
137084 case 113: /* on_opt ::= */
137085 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
137086 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
137087 case 200: /* case_else ::= */ yytestcase(yyruleno==200);
137088 case 202: /* case_operand ::= */ yytestcase(yyruleno==202);
137089 {yymsp[1].minor.yy72 = 0;}
137090 break;
137091 case 115: /* indexed_opt ::= INDEXED BY nm */
137092 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
137093 break;
@@ -137320,17 +137763,14 @@
137320 case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171);
137321 case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172);
137322 case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173);
137323 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
137324 break;
137325 case 174: /* likeop ::= LIKE_KW|MATCH */
137326 {yymsp[0].minor.yy0=yymsp[0].minor.yy0;/*A-overwrites-X*/}
137327 break;
137328 case 175: /* likeop ::= NOT LIKE_KW|MATCH */
137329 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
137330 break;
137331 case 176: /* expr ::= expr likeop expr */
137332 {
137333 ExprList *pList;
137334 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
137335 yymsp[-1].minor.yy0.n &= 0x7fffffff;
137336 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
@@ -137339,11 +137779,11 @@
137339 exprNot(pParse, bNot, &yymsp[-2].minor.yy190);
137340 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137341 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
137342 }
137343 break;
137344 case 177: /* expr ::= expr likeop expr ESCAPE expr */
137345 {
137346 ExprList *pList;
137347 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
137348 yymsp[-3].minor.yy0.n &= 0x7fffffff;
137349 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
@@ -137353,43 +137793,43 @@
137353 exprNot(pParse, bNot, &yymsp[-4].minor.yy190);
137354 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137355 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
137356 }
137357 break;
137358 case 178: /* expr ::= expr ISNULL|NOTNULL */
137359 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
137360 break;
137361 case 179: /* expr ::= expr NOT NULL */
137362 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
137363 break;
137364 case 180: /* expr ::= expr IS expr */
137365 {
137366 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
137367 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
137368 }
137369 break;
137370 case 181: /* expr ::= expr IS NOT expr */
137371 {
137372 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
137373 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
137374 }
137375 break;
137376 case 182: /* expr ::= NOT expr */
137377 case 183: /* expr ::= BITNOT expr */ yytestcase(yyruleno==183);
137378 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137379 break;
137380 case 184: /* expr ::= MINUS expr */
137381 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137382 break;
137383 case 185: /* expr ::= PLUS expr */
137384 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137385 break;
137386 case 186: /* between_op ::= BETWEEN */
137387 case 189: /* in_op ::= IN */ yytestcase(yyruleno==189);
137388 {yymsp[0].minor.yy194 = 0;}
137389 break;
137390 case 188: /* expr ::= expr between_op expr AND expr */
137391 {
137392 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137393 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
137394 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
137395 if( yymsp[-4].minor.yy190.pExpr ){
@@ -137399,11 +137839,11 @@
137399 }
137400 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137401 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137402 }
137403 break;
137404 case 191: /* expr ::= expr in_op LP exprlist RP */
137405 {
137406 if( yymsp[-1].minor.yy148==0 ){
137407 /* Expressions of the form
137408 **
137409 ** expr1 IN ()
@@ -137452,26 +137892,26 @@
137452 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137453 }
137454 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
137455 }
137456 break;
137457 case 192: /* expr ::= LP select RP */
137458 {
137459 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
137460 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
137461 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137462 }
137463 break;
137464 case 193: /* expr ::= expr in_op LP select RP */
137465 {
137466 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
137467 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137468 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137469 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
137470 }
137471 break;
137472 case 194: /* expr ::= expr in_op nm dbnm paren_exprlist */
137473 {
137474 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
137475 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
137476 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
137477 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
@@ -137478,19 +137918,19 @@
137478 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
137479 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137480 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
137481 }
137482 break;
137483 case 195: /* expr ::= EXISTS LP select RP */
137484 {
137485 Expr *p;
137486 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
137487 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
137488 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
137489 }
137490 break;
137491 case 196: /* expr ::= CASE case_operand case_exprlist case_else END */
137492 {
137493 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
137494 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
137495 if( yymsp[-4].minor.yy190.pExpr ){
137496 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -137499,313 +137939,314 @@
137499 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
137500 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
137501 }
137502 }
137503 break;
137504 case 197: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
137505 {
137506 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
137507 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
137508 }
137509 break;
137510 case 198: /* case_exprlist ::= WHEN expr THEN expr */
137511 {
137512 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137513 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
137514 }
137515 break;
137516 case 201: /* case_operand ::= expr */
137517 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
137518 break;
137519 case 204: /* nexprlist ::= nexprlist COMMA expr */
137520 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
137521 break;
137522 case 205: /* nexprlist ::= expr */
137523 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
137524 break;
137525 case 207: /* paren_exprlist ::= LP exprlist RP */
137526 case 212: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==212);
137527 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
137528 break;
137529 case 208: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
137530 {
137531 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
137532 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
137533 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
137534 }
137535 break;
137536 case 209: /* uniqueflag ::= UNIQUE */
137537 case 250: /* raisetype ::= ABORT */ yytestcase(yyruleno==250);
137538 {yymsp[0].minor.yy194 = OE_Abort;}
137539 break;
137540 case 210: /* uniqueflag ::= */
137541 {yymsp[1].minor.yy194 = OE_None;}
137542 break;
137543 case 213: /* eidlist ::= eidlist COMMA nm collate sortorder */
137544 {
137545 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
137546 }
137547 break;
137548 case 214: /* eidlist ::= nm collate sortorder */
137549 {
137550 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
137551 }
137552 break;
137553 case 217: /* cmd ::= DROP INDEX ifexists fullname */
137554 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
137555 break;
137556 case 218: /* cmd ::= VACUUM */
137557 {sqlite3Vacuum(pParse,0);}
137558 break;
137559 case 219: /* cmd ::= VACUUM nm */
137560 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
137561 break;
137562 case 220: /* cmd ::= PRAGMA nm dbnm */
137563 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
137564 break;
137565 case 221: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
137566 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
137567 break;
137568 case 222: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
137569 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
137570 break;
137571 case 223: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
137572 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
137573 break;
137574 case 224: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
137575 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
137576 break;
137577 case 227: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
137578 {
137579 Token all;
137580 all.z = yymsp[-3].minor.yy0.z;
137581 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
137582 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
137583 }
137584 break;
137585 case 228: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
137586 {
137587 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
137588 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
137589 }
137590 break;
137591 case 229: /* trigger_time ::= BEFORE */
137592 { yymsp[0].minor.yy194 = TK_BEFORE; }
137593 break;
137594 case 230: /* trigger_time ::= AFTER */
137595 { yymsp[0].minor.yy194 = TK_AFTER; }
137596 break;
137597 case 231: /* trigger_time ::= INSTEAD OF */
137598 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
137599 break;
137600 case 232: /* trigger_time ::= */
137601 { yymsp[1].minor.yy194 = TK_BEFORE; }
137602 break;
137603 case 233: /* trigger_event ::= DELETE|INSERT */
137604 case 234: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==234);
137605 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
137606 break;
137607 case 235: /* trigger_event ::= UPDATE OF idlist */
137608 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
137609 break;
137610 case 236: /* when_clause ::= */
137611 case 255: /* key_opt ::= */ yytestcase(yyruleno==255);
137612 { yymsp[1].minor.yy72 = 0; }
137613 break;
137614 case 237: /* when_clause ::= WHEN expr */
137615 case 256: /* key_opt ::= KEY expr */ yytestcase(yyruleno==256);
137616 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
137617 break;
137618 case 238: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
137619 {
137620 assert( yymsp[-2].minor.yy145!=0 );
137621 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
137622 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
137623 }
137624 break;
137625 case 239: /* trigger_cmd_list ::= trigger_cmd SEMI */
137626 {
137627 assert( yymsp[-1].minor.yy145!=0 );
137628 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
137629 }
137630 break;
137631 case 240: /* trnm ::= nm DOT nm */
137632 {
137633 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
137634 sqlite3ErrorMsg(pParse,
137635 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
137636 "statements within triggers");
137637 }
137638 break;
137639 case 241: /* tridxby ::= INDEXED BY nm */
137640 {
137641 sqlite3ErrorMsg(pParse,
137642 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
137643 "within triggers");
137644 }
137645 break;
137646 case 242: /* tridxby ::= NOT INDEXED */
137647 {
137648 sqlite3ErrorMsg(pParse,
137649 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
137650 "within triggers");
137651 }
137652 break;
137653 case 243: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
137654 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
137655 break;
137656 case 244: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
137657 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
137658 break;
137659 case 245: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
137660 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
137661 break;
137662 case 246: /* trigger_cmd ::= select */
137663 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
137664 break;
137665 case 247: /* expr ::= RAISE LP IGNORE RP */
137666 {
137667 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
137668 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
137669 if( yymsp[-3].minor.yy190.pExpr ){
137670 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
137671 }
137672 }
137673 break;
137674 case 248: /* expr ::= RAISE LP raisetype COMMA nm RP */
137675 {
137676 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
137677 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
137678 if( yymsp[-5].minor.yy190.pExpr ) {
137679 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
137680 }
137681 }
137682 break;
137683 case 249: /* raisetype ::= ROLLBACK */
137684 {yymsp[0].minor.yy194 = OE_Rollback;}
137685 break;
137686 case 251: /* raisetype ::= FAIL */
137687 {yymsp[0].minor.yy194 = OE_Fail;}
137688 break;
137689 case 252: /* cmd ::= DROP TRIGGER ifexists fullname */
137690 {
137691 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
137692 }
137693 break;
137694 case 253: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
137695 {
137696 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
137697 }
137698 break;
137699 case 254: /* cmd ::= DETACH database_kw_opt expr */
137700 {
137701 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
137702 }
137703 break;
137704 case 257: /* cmd ::= REINDEX */
137705 {sqlite3Reindex(pParse, 0, 0);}
137706 break;
137707 case 258: /* cmd ::= REINDEX nm dbnm */
137708 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
137709 break;
137710 case 259: /* cmd ::= ANALYZE */
137711 {sqlite3Analyze(pParse, 0, 0);}
137712 break;
137713 case 260: /* cmd ::= ANALYZE nm dbnm */
137714 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
137715 break;
137716 case 261: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
137717 {
137718 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
137719 }
137720 break;
137721 case 262: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
137722 {
137723 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
137724 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
137725 }
137726 break;
137727 case 263: /* add_column_fullname ::= fullname */
137728 {
137729 disableLookaside(pParse);
137730 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
137731 }
137732 break;
137733 case 264: /* cmd ::= create_vtab */
137734 {sqlite3VtabFinishParse(pParse,0);}
137735 break;
137736 case 265: /* cmd ::= create_vtab LP vtabarglist RP */
137737 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
137738 break;
137739 case 266: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
137740 {
137741 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
137742 }
137743 break;
137744 case 267: /* vtabarg ::= */
137745 {sqlite3VtabArgInit(pParse);}
137746 break;
137747 case 268: /* vtabargtoken ::= ANY */
137748 case 269: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==269);
137749 case 270: /* lp ::= LP */ yytestcase(yyruleno==270);
137750 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
137751 break;
137752 case 271: /* with ::= */
137753 {yymsp[1].minor.yy285 = 0;}
137754 break;
137755 case 272: /* with ::= WITH wqlist */
137756 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
137757 break;
137758 case 273: /* with ::= WITH RECURSIVE wqlist */
137759 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
137760 break;
137761 case 274: /* wqlist ::= nm eidlist_opt AS LP select RP */
137762 {
137763 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
137764 }
137765 break;
137766 case 275: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
137767 {
137768 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
137769 }
137770 break;
137771 default:
137772 /* (276) input ::= cmdlist */ yytestcase(yyruleno==276);
137773 /* (277) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==277);
137774 /* (278) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=278);
137775 /* (279) ecmd ::= SEMI */ yytestcase(yyruleno==279);
137776 /* (280) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==280);
137777 /* (281) explain ::= */ yytestcase(yyruleno==281);
137778 /* (282) trans_opt ::= */ yytestcase(yyruleno==282);
137779 /* (283) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==283);
137780 /* (284) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==284);
137781 /* (285) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==285);
137782 /* (286) savepoint_opt ::= */ yytestcase(yyruleno==286);
137783 /* (287) cmd ::= create_table create_table_args */ yytestcase(yyruleno==287);
137784 /* (288) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==288);
137785 /* (289) columnlist ::= columnname carglist */ yytestcase(yyruleno==289);
137786 /* (290) nm ::= ID|INDEXED */ yytestcase(yyruleno==290);
137787 /* (291) nm ::= STRING */ yytestcase(yyruleno==291);
137788 /* (292) nm ::= JOIN_KW */ yytestcase(yyruleno==292);
137789 /* (293) typetoken ::= typename */ yytestcase(yyruleno==293);
137790 /* (294) typename ::= ID|STRING */ yytestcase(yyruleno==294);
137791 /* (295) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
137792 /* (296) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=296);
137793 /* (297) carglist ::= carglist ccons */ yytestcase(yyruleno==297);
137794 /* (298) carglist ::= */ yytestcase(yyruleno==298);
137795 /* (299) ccons ::= NULL onconf */ yytestcase(yyruleno==299);
137796 /* (300) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==300);
137797 /* (301) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==301);
137798 /* (302) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=302);
137799 /* (303) tconscomma ::= */ yytestcase(yyruleno==303);
137800 /* (304) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=304);
137801 /* (305) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=305);
137802 /* (306) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=306);
137803 /* (307) oneselect ::= values */ yytestcase(yyruleno==307);
137804 /* (308) sclp ::= selcollist COMMA */ yytestcase(yyruleno==308);
137805 /* (309) as ::= ID|STRING */ yytestcase(yyruleno==309);
137806 /* (310) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=310);
 
137807 /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
137808 /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
137809 /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
137810 /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
137811 /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
@@ -140301,10 +140742,25 @@
140301 return 0;
140302 }
140303 #endif
140304 return db->lastRowid;
140305 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140306
140307 /*
140308 ** Return the number of changes in the most recent call to sqlite3_exec().
140309 */
140310 SQLITE_API int sqlite3_changes(sqlite3 *db){
@@ -148111,12 +148567,14 @@
148111 ** segments.
148112 */
148113 const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */
148114
148115 Fts3Table *p = (Fts3Table*)pVtab;
148116 int rc = sqlite3Fts3PendingTermsFlush(p);
 
148117
 
148118 if( rc==SQLITE_OK
148119 && p->nLeafAdd>(nMinMerge/16)
148120 && p->nAutoincrmerge && p->nAutoincrmerge!=0xff
148121 ){
148122 int mxLevel = 0; /* Maximum relative level value in db */
@@ -148127,10 +148585,11 @@
148127 A = p->nLeafAdd * mxLevel;
148128 A += (A/2);
148129 if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge);
148130 }
148131 sqlite3Fts3SegmentsClose(p);
 
148132 return rc;
148133 }
148134
148135 /*
148136 ** If it is currently unknown whether or not the FTS table has an %_stat
@@ -168462,10 +168921,11 @@
168462 int nStep; /* Rows processed for current object */
168463 int nProgress; /* Rows processed for all objects */
168464 RbuObjIter objiter; /* Iterator for skipping through tbl/idx */
168465 const char *zVfsName; /* Name of automatically created rbu vfs */
168466 rbu_file *pTargetFd; /* File handle open on target db */
 
168467 i64 iOalSz;
168468 i64 nPhaseOneStep;
168469
168470 /* The following state variables are used as part of the incremental
168471 ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding
@@ -170726,10 +171186,27 @@
170726
170727 if( p->rc==SQLITE_OK ){
170728 if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){
170729 p->rc = SQLITE_DONE;
170730 p->eStage = RBU_STAGE_DONE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170731 }
170732 }
170733 }
170734
170735 /*
@@ -171381,13 +171858,30 @@
171381 if( p->rc==SQLITE_OK ){
171382 p->eStage = RBU_STAGE_DONE;
171383 p->rc = SQLITE_DONE;
171384 }
171385 }else{
171386 RbuFrame *pFrame = &p->aFrame[p->nStep];
171387 rbuCheckpointFrame(p, pFrame);
171388 p->nStep++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171389 }
171390 p->nProgress++;
171391 }
171392 break;
171393 }
@@ -171823,10 +172317,16 @@
171823
171824 /* Commit the transaction to the *-oal file. */
171825 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
171826 p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg);
171827 }
 
 
 
 
 
 
171828
171829 rbuSaveState(p, p->eStage);
171830
171831 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
171832 p->rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, &p->zErrmsg);
@@ -171947,10 +172447,16 @@
171947 assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
171948 if( p->eStage==RBU_STAGE_OAL ){
171949 assert( rc!=SQLITE_DONE );
171950 if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0);
171951 }
 
 
 
 
 
 
171952
171953 p->rc = rc;
171954 rbuSaveState(p, p->eStage);
171955 rc = p->rc;
171956
@@ -181079,11 +181585,13 @@
181079 typedef unsigned short u16;
181080 typedef short i16;
181081 typedef sqlite3_int64 i64;
181082 typedef sqlite3_uint64 u64;
181083
181084 #define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
 
 
181085
181086 #define testcase(x)
181087 #define ALWAYS(x) 1
181088 #define NEVER(x) 0
181089
@@ -186302,11 +186810,14 @@
186302 if( p1->bEof==0 ){
186303 if( (p1->iRowid==iLast)
186304 || (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)
186305 ){
186306 int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);
186307 if( rc!=SQLITE_OK ) return rc;
 
 
 
186308 }
186309 }
186310 }
186311
186312 fts5ExprNodeTest_OR(pExpr, pNode);
@@ -186333,11 +186844,14 @@
186333 Fts5ExprNode *pChild = pAnd->apChild[iChild];
186334 int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);
186335 if( cmp>0 ){
186336 /* Advance pChild until it points to iLast or laster */
186337 rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);
186338 if( rc!=SQLITE_OK ) return rc;
 
 
 
186339 }
186340
186341 /* If the child node is now at EOF, so is the parent AND node. Otherwise,
186342 ** the child node is guaranteed to have advanced at least as far as
186343 ** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the
@@ -186372,10 +186886,12 @@
186372 i64 iFrom
186373 ){
186374 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
186375 if( rc==SQLITE_OK ){
186376 rc = fts5ExprNodeTest_AND(pExpr, pNode);
 
 
186377 }
186378 return rc;
186379 }
186380
186381 static int fts5ExprNodeTest_NOT(
@@ -186414,10 +186930,13 @@
186414 ){
186415 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
186416 if( rc==SQLITE_OK ){
186417 rc = fts5ExprNodeTest_NOT(pExpr, pNode);
186418 }
 
 
 
186419 return rc;
186420 }
186421
186422 /*
186423 ** If pNode currently points to a match, this function returns SQLITE_OK
@@ -197534,11 +198053,11 @@
197534 int nArg, /* Number of args */
197535 sqlite3_value **apUnused /* Function arguments */
197536 ){
197537 assert( nArg==0 );
197538 UNUSED_PARAM2(nArg, apUnused);
197539 sqlite3_result_text(pCtx, "fts5: 2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c", -1, SQLITE_TRANSIENT);
197540 }
197541
197542 static int fts5Init(sqlite3 *db){
197543 static const sqlite3_module fts5Mod = {
197544 /* iVersion */ 2,
@@ -198197,15 +198716,10 @@
198197 sqlite3_step(pDel);
198198 rc = sqlite3_reset(pDel);
198199 }
198200 }
198201
198202 /* Write the averages record */
198203 if( rc==SQLITE_OK ){
198204 rc = fts5StorageSaveTotals(p);
198205 }
198206
198207 return rc;
198208 }
198209
198210 /*
198211 ** Delete all entries in the FTS5 index.
@@ -198405,15 +198919,10 @@
198405 if( rc==SQLITE_OK ){
198406 rc = fts5StorageInsertDocsize(p, iRowid, &buf);
198407 }
198408 sqlite3_free(buf.p);
198409
198410 /* Write the averages record */
198411 if( rc==SQLITE_OK ){
198412 rc = fts5StorageSaveTotals(p);
198413 }
198414
198415 return rc;
198416 }
198417
198418 static int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){
198419 Fts5Config *pConfig = p->pConfig;
@@ -198744,16 +199253,21 @@
198744
198745 /*
198746 ** Flush any data currently held in-memory to disk.
198747 */
198748 static int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit){
198749 if( bCommit && p->bTotalsValid ){
198750 int rc = fts5StorageSaveTotals(p);
198751 p->bTotalsValid = 0;
198752 if( rc!=SQLITE_OK ) return rc;
 
198753 }
198754 return sqlite3Fts5IndexSync(p->pIndex, bCommit);
 
 
 
 
198755 }
198756
198757 static int sqlite3Fts5StorageRollback(Fts5Storage *p){
198758 p->bTotalsValid = 0;
198759 return sqlite3Fts5IndexRollback(p->pIndex);
198760
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.18.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -396,13 +396,13 @@
396 **
397 ** See also: [sqlite3_libversion()],
398 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
399 ** [sqlite_version()] and [sqlite_source_id()].
400 */
401 #define SQLITE_VERSION "3.18.0"
402 #define SQLITE_VERSION_NUMBER 3018000
403 #define SQLITE_SOURCE_ID "2017-03-06 17:33:58 137aeb2b160888100bc1e871b00860149e5f6196"
404
405 /*
406 ** CAPI3REF: Run-Time Library Version Numbers
407 ** KEYWORDS: sqlite3_version sqlite3_sourceid
408 **
@@ -2315,24 +2315,34 @@
2315 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
2316 ** names are not also used by explicitly declared columns. ^If
2317 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
2318 ** is another alias for the rowid.
2319 **
2320 ** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of
2321 ** the most recent successful [INSERT] into a rowid table or [virtual table]
2322 ** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not
2323 ** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred
2324 ** on the database connection D, then sqlite3_last_insert_rowid(D) returns
2325 ** zero.
 
2326 **
2327 ** As well as being set automatically as rows are inserted into database
2328 ** tables, the value returned by this function may be set explicitly by
2329 ** [sqlite3_set_last_insert_rowid()]
2330 **
2331 ** Some virtual table implementations may INSERT rows into rowid tables as
2332 ** part of committing a transaction (e.g. to flush data accumulated in memory
2333 ** to disk). In this case subsequent calls to this function return the rowid
2334 ** associated with these internal INSERT operations, which leads to
2335 ** unintuitive results. Virtual table implementations that do write to rowid
2336 ** tables in this way can avoid this problem by restoring the original
2337 ** rowid value using [sqlite3_set_last_insert_rowid()] before returning
2338 ** control to the user.
2339 **
2340 ** ^(If an [INSERT] occurs within a trigger then this routine will
2341 ** return the [rowid] of the inserted row as long as the trigger is
2342 ** running. Once the trigger program ends, the value returned
2343 ** by this routine reverts to what it was before the trigger was fired.)^
2344 **
2345 ** ^An [INSERT] that fails due to a constraint violation is not a
2346 ** successful [INSERT] and does not change the value returned by this
2347 ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
2348 ** and INSERT OR ABORT make no changes to the return value of this
@@ -2355,10 +2365,20 @@
2365 ** unpredictable and might not equal either the old or the new
2366 ** last insert [rowid].
2367 */
2368 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2369
2370 /*
2371 ** CAPI3REF: Set the Last Insert Rowid value.
2372 ** METHOD: sqlite3
2373 **
2374 ** The sqlite3_set_last_insert_rowid(D, R) method allows the application to
2375 ** set the value returned by calling sqlite3_last_insert_rowid(D) to R
2376 ** without inserting a row into the database.
2377 */
2378 SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2379
2380 /*
2381 ** CAPI3REF: Count The Number Of Rows Modified
2382 ** METHOD: sqlite3
2383 **
2384 ** ^This function returns the number of rows modified, inserted or
@@ -12457,10 +12477,11 @@
12477 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
12478 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
12479
12480 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
12481 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
12482 SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
12483
12484 #ifndef SQLITE_OMIT_INCRBLOB
12485 SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*);
12486 SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
12487 SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
@@ -12757,117 +12778,119 @@
12778 #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
12779 #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
12780 #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
12781 #define OP_Last 53
12782 #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */
12783 #define OP_IfSmaller 55
12784 #define OP_SorterSort 56
12785 #define OP_Sort 57
12786 #define OP_Rewind 58
12787 #define OP_IdxLE 59 /* synopsis: key=r[P3@P4] */
12788 #define OP_IdxGT 60 /* synopsis: key=r[P3@P4] */
12789 #define OP_IdxLT 61 /* synopsis: key=r[P3@P4] */
12790 #define OP_IdxGE 62 /* synopsis: key=r[P3@P4] */
12791 #define OP_RowSetRead 63 /* synopsis: r[P3]=rowset(P1) */
12792 #define OP_RowSetTest 64 /* synopsis: if r[P3] in rowset(P1) goto P2 */
12793 #define OP_Program 65
12794 #define OP_FkIfZero 66 /* synopsis: if fkctr[P1]==0 goto P2 */
12795 #define OP_IfPos 67 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
12796 #define OP_IfNotZero 68 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
12797 #define OP_DecrJumpZero 69 /* synopsis: if (--r[P1])==0 goto P2 */
12798 #define OP_IncrVacuum 70
12799 #define OP_VNext 71
12800 #define OP_Init 72 /* synopsis: Start at P2 */
12801 #define OP_Return 73
12802 #define OP_EndCoroutine 74
12803 #define OP_HaltIfNull 75 /* synopsis: if r[P3]=null halt */
12804 #define OP_Halt 76
12805 #define OP_Integer 77 /* synopsis: r[P2]=P1 */
12806 #define OP_Int64 78 /* synopsis: r[P2]=P4 */
12807 #define OP_String 79 /* synopsis: r[P2]='P4' (len=P1) */
12808 #define OP_Null 80 /* synopsis: r[P2..P3]=NULL */
12809 #define OP_SoftNull 81 /* synopsis: r[P1]=NULL */
12810 #define OP_Blob 82 /* synopsis: r[P2]=P4 (len=P1) */
12811 #define OP_Variable 83 /* synopsis: r[P2]=parameter(P1,P4) */
12812 #define OP_Move 84 /* synopsis: r[P2@P3]=r[P1@P3] */
12813 #define OP_Copy 85 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
12814 #define OP_SCopy 86 /* synopsis: r[P2]=r[P1] */
12815 #define OP_IntCopy 87 /* synopsis: r[P2]=r[P1] */
12816 #define OP_ResultRow 88 /* synopsis: output=r[P1@P2] */
12817 #define OP_CollSeq 89
12818 #define OP_Function0 90 /* synopsis: r[P3]=func(r[P2@P5]) */
12819 #define OP_Function 91 /* synopsis: r[P3]=func(r[P2@P5]) */
12820 #define OP_AddImm 92 /* synopsis: r[P1]=r[P1]+P2 */
12821 #define OP_RealAffinity 93
12822 #define OP_Cast 94 /* synopsis: affinity(r[P1]) */
12823 #define OP_Permutation 95
12824 #define OP_Compare 96 /* synopsis: r[P1@P3] <-> r[P2@P3] */
12825 #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */
12826 #define OP_Column 98 /* synopsis: r[P3]=PX */
12827 #define OP_Affinity 99 /* synopsis: affinity(r[P1@P2]) */
12828 #define OP_MakeRecord 100 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
12829 #define OP_Count 101 /* synopsis: r[P2]=count() */
12830 #define OP_ReadCookie 102
12831 #define OP_SetCookie 103
12832 #define OP_ReopenIdx 104 /* synopsis: root=P2 iDb=P3 */
12833 #define OP_OpenRead 105 /* synopsis: root=P2 iDb=P3 */
12834 #define OP_OpenWrite 106 /* synopsis: root=P2 iDb=P3 */
12835 #define OP_OpenAutoindex 107 /* synopsis: nColumn=P2 */
12836 #define OP_OpenEphemeral 108 /* synopsis: nColumn=P2 */
12837 #define OP_SorterOpen 109
12838 #define OP_SequenceTest 110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
12839 #define OP_OpenPseudo 111 /* synopsis: P3 columns in r[P2] */
12840 #define OP_Close 112
12841 #define OP_ColumnsUsed 113
12842 #define OP_Sequence 114 /* synopsis: r[P2]=cursor[P1].ctr++ */
12843 #define OP_NewRowid 115 /* synopsis: r[P2]=rowid */
12844 #define OP_Insert 116 /* synopsis: intkey=r[P3] data=r[P2] */
12845 #define OP_InsertInt 117 /* synopsis: intkey=P3 data=r[P2] */
12846 #define OP_Delete 118
12847 #define OP_ResetCount 119
12848 #define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
12849 #define OP_SorterData 121 /* synopsis: r[P2]=data */
12850 #define OP_RowData 122 /* synopsis: r[P2]=data */
12851 #define OP_Rowid 123 /* synopsis: r[P2]=rowid */
12852 #define OP_NullRow 124
12853 #define OP_SorterInsert 125 /* synopsis: key=r[P2] */
12854 #define OP_IdxInsert 126 /* synopsis: key=r[P2] */
12855 #define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */
12856 #define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */
12857 #define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */
12858 #define OP_Destroy 130
12859 #define OP_Clear 131
12860 #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
12861 #define OP_ResetSorter 133
12862 #define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */
12863 #define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */
12864 #define OP_SqlExec 136
12865 #define OP_ParseSchema 137
12866 #define OP_LoadAnalysis 138
12867 #define OP_DropTable 139
12868 #define OP_DropIndex 140
12869 #define OP_DropTrigger 141
12870 #define OP_IntegrityCk 142
12871 #define OP_RowSetAdd 143 /* synopsis: rowset(P1)=r[P2] */
12872 #define OP_Param 144
12873 #define OP_FkCounter 145 /* synopsis: fkctr[P1]+=P2 */
12874 #define OP_MemMax 146 /* synopsis: r[P1]=max(r[P1],r[P2]) */
12875 #define OP_OffsetLimit 147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
12876 #define OP_AggStep0 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12877 #define OP_AggStep 149 /* synopsis: accum=r[P3] step(r[P2@P5]) */
12878 #define OP_AggFinal 150 /* synopsis: accum=r[P1] N=P2 */
12879 #define OP_Expire 151
12880 #define OP_TableLock 152 /* synopsis: iDb=P1 root=P2 write=P3 */
12881 #define OP_VBegin 153
12882 #define OP_VCreate 154
12883 #define OP_VDestroy 155
12884 #define OP_VOpen 156
12885 #define OP_VColumn 157 /* synopsis: r[P3]=vcolumn(P2) */
12886 #define OP_VRename 158
12887 #define OP_Pagecount 159
12888 #define OP_MaxPgcnt 160
12889 #define OP_CursorHint 161
12890 #define OP_Noop 162
12891 #define OP_Explain 163
12892
12893 /* Properties such as "out2" or "jump" that are specified in
12894 ** comments following the "case" for each opcode in the vdbe.c
12895 ** are encoded into bitvectors as follows:
12896 */
@@ -12883,32 +12906,32 @@
12906 /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\
12907 /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\
12908 /* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
12909 /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\
12910 /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\
12911 /* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23,\
12912 /* 64 */ 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01,\
12913 /* 72 */ 0x01, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\
12914 /* 80 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\
12915 /* 88 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\
12916 /* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
12917 /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
12918 /* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\
12919 /* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\
12920 /* 128 */ 0x00, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\
12921 /* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\
12922 /* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\
12923 /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
12924 /* 160 */ 0x10, 0x00, 0x00, 0x00,}
12925
12926 /* The sqlite3P2Values() routine is able to run faster if it knows
12927 ** the value of the largest JUMP opcode. The smaller the maximum
12928 ** JUMP opcode the better, so the mkopcodeh.tcl script that
12929 ** generated this include file strives to group all JUMP opcodes
12930 ** together near the beginning of the list.
12931 */
12932 #define SQLITE_MX_JUMP_OPCODE 72 /* Maximum JUMP opcode */
12933
12934 /************** End of opcodes.h *********************************************/
12935 /************** Continuing where we left off in vdbe.h ***********************/
12936
12937 /*
@@ -14074,10 +14097,11 @@
14097 u8 suppressErr; /* Do not issue error messages if true */
14098 u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
14099 u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
14100 u8 mTrace; /* zero or more SQLITE_TRACE flags */
14101 u8 skipBtreeMutex; /* True if no shared-cache backends */
14102 u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
14103 int nextPagesize; /* Pagesize after VACUUM if >0 */
14104 u32 magic; /* Magic number for detect library misuse */
14105 int nChange; /* Value returned by sqlite3_changes() */
14106 int nTotalChange; /* Value returned by sqlite3_total_changes() */
14107 int aLimit[SQLITE_N_LIMIT]; /* Limits */
@@ -14589,18 +14613,18 @@
14613 char *zColAff; /* String defining the affinity of each column */
14614 ExprList *pCheck; /* All CHECK constraints */
14615 /* ... also used as column name list in a VIEW */
14616 int tnum; /* Root BTree page for this table */
14617 u32 nTabRef; /* Number of pointers to this Table */
14618 u32 tabFlags; /* Mask of TF_* values */
14619 i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
14620 i16 nCol; /* Number of columns in this table */
14621 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
14622 LogEst szTabRow; /* Estimated size of each table row in bytes */
14623 #ifdef SQLITE_ENABLE_COSTMULT
14624 LogEst costMult; /* Cost multiplier for using this table */
14625 #endif
 
14626 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
14627 #ifndef SQLITE_OMIT_ALTERTABLE
14628 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
14629 #endif
14630 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -14620,27 +14644,29 @@
14644 ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
14645 ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
14646 ** the TF_OOOHidden attribute would apply in this case. Such tables require
14647 ** special handling during INSERT processing.
14648 */
14649 #define TF_Readonly 0x0001 /* Read-only system table */
14650 #define TF_Ephemeral 0x0002 /* An ephemeral table */
14651 #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */
14652 #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */
14653 #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */
14654 #define TF_WithoutRowid 0x0020 /* No rowid. PRIMARY KEY is the key */
14655 #define TF_NoVisibleRowid 0x0040 /* No user-visible "rowid" column */
14656 #define TF_OOOHidden 0x0080 /* Out-of-Order hidden columns */
14657 #define TF_StatsUsed 0x0100 /* Query planner decisions affected by
14658 ** Index.aiRowLogEst[] values */
14659 #define TF_HasNotNull 0x0200 /* Contains NOT NULL constraints */
14660
14661 /*
14662 ** Test to see whether or not a table is a virtual table. This is
14663 ** done as a macro so that it will be optimized out when virtual
14664 ** table support is omitted from the build.
14665 */
14666 #ifndef SQLITE_OMIT_VIRTUALTABLE
14667 # define IsVirtual(X) ((X)->nModuleArg)
14668 #else
14669 # define IsVirtual(X) 0
14670 #endif
14671
14672 /*
@@ -14871,10 +14897,11 @@
14897 unsigned bUnordered:1; /* Use this index for == or IN queries only */
14898 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
14899 unsigned isResized:1; /* True if resizeIndexObject() has been called */
14900 unsigned isCovering:1; /* True if this is a covering index */
14901 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
14902 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
14903 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
14904 int nSample; /* Number of elements in aSample[] */
14905 int nSampleCol; /* Size of IndexSample.anEq[] and so on */
14906 tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
14907 IndexSample *aSample; /* Samples of the left-most key */
@@ -15181,11 +15208,11 @@
15208 ** form is used for name resolution with nested FROM clauses.
15209 */
15210 struct ExprList {
15211 int nExpr; /* Number of expressions on the list */
15212 struct ExprList_item { /* For each expression in the list */
15213 Expr *pExpr; /* The parse tree for this expression */
15214 char *zName; /* Token associated with this expression */
15215 char *zSpan; /* Original text of the expression */
15216 u8 sortOrder; /* 1 for DESC or 0 for ASC */
15217 unsigned done :1; /* A flag to indicate when processing is finished */
15218 unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */
@@ -16504,10 +16531,11 @@
16531 SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
16532 SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
16533 SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
16534 SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
16535 SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int);
16536 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
16537 SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int);
16538 SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
16539 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
16540 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
16541 SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
@@ -17450,11 +17478,11 @@
17478 "COMPILER=gcc-" __VERSION__,
17479 #endif
17480 #if SQLITE_COVERAGE_TEST
17481 "COVERAGE_TEST",
17482 #endif
17483 #ifdef SQLITE_DEBUG
17484 "DEBUG",
17485 #endif
17486 #if SQLITE_DEFAULT_LOCKING_MODE
17487 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
17488 #endif
@@ -19505,22 +19533,23 @@
19533 **
19534 ** Move the date backwards to the beginning of the current day,
19535 ** or month or year.
19536 */
19537 if( sqlite3_strnicmp(z, "start of ", 9)!=0 ) break;
19538 if( !p->validJD && !p->validYMD && !p->validHMS ) break;
19539 z += 9;
19540 computeYMD(p);
19541 p->validHMS = 1;
19542 p->h = p->m = 0;
19543 p->s = 0.0;
19544 p->rawS = 0;
19545 p->validTZ = 0;
19546 p->validJD = 0;
19547 if( sqlite3_stricmp(z,"month")==0 ){
19548 p->D = 1;
19549 rc = 0;
19550 }else if( sqlite3_stricmp(z,"year")==0 ){
 
19551 p->M = 1;
19552 p->D = 1;
19553 rc = 0;
19554 }else if( sqlite3_stricmp(z,"day")==0 ){
19555 rc = 0;
@@ -24050,12 +24079,12 @@
24079 #ifdef SQLITE_DEBUG
24080 assert( p->nRef>0 || p->owner==0 );
24081 p->owner = tid;
24082 p->nRef++;
24083 if( p->trace ){
24084 OSTRACE(("ENTER-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\n",
24085 tid, p->id, p, p->trace, p->nRef));
24086 }
24087 #endif
24088 }
24089
24090 static int winMutexTry(sqlite3_mutex *p){
@@ -24093,12 +24122,12 @@
24122 #else
24123 UNUSED_PARAMETER(p);
24124 #endif
24125 #ifdef SQLITE_DEBUG
24126 if( p->trace ){
24127 OSTRACE(("TRY-MUTEX tid=%lu, mutex(%d)=%p (%d), owner=%lu, nRef=%d, rc=%s\n",
24128 tid, p->id, p, p->trace, p->owner, p->nRef, sqlite3ErrName(rc)));
24129 }
24130 #endif
24131 return rc;
24132 }
24133
@@ -24122,12 +24151,12 @@
24151 #endif
24152 assert( winMutex_isInit==1 );
24153 LeaveCriticalSection(&p->mutex);
24154 #ifdef SQLITE_DEBUG
24155 if( p->trace ){
24156 OSTRACE(("LEAVE-MUTEX tid=%lu, mutex(%d)=%p (%d), nRef=%d\n",
24157 tid, p->id, p, p->trace, p->nRef));
24158 }
24159 #endif
24160 }
24161
24162 SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
@@ -24572,11 +24601,11 @@
24601 return sqlite3GlobalConfig.m.xSize(p);
24602 }
24603 SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
24604 assert( p!=0 );
24605 if( db==0 || !isLookaside(db,p) ){
24606 #ifdef SQLITE_DEBUG
24607 if( db==0 ){
24608 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
24609 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
24610 }else{
24611 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
@@ -24633,11 +24662,11 @@
24662 measureAllocationSize(db, p);
24663 return;
24664 }
24665 if( isLookaside(db, p) ){
24666 LookasideSlot *pBuf = (LookasideSlot*)p;
24667 #ifdef SQLITE_DEBUG
24668 /* Trash all content in the buffer being freed */
24669 memset(p, 0xaa, db->lookaside.sz);
24670 #endif
24671 pBuf->pNext = db->lookaside.pFree;
24672 db->lookaside.pFree = pBuf;
@@ -25002,11 +25031,11 @@
25031
25032 /*
25033 ** Conversion types fall into various categories as defined by the
25034 ** following enumeration.
25035 */
25036 #define etRADIX 0 /* non-decimal integer types. %x %o */
25037 #define etFLOAT 1 /* Floating point. %f */
25038 #define etEXP 2 /* Exponentional notation. %e and %E */
25039 #define etGENERIC 3 /* Floating or exponential, depending on exponent. %g */
25040 #define etSIZE 4 /* Return number of characters processed so far. %n */
25041 #define etSTRING 5 /* Strings. %s */
@@ -25020,12 +25049,13 @@
25049 #define etTOKEN 11 /* a pointer to a Token structure */
25050 #define etSRCLIST 12 /* a pointer to a SrcList */
25051 #define etPOINTER 13 /* The %p conversion */
25052 #define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */
25053 #define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */
25054 #define etDECIMAL 16 /* %d or %u, but not %x, %o */
25055
25056 #define etINVALID 17 /* Any unrecognized conversion type */
25057
25058
25059 /*
25060 ** An "etByte" is an 8-bit unsigned value.
25061 */
@@ -25045,40 +25075,40 @@
25075 } et_info;
25076
25077 /*
25078 ** Allowed values for et_info.flags
25079 */
25080 #define FLAG_SIGNED 1 /* True if the value to convert is signed */
25081 #define FLAG_STRING 4 /* Allow infinite precision */
25082
25083
25084 /*
25085 ** The following table is searched linearly, so it is good to put the
25086 ** most frequently used conversion types first.
25087 */
25088 static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
25089 static const char aPrefix[] = "-x0\000X0";
25090 static const et_info fmtinfo[] = {
25091 { 'd', 10, 1, etDECIMAL, 0, 0 },
25092 { 's', 0, 4, etSTRING, 0, 0 },
25093 { 'g', 0, 1, etGENERIC, 30, 0 },
25094 { 'z', 0, 4, etDYNSTRING, 0, 0 },
25095 { 'q', 0, 4, etSQLESCAPE, 0, 0 },
25096 { 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
25097 { 'w', 0, 4, etSQLESCAPE3, 0, 0 },
25098 { 'c', 0, 0, etCHARX, 0, 0 },
25099 { 'o', 8, 0, etRADIX, 0, 2 },
25100 { 'u', 10, 0, etDECIMAL, 0, 0 },
25101 { 'x', 16, 0, etRADIX, 16, 1 },
25102 { 'X', 16, 0, etRADIX, 0, 4 },
25103 #ifndef SQLITE_OMIT_FLOATING_POINT
25104 { 'f', 0, 1, etFLOAT, 0, 0 },
25105 { 'e', 0, 1, etEXP, 30, 0 },
25106 { 'E', 0, 1, etEXP, 14, 0 },
25107 { 'G', 0, 1, etGENERIC, 14, 0 },
25108 #endif
25109 { 'i', 10, 1, etDECIMAL, 0, 0 },
25110 { 'n', 0, 0, etSIZE, 0, 0 },
25111 { '%', 0, 0, etPERCENT, 0, 0 },
25112 { 'p', 16, 0, etPOINTER, 0, 1 },
25113
25114 /* All the rest are undocumented and are for internal use only */
@@ -25166,18 +25196,17 @@
25196 int precision; /* Precision of the current field */
25197 int length; /* Length of the field */
25198 int idx; /* A general purpose loop counter */
25199 int width; /* Width of the current field */
25200 etByte flag_leftjustify; /* True if "-" flag is present */
25201 etByte flag_prefix; /* '+' or ' ' or 0 for prefix */
 
25202 etByte flag_alternateform; /* True if "#" flag is present */
25203 etByte flag_altform2; /* True if "!" flag is present */
25204 etByte flag_zeropad; /* True if field width constant starts with zero */
25205 etByte flag_long; /* 1 for the "l" flag, 2 for "ll", 0 by default */
 
25206 etByte done; /* Loop termination flag */
25207 etByte cThousand; /* Thousands separator for %d and %u */
25208 etByte xtype = etINVALID; /* Conversion paradigm */
25209 u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */
25210 char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
25211 sqlite_uint64 longvalue; /* Value for integer types */
25212 LONGDOUBLE_TYPE realvalue; /* Value for real types */
@@ -25216,21 +25245,22 @@
25245 if( (c=(*++fmt))==0 ){
25246 sqlite3StrAccumAppend(pAccum, "%", 1);
25247 break;
25248 }
25249 /* Find out what flags are present */
25250 flag_leftjustify = flag_prefix = cThousand =
25251 flag_alternateform = flag_altform2 = flag_zeropad = 0;
25252 done = 0;
25253 do{
25254 switch( c ){
25255 case '-': flag_leftjustify = 1; break;
25256 case '+': flag_prefix = '+'; break;
25257 case ' ': flag_prefix = ' '; break;
25258 case '#': flag_alternateform = 1; break;
25259 case '!': flag_altform2 = 1; break;
25260 case '0': flag_zeropad = 1; break;
25261 case ',': cThousand = ','; break;
25262 default: done = 1; break;
25263 }
25264 }while( !done && (c=(*++fmt))!=0 );
25265 /* Get the field width */
25266 if( c=='*' ){
@@ -25296,17 +25326,15 @@
25326 /* Get the conversion type modifier */
25327 if( c=='l' ){
25328 flag_long = 1;
25329 c = *++fmt;
25330 if( c=='l' ){
25331 flag_long = 2;
25332 c = *++fmt;
 
 
25333 }
25334 }else{
25335 flag_long = 0;
25336 }
25337 /* Fetch the info entry for the field */
25338 infop = &fmtinfo[0];
25339 xtype = etINVALID;
25340 for(idx=0; idx<ArraySize(fmtinfo); idx++){
@@ -25320,41 +25348,42 @@
25348 /*
25349 ** At this point, variables are initialized as follows:
25350 **
25351 ** flag_alternateform TRUE if a '#' is present.
25352 ** flag_altform2 TRUE if a '!' is present.
25353 ** flag_prefix '+' or ' ' or zero
25354 ** flag_leftjustify TRUE if a '-' is present or if the
25355 ** field width was negative.
25356 ** flag_zeropad TRUE if the width began with 0.
25357 ** flag_long 1 for "l", 2 for "ll"
 
 
 
 
25358 ** width The specified field width. This is
25359 ** always non-negative. Zero is the default.
25360 ** precision The specified precision. The default
25361 ** is -1.
25362 ** xtype The class of the conversion.
25363 ** infop Pointer to the appropriate info struct.
25364 */
25365 switch( xtype ){
25366 case etPOINTER:
25367 flag_long = sizeof(char*)==sizeof(i64) ? 2 :
25368 sizeof(char*)==sizeof(long int) ? 1 : 0;
25369 /* Fall through into the next case */
25370 case etORDINAL:
25371 case etRADIX:
25372 cThousand = 0;
25373 /* Fall through into the next case */
25374 case etDECIMAL:
25375 if( infop->flags & FLAG_SIGNED ){
25376 i64 v;
25377 if( bArgList ){
25378 v = getIntArg(pArgList);
 
 
25379 }else if( flag_long ){
25380 if( flag_long==2 ){
25381 v = va_arg(ap,i64) ;
25382 }else{
25383 v = va_arg(ap,long int);
25384 }
25385 }else{
25386 v = va_arg(ap,int);
25387 }
25388 if( v<0 ){
25389 if( v==SMALLEST_INT64 ){
@@ -25363,35 +25392,35 @@
25392 longvalue = -v;
25393 }
25394 prefix = '-';
25395 }else{
25396 longvalue = v;
25397 prefix = flag_prefix;
 
 
25398 }
25399 }else{
25400 if( bArgList ){
25401 longvalue = (u64)getIntArg(pArgList);
 
 
25402 }else if( flag_long ){
25403 if( flag_long==2 ){
25404 longvalue = va_arg(ap,u64);
25405 }else{
25406 longvalue = va_arg(ap,unsigned long int);
25407 }
25408 }else{
25409 longvalue = va_arg(ap,unsigned int);
25410 }
25411 prefix = 0;
25412 }
25413 if( longvalue==0 ) flag_alternateform = 0;
25414 if( flag_zeropad && precision<width-(prefix!=0) ){
25415 precision = width-(prefix!=0);
25416 }
25417 if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
25418 nOut = etBUFSIZE;
25419 zOut = buf;
25420 }else{
25421 nOut = precision + 10 + precision/3;
25422 zOut = zExtra = sqlite3Malloc( nOut );
25423 if( zOut==0 ){
25424 setStrAccumError(pAccum, STRACCUM_NOMEM);
25425 return;
25426 }
@@ -25413,12 +25442,27 @@
25442 *(--bufpt) = cset[longvalue%base];
25443 longvalue = longvalue/base;
25444 }while( longvalue>0 );
25445 }
25446 length = (int)(&zOut[nOut-1]-bufpt);
25447 while( precision>length ){
25448 *(--bufpt) = '0'; /* Zero pad */
25449 length++;
25450 }
25451 if( cThousand ){
25452 int nn = (length - 1)/3; /* Number of "," to insert */
25453 int ix = (length - 1)%3 + 1;
25454 bufpt -= nn;
25455 for(idx=0; nn>0; idx++){
25456 bufpt[idx] = bufpt[idx+nn];
25457 ix--;
25458 if( ix==0 ){
25459 bufpt[++idx] = cThousand;
25460 nn--;
25461 ix = 3;
25462 }
25463 }
25464 }
25465 if( prefix ) *(--bufpt) = prefix; /* Add sign */
25466 if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
25467 const char *pre;
25468 char x;
@@ -25441,13 +25485,11 @@
25485 if( precision<0 ) precision = 6; /* Set default precision */
25486 if( realvalue<0.0 ){
25487 realvalue = -realvalue;
25488 prefix = '-';
25489 }else{
25490 prefix = flag_prefix;
 
 
25491 }
25492 if( xtype==etGENERIC && precision>0 ) precision--;
25493 testcase( precision>0xfff );
25494 for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
25495 if( xtype==etFLOAT ) realvalue += rounder;
@@ -29464,117 +29506,119 @@
29506 /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
29507 /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
29508 /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
29509 /* 53 */ "Last" OpHelp(""),
29510 /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"),
29511 /* 55 */ "IfSmaller" OpHelp(""),
29512 /* 56 */ "SorterSort" OpHelp(""),
29513 /* 57 */ "Sort" OpHelp(""),
29514 /* 58 */ "Rewind" OpHelp(""),
29515 /* 59 */ "IdxLE" OpHelp("key=r[P3@P4]"),
29516 /* 60 */ "IdxGT" OpHelp("key=r[P3@P4]"),
29517 /* 61 */ "IdxLT" OpHelp("key=r[P3@P4]"),
29518 /* 62 */ "IdxGE" OpHelp("key=r[P3@P4]"),
29519 /* 63 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
29520 /* 64 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
29521 /* 65 */ "Program" OpHelp(""),
29522 /* 66 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
29523 /* 67 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
29524 /* 68 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
29525 /* 69 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
29526 /* 70 */ "IncrVacuum" OpHelp(""),
29527 /* 71 */ "VNext" OpHelp(""),
29528 /* 72 */ "Init" OpHelp("Start at P2"),
29529 /* 73 */ "Return" OpHelp(""),
29530 /* 74 */ "EndCoroutine" OpHelp(""),
29531 /* 75 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
29532 /* 76 */ "Halt" OpHelp(""),
29533 /* 77 */ "Integer" OpHelp("r[P2]=P1"),
29534 /* 78 */ "Int64" OpHelp("r[P2]=P4"),
29535 /* 79 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
29536 /* 80 */ "Null" OpHelp("r[P2..P3]=NULL"),
29537 /* 81 */ "SoftNull" OpHelp("r[P1]=NULL"),
29538 /* 82 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
29539 /* 83 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
29540 /* 84 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
29541 /* 85 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
29542 /* 86 */ "SCopy" OpHelp("r[P2]=r[P1]"),
29543 /* 87 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
29544 /* 88 */ "ResultRow" OpHelp("output=r[P1@P2]"),
29545 /* 89 */ "CollSeq" OpHelp(""),
29546 /* 90 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"),
29547 /* 91 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"),
29548 /* 92 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
29549 /* 93 */ "RealAffinity" OpHelp(""),
29550 /* 94 */ "Cast" OpHelp("affinity(r[P1])"),
29551 /* 95 */ "Permutation" OpHelp(""),
29552 /* 96 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
29553 /* 97 */ "String8" OpHelp("r[P2]='P4'"),
29554 /* 98 */ "Column" OpHelp("r[P3]=PX"),
29555 /* 99 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
29556 /* 100 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
29557 /* 101 */ "Count" OpHelp("r[P2]=count()"),
29558 /* 102 */ "ReadCookie" OpHelp(""),
29559 /* 103 */ "SetCookie" OpHelp(""),
29560 /* 104 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
29561 /* 105 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
29562 /* 106 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
29563 /* 107 */ "OpenAutoindex" OpHelp("nColumn=P2"),
29564 /* 108 */ "OpenEphemeral" OpHelp("nColumn=P2"),
29565 /* 109 */ "SorterOpen" OpHelp(""),
29566 /* 110 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
29567 /* 111 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
29568 /* 112 */ "Close" OpHelp(""),
29569 /* 113 */ "ColumnsUsed" OpHelp(""),
29570 /* 114 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
29571 /* 115 */ "NewRowid" OpHelp("r[P2]=rowid"),
29572 /* 116 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
29573 /* 117 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"),
29574 /* 118 */ "Delete" OpHelp(""),
29575 /* 119 */ "ResetCount" OpHelp(""),
29576 /* 120 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
29577 /* 121 */ "SorterData" OpHelp("r[P2]=data"),
29578 /* 122 */ "RowData" OpHelp("r[P2]=data"),
29579 /* 123 */ "Rowid" OpHelp("r[P2]=rowid"),
29580 /* 124 */ "NullRow" OpHelp(""),
29581 /* 125 */ "SorterInsert" OpHelp("key=r[P2]"),
29582 /* 126 */ "IdxInsert" OpHelp("key=r[P2]"),
29583 /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
29584 /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"),
29585 /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"),
29586 /* 130 */ "Destroy" OpHelp(""),
29587 /* 131 */ "Clear" OpHelp(""),
29588 /* 132 */ "Real" OpHelp("r[P2]=P4"),
29589 /* 133 */ "ResetSorter" OpHelp(""),
29590 /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"),
29591 /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"),
29592 /* 136 */ "SqlExec" OpHelp(""),
29593 /* 137 */ "ParseSchema" OpHelp(""),
29594 /* 138 */ "LoadAnalysis" OpHelp(""),
29595 /* 139 */ "DropTable" OpHelp(""),
29596 /* 140 */ "DropIndex" OpHelp(""),
29597 /* 141 */ "DropTrigger" OpHelp(""),
29598 /* 142 */ "IntegrityCk" OpHelp(""),
29599 /* 143 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
29600 /* 144 */ "Param" OpHelp(""),
29601 /* 145 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
29602 /* 146 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
29603 /* 147 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
29604 /* 148 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"),
29605 /* 149 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
29606 /* 150 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
29607 /* 151 */ "Expire" OpHelp(""),
29608 /* 152 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
29609 /* 153 */ "VBegin" OpHelp(""),
29610 /* 154 */ "VCreate" OpHelp(""),
29611 /* 155 */ "VDestroy" OpHelp(""),
29612 /* 156 */ "VOpen" OpHelp(""),
29613 /* 157 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
29614 /* 158 */ "VRename" OpHelp(""),
29615 /* 159 */ "Pagecount" OpHelp(""),
29616 /* 160 */ "MaxPgcnt" OpHelp(""),
29617 /* 161 */ "CursorHint" OpHelp(""),
29618 /* 162 */ "Noop" OpHelp(""),
29619 /* 163 */ "Explain" OpHelp(""),
29620 };
29621 return azName[i];
29622 }
29623 #endif
29624
@@ -37952,46 +37996,84 @@
37996 * be freed immediately and any attempt to access any of that freed
37997 * data will almost certainly result in an immediate access violation.
37998 ******************************************************************************
37999 */
38000 #ifndef SQLITE_WIN32_HEAP_CREATE
38001 # define SQLITE_WIN32_HEAP_CREATE (TRUE)
38002 #endif
38003
38004 /*
38005 * This is the maximum possible initial size of the Win32-specific heap, in
38006 * bytes.
38007 */
38008 #ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE
38009 # define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U)
38010 #endif
38011
38012 /*
38013 * This is the extra space for the initial size of the Win32-specific heap,
38014 * in bytes. This value may be zero.
38015 */
38016 #ifndef SQLITE_WIN32_HEAP_INIT_EXTRA
38017 # define SQLITE_WIN32_HEAP_INIT_EXTRA (4194304)
38018 #endif
38019
38020 /*
38021 * Calculate the maximum legal cache size, in pages, based on the maximum
38022 * possible initial heap size and the default page size, setting aside the
38023 * needed extra space.
38024 */
38025 #ifndef SQLITE_WIN32_MAX_CACHE_SIZE
38026 # define SQLITE_WIN32_MAX_CACHE_SIZE (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \
38027 (SQLITE_WIN32_HEAP_INIT_EXTRA)) / \
38028 (SQLITE_DEFAULT_PAGE_SIZE))
38029 #endif
38030
38031 /*
38032 * This is cache size used in the calculation of the initial size of the
38033 * Win32-specific heap. It cannot be negative.
38034 */
38035 #ifndef SQLITE_WIN32_CACHE_SIZE
38036 # if SQLITE_DEFAULT_CACHE_SIZE>=0
38037 # define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE)
38038 # else
38039 # define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE))
38040 # endif
38041 #endif
38042
38043 /*
38044 * Make sure that the calculated cache size, in pages, cannot cause the
38045 * initial size of the Win32-specific heap to exceed the maximum amount
38046 * of memory that can be specified in the call to HeapCreate.
38047 */
38048 #if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE
38049 # undef SQLITE_WIN32_CACHE_SIZE
38050 # define SQLITE_WIN32_CACHE_SIZE (2000)
38051 #endif
38052
38053 /*
38054 * The initial size of the Win32-specific heap. This value may be zero.
38055 */
38056 #ifndef SQLITE_WIN32_HEAP_INIT_SIZE
38057 # define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \
38058 (SQLITE_DEFAULT_PAGE_SIZE) + \
38059 (SQLITE_WIN32_HEAP_INIT_EXTRA))
38060 #endif
38061
38062 /*
38063 * The maximum size of the Win32-specific heap. This value may be zero.
38064 */
38065 #ifndef SQLITE_WIN32_HEAP_MAX_SIZE
38066 # define SQLITE_WIN32_HEAP_MAX_SIZE (0)
38067 #endif
38068
38069 /*
38070 * The extra flags to use in calls to the Win32 heap APIs. This value may be
38071 * zero for the default behavior.
38072 */
38073 #ifndef SQLITE_WIN32_HEAP_FLAGS
38074 # define SQLITE_WIN32_HEAP_FLAGS (0)
38075 #endif
38076
38077
38078 /*
38079 ** The winMemData structure stores information required by the Win32-specific
@@ -44084,11 +44166,11 @@
44166 ** This routine is for use inside of assert() statements only. For
44167 ** example:
44168 **
44169 ** assert( sqlite3PcachePageSanity(pPg) );
44170 */
44171 #ifdef SQLITE_DEBUG
44172 SQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){
44173 PCache *pCache;
44174 assert( pPg!=0 );
44175 assert( pPg->pgno>0 || pPg->pPager==0 ); /* Page number is 1 or more */
44176 pCache = pPg->pCache;
@@ -60177,21 +60259,22 @@
60259 }
60260 #endif
60261
60262
60263 /*
60264 ** Defragment the page given. This routine reorganizes cells within the
60265 ** page so that there are no free-blocks on the free-block list.
60266 **
60267 ** Parameter nMaxFrag is the maximum amount of fragmented space that may be
60268 ** present in the page after this routine returns.
60269 **
60270 ** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a
60271 ** b-tree page so that there are no freeblocks or fragment bytes, all
60272 ** unused bytes are contained in the unallocated space region, and all
60273 ** cells are packed tightly at the end of the page.
60274 */
60275 static int defragmentPage(MemPage *pPage, int nMaxFrag){
60276 int i; /* Loop counter */
60277 int pc; /* Address of the i-th cell */
60278 int hdr; /* Offset to the page header */
60279 int size; /* Size of a cell */
60280 int usableSize; /* Number of usable bytes on a page */
@@ -60202,11 +60285,10 @@
60285 unsigned char *temp; /* Temp area for cell content */
60286 unsigned char *src; /* Source of content */
60287 int iCellFirst; /* First allowable cell index */
60288 int iCellLast; /* Last possible cell index */
60289
 
60290 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
60291 assert( pPage->pBt!=0 );
60292 assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
60293 assert( pPage->nOverflow==0 );
60294 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
@@ -60214,13 +60296,60 @@
60296 src = data = pPage->aData;
60297 hdr = pPage->hdrOffset;
60298 cellOffset = pPage->cellOffset;
60299 nCell = pPage->nCell;
60300 assert( nCell==get2byte(&data[hdr+3]) );
60301 iCellFirst = cellOffset + 2*nCell;
60302 usableSize = pPage->pBt->usableSize;
60303
60304 /* This block handles pages with two or fewer free blocks and nMaxFrag
60305 ** or fewer fragmented bytes. In this case it is faster to move the
60306 ** two (or one) blocks of cells using memmove() and add the required
60307 ** offsets to each pointer in the cell-pointer array than it is to
60308 ** reconstruct the entire page. */
60309 if( (int)data[hdr+7]<=nMaxFrag ){
60310 int iFree = get2byte(&data[hdr+1]);
60311 if( iFree ){
60312 int iFree2 = get2byte(&data[iFree]);
60313
60314 /* pageFindSlot() has already verified that free blocks are sorted
60315 ** in order of offset within the page, and that no block extends
60316 ** past the end of the page. Provided the two free slots do not
60317 ** overlap, this guarantees that the memmove() calls below will not
60318 ** overwrite the usableSize byte buffer, even if the database page
60319 ** is corrupt. */
60320 assert( iFree2==0 || iFree2>iFree );
60321 assert( iFree+get2byte(&data[iFree+2]) <= usableSize );
60322 assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize );
60323
60324 if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
60325 u8 *pEnd = &data[cellOffset + nCell*2];
60326 u8 *pAddr;
60327 int sz2 = 0;
60328 int sz = get2byte(&data[iFree+2]);
60329 int top = get2byte(&data[hdr+5]);
60330 if( iFree2 ){
60331 if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_BKPT;
60332 sz2 = get2byte(&data[iFree2+2]);
60333 assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
60334 memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
60335 sz += sz2;
60336 }
60337 cbrk = top+sz;
60338 assert( cbrk+(iFree-top) <= usableSize );
60339 memmove(&data[cbrk], &data[top], iFree-top);
60340 for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){
60341 pc = get2byte(pAddr);
60342 if( pc<iFree ){ put2byte(pAddr, pc+sz); }
60343 else if( pc<iFree2 ){ put2byte(pAddr, pc+sz2); }
60344 }
60345 goto defragment_out;
60346 }
60347 }
60348 }
60349
60350 cbrk = usableSize;
 
60351 iCellLast = usableSize - 4;
60352 for(i=0; i<nCell; i++){
60353 u8 *pAddr; /* The i-th cell pointer */
60354 pAddr = &data[cellOffset + i*2];
60355 pc = get2byte(pAddr);
@@ -60250,20 +60379,22 @@
60379 memcpy(&temp[x], &data[x], (cbrk+size) - x);
60380 src = temp;
60381 }
60382 memcpy(&data[cbrk], &src[pc], size);
60383 }
60384 data[hdr+7] = 0;
60385
60386 defragment_out:
60387 if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){
60388 return SQLITE_CORRUPT_BKPT;
60389 }
60390 assert( cbrk>=iCellFirst );
60391 put2byte(&data[hdr+5], cbrk);
60392 data[hdr+1] = 0;
60393 data[hdr+2] = 0;
 
60394 memset(&data[iCellFirst], 0, cbrk-iCellFirst);
60395 assert( sqlite3PagerIswriteable(pPage->pDbPage) );
 
 
 
60396 return SQLITE_OK;
60397 }
60398
60399 /*
60400 ** Search the free-list on page pPg for space to store a cell nByte bytes in
@@ -60397,14 +60528,14 @@
60528 ** to see if defragmentation is necessary.
60529 */
60530 testcase( gap+2+nByte==top );
60531 if( gap+2+nByte>top ){
60532 assert( pPage->nCell>0 || CORRUPT_DB );
60533 rc = defragmentPage(pPage, MIN(4, pPage->nFree - (2+nByte)));
60534 if( rc ) return rc;
60535 top = get2byteNotZero(&data[hdr+5]);
60536 assert( gap+2+nByte<=top );
60537 }
60538
60539
60540 /* Allocate memory from the gap in between the cell pointer array
60541 ** and the cell content area. The btreeInitPage() call has already
@@ -63636,11 +63767,11 @@
63767 pCur->aiIdx[pCur->iPage] = 0;
63768 return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage],
63769 pCur, pCur->curPagerFlags);
63770 }
63771
63772 #ifdef SQLITE_DEBUG
63773 /*
63774 ** Page pParent is an internal (non-leaf) tree page. This function
63775 ** asserts that page number iChild is the left-child if the iIdx'th
63776 ** cell in page pParent. Or, if iIdx is equal to the total number of
63777 ** cells in pParent, that page number iChild is the right-child of
@@ -64178,10 +64309,34 @@
64309 ** have been deleted? This API will need to change to return an error code
64310 ** as well as the boolean result value.
64311 */
64312 return (CURSOR_VALID!=pCur->eState);
64313 }
64314
64315 /*
64316 ** Return an estimate for the number of rows in the table that pCur is
64317 ** pointing to. Return a negative number if no estimate is currently
64318 ** available.
64319 */
64320 SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor *pCur){
64321 i64 n;
64322 u8 i;
64323
64324 assert( cursorOwnsBtShared(pCur) );
64325 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
64326
64327 /* Currently this interface is only called by the OP_IfSmaller
64328 ** opcode, and it that case the cursor will always be valid and
64329 ** will always point to a leaf node. */
64330 if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1;
64331 if( NEVER(pCur->apPage[pCur->iPage]->leaf==0) ) return -1;
64332
64333 for(n=1, i=0; i<=pCur->iPage; i++){
64334 n *= pCur->apPage[i]->nCell;
64335 }
64336 return n;
64337 }
64338
64339 /*
64340 ** Advance the cursor to the next entry in the database. If
64341 ** successful then set *pRes=0. If the cursor
64342 ** was already pointing to the last entry in the database before
@@ -65023,11 +65178,11 @@
65178 ** pPrior Where to write the pgno of the first overflow page
65179 **
65180 ** Use a call to btreeParseCellPtr() to verify that the values above
65181 ** were computed correctly.
65182 */
65183 #ifdef SQLITE_DEBUG
65184 {
65185 CellInfo info;
65186 pPage->xParseCell(pPage, pCell, &info);
65187 assert( nHeader==(int)(info.pPayload - pCell) );
65188 assert( info.nKey==pX->nKey );
@@ -66549,11 +66704,11 @@
66704 ** copied into the parent, because if the parent is page 1 then it will
66705 ** by smaller than the child due to the database header, and so all the
66706 ** free space needs to be up front.
66707 */
66708 assert( nNew==1 || CORRUPT_DB );
66709 rc = defragmentPage(apNew[0], -1);
66710 testcase( rc!=SQLITE_OK );
66711 assert( apNew[0]->nFree ==
66712 (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)
66713 || rc!=SQLITE_OK
66714 );
@@ -71201,10 +71356,11 @@
71356 ** Remember the SQL string for a prepared statement.
71357 */
71358 SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){
71359 assert( isPrepareV2==1 || isPrepareV2==0 );
71360 if( p==0 ) return;
71361 if( !isPrepareV2 ) p->expmask = 0;
71362 #if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG)
71363 if( !isPrepareV2 ) return;
71364 #endif
71365 assert( p->zSql==0 );
71366 p->zSql = sqlite3DbStrNDup(p->db, z, n);
@@ -71229,10 +71385,11 @@
71385 pB->pPrev = pTmp;
71386 zTmp = pA->zSql;
71387 pA->zSql = pB->zSql;
71388 pB->zSql = zTmp;
71389 pB->isPrepareV2 = pA->isPrepareV2;
71390 pB->expmask = pA->expmask;
71391 }
71392
71393 /*
71394 ** Resize the Vdbe.aOp array so that it is at least nOp elements larger
71395 ** than its current size. nOp is guaranteed to be less than or equal
@@ -73753,17 +73910,17 @@
73910 ** Then the internal cache might have been left in an inconsistent
73911 ** state. We need to rollback the statement transaction, if there is
73912 ** one, or the complete transaction if there is no statement transaction.
73913 */
73914
73915 if( p->magic!=VDBE_MAGIC_RUN ){
73916 return SQLITE_OK;
73917 }
73918 if( db->mallocFailed ){
73919 p->rc = SQLITE_NOMEM_BKPT;
73920 }
73921 closeAllCursors(p);
 
 
 
73922 checkActiveVdbeCnt(db);
73923
73924 /* No commit or rollback needed if the program never started or if the
73925 ** SQL statement does not read or write a database file. */
73926 if( p->pc>=0 && p->bIsReader ){
@@ -74706,11 +74863,11 @@
74863 }
74864 assert( u<=pKeyInfo->nField + 1 );
74865 p->nField = u;
74866 }
74867
74868 #ifdef SQLITE_DEBUG
74869 /*
74870 ** This function compares two index or table record keys in the same way
74871 ** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(),
74872 ** this function deserializes and compares values using the
74873 ** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used
@@ -74811,11 +74968,11 @@
74968 if( pKeyInfo->db->mallocFailed ) return 1;
74969 return 0;
74970 }
74971 #endif
74972
74973 #ifdef SQLITE_DEBUG
74974 /*
74975 ** Count the number of fields (a.k.a. columns) in the record given by
74976 ** pKey,nKey. The verify that this count is less than or equal to the
74977 ** limit given by pKeyInfo->nField + pKeyInfo->nXField.
74978 **
@@ -75694,12 +75851,12 @@
75851 ** to sqlite3_reoptimize() that re-preparing the statement may result
75852 ** in a better query plan.
75853 */
75854 SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){
75855 assert( iVar>0 );
75856 if( iVar>=32 ){
75857 v->expmask |= 0x80000000;
75858 }else{
75859 v->expmask |= ((u32)1 << (iVar-1));
75860 }
75861 }
75862
@@ -75965,11 +76122,12 @@
76122 sqlite3_mutex_enter(mutex);
76123 for(i=0; i<p->nVar; i++){
76124 sqlite3VdbeMemRelease(&p->aVar[i]);
76125 p->aVar[i].flags = MEM_Null;
76126 }
76127 assert( p->isPrepareV2 || p->expmask==0 );
76128 if( p->expmask ){
76129 p->expired = 1;
76130 }
76131 sqlite3_mutex_leave(mutex);
76132 return rc;
76133 }
@@ -77069,13 +77227,12 @@
77227 ** parameter in the WHERE clause might influence the choice of query plan
77228 ** for a statement, then the statement will be automatically recompiled,
77229 ** as if there had been a schema change, on the first sqlite3_step() call
77230 ** following any change to the bindings of that parameter.
77231 */
77232 assert( p->isPrepareV2 || p->expmask==0 );
77233 if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){
 
77234 p->expired = 1;
77235 }
77236 return SQLITE_OK;
77237 }
77238
@@ -77334,14 +77491,16 @@
77491 Vdbe *pFrom = (Vdbe*)pFromStmt;
77492 Vdbe *pTo = (Vdbe*)pToStmt;
77493 if( pFrom->nVar!=pTo->nVar ){
77494 return SQLITE_ERROR;
77495 }
77496 assert( pTo->isPrepareV2 || pTo->expmask==0 );
77497 if( pTo->expmask ){
77498 pTo->expired = 1;
77499 }
77500 assert( pFrom->isPrepareV2 || pFrom->expmask==0 );
77501 if( pFrom->expmask ){
77502 pFrom->expired = 1;
77503 }
77504 return sqlite3TransferBindings(pFromStmt, pToStmt);
77505 }
77506 #endif
@@ -79658,39 +79817,39 @@
79817 if( pCtx->pOut != pOut ){
79818 pCtx->pOut = pOut;
79819 for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i];
79820 }
79821
79822 memAboutToChange(p, pOut);
79823 #ifdef SQLITE_DEBUG
79824 for(i=0; i<pCtx->argc; i++){
79825 assert( memIsValid(pCtx->argv[i]) );
79826 REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]);
79827 }
79828 #endif
79829 MemSetTypeFlag(pOut, MEM_Null);
79830 pCtx->fErrorOrAux = 0;
79831 (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */
79832
79833 /* If the function returned an error, throw an exception */
79834 if( pCtx->fErrorOrAux ){
79835 if( pCtx->isError ){
79836 sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut));
79837 rc = pCtx->isError;
79838 }
79839 sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1);
79840 if( rc ) goto abort_due_to_error;
79841 }
79842
79843 /* Copy the result of the function into register P3 */
79844 if( pOut->flags & (MEM_Str|MEM_Blob) ){
79845 sqlite3VdbeChangeEncoding(pOut, encoding);
79846 if( sqlite3VdbeMemTooBig(pOut) ) goto too_big;
79847 }
79848
79849 REGISTER_TRACE(pOp->p3, pOut);
79850 UPDATE_MAX_BLOBSIZE(pOut);
79851 break;
79852 }
79853
79854 /* Opcode: BitAnd P1 P2 P3 * *
79855 ** Synopsis: r[P3]=r[P1]&r[P2]
@@ -80187,11 +80346,11 @@
80346 pKeyInfo = pOp->p4.pKeyInfo;
80347 assert( n>0 );
80348 assert( pKeyInfo!=0 );
80349 p1 = pOp->p1;
80350 p2 = pOp->p2;
80351 #ifdef SQLITE_DEBUG
80352 if( aPermute ){
80353 int k, mx = 0;
80354 for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k];
80355 assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 );
80356 assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 );
@@ -82836,10 +82995,37 @@
82995 assert( pOp->p2==0 );
82996 }
82997 break;
82998 }
82999
83000 /* Opcode: IfSmaller P1 P2 P3 * *
83001 **
83002 ** Estimate the number of rows in the table P1. Jump to P2 if that
83003 ** estimate is less than approximately 2**(0.1*P3).
83004 */
83005 case OP_IfSmaller: { /* jump */
83006 VdbeCursor *pC;
83007 BtCursor *pCrsr;
83008 int res;
83009 i64 sz;
83010
83011 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
83012 pC = p->apCsr[pOp->p1];
83013 assert( pC!=0 );
83014 pCrsr = pC->uc.pCursor;
83015 assert( pCrsr );
83016 rc = sqlite3BtreeFirst(pCrsr, &res);
83017 if( rc ) goto abort_due_to_error;
83018 if( res==0 ){
83019 sz = sqlite3BtreeRowCountEst(pCrsr);
83020 if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1;
83021 }
83022 VdbeBranchTaken(res!=0,2);
83023 if( res ) goto jump_to_p2;
83024 break;
83025 }
83026
83027
83028 /* Opcode: SorterSort P1 P2 * * *
83029 **
83030 ** After all records have been inserted into the Sorter object
83031 ** identified by P1, invoke this opcode to actually do the sorting.
@@ -83479,10 +83665,22 @@
83665 rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, flags);
83666 if( rc ) goto abort_due_to_error;
83667 pOut->u.i = pgno;
83668 break;
83669 }
83670
83671 /* Opcode: SqlExec * * * P4 *
83672 **
83673 ** Run the SQL statement or statements specified in the P4 string.
83674 */
83675 case OP_SqlExec: {
83676 db->nSqlExec++;
83677 rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0);
83678 db->nSqlExec--;
83679 if( rc ) goto abort_due_to_error;
83680 break;
83681 }
83682
83683 /* Opcode: ParseSchema P1 * * P4 *
83684 **
83685 ** Read and parse all entries from the SQLITE_MASTER table of database P1
83686 ** that match the WHERE clause P4.
@@ -83600,11 +83798,11 @@
83798 **
83799 ** Do an analysis of the currently open database. Store in
83800 ** register P1 the text of an error message describing any problems.
83801 ** If no problems are found, store a NULL in register P1.
83802 **
83803 ** The register P3 contains one less than the maximum number of allowed errors.
83804 ** At most reg(P3) errors will be reported.
83805 ** In other words, the analysis stops as soon as reg(P1) errors are
83806 ** seen. Reg(P1) is updated with the number of errors remaining.
83807 **
83808 ** The root page numbers of all tables in the database are integers
@@ -83633,18 +83831,18 @@
83831 assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 );
83832 pIn1 = &aMem[pOp->p1];
83833 assert( pOp->p5<db->nDb );
83834 assert( DbMaskTest(p->btreeMask, pOp->p5) );
83835 z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot,
83836 (int)pnErr->u.i+1, &nErr);
 
83837 sqlite3VdbeMemSetNull(pIn1);
83838 if( nErr==0 ){
83839 assert( z==0 );
83840 }else if( z==0 ){
83841 goto no_mem;
83842 }else{
83843 pnErr->u.i -= nErr-1;
83844 sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free);
83845 }
83846 UPDATE_MAX_BLOBSIZE(pIn1);
83847 sqlite3VdbeChangeEncoding(pIn1, encoding);
83848 break;
@@ -92833,11 +93031,11 @@
93031 int nVal = sqlite3ExprVectorSize(pLeft);
93032 Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0;
93033 char *zRet;
93034
93035 assert( pExpr->op==TK_IN );
93036 zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);
93037 if( zRet ){
93038 int i;
93039 for(i=0; i<nVal; i++){
93040 Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
93041 char a = sqlite3ExprAffinity(pA);
@@ -93738,11 +93936,11 @@
93936 ** Clear all column cache entries.
93937 */
93938 SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){
93939 int i;
93940
93941 #ifdef SQLITE_DEBUG
93942 if( pParse->db->flags & SQLITE_VdbeAddopTrace ){
93943 printf("CLEAR\n");
93944 }
93945 #endif
93946 for(i=0; i<pParse->nColCache; i++){
@@ -95145,10 +95343,21 @@
95343 if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1;
95344 if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1;
95345 }
95346 return 0;
95347 }
95348
95349 /*
95350 ** Like sqlite3ExprCompare() except COLLATE operators at the top-level
95351 ** are ignored.
95352 */
95353 SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){
95354 return sqlite3ExprCompare(
95355 sqlite3ExprSkipCollate(pA),
95356 sqlite3ExprSkipCollate(pB),
95357 iTab);
95358 }
95359
95360 /*
95361 ** Return true if we can prove the pE2 will always be true if pE1 is
95362 ** true. Return false if we cannot complete the proof or if pE2 might
95363 ** be false. Examples:
@@ -96698,10 +96907,11 @@
96907 Stat4Sample current; /* Current row as a Stat4Sample */
96908 u32 iPrn; /* Pseudo-random number used for sampling */
96909 Stat4Sample *aBest; /* Array of nCol best samples */
96910 int iMin; /* Index in a[] of entry with minimum score */
96911 int nSample; /* Current number of samples */
96912 int nMaxEqZero; /* Max leading 0 in anEq[] for any a[] entry */
96913 int iGet; /* Index of current sample accessed by stat_get() */
96914 Stat4Sample *a; /* Array of mxSample Stat4Sample objects */
96915 sqlite3 *db; /* Database connection, for malloc() */
96916 };
96917
@@ -96962,10 +97172,17 @@
97172 int i;
97173
97174 assert( IsStat4 || nEqZero==0 );
97175
97176 #ifdef SQLITE_ENABLE_STAT4
97177 /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0
97178 ** values in the anEq[] array of any sample in Stat4Accum.a[]. In
97179 ** other words, if nMaxEqZero is n, then it is guaranteed that there
97180 ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */
97181 if( nEqZero>p->nMaxEqZero ){
97182 p->nMaxEqZero = nEqZero;
97183 }
97184 if( pNew->isPSample==0 ){
97185 Stat4Sample *pUpgrade = 0;
97186 assert( pNew->anEq[pNew->iCol]>0 );
97187
97188 /* This sample is being added because the prefix that ends in column
@@ -97059,16 +97276,26 @@
97276 if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){
97277 sampleInsert(p, pBest, i);
97278 }
97279 }
97280
97281 /* Check that no sample contains an anEq[] entry with an index of
97282 ** p->nMaxEqZero or greater set to zero. */
97283 for(i=p->nSample-1; i>=0; i--){
97284 int j;
97285 for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 );
97286 }
97287
97288 /* Update the anEq[] fields of any samples already collected. */
97289 if( iChng<p->nMaxEqZero ){
97290 for(i=p->nSample-1; i>=0; i--){
97291 int j;
97292 for(j=iChng; j<p->nCol; j++){
97293 if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j];
97294 }
97295 }
97296 p->nMaxEqZero = iChng;
97297 }
97298 #endif
97299
97300 #if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4)
97301 if( iChng==0 ){
@@ -97778,44 +98005,32 @@
98005 /* Form 1: Analyze everything */
98006 for(i=0; i<db->nDb; i++){
98007 if( i==1 ) continue; /* Do not analyze the TEMP database */
98008 analyzeDatabase(pParse, i);
98009 }
98010 }else if( pName2->n==0 && (iDb = sqlite3FindDb(db, pName1))>=0 ){
98011 /* Analyze the schema named as the argument */
98012 analyzeDatabase(pParse, iDb);
98013 }else{
98014 /* Form 3: Analyze the table or index named as an argument */
 
 
 
 
 
 
 
 
 
 
 
 
 
98015 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName);
98016 if( iDb>=0 ){
98017 zDb = pName2->n ? db->aDb[iDb].zDbSName : 0;
98018 z = sqlite3NameFromToken(db, pTableName);
98019 if( z ){
98020 if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){
98021 analyzeTable(pParse, pIdx->pTable, pIdx);
98022 }else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){
98023 analyzeTable(pParse, pTab, 0);
98024 }
98025 sqlite3DbFree(db, z);
98026 }
98027 }
98028 }
98029 if( db->nSqlExec==0 && (v = sqlite3GetVdbe(pParse))!=0 ){
98030 sqlite3VdbeAddOp0(v, OP_Expire);
98031 }
98032 }
98033
98034 /*
98035 ** Used to pass information from the analyzer reader through to the
98036 ** callback routine.
@@ -97940,19 +98155,24 @@
98155 }
98156 aiRowEst = pIndex->aiRowEst;
98157 #endif
98158 pIndex->bUnordered = 0;
98159 decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
98160 pIndex->hasStat1 = 1;
98161 if( pIndex->pPartIdxWhere==0 ){
98162 pTable->nRowLogEst = pIndex->aiRowLogEst[0];
98163 pTable->tabFlags |= TF_HasStat1;
98164 }
98165 }else{
98166 Index fakeIdx;
98167 fakeIdx.szIdxRow = pTable->szTabRow;
98168 #ifdef SQLITE_ENABLE_COSTMULT
98169 fakeIdx.pTable = pTable;
98170 #endif
98171 decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx);
98172 pTable->szTabRow = fakeIdx.szIdxRow;
98173 pTable->tabFlags |= TF_HasStat1;
98174 }
98175
98176 return 0;
98177 }
98178
@@ -98243,19 +98463,24 @@
98463 SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
98464 analysisInfo sInfo;
98465 HashElem *i;
98466 char *zSql;
98467 int rc = SQLITE_OK;
98468 Schema *pSchema = db->aDb[iDb].pSchema;
98469
98470 assert( iDb>=0 && iDb<db->nDb );
98471 assert( db->aDb[iDb].pBt!=0 );
98472
98473 /* Clear any prior statistics */
98474 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
98475 for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){
98476 Table *pTab = sqliteHashData(i);
98477 pTab->tabFlags &= ~TF_HasStat1;
98478 }
98479 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
98480 Index *pIdx = sqliteHashData(i);
98481 pIdx->hasStat1 = 0;
98482 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
98483 sqlite3DeleteIndexSamples(db, pIdx);
98484 pIdx->aSample = 0;
98485 #endif
98486 }
@@ -98274,23 +98499,23 @@
98499 }
98500 }
98501
98502 /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */
98503 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
98504 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
98505 Index *pIdx = sqliteHashData(i);
98506 if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx);
98507 }
98508
98509 /* Load the statistics from the sqlite_stat4 table. */
98510 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
98511 if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
98512 db->lookaside.bDisable++;
98513 rc = loadStat4(db, sInfo.zDatabase);
98514 db->lookaside.bDisable--;
98515 }
98516 for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){
98517 Index *pIdx = sqliteHashData(i);
98518 sqlite3_free(pIdx->aiRowEst);
98519 pIdx->aiRowEst = 0;
98520 }
98521 #endif
@@ -100271,10 +100496,11 @@
100496 SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){
100497 Table *p;
100498 p = pParse->pNewTable;
100499 if( p==0 || NEVER(p->nCol<1) ) return;
100500 p->aCol[p->nCol-1].notNull = (u8)onError;
100501 p->tabFlags |= TF_HasNotNull;
100502 }
100503
100504 /*
100505 ** Scan the column type name zType (length nType) and return the
100506 ** associated affinity type.
@@ -102609,10 +102835,13 @@
102835 /* 10, 9, 8, 7, 6 */
102836 LogEst aVal[] = { 33, 32, 30, 28, 26 };
102837 LogEst *a = pIdx->aiRowLogEst;
102838 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
102839 int i;
102840
102841 /* Indexes with default row estimates should not have stat1 data */
102842 assert( !pIdx->hasStat1 );
102843
102844 /* Set the first entry (number of rows in the index) to the estimated
102845 ** number of rows in the table, or half the number of rows in the table
102846 ** for a partial index. But do not let the estimate drop below 10. */
102847 a[0] = pIdx->pTable->nRowLogEst;
@@ -109798,10 +110027,13 @@
110027 VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName));
110028 }
110029 }
110030 sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]);
110031 VdbeComment((v, "for %s", pIdx->zName));
110032 #ifdef SQLITE_ENABLE_NULL_TRIM
110033 if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable);
110034 #endif
110035
110036 /* In an UPDATE operation, if this index is the PRIMARY KEY index
110037 ** of a WITHOUT ROWID table and there has been no change the
110038 ** primary key, then no collision is possible. The collision detection
110039 ** logic below can all be skipped. */
@@ -109953,12 +110185,15 @@
110185
110186 /* Records with omitted columns are only allowed for schema format
110187 ** version 2 and later (SQLite version 3.1.4, 2005-02-20). */
110188 if( pTab->pSchema->file_format<2 ) return;
110189
110190 for(i=pTab->nCol-1; i>0; i--){
110191 if( pTab->aCol[i].pDflt!=0 ) break;
110192 if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break;
110193 }
110194 sqlite3VdbeChangeP5(v, i+1);
110195 }
110196 #endif
110197
110198 /*
110199 ** This routine generates code to finish the INSERT or UPDATE operation
@@ -110244,11 +110479,11 @@
110479 }
110480 if( sqlite3TriggerList(pParse, pDest) ){
110481 return 0; /* tab1 must not have triggers */
110482 }
110483 #ifndef SQLITE_OMIT_VIRTUALTABLE
110484 if( IsVirtual(pDest) ){
110485 return 0; /* tab1 must not be a virtual table */
110486 }
110487 #endif
110488 if( onError==OE_Default ){
110489 if( pDest->iPKey>=0 ) onError = pDest->keyConf;
@@ -110306,11 +110541,11 @@
110541 }
110542 if( HasRowid(pDest)!=HasRowid(pSrc) ){
110543 return 0; /* source and destination must both be WITHOUT ROWID or not */
110544 }
110545 #ifndef SQLITE_OMIT_VIRTUALTABLE
110546 if( IsVirtual(pSrc) ){
110547 return 0; /* tab2 must not be a virtual table */
110548 }
110549 #endif
110550 if( pSrc->pSelect ){
110551 return 0; /* tab2 may not be a view */
@@ -110603,11 +110838,11 @@
110838 /* Invoke the callback function if required */
110839 if( xCallback && (SQLITE_ROW==rc ||
110840 (SQLITE_DONE==rc && !callbackIsInit
110841 && db->flags&SQLITE_NullCallback)) ){
110842 if( !callbackIsInit ){
110843 azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
110844 if( azCols==0 ){
110845 goto exec_out;
110846 }
110847 for(i=0; i<nCol; i++){
110848 azCols[i] = (char *)sqlite3_column_name(pStmt, i);
@@ -110624,10 +110859,11 @@
110859 if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){
110860 sqlite3OomFault(db);
110861 goto exec_out;
110862 }
110863 }
110864 azVals[i] = 0;
110865 }
110866 if( xCallback(pArg, nCol, azVals, azCols) ){
110867 /* EVIDENCE-OF: R-38229-40159 If the callback function to
110868 ** sqlite3_exec() returns non-zero, then sqlite3_exec() will
110869 ** return SQLITE_ABORT. */
@@ -112094,15 +112330,15 @@
112330 #define PragTyp_JOURNAL_SIZE_LIMIT 20
112331 #define PragTyp_LOCK_PROXY_FILE 21
112332 #define PragTyp_LOCKING_MODE 22
112333 #define PragTyp_PAGE_COUNT 23
112334 #define PragTyp_MMAP_SIZE 24
112335 #define PragTyp_OPTIMIZE 25
112336 #define PragTyp_PAGE_SIZE 26
112337 #define PragTyp_SECURE_DELETE 27
112338 #define PragTyp_SHRINK_MEMORY 28
112339 #define PragTyp_SOFT_HEAP_LIMIT 29
112340 #define PragTyp_SYNCHRONOUS 30
112341 #define PragTyp_TABLE_INFO 31
112342 #define PragTyp_TEMP_STORE 32
112343 #define PragTyp_TEMP_STORE_DIRECTORY 33
112344 #define PragTyp_THREADS 34
@@ -112112,10 +112348,11 @@
112348 #define PragTyp_HEXKEY 38
112349 #define PragTyp_KEY 39
112350 #define PragTyp_REKEY 40
112351 #define PragTyp_LOCK_STATUS 41
112352 #define PragTyp_PARSER_TRACE 42
112353 #define PragTyp_STATS 43
112354
112355 /* Property flags associated with various pragma. */
112356 #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
112357 #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */
112358 #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
@@ -112135,51 +112372,52 @@
112372 /* 2 */ "name",
112373 /* 3 */ "type",
112374 /* 4 */ "notnull",
112375 /* 5 */ "dflt_value",
112376 /* 6 */ "pk",
112377 /* 7 */ "tbl", /* Used by: stats */
112378 /* 8 */ "idx",
112379 /* 9 */ "wdth",
112380 /* 10 */ "hght",
112381 /* 11 */ "flgs",
112382 /* 12 */ "seqno", /* Used by: index_info */
112383 /* 13 */ "cid",
112384 /* 14 */ "name",
112385 /* 15 */ "seqno", /* Used by: index_xinfo */
112386 /* 16 */ "cid",
112387 /* 17 */ "name",
112388 /* 18 */ "desc",
112389 /* 19 */ "coll",
112390 /* 20 */ "key",
112391 /* 21 */ "seq", /* Used by: index_list */
112392 /* 22 */ "name",
112393 /* 23 */ "unique",
112394 /* 24 */ "origin",
112395 /* 25 */ "partial",
112396 /* 26 */ "seq", /* Used by: database_list */
112397 /* 27 */ "name",
112398 /* 28 */ "file",
112399 /* 29 */ "seq", /* Used by: collation_list */
112400 /* 30 */ "name",
112401 /* 31 */ "id", /* Used by: foreign_key_list */
112402 /* 32 */ "seq",
112403 /* 33 */ "table",
112404 /* 34 */ "from",
112405 /* 35 */ "to",
112406 /* 36 */ "on_update",
112407 /* 37 */ "on_delete",
112408 /* 38 */ "match",
112409 /* 39 */ "table", /* Used by: foreign_key_check */
112410 /* 40 */ "rowid",
112411 /* 41 */ "parent",
112412 /* 42 */ "fkid",
112413 /* 43 */ "busy", /* Used by: wal_checkpoint */
112414 /* 44 */ "log",
112415 /* 45 */ "checkpointed",
112416 /* 46 */ "timeout", /* Used by: busy_timeout */
112417 /* 47 */ "database", /* Used by: lock_status */
112418 /* 48 */ "status",
112419 };
112420
112421 /* Definitions of all built-in pragmas */
112422 typedef struct PragmaName {
112423 const char *const zName; /* Name of pragma */
@@ -112221,11 +112459,11 @@
112459 #endif
112460 #endif
112461 {/* zName: */ "busy_timeout",
112462 /* ePragTyp: */ PragTyp_BUSY_TIMEOUT,
112463 /* ePragFlg: */ PragFlg_Result0,
112464 /* ColNames: */ 46, 1,
112465 /* iArg: */ 0 },
112466 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112467 {/* zName: */ "cache_size",
112468 /* ePragTyp: */ PragTyp_CACHE_SIZE,
112469 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
@@ -112258,11 +112496,11 @@
112496 #endif
112497 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112498 {/* zName: */ "collation_list",
112499 /* ePragTyp: */ PragTyp_COLLATION_LIST,
112500 /* ePragFlg: */ PragFlg_Result0,
112501 /* ColNames: */ 29, 2,
112502 /* iArg: */ 0 },
112503 #endif
112504 #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
112505 {/* zName: */ "compile_options",
112506 /* ePragTyp: */ PragTyp_COMPILE_OPTIONS,
@@ -112293,11 +112531,11 @@
112531 #endif
112532 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112533 {/* zName: */ "database_list",
112534 /* ePragTyp: */ PragTyp_DATABASE_LIST,
112535 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0,
112536 /* ColNames: */ 26, 3,
112537 /* iArg: */ 0 },
112538 #endif
112539 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
112540 {/* zName: */ "default_cache_size",
112541 /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE,
@@ -112330,18 +112568,18 @@
112568 #endif
112569 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
112570 {/* zName: */ "foreign_key_check",
112571 /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK,
112572 /* ePragFlg: */ PragFlg_NeedSchema,
112573 /* ColNames: */ 39, 4,
112574 /* iArg: */ 0 },
112575 #endif
112576 #if !defined(SQLITE_OMIT_FOREIGN_KEY)
112577 {/* zName: */ "foreign_key_list",
112578 /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST,
112579 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112580 /* ColNames: */ 31, 8,
112581 /* iArg: */ 0 },
112582 #endif
112583 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
112584 #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
112585 {/* zName: */ "foreign_keys",
@@ -112400,21 +112638,21 @@
112638 #endif
112639 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
112640 {/* zName: */ "index_info",
112641 /* ePragTyp: */ PragTyp_INDEX_INFO,
112642 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112643 /* ColNames: */ 12, 3,
112644 /* iArg: */ 0 },
112645 {/* zName: */ "index_list",
112646 /* ePragTyp: */ PragTyp_INDEX_LIST,
112647 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112648 /* ColNames: */ 21, 5,
112649 /* iArg: */ 0 },
112650 {/* zName: */ "index_xinfo",
112651 /* ePragTyp: */ PragTyp_INDEX_INFO,
112652 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
112653 /* ColNames: */ 15, 6,
112654 /* iArg: */ 1 },
112655 #endif
112656 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
112657 {/* zName: */ "integrity_check",
112658 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
@@ -112457,11 +112695,11 @@
112695 #endif
112696 #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
112697 {/* zName: */ "lock_status",
112698 /* ePragTyp: */ PragTyp_LOCK_STATUS,
112699 /* ePragFlg: */ PragFlg_Result0,
112700 /* ColNames: */ 47, 2,
112701 /* iArg: */ 0 },
112702 #endif
112703 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112704 {/* zName: */ "locking_mode",
112705 /* ePragTyp: */ PragTyp_LOCKING_MODE,
@@ -112476,10 +112714,17 @@
112714 {/* zName: */ "mmap_size",
112715 /* ePragTyp: */ PragTyp_MMAP_SIZE,
112716 /* ePragFlg: */ 0,
112717 /* ColNames: */ 0, 0,
112718 /* iArg: */ 0 },
112719 #endif
112720 {/* zName: */ "optimize",
112721 /* ePragTyp: */ PragTyp_OPTIMIZE,
112722 /* ePragFlg: */ PragFlg_Result1,
112723 /* ColNames: */ 0, 0,
112724 /* iArg: */ 0 },
112725 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112726 {/* zName: */ "page_count",
112727 /* ePragTyp: */ PragTyp_PAGE_COUNT,
112728 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
112729 /* ColNames: */ 0, 0,
112730 /* iArg: */ 0 },
@@ -112574,15 +112819,15 @@
112819 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
112820 /* ColNames: */ 0, 0,
112821 /* iArg: */ SQLITE_SqlTrace },
112822 #endif
112823 #endif
112824 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG)
112825 {/* zName: */ "stats",
112826 /* ePragTyp: */ PragTyp_STATS,
112827 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq,
112828 /* ColNames: */ 7, 5,
112829 /* iArg: */ 0 },
112830 #endif
112831 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
112832 {/* zName: */ "synchronous",
112833 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
@@ -112657,11 +112902,11 @@
112902 /* ColNames: */ 0, 0,
112903 /* iArg: */ 0 },
112904 {/* zName: */ "wal_checkpoint",
112905 /* ePragTyp: */ PragTyp_WAL_CHECKPOINT,
112906 /* ePragFlg: */ PragFlg_NeedSchema,
112907 /* ColNames: */ 43, 3,
112908 /* iArg: */ 0 },
112909 #endif
112910 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
112911 {/* zName: */ "writable_schema",
112912 /* ePragTyp: */ PragTyp_FLAG,
@@ -112668,11 +112913,11 @@
112913 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
112914 /* ColNames: */ 0, 0,
112915 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
112916 #endif
112917 };
112918 /* Number of pragmas: 60 on by default, 74 total. */
112919
112920 /************** End of pragma.h **********************************************/
112921 /************** Continuing where we left off in pragma.c *********************/
112922
112923 /*
@@ -112937,10 +113182,26 @@
113182 lwr = mid + 1;
113183 }
113184 }
113185 return lwr>upr ? 0 : &aPragmaName[mid];
113186 }
113187
113188 /*
113189 ** Helper subroutine for PRAGMA integrity_check:
113190 **
113191 ** Generate code to output a single-column result row with the result
113192 ** held in register regResult. Decrement the result count and halt if
113193 ** the maximum number of result rows have been issued.
113194 */
113195 static int integrityCheckResultRow(Vdbe *v, int regResult){
113196 int addr;
113197 sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 1);
113198 addr = sqlite3VdbeAddOp3(v, OP_IfPos, 1, sqlite3VdbeCurrentAddr(v)+2, 1);
113199 VdbeCoverage(v);
113200 sqlite3VdbeAddOp2(v, OP_Halt, 0, 0);
113201 return addr;
113202 }
113203
113204 /*
113205 ** Process a pragma statement.
113206 **
113207 ** Pragmas are of this form:
@@ -113741,33 +114002,37 @@
114002 }
114003 }
114004 }
114005 break;
114006
114007 #ifdef SQLITE_DEBUG
114008 case PragTyp_STATS: {
114009 Index *pIdx;
114010 HashElem *i;
114011 pParse->nMem = 5;
114012 sqlite3CodeVerifySchema(pParse, iDb);
114013 for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
114014 Table *pTab = sqliteHashData(i);
114015 sqlite3VdbeMultiLoad(v, 1, "ssiii",
114016 pTab->zName,
114017 0,
114018 pTab->szTabRow,
114019 pTab->nRowLogEst,
114020 pTab->tabFlags);
114021 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
114022 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
114023 sqlite3VdbeMultiLoad(v, 2, "siii",
114024 pIdx->zName,
114025 pIdx->szIdxRow,
114026 pIdx->aiRowLogEst[0],
114027 pIdx->hasStat1);
114028 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
114029 }
114030 }
114031 }
114032 break;
114033 #endif
114034
114035 case PragTyp_INDEX_INFO: if( zRight ){
114036 Index *pIdx;
114037 Table *pTab;
114038 pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -114020,13 +114285,21 @@
114285 #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX
114286 # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100
114287 #endif
114288
114289 #ifndef SQLITE_OMIT_INTEGRITY_CHECK
114290 /* PRAGMA integrity_check
114291 ** PRAGMA integrity_check(N)
114292 ** PRAGMA quick_check
114293 ** PRAGMA quick_check(N)
114294 **
114295 ** Verify the integrity of the database.
114296 **
114297 ** The "quick_check" is reduced version of
114298 ** integrity_check designed to detect most database corruption
114299 ** without the overhead of cross-checking indexes. Quick_check
114300 ** is linear time wherease integrity_check is O(NlogN).
114301 */
114302 case PragTyp_INTEGRITY_CHECK: {
114303 int i, j, addr, mxErr;
114304
114305 int isQuick = (sqlite3Tolower(zLeft[0])=='q');
@@ -114053,11 +114326,11 @@
114326 sqlite3GetInt32(zRight, &mxErr);
114327 if( mxErr<=0 ){
114328 mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX;
114329 }
114330 }
114331 sqlite3VdbeAddOp2(v, OP_Integer, mxErr-1, 1); /* reg[1] holds errors left */
114332
114333 /* Do an integrity check on each database file */
114334 for(i=0; i<db->nDb; i++){
114335 HashElem *x;
114336 Hash *pTbls;
@@ -114068,14 +114341,10 @@
114341
114342 if( OMIT_TEMPDB && i==1 ) continue;
114343 if( iDb>=0 && i!=iDb ) continue;
114344
114345 sqlite3CodeVerifySchema(pParse, i);
 
 
 
 
114346
114347 /* Do an integrity check of the B-Tree
114348 **
114349 ** Begin by finding the root pages numbers
114350 ** for all tables and indices in the database.
@@ -114111,29 +114380,30 @@
114380 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
114381 sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
114382 P4_DYNAMIC);
114383 sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1);
114384 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2);
114385 integrityCheckResultRow(v, 2);
114386 sqlite3VdbeJumpHere(v, addr);
114387
114388 /* Make sure all the indices are constructed correctly.
114389 */
114390 for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){
114391 Table *pTab = sqliteHashData(x);
114392 Index *pIdx, *pPk;
114393 Index *pPrior = 0;
114394 int loopTop;
114395 int iDataCur, iIdxCur;
114396 int r1 = -1;
114397
114398 if( pTab->pCheck==0
114399 && (pTab->tabFlags & TF_HasNotNull)==0
114400 && (pTab->pIndex==0 || isQuick)
114401 ){
114402 continue; /* No additional checks needed for this table */
114403 }
114404 pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab);
 
 
 
 
114405 sqlite3ExprCacheClear(pParse);
114406 sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0,
114407 1, 0, &iDataCur, &iIdxCur);
114408 sqlite3VdbeAddOp2(v, OP_Integer, 0, 7);
114409 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
@@ -114144,28 +114414,46 @@
114414 sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v);
114415 loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1);
114416 /* Verify that all NOT NULL columns really are NOT NULL */
114417 for(j=0; j<pTab->nCol; j++){
114418 char *zErr;
114419 int jmp2;
114420 if( j==pTab->iPKey ) continue;
114421 if( pTab->aCol[j].notNull==0 ) continue;
114422 sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3);
114423 sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
114424 jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v);
 
114425 zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName,
114426 pTab->aCol[j].zName);
114427 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
114428 integrityCheckResultRow(v, 3);
 
 
114429 sqlite3VdbeJumpHere(v, jmp2);
114430 }
114431 /* Verify CHECK constraints */
114432 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
114433 int addrCkFault = sqlite3VdbeMakeLabel(v);
114434 int addrCkOk = sqlite3VdbeMakeLabel(v);
114435 ExprList *pCheck = pTab->pCheck;
114436 char *zErr;
114437 int k;
114438 pParse->iSelfTab = iDataCur;
114439 sqlite3ExprCachePush(pParse);
114440 for(k=pCheck->nExpr-1; k>0; k--){
114441 sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0);
114442 }
114443 sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk,
114444 SQLITE_JUMPIFNULL);
114445 sqlite3VdbeResolveLabel(v, addrCkFault);
114446 zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s",
114447 pTab->zName);
114448 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC);
114449 integrityCheckResultRow(v, 3);
114450 sqlite3VdbeResolveLabel(v, addrCkOk);
114451 sqlite3ExprCachePop(pParse);
114452 }
114453 /* Validate index entries for the current row */
114454 for(j=0, pIdx=pTab->pIndex; pIdx && !isQuick; pIdx=pIdx->pNext, j++){
114455 int jmp2, jmp3, jmp4, jmp5;
114456 int ckUniq = sqlite3VdbeMakeLabel(v);
114457 if( pPk==pIdx ) continue;
114458 r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
114459 pPrior, r1);
@@ -114172,20 +114460,17 @@
114460 pPrior = pIdx;
114461 sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */
114462 /* Verify that an index entry exists for the current table row */
114463 jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1,
114464 pIdx->nColumn); VdbeCoverage(v);
 
114465 sqlite3VdbeLoadString(v, 3, "row ");
114466 sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3);
114467 sqlite3VdbeLoadString(v, 4, " missing from index ");
114468 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
114469 jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName);
114470 sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3);
114471 jmp4 = integrityCheckResultRow(v, 3);
 
 
114472 sqlite3VdbeJumpHere(v, jmp2);
114473 /* For UNIQUE indexes, verify that only one entry exists with the
114474 ** current key. The entry is unique if (1) any column is NULL
114475 ** or (2) the next entry has a different key */
114476 if( IsUniqueIndex(pIdx) ){
@@ -114202,11 +114487,10 @@
114487 jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v);
114488 sqlite3VdbeGoto(v, uniqOk);
114489 sqlite3VdbeJumpHere(v, jmp6);
114490 sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1,
114491 pIdx->nKeyCol); VdbeCoverage(v);
 
114492 sqlite3VdbeLoadString(v, 3, "non-unique entry in index ");
114493 sqlite3VdbeGoto(v, jmp5);
114494 sqlite3VdbeResolveLabel(v, uniqOk);
114495 }
114496 sqlite3VdbeJumpHere(v, jmp4);
@@ -114213,40 +114497,39 @@
114497 sqlite3ResolvePartIdxLabel(pParse, jmp3);
114498 }
114499 sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v);
114500 sqlite3VdbeJumpHere(v, loopTop-1);
114501 #ifndef SQLITE_OMIT_BTREECOUNT
114502 if( !isQuick ){
114503 sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
114504 for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
114505 if( pPk==pIdx ) continue;
114506 sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3);
114507 addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v);
114508 sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
114509 sqlite3VdbeLoadString(v, 3, pIdx->zName);
114510 sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7);
114511 integrityCheckResultRow(v, 7);
114512 sqlite3VdbeJumpHere(v, addr);
114513 }
 
114514 }
114515 #endif /* SQLITE_OMIT_BTREECOUNT */
114516 }
114517 }
114518 {
114519 static const int iLn = VDBE_OFFSET_LINENO(2);
114520 static const VdbeOpList endCode[] = {
114521 { OP_AddImm, 1, 0, 0}, /* 0 */
114522 { OP_IfNotZero, 1, 4, 0}, /* 1 */
114523 { OP_String8, 0, 3, 0}, /* 2 */
114524 { OP_ResultRow, 3, 1, 0}, /* 3 */
114525 };
114526 VdbeOp *aOp;
114527
114528 aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn);
114529 if( aOp ){
114530 aOp[0].p2 = 1-mxErr;
114531 aOp[2].p4type = P4_STATIC;
114532 aOp[2].p4.z = "ok";
114533 }
114534 }
114535 }
@@ -114466,10 +114749,122 @@
114749 */
114750 case PragTyp_SHRINK_MEMORY: {
114751 sqlite3_db_release_memory(db);
114752 break;
114753 }
114754
114755 /*
114756 ** PRAGMA optimize
114757 ** PRAGMA optimize(MASK)
114758 ** PRAGMA schema.optimize
114759 ** PRAGMA schema.optimize(MASK)
114760 **
114761 ** Attempt to optimize the database. All schemas are optimized in the first
114762 ** two forms, and only the specified schema is optimized in the latter two.
114763 **
114764 ** The details of optimizations performed by this pragma does are expected
114765 ** to change and improve over time. Applications should anticipate that
114766 ** this pragma will perform new optimizations in future releases.
114767 **
114768 ** The optional argument is a bitmask of optimizations to perform:
114769 **
114770 ** 0x0001 Debugging mode. Do not actually perform any optimizations
114771 ** but instead return one line of text for each optimization
114772 ** that would have been done. Off by default.
114773 **
114774 ** 0x0002 Run ANALYZE on tables that might benefit. On by default.
114775 ** See below for additional information.
114776 **
114777 ** 0x0004 (Not yet implemented) Record usage and performance
114778 ** information from the current session in the
114779 ** database file so that it will be available to "optimize"
114780 ** pragmas run by future database connections.
114781 **
114782 ** 0x0008 (Not yet implemented) Create indexes that might have
114783 ** been helpful to recent queries
114784 **
114785 ** The default MASK is 0x000e, which means perform all of the optimizations
114786 ** listed above except do not set Debug Mode. New optimizations may be
114787 ** added in future releases but they will be turned off by default. The
114788 ** default MASK will always be 0x0e.
114789 **
114790 ** DETERMINATION OF WHEN TO RUN ANALYZE
114791 **
114792 ** In the current implementation, a table is analyzed if only if all of
114793 ** the following are true:
114794 **
114795 ** (1) MASK bit 0x02 is set.
114796 **
114797 ** (2) The query planner used sqlite_stat1-style statistics for one or
114798 ** more indexes of the table at some point during the lifetime of
114799 ** the current connection.
114800 **
114801 ** (3) One or more indexes of the table are currently unanalyzed OR
114802 ** the number of rows in the table has increased by 25 times or more
114803 ** since the last time ANALYZE was run.
114804 **
114805 ** The rules for when tables are analyzed are likely to change in
114806 ** future releases.
114807 */
114808 case PragTyp_OPTIMIZE: {
114809 int iDbLast; /* Loop termination point for the schema loop */
114810 int iTabCur; /* Cursor for a table whose size needs checking */
114811 HashElem *k; /* Loop over tables of a schema */
114812 Schema *pSchema; /* The current schema */
114813 Table *pTab; /* A table in the schema */
114814 Index *pIdx; /* An index of the table */
114815 LogEst szThreshold; /* Size threshold above which reanalysis is needd */
114816 char *zSubSql; /* SQL statement for the OP_SqlExec opcode */
114817 u32 opMask; /* Mask of operations to perform */
114818
114819 if( zRight ){
114820 opMask = (u32)sqlite3Atoi(zRight);
114821 if( (opMask & 0x02)==0 ) break;
114822 }else{
114823 opMask = 0xe;
114824 }
114825 iTabCur = pParse->nTab++;
114826 for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){
114827 if( iDb==1 ) continue;
114828 sqlite3CodeVerifySchema(pParse, iDb);
114829 pSchema = db->aDb[iDb].pSchema;
114830 for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){
114831 pTab = (Table*)sqliteHashData(k);
114832
114833 /* If table pTab has not been used in a way that would benefit from
114834 ** having analysis statistics during the current session, then skip it.
114835 ** This also has the effect of skipping virtual tables and views */
114836 if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue;
114837
114838 /* Reanalyze if the table is 25 times larger than the last analysis */
114839 szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 );
114840 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
114841 if( !pIdx->hasStat1 ){
114842 szThreshold = 0; /* Always analyze if any index lacks statistics */
114843 break;
114844 }
114845 }
114846 if( szThreshold ){
114847 sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead);
114848 sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur,
114849 sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold);
114850 VdbeCoverage(v);
114851 }
114852 zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"",
114853 db->aDb[iDb].zDbSName, pTab->zName);
114854 if( opMask & 0x01 ){
114855 int r1 = sqlite3GetTempReg(pParse);
114856 sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC);
114857 sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1);
114858 }else{
114859 sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC);
114860 }
114861 }
114862 }
114863 sqlite3VdbeAddOp0(v, OP_Expire);
114864 break;
114865 }
114866
114867 /*
114868 ** PRAGMA busy_timeout
114869 ** PRAGMA busy_timeout = N
114870 **
@@ -123782,12 +124177,29 @@
124177 ** transient would cause the database file to appear to be deleted
124178 ** following reboot.
124179 */
124180 SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){
124181 Vdbe *v = sqlite3GetVdbe(pParse);
124182 int iDb = 0;
124183 if( v==0 ) return;
124184 if( pNm ){
124185 #ifndef SQLITE_BUG_COMPATIBLE_20160819
124186 /* Default behavior: Report an error if the argument to VACUUM is
124187 ** not recognized */
124188 iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);
124189 if( iDb<0 ) return;
124190 #else
124191 /* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments
124192 ** to VACUUM are silently ignored. This is a back-out of a bug fix that
124193 ** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270).
124194 ** The buggy behavior is required for binary compatibility with some
124195 ** legacy applications. */
124196 iDb = sqlite3FindDb(pParse->db, pNm);
124197 if( iDb<0 ) iDb = 0;
124198 #endif
124199 }
124200 if( iDb!=1 ){
124201 sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);
124202 sqlite3VdbeUsesBtree(v, iDb);
124203 }
124204 return;
124205 }
@@ -124377,12 +124789,11 @@
124789
124790 db = pParse->db;
124791 iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
124792 assert( iDb>=0 );
124793
124794 assert( pTable->nModuleArg==0 );
 
124795 addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
124796 addModuleArgument(db, pTable, 0);
124797 addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
124798 assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)
124799 || (pParse->sNameToken.z==pName1->z && pName2->z==0)
@@ -124666,11 +125077,11 @@
125077 const char *zMod;
125078 Module *pMod;
125079 int rc;
125080
125081 assert( pTab );
125082 if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){
125083 return SQLITE_OK;
125084 }
125085
125086 /* Locate the required virtual table module */
125087 zMod = pTab->azModuleArg[0];
@@ -124736,11 +125147,11 @@
125147 Table *pTab;
125148 Module *pMod;
125149 const char *zMod;
125150
125151 pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName);
125152 assert( pTab && IsVirtual(pTab) && !pTab->pVTable );
125153
125154 /* Locate the required virtual table module */
125155 zMod = pTab->azModuleArg[0];
125156 pMod = (Module*)sqlite3HashFind(&db->aModule, zMod);
125157
@@ -124790,11 +125201,11 @@
125201 sqlite3Error(db, SQLITE_MISUSE);
125202 sqlite3_mutex_leave(db->mutex);
125203 return SQLITE_MISUSE_BKPT;
125204 }
125205 pTab = pCtx->pTab;
125206 assert( IsVirtual(pTab) );
125207
125208 pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
125209 if( pParse==0 ){
125210 rc = SQLITE_NOMEM_BKPT;
125211 }else{
@@ -124804,11 +125215,11 @@
125215
125216 if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr)
125217 && pParse->pNewTable
125218 && !db->mallocFailed
125219 && !pParse->pNewTable->pSelect
125220 && !IsVirtual(pParse->pNewTable)
125221 ){
125222 if( !pTab->aCol ){
125223 Table *pNew = pParse->pNewTable;
125224 Index *pIdx;
125225 pTab->aCol = pNew->aCol;
@@ -125093,11 +125504,11 @@
125504 /* Check to see the left operand is a column in a virtual table */
125505 if( NEVER(pExpr==0) ) return pDef;
125506 if( pExpr->op!=TK_COLUMN ) return pDef;
125507 pTab = pExpr->pTab;
125508 if( NEVER(pTab==0) ) return pDef;
125509 if( !IsVirtual(pTab) ) return pDef;
125510 pVtab = sqlite3GetVTable(db, pTab)->pVtab;
125511 assert( pVtab!=0 );
125512 assert( pVtab->pModule!=0 );
125513 pMod = (sqlite3_module *)pVtab->pModule;
125514 if( pMod->xFindFunction==0 ) return pDef;
@@ -125188,12 +125599,11 @@
125599 return 0;
125600 }
125601 pMod->pEpoTab = pTab;
125602 pTab->nTabRef = 1;
125603 pTab->pSchema = db->aDb[0].pSchema;
125604 assert( pTab->nModuleArg==0 );
 
125605 pTab->iPKey = -1;
125606 addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
125607 addModuleArgument(db, pTab, 0);
125608 addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName));
125609 rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
@@ -125260,11 +125670,11 @@
125670 case SQLITE_VTAB_CONSTRAINT_SUPPORT: {
125671 VtabCtx *p = db->pVtabCtx;
125672 if( !p ){
125673 rc = SQLITE_MISUSE_BKPT;
125674 }else{
125675 assert( p->pTab==0 || IsVirtual(p->pTab) );
125676 p->pVTable->bConstraint = (u8)va_arg(ap, int);
125677 }
125678 break;
125679 }
125680 default:
@@ -125699,12 +126109,17 @@
126109 WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
126110 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
126111 UnpackedRecord *pRec; /* Probe for stat4 (if required) */
126112 int nRecValid; /* Number of valid fields currently in pRec */
126113 #endif
126114 unsigned int bldFlags; /* SQLITE_BLDF_* flags */
126115 };
126116
126117 /* Allowed values for WhereLoopBuider.bldFlags */
126118 #define SQLITE_BLDF_INDEXED 0x0001 /* An index is used */
126119 #define SQLITE_BLDF_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
126120
126121 /*
126122 ** The WHERE clause processing routine has two halves. The
126123 ** first part does the start of the WHERE loop and the second
126124 ** half does the tail of the WHERE loop. An instance of
126125 ** this structure is returned by the first half and passed
@@ -125715,11 +126130,11 @@
126130 */
126131 struct WhereInfo {
126132 Parse *pParse; /* Parsing and code generating context */
126133 SrcList *pTabList; /* List of tables in the join */
126134 ExprList *pOrderBy; /* The ORDER BY clause or NULL */
126135 ExprList *pResultSet; /* Result set of the query */
126136 LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */
126137 int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
126138 int iContinue; /* Jump here to continue with next record */
126139 int iBreak; /* Jump here to break out of the loop */
126140 int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */
@@ -126899,10 +127314,11 @@
127314 Parse *pParse; /* Parsing context */
127315 sqlite3 *db; /* Database connection */
127316 Vdbe *v; /* The prepared stmt under constructions */
127317 struct SrcList_item *pTabItem; /* FROM clause term being coded */
127318 int addrBrk; /* Jump here to break out of the loop */
127319 int addrHalt; /* addrBrk for the outermost loop */
127320 int addrCont; /* Jump here to continue with next cycle */
127321 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
127322 int iReleaseReg = 0; /* Temp register to free before returning */
127323
127324 pParse = pWInfo->pParse;
@@ -126939,10 +127355,15 @@
127355 if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
127356 pLevel->iLeftJoin = ++pParse->nMem;
127357 sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
127358 VdbeComment((v, "init LEFT JOIN no-match flag"));
127359 }
127360
127361 /* Compute a safe address to jump to if we discover that the table for
127362 ** this loop is empty and can never contribute content. */
127363 for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){}
127364 addrHalt = pWInfo->a[j].addrBrk;
127365
127366 /* Special case of a FROM clause subquery implemented as a co-routine */
127367 if( pTabItem->fg.viaCoroutine ){
127368 int regYield = pTabItem->regReturn;
127369 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub);
@@ -127124,11 +127545,11 @@
127545 VdbeCoverageIf(v, pX->op==TK_LT);
127546 VdbeCoverageIf(v, pX->op==TK_GE);
127547 sqlite3ExprCacheAffinityChange(pParse, r1, 1);
127548 sqlite3ReleaseTempReg(pParse, rTemp);
127549 }else{
127550 sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt);
127551 VdbeCoverageIf(v, bRev==0);
127552 VdbeCoverageIf(v, bRev!=0);
127553 }
127554 if( pEnd ){
127555 Expr *pX;
@@ -127770,11 +128191,11 @@
128191 pLevel->op = OP_Noop;
128192 }else{
128193 codeCursorHint(pTabItem, pWInfo, pLevel, 0);
128194 pLevel->op = aStep[bRev];
128195 pLevel->p1 = iCur;
128196 pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt);
128197 VdbeCoverageIf(v, bRev==0);
128198 VdbeCoverageIf(v, bRev!=0);
128199 pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP;
128200 }
128201 }
@@ -128095,19 +128516,10 @@
128516 #ifdef SQLITE_EBCDIC
128517 if( *pnoCase ) return 0;
128518 #endif
128519 pList = pExpr->x.pList;
128520 pLeft = pList->a[1].pExpr;
 
 
 
 
 
 
 
 
 
128521
128522 pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr);
128523 op = pRight->op;
128524 if( op==TK_VARIABLE ){
128525 Vdbe *pReprepare = pParse->pReprepare;
@@ -128120,10 +128532,27 @@
128532 assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER );
128533 }else if( op==TK_STRING ){
128534 z = pRight->u.zToken;
128535 }
128536 if( z ){
128537
128538 /* If the RHS begins with a digit or a minus sign, then the LHS must
128539 ** be an ordinary column (not a virtual table column) with TEXT affinity.
128540 ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false
128541 ** even though "lhs LIKE rhs" is true. But if the RHS does not start
128542 ** with a digit or '-', then "lhs LIKE rhs" will always be false if
128543 ** the LHS is numeric and so the optimization still works.
128544 */
128545 if( sqlite3Isdigit(z[0]) || z[0]=='-' ){
128546 if( pLeft->op!=TK_COLUMN
128547 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
128548 || IsVirtual(pLeft->pTab) /* Value might be numeric */
128549 ){
128550 sqlite3ValueFree(pVal);
128551 return 0;
128552 }
128553 }
128554 cnt = 0;
128555 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
128556 cnt++;
128557 }
128558 if( cnt!=0 && 255!=(u8)z[cnt-1] ){
@@ -128748,11 +129177,11 @@
129177 iCur = pFrom->a[i].iCursor;
129178 for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){
129179 if( pIdx->aColExpr==0 ) continue;
129180 for(i=0; i<pIdx->nKeyCol; i++){
129181 if( pIdx->aiColumn[i]!=XN_EXPR ) continue;
129182 if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){
129183 *piCur = iCur;
129184 *piColumn = XN_EXPR;
129185 return 1;
129186 }
129187 }
@@ -129539,11 +129968,12 @@
129968 do{
129969 for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
129970 if( pTerm->leftCursor==iCur
129971 && pTerm->u.leftColumn==iColumn
129972 && (iColumn!=XN_EXPR
129973 || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
129974 pScan->pIdxExpr,iCur)==0)
129975 && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
129976 ){
129977 if( (pTerm->eOperator & WO_EQUIV)!=0
129978 && pScan->nEquiv<ArraySize(pScan->aiCur)
129979 && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN
@@ -131716,10 +132146,15 @@
132146 testcase( eOp & WO_IS );
132147 testcase( eOp & WO_ISNULL );
132148 continue;
132149 }
132150
132151 if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){
132152 pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE;
132153 }else{
132154 pBuilder->bldFlags |= SQLITE_BLDF_INDEXED;
132155 }
132156 pNew->wsFlags = saved_wsFlags;
132157 pNew->u.btree.nEq = saved_nEq;
132158 pNew->u.btree.nBtm = saved_nBtm;
132159 pNew->u.btree.nTop = saved_nTop;
132160 pNew->nLTerm = saved_nLTerm;
@@ -132263,11 +132698,19 @@
132698 pNew->nOut = rSize;
132699 if( rc ) break;
132700 }
132701 }
132702
132703 pBuilder->bldFlags = 0;
132704 rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0);
132705 if( pBuilder->bldFlags==SQLITE_BLDF_INDEXED ){
132706 /* If a non-unique index is used, or if a prefix of the key for
132707 ** unique index is used (making the index functionally non-unique)
132708 ** then the sqlite_stat1 data becomes important for scoring the
132709 ** plan */
132710 pTab->tabFlags |= TF_StatsUsed;
132711 }
132712 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
132713 sqlite3Stat4ProbeFree(pBuilder->pRec);
132714 pBuilder->nRecValid = 0;
132715 pBuilder->pRec = 0;
132716 #endif
@@ -133443,13 +133886,13 @@
133886 && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0
133887 && pWInfo->eDistinct==WHERE_DISTINCT_NOOP
133888 && nRowEst
133889 ){
133890 Bitmask notUsed;
133891 int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom,
133892 WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], &notUsed);
133893 if( rc==pWInfo->pResultSet->nExpr ){
133894 pWInfo->eDistinct = WHERE_DISTINCT_ORDERED;
133895 }
133896 }
133897 if( pWInfo->pOrderBy ){
133898 if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){
@@ -133682,11 +134125,11 @@
134125 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
134126 Parse *pParse, /* The parser context */
134127 SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */
134128 Expr *pWhere, /* The WHERE clause */
134129 ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
134130 ExprList *pResultSet, /* Query result set. Req'd for DISTINCT */
134131 u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
134132 int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
134133 ** If WHERE_USE_LIMIT, then the limit amount */
134134 ){
134135 int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
@@ -133758,11 +134201,11 @@
134201 goto whereBeginError;
134202 }
134203 pWInfo->pParse = pParse;
134204 pWInfo->pTabList = pTabList;
134205 pWInfo->pOrderBy = pOrderBy;
134206 pWInfo->pResultSet = pResultSet;
134207 pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
134208 pWInfo->nLevel = nTabList;
134209 pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);
134210 pWInfo->wctrlFlags = wctrlFlags;
134211 pWInfo->iLimit = iAuxArg;
@@ -133836,17 +134279,17 @@
134279 /* Analyze all of the subexpressions. */
134280 sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
134281 if( db->mallocFailed ) goto whereBeginError;
134282
134283 if( wctrlFlags & WHERE_WANT_DISTINCT ){
134284 if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
134285 /* The DISTINCT marking is pointless. Ignore it. */
134286 pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
134287 }else if( pOrderBy==0 ){
134288 /* Try to ORDER BY the result set to make distinct processing easier */
134289 pWInfo->wctrlFlags |= WHERE_DISTINCTBY;
134290 pWInfo->pOrderBy = pResultSet;
134291 }
134292 }
134293
134294 /* Construct the WhereLoop objects */
134295 #if defined(WHERETRACE_ENABLED)
@@ -133918,14 +134361,14 @@
134361 }
134362 }
134363 #endif
134364 /* Attempt to omit tables from the join that do not effect the result */
134365 if( pWInfo->nLevel>=2
134366 && pResultSet!=0
134367 && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
134368 ){
134369 Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);
134370 if( sWLB.pOrderBy ){
134371 tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
134372 }
134373 while( pWInfo->nLevel>=2 ){
134374 WhereTerm *pTerm, *pEnd;
@@ -134704,166 +135147,166 @@
135147 **
135148 *********** Begin parsing tables **********************************************/
135149 #define YY_ACTTAB_COUNT (1567)
135150 static const YYACTIONTYPE yy_action[] = {
135151 /* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100,
135152 /* 10 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98,
135153 /* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95,
135154 /* 30 */ 94, 94, 94, 93, 351, 325, 976, 976, 824, 824,
135155 /* 40 */ 826, 946, 354, 99, 100, 90, 978, 978, 853, 856,
135156 /* 50 */ 845, 845, 97, 97, 98, 98, 98, 98, 338, 96,
135157 /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
135158 /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 976, 976,
135159 /* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100,
135160 /* 90 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98,
135161 /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95,
135162 /* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325,
135163 /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90,
135164 /* 130 */ 978, 978, 853, 856, 845, 845, 97, 97, 98, 98,
135165 /* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94,
135166 /* 150 */ 94, 94, 93, 351, 957, 957, 325, 268, 428, 413,
135167 /* 160 */ 411, 61, 752, 752, 99, 100, 90, 978, 978, 853,
135168 /* 170 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 60,
135169 /* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
135170 /* 190 */ 351, 325, 270, 329, 273, 277, 958, 959, 250, 99,
135171 /* 200 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
135172 /* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95,
135173 /* 220 */ 95, 94, 94, 94, 93, 351, 325, 937, 1326, 698,
135174 /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 978, 978, 853,
135175 /* 240 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 347,
135176 /* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
135177 /* 260 */ 351, 325, 937, 1327, 384, 699, 1327, 381, 379, 99,
135178 /* 270 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
135179 /* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95,
135180 /* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178,
135181 /* 300 */ 833, 935, 373, 700, 99, 100, 90, 978, 978, 853,
135182 /* 310 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 375,
135183 /* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
135184 /* 330 */ 351, 325, 1275, 946, 354, 818, 935, 739, 739, 99,
135185 /* 340 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
135186 /* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95,
135187 /* 360 */ 95, 94, 94, 94, 93, 351, 325, 968, 227, 92,
135188 /* 370 */ 89, 178, 373, 300, 99, 100, 90, 978, 978, 853,
135189 /* 380 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 920,
135190 /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
135191 /* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99,
135192 /* 410 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97,
135193 /* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95,
135194 /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 957,
135195 /* 440 */ 957, 158, 25, 422, 99, 100, 90, 978, 978, 853,
135196 /* 450 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 450,
135197 /* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
135198 /* 470 */ 351, 443, 224, 224, 420, 957, 957, 961, 325, 52,
135199 /* 480 */ 52, 958, 959, 176, 415, 78, 99, 100, 90, 978,
135200 /* 490 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98,
135201 /* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94,
135202 /* 510 */ 94, 93, 351, 325, 428, 418, 298, 958, 959, 961,
135203 /* 520 */ 81, 99, 88, 90, 978, 978, 853, 856, 845, 845,
135204 /* 530 */ 97, 97, 98, 98, 98, 98, 717, 96, 96, 96,
135205 /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 842,
135206 /* 550 */ 842, 854, 857, 996, 318, 343, 379, 100, 90, 978,
135207 /* 560 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98,
135208 /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94,
135209 /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340,
135210 /* 590 */ 928, 52, 52, 90, 978, 978, 853, 856, 845, 845,
135211 /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96,
135212 /* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445,
135213 /* 620 */ 846, 3, 1202, 361, 360, 378, 344, 813, 957, 957,
135214 /* 630 */ 1299, 86, 445, 729, 3, 212, 169, 287, 405, 282,
135215 /* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245,
135216 /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83,
135217 /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246,
135218 /* 670 */ 958, 959, 194, 455, 670, 402, 399, 398, 448, 243,
135219 /* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224,
135220 /* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427,
135221 /* 700 */ 819, 415, 734, 713, 132, 52, 52, 832, 268, 452,
135222 /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1270,
135223 /* 720 */ 1270, 23, 957, 957, 86, 445, 397, 3, 228, 429,
135224 /* 730 */ 894, 824, 824, 826, 827, 19, 203, 720, 52, 52,
135225 /* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229,
135226 /* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85,
135227 /* 760 */ 352, 352, 120, 157, 958, 959, 58, 976, 409, 355,
135228 /* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86,
135229 /* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96,
135230 /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351,
135231 /* 800 */ 832, 120, 452, 451, 813, 886, 819, 83, 84, 976,
135232 /* 810 */ 813, 132, 410, 919, 85, 352, 352, 132, 407, 789,
135233 /* 820 */ 957, 957, 92, 89, 178, 916, 448, 262, 370, 261,
135234 /* 830 */ 82, 913, 80, 262, 370, 261, 776, 824, 824, 826,
135235 /* 840 */ 827, 19, 933, 434, 96, 96, 96, 96, 95, 95,
135236 /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 957,
135237 /* 860 */ 957, 819, 958, 959, 120, 92, 89, 178, 944, 2,
135238 /* 870 */ 917, 964, 268, 1, 975, 76, 445, 762, 3, 708,
135239 /* 880 */ 900, 900, 387, 957, 957, 757, 918, 371, 740, 778,
135240 /* 890 */ 756, 257, 824, 824, 826, 827, 19, 417, 741, 450,
135241 /* 900 */ 24, 958, 959, 83, 84, 369, 957, 957, 177, 226,
135242 /* 910 */ 85, 352, 352, 884, 315, 314, 313, 215, 311, 10,
135243 /* 920 */ 10, 683, 448, 349, 348, 958, 959, 908, 777, 157,
135244 /* 930 */ 120, 957, 957, 337, 776, 416, 711, 310, 450, 434,
135245 /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 958, 959,
135246 /* 950 */ 907, 832, 792, 452, 451, 9, 9, 819, 10, 10,
135247 /* 960 */ 52, 52, 51, 51, 180, 716, 248, 10, 10, 171,
135248 /* 970 */ 170, 167, 339, 958, 959, 247, 984, 702, 702, 450,
135249 /* 980 */ 715, 233, 686, 982, 888, 983, 182, 913, 824, 824,
135250 /* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10,
135251 /* 1000 */ 10, 888, 890, 749, 957, 957, 916, 268, 985, 198,
135252 /* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825,
135253 /* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91,
135254 /* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93,
135255 /* 1040 */ 351, 157, 810, 371, 382, 359, 958, 959, 358, 268,
135256 /* 1050 */ 450, 917, 368, 324, 824, 824, 826, 450, 709, 450,
135257 /* 1060 */ 264, 380, 888, 450, 876, 746, 253, 918, 255, 433,
135258 /* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12,
135259 /* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162,
135260 /* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450,
135261 /* 1100 */ 709, 1209, 450, 132, 450, 39, 39, 450, 40, 40,
135262 /* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28,
135263 /* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450,
135264 /* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767,
135265 /* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47,
135266 /* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172,
135267 /* 1160 */ 49, 49, 450, 50, 50, 34, 34, 274, 122, 122,
135268 /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 897, 56, 56,
135269 /* 1180 */ 450, 896, 35, 35, 450, 267, 450, 817, 450, 817,
135270 /* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817,
135271 /* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119,
135272 /* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111,
135273 /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 911,
135274 /* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331,
135275 /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 936, 197,
135276 /* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436,
135277 /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 932,
135278 /* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202,
135279 /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 883,
135280 /* 1290 */ 120, 120, 120, 120, 120, 754, 278, 828, 77, 74,
135281 /* 1300 */ 726, 727, 785, 783, 879, 202, 999, 208, 893, 892,
135282 /* 1310 */ 893, 892, 694, 816, 763, 116, 774, 1289, 431, 432,
135283 /* 1320 */ 302, 999, 390, 303, 823, 697, 691, 680, 159, 289,
135284 /* 1330 */ 679, 883, 681, 951, 291, 218, 293, 7, 316, 828,
135285 /* 1340 */ 173, 805, 259, 364, 252, 910, 376, 713, 295, 435,
135286 /* 1350 */ 308, 168, 954, 993, 135, 400, 990, 284, 881, 880,
135287 /* 1360 */ 205, 927, 925, 59, 333, 62, 144, 156, 130, 72,
135288 /* 1370 */ 802, 366, 367, 393, 137, 185, 189, 160, 139, 383,
135289 /* 1380 */ 67, 895, 140, 141, 142, 148, 389, 812, 775, 266,
135290 /* 1390 */ 219, 190, 154, 391, 912, 875, 271, 406, 191, 322,
135291 /* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421,
135292 /* 1410 */ 705, 71, 323, 6, 204, 771, 288, 79, 297, 346,
135293 /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 966, 239,
135294 /* 1430 */ 769, 102, 861, 438, 426, 240, 424, 442, 73, 213,
135295 /* 1440 */ 688, 238, 22, 453, 952, 214, 217, 216, 454, 677,
135296 /* 1450 */ 676, 671, 753, 125, 115, 235, 126, 669, 353, 166,
135297 /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 891,
135298 /* 1470 */ 327, 889, 811, 328, 134, 128, 136, 138, 743, 258,
135299 /* 1480 */ 906, 184, 143, 129, 909, 186, 63, 64, 145, 187,
135300 /* 1490 */ 905, 65, 8, 66, 13, 188, 202, 898, 265, 149,
135301 /* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396,
135302 /* 1510 */ 151, 401, 68, 14, 15, 722, 69, 236, 831, 131,
135303 /* 1520 */ 830, 859, 70, 751, 16, 414, 755, 4, 174, 220,
135304 /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 874,
135305 /* 1540 */ 860, 858, 915, 863, 914, 207, 206, 941, 163, 437,
135306 /* 1550 */ 947, 942, 164, 209, 1002, 441, 862, 165, 210, 829,
135307 /* 1560 */ 695, 87, 312, 211, 1291, 1290, 309,
135308 };
135309 static const YYCODETYPE yy_lookahead[] = {
135310 /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28,
135311 /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
135312 /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48,
@@ -135112,55 +135555,55 @@
135555 /* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278,
135556 /* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228,
135557 /* 320 */ 1288, 1291, 1276, 1277, 1295,
135558 };
135559 static const YYACTIONTYPE yy_default[] = {
135560 /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096,
135561 /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201,
135562 /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332,
135563 /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140,
135564 /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198,
135565 /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332,
135566 /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135567 /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135568 /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135569 /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135570 /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169,
135571 /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172,
135572 /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332,
135573 /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135574 /* 140 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135575 /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332,
135576 /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332,
135577 /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135578 /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332,
135579 /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135580 /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332,
135581 /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231,
135582 /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114,
135583 /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125,
135584 /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105,
135585 /* 250 */ 1146, 1070, 1135, 1076, 1076, 1076, 1076, 1105, 1016, 1135,
135586 /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105,
135587 /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068,
135588 /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113,
135589 /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332,
135590 /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022,
135591 /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266,
135592 /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332,
135593 /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332,
135594 /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135595 /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332,
135596 /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135597 /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320,
135598 /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332,
135599 /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135600 /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332,
135601 /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332,
135602 /* 420 */ 1332, 1332, 1332, 1127, 1332, 1120, 1332, 1332, 1311, 1332,
135603 /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272,
135604 /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154,
135605 /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332,
135606 };
135607 /********** End of lemon-generated parsing tables *****************************/
135608
135609 /* The next table maps tokens (terminal symbols) into fallback tokens.
@@ -135602,147 +136045,147 @@
136045 /* 169 */ "expr ::= expr EQ|NE expr",
136046 /* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
136047 /* 171 */ "expr ::= expr PLUS|MINUS expr",
136048 /* 172 */ "expr ::= expr STAR|SLASH|REM expr",
136049 /* 173 */ "expr ::= expr CONCAT expr",
136050 /* 174 */ "likeop ::= NOT LIKE_KW|MATCH",
136051 /* 175 */ "expr ::= expr likeop expr",
136052 /* 176 */ "expr ::= expr likeop expr ESCAPE expr",
136053 /* 177 */ "expr ::= expr ISNULL|NOTNULL",
136054 /* 178 */ "expr ::= expr NOT NULL",
136055 /* 179 */ "expr ::= expr IS expr",
136056 /* 180 */ "expr ::= expr IS NOT expr",
136057 /* 181 */ "expr ::= NOT expr",
136058 /* 182 */ "expr ::= BITNOT expr",
136059 /* 183 */ "expr ::= MINUS expr",
136060 /* 184 */ "expr ::= PLUS expr",
136061 /* 185 */ "between_op ::= BETWEEN",
136062 /* 186 */ "between_op ::= NOT BETWEEN",
136063 /* 187 */ "expr ::= expr between_op expr AND expr",
136064 /* 188 */ "in_op ::= IN",
136065 /* 189 */ "in_op ::= NOT IN",
136066 /* 190 */ "expr ::= expr in_op LP exprlist RP",
136067 /* 191 */ "expr ::= LP select RP",
136068 /* 192 */ "expr ::= expr in_op LP select RP",
136069 /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist",
136070 /* 194 */ "expr ::= EXISTS LP select RP",
136071 /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END",
136072 /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
136073 /* 197 */ "case_exprlist ::= WHEN expr THEN expr",
136074 /* 198 */ "case_else ::= ELSE expr",
136075 /* 199 */ "case_else ::=",
136076 /* 200 */ "case_operand ::= expr",
136077 /* 201 */ "case_operand ::=",
136078 /* 202 */ "exprlist ::=",
136079 /* 203 */ "nexprlist ::= nexprlist COMMA expr",
136080 /* 204 */ "nexprlist ::= expr",
136081 /* 205 */ "paren_exprlist ::=",
136082 /* 206 */ "paren_exprlist ::= LP exprlist RP",
136083 /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
136084 /* 208 */ "uniqueflag ::= UNIQUE",
136085 /* 209 */ "uniqueflag ::=",
136086 /* 210 */ "eidlist_opt ::=",
136087 /* 211 */ "eidlist_opt ::= LP eidlist RP",
136088 /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder",
136089 /* 213 */ "eidlist ::= nm collate sortorder",
136090 /* 214 */ "collate ::=",
136091 /* 215 */ "collate ::= COLLATE ID|STRING",
136092 /* 216 */ "cmd ::= DROP INDEX ifexists fullname",
136093 /* 217 */ "cmd ::= VACUUM",
136094 /* 218 */ "cmd ::= VACUUM nm",
136095 /* 219 */ "cmd ::= PRAGMA nm dbnm",
136096 /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
136097 /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
136098 /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
136099 /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
136100 /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT",
136101 /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT",
136102 /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
136103 /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
136104 /* 228 */ "trigger_time ::= BEFORE",
136105 /* 229 */ "trigger_time ::= AFTER",
136106 /* 230 */ "trigger_time ::= INSTEAD OF",
136107 /* 231 */ "trigger_time ::=",
136108 /* 232 */ "trigger_event ::= DELETE|INSERT",
136109 /* 233 */ "trigger_event ::= UPDATE",
136110 /* 234 */ "trigger_event ::= UPDATE OF idlist",
136111 /* 235 */ "when_clause ::=",
136112 /* 236 */ "when_clause ::= WHEN expr",
136113 /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
136114 /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI",
136115 /* 239 */ "trnm ::= nm DOT nm",
136116 /* 240 */ "tridxby ::= INDEXED BY nm",
136117 /* 241 */ "tridxby ::= NOT INDEXED",
136118 /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
136119 /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select",
136120 /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
136121 /* 245 */ "trigger_cmd ::= select",
136122 /* 246 */ "expr ::= RAISE LP IGNORE RP",
136123 /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP",
136124 /* 248 */ "raisetype ::= ROLLBACK",
136125 /* 249 */ "raisetype ::= ABORT",
136126 /* 250 */ "raisetype ::= FAIL",
136127 /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname",
136128 /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
136129 /* 253 */ "cmd ::= DETACH database_kw_opt expr",
136130 /* 254 */ "key_opt ::=",
136131 /* 255 */ "key_opt ::= KEY expr",
136132 /* 256 */ "cmd ::= REINDEX",
136133 /* 257 */ "cmd ::= REINDEX nm dbnm",
136134 /* 258 */ "cmd ::= ANALYZE",
136135 /* 259 */ "cmd ::= ANALYZE nm dbnm",
136136 /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
136137 /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
136138 /* 262 */ "add_column_fullname ::= fullname",
136139 /* 263 */ "cmd ::= create_vtab",
136140 /* 264 */ "cmd ::= create_vtab LP vtabarglist RP",
136141 /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
136142 /* 266 */ "vtabarg ::=",
136143 /* 267 */ "vtabargtoken ::= ANY",
136144 /* 268 */ "vtabargtoken ::= lp anylist RP",
136145 /* 269 */ "lp ::= LP",
136146 /* 270 */ "with ::=",
136147 /* 271 */ "with ::= WITH wqlist",
136148 /* 272 */ "with ::= WITH RECURSIVE wqlist",
136149 /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP",
136150 /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
136151 /* 275 */ "input ::= cmdlist",
136152 /* 276 */ "cmdlist ::= cmdlist ecmd",
136153 /* 277 */ "cmdlist ::= ecmd",
136154 /* 278 */ "ecmd ::= SEMI",
136155 /* 279 */ "ecmd ::= explain cmdx SEMI",
136156 /* 280 */ "explain ::=",
136157 /* 281 */ "trans_opt ::=",
136158 /* 282 */ "trans_opt ::= TRANSACTION",
136159 /* 283 */ "trans_opt ::= TRANSACTION nm",
136160 /* 284 */ "savepoint_opt ::= SAVEPOINT",
136161 /* 285 */ "savepoint_opt ::=",
136162 /* 286 */ "cmd ::= create_table create_table_args",
136163 /* 287 */ "columnlist ::= columnlist COMMA columnname carglist",
136164 /* 288 */ "columnlist ::= columnname carglist",
136165 /* 289 */ "nm ::= ID|INDEXED",
136166 /* 290 */ "nm ::= STRING",
136167 /* 291 */ "nm ::= JOIN_KW",
136168 /* 292 */ "typetoken ::= typename",
136169 /* 293 */ "typename ::= ID|STRING",
136170 /* 294 */ "signed ::= plus_num",
136171 /* 295 */ "signed ::= minus_num",
136172 /* 296 */ "carglist ::= carglist ccons",
136173 /* 297 */ "carglist ::=",
136174 /* 298 */ "ccons ::= NULL onconf",
136175 /* 299 */ "conslist_opt ::= COMMA conslist",
136176 /* 300 */ "conslist ::= conslist tconscomma tcons",
136177 /* 301 */ "conslist ::= tcons",
136178 /* 302 */ "tconscomma ::=",
136179 /* 303 */ "defer_subclause_opt ::= defer_subclause",
136180 /* 304 */ "resolvetype ::= raisetype",
136181 /* 305 */ "selectnowith ::= oneselect",
136182 /* 306 */ "oneselect ::= values",
136183 /* 307 */ "sclp ::= selcollist COMMA",
136184 /* 308 */ "as ::= ID|STRING",
136185 /* 309 */ "expr ::= term",
136186 /* 310 */ "likeop ::= LIKE_KW|MATCH",
136187 /* 311 */ "exprlist ::= nexprlist",
136188 /* 312 */ "nmnum ::= plus_num",
136189 /* 313 */ "nmnum ::= nm",
136190 /* 314 */ "nmnum ::= ON",
136191 /* 315 */ "nmnum ::= DELETE",
@@ -136375,11 +136818,10 @@
136818 { 173, 3 },
136819 { 173, 3 },
136820 { 173, 3 },
136821 { 173, 3 },
136822 { 173, 3 },
 
136823 { 221, 2 },
136824 { 173, 3 },
136825 { 173, 5 },
136826 { 173, 2 },
136827 { 173, 3 },
@@ -136512,10 +136954,11 @@
136954 { 194, 1 },
136955 { 195, 1 },
136956 { 209, 2 },
136957 { 210, 1 },
136958 { 173, 1 },
136959 { 221, 1 },
136960 { 208, 1 },
136961 { 230, 1 },
136962 { 230, 1 },
136963 { 230, 1 },
136964 { 230, 1 },
@@ -136654,11 +137097,11 @@
137097 case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
137098 case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
137099 case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
137100 case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
137101 case 90: /* distinct ::= */ yytestcase(yyruleno==90);
137102 case 214: /* collate ::= */ yytestcase(yyruleno==214);
137103 {yymsp[1].minor.yy194 = 0;}
137104 break;
137105 case 17: /* ifnotexists ::= IF NOT EXISTS */
137106 {yymsp[-2].minor.yy194 = 1;}
137107 break;
@@ -136798,13 +137241,13 @@
137241 case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144);
137242 {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;}
137243 break;
137244 case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
137245 case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
137246 case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186);
137247 case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189);
137248 case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215);
137249 {yymsp[-1].minor.yy194 = 1;}
137250 break;
137251 case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
137252 {yymsp[-1].minor.yy194 = 0;}
137253 break;
@@ -136964,13 +137407,13 @@
137407 {yymsp[0].minor.yy194 = SF_All;}
137408 break;
137409 case 91: /* sclp ::= */
137410 case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119);
137411 case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126);
137412 case 202: /* exprlist ::= */ yytestcase(yyruleno==202);
137413 case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205);
137414 case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210);
137415 {yymsp[1].minor.yy148 = 0;}
137416 break;
137417 case 92: /* selcollist ::= sclp expr as */
137418 {
137419 yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr);
@@ -136992,12 +137435,12 @@
137435 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot);
137436 }
137437 break;
137438 case 95: /* as ::= AS nm */
137439 case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
137440 case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224);
137441 case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225);
137442 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
137443 break;
137444 case 97: /* from ::= */
137445 {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));}
137446 break;
@@ -137076,18 +137519,18 @@
137519 {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
137520 break;
137521 case 112: /* on_opt ::= ON expr */
137522 case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129);
137523 case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136);
137524 case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198);
137525 {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;}
137526 break;
137527 case 113: /* on_opt ::= */
137528 case 128: /* having_opt ::= */ yytestcase(yyruleno==128);
137529 case 135: /* where_opt ::= */ yytestcase(yyruleno==135);
137530 case 199: /* case_else ::= */ yytestcase(yyruleno==199);
137531 case 201: /* case_operand ::= */ yytestcase(yyruleno==201);
137532 {yymsp[1].minor.yy72 = 0;}
137533 break;
137534 case 115: /* indexed_opt ::= INDEXED BY nm */
137535 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
137536 break;
@@ -137320,17 +137763,14 @@
137763 case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171);
137764 case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172);
137765 case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173);
137766 {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);}
137767 break;
137768 case 174: /* likeop ::= NOT LIKE_KW|MATCH */
 
 
 
137769 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
137770 break;
137771 case 175: /* expr ::= expr likeop expr */
137772 {
137773 ExprList *pList;
137774 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
137775 yymsp[-1].minor.yy0.n &= 0x7fffffff;
137776 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr);
@@ -137339,11 +137779,11 @@
137779 exprNot(pParse, bNot, &yymsp[-2].minor.yy190);
137780 yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137781 if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc;
137782 }
137783 break;
137784 case 176: /* expr ::= expr likeop expr ESCAPE expr */
137785 {
137786 ExprList *pList;
137787 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
137788 yymsp[-3].minor.yy0.n &= 0x7fffffff;
137789 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
@@ -137353,43 +137793,43 @@
137793 exprNot(pParse, bNot, &yymsp[-4].minor.yy190);
137794 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137795 if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc;
137796 }
137797 break;
137798 case 177: /* expr ::= expr ISNULL|NOTNULL */
137799 {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);}
137800 break;
137801 case 178: /* expr ::= expr NOT NULL */
137802 {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);}
137803 break;
137804 case 179: /* expr ::= expr IS expr */
137805 {
137806 spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);
137807 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL);
137808 }
137809 break;
137810 case 180: /* expr ::= expr IS NOT expr */
137811 {
137812 spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190);
137813 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL);
137814 }
137815 break;
137816 case 181: /* expr ::= NOT expr */
137817 case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182);
137818 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137819 break;
137820 case 183: /* expr ::= MINUS expr */
137821 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137822 break;
137823 case 184: /* expr ::= PLUS expr */
137824 {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/}
137825 break;
137826 case 185: /* between_op ::= BETWEEN */
137827 case 188: /* in_op ::= IN */ yytestcase(yyruleno==188);
137828 {yymsp[0].minor.yy194 = 0;}
137829 break;
137830 case 187: /* expr ::= expr between_op expr AND expr */
137831 {
137832 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137833 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr);
137834 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0);
137835 if( yymsp[-4].minor.yy190.pExpr ){
@@ -137399,11 +137839,11 @@
137839 }
137840 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137841 yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd;
137842 }
137843 break;
137844 case 190: /* expr ::= expr in_op LP exprlist RP */
137845 {
137846 if( yymsp[-1].minor.yy148==0 ){
137847 /* Expressions of the form
137848 **
137849 ** expr1 IN ()
@@ -137452,26 +137892,26 @@
137892 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137893 }
137894 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
137895 }
137896 break;
137897 case 191: /* expr ::= LP select RP */
137898 {
137899 spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
137900 yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
137901 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137902 }
137903 break;
137904 case 192: /* expr ::= expr in_op LP select RP */
137905 {
137906 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
137907 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243);
137908 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137909 yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
137910 }
137911 break;
137912 case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */
137913 {
137914 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
137915 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
137916 if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148);
137917 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0);
@@ -137478,19 +137918,19 @@
137918 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect);
137919 exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190);
137920 yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n];
137921 }
137922 break;
137923 case 194: /* expr ::= EXISTS LP select RP */
137924 {
137925 Expr *p;
137926 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/
137927 p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
137928 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243);
137929 }
137930 break;
137931 case 195: /* expr ::= CASE case_operand case_exprlist case_else END */
137932 {
137933 spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/
137934 yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0);
137935 if( yymsp[-4].minor.yy190.pExpr ){
137936 yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148;
@@ -137499,313 +137939,314 @@
137939 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148);
137940 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72);
137941 }
137942 }
137943 break;
137944 case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
137945 {
137946 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr);
137947 yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr);
137948 }
137949 break;
137950 case 197: /* case_exprlist ::= WHEN expr THEN expr */
137951 {
137952 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr);
137953 yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr);
137954 }
137955 break;
137956 case 200: /* case_operand ::= expr */
137957 {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/}
137958 break;
137959 case 203: /* nexprlist ::= nexprlist COMMA expr */
137960 {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);}
137961 break;
137962 case 204: /* nexprlist ::= expr */
137963 {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/}
137964 break;
137965 case 206: /* paren_exprlist ::= LP exprlist RP */
137966 case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211);
137967 {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;}
137968 break;
137969 case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
137970 {
137971 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
137972 sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194,
137973 &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF);
137974 }
137975 break;
137976 case 208: /* uniqueflag ::= UNIQUE */
137977 case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249);
137978 {yymsp[0].minor.yy194 = OE_Abort;}
137979 break;
137980 case 209: /* uniqueflag ::= */
137981 {yymsp[1].minor.yy194 = OE_None;}
137982 break;
137983 case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */
137984 {
137985 yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194);
137986 }
137987 break;
137988 case 213: /* eidlist ::= nm collate sortorder */
137989 {
137990 yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/
137991 }
137992 break;
137993 case 216: /* cmd ::= DROP INDEX ifexists fullname */
137994 {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);}
137995 break;
137996 case 217: /* cmd ::= VACUUM */
137997 {sqlite3Vacuum(pParse,0);}
137998 break;
137999 case 218: /* cmd ::= VACUUM nm */
138000 {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
138001 break;
138002 case 219: /* cmd ::= PRAGMA nm dbnm */
138003 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
138004 break;
138005 case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
138006 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
138007 break;
138008 case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
138009 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
138010 break;
138011 case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
138012 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
138013 break;
138014 case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
138015 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
138016 break;
138017 case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
138018 {
138019 Token all;
138020 all.z = yymsp[-3].minor.yy0.z;
138021 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
138022 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all);
138023 }
138024 break;
138025 case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
138026 {
138027 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194);
138028 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
138029 }
138030 break;
138031 case 228: /* trigger_time ::= BEFORE */
138032 { yymsp[0].minor.yy194 = TK_BEFORE; }
138033 break;
138034 case 229: /* trigger_time ::= AFTER */
138035 { yymsp[0].minor.yy194 = TK_AFTER; }
138036 break;
138037 case 230: /* trigger_time ::= INSTEAD OF */
138038 { yymsp[-1].minor.yy194 = TK_INSTEAD;}
138039 break;
138040 case 231: /* trigger_time ::= */
138041 { yymsp[1].minor.yy194 = TK_BEFORE; }
138042 break;
138043 case 232: /* trigger_event ::= DELETE|INSERT */
138044 case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233);
138045 {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;}
138046 break;
138047 case 234: /* trigger_event ::= UPDATE OF idlist */
138048 {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;}
138049 break;
138050 case 235: /* when_clause ::= */
138051 case 254: /* key_opt ::= */ yytestcase(yyruleno==254);
138052 { yymsp[1].minor.yy72 = 0; }
138053 break;
138054 case 236: /* when_clause ::= WHEN expr */
138055 case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255);
138056 { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; }
138057 break;
138058 case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
138059 {
138060 assert( yymsp[-2].minor.yy145!=0 );
138061 yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145;
138062 yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145;
138063 }
138064 break;
138065 case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */
138066 {
138067 assert( yymsp[-1].minor.yy145!=0 );
138068 yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145;
138069 }
138070 break;
138071 case 239: /* trnm ::= nm DOT nm */
138072 {
138073 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
138074 sqlite3ErrorMsg(pParse,
138075 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
138076 "statements within triggers");
138077 }
138078 break;
138079 case 240: /* tridxby ::= INDEXED BY nm */
138080 {
138081 sqlite3ErrorMsg(pParse,
138082 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
138083 "within triggers");
138084 }
138085 break;
138086 case 241: /* tridxby ::= NOT INDEXED */
138087 {
138088 sqlite3ErrorMsg(pParse,
138089 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
138090 "within triggers");
138091 }
138092 break;
138093 case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
138094 {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);}
138095 break;
138096 case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */
138097 {yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/}
138098 break;
138099 case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
138100 {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);}
138101 break;
138102 case 245: /* trigger_cmd ::= select */
138103 {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/}
138104 break;
138105 case 246: /* expr ::= RAISE LP IGNORE RP */
138106 {
138107 spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138108 yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
138109 if( yymsp[-3].minor.yy190.pExpr ){
138110 yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore;
138111 }
138112 }
138113 break;
138114 case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */
138115 {
138116 spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/
138117 yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
138118 if( yymsp[-5].minor.yy190.pExpr ) {
138119 yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194;
138120 }
138121 }
138122 break;
138123 case 248: /* raisetype ::= ROLLBACK */
138124 {yymsp[0].minor.yy194 = OE_Rollback;}
138125 break;
138126 case 250: /* raisetype ::= FAIL */
138127 {yymsp[0].minor.yy194 = OE_Fail;}
138128 break;
138129 case 251: /* cmd ::= DROP TRIGGER ifexists fullname */
138130 {
138131 sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194);
138132 }
138133 break;
138134 case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
138135 {
138136 sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72);
138137 }
138138 break;
138139 case 253: /* cmd ::= DETACH database_kw_opt expr */
138140 {
138141 sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr);
138142 }
138143 break;
138144 case 256: /* cmd ::= REINDEX */
138145 {sqlite3Reindex(pParse, 0, 0);}
138146 break;
138147 case 257: /* cmd ::= REINDEX nm dbnm */
138148 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
138149 break;
138150 case 258: /* cmd ::= ANALYZE */
138151 {sqlite3Analyze(pParse, 0, 0);}
138152 break;
138153 case 259: /* cmd ::= ANALYZE nm dbnm */
138154 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
138155 break;
138156 case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
138157 {
138158 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0);
138159 }
138160 break;
138161 case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
138162 {
138163 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
138164 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
138165 }
138166 break;
138167 case 262: /* add_column_fullname ::= fullname */
138168 {
138169 disableLookaside(pParse);
138170 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185);
138171 }
138172 break;
138173 case 263: /* cmd ::= create_vtab */
138174 {sqlite3VtabFinishParse(pParse,0);}
138175 break;
138176 case 264: /* cmd ::= create_vtab LP vtabarglist RP */
138177 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
138178 break;
138179 case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
138180 {
138181 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194);
138182 }
138183 break;
138184 case 266: /* vtabarg ::= */
138185 {sqlite3VtabArgInit(pParse);}
138186 break;
138187 case 267: /* vtabargtoken ::= ANY */
138188 case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268);
138189 case 269: /* lp ::= LP */ yytestcase(yyruleno==269);
138190 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
138191 break;
138192 case 270: /* with ::= */
138193 {yymsp[1].minor.yy285 = 0;}
138194 break;
138195 case 271: /* with ::= WITH wqlist */
138196 { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; }
138197 break;
138198 case 272: /* with ::= WITH RECURSIVE wqlist */
138199 { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; }
138200 break;
138201 case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */
138202 {
138203 yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/
138204 }
138205 break;
138206 case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
138207 {
138208 yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243);
138209 }
138210 break;
138211 default:
138212 /* (275) input ::= cmdlist */ yytestcase(yyruleno==275);
138213 /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276);
138214 /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277);
138215 /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278);
138216 /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279);
138217 /* (280) explain ::= */ yytestcase(yyruleno==280);
138218 /* (281) trans_opt ::= */ yytestcase(yyruleno==281);
138219 /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282);
138220 /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283);
138221 /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284);
138222 /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285);
138223 /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286);
138224 /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287);
138225 /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288);
138226 /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289);
138227 /* (290) nm ::= STRING */ yytestcase(yyruleno==290);
138228 /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291);
138229 /* (292) typetoken ::= typename */ yytestcase(yyruleno==292);
138230 /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293);
138231 /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294);
138232 /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
138233 /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296);
138234 /* (297) carglist ::= */ yytestcase(yyruleno==297);
138235 /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298);
138236 /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299);
138237 /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300);
138238 /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301);
138239 /* (302) tconscomma ::= */ yytestcase(yyruleno==302);
138240 /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303);
138241 /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304);
138242 /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305);
138243 /* (306) oneselect ::= values */ yytestcase(yyruleno==306);
138244 /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307);
138245 /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308);
138246 /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309);
138247 /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310);
138248 /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311);
138249 /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312);
138250 /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313);
138251 /* (314) nmnum ::= ON */ yytestcase(yyruleno==314);
138252 /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315);
@@ -140301,10 +140742,25 @@
140742 return 0;
140743 }
140744 #endif
140745 return db->lastRowid;
140746 }
140747
140748 /*
140749 ** Set the value returned by the sqlite3_last_insert_rowid() API function.
140750 */
140751 SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *db, sqlite3_int64 iRowid){
140752 #ifdef SQLITE_ENABLE_API_ARMOR
140753 if( !sqlite3SafetyCheckOk(db) ){
140754 (void)SQLITE_MISUSE_BKPT;
140755 return;
140756 }
140757 #endif
140758 sqlite3_mutex_enter(db->mutex);
140759 db->lastRowid = iRowid;
140760 sqlite3_mutex_leave(db->mutex);
140761 }
140762
140763 /*
140764 ** Return the number of changes in the most recent call to sqlite3_exec().
140765 */
140766 SQLITE_API int sqlite3_changes(sqlite3 *db){
@@ -148111,12 +148567,14 @@
148567 ** segments.
148568 */
148569 const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */
148570
148571 Fts3Table *p = (Fts3Table*)pVtab;
148572 int rc;
148573 i64 iLastRowid = sqlite3_last_insert_rowid(p->db);
148574
148575 rc = sqlite3Fts3PendingTermsFlush(p);
148576 if( rc==SQLITE_OK
148577 && p->nLeafAdd>(nMinMerge/16)
148578 && p->nAutoincrmerge && p->nAutoincrmerge!=0xff
148579 ){
148580 int mxLevel = 0; /* Maximum relative level value in db */
@@ -148127,10 +148585,11 @@
148585 A = p->nLeafAdd * mxLevel;
148586 A += (A/2);
148587 if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge);
148588 }
148589 sqlite3Fts3SegmentsClose(p);
148590 sqlite3_set_last_insert_rowid(p->db, iLastRowid);
148591 return rc;
148592 }
148593
148594 /*
148595 ** If it is currently unknown whether or not the FTS table has an %_stat
@@ -168462,10 +168921,11 @@
168921 int nStep; /* Rows processed for current object */
168922 int nProgress; /* Rows processed for all objects */
168923 RbuObjIter objiter; /* Iterator for skipping through tbl/idx */
168924 const char *zVfsName; /* Name of automatically created rbu vfs */
168925 rbu_file *pTargetFd; /* File handle open on target db */
168926 int nPagePerSector; /* Pages per sector for pTargetFd */
168927 i64 iOalSz;
168928 i64 nPhaseOneStep;
168929
168930 /* The following state variables are used as part of the incremental
168931 ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding
@@ -170726,10 +171186,27 @@
171186
171187 if( p->rc==SQLITE_OK ){
171188 if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){
171189 p->rc = SQLITE_DONE;
171190 p->eStage = RBU_STAGE_DONE;
171191 }else{
171192 int nSectorSize;
171193 sqlite3_file *pDb = p->pTargetFd->pReal;
171194 sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal;
171195 assert( p->nPagePerSector==0 );
171196 nSectorSize = pDb->pMethods->xSectorSize(pDb);
171197 if( nSectorSize>p->pgsz ){
171198 p->nPagePerSector = nSectorSize / p->pgsz;
171199 }else{
171200 p->nPagePerSector = 1;
171201 }
171202
171203 /* Call xSync() on the wal file. This causes SQLite to sync the
171204 ** directory in which the target database and the wal file reside, in
171205 ** case it has not been synced since the rename() call in
171206 ** rbuMoveOalFile(). */
171207 p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL);
171208 }
171209 }
171210 }
171211
171212 /*
@@ -171381,13 +171858,30 @@
171858 if( p->rc==SQLITE_OK ){
171859 p->eStage = RBU_STAGE_DONE;
171860 p->rc = SQLITE_DONE;
171861 }
171862 }else{
171863 /* At one point the following block copied a single frame from the
171864 ** wal file to the database file. So that one call to sqlite3rbu_step()
171865 ** checkpointed a single frame.
171866 **
171867 ** However, if the sector-size is larger than the page-size, and the
171868 ** application calls sqlite3rbu_savestate() or close() immediately
171869 ** after this step, then rbu_step() again, then a power failure occurs,
171870 ** then the database page written here may be damaged. Work around
171871 ** this by checkpointing frames until the next page in the aFrame[]
171872 ** lies on a different disk sector to the current one. */
171873 u32 iSector;
171874 do{
171875 RbuFrame *pFrame = &p->aFrame[p->nStep];
171876 iSector = (pFrame->iDbPage-1) / p->nPagePerSector;
171877 rbuCheckpointFrame(p, pFrame);
171878 p->nStep++;
171879 }while( p->nStep<p->nFrame
171880 && iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector)
171881 && p->rc==SQLITE_OK
171882 );
171883 }
171884 p->nProgress++;
171885 }
171886 break;
171887 }
@@ -171823,10 +172317,16 @@
172317
172318 /* Commit the transaction to the *-oal file. */
172319 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
172320 p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg);
172321 }
172322
172323 /* Sync the db file if currently doing an incremental checkpoint */
172324 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
172325 sqlite3_file *pDb = p->pTargetFd->pReal;
172326 p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
172327 }
172328
172329 rbuSaveState(p, p->eStage);
172330
172331 if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){
172332 p->rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, &p->zErrmsg);
@@ -171947,10 +172447,16 @@
172447 assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE );
172448 if( p->eStage==RBU_STAGE_OAL ){
172449 assert( rc!=SQLITE_DONE );
172450 if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0);
172451 }
172452
172453 /* Sync the db file */
172454 if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){
172455 sqlite3_file *pDb = p->pTargetFd->pReal;
172456 rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL);
172457 }
172458
172459 p->rc = rc;
172460 rbuSaveState(p, p->eStage);
172461 rc = p->rc;
172462
@@ -181079,11 +181585,13 @@
181585 typedef unsigned short u16;
181586 typedef short i16;
181587 typedef sqlite3_int64 i64;
181588 typedef sqlite3_uint64 u64;
181589
181590 #ifndef ArraySize
181591 # define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0])))
181592 #endif
181593
181594 #define testcase(x)
181595 #define ALWAYS(x) 1
181596 #define NEVER(x) 0
181597
@@ -186302,11 +186810,14 @@
186810 if( p1->bEof==0 ){
186811 if( (p1->iRowid==iLast)
186812 || (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0)
186813 ){
186814 int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom);
186815 if( rc!=SQLITE_OK ){
186816 pNode->bNomatch = 0;
186817 return rc;
186818 }
186819 }
186820 }
186821 }
186822
186823 fts5ExprNodeTest_OR(pExpr, pNode);
@@ -186333,11 +186844,14 @@
186844 Fts5ExprNode *pChild = pAnd->apChild[iChild];
186845 int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid);
186846 if( cmp>0 ){
186847 /* Advance pChild until it points to iLast or laster */
186848 rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast);
186849 if( rc!=SQLITE_OK ){
186850 pAnd->bNomatch = 0;
186851 return rc;
186852 }
186853 }
186854
186855 /* If the child node is now at EOF, so is the parent AND node. Otherwise,
186856 ** the child node is guaranteed to have advanced at least as far as
186857 ** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the
@@ -186372,10 +186886,12 @@
186886 i64 iFrom
186887 ){
186888 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
186889 if( rc==SQLITE_OK ){
186890 rc = fts5ExprNodeTest_AND(pExpr, pNode);
186891 }else{
186892 pNode->bNomatch = 0;
186893 }
186894 return rc;
186895 }
186896
186897 static int fts5ExprNodeTest_NOT(
@@ -186414,10 +186930,13 @@
186930 ){
186931 int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom);
186932 if( rc==SQLITE_OK ){
186933 rc = fts5ExprNodeTest_NOT(pExpr, pNode);
186934 }
186935 if( rc!=SQLITE_OK ){
186936 pNode->bNomatch = 0;
186937 }
186938 return rc;
186939 }
186940
186941 /*
186942 ** If pNode currently points to a match, this function returns SQLITE_OK
@@ -197534,11 +198053,11 @@
198053 int nArg, /* Number of args */
198054 sqlite3_value **apUnused /* Function arguments */
198055 ){
198056 assert( nArg==0 );
198057 UNUSED_PARAM2(nArg, apUnused);
198058 sqlite3_result_text(pCtx, "fts5: 2017-03-03 16:51:46 915a9a28783fbb2f4c0794eb4264ce8c0b9d42f7", -1, SQLITE_TRANSIENT);
198059 }
198060
198061 static int fts5Init(sqlite3 *db){
198062 static const sqlite3_module fts5Mod = {
198063 /* iVersion */ 2,
@@ -198197,15 +198716,10 @@
198716 sqlite3_step(pDel);
198717 rc = sqlite3_reset(pDel);
198718 }
198719 }
198720
 
 
 
 
 
198721 return rc;
198722 }
198723
198724 /*
198725 ** Delete all entries in the FTS5 index.
@@ -198405,15 +198919,10 @@
198919 if( rc==SQLITE_OK ){
198920 rc = fts5StorageInsertDocsize(p, iRowid, &buf);
198921 }
198922 sqlite3_free(buf.p);
198923
 
 
 
 
 
198924 return rc;
198925 }
198926
198927 static int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){
198928 Fts5Config *pConfig = p->pConfig;
@@ -198744,16 +199253,21 @@
199253
199254 /*
199255 ** Flush any data currently held in-memory to disk.
199256 */
199257 static int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit){
199258 int rc = SQLITE_OK;
199259 i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db);
199260 if( p->bTotalsValid ){
199261 rc = fts5StorageSaveTotals(p);
199262 if( bCommit ) p->bTotalsValid = 0;
199263 }
199264 if( rc==SQLITE_OK ){
199265 rc = sqlite3Fts5IndexSync(p->pIndex, bCommit);
199266 }
199267 sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid);
199268 return rc;
199269 }
199270
199271 static int sqlite3Fts5StorageRollback(Fts5Storage *p){
199272 p->bTotalsValid = 0;
199273 return sqlite3Fts5IndexRollback(p->pIndex);
199274
+36 -16
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,13 +119,13 @@
119119
**
120120
** See also: [sqlite3_libversion()],
121121
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122122
** [sqlite_version()] and [sqlite_source_id()].
123123
*/
124
-#define SQLITE_VERSION "3.17.0"
125
-#define SQLITE_VERSION_NUMBER 3017000
126
-#define SQLITE_SOURCE_ID "2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c"
124
+#define SQLITE_VERSION "3.18.0"
125
+#define SQLITE_VERSION_NUMBER 3018000
126
+#define SQLITE_SOURCE_ID "2017-03-06 17:33:58 137aeb2b160888100bc1e871b00860149e5f6196"
127127
128128
/*
129129
** CAPI3REF: Run-Time Library Version Numbers
130130
** KEYWORDS: sqlite3_version sqlite3_sourceid
131131
**
@@ -2038,24 +2038,34 @@
20382038
** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
20392039
** names are not also used by explicitly declared columns. ^If
20402040
** the table has a column of type [INTEGER PRIMARY KEY] then that column
20412041
** is another alias for the rowid.
20422042
**
2043
-** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
2044
-** most recent successful [INSERT] into a rowid table or [virtual table]
2045
-** on database connection D.
2046
-** ^Inserts into [WITHOUT ROWID] tables are not recorded.
2047
-** ^If no successful [INSERT]s into rowid tables
2048
-** have ever occurred on the database connection D,
2049
-** then sqlite3_last_insert_rowid(D) returns zero.
2043
+** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of
2044
+** the most recent successful [INSERT] into a rowid table or [virtual table]
2045
+** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not
2046
+** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred
2047
+** on the database connection D, then sqlite3_last_insert_rowid(D) returns
2048
+** zero.
20502049
**
2051
-** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
2052
-** method, then this routine will return the [rowid] of the inserted
2053
-** row as long as the trigger or virtual table method is running.
2054
-** But once the trigger or virtual table method ends, the value returned
2055
-** by this routine reverts to what it was before the trigger or virtual
2056
-** table method began.)^
2050
+** As well as being set automatically as rows are inserted into database
2051
+** tables, the value returned by this function may be set explicitly by
2052
+** [sqlite3_set_last_insert_rowid()]
2053
+**
2054
+** Some virtual table implementations may INSERT rows into rowid tables as
2055
+** part of committing a transaction (e.g. to flush data accumulated in memory
2056
+** to disk). In this case subsequent calls to this function return the rowid
2057
+** associated with these internal INSERT operations, which leads to
2058
+** unintuitive results. Virtual table implementations that do write to rowid
2059
+** tables in this way can avoid this problem by restoring the original
2060
+** rowid value using [sqlite3_set_last_insert_rowid()] before returning
2061
+** control to the user.
2062
+**
2063
+** ^(If an [INSERT] occurs within a trigger then this routine will
2064
+** return the [rowid] of the inserted row as long as the trigger is
2065
+** running. Once the trigger program ends, the value returned
2066
+** by this routine reverts to what it was before the trigger was fired.)^
20572067
**
20582068
** ^An [INSERT] that fails due to a constraint violation is not a
20592069
** successful [INSERT] and does not change the value returned by this
20602070
** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
20612071
** and INSERT OR ABORT make no changes to the return value of this
@@ -2078,10 +2088,20 @@
20782088
** unpredictable and might not equal either the old or the new
20792089
** last insert [rowid].
20802090
*/
20812091
SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
20822092
2093
+/*
2094
+** CAPI3REF: Set the Last Insert Rowid value.
2095
+** METHOD: sqlite3
2096
+**
2097
+** The sqlite3_set_last_insert_rowid(D, R) method allows the application to
2098
+** set the value returned by calling sqlite3_last_insert_rowid(D) to R
2099
+** without inserting a row into the database.
2100
+*/
2101
+SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2102
+
20832103
/*
20842104
** CAPI3REF: Count The Number Of Rows Modified
20852105
** METHOD: sqlite3
20862106
**
20872107
** ^This function returns the number of rows modified, inserted or
20882108
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,13 +119,13 @@
119 **
120 ** See also: [sqlite3_libversion()],
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.17.0"
125 #define SQLITE_VERSION_NUMBER 3017000
126 #define SQLITE_SOURCE_ID "2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -2038,24 +2038,34 @@
2038 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
2039 ** names are not also used by explicitly declared columns. ^If
2040 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
2041 ** is another alias for the rowid.
2042 **
2043 ** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
2044 ** most recent successful [INSERT] into a rowid table or [virtual table]
2045 ** on database connection D.
2046 ** ^Inserts into [WITHOUT ROWID] tables are not recorded.
2047 ** ^If no successful [INSERT]s into rowid tables
2048 ** have ever occurred on the database connection D,
2049 ** then sqlite3_last_insert_rowid(D) returns zero.
2050 **
2051 ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
2052 ** method, then this routine will return the [rowid] of the inserted
2053 ** row as long as the trigger or virtual table method is running.
2054 ** But once the trigger or virtual table method ends, the value returned
2055 ** by this routine reverts to what it was before the trigger or virtual
2056 ** table method began.)^
 
 
 
 
 
 
 
 
 
 
 
2057 **
2058 ** ^An [INSERT] that fails due to a constraint violation is not a
2059 ** successful [INSERT] and does not change the value returned by this
2060 ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
2061 ** and INSERT OR ABORT make no changes to the return value of this
@@ -2078,10 +2088,20 @@
2078 ** unpredictable and might not equal either the old or the new
2079 ** last insert [rowid].
2080 */
2081 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2082
 
 
 
 
 
 
 
 
 
 
2083 /*
2084 ** CAPI3REF: Count The Number Of Rows Modified
2085 ** METHOD: sqlite3
2086 **
2087 ** ^This function returns the number of rows modified, inserted or
2088
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -119,13 +119,13 @@
119 **
120 ** See also: [sqlite3_libversion()],
121 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
122 ** [sqlite_version()] and [sqlite_source_id()].
123 */
124 #define SQLITE_VERSION "3.18.0"
125 #define SQLITE_VERSION_NUMBER 3018000
126 #define SQLITE_SOURCE_ID "2017-03-06 17:33:58 137aeb2b160888100bc1e871b00860149e5f6196"
127
128 /*
129 ** CAPI3REF: Run-Time Library Version Numbers
130 ** KEYWORDS: sqlite3_version sqlite3_sourceid
131 **
@@ -2038,24 +2038,34 @@
2038 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
2039 ** names are not also used by explicitly declared columns. ^If
2040 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
2041 ** is another alias for the rowid.
2042 **
2043 ** ^The sqlite3_last_insert_rowid(D) interface usually returns the [rowid] of
2044 ** the most recent successful [INSERT] into a rowid table or [virtual table]
2045 ** on database connection D. ^Inserts into [WITHOUT ROWID] tables are not
2046 ** recorded. ^If no successful [INSERT]s into rowid tables have ever occurred
2047 ** on the database connection D, then sqlite3_last_insert_rowid(D) returns
2048 ** zero.
 
2049 **
2050 ** As well as being set automatically as rows are inserted into database
2051 ** tables, the value returned by this function may be set explicitly by
2052 ** [sqlite3_set_last_insert_rowid()]
2053 **
2054 ** Some virtual table implementations may INSERT rows into rowid tables as
2055 ** part of committing a transaction (e.g. to flush data accumulated in memory
2056 ** to disk). In this case subsequent calls to this function return the rowid
2057 ** associated with these internal INSERT operations, which leads to
2058 ** unintuitive results. Virtual table implementations that do write to rowid
2059 ** tables in this way can avoid this problem by restoring the original
2060 ** rowid value using [sqlite3_set_last_insert_rowid()] before returning
2061 ** control to the user.
2062 **
2063 ** ^(If an [INSERT] occurs within a trigger then this routine will
2064 ** return the [rowid] of the inserted row as long as the trigger is
2065 ** running. Once the trigger program ends, the value returned
2066 ** by this routine reverts to what it was before the trigger was fired.)^
2067 **
2068 ** ^An [INSERT] that fails due to a constraint violation is not a
2069 ** successful [INSERT] and does not change the value returned by this
2070 ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
2071 ** and INSERT OR ABORT make no changes to the return value of this
@@ -2078,10 +2088,20 @@
2088 ** unpredictable and might not equal either the old or the new
2089 ** last insert [rowid].
2090 */
2091 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2092
2093 /*
2094 ** CAPI3REF: Set the Last Insert Rowid value.
2095 ** METHOD: sqlite3
2096 **
2097 ** The sqlite3_set_last_insert_rowid(D, R) method allows the application to
2098 ** set the value returned by calling sqlite3_last_insert_rowid(D) to R
2099 ** without inserting a row into the database.
2100 */
2101 SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64);
2102
2103 /*
2104 ** CAPI3REF: Count The Number Of Rows Modified
2105 ** METHOD: sqlite3
2106 **
2107 ** ^This function returns the number of rows modified, inserted or
2108
+64 -2
--- src/stat.c
+++ src/stat.c
@@ -388,10 +388,12 @@
388388
**
389389
** Show the repository schema
390390
*/
391391
void repo_schema_page(void){
392392
Stmt q;
393
+ Blob sql;
394
+ const char *zArg = P("n");
393395
login_check_credentials();
394396
if( !g.perm.Admin ){ login_needed(0); return; }
395397
396398
style_header("Repository Schema");
397399
style_adunit_config(ADUNIT_RIGHT_OK);
@@ -398,18 +400,78 @@
398400
style_submenu_element("Stat", "stat");
399401
style_submenu_element("URLs", "urllist");
400402
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
401403
style_submenu_element("Table Sizes", "repo-tabsize");
402404
}
403
- db_prepare(&q,
404
- "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL");
405
+ blob_init(&sql,
406
+ "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
407
+ if( zArg ){
408
+ style_submenu_element("All", "repo_schema");
409
+ blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
410
+ }
411
+ blob_appendf(&sql, " ORDER BY tbl_name, type<>'table', name");
412
+ db_prepare(&q, "%s", blob_str(&sql)/*safe-for-%s*/);
413
+ blob_reset(&sql);
405414
@ <pre>
406415
while( db_step(&q)==SQLITE_ROW ){
407416
@ %h(db_column_text(&q, 0));
408417
}
409418
@ </pre>
410419
db_finalize(&q);
420
+ if( db_table_exists("repository","sqlite_stat1") ){
421
+ if( zArg ){
422
+ db_prepare(&q,
423
+ "SELECT tbl, idx, stat FROM repository.sqlite_stat1"
424
+ " WHERE tbl LIKE %Q OR idx LIKE %Q"
425
+ " ORDER BY tbl, idx", zArg, zArg);
426
+
427
+ @ <hr>
428
+ @ <pre>
429
+ while( db_step(&q)==SQLITE_ROW ){
430
+ const char *zTab = db_column_text(&q,0);
431
+ const char *zIdx = db_column_text(&q,1);
432
+ const char *zStat = db_column_text(&q,2);
433
+ @ INSERT INTO sqlite_stat1 VALUES('%h(zTab)','%h(zIdx)','%h(zStat)');
434
+ }
435
+ @ </pre>
436
+ db_finalize(&q);
437
+ }else{
438
+ style_submenu_element("Stat1","repo_stat1");
439
+ }
440
+ }
441
+ style_footer();
442
+}
443
+
444
+/*
445
+** WEBPAGE: repo_stat1
446
+**
447
+** Show the sqlite_stat1 table for the repository schema
448
+*/
449
+void repo_stat1_page(void){
450
+ login_check_credentials();
451
+ if( !g.perm.Admin ){ login_needed(0); return; }
452
+
453
+ style_header("Repository STAT1 Table");
454
+ style_adunit_config(ADUNIT_RIGHT_OK);
455
+ style_submenu_element("Stat", "stat");
456
+ style_submenu_element("Schema", "repo_schema");
457
+ if( db_table_exists("repository","sqlite_stat1") ){
458
+ Stmt q;
459
+ db_prepare(&q,
460
+ "SELECT tbl, idx, stat FROM repository.sqlite_stat1"
461
+ " ORDER BY tbl, idx");
462
+ @ <pre>
463
+ while( db_step(&q)==SQLITE_ROW ){
464
+ const char *zTab = db_column_text(&q,0);
465
+ const char *zIdx = db_column_text(&q,1);
466
+ const char *zStat = db_column_text(&q,2);
467
+ char *zUrl = href("%R/repo_schema?n=%t",zTab);
468
+ @ INSERT INTO sqlite_stat1 VALUES('%z(zUrl)%h(zTab)</a>','%h(zIdx)','%h(zStat)');
469
+ }
470
+ @ </pre>
471
+ db_finalize(&q);
472
+ }
411473
style_footer();
412474
}
413475
414476
/*
415477
** WEBPAGE: repo-tabsize
416478
--- src/stat.c
+++ src/stat.c
@@ -388,10 +388,12 @@
388 **
389 ** Show the repository schema
390 */
391 void repo_schema_page(void){
392 Stmt q;
 
 
393 login_check_credentials();
394 if( !g.perm.Admin ){ login_needed(0); return; }
395
396 style_header("Repository Schema");
397 style_adunit_config(ADUNIT_RIGHT_OK);
@@ -398,18 +400,78 @@
398 style_submenu_element("Stat", "stat");
399 style_submenu_element("URLs", "urllist");
400 if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
401 style_submenu_element("Table Sizes", "repo-tabsize");
402 }
403 db_prepare(&q,
404 "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL");
 
 
 
 
 
 
 
405 @ <pre>
406 while( db_step(&q)==SQLITE_ROW ){
407 @ %h(db_column_text(&q, 0));
408 }
409 @ </pre>
410 db_finalize(&q);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411 style_footer();
412 }
413
414 /*
415 ** WEBPAGE: repo-tabsize
416
--- src/stat.c
+++ src/stat.c
@@ -388,10 +388,12 @@
388 **
389 ** Show the repository schema
390 */
391 void repo_schema_page(void){
392 Stmt q;
393 Blob sql;
394 const char *zArg = P("n");
395 login_check_credentials();
396 if( !g.perm.Admin ){ login_needed(0); return; }
397
398 style_header("Repository Schema");
399 style_adunit_config(ADUNIT_RIGHT_OK);
@@ -398,18 +400,78 @@
400 style_submenu_element("Stat", "stat");
401 style_submenu_element("URLs", "urllist");
402 if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
403 style_submenu_element("Table Sizes", "repo-tabsize");
404 }
405 blob_init(&sql,
406 "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
407 if( zArg ){
408 style_submenu_element("All", "repo_schema");
409 blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
410 }
411 blob_appendf(&sql, " ORDER BY tbl_name, type<>'table', name");
412 db_prepare(&q, "%s", blob_str(&sql)/*safe-for-%s*/);
413 blob_reset(&sql);
414 @ <pre>
415 while( db_step(&q)==SQLITE_ROW ){
416 @ %h(db_column_text(&q, 0));
417 }
418 @ </pre>
419 db_finalize(&q);
420 if( db_table_exists("repository","sqlite_stat1") ){
421 if( zArg ){
422 db_prepare(&q,
423 "SELECT tbl, idx, stat FROM repository.sqlite_stat1"
424 " WHERE tbl LIKE %Q OR idx LIKE %Q"
425 " ORDER BY tbl, idx", zArg, zArg);
426
427 @ <hr>
428 @ <pre>
429 while( db_step(&q)==SQLITE_ROW ){
430 const char *zTab = db_column_text(&q,0);
431 const char *zIdx = db_column_text(&q,1);
432 const char *zStat = db_column_text(&q,2);
433 @ INSERT INTO sqlite_stat1 VALUES('%h(zTab)','%h(zIdx)','%h(zStat)');
434 }
435 @ </pre>
436 db_finalize(&q);
437 }else{
438 style_submenu_element("Stat1","repo_stat1");
439 }
440 }
441 style_footer();
442 }
443
444 /*
445 ** WEBPAGE: repo_stat1
446 **
447 ** Show the sqlite_stat1 table for the repository schema
448 */
449 void repo_stat1_page(void){
450 login_check_credentials();
451 if( !g.perm.Admin ){ login_needed(0); return; }
452
453 style_header("Repository STAT1 Table");
454 style_adunit_config(ADUNIT_RIGHT_OK);
455 style_submenu_element("Stat", "stat");
456 style_submenu_element("Schema", "repo_schema");
457 if( db_table_exists("repository","sqlite_stat1") ){
458 Stmt q;
459 db_prepare(&q,
460 "SELECT tbl, idx, stat FROM repository.sqlite_stat1"
461 " ORDER BY tbl, idx");
462 @ <pre>
463 while( db_step(&q)==SQLITE_ROW ){
464 const char *zTab = db_column_text(&q,0);
465 const char *zIdx = db_column_text(&q,1);
466 const char *zStat = db_column_text(&q,2);
467 char *zUrl = href("%R/repo_schema?n=%t",zTab);
468 @ INSERT INTO sqlite_stat1 VALUES('%z(zUrl)%h(zTab)</a>','%h(zIdx)','%h(zStat)');
469 }
470 @ </pre>
471 db_finalize(&q);
472 }
473 style_footer();
474 }
475
476 /*
477 ** WEBPAGE: repo-tabsize
478

Keyboard Shortcuts

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