| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 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 |
| 3 | +** version 3.18.0. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -396,13 +396,13 @@ |
| 396 | 396 | ** |
| 397 | 397 | ** See also: [sqlite3_libversion()], |
| 398 | 398 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 399 | 399 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 400 | 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" |
| 401 | +#define SQLITE_VERSION "3.18.0" |
| 402 | +#define SQLITE_VERSION_NUMBER 3018000 |
| 403 | +#define SQLITE_SOURCE_ID "2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471" |
| 404 | 404 | |
| 405 | 405 | /* |
| 406 | 406 | ** CAPI3REF: Run-Time Library Version Numbers |
| 407 | 407 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 408 | 408 | ** |
| | @@ -2315,24 +2315,34 @@ |
| 2315 | 2315 | ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those |
| 2316 | 2316 | ** names are not also used by explicitly declared columns. ^If |
| 2317 | 2317 | ** the table has a column of type [INTEGER PRIMARY KEY] then that column |
| 2318 | 2318 | ** is another alias for the rowid. |
| 2319 | 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. |
| 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. |
| 2327 | 2326 | ** |
| 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.)^ |
| 2334 | 2344 | ** |
| 2335 | 2345 | ** ^An [INSERT] that fails due to a constraint violation is not a |
| 2336 | 2346 | ** successful [INSERT] and does not change the value returned by this |
| 2337 | 2347 | ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, |
| 2338 | 2348 | ** and INSERT OR ABORT make no changes to the return value of this |
| | @@ -2355,10 +2365,20 @@ |
| 2355 | 2365 | ** unpredictable and might not equal either the old or the new |
| 2356 | 2366 | ** last insert [rowid]. |
| 2357 | 2367 | */ |
| 2358 | 2368 | SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); |
| 2359 | 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 | + |
| 2360 | 2380 | /* |
| 2361 | 2381 | ** CAPI3REF: Count The Number Of Rows Modified |
| 2362 | 2382 | ** METHOD: sqlite3 |
| 2363 | 2383 | ** |
| 2364 | 2384 | ** ^This function returns the number of rows modified, inserted or |
| | @@ -12457,10 +12477,11 @@ |
| 12457 | 12477 | SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); |
| 12458 | 12478 | SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); |
| 12459 | 12479 | |
| 12460 | 12480 | SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); |
| 12461 | 12481 | SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); |
| 12482 | +SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*); |
| 12462 | 12483 | |
| 12463 | 12484 | #ifndef SQLITE_OMIT_INCRBLOB |
| 12464 | 12485 | SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*); |
| 12465 | 12486 | SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); |
| 12466 | 12487 | SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *); |
| | @@ -12757,117 +12778,119 @@ |
| 12757 | 12778 | #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 12758 | 12779 | #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 12759 | 12780 | #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 12760 | 12781 | #define OP_Last 53 |
| 12761 | 12782 | #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] */ |
| 12804 | 12825 | #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 |
| 12839 | 12860 | #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 |
| 12869 | 12892 | |
| 12870 | 12893 | /* Properties such as "out2" or "jump" that are specified in |
| 12871 | 12894 | ** comments following the "case" for each opcode in the vdbe.c |
| 12872 | 12895 | ** are encoded into bitvectors as follows: |
| 12873 | 12896 | */ |
| | @@ -12883,32 +12906,32 @@ |
| 12883 | 12906 | /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\ |
| 12884 | 12907 | /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\ |
| 12885 | 12908 | /* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 12886 | 12909 | /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 12887 | 12910 | /* 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,\ |
| 12894 | 12917 | /* 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,} |
| 12902 | 12925 | |
| 12903 | 12926 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 12904 | 12927 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 12905 | 12928 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 12906 | 12929 | ** generated this include file strives to group all JUMP opcodes |
| 12907 | 12930 | ** together near the beginning of the list. |
| 12908 | 12931 | */ |
| 12909 | | -#define SQLITE_MX_JUMP_OPCODE 71 /* Maximum JUMP opcode */ |
| 12932 | +#define SQLITE_MX_JUMP_OPCODE 72 /* Maximum JUMP opcode */ |
| 12910 | 12933 | |
| 12911 | 12934 | /************** End of opcodes.h *********************************************/ |
| 12912 | 12935 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 12913 | 12936 | |
| 12914 | 12937 | /* |
| | @@ -14074,10 +14097,11 @@ |
| 14074 | 14097 | u8 suppressErr; /* Do not issue error messages if true */ |
| 14075 | 14098 | u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ |
| 14076 | 14099 | u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ |
| 14077 | 14100 | u8 mTrace; /* zero or more SQLITE_TRACE flags */ |
| 14078 | 14101 | u8 skipBtreeMutex; /* True if no shared-cache backends */ |
| 14102 | + u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */ |
| 14079 | 14103 | int nextPagesize; /* Pagesize after VACUUM if >0 */ |
| 14080 | 14104 | u32 magic; /* Magic number for detect library misuse */ |
| 14081 | 14105 | int nChange; /* Value returned by sqlite3_changes() */ |
| 14082 | 14106 | int nTotalChange; /* Value returned by sqlite3_total_changes() */ |
| 14083 | 14107 | int aLimit[SQLITE_N_LIMIT]; /* Limits */ |
| | @@ -14589,18 +14613,18 @@ |
| 14589 | 14613 | char *zColAff; /* String defining the affinity of each column */ |
| 14590 | 14614 | ExprList *pCheck; /* All CHECK constraints */ |
| 14591 | 14615 | /* ... also used as column name list in a VIEW */ |
| 14592 | 14616 | int tnum; /* Root BTree page for this table */ |
| 14593 | 14617 | u32 nTabRef; /* Number of pointers to this Table */ |
| 14618 | + u32 tabFlags; /* Mask of TF_* values */ |
| 14594 | 14619 | i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */ |
| 14595 | 14620 | i16 nCol; /* Number of columns in this table */ |
| 14596 | 14621 | LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */ |
| 14597 | 14622 | LogEst szTabRow; /* Estimated size of each table row in bytes */ |
| 14598 | 14623 | #ifdef SQLITE_ENABLE_COSTMULT |
| 14599 | 14624 | LogEst costMult; /* Cost multiplier for using this table */ |
| 14600 | 14625 | #endif |
| 14601 | | - u8 tabFlags; /* Mask of TF_* values */ |
| 14602 | 14626 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
| 14603 | 14627 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 14604 | 14628 | int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ |
| 14605 | 14629 | #endif |
| 14606 | 14630 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| | @@ -14620,27 +14644,29 @@ |
| 14620 | 14644 | ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING |
| 14621 | 14645 | ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden, |
| 14622 | 14646 | ** the TF_OOOHidden attribute would apply in this case. Such tables require |
| 14623 | 14647 | ** special handling during INSERT processing. |
| 14624 | 14648 | */ |
| 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 */ |
| 14634 | 14660 | |
| 14635 | 14661 | /* |
| 14636 | 14662 | ** Test to see whether or not a table is a virtual table. This is |
| 14637 | 14663 | ** done as a macro so that it will be optimized out when virtual |
| 14638 | 14664 | ** table support is omitted from the build. |
| 14639 | 14665 | */ |
| 14640 | 14666 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 14641 | | -# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) |
| 14667 | +# define IsVirtual(X) ((X)->nModuleArg) |
| 14642 | 14668 | #else |
| 14643 | 14669 | # define IsVirtual(X) 0 |
| 14644 | 14670 | #endif |
| 14645 | 14671 | |
| 14646 | 14672 | /* |
| | @@ -14871,10 +14897,11 @@ |
| 14871 | 14897 | unsigned bUnordered:1; /* Use this index for == or IN queries only */ |
| 14872 | 14898 | unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */ |
| 14873 | 14899 | unsigned isResized:1; /* True if resizeIndexObject() has been called */ |
| 14874 | 14900 | unsigned isCovering:1; /* True if this is a covering index */ |
| 14875 | 14901 | unsigned noSkipScan:1; /* Do not try to use skip-scan if true */ |
| 14902 | + unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */ |
| 14876 | 14903 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 14877 | 14904 | int nSample; /* Number of elements in aSample[] */ |
| 14878 | 14905 | int nSampleCol; /* Size of IndexSample.anEq[] and so on */ |
| 14879 | 14906 | tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */ |
| 14880 | 14907 | IndexSample *aSample; /* Samples of the left-most key */ |
| | @@ -15181,11 +15208,11 @@ |
| 15181 | 15208 | ** form is used for name resolution with nested FROM clauses. |
| 15182 | 15209 | */ |
| 15183 | 15210 | struct ExprList { |
| 15184 | 15211 | int nExpr; /* Number of expressions on the list */ |
| 15185 | 15212 | 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 */ |
| 15187 | 15214 | char *zName; /* Token associated with this expression */ |
| 15188 | 15215 | char *zSpan; /* Original text of the expression */ |
| 15189 | 15216 | u8 sortOrder; /* 1 for DESC or 0 for ASC */ |
| 15190 | 15217 | unsigned done :1; /* A flag to indicate when processing is finished */ |
| 15191 | 15218 | unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */ |
| | @@ -16504,10 +16531,11 @@ |
| 16504 | 16531 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
| 16505 | 16532 | SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*); |
| 16506 | 16533 | SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int); |
| 16507 | 16534 | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*); |
| 16508 | 16535 | SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int); |
| 16536 | +SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int); |
| 16509 | 16537 | SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int); |
| 16510 | 16538 | SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int); |
| 16511 | 16539 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 16512 | 16540 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 16513 | 16541 | SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); |
| | @@ -17450,11 +17478,11 @@ |
| 17450 | 17478 | "COMPILER=gcc-" __VERSION__, |
| 17451 | 17479 | #endif |
| 17452 | 17480 | #if SQLITE_COVERAGE_TEST |
| 17453 | 17481 | "COVERAGE_TEST", |
| 17454 | 17482 | #endif |
| 17455 | | -#if SQLITE_DEBUG |
| 17483 | +#ifdef SQLITE_DEBUG |
| 17456 | 17484 | "DEBUG", |
| 17457 | 17485 | #endif |
| 17458 | 17486 | #if SQLITE_DEFAULT_LOCKING_MODE |
| 17459 | 17487 | "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), |
| 17460 | 17488 | #endif |
| | @@ -19505,22 +19533,23 @@ |
| 19505 | 19533 | ** |
| 19506 | 19534 | ** Move the date backwards to the beginning of the current day, |
| 19507 | 19535 | ** or month or year. |
| 19508 | 19536 | */ |
| 19509 | 19537 | if( sqlite3_strnicmp(z, "start of ", 9)!=0 ) break; |
| 19538 | + if( !p->validJD && !p->validYMD && !p->validHMS ) break; |
| 19510 | 19539 | z += 9; |
| 19511 | 19540 | computeYMD(p); |
| 19512 | 19541 | p->validHMS = 1; |
| 19513 | 19542 | p->h = p->m = 0; |
| 19514 | 19543 | p->s = 0.0; |
| 19544 | + p->rawS = 0; |
| 19515 | 19545 | p->validTZ = 0; |
| 19516 | 19546 | p->validJD = 0; |
| 19517 | 19547 | if( sqlite3_stricmp(z,"month")==0 ){ |
| 19518 | 19548 | p->D = 1; |
| 19519 | 19549 | rc = 0; |
| 19520 | 19550 | }else if( sqlite3_stricmp(z,"year")==0 ){ |
| 19521 | | - computeYMD(p); |
| 19522 | 19551 | p->M = 1; |
| 19523 | 19552 | p->D = 1; |
| 19524 | 19553 | rc = 0; |
| 19525 | 19554 | }else if( sqlite3_stricmp(z,"day")==0 ){ |
| 19526 | 19555 | rc = 0; |
| | @@ -24050,12 +24079,12 @@ |
| 24050 | 24079 | #ifdef SQLITE_DEBUG |
| 24051 | 24080 | assert( p->nRef>0 || p->owner==0 ); |
| 24052 | 24081 | p->owner = tid; |
| 24053 | 24082 | p->nRef++; |
| 24054 | 24083 | 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)); |
| 24057 | 24086 | } |
| 24058 | 24087 | #endif |
| 24059 | 24088 | } |
| 24060 | 24089 | |
| 24061 | 24090 | static int winMutexTry(sqlite3_mutex *p){ |
| | @@ -24093,12 +24122,12 @@ |
| 24093 | 24122 | #else |
| 24094 | 24123 | UNUSED_PARAMETER(p); |
| 24095 | 24124 | #endif |
| 24096 | 24125 | #ifdef SQLITE_DEBUG |
| 24097 | 24126 | 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))); |
| 24100 | 24129 | } |
| 24101 | 24130 | #endif |
| 24102 | 24131 | return rc; |
| 24103 | 24132 | } |
| 24104 | 24133 | |
| | @@ -24122,12 +24151,12 @@ |
| 24122 | 24151 | #endif |
| 24123 | 24152 | assert( winMutex_isInit==1 ); |
| 24124 | 24153 | LeaveCriticalSection(&p->mutex); |
| 24125 | 24154 | #ifdef SQLITE_DEBUG |
| 24126 | 24155 | 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)); |
| 24129 | 24158 | } |
| 24130 | 24159 | #endif |
| 24131 | 24160 | } |
| 24132 | 24161 | |
| 24133 | 24162 | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ |
| | @@ -24383,10 +24412,17 @@ |
| 24383 | 24412 | ** implementation of malloc_good_size(), which must be called in debug |
| 24384 | 24413 | ** mode and specifically when the DMD "Dark Matter Detector" is enabled |
| 24385 | 24414 | ** or else a crash results. Hence, do not attempt to optimize out the |
| 24386 | 24415 | ** following xRoundup() call. */ |
| 24387 | 24416 | nFull = sqlite3GlobalConfig.m.xRoundup(n); |
| 24417 | + |
| 24418 | +#ifdef SQLITE_MAX_MEMORY |
| 24419 | + if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED)+nFull>SQLITE_MAX_MEMORY ){ |
| 24420 | + *pp = 0; |
| 24421 | + return; |
| 24422 | + } |
| 24423 | +#endif |
| 24388 | 24424 | |
| 24389 | 24425 | sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n); |
| 24390 | 24426 | if( mem0.alarmThreshold>0 ){ |
| 24391 | 24427 | sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 24392 | 24428 | if( nUsed >= mem0.alarmThreshold - nFull ){ |
| | @@ -24572,11 +24608,11 @@ |
| 24572 | 24608 | return sqlite3GlobalConfig.m.xSize(p); |
| 24573 | 24609 | } |
| 24574 | 24610 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ |
| 24575 | 24611 | assert( p!=0 ); |
| 24576 | 24612 | if( db==0 || !isLookaside(db,p) ){ |
| 24577 | | -#if SQLITE_DEBUG |
| 24613 | +#ifdef SQLITE_DEBUG |
| 24578 | 24614 | if( db==0 ){ |
| 24579 | 24615 | assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 24580 | 24616 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 24581 | 24617 | }else{ |
| 24582 | 24618 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| | @@ -24633,11 +24669,11 @@ |
| 24633 | 24669 | measureAllocationSize(db, p); |
| 24634 | 24670 | return; |
| 24635 | 24671 | } |
| 24636 | 24672 | if( isLookaside(db, p) ){ |
| 24637 | 24673 | LookasideSlot *pBuf = (LookasideSlot*)p; |
| 24638 | | -#if SQLITE_DEBUG |
| 24674 | +#ifdef SQLITE_DEBUG |
| 24639 | 24675 | /* Trash all content in the buffer being freed */ |
| 24640 | 24676 | memset(p, 0xaa, db->lookaside.sz); |
| 24641 | 24677 | #endif |
| 24642 | 24678 | pBuf->pNext = db->lookaside.pFree; |
| 24643 | 24679 | db->lookaside.pFree = pBuf; |
| | @@ -25002,11 +25038,11 @@ |
| 25002 | 25038 | |
| 25003 | 25039 | /* |
| 25004 | 25040 | ** Conversion types fall into various categories as defined by the |
| 25005 | 25041 | ** following enumeration. |
| 25006 | 25042 | */ |
| 25007 | | -#define etRADIX 0 /* Integer types. %d, %x, %o, and so forth */ |
| 25043 | +#define etRADIX 0 /* non-decimal integer types. %x %o */ |
| 25008 | 25044 | #define etFLOAT 1 /* Floating point. %f */ |
| 25009 | 25045 | #define etEXP 2 /* Exponentional notation. %e and %E */ |
| 25010 | 25046 | #define etGENERIC 3 /* Floating or exponential, depending on exponent. %g */ |
| 25011 | 25047 | #define etSIZE 4 /* Return number of characters processed so far. %n */ |
| 25012 | 25048 | #define etSTRING 5 /* Strings. %s */ |
| | @@ -25020,12 +25056,13 @@ |
| 25020 | 25056 | #define etTOKEN 11 /* a pointer to a Token structure */ |
| 25021 | 25057 | #define etSRCLIST 12 /* a pointer to a SrcList */ |
| 25022 | 25058 | #define etPOINTER 13 /* The %p conversion */ |
| 25023 | 25059 | #define etSQLESCAPE3 14 /* %w -> Strings with '\"' doubled */ |
| 25024 | 25060 | #define etORDINAL 15 /* %r -> 1st, 2nd, 3rd, 4th, etc. English only */ |
| 25061 | +#define etDECIMAL 16 /* %d or %u, but not %x, %o */ |
| 25025 | 25062 | |
| 25026 | | -#define etINVALID 16 /* Any unrecognized conversion type */ |
| 25063 | +#define etINVALID 17 /* Any unrecognized conversion type */ |
| 25027 | 25064 | |
| 25028 | 25065 | |
| 25029 | 25066 | /* |
| 25030 | 25067 | ** An "etByte" is an 8-bit unsigned value. |
| 25031 | 25068 | */ |
| | @@ -25045,40 +25082,40 @@ |
| 25045 | 25082 | } et_info; |
| 25046 | 25083 | |
| 25047 | 25084 | /* |
| 25048 | 25085 | ** Allowed values for et_info.flags |
| 25049 | 25086 | */ |
| 25050 | | -#define FLAG_SIGNED 1 /* True if the value to convert is signed */ |
| 25051 | | -#define FLAG_STRING 4 /* Allow infinity precision */ |
| 25087 | +#define FLAG_SIGNED 1 /* True if the value to convert is signed */ |
| 25088 | +#define FLAG_STRING 4 /* Allow infinite precision */ |
| 25052 | 25089 | |
| 25053 | 25090 | |
| 25054 | 25091 | /* |
| 25055 | 25092 | ** The following table is searched linearly, so it is good to put the |
| 25056 | 25093 | ** most frequently used conversion types first. |
| 25057 | 25094 | */ |
| 25058 | 25095 | static const char aDigits[] = "0123456789ABCDEF0123456789abcdef"; |
| 25059 | 25096 | static const char aPrefix[] = "-x0\000X0"; |
| 25060 | 25097 | static const et_info fmtinfo[] = { |
| 25061 | | - { 'd', 10, 1, etRADIX, 0, 0 }, |
| 25098 | + { 'd', 10, 1, etDECIMAL, 0, 0 }, |
| 25062 | 25099 | { 's', 0, 4, etSTRING, 0, 0 }, |
| 25063 | 25100 | { 'g', 0, 1, etGENERIC, 30, 0 }, |
| 25064 | 25101 | { 'z', 0, 4, etDYNSTRING, 0, 0 }, |
| 25065 | 25102 | { 'q', 0, 4, etSQLESCAPE, 0, 0 }, |
| 25066 | 25103 | { 'Q', 0, 4, etSQLESCAPE2, 0, 0 }, |
| 25067 | 25104 | { 'w', 0, 4, etSQLESCAPE3, 0, 0 }, |
| 25068 | 25105 | { 'c', 0, 0, etCHARX, 0, 0 }, |
| 25069 | 25106 | { 'o', 8, 0, etRADIX, 0, 2 }, |
| 25070 | | - { 'u', 10, 0, etRADIX, 0, 0 }, |
| 25107 | + { 'u', 10, 0, etDECIMAL, 0, 0 }, |
| 25071 | 25108 | { 'x', 16, 0, etRADIX, 16, 1 }, |
| 25072 | 25109 | { 'X', 16, 0, etRADIX, 0, 4 }, |
| 25073 | 25110 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 25074 | 25111 | { 'f', 0, 1, etFLOAT, 0, 0 }, |
| 25075 | 25112 | { 'e', 0, 1, etEXP, 30, 0 }, |
| 25076 | 25113 | { 'E', 0, 1, etEXP, 14, 0 }, |
| 25077 | 25114 | { 'G', 0, 1, etGENERIC, 14, 0 }, |
| 25078 | 25115 | #endif |
| 25079 | | - { 'i', 10, 1, etRADIX, 0, 0 }, |
| 25116 | + { 'i', 10, 1, etDECIMAL, 0, 0 }, |
| 25080 | 25117 | { 'n', 0, 0, etSIZE, 0, 0 }, |
| 25081 | 25118 | { '%', 0, 0, etPERCENT, 0, 0 }, |
| 25082 | 25119 | { 'p', 16, 0, etPOINTER, 0, 1 }, |
| 25083 | 25120 | |
| 25084 | 25121 | /* All the rest are undocumented and are for internal use only */ |
| | @@ -25166,18 +25203,17 @@ |
| 25166 | 25203 | int precision; /* Precision of the current field */ |
| 25167 | 25204 | int length; /* Length of the field */ |
| 25168 | 25205 | int idx; /* A general purpose loop counter */ |
| 25169 | 25206 | int width; /* Width of the current field */ |
| 25170 | 25207 | 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 */ |
| 25208 | + etByte flag_prefix; /* '+' or ' ' or 0 for prefix */ |
| 25173 | 25209 | etByte flag_alternateform; /* True if "#" flag is present */ |
| 25174 | 25210 | etByte flag_altform2; /* True if "!" flag is present */ |
| 25175 | 25211 | 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 */ |
| 25212 | + etByte flag_long; /* 1 for the "l" flag, 2 for "ll", 0 by default */ |
| 25178 | 25213 | etByte done; /* Loop termination flag */ |
| 25214 | + etByte cThousand; /* Thousands separator for %d and %u */ |
| 25179 | 25215 | etByte xtype = etINVALID; /* Conversion paradigm */ |
| 25180 | 25216 | u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */ |
| 25181 | 25217 | char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */ |
| 25182 | 25218 | sqlite_uint64 longvalue; /* Value for integer types */ |
| 25183 | 25219 | LONGDOUBLE_TYPE realvalue; /* Value for real types */ |
| | @@ -25216,21 +25252,22 @@ |
| 25216 | 25252 | if( (c=(*++fmt))==0 ){ |
| 25217 | 25253 | sqlite3StrAccumAppend(pAccum, "%", 1); |
| 25218 | 25254 | break; |
| 25219 | 25255 | } |
| 25220 | 25256 | /* Find out what flags are present */ |
| 25221 | | - flag_leftjustify = flag_plussign = flag_blanksign = |
| 25257 | + flag_leftjustify = flag_prefix = cThousand = |
| 25222 | 25258 | flag_alternateform = flag_altform2 = flag_zeropad = 0; |
| 25223 | 25259 | done = 0; |
| 25224 | 25260 | do{ |
| 25225 | 25261 | switch( c ){ |
| 25226 | 25262 | case '-': flag_leftjustify = 1; break; |
| 25227 | | - case '+': flag_plussign = 1; break; |
| 25228 | | - case ' ': flag_blanksign = 1; break; |
| 25263 | + case '+': flag_prefix = '+'; break; |
| 25264 | + case ' ': flag_prefix = ' '; break; |
| 25229 | 25265 | case '#': flag_alternateform = 1; break; |
| 25230 | 25266 | case '!': flag_altform2 = 1; break; |
| 25231 | 25267 | case '0': flag_zeropad = 1; break; |
| 25268 | + case ',': cThousand = ','; break; |
| 25232 | 25269 | default: done = 1; break; |
| 25233 | 25270 | } |
| 25234 | 25271 | }while( !done && (c=(*++fmt))!=0 ); |
| 25235 | 25272 | /* Get the field width */ |
| 25236 | 25273 | if( c=='*' ){ |
| | @@ -25296,17 +25333,15 @@ |
| 25296 | 25333 | /* Get the conversion type modifier */ |
| 25297 | 25334 | if( c=='l' ){ |
| 25298 | 25335 | flag_long = 1; |
| 25299 | 25336 | c = *++fmt; |
| 25300 | 25337 | if( c=='l' ){ |
| 25301 | | - flag_longlong = 1; |
| 25338 | + flag_long = 2; |
| 25302 | 25339 | c = *++fmt; |
| 25303 | | - }else{ |
| 25304 | | - flag_longlong = 0; |
| 25305 | 25340 | } |
| 25306 | 25341 | }else{ |
| 25307 | | - flag_long = flag_longlong = 0; |
| 25342 | + flag_long = 0; |
| 25308 | 25343 | } |
| 25309 | 25344 | /* Fetch the info entry for the field */ |
| 25310 | 25345 | infop = &fmtinfo[0]; |
| 25311 | 25346 | xtype = etINVALID; |
| 25312 | 25347 | for(idx=0; idx<ArraySize(fmtinfo); idx++){ |
| | @@ -25320,41 +25355,42 @@ |
| 25320 | 25355 | /* |
| 25321 | 25356 | ** At this point, variables are initialized as follows: |
| 25322 | 25357 | ** |
| 25323 | 25358 | ** flag_alternateform TRUE if a '#' is present. |
| 25324 | 25359 | ** flag_altform2 TRUE if a '!' is present. |
| 25325 | | - ** flag_plussign TRUE if a '+' is present. |
| 25360 | + ** flag_prefix '+' or ' ' or zero |
| 25326 | 25361 | ** flag_leftjustify TRUE if a '-' is present or if the |
| 25327 | 25362 | ** field width was negative. |
| 25328 | 25363 | ** 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. |
| 25364 | + ** flag_long 1 for "l", 2 for "ll" |
| 25334 | 25365 | ** width The specified field width. This is |
| 25335 | 25366 | ** always non-negative. Zero is the default. |
| 25336 | 25367 | ** precision The specified precision. The default |
| 25337 | 25368 | ** is -1. |
| 25338 | 25369 | ** xtype The class of the conversion. |
| 25339 | 25370 | ** infop Pointer to the appropriate info struct. |
| 25340 | 25371 | */ |
| 25341 | 25372 | switch( xtype ){ |
| 25342 | 25373 | case etPOINTER: |
| 25343 | | - flag_longlong = sizeof(char*)==sizeof(i64); |
| 25344 | | - flag_long = sizeof(char*)==sizeof(long int); |
| 25374 | + flag_long = sizeof(char*)==sizeof(i64) ? 2 : |
| 25375 | + sizeof(char*)==sizeof(long int) ? 1 : 0; |
| 25345 | 25376 | /* Fall through into the next case */ |
| 25346 | 25377 | case etORDINAL: |
| 25347 | | - case etRADIX: |
| 25378 | + case etRADIX: |
| 25379 | + cThousand = 0; |
| 25380 | + /* Fall through into the next case */ |
| 25381 | + case etDECIMAL: |
| 25348 | 25382 | if( infop->flags & FLAG_SIGNED ){ |
| 25349 | 25383 | i64 v; |
| 25350 | 25384 | if( bArgList ){ |
| 25351 | 25385 | v = getIntArg(pArgList); |
| 25352 | | - }else if( flag_longlong ){ |
| 25353 | | - v = va_arg(ap,i64); |
| 25354 | 25386 | }else if( flag_long ){ |
| 25355 | | - v = va_arg(ap,long int); |
| 25387 | + if( flag_long==2 ){ |
| 25388 | + v = va_arg(ap,i64) ; |
| 25389 | + }else{ |
| 25390 | + v = va_arg(ap,long int); |
| 25391 | + } |
| 25356 | 25392 | }else{ |
| 25357 | 25393 | v = va_arg(ap,int); |
| 25358 | 25394 | } |
| 25359 | 25395 | if( v<0 ){ |
| 25360 | 25396 | if( v==SMALLEST_INT64 ){ |
| | @@ -25363,35 +25399,35 @@ |
| 25363 | 25399 | longvalue = -v; |
| 25364 | 25400 | } |
| 25365 | 25401 | prefix = '-'; |
| 25366 | 25402 | }else{ |
| 25367 | 25403 | longvalue = v; |
| 25368 | | - if( flag_plussign ) prefix = '+'; |
| 25369 | | - else if( flag_blanksign ) prefix = ' '; |
| 25370 | | - else prefix = 0; |
| 25404 | + prefix = flag_prefix; |
| 25371 | 25405 | } |
| 25372 | 25406 | }else{ |
| 25373 | 25407 | if( bArgList ){ |
| 25374 | 25408 | longvalue = (u64)getIntArg(pArgList); |
| 25375 | | - }else if( flag_longlong ){ |
| 25376 | | - longvalue = va_arg(ap,u64); |
| 25377 | 25409 | }else if( flag_long ){ |
| 25378 | | - longvalue = va_arg(ap,unsigned long int); |
| 25410 | + if( flag_long==2 ){ |
| 25411 | + longvalue = va_arg(ap,u64); |
| 25412 | + }else{ |
| 25413 | + longvalue = va_arg(ap,unsigned long int); |
| 25414 | + } |
| 25379 | 25415 | }else{ |
| 25380 | 25416 | longvalue = va_arg(ap,unsigned int); |
| 25381 | 25417 | } |
| 25382 | 25418 | prefix = 0; |
| 25383 | 25419 | } |
| 25384 | 25420 | if( longvalue==0 ) flag_alternateform = 0; |
| 25385 | 25421 | if( flag_zeropad && precision<width-(prefix!=0) ){ |
| 25386 | 25422 | precision = width-(prefix!=0); |
| 25387 | 25423 | } |
| 25388 | | - if( precision<etBUFSIZE-10 ){ |
| 25424 | + if( precision<etBUFSIZE-10-etBUFSIZE/3 ){ |
| 25389 | 25425 | nOut = etBUFSIZE; |
| 25390 | 25426 | zOut = buf; |
| 25391 | 25427 | }else{ |
| 25392 | | - nOut = precision + 10; |
| 25428 | + nOut = precision + 10 + precision/3; |
| 25393 | 25429 | zOut = zExtra = sqlite3Malloc( nOut ); |
| 25394 | 25430 | if( zOut==0 ){ |
| 25395 | 25431 | setStrAccumError(pAccum, STRACCUM_NOMEM); |
| 25396 | 25432 | return; |
| 25397 | 25433 | } |
| | @@ -25413,12 +25449,27 @@ |
| 25413 | 25449 | *(--bufpt) = cset[longvalue%base]; |
| 25414 | 25450 | longvalue = longvalue/base; |
| 25415 | 25451 | }while( longvalue>0 ); |
| 25416 | 25452 | } |
| 25417 | 25453 | length = (int)(&zOut[nOut-1]-bufpt); |
| 25418 | | - for(idx=precision-length; idx>0; idx--){ |
| 25454 | + while( precision>length ){ |
| 25419 | 25455 | *(--bufpt) = '0'; /* Zero pad */ |
| 25456 | + length++; |
| 25457 | + } |
| 25458 | + if( cThousand ){ |
| 25459 | + int nn = (length - 1)/3; /* Number of "," to insert */ |
| 25460 | + int ix = (length - 1)%3 + 1; |
| 25461 | + bufpt -= nn; |
| 25462 | + for(idx=0; nn>0; idx++){ |
| 25463 | + bufpt[idx] = bufpt[idx+nn]; |
| 25464 | + ix--; |
| 25465 | + if( ix==0 ){ |
| 25466 | + bufpt[++idx] = cThousand; |
| 25467 | + nn--; |
| 25468 | + ix = 3; |
| 25469 | + } |
| 25470 | + } |
| 25420 | 25471 | } |
| 25421 | 25472 | if( prefix ) *(--bufpt) = prefix; /* Add sign */ |
| 25422 | 25473 | if( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */ |
| 25423 | 25474 | const char *pre; |
| 25424 | 25475 | char x; |
| | @@ -25441,13 +25492,11 @@ |
| 25441 | 25492 | if( precision<0 ) precision = 6; /* Set default precision */ |
| 25442 | 25493 | if( realvalue<0.0 ){ |
| 25443 | 25494 | realvalue = -realvalue; |
| 25444 | 25495 | prefix = '-'; |
| 25445 | 25496 | }else{ |
| 25446 | | - if( flag_plussign ) prefix = '+'; |
| 25447 | | - else if( flag_blanksign ) prefix = ' '; |
| 25448 | | - else prefix = 0; |
| 25497 | + prefix = flag_prefix; |
| 25449 | 25498 | } |
| 25450 | 25499 | if( xtype==etGENERIC && precision>0 ) precision--; |
| 25451 | 25500 | testcase( precision>0xfff ); |
| 25452 | 25501 | for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){} |
| 25453 | 25502 | if( xtype==etFLOAT ) realvalue += rounder; |
| | @@ -29464,117 +29513,119 @@ |
| 29464 | 29513 | /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 29465 | 29514 | /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 29466 | 29515 | /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 29467 | 29516 | /* 53 */ "Last" OpHelp(""), |
| 29468 | 29517 | /* 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"), |
| 29518 | + /* 55 */ "IfSmaller" OpHelp(""), |
| 29519 | + /* 56 */ "SorterSort" OpHelp(""), |
| 29520 | + /* 57 */ "Sort" OpHelp(""), |
| 29521 | + /* 58 */ "Rewind" OpHelp(""), |
| 29522 | + /* 59 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 29523 | + /* 60 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 29524 | + /* 61 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 29525 | + /* 62 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 29526 | + /* 63 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 29527 | + /* 64 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 29528 | + /* 65 */ "Program" OpHelp(""), |
| 29529 | + /* 66 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 29530 | + /* 67 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 29531 | + /* 68 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 29532 | + /* 69 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 29533 | + /* 70 */ "IncrVacuum" OpHelp(""), |
| 29534 | + /* 71 */ "VNext" OpHelp(""), |
| 29535 | + /* 72 */ "Init" OpHelp("Start at P2"), |
| 29536 | + /* 73 */ "Return" OpHelp(""), |
| 29537 | + /* 74 */ "EndCoroutine" OpHelp(""), |
| 29538 | + /* 75 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 29539 | + /* 76 */ "Halt" OpHelp(""), |
| 29540 | + /* 77 */ "Integer" OpHelp("r[P2]=P1"), |
| 29541 | + /* 78 */ "Int64" OpHelp("r[P2]=P4"), |
| 29542 | + /* 79 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 29543 | + /* 80 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 29544 | + /* 81 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 29545 | + /* 82 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 29546 | + /* 83 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 29547 | + /* 84 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 29548 | + /* 85 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 29549 | + /* 86 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 29550 | + /* 87 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 29551 | + /* 88 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 29552 | + /* 89 */ "CollSeq" OpHelp(""), |
| 29553 | + /* 90 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29554 | + /* 91 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29555 | + /* 92 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 29556 | + /* 93 */ "RealAffinity" OpHelp(""), |
| 29557 | + /* 94 */ "Cast" OpHelp("affinity(r[P1])"), |
| 29558 | + /* 95 */ "Permutation" OpHelp(""), |
| 29559 | + /* 96 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 29511 | 29560 | /* 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(""), |
| 29561 | + /* 98 */ "Column" OpHelp("r[P3]=PX"), |
| 29562 | + /* 99 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 29563 | + /* 100 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 29564 | + /* 101 */ "Count" OpHelp("r[P2]=count()"), |
| 29565 | + /* 102 */ "ReadCookie" OpHelp(""), |
| 29566 | + /* 103 */ "SetCookie" OpHelp(""), |
| 29567 | + /* 104 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 29568 | + /* 105 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 29569 | + /* 106 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 29570 | + /* 107 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 29571 | + /* 108 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 29572 | + /* 109 */ "SorterOpen" OpHelp(""), |
| 29573 | + /* 110 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 29574 | + /* 111 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 29575 | + /* 112 */ "Close" OpHelp(""), |
| 29576 | + /* 113 */ "ColumnsUsed" OpHelp(""), |
| 29577 | + /* 114 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 29578 | + /* 115 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 29579 | + /* 116 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 29580 | + /* 117 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 29581 | + /* 118 */ "Delete" OpHelp(""), |
| 29582 | + /* 119 */ "ResetCount" OpHelp(""), |
| 29583 | + /* 120 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 29584 | + /* 121 */ "SorterData" OpHelp("r[P2]=data"), |
| 29585 | + /* 122 */ "RowData" OpHelp("r[P2]=data"), |
| 29586 | + /* 123 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 29587 | + /* 124 */ "NullRow" OpHelp(""), |
| 29588 | + /* 125 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 29589 | + /* 126 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 29590 | + /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 29591 | + /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"), |
| 29592 | + /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 29593 | + /* 130 */ "Destroy" OpHelp(""), |
| 29594 | + /* 131 */ "Clear" OpHelp(""), |
| 29546 | 29595 | /* 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(""), |
| 29596 | + /* 133 */ "ResetSorter" OpHelp(""), |
| 29597 | + /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 29598 | + /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 29599 | + /* 136 */ "SqlExec" OpHelp(""), |
| 29600 | + /* 137 */ "ParseSchema" OpHelp(""), |
| 29601 | + /* 138 */ "LoadAnalysis" OpHelp(""), |
| 29602 | + /* 139 */ "DropTable" OpHelp(""), |
| 29603 | + /* 140 */ "DropIndex" OpHelp(""), |
| 29604 | + /* 141 */ "DropTrigger" OpHelp(""), |
| 29605 | + /* 142 */ "IntegrityCk" OpHelp(""), |
| 29606 | + /* 143 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 29607 | + /* 144 */ "Param" OpHelp(""), |
| 29608 | + /* 145 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 29609 | + /* 146 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 29610 | + /* 147 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 29611 | + /* 148 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29612 | + /* 149 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29613 | + /* 150 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 29614 | + /* 151 */ "Expire" OpHelp(""), |
| 29615 | + /* 152 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 29616 | + /* 153 */ "VBegin" OpHelp(""), |
| 29617 | + /* 154 */ "VCreate" OpHelp(""), |
| 29618 | + /* 155 */ "VDestroy" OpHelp(""), |
| 29619 | + /* 156 */ "VOpen" OpHelp(""), |
| 29620 | + /* 157 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 29621 | + /* 158 */ "VRename" OpHelp(""), |
| 29622 | + /* 159 */ "Pagecount" OpHelp(""), |
| 29623 | + /* 160 */ "MaxPgcnt" OpHelp(""), |
| 29624 | + /* 161 */ "CursorHint" OpHelp(""), |
| 29625 | + /* 162 */ "Noop" OpHelp(""), |
| 29626 | + /* 163 */ "Explain" OpHelp(""), |
| 29576 | 29627 | }; |
| 29577 | 29628 | return azName[i]; |
| 29578 | 29629 | } |
| 29579 | 29630 | #endif |
| 29580 | 29631 | |
| | @@ -37952,46 +38003,84 @@ |
| 37952 | 38003 | * be freed immediately and any attempt to access any of that freed |
| 37953 | 38004 | * data will almost certainly result in an immediate access violation. |
| 37954 | 38005 | ****************************************************************************** |
| 37955 | 38006 | */ |
| 37956 | 38007 | #ifndef SQLITE_WIN32_HEAP_CREATE |
| 37957 | | -# define SQLITE_WIN32_HEAP_CREATE (TRUE) |
| 38008 | +# define SQLITE_WIN32_HEAP_CREATE (TRUE) |
| 38009 | +#endif |
| 38010 | + |
| 38011 | +/* |
| 38012 | + * This is the maximum possible initial size of the Win32-specific heap, in |
| 38013 | + * bytes. |
| 38014 | + */ |
| 38015 | +#ifndef SQLITE_WIN32_HEAP_MAX_INIT_SIZE |
| 38016 | +# define SQLITE_WIN32_HEAP_MAX_INIT_SIZE (4294967295U) |
| 38017 | +#endif |
| 38018 | + |
| 38019 | +/* |
| 38020 | + * This is the extra space for the initial size of the Win32-specific heap, |
| 38021 | + * in bytes. This value may be zero. |
| 38022 | + */ |
| 38023 | +#ifndef SQLITE_WIN32_HEAP_INIT_EXTRA |
| 38024 | +# define SQLITE_WIN32_HEAP_INIT_EXTRA (4194304) |
| 38025 | +#endif |
| 38026 | + |
| 38027 | +/* |
| 38028 | + * Calculate the maximum legal cache size, in pages, based on the maximum |
| 38029 | + * possible initial heap size and the default page size, setting aside the |
| 38030 | + * needed extra space. |
| 38031 | + */ |
| 38032 | +#ifndef SQLITE_WIN32_MAX_CACHE_SIZE |
| 38033 | +# define SQLITE_WIN32_MAX_CACHE_SIZE (((SQLITE_WIN32_HEAP_MAX_INIT_SIZE) - \ |
| 38034 | + (SQLITE_WIN32_HEAP_INIT_EXTRA)) / \ |
| 38035 | + (SQLITE_DEFAULT_PAGE_SIZE)) |
| 37958 | 38036 | #endif |
| 37959 | 38037 | |
| 37960 | 38038 | /* |
| 37961 | 38039 | * This is cache size used in the calculation of the initial size of the |
| 37962 | 38040 | * Win32-specific heap. It cannot be negative. |
| 37963 | 38041 | */ |
| 37964 | 38042 | #ifndef SQLITE_WIN32_CACHE_SIZE |
| 37965 | 38043 | # if SQLITE_DEFAULT_CACHE_SIZE>=0 |
| 37966 | | -# define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE) |
| 38044 | +# define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE) |
| 37967 | 38045 | # else |
| 37968 | | -# define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE)) |
| 38046 | +# define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE)) |
| 37969 | 38047 | # endif |
| 37970 | 38048 | #endif |
| 37971 | 38049 | |
| 38050 | +/* |
| 38051 | + * Make sure that the calculated cache size, in pages, cannot cause the |
| 38052 | + * initial size of the Win32-specific heap to exceed the maximum amount |
| 38053 | + * of memory that can be specified in the call to HeapCreate. |
| 38054 | + */ |
| 38055 | +#if SQLITE_WIN32_CACHE_SIZE>SQLITE_WIN32_MAX_CACHE_SIZE |
| 38056 | +# undef SQLITE_WIN32_CACHE_SIZE |
| 38057 | +# define SQLITE_WIN32_CACHE_SIZE (2000) |
| 38058 | +#endif |
| 38059 | + |
| 37972 | 38060 | /* |
| 37973 | 38061 | * The initial size of the Win32-specific heap. This value may be zero. |
| 37974 | 38062 | */ |
| 37975 | 38063 | #ifndef SQLITE_WIN32_HEAP_INIT_SIZE |
| 37976 | | -# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \ |
| 37977 | | - (SQLITE_DEFAULT_PAGE_SIZE) + 4194304) |
| 38064 | +# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \ |
| 38065 | + (SQLITE_DEFAULT_PAGE_SIZE) + \ |
| 38066 | + (SQLITE_WIN32_HEAP_INIT_EXTRA)) |
| 37978 | 38067 | #endif |
| 37979 | 38068 | |
| 37980 | 38069 | /* |
| 37981 | 38070 | * The maximum size of the Win32-specific heap. This value may be zero. |
| 37982 | 38071 | */ |
| 37983 | 38072 | #ifndef SQLITE_WIN32_HEAP_MAX_SIZE |
| 37984 | | -# define SQLITE_WIN32_HEAP_MAX_SIZE (0) |
| 38073 | +# define SQLITE_WIN32_HEAP_MAX_SIZE (0) |
| 37985 | 38074 | #endif |
| 37986 | 38075 | |
| 37987 | 38076 | /* |
| 37988 | 38077 | * The extra flags to use in calls to the Win32 heap APIs. This value may be |
| 37989 | 38078 | * zero for the default behavior. |
| 37990 | 38079 | */ |
| 37991 | 38080 | #ifndef SQLITE_WIN32_HEAP_FLAGS |
| 37992 | | -# define SQLITE_WIN32_HEAP_FLAGS (0) |
| 38081 | +# define SQLITE_WIN32_HEAP_FLAGS (0) |
| 37993 | 38082 | #endif |
| 37994 | 38083 | |
| 37995 | 38084 | |
| 37996 | 38085 | /* |
| 37997 | 38086 | ** The winMemData structure stores information required by the Win32-specific |
| | @@ -44084,11 +44173,11 @@ |
| 44084 | 44173 | ** This routine is for use inside of assert() statements only. For |
| 44085 | 44174 | ** example: |
| 44086 | 44175 | ** |
| 44087 | 44176 | ** assert( sqlite3PcachePageSanity(pPg) ); |
| 44088 | 44177 | */ |
| 44089 | | -#if SQLITE_DEBUG |
| 44178 | +#ifdef SQLITE_DEBUG |
| 44090 | 44179 | SQLITE_PRIVATE int sqlite3PcachePageSanity(PgHdr *pPg){ |
| 44091 | 44180 | PCache *pCache; |
| 44092 | 44181 | assert( pPg!=0 ); |
| 44093 | 44182 | assert( pPg->pgno>0 || pPg->pPager==0 ); /* Page number is 1 or more */ |
| 44094 | 44183 | pCache = pPg->pCache; |
| | @@ -60177,21 +60266,22 @@ |
| 60177 | 60266 | } |
| 60178 | 60267 | #endif |
| 60179 | 60268 | |
| 60180 | 60269 | |
| 60181 | 60270 | /* |
| 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. |
| 60271 | +** Defragment the page given. This routine reorganizes cells within the |
| 60272 | +** page so that there are no free-blocks on the free-block list. |
| 60273 | +** |
| 60274 | +** Parameter nMaxFrag is the maximum amount of fragmented space that may be |
| 60275 | +** present in the page after this routine returns. |
| 60186 | 60276 | ** |
| 60187 | 60277 | ** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a |
| 60188 | 60278 | ** b-tree page so that there are no freeblocks or fragment bytes, all |
| 60189 | 60279 | ** unused bytes are contained in the unallocated space region, and all |
| 60190 | 60280 | ** cells are packed tightly at the end of the page. |
| 60191 | 60281 | */ |
| 60192 | | -static int defragmentPage(MemPage *pPage){ |
| 60282 | +static int defragmentPage(MemPage *pPage, int nMaxFrag){ |
| 60193 | 60283 | int i; /* Loop counter */ |
| 60194 | 60284 | int pc; /* Address of the i-th cell */ |
| 60195 | 60285 | int hdr; /* Offset to the page header */ |
| 60196 | 60286 | int size; /* Size of a cell */ |
| 60197 | 60287 | int usableSize; /* Number of usable bytes on a page */ |
| | @@ -60202,11 +60292,10 @@ |
| 60202 | 60292 | unsigned char *temp; /* Temp area for cell content */ |
| 60203 | 60293 | unsigned char *src; /* Source of content */ |
| 60204 | 60294 | int iCellFirst; /* First allowable cell index */ |
| 60205 | 60295 | int iCellLast; /* Last possible cell index */ |
| 60206 | 60296 | |
| 60207 | | - |
| 60208 | 60297 | assert( sqlite3PagerIswriteable(pPage->pDbPage) ); |
| 60209 | 60298 | assert( pPage->pBt!=0 ); |
| 60210 | 60299 | assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE ); |
| 60211 | 60300 | assert( pPage->nOverflow==0 ); |
| 60212 | 60301 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| | @@ -60214,13 +60303,60 @@ |
| 60214 | 60303 | src = data = pPage->aData; |
| 60215 | 60304 | hdr = pPage->hdrOffset; |
| 60216 | 60305 | cellOffset = pPage->cellOffset; |
| 60217 | 60306 | nCell = pPage->nCell; |
| 60218 | 60307 | assert( nCell==get2byte(&data[hdr+3]) ); |
| 60308 | + iCellFirst = cellOffset + 2*nCell; |
| 60219 | 60309 | usableSize = pPage->pBt->usableSize; |
| 60310 | + |
| 60311 | + /* This block handles pages with two or fewer free blocks and nMaxFrag |
| 60312 | + ** or fewer fragmented bytes. In this case it is faster to move the |
| 60313 | + ** two (or one) blocks of cells using memmove() and add the required |
| 60314 | + ** offsets to each pointer in the cell-pointer array than it is to |
| 60315 | + ** reconstruct the entire page. */ |
| 60316 | + if( (int)data[hdr+7]<=nMaxFrag ){ |
| 60317 | + int iFree = get2byte(&data[hdr+1]); |
| 60318 | + if( iFree ){ |
| 60319 | + int iFree2 = get2byte(&data[iFree]); |
| 60320 | + |
| 60321 | + /* pageFindSlot() has already verified that free blocks are sorted |
| 60322 | + ** in order of offset within the page, and that no block extends |
| 60323 | + ** past the end of the page. Provided the two free slots do not |
| 60324 | + ** overlap, this guarantees that the memmove() calls below will not |
| 60325 | + ** overwrite the usableSize byte buffer, even if the database page |
| 60326 | + ** is corrupt. */ |
| 60327 | + assert( iFree2==0 || iFree2>iFree ); |
| 60328 | + assert( iFree+get2byte(&data[iFree+2]) <= usableSize ); |
| 60329 | + assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize ); |
| 60330 | + |
| 60331 | + if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){ |
| 60332 | + u8 *pEnd = &data[cellOffset + nCell*2]; |
| 60333 | + u8 *pAddr; |
| 60334 | + int sz2 = 0; |
| 60335 | + int sz = get2byte(&data[iFree+2]); |
| 60336 | + int top = get2byte(&data[hdr+5]); |
| 60337 | + if( iFree2 ){ |
| 60338 | + if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_BKPT; |
| 60339 | + sz2 = get2byte(&data[iFree2+2]); |
| 60340 | + assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize ); |
| 60341 | + memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); |
| 60342 | + sz += sz2; |
| 60343 | + } |
| 60344 | + cbrk = top+sz; |
| 60345 | + assert( cbrk+(iFree-top) <= usableSize ); |
| 60346 | + memmove(&data[cbrk], &data[top], iFree-top); |
| 60347 | + for(pAddr=&data[cellOffset]; pAddr<pEnd; pAddr+=2){ |
| 60348 | + pc = get2byte(pAddr); |
| 60349 | + if( pc<iFree ){ put2byte(pAddr, pc+sz); } |
| 60350 | + else if( pc<iFree2 ){ put2byte(pAddr, pc+sz2); } |
| 60351 | + } |
| 60352 | + goto defragment_out; |
| 60353 | + } |
| 60354 | + } |
| 60355 | + } |
| 60356 | + |
| 60220 | 60357 | cbrk = usableSize; |
| 60221 | | - iCellFirst = cellOffset + 2*nCell; |
| 60222 | 60358 | iCellLast = usableSize - 4; |
| 60223 | 60359 | for(i=0; i<nCell; i++){ |
| 60224 | 60360 | u8 *pAddr; /* The i-th cell pointer */ |
| 60225 | 60361 | pAddr = &data[cellOffset + i*2]; |
| 60226 | 60362 | pc = get2byte(pAddr); |
| | @@ -60250,20 +60386,22 @@ |
| 60250 | 60386 | memcpy(&temp[x], &data[x], (cbrk+size) - x); |
| 60251 | 60387 | src = temp; |
| 60252 | 60388 | } |
| 60253 | 60389 | memcpy(&data[cbrk], &src[pc], size); |
| 60254 | 60390 | } |
| 60391 | + data[hdr+7] = 0; |
| 60392 | + |
| 60393 | + defragment_out: |
| 60394 | + if( data[hdr+7]+cbrk-iCellFirst!=pPage->nFree ){ |
| 60395 | + return SQLITE_CORRUPT_BKPT; |
| 60396 | + } |
| 60255 | 60397 | assert( cbrk>=iCellFirst ); |
| 60256 | 60398 | put2byte(&data[hdr+5], cbrk); |
| 60257 | 60399 | data[hdr+1] = 0; |
| 60258 | 60400 | data[hdr+2] = 0; |
| 60259 | | - data[hdr+7] = 0; |
| 60260 | 60401 | memset(&data[iCellFirst], 0, cbrk-iCellFirst); |
| 60261 | 60402 | assert( sqlite3PagerIswriteable(pPage->pDbPage) ); |
| 60262 | | - if( cbrk-iCellFirst!=pPage->nFree ){ |
| 60263 | | - return SQLITE_CORRUPT_BKPT; |
| 60264 | | - } |
| 60265 | 60403 | return SQLITE_OK; |
| 60266 | 60404 | } |
| 60267 | 60405 | |
| 60268 | 60406 | /* |
| 60269 | 60407 | ** Search the free-list on page pPg for space to store a cell nByte bytes in |
| | @@ -60397,14 +60535,14 @@ |
| 60397 | 60535 | ** to see if defragmentation is necessary. |
| 60398 | 60536 | */ |
| 60399 | 60537 | testcase( gap+2+nByte==top ); |
| 60400 | 60538 | if( gap+2+nByte>top ){ |
| 60401 | 60539 | assert( pPage->nCell>0 || CORRUPT_DB ); |
| 60402 | | - rc = defragmentPage(pPage); |
| 60540 | + rc = defragmentPage(pPage, MIN(4, pPage->nFree - (2+nByte))); |
| 60403 | 60541 | if( rc ) return rc; |
| 60404 | 60542 | top = get2byteNotZero(&data[hdr+5]); |
| 60405 | | - assert( gap+nByte<=top ); |
| 60543 | + assert( gap+2+nByte<=top ); |
| 60406 | 60544 | } |
| 60407 | 60545 | |
| 60408 | 60546 | |
| 60409 | 60547 | /* Allocate memory from the gap in between the cell pointer array |
| 60410 | 60548 | ** and the cell content area. The btreeInitPage() call has already |
| | @@ -63636,11 +63774,11 @@ |
| 63636 | 63774 | pCur->aiIdx[pCur->iPage] = 0; |
| 63637 | 63775 | return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage], |
| 63638 | 63776 | pCur, pCur->curPagerFlags); |
| 63639 | 63777 | } |
| 63640 | 63778 | |
| 63641 | | -#if SQLITE_DEBUG |
| 63779 | +#ifdef SQLITE_DEBUG |
| 63642 | 63780 | /* |
| 63643 | 63781 | ** Page pParent is an internal (non-leaf) tree page. This function |
| 63644 | 63782 | ** asserts that page number iChild is the left-child if the iIdx'th |
| 63645 | 63783 | ** cell in page pParent. Or, if iIdx is equal to the total number of |
| 63646 | 63784 | ** cells in pParent, that page number iChild is the right-child of |
| | @@ -64178,10 +64316,34 @@ |
| 64178 | 64316 | ** have been deleted? This API will need to change to return an error code |
| 64179 | 64317 | ** as well as the boolean result value. |
| 64180 | 64318 | */ |
| 64181 | 64319 | return (CURSOR_VALID!=pCur->eState); |
| 64182 | 64320 | } |
| 64321 | + |
| 64322 | +/* |
| 64323 | +** Return an estimate for the number of rows in the table that pCur is |
| 64324 | +** pointing to. Return a negative number if no estimate is currently |
| 64325 | +** available. |
| 64326 | +*/ |
| 64327 | +SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor *pCur){ |
| 64328 | + i64 n; |
| 64329 | + u8 i; |
| 64330 | + |
| 64331 | + assert( cursorOwnsBtShared(pCur) ); |
| 64332 | + assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 64333 | + |
| 64334 | + /* Currently this interface is only called by the OP_IfSmaller |
| 64335 | + ** opcode, and it that case the cursor will always be valid and |
| 64336 | + ** will always point to a leaf node. */ |
| 64337 | + if( NEVER(pCur->eState!=CURSOR_VALID) ) return -1; |
| 64338 | + if( NEVER(pCur->apPage[pCur->iPage]->leaf==0) ) return -1; |
| 64339 | + |
| 64340 | + for(n=1, i=0; i<=pCur->iPage; i++){ |
| 64341 | + n *= pCur->apPage[i]->nCell; |
| 64342 | + } |
| 64343 | + return n; |
| 64344 | +} |
| 64183 | 64345 | |
| 64184 | 64346 | /* |
| 64185 | 64347 | ** Advance the cursor to the next entry in the database. If |
| 64186 | 64348 | ** successful then set *pRes=0. If the cursor |
| 64187 | 64349 | ** was already pointing to the last entry in the database before |
| | @@ -65023,11 +65185,11 @@ |
| 65023 | 65185 | ** pPrior Where to write the pgno of the first overflow page |
| 65024 | 65186 | ** |
| 65025 | 65187 | ** Use a call to btreeParseCellPtr() to verify that the values above |
| 65026 | 65188 | ** were computed correctly. |
| 65027 | 65189 | */ |
| 65028 | | -#if SQLITE_DEBUG |
| 65190 | +#ifdef SQLITE_DEBUG |
| 65029 | 65191 | { |
| 65030 | 65192 | CellInfo info; |
| 65031 | 65193 | pPage->xParseCell(pPage, pCell, &info); |
| 65032 | 65194 | assert( nHeader==(int)(info.pPayload - pCell) ); |
| 65033 | 65195 | assert( info.nKey==pX->nKey ); |
| | @@ -66549,11 +66711,11 @@ |
| 66549 | 66711 | ** copied into the parent, because if the parent is page 1 then it will |
| 66550 | 66712 | ** by smaller than the child due to the database header, and so all the |
| 66551 | 66713 | ** free space needs to be up front. |
| 66552 | 66714 | */ |
| 66553 | 66715 | assert( nNew==1 || CORRUPT_DB ); |
| 66554 | | - rc = defragmentPage(apNew[0]); |
| 66716 | + rc = defragmentPage(apNew[0], -1); |
| 66555 | 66717 | testcase( rc!=SQLITE_OK ); |
| 66556 | 66718 | assert( apNew[0]->nFree == |
| 66557 | 66719 | (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2) |
| 66558 | 66720 | || rc!=SQLITE_OK |
| 66559 | 66721 | ); |
| | @@ -71201,10 +71363,11 @@ |
| 71201 | 71363 | ** Remember the SQL string for a prepared statement. |
| 71202 | 71364 | */ |
| 71203 | 71365 | SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepareV2){ |
| 71204 | 71366 | assert( isPrepareV2==1 || isPrepareV2==0 ); |
| 71205 | 71367 | if( p==0 ) return; |
| 71368 | + if( !isPrepareV2 ) p->expmask = 0; |
| 71206 | 71369 | #if defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_ENABLE_SQLLOG) |
| 71207 | 71370 | if( !isPrepareV2 ) return; |
| 71208 | 71371 | #endif |
| 71209 | 71372 | assert( p->zSql==0 ); |
| 71210 | 71373 | p->zSql = sqlite3DbStrNDup(p->db, z, n); |
| | @@ -71229,10 +71392,11 @@ |
| 71229 | 71392 | pB->pPrev = pTmp; |
| 71230 | 71393 | zTmp = pA->zSql; |
| 71231 | 71394 | pA->zSql = pB->zSql; |
| 71232 | 71395 | pB->zSql = zTmp; |
| 71233 | 71396 | pB->isPrepareV2 = pA->isPrepareV2; |
| 71397 | + pB->expmask = pA->expmask; |
| 71234 | 71398 | } |
| 71235 | 71399 | |
| 71236 | 71400 | /* |
| 71237 | 71401 | ** Resize the Vdbe.aOp array so that it is at least nOp elements larger |
| 71238 | 71402 | ** than its current size. nOp is guaranteed to be less than or equal |
| | @@ -73753,17 +73917,17 @@ |
| 73753 | 73917 | ** Then the internal cache might have been left in an inconsistent |
| 73754 | 73918 | ** state. We need to rollback the statement transaction, if there is |
| 73755 | 73919 | ** one, or the complete transaction if there is no statement transaction. |
| 73756 | 73920 | */ |
| 73757 | 73921 | |
| 73922 | + if( p->magic!=VDBE_MAGIC_RUN ){ |
| 73923 | + return SQLITE_OK; |
| 73924 | + } |
| 73758 | 73925 | if( db->mallocFailed ){ |
| 73759 | 73926 | p->rc = SQLITE_NOMEM_BKPT; |
| 73760 | 73927 | } |
| 73761 | 73928 | closeAllCursors(p); |
| 73762 | | - if( p->magic!=VDBE_MAGIC_RUN ){ |
| 73763 | | - return SQLITE_OK; |
| 73764 | | - } |
| 73765 | 73929 | checkActiveVdbeCnt(db); |
| 73766 | 73930 | |
| 73767 | 73931 | /* No commit or rollback needed if the program never started or if the |
| 73768 | 73932 | ** SQL statement does not read or write a database file. */ |
| 73769 | 73933 | if( p->pc>=0 && p->bIsReader ){ |
| | @@ -74706,11 +74870,11 @@ |
| 74706 | 74870 | } |
| 74707 | 74871 | assert( u<=pKeyInfo->nField + 1 ); |
| 74708 | 74872 | p->nField = u; |
| 74709 | 74873 | } |
| 74710 | 74874 | |
| 74711 | | -#if SQLITE_DEBUG |
| 74875 | +#ifdef SQLITE_DEBUG |
| 74712 | 74876 | /* |
| 74713 | 74877 | ** This function compares two index or table record keys in the same way |
| 74714 | 74878 | ** as the sqlite3VdbeRecordCompare() routine. Unlike VdbeRecordCompare(), |
| 74715 | 74879 | ** this function deserializes and compares values using the |
| 74716 | 74880 | ** sqlite3VdbeSerialGet() and sqlite3MemCompare() functions. It is used |
| | @@ -74811,11 +74975,11 @@ |
| 74811 | 74975 | if( pKeyInfo->db->mallocFailed ) return 1; |
| 74812 | 74976 | return 0; |
| 74813 | 74977 | } |
| 74814 | 74978 | #endif |
| 74815 | 74979 | |
| 74816 | | -#if SQLITE_DEBUG |
| 74980 | +#ifdef SQLITE_DEBUG |
| 74817 | 74981 | /* |
| 74818 | 74982 | ** Count the number of fields (a.k.a. columns) in the record given by |
| 74819 | 74983 | ** pKey,nKey. The verify that this count is less than or equal to the |
| 74820 | 74984 | ** limit given by pKeyInfo->nField + pKeyInfo->nXField. |
| 74821 | 74985 | ** |
| | @@ -75694,12 +75858,12 @@ |
| 75694 | 75858 | ** to sqlite3_reoptimize() that re-preparing the statement may result |
| 75695 | 75859 | ** in a better query plan. |
| 75696 | 75860 | */ |
| 75697 | 75861 | SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe *v, int iVar){ |
| 75698 | 75862 | assert( iVar>0 ); |
| 75699 | | - if( iVar>32 ){ |
| 75700 | | - v->expmask = 0xffffffff; |
| 75863 | + if( iVar>=32 ){ |
| 75864 | + v->expmask |= 0x80000000; |
| 75701 | 75865 | }else{ |
| 75702 | 75866 | v->expmask |= ((u32)1 << (iVar-1)); |
| 75703 | 75867 | } |
| 75704 | 75868 | } |
| 75705 | 75869 | |
| | @@ -75965,11 +76129,12 @@ |
| 75965 | 76129 | sqlite3_mutex_enter(mutex); |
| 75966 | 76130 | for(i=0; i<p->nVar; i++){ |
| 75967 | 76131 | sqlite3VdbeMemRelease(&p->aVar[i]); |
| 75968 | 76132 | p->aVar[i].flags = MEM_Null; |
| 75969 | 76133 | } |
| 75970 | | - if( p->isPrepareV2 && p->expmask ){ |
| 76134 | + assert( p->isPrepareV2 || p->expmask==0 ); |
| 76135 | + if( p->expmask ){ |
| 75971 | 76136 | p->expired = 1; |
| 75972 | 76137 | } |
| 75973 | 76138 | sqlite3_mutex_leave(mutex); |
| 75974 | 76139 | return rc; |
| 75975 | 76140 | } |
| | @@ -77069,13 +77234,12 @@ |
| 77069 | 77234 | ** parameter in the WHERE clause might influence the choice of query plan |
| 77070 | 77235 | ** for a statement, then the statement will be automatically recompiled, |
| 77071 | 77236 | ** as if there had been a schema change, on the first sqlite3_step() call |
| 77072 | 77237 | ** following any change to the bindings of that parameter. |
| 77073 | 77238 | */ |
| 77074 | | - if( p->isPrepareV2 && |
| 77075 | | - ((i<32 && p->expmask & ((u32)1 << i)) || p->expmask==0xffffffff) |
| 77076 | | - ){ |
| 77239 | + assert( p->isPrepareV2 || p->expmask==0 ); |
| 77240 | + if( p->expmask!=0 && (p->expmask & (i>=31 ? 0x80000000 : (u32)1<<i))!=0 ){ |
| 77077 | 77241 | p->expired = 1; |
| 77078 | 77242 | } |
| 77079 | 77243 | return SQLITE_OK; |
| 77080 | 77244 | } |
| 77081 | 77245 | |
| | @@ -77334,14 +77498,16 @@ |
| 77334 | 77498 | Vdbe *pFrom = (Vdbe*)pFromStmt; |
| 77335 | 77499 | Vdbe *pTo = (Vdbe*)pToStmt; |
| 77336 | 77500 | if( pFrom->nVar!=pTo->nVar ){ |
| 77337 | 77501 | return SQLITE_ERROR; |
| 77338 | 77502 | } |
| 77339 | | - if( pTo->isPrepareV2 && pTo->expmask ){ |
| 77503 | + assert( pTo->isPrepareV2 || pTo->expmask==0 ); |
| 77504 | + if( pTo->expmask ){ |
| 77340 | 77505 | pTo->expired = 1; |
| 77341 | 77506 | } |
| 77342 | | - if( pFrom->isPrepareV2 && pFrom->expmask ){ |
| 77507 | + assert( pFrom->isPrepareV2 || pFrom->expmask==0 ); |
| 77508 | + if( pFrom->expmask ){ |
| 77343 | 77509 | pFrom->expired = 1; |
| 77344 | 77510 | } |
| 77345 | 77511 | return sqlite3TransferBindings(pFromStmt, pToStmt); |
| 77346 | 77512 | } |
| 77347 | 77513 | #endif |
| | @@ -79658,39 +79824,39 @@ |
| 79658 | 79824 | if( pCtx->pOut != pOut ){ |
| 79659 | 79825 | pCtx->pOut = pOut; |
| 79660 | 79826 | for(i=pCtx->argc-1; i>=0; i--) pCtx->argv[i] = &aMem[pOp->p2+i]; |
| 79661 | 79827 | } |
| 79662 | 79828 | |
| 79663 | | - memAboutToChange(p, pCtx->pOut); |
| 79829 | + memAboutToChange(p, pOut); |
| 79664 | 79830 | #ifdef SQLITE_DEBUG |
| 79665 | 79831 | for(i=0; i<pCtx->argc; i++){ |
| 79666 | 79832 | assert( memIsValid(pCtx->argv[i]) ); |
| 79667 | 79833 | REGISTER_TRACE(pOp->p2+i, pCtx->argv[i]); |
| 79668 | 79834 | } |
| 79669 | 79835 | #endif |
| 79670 | | - MemSetTypeFlag(pCtx->pOut, MEM_Null); |
| 79836 | + MemSetTypeFlag(pOut, MEM_Null); |
| 79671 | 79837 | pCtx->fErrorOrAux = 0; |
| 79672 | 79838 | (*pCtx->pFunc->xSFunc)(pCtx, pCtx->argc, pCtx->argv);/* IMP: R-24505-23230 */ |
| 79673 | 79839 | |
| 79674 | 79840 | /* If the function returned an error, throw an exception */ |
| 79675 | 79841 | if( pCtx->fErrorOrAux ){ |
| 79676 | 79842 | if( pCtx->isError ){ |
| 79677 | | - sqlite3VdbeError(p, "%s", sqlite3_value_text(pCtx->pOut)); |
| 79843 | + sqlite3VdbeError(p, "%s", sqlite3_value_text(pOut)); |
| 79678 | 79844 | rc = pCtx->isError; |
| 79679 | 79845 | } |
| 79680 | 79846 | sqlite3VdbeDeleteAuxData(db, &p->pAuxData, pCtx->iOp, pOp->p1); |
| 79681 | 79847 | if( rc ) goto abort_due_to_error; |
| 79682 | 79848 | } |
| 79683 | 79849 | |
| 79684 | 79850 | /* Copy the result of the function into register P3 */ |
| 79685 | 79851 | if( pOut->flags & (MEM_Str|MEM_Blob) ){ |
| 79686 | | - sqlite3VdbeChangeEncoding(pCtx->pOut, encoding); |
| 79687 | | - if( sqlite3VdbeMemTooBig(pCtx->pOut) ) goto too_big; |
| 79852 | + sqlite3VdbeChangeEncoding(pOut, encoding); |
| 79853 | + if( sqlite3VdbeMemTooBig(pOut) ) goto too_big; |
| 79688 | 79854 | } |
| 79689 | 79855 | |
| 79690 | | - REGISTER_TRACE(pOp->p3, pCtx->pOut); |
| 79691 | | - UPDATE_MAX_BLOBSIZE(pCtx->pOut); |
| 79856 | + REGISTER_TRACE(pOp->p3, pOut); |
| 79857 | + UPDATE_MAX_BLOBSIZE(pOut); |
| 79692 | 79858 | break; |
| 79693 | 79859 | } |
| 79694 | 79860 | |
| 79695 | 79861 | /* Opcode: BitAnd P1 P2 P3 * * |
| 79696 | 79862 | ** Synopsis: r[P3]=r[P1]&r[P2] |
| | @@ -80187,11 +80353,11 @@ |
| 80187 | 80353 | pKeyInfo = pOp->p4.pKeyInfo; |
| 80188 | 80354 | assert( n>0 ); |
| 80189 | 80355 | assert( pKeyInfo!=0 ); |
| 80190 | 80356 | p1 = pOp->p1; |
| 80191 | 80357 | p2 = pOp->p2; |
| 80192 | | -#if SQLITE_DEBUG |
| 80358 | +#ifdef SQLITE_DEBUG |
| 80193 | 80359 | if( aPermute ){ |
| 80194 | 80360 | int k, mx = 0; |
| 80195 | 80361 | for(k=0; k<n; k++) if( aPermute[k]>mx ) mx = aPermute[k]; |
| 80196 | 80362 | assert( p1>0 && p1+mx<=(p->nMem+1 - p->nCursor)+1 ); |
| 80197 | 80363 | assert( p2>0 && p2+mx<=(p->nMem+1 - p->nCursor)+1 ); |
| | @@ -82836,10 +83002,37 @@ |
| 82836 | 83002 | assert( pOp->p2==0 ); |
| 82837 | 83003 | } |
| 82838 | 83004 | break; |
| 82839 | 83005 | } |
| 82840 | 83006 | |
| 83007 | +/* Opcode: IfSmaller P1 P2 P3 * * |
| 83008 | +** |
| 83009 | +** Estimate the number of rows in the table P1. Jump to P2 if that |
| 83010 | +** estimate is less than approximately 2**(0.1*P3). |
| 83011 | +*/ |
| 83012 | +case OP_IfSmaller: { /* jump */ |
| 83013 | + VdbeCursor *pC; |
| 83014 | + BtCursor *pCrsr; |
| 83015 | + int res; |
| 83016 | + i64 sz; |
| 83017 | + |
| 83018 | + assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 83019 | + pC = p->apCsr[pOp->p1]; |
| 83020 | + assert( pC!=0 ); |
| 83021 | + pCrsr = pC->uc.pCursor; |
| 83022 | + assert( pCrsr ); |
| 83023 | + rc = sqlite3BtreeFirst(pCrsr, &res); |
| 83024 | + if( rc ) goto abort_due_to_error; |
| 83025 | + if( res==0 ){ |
| 83026 | + sz = sqlite3BtreeRowCountEst(pCrsr); |
| 83027 | + if( ALWAYS(sz>=0) && sqlite3LogEst((u64)sz)<pOp->p3 ) res = 1; |
| 83028 | + } |
| 83029 | + VdbeBranchTaken(res!=0,2); |
| 83030 | + if( res ) goto jump_to_p2; |
| 83031 | + break; |
| 83032 | +} |
| 83033 | + |
| 82841 | 83034 | |
| 82842 | 83035 | /* Opcode: SorterSort P1 P2 * * * |
| 82843 | 83036 | ** |
| 82844 | 83037 | ** After all records have been inserted into the Sorter object |
| 82845 | 83038 | ** identified by P1, invoke this opcode to actually do the sorting. |
| | @@ -83479,10 +83672,22 @@ |
| 83479 | 83672 | rc = sqlite3BtreeCreateTable(pDb->pBt, &pgno, flags); |
| 83480 | 83673 | if( rc ) goto abort_due_to_error; |
| 83481 | 83674 | pOut->u.i = pgno; |
| 83482 | 83675 | break; |
| 83483 | 83676 | } |
| 83677 | + |
| 83678 | +/* Opcode: SqlExec * * * P4 * |
| 83679 | +** |
| 83680 | +** Run the SQL statement or statements specified in the P4 string. |
| 83681 | +*/ |
| 83682 | +case OP_SqlExec: { |
| 83683 | + db->nSqlExec++; |
| 83684 | + rc = sqlite3_exec(db, pOp->p4.z, 0, 0, 0); |
| 83685 | + db->nSqlExec--; |
| 83686 | + if( rc ) goto abort_due_to_error; |
| 83687 | + break; |
| 83688 | +} |
| 83484 | 83689 | |
| 83485 | 83690 | /* Opcode: ParseSchema P1 * * P4 * |
| 83486 | 83691 | ** |
| 83487 | 83692 | ** Read and parse all entries from the SQLITE_MASTER table of database P1 |
| 83488 | 83693 | ** that match the WHERE clause P4. |
| | @@ -83600,11 +83805,11 @@ |
| 83600 | 83805 | ** |
| 83601 | 83806 | ** Do an analysis of the currently open database. Store in |
| 83602 | 83807 | ** register P1 the text of an error message describing any problems. |
| 83603 | 83808 | ** If no problems are found, store a NULL in register P1. |
| 83604 | 83809 | ** |
| 83605 | | -** The register P3 contains the maximum number of allowed errors. |
| 83810 | +** The register P3 contains one less than the maximum number of allowed errors. |
| 83606 | 83811 | ** At most reg(P3) errors will be reported. |
| 83607 | 83812 | ** In other words, the analysis stops as soon as reg(P1) errors are |
| 83608 | 83813 | ** seen. Reg(P1) is updated with the number of errors remaining. |
| 83609 | 83814 | ** |
| 83610 | 83815 | ** The root page numbers of all tables in the database are integers |
| | @@ -83633,18 +83838,18 @@ |
| 83633 | 83838 | assert( (pnErr->flags & (MEM_Str|MEM_Blob))==0 ); |
| 83634 | 83839 | pIn1 = &aMem[pOp->p1]; |
| 83635 | 83840 | assert( pOp->p5<db->nDb ); |
| 83636 | 83841 | assert( DbMaskTest(p->btreeMask, pOp->p5) ); |
| 83637 | 83842 | z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot, |
| 83638 | | - (int)pnErr->u.i, &nErr); |
| 83639 | | - pnErr->u.i -= nErr; |
| 83843 | + (int)pnErr->u.i+1, &nErr); |
| 83640 | 83844 | sqlite3VdbeMemSetNull(pIn1); |
| 83641 | 83845 | if( nErr==0 ){ |
| 83642 | 83846 | assert( z==0 ); |
| 83643 | 83847 | }else if( z==0 ){ |
| 83644 | 83848 | goto no_mem; |
| 83645 | 83849 | }else{ |
| 83850 | + pnErr->u.i -= nErr-1; |
| 83646 | 83851 | sqlite3VdbeMemSetStr(pIn1, z, -1, SQLITE_UTF8, sqlite3_free); |
| 83647 | 83852 | } |
| 83648 | 83853 | UPDATE_MAX_BLOBSIZE(pIn1); |
| 83649 | 83854 | sqlite3VdbeChangeEncoding(pIn1, encoding); |
| 83650 | 83855 | break; |
| | @@ -88787,15 +88992,15 @@ |
| 88787 | 88992 | ** The return value from the callback should be one of the WRC_* |
| 88788 | 88993 | ** constants to specify how to proceed with the walk. |
| 88789 | 88994 | ** |
| 88790 | 88995 | ** WRC_Continue Continue descending down the tree. |
| 88791 | 88996 | ** |
| 88792 | | -** WRC_Prune Do not descend into child nodes. But allow |
| 88997 | +** WRC_Prune Do not descend into child nodes, but allow |
| 88793 | 88998 | ** the walk to continue with sibling nodes. |
| 88794 | 88999 | ** |
| 88795 | 89000 | ** WRC_Abort Do no more callbacks. Unwind the stack and |
| 88796 | | -** return the top-level walk call. |
| 89001 | +** return from the top-level walk call. |
| 88797 | 89002 | ** |
| 88798 | 89003 | ** The return value from this routine is WRC_Abort to abandon the tree walk |
| 88799 | 89004 | ** and WRC_Continue to continue. |
| 88800 | 89005 | */ |
| 88801 | 89006 | static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ |
| | @@ -89153,11 +89358,12 @@ |
| 89153 | 89358 | } |
| 89154 | 89359 | } |
| 89155 | 89360 | } |
| 89156 | 89361 | |
| 89157 | 89362 | /* Start at the inner-most context and move outward until a match is found */ |
| 89158 | | - while( pNC && cnt==0 ){ |
| 89363 | + assert( pNC && cnt==0 ); |
| 89364 | + do{ |
| 89159 | 89365 | ExprList *pEList; |
| 89160 | 89366 | SrcList *pSrcList = pNC->pSrcList; |
| 89161 | 89367 | |
| 89162 | 89368 | if( pSrcList ){ |
| 89163 | 89369 | for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){ |
| | @@ -89338,15 +89544,15 @@ |
| 89338 | 89544 | } |
| 89339 | 89545 | |
| 89340 | 89546 | /* Advance to the next name context. The loop will exit when either |
| 89341 | 89547 | ** we have a match (cnt>0) or when we run out of name contexts. |
| 89342 | 89548 | */ |
| 89343 | | - if( cnt==0 ){ |
| 89344 | | - pNC = pNC->pNext; |
| 89345 | | - nSubquery++; |
| 89346 | | - } |
| 89347 | | - } |
| 89549 | + if( cnt ) break; |
| 89550 | + pNC = pNC->pNext; |
| 89551 | + nSubquery++; |
| 89552 | + }while( pNC ); |
| 89553 | + |
| 89348 | 89554 | |
| 89349 | 89555 | /* |
| 89350 | 89556 | ** If X and Y are NULL (in other words if only the column name Z is |
| 89351 | 89557 | ** supplied) and the value of Z is enclosed in double-quotes, then |
| 89352 | 89558 | ** Z is a string literal if it doesn't match any column names. In that |
| | @@ -89532,37 +89738,42 @@ |
| 89532 | 89738 | break; |
| 89533 | 89739 | } |
| 89534 | 89740 | #endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) |
| 89535 | 89741 | && !defined(SQLITE_OMIT_SUBQUERY) */ |
| 89536 | 89742 | |
| 89537 | | - /* A lone identifier is the name of a column. |
| 89538 | | - */ |
| 89539 | | - case TK_ID: { |
| 89540 | | - return lookupName(pParse, 0, 0, pExpr->u.zToken, pNC, pExpr); |
| 89541 | | - } |
| 89542 | | - |
| 89543 | | - /* A table name and column name: ID.ID |
| 89743 | + /* A column name: ID |
| 89744 | + ** Or table name and column name: ID.ID |
| 89544 | 89745 | ** Or a database, table and column: ID.ID.ID |
| 89746 | + ** |
| 89747 | + ** The TK_ID and TK_OUT cases are combined so that there will only |
| 89748 | + ** be one call to lookupName(). Then the compiler will in-line |
| 89749 | + ** lookupName() for a size reduction and performance increase. |
| 89545 | 89750 | */ |
| 89751 | + case TK_ID: |
| 89546 | 89752 | case TK_DOT: { |
| 89547 | 89753 | const char *zColumn; |
| 89548 | 89754 | const char *zTable; |
| 89549 | 89755 | const char *zDb; |
| 89550 | 89756 | Expr *pRight; |
| 89551 | 89757 | |
| 89552 | | - /* if( pSrcList==0 ) break; */ |
| 89553 | | - notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); |
| 89554 | | - pRight = pExpr->pRight; |
| 89555 | | - if( pRight->op==TK_ID ){ |
| 89758 | + if( pExpr->op==TK_ID ){ |
| 89556 | 89759 | zDb = 0; |
| 89557 | | - zTable = pExpr->pLeft->u.zToken; |
| 89558 | | - zColumn = pRight->u.zToken; |
| 89760 | + zTable = 0; |
| 89761 | + zColumn = pExpr->u.zToken; |
| 89559 | 89762 | }else{ |
| 89560 | | - assert( pRight->op==TK_DOT ); |
| 89561 | | - zDb = pExpr->pLeft->u.zToken; |
| 89562 | | - zTable = pRight->pLeft->u.zToken; |
| 89563 | | - zColumn = pRight->pRight->u.zToken; |
| 89763 | + notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); |
| 89764 | + pRight = pExpr->pRight; |
| 89765 | + if( pRight->op==TK_ID ){ |
| 89766 | + zDb = 0; |
| 89767 | + zTable = pExpr->pLeft->u.zToken; |
| 89768 | + zColumn = pRight->u.zToken; |
| 89769 | + }else{ |
| 89770 | + assert( pRight->op==TK_DOT ); |
| 89771 | + zDb = pExpr->pLeft->u.zToken; |
| 89772 | + zTable = pRight->pLeft->u.zToken; |
| 89773 | + zColumn = pRight->pRight->u.zToken; |
| 89774 | + } |
| 89564 | 89775 | } |
| 89565 | 89776 | return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr); |
| 89566 | 89777 | } |
| 89567 | 89778 | |
| 89568 | 89779 | /* Resolve function names |
| | @@ -92833,11 +93044,11 @@ |
| 92833 | 93044 | int nVal = sqlite3ExprVectorSize(pLeft); |
| 92834 | 93045 | Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0; |
| 92835 | 93046 | char *zRet; |
| 92836 | 93047 | |
| 92837 | 93048 | assert( pExpr->op==TK_IN ); |
| 92838 | | - zRet = sqlite3DbMallocZero(pParse->db, nVal+1); |
| 93049 | + zRet = sqlite3DbMallocRaw(pParse->db, nVal+1); |
| 92839 | 93050 | if( zRet ){ |
| 92840 | 93051 | int i; |
| 92841 | 93052 | for(i=0; i<nVal; i++){ |
| 92842 | 93053 | Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i); |
| 92843 | 93054 | char a = sqlite3ExprAffinity(pA); |
| | @@ -93738,11 +93949,11 @@ |
| 93738 | 93949 | ** Clear all column cache entries. |
| 93739 | 93950 | */ |
| 93740 | 93951 | SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse *pParse){ |
| 93741 | 93952 | int i; |
| 93742 | 93953 | |
| 93743 | | -#if SQLITE_DEBUG |
| 93954 | +#ifdef SQLITE_DEBUG |
| 93744 | 93955 | if( pParse->db->flags & SQLITE_VdbeAddopTrace ){ |
| 93745 | 93956 | printf("CLEAR\n"); |
| 93746 | 93957 | } |
| 93747 | 93958 | #endif |
| 93748 | 93959 | for(i=0; i<pParse->nColCache; i++){ |
| | @@ -95145,10 +95356,21 @@ |
| 95145 | 95356 | if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1; |
| 95146 | 95357 | if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1; |
| 95147 | 95358 | } |
| 95148 | 95359 | return 0; |
| 95149 | 95360 | } |
| 95361 | + |
| 95362 | +/* |
| 95363 | +** Like sqlite3ExprCompare() except COLLATE operators at the top-level |
| 95364 | +** are ignored. |
| 95365 | +*/ |
| 95366 | +SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){ |
| 95367 | + return sqlite3ExprCompare( |
| 95368 | + sqlite3ExprSkipCollate(pA), |
| 95369 | + sqlite3ExprSkipCollate(pB), |
| 95370 | + iTab); |
| 95371 | +} |
| 95150 | 95372 | |
| 95151 | 95373 | /* |
| 95152 | 95374 | ** Return true if we can prove the pE2 will always be true if pE1 is |
| 95153 | 95375 | ** true. Return false if we cannot complete the proof or if pE2 might |
| 95154 | 95376 | ** be false. Examples: |
| | @@ -96698,10 +96920,11 @@ |
| 96698 | 96920 | Stat4Sample current; /* Current row as a Stat4Sample */ |
| 96699 | 96921 | u32 iPrn; /* Pseudo-random number used for sampling */ |
| 96700 | 96922 | Stat4Sample *aBest; /* Array of nCol best samples */ |
| 96701 | 96923 | int iMin; /* Index in a[] of entry with minimum score */ |
| 96702 | 96924 | int nSample; /* Current number of samples */ |
| 96925 | + int nMaxEqZero; /* Max leading 0 in anEq[] for any a[] entry */ |
| 96703 | 96926 | int iGet; /* Index of current sample accessed by stat_get() */ |
| 96704 | 96927 | Stat4Sample *a; /* Array of mxSample Stat4Sample objects */ |
| 96705 | 96928 | sqlite3 *db; /* Database connection, for malloc() */ |
| 96706 | 96929 | }; |
| 96707 | 96930 | |
| | @@ -96962,10 +97185,17 @@ |
| 96962 | 97185 | int i; |
| 96963 | 97186 | |
| 96964 | 97187 | assert( IsStat4 || nEqZero==0 ); |
| 96965 | 97188 | |
| 96966 | 97189 | #ifdef SQLITE_ENABLE_STAT4 |
| 97190 | + /* Stat4Accum.nMaxEqZero is set to the maximum number of leading 0 |
| 97191 | + ** values in the anEq[] array of any sample in Stat4Accum.a[]. In |
| 97192 | + ** other words, if nMaxEqZero is n, then it is guaranteed that there |
| 97193 | + ** are no samples with Stat4Sample.anEq[m]==0 for (m>=n). */ |
| 97194 | + if( nEqZero>p->nMaxEqZero ){ |
| 97195 | + p->nMaxEqZero = nEqZero; |
| 97196 | + } |
| 96967 | 97197 | if( pNew->isPSample==0 ){ |
| 96968 | 97198 | Stat4Sample *pUpgrade = 0; |
| 96969 | 97199 | assert( pNew->anEq[pNew->iCol]>0 ); |
| 96970 | 97200 | |
| 96971 | 97201 | /* This sample is being added because the prefix that ends in column |
| | @@ -97059,16 +97289,26 @@ |
| 97059 | 97289 | if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){ |
| 97060 | 97290 | sampleInsert(p, pBest, i); |
| 97061 | 97291 | } |
| 97062 | 97292 | } |
| 97063 | 97293 | |
| 97064 | | - /* Update the anEq[] fields of any samples already collected. */ |
| 97294 | + /* Check that no sample contains an anEq[] entry with an index of |
| 97295 | + ** p->nMaxEqZero or greater set to zero. */ |
| 97065 | 97296 | for(i=p->nSample-1; i>=0; i--){ |
| 97066 | 97297 | 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]; |
| 97298 | + for(j=p->nMaxEqZero; j<p->nCol; j++) assert( p->a[i].anEq[j]>0 ); |
| 97299 | + } |
| 97300 | + |
| 97301 | + /* Update the anEq[] fields of any samples already collected. */ |
| 97302 | + if( iChng<p->nMaxEqZero ){ |
| 97303 | + for(i=p->nSample-1; i>=0; i--){ |
| 97304 | + int j; |
| 97305 | + for(j=iChng; j<p->nCol; j++){ |
| 97306 | + if( p->a[i].anEq[j]==0 ) p->a[i].anEq[j] = p->current.anEq[j]; |
| 97307 | + } |
| 97069 | 97308 | } |
| 97309 | + p->nMaxEqZero = iChng; |
| 97070 | 97310 | } |
| 97071 | 97311 | #endif |
| 97072 | 97312 | |
| 97073 | 97313 | #if defined(SQLITE_ENABLE_STAT3) && !defined(SQLITE_ENABLE_STAT4) |
| 97074 | 97314 | if( iChng==0 ){ |
| | @@ -97778,44 +98018,32 @@ |
| 97778 | 98018 | /* Form 1: Analyze everything */ |
| 97779 | 98019 | for(i=0; i<db->nDb; i++){ |
| 97780 | 98020 | if( i==1 ) continue; /* Do not analyze the TEMP database */ |
| 97781 | 98021 | analyzeDatabase(pParse, i); |
| 97782 | 98022 | } |
| 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 */ |
| 98023 | + }else if( pName2->n==0 && (iDb = sqlite3FindDb(db, pName1))>=0 ){ |
| 98024 | + /* Analyze the schema named as the argument */ |
| 98025 | + analyzeDatabase(pParse, iDb); |
| 98026 | + }else{ |
| 98027 | + /* Form 3: Analyze the table or index named as an argument */ |
| 97801 | 98028 | iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pTableName); |
| 97802 | 98029 | if( iDb>=0 ){ |
| 97803 | | - zDb = db->aDb[iDb].zDbSName; |
| 98030 | + zDb = pName2->n ? db->aDb[iDb].zDbSName : 0; |
| 97804 | 98031 | z = sqlite3NameFromToken(db, pTableName); |
| 97805 | 98032 | if( z ){ |
| 97806 | 98033 | if( (pIdx = sqlite3FindIndex(db, z, zDb))!=0 ){ |
| 97807 | 98034 | analyzeTable(pParse, pIdx->pTable, pIdx); |
| 97808 | 98035 | }else if( (pTab = sqlite3LocateTable(pParse, 0, z, zDb))!=0 ){ |
| 97809 | 98036 | analyzeTable(pParse, pTab, 0); |
| 97810 | 98037 | } |
| 97811 | 98038 | sqlite3DbFree(db, z); |
| 97812 | 98039 | } |
| 97813 | | - } |
| 98040 | + } |
| 97814 | 98041 | } |
| 97815 | | - v = sqlite3GetVdbe(pParse); |
| 97816 | | - if( v ) sqlite3VdbeAddOp0(v, OP_Expire); |
| 98042 | + if( db->nSqlExec==0 && (v = sqlite3GetVdbe(pParse))!=0 ){ |
| 98043 | + sqlite3VdbeAddOp0(v, OP_Expire); |
| 98044 | + } |
| 97817 | 98045 | } |
| 97818 | 98046 | |
| 97819 | 98047 | /* |
| 97820 | 98048 | ** Used to pass information from the analyzer reader through to the |
| 97821 | 98049 | ** callback routine. |
| | @@ -97940,19 +98168,24 @@ |
| 97940 | 98168 | } |
| 97941 | 98169 | aiRowEst = pIndex->aiRowEst; |
| 97942 | 98170 | #endif |
| 97943 | 98171 | pIndex->bUnordered = 0; |
| 97944 | 98172 | decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex); |
| 97945 | | - if( pIndex->pPartIdxWhere==0 ) pTable->nRowLogEst = pIndex->aiRowLogEst[0]; |
| 98173 | + pIndex->hasStat1 = 1; |
| 98174 | + if( pIndex->pPartIdxWhere==0 ){ |
| 98175 | + pTable->nRowLogEst = pIndex->aiRowLogEst[0]; |
| 98176 | + pTable->tabFlags |= TF_HasStat1; |
| 98177 | + } |
| 97946 | 98178 | }else{ |
| 97947 | 98179 | Index fakeIdx; |
| 97948 | 98180 | fakeIdx.szIdxRow = pTable->szTabRow; |
| 97949 | 98181 | #ifdef SQLITE_ENABLE_COSTMULT |
| 97950 | 98182 | fakeIdx.pTable = pTable; |
| 97951 | 98183 | #endif |
| 97952 | 98184 | decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx); |
| 97953 | 98185 | pTable->szTabRow = fakeIdx.szIdxRow; |
| 98186 | + pTable->tabFlags |= TF_HasStat1; |
| 97954 | 98187 | } |
| 97955 | 98188 | |
| 97956 | 98189 | return 0; |
| 97957 | 98190 | } |
| 97958 | 98191 | |
| | @@ -98243,19 +98476,24 @@ |
| 98243 | 98476 | SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ |
| 98244 | 98477 | analysisInfo sInfo; |
| 98245 | 98478 | HashElem *i; |
| 98246 | 98479 | char *zSql; |
| 98247 | 98480 | int rc = SQLITE_OK; |
| 98481 | + Schema *pSchema = db->aDb[iDb].pSchema; |
| 98248 | 98482 | |
| 98249 | 98483 | assert( iDb>=0 && iDb<db->nDb ); |
| 98250 | 98484 | assert( db->aDb[iDb].pBt!=0 ); |
| 98251 | 98485 | |
| 98252 | 98486 | /* Clear any prior statistics */ |
| 98253 | 98487 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 98254 | | - for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ |
| 98488 | + for(i=sqliteHashFirst(&pSchema->tblHash); i; i=sqliteHashNext(i)){ |
| 98489 | + Table *pTab = sqliteHashData(i); |
| 98490 | + pTab->tabFlags &= ~TF_HasStat1; |
| 98491 | + } |
| 98492 | + for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){ |
| 98255 | 98493 | Index *pIdx = sqliteHashData(i); |
| 98256 | | - pIdx->aiRowLogEst[0] = 0; |
| 98494 | + pIdx->hasStat1 = 0; |
| 98257 | 98495 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 98258 | 98496 | sqlite3DeleteIndexSamples(db, pIdx); |
| 98259 | 98497 | pIdx->aSample = 0; |
| 98260 | 98498 | #endif |
| 98261 | 98499 | } |
| | @@ -98274,23 +98512,23 @@ |
| 98274 | 98512 | } |
| 98275 | 98513 | } |
| 98276 | 98514 | |
| 98277 | 98515 | /* Set appropriate defaults on all indexes not in the sqlite_stat1 table */ |
| 98278 | 98516 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 98279 | | - for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ |
| 98517 | + for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){ |
| 98280 | 98518 | Index *pIdx = sqliteHashData(i); |
| 98281 | | - if( pIdx->aiRowLogEst[0]==0 ) sqlite3DefaultRowEst(pIdx); |
| 98519 | + if( !pIdx->hasStat1 ) sqlite3DefaultRowEst(pIdx); |
| 98282 | 98520 | } |
| 98283 | 98521 | |
| 98284 | 98522 | /* Load the statistics from the sqlite_stat4 table. */ |
| 98285 | 98523 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 98286 | 98524 | if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){ |
| 98287 | 98525 | db->lookaside.bDisable++; |
| 98288 | 98526 | rc = loadStat4(db, sInfo.zDatabase); |
| 98289 | 98527 | db->lookaside.bDisable--; |
| 98290 | 98528 | } |
| 98291 | | - for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ |
| 98529 | + for(i=sqliteHashFirst(&pSchema->idxHash); i; i=sqliteHashNext(i)){ |
| 98292 | 98530 | Index *pIdx = sqliteHashData(i); |
| 98293 | 98531 | sqlite3_free(pIdx->aiRowEst); |
| 98294 | 98532 | pIdx->aiRowEst = 0; |
| 98295 | 98533 | } |
| 98296 | 98534 | #endif |
| | @@ -100271,10 +100509,11 @@ |
| 100271 | 100509 | SQLITE_PRIVATE void sqlite3AddNotNull(Parse *pParse, int onError){ |
| 100272 | 100510 | Table *p; |
| 100273 | 100511 | p = pParse->pNewTable; |
| 100274 | 100512 | if( p==0 || NEVER(p->nCol<1) ) return; |
| 100275 | 100513 | p->aCol[p->nCol-1].notNull = (u8)onError; |
| 100514 | + p->tabFlags |= TF_HasNotNull; |
| 100276 | 100515 | } |
| 100277 | 100516 | |
| 100278 | 100517 | /* |
| 100279 | 100518 | ** Scan the column type name zType (length nType) and return the |
| 100280 | 100519 | ** associated affinity type. |
| | @@ -102609,10 +102848,13 @@ |
| 102609 | 102848 | /* 10, 9, 8, 7, 6 */ |
| 102610 | 102849 | LogEst aVal[] = { 33, 32, 30, 28, 26 }; |
| 102611 | 102850 | LogEst *a = pIdx->aiRowLogEst; |
| 102612 | 102851 | int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol); |
| 102613 | 102852 | int i; |
| 102853 | + |
| 102854 | + /* Indexes with default row estimates should not have stat1 data */ |
| 102855 | + assert( !pIdx->hasStat1 ); |
| 102614 | 102856 | |
| 102615 | 102857 | /* Set the first entry (number of rows in the index) to the estimated |
| 102616 | 102858 | ** number of rows in the table, or half the number of rows in the table |
| 102617 | 102859 | ** for a partial index. But do not let the estimate drop below 10. */ |
| 102618 | 102860 | a[0] = pIdx->pTable->nRowLogEst; |
| | @@ -109798,10 +110040,13 @@ |
| 109798 | 110040 | VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName)); |
| 109799 | 110041 | } |
| 109800 | 110042 | } |
| 109801 | 110043 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]); |
| 109802 | 110044 | VdbeComment((v, "for %s", pIdx->zName)); |
| 110045 | +#ifdef SQLITE_ENABLE_NULL_TRIM |
| 110046 | + if( pIdx->idxType==2 ) sqlite3SetMakeRecordP5(v, pIdx->pTable); |
| 110047 | +#endif |
| 109803 | 110048 | |
| 109804 | 110049 | /* In an UPDATE operation, if this index is the PRIMARY KEY index |
| 109805 | 110050 | ** of a WITHOUT ROWID table and there has been no change the |
| 109806 | 110051 | ** primary key, then no collision is possible. The collision detection |
| 109807 | 110052 | ** logic below can all be skipped. */ |
| | @@ -109953,12 +110198,15 @@ |
| 109953 | 110198 | |
| 109954 | 110199 | /* Records with omitted columns are only allowed for schema format |
| 109955 | 110200 | ** version 2 and later (SQLite version 3.1.4, 2005-02-20). */ |
| 109956 | 110201 | if( pTab->pSchema->file_format<2 ) return; |
| 109957 | 110202 | |
| 109958 | | - for(i=pTab->nCol; i>1 && pTab->aCol[i-1].pDflt==0; i--){} |
| 109959 | | - sqlite3VdbeChangeP5(v, i); |
| 110203 | + for(i=pTab->nCol-1; i>0; i--){ |
| 110204 | + if( pTab->aCol[i].pDflt!=0 ) break; |
| 110205 | + if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break; |
| 110206 | + } |
| 110207 | + sqlite3VdbeChangeP5(v, i+1); |
| 109960 | 110208 | } |
| 109961 | 110209 | #endif |
| 109962 | 110210 | |
| 109963 | 110211 | /* |
| 109964 | 110212 | ** This routine generates code to finish the INSERT or UPDATE operation |
| | @@ -110244,11 +110492,11 @@ |
| 110244 | 110492 | } |
| 110245 | 110493 | if( sqlite3TriggerList(pParse, pDest) ){ |
| 110246 | 110494 | return 0; /* tab1 must not have triggers */ |
| 110247 | 110495 | } |
| 110248 | 110496 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 110249 | | - if( pDest->tabFlags & TF_Virtual ){ |
| 110497 | + if( IsVirtual(pDest) ){ |
| 110250 | 110498 | return 0; /* tab1 must not be a virtual table */ |
| 110251 | 110499 | } |
| 110252 | 110500 | #endif |
| 110253 | 110501 | if( onError==OE_Default ){ |
| 110254 | 110502 | if( pDest->iPKey>=0 ) onError = pDest->keyConf; |
| | @@ -110306,11 +110554,11 @@ |
| 110306 | 110554 | } |
| 110307 | 110555 | if( HasRowid(pDest)!=HasRowid(pSrc) ){ |
| 110308 | 110556 | return 0; /* source and destination must both be WITHOUT ROWID or not */ |
| 110309 | 110557 | } |
| 110310 | 110558 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 110311 | | - if( pSrc->tabFlags & TF_Virtual ){ |
| 110559 | + if( IsVirtual(pSrc) ){ |
| 110312 | 110560 | return 0; /* tab2 must not be a virtual table */ |
| 110313 | 110561 | } |
| 110314 | 110562 | #endif |
| 110315 | 110563 | if( pSrc->pSelect ){ |
| 110316 | 110564 | return 0; /* tab2 may not be a view */ |
| | @@ -110603,11 +110851,11 @@ |
| 110603 | 110851 | /* Invoke the callback function if required */ |
| 110604 | 110852 | if( xCallback && (SQLITE_ROW==rc || |
| 110605 | 110853 | (SQLITE_DONE==rc && !callbackIsInit |
| 110606 | 110854 | && db->flags&SQLITE_NullCallback)) ){ |
| 110607 | 110855 | if( !callbackIsInit ){ |
| 110608 | | - azCols = sqlite3DbMallocZero(db, 2*nCol*sizeof(const char*) + 1); |
| 110856 | + azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*)); |
| 110609 | 110857 | if( azCols==0 ){ |
| 110610 | 110858 | goto exec_out; |
| 110611 | 110859 | } |
| 110612 | 110860 | for(i=0; i<nCol; i++){ |
| 110613 | 110861 | azCols[i] = (char *)sqlite3_column_name(pStmt, i); |
| | @@ -110624,10 +110872,11 @@ |
| 110624 | 110872 | if( !azVals[i] && sqlite3_column_type(pStmt, i)!=SQLITE_NULL ){ |
| 110625 | 110873 | sqlite3OomFault(db); |
| 110626 | 110874 | goto exec_out; |
| 110627 | 110875 | } |
| 110628 | 110876 | } |
| 110877 | + azVals[i] = 0; |
| 110629 | 110878 | } |
| 110630 | 110879 | if( xCallback(pArg, nCol, azVals, azCols) ){ |
| 110631 | 110880 | /* EVIDENCE-OF: R-38229-40159 If the callback function to |
| 110632 | 110881 | ** sqlite3_exec() returns non-zero, then sqlite3_exec() will |
| 110633 | 110882 | ** return SQLITE_ABORT. */ |
| | @@ -112094,15 +112343,15 @@ |
| 112094 | 112343 | #define PragTyp_JOURNAL_SIZE_LIMIT 20 |
| 112095 | 112344 | #define PragTyp_LOCK_PROXY_FILE 21 |
| 112096 | 112345 | #define PragTyp_LOCKING_MODE 22 |
| 112097 | 112346 | #define PragTyp_PAGE_COUNT 23 |
| 112098 | 112347 | #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 |
| 112348 | +#define PragTyp_OPTIMIZE 25 |
| 112349 | +#define PragTyp_PAGE_SIZE 26 |
| 112350 | +#define PragTyp_SECURE_DELETE 27 |
| 112351 | +#define PragTyp_SHRINK_MEMORY 28 |
| 112352 | +#define PragTyp_SOFT_HEAP_LIMIT 29 |
| 112104 | 112353 | #define PragTyp_SYNCHRONOUS 30 |
| 112105 | 112354 | #define PragTyp_TABLE_INFO 31 |
| 112106 | 112355 | #define PragTyp_TEMP_STORE 32 |
| 112107 | 112356 | #define PragTyp_TEMP_STORE_DIRECTORY 33 |
| 112108 | 112357 | #define PragTyp_THREADS 34 |
| | @@ -112112,10 +112361,11 @@ |
| 112112 | 112361 | #define PragTyp_HEXKEY 38 |
| 112113 | 112362 | #define PragTyp_KEY 39 |
| 112114 | 112363 | #define PragTyp_REKEY 40 |
| 112115 | 112364 | #define PragTyp_LOCK_STATUS 41 |
| 112116 | 112365 | #define PragTyp_PARSER_TRACE 42 |
| 112366 | +#define PragTyp_STATS 43 |
| 112117 | 112367 | |
| 112118 | 112368 | /* Property flags associated with various pragma. */ |
| 112119 | 112369 | #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ |
| 112120 | 112370 | #define PragFlg_NoColumns 0x02 /* OP_ResultRow called with zero columns */ |
| 112121 | 112371 | #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */ |
| | @@ -112135,51 +112385,52 @@ |
| 112135 | 112385 | /* 2 */ "name", |
| 112136 | 112386 | /* 3 */ "type", |
| 112137 | 112387 | /* 4 */ "notnull", |
| 112138 | 112388 | /* 5 */ "dflt_value", |
| 112139 | 112389 | /* 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", |
| 112390 | + /* 7 */ "tbl", /* Used by: stats */ |
| 112391 | + /* 8 */ "idx", |
| 112392 | + /* 9 */ "wdth", |
| 112393 | + /* 10 */ "hght", |
| 112394 | + /* 11 */ "flgs", |
| 112395 | + /* 12 */ "seqno", /* Used by: index_info */ |
| 112396 | + /* 13 */ "cid", |
| 112397 | + /* 14 */ "name", |
| 112398 | + /* 15 */ "seqno", /* Used by: index_xinfo */ |
| 112399 | + /* 16 */ "cid", |
| 112400 | + /* 17 */ "name", |
| 112401 | + /* 18 */ "desc", |
| 112402 | + /* 19 */ "coll", |
| 112403 | + /* 20 */ "key", |
| 112404 | + /* 21 */ "seq", /* Used by: index_list */ |
| 112405 | + /* 22 */ "name", |
| 112406 | + /* 23 */ "unique", |
| 112407 | + /* 24 */ "origin", |
| 112408 | + /* 25 */ "partial", |
| 112409 | + /* 26 */ "seq", /* Used by: database_list */ |
| 112410 | + /* 27 */ "name", |
| 112411 | + /* 28 */ "file", |
| 112412 | + /* 29 */ "seq", /* Used by: collation_list */ |
| 112413 | + /* 30 */ "name", |
| 112414 | + /* 31 */ "id", /* Used by: foreign_key_list */ |
| 112415 | + /* 32 */ "seq", |
| 112416 | + /* 33 */ "table", |
| 112417 | + /* 34 */ "from", |
| 112418 | + /* 35 */ "to", |
| 112419 | + /* 36 */ "on_update", |
| 112420 | + /* 37 */ "on_delete", |
| 112421 | + /* 38 */ "match", |
| 112422 | + /* 39 */ "table", /* Used by: foreign_key_check */ |
| 112423 | + /* 40 */ "rowid", |
| 112424 | + /* 41 */ "parent", |
| 112425 | + /* 42 */ "fkid", |
| 112426 | + /* 43 */ "busy", /* Used by: wal_checkpoint */ |
| 112427 | + /* 44 */ "log", |
| 112428 | + /* 45 */ "checkpointed", |
| 112429 | + /* 46 */ "timeout", /* Used by: busy_timeout */ |
| 112430 | + /* 47 */ "database", /* Used by: lock_status */ |
| 112431 | + /* 48 */ "status", |
| 112181 | 112432 | }; |
| 112182 | 112433 | |
| 112183 | 112434 | /* Definitions of all built-in pragmas */ |
| 112184 | 112435 | typedef struct PragmaName { |
| 112185 | 112436 | const char *const zName; /* Name of pragma */ |
| | @@ -112221,11 +112472,11 @@ |
| 112221 | 112472 | #endif |
| 112222 | 112473 | #endif |
| 112223 | 112474 | {/* zName: */ "busy_timeout", |
| 112224 | 112475 | /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, |
| 112225 | 112476 | /* ePragFlg: */ PragFlg_Result0, |
| 112226 | | - /* ColNames: */ 45, 1, |
| 112477 | + /* ColNames: */ 46, 1, |
| 112227 | 112478 | /* iArg: */ 0 }, |
| 112228 | 112479 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 112229 | 112480 | {/* zName: */ "cache_size", |
| 112230 | 112481 | /* ePragTyp: */ PragTyp_CACHE_SIZE, |
| 112231 | 112482 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, |
| | @@ -112258,11 +112509,11 @@ |
| 112258 | 112509 | #endif |
| 112259 | 112510 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 112260 | 112511 | {/* zName: */ "collation_list", |
| 112261 | 112512 | /* ePragTyp: */ PragTyp_COLLATION_LIST, |
| 112262 | 112513 | /* ePragFlg: */ PragFlg_Result0, |
| 112263 | | - /* ColNames: */ 28, 2, |
| 112514 | + /* ColNames: */ 29, 2, |
| 112264 | 112515 | /* iArg: */ 0 }, |
| 112265 | 112516 | #endif |
| 112266 | 112517 | #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) |
| 112267 | 112518 | {/* zName: */ "compile_options", |
| 112268 | 112519 | /* ePragTyp: */ PragTyp_COMPILE_OPTIONS, |
| | @@ -112293,11 +112544,11 @@ |
| 112293 | 112544 | #endif |
| 112294 | 112545 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 112295 | 112546 | {/* zName: */ "database_list", |
| 112296 | 112547 | /* ePragTyp: */ PragTyp_DATABASE_LIST, |
| 112297 | 112548 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, |
| 112298 | | - /* ColNames: */ 25, 3, |
| 112549 | + /* ColNames: */ 26, 3, |
| 112299 | 112550 | /* iArg: */ 0 }, |
| 112300 | 112551 | #endif |
| 112301 | 112552 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) |
| 112302 | 112553 | {/* zName: */ "default_cache_size", |
| 112303 | 112554 | /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE, |
| | @@ -112330,18 +112581,18 @@ |
| 112330 | 112581 | #endif |
| 112331 | 112582 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
| 112332 | 112583 | {/* zName: */ "foreign_key_check", |
| 112333 | 112584 | /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, |
| 112334 | 112585 | /* ePragFlg: */ PragFlg_NeedSchema, |
| 112335 | | - /* ColNames: */ 38, 4, |
| 112586 | + /* ColNames: */ 39, 4, |
| 112336 | 112587 | /* iArg: */ 0 }, |
| 112337 | 112588 | #endif |
| 112338 | 112589 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) |
| 112339 | 112590 | {/* zName: */ "foreign_key_list", |
| 112340 | 112591 | /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST, |
| 112341 | 112592 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 112342 | | - /* ColNames: */ 30, 8, |
| 112593 | + /* ColNames: */ 31, 8, |
| 112343 | 112594 | /* iArg: */ 0 }, |
| 112344 | 112595 | #endif |
| 112345 | 112596 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 112346 | 112597 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
| 112347 | 112598 | {/* zName: */ "foreign_keys", |
| | @@ -112400,21 +112651,21 @@ |
| 112400 | 112651 | #endif |
| 112401 | 112652 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 112402 | 112653 | {/* zName: */ "index_info", |
| 112403 | 112654 | /* ePragTyp: */ PragTyp_INDEX_INFO, |
| 112404 | 112655 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 112405 | | - /* ColNames: */ 11, 3, |
| 112656 | + /* ColNames: */ 12, 3, |
| 112406 | 112657 | /* iArg: */ 0 }, |
| 112407 | 112658 | {/* zName: */ "index_list", |
| 112408 | 112659 | /* ePragTyp: */ PragTyp_INDEX_LIST, |
| 112409 | 112660 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 112410 | | - /* ColNames: */ 20, 5, |
| 112661 | + /* ColNames: */ 21, 5, |
| 112411 | 112662 | /* iArg: */ 0 }, |
| 112412 | 112663 | {/* zName: */ "index_xinfo", |
| 112413 | 112664 | /* ePragTyp: */ PragTyp_INDEX_INFO, |
| 112414 | 112665 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 112415 | | - /* ColNames: */ 14, 6, |
| 112666 | + /* ColNames: */ 15, 6, |
| 112416 | 112667 | /* iArg: */ 1 }, |
| 112417 | 112668 | #endif |
| 112418 | 112669 | #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) |
| 112419 | 112670 | {/* zName: */ "integrity_check", |
| 112420 | 112671 | /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, |
| | @@ -112457,11 +112708,11 @@ |
| 112457 | 112708 | #endif |
| 112458 | 112709 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
| 112459 | 112710 | {/* zName: */ "lock_status", |
| 112460 | 112711 | /* ePragTyp: */ PragTyp_LOCK_STATUS, |
| 112461 | 112712 | /* ePragFlg: */ PragFlg_Result0, |
| 112462 | | - /* ColNames: */ 46, 2, |
| 112713 | + /* ColNames: */ 47, 2, |
| 112463 | 112714 | /* iArg: */ 0 }, |
| 112464 | 112715 | #endif |
| 112465 | 112716 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 112466 | 112717 | {/* zName: */ "locking_mode", |
| 112467 | 112718 | /* ePragTyp: */ PragTyp_LOCKING_MODE, |
| | @@ -112476,10 +112727,17 @@ |
| 112476 | 112727 | {/* zName: */ "mmap_size", |
| 112477 | 112728 | /* ePragTyp: */ PragTyp_MMAP_SIZE, |
| 112478 | 112729 | /* ePragFlg: */ 0, |
| 112479 | 112730 | /* ColNames: */ 0, 0, |
| 112480 | 112731 | /* iArg: */ 0 }, |
| 112732 | +#endif |
| 112733 | + {/* zName: */ "optimize", |
| 112734 | + /* ePragTyp: */ PragTyp_OPTIMIZE, |
| 112735 | + /* ePragFlg: */ PragFlg_Result1, |
| 112736 | + /* ColNames: */ 0, 0, |
| 112737 | + /* iArg: */ 0 }, |
| 112738 | +#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 112481 | 112739 | {/* zName: */ "page_count", |
| 112482 | 112740 | /* ePragTyp: */ PragTyp_PAGE_COUNT, |
| 112483 | 112741 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq, |
| 112484 | 112742 | /* ColNames: */ 0, 0, |
| 112485 | 112743 | /* iArg: */ 0 }, |
| | @@ -112574,15 +112832,15 @@ |
| 112574 | 112832 | /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, |
| 112575 | 112833 | /* ColNames: */ 0, 0, |
| 112576 | 112834 | /* iArg: */ SQLITE_SqlTrace }, |
| 112577 | 112835 | #endif |
| 112578 | 112836 | #endif |
| 112579 | | -#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 112837 | +#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) && defined(SQLITE_DEBUG) |
| 112580 | 112838 | {/* zName: */ "stats", |
| 112581 | 112839 | /* ePragTyp: */ PragTyp_STATS, |
| 112582 | 112840 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq, |
| 112583 | | - /* ColNames: */ 7, 4, |
| 112841 | + /* ColNames: */ 7, 5, |
| 112584 | 112842 | /* iArg: */ 0 }, |
| 112585 | 112843 | #endif |
| 112586 | 112844 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 112587 | 112845 | {/* zName: */ "synchronous", |
| 112588 | 112846 | /* ePragTyp: */ PragTyp_SYNCHRONOUS, |
| | @@ -112657,11 +112915,11 @@ |
| 112657 | 112915 | /* ColNames: */ 0, 0, |
| 112658 | 112916 | /* iArg: */ 0 }, |
| 112659 | 112917 | {/* zName: */ "wal_checkpoint", |
| 112660 | 112918 | /* ePragTyp: */ PragTyp_WAL_CHECKPOINT, |
| 112661 | 112919 | /* ePragFlg: */ PragFlg_NeedSchema, |
| 112662 | | - /* ColNames: */ 42, 3, |
| 112920 | + /* ColNames: */ 43, 3, |
| 112663 | 112921 | /* iArg: */ 0 }, |
| 112664 | 112922 | #endif |
| 112665 | 112923 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 112666 | 112924 | {/* zName: */ "writable_schema", |
| 112667 | 112925 | /* ePragTyp: */ PragTyp_FLAG, |
| | @@ -112668,11 +112926,11 @@ |
| 112668 | 112926 | /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1, |
| 112669 | 112927 | /* ColNames: */ 0, 0, |
| 112670 | 112928 | /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, |
| 112671 | 112929 | #endif |
| 112672 | 112930 | }; |
| 112673 | | -/* Number of pragmas: 60 on by default, 73 total. */ |
| 112931 | +/* Number of pragmas: 60 on by default, 74 total. */ |
| 112674 | 112932 | |
| 112675 | 112933 | /************** End of pragma.h **********************************************/ |
| 112676 | 112934 | /************** Continuing where we left off in pragma.c *********************/ |
| 112677 | 112935 | |
| 112678 | 112936 | /* |
| | @@ -112937,10 +113195,26 @@ |
| 112937 | 113195 | lwr = mid + 1; |
| 112938 | 113196 | } |
| 112939 | 113197 | } |
| 112940 | 113198 | return lwr>upr ? 0 : &aPragmaName[mid]; |
| 112941 | 113199 | } |
| 113200 | + |
| 113201 | +/* |
| 113202 | +** Helper subroutine for PRAGMA integrity_check: |
| 113203 | +** |
| 113204 | +** Generate code to output a single-column result row with the result |
| 113205 | +** held in register regResult. Decrement the result count and halt if |
| 113206 | +** the maximum number of result rows have been issued. |
| 113207 | +*/ |
| 113208 | +static int integrityCheckResultRow(Vdbe *v, int regResult){ |
| 113209 | + int addr; |
| 113210 | + sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 1); |
| 113211 | + addr = sqlite3VdbeAddOp3(v, OP_IfPos, 1, sqlite3VdbeCurrentAddr(v)+2, 1); |
| 113212 | + VdbeCoverage(v); |
| 113213 | + sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 113214 | + return addr; |
| 113215 | +} |
| 112942 | 113216 | |
| 112943 | 113217 | /* |
| 112944 | 113218 | ** Process a pragma statement. |
| 112945 | 113219 | ** |
| 112946 | 113220 | ** Pragmas are of this form: |
| | @@ -113741,33 +114015,37 @@ |
| 113741 | 114015 | } |
| 113742 | 114016 | } |
| 113743 | 114017 | } |
| 113744 | 114018 | break; |
| 113745 | 114019 | |
| 114020 | +#ifdef SQLITE_DEBUG |
| 113746 | 114021 | case PragTyp_STATS: { |
| 113747 | 114022 | Index *pIdx; |
| 113748 | 114023 | HashElem *i; |
| 113749 | | - pParse->nMem = 4; |
| 114024 | + pParse->nMem = 5; |
| 113750 | 114025 | sqlite3CodeVerifySchema(pParse, iDb); |
| 113751 | 114026 | for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){ |
| 113752 | 114027 | Table *pTab = sqliteHashData(i); |
| 113753 | | - sqlite3VdbeMultiLoad(v, 1, "ssii", |
| 114028 | + sqlite3VdbeMultiLoad(v, 1, "ssiii", |
| 113754 | 114029 | pTab->zName, |
| 113755 | 114030 | 0, |
| 113756 | 114031 | pTab->szTabRow, |
| 113757 | | - pTab->nRowLogEst); |
| 113758 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); |
| 114032 | + pTab->nRowLogEst, |
| 114033 | + pTab->tabFlags); |
| 114034 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5); |
| 113759 | 114035 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 113760 | | - sqlite3VdbeMultiLoad(v, 2, "sii", |
| 114036 | + sqlite3VdbeMultiLoad(v, 2, "siii", |
| 113761 | 114037 | pIdx->zName, |
| 113762 | 114038 | pIdx->szIdxRow, |
| 113763 | | - pIdx->aiRowLogEst[0]); |
| 113764 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); |
| 114039 | + pIdx->aiRowLogEst[0], |
| 114040 | + pIdx->hasStat1); |
| 114041 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5); |
| 113765 | 114042 | } |
| 113766 | 114043 | } |
| 113767 | 114044 | } |
| 113768 | 114045 | break; |
| 114046 | +#endif |
| 113769 | 114047 | |
| 113770 | 114048 | case PragTyp_INDEX_INFO: if( zRight ){ |
| 113771 | 114049 | Index *pIdx; |
| 113772 | 114050 | Table *pTab; |
| 113773 | 114051 | pIdx = sqlite3FindIndex(db, zRight, zDb); |
| | @@ -114020,13 +114298,21 @@ |
| 114020 | 114298 | #ifndef SQLITE_INTEGRITY_CHECK_ERROR_MAX |
| 114021 | 114299 | # define SQLITE_INTEGRITY_CHECK_ERROR_MAX 100 |
| 114022 | 114300 | #endif |
| 114023 | 114301 | |
| 114024 | 114302 | #ifndef SQLITE_OMIT_INTEGRITY_CHECK |
| 114025 | | - /* Pragma "quick_check" is reduced version of |
| 114303 | + /* PRAGMA integrity_check |
| 114304 | + ** PRAGMA integrity_check(N) |
| 114305 | + ** PRAGMA quick_check |
| 114306 | + ** PRAGMA quick_check(N) |
| 114307 | + ** |
| 114308 | + ** Verify the integrity of the database. |
| 114309 | + ** |
| 114310 | + ** The "quick_check" is reduced version of |
| 114026 | 114311 | ** integrity_check designed to detect most database corruption |
| 114027 | | - ** without most of the overhead of a full integrity-check. |
| 114312 | + ** without the overhead of cross-checking indexes. Quick_check |
| 114313 | + ** is linear time wherease integrity_check is O(NlogN). |
| 114028 | 114314 | */ |
| 114029 | 114315 | case PragTyp_INTEGRITY_CHECK: { |
| 114030 | 114316 | int i, j, addr, mxErr; |
| 114031 | 114317 | |
| 114032 | 114318 | int isQuick = (sqlite3Tolower(zLeft[0])=='q'); |
| | @@ -114053,11 +114339,11 @@ |
| 114053 | 114339 | sqlite3GetInt32(zRight, &mxErr); |
| 114054 | 114340 | if( mxErr<=0 ){ |
| 114055 | 114341 | mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; |
| 114056 | 114342 | } |
| 114057 | 114343 | } |
| 114058 | | - sqlite3VdbeAddOp2(v, OP_Integer, mxErr, 1); /* reg[1] holds errors left */ |
| 114344 | + sqlite3VdbeAddOp2(v, OP_Integer, mxErr-1, 1); /* reg[1] holds errors left */ |
| 114059 | 114345 | |
| 114060 | 114346 | /* Do an integrity check on each database file */ |
| 114061 | 114347 | for(i=0; i<db->nDb; i++){ |
| 114062 | 114348 | HashElem *x; |
| 114063 | 114349 | Hash *pTbls; |
| | @@ -114068,14 +114354,10 @@ |
| 114068 | 114354 | |
| 114069 | 114355 | if( OMIT_TEMPDB && i==1 ) continue; |
| 114070 | 114356 | if( iDb>=0 && i!=iDb ) continue; |
| 114071 | 114357 | |
| 114072 | 114358 | 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 | 114359 | |
| 114078 | 114360 | /* Do an integrity check of the B-Tree |
| 114079 | 114361 | ** |
| 114080 | 114362 | ** Begin by finding the root pages numbers |
| 114081 | 114363 | ** for all tables and indices in the database. |
| | @@ -114111,29 +114393,30 @@ |
| 114111 | 114393 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, |
| 114112 | 114394 | sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName), |
| 114113 | 114395 | P4_DYNAMIC); |
| 114114 | 114396 | sqlite3VdbeAddOp3(v, OP_Move, 2, 4, 1); |
| 114115 | 114397 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 2); |
| 114116 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 2, 1); |
| 114398 | + integrityCheckResultRow(v, 2); |
| 114117 | 114399 | sqlite3VdbeJumpHere(v, addr); |
| 114118 | 114400 | |
| 114119 | 114401 | /* Make sure all the indices are constructed correctly. |
| 114120 | 114402 | */ |
| 114121 | | - for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){ |
| 114403 | + for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ |
| 114122 | 114404 | Table *pTab = sqliteHashData(x); |
| 114123 | 114405 | Index *pIdx, *pPk; |
| 114124 | 114406 | Index *pPrior = 0; |
| 114125 | 114407 | int loopTop; |
| 114126 | 114408 | int iDataCur, iIdxCur; |
| 114127 | 114409 | int r1 = -1; |
| 114128 | 114410 | |
| 114129 | | - if( pTab->pIndex==0 ) continue; |
| 114411 | + if( pTab->pCheck==0 |
| 114412 | + && (pTab->tabFlags & TF_HasNotNull)==0 |
| 114413 | + && (pTab->pIndex==0 || isQuick) |
| 114414 | + ){ |
| 114415 | + continue; /* No additional checks needed for this table */ |
| 114416 | + } |
| 114130 | 114417 | 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 | 114418 | sqlite3ExprCacheClear(pParse); |
| 114136 | 114419 | sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0, |
| 114137 | 114420 | 1, 0, &iDataCur, &iIdxCur); |
| 114138 | 114421 | sqlite3VdbeAddOp2(v, OP_Integer, 0, 7); |
| 114139 | 114422 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| | @@ -114144,28 +114427,46 @@ |
| 114144 | 114427 | sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); VdbeCoverage(v); |
| 114145 | 114428 | loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1); |
| 114146 | 114429 | /* Verify that all NOT NULL columns really are NOT NULL */ |
| 114147 | 114430 | for(j=0; j<pTab->nCol; j++){ |
| 114148 | 114431 | char *zErr; |
| 114149 | | - int jmp2, jmp3; |
| 114432 | + int jmp2; |
| 114150 | 114433 | if( j==pTab->iPKey ) continue; |
| 114151 | 114434 | if( pTab->aCol[j].notNull==0 ) continue; |
| 114152 | 114435 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); |
| 114153 | 114436 | sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); |
| 114154 | 114437 | jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); |
| 114155 | | - sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */ |
| 114156 | 114438 | zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, |
| 114157 | 114439 | pTab->aCol[j].zName); |
| 114158 | 114440 | 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); |
| 114441 | + integrityCheckResultRow(v, 3); |
| 114162 | 114442 | sqlite3VdbeJumpHere(v, jmp2); |
| 114163 | | - sqlite3VdbeJumpHere(v, jmp3); |
| 114443 | + } |
| 114444 | + /* Verify CHECK constraints */ |
| 114445 | + if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 114446 | + int addrCkFault = sqlite3VdbeMakeLabel(v); |
| 114447 | + int addrCkOk = sqlite3VdbeMakeLabel(v); |
| 114448 | + ExprList *pCheck = pTab->pCheck; |
| 114449 | + char *zErr; |
| 114450 | + int k; |
| 114451 | + pParse->iSelfTab = iDataCur; |
| 114452 | + sqlite3ExprCachePush(pParse); |
| 114453 | + for(k=pCheck->nExpr-1; k>0; k--){ |
| 114454 | + sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0); |
| 114455 | + } |
| 114456 | + sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, |
| 114457 | + SQLITE_JUMPIFNULL); |
| 114458 | + sqlite3VdbeResolveLabel(v, addrCkFault); |
| 114459 | + zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s", |
| 114460 | + pTab->zName); |
| 114461 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 114462 | + integrityCheckResultRow(v, 3); |
| 114463 | + sqlite3VdbeResolveLabel(v, addrCkOk); |
| 114464 | + sqlite3ExprCachePop(pParse); |
| 114164 | 114465 | } |
| 114165 | 114466 | /* Validate index entries for the current row */ |
| 114166 | | - for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 114467 | + for(j=0, pIdx=pTab->pIndex; pIdx && !isQuick; pIdx=pIdx->pNext, j++){ |
| 114167 | 114468 | int jmp2, jmp3, jmp4, jmp5; |
| 114168 | 114469 | int ckUniq = sqlite3VdbeMakeLabel(v); |
| 114169 | 114470 | if( pPk==pIdx ) continue; |
| 114170 | 114471 | r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3, |
| 114171 | 114472 | pPrior, r1); |
| | @@ -114172,20 +114473,17 @@ |
| 114172 | 114473 | pPrior = pIdx; |
| 114173 | 114474 | sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */ |
| 114174 | 114475 | /* Verify that an index entry exists for the current table row */ |
| 114175 | 114476 | jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1, |
| 114176 | 114477 | pIdx->nColumn); VdbeCoverage(v); |
| 114177 | | - sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */ |
| 114178 | 114478 | sqlite3VdbeLoadString(v, 3, "row "); |
| 114179 | 114479 | sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); |
| 114180 | 114480 | sqlite3VdbeLoadString(v, 4, " missing from index "); |
| 114181 | 114481 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 114182 | 114482 | jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName); |
| 114183 | 114483 | 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); |
| 114484 | + jmp4 = integrityCheckResultRow(v, 3); |
| 114187 | 114485 | sqlite3VdbeJumpHere(v, jmp2); |
| 114188 | 114486 | /* For UNIQUE indexes, verify that only one entry exists with the |
| 114189 | 114487 | ** current key. The entry is unique if (1) any column is NULL |
| 114190 | 114488 | ** or (2) the next entry has a different key */ |
| 114191 | 114489 | if( IsUniqueIndex(pIdx) ){ |
| | @@ -114202,11 +114500,10 @@ |
| 114202 | 114500 | jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v); |
| 114203 | 114501 | sqlite3VdbeGoto(v, uniqOk); |
| 114204 | 114502 | sqlite3VdbeJumpHere(v, jmp6); |
| 114205 | 114503 | sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1, |
| 114206 | 114504 | pIdx->nKeyCol); VdbeCoverage(v); |
| 114207 | | - sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */ |
| 114208 | 114505 | sqlite3VdbeLoadString(v, 3, "non-unique entry in index "); |
| 114209 | 114506 | sqlite3VdbeGoto(v, jmp5); |
| 114210 | 114507 | sqlite3VdbeResolveLabel(v, uniqOk); |
| 114211 | 114508 | } |
| 114212 | 114509 | sqlite3VdbeJumpHere(v, jmp4); |
| | @@ -114213,40 +114510,39 @@ |
| 114213 | 114510 | sqlite3ResolvePartIdxLabel(pParse, jmp3); |
| 114214 | 114511 | } |
| 114215 | 114512 | sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v); |
| 114216 | 114513 | sqlite3VdbeJumpHere(v, loopTop-1); |
| 114217 | 114514 | #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); |
| 114515 | + if( !isQuick ){ |
| 114516 | + sqlite3VdbeLoadString(v, 2, "wrong # of entries in index "); |
| 114517 | + for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 114518 | + if( pPk==pIdx ) continue; |
| 114519 | + sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3); |
| 114520 | + addr = sqlite3VdbeAddOp3(v, OP_Eq, 8+j, 0, 3); VdbeCoverage(v); |
| 114521 | + sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); |
| 114522 | + sqlite3VdbeLoadString(v, 3, pIdx->zName); |
| 114523 | + sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7); |
| 114524 | + integrityCheckResultRow(v, 7); |
| 114525 | + sqlite3VdbeJumpHere(v, addr); |
| 114526 | + } |
| 114231 | 114527 | } |
| 114232 | 114528 | #endif /* SQLITE_OMIT_BTREECOUNT */ |
| 114233 | 114529 | } |
| 114234 | 114530 | } |
| 114235 | 114531 | { |
| 114236 | 114532 | static const int iLn = VDBE_OFFSET_LINENO(2); |
| 114237 | 114533 | static const VdbeOpList endCode[] = { |
| 114238 | 114534 | { OP_AddImm, 1, 0, 0}, /* 0 */ |
| 114239 | | - { OP_If, 1, 4, 0}, /* 1 */ |
| 114535 | + { OP_IfNotZero, 1, 4, 0}, /* 1 */ |
| 114240 | 114536 | { OP_String8, 0, 3, 0}, /* 2 */ |
| 114241 | 114537 | { OP_ResultRow, 3, 1, 0}, /* 3 */ |
| 114242 | 114538 | }; |
| 114243 | 114539 | VdbeOp *aOp; |
| 114244 | 114540 | |
| 114245 | 114541 | aOp = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode, iLn); |
| 114246 | 114542 | if( aOp ){ |
| 114247 | | - aOp[0].p2 = -mxErr; |
| 114543 | + aOp[0].p2 = 1-mxErr; |
| 114248 | 114544 | aOp[2].p4type = P4_STATIC; |
| 114249 | 114545 | aOp[2].p4.z = "ok"; |
| 114250 | 114546 | } |
| 114251 | 114547 | } |
| 114252 | 114548 | } |
| | @@ -114466,10 +114762,122 @@ |
| 114466 | 114762 | */ |
| 114467 | 114763 | case PragTyp_SHRINK_MEMORY: { |
| 114468 | 114764 | sqlite3_db_release_memory(db); |
| 114469 | 114765 | break; |
| 114470 | 114766 | } |
| 114767 | + |
| 114768 | + /* |
| 114769 | + ** PRAGMA optimize |
| 114770 | + ** PRAGMA optimize(MASK) |
| 114771 | + ** PRAGMA schema.optimize |
| 114772 | + ** PRAGMA schema.optimize(MASK) |
| 114773 | + ** |
| 114774 | + ** Attempt to optimize the database. All schemas are optimized in the first |
| 114775 | + ** two forms, and only the specified schema is optimized in the latter two. |
| 114776 | + ** |
| 114777 | + ** The details of optimizations performed by this pragma are expected |
| 114778 | + ** to change and improve over time. Applications should anticipate that |
| 114779 | + ** this pragma will perform new optimizations in future releases. |
| 114780 | + ** |
| 114781 | + ** The optional argument is a bitmask of optimizations to perform: |
| 114782 | + ** |
| 114783 | + ** 0x0001 Debugging mode. Do not actually perform any optimizations |
| 114784 | + ** but instead return one line of text for each optimization |
| 114785 | + ** that would have been done. Off by default. |
| 114786 | + ** |
| 114787 | + ** 0x0002 Run ANALYZE on tables that might benefit. On by default. |
| 114788 | + ** See below for additional information. |
| 114789 | + ** |
| 114790 | + ** 0x0004 (Not yet implemented) Record usage and performance |
| 114791 | + ** information from the current session in the |
| 114792 | + ** database file so that it will be available to "optimize" |
| 114793 | + ** pragmas run by future database connections. |
| 114794 | + ** |
| 114795 | + ** 0x0008 (Not yet implemented) Create indexes that might have |
| 114796 | + ** been helpful to recent queries |
| 114797 | + ** |
| 114798 | + ** The default MASK is and always shall be 0xfffe. 0xfffe means perform all ** of the optimizations listed above except Debug Mode, including new |
| 114799 | + ** optimizations that have not yet been invented. If new optimizations are |
| 114800 | + ** ever added that should be off by default, those off-by-default |
| 114801 | + ** optimizations will have bitmasks of 0x10000 or larger. |
| 114802 | + ** |
| 114803 | + ** DETERMINATION OF WHEN TO RUN ANALYZE |
| 114804 | + ** |
| 114805 | + ** In the current implementation, a table is analyzed if only if all of |
| 114806 | + ** the following are true: |
| 114807 | + ** |
| 114808 | + ** (1) MASK bit 0x02 is set. |
| 114809 | + ** |
| 114810 | + ** (2) The query planner used sqlite_stat1-style statistics for one or |
| 114811 | + ** more indexes of the table at some point during the lifetime of |
| 114812 | + ** the current connection. |
| 114813 | + ** |
| 114814 | + ** (3) One or more indexes of the table are currently unanalyzed OR |
| 114815 | + ** the number of rows in the table has increased by 25 times or more |
| 114816 | + ** since the last time ANALYZE was run. |
| 114817 | + ** |
| 114818 | + ** The rules for when tables are analyzed are likely to change in |
| 114819 | + ** future releases. |
| 114820 | + */ |
| 114821 | + case PragTyp_OPTIMIZE: { |
| 114822 | + int iDbLast; /* Loop termination point for the schema loop */ |
| 114823 | + int iTabCur; /* Cursor for a table whose size needs checking */ |
| 114824 | + HashElem *k; /* Loop over tables of a schema */ |
| 114825 | + Schema *pSchema; /* The current schema */ |
| 114826 | + Table *pTab; /* A table in the schema */ |
| 114827 | + Index *pIdx; /* An index of the table */ |
| 114828 | + LogEst szThreshold; /* Size threshold above which reanalysis is needd */ |
| 114829 | + char *zSubSql; /* SQL statement for the OP_SqlExec opcode */ |
| 114830 | + u32 opMask; /* Mask of operations to perform */ |
| 114831 | + |
| 114832 | + if( zRight ){ |
| 114833 | + opMask = (u32)sqlite3Atoi(zRight); |
| 114834 | + if( (opMask & 0x02)==0 ) break; |
| 114835 | + }else{ |
| 114836 | + opMask = 0xfffe; |
| 114837 | + } |
| 114838 | + iTabCur = pParse->nTab++; |
| 114839 | + for(iDbLast = zDb?iDb:db->nDb-1; iDb<=iDbLast; iDb++){ |
| 114840 | + if( iDb==1 ) continue; |
| 114841 | + sqlite3CodeVerifySchema(pParse, iDb); |
| 114842 | + pSchema = db->aDb[iDb].pSchema; |
| 114843 | + for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 114844 | + pTab = (Table*)sqliteHashData(k); |
| 114845 | + |
| 114846 | + /* If table pTab has not been used in a way that would benefit from |
| 114847 | + ** having analysis statistics during the current session, then skip it. |
| 114848 | + ** This also has the effect of skipping virtual tables and views */ |
| 114849 | + if( (pTab->tabFlags & TF_StatsUsed)==0 ) continue; |
| 114850 | + |
| 114851 | + /* Reanalyze if the table is 25 times larger than the last analysis */ |
| 114852 | + szThreshold = pTab->nRowLogEst + 46; assert( sqlite3LogEst(25)==46 ); |
| 114853 | + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 114854 | + if( !pIdx->hasStat1 ){ |
| 114855 | + szThreshold = 0; /* Always analyze if any index lacks statistics */ |
| 114856 | + break; |
| 114857 | + } |
| 114858 | + } |
| 114859 | + if( szThreshold ){ |
| 114860 | + sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); |
| 114861 | + sqlite3VdbeAddOp3(v, OP_IfSmaller, iTabCur, |
| 114862 | + sqlite3VdbeCurrentAddr(v)+2+(opMask&1), szThreshold); |
| 114863 | + VdbeCoverage(v); |
| 114864 | + } |
| 114865 | + zSubSql = sqlite3MPrintf(db, "ANALYZE \"%w\".\"%w\"", |
| 114866 | + db->aDb[iDb].zDbSName, pTab->zName); |
| 114867 | + if( opMask & 0x01 ){ |
| 114868 | + int r1 = sqlite3GetTempReg(pParse); |
| 114869 | + sqlite3VdbeAddOp4(v, OP_String8, 0, r1, 0, zSubSql, P4_DYNAMIC); |
| 114870 | + sqlite3VdbeAddOp2(v, OP_ResultRow, r1, 1); |
| 114871 | + }else{ |
| 114872 | + sqlite3VdbeAddOp4(v, OP_SqlExec, 0, 0, 0, zSubSql, P4_DYNAMIC); |
| 114873 | + } |
| 114874 | + } |
| 114875 | + } |
| 114876 | + sqlite3VdbeAddOp0(v, OP_Expire); |
| 114877 | + break; |
| 114878 | + } |
| 114471 | 114879 | |
| 114472 | 114880 | /* |
| 114473 | 114881 | ** PRAGMA busy_timeout |
| 114474 | 114882 | ** PRAGMA busy_timeout = N |
| 114475 | 114883 | ** |
| | @@ -123782,12 +124190,29 @@ |
| 123782 | 124190 | ** transient would cause the database file to appear to be deleted |
| 123783 | 124191 | ** following reboot. |
| 123784 | 124192 | */ |
| 123785 | 124193 | SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){ |
| 123786 | 124194 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 123787 | | - int iDb = pNm ? sqlite3TwoPartName(pParse, pNm, pNm, &pNm) : 0; |
| 123788 | | - if( v && (iDb>=2 || iDb==0) ){ |
| 124195 | + int iDb = 0; |
| 124196 | + if( v==0 ) return; |
| 124197 | + if( pNm ){ |
| 124198 | +#ifndef SQLITE_BUG_COMPATIBLE_20160819 |
| 124199 | + /* Default behavior: Report an error if the argument to VACUUM is |
| 124200 | + ** not recognized */ |
| 124201 | + iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm); |
| 124202 | + if( iDb<0 ) return; |
| 124203 | +#else |
| 124204 | + /* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments |
| 124205 | + ** to VACUUM are silently ignored. This is a back-out of a bug fix that |
| 124206 | + ** occurred on 2016-08-19 (https://www.sqlite.org/src/info/083f9e6270). |
| 124207 | + ** The buggy behavior is required for binary compatibility with some |
| 124208 | + ** legacy applications. */ |
| 124209 | + iDb = sqlite3FindDb(pParse->db, pNm); |
| 124210 | + if( iDb<0 ) iDb = 0; |
| 124211 | +#endif |
| 124212 | + } |
| 124213 | + if( iDb!=1 ){ |
| 123789 | 124214 | sqlite3VdbeAddOp1(v, OP_Vacuum, iDb); |
| 123790 | 124215 | sqlite3VdbeUsesBtree(v, iDb); |
| 123791 | 124216 | } |
| 123792 | 124217 | return; |
| 123793 | 124218 | } |
| | @@ -124377,12 +124802,11 @@ |
| 124377 | 124802 | |
| 124378 | 124803 | db = pParse->db; |
| 124379 | 124804 | iDb = sqlite3SchemaToIndex(db, pTable->pSchema); |
| 124380 | 124805 | assert( iDb>=0 ); |
| 124381 | 124806 | |
| 124382 | | - pTable->tabFlags |= TF_Virtual; |
| 124383 | | - pTable->nModuleArg = 0; |
| 124807 | + assert( pTable->nModuleArg==0 ); |
| 124384 | 124808 | addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName)); |
| 124385 | 124809 | addModuleArgument(db, pTable, 0); |
| 124386 | 124810 | addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName)); |
| 124387 | 124811 | assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0) |
| 124388 | 124812 | || (pParse->sNameToken.z==pName1->z && pName2->z==0) |
| | @@ -124666,11 +125090,11 @@ |
| 124666 | 125090 | const char *zMod; |
| 124667 | 125091 | Module *pMod; |
| 124668 | 125092 | int rc; |
| 124669 | 125093 | |
| 124670 | 125094 | assert( pTab ); |
| 124671 | | - if( (pTab->tabFlags & TF_Virtual)==0 || sqlite3GetVTable(db, pTab) ){ |
| 125095 | + if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){ |
| 124672 | 125096 | return SQLITE_OK; |
| 124673 | 125097 | } |
| 124674 | 125098 | |
| 124675 | 125099 | /* Locate the required virtual table module */ |
| 124676 | 125100 | zMod = pTab->azModuleArg[0]; |
| | @@ -124736,11 +125160,11 @@ |
| 124736 | 125160 | Table *pTab; |
| 124737 | 125161 | Module *pMod; |
| 124738 | 125162 | const char *zMod; |
| 124739 | 125163 | |
| 124740 | 125164 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); |
| 124741 | | - assert( pTab && (pTab->tabFlags & TF_Virtual)!=0 && !pTab->pVTable ); |
| 125165 | + assert( pTab && IsVirtual(pTab) && !pTab->pVTable ); |
| 124742 | 125166 | |
| 124743 | 125167 | /* Locate the required virtual table module */ |
| 124744 | 125168 | zMod = pTab->azModuleArg[0]; |
| 124745 | 125169 | pMod = (Module*)sqlite3HashFind(&db->aModule, zMod); |
| 124746 | 125170 | |
| | @@ -124790,11 +125214,11 @@ |
| 124790 | 125214 | sqlite3Error(db, SQLITE_MISUSE); |
| 124791 | 125215 | sqlite3_mutex_leave(db->mutex); |
| 124792 | 125216 | return SQLITE_MISUSE_BKPT; |
| 124793 | 125217 | } |
| 124794 | 125218 | pTab = pCtx->pTab; |
| 124795 | | - assert( (pTab->tabFlags & TF_Virtual)!=0 ); |
| 125219 | + assert( IsVirtual(pTab) ); |
| 124796 | 125220 | |
| 124797 | 125221 | pParse = sqlite3StackAllocZero(db, sizeof(*pParse)); |
| 124798 | 125222 | if( pParse==0 ){ |
| 124799 | 125223 | rc = SQLITE_NOMEM_BKPT; |
| 124800 | 125224 | }else{ |
| | @@ -124804,11 +125228,11 @@ |
| 124804 | 125228 | |
| 124805 | 125229 | if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr) |
| 124806 | 125230 | && pParse->pNewTable |
| 124807 | 125231 | && !db->mallocFailed |
| 124808 | 125232 | && !pParse->pNewTable->pSelect |
| 124809 | | - && (pParse->pNewTable->tabFlags & TF_Virtual)==0 |
| 125233 | + && !IsVirtual(pParse->pNewTable) |
| 124810 | 125234 | ){ |
| 124811 | 125235 | if( !pTab->aCol ){ |
| 124812 | 125236 | Table *pNew = pParse->pNewTable; |
| 124813 | 125237 | Index *pIdx; |
| 124814 | 125238 | pTab->aCol = pNew->aCol; |
| | @@ -125093,11 +125517,11 @@ |
| 125093 | 125517 | /* Check to see the left operand is a column in a virtual table */ |
| 125094 | 125518 | if( NEVER(pExpr==0) ) return pDef; |
| 125095 | 125519 | if( pExpr->op!=TK_COLUMN ) return pDef; |
| 125096 | 125520 | pTab = pExpr->pTab; |
| 125097 | 125521 | if( NEVER(pTab==0) ) return pDef; |
| 125098 | | - if( (pTab->tabFlags & TF_Virtual)==0 ) return pDef; |
| 125522 | + if( !IsVirtual(pTab) ) return pDef; |
| 125099 | 125523 | pVtab = sqlite3GetVTable(db, pTab)->pVtab; |
| 125100 | 125524 | assert( pVtab!=0 ); |
| 125101 | 125525 | assert( pVtab->pModule!=0 ); |
| 125102 | 125526 | pMod = (sqlite3_module *)pVtab->pModule; |
| 125103 | 125527 | if( pMod->xFindFunction==0 ) return pDef; |
| | @@ -125188,12 +125612,11 @@ |
| 125188 | 125612 | return 0; |
| 125189 | 125613 | } |
| 125190 | 125614 | pMod->pEpoTab = pTab; |
| 125191 | 125615 | pTab->nTabRef = 1; |
| 125192 | 125616 | pTab->pSchema = db->aDb[0].pSchema; |
| 125193 | | - pTab->tabFlags |= TF_Virtual; |
| 125194 | | - pTab->nModuleArg = 0; |
| 125617 | + assert( pTab->nModuleArg==0 ); |
| 125195 | 125618 | pTab->iPKey = -1; |
| 125196 | 125619 | addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| 125197 | 125620 | addModuleArgument(db, pTab, 0); |
| 125198 | 125621 | addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| 125199 | 125622 | rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr); |
| | @@ -125260,11 +125683,11 @@ |
| 125260 | 125683 | case SQLITE_VTAB_CONSTRAINT_SUPPORT: { |
| 125261 | 125684 | VtabCtx *p = db->pVtabCtx; |
| 125262 | 125685 | if( !p ){ |
| 125263 | 125686 | rc = SQLITE_MISUSE_BKPT; |
| 125264 | 125687 | }else{ |
| 125265 | | - assert( p->pTab==0 || (p->pTab->tabFlags & TF_Virtual)!=0 ); |
| 125688 | + assert( p->pTab==0 || IsVirtual(p->pTab) ); |
| 125266 | 125689 | p->pVTable->bConstraint = (u8)va_arg(ap, int); |
| 125267 | 125690 | } |
| 125268 | 125691 | break; |
| 125269 | 125692 | } |
| 125270 | 125693 | default: |
| | @@ -125699,12 +126122,17 @@ |
| 125699 | 126122 | WhereOrSet *pOrSet; /* Record best loops here, if not NULL */ |
| 125700 | 126123 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 125701 | 126124 | UnpackedRecord *pRec; /* Probe for stat4 (if required) */ |
| 125702 | 126125 | int nRecValid; /* Number of valid fields currently in pRec */ |
| 125703 | 126126 | #endif |
| 126127 | + unsigned int bldFlags; /* SQLITE_BLDF_* flags */ |
| 125704 | 126128 | }; |
| 125705 | 126129 | |
| 126130 | +/* Allowed values for WhereLoopBuider.bldFlags */ |
| 126131 | +#define SQLITE_BLDF_INDEXED 0x0001 /* An index is used */ |
| 126132 | +#define SQLITE_BLDF_UNIQUE 0x0002 /* All keys of a UNIQUE index used */ |
| 126133 | + |
| 125706 | 126134 | /* |
| 125707 | 126135 | ** The WHERE clause processing routine has two halves. The |
| 125708 | 126136 | ** first part does the start of the WHERE loop and the second |
| 125709 | 126137 | ** half does the tail of the WHERE loop. An instance of |
| 125710 | 126138 | ** this structure is returned by the first half and passed |
| | @@ -125715,11 +126143,11 @@ |
| 125715 | 126143 | */ |
| 125716 | 126144 | struct WhereInfo { |
| 125717 | 126145 | Parse *pParse; /* Parsing and code generating context */ |
| 125718 | 126146 | SrcList *pTabList; /* List of tables in the join */ |
| 125719 | 126147 | ExprList *pOrderBy; /* The ORDER BY clause or NULL */ |
| 125720 | | - ExprList *pDistinctSet; /* DISTINCT over all these values */ |
| 126148 | + ExprList *pResultSet; /* Result set of the query */ |
| 125721 | 126149 | LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ |
| 125722 | 126150 | int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ |
| 125723 | 126151 | int iContinue; /* Jump here to continue with next record */ |
| 125724 | 126152 | int iBreak; /* Jump here to break out of the loop */ |
| 125725 | 126153 | int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
| | @@ -126899,10 +127327,11 @@ |
| 126899 | 127327 | Parse *pParse; /* Parsing context */ |
| 126900 | 127328 | sqlite3 *db; /* Database connection */ |
| 126901 | 127329 | Vdbe *v; /* The prepared stmt under constructions */ |
| 126902 | 127330 | struct SrcList_item *pTabItem; /* FROM clause term being coded */ |
| 126903 | 127331 | int addrBrk; /* Jump here to break out of the loop */ |
| 127332 | + int addrHalt; /* addrBrk for the outermost loop */ |
| 126904 | 127333 | int addrCont; /* Jump here to continue with next cycle */ |
| 126905 | 127334 | int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ |
| 126906 | 127335 | int iReleaseReg = 0; /* Temp register to free before returning */ |
| 126907 | 127336 | |
| 126908 | 127337 | pParse = pWInfo->pParse; |
| | @@ -126939,10 +127368,15 @@ |
| 126939 | 127368 | if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){ |
| 126940 | 127369 | pLevel->iLeftJoin = ++pParse->nMem; |
| 126941 | 127370 | sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin); |
| 126942 | 127371 | VdbeComment((v, "init LEFT JOIN no-match flag")); |
| 126943 | 127372 | } |
| 127373 | + |
| 127374 | + /* Compute a safe address to jump to if we discover that the table for |
| 127375 | + ** this loop is empty and can never contribute content. */ |
| 127376 | + for(j=iLevel; j>0 && pWInfo->a[j].iLeftJoin==0; j--){} |
| 127377 | + addrHalt = pWInfo->a[j].addrBrk; |
| 126944 | 127378 | |
| 126945 | 127379 | /* Special case of a FROM clause subquery implemented as a co-routine */ |
| 126946 | 127380 | if( pTabItem->fg.viaCoroutine ){ |
| 126947 | 127381 | int regYield = pTabItem->regReturn; |
| 126948 | 127382 | sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub); |
| | @@ -127124,11 +127558,11 @@ |
| 127124 | 127558 | VdbeCoverageIf(v, pX->op==TK_LT); |
| 127125 | 127559 | VdbeCoverageIf(v, pX->op==TK_GE); |
| 127126 | 127560 | sqlite3ExprCacheAffinityChange(pParse, r1, 1); |
| 127127 | 127561 | sqlite3ReleaseTempReg(pParse, rTemp); |
| 127128 | 127562 | }else{ |
| 127129 | | - sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrBrk); |
| 127563 | + sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iCur, addrHalt); |
| 127130 | 127564 | VdbeCoverageIf(v, bRev==0); |
| 127131 | 127565 | VdbeCoverageIf(v, bRev!=0); |
| 127132 | 127566 | } |
| 127133 | 127567 | if( pEnd ){ |
| 127134 | 127568 | Expr *pX; |
| | @@ -127770,11 +128204,11 @@ |
| 127770 | 128204 | pLevel->op = OP_Noop; |
| 127771 | 128205 | }else{ |
| 127772 | 128206 | codeCursorHint(pTabItem, pWInfo, pLevel, 0); |
| 127773 | 128207 | pLevel->op = aStep[bRev]; |
| 127774 | 128208 | pLevel->p1 = iCur; |
| 127775 | | - pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk); |
| 128209 | + pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrHalt); |
| 127776 | 128210 | VdbeCoverageIf(v, bRev==0); |
| 127777 | 128211 | VdbeCoverageIf(v, bRev!=0); |
| 127778 | 128212 | pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; |
| 127779 | 128213 | } |
| 127780 | 128214 | } |
| | @@ -128095,19 +128529,10 @@ |
| 128095 | 128529 | #ifdef SQLITE_EBCDIC |
| 128096 | 128530 | if( *pnoCase ) return 0; |
| 128097 | 128531 | #endif |
| 128098 | 128532 | pList = pExpr->x.pList; |
| 128099 | 128533 | 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 | 128534 | |
| 128110 | 128535 | pRight = sqlite3ExprSkipCollate(pList->a[0].pExpr); |
| 128111 | 128536 | op = pRight->op; |
| 128112 | 128537 | if( op==TK_VARIABLE ){ |
| 128113 | 128538 | Vdbe *pReprepare = pParse->pReprepare; |
| | @@ -128120,10 +128545,27 @@ |
| 128120 | 128545 | assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER ); |
| 128121 | 128546 | }else if( op==TK_STRING ){ |
| 128122 | 128547 | z = pRight->u.zToken; |
| 128123 | 128548 | } |
| 128124 | 128549 | if( z ){ |
| 128550 | + |
| 128551 | + /* If the RHS begins with a digit or a minus sign, then the LHS must |
| 128552 | + ** be an ordinary column (not a virtual table column) with TEXT affinity. |
| 128553 | + ** Otherwise the LHS might be numeric and "lhs >= rhs" would be false |
| 128554 | + ** even though "lhs LIKE rhs" is true. But if the RHS does not start |
| 128555 | + ** with a digit or '-', then "lhs LIKE rhs" will always be false if |
| 128556 | + ** the LHS is numeric and so the optimization still works. |
| 128557 | + */ |
| 128558 | + if( sqlite3Isdigit(z[0]) || z[0]=='-' ){ |
| 128559 | + if( pLeft->op!=TK_COLUMN |
| 128560 | + || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT |
| 128561 | + || IsVirtual(pLeft->pTab) /* Value might be numeric */ |
| 128562 | + ){ |
| 128563 | + sqlite3ValueFree(pVal); |
| 128564 | + return 0; |
| 128565 | + } |
| 128566 | + } |
| 128125 | 128567 | cnt = 0; |
| 128126 | 128568 | while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){ |
| 128127 | 128569 | cnt++; |
| 128128 | 128570 | } |
| 128129 | 128571 | if( cnt!=0 && 255!=(u8)z[cnt-1] ){ |
| | @@ -128748,11 +129190,11 @@ |
| 128748 | 129190 | iCur = pFrom->a[i].iCursor; |
| 128749 | 129191 | for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 128750 | 129192 | if( pIdx->aColExpr==0 ) continue; |
| 128751 | 129193 | for(i=0; i<pIdx->nKeyCol; i++){ |
| 128752 | 129194 | if( pIdx->aiColumn[i]!=XN_EXPR ) continue; |
| 128753 | | - if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){ |
| 129195 | + if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){ |
| 128754 | 129196 | *piCur = iCur; |
| 128755 | 129197 | *piColumn = XN_EXPR; |
| 128756 | 129198 | return 1; |
| 128757 | 129199 | } |
| 128758 | 129200 | } |
| | @@ -129539,11 +129981,12 @@ |
| 129539 | 129981 | do{ |
| 129540 | 129982 | for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){ |
| 129541 | 129983 | if( pTerm->leftCursor==iCur |
| 129542 | 129984 | && pTerm->u.leftColumn==iColumn |
| 129543 | 129985 | && (iColumn!=XN_EXPR |
| 129544 | | - || sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0) |
| 129986 | + || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft, |
| 129987 | + pScan->pIdxExpr,iCur)==0) |
| 129545 | 129988 | && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin)) |
| 129546 | 129989 | ){ |
| 129547 | 129990 | if( (pTerm->eOperator & WO_EQUIV)!=0 |
| 129548 | 129991 | && pScan->nEquiv<ArraySize(pScan->aiCur) |
| 129549 | 129992 | && (pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight))->op==TK_COLUMN |
| | @@ -131716,10 +132159,15 @@ |
| 131716 | 132159 | testcase( eOp & WO_IS ); |
| 131717 | 132160 | testcase( eOp & WO_ISNULL ); |
| 131718 | 132161 | continue; |
| 131719 | 132162 | } |
| 131720 | 132163 | |
| 132164 | + if( IsUniqueIndex(pProbe) && saved_nEq==pProbe->nKeyCol-1 ){ |
| 132165 | + pBuilder->bldFlags |= SQLITE_BLDF_UNIQUE; |
| 132166 | + }else{ |
| 132167 | + pBuilder->bldFlags |= SQLITE_BLDF_INDEXED; |
| 132168 | + } |
| 131721 | 132169 | pNew->wsFlags = saved_wsFlags; |
| 131722 | 132170 | pNew->u.btree.nEq = saved_nEq; |
| 131723 | 132171 | pNew->u.btree.nBtm = saved_nBtm; |
| 131724 | 132172 | pNew->u.btree.nTop = saved_nTop; |
| 131725 | 132173 | pNew->nLTerm = saved_nLTerm; |
| | @@ -132263,11 +132711,19 @@ |
| 132263 | 132711 | pNew->nOut = rSize; |
| 132264 | 132712 | if( rc ) break; |
| 132265 | 132713 | } |
| 132266 | 132714 | } |
| 132267 | 132715 | |
| 132716 | + pBuilder->bldFlags = 0; |
| 132268 | 132717 | rc = whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, 0); |
| 132718 | + if( pBuilder->bldFlags==SQLITE_BLDF_INDEXED ){ |
| 132719 | + /* If a non-unique index is used, or if a prefix of the key for |
| 132720 | + ** unique index is used (making the index functionally non-unique) |
| 132721 | + ** then the sqlite_stat1 data becomes important for scoring the |
| 132722 | + ** plan */ |
| 132723 | + pTab->tabFlags |= TF_StatsUsed; |
| 132724 | + } |
| 132269 | 132725 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 132270 | 132726 | sqlite3Stat4ProbeFree(pBuilder->pRec); |
| 132271 | 132727 | pBuilder->nRecValid = 0; |
| 132272 | 132728 | pBuilder->pRec = 0; |
| 132273 | 132729 | #endif |
| | @@ -133443,13 +133899,13 @@ |
| 133443 | 133899 | && (pWInfo->wctrlFlags & WHERE_DISTINCTBY)==0 |
| 133444 | 133900 | && pWInfo->eDistinct==WHERE_DISTINCT_NOOP |
| 133445 | 133901 | && nRowEst |
| 133446 | 133902 | ){ |
| 133447 | 133903 | Bitmask notUsed; |
| 133448 | | - int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pDistinctSet, pFrom, |
| 133904 | + int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pResultSet, pFrom, |
| 133449 | 133905 | WHERE_DISTINCTBY, nLoop-1, pFrom->aLoop[nLoop-1], ¬Used); |
| 133450 | | - if( rc==pWInfo->pDistinctSet->nExpr ){ |
| 133906 | + if( rc==pWInfo->pResultSet->nExpr ){ |
| 133451 | 133907 | pWInfo->eDistinct = WHERE_DISTINCT_ORDERED; |
| 133452 | 133908 | } |
| 133453 | 133909 | } |
| 133454 | 133910 | if( pWInfo->pOrderBy ){ |
| 133455 | 133911 | if( pWInfo->wctrlFlags & WHERE_DISTINCTBY ){ |
| | @@ -133682,11 +134138,11 @@ |
| 133682 | 134138 | SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( |
| 133683 | 134139 | Parse *pParse, /* The parser context */ |
| 133684 | 134140 | SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */ |
| 133685 | 134141 | Expr *pWhere, /* The WHERE clause */ |
| 133686 | 134142 | ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */ |
| 133687 | | - ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */ |
| 134143 | + ExprList *pResultSet, /* Query result set. Req'd for DISTINCT */ |
| 133688 | 134144 | u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */ |
| 133689 | 134145 | int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number |
| 133690 | 134146 | ** If WHERE_USE_LIMIT, then the limit amount */ |
| 133691 | 134147 | ){ |
| 133692 | 134148 | int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ |
| | @@ -133758,11 +134214,11 @@ |
| 133758 | 134214 | goto whereBeginError; |
| 133759 | 134215 | } |
| 133760 | 134216 | pWInfo->pParse = pParse; |
| 133761 | 134217 | pWInfo->pTabList = pTabList; |
| 133762 | 134218 | pWInfo->pOrderBy = pOrderBy; |
| 133763 | | - pWInfo->pDistinctSet = pDistinctSet; |
| 134219 | + pWInfo->pResultSet = pResultSet; |
| 133764 | 134220 | pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; |
| 133765 | 134221 | pWInfo->nLevel = nTabList; |
| 133766 | 134222 | pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v); |
| 133767 | 134223 | pWInfo->wctrlFlags = wctrlFlags; |
| 133768 | 134224 | pWInfo->iLimit = iAuxArg; |
| | @@ -133836,17 +134292,17 @@ |
| 133836 | 134292 | /* Analyze all of the subexpressions. */ |
| 133837 | 134293 | sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC); |
| 133838 | 134294 | if( db->mallocFailed ) goto whereBeginError; |
| 133839 | 134295 | |
| 133840 | 134296 | if( wctrlFlags & WHERE_WANT_DISTINCT ){ |
| 133841 | | - if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pDistinctSet) ){ |
| 134297 | + if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){ |
| 133842 | 134298 | /* The DISTINCT marking is pointless. Ignore it. */ |
| 133843 | 134299 | pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE; |
| 133844 | 134300 | }else if( pOrderBy==0 ){ |
| 133845 | 134301 | /* Try to ORDER BY the result set to make distinct processing easier */ |
| 133846 | 134302 | pWInfo->wctrlFlags |= WHERE_DISTINCTBY; |
| 133847 | | - pWInfo->pOrderBy = pDistinctSet; |
| 134303 | + pWInfo->pOrderBy = pResultSet; |
| 133848 | 134304 | } |
| 133849 | 134305 | } |
| 133850 | 134306 | |
| 133851 | 134307 | /* Construct the WhereLoop objects */ |
| 133852 | 134308 | #if defined(WHERETRACE_ENABLED) |
| | @@ -133918,14 +134374,14 @@ |
| 133918 | 134374 | } |
| 133919 | 134375 | } |
| 133920 | 134376 | #endif |
| 133921 | 134377 | /* Attempt to omit tables from the join that do not effect the result */ |
| 133922 | 134378 | if( pWInfo->nLevel>=2 |
| 133923 | | - && pDistinctSet!=0 |
| 134379 | + && pResultSet!=0 |
| 133924 | 134380 | && OptimizationEnabled(db, SQLITE_OmitNoopJoin) |
| 133925 | 134381 | ){ |
| 133926 | | - Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pDistinctSet); |
| 134382 | + Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet); |
| 133927 | 134383 | if( sWLB.pOrderBy ){ |
| 133928 | 134384 | tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy); |
| 133929 | 134385 | } |
| 133930 | 134386 | while( pWInfo->nLevel>=2 ){ |
| 133931 | 134387 | WhereTerm *pTerm, *pEnd; |
| | @@ -134704,166 +135160,166 @@ |
| 134704 | 135160 | ** |
| 134705 | 135161 | *********** Begin parsing tables **********************************************/ |
| 134706 | 135162 | #define YY_ACTTAB_COUNT (1567) |
| 134707 | 135163 | static const YYACTIONTYPE yy_action[] = { |
| 134708 | 135164 | /* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100, |
| 134709 | | - /* 10 */ 90, 842, 842, 854, 857, 846, 846, 97, 97, 98, |
| 135165 | + /* 10 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, |
| 134710 | 135166 | /* 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, |
| 135167 | + /* 30 */ 94, 94, 94, 93, 351, 325, 976, 976, 824, 824, |
| 135168 | + /* 40 */ 826, 946, 354, 99, 100, 90, 978, 978, 853, 856, |
| 135169 | + /* 50 */ 845, 845, 97, 97, 98, 98, 98, 98, 338, 96, |
| 134714 | 135170 | /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 134715 | | - /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 977, 977, |
| 135171 | + /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 976, 976, |
| 134716 | 135172 | /* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100, |
| 134717 | | - /* 90 */ 90, 842, 842, 854, 857, 846, 846, 97, 97, 98, |
| 135173 | + /* 90 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, |
| 134718 | 135174 | /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95, |
| 134719 | 135175 | /* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325, |
| 134720 | 135176 | /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90, |
| 134721 | | - /* 130 */ 842, 842, 854, 857, 846, 846, 97, 97, 98, 98, |
| 135177 | + /* 130 */ 978, 978, 853, 856, 845, 845, 97, 97, 98, 98, |
| 134722 | 135178 | /* 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, |
| 135179 | + /* 150 */ 94, 94, 93, 351, 957, 957, 325, 268, 428, 413, |
| 135180 | + /* 160 */ 411, 61, 752, 752, 99, 100, 90, 978, 978, 853, |
| 135181 | + /* 170 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 60, |
| 134726 | 135182 | /* 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, |
| 135183 | + /* 190 */ 351, 325, 270, 329, 273, 277, 958, 959, 250, 99, |
| 135184 | + /* 200 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 134729 | 135185 | /* 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, |
| 135186 | + /* 220 */ 95, 94, 94, 94, 93, 351, 325, 937, 1326, 698, |
| 135187 | + /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 978, 978, 853, |
| 135188 | + /* 240 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 347, |
| 134733 | 135189 | /* 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, |
| 135190 | + /* 260 */ 351, 325, 937, 1327, 384, 699, 1327, 381, 379, 99, |
| 135191 | + /* 270 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 134736 | 135192 | /* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95, |
| 134737 | 135193 | /* 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, |
| 135194 | + /* 300 */ 833, 935, 373, 700, 99, 100, 90, 978, 978, 853, |
| 135195 | + /* 310 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 375, |
| 134740 | 135196 | /* 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, |
| 135197 | + /* 330 */ 351, 325, 1275, 946, 354, 818, 935, 739, 739, 99, |
| 135198 | + /* 340 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 134743 | 135199 | /* 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, |
| 135200 | + /* 360 */ 95, 94, 94, 94, 93, 351, 325, 968, 227, 92, |
| 135201 | + /* 370 */ 89, 178, 373, 300, 99, 100, 90, 978, 978, 853, |
| 135202 | + /* 380 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 920, |
| 134747 | 135203 | /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 134748 | 135204 | /* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99, |
| 134749 | | - /* 410 */ 100, 90, 842, 842, 854, 857, 846, 846, 97, 97, |
| 135205 | + /* 410 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 134750 | 135206 | /* 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, |
| 135207 | + /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 957, |
| 135208 | + /* 440 */ 957, 158, 25, 422, 99, 100, 90, 978, 978, 853, |
| 135209 | + /* 450 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 450, |
| 134754 | 135210 | /* 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, |
| 135211 | + /* 470 */ 351, 443, 224, 224, 420, 957, 957, 961, 325, 52, |
| 135212 | + /* 480 */ 52, 958, 959, 176, 415, 78, 99, 100, 90, 978, |
| 135213 | + /* 490 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, |
| 134758 | 135214 | /* 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, |
| 135215 | + /* 510 */ 94, 93, 351, 325, 428, 418, 298, 958, 959, 961, |
| 135216 | + /* 520 */ 81, 99, 88, 90, 978, 978, 853, 856, 845, 845, |
| 134761 | 135217 | /* 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, |
| 135218 | + /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 842, |
| 135219 | + /* 550 */ 842, 854, 857, 996, 318, 343, 379, 100, 90, 978, |
| 135220 | + /* 560 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, |
| 134765 | 135221 | /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94, |
| 134766 | 135222 | /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340, |
| 134767 | | - /* 590 */ 929, 52, 52, 90, 842, 842, 854, 857, 846, 846, |
| 135223 | + /* 590 */ 928, 52, 52, 90, 978, 978, 853, 856, 845, 845, |
| 134768 | 135224 | /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96, |
| 134769 | 135225 | /* 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, |
| 135226 | + /* 620 */ 846, 3, 1202, 361, 360, 378, 344, 813, 957, 957, |
| 135227 | + /* 630 */ 1299, 86, 445, 729, 3, 212, 169, 287, 405, 282, |
| 134772 | 135228 | /* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245, |
| 134773 | 135229 | /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83, |
| 134774 | 135230 | /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246, |
| 134775 | | - /* 670 */ 959, 960, 194, 455, 670, 402, 399, 398, 448, 243, |
| 135231 | + /* 670 */ 958, 959, 194, 455, 670, 402, 399, 398, 448, 243, |
| 134776 | 135232 | /* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224, |
| 134777 | 135233 | /* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427, |
| 134778 | 135234 | /* 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, |
| 135235 | + /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1270, |
| 135236 | + /* 720 */ 1270, 23, 957, 957, 86, 445, 397, 3, 228, 429, |
| 135237 | + /* 730 */ 894, 824, 824, 826, 827, 19, 203, 720, 52, 52, |
| 134782 | 135238 | /* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229, |
| 134783 | 135239 | /* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85, |
| 134784 | | - /* 760 */ 352, 352, 120, 157, 959, 960, 58, 977, 409, 355, |
| 135240 | + /* 760 */ 352, 352, 120, 157, 958, 959, 58, 976, 409, 355, |
| 134785 | 135241 | /* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86, |
| 134786 | 135242 | /* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96, |
| 134787 | 135243 | /* 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, |
| 135244 | + /* 800 */ 832, 120, 452, 451, 813, 886, 819, 83, 84, 976, |
| 135245 | + /* 810 */ 813, 132, 410, 919, 85, 352, 352, 132, 407, 789, |
| 135246 | + /* 820 */ 957, 957, 92, 89, 178, 916, 448, 262, 370, 261, |
| 135247 | + /* 830 */ 82, 913, 80, 262, 370, 261, 776, 824, 824, 826, |
| 135248 | + /* 840 */ 827, 19, 933, 434, 96, 96, 96, 96, 95, 95, |
| 135249 | + /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 957, |
| 135250 | + /* 860 */ 957, 819, 958, 959, 120, 92, 89, 178, 944, 2, |
| 135251 | + /* 870 */ 917, 964, 268, 1, 975, 76, 445, 762, 3, 708, |
| 135252 | + /* 880 */ 900, 900, 387, 957, 957, 757, 918, 371, 740, 778, |
| 134797 | 135253 | /* 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, |
| 135254 | + /* 900 */ 24, 958, 959, 83, 84, 369, 957, 957, 177, 226, |
| 135255 | + /* 910 */ 85, 352, 352, 884, 315, 314, 313, 215, 311, 10, |
| 135256 | + /* 920 */ 10, 683, 448, 349, 348, 958, 959, 908, 777, 157, |
| 135257 | + /* 930 */ 120, 957, 957, 337, 776, 416, 711, 310, 450, 434, |
| 135258 | + /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 958, 959, |
| 135259 | + /* 950 */ 907, 832, 792, 452, 451, 9, 9, 819, 10, 10, |
| 134804 | 135260 | /* 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, |
| 135261 | + /* 970 */ 170, 167, 339, 958, 959, 247, 984, 702, 702, 450, |
| 135262 | + /* 980 */ 715, 233, 686, 982, 888, 983, 182, 913, 824, 824, |
| 134807 | 135263 | /* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10, |
| 134808 | | - /* 1000 */ 10, 889, 891, 749, 958, 958, 917, 268, 985, 198, |
| 135264 | + /* 1000 */ 10, 888, 890, 749, 957, 957, 916, 268, 985, 198, |
| 134809 | 135265 | /* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825, |
| 134810 | 135266 | /* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91, |
| 134811 | 135267 | /* 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, |
| 135268 | + /* 1040 */ 351, 157, 810, 371, 382, 359, 958, 959, 358, 268, |
| 135269 | + /* 1050 */ 450, 917, 368, 324, 824, 824, 826, 450, 709, 450, |
| 135270 | + /* 1060 */ 264, 380, 888, 450, 876, 746, 253, 918, 255, 433, |
| 134815 | 135271 | /* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12, |
| 134816 | 135272 | /* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162, |
| 134817 | 135273 | /* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450, |
| 134818 | | - /* 1100 */ 709, 1210, 450, 132, 450, 39, 39, 450, 40, 40, |
| 135274 | + /* 1100 */ 709, 1209, 450, 132, 450, 39, 39, 450, 40, 40, |
| 134819 | 135275 | /* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28, |
| 134820 | 135276 | /* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450, |
| 134821 | 135277 | /* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767, |
| 134822 | 135278 | /* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47, |
| 134823 | 135279 | /* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172, |
| 134824 | 135280 | /* 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, |
| 135281 | + /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 897, 56, 56, |
| 135282 | + /* 1180 */ 450, 896, 35, 35, 450, 267, 450, 817, 450, 817, |
| 134827 | 135283 | /* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817, |
| 134828 | 135284 | /* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119, |
| 134829 | 135285 | /* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111, |
| 134830 | | - /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 912, |
| 135286 | + /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 911, |
| 134831 | 135287 | /* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331, |
| 134832 | | - /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 937, 197, |
| 135288 | + /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 936, 197, |
| 134833 | 135289 | /* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436, |
| 134834 | | - /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 933, |
| 135290 | + /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 932, |
| 134835 | 135291 | /* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202, |
| 134836 | | - /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 884, |
| 135292 | + /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 883, |
| 134837 | 135293 | /* 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, |
| 135294 | + /* 1300 */ 726, 727, 785, 783, 879, 202, 999, 208, 893, 892, |
| 135295 | + /* 1310 */ 893, 892, 694, 816, 763, 116, 774, 1289, 431, 432, |
| 134840 | 135296 | /* 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, |
| 135297 | + /* 1330 */ 679, 883, 681, 951, 291, 218, 293, 7, 316, 828, |
| 135298 | + /* 1340 */ 173, 805, 259, 364, 252, 910, 376, 713, 295, 435, |
| 135299 | + /* 1350 */ 308, 168, 954, 993, 135, 400, 990, 284, 881, 880, |
| 135300 | + /* 1360 */ 205, 927, 925, 59, 333, 62, 144, 156, 130, 72, |
| 134845 | 135301 | /* 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, |
| 135302 | + /* 1380 */ 67, 895, 140, 141, 142, 148, 389, 812, 775, 266, |
| 135303 | + /* 1390 */ 219, 190, 154, 391, 912, 875, 271, 406, 191, 322, |
| 134848 | 135304 | /* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421, |
| 134849 | 135305 | /* 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, |
| 135306 | + /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 966, 239, |
| 135307 | + /* 1430 */ 769, 102, 861, 438, 426, 240, 424, 442, 73, 213, |
| 135308 | + /* 1440 */ 688, 238, 22, 453, 952, 214, 217, 216, 454, 677, |
| 134853 | 135309 | /* 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, |
| 135310 | + /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 891, |
| 135311 | + /* 1470 */ 327, 889, 811, 328, 134, 128, 136, 138, 743, 258, |
| 135312 | + /* 1480 */ 906, 184, 143, 129, 909, 186, 63, 64, 145, 187, |
| 135313 | + /* 1490 */ 905, 65, 8, 66, 13, 188, 202, 898, 265, 149, |
| 134858 | 135314 | /* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396, |
| 134859 | 135315 | /* 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, |
| 135316 | + /* 1520 */ 830, 859, 70, 751, 16, 414, 755, 4, 174, 220, |
| 135317 | + /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 874, |
| 135318 | + /* 1540 */ 860, 858, 915, 863, 914, 207, 206, 941, 163, 437, |
| 135319 | + /* 1550 */ 947, 942, 164, 209, 1002, 441, 862, 165, 210, 829, |
| 135320 | + /* 1560 */ 695, 87, 312, 211, 1291, 1290, 309, |
| 134865 | 135321 | }; |
| 134866 | 135322 | static const YYCODETYPE yy_lookahead[] = { |
| 134867 | 135323 | /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28, |
| 134868 | 135324 | /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
| 134869 | 135325 | /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48, |
| | @@ -135112,55 +135568,55 @@ |
| 135112 | 135568 | /* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278, |
| 135113 | 135569 | /* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228, |
| 135114 | 135570 | /* 320 */ 1288, 1291, 1276, 1277, 1295, |
| 135115 | 135571 | }; |
| 135116 | 135572 | 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, |
| 135573 | + /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096, |
| 135574 | + /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201, |
| 135575 | + /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332, |
| 135576 | + /* 30 */ 1332, 1203, 1204, 1332, 1332, 1332, 1253, 1255, 1141, 1140, |
| 135577 | + /* 40 */ 1139, 1138, 1236, 1112, 1136, 1129, 1133, 1203, 1197, 1198, |
| 135578 | + /* 50 */ 1196, 1200, 1204, 1332, 1132, 1167, 1181, 1166, 1332, 1332, |
| 135123 | 135579 | /* 60 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135124 | 135580 | /* 70 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135125 | 135581 | /* 80 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135126 | 135582 | /* 90 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135127 | | - /* 100 */ 1332, 1332, 1332, 1332, 1176, 1181, 1188, 1180, 1177, 1169, |
| 135583 | + /* 100 */ 1332, 1332, 1332, 1332, 1175, 1180, 1187, 1179, 1176, 1169, |
| 135128 | 135584 | /* 110 */ 1168, 1170, 1171, 1332, 1019, 1067, 1332, 1332, 1332, 1172, |
| 135129 | | - /* 120 */ 1332, 1173, 1185, 1184, 1183, 1262, 1289, 1288, 1332, 1332, |
| 135585 | + /* 120 */ 1332, 1173, 1184, 1183, 1182, 1261, 1288, 1287, 1332, 1332, |
| 135130 | 135586 | /* 130 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135131 | 135587 | /* 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, |
| 135588 | + /* 150 */ 1332, 1332, 1332, 1332, 1332, 1280, 1270, 1025, 1025, 1332, |
| 135589 | + /* 160 */ 1270, 1270, 1270, 1270, 1270, 1270, 1266, 1100, 1091, 1332, |
| 135134 | 135590 | /* 170 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135135 | | - /* 180 */ 1259, 1257, 1332, 1218, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135591 | + /* 180 */ 1258, 1256, 1332, 1217, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135136 | 135592 | /* 190 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135137 | 135593 | /* 200 */ 1332, 1332, 1332, 1332, 1096, 1332, 1332, 1332, 1332, 1332, |
| 135138 | | - /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1283, 1332, 1232, |
| 135594 | + /* 210 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1282, 1332, 1231, |
| 135139 | 135595 | /* 220 */ 1096, 1096, 1096, 1098, 1080, 1090, 1004, 1135, 1114, 1114, |
| 135140 | | - /* 230 */ 1321, 1135, 1321, 1042, 1303, 1039, 1125, 1114, 1200, 1125, |
| 135596 | + /* 230 */ 1321, 1135, 1321, 1042, 1302, 1039, 1125, 1114, 1199, 1125, |
| 135141 | 135597 | /* 240 */ 1125, 1097, 1090, 1332, 1324, 1105, 1105, 1323, 1323, 1105, |
| 135142 | 135598 | /* 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, |
| 135599 | + /* 260 */ 1146, 1070, 1070, 1135, 1105, 1016, 1235, 1318, 1105, 1105, |
| 135600 | + /* 270 */ 1016, 1210, 1105, 1016, 1105, 1016, 1210, 1068, 1068, 1068, |
| 135601 | + /* 280 */ 1057, 1210, 1068, 1042, 1068, 1057, 1068, 1068, 1118, 1113, |
| 135602 | + /* 290 */ 1118, 1113, 1118, 1113, 1118, 1113, 1105, 1205, 1105, 1332, |
| 135603 | + /* 300 */ 1210, 1214, 1214, 1210, 1130, 1119, 1128, 1126, 1135, 1022, |
| 135604 | + /* 310 */ 1060, 1285, 1285, 1281, 1281, 1281, 1281, 1329, 1329, 1266, |
| 135605 | + /* 320 */ 1297, 1297, 1044, 1044, 1297, 1332, 1332, 1332, 1332, 1332, |
| 135606 | + /* 330 */ 1332, 1292, 1332, 1219, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135151 | 135607 | /* 340 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135152 | | - /* 350 */ 1332, 1332, 1152, 1332, 1000, 1264, 1332, 1332, 1263, 1332, |
| 135608 | + /* 350 */ 1332, 1332, 1152, 1332, 1000, 1263, 1332, 1332, 1262, 1332, |
| 135153 | 135609 | /* 360 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135154 | 135610 | /* 370 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1320, |
| 135155 | | - /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1235, 1234, 1332, 1332, |
| 135611 | + /* 380 */ 1332, 1332, 1332, 1332, 1332, 1332, 1234, 1233, 1332, 1332, |
| 135156 | 135612 | /* 390 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135157 | 135613 | /* 400 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, |
| 135158 | | - /* 410 */ 1332, 1082, 1332, 1332, 1332, 1307, 1332, 1332, 1332, 1332, |
| 135614 | + /* 410 */ 1332, 1082, 1332, 1332, 1332, 1306, 1332, 1332, 1332, 1332, |
| 135159 | 135615 | /* 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, |
| 135616 | + /* 430 */ 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1332, 1272, |
| 135617 | + /* 440 */ 1332, 1332, 1332, 1271, 1332, 1332, 1332, 1332, 1332, 1154, |
| 135162 | 135618 | /* 450 */ 1332, 1153, 1157, 1332, 1010, 1332, |
| 135163 | 135619 | }; |
| 135164 | 135620 | /********** End of lemon-generated parsing tables *****************************/ |
| 135165 | 135621 | |
| 135166 | 135622 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| | @@ -135602,147 +136058,147 @@ |
| 135602 | 136058 | /* 169 */ "expr ::= expr EQ|NE expr", |
| 135603 | 136059 | /* 170 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 135604 | 136060 | /* 171 */ "expr ::= expr PLUS|MINUS expr", |
| 135605 | 136061 | /* 172 */ "expr ::= expr STAR|SLASH|REM expr", |
| 135606 | 136062 | /* 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", |
| 136063 | + /* 174 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 136064 | + /* 175 */ "expr ::= expr likeop expr", |
| 136065 | + /* 176 */ "expr ::= expr likeop expr ESCAPE expr", |
| 136066 | + /* 177 */ "expr ::= expr ISNULL|NOTNULL", |
| 136067 | + /* 178 */ "expr ::= expr NOT NULL", |
| 136068 | + /* 179 */ "expr ::= expr IS expr", |
| 136069 | + /* 180 */ "expr ::= expr IS NOT expr", |
| 136070 | + /* 181 */ "expr ::= NOT expr", |
| 136071 | + /* 182 */ "expr ::= BITNOT expr", |
| 136072 | + /* 183 */ "expr ::= MINUS expr", |
| 136073 | + /* 184 */ "expr ::= PLUS expr", |
| 136074 | + /* 185 */ "between_op ::= BETWEEN", |
| 136075 | + /* 186 */ "between_op ::= NOT BETWEEN", |
| 136076 | + /* 187 */ "expr ::= expr between_op expr AND expr", |
| 136077 | + /* 188 */ "in_op ::= IN", |
| 136078 | + /* 189 */ "in_op ::= NOT IN", |
| 136079 | + /* 190 */ "expr ::= expr in_op LP exprlist RP", |
| 136080 | + /* 191 */ "expr ::= LP select RP", |
| 136081 | + /* 192 */ "expr ::= expr in_op LP select RP", |
| 136082 | + /* 193 */ "expr ::= expr in_op nm dbnm paren_exprlist", |
| 136083 | + /* 194 */ "expr ::= EXISTS LP select RP", |
| 136084 | + /* 195 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 136085 | + /* 196 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 136086 | + /* 197 */ "case_exprlist ::= WHEN expr THEN expr", |
| 136087 | + /* 198 */ "case_else ::= ELSE expr", |
| 136088 | + /* 199 */ "case_else ::=", |
| 136089 | + /* 200 */ "case_operand ::= expr", |
| 136090 | + /* 201 */ "case_operand ::=", |
| 136091 | + /* 202 */ "exprlist ::=", |
| 136092 | + /* 203 */ "nexprlist ::= nexprlist COMMA expr", |
| 136093 | + /* 204 */ "nexprlist ::= expr", |
| 136094 | + /* 205 */ "paren_exprlist ::=", |
| 136095 | + /* 206 */ "paren_exprlist ::= LP exprlist RP", |
| 136096 | + /* 207 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 136097 | + /* 208 */ "uniqueflag ::= UNIQUE", |
| 136098 | + /* 209 */ "uniqueflag ::=", |
| 136099 | + /* 210 */ "eidlist_opt ::=", |
| 136100 | + /* 211 */ "eidlist_opt ::= LP eidlist RP", |
| 136101 | + /* 212 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 136102 | + /* 213 */ "eidlist ::= nm collate sortorder", |
| 136103 | + /* 214 */ "collate ::=", |
| 136104 | + /* 215 */ "collate ::= COLLATE ID|STRING", |
| 136105 | + /* 216 */ "cmd ::= DROP INDEX ifexists fullname", |
| 136106 | + /* 217 */ "cmd ::= VACUUM", |
| 136107 | + /* 218 */ "cmd ::= VACUUM nm", |
| 136108 | + /* 219 */ "cmd ::= PRAGMA nm dbnm", |
| 136109 | + /* 220 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 136110 | + /* 221 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 136111 | + /* 222 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 136112 | + /* 223 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 136113 | + /* 224 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 136114 | + /* 225 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 136115 | + /* 226 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 136116 | + /* 227 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 136117 | + /* 228 */ "trigger_time ::= BEFORE", |
| 136118 | + /* 229 */ "trigger_time ::= AFTER", |
| 136119 | + /* 230 */ "trigger_time ::= INSTEAD OF", |
| 136120 | + /* 231 */ "trigger_time ::=", |
| 136121 | + /* 232 */ "trigger_event ::= DELETE|INSERT", |
| 136122 | + /* 233 */ "trigger_event ::= UPDATE", |
| 136123 | + /* 234 */ "trigger_event ::= UPDATE OF idlist", |
| 136124 | + /* 235 */ "when_clause ::=", |
| 136125 | + /* 236 */ "when_clause ::= WHEN expr", |
| 136126 | + /* 237 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 136127 | + /* 238 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 136128 | + /* 239 */ "trnm ::= nm DOT nm", |
| 136129 | + /* 240 */ "tridxby ::= INDEXED BY nm", |
| 136130 | + /* 241 */ "tridxby ::= NOT INDEXED", |
| 136131 | + /* 242 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 136132 | + /* 243 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select", |
| 136133 | + /* 244 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 136134 | + /* 245 */ "trigger_cmd ::= select", |
| 136135 | + /* 246 */ "expr ::= RAISE LP IGNORE RP", |
| 136136 | + /* 247 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 136137 | + /* 248 */ "raisetype ::= ROLLBACK", |
| 136138 | + /* 249 */ "raisetype ::= ABORT", |
| 136139 | + /* 250 */ "raisetype ::= FAIL", |
| 136140 | + /* 251 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 136141 | + /* 252 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 136142 | + /* 253 */ "cmd ::= DETACH database_kw_opt expr", |
| 136143 | + /* 254 */ "key_opt ::=", |
| 136144 | + /* 255 */ "key_opt ::= KEY expr", |
| 136145 | + /* 256 */ "cmd ::= REINDEX", |
| 136146 | + /* 257 */ "cmd ::= REINDEX nm dbnm", |
| 136147 | + /* 258 */ "cmd ::= ANALYZE", |
| 136148 | + /* 259 */ "cmd ::= ANALYZE nm dbnm", |
| 136149 | + /* 260 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 136150 | + /* 261 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 136151 | + /* 262 */ "add_column_fullname ::= fullname", |
| 136152 | + /* 263 */ "cmd ::= create_vtab", |
| 136153 | + /* 264 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 136154 | + /* 265 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 136155 | + /* 266 */ "vtabarg ::=", |
| 136156 | + /* 267 */ "vtabargtoken ::= ANY", |
| 136157 | + /* 268 */ "vtabargtoken ::= lp anylist RP", |
| 136158 | + /* 269 */ "lp ::= LP", |
| 136159 | + /* 270 */ "with ::=", |
| 136160 | + /* 271 */ "with ::= WITH wqlist", |
| 136161 | + /* 272 */ "with ::= WITH RECURSIVE wqlist", |
| 136162 | + /* 273 */ "wqlist ::= nm eidlist_opt AS LP select RP", |
| 136163 | + /* 274 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", |
| 136164 | + /* 275 */ "input ::= cmdlist", |
| 136165 | + /* 276 */ "cmdlist ::= cmdlist ecmd", |
| 136166 | + /* 277 */ "cmdlist ::= ecmd", |
| 136167 | + /* 278 */ "ecmd ::= SEMI", |
| 136168 | + /* 279 */ "ecmd ::= explain cmdx SEMI", |
| 136169 | + /* 280 */ "explain ::=", |
| 136170 | + /* 281 */ "trans_opt ::=", |
| 136171 | + /* 282 */ "trans_opt ::= TRANSACTION", |
| 136172 | + /* 283 */ "trans_opt ::= TRANSACTION nm", |
| 136173 | + /* 284 */ "savepoint_opt ::= SAVEPOINT", |
| 136174 | + /* 285 */ "savepoint_opt ::=", |
| 136175 | + /* 286 */ "cmd ::= create_table create_table_args", |
| 136176 | + /* 287 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 136177 | + /* 288 */ "columnlist ::= columnname carglist", |
| 136178 | + /* 289 */ "nm ::= ID|INDEXED", |
| 136179 | + /* 290 */ "nm ::= STRING", |
| 136180 | + /* 291 */ "nm ::= JOIN_KW", |
| 136181 | + /* 292 */ "typetoken ::= typename", |
| 136182 | + /* 293 */ "typename ::= ID|STRING", |
| 136183 | + /* 294 */ "signed ::= plus_num", |
| 136184 | + /* 295 */ "signed ::= minus_num", |
| 136185 | + /* 296 */ "carglist ::= carglist ccons", |
| 136186 | + /* 297 */ "carglist ::=", |
| 136187 | + /* 298 */ "ccons ::= NULL onconf", |
| 136188 | + /* 299 */ "conslist_opt ::= COMMA conslist", |
| 136189 | + /* 300 */ "conslist ::= conslist tconscomma tcons", |
| 136190 | + /* 301 */ "conslist ::= tcons", |
| 136191 | + /* 302 */ "tconscomma ::=", |
| 136192 | + /* 303 */ "defer_subclause_opt ::= defer_subclause", |
| 136193 | + /* 304 */ "resolvetype ::= raisetype", |
| 136194 | + /* 305 */ "selectnowith ::= oneselect", |
| 136195 | + /* 306 */ "oneselect ::= values", |
| 136196 | + /* 307 */ "sclp ::= selcollist COMMA", |
| 136197 | + /* 308 */ "as ::= ID|STRING", |
| 136198 | + /* 309 */ "expr ::= term", |
| 136199 | + /* 310 */ "likeop ::= LIKE_KW|MATCH", |
| 135744 | 136200 | /* 311 */ "exprlist ::= nexprlist", |
| 135745 | 136201 | /* 312 */ "nmnum ::= plus_num", |
| 135746 | 136202 | /* 313 */ "nmnum ::= nm", |
| 135747 | 136203 | /* 314 */ "nmnum ::= ON", |
| 135748 | 136204 | /* 315 */ "nmnum ::= DELETE", |
| | @@ -136375,11 +136831,10 @@ |
| 136375 | 136831 | { 173, 3 }, |
| 136376 | 136832 | { 173, 3 }, |
| 136377 | 136833 | { 173, 3 }, |
| 136378 | 136834 | { 173, 3 }, |
| 136379 | 136835 | { 173, 3 }, |
| 136380 | | - { 221, 1 }, |
| 136381 | 136836 | { 221, 2 }, |
| 136382 | 136837 | { 173, 3 }, |
| 136383 | 136838 | { 173, 5 }, |
| 136384 | 136839 | { 173, 2 }, |
| 136385 | 136840 | { 173, 3 }, |
| | @@ -136512,10 +136967,11 @@ |
| 136512 | 136967 | { 194, 1 }, |
| 136513 | 136968 | { 195, 1 }, |
| 136514 | 136969 | { 209, 2 }, |
| 136515 | 136970 | { 210, 1 }, |
| 136516 | 136971 | { 173, 1 }, |
| 136972 | + { 221, 1 }, |
| 136517 | 136973 | { 208, 1 }, |
| 136518 | 136974 | { 230, 1 }, |
| 136519 | 136975 | { 230, 1 }, |
| 136520 | 136976 | { 230, 1 }, |
| 136521 | 136977 | { 230, 1 }, |
| | @@ -136654,11 +137110,11 @@ |
| 136654 | 137110 | case 42: /* autoinc ::= */ yytestcase(yyruleno==42); |
| 136655 | 137111 | case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57); |
| 136656 | 137112 | case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67); |
| 136657 | 137113 | case 76: /* ifexists ::= */ yytestcase(yyruleno==76); |
| 136658 | 137114 | case 90: /* distinct ::= */ yytestcase(yyruleno==90); |
| 136659 | | - case 215: /* collate ::= */ yytestcase(yyruleno==215); |
| 137115 | + case 214: /* collate ::= */ yytestcase(yyruleno==214); |
| 136660 | 137116 | {yymsp[1].minor.yy194 = 0;} |
| 136661 | 137117 | break; |
| 136662 | 137118 | case 17: /* ifnotexists ::= IF NOT EXISTS */ |
| 136663 | 137119 | {yymsp[-2].minor.yy194 = 1;} |
| 136664 | 137120 | break; |
| | @@ -136798,13 +137254,13 @@ |
| 136798 | 137254 | case 144: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==144); |
| 136799 | 137255 | {yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;} |
| 136800 | 137256 | break; |
| 136801 | 137257 | case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 136802 | 137258 | 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); |
| 137259 | + case 186: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==186); |
| 137260 | + case 189: /* in_op ::= NOT IN */ yytestcase(yyruleno==189); |
| 137261 | + case 215: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==215); |
| 136806 | 137262 | {yymsp[-1].minor.yy194 = 1;} |
| 136807 | 137263 | break; |
| 136808 | 137264 | case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 136809 | 137265 | {yymsp[-1].minor.yy194 = 0;} |
| 136810 | 137266 | break; |
| | @@ -136964,13 +137420,13 @@ |
| 136964 | 137420 | {yymsp[0].minor.yy194 = SF_All;} |
| 136965 | 137421 | break; |
| 136966 | 137422 | case 91: /* sclp ::= */ |
| 136967 | 137423 | case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119); |
| 136968 | 137424 | 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); |
| 137425 | + case 202: /* exprlist ::= */ yytestcase(yyruleno==202); |
| 137426 | + case 205: /* paren_exprlist ::= */ yytestcase(yyruleno==205); |
| 137427 | + case 210: /* eidlist_opt ::= */ yytestcase(yyruleno==210); |
| 136972 | 137428 | {yymsp[1].minor.yy148 = 0;} |
| 136973 | 137429 | break; |
| 136974 | 137430 | case 92: /* selcollist ::= sclp expr as */ |
| 136975 | 137431 | { |
| 136976 | 137432 | yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr); |
| | @@ -136992,12 +137448,12 @@ |
| 136992 | 137448 | yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot); |
| 136993 | 137449 | } |
| 136994 | 137450 | break; |
| 136995 | 137451 | case 95: /* as ::= AS nm */ |
| 136996 | 137452 | 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); |
| 137453 | + case 224: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==224); |
| 137454 | + case 225: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==225); |
| 136999 | 137455 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 137000 | 137456 | break; |
| 137001 | 137457 | case 97: /* from ::= */ |
| 137002 | 137458 | {yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));} |
| 137003 | 137459 | break; |
| | @@ -137076,18 +137532,18 @@ |
| 137076 | 137532 | {yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 137077 | 137533 | break; |
| 137078 | 137534 | case 112: /* on_opt ::= ON expr */ |
| 137079 | 137535 | case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129); |
| 137080 | 137536 | case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136); |
| 137081 | | - case 199: /* case_else ::= ELSE expr */ yytestcase(yyruleno==199); |
| 137537 | + case 198: /* case_else ::= ELSE expr */ yytestcase(yyruleno==198); |
| 137082 | 137538 | {yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;} |
| 137083 | 137539 | break; |
| 137084 | 137540 | case 113: /* on_opt ::= */ |
| 137085 | 137541 | case 128: /* having_opt ::= */ yytestcase(yyruleno==128); |
| 137086 | 137542 | case 135: /* where_opt ::= */ yytestcase(yyruleno==135); |
| 137087 | | - case 200: /* case_else ::= */ yytestcase(yyruleno==200); |
| 137088 | | - case 202: /* case_operand ::= */ yytestcase(yyruleno==202); |
| 137543 | + case 199: /* case_else ::= */ yytestcase(yyruleno==199); |
| 137544 | + case 201: /* case_operand ::= */ yytestcase(yyruleno==201); |
| 137089 | 137545 | {yymsp[1].minor.yy72 = 0;} |
| 137090 | 137546 | break; |
| 137091 | 137547 | case 115: /* indexed_opt ::= INDEXED BY nm */ |
| 137092 | 137548 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| 137093 | 137549 | break; |
| | @@ -137230,11 +137686,11 @@ |
| 137230 | 137686 | case 158: /* term ::= INTEGER */ |
| 137231 | 137687 | { |
| 137232 | 137688 | yylhsminor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); |
| 137233 | 137689 | yylhsminor.yy190.zStart = yymsp[0].minor.yy0.z; |
| 137234 | 137690 | yylhsminor.yy190.zEnd = yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n; |
| 137235 | | - if( yylhsminor.yy190.pExpr ) yylhsminor.yy190.pExpr->flags |= EP_Leaf; |
| 137691 | + if( yylhsminor.yy190.pExpr ) yylhsminor.yy190.pExpr->flags |= EP_Leaf|EP_Resolved; |
| 137236 | 137692 | } |
| 137237 | 137693 | yymsp[0].minor.yy190 = yylhsminor.yy190; |
| 137238 | 137694 | break; |
| 137239 | 137695 | case 159: /* expr ::= VARIABLE */ |
| 137240 | 137696 | { |
| | @@ -137320,17 +137776,14 @@ |
| 137320 | 137776 | case 171: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==171); |
| 137321 | 137777 | case 172: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==172); |
| 137322 | 137778 | case 173: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==173); |
| 137323 | 137779 | {spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);} |
| 137324 | 137780 | 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 */ |
| 137781 | + case 174: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 137329 | 137782 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 137330 | 137783 | break; |
| 137331 | | - case 176: /* expr ::= expr likeop expr */ |
| 137784 | + case 175: /* expr ::= expr likeop expr */ |
| 137332 | 137785 | { |
| 137333 | 137786 | ExprList *pList; |
| 137334 | 137787 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 137335 | 137788 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 137336 | 137789 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr); |
| | @@ -137339,11 +137792,11 @@ |
| 137339 | 137792 | exprNot(pParse, bNot, &yymsp[-2].minor.yy190); |
| 137340 | 137793 | yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd; |
| 137341 | 137794 | if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc; |
| 137342 | 137795 | } |
| 137343 | 137796 | break; |
| 137344 | | - case 177: /* expr ::= expr likeop expr ESCAPE expr */ |
| 137797 | + case 176: /* expr ::= expr likeop expr ESCAPE expr */ |
| 137345 | 137798 | { |
| 137346 | 137799 | ExprList *pList; |
| 137347 | 137800 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 137348 | 137801 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 137349 | 137802 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr); |
| | @@ -137353,43 +137806,43 @@ |
| 137353 | 137806 | exprNot(pParse, bNot, &yymsp[-4].minor.yy190); |
| 137354 | 137807 | yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd; |
| 137355 | 137808 | if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc; |
| 137356 | 137809 | } |
| 137357 | 137810 | break; |
| 137358 | | - case 178: /* expr ::= expr ISNULL|NOTNULL */ |
| 137811 | + case 177: /* expr ::= expr ISNULL|NOTNULL */ |
| 137359 | 137812 | {spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);} |
| 137360 | 137813 | break; |
| 137361 | | - case 179: /* expr ::= expr NOT NULL */ |
| 137814 | + case 178: /* expr ::= expr NOT NULL */ |
| 137362 | 137815 | {spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);} |
| 137363 | 137816 | break; |
| 137364 | | - case 180: /* expr ::= expr IS expr */ |
| 137817 | + case 179: /* expr ::= expr IS expr */ |
| 137365 | 137818 | { |
| 137366 | 137819 | spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190); |
| 137367 | 137820 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL); |
| 137368 | 137821 | } |
| 137369 | 137822 | break; |
| 137370 | | - case 181: /* expr ::= expr IS NOT expr */ |
| 137823 | + case 180: /* expr ::= expr IS NOT expr */ |
| 137371 | 137824 | { |
| 137372 | 137825 | spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190); |
| 137373 | 137826 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL); |
| 137374 | 137827 | } |
| 137375 | 137828 | break; |
| 137376 | | - case 182: /* expr ::= NOT expr */ |
| 137377 | | - case 183: /* expr ::= BITNOT expr */ yytestcase(yyruleno==183); |
| 137829 | + case 181: /* expr ::= NOT expr */ |
| 137830 | + case 182: /* expr ::= BITNOT expr */ yytestcase(yyruleno==182); |
| 137378 | 137831 | {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 137379 | 137832 | break; |
| 137380 | | - case 184: /* expr ::= MINUS expr */ |
| 137833 | + case 183: /* expr ::= MINUS expr */ |
| 137381 | 137834 | {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 137382 | 137835 | break; |
| 137383 | | - case 185: /* expr ::= PLUS expr */ |
| 137836 | + case 184: /* expr ::= PLUS expr */ |
| 137384 | 137837 | {spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 137385 | 137838 | break; |
| 137386 | | - case 186: /* between_op ::= BETWEEN */ |
| 137387 | | - case 189: /* in_op ::= IN */ yytestcase(yyruleno==189); |
| 137839 | + case 185: /* between_op ::= BETWEEN */ |
| 137840 | + case 188: /* in_op ::= IN */ yytestcase(yyruleno==188); |
| 137388 | 137841 | {yymsp[0].minor.yy194 = 0;} |
| 137389 | 137842 | break; |
| 137390 | | - case 188: /* expr ::= expr between_op expr AND expr */ |
| 137843 | + case 187: /* expr ::= expr between_op expr AND expr */ |
| 137391 | 137844 | { |
| 137392 | 137845 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr); |
| 137393 | 137846 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr); |
| 137394 | 137847 | yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0); |
| 137395 | 137848 | if( yymsp[-4].minor.yy190.pExpr ){ |
| | @@ -137399,11 +137852,11 @@ |
| 137399 | 137852 | } |
| 137400 | 137853 | exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 137401 | 137854 | yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd; |
| 137402 | 137855 | } |
| 137403 | 137856 | break; |
| 137404 | | - case 191: /* expr ::= expr in_op LP exprlist RP */ |
| 137857 | + case 190: /* expr ::= expr in_op LP exprlist RP */ |
| 137405 | 137858 | { |
| 137406 | 137859 | if( yymsp[-1].minor.yy148==0 ){ |
| 137407 | 137860 | /* Expressions of the form |
| 137408 | 137861 | ** |
| 137409 | 137862 | ** expr1 IN () |
| | @@ -137452,26 +137905,26 @@ |
| 137452 | 137905 | exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 137453 | 137906 | } |
| 137454 | 137907 | yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 137455 | 137908 | } |
| 137456 | 137909 | break; |
| 137457 | | - case 192: /* expr ::= LP select RP */ |
| 137910 | + case 191: /* expr ::= LP select RP */ |
| 137458 | 137911 | { |
| 137459 | 137912 | spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ |
| 137460 | 137913 | yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 137461 | 137914 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243); |
| 137462 | 137915 | } |
| 137463 | 137916 | break; |
| 137464 | | - case 193: /* expr ::= expr in_op LP select RP */ |
| 137917 | + case 192: /* expr ::= expr in_op LP select RP */ |
| 137465 | 137918 | { |
| 137466 | 137919 | yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0); |
| 137467 | 137920 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243); |
| 137468 | 137921 | exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 137469 | 137922 | yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 137470 | 137923 | } |
| 137471 | 137924 | break; |
| 137472 | | - case 194: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 137925 | + case 193: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 137473 | 137926 | { |
| 137474 | 137927 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 137475 | 137928 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| 137476 | 137929 | if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148); |
| 137477 | 137930 | yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0); |
| | @@ -137478,19 +137931,19 @@ |
| 137478 | 137931 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect); |
| 137479 | 137932 | exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 137480 | 137933 | 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 | 137934 | } |
| 137482 | 137935 | break; |
| 137483 | | - case 195: /* expr ::= EXISTS LP select RP */ |
| 137936 | + case 194: /* expr ::= EXISTS LP select RP */ |
| 137484 | 137937 | { |
| 137485 | 137938 | Expr *p; |
| 137486 | 137939 | spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ |
| 137487 | 137940 | p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 137488 | 137941 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243); |
| 137489 | 137942 | } |
| 137490 | 137943 | break; |
| 137491 | | - case 196: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 137944 | + case 195: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 137492 | 137945 | { |
| 137493 | 137946 | spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/ |
| 137494 | 137947 | yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0); |
| 137495 | 137948 | if( yymsp[-4].minor.yy190.pExpr ){ |
| 137496 | 137949 | 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 +137952,314 @@ |
| 137499 | 137952 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148); |
| 137500 | 137953 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72); |
| 137501 | 137954 | } |
| 137502 | 137955 | } |
| 137503 | 137956 | break; |
| 137504 | | - case 197: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 137957 | + case 196: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 137505 | 137958 | { |
| 137506 | 137959 | yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr); |
| 137507 | 137960 | yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr); |
| 137508 | 137961 | } |
| 137509 | 137962 | break; |
| 137510 | | - case 198: /* case_exprlist ::= WHEN expr THEN expr */ |
| 137963 | + case 197: /* case_exprlist ::= WHEN expr THEN expr */ |
| 137511 | 137964 | { |
| 137512 | 137965 | yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr); |
| 137513 | 137966 | yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr); |
| 137514 | 137967 | } |
| 137515 | 137968 | break; |
| 137516 | | - case 201: /* case_operand ::= expr */ |
| 137969 | + case 200: /* case_operand ::= expr */ |
| 137517 | 137970 | {yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/} |
| 137518 | 137971 | break; |
| 137519 | | - case 204: /* nexprlist ::= nexprlist COMMA expr */ |
| 137972 | + case 203: /* nexprlist ::= nexprlist COMMA expr */ |
| 137520 | 137973 | {yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);} |
| 137521 | 137974 | break; |
| 137522 | | - case 205: /* nexprlist ::= expr */ |
| 137975 | + case 204: /* nexprlist ::= expr */ |
| 137523 | 137976 | {yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/} |
| 137524 | 137977 | break; |
| 137525 | | - case 207: /* paren_exprlist ::= LP exprlist RP */ |
| 137526 | | - case 212: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==212); |
| 137978 | + case 206: /* paren_exprlist ::= LP exprlist RP */ |
| 137979 | + case 211: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==211); |
| 137527 | 137980 | {yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;} |
| 137528 | 137981 | break; |
| 137529 | | - case 208: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 137982 | + case 207: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 137530 | 137983 | { |
| 137531 | 137984 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 137532 | 137985 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194, |
| 137533 | 137986 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF); |
| 137534 | 137987 | } |
| 137535 | 137988 | break; |
| 137536 | | - case 209: /* uniqueflag ::= UNIQUE */ |
| 137537 | | - case 250: /* raisetype ::= ABORT */ yytestcase(yyruleno==250); |
| 137989 | + case 208: /* uniqueflag ::= UNIQUE */ |
| 137990 | + case 249: /* raisetype ::= ABORT */ yytestcase(yyruleno==249); |
| 137538 | 137991 | {yymsp[0].minor.yy194 = OE_Abort;} |
| 137539 | 137992 | break; |
| 137540 | | - case 210: /* uniqueflag ::= */ |
| 137993 | + case 209: /* uniqueflag ::= */ |
| 137541 | 137994 | {yymsp[1].minor.yy194 = OE_None;} |
| 137542 | 137995 | break; |
| 137543 | | - case 213: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 137996 | + case 212: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 137544 | 137997 | { |
| 137545 | 137998 | yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); |
| 137546 | 137999 | } |
| 137547 | 138000 | break; |
| 137548 | | - case 214: /* eidlist ::= nm collate sortorder */ |
| 138001 | + case 213: /* eidlist ::= nm collate sortorder */ |
| 137549 | 138002 | { |
| 137550 | 138003 | yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/ |
| 137551 | 138004 | } |
| 137552 | 138005 | break; |
| 137553 | | - case 217: /* cmd ::= DROP INDEX ifexists fullname */ |
| 138006 | + case 216: /* cmd ::= DROP INDEX ifexists fullname */ |
| 137554 | 138007 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);} |
| 137555 | 138008 | break; |
| 137556 | | - case 218: /* cmd ::= VACUUM */ |
| 138009 | + case 217: /* cmd ::= VACUUM */ |
| 137557 | 138010 | {sqlite3Vacuum(pParse,0);} |
| 137558 | 138011 | break; |
| 137559 | | - case 219: /* cmd ::= VACUUM nm */ |
| 138012 | + case 218: /* cmd ::= VACUUM nm */ |
| 137560 | 138013 | {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);} |
| 137561 | 138014 | break; |
| 137562 | | - case 220: /* cmd ::= PRAGMA nm dbnm */ |
| 138015 | + case 219: /* cmd ::= PRAGMA nm dbnm */ |
| 137563 | 138016 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 137564 | 138017 | break; |
| 137565 | | - case 221: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 138018 | + case 220: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 137566 | 138019 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 137567 | 138020 | break; |
| 137568 | | - case 222: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 138021 | + case 221: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 137569 | 138022 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 137570 | 138023 | break; |
| 137571 | | - case 223: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 138024 | + case 222: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 137572 | 138025 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 137573 | 138026 | break; |
| 137574 | | - case 224: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 138027 | + case 223: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 137575 | 138028 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 137576 | 138029 | break; |
| 137577 | | - case 227: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 138030 | + case 226: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 137578 | 138031 | { |
| 137579 | 138032 | Token all; |
| 137580 | 138033 | all.z = yymsp[-3].minor.yy0.z; |
| 137581 | 138034 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 137582 | 138035 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all); |
| 137583 | 138036 | } |
| 137584 | 138037 | break; |
| 137585 | | - case 228: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 138038 | + case 227: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 137586 | 138039 | { |
| 137587 | 138040 | 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 | 138041 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 137589 | 138042 | } |
| 137590 | 138043 | break; |
| 137591 | | - case 229: /* trigger_time ::= BEFORE */ |
| 138044 | + case 228: /* trigger_time ::= BEFORE */ |
| 137592 | 138045 | { yymsp[0].minor.yy194 = TK_BEFORE; } |
| 137593 | 138046 | break; |
| 137594 | | - case 230: /* trigger_time ::= AFTER */ |
| 138047 | + case 229: /* trigger_time ::= AFTER */ |
| 137595 | 138048 | { yymsp[0].minor.yy194 = TK_AFTER; } |
| 137596 | 138049 | break; |
| 137597 | | - case 231: /* trigger_time ::= INSTEAD OF */ |
| 138050 | + case 230: /* trigger_time ::= INSTEAD OF */ |
| 137598 | 138051 | { yymsp[-1].minor.yy194 = TK_INSTEAD;} |
| 137599 | 138052 | break; |
| 137600 | | - case 232: /* trigger_time ::= */ |
| 138053 | + case 231: /* trigger_time ::= */ |
| 137601 | 138054 | { yymsp[1].minor.yy194 = TK_BEFORE; } |
| 137602 | 138055 | break; |
| 137603 | | - case 233: /* trigger_event ::= DELETE|INSERT */ |
| 137604 | | - case 234: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==234); |
| 138056 | + case 232: /* trigger_event ::= DELETE|INSERT */ |
| 138057 | + case 233: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==233); |
| 137605 | 138058 | {yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;} |
| 137606 | 138059 | break; |
| 137607 | | - case 235: /* trigger_event ::= UPDATE OF idlist */ |
| 138060 | + case 234: /* trigger_event ::= UPDATE OF idlist */ |
| 137608 | 138061 | {yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;} |
| 137609 | 138062 | break; |
| 137610 | | - case 236: /* when_clause ::= */ |
| 137611 | | - case 255: /* key_opt ::= */ yytestcase(yyruleno==255); |
| 138063 | + case 235: /* when_clause ::= */ |
| 138064 | + case 254: /* key_opt ::= */ yytestcase(yyruleno==254); |
| 137612 | 138065 | { yymsp[1].minor.yy72 = 0; } |
| 137613 | 138066 | break; |
| 137614 | | - case 237: /* when_clause ::= WHEN expr */ |
| 137615 | | - case 256: /* key_opt ::= KEY expr */ yytestcase(yyruleno==256); |
| 138067 | + case 236: /* when_clause ::= WHEN expr */ |
| 138068 | + case 255: /* key_opt ::= KEY expr */ yytestcase(yyruleno==255); |
| 137616 | 138069 | { yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; } |
| 137617 | 138070 | break; |
| 137618 | | - case 238: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 138071 | + case 237: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 137619 | 138072 | { |
| 137620 | 138073 | assert( yymsp[-2].minor.yy145!=0 ); |
| 137621 | 138074 | yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145; |
| 137622 | 138075 | yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145; |
| 137623 | 138076 | } |
| 137624 | 138077 | break; |
| 137625 | | - case 239: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 138078 | + case 238: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 137626 | 138079 | { |
| 137627 | 138080 | assert( yymsp[-1].minor.yy145!=0 ); |
| 137628 | 138081 | yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145; |
| 137629 | 138082 | } |
| 137630 | 138083 | break; |
| 137631 | | - case 240: /* trnm ::= nm DOT nm */ |
| 138084 | + case 239: /* trnm ::= nm DOT nm */ |
| 137632 | 138085 | { |
| 137633 | 138086 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 137634 | 138087 | sqlite3ErrorMsg(pParse, |
| 137635 | 138088 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 137636 | 138089 | "statements within triggers"); |
| 137637 | 138090 | } |
| 137638 | 138091 | break; |
| 137639 | | - case 241: /* tridxby ::= INDEXED BY nm */ |
| 138092 | + case 240: /* tridxby ::= INDEXED BY nm */ |
| 137640 | 138093 | { |
| 137641 | 138094 | sqlite3ErrorMsg(pParse, |
| 137642 | 138095 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 137643 | 138096 | "within triggers"); |
| 137644 | 138097 | } |
| 137645 | 138098 | break; |
| 137646 | | - case 242: /* tridxby ::= NOT INDEXED */ |
| 138099 | + case 241: /* tridxby ::= NOT INDEXED */ |
| 137647 | 138100 | { |
| 137648 | 138101 | sqlite3ErrorMsg(pParse, |
| 137649 | 138102 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 137650 | 138103 | "within triggers"); |
| 137651 | 138104 | } |
| 137652 | 138105 | break; |
| 137653 | | - case 243: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 138106 | + case 242: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 137654 | 138107 | {yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);} |
| 137655 | 138108 | break; |
| 137656 | | - case 244: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */ |
| 138109 | + case 243: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */ |
| 137657 | 138110 | {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 | 138111 | break; |
| 137659 | | - case 245: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 138112 | + case 244: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 137660 | 138113 | {yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);} |
| 137661 | 138114 | break; |
| 137662 | | - case 246: /* trigger_cmd ::= select */ |
| 138115 | + case 245: /* trigger_cmd ::= select */ |
| 137663 | 138116 | {yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/} |
| 137664 | 138117 | break; |
| 137665 | | - case 247: /* expr ::= RAISE LP IGNORE RP */ |
| 138118 | + case 246: /* expr ::= RAISE LP IGNORE RP */ |
| 137666 | 138119 | { |
| 137667 | 138120 | spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 137668 | 138121 | yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 137669 | 138122 | if( yymsp[-3].minor.yy190.pExpr ){ |
| 137670 | 138123 | yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore; |
| 137671 | 138124 | } |
| 137672 | 138125 | } |
| 137673 | 138126 | break; |
| 137674 | | - case 248: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 138127 | + case 247: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 137675 | 138128 | { |
| 137676 | 138129 | spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 137677 | 138130 | yymsp[-5].minor.yy190.pExpr = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 137678 | 138131 | if( yymsp[-5].minor.yy190.pExpr ) { |
| 137679 | 138132 | yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194; |
| 137680 | 138133 | } |
| 137681 | 138134 | } |
| 137682 | 138135 | break; |
| 137683 | | - case 249: /* raisetype ::= ROLLBACK */ |
| 138136 | + case 248: /* raisetype ::= ROLLBACK */ |
| 137684 | 138137 | {yymsp[0].minor.yy194 = OE_Rollback;} |
| 137685 | 138138 | break; |
| 137686 | | - case 251: /* raisetype ::= FAIL */ |
| 138139 | + case 250: /* raisetype ::= FAIL */ |
| 137687 | 138140 | {yymsp[0].minor.yy194 = OE_Fail;} |
| 137688 | 138141 | break; |
| 137689 | | - case 252: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 138142 | + case 251: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 137690 | 138143 | { |
| 137691 | 138144 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194); |
| 137692 | 138145 | } |
| 137693 | 138146 | break; |
| 137694 | | - case 253: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 138147 | + case 252: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 137695 | 138148 | { |
| 137696 | 138149 | sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72); |
| 137697 | 138150 | } |
| 137698 | 138151 | break; |
| 137699 | | - case 254: /* cmd ::= DETACH database_kw_opt expr */ |
| 138152 | + case 253: /* cmd ::= DETACH database_kw_opt expr */ |
| 137700 | 138153 | { |
| 137701 | 138154 | sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr); |
| 137702 | 138155 | } |
| 137703 | 138156 | break; |
| 137704 | | - case 257: /* cmd ::= REINDEX */ |
| 138157 | + case 256: /* cmd ::= REINDEX */ |
| 137705 | 138158 | {sqlite3Reindex(pParse, 0, 0);} |
| 137706 | 138159 | break; |
| 137707 | | - case 258: /* cmd ::= REINDEX nm dbnm */ |
| 138160 | + case 257: /* cmd ::= REINDEX nm dbnm */ |
| 137708 | 138161 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 137709 | 138162 | break; |
| 137710 | | - case 259: /* cmd ::= ANALYZE */ |
| 138163 | + case 258: /* cmd ::= ANALYZE */ |
| 137711 | 138164 | {sqlite3Analyze(pParse, 0, 0);} |
| 137712 | 138165 | break; |
| 137713 | | - case 260: /* cmd ::= ANALYZE nm dbnm */ |
| 138166 | + case 259: /* cmd ::= ANALYZE nm dbnm */ |
| 137714 | 138167 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 137715 | 138168 | break; |
| 137716 | | - case 261: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 138169 | + case 260: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 137717 | 138170 | { |
| 137718 | 138171 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0); |
| 137719 | 138172 | } |
| 137720 | 138173 | break; |
| 137721 | | - case 262: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 138174 | + case 261: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 137722 | 138175 | { |
| 137723 | 138176 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 137724 | 138177 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 137725 | 138178 | } |
| 137726 | 138179 | break; |
| 137727 | | - case 263: /* add_column_fullname ::= fullname */ |
| 138180 | + case 262: /* add_column_fullname ::= fullname */ |
| 137728 | 138181 | { |
| 137729 | 138182 | disableLookaside(pParse); |
| 137730 | 138183 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185); |
| 137731 | 138184 | } |
| 137732 | 138185 | break; |
| 137733 | | - case 264: /* cmd ::= create_vtab */ |
| 138186 | + case 263: /* cmd ::= create_vtab */ |
| 137734 | 138187 | {sqlite3VtabFinishParse(pParse,0);} |
| 137735 | 138188 | break; |
| 137736 | | - case 265: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 138189 | + case 264: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 137737 | 138190 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 137738 | 138191 | break; |
| 137739 | | - case 266: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 138192 | + case 265: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 137740 | 138193 | { |
| 137741 | 138194 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194); |
| 137742 | 138195 | } |
| 137743 | 138196 | break; |
| 137744 | | - case 267: /* vtabarg ::= */ |
| 138197 | + case 266: /* vtabarg ::= */ |
| 137745 | 138198 | {sqlite3VtabArgInit(pParse);} |
| 137746 | 138199 | break; |
| 137747 | | - case 268: /* vtabargtoken ::= ANY */ |
| 137748 | | - case 269: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==269); |
| 137749 | | - case 270: /* lp ::= LP */ yytestcase(yyruleno==270); |
| 138200 | + case 267: /* vtabargtoken ::= ANY */ |
| 138201 | + case 268: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==268); |
| 138202 | + case 269: /* lp ::= LP */ yytestcase(yyruleno==269); |
| 137750 | 138203 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 137751 | 138204 | break; |
| 137752 | | - case 271: /* with ::= */ |
| 138205 | + case 270: /* with ::= */ |
| 137753 | 138206 | {yymsp[1].minor.yy285 = 0;} |
| 137754 | 138207 | break; |
| 137755 | | - case 272: /* with ::= WITH wqlist */ |
| 138208 | + case 271: /* with ::= WITH wqlist */ |
| 137756 | 138209 | { yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; } |
| 137757 | 138210 | break; |
| 137758 | | - case 273: /* with ::= WITH RECURSIVE wqlist */ |
| 138211 | + case 272: /* with ::= WITH RECURSIVE wqlist */ |
| 137759 | 138212 | { yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; } |
| 137760 | 138213 | break; |
| 137761 | | - case 274: /* wqlist ::= nm eidlist_opt AS LP select RP */ |
| 138214 | + case 273: /* wqlist ::= nm eidlist_opt AS LP select RP */ |
| 137762 | 138215 | { |
| 137763 | 138216 | yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/ |
| 137764 | 138217 | } |
| 137765 | 138218 | break; |
| 137766 | | - case 275: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ |
| 138219 | + case 274: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ |
| 137767 | 138220 | { |
| 137768 | 138221 | yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); |
| 137769 | 138222 | } |
| 137770 | 138223 | break; |
| 137771 | 138224 | 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); |
| 138225 | + /* (275) input ::= cmdlist */ yytestcase(yyruleno==275); |
| 138226 | + /* (276) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==276); |
| 138227 | + /* (277) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=277); |
| 138228 | + /* (278) ecmd ::= SEMI */ yytestcase(yyruleno==278); |
| 138229 | + /* (279) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==279); |
| 138230 | + /* (280) explain ::= */ yytestcase(yyruleno==280); |
| 138231 | + /* (281) trans_opt ::= */ yytestcase(yyruleno==281); |
| 138232 | + /* (282) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==282); |
| 138233 | + /* (283) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==283); |
| 138234 | + /* (284) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==284); |
| 138235 | + /* (285) savepoint_opt ::= */ yytestcase(yyruleno==285); |
| 138236 | + /* (286) cmd ::= create_table create_table_args */ yytestcase(yyruleno==286); |
| 138237 | + /* (287) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==287); |
| 138238 | + /* (288) columnlist ::= columnname carglist */ yytestcase(yyruleno==288); |
| 138239 | + /* (289) nm ::= ID|INDEXED */ yytestcase(yyruleno==289); |
| 138240 | + /* (290) nm ::= STRING */ yytestcase(yyruleno==290); |
| 138241 | + /* (291) nm ::= JOIN_KW */ yytestcase(yyruleno==291); |
| 138242 | + /* (292) typetoken ::= typename */ yytestcase(yyruleno==292); |
| 138243 | + /* (293) typename ::= ID|STRING */ yytestcase(yyruleno==293); |
| 138244 | + /* (294) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=294); |
| 138245 | + /* (295) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=295); |
| 138246 | + /* (296) carglist ::= carglist ccons */ yytestcase(yyruleno==296); |
| 138247 | + /* (297) carglist ::= */ yytestcase(yyruleno==297); |
| 138248 | + /* (298) ccons ::= NULL onconf */ yytestcase(yyruleno==298); |
| 138249 | + /* (299) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==299); |
| 138250 | + /* (300) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==300); |
| 138251 | + /* (301) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=301); |
| 138252 | + /* (302) tconscomma ::= */ yytestcase(yyruleno==302); |
| 138253 | + /* (303) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=303); |
| 138254 | + /* (304) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=304); |
| 138255 | + /* (305) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=305); |
| 138256 | + /* (306) oneselect ::= values */ yytestcase(yyruleno==306); |
| 138257 | + /* (307) sclp ::= selcollist COMMA */ yytestcase(yyruleno==307); |
| 138258 | + /* (308) as ::= ID|STRING */ yytestcase(yyruleno==308); |
| 138259 | + /* (309) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=309); |
| 138260 | + /* (310) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==310); |
| 137807 | 138261 | /* (311) exprlist ::= nexprlist */ yytestcase(yyruleno==311); |
| 137808 | 138262 | /* (312) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=312); |
| 137809 | 138263 | /* (313) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=313); |
| 137810 | 138264 | /* (314) nmnum ::= ON */ yytestcase(yyruleno==314); |
| 137811 | 138265 | /* (315) nmnum ::= DELETE */ yytestcase(yyruleno==315); |
| | @@ -138854,12 +139308,12 @@ |
| 138854 | 139308 | ** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that |
| 138855 | 139309 | ** error message. |
| 138856 | 139310 | */ |
| 138857 | 139311 | SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ |
| 138858 | 139312 | int nErr = 0; /* Number of errors encountered */ |
| 138859 | | - int i; /* Loop counter */ |
| 138860 | 139313 | void *pEngine; /* The LEMON-generated LALR(1) parser */ |
| 139314 | + int n = 0; /* Length of the next token token */ |
| 138861 | 139315 | int tokenType; /* type of the next token */ |
| 138862 | 139316 | int lastTokenParsed = -1; /* type of the previous token */ |
| 138863 | 139317 | sqlite3 *db = pParse->db; /* The database connection */ |
| 138864 | 139318 | int mxSqlLen; /* Max length of an SQL string */ |
| 138865 | 139319 | #ifdef sqlite3Parser_ENGINEALWAYSONSTACK |
| | @@ -138871,11 +139325,10 @@ |
| 138871 | 139325 | if( db->nVdbeActive==0 ){ |
| 138872 | 139326 | db->u1.isInterrupted = 0; |
| 138873 | 139327 | } |
| 138874 | 139328 | pParse->rc = SQLITE_OK; |
| 138875 | 139329 | pParse->zTail = zSql; |
| 138876 | | - i = 0; |
| 138877 | 139330 | assert( pzErrMsg!=0 ); |
| 138878 | 139331 | /* sqlite3ParserTrace(stdout, "parser: "); */ |
| 138879 | 139332 | #ifdef sqlite3Parser_ENGINEALWAYSONSTACK |
| 138880 | 139333 | pEngine = zSpace; |
| 138881 | 139334 | sqlite3ParserInit(pEngine); |
| | @@ -138889,16 +139342,14 @@ |
| 138889 | 139342 | assert( pParse->pNewTable==0 ); |
| 138890 | 139343 | assert( pParse->pNewTrigger==0 ); |
| 138891 | 139344 | assert( pParse->nVar==0 ); |
| 138892 | 139345 | assert( pParse->pVList==0 ); |
| 138893 | 139346 | while( 1 ){ |
| 138894 | | - assert( i>=0 ); |
| 138895 | | - if( zSql[i]!=0 ){ |
| 138896 | | - pParse->sLastToken.z = &zSql[i]; |
| 138897 | | - pParse->sLastToken.n = sqlite3GetToken((u8*)&zSql[i],&tokenType); |
| 138898 | | - i += pParse->sLastToken.n; |
| 138899 | | - if( i>mxSqlLen ){ |
| 139347 | + if( zSql[0]!=0 ){ |
| 139348 | + n = sqlite3GetToken((u8*)zSql, &tokenType); |
| 139349 | + mxSqlLen -= n; |
| 139350 | + if( mxSqlLen<0 ){ |
| 138900 | 139351 | pParse->rc = SQLITE_TOOBIG; |
| 138901 | 139352 | break; |
| 138902 | 139353 | } |
| 138903 | 139354 | }else{ |
| 138904 | 139355 | /* Upon reaching the end of input, call the parser two more times |
| | @@ -138908,30 +139359,34 @@ |
| 138908 | 139359 | }else if( lastTokenParsed==0 ){ |
| 138909 | 139360 | break; |
| 138910 | 139361 | }else{ |
| 138911 | 139362 | tokenType = TK_SEMI; |
| 138912 | 139363 | } |
| 139364 | + zSql -= n; |
| 138913 | 139365 | } |
| 138914 | 139366 | if( tokenType>=TK_SPACE ){ |
| 138915 | 139367 | assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL ); |
| 138916 | 139368 | if( db->u1.isInterrupted ){ |
| 138917 | 139369 | pParse->rc = SQLITE_INTERRUPT; |
| 138918 | 139370 | break; |
| 138919 | 139371 | } |
| 138920 | 139372 | if( tokenType==TK_ILLEGAL ){ |
| 138921 | | - sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", |
| 138922 | | - &pParse->sLastToken); |
| 139373 | + sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql); |
| 138923 | 139374 | break; |
| 138924 | 139375 | } |
| 139376 | + zSql += n; |
| 138925 | 139377 | }else{ |
| 139378 | + pParse->sLastToken.z = zSql; |
| 139379 | + pParse->sLastToken.n = n; |
| 138926 | 139380 | sqlite3Parser(pEngine, tokenType, pParse->sLastToken, pParse); |
| 138927 | 139381 | lastTokenParsed = tokenType; |
| 139382 | + zSql += n; |
| 138928 | 139383 | if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break; |
| 138929 | 139384 | } |
| 138930 | 139385 | } |
| 138931 | 139386 | assert( nErr==0 ); |
| 138932 | | - pParse->zTail = &zSql[i]; |
| 139387 | + pParse->zTail = zSql; |
| 138933 | 139388 | #ifdef YYTRACKMAXSTACKDEPTH |
| 138934 | 139389 | sqlite3_mutex_enter(sqlite3MallocMutex()); |
| 138935 | 139390 | sqlite3StatusHighwater(SQLITE_STATUS_PARSER_STACK, |
| 138936 | 139391 | sqlite3ParserStackPeak(pEngine) |
| 138937 | 139392 | ); |
| | @@ -140301,10 +140756,25 @@ |
| 140301 | 140756 | return 0; |
| 140302 | 140757 | } |
| 140303 | 140758 | #endif |
| 140304 | 140759 | return db->lastRowid; |
| 140305 | 140760 | } |
| 140761 | + |
| 140762 | +/* |
| 140763 | +** Set the value returned by the sqlite3_last_insert_rowid() API function. |
| 140764 | +*/ |
| 140765 | +SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *db, sqlite3_int64 iRowid){ |
| 140766 | +#ifdef SQLITE_ENABLE_API_ARMOR |
| 140767 | + if( !sqlite3SafetyCheckOk(db) ){ |
| 140768 | + (void)SQLITE_MISUSE_BKPT; |
| 140769 | + return; |
| 140770 | + } |
| 140771 | +#endif |
| 140772 | + sqlite3_mutex_enter(db->mutex); |
| 140773 | + db->lastRowid = iRowid; |
| 140774 | + sqlite3_mutex_leave(db->mutex); |
| 140775 | +} |
| 140306 | 140776 | |
| 140307 | 140777 | /* |
| 140308 | 140778 | ** Return the number of changes in the most recent call to sqlite3_exec(). |
| 140309 | 140779 | */ |
| 140310 | 140780 | SQLITE_API int sqlite3_changes(sqlite3 *db){ |
| | @@ -148111,12 +148581,14 @@ |
| 148111 | 148581 | ** segments. |
| 148112 | 148582 | */ |
| 148113 | 148583 | const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */ |
| 148114 | 148584 | |
| 148115 | 148585 | Fts3Table *p = (Fts3Table*)pVtab; |
| 148116 | | - int rc = sqlite3Fts3PendingTermsFlush(p); |
| 148586 | + int rc; |
| 148587 | + i64 iLastRowid = sqlite3_last_insert_rowid(p->db); |
| 148117 | 148588 | |
| 148589 | + rc = sqlite3Fts3PendingTermsFlush(p); |
| 148118 | 148590 | if( rc==SQLITE_OK |
| 148119 | 148591 | && p->nLeafAdd>(nMinMerge/16) |
| 148120 | 148592 | && p->nAutoincrmerge && p->nAutoincrmerge!=0xff |
| 148121 | 148593 | ){ |
| 148122 | 148594 | int mxLevel = 0; /* Maximum relative level value in db */ |
| | @@ -148127,10 +148599,11 @@ |
| 148127 | 148599 | A = p->nLeafAdd * mxLevel; |
| 148128 | 148600 | A += (A/2); |
| 148129 | 148601 | if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, p->nAutoincrmerge); |
| 148130 | 148602 | } |
| 148131 | 148603 | sqlite3Fts3SegmentsClose(p); |
| 148604 | + sqlite3_set_last_insert_rowid(p->db, iLastRowid); |
| 148132 | 148605 | return rc; |
| 148133 | 148606 | } |
| 148134 | 148607 | |
| 148135 | 148608 | /* |
| 148136 | 148609 | ** If it is currently unknown whether or not the FTS table has an %_stat |
| | @@ -168462,10 +168935,11 @@ |
| 168462 | 168935 | int nStep; /* Rows processed for current object */ |
| 168463 | 168936 | int nProgress; /* Rows processed for all objects */ |
| 168464 | 168937 | RbuObjIter objiter; /* Iterator for skipping through tbl/idx */ |
| 168465 | 168938 | const char *zVfsName; /* Name of automatically created rbu vfs */ |
| 168466 | 168939 | rbu_file *pTargetFd; /* File handle open on target db */ |
| 168940 | + int nPagePerSector; /* Pages per sector for pTargetFd */ |
| 168467 | 168941 | i64 iOalSz; |
| 168468 | 168942 | i64 nPhaseOneStep; |
| 168469 | 168943 | |
| 168470 | 168944 | /* The following state variables are used as part of the incremental |
| 168471 | 168945 | ** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding |
| | @@ -170726,10 +171200,27 @@ |
| 170726 | 171200 | |
| 170727 | 171201 | if( p->rc==SQLITE_OK ){ |
| 170728 | 171202 | if( p->nFrame==0 || (pState && pState->iWalCksum!=p->iWalCksum) ){ |
| 170729 | 171203 | p->rc = SQLITE_DONE; |
| 170730 | 171204 | p->eStage = RBU_STAGE_DONE; |
| 171205 | + }else{ |
| 171206 | + int nSectorSize; |
| 171207 | + sqlite3_file *pDb = p->pTargetFd->pReal; |
| 171208 | + sqlite3_file *pWal = p->pTargetFd->pWalFd->pReal; |
| 171209 | + assert( p->nPagePerSector==0 ); |
| 171210 | + nSectorSize = pDb->pMethods->xSectorSize(pDb); |
| 171211 | + if( nSectorSize>p->pgsz ){ |
| 171212 | + p->nPagePerSector = nSectorSize / p->pgsz; |
| 171213 | + }else{ |
| 171214 | + p->nPagePerSector = 1; |
| 171215 | + } |
| 171216 | + |
| 171217 | + /* Call xSync() on the wal file. This causes SQLite to sync the |
| 171218 | + ** directory in which the target database and the wal file reside, in |
| 171219 | + ** case it has not been synced since the rename() call in |
| 171220 | + ** rbuMoveOalFile(). */ |
| 171221 | + p->rc = pWal->pMethods->xSync(pWal, SQLITE_SYNC_NORMAL); |
| 170731 | 171222 | } |
| 170732 | 171223 | } |
| 170733 | 171224 | } |
| 170734 | 171225 | |
| 170735 | 171226 | /* |
| | @@ -171381,13 +171872,30 @@ |
| 171381 | 171872 | if( p->rc==SQLITE_OK ){ |
| 171382 | 171873 | p->eStage = RBU_STAGE_DONE; |
| 171383 | 171874 | p->rc = SQLITE_DONE; |
| 171384 | 171875 | } |
| 171385 | 171876 | }else{ |
| 171386 | | - RbuFrame *pFrame = &p->aFrame[p->nStep]; |
| 171387 | | - rbuCheckpointFrame(p, pFrame); |
| 171388 | | - p->nStep++; |
| 171877 | + /* At one point the following block copied a single frame from the |
| 171878 | + ** wal file to the database file. So that one call to sqlite3rbu_step() |
| 171879 | + ** checkpointed a single frame. |
| 171880 | + ** |
| 171881 | + ** However, if the sector-size is larger than the page-size, and the |
| 171882 | + ** application calls sqlite3rbu_savestate() or close() immediately |
| 171883 | + ** after this step, then rbu_step() again, then a power failure occurs, |
| 171884 | + ** then the database page written here may be damaged. Work around |
| 171885 | + ** this by checkpointing frames until the next page in the aFrame[] |
| 171886 | + ** lies on a different disk sector to the current one. */ |
| 171887 | + u32 iSector; |
| 171888 | + do{ |
| 171889 | + RbuFrame *pFrame = &p->aFrame[p->nStep]; |
| 171890 | + iSector = (pFrame->iDbPage-1) / p->nPagePerSector; |
| 171891 | + rbuCheckpointFrame(p, pFrame); |
| 171892 | + p->nStep++; |
| 171893 | + }while( p->nStep<p->nFrame |
| 171894 | + && iSector==((p->aFrame[p->nStep].iDbPage-1) / p->nPagePerSector) |
| 171895 | + && p->rc==SQLITE_OK |
| 171896 | + ); |
| 171389 | 171897 | } |
| 171390 | 171898 | p->nProgress++; |
| 171391 | 171899 | } |
| 171392 | 171900 | break; |
| 171393 | 171901 | } |
| | @@ -171823,10 +172331,16 @@ |
| 171823 | 172331 | |
| 171824 | 172332 | /* Commit the transaction to the *-oal file. */ |
| 171825 | 172333 | if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){ |
| 171826 | 172334 | p->rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, &p->zErrmsg); |
| 171827 | 172335 | } |
| 172336 | + |
| 172337 | + /* Sync the db file if currently doing an incremental checkpoint */ |
| 172338 | + if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){ |
| 172339 | + sqlite3_file *pDb = p->pTargetFd->pReal; |
| 172340 | + p->rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL); |
| 172341 | + } |
| 171828 | 172342 | |
| 171829 | 172343 | rbuSaveState(p, p->eStage); |
| 171830 | 172344 | |
| 171831 | 172345 | if( p->rc==SQLITE_OK && p->eStage==RBU_STAGE_OAL ){ |
| 171832 | 172346 | p->rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, &p->zErrmsg); |
| | @@ -171947,10 +172461,16 @@ |
| 171947 | 172461 | assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE ); |
| 171948 | 172462 | if( p->eStage==RBU_STAGE_OAL ){ |
| 171949 | 172463 | assert( rc!=SQLITE_DONE ); |
| 171950 | 172464 | if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0); |
| 171951 | 172465 | } |
| 172466 | + |
| 172467 | + /* Sync the db file */ |
| 172468 | + if( rc==SQLITE_OK && p->eStage==RBU_STAGE_CKPT ){ |
| 172469 | + sqlite3_file *pDb = p->pTargetFd->pReal; |
| 172470 | + rc = pDb->pMethods->xSync(pDb, SQLITE_SYNC_NORMAL); |
| 172471 | + } |
| 171952 | 172472 | |
| 171953 | 172473 | p->rc = rc; |
| 171954 | 172474 | rbuSaveState(p, p->eStage); |
| 171955 | 172475 | rc = p->rc; |
| 171956 | 172476 | |
| | @@ -181079,11 +181599,13 @@ |
| 181079 | 181599 | typedef unsigned short u16; |
| 181080 | 181600 | typedef short i16; |
| 181081 | 181601 | typedef sqlite3_int64 i64; |
| 181082 | 181602 | typedef sqlite3_uint64 u64; |
| 181083 | 181603 | |
| 181084 | | -#define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0]))) |
| 181604 | +#ifndef ArraySize |
| 181605 | +# define ArraySize(x) ((int)(sizeof(x) / sizeof(x[0]))) |
| 181606 | +#endif |
| 181085 | 181607 | |
| 181086 | 181608 | #define testcase(x) |
| 181087 | 181609 | #define ALWAYS(x) 1 |
| 181088 | 181610 | #define NEVER(x) 0 |
| 181089 | 181611 | |
| | @@ -186302,11 +186824,14 @@ |
| 186302 | 186824 | if( p1->bEof==0 ){ |
| 186303 | 186825 | if( (p1->iRowid==iLast) |
| 186304 | 186826 | || (bFromValid && fts5RowidCmp(pExpr, p1->iRowid, iFrom)<0) |
| 186305 | 186827 | ){ |
| 186306 | 186828 | int rc = fts5ExprNodeNext(pExpr, p1, bFromValid, iFrom); |
| 186307 | | - if( rc!=SQLITE_OK ) return rc; |
| 186829 | + if( rc!=SQLITE_OK ){ |
| 186830 | + pNode->bNomatch = 0; |
| 186831 | + return rc; |
| 186832 | + } |
| 186308 | 186833 | } |
| 186309 | 186834 | } |
| 186310 | 186835 | } |
| 186311 | 186836 | |
| 186312 | 186837 | fts5ExprNodeTest_OR(pExpr, pNode); |
| | @@ -186333,11 +186858,14 @@ |
| 186333 | 186858 | Fts5ExprNode *pChild = pAnd->apChild[iChild]; |
| 186334 | 186859 | int cmp = fts5RowidCmp(pExpr, iLast, pChild->iRowid); |
| 186335 | 186860 | if( cmp>0 ){ |
| 186336 | 186861 | /* Advance pChild until it points to iLast or laster */ |
| 186337 | 186862 | rc = fts5ExprNodeNext(pExpr, pChild, 1, iLast); |
| 186338 | | - if( rc!=SQLITE_OK ) return rc; |
| 186863 | + if( rc!=SQLITE_OK ){ |
| 186864 | + pAnd->bNomatch = 0; |
| 186865 | + return rc; |
| 186866 | + } |
| 186339 | 186867 | } |
| 186340 | 186868 | |
| 186341 | 186869 | /* If the child node is now at EOF, so is the parent AND node. Otherwise, |
| 186342 | 186870 | ** the child node is guaranteed to have advanced at least as far as |
| 186343 | 186871 | ** rowid iLast. So if it is not at exactly iLast, pChild->iRowid is the |
| | @@ -186372,10 +186900,12 @@ |
| 186372 | 186900 | i64 iFrom |
| 186373 | 186901 | ){ |
| 186374 | 186902 | int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom); |
| 186375 | 186903 | if( rc==SQLITE_OK ){ |
| 186376 | 186904 | rc = fts5ExprNodeTest_AND(pExpr, pNode); |
| 186905 | + }else{ |
| 186906 | + pNode->bNomatch = 0; |
| 186377 | 186907 | } |
| 186378 | 186908 | return rc; |
| 186379 | 186909 | } |
| 186380 | 186910 | |
| 186381 | 186911 | static int fts5ExprNodeTest_NOT( |
| | @@ -186414,10 +186944,13 @@ |
| 186414 | 186944 | ){ |
| 186415 | 186945 | int rc = fts5ExprNodeNext(pExpr, pNode->apChild[0], bFromValid, iFrom); |
| 186416 | 186946 | if( rc==SQLITE_OK ){ |
| 186417 | 186947 | rc = fts5ExprNodeTest_NOT(pExpr, pNode); |
| 186418 | 186948 | } |
| 186949 | + if( rc!=SQLITE_OK ){ |
| 186950 | + pNode->bNomatch = 0; |
| 186951 | + } |
| 186419 | 186952 | return rc; |
| 186420 | 186953 | } |
| 186421 | 186954 | |
| 186422 | 186955 | /* |
| 186423 | 186956 | ** If pNode currently points to a match, this function returns SQLITE_OK |
| | @@ -197534,11 +198067,11 @@ |
| 197534 | 198067 | int nArg, /* Number of args */ |
| 197535 | 198068 | sqlite3_value **apUnused /* Function arguments */ |
| 197536 | 198069 | ){ |
| 197537 | 198070 | assert( nArg==0 ); |
| 197538 | 198071 | UNUSED_PARAM2(nArg, apUnused); |
| 197539 | | - sqlite3_result_text(pCtx, "fts5: 2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c", -1, SQLITE_TRANSIENT); |
| 198072 | + sqlite3_result_text(pCtx, "fts5: 2017-03-10 17:03:11 f8560c60d10c0365b33342ab05b5a953987b0471", -1, SQLITE_TRANSIENT); |
| 197540 | 198073 | } |
| 197541 | 198074 | |
| 197542 | 198075 | static int fts5Init(sqlite3 *db){ |
| 197543 | 198076 | static const sqlite3_module fts5Mod = { |
| 197544 | 198077 | /* iVersion */ 2, |
| | @@ -198197,15 +198730,10 @@ |
| 198197 | 198730 | sqlite3_step(pDel); |
| 198198 | 198731 | rc = sqlite3_reset(pDel); |
| 198199 | 198732 | } |
| 198200 | 198733 | } |
| 198201 | 198734 | |
| 198202 | | - /* Write the averages record */ |
| 198203 | | - if( rc==SQLITE_OK ){ |
| 198204 | | - rc = fts5StorageSaveTotals(p); |
| 198205 | | - } |
| 198206 | | - |
| 198207 | 198735 | return rc; |
| 198208 | 198736 | } |
| 198209 | 198737 | |
| 198210 | 198738 | /* |
| 198211 | 198739 | ** Delete all entries in the FTS5 index. |
| | @@ -198405,15 +198933,10 @@ |
| 198405 | 198933 | if( rc==SQLITE_OK ){ |
| 198406 | 198934 | rc = fts5StorageInsertDocsize(p, iRowid, &buf); |
| 198407 | 198935 | } |
| 198408 | 198936 | sqlite3_free(buf.p); |
| 198409 | 198937 | |
| 198410 | | - /* Write the averages record */ |
| 198411 | | - if( rc==SQLITE_OK ){ |
| 198412 | | - rc = fts5StorageSaveTotals(p); |
| 198413 | | - } |
| 198414 | | - |
| 198415 | 198938 | return rc; |
| 198416 | 198939 | } |
| 198417 | 198940 | |
| 198418 | 198941 | static int fts5StorageCount(Fts5Storage *p, const char *zSuffix, i64 *pnRow){ |
| 198419 | 198942 | Fts5Config *pConfig = p->pConfig; |
| | @@ -198744,16 +199267,21 @@ |
| 198744 | 199267 | |
| 198745 | 199268 | /* |
| 198746 | 199269 | ** Flush any data currently held in-memory to disk. |
| 198747 | 199270 | */ |
| 198748 | 199271 | 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; |
| 199272 | + int rc = SQLITE_OK; |
| 199273 | + i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); |
| 199274 | + if( p->bTotalsValid ){ |
| 199275 | + rc = fts5StorageSaveTotals(p); |
| 199276 | + if( bCommit ) p->bTotalsValid = 0; |
| 198753 | 199277 | } |
| 198754 | | - return sqlite3Fts5IndexSync(p->pIndex, bCommit); |
| 199278 | + if( rc==SQLITE_OK ){ |
| 199279 | + rc = sqlite3Fts5IndexSync(p->pIndex, bCommit); |
| 199280 | + } |
| 199281 | + sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid); |
| 199282 | + return rc; |
| 198755 | 199283 | } |
| 198756 | 199284 | |
| 198757 | 199285 | static int sqlite3Fts5StorageRollback(Fts5Storage *p){ |
| 198758 | 199286 | p->bTotalsValid = 0; |
| 198759 | 199287 | return sqlite3Fts5IndexRollback(p->pIndex); |
| 198760 | 199288 | |