| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.18.0. By combining all the individual C code files into this |
| 3 | +** version 3.19.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.18.0" |
| 402 | | -#define SQLITE_VERSION_NUMBER 3018000 |
| 403 | | -#define SQLITE_SOURCE_ID "2017-03-28 18:48:43 424a0d380332858ee55bdebc4af3789f74e70a2b3ba1cf29d84b9b4bcf3e2e37" |
| 401 | +#define SQLITE_VERSION "3.19.0" |
| 402 | +#define SQLITE_VERSION_NUMBER 3019000 |
| 403 | +#define SQLITE_SOURCE_ID "2017-05-02 18:00:31 430f539cbb3f806fb89191e0b759a5f8b49d9e5b6c95fe9a4b55a1aa0875762a" |
| 404 | 404 | |
| 405 | 405 | /* |
| 406 | 406 | ** CAPI3REF: Run-Time Library Version Numbers |
| 407 | 407 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 408 | 408 | ** |
| | @@ -1132,11 +1132,11 @@ |
| 1132 | 1132 | ** of 25 milliseconds before the first retry and with the delay increasing |
| 1133 | 1133 | ** by an additional 25 milliseconds with each subsequent retry. This |
| 1134 | 1134 | ** opcode allows these two values (10 retries and 25 milliseconds of delay) |
| 1135 | 1135 | ** to be adjusted. The values are changed for all database connections |
| 1136 | 1136 | ** within the same process. The argument is a pointer to an array of two |
| 1137 | | -** integers where the first integer i the new retry count and the second |
| 1137 | +** integers where the first integer is the new retry count and the second |
| 1138 | 1138 | ** integer is the delay. If either integer is negative, then the setting |
| 1139 | 1139 | ** is not changed but instead the prior value of that setting is written |
| 1140 | 1140 | ** into the array entry, allowing the current retry settings to be |
| 1141 | 1141 | ** interrogated. The zDbName parameter is ignored. |
| 1142 | 1142 | ** |
| | @@ -2486,13 +2486,10 @@ |
| 2486 | 2486 | ** that are started after the running statement count reaches zero are |
| 2487 | 2487 | ** not effected by the sqlite3_interrupt(). |
| 2488 | 2488 | ** ^A call to sqlite3_interrupt(D) that occurs when there are no running |
| 2489 | 2489 | ** SQL statements is a no-op and has no effect on SQL statements |
| 2490 | 2490 | ** that are started after the sqlite3_interrupt() call returns. |
| 2491 | | -** |
| 2492 | | -** If the database connection closes while [sqlite3_interrupt()] |
| 2493 | | -** is running then bad things will likely happen. |
| 2494 | 2491 | */ |
| 2495 | 2492 | SQLITE_API void sqlite3_interrupt(sqlite3*); |
| 2496 | 2493 | |
| 2497 | 2494 | /* |
| 2498 | 2495 | ** CAPI3REF: Determine If An SQL Statement Is Complete |
| | @@ -3980,11 +3977,11 @@ |
| 3980 | 3977 | ** Unprotected sqlite3_value objects may only be used with |
| 3981 | 3978 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. |
| 3982 | 3979 | ** The [sqlite3_value_blob | sqlite3_value_type()] family of |
| 3983 | 3980 | ** interfaces require protected sqlite3_value objects. |
| 3984 | 3981 | */ |
| 3985 | | -typedef struct Mem sqlite3_value; |
| 3982 | +typedef struct sqlite3_value sqlite3_value; |
| 3986 | 3983 | |
| 3987 | 3984 | /* |
| 3988 | 3985 | ** CAPI3REF: SQL Function Context Object |
| 3989 | 3986 | ** |
| 3990 | 3987 | ** The context in which an SQL function executes is stored in an |
| | @@ -11451,80 +11448,80 @@ |
| 11451 | 11448 | #define TK_LP 22 |
| 11452 | 11449 | #define TK_RP 23 |
| 11453 | 11450 | #define TK_AS 24 |
| 11454 | 11451 | #define TK_WITHOUT 25 |
| 11455 | 11452 | #define TK_COMMA 26 |
| 11456 | | -#define TK_OR 27 |
| 11457 | | -#define TK_AND 28 |
| 11458 | | -#define TK_IS 29 |
| 11459 | | -#define TK_MATCH 30 |
| 11460 | | -#define TK_LIKE_KW 31 |
| 11461 | | -#define TK_BETWEEN 32 |
| 11462 | | -#define TK_IN 33 |
| 11463 | | -#define TK_ISNULL 34 |
| 11464 | | -#define TK_NOTNULL 35 |
| 11465 | | -#define TK_NE 36 |
| 11466 | | -#define TK_EQ 37 |
| 11467 | | -#define TK_GT 38 |
| 11468 | | -#define TK_LE 39 |
| 11469 | | -#define TK_LT 40 |
| 11470 | | -#define TK_GE 41 |
| 11471 | | -#define TK_ESCAPE 42 |
| 11472 | | -#define TK_BITAND 43 |
| 11473 | | -#define TK_BITOR 44 |
| 11474 | | -#define TK_LSHIFT 45 |
| 11475 | | -#define TK_RSHIFT 46 |
| 11476 | | -#define TK_PLUS 47 |
| 11477 | | -#define TK_MINUS 48 |
| 11478 | | -#define TK_STAR 49 |
| 11479 | | -#define TK_SLASH 50 |
| 11480 | | -#define TK_REM 51 |
| 11481 | | -#define TK_CONCAT 52 |
| 11482 | | -#define TK_COLLATE 53 |
| 11483 | | -#define TK_BITNOT 54 |
| 11484 | | -#define TK_ID 55 |
| 11485 | | -#define TK_INDEXED 56 |
| 11486 | | -#define TK_ABORT 57 |
| 11487 | | -#define TK_ACTION 58 |
| 11488 | | -#define TK_AFTER 59 |
| 11489 | | -#define TK_ANALYZE 60 |
| 11490 | | -#define TK_ASC 61 |
| 11491 | | -#define TK_ATTACH 62 |
| 11492 | | -#define TK_BEFORE 63 |
| 11493 | | -#define TK_BY 64 |
| 11494 | | -#define TK_CASCADE 65 |
| 11495 | | -#define TK_CAST 66 |
| 11496 | | -#define TK_COLUMNKW 67 |
| 11497 | | -#define TK_CONFLICT 68 |
| 11498 | | -#define TK_DATABASE 69 |
| 11499 | | -#define TK_DESC 70 |
| 11500 | | -#define TK_DETACH 71 |
| 11501 | | -#define TK_EACH 72 |
| 11502 | | -#define TK_FAIL 73 |
| 11503 | | -#define TK_FOR 74 |
| 11504 | | -#define TK_IGNORE 75 |
| 11505 | | -#define TK_INITIALLY 76 |
| 11506 | | -#define TK_INSTEAD 77 |
| 11507 | | -#define TK_NO 78 |
| 11508 | | -#define TK_KEY 79 |
| 11509 | | -#define TK_OF 80 |
| 11510 | | -#define TK_OFFSET 81 |
| 11511 | | -#define TK_PRAGMA 82 |
| 11512 | | -#define TK_RAISE 83 |
| 11513 | | -#define TK_RECURSIVE 84 |
| 11514 | | -#define TK_REPLACE 85 |
| 11515 | | -#define TK_RESTRICT 86 |
| 11516 | | -#define TK_ROW 87 |
| 11517 | | -#define TK_TRIGGER 88 |
| 11518 | | -#define TK_VACUUM 89 |
| 11519 | | -#define TK_VIEW 90 |
| 11520 | | -#define TK_VIRTUAL 91 |
| 11521 | | -#define TK_WITH 92 |
| 11522 | | -#define TK_REINDEX 93 |
| 11523 | | -#define TK_RENAME 94 |
| 11524 | | -#define TK_CTIME_KW 95 |
| 11525 | | -#define TK_ANY 96 |
| 11453 | +#define TK_ID 27 |
| 11454 | +#define TK_ABORT 28 |
| 11455 | +#define TK_ACTION 29 |
| 11456 | +#define TK_AFTER 30 |
| 11457 | +#define TK_ANALYZE 31 |
| 11458 | +#define TK_ASC 32 |
| 11459 | +#define TK_ATTACH 33 |
| 11460 | +#define TK_BEFORE 34 |
| 11461 | +#define TK_BY 35 |
| 11462 | +#define TK_CASCADE 36 |
| 11463 | +#define TK_CAST 37 |
| 11464 | +#define TK_COLUMNKW 38 |
| 11465 | +#define TK_CONFLICT 39 |
| 11466 | +#define TK_DATABASE 40 |
| 11467 | +#define TK_DESC 41 |
| 11468 | +#define TK_DETACH 42 |
| 11469 | +#define TK_EACH 43 |
| 11470 | +#define TK_FAIL 44 |
| 11471 | +#define TK_FOR 45 |
| 11472 | +#define TK_IGNORE 46 |
| 11473 | +#define TK_INITIALLY 47 |
| 11474 | +#define TK_INSTEAD 48 |
| 11475 | +#define TK_LIKE_KW 49 |
| 11476 | +#define TK_MATCH 50 |
| 11477 | +#define TK_NO 51 |
| 11478 | +#define TK_KEY 52 |
| 11479 | +#define TK_OF 53 |
| 11480 | +#define TK_OFFSET 54 |
| 11481 | +#define TK_PRAGMA 55 |
| 11482 | +#define TK_RAISE 56 |
| 11483 | +#define TK_RECURSIVE 57 |
| 11484 | +#define TK_REPLACE 58 |
| 11485 | +#define TK_RESTRICT 59 |
| 11486 | +#define TK_ROW 60 |
| 11487 | +#define TK_TRIGGER 61 |
| 11488 | +#define TK_VACUUM 62 |
| 11489 | +#define TK_VIEW 63 |
| 11490 | +#define TK_VIRTUAL 64 |
| 11491 | +#define TK_WITH 65 |
| 11492 | +#define TK_REINDEX 66 |
| 11493 | +#define TK_RENAME 67 |
| 11494 | +#define TK_CTIME_KW 68 |
| 11495 | +#define TK_ANY 69 |
| 11496 | +#define TK_OR 70 |
| 11497 | +#define TK_AND 71 |
| 11498 | +#define TK_IS 72 |
| 11499 | +#define TK_BETWEEN 73 |
| 11500 | +#define TK_IN 74 |
| 11501 | +#define TK_ISNULL 75 |
| 11502 | +#define TK_NOTNULL 76 |
| 11503 | +#define TK_NE 77 |
| 11504 | +#define TK_EQ 78 |
| 11505 | +#define TK_GT 79 |
| 11506 | +#define TK_LE 80 |
| 11507 | +#define TK_LT 81 |
| 11508 | +#define TK_GE 82 |
| 11509 | +#define TK_ESCAPE 83 |
| 11510 | +#define TK_BITAND 84 |
| 11511 | +#define TK_BITOR 85 |
| 11512 | +#define TK_LSHIFT 86 |
| 11513 | +#define TK_RSHIFT 87 |
| 11514 | +#define TK_PLUS 88 |
| 11515 | +#define TK_MINUS 89 |
| 11516 | +#define TK_STAR 90 |
| 11517 | +#define TK_SLASH 91 |
| 11518 | +#define TK_REM 92 |
| 11519 | +#define TK_CONCAT 93 |
| 11520 | +#define TK_COLLATE 94 |
| 11521 | +#define TK_BITNOT 95 |
| 11522 | +#define TK_INDEXED 96 |
| 11526 | 11523 | #define TK_STRING 97 |
| 11527 | 11524 | #define TK_JOIN_KW 98 |
| 11528 | 11525 | #define TK_CONSTRAINT 99 |
| 11529 | 11526 | #define TK_DEFAULT 100 |
| 11530 | 11527 | #define TK_NULL 101 |
| | @@ -11584,14 +11581,15 @@ |
| 11584 | 11581 | #define TK_UMINUS 155 |
| 11585 | 11582 | #define TK_UPLUS 156 |
| 11586 | 11583 | #define TK_REGISTER 157 |
| 11587 | 11584 | #define TK_VECTOR 158 |
| 11588 | 11585 | #define TK_SELECT_COLUMN 159 |
| 11589 | | -#define TK_ASTERISK 160 |
| 11590 | | -#define TK_SPAN 161 |
| 11591 | | -#define TK_SPACE 162 |
| 11592 | | -#define TK_ILLEGAL 163 |
| 11586 | +#define TK_IF_NULL_ROW 160 |
| 11587 | +#define TK_ASTERISK 161 |
| 11588 | +#define TK_SPAN 162 |
| 11589 | +#define TK_SPACE 163 |
| 11590 | +#define TK_ILLEGAL 164 |
| 11593 | 11591 | |
| 11594 | 11592 | /* The token codes above must all fit in 8 bits */ |
| 11595 | 11593 | #define TKFLG_MASK 0xff |
| 11596 | 11594 | |
| 11597 | 11595 | /* Flags that can be added to a token code when it is not |
| | @@ -12458,11 +12456,11 @@ |
| 12458 | 12456 | */ |
| 12459 | 12457 | struct BtreePayload { |
| 12460 | 12458 | const void *pKey; /* Key content for indexes. NULL for tables */ |
| 12461 | 12459 | sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */ |
| 12462 | 12460 | const void *pData; /* Data for tables. NULL for indexes */ |
| 12463 | | - struct Mem *aMem; /* First of nMem value in the unpacked pKey */ |
| 12461 | + sqlite3_value *aMem; /* First of nMem value in the unpacked pKey */ |
| 12464 | 12462 | u16 nMem; /* Number of aMem[] value. Might be zero */ |
| 12465 | 12463 | int nData; /* Size of pData. 0 if none. */ |
| 12466 | 12464 | int nZero; /* Extra zero data appended after pData,nData */ |
| 12467 | 12465 | }; |
| 12468 | 12466 | |
| | @@ -12588,11 +12586,11 @@ |
| 12588 | 12586 | |
| 12589 | 12587 | /* |
| 12590 | 12588 | ** The names of the following types declared in vdbeInt.h are required |
| 12591 | 12589 | ** for the VdbeOp definition. |
| 12592 | 12590 | */ |
| 12593 | | -typedef struct Mem Mem; |
| 12591 | +typedef struct sqlite3_value Mem; |
| 12594 | 12592 | typedef struct SubProgram SubProgram; |
| 12595 | 12593 | |
| 12596 | 12594 | /* |
| 12597 | 12595 | ** A single instruction of the virtual machine has an opcode |
| 12598 | 12596 | ** and as many as three operands. The instruction is recorded |
| | @@ -12748,151 +12746,153 @@ |
| 12748 | 12746 | #define OP_Jump 18 |
| 12749 | 12747 | #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */ |
| 12750 | 12748 | #define OP_Once 20 |
| 12751 | 12749 | #define OP_If 21 |
| 12752 | 12750 | #define OP_IfNot 22 |
| 12753 | | -#define OP_SeekLT 23 /* synopsis: key=r[P3@P4] */ |
| 12754 | | -#define OP_SeekLE 24 /* synopsis: key=r[P3@P4] */ |
| 12755 | | -#define OP_SeekGE 25 /* synopsis: key=r[P3@P4] */ |
| 12756 | | -#define OP_SeekGT 26 /* synopsis: key=r[P3@P4] */ |
| 12757 | | -#define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 12758 | | -#define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 12759 | | -#define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */ |
| 12760 | | -#define OP_NotFound 30 /* synopsis: key=r[P3@P4] */ |
| 12761 | | -#define OP_Found 31 /* synopsis: key=r[P3@P4] */ |
| 12762 | | -#define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */ |
| 12763 | | -#define OP_NotExists 33 /* synopsis: intkey=r[P3] */ |
| 12764 | | -#define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 12765 | | -#define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 12766 | | -#define OP_Ne 36 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 12767 | | -#define OP_Eq 37 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 12768 | | -#define OP_Gt 38 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 12769 | | -#define OP_Le 39 /* same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 12770 | | -#define OP_Lt 40 /* same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 12771 | | -#define OP_Ge 41 /* same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 12772 | | -#define OP_ElseNotEq 42 /* same as TK_ESCAPE */ |
| 12773 | | -#define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 12774 | | -#define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 12775 | | -#define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 12776 | | -#define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 12777 | | -#define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 12778 | | -#define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 12779 | | -#define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 12780 | | -#define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 12781 | | -#define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 12782 | | -#define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 12783 | | -#define OP_Last 53 |
| 12784 | | -#define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 12785 | | -#define OP_IfSmaller 55 |
| 12786 | | -#define OP_SorterSort 56 |
| 12787 | | -#define OP_Sort 57 |
| 12788 | | -#define OP_Rewind 58 |
| 12789 | | -#define OP_IdxLE 59 /* synopsis: key=r[P3@P4] */ |
| 12790 | | -#define OP_IdxGT 60 /* synopsis: key=r[P3@P4] */ |
| 12791 | | -#define OP_IdxLT 61 /* synopsis: key=r[P3@P4] */ |
| 12792 | | -#define OP_IdxGE 62 /* synopsis: key=r[P3@P4] */ |
| 12793 | | -#define OP_RowSetRead 63 /* synopsis: r[P3]=rowset(P1) */ |
| 12794 | | -#define OP_RowSetTest 64 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 12795 | | -#define OP_Program 65 |
| 12796 | | -#define OP_FkIfZero 66 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 12797 | | -#define OP_IfPos 67 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 12798 | | -#define OP_IfNotZero 68 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 12799 | | -#define OP_DecrJumpZero 69 /* synopsis: if (--r[P1])==0 goto P2 */ |
| 12800 | | -#define OP_IncrVacuum 70 |
| 12801 | | -#define OP_VNext 71 |
| 12802 | | -#define OP_Init 72 /* synopsis: Start at P2 */ |
| 12803 | | -#define OP_Return 73 |
| 12804 | | -#define OP_EndCoroutine 74 |
| 12805 | | -#define OP_HaltIfNull 75 /* synopsis: if r[P3]=null halt */ |
| 12806 | | -#define OP_Halt 76 |
| 12807 | | -#define OP_Integer 77 /* synopsis: r[P2]=P1 */ |
| 12808 | | -#define OP_Int64 78 /* synopsis: r[P2]=P4 */ |
| 12809 | | -#define OP_String 79 /* synopsis: r[P2]='P4' (len=P1) */ |
| 12810 | | -#define OP_Null 80 /* synopsis: r[P2..P3]=NULL */ |
| 12811 | | -#define OP_SoftNull 81 /* synopsis: r[P1]=NULL */ |
| 12812 | | -#define OP_Blob 82 /* synopsis: r[P2]=P4 (len=P1) */ |
| 12813 | | -#define OP_Variable 83 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 12814 | | -#define OP_Move 84 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 12815 | | -#define OP_Copy 85 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 12816 | | -#define OP_SCopy 86 /* synopsis: r[P2]=r[P1] */ |
| 12817 | | -#define OP_IntCopy 87 /* synopsis: r[P2]=r[P1] */ |
| 12818 | | -#define OP_ResultRow 88 /* synopsis: output=r[P1@P2] */ |
| 12819 | | -#define OP_CollSeq 89 |
| 12820 | | -#define OP_Function0 90 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12821 | | -#define OP_Function 91 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12822 | | -#define OP_AddImm 92 /* synopsis: r[P1]=r[P1]+P2 */ |
| 12823 | | -#define OP_RealAffinity 93 |
| 12751 | +#define OP_IfNullRow 23 /* synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */ |
| 12752 | +#define OP_SeekLT 24 /* synopsis: key=r[P3@P4] */ |
| 12753 | +#define OP_SeekLE 25 /* synopsis: key=r[P3@P4] */ |
| 12754 | +#define OP_SeekGE 26 /* synopsis: key=r[P3@P4] */ |
| 12755 | +#define OP_SeekGT 27 /* synopsis: key=r[P3@P4] */ |
| 12756 | +#define OP_NoConflict 28 /* synopsis: key=r[P3@P4] */ |
| 12757 | +#define OP_NotFound 29 /* synopsis: key=r[P3@P4] */ |
| 12758 | +#define OP_Found 30 /* synopsis: key=r[P3@P4] */ |
| 12759 | +#define OP_SeekRowid 31 /* synopsis: intkey=r[P3] */ |
| 12760 | +#define OP_NotExists 32 /* synopsis: intkey=r[P3] */ |
| 12761 | +#define OP_Last 33 |
| 12762 | +#define OP_IfSmaller 34 |
| 12763 | +#define OP_SorterSort 35 |
| 12764 | +#define OP_Sort 36 |
| 12765 | +#define OP_Rewind 37 |
| 12766 | +#define OP_IdxLE 38 /* synopsis: key=r[P3@P4] */ |
| 12767 | +#define OP_IdxGT 39 /* synopsis: key=r[P3@P4] */ |
| 12768 | +#define OP_IdxLT 40 /* synopsis: key=r[P3@P4] */ |
| 12769 | +#define OP_IdxGE 41 /* synopsis: key=r[P3@P4] */ |
| 12770 | +#define OP_RowSetRead 42 /* synopsis: r[P3]=rowset(P1) */ |
| 12771 | +#define OP_RowSetTest 43 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 12772 | +#define OP_Program 44 |
| 12773 | +#define OP_FkIfZero 45 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 12774 | +#define OP_IfPos 46 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 12775 | +#define OP_IfNotZero 47 /* synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 12776 | +#define OP_DecrJumpZero 48 /* synopsis: if (--r[P1])==0 goto P2 */ |
| 12777 | +#define OP_IncrVacuum 49 |
| 12778 | +#define OP_VNext 50 |
| 12779 | +#define OP_Init 51 /* synopsis: Start at P2 */ |
| 12780 | +#define OP_Return 52 |
| 12781 | +#define OP_EndCoroutine 53 |
| 12782 | +#define OP_HaltIfNull 54 /* synopsis: if r[P3]=null halt */ |
| 12783 | +#define OP_Halt 55 |
| 12784 | +#define OP_Integer 56 /* synopsis: r[P2]=P1 */ |
| 12785 | +#define OP_Int64 57 /* synopsis: r[P2]=P4 */ |
| 12786 | +#define OP_String 58 /* synopsis: r[P2]='P4' (len=P1) */ |
| 12787 | +#define OP_Null 59 /* synopsis: r[P2..P3]=NULL */ |
| 12788 | +#define OP_SoftNull 60 /* synopsis: r[P1]=NULL */ |
| 12789 | +#define OP_Blob 61 /* synopsis: r[P2]=P4 (len=P1) */ |
| 12790 | +#define OP_Variable 62 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 12791 | +#define OP_Move 63 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 12792 | +#define OP_Copy 64 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 12793 | +#define OP_SCopy 65 /* synopsis: r[P2]=r[P1] */ |
| 12794 | +#define OP_IntCopy 66 /* synopsis: r[P2]=r[P1] */ |
| 12795 | +#define OP_ResultRow 67 /* synopsis: output=r[P1@P2] */ |
| 12796 | +#define OP_CollSeq 68 |
| 12797 | +#define OP_Function0 69 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12798 | +#define OP_Or 70 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 12799 | +#define OP_And 71 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 12800 | +#define OP_Function 72 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12801 | +#define OP_AddImm 73 /* synopsis: r[P1]=r[P1]+P2 */ |
| 12802 | +#define OP_RealAffinity 74 |
| 12803 | +#define OP_IsNull 75 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 12804 | +#define OP_NotNull 76 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 12805 | +#define OP_Ne 77 /* same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 12806 | +#define OP_Eq 78 /* same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 12807 | +#define OP_Gt 79 /* same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 12808 | +#define OP_Le 80 /* same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 12809 | +#define OP_Lt 81 /* same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 12810 | +#define OP_Ge 82 /* same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 12811 | +#define OP_ElseNotEq 83 /* same as TK_ESCAPE */ |
| 12812 | +#define OP_BitAnd 84 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 12813 | +#define OP_BitOr 85 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 12814 | +#define OP_ShiftLeft 86 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 12815 | +#define OP_ShiftRight 87 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 12816 | +#define OP_Add 88 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 12817 | +#define OP_Subtract 89 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 12818 | +#define OP_Multiply 90 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 12819 | +#define OP_Divide 91 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 12820 | +#define OP_Remainder 92 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 12821 | +#define OP_Concat 93 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 12824 | 12822 | #define OP_Cast 94 /* synopsis: affinity(r[P1]) */ |
| 12825 | | -#define OP_Permutation 95 |
| 12826 | | -#define OP_Compare 96 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 12823 | +#define OP_BitNot 95 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 12824 | +#define OP_Permutation 96 |
| 12827 | 12825 | #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 12828 | | -#define OP_Column 98 /* synopsis: r[P3]=PX */ |
| 12829 | | -#define OP_Affinity 99 /* synopsis: affinity(r[P1@P2]) */ |
| 12830 | | -#define OP_MakeRecord 100 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 12831 | | -#define OP_Count 101 /* synopsis: r[P2]=count() */ |
| 12832 | | -#define OP_ReadCookie 102 |
| 12833 | | -#define OP_SetCookie 103 |
| 12834 | | -#define OP_ReopenIdx 104 /* synopsis: root=P2 iDb=P3 */ |
| 12835 | | -#define OP_OpenRead 105 /* synopsis: root=P2 iDb=P3 */ |
| 12836 | | -#define OP_OpenWrite 106 /* synopsis: root=P2 iDb=P3 */ |
| 12837 | | -#define OP_OpenAutoindex 107 /* synopsis: nColumn=P2 */ |
| 12838 | | -#define OP_OpenEphemeral 108 /* synopsis: nColumn=P2 */ |
| 12839 | | -#define OP_SorterOpen 109 |
| 12840 | | -#define OP_SequenceTest 110 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 12841 | | -#define OP_OpenPseudo 111 /* synopsis: P3 columns in r[P2] */ |
| 12842 | | -#define OP_Close 112 |
| 12843 | | -#define OP_ColumnsUsed 113 |
| 12844 | | -#define OP_Sequence 114 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 12845 | | -#define OP_NewRowid 115 /* synopsis: r[P2]=rowid */ |
| 12846 | | -#define OP_Insert 116 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 12847 | | -#define OP_InsertInt 117 /* synopsis: intkey=P3 data=r[P2] */ |
| 12848 | | -#define OP_Delete 118 |
| 12849 | | -#define OP_ResetCount 119 |
| 12850 | | -#define OP_SorterCompare 120 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 12851 | | -#define OP_SorterData 121 /* synopsis: r[P2]=data */ |
| 12852 | | -#define OP_RowData 122 /* synopsis: r[P2]=data */ |
| 12853 | | -#define OP_Rowid 123 /* synopsis: r[P2]=rowid */ |
| 12854 | | -#define OP_NullRow 124 |
| 12855 | | -#define OP_SorterInsert 125 /* synopsis: key=r[P2] */ |
| 12856 | | -#define OP_IdxInsert 126 /* synopsis: key=r[P2] */ |
| 12857 | | -#define OP_IdxDelete 127 /* synopsis: key=r[P2@P3] */ |
| 12858 | | -#define OP_Seek 128 /* synopsis: Move P3 to P1.rowid */ |
| 12859 | | -#define OP_IdxRowid 129 /* synopsis: r[P2]=rowid */ |
| 12860 | | -#define OP_Destroy 130 |
| 12861 | | -#define OP_Clear 131 |
| 12826 | +#define OP_Compare 98 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 12827 | +#define OP_Column 99 /* synopsis: r[P3]=PX */ |
| 12828 | +#define OP_Affinity 100 /* synopsis: affinity(r[P1@P2]) */ |
| 12829 | +#define OP_MakeRecord 101 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 12830 | +#define OP_Count 102 /* synopsis: r[P2]=count() */ |
| 12831 | +#define OP_ReadCookie 103 |
| 12832 | +#define OP_SetCookie 104 |
| 12833 | +#define OP_ReopenIdx 105 /* synopsis: root=P2 iDb=P3 */ |
| 12834 | +#define OP_OpenRead 106 /* synopsis: root=P2 iDb=P3 */ |
| 12835 | +#define OP_OpenWrite 107 /* synopsis: root=P2 iDb=P3 */ |
| 12836 | +#define OP_OpenDup 108 |
| 12837 | +#define OP_OpenAutoindex 109 /* synopsis: nColumn=P2 */ |
| 12838 | +#define OP_OpenEphemeral 110 /* synopsis: nColumn=P2 */ |
| 12839 | +#define OP_SorterOpen 111 |
| 12840 | +#define OP_SequenceTest 112 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 12841 | +#define OP_OpenPseudo 113 /* synopsis: P3 columns in r[P2] */ |
| 12842 | +#define OP_Close 114 |
| 12843 | +#define OP_ColumnsUsed 115 |
| 12844 | +#define OP_Sequence 116 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 12845 | +#define OP_NewRowid 117 /* synopsis: r[P2]=rowid */ |
| 12846 | +#define OP_Insert 118 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 12847 | +#define OP_InsertInt 119 /* synopsis: intkey=P3 data=r[P2] */ |
| 12848 | +#define OP_Delete 120 |
| 12849 | +#define OP_ResetCount 121 |
| 12850 | +#define OP_SorterCompare 122 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 12851 | +#define OP_SorterData 123 /* synopsis: r[P2]=data */ |
| 12852 | +#define OP_RowData 124 /* synopsis: r[P2]=data */ |
| 12853 | +#define OP_Rowid 125 /* synopsis: r[P2]=rowid */ |
| 12854 | +#define OP_NullRow 126 |
| 12855 | +#define OP_SorterInsert 127 /* synopsis: key=r[P2] */ |
| 12856 | +#define OP_IdxInsert 128 /* synopsis: key=r[P2] */ |
| 12857 | +#define OP_IdxDelete 129 /* synopsis: key=r[P2@P3] */ |
| 12858 | +#define OP_Seek 130 /* synopsis: Move P3 to P1.rowid */ |
| 12859 | +#define OP_IdxRowid 131 /* synopsis: r[P2]=rowid */ |
| 12862 | 12860 | #define OP_Real 132 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 12863 | | -#define OP_ResetSorter 133 |
| 12864 | | -#define OP_CreateIndex 134 /* synopsis: r[P2]=root iDb=P1 */ |
| 12865 | | -#define OP_CreateTable 135 /* synopsis: r[P2]=root iDb=P1 */ |
| 12866 | | -#define OP_SqlExec 136 |
| 12867 | | -#define OP_ParseSchema 137 |
| 12868 | | -#define OP_LoadAnalysis 138 |
| 12869 | | -#define OP_DropTable 139 |
| 12870 | | -#define OP_DropIndex 140 |
| 12871 | | -#define OP_DropTrigger 141 |
| 12872 | | -#define OP_IntegrityCk 142 |
| 12873 | | -#define OP_RowSetAdd 143 /* synopsis: rowset(P1)=r[P2] */ |
| 12874 | | -#define OP_Param 144 |
| 12875 | | -#define OP_FkCounter 145 /* synopsis: fkctr[P1]+=P2 */ |
| 12876 | | -#define OP_MemMax 146 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 12877 | | -#define OP_OffsetLimit 147 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 12878 | | -#define OP_AggStep0 148 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12879 | | -#define OP_AggStep 149 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12880 | | -#define OP_AggFinal 150 /* synopsis: accum=r[P1] N=P2 */ |
| 12881 | | -#define OP_Expire 151 |
| 12882 | | -#define OP_TableLock 152 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 12883 | | -#define OP_VBegin 153 |
| 12884 | | -#define OP_VCreate 154 |
| 12885 | | -#define OP_VDestroy 155 |
| 12886 | | -#define OP_VOpen 156 |
| 12887 | | -#define OP_VColumn 157 /* synopsis: r[P3]=vcolumn(P2) */ |
| 12888 | | -#define OP_VRename 158 |
| 12889 | | -#define OP_Pagecount 159 |
| 12890 | | -#define OP_MaxPgcnt 160 |
| 12891 | | -#define OP_CursorHint 161 |
| 12892 | | -#define OP_Noop 162 |
| 12893 | | -#define OP_Explain 163 |
| 12861 | +#define OP_Destroy 133 |
| 12862 | +#define OP_Clear 134 |
| 12863 | +#define OP_ResetSorter 135 |
| 12864 | +#define OP_CreateIndex 136 /* synopsis: r[P2]=root iDb=P1 */ |
| 12865 | +#define OP_CreateTable 137 /* synopsis: r[P2]=root iDb=P1 */ |
| 12866 | +#define OP_SqlExec 138 |
| 12867 | +#define OP_ParseSchema 139 |
| 12868 | +#define OP_LoadAnalysis 140 |
| 12869 | +#define OP_DropTable 141 |
| 12870 | +#define OP_DropIndex 142 |
| 12871 | +#define OP_DropTrigger 143 |
| 12872 | +#define OP_IntegrityCk 144 |
| 12873 | +#define OP_RowSetAdd 145 /* synopsis: rowset(P1)=r[P2] */ |
| 12874 | +#define OP_Param 146 |
| 12875 | +#define OP_FkCounter 147 /* synopsis: fkctr[P1]+=P2 */ |
| 12876 | +#define OP_MemMax 148 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 12877 | +#define OP_OffsetLimit 149 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 12878 | +#define OP_AggStep0 150 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12879 | +#define OP_AggStep 151 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12880 | +#define OP_AggFinal 152 /* synopsis: accum=r[P1] N=P2 */ |
| 12881 | +#define OP_Expire 153 |
| 12882 | +#define OP_TableLock 154 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 12883 | +#define OP_VBegin 155 |
| 12884 | +#define OP_VCreate 156 |
| 12885 | +#define OP_VDestroy 157 |
| 12886 | +#define OP_VOpen 158 |
| 12887 | +#define OP_VColumn 159 /* synopsis: r[P3]=vcolumn(P2) */ |
| 12888 | +#define OP_VRename 160 |
| 12889 | +#define OP_Pagecount 161 |
| 12890 | +#define OP_MaxPgcnt 162 |
| 12891 | +#define OP_CursorHint 163 |
| 12892 | +#define OP_Noop 164 |
| 12893 | +#define OP_Explain 165 |
| 12894 | 12894 | |
| 12895 | 12895 | /* Properties such as "out2" or "jump" that are specified in |
| 12896 | 12896 | ** comments following the "case" for each opcode in the vdbe.c |
| 12897 | 12897 | ** are encoded into bitvectors as follows: |
| 12898 | 12898 | */ |
| | @@ -12903,37 +12903,37 @@ |
| 12903 | 12903 | #define OPFLG_OUT2 0x10 /* out2: P2 is an output */ |
| 12904 | 12904 | #define OPFLG_OUT3 0x20 /* out3: P3 is an output */ |
| 12905 | 12905 | #define OPFLG_INITIALIZER {\ |
| 12906 | 12906 | /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 12907 | 12907 | /* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\ |
| 12908 | | -/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\ |
| 12909 | | -/* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\ |
| 12910 | | -/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 12911 | | -/* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 12912 | | -/* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\ |
| 12913 | | -/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x23,\ |
| 12914 | | -/* 64 */ 0x0b, 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01,\ |
| 12915 | | -/* 72 */ 0x01, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ |
| 12916 | | -/* 80 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ |
| 12917 | | -/* 88 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\ |
| 12918 | | -/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ |
| 12908 | +/* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x01,\ |
| 12909 | +/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\ |
| 12910 | +/* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 12911 | +/* 40 */ 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01, 0x03, 0x03,\ |
| 12912 | +/* 48 */ 0x03, 0x01, 0x01, 0x01, 0x02, 0x02, 0x08, 0x00,\ |
| 12913 | +/* 56 */ 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00,\ |
| 12914 | +/* 64 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\ |
| 12915 | +/* 72 */ 0x00, 0x02, 0x02, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ |
| 12916 | +/* 80 */ 0x0b, 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26,\ |
| 12917 | +/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x02, 0x12,\ |
| 12918 | +/* 96 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\ |
| 12919 | 12919 | /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12920 | | -/* 112 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 12921 | | -/* 120 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00,\ |
| 12922 | | -/* 128 */ 0x00, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\ |
| 12923 | | -/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\ |
| 12924 | | -/* 144 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\ |
| 12925 | | -/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\ |
| 12926 | | -/* 160 */ 0x10, 0x00, 0x00, 0x00,} |
| 12920 | +/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 12921 | +/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04,\ |
| 12922 | +/* 128 */ 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\ |
| 12923 | +/* 136 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12924 | +/* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\ |
| 12925 | +/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12926 | +/* 160 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,} |
| 12927 | 12927 | |
| 12928 | 12928 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 12929 | 12929 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 12930 | 12930 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 12931 | 12931 | ** generated this include file strives to group all JUMP opcodes |
| 12932 | 12932 | ** together near the beginning of the list. |
| 12933 | 12933 | */ |
| 12934 | | -#define SQLITE_MX_JUMP_OPCODE 72 /* Maximum JUMP opcode */ |
| 12934 | +#define SQLITE_MX_JUMP_OPCODE 83 /* Maximum JUMP opcode */ |
| 12935 | 12935 | |
| 12936 | 12936 | /************** End of opcodes.h *********************************************/ |
| 12937 | 12937 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 12938 | 12938 | |
| 12939 | 12939 | /* |
| | @@ -15209,10 +15209,11 @@ |
| 15209 | 15209 | ** of the result column in the form: DATABASE.TABLE.COLUMN. This later |
| 15210 | 15210 | ** form is used for name resolution with nested FROM clauses. |
| 15211 | 15211 | */ |
| 15212 | 15212 | struct ExprList { |
| 15213 | 15213 | int nExpr; /* Number of expressions on the list */ |
| 15214 | + int nAlloc; /* Number of a[] slots allocated */ |
| 15214 | 15215 | struct ExprList_item { /* For each expression in the list */ |
| 15215 | 15216 | Expr *pExpr; /* The parse tree for this expression */ |
| 15216 | 15217 | char *zName; /* Token associated with this expression */ |
| 15217 | 15218 | char *zSpan; /* Original text of the expression */ |
| 15218 | 15219 | u8 sortOrder; /* 1 for DESC or 0 for ASC */ |
| | @@ -15224,11 +15225,11 @@ |
| 15224 | 15225 | u16 iOrderByCol; /* For ORDER BY, column number in result set */ |
| 15225 | 15226 | u16 iAlias; /* Index into Parse.aAlias[] for zName */ |
| 15226 | 15227 | } x; |
| 15227 | 15228 | int iConstExprReg; /* Register in which Expr value is cached */ |
| 15228 | 15229 | } u; |
| 15229 | | - } *a; /* Alloc a power of two greater or equal to nExpr */ |
| 15230 | + } a[1]; /* One slot for each expression in the list */ |
| 15230 | 15231 | }; |
| 15231 | 15232 | |
| 15232 | 15233 | /* |
| 15233 | 15234 | ** An instance of this structure is used by the parser to record both |
| 15234 | 15235 | ** the parse tree for an expression and the span of input text for an |
| | @@ -16081,18 +16082,21 @@ |
| 16081 | 16082 | int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */ |
| 16082 | 16083 | void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */ |
| 16083 | 16084 | int walkerDepth; /* Number of subqueries */ |
| 16084 | 16085 | u8 eCode; /* A small processing code */ |
| 16085 | 16086 | union { /* Extra data for callback */ |
| 16086 | | - NameContext *pNC; /* Naming context */ |
| 16087 | | - int n; /* A counter */ |
| 16088 | | - int iCur; /* A cursor number */ |
| 16089 | | - SrcList *pSrcList; /* FROM clause */ |
| 16090 | | - struct SrcCount *pSrcCount; /* Counting column references */ |
| 16091 | | - struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 16092 | | - int *aiCol; /* array of column indexes */ |
| 16093 | | - struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 16087 | + NameContext *pNC; /* Naming context */ |
| 16088 | + int n; /* A counter */ |
| 16089 | + int iCur; /* A cursor number */ |
| 16090 | + SrcList *pSrcList; /* FROM clause */ |
| 16091 | + struct SrcCount *pSrcCount; /* Counting column references */ |
| 16092 | + struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 16093 | + int *aiCol; /* array of column indexes */ |
| 16094 | + struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 16095 | + struct IdxExprTrans *pIdxTrans; /* Convert indexed expr to column */ |
| 16096 | + ExprList *pGroupBy; /* GROUP BY clause */ |
| 16097 | + struct HavingToWhereCtx *pHavingCtx; /* HAVING to WHERE clause ctx */ |
| 16094 | 16098 | } u; |
| 16095 | 16099 | }; |
| 16096 | 16100 | |
| 16097 | 16101 | /* Forward declarations */ |
| 16098 | 16102 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); |
| | @@ -16242,10 +16246,11 @@ |
| 16242 | 16246 | SQLITE_PRIVATE char *sqlite3DbStrNDup(sqlite3*,const char*, u64); |
| 16243 | 16247 | SQLITE_PRIVATE void *sqlite3Realloc(void*, u64); |
| 16244 | 16248 | SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64); |
| 16245 | 16249 | SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64); |
| 16246 | 16250 | SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*); |
| 16251 | +SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3*, void*); |
| 16247 | 16252 | SQLITE_PRIVATE int sqlite3MallocSize(void*); |
| 16248 | 16253 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*); |
| 16249 | 16254 | SQLITE_PRIVATE void *sqlite3ScratchMalloc(int); |
| 16250 | 16255 | SQLITE_PRIVATE void sqlite3ScratchFree(void*); |
| 16251 | 16256 | SQLITE_PRIVATE void *sqlite3PageMalloc(int); |
| | @@ -16557,10 +16562,11 @@ |
| 16557 | 16562 | SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *); |
| 16558 | 16563 | SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*); |
| 16559 | 16564 | SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*); |
| 16560 | 16565 | SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*); |
| 16561 | 16566 | SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8); |
| 16567 | +SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse*, Expr*, ExprList*); |
| 16562 | 16568 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int); |
| 16563 | 16569 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 16564 | 16570 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); |
| 16565 | 16571 | #endif |
| 16566 | 16572 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*); |
| | @@ -18092,11 +18098,11 @@ |
| 18092 | 18098 | /* |
| 18093 | 18099 | ** Internally, the vdbe manipulates nearly all SQL values as Mem |
| 18094 | 18100 | ** structures. Each Mem struct may cache multiple representations (string, |
| 18095 | 18101 | ** integer etc.) of the same value. |
| 18096 | 18102 | */ |
| 18097 | | -struct Mem { |
| 18103 | +struct sqlite3_value { |
| 18098 | 18104 | union MemValue { |
| 18099 | 18105 | double r; /* Real value used when MEM_Real is set in flags */ |
| 18100 | 18106 | i64 i; /* Integer value used when MEM_Int is set in flags */ |
| 18101 | 18107 | int nZero; /* Used when bit MEM_Zero is set in flags */ |
| 18102 | 18108 | FuncDef *pDef; /* Used only when flags==MEM_Agg */ |
| | @@ -19222,12 +19228,14 @@ |
| 19222 | 19228 | if( p->validYMD ) return; |
| 19223 | 19229 | if( !p->validJD ){ |
| 19224 | 19230 | p->Y = 2000; |
| 19225 | 19231 | p->M = 1; |
| 19226 | 19232 | p->D = 1; |
| 19233 | + }else if( !validJulianDay(p->iJD) ){ |
| 19234 | + datetimeError(p); |
| 19235 | + return; |
| 19227 | 19236 | }else{ |
| 19228 | | - assert( validJulianDay(p->iJD) ); |
| 19229 | 19237 | Z = (int)((p->iJD + 43200000)/86400000); |
| 19230 | 19238 | A = (int)((Z - 1867216.25)/36524.25); |
| 19231 | 19239 | A = Z + 1 + A - (A/4); |
| 19232 | 19240 | B = A + 1524; |
| 19233 | 19241 | C = (int)((B - 122.1)/365.25); |
| | @@ -24659,15 +24667,16 @@ |
| 24659 | 24667 | *db->pnBytesFreed += sqlite3DbMallocSize(db,p); |
| 24660 | 24668 | } |
| 24661 | 24669 | |
| 24662 | 24670 | /* |
| 24663 | 24671 | ** Free memory that might be associated with a particular database |
| 24664 | | -** connection. |
| 24672 | +** connection. Calling sqlite3DbFree(D,X) for X==0 is a harmless no-op. |
| 24673 | +** The sqlite3DbFreeNN(D,X) version requires that X be non-NULL. |
| 24665 | 24674 | */ |
| 24666 | | -SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){ |
| 24675 | +SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3 *db, void *p){ |
| 24667 | 24676 | assert( db==0 || sqlite3_mutex_held(db->mutex) ); |
| 24668 | | - if( p==0 ) return; |
| 24677 | + assert( p!=0 ); |
| 24669 | 24678 | if( db ){ |
| 24670 | 24679 | if( db->pnBytesFreed ){ |
| 24671 | 24680 | measureAllocationSize(db, p); |
| 24672 | 24681 | return; |
| 24673 | 24682 | } |
| | @@ -24686,10 +24695,14 @@ |
| 24686 | 24695 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 24687 | 24696 | assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 24688 | 24697 | assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) ); |
| 24689 | 24698 | sqlite3MemdebugSetType(p, MEMTYPE_HEAP); |
| 24690 | 24699 | sqlite3_free(p); |
| 24700 | +} |
| 24701 | +SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){ |
| 24702 | + assert( db==0 || sqlite3_mutex_held(db->mutex) ); |
| 24703 | + if( p ) sqlite3DbFreeNN(db, p); |
| 24691 | 24704 | } |
| 24692 | 24705 | |
| 24693 | 24706 | /* |
| 24694 | 24707 | ** Change the size of an existing memory allocation |
| 24695 | 24708 | */ |
| | @@ -26379,19 +26392,24 @@ |
| 26379 | 26392 | ** Generate a human-readable explanation of an expression tree. |
| 26380 | 26393 | */ |
| 26381 | 26394 | SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){ |
| 26382 | 26395 | const char *zBinOp = 0; /* Binary operator */ |
| 26383 | 26396 | const char *zUniOp = 0; /* Unary operator */ |
| 26384 | | - char zFlgs[30]; |
| 26397 | + char zFlgs[60]; |
| 26385 | 26398 | pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 26386 | 26399 | if( pExpr==0 ){ |
| 26387 | 26400 | sqlite3TreeViewLine(pView, "nil"); |
| 26388 | 26401 | sqlite3TreeViewPop(pView); |
| 26389 | 26402 | return; |
| 26390 | 26403 | } |
| 26391 | 26404 | if( pExpr->flags ){ |
| 26392 | | - sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x",pExpr->flags); |
| 26405 | + if( ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 26406 | + sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x iRJT=%d", |
| 26407 | + pExpr->flags, pExpr->iRightJoinTable); |
| 26408 | + }else{ |
| 26409 | + sqlite3_snprintf(sizeof(zFlgs),zFlgs," flags=0x%x",pExpr->flags); |
| 26410 | + } |
| 26393 | 26411 | }else{ |
| 26394 | 26412 | zFlgs[0] = 0; |
| 26395 | 26413 | } |
| 26396 | 26414 | switch( pExpr->op ){ |
| 26397 | 26415 | case TK_AGG_COLUMN: { |
| | @@ -26605,10 +26623,15 @@ |
| 26605 | 26623 | } |
| 26606 | 26624 | case TK_SELECT_COLUMN: { |
| 26607 | 26625 | sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn); |
| 26608 | 26626 | sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0); |
| 26609 | 26627 | break; |
| 26628 | + } |
| 26629 | + case TK_IF_NULL_ROW: { |
| 26630 | + sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable); |
| 26631 | + sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 26632 | + break; |
| 26610 | 26633 | } |
| 26611 | 26634 | default: { |
| 26612 | 26635 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); |
| 26613 | 26636 | break; |
| 26614 | 26637 | } |
| | @@ -29488,151 +29511,153 @@ |
| 29488 | 29511 | /* 18 */ "Jump" OpHelp(""), |
| 29489 | 29512 | /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"), |
| 29490 | 29513 | /* 20 */ "Once" OpHelp(""), |
| 29491 | 29514 | /* 21 */ "If" OpHelp(""), |
| 29492 | 29515 | /* 22 */ "IfNot" OpHelp(""), |
| 29493 | | - /* 23 */ "SeekLT" OpHelp("key=r[P3@P4]"), |
| 29494 | | - /* 24 */ "SeekLE" OpHelp("key=r[P3@P4]"), |
| 29495 | | - /* 25 */ "SeekGE" OpHelp("key=r[P3@P4]"), |
| 29496 | | - /* 26 */ "SeekGT" OpHelp("key=r[P3@P4]"), |
| 29497 | | - /* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 29498 | | - /* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 29499 | | - /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 29500 | | - /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 29501 | | - /* 31 */ "Found" OpHelp("key=r[P3@P4]"), |
| 29502 | | - /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 29503 | | - /* 33 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 29504 | | - /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 29505 | | - /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 29506 | | - /* 36 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 29507 | | - /* 37 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 29508 | | - /* 38 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 29509 | | - /* 39 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 29510 | | - /* 40 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 29511 | | - /* 41 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 29512 | | - /* 42 */ "ElseNotEq" OpHelp(""), |
| 29513 | | - /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 29514 | | - /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 29515 | | - /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 29516 | | - /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 29517 | | - /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 29518 | | - /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 29519 | | - /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 29520 | | - /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 29521 | | - /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 29522 | | - /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 29523 | | - /* 53 */ "Last" OpHelp(""), |
| 29524 | | - /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 29525 | | - /* 55 */ "IfSmaller" OpHelp(""), |
| 29526 | | - /* 56 */ "SorterSort" OpHelp(""), |
| 29527 | | - /* 57 */ "Sort" OpHelp(""), |
| 29528 | | - /* 58 */ "Rewind" OpHelp(""), |
| 29529 | | - /* 59 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 29530 | | - /* 60 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 29531 | | - /* 61 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 29532 | | - /* 62 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 29533 | | - /* 63 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 29534 | | - /* 64 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 29535 | | - /* 65 */ "Program" OpHelp(""), |
| 29536 | | - /* 66 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 29537 | | - /* 67 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 29538 | | - /* 68 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 29539 | | - /* 69 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 29540 | | - /* 70 */ "IncrVacuum" OpHelp(""), |
| 29541 | | - /* 71 */ "VNext" OpHelp(""), |
| 29542 | | - /* 72 */ "Init" OpHelp("Start at P2"), |
| 29543 | | - /* 73 */ "Return" OpHelp(""), |
| 29544 | | - /* 74 */ "EndCoroutine" OpHelp(""), |
| 29545 | | - /* 75 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 29546 | | - /* 76 */ "Halt" OpHelp(""), |
| 29547 | | - /* 77 */ "Integer" OpHelp("r[P2]=P1"), |
| 29548 | | - /* 78 */ "Int64" OpHelp("r[P2]=P4"), |
| 29549 | | - /* 79 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 29550 | | - /* 80 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 29551 | | - /* 81 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 29552 | | - /* 82 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 29553 | | - /* 83 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 29554 | | - /* 84 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 29555 | | - /* 85 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 29556 | | - /* 86 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 29557 | | - /* 87 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 29558 | | - /* 88 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 29559 | | - /* 89 */ "CollSeq" OpHelp(""), |
| 29560 | | - /* 90 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29561 | | - /* 91 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29562 | | - /* 92 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 29563 | | - /* 93 */ "RealAffinity" OpHelp(""), |
| 29516 | + /* 23 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"), |
| 29517 | + /* 24 */ "SeekLT" OpHelp("key=r[P3@P4]"), |
| 29518 | + /* 25 */ "SeekLE" OpHelp("key=r[P3@P4]"), |
| 29519 | + /* 26 */ "SeekGE" OpHelp("key=r[P3@P4]"), |
| 29520 | + /* 27 */ "SeekGT" OpHelp("key=r[P3@P4]"), |
| 29521 | + /* 28 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 29522 | + /* 29 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 29523 | + /* 30 */ "Found" OpHelp("key=r[P3@P4]"), |
| 29524 | + /* 31 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 29525 | + /* 32 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 29526 | + /* 33 */ "Last" OpHelp(""), |
| 29527 | + /* 34 */ "IfSmaller" OpHelp(""), |
| 29528 | + /* 35 */ "SorterSort" OpHelp(""), |
| 29529 | + /* 36 */ "Sort" OpHelp(""), |
| 29530 | + /* 37 */ "Rewind" OpHelp(""), |
| 29531 | + /* 38 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 29532 | + /* 39 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 29533 | + /* 40 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 29534 | + /* 41 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 29535 | + /* 42 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 29536 | + /* 43 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 29537 | + /* 44 */ "Program" OpHelp(""), |
| 29538 | + /* 45 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 29539 | + /* 46 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 29540 | + /* 47 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 29541 | + /* 48 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 29542 | + /* 49 */ "IncrVacuum" OpHelp(""), |
| 29543 | + /* 50 */ "VNext" OpHelp(""), |
| 29544 | + /* 51 */ "Init" OpHelp("Start at P2"), |
| 29545 | + /* 52 */ "Return" OpHelp(""), |
| 29546 | + /* 53 */ "EndCoroutine" OpHelp(""), |
| 29547 | + /* 54 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 29548 | + /* 55 */ "Halt" OpHelp(""), |
| 29549 | + /* 56 */ "Integer" OpHelp("r[P2]=P1"), |
| 29550 | + /* 57 */ "Int64" OpHelp("r[P2]=P4"), |
| 29551 | + /* 58 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 29552 | + /* 59 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 29553 | + /* 60 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 29554 | + /* 61 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 29555 | + /* 62 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 29556 | + /* 63 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 29557 | + /* 64 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 29558 | + /* 65 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 29559 | + /* 66 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 29560 | + /* 67 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 29561 | + /* 68 */ "CollSeq" OpHelp(""), |
| 29562 | + /* 69 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29563 | + /* 70 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 29564 | + /* 71 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 29565 | + /* 72 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29566 | + /* 73 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 29567 | + /* 74 */ "RealAffinity" OpHelp(""), |
| 29568 | + /* 75 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 29569 | + /* 76 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 29570 | + /* 77 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 29571 | + /* 78 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 29572 | + /* 79 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 29573 | + /* 80 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 29574 | + /* 81 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 29575 | + /* 82 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 29576 | + /* 83 */ "ElseNotEq" OpHelp(""), |
| 29577 | + /* 84 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 29578 | + /* 85 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 29579 | + /* 86 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 29580 | + /* 87 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 29581 | + /* 88 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 29582 | + /* 89 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 29583 | + /* 90 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 29584 | + /* 91 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 29585 | + /* 92 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 29586 | + /* 93 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 29564 | 29587 | /* 94 */ "Cast" OpHelp("affinity(r[P1])"), |
| 29565 | | - /* 95 */ "Permutation" OpHelp(""), |
| 29566 | | - /* 96 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 29588 | + /* 95 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 29589 | + /* 96 */ "Permutation" OpHelp(""), |
| 29567 | 29590 | /* 97 */ "String8" OpHelp("r[P2]='P4'"), |
| 29568 | | - /* 98 */ "Column" OpHelp("r[P3]=PX"), |
| 29569 | | - /* 99 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 29570 | | - /* 100 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 29571 | | - /* 101 */ "Count" OpHelp("r[P2]=count()"), |
| 29572 | | - /* 102 */ "ReadCookie" OpHelp(""), |
| 29573 | | - /* 103 */ "SetCookie" OpHelp(""), |
| 29574 | | - /* 104 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 29575 | | - /* 105 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 29576 | | - /* 106 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 29577 | | - /* 107 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 29578 | | - /* 108 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 29579 | | - /* 109 */ "SorterOpen" OpHelp(""), |
| 29580 | | - /* 110 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 29581 | | - /* 111 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 29582 | | - /* 112 */ "Close" OpHelp(""), |
| 29583 | | - /* 113 */ "ColumnsUsed" OpHelp(""), |
| 29584 | | - /* 114 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 29585 | | - /* 115 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 29586 | | - /* 116 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 29587 | | - /* 117 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 29588 | | - /* 118 */ "Delete" OpHelp(""), |
| 29589 | | - /* 119 */ "ResetCount" OpHelp(""), |
| 29590 | | - /* 120 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 29591 | | - /* 121 */ "SorterData" OpHelp("r[P2]=data"), |
| 29592 | | - /* 122 */ "RowData" OpHelp("r[P2]=data"), |
| 29593 | | - /* 123 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 29594 | | - /* 124 */ "NullRow" OpHelp(""), |
| 29595 | | - /* 125 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 29596 | | - /* 126 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 29597 | | - /* 127 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 29598 | | - /* 128 */ "Seek" OpHelp("Move P3 to P1.rowid"), |
| 29599 | | - /* 129 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 29600 | | - /* 130 */ "Destroy" OpHelp(""), |
| 29601 | | - /* 131 */ "Clear" OpHelp(""), |
| 29591 | + /* 98 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 29592 | + /* 99 */ "Column" OpHelp("r[P3]=PX"), |
| 29593 | + /* 100 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 29594 | + /* 101 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 29595 | + /* 102 */ "Count" OpHelp("r[P2]=count()"), |
| 29596 | + /* 103 */ "ReadCookie" OpHelp(""), |
| 29597 | + /* 104 */ "SetCookie" OpHelp(""), |
| 29598 | + /* 105 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 29599 | + /* 106 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 29600 | + /* 107 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 29601 | + /* 108 */ "OpenDup" OpHelp(""), |
| 29602 | + /* 109 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 29603 | + /* 110 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 29604 | + /* 111 */ "SorterOpen" OpHelp(""), |
| 29605 | + /* 112 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 29606 | + /* 113 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 29607 | + /* 114 */ "Close" OpHelp(""), |
| 29608 | + /* 115 */ "ColumnsUsed" OpHelp(""), |
| 29609 | + /* 116 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 29610 | + /* 117 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 29611 | + /* 118 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 29612 | + /* 119 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 29613 | + /* 120 */ "Delete" OpHelp(""), |
| 29614 | + /* 121 */ "ResetCount" OpHelp(""), |
| 29615 | + /* 122 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 29616 | + /* 123 */ "SorterData" OpHelp("r[P2]=data"), |
| 29617 | + /* 124 */ "RowData" OpHelp("r[P2]=data"), |
| 29618 | + /* 125 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 29619 | + /* 126 */ "NullRow" OpHelp(""), |
| 29620 | + /* 127 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 29621 | + /* 128 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 29622 | + /* 129 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 29623 | + /* 130 */ "Seek" OpHelp("Move P3 to P1.rowid"), |
| 29624 | + /* 131 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 29602 | 29625 | /* 132 */ "Real" OpHelp("r[P2]=P4"), |
| 29603 | | - /* 133 */ "ResetSorter" OpHelp(""), |
| 29604 | | - /* 134 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 29605 | | - /* 135 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 29606 | | - /* 136 */ "SqlExec" OpHelp(""), |
| 29607 | | - /* 137 */ "ParseSchema" OpHelp(""), |
| 29608 | | - /* 138 */ "LoadAnalysis" OpHelp(""), |
| 29609 | | - /* 139 */ "DropTable" OpHelp(""), |
| 29610 | | - /* 140 */ "DropIndex" OpHelp(""), |
| 29611 | | - /* 141 */ "DropTrigger" OpHelp(""), |
| 29612 | | - /* 142 */ "IntegrityCk" OpHelp(""), |
| 29613 | | - /* 143 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 29614 | | - /* 144 */ "Param" OpHelp(""), |
| 29615 | | - /* 145 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 29616 | | - /* 146 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 29617 | | - /* 147 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 29618 | | - /* 148 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29619 | | - /* 149 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29620 | | - /* 150 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 29621 | | - /* 151 */ "Expire" OpHelp(""), |
| 29622 | | - /* 152 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 29623 | | - /* 153 */ "VBegin" OpHelp(""), |
| 29624 | | - /* 154 */ "VCreate" OpHelp(""), |
| 29625 | | - /* 155 */ "VDestroy" OpHelp(""), |
| 29626 | | - /* 156 */ "VOpen" OpHelp(""), |
| 29627 | | - /* 157 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 29628 | | - /* 158 */ "VRename" OpHelp(""), |
| 29629 | | - /* 159 */ "Pagecount" OpHelp(""), |
| 29630 | | - /* 160 */ "MaxPgcnt" OpHelp(""), |
| 29631 | | - /* 161 */ "CursorHint" OpHelp(""), |
| 29632 | | - /* 162 */ "Noop" OpHelp(""), |
| 29633 | | - /* 163 */ "Explain" OpHelp(""), |
| 29626 | + /* 133 */ "Destroy" OpHelp(""), |
| 29627 | + /* 134 */ "Clear" OpHelp(""), |
| 29628 | + /* 135 */ "ResetSorter" OpHelp(""), |
| 29629 | + /* 136 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 29630 | + /* 137 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 29631 | + /* 138 */ "SqlExec" OpHelp(""), |
| 29632 | + /* 139 */ "ParseSchema" OpHelp(""), |
| 29633 | + /* 140 */ "LoadAnalysis" OpHelp(""), |
| 29634 | + /* 141 */ "DropTable" OpHelp(""), |
| 29635 | + /* 142 */ "DropIndex" OpHelp(""), |
| 29636 | + /* 143 */ "DropTrigger" OpHelp(""), |
| 29637 | + /* 144 */ "IntegrityCk" OpHelp(""), |
| 29638 | + /* 145 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 29639 | + /* 146 */ "Param" OpHelp(""), |
| 29640 | + /* 147 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 29641 | + /* 148 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 29642 | + /* 149 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 29643 | + /* 150 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29644 | + /* 151 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29645 | + /* 152 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 29646 | + /* 153 */ "Expire" OpHelp(""), |
| 29647 | + /* 154 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 29648 | + /* 155 */ "VBegin" OpHelp(""), |
| 29649 | + /* 156 */ "VCreate" OpHelp(""), |
| 29650 | + /* 157 */ "VDestroy" OpHelp(""), |
| 29651 | + /* 158 */ "VOpen" OpHelp(""), |
| 29652 | + /* 159 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 29653 | + /* 160 */ "VRename" OpHelp(""), |
| 29654 | + /* 161 */ "Pagecount" OpHelp(""), |
| 29655 | + /* 162 */ "MaxPgcnt" OpHelp(""), |
| 29656 | + /* 163 */ "CursorHint" OpHelp(""), |
| 29657 | + /* 164 */ "Noop" OpHelp(""), |
| 29658 | + /* 165 */ "Explain" OpHelp(""), |
| 29634 | 29659 | }; |
| 29635 | 29660 | return azName[i]; |
| 29636 | 29661 | } |
| 29637 | 29662 | #endif |
| 29638 | 29663 | |
| | @@ -45243,21 +45268,20 @@ |
| 45243 | 45268 | } |
| 45244 | 45269 | zBulk = pCache->pBulk = sqlite3Malloc( szBulk ); |
| 45245 | 45270 | sqlite3EndBenignMalloc(); |
| 45246 | 45271 | if( zBulk ){ |
| 45247 | 45272 | int nBulk = sqlite3MallocSize(zBulk)/pCache->szAlloc; |
| 45248 | | - int i; |
| 45249 | | - for(i=0; i<nBulk; i++){ |
| 45273 | + do{ |
| 45250 | 45274 | PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; |
| 45251 | 45275 | pX->page.pBuf = zBulk; |
| 45252 | 45276 | pX->page.pExtra = &pX[1]; |
| 45253 | 45277 | pX->isBulkLocal = 1; |
| 45254 | 45278 | pX->isAnchor = 0; |
| 45255 | 45279 | pX->pNext = pCache->pFree; |
| 45256 | 45280 | pCache->pFree = pX; |
| 45257 | 45281 | zBulk += pCache->szAlloc; |
| 45258 | | - } |
| 45282 | + }while( --nBulk ); |
| 45259 | 45283 | } |
| 45260 | 45284 | return pCache->pFree!=0; |
| 45261 | 45285 | } |
| 45262 | 45286 | |
| 45263 | 45287 | /* |
| | @@ -46169,11 +46193,11 @@ |
| 46169 | 46193 | */ |
| 46170 | 46194 | SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){ |
| 46171 | 46195 | int nFree = 0; |
| 46172 | 46196 | assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); |
| 46173 | 46197 | assert( sqlite3_mutex_notheld(pcache1.mutex) ); |
| 46174 | | - if( sqlite3GlobalConfig.nPage==0 ){ |
| 46198 | + if( sqlite3GlobalConfig.pPage==0 ){ |
| 46175 | 46199 | PgHdr1 *p; |
| 46176 | 46200 | pcache1EnterMutex(&pcache1.grp); |
| 46177 | 46201 | while( (nReq<0 || nFree<nReq) |
| 46178 | 46202 | && (p=pcache1.grp.lru.pLruPrev)!=0 |
| 46179 | 46203 | && p->isAnchor==0 |
| | @@ -58476,14 +58500,14 @@ |
| 58476 | 58500 | /* All fields above are zeroed when the cursor is allocated. See |
| 58477 | 58501 | ** sqlite3BtreeCursorZero(). Fields that follow must be manually |
| 58478 | 58502 | ** initialized. */ |
| 58479 | 58503 | i8 iPage; /* Index of current page in apPage */ |
| 58480 | 58504 | u8 curIntKey; /* Value of apPage[0]->intKey */ |
| 58481 | | - struct KeyInfo *pKeyInfo; /* Argument passed to comparison function */ |
| 58482 | | - void *padding1; /* Make object size a multiple of 16 */ |
| 58483 | | - u16 aiIdx[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ |
| 58484 | | - MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ |
| 58505 | + u16 ix; /* Current index for apPage[iPage] */ |
| 58506 | + u16 aiIdx[BTCURSOR_MAX_DEPTH-1]; /* Current index in apPage[i] */ |
| 58507 | + struct KeyInfo *pKeyInfo; /* Arg passed to comparison function */ |
| 58508 | + MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ |
| 58485 | 58509 | }; |
| 58486 | 58510 | |
| 58487 | 58511 | /* |
| 58488 | 58512 | ** Legal values for BtCursor.curFlags |
| 58489 | 58513 | */ |
| | @@ -59455,10 +59479,11 @@ |
| 59455 | 59479 | ** rowid iRow is being replaced or deleted. In this case invalidate |
| 59456 | 59480 | ** only those incrblob cursors open on that specific row. |
| 59457 | 59481 | */ |
| 59458 | 59482 | static void invalidateIncrblobCursors( |
| 59459 | 59483 | Btree *pBtree, /* The database file to check */ |
| 59484 | + Pgno pgnoRoot, /* The table that might be changing */ |
| 59460 | 59485 | i64 iRow, /* The rowid that might be changing */ |
| 59461 | 59486 | int isClearTable /* True if all rows are being deleted */ |
| 59462 | 59487 | ){ |
| 59463 | 59488 | BtCursor *p; |
| 59464 | 59489 | if( pBtree->hasIncrblobCur==0 ) return; |
| | @@ -59465,20 +59490,20 @@ |
| 59465 | 59490 | assert( sqlite3BtreeHoldsMutex(pBtree) ); |
| 59466 | 59491 | pBtree->hasIncrblobCur = 0; |
| 59467 | 59492 | for(p=pBtree->pBt->pCursor; p; p=p->pNext){ |
| 59468 | 59493 | if( (p->curFlags & BTCF_Incrblob)!=0 ){ |
| 59469 | 59494 | pBtree->hasIncrblobCur = 1; |
| 59470 | | - if( isClearTable || p->info.nKey==iRow ){ |
| 59495 | + if( p->pgnoRoot==pgnoRoot && (isClearTable || p->info.nKey==iRow) ){ |
| 59471 | 59496 | p->eState = CURSOR_INVALID; |
| 59472 | 59497 | } |
| 59473 | 59498 | } |
| 59474 | 59499 | } |
| 59475 | 59500 | } |
| 59476 | 59501 | |
| 59477 | 59502 | #else |
| 59478 | 59503 | /* Stub function when INCRBLOB is omitted */ |
| 59479 | | - #define invalidateIncrblobCursors(x,y,z) |
| 59504 | + #define invalidateIncrblobCursors(w,x,y,z) |
| 59480 | 59505 | #endif /* SQLITE_OMIT_INCRBLOB */ |
| 59481 | 59506 | |
| 59482 | 59507 | /* |
| 59483 | 59508 | ** Set bit pgno of the BtShared.pHasContent bitvec. This is called |
| 59484 | 59509 | ** when a page that previously contained data becomes a free-list leaf |
| | @@ -63272,21 +63297,21 @@ |
| 63272 | 63297 | #ifndef NDEBUG |
| 63273 | 63298 | static void assertCellInfo(BtCursor *pCur){ |
| 63274 | 63299 | CellInfo info; |
| 63275 | 63300 | int iPage = pCur->iPage; |
| 63276 | 63301 | memset(&info, 0, sizeof(info)); |
| 63277 | | - btreeParseCell(pCur->apPage[iPage], pCur->aiIdx[iPage], &info); |
| 63302 | + btreeParseCell(pCur->apPage[iPage], pCur->ix, &info); |
| 63278 | 63303 | assert( CORRUPT_DB || memcmp(&info, &pCur->info, sizeof(info))==0 ); |
| 63279 | 63304 | } |
| 63280 | 63305 | #else |
| 63281 | 63306 | #define assertCellInfo(x) |
| 63282 | 63307 | #endif |
| 63283 | 63308 | static SQLITE_NOINLINE void getCellInfo(BtCursor *pCur){ |
| 63284 | 63309 | if( pCur->info.nSize==0 ){ |
| 63285 | 63310 | int iPage = pCur->iPage; |
| 63286 | 63311 | pCur->curFlags |= BTCF_ValidNKey; |
| 63287 | | - btreeParseCell(pCur->apPage[iPage],pCur->aiIdx[iPage],&pCur->info); |
| 63312 | + btreeParseCell(pCur->apPage[iPage],pCur->ix,&pCur->info); |
| 63288 | 63313 | }else{ |
| 63289 | 63314 | assertCellInfo(pCur); |
| 63290 | 63315 | } |
| 63291 | 63316 | } |
| 63292 | 63317 | |
| | @@ -63489,11 +63514,11 @@ |
| 63489 | 63514 | #endif |
| 63490 | 63515 | |
| 63491 | 63516 | assert( pPage ); |
| 63492 | 63517 | assert( eOp==0 || eOp==1 ); |
| 63493 | 63518 | assert( pCur->eState==CURSOR_VALID ); |
| 63494 | | - assert( pCur->aiIdx[pCur->iPage]<pPage->nCell ); |
| 63519 | + assert( pCur->ix<pPage->nCell ); |
| 63495 | 63520 | assert( cursorHoldsMutex(pCur) ); |
| 63496 | 63521 | |
| 63497 | 63522 | getCellInfo(pCur); |
| 63498 | 63523 | aPayload = pCur->info.pPayload; |
| 63499 | 63524 | assert( offset+amt <= pCur->info.nPayload ); |
| | @@ -63676,11 +63701,11 @@ |
| 63676 | 63701 | */ |
| 63677 | 63702 | SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){ |
| 63678 | 63703 | assert( cursorHoldsMutex(pCur) ); |
| 63679 | 63704 | assert( pCur->eState==CURSOR_VALID ); |
| 63680 | 63705 | assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] ); |
| 63681 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 63706 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 63682 | 63707 | return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0); |
| 63683 | 63708 | } |
| 63684 | 63709 | |
| 63685 | 63710 | /* |
| 63686 | 63711 | ** This variant of sqlite3BtreePayload() works even if the cursor has not |
| | @@ -63738,11 +63763,11 @@ |
| 63738 | 63763 | u32 amt; |
| 63739 | 63764 | assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]); |
| 63740 | 63765 | assert( pCur->eState==CURSOR_VALID ); |
| 63741 | 63766 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 63742 | 63767 | assert( cursorOwnsBtShared(pCur) ); |
| 63743 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 63768 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 63744 | 63769 | assert( pCur->info.nSize>0 ); |
| 63745 | 63770 | assert( pCur->info.pPayload>pCur->apPage[pCur->iPage]->aData || CORRUPT_DB ); |
| 63746 | 63771 | assert( pCur->info.pPayload<pCur->apPage[pCur->iPage]->aDataEnd ||CORRUPT_DB); |
| 63747 | 63772 | amt = (int)(pCur->apPage[pCur->iPage]->aDataEnd - pCur->info.pPayload); |
| 63748 | 63773 | if( pCur->info.nLocal<amt ) amt = pCur->info.nLocal; |
| | @@ -63789,12 +63814,12 @@ |
| 63789 | 63814 | if( pCur->iPage>=(BTCURSOR_MAX_DEPTH-1) ){ |
| 63790 | 63815 | return SQLITE_CORRUPT_BKPT; |
| 63791 | 63816 | } |
| 63792 | 63817 | pCur->info.nSize = 0; |
| 63793 | 63818 | pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 63794 | | - pCur->iPage++; |
| 63795 | | - pCur->aiIdx[pCur->iPage] = 0; |
| 63819 | + pCur->aiIdx[pCur->iPage++] = pCur->ix; |
| 63820 | + pCur->ix = 0; |
| 63796 | 63821 | return getAndInitPage(pBt, newPgno, &pCur->apPage[pCur->iPage], |
| 63797 | 63822 | pCur, pCur->curPagerFlags); |
| 63798 | 63823 | } |
| 63799 | 63824 | |
| 63800 | 63825 | #ifdef SQLITE_DEBUG |
| | @@ -63838,10 +63863,11 @@ |
| 63838 | 63863 | pCur->apPage[pCur->iPage]->pgno |
| 63839 | 63864 | ); |
| 63840 | 63865 | testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell ); |
| 63841 | 63866 | pCur->info.nSize = 0; |
| 63842 | 63867 | pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 63868 | + pCur->ix = pCur->aiIdx[pCur->iPage-1]; |
| 63843 | 63869 | releasePageNotNull(pCur->apPage[pCur->iPage--]); |
| 63844 | 63870 | } |
| 63845 | 63871 | |
| 63846 | 63872 | /* |
| 63847 | 63873 | ** Move the cursor to point to the root page of its b-tree structure. |
| | @@ -63919,11 +63945,11 @@ |
| 63919 | 63945 | if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){ |
| 63920 | 63946 | return SQLITE_CORRUPT_BKPT; |
| 63921 | 63947 | } |
| 63922 | 63948 | |
| 63923 | 63949 | skip_init: |
| 63924 | | - pCur->aiIdx[0] = 0; |
| 63950 | + pCur->ix = 0; |
| 63925 | 63951 | pCur->info.nSize = 0; |
| 63926 | 63952 | pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl); |
| 63927 | 63953 | |
| 63928 | 63954 | pRoot = pCur->apPage[0]; |
| 63929 | 63955 | if( pRoot->nCell>0 ){ |
| | @@ -63953,12 +63979,12 @@ |
| 63953 | 63979 | MemPage *pPage; |
| 63954 | 63980 | |
| 63955 | 63981 | assert( cursorOwnsBtShared(pCur) ); |
| 63956 | 63982 | assert( pCur->eState==CURSOR_VALID ); |
| 63957 | 63983 | while( rc==SQLITE_OK && !(pPage = pCur->apPage[pCur->iPage])->leaf ){ |
| 63958 | | - assert( pCur->aiIdx[pCur->iPage]<pPage->nCell ); |
| 63959 | | - pgno = get4byte(findCell(pPage, pCur->aiIdx[pCur->iPage])); |
| 63984 | + assert( pCur->ix<pPage->nCell ); |
| 63985 | + pgno = get4byte(findCell(pPage, pCur->ix)); |
| 63960 | 63986 | rc = moveToChild(pCur, pgno); |
| 63961 | 63987 | } |
| 63962 | 63988 | return rc; |
| 63963 | 63989 | } |
| 63964 | 63990 | |
| | @@ -63979,15 +64005,15 @@ |
| 63979 | 64005 | |
| 63980 | 64006 | assert( cursorOwnsBtShared(pCur) ); |
| 63981 | 64007 | assert( pCur->eState==CURSOR_VALID ); |
| 63982 | 64008 | while( !(pPage = pCur->apPage[pCur->iPage])->leaf ){ |
| 63983 | 64009 | pgno = get4byte(&pPage->aData[pPage->hdrOffset+8]); |
| 63984 | | - pCur->aiIdx[pCur->iPage] = pPage->nCell; |
| 64010 | + pCur->ix = pPage->nCell; |
| 63985 | 64011 | rc = moveToChild(pCur, pgno); |
| 63986 | 64012 | if( rc ) return rc; |
| 63987 | 64013 | } |
| 63988 | | - pCur->aiIdx[pCur->iPage] = pPage->nCell-1; |
| 64014 | + pCur->ix = pPage->nCell-1; |
| 63989 | 64015 | assert( pCur->info.nSize==0 ); |
| 63990 | 64016 | assert( (pCur->curFlags & BTCF_ValidNKey)==0 ); |
| 63991 | 64017 | return SQLITE_OK; |
| 63992 | 64018 | } |
| 63993 | 64019 | |
| | @@ -64031,11 +64057,11 @@ |
| 64031 | 64057 | ** to the last entry in the b-tree. */ |
| 64032 | 64058 | int ii; |
| 64033 | 64059 | for(ii=0; ii<pCur->iPage; ii++){ |
| 64034 | 64060 | assert( pCur->aiIdx[ii]==pCur->apPage[ii]->nCell ); |
| 64035 | 64061 | } |
| 64036 | | - assert( pCur->aiIdx[pCur->iPage]==pCur->apPage[pCur->iPage]->nCell-1 ); |
| 64062 | + assert( pCur->ix==pCur->apPage[pCur->iPage]->nCell-1 ); |
| 64037 | 64063 | assert( pCur->apPage[pCur->iPage]->leaf ); |
| 64038 | 64064 | #endif |
| 64039 | 64065 | return SQLITE_OK; |
| 64040 | 64066 | } |
| 64041 | 64067 | |
| | @@ -64178,11 +64204,11 @@ |
| 64178 | 64204 | assert( pPage->intKey==(pIdxKey==0) ); |
| 64179 | 64205 | lwr = 0; |
| 64180 | 64206 | upr = pPage->nCell-1; |
| 64181 | 64207 | assert( biasRight==0 || biasRight==1 ); |
| 64182 | 64208 | idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */ |
| 64183 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64209 | + pCur->ix = (u16)idx; |
| 64184 | 64210 | if( xRecordCompare==0 ){ |
| 64185 | 64211 | for(;;){ |
| 64186 | 64212 | i64 nCellKey; |
| 64187 | 64213 | pCell = findCellPastPtr(pPage, idx); |
| 64188 | 64214 | if( pPage->intKeyLeaf ){ |
| | @@ -64197,11 +64223,11 @@ |
| 64197 | 64223 | }else if( nCellKey>intKey ){ |
| 64198 | 64224 | upr = idx-1; |
| 64199 | 64225 | if( lwr>upr ){ c = +1; break; } |
| 64200 | 64226 | }else{ |
| 64201 | 64227 | assert( nCellKey==intKey ); |
| 64202 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64228 | + pCur->ix = (u16)idx; |
| 64203 | 64229 | if( !pPage->leaf ){ |
| 64204 | 64230 | lwr = idx; |
| 64205 | 64231 | goto moveto_next_layer; |
| 64206 | 64232 | }else{ |
| 64207 | 64233 | pCur->curFlags |= BTCF_ValidNKey; |
| | @@ -64266,11 +64292,11 @@ |
| 64266 | 64292 | pCellKey = sqlite3Malloc( nCell+18 ); |
| 64267 | 64293 | if( pCellKey==0 ){ |
| 64268 | 64294 | rc = SQLITE_NOMEM_BKPT; |
| 64269 | 64295 | goto moveto_finish; |
| 64270 | 64296 | } |
| 64271 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64297 | + pCur->ix = (u16)idx; |
| 64272 | 64298 | rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0); |
| 64273 | 64299 | pCur->curFlags &= ~BTCF_ValidOvfl; |
| 64274 | 64300 | if( rc ){ |
| 64275 | 64301 | sqlite3_free(pCellKey); |
| 64276 | 64302 | goto moveto_finish; |
| | @@ -64288,11 +64314,11 @@ |
| 64288 | 64314 | upr = idx-1; |
| 64289 | 64315 | }else{ |
| 64290 | 64316 | assert( c==0 ); |
| 64291 | 64317 | *pRes = 0; |
| 64292 | 64318 | rc = SQLITE_OK; |
| 64293 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64319 | + pCur->ix = (u16)idx; |
| 64294 | 64320 | if( pIdxKey->errCode ) rc = SQLITE_CORRUPT; |
| 64295 | 64321 | goto moveto_finish; |
| 64296 | 64322 | } |
| 64297 | 64323 | if( lwr>upr ) break; |
| 64298 | 64324 | assert( lwr+upr>=0 ); |
| | @@ -64300,12 +64326,12 @@ |
| 64300 | 64326 | } |
| 64301 | 64327 | } |
| 64302 | 64328 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); |
| 64303 | 64329 | assert( pPage->isInit ); |
| 64304 | 64330 | if( pPage->leaf ){ |
| 64305 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 64306 | | - pCur->aiIdx[pCur->iPage] = (u16)idx; |
| 64331 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 64332 | + pCur->ix = (u16)idx; |
| 64307 | 64333 | *pRes = c; |
| 64308 | 64334 | rc = SQLITE_OK; |
| 64309 | 64335 | goto moveto_finish; |
| 64310 | 64336 | } |
| 64311 | 64337 | moveto_next_layer: |
| | @@ -64312,11 +64338,11 @@ |
| 64312 | 64338 | if( lwr>=pPage->nCell ){ |
| 64313 | 64339 | chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); |
| 64314 | 64340 | }else{ |
| 64315 | 64341 | chldPg = get4byte(findCell(pPage, lwr)); |
| 64316 | 64342 | } |
| 64317 | | - pCur->aiIdx[pCur->iPage] = (u16)lwr; |
| 64343 | + pCur->ix = (u16)lwr; |
| 64318 | 64344 | rc = moveToChild(pCur, chldPg); |
| 64319 | 64345 | if( rc ) break; |
| 64320 | 64346 | } |
| 64321 | 64347 | moveto_finish: |
| 64322 | 64348 | pCur->info.nSize = 0; |
| | @@ -64413,11 +64439,11 @@ |
| 64413 | 64439 | pCur->skipNext = 0; |
| 64414 | 64440 | } |
| 64415 | 64441 | } |
| 64416 | 64442 | |
| 64417 | 64443 | pPage = pCur->apPage[pCur->iPage]; |
| 64418 | | - idx = ++pCur->aiIdx[pCur->iPage]; |
| 64444 | + idx = ++pCur->ix; |
| 64419 | 64445 | assert( pPage->isInit ); |
| 64420 | 64446 | |
| 64421 | 64447 | /* If the database file is corrupt, it is possible for the value of idx |
| 64422 | 64448 | ** to be invalid here. This can only occur if a second cursor modifies |
| 64423 | 64449 | ** the page while cursor pCur is holding a reference to it. Which can |
| | @@ -64437,11 +64463,11 @@ |
| 64437 | 64463 | pCur->eState = CURSOR_INVALID; |
| 64438 | 64464 | return SQLITE_OK; |
| 64439 | 64465 | } |
| 64440 | 64466 | moveToParent(pCur); |
| 64441 | 64467 | pPage = pCur->apPage[pCur->iPage]; |
| 64442 | | - }while( pCur->aiIdx[pCur->iPage]>=pPage->nCell ); |
| 64468 | + }while( pCur->ix>=pPage->nCell ); |
| 64443 | 64469 | if( pPage->intKey ){ |
| 64444 | 64470 | return sqlite3BtreeNext(pCur, pRes); |
| 64445 | 64471 | }else{ |
| 64446 | 64472 | return SQLITE_OK; |
| 64447 | 64473 | } |
| | @@ -64461,12 +64487,12 @@ |
| 64461 | 64487 | pCur->info.nSize = 0; |
| 64462 | 64488 | pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl); |
| 64463 | 64489 | *pRes = 0; |
| 64464 | 64490 | if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur, pRes); |
| 64465 | 64491 | pPage = pCur->apPage[pCur->iPage]; |
| 64466 | | - if( (++pCur->aiIdx[pCur->iPage])>=pPage->nCell ){ |
| 64467 | | - pCur->aiIdx[pCur->iPage]--; |
| 64492 | + if( (++pCur->ix)>=pPage->nCell ){ |
| 64493 | + pCur->ix--; |
| 64468 | 64494 | return btreeNext(pCur, pRes); |
| 64469 | 64495 | } |
| 64470 | 64496 | if( pPage->leaf ){ |
| 64471 | 64497 | return SQLITE_OK; |
| 64472 | 64498 | }else{ |
| | @@ -64526,16 +64552,16 @@ |
| 64526 | 64552 | } |
| 64527 | 64553 | |
| 64528 | 64554 | pPage = pCur->apPage[pCur->iPage]; |
| 64529 | 64555 | assert( pPage->isInit ); |
| 64530 | 64556 | if( !pPage->leaf ){ |
| 64531 | | - int idx = pCur->aiIdx[pCur->iPage]; |
| 64557 | + int idx = pCur->ix; |
| 64532 | 64558 | rc = moveToChild(pCur, get4byte(findCell(pPage, idx))); |
| 64533 | 64559 | if( rc ) return rc; |
| 64534 | 64560 | rc = moveToRightmost(pCur); |
| 64535 | 64561 | }else{ |
| 64536 | | - while( pCur->aiIdx[pCur->iPage]==0 ){ |
| 64562 | + while( pCur->ix==0 ){ |
| 64537 | 64563 | if( pCur->iPage==0 ){ |
| 64538 | 64564 | pCur->eState = CURSOR_INVALID; |
| 64539 | 64565 | *pRes = 1; |
| 64540 | 64566 | return SQLITE_OK; |
| 64541 | 64567 | } |
| | @@ -64542,11 +64568,11 @@ |
| 64542 | 64568 | moveToParent(pCur); |
| 64543 | 64569 | } |
| 64544 | 64570 | assert( pCur->info.nSize==0 ); |
| 64545 | 64571 | assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 ); |
| 64546 | 64572 | |
| 64547 | | - pCur->aiIdx[pCur->iPage]--; |
| 64573 | + pCur->ix--; |
| 64548 | 64574 | pPage = pCur->apPage[pCur->iPage]; |
| 64549 | 64575 | if( pPage->intKey && !pPage->leaf ){ |
| 64550 | 64576 | rc = sqlite3BtreePrevious(pCur, pRes); |
| 64551 | 64577 | }else{ |
| 64552 | 64578 | rc = SQLITE_OK; |
| | @@ -64561,16 +64587,16 @@ |
| 64561 | 64587 | assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); |
| 64562 | 64588 | *pRes = 0; |
| 64563 | 64589 | pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey); |
| 64564 | 64590 | pCur->info.nSize = 0; |
| 64565 | 64591 | if( pCur->eState!=CURSOR_VALID |
| 64566 | | - || pCur->aiIdx[pCur->iPage]==0 |
| 64592 | + || pCur->ix==0 |
| 64567 | 64593 | || pCur->apPage[pCur->iPage]->leaf==0 |
| 64568 | 64594 | ){ |
| 64569 | 64595 | return btreePrevious(pCur, pRes); |
| 64570 | 64596 | } |
| 64571 | | - pCur->aiIdx[pCur->iPage]--; |
| 64597 | + pCur->ix--; |
| 64572 | 64598 | return SQLITE_OK; |
| 64573 | 64599 | } |
| 64574 | 64600 | |
| 64575 | 64601 | /* |
| 64576 | 64602 | ** Allocate a new page from the database file. |
| | @@ -66888,12 +66914,12 @@ |
| 66888 | 66914 | assert( balance_deeper_called==0 ); |
| 66889 | 66915 | VVA_ONLY( balance_deeper_called++ ); |
| 66890 | 66916 | rc = balance_deeper(pPage, &pCur->apPage[1]); |
| 66891 | 66917 | if( rc==SQLITE_OK ){ |
| 66892 | 66918 | pCur->iPage = 1; |
| 66919 | + pCur->ix = 0; |
| 66893 | 66920 | pCur->aiIdx[0] = 0; |
| 66894 | | - pCur->aiIdx[1] = 0; |
| 66895 | 66921 | assert( pCur->apPage[1]->nOverflow ); |
| 66896 | 66922 | } |
| 66897 | 66923 | }else{ |
| 66898 | 66924 | break; |
| 66899 | 66925 | } |
| | @@ -67066,11 +67092,11 @@ |
| 67066 | 67092 | |
| 67067 | 67093 | if( pCur->pKeyInfo==0 ){ |
| 67068 | 67094 | assert( pX->pKey==0 ); |
| 67069 | 67095 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 67070 | 67096 | ** cursors open on the row being replaced */ |
| 67071 | | - invalidateIncrblobCursors(p, pX->nKey, 0); |
| 67097 | + invalidateIncrblobCursors(p, pCur->pgnoRoot, pX->nKey, 0); |
| 67072 | 67098 | |
| 67073 | 67099 | /* If BTREE_SAVEPOSITION is set, the cursor must already be pointing |
| 67074 | 67100 | ** to a row with the same key as the new entry being inserted. */ |
| 67075 | 67101 | assert( (flags & BTREE_SAVEPOSITION)==0 || |
| 67076 | 67102 | ((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) ); |
| | @@ -67078,13 +67104,10 @@ |
| 67078 | 67104 | /* If the cursor is currently on the last row and we are appending a |
| 67079 | 67105 | ** new row onto the end, set the "loc" to avoid an unnecessary |
| 67080 | 67106 | ** btreeMoveto() call */ |
| 67081 | 67107 | if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey ){ |
| 67082 | 67108 | loc = 0; |
| 67083 | | - }else if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0 |
| 67084 | | - && pCur->info.nKey==pX->nKey-1 ){ |
| 67085 | | - loc = -1; |
| 67086 | 67109 | }else if( loc==0 ){ |
| 67087 | 67110 | rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc); |
| 67088 | 67111 | if( rc ) return rc; |
| 67089 | 67112 | } |
| 67090 | 67113 | }else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){ |
| | @@ -67118,11 +67141,11 @@ |
| 67118 | 67141 | assert( newCell!=0 ); |
| 67119 | 67142 | rc = fillInCell(pPage, newCell, pX, &szNew); |
| 67120 | 67143 | if( rc ) goto end_insert; |
| 67121 | 67144 | assert( szNew==pPage->xCellSize(pPage, newCell) ); |
| 67122 | 67145 | assert( szNew <= MX_CELL_SIZE(pBt) ); |
| 67123 | | - idx = pCur->aiIdx[pCur->iPage]; |
| 67146 | + idx = pCur->ix; |
| 67124 | 67147 | if( loc==0 ){ |
| 67125 | 67148 | CellInfo info; |
| 67126 | 67149 | assert( idx<pPage->nCell ); |
| 67127 | 67150 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 67128 | 67151 | if( rc ){ |
| | @@ -67146,11 +67169,12 @@ |
| 67146 | 67169 | } |
| 67147 | 67170 | dropCell(pPage, idx, info.nSize, &rc); |
| 67148 | 67171 | if( rc ) goto end_insert; |
| 67149 | 67172 | }else if( loc<0 && pPage->nCell>0 ){ |
| 67150 | 67173 | assert( pPage->leaf ); |
| 67151 | | - idx = ++pCur->aiIdx[pCur->iPage]; |
| 67174 | + idx = ++pCur->ix; |
| 67175 | + pCur->curFlags &= ~BTCF_ValidNKey; |
| 67152 | 67176 | }else{ |
| 67153 | 67177 | assert( pPage->leaf ); |
| 67154 | 67178 | } |
| 67155 | 67179 | insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); |
| 67156 | 67180 | assert( pPage->nOverflow==0 || rc==SQLITE_OK ); |
| | @@ -67242,16 +67266,16 @@ |
| 67242 | 67266 | assert( pBt->inTransaction==TRANS_WRITE ); |
| 67243 | 67267 | assert( (pBt->btsFlags & BTS_READ_ONLY)==0 ); |
| 67244 | 67268 | assert( pCur->curFlags & BTCF_WriteFlag ); |
| 67245 | 67269 | assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) ); |
| 67246 | 67270 | assert( !hasReadConflicts(p, pCur->pgnoRoot) ); |
| 67247 | | - assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell ); |
| 67271 | + assert( pCur->ix<pCur->apPage[pCur->iPage]->nCell ); |
| 67248 | 67272 | assert( pCur->eState==CURSOR_VALID ); |
| 67249 | 67273 | assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 ); |
| 67250 | 67274 | |
| 67251 | 67275 | iCellDepth = pCur->iPage; |
| 67252 | | - iCellIdx = pCur->aiIdx[iCellDepth]; |
| 67276 | + iCellIdx = pCur->ix; |
| 67253 | 67277 | pPage = pCur->apPage[iCellDepth]; |
| 67254 | 67278 | pCell = findCell(pPage, iCellIdx); |
| 67255 | 67279 | |
| 67256 | 67280 | /* If the bPreserve flag is set to true, then the cursor position must |
| 67257 | 67281 | ** be preserved following this delete operation. If the current delete |
| | @@ -67296,11 +67320,11 @@ |
| 67296 | 67320 | } |
| 67297 | 67321 | |
| 67298 | 67322 | /* If this is a delete operation to remove a row from a table b-tree, |
| 67299 | 67323 | ** invalidate any incrblob cursors open on the row being deleted. */ |
| 67300 | 67324 | if( pCur->pKeyInfo==0 ){ |
| 67301 | | - invalidateIncrblobCursors(p, pCur->info.nKey, 0); |
| 67325 | + invalidateIncrblobCursors(p, pCur->pgnoRoot, pCur->info.nKey, 0); |
| 67302 | 67326 | } |
| 67303 | 67327 | |
| 67304 | 67328 | /* Make the page containing the entry to be deleted writable. Then free any |
| 67305 | 67329 | ** overflow pages associated with the entry and finally remove the cell |
| 67306 | 67330 | ** itself from within the page. */ |
| | @@ -67364,11 +67388,11 @@ |
| 67364 | 67388 | assert( pPage==pCur->apPage[pCur->iPage] || CORRUPT_DB ); |
| 67365 | 67389 | assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell ); |
| 67366 | 67390 | pCur->eState = CURSOR_SKIPNEXT; |
| 67367 | 67391 | if( iCellIdx>=pPage->nCell ){ |
| 67368 | 67392 | pCur->skipNext = -1; |
| 67369 | | - pCur->aiIdx[iCellDepth] = pPage->nCell-1; |
| 67393 | + pCur->ix = pPage->nCell-1; |
| 67370 | 67394 | }else{ |
| 67371 | 67395 | pCur->skipNext = 1; |
| 67372 | 67396 | } |
| 67373 | 67397 | }else{ |
| 67374 | 67398 | rc = moveToRoot(pCur); |
| | @@ -67623,11 +67647,11 @@ |
| 67623 | 67647 | |
| 67624 | 67648 | if( SQLITE_OK==rc ){ |
| 67625 | 67649 | /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 67626 | 67650 | ** is the root of a table b-tree - if it is not, the following call is |
| 67627 | 67651 | ** a no-op). */ |
| 67628 | | - invalidateIncrblobCursors(p, 0, 1); |
| 67652 | + invalidateIncrblobCursors(p, (Pgno)iTable, 0, 1); |
| 67629 | 67653 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 67630 | 67654 | } |
| 67631 | 67655 | sqlite3BtreeLeave(p); |
| 67632 | 67656 | return rc; |
| 67633 | 67657 | } |
| | @@ -67877,20 +67901,20 @@ |
| 67877 | 67901 | /* All pages of the b-tree have been visited. Return successfully. */ |
| 67878 | 67902 | *pnEntry = nEntry; |
| 67879 | 67903 | return moveToRoot(pCur); |
| 67880 | 67904 | } |
| 67881 | 67905 | moveToParent(pCur); |
| 67882 | | - }while ( pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell ); |
| 67906 | + }while ( pCur->ix>=pCur->apPage[pCur->iPage]->nCell ); |
| 67883 | 67907 | |
| 67884 | | - pCur->aiIdx[pCur->iPage]++; |
| 67908 | + pCur->ix++; |
| 67885 | 67909 | pPage = pCur->apPage[pCur->iPage]; |
| 67886 | 67910 | } |
| 67887 | 67911 | |
| 67888 | 67912 | /* Descend to the child node of the cell that the cursor currently |
| 67889 | 67913 | ** points at. This is the right-child if (iIdx==pPage->nCell). |
| 67890 | 67914 | */ |
| 67891 | | - iIdx = pCur->aiIdx[pCur->iPage]; |
| 67915 | + iIdx = pCur->ix; |
| 67892 | 67916 | if( iIdx==pPage->nCell ){ |
| 67893 | 67917 | rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8])); |
| 67894 | 67918 | }else{ |
| 67895 | 67919 | rc = moveToChild(pCur, get4byte(findCell(pPage, iIdx))); |
| 67896 | 67920 | } |
| | @@ -68271,10 +68295,11 @@ |
| 68271 | 68295 | if( pPage->intKey ){ |
| 68272 | 68296 | if( keyCanBeEqual ? (info.nKey > maxKey) : (info.nKey >= maxKey) ){ |
| 68273 | 68297 | checkAppendMsg(pCheck, "Rowid %lld out of order", info.nKey); |
| 68274 | 68298 | } |
| 68275 | 68299 | maxKey = info.nKey; |
| 68300 | + keyCanBeEqual = 0; /* Only the first key on the page may ==maxKey */ |
| 68276 | 68301 | } |
| 68277 | 68302 | |
| 68278 | 68303 | /* Check the content overflow list */ |
| 68279 | 68304 | if( info.nPayload>info.nLocal ){ |
| 68280 | 68305 | int nPage; /* Number of pages on the overflow chain */ |
| | @@ -69656,10 +69681,14 @@ |
| 69656 | 69681 | assert( (p->flags & MEM_Dyn)==0 || p->szMalloc==0 ); |
| 69657 | 69682 | |
| 69658 | 69683 | /* Cannot be both MEM_Int and MEM_Real at the same time */ |
| 69659 | 69684 | assert( (p->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real) ); |
| 69660 | 69685 | |
| 69686 | + /* Cannot be both MEM_Null and some other type */ |
| 69687 | + assert( (p->flags & MEM_Null)==0 || |
| 69688 | + (p->flags & (MEM_Int|MEM_Real|MEM_Str|MEM_Blob))==0 ); |
| 69689 | + |
| 69661 | 69690 | /* The szMalloc field holds the correct memory allocation size */ |
| 69662 | 69691 | assert( p->szMalloc==0 |
| 69663 | 69692 | || p->szMalloc==sqlite3DbMallocSize(p->db,p->zMalloc) ); |
| 69664 | 69693 | |
| 69665 | 69694 | /* If p holds a string or blob, the Mem.z must point to exactly |
| | @@ -69741,30 +69770,28 @@ |
| 69741 | 69770 | assert( bPreserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); |
| 69742 | 69771 | testcase( bPreserve && pMem->z==0 ); |
| 69743 | 69772 | |
| 69744 | 69773 | assert( pMem->szMalloc==0 |
| 69745 | 69774 | || pMem->szMalloc==sqlite3DbMallocSize(pMem->db, pMem->zMalloc) ); |
| 69746 | | - if( pMem->szMalloc<n ){ |
| 69747 | | - if( n<32 ) n = 32; |
| 69748 | | - if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){ |
| 69749 | | - pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 69750 | | - bPreserve = 0; |
| 69751 | | - }else{ |
| 69752 | | - if( pMem->szMalloc>0 ) sqlite3DbFree(pMem->db, pMem->zMalloc); |
| 69753 | | - pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n); |
| 69754 | | - } |
| 69755 | | - if( pMem->zMalloc==0 ){ |
| 69756 | | - sqlite3VdbeMemSetNull(pMem); |
| 69757 | | - pMem->z = 0; |
| 69758 | | - pMem->szMalloc = 0; |
| 69759 | | - return SQLITE_NOMEM_BKPT; |
| 69760 | | - }else{ |
| 69761 | | - pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc); |
| 69762 | | - } |
| 69763 | | - } |
| 69764 | | - |
| 69765 | | - if( bPreserve && pMem->z && pMem->z!=pMem->zMalloc ){ |
| 69775 | + if( n<32 ) n = 32; |
| 69776 | + if( bPreserve && pMem->szMalloc>0 && pMem->z==pMem->zMalloc ){ |
| 69777 | + pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| 69778 | + bPreserve = 0; |
| 69779 | + }else{ |
| 69780 | + if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc); |
| 69781 | + pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, n); |
| 69782 | + } |
| 69783 | + if( pMem->zMalloc==0 ){ |
| 69784 | + sqlite3VdbeMemSetNull(pMem); |
| 69785 | + pMem->z = 0; |
| 69786 | + pMem->szMalloc = 0; |
| 69787 | + return SQLITE_NOMEM_BKPT; |
| 69788 | + }else{ |
| 69789 | + pMem->szMalloc = sqlite3DbMallocSize(pMem->db, pMem->zMalloc); |
| 69790 | + } |
| 69791 | + |
| 69792 | + if( bPreserve && pMem->z && ALWAYS(pMem->z!=pMem->zMalloc) ){ |
| 69766 | 69793 | memcpy(pMem->zMalloc, pMem->z, pMem->n); |
| 69767 | 69794 | } |
| 69768 | 69795 | if( (pMem->flags&MEM_Dyn)!=0 ){ |
| 69769 | 69796 | assert( pMem->xDel!=0 && pMem->xDel!=SQLITE_DYNAMIC ); |
| 69770 | 69797 | pMem->xDel((void *)(pMem->z)); |
| | @@ -69957,11 +69984,11 @@ |
| 69957 | 69984 | ctx.pOut = &t; |
| 69958 | 69985 | ctx.pMem = pMem; |
| 69959 | 69986 | ctx.pFunc = pFunc; |
| 69960 | 69987 | pFunc->xFinalize(&ctx); /* IMP: R-24505-23230 */ |
| 69961 | 69988 | assert( (pMem->flags & MEM_Dyn)==0 ); |
| 69962 | | - if( pMem->szMalloc>0 ) sqlite3DbFree(pMem->db, pMem->zMalloc); |
| 69989 | + if( pMem->szMalloc>0 ) sqlite3DbFreeNN(pMem->db, pMem->zMalloc); |
| 69963 | 69990 | memcpy(pMem, &t, sizeof(t)); |
| 69964 | 69991 | rc = ctx.isError; |
| 69965 | 69992 | } |
| 69966 | 69993 | return rc; |
| 69967 | 69994 | } |
| | @@ -70008,11 +70035,11 @@ |
| 70008 | 70035 | static SQLITE_NOINLINE void vdbeMemClear(Mem *p){ |
| 70009 | 70036 | if( VdbeMemDynamic(p) ){ |
| 70010 | 70037 | vdbeMemClearExternAndSetNull(p); |
| 70011 | 70038 | } |
| 70012 | 70039 | if( p->szMalloc ){ |
| 70013 | | - sqlite3DbFree(p->db, p->zMalloc); |
| 70040 | + sqlite3DbFreeNN(p->db, p->zMalloc); |
| 70014 | 70041 | p->szMalloc = 0; |
| 70015 | 70042 | } |
| 70016 | 70043 | p->z = 0; |
| 70017 | 70044 | } |
| 70018 | 70045 | |
| | @@ -70036,11 +70063,11 @@ |
| 70036 | 70063 | /* |
| 70037 | 70064 | ** Convert a 64-bit IEEE double into a 64-bit signed integer. |
| 70038 | 70065 | ** If the double is out of range of a 64-bit signed integer then |
| 70039 | 70066 | ** return the closest available 64-bit signed integer. |
| 70040 | 70067 | */ |
| 70041 | | -static i64 doubleToInt64(double r){ |
| 70068 | +static SQLITE_NOINLINE i64 doubleToInt64(double r){ |
| 70042 | 70069 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 70043 | 70070 | /* When floating-point is omitted, double and int64 are the same thing */ |
| 70044 | 70071 | return r; |
| 70045 | 70072 | #else |
| 70046 | 70073 | /* |
| | @@ -70072,10 +70099,15 @@ |
| 70072 | 70099 | ** it into an integer and return that. If pMem represents an |
| 70073 | 70100 | ** an SQL-NULL value, return 0. |
| 70074 | 70101 | ** |
| 70075 | 70102 | ** If pMem represents a string value, its encoding might be changed. |
| 70076 | 70103 | */ |
| 70104 | +static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){ |
| 70105 | + i64 value = 0; |
| 70106 | + sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc); |
| 70107 | + return value; |
| 70108 | +} |
| 70077 | 70109 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){ |
| 70078 | 70110 | int flags; |
| 70079 | 70111 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 70080 | 70112 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 70081 | 70113 | flags = pMem->flags; |
| | @@ -70082,14 +70114,12 @@ |
| 70082 | 70114 | if( flags & MEM_Int ){ |
| 70083 | 70115 | return pMem->u.i; |
| 70084 | 70116 | }else if( flags & MEM_Real ){ |
| 70085 | 70117 | return doubleToInt64(pMem->u.r); |
| 70086 | 70118 | }else if( flags & (MEM_Str|MEM_Blob) ){ |
| 70087 | | - i64 value = 0; |
| 70088 | 70119 | assert( pMem->z || pMem->n==0 ); |
| 70089 | | - sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc); |
| 70090 | | - return value; |
| 70120 | + return memIntValue(pMem); |
| 70091 | 70121 | }else{ |
| 70092 | 70122 | return 0; |
| 70093 | 70123 | } |
| 70094 | 70124 | } |
| 70095 | 70125 | |
| | @@ -70097,22 +70127,25 @@ |
| 70097 | 70127 | ** Return the best representation of pMem that we can get into a |
| 70098 | 70128 | ** double. If pMem is already a double or an integer, return its |
| 70099 | 70129 | ** value. If it is a string or blob, try to convert it to a double. |
| 70100 | 70130 | ** If it is a NULL, return 0.0. |
| 70101 | 70131 | */ |
| 70132 | +static SQLITE_NOINLINE double memRealValue(Mem *pMem){ |
| 70133 | + /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 70134 | + double val = (double)0; |
| 70135 | + sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc); |
| 70136 | + return val; |
| 70137 | +} |
| 70102 | 70138 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){ |
| 70103 | 70139 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 70104 | 70140 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 70105 | 70141 | if( pMem->flags & MEM_Real ){ |
| 70106 | 70142 | return pMem->u.r; |
| 70107 | 70143 | }else if( pMem->flags & MEM_Int ){ |
| 70108 | 70144 | return (double)pMem->u.i; |
| 70109 | 70145 | }else if( pMem->flags & (MEM_Str|MEM_Blob) ){ |
| 70110 | | - /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 70111 | | - double val = (double)0; |
| 70112 | | - sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc); |
| 70113 | | - return val; |
| 70146 | + return memRealValue(pMem); |
| 70114 | 70147 | }else{ |
| 70115 | 70148 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 70116 | 70149 | return (double)0; |
| 70117 | 70150 | } |
| 70118 | 70151 | } |
| | @@ -70733,11 +70766,11 @@ |
| 70733 | 70766 | for(i=0; i<nCol; i++){ |
| 70734 | 70767 | pRec->aMem[i].flags = MEM_Null; |
| 70735 | 70768 | pRec->aMem[i].db = db; |
| 70736 | 70769 | } |
| 70737 | 70770 | }else{ |
| 70738 | | - sqlite3DbFree(db, pRec); |
| 70771 | + sqlite3DbFreeNN(db, pRec); |
| 70739 | 70772 | pRec = 0; |
| 70740 | 70773 | } |
| 70741 | 70774 | } |
| 70742 | 70775 | if( pRec==0 ) return 0; |
| 70743 | 70776 | p->ppRec[0] = pRec; |
| | @@ -70845,11 +70878,11 @@ |
| 70845 | 70878 | } |
| 70846 | 70879 | if( apVal ){ |
| 70847 | 70880 | for(i=0; i<nVal; i++){ |
| 70848 | 70881 | sqlite3ValueFree(apVal[i]); |
| 70849 | 70882 | } |
| 70850 | | - sqlite3DbFree(db, apVal); |
| 70883 | + sqlite3DbFreeNN(db, apVal); |
| 70851 | 70884 | } |
| 70852 | 70885 | |
| 70853 | 70886 | *ppVal = pVal; |
| 70854 | 70887 | return rc; |
| 70855 | 70888 | } |
| | @@ -71044,11 +71077,11 @@ |
| 71044 | 71077 | }else{ |
| 71045 | 71078 | aRet[0] = nSerial+1; |
| 71046 | 71079 | putVarint32(&aRet[1], iSerial); |
| 71047 | 71080 | sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial); |
| 71048 | 71081 | sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT); |
| 71049 | | - sqlite3DbFree(db, aRet); |
| 71082 | + sqlite3DbFreeNN(db, aRet); |
| 71050 | 71083 | } |
| 71051 | 71084 | } |
| 71052 | 71085 | |
| 71053 | 71086 | /* |
| 71054 | 71087 | ** Register built-in functions used to help read ANALYZE data. |
| | @@ -71271,11 +71304,11 @@ |
| 71271 | 71304 | sqlite3 *db = aMem[0].db; |
| 71272 | 71305 | for(i=0; i<nCol; i++){ |
| 71273 | 71306 | sqlite3VdbeMemRelease(&aMem[i]); |
| 71274 | 71307 | } |
| 71275 | 71308 | sqlite3KeyInfoUnref(pRec->pKeyInfo); |
| 71276 | | - sqlite3DbFree(db, pRec); |
| 71309 | + sqlite3DbFreeNN(db, pRec); |
| 71277 | 71310 | } |
| 71278 | 71311 | } |
| 71279 | 71312 | #endif /* ifdef SQLITE_ENABLE_STAT4 */ |
| 71280 | 71313 | |
| 71281 | 71314 | /* |
| | @@ -71295,11 +71328,11 @@ |
| 71295 | 71328 | ** Free an sqlite3_value object |
| 71296 | 71329 | */ |
| 71297 | 71330 | SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value *v){ |
| 71298 | 71331 | if( !v ) return; |
| 71299 | 71332 | sqlite3VdbeMemRelease((Mem *)v); |
| 71300 | | - sqlite3DbFree(((Mem*)v)->db, v); |
| 71333 | + sqlite3DbFreeNN(((Mem*)v)->db, v); |
| 71301 | 71334 | } |
| 71302 | 71335 | |
| 71303 | 71336 | /* |
| 71304 | 71337 | ** The sqlite3ValueBytes() routine returns the number of bytes in the |
| 71305 | 71338 | ** sqlite3_value object assuming that it uses the encoding "enc". |
| | @@ -72138,11 +72171,11 @@ |
| 72138 | 72171 | ** If the input FuncDef structure is ephemeral, then free it. If |
| 72139 | 72172 | ** the FuncDef is not ephermal, then do nothing. |
| 72140 | 72173 | */ |
| 72141 | 72174 | static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){ |
| 72142 | 72175 | if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){ |
| 72143 | | - sqlite3DbFree(db, pDef); |
| 72176 | + sqlite3DbFreeNN(db, pDef); |
| 72144 | 72177 | } |
| 72145 | 72178 | } |
| 72146 | 72179 | |
| 72147 | 72180 | static void vdbeFreeOpArray(sqlite3 *, Op *, int); |
| 72148 | 72181 | |
| | @@ -72149,15 +72182,15 @@ |
| 72149 | 72182 | /* |
| 72150 | 72183 | ** Delete a P4 value if necessary. |
| 72151 | 72184 | */ |
| 72152 | 72185 | static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){ |
| 72153 | 72186 | if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc); |
| 72154 | | - sqlite3DbFree(db, p); |
| 72187 | + sqlite3DbFreeNN(db, p); |
| 72155 | 72188 | } |
| 72156 | 72189 | static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){ |
| 72157 | 72190 | freeEphemeralFunction(db, p->pFunc); |
| 72158 | | - sqlite3DbFree(db, p); |
| 72191 | + sqlite3DbFreeNN(db, p); |
| 72159 | 72192 | } |
| 72160 | 72193 | static void freeP4(sqlite3 *db, int p4type, void *p4){ |
| 72161 | 72194 | assert( db ); |
| 72162 | 72195 | switch( p4type ){ |
| 72163 | 72196 | case P4_FUNCCTX: { |
| | @@ -72206,18 +72239,18 @@ |
| 72206 | 72239 | ** nOp entries. |
| 72207 | 72240 | */ |
| 72208 | 72241 | static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){ |
| 72209 | 72242 | if( aOp ){ |
| 72210 | 72243 | Op *pOp; |
| 72211 | | - for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ |
| 72244 | + for(pOp=&aOp[nOp-1]; pOp>=aOp; pOp--){ |
| 72212 | 72245 | if( pOp->p4type ) freeP4(db, pOp->p4type, pOp->p4.p); |
| 72213 | 72246 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 72214 | 72247 | sqlite3DbFree(db, pOp->zComment); |
| 72215 | 72248 | #endif |
| 72216 | 72249 | } |
| 72250 | + sqlite3DbFreeNN(db, aOp); |
| 72217 | 72251 | } |
| 72218 | | - sqlite3DbFree(db, aOp); |
| 72219 | 72252 | } |
| 72220 | 72253 | |
| 72221 | 72254 | /* |
| 72222 | 72255 | ** Link the SubProgram object passed as the second argument into the linked |
| 72223 | 72256 | ** list at Vdbe.pSubProgram. This list is used to delete all sub-program |
| | @@ -72886,11 +72919,11 @@ |
| 72886 | 72919 | testcase( p->flags & MEM_Frame ); |
| 72887 | 72920 | testcase( p->flags & MEM_RowSet ); |
| 72888 | 72921 | if( p->flags&(MEM_Agg|MEM_Dyn|MEM_Frame|MEM_RowSet) ){ |
| 72889 | 72922 | sqlite3VdbeMemRelease(p); |
| 72890 | 72923 | }else if( p->szMalloc ){ |
| 72891 | | - sqlite3DbFree(db, p->zMalloc); |
| 72924 | + sqlite3DbFreeNN(db, p->zMalloc); |
| 72892 | 72925 | p->szMalloc = 0; |
| 72893 | 72926 | } |
| 72894 | 72927 | |
| 72895 | 72928 | p->flags = MEM_Undefined; |
| 72896 | 72929 | }while( (++p)<pEnd ); |
| | @@ -73362,12 +73395,12 @@ |
| 73362 | 73395 | case CURTYPE_SORTER: { |
| 73363 | 73396 | sqlite3VdbeSorterClose(p->db, pCx); |
| 73364 | 73397 | break; |
| 73365 | 73398 | } |
| 73366 | 73399 | case CURTYPE_BTREE: { |
| 73367 | | - if( pCx->pBtx ){ |
| 73368 | | - sqlite3BtreeClose(pCx->pBtx); |
| 73400 | + if( pCx->isEphemeral ){ |
| 73401 | + if( pCx->pBtx ) sqlite3BtreeClose(pCx->pBtx); |
| 73369 | 73402 | /* The pCx->pCursor will be close automatically, if it exists, by |
| 73370 | 73403 | ** the call above. */ |
| 73371 | 73404 | }else{ |
| 73372 | 73405 | assert( pCx->uc.pCursor!=0 ); |
| 73373 | 73406 | sqlite3BtreeCloseCursor(pCx->uc.pCursor); |
| | @@ -74257,11 +74290,10 @@ |
| 74257 | 74290 | } |
| 74258 | 74291 | fclose(out); |
| 74259 | 74292 | } |
| 74260 | 74293 | } |
| 74261 | 74294 | #endif |
| 74262 | | - p->iCurrentTime = 0; |
| 74263 | 74295 | p->magic = VDBE_MAGIC_RESET; |
| 74264 | 74296 | return p->rc & db->errMask; |
| 74265 | 74297 | } |
| 74266 | 74298 | |
| 74267 | 74299 | /* |
| | @@ -74367,11 +74399,11 @@ |
| 74367 | 74399 | if( p->pNext ){ |
| 74368 | 74400 | p->pNext->pPrev = p->pPrev; |
| 74369 | 74401 | } |
| 74370 | 74402 | p->magic = VDBE_MAGIC_DEAD; |
| 74371 | 74403 | p->db = 0; |
| 74372 | | - sqlite3DbFree(db, p); |
| 74404 | + sqlite3DbFreeNN(db, p); |
| 74373 | 74405 | } |
| 74374 | 74406 | |
| 74375 | 74407 | /* |
| 74376 | 74408 | ** The cursor "p" has a pending seek operation that has not yet been |
| 74377 | 74409 | ** carried out. Seek the cursor now. If an error occurs, return |
| | @@ -75926,11 +75958,11 @@ |
| 75926 | 75958 | int i; |
| 75927 | 75959 | for(i=0; i<nField; i++){ |
| 75928 | 75960 | Mem *pMem = &p->aMem[i]; |
| 75929 | 75961 | if( pMem->zMalloc ) sqlite3VdbeMemRelease(pMem); |
| 75930 | 75962 | } |
| 75931 | | - sqlite3DbFree(db, p); |
| 75963 | + sqlite3DbFreeNN(db, p); |
| 75932 | 75964 | } |
| 75933 | 75965 | } |
| 75934 | 75966 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 75935 | 75967 | |
| 75936 | 75968 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| | @@ -75993,11 +76025,11 @@ |
| 75993 | 76025 | if( preupdate.aNew ){ |
| 75994 | 76026 | int i; |
| 75995 | 76027 | for(i=0; i<pCsr->nField; i++){ |
| 75996 | 76028 | sqlite3VdbeMemRelease(&preupdate.aNew[i]); |
| 75997 | 76029 | } |
| 75998 | | - sqlite3DbFree(db, preupdate.aNew); |
| 76030 | + sqlite3DbFreeNN(db, preupdate.aNew); |
| 75999 | 76031 | } |
| 76000 | 76032 | } |
| 76001 | 76033 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 76002 | 76034 | |
| 76003 | 76035 | /************** End of vdbeaux.c *********************************************/ |
| | @@ -78579,10 +78611,11 @@ |
| 78579 | 78611 | } |
| 78580 | 78612 | static void registerTrace(int iReg, Mem *p){ |
| 78581 | 78613 | printf("REG[%d] = ", iReg); |
| 78582 | 78614 | memTracePrint(p); |
| 78583 | 78615 | printf("\n"); |
| 78616 | + sqlite3VdbeCheckMemInvariants(p); |
| 78584 | 78617 | } |
| 78585 | 78618 | #endif |
| 78586 | 78619 | |
| 78587 | 78620 | #ifdef SQLITE_DEBUG |
| 78588 | 78621 | # define REGISTER_TRACE(R,M) if(db->flags&SQLITE_VdbeTrace)registerTrace(R,M) |
| | @@ -78945,11 +78978,11 @@ |
| 78945 | 78978 | case OP_Goto: { /* jump */ |
| 78946 | 78979 | jump_to_p2_and_check_for_interrupt: |
| 78947 | 78980 | pOp = &aOp[pOp->p2 - 1]; |
| 78948 | 78981 | |
| 78949 | 78982 | /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev, |
| 78950 | | - ** OP_VNext, OP_RowSetNext, or OP_SorterNext) all jump here upon |
| 78983 | + ** OP_VNext, or OP_SorterNext) all jump here upon |
| 78951 | 78984 | ** completion. Check to see if sqlite3_interrupt() has been called |
| 78952 | 78985 | ** or if the progress callback needs to be invoked. |
| 78953 | 78986 | ** |
| 78954 | 78987 | ** This code uses unstructured "goto" statements and does not look clean. |
| 78955 | 78988 | ** But that is not due to sloppy coding habits. The code is written this |
| | @@ -79333,11 +79366,11 @@ |
| 79333 | 79366 | ** previously copied using OP_SCopy, the copies will continue to be valid. |
| 79334 | 79367 | */ |
| 79335 | 79368 | case OP_SoftNull: { |
| 79336 | 79369 | assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) ); |
| 79337 | 79370 | pOut = &aMem[pOp->p1]; |
| 79338 | | - pOut->flags = (pOut->flags|MEM_Null)&~MEM_Undefined; |
| 79371 | + pOut->flags = (pOut->flags&~(MEM_Undefined|MEM_AffMask))|MEM_Null; |
| 79339 | 79372 | break; |
| 79340 | 79373 | } |
| 79341 | 79374 | |
| 79342 | 79375 | /* Opcode: Blob P1 P2 * P4 * |
| 79343 | 79376 | ** Synopsis: r[P2]=P4 (len=P1) |
| | @@ -79676,11 +79709,10 @@ |
| 79676 | 79709 | type1 = numericType(pIn1); |
| 79677 | 79710 | pIn2 = &aMem[pOp->p2]; |
| 79678 | 79711 | type2 = numericType(pIn2); |
| 79679 | 79712 | pOut = &aMem[pOp->p3]; |
| 79680 | 79713 | flags = pIn1->flags | pIn2->flags; |
| 79681 | | - if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; |
| 79682 | 79714 | if( (type1 & type2 & MEM_Int)!=0 ){ |
| 79683 | 79715 | iA = pIn1->u.i; |
| 79684 | 79716 | iB = pIn2->u.i; |
| 79685 | 79717 | bIntint = 1; |
| 79686 | 79718 | switch( pOp->opcode ){ |
| | @@ -79700,10 +79732,12 @@ |
| 79700 | 79732 | break; |
| 79701 | 79733 | } |
| 79702 | 79734 | } |
| 79703 | 79735 | pOut->u.i = iB; |
| 79704 | 79736 | MemSetTypeFlag(pOut, MEM_Int); |
| 79737 | + }else if( (flags & MEM_Null)!=0 ){ |
| 79738 | + goto arithmetic_result_is_null; |
| 79705 | 79739 | }else{ |
| 79706 | 79740 | bIntint = 0; |
| 79707 | 79741 | fp_math: |
| 79708 | 79742 | rA = sqlite3VdbeRealValue(pIn1); |
| 79709 | 79743 | rB = sqlite3VdbeRealValue(pIn2); |
| | @@ -79747,11 +79781,11 @@ |
| 79747 | 79781 | break; |
| 79748 | 79782 | } |
| 79749 | 79783 | |
| 79750 | 79784 | /* Opcode: CollSeq P1 * * P4 |
| 79751 | 79785 | ** |
| 79752 | | -** P4 is a pointer to a CollSeq struct. If the next call to a user function |
| 79786 | +** P4 is a pointer to a CollSeq object. If the next call to a user function |
| 79753 | 79787 | ** or aggregate calls sqlite3GetFuncCollSeq(), this collation sequence will |
| 79754 | 79788 | ** be returned. This is used by the built-in min(), max() and nullif() |
| 79755 | 79789 | ** functions. |
| 79756 | 79790 | ** |
| 79757 | 79791 | ** If P1 is not zero, then it is a register that a subsequent min() or |
| | @@ -80028,15 +80062,15 @@ |
| 80028 | 80062 | ** Synopsis: affinity(r[P1]) |
| 80029 | 80063 | ** |
| 80030 | 80064 | ** Force the value in register P1 to be the type defined by P2. |
| 80031 | 80065 | ** |
| 80032 | 80066 | ** <ul> |
| 80033 | | -** <li value="97"> TEXT |
| 80034 | | -** <li value="98"> BLOB |
| 80035 | | -** <li value="99"> NUMERIC |
| 80036 | | -** <li value="100"> INTEGER |
| 80037 | | -** <li value="101"> REAL |
| 80067 | +** <li> P2=='A' → BLOB |
| 80068 | +** <li> P2=='B' → TEXT |
| 80069 | +** <li> P2=='C' → NUMERIC |
| 80070 | +** <li> P2=='D' → INTEGER |
| 80071 | +** <li> P2=='E' → REAL |
| 80038 | 80072 | ** </ul> |
| 80039 | 80073 | ** |
| 80040 | 80074 | ** A NULL value is not changed by this routine. It remains NULL. |
| 80041 | 80075 | */ |
| 80042 | 80076 | case OP_Cast: { /* in1 */ |
| | @@ -80610,10 +80644,27 @@ |
| 80610 | 80644 | if( (pIn1->flags & MEM_Null)==0 ){ |
| 80611 | 80645 | goto jump_to_p2; |
| 80612 | 80646 | } |
| 80613 | 80647 | break; |
| 80614 | 80648 | } |
| 80649 | + |
| 80650 | +/* Opcode: IfNullRow P1 P2 P3 * * |
| 80651 | +** Synopsis: if P1.nullRow then r[P3]=NULL, goto P2 |
| 80652 | +** |
| 80653 | +** Check the cursor P1 to see if it is currently pointing at a NULL row. |
| 80654 | +** If it is, then set register P3 to NULL and jump immediately to P2. |
| 80655 | +** If P1 is not on a NULL row, then fall through without making any |
| 80656 | +** changes. |
| 80657 | +*/ |
| 80658 | +case OP_IfNullRow: { /* jump */ |
| 80659 | + assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 80660 | + if( p->apCsr[pOp->p1]->nullRow ){ |
| 80661 | + sqlite3VdbeMemSetNull(aMem + pOp->p3); |
| 80662 | + goto jump_to_p2; |
| 80663 | + } |
| 80664 | + break; |
| 80665 | +} |
| 80615 | 80666 | |
| 80616 | 80667 | /* Opcode: Column P1 P2 P3 P4 P5 |
| 80617 | 80668 | ** Synopsis: r[P3]=PX |
| 80618 | 80669 | ** |
| 80619 | 80670 | ** Interpret the data that cursor P1 points to as a structure built using |
| | @@ -80622,20 +80673,20 @@ |
| 80622 | 80673 | ** from this record. If there are less that (P2+1) |
| 80623 | 80674 | ** values in the record, extract a NULL. |
| 80624 | 80675 | ** |
| 80625 | 80676 | ** The value extracted is stored in register P3. |
| 80626 | 80677 | ** |
| 80627 | | -** If the column contains fewer than P2 fields, then extract a NULL. Or, |
| 80678 | +** If the record contains fewer than P2 fields, then extract a NULL. Or, |
| 80628 | 80679 | ** if the P4 argument is a P4_MEM use the value of the P4 argument as |
| 80629 | 80680 | ** the result. |
| 80630 | 80681 | ** |
| 80631 | 80682 | ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, |
| 80632 | 80683 | ** then the cache of the cursor is reset prior to extracting the column. |
| 80633 | 80684 | ** The first OP_Column against a pseudo-table after the value of the content |
| 80634 | 80685 | ** register has changed should have this bit set. |
| 80635 | 80686 | ** |
| 80636 | | -** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when |
| 80687 | +** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 then |
| 80637 | 80688 | ** the result is guaranteed to only be used as the argument of a length() |
| 80638 | 80689 | ** or typeof() function, respectively. The loading of large blobs can be |
| 80639 | 80690 | ** skipped for length() and all content loading can be skipped for typeof(). |
| 80640 | 80691 | */ |
| 80641 | 80692 | case OP_Column: { |
| | @@ -80886,28 +80937,28 @@ |
| 80886 | 80937 | /* Opcode: Affinity P1 P2 * P4 * |
| 80887 | 80938 | ** Synopsis: affinity(r[P1@P2]) |
| 80888 | 80939 | ** |
| 80889 | 80940 | ** Apply affinities to a range of P2 registers starting with P1. |
| 80890 | 80941 | ** |
| 80891 | | -** P4 is a string that is P2 characters long. The nth character of the |
| 80892 | | -** string indicates the column affinity that should be used for the nth |
| 80942 | +** P4 is a string that is P2 characters long. The N-th character of the |
| 80943 | +** string indicates the column affinity that should be used for the N-th |
| 80893 | 80944 | ** memory cell in the range. |
| 80894 | 80945 | */ |
| 80895 | 80946 | case OP_Affinity: { |
| 80896 | 80947 | const char *zAffinity; /* The affinity to be applied */ |
| 80897 | | - char cAff; /* A single character of affinity */ |
| 80898 | 80948 | |
| 80899 | 80949 | zAffinity = pOp->p4.z; |
| 80900 | 80950 | assert( zAffinity!=0 ); |
| 80951 | + assert( pOp->p2>0 ); |
| 80901 | 80952 | assert( zAffinity[pOp->p2]==0 ); |
| 80902 | 80953 | pIn1 = &aMem[pOp->p1]; |
| 80903 | | - while( (cAff = *(zAffinity++))!=0 ){ |
| 80954 | + do{ |
| 80904 | 80955 | assert( pIn1 <= &p->aMem[(p->nMem+1 - p->nCursor)] ); |
| 80905 | 80956 | assert( memIsValid(pIn1) ); |
| 80906 | | - applyAffinity(pIn1, cAff, encoding); |
| 80957 | + applyAffinity(pIn1, *(zAffinity++), encoding); |
| 80907 | 80958 | pIn1++; |
| 80908 | | - } |
| 80959 | + }while( zAffinity[0] ); |
| 80909 | 80960 | break; |
| 80910 | 80961 | } |
| 80911 | 80962 | |
| 80912 | 80963 | /* Opcode: MakeRecord P1 P2 P3 P4 * |
| 80913 | 80964 | ** Synopsis: r[P3]=mkrec(r[P1@P2]) |
| | @@ -80914,12 +80965,12 @@ |
| 80914 | 80965 | ** |
| 80915 | 80966 | ** Convert P2 registers beginning with P1 into the [record format] |
| 80916 | 80967 | ** use as a data record in a database table or as a key |
| 80917 | 80968 | ** in an index. The OP_Column opcode can decode the record later. |
| 80918 | 80969 | ** |
| 80919 | | -** P4 may be a string that is P2 characters long. The nth character of the |
| 80920 | | -** string indicates the column affinity that should be used for the nth |
| 80970 | +** P4 may be a string that is P2 characters long. The N-th character of the |
| 80971 | +** string indicates the column affinity that should be used for the N-th |
| 80921 | 80972 | ** field of the index key. |
| 80922 | 80973 | ** |
| 80923 | 80974 | ** The mapping from character to affinity is given by the SQLITE_AFF_ |
| 80924 | 80975 | ** macros defined in sqliteInt.h. |
| 80925 | 80976 | ** |
| | @@ -81074,11 +81125,10 @@ |
| 81074 | 81125 | pOut->flags = MEM_Blob; |
| 81075 | 81126 | if( nZero ){ |
| 81076 | 81127 | pOut->u.nZero = nZero; |
| 81077 | 81128 | pOut->flags |= MEM_Zero; |
| 81078 | 81129 | } |
| 81079 | | - pOut->enc = SQLITE_UTF8; /* In case the blob is ever converted to text */ |
| 81080 | 81130 | REGISTER_TRACE(pOp->p3, pOut); |
| 81081 | 81131 | UPDATE_MAX_BLOBSIZE(pOut); |
| 81082 | 81132 | break; |
| 81083 | 81133 | } |
| 81084 | 81134 | |
| | @@ -81703,10 +81753,41 @@ |
| 81703 | 81753 | sqlite3BtreeCursorHintFlags(pCur->uc.pCursor, |
| 81704 | 81754 | (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ))); |
| 81705 | 81755 | if( rc ) goto abort_due_to_error; |
| 81706 | 81756 | break; |
| 81707 | 81757 | } |
| 81758 | + |
| 81759 | +/* Opcode: OpenDup P1 P2 * * * |
| 81760 | +** |
| 81761 | +** Open a new cursor P1 that points to the same ephemeral table as |
| 81762 | +** cursor P2. The P2 cursor must have been opened by a prior OP_OpenEphemeral |
| 81763 | +** opcode. Only ephemeral cursors may be duplicated. |
| 81764 | +** |
| 81765 | +** Duplicate ephemeral cursors are used for self-joins of materialized views. |
| 81766 | +*/ |
| 81767 | +case OP_OpenDup: { |
| 81768 | + VdbeCursor *pOrig; /* The original cursor to be duplicated */ |
| 81769 | + VdbeCursor *pCx; /* The new cursor */ |
| 81770 | + |
| 81771 | + pOrig = p->apCsr[pOp->p2]; |
| 81772 | + assert( pOrig->pBtx!=0 ); /* Only ephemeral cursors can be duplicated */ |
| 81773 | + |
| 81774 | + pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); |
| 81775 | + if( pCx==0 ) goto no_mem; |
| 81776 | + pCx->nullRow = 1; |
| 81777 | + pCx->isEphemeral = 1; |
| 81778 | + pCx->pKeyInfo = pOrig->pKeyInfo; |
| 81779 | + pCx->isTable = pOrig->isTable; |
| 81780 | + rc = sqlite3BtreeCursor(pOrig->pBtx, MASTER_ROOT, BTREE_WRCSR, |
| 81781 | + pCx->pKeyInfo, pCx->uc.pCursor); |
| 81782 | + /* The sqlite3BtreeCursor() routine can only fail for the first cursor |
| 81783 | + ** opened for a database. Since there is already an open cursor when this |
| 81784 | + ** opcode is run, the sqlite3BtreeCursor() cannot fail */ |
| 81785 | + assert( rc==SQLITE_OK ); |
| 81786 | + break; |
| 81787 | +} |
| 81788 | + |
| 81708 | 81789 | |
| 81709 | 81790 | /* Opcode: OpenEphemeral P1 P2 * P4 P5 |
| 81710 | 81791 | ** Synopsis: nColumn=P2 |
| 81711 | 81792 | ** |
| 81712 | 81793 | ** Open a new cursor P1 to a transient table. |
| | @@ -82259,11 +82340,11 @@ |
| 82259 | 82340 | break; |
| 82260 | 82341 | } |
| 82261 | 82342 | } |
| 82262 | 82343 | } |
| 82263 | 82344 | rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res); |
| 82264 | | - if( pFree ) sqlite3DbFree(db, pFree); |
| 82345 | + if( pFree ) sqlite3DbFreeNN(db, pFree); |
| 82265 | 82346 | if( rc!=SQLITE_OK ){ |
| 82266 | 82347 | goto abort_due_to_error; |
| 82267 | 82348 | } |
| 82268 | 82349 | pC->seekResult = res; |
| 82269 | 82350 | alreadyExists = (res==0); |
| | @@ -83569,14 +83650,21 @@ |
| 83569 | 83650 | ** |
| 83570 | 83651 | ** If AUTOVACUUM is enabled then it is possible that another root page |
| 83571 | 83652 | ** might be moved into the newly deleted root page in order to keep all |
| 83572 | 83653 | ** root pages contiguous at the beginning of the database. The former |
| 83573 | 83654 | ** value of the root page that moved - its value before the move occurred - |
| 83574 | | -** is stored in register P2. If no page |
| 83575 | | -** movement was required (because the table being dropped was already |
| 83576 | | -** the last one in the database) then a zero is stored in register P2. |
| 83577 | | -** If AUTOVACUUM is disabled then a zero is stored in register P2. |
| 83655 | +** is stored in register P2. If no page movement was required (because the |
| 83656 | +** table being dropped was already the last one in the database) then a |
| 83657 | +** zero is stored in register P2. If AUTOVACUUM is disabled then a zero |
| 83658 | +** is stored in register P2. |
| 83659 | +** |
| 83660 | +** This opcode throws an error if there are any active reader VMs when |
| 83661 | +** it is invoked. This is done to avoid the difficulty associated with |
| 83662 | +** updating existing cursors when a root page is moved in an AUTOVACUUM |
| 83663 | +** database. This error is thrown even if the database is not an AUTOVACUUM |
| 83664 | +** db in order to avoid introducing an incompatibility between autovacuum |
| 83665 | +** and non-autovacuum modes. |
| 83578 | 83666 | ** |
| 83579 | 83667 | ** See also: Clear |
| 83580 | 83668 | */ |
| 83581 | 83669 | case OP_Destroy: { /* out2 */ |
| 83582 | 83670 | int iMoved; |
| | @@ -83777,11 +83865,11 @@ |
| 83777 | 83865 | db->init.busy = 1; |
| 83778 | 83866 | initData.rc = SQLITE_OK; |
| 83779 | 83867 | assert( !db->mallocFailed ); |
| 83780 | 83868 | rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); |
| 83781 | 83869 | if( rc==SQLITE_OK ) rc = initData.rc; |
| 83782 | | - sqlite3DbFree(db, zSql); |
| 83870 | + sqlite3DbFreeNN(db, zSql); |
| 83783 | 83871 | db->init.busy = 0; |
| 83784 | 83872 | } |
| 83785 | 83873 | } |
| 83786 | 83874 | if( rc ){ |
| 83787 | 83875 | sqlite3ResetAllSchemasOfConnection(db); |
| | @@ -83905,11 +83993,11 @@ |
| 83905 | 83993 | #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ |
| 83906 | 83994 | |
| 83907 | 83995 | /* Opcode: RowSetAdd P1 P2 * * * |
| 83908 | 83996 | ** Synopsis: rowset(P1)=r[P2] |
| 83909 | 83997 | ** |
| 83910 | | -** Insert the integer value held by register P2 into a boolean index |
| 83998 | +** Insert the integer value held by register P2 into a RowSet object |
| 83911 | 83999 | ** held in register P1. |
| 83912 | 84000 | ** |
| 83913 | 84001 | ** An assertion fails if P2 is not an integer. |
| 83914 | 84002 | */ |
| 83915 | 84003 | case OP_RowSetAdd: { /* in1, in2 */ |
| | @@ -83925,12 +84013,13 @@ |
| 83925 | 84013 | } |
| 83926 | 84014 | |
| 83927 | 84015 | /* Opcode: RowSetRead P1 P2 P3 * * |
| 83928 | 84016 | ** Synopsis: r[P3]=rowset(P1) |
| 83929 | 84017 | ** |
| 83930 | | -** Extract the smallest value from boolean index P1 and put that value into |
| 83931 | | -** register P3. Or, if boolean index P1 is initially empty, leave P3 |
| 84018 | +** Extract the smallest value from the RowSet object in P1 |
| 84019 | +** and put that value into register P3. |
| 84020 | +** Or, if RowSet object P1 is initially empty, leave P3 |
| 83932 | 84021 | ** unchanged and jump to instruction P2. |
| 83933 | 84022 | */ |
| 83934 | 84023 | case OP_RowSetRead: { /* jump, in1, out3 */ |
| 83935 | 84024 | i64 val; |
| 83936 | 84025 | |
| | @@ -83957,19 +84046,18 @@ |
| 83957 | 84046 | ** contains a RowSet object and that RowSet object contains |
| 83958 | 84047 | ** the value held in P3, jump to register P2. Otherwise, insert the |
| 83959 | 84048 | ** integer in P3 into the RowSet and continue on to the |
| 83960 | 84049 | ** next opcode. |
| 83961 | 84050 | ** |
| 83962 | | -** The RowSet object is optimized for the case where successive sets |
| 83963 | | -** of integers, where each set contains no duplicates. Each set |
| 83964 | | -** of values is identified by a unique P4 value. The first set |
| 83965 | | -** must have P4==0, the final set P4=-1. P4 must be either -1 or |
| 83966 | | -** non-negative. For non-negative values of P4 only the lower 4 |
| 83967 | | -** bits are significant. |
| 84051 | +** The RowSet object is optimized for the case where sets of integers |
| 84052 | +** are inserted in distinct phases, which each set contains no duplicates. |
| 84053 | +** Each set is identified by a unique P4 value. The first set |
| 84054 | +** must have P4==0, the final set must have P4==-1, and for all other sets |
| 84055 | +** must have P4>0. |
| 83968 | 84056 | ** |
| 83969 | 84057 | ** This allows optimizations: (a) when P4==0 there is no need to test |
| 83970 | | -** the rowset object for P3, as it is guaranteed not to contain it, |
| 84058 | +** the RowSet object for P3, as it is guaranteed not to contain it, |
| 83971 | 84059 | ** (b) when P4==-1 there is no need to insert the value, as it will |
| 83972 | 84060 | ** never be tested for, and (c) when a value that is part of set X is |
| 83973 | 84061 | ** inserted, there is no need to search to see if the same value was |
| 83974 | 84062 | ** previously inserted as part of set X (only if it was previously |
| 83975 | 84063 | ** inserted as part of some other set). |
| | @@ -86705,41 +86793,40 @@ |
| 86705 | 86793 | int res; /* Return value */ |
| 86706 | 86794 | |
| 86707 | 86795 | assert( (s1>0 && s1<7) || s1==8 || s1==9 ); |
| 86708 | 86796 | assert( (s2>0 && s2<7) || s2==8 || s2==9 ); |
| 86709 | 86797 | |
| 86710 | | - if( s1>7 && s2>7 ){ |
| 86711 | | - res = s1 - s2; |
| 86712 | | - }else{ |
| 86713 | | - if( s1==s2 ){ |
| 86714 | | - if( (*v1 ^ *v2) & 0x80 ){ |
| 86715 | | - /* The two values have different signs */ |
| 86716 | | - res = (*v1 & 0x80) ? -1 : +1; |
| 86717 | | - }else{ |
| 86718 | | - /* The two values have the same sign. Compare using memcmp(). */ |
| 86719 | | - static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8 }; |
| 86720 | | - int i; |
| 86721 | | - res = 0; |
| 86722 | | - for(i=0; i<aLen[s1]; i++){ |
| 86723 | | - if( (res = v1[i] - v2[i]) ) break; |
| 86724 | | - } |
| 86725 | | - } |
| 86726 | | - }else{ |
| 86727 | | - if( s2>7 ){ |
| 86728 | | - res = +1; |
| 86729 | | - }else if( s1>7 ){ |
| 86730 | | - res = -1; |
| 86731 | | - }else{ |
| 86732 | | - res = s1 - s2; |
| 86733 | | - } |
| 86734 | | - assert( res!=0 ); |
| 86735 | | - |
| 86736 | | - if( res>0 ){ |
| 86737 | | - if( *v1 & 0x80 ) res = -1; |
| 86738 | | - }else{ |
| 86739 | | - if( *v2 & 0x80 ) res = +1; |
| 86740 | | - } |
| 86798 | + if( s1==s2 ){ |
| 86799 | + /* The two values have the same sign. Compare using memcmp(). */ |
| 86800 | + static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8, 0, 0, 0 }; |
| 86801 | + const u8 n = aLen[s1]; |
| 86802 | + int i; |
| 86803 | + res = 0; |
| 86804 | + for(i=0; i<n; i++){ |
| 86805 | + if( (res = v1[i] - v2[i])!=0 ){ |
| 86806 | + if( ((v1[0] ^ v2[0]) & 0x80)!=0 ){ |
| 86807 | + res = v1[0] & 0x80 ? -1 : +1; |
| 86808 | + } |
| 86809 | + break; |
| 86810 | + } |
| 86811 | + } |
| 86812 | + }else if( s1>7 && s2>7 ){ |
| 86813 | + res = s1 - s2; |
| 86814 | + }else{ |
| 86815 | + if( s2>7 ){ |
| 86816 | + res = +1; |
| 86817 | + }else if( s1>7 ){ |
| 86818 | + res = -1; |
| 86819 | + }else{ |
| 86820 | + res = s1 - s2; |
| 86821 | + } |
| 86822 | + assert( res!=0 ); |
| 86823 | + |
| 86824 | + if( res>0 ){ |
| 86825 | + if( *v1 & 0x80 ) res = -1; |
| 86826 | + }else{ |
| 86827 | + if( *v2 & 0x80 ) res = +1; |
| 86741 | 86828 | } |
| 86742 | 86829 | } |
| 86743 | 86830 | |
| 86744 | 86831 | if( res==0 ){ |
| 86745 | 86832 | if( pTask->pSorter->pKeyInfo->nField>1 ){ |
| | @@ -90790,11 +90877,11 @@ |
| 90790 | 90877 | if( op==TK_CAST ){ |
| 90791 | 90878 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 90792 | 90879 | return sqlite3AffinityType(pExpr->u.zToken, 0); |
| 90793 | 90880 | } |
| 90794 | 90881 | #endif |
| 90795 | | - if( op==TK_AGG_COLUMN || op==TK_COLUMN ){ |
| 90882 | + if( (op==TK_AGG_COLUMN || op==TK_COLUMN) && pExpr->pTab ){ |
| 90796 | 90883 | return sqlite3TableColumnAffinity(pExpr->pTab, pExpr->iColumn); |
| 90797 | 90884 | } |
| 90798 | 90885 | if( op==TK_SELECT_COLUMN ){ |
| 90799 | 90886 | assert( pExpr->pLeft->flags&EP_xIsSelect ); |
| 90800 | 90887 | return sqlite3ExprAffinity( |
| | @@ -91688,11 +91775,11 @@ |
| 91688 | 91775 | if( pExpr==0 ) return; |
| 91689 | 91776 | assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) ); |
| 91690 | 91777 | z = pExpr->u.zToken; |
| 91691 | 91778 | assert( z!=0 ); |
| 91692 | 91779 | assert( z[0]!=0 ); |
| 91693 | | - assert( n==sqlite3Strlen30(z) ); |
| 91780 | + assert( n==(u32)sqlite3Strlen30(z) ); |
| 91694 | 91781 | if( z[1]==0 ){ |
| 91695 | 91782 | /* Wildcard of the form "?". Assign the next variable number */ |
| 91696 | 91783 | assert( z[0]=='?' ); |
| 91697 | 91784 | x = (ynVar)(++pParse->nVar); |
| 91698 | 91785 | }else{ |
| | @@ -91770,11 +91857,11 @@ |
| 91770 | 91857 | sqlite3ExprListDelete(db, p->x.pList); |
| 91771 | 91858 | } |
| 91772 | 91859 | } |
| 91773 | 91860 | if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken); |
| 91774 | 91861 | if( !ExprHasProperty(p, EP_Static) ){ |
| 91775 | | - sqlite3DbFree(db, p); |
| 91862 | + sqlite3DbFreeNN(db, p); |
| 91776 | 91863 | } |
| 91777 | 91864 | } |
| 91778 | 91865 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3 *db, Expr *p){ |
| 91779 | 91866 | if( p ) sqlite3ExprDeleteNN(db, p); |
| 91780 | 91867 | } |
| | @@ -92037,19 +92124,15 @@ |
| 92037 | 92124 | struct ExprList_item *pItem, *pOldItem; |
| 92038 | 92125 | int i; |
| 92039 | 92126 | Expr *pPriorSelectCol = 0; |
| 92040 | 92127 | assert( db!=0 ); |
| 92041 | 92128 | if( p==0 ) return 0; |
| 92042 | | - pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); |
| 92129 | + pNew = sqlite3DbMallocRawNN(db, |
| 92130 | + sizeof(*pNew)+sizeof(pNew->a[0])*(p->nExpr-1) ); |
| 92043 | 92131 | if( pNew==0 ) return 0; |
| 92044 | | - pNew->nExpr = i = p->nExpr; |
| 92045 | | - if( (flags & EXPRDUP_REDUCE)==0 ) for(i=1; i<p->nExpr; i+=i){} |
| 92046 | | - pNew->a = pItem = sqlite3DbMallocRawNN(db, i*sizeof(p->a[0]) ); |
| 92047 | | - if( pItem==0 ){ |
| 92048 | | - sqlite3DbFree(db, pNew); |
| 92049 | | - return 0; |
| 92050 | | - } |
| 92132 | + pNew->nAlloc = pNew->nExpr = p->nExpr; |
| 92133 | + pItem = pNew->a; |
| 92051 | 92134 | pOldItem = p->a; |
| 92052 | 92135 | for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){ |
| 92053 | 92136 | Expr *pOldExpr = pOldItem->pExpr; |
| 92054 | 92137 | Expr *pNewExpr; |
| 92055 | 92138 | pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags); |
| | @@ -92136,11 +92219,11 @@ |
| 92136 | 92219 | pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); |
| 92137 | 92220 | if( pNew==0 ) return 0; |
| 92138 | 92221 | pNew->nId = p->nId; |
| 92139 | 92222 | pNew->a = sqlite3DbMallocRawNN(db, p->nId*sizeof(p->a[0]) ); |
| 92140 | 92223 | if( pNew->a==0 ){ |
| 92141 | | - sqlite3DbFree(db, pNew); |
| 92224 | + sqlite3DbFreeNN(db, pNew); |
| 92142 | 92225 | return 0; |
| 92143 | 92226 | } |
| 92144 | 92227 | /* Note that because the size of the allocation for p->a[] is not |
| 92145 | 92228 | ** necessarily a power of two, sqlite3IdListAppend() may not be called |
| 92146 | 92229 | ** on the duplicate created by this function. */ |
| | @@ -92207,35 +92290,33 @@ |
| 92207 | 92290 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend( |
| 92208 | 92291 | Parse *pParse, /* Parsing context */ |
| 92209 | 92292 | ExprList *pList, /* List to which to append. Might be NULL */ |
| 92210 | 92293 | Expr *pExpr /* Expression to be appended. Might be NULL */ |
| 92211 | 92294 | ){ |
| 92295 | + struct ExprList_item *pItem; |
| 92212 | 92296 | sqlite3 *db = pParse->db; |
| 92213 | 92297 | assert( db!=0 ); |
| 92214 | 92298 | if( pList==0 ){ |
| 92215 | 92299 | pList = sqlite3DbMallocRawNN(db, sizeof(ExprList) ); |
| 92216 | 92300 | if( pList==0 ){ |
| 92217 | 92301 | goto no_mem; |
| 92218 | 92302 | } |
| 92219 | 92303 | pList->nExpr = 0; |
| 92220 | | - pList->a = sqlite3DbMallocRawNN(db, sizeof(pList->a[0])); |
| 92221 | | - if( pList->a==0 ) goto no_mem; |
| 92222 | | - }else if( (pList->nExpr & (pList->nExpr-1))==0 ){ |
| 92223 | | - struct ExprList_item *a; |
| 92224 | | - assert( pList->nExpr>0 ); |
| 92225 | | - a = sqlite3DbRealloc(db, pList->a, pList->nExpr*2*sizeof(pList->a[0])); |
| 92226 | | - if( a==0 ){ |
| 92304 | + pList->nAlloc = 1; |
| 92305 | + }else if( pList->nExpr==pList->nAlloc ){ |
| 92306 | + ExprList *pNew; |
| 92307 | + pNew = sqlite3DbRealloc(db, pList, |
| 92308 | + sizeof(*pList)+(2*pList->nAlloc - 1)*sizeof(pList->a[0])); |
| 92309 | + if( pNew==0 ){ |
| 92227 | 92310 | goto no_mem; |
| 92228 | 92311 | } |
| 92229 | | - pList->a = a; |
| 92230 | | - } |
| 92231 | | - assert( pList->a!=0 ); |
| 92232 | | - if( 1 ){ |
| 92233 | | - struct ExprList_item *pItem = &pList->a[pList->nExpr++]; |
| 92234 | | - memset(pItem, 0, sizeof(*pItem)); |
| 92235 | | - pItem->pExpr = pExpr; |
| 92236 | | - } |
| 92312 | + pList = pNew; |
| 92313 | + pList->nAlloc *= 2; |
| 92314 | + } |
| 92315 | + pItem = &pList->a[pList->nExpr++]; |
| 92316 | + memset(pItem, 0, sizeof(*pItem)); |
| 92317 | + pItem->pExpr = pExpr; |
| 92237 | 92318 | return pList; |
| 92238 | 92319 | |
| 92239 | 92320 | no_mem: |
| 92240 | 92321 | /* Avoid leaking memory if malloc has failed. */ |
| 92241 | 92322 | sqlite3ExprDelete(db, pExpr); |
| | @@ -92288,24 +92369,23 @@ |
| 92288 | 92369 | pList->a[pList->nExpr-1].zName = pColumns->a[i].zName; |
| 92289 | 92370 | pColumns->a[i].zName = 0; |
| 92290 | 92371 | } |
| 92291 | 92372 | } |
| 92292 | 92373 | |
| 92293 | | - if( pExpr->op==TK_SELECT ){ |
| 92294 | | - if( pList && pList->a[iFirst].pExpr ){ |
| 92295 | | - Expr *pFirst = pList->a[iFirst].pExpr; |
| 92296 | | - assert( pFirst->op==TK_SELECT_COLUMN ); |
| 92297 | | - |
| 92298 | | - /* Store the SELECT statement in pRight so it will be deleted when |
| 92299 | | - ** sqlite3ExprListDelete() is called */ |
| 92300 | | - pFirst->pRight = pExpr; |
| 92301 | | - pExpr = 0; |
| 92302 | | - |
| 92303 | | - /* Remember the size of the LHS in iTable so that we can check that |
| 92304 | | - ** the RHS and LHS sizes match during code generation. */ |
| 92305 | | - pFirst->iTable = pColumns->nId; |
| 92306 | | - } |
| 92374 | + if( pExpr->op==TK_SELECT && pList ){ |
| 92375 | + Expr *pFirst = pList->a[iFirst].pExpr; |
| 92376 | + assert( pFirst!=0 ); |
| 92377 | + assert( pFirst->op==TK_SELECT_COLUMN ); |
| 92378 | + |
| 92379 | + /* Store the SELECT statement in pRight so it will be deleted when |
| 92380 | + ** sqlite3ExprListDelete() is called */ |
| 92381 | + pFirst->pRight = pExpr; |
| 92382 | + pExpr = 0; |
| 92383 | + |
| 92384 | + /* Remember the size of the LHS in iTable so that we can check that |
| 92385 | + ** the RHS and LHS sizes match during code generation. */ |
| 92386 | + pFirst->iTable = pColumns->nId; |
| 92307 | 92387 | } |
| 92308 | 92388 | |
| 92309 | 92389 | vector_append_error: |
| 92310 | 92390 | sqlite3ExprDelete(db, pExpr); |
| 92311 | 92391 | sqlite3IdListDelete(db, pColumns); |
| | @@ -92395,20 +92475,20 @@ |
| 92395 | 92475 | |
| 92396 | 92476 | /* |
| 92397 | 92477 | ** Delete an entire expression list. |
| 92398 | 92478 | */ |
| 92399 | 92479 | static SQLITE_NOINLINE void exprListDeleteNN(sqlite3 *db, ExprList *pList){ |
| 92400 | | - int i; |
| 92401 | | - struct ExprList_item *pItem; |
| 92402 | | - assert( pList->a!=0 || pList->nExpr==0 ); |
| 92403 | | - for(pItem=pList->a, i=0; i<pList->nExpr; i++, pItem++){ |
| 92480 | + int i = pList->nExpr; |
| 92481 | + struct ExprList_item *pItem = pList->a; |
| 92482 | + assert( pList->nExpr>0 ); |
| 92483 | + do{ |
| 92404 | 92484 | sqlite3ExprDelete(db, pItem->pExpr); |
| 92405 | 92485 | sqlite3DbFree(db, pItem->zName); |
| 92406 | 92486 | sqlite3DbFree(db, pItem->zSpan); |
| 92407 | | - } |
| 92408 | | - sqlite3DbFree(db, pList->a); |
| 92409 | | - sqlite3DbFree(db, pList); |
| 92487 | + pItem++; |
| 92488 | + }while( --i>0 ); |
| 92489 | + sqlite3DbFreeNN(db, pList); |
| 92410 | 92490 | } |
| 92411 | 92491 | SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){ |
| 92412 | 92492 | if( pList ) exprListDeleteNN(db, pList); |
| 92413 | 92493 | } |
| 92414 | 92494 | |
| | @@ -92554,10 +92634,69 @@ |
| 92554 | 92634 | */ |
| 92555 | 92635 | SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){ |
| 92556 | 92636 | return exprIsConst(p, 3, iCur); |
| 92557 | 92637 | } |
| 92558 | 92638 | |
| 92639 | + |
| 92640 | +/* |
| 92641 | +** sqlite3WalkExpr() callback used by sqlite3ExprIsConstantOrGroupBy(). |
| 92642 | +*/ |
| 92643 | +static int exprNodeIsConstantOrGroupBy(Walker *pWalker, Expr *pExpr){ |
| 92644 | + ExprList *pGroupBy = pWalker->u.pGroupBy; |
| 92645 | + int i; |
| 92646 | + |
| 92647 | + /* Check if pExpr is identical to any GROUP BY term. If so, consider |
| 92648 | + ** it constant. */ |
| 92649 | + for(i=0; i<pGroupBy->nExpr; i++){ |
| 92650 | + Expr *p = pGroupBy->a[i].pExpr; |
| 92651 | + if( sqlite3ExprCompare(pExpr, p, -1)<2 ){ |
| 92652 | + CollSeq *pColl = sqlite3ExprCollSeq(pWalker->pParse, p); |
| 92653 | + if( pColl==0 || sqlite3_stricmp("BINARY", pColl->zName)==0 ){ |
| 92654 | + return WRC_Prune; |
| 92655 | + } |
| 92656 | + } |
| 92657 | + } |
| 92658 | + |
| 92659 | + /* Check if pExpr is a sub-select. If so, consider it variable. */ |
| 92660 | + if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 92661 | + pWalker->eCode = 0; |
| 92662 | + return WRC_Abort; |
| 92663 | + } |
| 92664 | + |
| 92665 | + return exprNodeIsConstant(pWalker, pExpr); |
| 92666 | +} |
| 92667 | + |
| 92668 | +/* |
| 92669 | +** Walk the expression tree passed as the first argument. Return non-zero |
| 92670 | +** if the expression consists entirely of constants or copies of terms |
| 92671 | +** in pGroupBy that sort with the BINARY collation sequence. |
| 92672 | +** |
| 92673 | +** This routine is used to determine if a term of the HAVING clause can |
| 92674 | +** be promoted into the WHERE clause. In order for such a promotion to work, |
| 92675 | +** the value of the HAVING clause term must be the same for all members of |
| 92676 | +** a "group". The requirement that the GROUP BY term must be BINARY |
| 92677 | +** assumes that no other collating sequence will have a finer-grained |
| 92678 | +** grouping than binary. In other words (A=B COLLATE binary) implies |
| 92679 | +** A=B in every other collating sequence. The requirement that the |
| 92680 | +** GROUP BY be BINARY is stricter than necessary. It would also work |
| 92681 | +** to promote HAVING clauses that use the same alternative collating |
| 92682 | +** sequence as the GROUP BY term, but that is much harder to check, |
| 92683 | +** alternative collating sequences are uncommon, and this is only an |
| 92684 | +** optimization, so we take the easy way out and simply require the |
| 92685 | +** GROUP BY to use the BINARY collating sequence. |
| 92686 | +*/ |
| 92687 | +SQLITE_PRIVATE int sqlite3ExprIsConstantOrGroupBy(Parse *pParse, Expr *p, ExprList *pGroupBy){ |
| 92688 | + Walker w; |
| 92689 | + memset(&w, 0, sizeof(w)); |
| 92690 | + w.eCode = 1; |
| 92691 | + w.xExprCallback = exprNodeIsConstantOrGroupBy; |
| 92692 | + w.u.pGroupBy = pGroupBy; |
| 92693 | + w.pParse = pParse; |
| 92694 | + sqlite3WalkExpr(&w, p); |
| 92695 | + return w.eCode; |
| 92696 | +} |
| 92697 | + |
| 92559 | 92698 | /* |
| 92560 | 92699 | ** Walk an expression tree. Return non-zero if the expression is constant |
| 92561 | 92700 | ** or a function call with constant arguments. Return and 0 if there |
| 92562 | 92701 | ** are any variables. |
| 92563 | 92702 | ** |
| | @@ -93931,10 +94070,14 @@ |
| 93931 | 94070 | Table *pTab, /* The table containing the value */ |
| 93932 | 94071 | int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */ |
| 93933 | 94072 | int iCol, /* Index of the column to extract */ |
| 93934 | 94073 | int regOut /* Extract the value into this register */ |
| 93935 | 94074 | ){ |
| 94075 | + if( pTab==0 ){ |
| 94076 | + sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut); |
| 94077 | + return; |
| 94078 | + } |
| 93936 | 94079 | if( iCol<0 || iCol==pTab->iPKey ){ |
| 93937 | 94080 | sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); |
| 93938 | 94081 | }else{ |
| 93939 | 94082 | int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; |
| 93940 | 94083 | int x = iCol; |
| | @@ -94623,10 +94766,21 @@ |
| 94623 | 94766 | |
| 94624 | 94767 | case TK_VECTOR: { |
| 94625 | 94768 | sqlite3ErrorMsg(pParse, "row value misused"); |
| 94626 | 94769 | break; |
| 94627 | 94770 | } |
| 94771 | + |
| 94772 | + case TK_IF_NULL_ROW: { |
| 94773 | + int addrINR; |
| 94774 | + addrINR = sqlite3VdbeAddOp1(v, OP_IfNullRow, pExpr->iTable); |
| 94775 | + sqlite3ExprCachePush(pParse); |
| 94776 | + inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 94777 | + sqlite3ExprCachePop(pParse); |
| 94778 | + sqlite3VdbeJumpHere(v, addrINR); |
| 94779 | + sqlite3VdbeChangeP3(v, addrINR, inReg); |
| 94780 | + break; |
| 94781 | + } |
| 94628 | 94782 | |
| 94629 | 94783 | /* |
| 94630 | 94784 | ** Form A: |
| 94631 | 94785 | ** CASE x WHEN e1 THEN r1 WHEN e2 THEN r2 ... WHEN eN THEN rN ELSE y END |
| 94632 | 94786 | ** |
| | @@ -103072,11 +103226,11 @@ |
| 103072 | 103226 | if( pList==0 ) return; |
| 103073 | 103227 | for(i=0; i<pList->nId; i++){ |
| 103074 | 103228 | sqlite3DbFree(db, pList->a[i].zName); |
| 103075 | 103229 | } |
| 103076 | 103230 | sqlite3DbFree(db, pList->a); |
| 103077 | | - sqlite3DbFree(db, pList); |
| 103231 | + sqlite3DbFreeNN(db, pList); |
| 103078 | 103232 | } |
| 103079 | 103233 | |
| 103080 | 103234 | /* |
| 103081 | 103235 | ** Return the index in pList of the identifier named zId. Return -1 |
| 103082 | 103236 | ** if not found. |
| | @@ -103262,11 +103416,11 @@ |
| 103262 | 103416 | sqlite3DeleteTable(db, pItem->pTab); |
| 103263 | 103417 | sqlite3SelectDelete(db, pItem->pSelect); |
| 103264 | 103418 | sqlite3ExprDelete(db, pItem->pOn); |
| 103265 | 103419 | sqlite3IdListDelete(db, pItem->pUsing); |
| 103266 | 103420 | } |
| 103267 | | - sqlite3DbFree(db, pList); |
| 103421 | + sqlite3DbFreeNN(db, pList); |
| 103268 | 103422 | } |
| 103269 | 103423 | |
| 103270 | 103424 | /* |
| 103271 | 103425 | ** This routine is called by the parser to add a new term to the |
| 103272 | 103426 | ** end of a growing FROM clause. The "p" parameter is the part of |
| | @@ -108246,42 +108400,57 @@ |
| 108246 | 108400 | ** entry in the aChange[] array is set to -1. If the column is modified, |
| 108247 | 108401 | ** the value is 0 or greater. Parameter chngRowid is set to true if the |
| 108248 | 108402 | ** UPDATE statement modifies the rowid fields of the table. |
| 108249 | 108403 | ** |
| 108250 | 108404 | ** If any foreign key processing will be required, this function returns |
| 108251 | | -** true. If there is no foreign key related processing, this function |
| 108252 | | -** returns false. |
| 108405 | +** non-zero. If there is no foreign key related processing, this function |
| 108406 | +** returns zero. |
| 108407 | +** |
| 108408 | +** For an UPDATE, this function returns 2 if: |
| 108409 | +** |
| 108410 | +** * There are any FKs for which pTab is the child and the parent table, or |
| 108411 | +** * the UPDATE modifies one or more parent keys for which the action is |
| 108412 | +** not "NO ACTION" (i.e. is CASCADE, SET DEFAULT or SET NULL). |
| 108413 | +** |
| 108414 | +** Or, assuming some other foreign key processing is required, 1. |
| 108253 | 108415 | */ |
| 108254 | 108416 | SQLITE_PRIVATE int sqlite3FkRequired( |
| 108255 | 108417 | Parse *pParse, /* Parse context */ |
| 108256 | 108418 | Table *pTab, /* Table being modified */ |
| 108257 | 108419 | int *aChange, /* Non-NULL for UPDATE operations */ |
| 108258 | 108420 | int chngRowid /* True for UPDATE that affects rowid */ |
| 108259 | 108421 | ){ |
| 108422 | + int eRet = 0; |
| 108260 | 108423 | if( pParse->db->flags&SQLITE_ForeignKeys ){ |
| 108261 | 108424 | if( !aChange ){ |
| 108262 | 108425 | /* A DELETE operation. Foreign key processing is required if the |
| 108263 | 108426 | ** table in question is either the child or parent table for any |
| 108264 | 108427 | ** foreign key constraint. */ |
| 108265 | | - return (sqlite3FkReferences(pTab) || pTab->pFKey); |
| 108428 | + eRet = (sqlite3FkReferences(pTab) || pTab->pFKey); |
| 108266 | 108429 | }else{ |
| 108267 | 108430 | /* This is an UPDATE. Foreign key processing is only required if the |
| 108268 | 108431 | ** operation modifies one or more child or parent key columns. */ |
| 108269 | 108432 | FKey *p; |
| 108270 | 108433 | |
| 108271 | 108434 | /* Check if any child key columns are being modified. */ |
| 108272 | 108435 | for(p=pTab->pFKey; p; p=p->pNextFrom){ |
| 108273 | | - if( fkChildIsModified(pTab, p, aChange, chngRowid) ) return 1; |
| 108436 | + if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) return 2; |
| 108437 | + if( fkChildIsModified(pTab, p, aChange, chngRowid) ){ |
| 108438 | + eRet = 1; |
| 108439 | + } |
| 108274 | 108440 | } |
| 108275 | 108441 | |
| 108276 | 108442 | /* Check if any parent key columns are being modified. */ |
| 108277 | 108443 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 108278 | | - if( fkParentIsModified(pTab, p, aChange, chngRowid) ) return 1; |
| 108444 | + if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ |
| 108445 | + if( p->aAction[1]!=OE_None ) return 2; |
| 108446 | + eRet = 1; |
| 108447 | + } |
| 108279 | 108448 | } |
| 108280 | 108449 | } |
| 108281 | 108450 | } |
| 108282 | | - return 0; |
| 108451 | + return eRet; |
| 108283 | 108452 | } |
| 108284 | 108453 | |
| 108285 | 108454 | /* |
| 108286 | 108455 | ** This function is called when an UPDATE or DELETE operation is being |
| 108287 | 108456 | ** compiled on table pTab, which is the parent table of foreign-key pFKey. |
| | @@ -112787,11 +112956,11 @@ |
| 112787 | 112956 | /* ColNames: */ 0, 0, |
| 112788 | 112957 | /* iArg: */ 0 }, |
| 112789 | 112958 | #endif |
| 112790 | 112959 | {/* zName: */ "optimize", |
| 112791 | 112960 | /* ePragTyp: */ PragTyp_OPTIMIZE, |
| 112792 | | - /* ePragFlg: */ PragFlg_Result1, |
| 112961 | + /* ePragFlg: */ PragFlg_Result1|PragFlg_NeedSchema, |
| 112793 | 112962 | /* ColNames: */ 0, 0, |
| 112794 | 112963 | /* iArg: */ 0 }, |
| 112795 | 112964 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 112796 | 112965 | {/* zName: */ "page_count", |
| 112797 | 112966 | /* ePragTyp: */ PragTyp_PAGE_COUNT, |
| | @@ -114287,37 +114456,41 @@ |
| 114287 | 114456 | if( pParent ){ |
| 114288 | 114457 | x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); |
| 114289 | 114458 | assert( x==0 ); |
| 114290 | 114459 | } |
| 114291 | 114460 | addrOk = sqlite3VdbeMakeLabel(v); |
| 114292 | | - if( pParent && pIdx==0 ){ |
| 114293 | | - int iKey = pFK->aCol[0].iFrom; |
| 114294 | | - assert( iKey>=0 && iKey<pTab->nCol ); |
| 114295 | | - if( iKey!=pTab->iPKey ){ |
| 114296 | | - sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); |
| 114297 | | - sqlite3ColumnDefault(v, pTab, iKey, regRow); |
| 114298 | | - sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v); |
| 114299 | | - }else{ |
| 114300 | | - sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); |
| 114301 | | - } |
| 114302 | | - sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v); |
| 114461 | + |
| 114462 | + /* Generate code to read the child key values into registers |
| 114463 | + ** regRow..regRow+n. If any of the child key values are NULL, this |
| 114464 | + ** row cannot cause an FK violation. Jump directly to addrOk in |
| 114465 | + ** this case. */ |
| 114466 | + for(j=0; j<pFK->nCol; j++){ |
| 114467 | + int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom; |
| 114468 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j); |
| 114469 | + sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v); |
| 114470 | + } |
| 114471 | + |
| 114472 | + /* Generate code to query the parent index for a matching parent |
| 114473 | + ** key. If a match is found, jump to addrOk. */ |
| 114474 | + if( pIdx ){ |
| 114475 | + sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey, |
| 114476 | + sqlite3IndexAffinityStr(db,pIdx), pFK->nCol); |
| 114477 | + sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); |
| 114478 | + VdbeCoverage(v); |
| 114479 | + }else if( pParent ){ |
| 114480 | + int jmp = sqlite3VdbeCurrentAddr(v)+2; |
| 114481 | + sqlite3VdbeAddOp3(v, OP_SeekRowid, i, jmp, regRow); VdbeCoverage(v); |
| 114303 | 114482 | sqlite3VdbeGoto(v, addrOk); |
| 114304 | | - sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
| 114483 | + assert( pFK->nCol==1 ); |
| 114484 | + } |
| 114485 | + |
| 114486 | + /* Generate code to report an FK violation to the caller. */ |
| 114487 | + if( HasRowid(pTab) ){ |
| 114488 | + sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); |
| 114305 | 114489 | }else{ |
| 114306 | | - for(j=0; j<pFK->nCol; j++){ |
| 114307 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, |
| 114308 | | - aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j); |
| 114309 | | - sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v); |
| 114310 | | - } |
| 114311 | | - if( pParent ){ |
| 114312 | | - sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey, |
| 114313 | | - sqlite3IndexAffinityStr(db,pIdx), pFK->nCol); |
| 114314 | | - sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); |
| 114315 | | - VdbeCoverage(v); |
| 114316 | | - } |
| 114317 | | - } |
| 114318 | | - sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); |
| 114490 | + sqlite3VdbeAddOp2(v, OP_Null, 0, regResult+1); |
| 114491 | + } |
| 114319 | 114492 | sqlite3VdbeMultiLoad(v, regResult+2, "si", pFK->zTo, i-1); |
| 114320 | 114493 | sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4); |
| 114321 | 114494 | sqlite3VdbeResolveLabel(v, addrOk); |
| 114322 | 114495 | sqlite3DbFree(db, aiCols); |
| 114323 | 114496 | } |
| | @@ -114499,29 +114672,32 @@ |
| 114499 | 114672 | integrityCheckResultRow(v, 3); |
| 114500 | 114673 | sqlite3VdbeJumpHere(v, jmp2); |
| 114501 | 114674 | } |
| 114502 | 114675 | /* Verify CHECK constraints */ |
| 114503 | 114676 | if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 114504 | | - int addrCkFault = sqlite3VdbeMakeLabel(v); |
| 114505 | | - int addrCkOk = sqlite3VdbeMakeLabel(v); |
| 114506 | | - ExprList *pCheck = pTab->pCheck; |
| 114507 | | - char *zErr; |
| 114508 | | - int k; |
| 114509 | | - pParse->iSelfTab = iDataCur; |
| 114510 | | - sqlite3ExprCachePush(pParse); |
| 114511 | | - for(k=pCheck->nExpr-1; k>0; k--){ |
| 114512 | | - sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0); |
| 114513 | | - } |
| 114514 | | - sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, |
| 114515 | | - SQLITE_JUMPIFNULL); |
| 114516 | | - sqlite3VdbeResolveLabel(v, addrCkFault); |
| 114517 | | - zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s", |
| 114518 | | - pTab->zName); |
| 114519 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 114520 | | - integrityCheckResultRow(v, 3); |
| 114521 | | - sqlite3VdbeResolveLabel(v, addrCkOk); |
| 114522 | | - sqlite3ExprCachePop(pParse); |
| 114677 | + ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0); |
| 114678 | + if( db->mallocFailed==0 ){ |
| 114679 | + int addrCkFault = sqlite3VdbeMakeLabel(v); |
| 114680 | + int addrCkOk = sqlite3VdbeMakeLabel(v); |
| 114681 | + char *zErr; |
| 114682 | + int k; |
| 114683 | + pParse->iSelfTab = iDataCur; |
| 114684 | + sqlite3ExprCachePush(pParse); |
| 114685 | + for(k=pCheck->nExpr-1; k>0; k--){ |
| 114686 | + sqlite3ExprIfFalse(pParse, pCheck->a[k].pExpr, addrCkFault, 0); |
| 114687 | + } |
| 114688 | + sqlite3ExprIfTrue(pParse, pCheck->a[0].pExpr, addrCkOk, |
| 114689 | + SQLITE_JUMPIFNULL); |
| 114690 | + sqlite3VdbeResolveLabel(v, addrCkFault); |
| 114691 | + zErr = sqlite3MPrintf(db, "CHECK constraint failed in %s", |
| 114692 | + pTab->zName); |
| 114693 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 114694 | + integrityCheckResultRow(v, 3); |
| 114695 | + sqlite3VdbeResolveLabel(v, addrCkOk); |
| 114696 | + sqlite3ExprCachePop(pParse); |
| 114697 | + } |
| 114698 | + sqlite3ExprListDelete(db, pCheck); |
| 114523 | 114699 | } |
| 114524 | 114700 | /* Validate index entries for the current row */ |
| 114525 | 114701 | for(j=0, pIdx=pTab->pIndex; pIdx && !isQuick; pIdx=pIdx->pNext, j++){ |
| 114526 | 114702 | int jmp2, jmp3, jmp4, jmp5; |
| 114527 | 114703 | int ckUniq = sqlite3VdbeMakeLabel(v); |
| | @@ -116321,11 +116497,11 @@ |
| 116321 | 116497 | sqlite3ExprDelete(db, p->pHaving); |
| 116322 | 116498 | sqlite3ExprListDelete(db, p->pOrderBy); |
| 116323 | 116499 | sqlite3ExprDelete(db, p->pLimit); |
| 116324 | 116500 | sqlite3ExprDelete(db, p->pOffset); |
| 116325 | 116501 | if( p->pWith ) sqlite3WithDelete(db, p->pWith); |
| 116326 | | - if( bFree ) sqlite3DbFree(db, p); |
| 116502 | + if( bFree ) sqlite3DbFreeNN(db, p); |
| 116327 | 116503 | p = pPrior; |
| 116328 | 116504 | bFree = 1; |
| 116329 | 116505 | } |
| 116330 | 116506 | } |
| 116331 | 116507 | |
| | @@ -116357,18 +116533,17 @@ |
| 116357 | 116533 | Expr *pLimit, /* LIMIT value. NULL means not used */ |
| 116358 | 116534 | Expr *pOffset /* OFFSET value. NULL means no offset */ |
| 116359 | 116535 | ){ |
| 116360 | 116536 | Select *pNew; |
| 116361 | 116537 | Select standin; |
| 116362 | | - sqlite3 *db = pParse->db; |
| 116363 | | - pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew) ); |
| 116538 | + pNew = sqlite3DbMallocRawNN(pParse->db, sizeof(*pNew) ); |
| 116364 | 116539 | if( pNew==0 ){ |
| 116365 | | - assert( db->mallocFailed ); |
| 116540 | + assert( pParse->db->mallocFailed ); |
| 116366 | 116541 | pNew = &standin; |
| 116367 | 116542 | } |
| 116368 | 116543 | if( pEList==0 ){ |
| 116369 | | - pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db,TK_ASTERISK,0)); |
| 116544 | + pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(pParse->db,TK_ASTERISK,0)); |
| 116370 | 116545 | } |
| 116371 | 116546 | pNew->pEList = pEList; |
| 116372 | 116547 | pNew->op = TK_SELECT; |
| 116373 | 116548 | pNew->selFlags = selFlags; |
| 116374 | 116549 | pNew->iLimit = 0; |
| | @@ -116377,11 +116552,11 @@ |
| 116377 | 116552 | pNew->zSelName[0] = 0; |
| 116378 | 116553 | #endif |
| 116379 | 116554 | pNew->addrOpenEphm[0] = -1; |
| 116380 | 116555 | pNew->addrOpenEphm[1] = -1; |
| 116381 | 116556 | pNew->nSelectRow = 0; |
| 116382 | | - if( pSrc==0 ) pSrc = sqlite3DbMallocZero(db, sizeof(*pSrc)); |
| 116557 | + if( pSrc==0 ) pSrc = sqlite3DbMallocZero(pParse->db, sizeof(*pSrc)); |
| 116383 | 116558 | pNew->pSrc = pSrc; |
| 116384 | 116559 | pNew->pWhere = pWhere; |
| 116385 | 116560 | pNew->pGroupBy = pGroupBy; |
| 116386 | 116561 | pNew->pHaving = pHaving; |
| 116387 | 116562 | pNew->pOrderBy = pOrderBy; |
| | @@ -116388,13 +116563,13 @@ |
| 116388 | 116563 | pNew->pPrior = 0; |
| 116389 | 116564 | pNew->pNext = 0; |
| 116390 | 116565 | pNew->pLimit = pLimit; |
| 116391 | 116566 | pNew->pOffset = pOffset; |
| 116392 | 116567 | pNew->pWith = 0; |
| 116393 | | - assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || db->mallocFailed!=0 ); |
| 116394 | | - if( db->mallocFailed ) { |
| 116395 | | - clearSelect(db, pNew, pNew!=&standin); |
| 116568 | + assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || pParse->db->mallocFailed!=0 ); |
| 116569 | + if( pParse->db->mallocFailed ) { |
| 116570 | + clearSelect(pParse->db, pNew, pNew!=&standin); |
| 116396 | 116571 | pNew = 0; |
| 116397 | 116572 | }else{ |
| 116398 | 116573 | assert( pNew->pSrc!=0 || pParse->nErr>0 ); |
| 116399 | 116574 | } |
| 116400 | 116575 | assert( pNew!=&standin ); |
| | @@ -117300,11 +117475,11 @@ |
| 117300 | 117475 | */ |
| 117301 | 117476 | SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){ |
| 117302 | 117477 | if( p ){ |
| 117303 | 117478 | assert( p->nRef>0 ); |
| 117304 | 117479 | p->nRef--; |
| 117305 | | - if( p->nRef==0 ) sqlite3DbFree(p->db, p); |
| 117480 | + if( p->nRef==0 ) sqlite3DbFreeNN(p->db, p); |
| 117306 | 117481 | } |
| 117307 | 117482 | } |
| 117308 | 117483 | |
| 117309 | 117484 | /* |
| 117310 | 117485 | ** Make a new pointer to a KeyInfo object |
| | @@ -117775,10 +117950,11 @@ |
| 117775 | 117950 | Vdbe *v = pParse->pVdbe; |
| 117776 | 117951 | int i; |
| 117777 | 117952 | NameContext sNC; |
| 117778 | 117953 | sNC.pSrcList = pTabList; |
| 117779 | 117954 | sNC.pParse = pParse; |
| 117955 | + sNC.pNext = 0; |
| 117780 | 117956 | for(i=0; i<pEList->nExpr; i++){ |
| 117781 | 117957 | Expr *p = pEList->a[i].pExpr; |
| 117782 | 117958 | const char *zType; |
| 117783 | 117959 | #ifdef SQLITE_ENABLE_COLUMN_METADATA |
| 117784 | 117960 | const char *zOrigDb = 0; |
| | @@ -117798,10 +117974,23 @@ |
| 117798 | 117974 | #endif |
| 117799 | 117975 | sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType, SQLITE_TRANSIENT); |
| 117800 | 117976 | } |
| 117801 | 117977 | #endif /* !defined(SQLITE_OMIT_DECLTYPE) */ |
| 117802 | 117978 | } |
| 117979 | + |
| 117980 | +/* |
| 117981 | +** Return the Table objecct in the SrcList that has cursor iCursor. |
| 117982 | +** Or return NULL if no such Table object exists in the SrcList. |
| 117983 | +*/ |
| 117984 | +static Table *tableWithCursor(SrcList *pList, int iCursor){ |
| 117985 | + int j; |
| 117986 | + for(j=0; j<pList->nSrc; j++){ |
| 117987 | + if( pList->a[j].iCursor==iCursor ) return pList->a[j].pTab; |
| 117988 | + } |
| 117989 | + return 0; |
| 117990 | +} |
| 117991 | + |
| 117803 | 117992 | |
| 117804 | 117993 | /* |
| 117805 | 117994 | ** Generate code that will tell the VDBE the names of columns |
| 117806 | 117995 | ** in the result set. This information is used to provide the |
| 117807 | 117996 | ** azCol[] values in the callback. |
| | @@ -117810,11 +117999,12 @@ |
| 117810 | 117999 | Parse *pParse, /* Parser context */ |
| 117811 | 118000 | SrcList *pTabList, /* List of tables */ |
| 117812 | 118001 | ExprList *pEList /* Expressions defining the result set */ |
| 117813 | 118002 | ){ |
| 117814 | 118003 | Vdbe *v = pParse->pVdbe; |
| 117815 | | - int i, j; |
| 118004 | + int i; |
| 118005 | + Table *pTab; |
| 117816 | 118006 | sqlite3 *db = pParse->db; |
| 117817 | 118007 | int fullNames, shortNames; |
| 117818 | 118008 | |
| 117819 | 118009 | #ifndef SQLITE_OMIT_EXPLAIN |
| 117820 | 118010 | /* If this is an EXPLAIN, skip this step */ |
| | @@ -117835,19 +118025,15 @@ |
| 117835 | 118025 | p = pEList->a[i].pExpr; |
| 117836 | 118026 | if( NEVER(p==0) ) continue; |
| 117837 | 118027 | if( pEList->a[i].zName ){ |
| 117838 | 118028 | char *zName = pEList->a[i].zName; |
| 117839 | 118029 | sqlite3VdbeSetColName(v, i, COLNAME_NAME, zName, SQLITE_TRANSIENT); |
| 117840 | | - }else if( p->op==TK_COLUMN || p->op==TK_AGG_COLUMN ){ |
| 117841 | | - Table *pTab; |
| 118030 | + }else if( (p->op==TK_COLUMN || p->op==TK_AGG_COLUMN) |
| 118031 | + && (pTab = tableWithCursor(pTabList, p->iTable))!=0 |
| 118032 | + ){ |
| 117842 | 118033 | char *zCol; |
| 117843 | 118034 | int iCol = p->iColumn; |
| 117844 | | - for(j=0; ALWAYS(j<pTabList->nSrc); j++){ |
| 117845 | | - if( pTabList->a[j].iCursor==p->iTable ) break; |
| 117846 | | - } |
| 117847 | | - assert( j<pTabList->nSrc ); |
| 117848 | | - pTab = pTabList->a[j].pTab; |
| 117849 | 118035 | if( iCol<0 ) iCol = pTab->iPKey; |
| 117850 | 118036 | assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) ); |
| 117851 | 118037 | if( iCol<0 ){ |
| 117852 | 118038 | zCol = "rowid"; |
| 117853 | 118039 | }else{ |
| | @@ -117925,11 +118111,11 @@ |
| 117925 | 118111 | Table *pTab; /* Table associated with this expression */ |
| 117926 | 118112 | while( pColExpr->op==TK_DOT ){ |
| 117927 | 118113 | pColExpr = pColExpr->pRight; |
| 117928 | 118114 | assert( pColExpr!=0 ); |
| 117929 | 118115 | } |
| 117930 | | - if( pColExpr->op==TK_COLUMN && ALWAYS(pColExpr->pTab!=0) ){ |
| 118116 | + if( pColExpr->op==TK_COLUMN && pColExpr->pTab!=0 ){ |
| 117931 | 118117 | /* For columns use the column name name */ |
| 117932 | 118118 | int iCol = pColExpr->iColumn; |
| 117933 | 118119 | pTab = pColExpr->pTab; |
| 117934 | 118120 | if( iCol<0 ) iCol = pTab->iPKey; |
| 117935 | 118121 | zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid"; |
| | @@ -119145,11 +119331,11 @@ |
| 119145 | 119331 | if( j==nOrderBy ){ |
| 119146 | 119332 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0); |
| 119147 | 119333 | if( pNew==0 ) return SQLITE_NOMEM_BKPT; |
| 119148 | 119334 | pNew->flags |= EP_IntValue; |
| 119149 | 119335 | pNew->u.iValue = i; |
| 119150 | | - pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew); |
| 119336 | + p->pOrderBy = pOrderBy = sqlite3ExprListAppend(pParse, pOrderBy, pNew); |
| 119151 | 119337 | if( pOrderBy ) pOrderBy->a[nOrderBy++].u.x.iOrderByCol = (u16)i; |
| 119152 | 119338 | } |
| 119153 | 119339 | } |
| 119154 | 119340 | } |
| 119155 | 119341 | |
| | @@ -119379,13 +119565,28 @@ |
| 119379 | 119565 | return pParse->nErr!=0; |
| 119380 | 119566 | } |
| 119381 | 119567 | #endif |
| 119382 | 119568 | |
| 119383 | 119569 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 119570 | + |
| 119571 | +/* An instance of the SubstContext object describes an substitution edit |
| 119572 | +** to be performed on a parse tree. |
| 119573 | +** |
| 119574 | +** All references to columns in table iTable are to be replaced by corresponding |
| 119575 | +** expressions in pEList. |
| 119576 | +*/ |
| 119577 | +typedef struct SubstContext { |
| 119578 | + Parse *pParse; /* The parsing context */ |
| 119579 | + int iTable; /* Replace references to this table */ |
| 119580 | + int iNewTable; /* New table number */ |
| 119581 | + int isLeftJoin; /* Add TK_IF_NULL_ROW opcodes on each replacement */ |
| 119582 | + ExprList *pEList; /* Replacement expressions */ |
| 119583 | +} SubstContext; |
| 119584 | + |
| 119384 | 119585 | /* Forward Declarations */ |
| 119385 | | -static void substExprList(Parse*, ExprList*, int, ExprList*); |
| 119386 | | -static void substSelect(Parse*, Select *, int, ExprList*, int); |
| 119586 | +static void substExprList(SubstContext*, ExprList*); |
| 119587 | +static void substSelect(SubstContext*, Select*, int); |
| 119387 | 119588 | |
| 119388 | 119589 | /* |
| 119389 | 119590 | ** Scan through the expression pExpr. Replace every reference to |
| 119390 | 119591 | ** a column in table number iTable with a copy of the iColumn-th |
| 119391 | 119592 | ** entry in pEList. (But leave references to the ROWID column |
| | @@ -119392,33 +119593,42 @@ |
| 119392 | 119593 | ** unchanged.) |
| 119393 | 119594 | ** |
| 119394 | 119595 | ** This routine is part of the flattening procedure. A subquery |
| 119395 | 119596 | ** whose result set is defined by pEList appears as entry in the |
| 119396 | 119597 | ** FROM clause of a SELECT such that the VDBE cursor assigned to that |
| 119397 | | -** FORM clause entry is iTable. This routine make the necessary |
| 119598 | +** FORM clause entry is iTable. This routine makes the necessary |
| 119398 | 119599 | ** changes to pExpr so that it refers directly to the source table |
| 119399 | 119600 | ** of the subquery rather the result set of the subquery. |
| 119400 | 119601 | */ |
| 119401 | 119602 | static Expr *substExpr( |
| 119402 | | - Parse *pParse, /* Report errors here */ |
| 119403 | | - Expr *pExpr, /* Expr in which substitution occurs */ |
| 119404 | | - int iTable, /* Table to be substituted */ |
| 119405 | | - ExprList *pEList /* Substitute expressions */ |
| 119603 | + SubstContext *pSubst, /* Description of the substitution */ |
| 119604 | + Expr *pExpr /* Expr in which substitution occurs */ |
| 119406 | 119605 | ){ |
| 119407 | | - sqlite3 *db = pParse->db; |
| 119408 | 119606 | if( pExpr==0 ) return 0; |
| 119409 | | - if( pExpr->op==TK_COLUMN && pExpr->iTable==iTable ){ |
| 119607 | + if( ExprHasProperty(pExpr, EP_FromJoin) && pExpr->iRightJoinTable==pSubst->iTable ){ |
| 119608 | + pExpr->iRightJoinTable = pSubst->iNewTable; |
| 119609 | + } |
| 119610 | + if( pExpr->op==TK_COLUMN && pExpr->iTable==pSubst->iTable ){ |
| 119410 | 119611 | if( pExpr->iColumn<0 ){ |
| 119411 | 119612 | pExpr->op = TK_NULL; |
| 119412 | 119613 | }else{ |
| 119413 | 119614 | Expr *pNew; |
| 119414 | | - Expr *pCopy = pEList->a[pExpr->iColumn].pExpr; |
| 119415 | | - assert( pEList!=0 && pExpr->iColumn<pEList->nExpr ); |
| 119615 | + Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr; |
| 119616 | + Expr ifNullRow; |
| 119617 | + assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr ); |
| 119416 | 119618 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); |
| 119417 | 119619 | if( sqlite3ExprIsVector(pCopy) ){ |
| 119418 | | - sqlite3VectorErrorMsg(pParse, pCopy); |
| 119620 | + sqlite3VectorErrorMsg(pSubst->pParse, pCopy); |
| 119419 | 119621 | }else{ |
| 119622 | + sqlite3 *db = pSubst->pParse->db; |
| 119623 | + if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){ |
| 119624 | + memset(&ifNullRow, 0, sizeof(ifNullRow)); |
| 119625 | + ifNullRow.op = TK_IF_NULL_ROW; |
| 119626 | + ifNullRow.pLeft = pCopy; |
| 119627 | + ifNullRow.iTable = pSubst->iNewTable; |
| 119628 | + pCopy = &ifNullRow; |
| 119629 | + } |
| 119420 | 119630 | pNew = sqlite3ExprDup(db, pCopy, 0); |
| 119421 | 119631 | if( pNew && (pExpr->flags & EP_FromJoin) ){ |
| 119422 | 119632 | pNew->iRightJoinTable = pExpr->iRightJoinTable; |
| 119423 | 119633 | pNew->flags |= EP_FromJoin; |
| 119424 | 119634 | } |
| | @@ -119425,55 +119635,51 @@ |
| 119425 | 119635 | sqlite3ExprDelete(db, pExpr); |
| 119426 | 119636 | pExpr = pNew; |
| 119427 | 119637 | } |
| 119428 | 119638 | } |
| 119429 | 119639 | }else{ |
| 119430 | | - pExpr->pLeft = substExpr(pParse, pExpr->pLeft, iTable, pEList); |
| 119431 | | - pExpr->pRight = substExpr(pParse, pExpr->pRight, iTable, pEList); |
| 119640 | + pExpr->pLeft = substExpr(pSubst, pExpr->pLeft); |
| 119641 | + pExpr->pRight = substExpr(pSubst, pExpr->pRight); |
| 119432 | 119642 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 119433 | | - substSelect(pParse, pExpr->x.pSelect, iTable, pEList, 1); |
| 119643 | + substSelect(pSubst, pExpr->x.pSelect, 1); |
| 119434 | 119644 | }else{ |
| 119435 | | - substExprList(pParse, pExpr->x.pList, iTable, pEList); |
| 119645 | + substExprList(pSubst, pExpr->x.pList); |
| 119436 | 119646 | } |
| 119437 | 119647 | } |
| 119438 | 119648 | return pExpr; |
| 119439 | 119649 | } |
| 119440 | 119650 | static void substExprList( |
| 119441 | | - Parse *pParse, /* Report errors here */ |
| 119442 | | - ExprList *pList, /* List to scan and in which to make substitutes */ |
| 119443 | | - int iTable, /* Table to be substituted */ |
| 119444 | | - ExprList *pEList /* Substitute values */ |
| 119651 | + SubstContext *pSubst, /* Description of the substitution */ |
| 119652 | + ExprList *pList /* List to scan and in which to make substitutes */ |
| 119445 | 119653 | ){ |
| 119446 | 119654 | int i; |
| 119447 | 119655 | if( pList==0 ) return; |
| 119448 | 119656 | for(i=0; i<pList->nExpr; i++){ |
| 119449 | | - pList->a[i].pExpr = substExpr(pParse, pList->a[i].pExpr, iTable, pEList); |
| 119657 | + pList->a[i].pExpr = substExpr(pSubst, pList->a[i].pExpr); |
| 119450 | 119658 | } |
| 119451 | 119659 | } |
| 119452 | 119660 | static void substSelect( |
| 119453 | | - Parse *pParse, /* Report errors here */ |
| 119454 | | - Select *p, /* SELECT statement in which to make substitutions */ |
| 119455 | | - int iTable, /* Table to be replaced */ |
| 119456 | | - ExprList *pEList, /* Substitute values */ |
| 119457 | | - int doPrior /* Do substitutes on p->pPrior too */ |
| 119661 | + SubstContext *pSubst, /* Description of the substitution */ |
| 119662 | + Select *p, /* SELECT statement in which to make substitutions */ |
| 119663 | + int doPrior /* Do substitutes on p->pPrior too */ |
| 119458 | 119664 | ){ |
| 119459 | 119665 | SrcList *pSrc; |
| 119460 | 119666 | struct SrcList_item *pItem; |
| 119461 | 119667 | int i; |
| 119462 | 119668 | if( !p ) return; |
| 119463 | 119669 | do{ |
| 119464 | | - substExprList(pParse, p->pEList, iTable, pEList); |
| 119465 | | - substExprList(pParse, p->pGroupBy, iTable, pEList); |
| 119466 | | - substExprList(pParse, p->pOrderBy, iTable, pEList); |
| 119467 | | - p->pHaving = substExpr(pParse, p->pHaving, iTable, pEList); |
| 119468 | | - p->pWhere = substExpr(pParse, p->pWhere, iTable, pEList); |
| 119670 | + substExprList(pSubst, p->pEList); |
| 119671 | + substExprList(pSubst, p->pGroupBy); |
| 119672 | + substExprList(pSubst, p->pOrderBy); |
| 119673 | + p->pHaving = substExpr(pSubst, p->pHaving); |
| 119674 | + p->pWhere = substExpr(pSubst, p->pWhere); |
| 119469 | 119675 | pSrc = p->pSrc; |
| 119470 | 119676 | assert( pSrc!=0 ); |
| 119471 | 119677 | for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ |
| 119472 | | - substSelect(pParse, pItem->pSelect, iTable, pEList, 1); |
| 119678 | + substSelect(pSubst, pItem->pSelect, 1); |
| 119473 | 119679 | if( pItem->fg.isTabFunc ){ |
| 119474 | | - substExprList(pParse, pItem->u1.pFuncArg, iTable, pEList); |
| 119680 | + substExprList(pSubst, pItem->u1.pFuncArg); |
| 119475 | 119681 | } |
| 119476 | 119682 | } |
| 119477 | 119683 | }while( doPrior && (p = p->pPrior)!=0 ); |
| 119478 | 119684 | } |
| 119479 | 119685 | #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */ |
| | @@ -119512,12 +119718,12 @@ |
| 119512 | 119718 | ** (2) The subquery is not an aggregate or (2a) the outer query is not a join |
| 119513 | 119719 | ** and (2b) the outer query does not use subqueries other than the one |
| 119514 | 119720 | ** FROM-clause subquery that is a candidate for flattening. (2b is |
| 119515 | 119721 | ** due to ticket [2f7170d73bf9abf80] from 2015-02-09.) |
| 119516 | 119722 | ** |
| 119517 | | -** (3) The subquery is not the right operand of a left outer join |
| 119518 | | -** (Originally ticket #306. Strengthened by ticket #3300) |
| 119723 | +** (3) The subquery is not the right operand of a LEFT JOIN |
| 119724 | +** or the subquery is not itself a join. |
| 119519 | 119725 | ** |
| 119520 | 119726 | ** (4) The subquery is not DISTINCT. |
| 119521 | 119727 | ** |
| 119522 | 119728 | ** (**) At one point restrictions (4) and (5) defined a subset of DISTINCT |
| 119523 | 119729 | ** sub-queries that were excluded from this optimization. Restriction |
| | @@ -119525,11 +119731,11 @@ |
| 119525 | 119731 | ** |
| 119526 | 119732 | ** (6) The subquery does not use aggregates or the outer query is not |
| 119527 | 119733 | ** DISTINCT. |
| 119528 | 119734 | ** |
| 119529 | 119735 | ** (7) The subquery has a FROM clause. TODO: For subqueries without |
| 119530 | | -** A FROM clause, consider adding a FROM close with the special |
| 119736 | +** A FROM clause, consider adding a FROM clause with the special |
| 119531 | 119737 | ** table sqlite_once that consists of a single row containing a |
| 119532 | 119738 | ** single NULL. |
| 119533 | 119739 | ** |
| 119534 | 119740 | ** (8) The subquery does not use LIMIT or the outer query is not a join. |
| 119535 | 119741 | ** |
| | @@ -119631,10 +119837,12 @@ |
| 119631 | 119837 | Select *pSub1; /* Pointer to the rightmost select in sub-query */ |
| 119632 | 119838 | SrcList *pSrc; /* The FROM clause of the outer query */ |
| 119633 | 119839 | SrcList *pSubSrc; /* The FROM clause of the subquery */ |
| 119634 | 119840 | ExprList *pList; /* The result set of the outer query */ |
| 119635 | 119841 | int iParent; /* VDBE cursor number of the pSub result set temp table */ |
| 119842 | + int iNewParent = -1;/* Replacement table for iParent */ |
| 119843 | + int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */ |
| 119636 | 119844 | int i; /* Loop counter */ |
| 119637 | 119845 | Expr *pWhere; /* The WHERE clause */ |
| 119638 | 119846 | struct SrcList_item *pSubitem; /* The subquery */ |
| 119639 | 119847 | sqlite3 *db = pParse->db; |
| 119640 | 119848 | |
| | @@ -119657,11 +119865,11 @@ |
| 119657 | 119865 | || (sqlite3ExprListFlags(p->pOrderBy) & EP_Subquery)!=0 |
| 119658 | 119866 | ){ |
| 119659 | 119867 | return 0; /* Restriction (2b) */ |
| 119660 | 119868 | } |
| 119661 | 119869 | } |
| 119662 | | - |
| 119870 | + |
| 119663 | 119871 | pSubSrc = pSub->pSrc; |
| 119664 | 119872 | assert( pSubSrc ); |
| 119665 | 119873 | /* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants, |
| 119666 | 119874 | ** not arbitrary expressions, we allowed some combining of LIMIT and OFFSET |
| 119667 | 119875 | ** because they could be computed at compile-time. But when LIMIT and OFFSET |
| | @@ -119695,44 +119903,29 @@ |
| 119695 | 119903 | } |
| 119696 | 119904 | if( (p->selFlags & SF_Recursive) && pSub->pPrior ){ |
| 119697 | 119905 | return 0; /* Restriction (23) */ |
| 119698 | 119906 | } |
| 119699 | 119907 | |
| 119700 | | - /* OBSOLETE COMMENT 1: |
| 119701 | | - ** Restriction 3: If the subquery is a join, make sure the subquery is |
| 119702 | | - ** not used as the right operand of an outer join. Examples of why this |
| 119703 | | - ** is not allowed: |
| 119908 | + /* |
| 119909 | + ** If the subquery is the right operand of a LEFT JOIN, then the |
| 119910 | + ** subquery may not be a join itself. Example of why this is not allowed: |
| 119704 | 119911 | ** |
| 119705 | 119912 | ** t1 LEFT OUTER JOIN (t2 JOIN t3) |
| 119706 | 119913 | ** |
| 119707 | 119914 | ** If we flatten the above, we would get |
| 119708 | 119915 | ** |
| 119709 | 119916 | ** (t1 LEFT OUTER JOIN t2) JOIN t3 |
| 119710 | 119917 | ** |
| 119711 | 119918 | ** which is not at all the same thing. |
| 119712 | 119919 | ** |
| 119713 | | - ** OBSOLETE COMMENT 2: |
| 119714 | | - ** Restriction 12: If the subquery is the right operand of a left outer |
| 119715 | | - ** join, make sure the subquery has no WHERE clause. |
| 119716 | | - ** An examples of why this is not allowed: |
| 119717 | | - ** |
| 119718 | | - ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0) |
| 119719 | | - ** |
| 119720 | | - ** If we flatten the above, we would get |
| 119721 | | - ** |
| 119722 | | - ** (t1 LEFT OUTER JOIN t2) WHERE t2.x>0 |
| 119723 | | - ** |
| 119724 | | - ** But the t2.x>0 test will always fail on a NULL row of t2, which |
| 119725 | | - ** effectively converts the OUTER JOIN into an INNER JOIN. |
| 119726 | | - ** |
| 119727 | | - ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE: |
| 119728 | | - ** Ticket #3300 shows that flattening the right term of a LEFT JOIN |
| 119729 | | - ** is fraught with danger. Best to avoid the whole thing. If the |
| 119730 | | - ** subquery is the right term of a LEFT JOIN, then do not flatten. |
| 119920 | + ** See also tickets #306, #350, and #3300. |
| 119731 | 119921 | */ |
| 119732 | 119922 | if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ |
| 119733 | | - return 0; |
| 119923 | + isLeftJoin = 1; |
| 119924 | + if( pSubSrc->nSrc>1 ){ |
| 119925 | + return 0; /* Restriction (3) */ |
| 119926 | + } |
| 119734 | 119927 | } |
| 119735 | 119928 | |
| 119736 | 119929 | /* Restriction 17: If the sub-query is a compound SELECT, then it must |
| 119737 | 119930 | ** use only the UNION ALL operator. And none of the simple select queries |
| 119738 | 119931 | ** that make up the compound SELECT are allowed to be aggregate or distinct |
| | @@ -119937,10 +120130,11 @@ |
| 119937 | 120130 | */ |
| 119938 | 120131 | for(i=0; i<nSubSrc; i++){ |
| 119939 | 120132 | sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing); |
| 119940 | 120133 | assert( pSrc->a[i+iFrom].fg.isTabFunc==0 ); |
| 119941 | 120134 | pSrc->a[i+iFrom] = pSubSrc->a[i]; |
| 120135 | + iNewParent = pSubSrc->a[i].iCursor; |
| 119942 | 120136 | memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); |
| 119943 | 120137 | } |
| 119944 | 120138 | pSrc->a[iFrom].fg.jointype = jointype; |
| 119945 | 120139 | |
| 119946 | 120140 | /* Now begin substituting subquery result set expressions for |
| | @@ -119982,10 +120176,13 @@ |
| 119982 | 120176 | assert( pSub->pPrior==0 ); |
| 119983 | 120177 | pParent->pOrderBy = pOrderBy; |
| 119984 | 120178 | pSub->pOrderBy = 0; |
| 119985 | 120179 | } |
| 119986 | 120180 | pWhere = sqlite3ExprDup(db, pSub->pWhere, 0); |
| 120181 | + if( isLeftJoin ){ |
| 120182 | + setJoinExpr(pWhere, iNewParent); |
| 120183 | + } |
| 119987 | 120184 | if( subqueryIsAgg ){ |
| 119988 | 120185 | assert( pParent->pHaving==0 ); |
| 119989 | 120186 | pParent->pHaving = pParent->pWhere; |
| 119990 | 120187 | pParent->pWhere = pWhere; |
| 119991 | 120188 | pParent->pHaving = sqlite3ExprAnd(db, |
| | @@ -119995,11 +120192,17 @@ |
| 119995 | 120192 | pParent->pGroupBy = sqlite3ExprListDup(db, pSub->pGroupBy, 0); |
| 119996 | 120193 | }else{ |
| 119997 | 120194 | pParent->pWhere = sqlite3ExprAnd(db, pWhere, pParent->pWhere); |
| 119998 | 120195 | } |
| 119999 | 120196 | if( db->mallocFailed==0 ){ |
| 120000 | | - substSelect(pParse, pParent, iParent, pSub->pEList, 0); |
| 120197 | + SubstContext x; |
| 120198 | + x.pParse = pParse; |
| 120199 | + x.iTable = iParent; |
| 120200 | + x.iNewTable = iNewParent; |
| 120201 | + x.isLeftJoin = isLeftJoin; |
| 120202 | + x.pEList = pSub->pEList; |
| 120203 | + substSelect(&x, pParent, 0); |
| 120001 | 120204 | } |
| 120002 | 120205 | |
| 120003 | 120206 | /* The flattened query is distinct if either the inner or the |
| 120004 | 120207 | ** outer query is distinct. |
| 120005 | 120208 | */ |
| | @@ -120098,12 +120301,18 @@ |
| 120098 | 120301 | } |
| 120099 | 120302 | if( ExprHasProperty(pWhere,EP_FromJoin) ) return 0; /* restriction 5 */ |
| 120100 | 120303 | if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ |
| 120101 | 120304 | nChng++; |
| 120102 | 120305 | while( pSubq ){ |
| 120306 | + SubstContext x; |
| 120103 | 120307 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| 120104 | | - pNew = substExpr(pParse, pNew, iCursor, pSubq->pEList); |
| 120308 | + x.pParse = pParse; |
| 120309 | + x.iTable = iCursor; |
| 120310 | + x.iNewTable = iCursor; |
| 120311 | + x.isLeftJoin = 0; |
| 120312 | + x.pEList = pSubq->pEList; |
| 120313 | + pNew = substExpr(&x, pNew); |
| 120105 | 120314 | pSubq->pWhere = sqlite3ExprAnd(pParse->db, pSubq->pWhere, pNew); |
| 120106 | 120315 | pSubq = pSubq->pPrior; |
| 120107 | 120316 | } |
| 120108 | 120317 | } |
| 120109 | 120318 | return nChng; |
| | @@ -121090,10 +121299,107 @@ |
| 121090 | 121299 | } |
| 121091 | 121300 | } |
| 121092 | 121301 | #else |
| 121093 | 121302 | # define explainSimpleCount(a,b,c) |
| 121094 | 121303 | #endif |
| 121304 | + |
| 121305 | +/* |
| 121306 | +** Context object for havingToWhereExprCb(). |
| 121307 | +*/ |
| 121308 | +struct HavingToWhereCtx { |
| 121309 | + Expr **ppWhere; |
| 121310 | + ExprList *pGroupBy; |
| 121311 | +}; |
| 121312 | + |
| 121313 | +/* |
| 121314 | +** sqlite3WalkExpr() callback used by havingToWhere(). |
| 121315 | +** |
| 121316 | +** If the node passed to the callback is a TK_AND node, return |
| 121317 | +** WRC_Continue to tell sqlite3WalkExpr() to iterate through child nodes. |
| 121318 | +** |
| 121319 | +** Otherwise, return WRC_Prune. In this case, also check if the |
| 121320 | +** sub-expression matches the criteria for being moved to the WHERE |
| 121321 | +** clause. If so, add it to the WHERE clause and replace the sub-expression |
| 121322 | +** within the HAVING expression with a constant "1". |
| 121323 | +*/ |
| 121324 | +static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ |
| 121325 | + if( pExpr->op!=TK_AND ){ |
| 121326 | + struct HavingToWhereCtx *p = pWalker->u.pHavingCtx; |
| 121327 | + if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, p->pGroupBy) ){ |
| 121328 | + sqlite3 *db = pWalker->pParse->db; |
| 121329 | + Expr *pNew = sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[1], 0); |
| 121330 | + if( pNew ){ |
| 121331 | + Expr *pWhere = *(p->ppWhere); |
| 121332 | + SWAP(Expr, *pNew, *pExpr); |
| 121333 | + pNew = sqlite3ExprAnd(db, pWhere, pNew); |
| 121334 | + *(p->ppWhere) = pNew; |
| 121335 | + } |
| 121336 | + } |
| 121337 | + return WRC_Prune; |
| 121338 | + } |
| 121339 | + return WRC_Continue; |
| 121340 | +} |
| 121341 | + |
| 121342 | +/* |
| 121343 | +** Transfer eligible terms from the HAVING clause of a query, which is |
| 121344 | +** processed after grouping, to the WHERE clause, which is processed before |
| 121345 | +** grouping. For example, the query: |
| 121346 | +** |
| 121347 | +** SELECT * FROM <tables> WHERE a=? GROUP BY b HAVING b=? AND c=? |
| 121348 | +** |
| 121349 | +** can be rewritten as: |
| 121350 | +** |
| 121351 | +** SELECT * FROM <tables> WHERE a=? AND b=? GROUP BY b HAVING c=? |
| 121352 | +** |
| 121353 | +** A term of the HAVING expression is eligible for transfer if it consists |
| 121354 | +** entirely of constants and expressions that are also GROUP BY terms that |
| 121355 | +** use the "BINARY" collation sequence. |
| 121356 | +*/ |
| 121357 | +static void havingToWhere( |
| 121358 | + Parse *pParse, |
| 121359 | + ExprList *pGroupBy, |
| 121360 | + Expr *pHaving, |
| 121361 | + Expr **ppWhere |
| 121362 | +){ |
| 121363 | + struct HavingToWhereCtx sCtx; |
| 121364 | + Walker sWalker; |
| 121365 | + |
| 121366 | + sCtx.ppWhere = ppWhere; |
| 121367 | + sCtx.pGroupBy = pGroupBy; |
| 121368 | + |
| 121369 | + memset(&sWalker, 0, sizeof(sWalker)); |
| 121370 | + sWalker.pParse = pParse; |
| 121371 | + sWalker.xExprCallback = havingToWhereExprCb; |
| 121372 | + sWalker.u.pHavingCtx = &sCtx; |
| 121373 | + sqlite3WalkExpr(&sWalker, pHaving); |
| 121374 | +} |
| 121375 | + |
| 121376 | +/* |
| 121377 | +** Check to see if the pThis entry of pTabList is a self-join of a prior view. |
| 121378 | +** If it is, then return the SrcList_item for the prior view. If it is not, |
| 121379 | +** then return 0. |
| 121380 | +*/ |
| 121381 | +static struct SrcList_item *isSelfJoinView( |
| 121382 | + SrcList *pTabList, /* Search for self-joins in this FROM clause */ |
| 121383 | + struct SrcList_item *pThis /* Search for prior reference to this subquery */ |
| 121384 | +){ |
| 121385 | + struct SrcList_item *pItem; |
| 121386 | + for(pItem = pTabList->a; pItem<pThis; pItem++){ |
| 121387 | + if( pItem->pSelect==0 ) continue; |
| 121388 | + if( pItem->fg.viaCoroutine ) continue; |
| 121389 | + if( pItem->zName==0 ) continue; |
| 121390 | + if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue; |
| 121391 | + if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue; |
| 121392 | + if( sqlite3ExprCompare(pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1) ){ |
| 121393 | + /* The view was modified by some other optimization such as |
| 121394 | + ** pushDownWhereTerms() */ |
| 121395 | + continue; |
| 121396 | + } |
| 121397 | + return pItem; |
| 121398 | + } |
| 121399 | + return 0; |
| 121400 | +} |
| 121095 | 121401 | |
| 121096 | 121402 | /* |
| 121097 | 121403 | ** Generate code for the SELECT statement given in the p argument. |
| 121098 | 121404 | ** |
| 121099 | 121405 | ** The results are returned according to the SelectDest structure. |
| | @@ -121247,10 +121553,14 @@ |
| 121247 | 121553 | ** a view or the co-routine to implement a view. The first instance |
| 121248 | 121554 | ** is sufficient, though the subroutine to manifest the view does need |
| 121249 | 121555 | ** to be invoked again. */ |
| 121250 | 121556 | if( pItem->addrFillSub ){ |
| 121251 | 121557 | if( pItem->fg.viaCoroutine==0 ){ |
| 121558 | + /* The subroutine that manifests the view might be a one-time routine, |
| 121559 | + ** or it might need to be rerun on each iteration because it |
| 121560 | + ** encodes a correlated subquery. */ |
| 121561 | + testcase( sqlite3VdbeGetOp(v, pItem->addrFillSub)->opcode==OP_Once ); |
| 121252 | 121562 | sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub); |
| 121253 | 121563 | } |
| 121254 | 121564 | continue; |
| 121255 | 121565 | } |
| 121256 | 121566 | |
| | @@ -121321,10 +121631,12 @@ |
| 121321 | 121631 | ** is a register allocated to hold the subroutine return address |
| 121322 | 121632 | */ |
| 121323 | 121633 | int topAddr; |
| 121324 | 121634 | int onceAddr = 0; |
| 121325 | 121635 | int retAddr; |
| 121636 | + struct SrcList_item *pPrior; |
| 121637 | + |
| 121326 | 121638 | assert( pItem->addrFillSub==0 ); |
| 121327 | 121639 | pItem->regReturn = ++pParse->nMem; |
| 121328 | 121640 | topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn); |
| 121329 | 121641 | pItem->addrFillSub = topAddr+1; |
| 121330 | 121642 | if( pItem->fg.isCorrelated==0 ){ |
| | @@ -121334,13 +121646,18 @@ |
| 121334 | 121646 | onceAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 121335 | 121647 | VdbeComment((v, "materialize \"%s\"", pItem->pTab->zName)); |
| 121336 | 121648 | }else{ |
| 121337 | 121649 | VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName)); |
| 121338 | 121650 | } |
| 121339 | | - sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); |
| 121340 | | - explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); |
| 121341 | | - sqlite3Select(pParse, pSub, &dest); |
| 121651 | + pPrior = isSelfJoinView(pTabList, pItem); |
| 121652 | + if( pPrior ){ |
| 121653 | + sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); |
| 121654 | + }else{ |
| 121655 | + sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); |
| 121656 | + explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); |
| 121657 | + sqlite3Select(pParse, pSub, &dest); |
| 121658 | + } |
| 121342 | 121659 | pItem->pTab->nRowLogEst = pSub->nSelectRow; |
| 121343 | 121660 | if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); |
| 121344 | 121661 | retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn); |
| 121345 | 121662 | VdbeComment((v, "end %s", pItem->pTab->zName)); |
| 121346 | 121663 | sqlite3VdbeChangeP1(v, topAddr, retAddr); |
| | @@ -121555,10 +121872,15 @@ |
| 121555 | 121872 | sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0; |
| 121556 | 121873 | sAggInfo.pGroupBy = pGroupBy; |
| 121557 | 121874 | sqlite3ExprAnalyzeAggList(&sNC, pEList); |
| 121558 | 121875 | sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy); |
| 121559 | 121876 | if( pHaving ){ |
| 121877 | + if( pGroupBy ){ |
| 121878 | + assert( pWhere==p->pWhere ); |
| 121879 | + havingToWhere(pParse, pGroupBy, pHaving, &p->pWhere); |
| 121880 | + pWhere = p->pWhere; |
| 121881 | + } |
| 121560 | 121882 | sqlite3ExprAnalyzeAggregates(&sNC, pHaving); |
| 121561 | 121883 | } |
| 121562 | 121884 | sAggInfo.nAccumulator = sAggInfo.nColumn; |
| 121563 | 121885 | for(i=0; i<sAggInfo.nFunc; i++){ |
| 121564 | 121886 | assert( !ExprHasProperty(sAggInfo.aFunc[i].pExpr, EP_xIsSelect) ); |
| | @@ -123567,11 +123889,11 @@ |
| 123567 | 123889 | ** |
| 123568 | 123890 | ** FIXME: Be smarter about omitting indexes that use expressions. |
| 123569 | 123891 | */ |
| 123570 | 123892 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 123571 | 123893 | int reg; |
| 123572 | | - if( chngKey || hasFK || pIdx->pPartIdxWhere || pIdx==pPk ){ |
| 123894 | + if( chngKey || hasFK>1 || pIdx->pPartIdxWhere || pIdx==pPk ){ |
| 123573 | 123895 | reg = ++pParse->nMem; |
| 123574 | 123896 | pParse->nMem += pIdx->nColumn; |
| 123575 | 123897 | }else{ |
| 123576 | 123898 | reg = 0; |
| 123577 | 123899 | for(i=0; i<pIdx->nKeyCol; i++){ |
| | @@ -123922,11 +124244,11 @@ |
| 123922 | 124244 | ** is the column index supplied by the user. |
| 123923 | 124245 | */ |
| 123924 | 124246 | assert( regNew==regNewRowid+1 ); |
| 123925 | 124247 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 123926 | 124248 | sqlite3VdbeAddOp3(v, OP_Delete, iDataCur, |
| 123927 | | - OPFLAG_ISUPDATE | ((hasFK || chngKey) ? 0 : OPFLAG_ISNOOP), |
| 124249 | + OPFLAG_ISUPDATE | ((hasFK>1 || chngKey) ? 0 : OPFLAG_ISNOOP), |
| 123928 | 124250 | regNewRowid |
| 123929 | 124251 | ); |
| 123930 | 124252 | if( eOnePass==ONEPASS_MULTI ){ |
| 123931 | 124253 | assert( hasFK==0 && chngKey==0 ); |
| 123932 | 124254 | sqlite3VdbeChangeP5(v, OPFLAG_SAVEPOSITION); |
| | @@ -123933,11 +124255,11 @@ |
| 123933 | 124255 | } |
| 123934 | 124256 | if( !pParse->nested ){ |
| 123935 | 124257 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); |
| 123936 | 124258 | } |
| 123937 | 124259 | #else |
| 123938 | | - if( hasFK || chngKey ){ |
| 124260 | + if( hasFK>1 || chngKey ){ |
| 123939 | 124261 | sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0); |
| 123940 | 124262 | } |
| 123941 | 124263 | #endif |
| 123942 | 124264 | if( bReplace || chngKey ){ |
| 123943 | 124265 | sqlite3VdbeJumpHere(v, addr1); |
| | @@ -125576,11 +125898,11 @@ |
| 125576 | 125898 | |
| 125577 | 125899 | /* Check to see the left operand is a column in a virtual table */ |
| 125578 | 125900 | if( NEVER(pExpr==0) ) return pDef; |
| 125579 | 125901 | if( pExpr->op!=TK_COLUMN ) return pDef; |
| 125580 | 125902 | pTab = pExpr->pTab; |
| 125581 | | - if( NEVER(pTab==0) ) return pDef; |
| 125903 | + if( pTab==0 ) return pDef; |
| 125582 | 125904 | if( !IsVirtual(pTab) ) return pDef; |
| 125583 | 125905 | pVtab = sqlite3GetVTable(db, pTab)->pVtab; |
| 125584 | 125906 | assert( pVtab!=0 ); |
| 125585 | 125907 | assert( pVtab->pModule!=0 ); |
| 125586 | 125908 | pMod = (sqlite3_module *)pVtab->pModule; |
| | @@ -125911,10 +126233,11 @@ |
| 125911 | 126233 | union { |
| 125912 | 126234 | struct { /* Information for internal btree tables */ |
| 125913 | 126235 | u16 nEq; /* Number of equality constraints */ |
| 125914 | 126236 | u16 nBtm; /* Size of BTM vector */ |
| 125915 | 126237 | u16 nTop; /* Size of TOP vector */ |
| 126238 | + u16 nIdxCol; /* Index column used for ORDER BY */ |
| 125916 | 126239 | Index *pIndex; /* Index used, or NULL */ |
| 125917 | 126240 | } btree; |
| 125918 | 126241 | struct { /* Information for virtual tables */ |
| 125919 | 126242 | int idxNum; /* Index number */ |
| 125920 | 126243 | u8 needFree; /* True if sqlite3_free(idxStr) is needed */ |
| | @@ -126204,10 +126527,11 @@ |
| 126204 | 126527 | struct WhereInfo { |
| 126205 | 126528 | Parse *pParse; /* Parsing and code generating context */ |
| 126206 | 126529 | SrcList *pTabList; /* List of tables in the join */ |
| 126207 | 126530 | ExprList *pOrderBy; /* The ORDER BY clause or NULL */ |
| 126208 | 126531 | ExprList *pResultSet; /* Result set of the query */ |
| 126532 | + Expr *pWhere; /* The complete WHERE clause */ |
| 126209 | 126533 | LogEst iLimit; /* LIMIT if wctrlFlags has WHERE_USE_LIMIT */ |
| 126210 | 126534 | int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ |
| 126211 | 126535 | int iContinue; /* Jump here to continue with next record */ |
| 126212 | 126536 | int iBreak; /* Jump here to break out of the loop */ |
| 126213 | 126537 | int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
| | @@ -127363,10 +127687,73 @@ |
| 127363 | 127687 | }else{ |
| 127364 | 127688 | assert( nReg==1 ); |
| 127365 | 127689 | sqlite3ExprCode(pParse, p, iReg); |
| 127366 | 127690 | } |
| 127367 | 127691 | } |
| 127692 | + |
| 127693 | +/* An instance of the IdxExprTrans object carries information about a |
| 127694 | +** mapping from an expression on table columns into a column in an index |
| 127695 | +** down through the Walker. |
| 127696 | +*/ |
| 127697 | +typedef struct IdxExprTrans { |
| 127698 | + Expr *pIdxExpr; /* The index expression */ |
| 127699 | + int iTabCur; /* The cursor of the corresponding table */ |
| 127700 | + int iIdxCur; /* The cursor for the index */ |
| 127701 | + int iIdxCol; /* The column for the index */ |
| 127702 | +} IdxExprTrans; |
| 127703 | + |
| 127704 | +/* The walker node callback used to transform matching expressions into |
| 127705 | +** a reference to an index column for an index on an expression. |
| 127706 | +** |
| 127707 | +** If pExpr matches, then transform it into a reference to the index column |
| 127708 | +** that contains the value of pExpr. |
| 127709 | +*/ |
| 127710 | +static int whereIndexExprTransNode(Walker *p, Expr *pExpr){ |
| 127711 | + IdxExprTrans *pX = p->u.pIdxTrans; |
| 127712 | + if( sqlite3ExprCompare(pExpr, pX->pIdxExpr, pX->iTabCur)==0 ){ |
| 127713 | + pExpr->op = TK_COLUMN; |
| 127714 | + pExpr->iTable = pX->iIdxCur; |
| 127715 | + pExpr->iColumn = pX->iIdxCol; |
| 127716 | + pExpr->pTab = 0; |
| 127717 | + return WRC_Prune; |
| 127718 | + }else{ |
| 127719 | + return WRC_Continue; |
| 127720 | + } |
| 127721 | +} |
| 127722 | + |
| 127723 | +/* |
| 127724 | +** For an indexes on expression X, locate every instance of expression X in pExpr |
| 127725 | +** and change that subexpression into a reference to the appropriate column of |
| 127726 | +** the index. |
| 127727 | +*/ |
| 127728 | +static void whereIndexExprTrans( |
| 127729 | + Index *pIdx, /* The Index */ |
| 127730 | + int iTabCur, /* Cursor of the table that is being indexed */ |
| 127731 | + int iIdxCur, /* Cursor of the index itself */ |
| 127732 | + WhereInfo *pWInfo /* Transform expressions in this WHERE clause */ |
| 127733 | +){ |
| 127734 | + int iIdxCol; /* Column number of the index */ |
| 127735 | + ExprList *aColExpr; /* Expressions that are indexed */ |
| 127736 | + Walker w; |
| 127737 | + IdxExprTrans x; |
| 127738 | + aColExpr = pIdx->aColExpr; |
| 127739 | + if( aColExpr==0 ) return; /* Not an index on expressions */ |
| 127740 | + memset(&w, 0, sizeof(w)); |
| 127741 | + w.xExprCallback = whereIndexExprTransNode; |
| 127742 | + w.u.pIdxTrans = &x; |
| 127743 | + x.iTabCur = iTabCur; |
| 127744 | + x.iIdxCur = iIdxCur; |
| 127745 | + for(iIdxCol=0; iIdxCol<aColExpr->nExpr; iIdxCol++){ |
| 127746 | + if( pIdx->aiColumn[iIdxCol]!=XN_EXPR ) continue; |
| 127747 | + assert( aColExpr->a[iIdxCol].pExpr!=0 ); |
| 127748 | + x.iIdxCol = iIdxCol; |
| 127749 | + x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; |
| 127750 | + sqlite3WalkExpr(&w, pWInfo->pWhere); |
| 127751 | + sqlite3WalkExprList(&w, pWInfo->pOrderBy); |
| 127752 | + sqlite3WalkExprList(&w, pWInfo->pResultSet); |
| 127753 | + } |
| 127754 | +} |
| 127368 | 127755 | |
| 127369 | 127756 | /* |
| 127370 | 127757 | ** Generate code for the start of the iLevel-th loop in the WHERE clause |
| 127371 | 127758 | ** implementation described by pWInfo. |
| 127372 | 127759 | */ |
| | @@ -127391,10 +127778,12 @@ |
| 127391 | 127778 | int addrBrk; /* Jump here to break out of the loop */ |
| 127392 | 127779 | int addrHalt; /* addrBrk for the outermost loop */ |
| 127393 | 127780 | int addrCont; /* Jump here to continue with next cycle */ |
| 127394 | 127781 | int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ |
| 127395 | 127782 | int iReleaseReg = 0; /* Temp register to free before returning */ |
| 127783 | + Index *pIdx = 0; /* Index used by loop (if any) */ |
| 127784 | + int loopAgain; /* True if constraint generator loop should repeat */ |
| 127396 | 127785 | |
| 127397 | 127786 | pParse = pWInfo->pParse; |
| 127398 | 127787 | v = pParse->pVdbe; |
| 127399 | 127788 | pWC = &pWInfo->sWC; |
| 127400 | 127789 | db = pParse->db; |
| | @@ -127716,11 +128105,10 @@ |
| 127716 | 128105 | WhereTerm *pRangeEnd = 0; /* Inequality constraint at range end */ |
| 127717 | 128106 | int startEq; /* True if range start uses ==, >= or <= */ |
| 127718 | 128107 | int endEq; /* True if range end uses ==, >= or <= */ |
| 127719 | 128108 | int start_constraints; /* Start of range is constrained */ |
| 127720 | 128109 | int nConstraint; /* Number of constraint terms */ |
| 127721 | | - Index *pIdx; /* The index we will be using */ |
| 127722 | 128110 | int iIdxCur; /* The VDBE cursor for the index */ |
| 127723 | 128111 | int nExtraReg = 0; /* Number of extra registers needed */ |
| 127724 | 128112 | int op; /* Instruction opcode */ |
| 127725 | 128113 | char *zStartAff; /* Affinity for start of range constraint */ |
| 127726 | 128114 | char *zEndAff = 0; /* Affinity for end of range constraint */ |
| | @@ -127944,10 +128332,17 @@ |
| 127944 | 128332 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j); |
| 127945 | 128333 | } |
| 127946 | 128334 | sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont, |
| 127947 | 128335 | iRowidReg, pPk->nKeyCol); VdbeCoverage(v); |
| 127948 | 128336 | } |
| 128337 | + |
| 128338 | + /* If pIdx is an index on one or more expressions, then look through |
| 128339 | + ** all the expressions in pWInfo and try to transform matching expressions |
| 128340 | + ** into reference to index columns. |
| 128341 | + */ |
| 128342 | + whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo); |
| 128343 | + |
| 127949 | 128344 | |
| 127950 | 128345 | /* Record the instruction used to terminate the loop. */ |
| 127951 | 128346 | if( pLoop->wsFlags & WHERE_ONEROW ){ |
| 127952 | 128347 | pLevel->op = OP_Noop; |
| 127953 | 128348 | }else if( bRev ){ |
| | @@ -127960,10 +128355,11 @@ |
| 127960 | 128355 | if( (pLoop->wsFlags & WHERE_CONSTRAINT)==0 ){ |
| 127961 | 128356 | pLevel->p5 = SQLITE_STMTSTATUS_FULLSCAN_STEP; |
| 127962 | 128357 | }else{ |
| 127963 | 128358 | assert( pLevel->p5==0 ); |
| 127964 | 128359 | } |
| 128360 | + if( omitTable ) pIdx = 0; |
| 127965 | 128361 | }else |
| 127966 | 128362 | |
| 127967 | 128363 | #ifndef SQLITE_OMIT_OR_OPTIMIZATION |
| 127968 | 128364 | if( pLoop->wsFlags & WHERE_MULTI_OR ){ |
| 127969 | 128365 | /* Case 5: Two or more separately indexed terms connected by OR |
| | @@ -128277,47 +128673,60 @@ |
| 128277 | 128673 | pLevel->addrVisit = sqlite3VdbeCurrentAddr(v); |
| 128278 | 128674 | #endif |
| 128279 | 128675 | |
| 128280 | 128676 | /* Insert code to test every subexpression that can be completely |
| 128281 | 128677 | ** computed using the current set of tables. |
| 128678 | + ** |
| 128679 | + ** This loop may run either once (pIdx==0) or twice (pIdx!=0). If |
| 128680 | + ** it is run twice, then the first iteration codes those sub-expressions |
| 128681 | + ** that can be computed using columns from pIdx only (without seeking |
| 128682 | + ** the main table cursor). |
| 128282 | 128683 | */ |
| 128283 | | - for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 128284 | | - Expr *pE; |
| 128285 | | - int skipLikeAddr = 0; |
| 128286 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 128287 | | - testcase( pTerm->wtFlags & TERM_CODED ); |
| 128288 | | - if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 128289 | | - if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ |
| 128290 | | - testcase( pWInfo->untestedTerms==0 |
| 128291 | | - && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ); |
| 128292 | | - pWInfo->untestedTerms = 1; |
| 128293 | | - continue; |
| 128294 | | - } |
| 128295 | | - pE = pTerm->pExpr; |
| 128296 | | - assert( pE!=0 ); |
| 128297 | | - if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){ |
| 128298 | | - continue; |
| 128299 | | - } |
| 128300 | | - if( pTerm->wtFlags & TERM_LIKECOND ){ |
| 128301 | | - /* If the TERM_LIKECOND flag is set, that means that the range search |
| 128302 | | - ** is sufficient to guarantee that the LIKE operator is true, so we |
| 128303 | | - ** can skip the call to the like(A,B) function. But this only works |
| 128304 | | - ** for strings. So do not skip the call to the function on the pass |
| 128305 | | - ** that compares BLOBs. */ |
| 128684 | + do{ |
| 128685 | + loopAgain = 0; |
| 128686 | + for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 128687 | + Expr *pE; |
| 128688 | + int skipLikeAddr = 0; |
| 128689 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 128690 | + testcase( pTerm->wtFlags & TERM_CODED ); |
| 128691 | + if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 128692 | + if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ |
| 128693 | + testcase( pWInfo->untestedTerms==0 |
| 128694 | + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ); |
| 128695 | + pWInfo->untestedTerms = 1; |
| 128696 | + continue; |
| 128697 | + } |
| 128698 | + pE = pTerm->pExpr; |
| 128699 | + assert( pE!=0 ); |
| 128700 | + if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){ |
| 128701 | + continue; |
| 128702 | + } |
| 128703 | + if( pIdx && !sqlite3ExprCoveredByIndex(pE, pLevel->iTabCur, pIdx) ){ |
| 128704 | + loopAgain = 1; |
| 128705 | + continue; |
| 128706 | + } |
| 128707 | + if( pTerm->wtFlags & TERM_LIKECOND ){ |
| 128708 | + /* If the TERM_LIKECOND flag is set, that means that the range search |
| 128709 | + ** is sufficient to guarantee that the LIKE operator is true, so we |
| 128710 | + ** can skip the call to the like(A,B) function. But this only works |
| 128711 | + ** for strings. So do not skip the call to the function on the pass |
| 128712 | + ** that compares BLOBs. */ |
| 128306 | 128713 | #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS |
| 128307 | | - continue; |
| 128714 | + continue; |
| 128308 | 128715 | #else |
| 128309 | | - u32 x = pLevel->iLikeRepCntr; |
| 128310 | | - assert( x>0 ); |
| 128311 | | - skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)? OP_IfNot : OP_If, (int)(x>>1)); |
| 128312 | | - VdbeCoverage(v); |
| 128716 | + u32 x = pLevel->iLikeRepCntr; |
| 128717 | + assert( x>0 ); |
| 128718 | + skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If, (int)(x>>1)); |
| 128719 | + VdbeCoverage(v); |
| 128313 | 128720 | #endif |
| 128721 | + } |
| 128722 | + sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); |
| 128723 | + if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr); |
| 128724 | + pTerm->wtFlags |= TERM_CODED; |
| 128314 | 128725 | } |
| 128315 | | - sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); |
| 128316 | | - if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr); |
| 128317 | | - pTerm->wtFlags |= TERM_CODED; |
| 128318 | | - } |
| 128726 | + pIdx = 0; |
| 128727 | + }while( loopAgain ); |
| 128319 | 128728 | |
| 128320 | 128729 | /* Insert code to test for implied constraints based on transitivity |
| 128321 | 128730 | ** of the "==" operator. |
| 128322 | 128731 | ** |
| 128323 | 128732 | ** Example: If the WHERE clause contains "t1.a=t2.b" and "t2.b=123" |
| | @@ -129206,31 +129615,50 @@ |
| 129206 | 129615 | |
| 129207 | 129616 | /* |
| 129208 | 129617 | ** Expression pExpr is one operand of a comparison operator that might |
| 129209 | 129618 | ** be useful for indexing. This routine checks to see if pExpr appears |
| 129210 | 129619 | ** in any index. Return TRUE (1) if pExpr is an indexed term and return |
| 129211 | | -** FALSE (0) if not. If TRUE is returned, also set *piCur to the cursor |
| 129212 | | -** number of the table that is indexed and *piColumn to the column number |
| 129620 | +** FALSE (0) if not. If TRUE is returned, also set aiCurCol[0] to the cursor |
| 129621 | +** number of the table that is indexed and aiCurCol[1] to the column number |
| 129213 | 129622 | ** of the column that is indexed, or XN_EXPR (-2) if an expression is being |
| 129214 | 129623 | ** indexed. |
| 129215 | 129624 | ** |
| 129216 | 129625 | ** If pExpr is a TK_COLUMN column reference, then this routine always returns |
| 129217 | 129626 | ** true even if that particular column is not indexed, because the column |
| 129218 | 129627 | ** might be added to an automatic index later. |
| 129219 | 129628 | */ |
| 129220 | | -static int exprMightBeIndexed( |
| 129629 | +static SQLITE_NOINLINE int exprMightBeIndexed2( |
| 129221 | 129630 | SrcList *pFrom, /* The FROM clause */ |
| 129222 | | - int op, /* The specific comparison operator */ |
| 129223 | 129631 | Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */ |
| 129224 | | - Expr *pExpr, /* An operand of a comparison operator */ |
| 129225 | | - int *piCur, /* Write the referenced table cursor number here */ |
| 129226 | | - int *piColumn /* Write the referenced table column number here */ |
| 129632 | + int *aiCurCol, /* Write the referenced table cursor and column here */ |
| 129633 | + Expr *pExpr /* An operand of a comparison operator */ |
| 129227 | 129634 | ){ |
| 129228 | 129635 | Index *pIdx; |
| 129229 | 129636 | int i; |
| 129230 | 129637 | int iCur; |
| 129231 | | - |
| 129638 | + for(i=0; mPrereq>1; i++, mPrereq>>=1){} |
| 129639 | + iCur = pFrom->a[i].iCursor; |
| 129640 | + for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 129641 | + if( pIdx->aColExpr==0 ) continue; |
| 129642 | + for(i=0; i<pIdx->nKeyCol; i++){ |
| 129643 | + if( pIdx->aiColumn[i]!=XN_EXPR ) continue; |
| 129644 | + if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){ |
| 129645 | + aiCurCol[0] = iCur; |
| 129646 | + aiCurCol[1] = XN_EXPR; |
| 129647 | + return 1; |
| 129648 | + } |
| 129649 | + } |
| 129650 | + } |
| 129651 | + return 0; |
| 129652 | +} |
| 129653 | +static int exprMightBeIndexed( |
| 129654 | + SrcList *pFrom, /* The FROM clause */ |
| 129655 | + Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */ |
| 129656 | + int *aiCurCol, /* Write the referenced table cursor & column here */ |
| 129657 | + Expr *pExpr, /* An operand of a comparison operator */ |
| 129658 | + int op /* The specific comparison operator */ |
| 129659 | +){ |
| 129232 | 129660 | /* If this expression is a vector to the left or right of a |
| 129233 | 129661 | ** inequality constraint (>, <, >= or <=), perform the processing |
| 129234 | 129662 | ** on the first element of the vector. */ |
| 129235 | 129663 | assert( TK_GT+1==TK_LE && TK_GT+2==TK_LT && TK_GT+3==TK_GE ); |
| 129236 | 129664 | assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE ); |
| | @@ -129238,30 +129666,17 @@ |
| 129238 | 129666 | if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){ |
| 129239 | 129667 | pExpr = pExpr->x.pList->a[0].pExpr; |
| 129240 | 129668 | } |
| 129241 | 129669 | |
| 129242 | 129670 | if( pExpr->op==TK_COLUMN ){ |
| 129243 | | - *piCur = pExpr->iTable; |
| 129244 | | - *piColumn = pExpr->iColumn; |
| 129671 | + aiCurCol[0] = pExpr->iTable; |
| 129672 | + aiCurCol[1] = pExpr->iColumn; |
| 129245 | 129673 | return 1; |
| 129246 | 129674 | } |
| 129247 | 129675 | if( mPrereq==0 ) return 0; /* No table references */ |
| 129248 | 129676 | if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */ |
| 129249 | | - for(i=0; mPrereq>1; i++, mPrereq>>=1){} |
| 129250 | | - iCur = pFrom->a[i].iCursor; |
| 129251 | | - for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 129252 | | - if( pIdx->aColExpr==0 ) continue; |
| 129253 | | - for(i=0; i<pIdx->nKeyCol; i++){ |
| 129254 | | - if( pIdx->aiColumn[i]!=XN_EXPR ) continue; |
| 129255 | | - if( sqlite3ExprCompareSkip(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){ |
| 129256 | | - *piCur = iCur; |
| 129257 | | - *piColumn = XN_EXPR; |
| 129258 | | - return 1; |
| 129259 | | - } |
| 129260 | | - } |
| 129261 | | - } |
| 129262 | | - return 0; |
| 129677 | + return exprMightBeIndexed2(pFrom,mPrereq,aiCurCol,pExpr); |
| 129263 | 129678 | } |
| 129264 | 129679 | |
| 129265 | 129680 | /* |
| 129266 | 129681 | ** The input to this routine is an WhereTerm structure with only the |
| 129267 | 129682 | ** "pExpr" field filled in. The job of this routine is to analyze the |
| | @@ -129337,11 +129752,11 @@ |
| 129337 | 129752 | pTerm->prereqAll = prereqAll; |
| 129338 | 129753 | pTerm->leftCursor = -1; |
| 129339 | 129754 | pTerm->iParent = -1; |
| 129340 | 129755 | pTerm->eOperator = 0; |
| 129341 | 129756 | if( allowedOp(op) ){ |
| 129342 | | - int iCur, iColumn; |
| 129757 | + int aiCurCol[2]; |
| 129343 | 129758 | Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft); |
| 129344 | 129759 | Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight); |
| 129345 | 129760 | u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV; |
| 129346 | 129761 | |
| 129347 | 129762 | if( pTerm->iField>0 ){ |
| | @@ -129348,18 +129763,18 @@ |
| 129348 | 129763 | assert( op==TK_IN ); |
| 129349 | 129764 | assert( pLeft->op==TK_VECTOR ); |
| 129350 | 129765 | pLeft = pLeft->x.pList->a[pTerm->iField-1].pExpr; |
| 129351 | 129766 | } |
| 129352 | 129767 | |
| 129353 | | - if( exprMightBeIndexed(pSrc, op, prereqLeft, pLeft, &iCur, &iColumn) ){ |
| 129354 | | - pTerm->leftCursor = iCur; |
| 129355 | | - pTerm->u.leftColumn = iColumn; |
| 129768 | + if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){ |
| 129769 | + pTerm->leftCursor = aiCurCol[0]; |
| 129770 | + pTerm->u.leftColumn = aiCurCol[1]; |
| 129356 | 129771 | pTerm->eOperator = operatorMask(op) & opMask; |
| 129357 | 129772 | } |
| 129358 | 129773 | if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; |
| 129359 | 129774 | if( pRight |
| 129360 | | - && exprMightBeIndexed(pSrc, op, pTerm->prereqRight, pRight, &iCur,&iColumn) |
| 129775 | + && exprMightBeIndexed(pSrc, pTerm->prereqRight, aiCurCol, pRight, op) |
| 129361 | 129776 | ){ |
| 129362 | 129777 | WhereTerm *pNew; |
| 129363 | 129778 | Expr *pDup; |
| 129364 | 129779 | u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */ |
| 129365 | 129780 | assert( pTerm->iField==0 ); |
| | @@ -129385,12 +129800,12 @@ |
| 129385 | 129800 | }else{ |
| 129386 | 129801 | pDup = pExpr; |
| 129387 | 129802 | pNew = pTerm; |
| 129388 | 129803 | } |
| 129389 | 129804 | exprCommute(pParse, pDup); |
| 129390 | | - pNew->leftCursor = iCur; |
| 129391 | | - pNew->u.leftColumn = iColumn; |
| 129805 | + pNew->leftCursor = aiCurCol[0]; |
| 129806 | + pNew->u.leftColumn = aiCurCol[1]; |
| 129392 | 129807 | testcase( (prereqLeft | extraRight) != prereqLeft ); |
| 129393 | 129808 | pNew->prereqRight = prereqLeft | extraRight; |
| 129394 | 129809 | pNew->prereqAll = prereqAll; |
| 129395 | 129810 | pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask; |
| 129396 | 129811 | } |
| | @@ -131618,21 +132033,21 @@ |
| 131618 | 132033 | sqlite3_free(p->u.vtab.idxStr); |
| 131619 | 132034 | p->u.vtab.needFree = 0; |
| 131620 | 132035 | p->u.vtab.idxStr = 0; |
| 131621 | 132036 | }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){ |
| 131622 | 132037 | sqlite3DbFree(db, p->u.btree.pIndex->zColAff); |
| 131623 | | - sqlite3DbFree(db, p->u.btree.pIndex); |
| 132038 | + sqlite3DbFreeNN(db, p->u.btree.pIndex); |
| 131624 | 132039 | p->u.btree.pIndex = 0; |
| 131625 | 132040 | } |
| 131626 | 132041 | } |
| 131627 | 132042 | } |
| 131628 | 132043 | |
| 131629 | 132044 | /* |
| 131630 | 132045 | ** Deallocate internal memory used by a WhereLoop object |
| 131631 | 132046 | */ |
| 131632 | 132047 | static void whereLoopClear(sqlite3 *db, WhereLoop *p){ |
| 131633 | | - if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFree(db, p->aLTerm); |
| 132048 | + if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm); |
| 131634 | 132049 | whereLoopClearUnion(db, p); |
| 131635 | 132050 | whereLoopInit(p); |
| 131636 | 132051 | } |
| 131637 | 132052 | |
| 131638 | 132053 | /* |
| | @@ -131643,11 +132058,11 @@ |
| 131643 | 132058 | if( p->nLSlot>=n ) return SQLITE_OK; |
| 131644 | 132059 | n = (n+7)&~7; |
| 131645 | 132060 | paNew = sqlite3DbMallocRawNN(db, sizeof(p->aLTerm[0])*n); |
| 131646 | 132061 | if( paNew==0 ) return SQLITE_NOMEM_BKPT; |
| 131647 | 132062 | memcpy(paNew, p->aLTerm, sizeof(p->aLTerm[0])*p->nLSlot); |
| 131648 | | - if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFree(db, p->aLTerm); |
| 132063 | + if( p->aLTerm!=p->aLTermSpace ) sqlite3DbFreeNN(db, p->aLTerm); |
| 131649 | 132064 | p->aLTerm = paNew; |
| 131650 | 132065 | p->nLSlot = n; |
| 131651 | 132066 | return SQLITE_OK; |
| 131652 | 132067 | } |
| 131653 | 132068 | |
| | @@ -131673,11 +132088,11 @@ |
| 131673 | 132088 | /* |
| 131674 | 132089 | ** Delete a WhereLoop object |
| 131675 | 132090 | */ |
| 131676 | 132091 | static void whereLoopDelete(sqlite3 *db, WhereLoop *p){ |
| 131677 | 132092 | whereLoopClear(db, p); |
| 131678 | | - sqlite3DbFree(db, p); |
| 132093 | + sqlite3DbFreeNN(db, p); |
| 131679 | 132094 | } |
| 131680 | 132095 | |
| 131681 | 132096 | /* |
| 131682 | 132097 | ** Free a WhereInfo structure |
| 131683 | 132098 | */ |
| | @@ -131694,11 +132109,11 @@ |
| 131694 | 132109 | while( pWInfo->pLoops ){ |
| 131695 | 132110 | WhereLoop *p = pWInfo->pLoops; |
| 131696 | 132111 | pWInfo->pLoops = p->pNextLoop; |
| 131697 | 132112 | whereLoopDelete(db, p); |
| 131698 | 132113 | } |
| 131699 | | - sqlite3DbFree(db, pWInfo); |
| 132114 | + sqlite3DbFreeNN(db, pWInfo); |
| 131700 | 132115 | } |
| 131701 | 132116 | } |
| 131702 | 132117 | |
| 131703 | 132118 | /* |
| 131704 | 132119 | ** Return TRUE if all of the following are true: |
| | @@ -133085,11 +133500,11 @@ |
| 133085 | 133500 | pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn); |
| 133086 | 133501 | } |
| 133087 | 133502 | } |
| 133088 | 133503 | |
| 133089 | 133504 | if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); |
| 133090 | | - sqlite3DbFree(pParse->db, p); |
| 133505 | + sqlite3DbFreeNN(pParse->db, p); |
| 133091 | 133506 | return rc; |
| 133092 | 133507 | } |
| 133093 | 133508 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 133094 | 133509 | |
| 133095 | 133510 | /* |
| | @@ -133269,11 +133684,11 @@ |
| 133269 | 133684 | whereLoopClear(db, pNew); |
| 133270 | 133685 | return rc; |
| 133271 | 133686 | } |
| 133272 | 133687 | |
| 133273 | 133688 | /* |
| 133274 | | -** Examine a WherePath (with the addition of the extra WhereLoop of the 5th |
| 133689 | +** Examine a WherePath (with the addition of the extra WhereLoop of the 6th |
| 133275 | 133690 | ** parameters) to see if it outputs rows in the requested ORDER BY |
| 133276 | 133691 | ** (or GROUP BY) without requiring a separate sort operation. Return N: |
| 133277 | 133692 | ** |
| 133278 | 133693 | ** N>0: N terms of the ORDER BY clause are satisfied |
| 133279 | 133694 | ** N==0: No terms of the ORDER BY clause are satisfied |
| | @@ -133364,10 +133779,12 @@ |
| 133364 | 133779 | pLoop = pLast; |
| 133365 | 133780 | } |
| 133366 | 133781 | if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){ |
| 133367 | 133782 | if( pLoop->u.vtab.isOrdered ) obSat = obDone; |
| 133368 | 133783 | break; |
| 133784 | + }else{ |
| 133785 | + pLoop->u.btree.nIdxCol = 0; |
| 133369 | 133786 | } |
| 133370 | 133787 | iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor; |
| 133371 | 133788 | |
| 133372 | 133789 | /* Mark off any ORDER BY term X that is a column in the table of |
| 133373 | 133790 | ** the current loop for which there is term in the WHERE |
| | @@ -133509,10 +133926,11 @@ |
| 133509 | 133926 | if( iColumn>=0 ){ |
| 133510 | 133927 | pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr); |
| 133511 | 133928 | if( !pColl ) pColl = db->pDfltColl; |
| 133512 | 133929 | if( sqlite3StrICmp(pColl->zName, pIndex->azColl[j])!=0 ) continue; |
| 133513 | 133930 | } |
| 133931 | + pLoop->u.btree.nIdxCol = j+1; |
| 133514 | 133932 | isMatch = 1; |
| 133515 | 133933 | break; |
| 133516 | 133934 | } |
| 133517 | 133935 | if( isMatch && (wctrlFlags & WHERE_GROUPBY)==0 ){ |
| 133518 | 133936 | /* Make sure the sort order is compatible in an ORDER BY clause. |
| | @@ -133940,11 +134358,11 @@ |
| 133940 | 134358 | nFrom = nTo; |
| 133941 | 134359 | } |
| 133942 | 134360 | |
| 133943 | 134361 | if( nFrom==0 ){ |
| 133944 | 134362 | sqlite3ErrorMsg(pParse, "no query solution"); |
| 133945 | | - sqlite3DbFree(db, pSpace); |
| 134363 | + sqlite3DbFreeNN(db, pSpace); |
| 133946 | 134364 | return SQLITE_ERROR; |
| 133947 | 134365 | } |
| 133948 | 134366 | |
| 133949 | 134367 | /* Find the lowest cost path. pFrom will be left pointing to that path */ |
| 133950 | 134368 | pFrom = aFrom; |
| | @@ -134016,11 +134434,11 @@ |
| 134016 | 134434 | |
| 134017 | 134435 | |
| 134018 | 134436 | pWInfo->nRowOut = pFrom->nRow; |
| 134019 | 134437 | |
| 134020 | 134438 | /* Free temporary memory and return success */ |
| 134021 | | - sqlite3DbFree(db, pSpace); |
| 134439 | + sqlite3DbFreeNN(db, pSpace); |
| 134022 | 134440 | return SQLITE_OK; |
| 134023 | 134441 | } |
| 134024 | 134442 | |
| 134025 | 134443 | /* |
| 134026 | 134444 | ** Most queries use only a single table (they are not joins) and have |
| | @@ -134094,11 +134512,12 @@ |
| 134094 | 134512 | } |
| 134095 | 134513 | } |
| 134096 | 134514 | if( pLoop->wsFlags ){ |
| 134097 | 134515 | pLoop->nOut = (LogEst)1; |
| 134098 | 134516 | pWInfo->a[0].pWLoop = pLoop; |
| 134099 | | - pLoop->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); |
| 134517 | + assert( pWInfo->sMaskSet.n==1 && iCur==pWInfo->sMaskSet.ix[0] ); |
| 134518 | + pLoop->maskSelf = 1; /* sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); */ |
| 134100 | 134519 | pWInfo->a[0].iTabCur = iCur; |
| 134101 | 134520 | pWInfo->nRowOut = 1; |
| 134102 | 134521 | if( pWInfo->pOrderBy ) pWInfo->nOBSat = pWInfo->pOrderBy->nExpr; |
| 134103 | 134522 | if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){ |
| 134104 | 134523 | pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE; |
| | @@ -134278,10 +134697,11 @@ |
| 134278 | 134697 | goto whereBeginError; |
| 134279 | 134698 | } |
| 134280 | 134699 | pWInfo->pParse = pParse; |
| 134281 | 134700 | pWInfo->pTabList = pTabList; |
| 134282 | 134701 | pWInfo->pOrderBy = pOrderBy; |
| 134702 | + pWInfo->pWhere = pWhere; |
| 134283 | 134703 | pWInfo->pResultSet = pResultSet; |
| 134284 | 134704 | pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; |
| 134285 | 134705 | pWInfo->nLevel = nTabList; |
| 134286 | 134706 | pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v); |
| 134287 | 134707 | pWInfo->wctrlFlags = wctrlFlags; |
| | @@ -134588,10 +135008,11 @@ |
| 134588 | 135008 | sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb); |
| 134589 | 135009 | sqlite3VdbeSetP4KeyInfo(pParse, pIx); |
| 134590 | 135010 | if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0 |
| 134591 | 135011 | && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0 |
| 134592 | 135012 | && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0 |
| 135013 | + && pWInfo->eDistinct!=WHERE_DISTINCT_ORDERED |
| 134593 | 135014 | ){ |
| 134594 | 135015 | sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */ |
| 134595 | 135016 | } |
| 134596 | 135017 | VdbeComment((v, "%s", pIx->zName)); |
| 134597 | 135018 | #ifdef SQLITE_ENABLE_COLUMN_USED_MASK |
| | @@ -134676,18 +135097,47 @@ |
| 134676 | 135097 | sqlite3ExprCacheClear(pParse); |
| 134677 | 135098 | for(i=pWInfo->nLevel-1; i>=0; i--){ |
| 134678 | 135099 | int addr; |
| 134679 | 135100 | pLevel = &pWInfo->a[i]; |
| 134680 | 135101 | pLoop = pLevel->pWLoop; |
| 134681 | | - sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 134682 | 135102 | if( pLevel->op!=OP_Noop ){ |
| 135103 | +#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT |
| 135104 | + int addrSeek = 0; |
| 135105 | + Index *pIdx; |
| 135106 | + int n; |
| 135107 | + if( pWInfo->eDistinct==WHERE_DISTINCT_ORDERED |
| 135108 | + && (pLoop->wsFlags & WHERE_INDEXED)!=0 |
| 135109 | + && (pIdx = pLoop->u.btree.pIndex)->hasStat1 |
| 135110 | + && (n = pLoop->u.btree.nIdxCol)>0 |
| 135111 | + && pIdx->aiRowLogEst[n]>=36 |
| 135112 | + ){ |
| 135113 | + int r1 = pParse->nMem+1; |
| 135114 | + int j, op; |
| 135115 | + for(j=0; j<n; j++){ |
| 135116 | + sqlite3VdbeAddOp3(v, OP_Column, pLevel->iIdxCur, j, r1+j); |
| 135117 | + } |
| 135118 | + pParse->nMem += n+1; |
| 135119 | + op = pLevel->op==OP_Prev ? OP_SeekLT : OP_SeekGT; |
| 135120 | + addrSeek = sqlite3VdbeAddOp4Int(v, op, pLevel->iIdxCur, 0, r1, n); |
| 135121 | + VdbeCoverageIf(v, op==OP_SeekLT); |
| 135122 | + VdbeCoverageIf(v, op==OP_SeekGT); |
| 135123 | + sqlite3VdbeAddOp2(v, OP_Goto, 1, pLevel->p2); |
| 135124 | + } |
| 135125 | +#endif /* SQLITE_DISABLE_SKIPAHEAD_DISTINCT */ |
| 135126 | + /* The common case: Advance to the next row */ |
| 135127 | + sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 134683 | 135128 | sqlite3VdbeAddOp3(v, pLevel->op, pLevel->p1, pLevel->p2, pLevel->p3); |
| 134684 | 135129 | sqlite3VdbeChangeP5(v, pLevel->p5); |
| 134685 | 135130 | VdbeCoverage(v); |
| 134686 | 135131 | VdbeCoverageIf(v, pLevel->op==OP_Next); |
| 134687 | 135132 | VdbeCoverageIf(v, pLevel->op==OP_Prev); |
| 134688 | 135133 | VdbeCoverageIf(v, pLevel->op==OP_VNext); |
| 135134 | +#ifndef SQLITE_DISABLE_SKIPAHEAD_DISTINCT |
| 135135 | + if( addrSeek ) sqlite3VdbeJumpHere(v, addrSeek); |
| 135136 | +#endif |
| 135137 | + }else{ |
| 135138 | + sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 134689 | 135139 | } |
| 134690 | 135140 | if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){ |
| 134691 | 135141 | struct InLoop *pIn; |
| 134692 | 135142 | int j; |
| 134693 | 135143 | sqlite3VdbeResolveLabel(v, pLevel->addrNxt); |
| | @@ -134806,10 +135256,12 @@ |
| 134806 | 135256 | assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 |
| 134807 | 135257 | || pWInfo->eOnePass ); |
| 134808 | 135258 | }else if( pOp->opcode==OP_Rowid ){ |
| 134809 | 135259 | pOp->p1 = pLevel->iIdxCur; |
| 134810 | 135260 | pOp->opcode = OP_IdxRowid; |
| 135261 | + }else if( pOp->opcode==OP_IfNullRow ){ |
| 135262 | + pOp->p1 = pLevel->iIdxCur; |
| 134811 | 135263 | } |
| 134812 | 135264 | } |
| 134813 | 135265 | } |
| 134814 | 135266 | } |
| 134815 | 135267 | |
| | @@ -135115,11 +135567,11 @@ |
| 135115 | 135567 | #endif |
| 135116 | 135568 | /************* Begin control #defines *****************************************/ |
| 135117 | 135569 | #define YYCODETYPE unsigned char |
| 135118 | 135570 | #define YYNOCODE 252 |
| 135119 | 135571 | #define YYACTIONTYPE unsigned short int |
| 135120 | | -#define YYWILDCARD 96 |
| 135572 | +#define YYWILDCARD 69 |
| 135121 | 135573 | #define sqlite3ParserTOKENTYPE Token |
| 135122 | 135574 | typedef union { |
| 135123 | 135575 | int yyinit; |
| 135124 | 135576 | sqlite3ParserTOKENTYPE yy0; |
| 135125 | 135577 | Expr* yy72; |
| | @@ -135222,419 +135674,419 @@ |
| 135222 | 135674 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 135223 | 135675 | ** shifting non-terminals after a reduce. |
| 135224 | 135676 | ** yy_default[] Default action for each state. |
| 135225 | 135677 | ** |
| 135226 | 135678 | *********** Begin parsing tables **********************************************/ |
| 135227 | | -#define YY_ACTTAB_COUNT (1567) |
| 135679 | +#define YY_ACTTAB_COUNT (1566) |
| 135228 | 135680 | static const YYACTIONTYPE yy_action[] = { |
| 135229 | | - /* 0 */ 325, 832, 351, 825, 5, 203, 203, 819, 99, 100, |
| 135230 | | - /* 10 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, |
| 135231 | | - /* 20 */ 98, 98, 98, 301, 96, 96, 96, 96, 95, 95, |
| 135232 | | - /* 30 */ 94, 94, 94, 93, 351, 325, 976, 976, 824, 824, |
| 135233 | | - /* 40 */ 826, 946, 354, 99, 100, 90, 978, 978, 853, 856, |
| 135234 | | - /* 50 */ 845, 845, 97, 97, 98, 98, 98, 98, 338, 96, |
| 135235 | | - /* 60 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135236 | | - /* 70 */ 95, 95, 94, 94, 94, 93, 351, 791, 976, 976, |
| 135237 | | - /* 80 */ 325, 94, 94, 94, 93, 351, 792, 75, 99, 100, |
| 135238 | | - /* 90 */ 90, 978, 978, 853, 856, 845, 845, 97, 97, 98, |
| 135239 | | - /* 100 */ 98, 98, 98, 450, 96, 96, 96, 96, 95, 95, |
| 135240 | | - /* 110 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 325, |
| 135241 | | - /* 120 */ 275, 146, 132, 52, 52, 93, 351, 99, 100, 90, |
| 135242 | | - /* 130 */ 978, 978, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135243 | | - /* 140 */ 98, 98, 101, 96, 96, 96, 96, 95, 95, 94, |
| 135244 | | - /* 150 */ 94, 94, 93, 351, 957, 957, 325, 268, 428, 413, |
| 135245 | | - /* 160 */ 411, 61, 752, 752, 99, 100, 90, 978, 978, 853, |
| 135246 | | - /* 170 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 60, |
| 135247 | | - /* 180 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135248 | | - /* 190 */ 351, 325, 270, 329, 273, 277, 958, 959, 250, 99, |
| 135249 | | - /* 200 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135250 | | - /* 210 */ 98, 98, 98, 98, 301, 96, 96, 96, 96, 95, |
| 135251 | | - /* 220 */ 95, 94, 94, 94, 93, 351, 325, 937, 1326, 698, |
| 135252 | | - /* 230 */ 706, 1326, 242, 412, 99, 100, 90, 978, 978, 853, |
| 135253 | | - /* 240 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 347, |
| 135254 | | - /* 250 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135255 | | - /* 260 */ 351, 325, 937, 1327, 384, 699, 1327, 381, 379, 99, |
| 135256 | | - /* 270 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135257 | | - /* 280 */ 98, 98, 98, 98, 701, 96, 96, 96, 96, 95, |
| 135258 | | - /* 290 */ 95, 94, 94, 94, 93, 351, 325, 92, 89, 178, |
| 135259 | | - /* 300 */ 833, 935, 373, 700, 99, 100, 90, 978, 978, 853, |
| 135260 | | - /* 310 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 375, |
| 135261 | | - /* 320 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135262 | | - /* 330 */ 351, 325, 1275, 946, 354, 818, 935, 739, 739, 99, |
| 135263 | | - /* 340 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135264 | | - /* 350 */ 98, 98, 98, 98, 230, 96, 96, 96, 96, 95, |
| 135265 | | - /* 360 */ 95, 94, 94, 94, 93, 351, 325, 968, 227, 92, |
| 135266 | | - /* 370 */ 89, 178, 373, 300, 99, 100, 90, 978, 978, 853, |
| 135267 | | - /* 380 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 920, |
| 135268 | | - /* 390 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135269 | | - /* 400 */ 351, 325, 449, 447, 447, 447, 147, 737, 737, 99, |
| 135270 | | - /* 410 */ 100, 90, 978, 978, 853, 856, 845, 845, 97, 97, |
| 135271 | | - /* 420 */ 98, 98, 98, 98, 296, 96, 96, 96, 96, 95, |
| 135272 | | - /* 430 */ 95, 94, 94, 94, 93, 351, 325, 419, 231, 957, |
| 135273 | | - /* 440 */ 957, 158, 25, 422, 99, 100, 90, 978, 978, 853, |
| 135274 | | - /* 450 */ 856, 845, 845, 97, 97, 98, 98, 98, 98, 450, |
| 135275 | | - /* 460 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135276 | | - /* 470 */ 351, 443, 224, 224, 420, 957, 957, 961, 325, 52, |
| 135277 | | - /* 480 */ 52, 958, 959, 176, 415, 78, 99, 100, 90, 978, |
| 135278 | | - /* 490 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, |
| 135279 | | - /* 500 */ 98, 379, 96, 96, 96, 96, 95, 95, 94, 94, |
| 135280 | | - /* 510 */ 94, 93, 351, 325, 428, 418, 298, 958, 959, 961, |
| 135281 | | - /* 520 */ 81, 99, 88, 90, 978, 978, 853, 856, 845, 845, |
| 135282 | | - /* 530 */ 97, 97, 98, 98, 98, 98, 717, 96, 96, 96, |
| 135283 | | - /* 540 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 842, |
| 135284 | | - /* 550 */ 842, 854, 857, 996, 318, 343, 379, 100, 90, 978, |
| 135285 | | - /* 560 */ 978, 853, 856, 845, 845, 97, 97, 98, 98, 98, |
| 135286 | | - /* 570 */ 98, 450, 96, 96, 96, 96, 95, 95, 94, 94, |
| 135287 | | - /* 580 */ 94, 93, 351, 325, 350, 350, 350, 260, 377, 340, |
| 135288 | | - /* 590 */ 928, 52, 52, 90, 978, 978, 853, 856, 845, 845, |
| 135289 | | - /* 600 */ 97, 97, 98, 98, 98, 98, 361, 96, 96, 96, |
| 135290 | | - /* 610 */ 96, 95, 95, 94, 94, 94, 93, 351, 86, 445, |
| 135291 | | - /* 620 */ 846, 3, 1202, 361, 360, 378, 344, 813, 957, 957, |
| 135292 | | - /* 630 */ 1299, 86, 445, 729, 3, 212, 169, 287, 405, 282, |
| 135293 | | - /* 640 */ 404, 199, 232, 450, 300, 760, 83, 84, 280, 245, |
| 135294 | | - /* 650 */ 262, 365, 251, 85, 352, 352, 92, 89, 178, 83, |
| 135295 | | - /* 660 */ 84, 242, 412, 52, 52, 448, 85, 352, 352, 246, |
| 135296 | | - /* 670 */ 958, 959, 194, 455, 670, 402, 399, 398, 448, 243, |
| 135297 | | - /* 680 */ 221, 114, 434, 776, 361, 450, 397, 268, 747, 224, |
| 135298 | | - /* 690 */ 224, 132, 132, 198, 832, 434, 452, 451, 428, 427, |
| 135299 | | - /* 700 */ 819, 415, 734, 713, 132, 52, 52, 832, 268, 452, |
| 135300 | | - /* 710 */ 451, 734, 194, 819, 363, 402, 399, 398, 450, 1270, |
| 135301 | | - /* 720 */ 1270, 23, 957, 957, 86, 445, 397, 3, 228, 429, |
| 135302 | | - /* 730 */ 894, 824, 824, 826, 827, 19, 203, 720, 52, 52, |
| 135303 | | - /* 740 */ 428, 408, 439, 249, 824, 824, 826, 827, 19, 229, |
| 135304 | | - /* 750 */ 403, 153, 83, 84, 761, 177, 241, 450, 721, 85, |
| 135305 | | - /* 760 */ 352, 352, 120, 157, 958, 959, 58, 976, 409, 355, |
| 135306 | | - /* 770 */ 330, 448, 268, 428, 430, 320, 790, 32, 32, 86, |
| 135307 | | - /* 780 */ 445, 776, 3, 341, 98, 98, 98, 98, 434, 96, |
| 135308 | | - /* 790 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135309 | | - /* 800 */ 832, 120, 452, 451, 813, 886, 819, 83, 84, 976, |
| 135310 | | - /* 810 */ 813, 132, 410, 919, 85, 352, 352, 132, 407, 789, |
| 135311 | | - /* 820 */ 957, 957, 92, 89, 178, 916, 448, 262, 370, 261, |
| 135312 | | - /* 830 */ 82, 913, 80, 262, 370, 261, 776, 824, 824, 826, |
| 135313 | | - /* 840 */ 827, 19, 933, 434, 96, 96, 96, 96, 95, 95, |
| 135314 | | - /* 850 */ 94, 94, 94, 93, 351, 832, 74, 452, 451, 957, |
| 135315 | | - /* 860 */ 957, 819, 958, 959, 120, 92, 89, 178, 944, 2, |
| 135316 | | - /* 870 */ 917, 964, 268, 1, 975, 76, 445, 762, 3, 708, |
| 135317 | | - /* 880 */ 900, 900, 387, 957, 957, 757, 918, 371, 740, 778, |
| 135318 | | - /* 890 */ 756, 257, 824, 824, 826, 827, 19, 417, 741, 450, |
| 135319 | | - /* 900 */ 24, 958, 959, 83, 84, 369, 957, 957, 177, 226, |
| 135320 | | - /* 910 */ 85, 352, 352, 884, 315, 314, 313, 215, 311, 10, |
| 135321 | | - /* 920 */ 10, 683, 448, 349, 348, 958, 959, 908, 777, 157, |
| 135322 | | - /* 930 */ 120, 957, 957, 337, 776, 416, 711, 310, 450, 434, |
| 135323 | | - /* 940 */ 450, 321, 450, 791, 103, 200, 175, 450, 958, 959, |
| 135324 | | - /* 950 */ 907, 832, 792, 452, 451, 9, 9, 819, 10, 10, |
| 135325 | | - /* 960 */ 52, 52, 51, 51, 180, 716, 248, 10, 10, 171, |
| 135326 | | - /* 970 */ 170, 167, 339, 958, 959, 247, 984, 702, 702, 450, |
| 135327 | | - /* 980 */ 715, 233, 686, 982, 888, 983, 182, 913, 824, 824, |
| 135328 | | - /* 990 */ 826, 827, 19, 183, 256, 423, 132, 181, 394, 10, |
| 135329 | | - /* 1000 */ 10, 888, 890, 749, 957, 957, 916, 268, 985, 198, |
| 135330 | | - /* 1010 */ 985, 349, 348, 425, 415, 299, 817, 832, 326, 825, |
| 135331 | | - /* 1020 */ 120, 332, 133, 819, 268, 98, 98, 98, 98, 91, |
| 135332 | | - /* 1030 */ 96, 96, 96, 96, 95, 95, 94, 94, 94, 93, |
| 135333 | | - /* 1040 */ 351, 157, 810, 371, 382, 359, 958, 959, 358, 268, |
| 135334 | | - /* 1050 */ 450, 917, 368, 324, 824, 824, 826, 450, 709, 450, |
| 135335 | | - /* 1060 */ 264, 380, 888, 450, 876, 746, 253, 918, 255, 433, |
| 135336 | | - /* 1070 */ 36, 36, 234, 450, 234, 120, 269, 37, 37, 12, |
| 135337 | | - /* 1080 */ 12, 334, 272, 27, 27, 450, 330, 118, 450, 162, |
| 135338 | | - /* 1090 */ 742, 280, 450, 38, 38, 450, 985, 356, 985, 450, |
| 135339 | | - /* 1100 */ 709, 1209, 450, 132, 450, 39, 39, 450, 40, 40, |
| 135340 | | - /* 1110 */ 450, 362, 41, 41, 450, 42, 42, 450, 254, 28, |
| 135341 | | - /* 1120 */ 28, 450, 29, 29, 31, 31, 450, 43, 43, 450, |
| 135342 | | - /* 1130 */ 44, 44, 450, 714, 45, 45, 450, 11, 11, 767, |
| 135343 | | - /* 1140 */ 450, 46, 46, 450, 268, 450, 105, 105, 450, 47, |
| 135344 | | - /* 1150 */ 47, 450, 48, 48, 450, 237, 33, 33, 450, 172, |
| 135345 | | - /* 1160 */ 49, 49, 450, 50, 50, 34, 34, 274, 122, 122, |
| 135346 | | - /* 1170 */ 450, 123, 123, 450, 124, 124, 450, 897, 56, 56, |
| 135347 | | - /* 1180 */ 450, 896, 35, 35, 450, 267, 450, 817, 450, 817, |
| 135348 | | - /* 1190 */ 106, 106, 450, 53, 53, 385, 107, 107, 450, 817, |
| 135349 | | - /* 1200 */ 108, 108, 817, 450, 104, 104, 121, 121, 119, 119, |
| 135350 | | - /* 1210 */ 450, 117, 112, 112, 450, 276, 450, 225, 111, 111, |
| 135351 | | - /* 1220 */ 450, 730, 450, 109, 109, 450, 673, 674, 675, 911, |
| 135352 | | - /* 1230 */ 110, 110, 317, 998, 55, 55, 57, 57, 692, 331, |
| 135353 | | - /* 1240 */ 54, 54, 26, 26, 696, 30, 30, 317, 936, 197, |
| 135354 | | - /* 1250 */ 196, 195, 335, 281, 336, 446, 331, 745, 689, 436, |
| 135355 | | - /* 1260 */ 440, 444, 120, 72, 386, 223, 175, 345, 757, 932, |
| 135356 | | - /* 1270 */ 20, 286, 319, 756, 815, 372, 374, 202, 202, 202, |
| 135357 | | - /* 1280 */ 263, 395, 285, 74, 208, 21, 696, 719, 718, 883, |
| 135358 | | - /* 1290 */ 120, 120, 120, 120, 120, 754, 278, 828, 77, 74, |
| 135359 | | - /* 1300 */ 726, 727, 785, 783, 879, 202, 999, 208, 893, 892, |
| 135360 | | - /* 1310 */ 893, 892, 694, 816, 763, 116, 774, 1289, 431, 432, |
| 135361 | | - /* 1320 */ 302, 999, 390, 303, 823, 697, 691, 680, 159, 289, |
| 135362 | | - /* 1330 */ 679, 883, 681, 951, 291, 218, 293, 7, 316, 828, |
| 135363 | | - /* 1340 */ 173, 805, 259, 364, 252, 910, 376, 713, 295, 435, |
| 135364 | | - /* 1350 */ 308, 168, 954, 993, 135, 400, 990, 284, 881, 880, |
| 135365 | | - /* 1360 */ 205, 927, 925, 59, 333, 62, 144, 156, 130, 72, |
| 135366 | | - /* 1370 */ 802, 366, 367, 393, 137, 185, 189, 160, 139, 383, |
| 135367 | | - /* 1380 */ 67, 895, 140, 141, 142, 148, 389, 812, 775, 266, |
| 135368 | | - /* 1390 */ 219, 190, 154, 391, 912, 875, 271, 406, 191, 322, |
| 135369 | | - /* 1400 */ 682, 733, 192, 342, 732, 724, 731, 711, 723, 421, |
| 135370 | | - /* 1410 */ 705, 71, 323, 6, 204, 771, 288, 79, 297, 346, |
| 135371 | | - /* 1420 */ 772, 704, 290, 283, 703, 770, 292, 294, 966, 239, |
| 135372 | | - /* 1430 */ 769, 102, 861, 438, 426, 240, 424, 442, 73, 213, |
| 135373 | | - /* 1440 */ 688, 238, 22, 453, 952, 214, 217, 216, 454, 677, |
| 135374 | | - /* 1450 */ 676, 671, 753, 125, 115, 235, 126, 669, 353, 166, |
| 135375 | | - /* 1460 */ 127, 244, 179, 357, 306, 304, 305, 307, 113, 891, |
| 135376 | | - /* 1470 */ 327, 889, 811, 328, 134, 128, 136, 138, 743, 258, |
| 135377 | | - /* 1480 */ 906, 184, 143, 129, 909, 186, 63, 64, 145, 187, |
| 135378 | | - /* 1490 */ 905, 65, 8, 66, 13, 188, 202, 898, 265, 149, |
| 135379 | | - /* 1500 */ 987, 388, 150, 685, 161, 392, 285, 193, 279, 396, |
| 135380 | | - /* 1510 */ 151, 401, 68, 14, 15, 722, 69, 236, 831, 131, |
| 135381 | | - /* 1520 */ 830, 859, 70, 751, 16, 414, 755, 4, 174, 220, |
| 135382 | | - /* 1530 */ 222, 784, 201, 152, 779, 77, 74, 17, 18, 874, |
| 135383 | | - /* 1540 */ 860, 858, 915, 863, 914, 207, 206, 941, 163, 437, |
| 135384 | | - /* 1550 */ 947, 942, 164, 209, 1002, 441, 862, 165, 210, 829, |
| 135385 | | - /* 1560 */ 695, 87, 312, 211, 1291, 1290, 309, |
| 135681 | + /* 0 */ 325, 411, 343, 752, 752, 203, 946, 354, 976, 98, |
| 135682 | + /* 10 */ 98, 98, 98, 91, 96, 96, 96, 96, 95, 95, |
| 135683 | + /* 20 */ 94, 94, 94, 93, 351, 1333, 155, 155, 2, 813, |
| 135684 | + /* 30 */ 978, 978, 98, 98, 98, 98, 20, 96, 96, 96, |
| 135685 | + /* 40 */ 96, 95, 95, 94, 94, 94, 93, 351, 92, 89, |
| 135686 | + /* 50 */ 178, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135687 | + /* 60 */ 98, 98, 98, 98, 351, 96, 96, 96, 96, 95, |
| 135688 | + /* 70 */ 95, 94, 94, 94, 93, 351, 325, 340, 976, 262, |
| 135689 | + /* 80 */ 365, 251, 212, 169, 287, 405, 282, 404, 199, 791, |
| 135690 | + /* 90 */ 242, 412, 21, 957, 379, 280, 93, 351, 792, 95, |
| 135691 | + /* 100 */ 95, 94, 94, 94, 93, 351, 978, 978, 96, 96, |
| 135692 | + /* 110 */ 96, 96, 95, 95, 94, 94, 94, 93, 351, 813, |
| 135693 | + /* 120 */ 329, 242, 412, 913, 832, 913, 132, 99, 100, 90, |
| 135694 | + /* 130 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98, |
| 135695 | + /* 140 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94, |
| 135696 | + /* 150 */ 93, 351, 325, 825, 349, 348, 120, 819, 120, 75, |
| 135697 | + /* 160 */ 52, 52, 957, 958, 959, 760, 984, 146, 361, 262, |
| 135698 | + /* 170 */ 370, 261, 957, 982, 961, 983, 92, 89, 178, 371, |
| 135699 | + /* 180 */ 230, 371, 978, 978, 817, 361, 360, 101, 824, 824, |
| 135700 | + /* 190 */ 826, 384, 24, 964, 381, 428, 413, 369, 985, 380, |
| 135701 | + /* 200 */ 985, 708, 325, 99, 100, 90, 853, 856, 845, 845, |
| 135702 | + /* 210 */ 97, 97, 98, 98, 98, 98, 373, 96, 96, 96, |
| 135703 | + /* 220 */ 96, 95, 95, 94, 94, 94, 93, 351, 957, 132, |
| 135704 | + /* 230 */ 897, 450, 978, 978, 896, 60, 94, 94, 94, 93, |
| 135705 | + /* 240 */ 351, 957, 958, 959, 961, 103, 361, 957, 385, 334, |
| 135706 | + /* 250 */ 702, 52, 52, 99, 100, 90, 853, 856, 845, 845, |
| 135707 | + /* 260 */ 97, 97, 98, 98, 98, 98, 698, 96, 96, 96, |
| 135708 | + /* 270 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 455, |
| 135709 | + /* 280 */ 670, 450, 227, 61, 157, 243, 344, 114, 701, 888, |
| 135710 | + /* 290 */ 147, 832, 957, 373, 747, 957, 320, 957, 958, 959, |
| 135711 | + /* 300 */ 194, 10, 10, 402, 399, 398, 888, 890, 978, 978, |
| 135712 | + /* 310 */ 762, 171, 170, 157, 397, 337, 957, 958, 959, 702, |
| 135713 | + /* 320 */ 825, 310, 153, 957, 819, 321, 82, 23, 80, 99, |
| 135714 | + /* 330 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135715 | + /* 340 */ 98, 98, 894, 96, 96, 96, 96, 95, 95, 94, |
| 135716 | + /* 350 */ 94, 94, 93, 351, 325, 824, 824, 826, 277, 231, |
| 135717 | + /* 360 */ 300, 957, 958, 959, 957, 958, 959, 888, 194, 25, |
| 135718 | + /* 370 */ 450, 402, 399, 398, 957, 355, 300, 450, 957, 74, |
| 135719 | + /* 380 */ 450, 1, 397, 132, 978, 978, 957, 224, 224, 813, |
| 135720 | + /* 390 */ 10, 10, 957, 958, 959, 968, 132, 52, 52, 415, |
| 135721 | + /* 400 */ 52, 52, 739, 739, 339, 99, 100, 90, 853, 856, |
| 135722 | + /* 410 */ 845, 845, 97, 97, 98, 98, 98, 98, 790, 96, |
| 135723 | + /* 420 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135724 | + /* 430 */ 325, 789, 428, 418, 706, 428, 427, 1270, 1270, 262, |
| 135725 | + /* 440 */ 370, 261, 957, 957, 958, 959, 757, 957, 958, 959, |
| 135726 | + /* 450 */ 450, 756, 450, 734, 713, 957, 958, 959, 443, 711, |
| 135727 | + /* 460 */ 978, 978, 734, 394, 92, 89, 178, 447, 447, 447, |
| 135728 | + /* 470 */ 51, 51, 52, 52, 439, 778, 700, 92, 89, 178, |
| 135729 | + /* 480 */ 172, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135730 | + /* 490 */ 98, 98, 98, 98, 198, 96, 96, 96, 96, 95, |
| 135731 | + /* 500 */ 95, 94, 94, 94, 93, 351, 325, 428, 408, 916, |
| 135732 | + /* 510 */ 699, 957, 958, 959, 92, 89, 178, 224, 224, 157, |
| 135733 | + /* 520 */ 241, 221, 419, 299, 776, 917, 416, 375, 450, 415, |
| 135734 | + /* 530 */ 58, 324, 737, 737, 920, 379, 978, 978, 379, 777, |
| 135735 | + /* 540 */ 449, 918, 363, 740, 296, 686, 9, 9, 52, 52, |
| 135736 | + /* 550 */ 234, 330, 234, 256, 417, 741, 280, 99, 100, 90, |
| 135737 | + /* 560 */ 853, 856, 845, 845, 97, 97, 98, 98, 98, 98, |
| 135738 | + /* 570 */ 450, 96, 96, 96, 96, 95, 95, 94, 94, 94, |
| 135739 | + /* 580 */ 93, 351, 325, 423, 72, 450, 833, 120, 368, 450, |
| 135740 | + /* 590 */ 10, 10, 5, 301, 203, 450, 177, 976, 253, 420, |
| 135741 | + /* 600 */ 255, 776, 200, 175, 233, 10, 10, 842, 842, 36, |
| 135742 | + /* 610 */ 36, 1299, 978, 978, 729, 37, 37, 349, 348, 425, |
| 135743 | + /* 620 */ 203, 260, 776, 976, 232, 937, 1326, 876, 338, 1326, |
| 135744 | + /* 630 */ 422, 854, 857, 99, 100, 90, 853, 856, 845, 845, |
| 135745 | + /* 640 */ 97, 97, 98, 98, 98, 98, 268, 96, 96, 96, |
| 135746 | + /* 650 */ 96, 95, 95, 94, 94, 94, 93, 351, 325, 846, |
| 135747 | + /* 660 */ 450, 985, 818, 985, 1209, 450, 916, 976, 720, 350, |
| 135748 | + /* 670 */ 350, 350, 935, 177, 450, 937, 1327, 254, 198, 1327, |
| 135749 | + /* 680 */ 12, 12, 917, 403, 450, 27, 27, 250, 978, 978, |
| 135750 | + /* 690 */ 118, 721, 162, 976, 38, 38, 268, 176, 918, 776, |
| 135751 | + /* 700 */ 433, 1275, 946, 354, 39, 39, 317, 998, 325, 99, |
| 135752 | + /* 710 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135753 | + /* 720 */ 98, 98, 935, 96, 96, 96, 96, 95, 95, 94, |
| 135754 | + /* 730 */ 94, 94, 93, 351, 450, 330, 450, 358, 978, 978, |
| 135755 | + /* 740 */ 717, 317, 936, 341, 900, 900, 387, 673, 674, 675, |
| 135756 | + /* 750 */ 275, 996, 318, 999, 40, 40, 41, 41, 268, 99, |
| 135757 | + /* 760 */ 100, 90, 853, 856, 845, 845, 97, 97, 98, 98, |
| 135758 | + /* 770 */ 98, 98, 450, 96, 96, 96, 96, 95, 95, 94, |
| 135759 | + /* 780 */ 94, 94, 93, 351, 325, 450, 356, 450, 999, 450, |
| 135760 | + /* 790 */ 692, 331, 42, 42, 791, 270, 450, 273, 450, 228, |
| 135761 | + /* 800 */ 450, 298, 450, 792, 450, 28, 28, 29, 29, 31, |
| 135762 | + /* 810 */ 31, 450, 817, 450, 978, 978, 43, 43, 44, 44, |
| 135763 | + /* 820 */ 45, 45, 11, 11, 46, 46, 893, 78, 893, 268, |
| 135764 | + /* 830 */ 268, 105, 105, 47, 47, 99, 100, 90, 853, 856, |
| 135765 | + /* 840 */ 845, 845, 97, 97, 98, 98, 98, 98, 450, 96, |
| 135766 | + /* 850 */ 96, 96, 96, 95, 95, 94, 94, 94, 93, 351, |
| 135767 | + /* 860 */ 325, 450, 117, 450, 749, 158, 450, 696, 48, 48, |
| 135768 | + /* 870 */ 229, 919, 450, 928, 450, 415, 450, 335, 450, 245, |
| 135769 | + /* 880 */ 450, 33, 33, 49, 49, 450, 50, 50, 246, 817, |
| 135770 | + /* 890 */ 978, 978, 34, 34, 122, 122, 123, 123, 124, 124, |
| 135771 | + /* 900 */ 56, 56, 268, 81, 249, 35, 35, 197, 196, 195, |
| 135772 | + /* 910 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135773 | + /* 920 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95, |
| 135774 | + /* 930 */ 95, 94, 94, 94, 93, 351, 450, 696, 450, 817, |
| 135775 | + /* 940 */ 978, 978, 975, 884, 106, 106, 268, 886, 268, 944, |
| 135776 | + /* 950 */ 2, 892, 268, 892, 336, 716, 53, 53, 107, 107, |
| 135777 | + /* 960 */ 325, 99, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135778 | + /* 970 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95, |
| 135779 | + /* 980 */ 95, 94, 94, 94, 93, 351, 450, 746, 450, 742, |
| 135780 | + /* 990 */ 978, 978, 715, 267, 108, 108, 446, 331, 332, 133, |
| 135781 | + /* 1000 */ 223, 175, 301, 225, 386, 933, 104, 104, 121, 121, |
| 135782 | + /* 1010 */ 325, 99, 88, 90, 853, 856, 845, 845, 97, 97, |
| 135783 | + /* 1020 */ 98, 98, 98, 98, 817, 96, 96, 96, 96, 95, |
| 135784 | + /* 1030 */ 95, 94, 94, 94, 93, 351, 450, 347, 450, 167, |
| 135785 | + /* 1040 */ 978, 978, 932, 815, 372, 319, 202, 202, 374, 263, |
| 135786 | + /* 1050 */ 395, 202, 74, 208, 726, 727, 119, 119, 112, 112, |
| 135787 | + /* 1060 */ 325, 407, 100, 90, 853, 856, 845, 845, 97, 97, |
| 135788 | + /* 1070 */ 98, 98, 98, 98, 450, 96, 96, 96, 96, 95, |
| 135789 | + /* 1080 */ 95, 94, 94, 94, 93, 351, 450, 757, 450, 345, |
| 135790 | + /* 1090 */ 978, 978, 756, 278, 111, 111, 74, 719, 718, 709, |
| 135791 | + /* 1100 */ 286, 883, 754, 1289, 257, 77, 109, 109, 110, 110, |
| 135792 | + /* 1110 */ 908, 285, 810, 90, 853, 856, 845, 845, 97, 97, |
| 135793 | + /* 1120 */ 98, 98, 98, 98, 911, 96, 96, 96, 96, 95, |
| 135794 | + /* 1130 */ 95, 94, 94, 94, 93, 351, 86, 445, 450, 3, |
| 135795 | + /* 1140 */ 1202, 450, 745, 132, 352, 120, 689, 86, 445, 785, |
| 135796 | + /* 1150 */ 3, 767, 202, 377, 448, 352, 907, 120, 55, 55, |
| 135797 | + /* 1160 */ 450, 57, 57, 828, 879, 448, 450, 208, 450, 709, |
| 135798 | + /* 1170 */ 450, 883, 237, 434, 436, 120, 440, 429, 362, 120, |
| 135799 | + /* 1180 */ 54, 54, 132, 450, 434, 832, 52, 52, 26, 26, |
| 135800 | + /* 1190 */ 30, 30, 382, 132, 409, 444, 832, 694, 264, 390, |
| 135801 | + /* 1200 */ 116, 269, 272, 32, 32, 83, 84, 120, 274, 120, |
| 135802 | + /* 1210 */ 120, 276, 85, 352, 452, 451, 83, 84, 819, 730, |
| 135803 | + /* 1220 */ 714, 428, 430, 85, 352, 452, 451, 120, 120, 819, |
| 135804 | + /* 1230 */ 378, 218, 281, 828, 783, 816, 86, 445, 410, 3, |
| 135805 | + /* 1240 */ 763, 774, 431, 432, 352, 302, 303, 823, 697, 824, |
| 135806 | + /* 1250 */ 824, 826, 827, 19, 448, 691, 680, 679, 681, 951, |
| 135807 | + /* 1260 */ 824, 824, 826, 827, 19, 289, 159, 291, 293, 7, |
| 135808 | + /* 1270 */ 316, 173, 259, 434, 805, 364, 252, 910, 376, 713, |
| 135809 | + /* 1280 */ 295, 435, 168, 993, 400, 832, 284, 881, 880, 205, |
| 135810 | + /* 1290 */ 954, 308, 927, 86, 445, 990, 3, 925, 333, 144, |
| 135811 | + /* 1300 */ 130, 352, 72, 135, 59, 83, 84, 761, 137, 366, |
| 135812 | + /* 1310 */ 802, 448, 85, 352, 452, 451, 139, 226, 819, 140, |
| 135813 | + /* 1320 */ 156, 62, 315, 314, 313, 215, 311, 367, 393, 683, |
| 135814 | + /* 1330 */ 434, 185, 141, 912, 142, 160, 148, 812, 875, 383, |
| 135815 | + /* 1340 */ 189, 67, 832, 180, 389, 248, 895, 775, 219, 824, |
| 135816 | + /* 1350 */ 824, 826, 827, 19, 247, 190, 266, 154, 391, 271, |
| 135817 | + /* 1360 */ 191, 192, 83, 84, 682, 406, 733, 182, 322, 85, |
| 135818 | + /* 1370 */ 352, 452, 451, 732, 183, 819, 342, 132, 181, 711, |
| 135819 | + /* 1380 */ 731, 421, 76, 445, 705, 3, 323, 704, 283, 724, |
| 135820 | + /* 1390 */ 352, 771, 703, 966, 723, 71, 204, 6, 288, 290, |
| 135821 | + /* 1400 */ 448, 772, 770, 769, 79, 292, 824, 824, 826, 827, |
| 135822 | + /* 1410 */ 19, 294, 297, 438, 346, 442, 102, 861, 753, 434, |
| 135823 | + /* 1420 */ 238, 426, 73, 305, 239, 304, 326, 240, 424, 306, |
| 135824 | + /* 1430 */ 307, 832, 213, 688, 22, 952, 453, 214, 216, 217, |
| 135825 | + /* 1440 */ 454, 677, 115, 676, 671, 125, 126, 235, 127, 669, |
| 135826 | + /* 1450 */ 327, 83, 84, 359, 353, 244, 166, 328, 85, 352, |
| 135827 | + /* 1460 */ 452, 451, 134, 179, 819, 357, 113, 891, 811, 889, |
| 135828 | + /* 1470 */ 136, 128, 138, 743, 258, 184, 906, 143, 145, 63, |
| 135829 | + /* 1480 */ 64, 65, 66, 129, 909, 905, 187, 186, 8, 13, |
| 135830 | + /* 1490 */ 188, 265, 898, 149, 202, 824, 824, 826, 827, 19, |
| 135831 | + /* 1500 */ 388, 987, 150, 161, 285, 685, 392, 396, 151, 722, |
| 135832 | + /* 1510 */ 193, 68, 14, 401, 279, 15, 69, 236, 831, 830, |
| 135833 | + /* 1520 */ 131, 859, 751, 70, 16, 414, 755, 4, 784, 220, |
| 135834 | + /* 1530 */ 222, 174, 152, 437, 779, 201, 17, 77, 74, 18, |
| 135835 | + /* 1540 */ 874, 860, 858, 915, 863, 914, 207, 206, 941, 163, |
| 135836 | + /* 1550 */ 210, 942, 209, 164, 441, 862, 165, 211, 829, 695, |
| 135837 | + /* 1560 */ 87, 312, 309, 947, 1291, 1290, |
| 135386 | 135838 | }; |
| 135387 | 135839 | static const YYCODETYPE yy_lookahead[] = { |
| 135388 | | - /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28, |
| 135389 | | - /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
| 135390 | | - /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48, |
| 135391 | | - /* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133, |
| 135392 | | - /* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33, |
| 135393 | | - /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 187, 43, |
| 135394 | | - /* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 135395 | | - /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97, |
| 135396 | | - /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28, |
| 135397 | | - /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
| 135398 | | - /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48, |
| 135399 | | - /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19, |
| 135400 | | - /* 120 */ 16, 22, 92, 172, 173, 52, 53, 27, 28, 29, |
| 135401 | | - /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, |
| 135402 | | - /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49, |
| 135403 | | - /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208, |
| 135404 | | - /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32, |
| 135405 | | - /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79, |
| 135406 | | - /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135407 | | - /* 190 */ 53, 19, 88, 157, 90, 23, 97, 98, 193, 27, |
| 135408 | | - /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135409 | | - /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47, |
| 135410 | | - /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172, |
| 135411 | | - /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32, |
| 135412 | | - /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187, |
| 135413 | | - /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135414 | | - /* 260 */ 53, 19, 22, 23, 228, 23, 26, 231, 152, 27, |
| 135415 | | - /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135416 | | - /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47, |
| 135417 | | - /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223, |
| 135418 | | - /* 300 */ 23, 96, 152, 172, 27, 28, 29, 30, 31, 32, |
| 135419 | | - /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152, |
| 135420 | | - /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135421 | | - /* 330 */ 53, 19, 0, 1, 2, 23, 96, 190, 191, 27, |
| 135422 | | - /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135423 | | - /* 350 */ 38, 39, 40, 41, 238, 43, 44, 45, 46, 47, |
| 135424 | | - /* 360 */ 48, 49, 50, 51, 52, 53, 19, 185, 218, 221, |
| 135425 | | - /* 370 */ 222, 223, 152, 152, 27, 28, 29, 30, 31, 32, |
| 135426 | | - /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 241, |
| 135427 | | - /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135428 | | - /* 400 */ 53, 19, 152, 168, 169, 170, 22, 190, 191, 27, |
| 135429 | | - /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 135430 | | - /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47, |
| 135431 | | - /* 430 */ 48, 49, 50, 51, 52, 53, 19, 19, 218, 55, |
| 135432 | | - /* 440 */ 56, 24, 22, 152, 27, 28, 29, 30, 31, 32, |
| 135433 | | - /* 450 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 152, |
| 135434 | | - /* 460 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135435 | | - /* 470 */ 53, 250, 194, 195, 56, 55, 56, 55, 19, 172, |
| 135436 | | - /* 480 */ 173, 97, 98, 152, 206, 138, 27, 28, 29, 30, |
| 135437 | | - /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
| 135438 | | - /* 500 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50, |
| 135439 | | - /* 510 */ 51, 52, 53, 19, 207, 208, 152, 97, 98, 97, |
| 135440 | | - /* 520 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35, |
| 135441 | | - /* 530 */ 36, 37, 38, 39, 40, 41, 181, 43, 44, 45, |
| 135442 | | - /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 30, |
| 135443 | | - /* 550 */ 31, 32, 33, 247, 248, 19, 152, 28, 29, 30, |
| 135444 | | - /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
| 135445 | | - /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50, |
| 135446 | | - /* 580 */ 51, 52, 53, 19, 168, 169, 170, 238, 19, 53, |
| 135447 | | - /* 590 */ 152, 172, 173, 29, 30, 31, 32, 33, 34, 35, |
| 135448 | | - /* 600 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45, |
| 135449 | | - /* 610 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 20, |
| 135450 | | - /* 620 */ 101, 22, 23, 169, 170, 56, 207, 85, 55, 56, |
| 135451 | | - /* 630 */ 23, 19, 20, 26, 22, 99, 100, 101, 102, 103, |
| 135452 | | - /* 640 */ 104, 105, 238, 152, 152, 210, 47, 48, 112, 152, |
| 135453 | | - /* 650 */ 108, 109, 110, 54, 55, 56, 221, 222, 223, 47, |
| 135454 | | - /* 660 */ 48, 119, 120, 172, 173, 66, 54, 55, 56, 152, |
| 135455 | | - /* 670 */ 97, 98, 99, 148, 149, 102, 103, 104, 66, 154, |
| 135456 | | - /* 680 */ 23, 156, 83, 26, 230, 152, 113, 152, 163, 194, |
| 135457 | | - /* 690 */ 195, 92, 92, 30, 95, 83, 97, 98, 207, 208, |
| 135458 | | - /* 700 */ 101, 206, 179, 180, 92, 172, 173, 95, 152, 97, |
| 135459 | | - /* 710 */ 98, 188, 99, 101, 219, 102, 103, 104, 152, 119, |
| 135460 | | - /* 720 */ 120, 196, 55, 56, 19, 20, 113, 22, 193, 163, |
| 135461 | | - /* 730 */ 11, 132, 133, 134, 135, 136, 24, 65, 172, 173, |
| 135462 | | - /* 740 */ 207, 208, 250, 152, 132, 133, 134, 135, 136, 193, |
| 135463 | | - /* 750 */ 78, 84, 47, 48, 49, 98, 199, 152, 86, 54, |
| 135464 | | - /* 760 */ 55, 56, 196, 152, 97, 98, 209, 55, 163, 244, |
| 135465 | | - /* 770 */ 107, 66, 152, 207, 208, 164, 175, 172, 173, 19, |
| 135466 | | - /* 780 */ 20, 124, 22, 111, 38, 39, 40, 41, 83, 43, |
| 135467 | | - /* 790 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 135468 | | - /* 800 */ 95, 196, 97, 98, 85, 152, 101, 47, 48, 97, |
| 135469 | | - /* 810 */ 85, 92, 207, 193, 54, 55, 56, 92, 49, 175, |
| 135470 | | - /* 820 */ 55, 56, 221, 222, 223, 12, 66, 108, 109, 110, |
| 135471 | | - /* 830 */ 137, 163, 139, 108, 109, 110, 26, 132, 133, 134, |
| 135472 | | - /* 840 */ 135, 136, 152, 83, 43, 44, 45, 46, 47, 48, |
| 135473 | | - /* 850 */ 49, 50, 51, 52, 53, 95, 26, 97, 98, 55, |
| 135474 | | - /* 860 */ 56, 101, 97, 98, 196, 221, 222, 223, 146, 147, |
| 135475 | | - /* 870 */ 57, 171, 152, 22, 26, 19, 20, 49, 22, 179, |
| 135476 | | - /* 880 */ 108, 109, 110, 55, 56, 116, 73, 219, 75, 124, |
| 135477 | | - /* 890 */ 121, 152, 132, 133, 134, 135, 136, 163, 85, 152, |
| 135478 | | - /* 900 */ 232, 97, 98, 47, 48, 237, 55, 56, 98, 5, |
| 135479 | | - /* 910 */ 54, 55, 56, 193, 10, 11, 12, 13, 14, 172, |
| 135480 | | - /* 920 */ 173, 17, 66, 47, 48, 97, 98, 152, 124, 152, |
| 135481 | | - /* 930 */ 196, 55, 56, 186, 124, 152, 106, 160, 152, 83, |
| 135482 | | - /* 940 */ 152, 164, 152, 61, 22, 211, 212, 152, 97, 98, |
| 135483 | | - /* 950 */ 152, 95, 70, 97, 98, 172, 173, 101, 172, 173, |
| 135484 | | - /* 960 */ 172, 173, 172, 173, 60, 181, 62, 172, 173, 47, |
| 135485 | | - /* 970 */ 48, 123, 186, 97, 98, 71, 100, 55, 56, 152, |
| 135486 | | - /* 980 */ 181, 186, 21, 107, 152, 109, 82, 163, 132, 133, |
| 135487 | | - /* 990 */ 134, 135, 136, 89, 16, 207, 92, 93, 19, 172, |
| 135488 | | - /* 1000 */ 173, 169, 170, 195, 55, 56, 12, 152, 132, 30, |
| 135489 | | - /* 1010 */ 134, 47, 48, 186, 206, 225, 152, 95, 114, 97, |
| 135490 | | - /* 1020 */ 196, 245, 246, 101, 152, 38, 39, 40, 41, 42, |
| 135491 | | - /* 1030 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 135492 | | - /* 1040 */ 53, 152, 163, 219, 152, 141, 97, 98, 193, 152, |
| 135493 | | - /* 1050 */ 152, 57, 91, 164, 132, 133, 134, 152, 55, 152, |
| 135494 | | - /* 1060 */ 152, 237, 230, 152, 103, 193, 88, 73, 90, 75, |
| 135495 | | - /* 1070 */ 172, 173, 183, 152, 185, 196, 152, 172, 173, 172, |
| 135496 | | - /* 1080 */ 173, 217, 152, 172, 173, 152, 107, 22, 152, 24, |
| 135497 | | - /* 1090 */ 193, 112, 152, 172, 173, 152, 132, 242, 134, 152, |
| 135498 | | - /* 1100 */ 97, 140, 152, 92, 152, 172, 173, 152, 172, 173, |
| 135499 | | - /* 1110 */ 152, 100, 172, 173, 152, 172, 173, 152, 140, 172, |
| 135500 | | - /* 1120 */ 173, 152, 172, 173, 172, 173, 152, 172, 173, 152, |
| 135501 | | - /* 1130 */ 172, 173, 152, 152, 172, 173, 152, 172, 173, 213, |
| 135502 | | - /* 1140 */ 152, 172, 173, 152, 152, 152, 172, 173, 152, 172, |
| 135503 | | - /* 1150 */ 173, 152, 172, 173, 152, 210, 172, 173, 152, 26, |
| 135504 | | - /* 1160 */ 172, 173, 152, 172, 173, 172, 173, 152, 172, 173, |
| 135505 | | - /* 1170 */ 152, 172, 173, 152, 172, 173, 152, 59, 172, 173, |
| 135506 | | - /* 1180 */ 152, 63, 172, 173, 152, 193, 152, 152, 152, 152, |
| 135507 | | - /* 1190 */ 172, 173, 152, 172, 173, 77, 172, 173, 152, 152, |
| 135508 | | - /* 1200 */ 172, 173, 152, 152, 172, 173, 172, 173, 172, 173, |
| 135509 | | - /* 1210 */ 152, 22, 172, 173, 152, 152, 152, 22, 172, 173, |
| 135510 | | - /* 1220 */ 152, 152, 152, 172, 173, 152, 7, 8, 9, 163, |
| 135511 | | - /* 1230 */ 172, 173, 22, 23, 172, 173, 172, 173, 166, 167, |
| 135512 | | - /* 1240 */ 172, 173, 172, 173, 55, 172, 173, 22, 23, 108, |
| 135513 | | - /* 1250 */ 109, 110, 217, 152, 217, 166, 167, 163, 163, 163, |
| 135514 | | - /* 1260 */ 163, 163, 196, 130, 217, 211, 212, 217, 116, 23, |
| 135515 | | - /* 1270 */ 22, 101, 26, 121, 23, 23, 23, 26, 26, 26, |
| 135516 | | - /* 1280 */ 23, 23, 112, 26, 26, 37, 97, 100, 101, 55, |
| 135517 | | - /* 1290 */ 196, 196, 196, 196, 196, 23, 23, 55, 26, 26, |
| 135518 | | - /* 1300 */ 7, 8, 23, 152, 23, 26, 96, 26, 132, 132, |
| 135519 | | - /* 1310 */ 134, 134, 23, 152, 152, 26, 152, 122, 152, 191, |
| 135520 | | - /* 1320 */ 152, 96, 234, 152, 152, 152, 152, 152, 197, 210, |
| 135521 | | - /* 1330 */ 152, 97, 152, 152, 210, 233, 210, 198, 150, 97, |
| 135522 | | - /* 1340 */ 184, 201, 239, 214, 214, 201, 239, 180, 214, 227, |
| 135523 | | - /* 1350 */ 200, 198, 155, 67, 243, 176, 69, 175, 175, 175, |
| 135524 | | - /* 1360 */ 122, 159, 159, 240, 159, 240, 22, 220, 27, 130, |
| 135525 | | - /* 1370 */ 201, 18, 159, 18, 189, 158, 158, 220, 192, 159, |
| 135526 | | - /* 1380 */ 137, 236, 192, 192, 192, 189, 74, 189, 159, 235, |
| 135527 | | - /* 1390 */ 159, 158, 22, 177, 201, 201, 159, 107, 158, 177, |
| 135528 | | - /* 1400 */ 159, 174, 158, 76, 174, 182, 174, 106, 182, 125, |
| 135529 | | - /* 1410 */ 174, 107, 177, 22, 159, 216, 215, 137, 159, 53, |
| 135530 | | - /* 1420 */ 216, 176, 215, 174, 174, 216, 215, 215, 174, 229, |
| 135531 | | - /* 1430 */ 216, 129, 224, 177, 126, 229, 127, 177, 128, 25, |
| 135532 | | - /* 1440 */ 162, 226, 26, 161, 13, 153, 6, 153, 151, 151, |
| 135533 | | - /* 1450 */ 151, 151, 205, 165, 178, 178, 165, 4, 3, 22, |
| 135534 | | - /* 1460 */ 165, 142, 15, 94, 202, 204, 203, 201, 16, 23, |
| 135535 | | - /* 1470 */ 249, 23, 120, 249, 246, 111, 131, 123, 20, 16, |
| 135536 | | - /* 1480 */ 1, 125, 123, 111, 56, 64, 37, 37, 131, 122, |
| 135537 | | - /* 1490 */ 1, 37, 5, 37, 22, 107, 26, 80, 140, 80, |
| 135538 | | - /* 1500 */ 87, 72, 107, 20, 24, 19, 112, 105, 23, 79, |
| 135539 | | - /* 1510 */ 22, 79, 22, 22, 22, 58, 22, 79, 23, 68, |
| 135540 | | - /* 1520 */ 23, 23, 26, 116, 22, 26, 23, 22, 122, 23, |
| 135541 | | - /* 1530 */ 23, 56, 64, 22, 124, 26, 26, 64, 64, 23, |
| 135542 | | - /* 1540 */ 23, 23, 23, 11, 23, 22, 26, 23, 22, 24, |
| 135543 | | - /* 1550 */ 1, 23, 22, 26, 251, 24, 23, 22, 122, 23, |
| 135544 | | - /* 1560 */ 23, 22, 15, 122, 122, 122, 23, |
| 135545 | | -}; |
| 135546 | | -#define YY_SHIFT_USE_DFLT (1567) |
| 135840 | + /* 0 */ 19, 115, 19, 117, 118, 24, 1, 2, 27, 79, |
| 135841 | + /* 10 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, |
| 135842 | + /* 20 */ 90, 91, 92, 93, 94, 144, 145, 146, 147, 58, |
| 135843 | + /* 30 */ 49, 50, 79, 80, 81, 82, 22, 84, 85, 86, |
| 135844 | + /* 40 */ 87, 88, 89, 90, 91, 92, 93, 94, 221, 222, |
| 135845 | + /* 50 */ 223, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 135846 | + /* 60 */ 79, 80, 81, 82, 94, 84, 85, 86, 87, 88, |
| 135847 | + /* 70 */ 89, 90, 91, 92, 93, 94, 19, 94, 97, 108, |
| 135848 | + /* 80 */ 109, 110, 99, 100, 101, 102, 103, 104, 105, 32, |
| 135849 | + /* 90 */ 119, 120, 78, 27, 152, 112, 93, 94, 41, 88, |
| 135850 | + /* 100 */ 89, 90, 91, 92, 93, 94, 49, 50, 84, 85, |
| 135851 | + /* 110 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 58, |
| 135852 | + /* 120 */ 157, 119, 120, 163, 68, 163, 65, 70, 71, 72, |
| 135853 | + /* 130 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 135854 | + /* 140 */ 152, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 135855 | + /* 150 */ 93, 94, 19, 97, 88, 89, 196, 101, 196, 26, |
| 135856 | + /* 160 */ 172, 173, 96, 97, 98, 210, 100, 22, 152, 108, |
| 135857 | + /* 170 */ 109, 110, 27, 107, 27, 109, 221, 222, 223, 219, |
| 135858 | + /* 180 */ 238, 219, 49, 50, 152, 169, 170, 54, 132, 133, |
| 135859 | + /* 190 */ 134, 228, 232, 171, 231, 207, 208, 237, 132, 237, |
| 135860 | + /* 200 */ 134, 179, 19, 70, 71, 72, 73, 74, 75, 76, |
| 135861 | + /* 210 */ 77, 78, 79, 80, 81, 82, 152, 84, 85, 86, |
| 135862 | + /* 220 */ 87, 88, 89, 90, 91, 92, 93, 94, 27, 65, |
| 135863 | + /* 230 */ 30, 152, 49, 50, 34, 52, 90, 91, 92, 93, |
| 135864 | + /* 240 */ 94, 96, 97, 98, 97, 22, 230, 27, 48, 217, |
| 135865 | + /* 250 */ 27, 172, 173, 70, 71, 72, 73, 74, 75, 76, |
| 135866 | + /* 260 */ 77, 78, 79, 80, 81, 82, 172, 84, 85, 86, |
| 135867 | + /* 270 */ 87, 88, 89, 90, 91, 92, 93, 94, 19, 148, |
| 135868 | + /* 280 */ 149, 152, 218, 24, 152, 154, 207, 156, 172, 152, |
| 135869 | + /* 290 */ 22, 68, 27, 152, 163, 27, 164, 96, 97, 98, |
| 135870 | + /* 300 */ 99, 172, 173, 102, 103, 104, 169, 170, 49, 50, |
| 135871 | + /* 310 */ 90, 88, 89, 152, 113, 186, 96, 97, 98, 96, |
| 135872 | + /* 320 */ 97, 160, 57, 27, 101, 164, 137, 196, 139, 70, |
| 135873 | + /* 330 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 135874 | + /* 340 */ 81, 82, 11, 84, 85, 86, 87, 88, 89, 90, |
| 135875 | + /* 350 */ 91, 92, 93, 94, 19, 132, 133, 134, 23, 218, |
| 135876 | + /* 360 */ 152, 96, 97, 98, 96, 97, 98, 230, 99, 22, |
| 135877 | + /* 370 */ 152, 102, 103, 104, 27, 244, 152, 152, 27, 26, |
| 135878 | + /* 380 */ 152, 22, 113, 65, 49, 50, 27, 194, 195, 58, |
| 135879 | + /* 390 */ 172, 173, 96, 97, 98, 185, 65, 172, 173, 206, |
| 135880 | + /* 400 */ 172, 173, 190, 191, 186, 70, 71, 72, 73, 74, |
| 135881 | + /* 410 */ 75, 76, 77, 78, 79, 80, 81, 82, 175, 84, |
| 135882 | + /* 420 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 135883 | + /* 430 */ 19, 175, 207, 208, 23, 207, 208, 119, 120, 108, |
| 135884 | + /* 440 */ 109, 110, 27, 96, 97, 98, 116, 96, 97, 98, |
| 135885 | + /* 450 */ 152, 121, 152, 179, 180, 96, 97, 98, 250, 106, |
| 135886 | + /* 460 */ 49, 50, 188, 19, 221, 222, 223, 168, 169, 170, |
| 135887 | + /* 470 */ 172, 173, 172, 173, 250, 124, 172, 221, 222, 223, |
| 135888 | + /* 480 */ 26, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 135889 | + /* 490 */ 79, 80, 81, 82, 50, 84, 85, 86, 87, 88, |
| 135890 | + /* 500 */ 89, 90, 91, 92, 93, 94, 19, 207, 208, 12, |
| 135891 | + /* 510 */ 23, 96, 97, 98, 221, 222, 223, 194, 195, 152, |
| 135892 | + /* 520 */ 199, 23, 19, 225, 26, 28, 152, 152, 152, 206, |
| 135893 | + /* 530 */ 209, 164, 190, 191, 241, 152, 49, 50, 152, 124, |
| 135894 | + /* 540 */ 152, 44, 219, 46, 152, 21, 172, 173, 172, 173, |
| 135895 | + /* 550 */ 183, 107, 185, 16, 163, 58, 112, 70, 71, 72, |
| 135896 | + /* 560 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 135897 | + /* 570 */ 152, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 135898 | + /* 580 */ 93, 94, 19, 207, 130, 152, 23, 196, 64, 152, |
| 135899 | + /* 590 */ 172, 173, 22, 152, 24, 152, 98, 27, 61, 96, |
| 135900 | + /* 600 */ 63, 26, 211, 212, 186, 172, 173, 49, 50, 172, |
| 135901 | + /* 610 */ 173, 23, 49, 50, 26, 172, 173, 88, 89, 186, |
| 135902 | + /* 620 */ 24, 238, 124, 27, 238, 22, 23, 103, 187, 26, |
| 135903 | + /* 630 */ 152, 73, 74, 70, 71, 72, 73, 74, 75, 76, |
| 135904 | + /* 640 */ 77, 78, 79, 80, 81, 82, 152, 84, 85, 86, |
| 135905 | + /* 650 */ 87, 88, 89, 90, 91, 92, 93, 94, 19, 101, |
| 135906 | + /* 660 */ 152, 132, 23, 134, 140, 152, 12, 97, 36, 168, |
| 135907 | + /* 670 */ 169, 170, 69, 98, 152, 22, 23, 140, 50, 26, |
| 135908 | + /* 680 */ 172, 173, 28, 51, 152, 172, 173, 193, 49, 50, |
| 135909 | + /* 690 */ 22, 59, 24, 97, 172, 173, 152, 152, 44, 124, |
| 135910 | + /* 700 */ 46, 0, 1, 2, 172, 173, 22, 23, 19, 70, |
| 135911 | + /* 710 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 135912 | + /* 720 */ 81, 82, 69, 84, 85, 86, 87, 88, 89, 90, |
| 135913 | + /* 730 */ 91, 92, 93, 94, 152, 107, 152, 193, 49, 50, |
| 135914 | + /* 740 */ 181, 22, 23, 111, 108, 109, 110, 7, 8, 9, |
| 135915 | + /* 750 */ 16, 247, 248, 69, 172, 173, 172, 173, 152, 70, |
| 135916 | + /* 760 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 135917 | + /* 770 */ 81, 82, 152, 84, 85, 86, 87, 88, 89, 90, |
| 135918 | + /* 780 */ 91, 92, 93, 94, 19, 152, 242, 152, 69, 152, |
| 135919 | + /* 790 */ 166, 167, 172, 173, 32, 61, 152, 63, 152, 193, |
| 135920 | + /* 800 */ 152, 152, 152, 41, 152, 172, 173, 172, 173, 172, |
| 135921 | + /* 810 */ 173, 152, 152, 152, 49, 50, 172, 173, 172, 173, |
| 135922 | + /* 820 */ 172, 173, 172, 173, 172, 173, 132, 138, 134, 152, |
| 135923 | + /* 830 */ 152, 172, 173, 172, 173, 70, 71, 72, 73, 74, |
| 135924 | + /* 840 */ 75, 76, 77, 78, 79, 80, 81, 82, 152, 84, |
| 135925 | + /* 850 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 135926 | + /* 860 */ 19, 152, 22, 152, 195, 24, 152, 27, 172, 173, |
| 135927 | + /* 870 */ 193, 193, 152, 152, 152, 206, 152, 217, 152, 152, |
| 135928 | + /* 880 */ 152, 172, 173, 172, 173, 152, 172, 173, 152, 152, |
| 135929 | + /* 890 */ 49, 50, 172, 173, 172, 173, 172, 173, 172, 173, |
| 135930 | + /* 900 */ 172, 173, 152, 138, 152, 172, 173, 108, 109, 110, |
| 135931 | + /* 910 */ 19, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 135932 | + /* 920 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 135933 | + /* 930 */ 89, 90, 91, 92, 93, 94, 152, 97, 152, 152, |
| 135934 | + /* 940 */ 49, 50, 26, 193, 172, 173, 152, 152, 152, 146, |
| 135935 | + /* 950 */ 147, 132, 152, 134, 217, 181, 172, 173, 172, 173, |
| 135936 | + /* 960 */ 19, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 135937 | + /* 970 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 135938 | + /* 980 */ 89, 90, 91, 92, 93, 94, 152, 193, 152, 193, |
| 135939 | + /* 990 */ 49, 50, 181, 193, 172, 173, 166, 167, 245, 246, |
| 135940 | + /* 1000 */ 211, 212, 152, 22, 217, 152, 172, 173, 172, 173, |
| 135941 | + /* 1010 */ 19, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 135942 | + /* 1020 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 135943 | + /* 1030 */ 89, 90, 91, 92, 93, 94, 152, 187, 152, 123, |
| 135944 | + /* 1040 */ 49, 50, 23, 23, 23, 26, 26, 26, 23, 23, |
| 135945 | + /* 1050 */ 23, 26, 26, 26, 7, 8, 172, 173, 172, 173, |
| 135946 | + /* 1060 */ 19, 90, 71, 72, 73, 74, 75, 76, 77, 78, |
| 135947 | + /* 1070 */ 79, 80, 81, 82, 152, 84, 85, 86, 87, 88, |
| 135948 | + /* 1080 */ 89, 90, 91, 92, 93, 94, 152, 116, 152, 217, |
| 135949 | + /* 1090 */ 49, 50, 121, 23, 172, 173, 26, 100, 101, 27, |
| 135950 | + /* 1100 */ 101, 27, 23, 122, 152, 26, 172, 173, 172, 173, |
| 135951 | + /* 1110 */ 152, 112, 163, 72, 73, 74, 75, 76, 77, 78, |
| 135952 | + /* 1120 */ 79, 80, 81, 82, 163, 84, 85, 86, 87, 88, |
| 135953 | + /* 1130 */ 89, 90, 91, 92, 93, 94, 19, 20, 152, 22, |
| 135954 | + /* 1140 */ 23, 152, 163, 65, 27, 196, 163, 19, 20, 23, |
| 135955 | + /* 1150 */ 22, 213, 26, 19, 37, 27, 152, 196, 172, 173, |
| 135956 | + /* 1160 */ 152, 172, 173, 27, 23, 37, 152, 26, 152, 97, |
| 135957 | + /* 1170 */ 152, 97, 210, 56, 163, 196, 163, 163, 100, 196, |
| 135958 | + /* 1180 */ 172, 173, 65, 152, 56, 68, 172, 173, 172, 173, |
| 135959 | + /* 1190 */ 172, 173, 152, 65, 163, 163, 68, 23, 152, 234, |
| 135960 | + /* 1200 */ 26, 152, 152, 172, 173, 88, 89, 196, 152, 196, |
| 135961 | + /* 1210 */ 196, 152, 95, 96, 97, 98, 88, 89, 101, 152, |
| 135962 | + /* 1220 */ 152, 207, 208, 95, 96, 97, 98, 196, 196, 101, |
| 135963 | + /* 1230 */ 96, 233, 152, 97, 152, 152, 19, 20, 207, 22, |
| 135964 | + /* 1240 */ 152, 152, 152, 191, 27, 152, 152, 152, 152, 132, |
| 135965 | + /* 1250 */ 133, 134, 135, 136, 37, 152, 152, 152, 152, 152, |
| 135966 | + /* 1260 */ 132, 133, 134, 135, 136, 210, 197, 210, 210, 198, |
| 135967 | + /* 1270 */ 150, 184, 239, 56, 201, 214, 214, 201, 239, 180, |
| 135968 | + /* 1280 */ 214, 227, 198, 38, 176, 68, 175, 175, 175, 122, |
| 135969 | + /* 1290 */ 155, 200, 159, 19, 20, 40, 22, 159, 159, 22, |
| 135970 | + /* 1300 */ 70, 27, 130, 243, 240, 88, 89, 90, 189, 18, |
| 135971 | + /* 1310 */ 201, 37, 95, 96, 97, 98, 192, 5, 101, 192, |
| 135972 | + /* 1320 */ 220, 240, 10, 11, 12, 13, 14, 159, 18, 17, |
| 135973 | + /* 1330 */ 56, 158, 192, 201, 192, 220, 189, 189, 201, 159, |
| 135974 | + /* 1340 */ 158, 137, 68, 31, 45, 33, 236, 159, 159, 132, |
| 135975 | + /* 1350 */ 133, 134, 135, 136, 42, 158, 235, 22, 177, 159, |
| 135976 | + /* 1360 */ 158, 158, 88, 89, 159, 107, 174, 55, 177, 95, |
| 135977 | + /* 1370 */ 96, 97, 98, 174, 62, 101, 47, 65, 66, 106, |
| 135978 | + /* 1380 */ 174, 125, 19, 20, 174, 22, 177, 176, 174, 182, |
| 135979 | + /* 1390 */ 27, 216, 174, 174, 182, 107, 159, 22, 215, 215, |
| 135980 | + /* 1400 */ 37, 216, 216, 216, 137, 215, 132, 133, 134, 135, |
| 135981 | + /* 1410 */ 136, 215, 159, 177, 94, 177, 129, 224, 205, 56, |
| 135982 | + /* 1420 */ 226, 126, 128, 203, 229, 204, 114, 229, 127, 202, |
| 135983 | + /* 1430 */ 201, 68, 25, 162, 26, 13, 161, 153, 153, 6, |
| 135984 | + /* 1440 */ 151, 151, 178, 151, 151, 165, 165, 178, 165, 4, |
| 135985 | + /* 1450 */ 249, 88, 89, 141, 3, 142, 22, 249, 95, 96, |
| 135986 | + /* 1460 */ 97, 98, 246, 15, 101, 67, 16, 23, 120, 23, |
| 135987 | + /* 1470 */ 131, 111, 123, 20, 16, 125, 1, 123, 131, 78, |
| 135988 | + /* 1480 */ 78, 78, 78, 111, 96, 1, 122, 35, 5, 22, |
| 135989 | + /* 1490 */ 107, 140, 53, 53, 26, 132, 133, 134, 135, 136, |
| 135990 | + /* 1500 */ 43, 60, 107, 24, 112, 20, 19, 52, 22, 29, |
| 135991 | + /* 1510 */ 105, 22, 22, 52, 23, 22, 22, 52, 23, 23, |
| 135992 | + /* 1520 */ 39, 23, 116, 26, 22, 26, 23, 22, 96, 23, |
| 135993 | + /* 1530 */ 23, 122, 22, 24, 124, 35, 35, 26, 26, 35, |
| 135994 | + /* 1540 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22, |
| 135995 | + /* 1550 */ 122, 23, 26, 22, 24, 23, 22, 122, 23, 23, |
| 135996 | + /* 1560 */ 22, 15, 23, 1, 122, 122, |
| 135997 | +}; |
| 135998 | +#define YY_SHIFT_USE_DFLT (1566) |
| 135547 | 135999 | #define YY_SHIFT_COUNT (455) |
| 135548 | | -#define YY_SHIFT_MIN (-94) |
| 135549 | | -#define YY_SHIFT_MAX (1549) |
| 136000 | +#define YY_SHIFT_MIN (-114) |
| 136001 | +#define YY_SHIFT_MAX (1562) |
| 135550 | 136002 | static const short yy_shift_ofst[] = { |
| 135551 | | - /* 0 */ 40, 599, 904, 612, 760, 760, 760, 760, 725, -19, |
| 135552 | | - /* 10 */ 16, 16, 100, 760, 760, 760, 760, 760, 760, 760, |
| 135553 | | - /* 20 */ 876, 876, 573, 542, 719, 600, 61, 137, 172, 207, |
| 135554 | | - /* 30 */ 242, 277, 312, 347, 382, 417, 459, 459, 459, 459, |
| 135555 | | - /* 40 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, |
| 135556 | | - /* 50 */ 459, 459, 459, 494, 459, 529, 564, 564, 705, 760, |
| 135557 | | - /* 60 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135558 | | - /* 70 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135559 | | - /* 80 */ 760, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135560 | | - /* 90 */ 856, 760, 760, 760, 760, 760, 760, 760, 760, 760, |
| 135561 | | - /* 100 */ 760, 760, 760, 760, 987, 746, 746, 746, 746, 746, |
| 135562 | | - /* 110 */ 801, 23, 32, 949, 961, 979, 964, 964, 949, 73, |
| 135563 | | - /* 120 */ 113, -51, 1567, 1567, 1567, 536, 536, 536, 99, 99, |
| 135564 | | - /* 130 */ 813, 813, 667, 205, 240, 949, 949, 949, 949, 949, |
| 135565 | | - /* 140 */ 949, 949, 949, 949, 949, 949, 949, 949, 949, 949, |
| 135566 | | - /* 150 */ 949, 949, 949, 949, 949, 332, 1011, 422, 422, 113, |
| 135567 | | - /* 160 */ 30, 30, 30, 30, 30, 30, 1567, 1567, 1567, 922, |
| 135568 | | - /* 170 */ -94, -94, 384, 613, 828, 420, 765, 804, 851, 949, |
| 135569 | | - /* 180 */ 949, 949, 949, 949, 949, 949, 949, 949, 949, 949, |
| 135570 | | - /* 190 */ 949, 949, 949, 949, 949, 672, 672, 672, 949, 949, |
| 135571 | | - /* 200 */ 657, 949, 949, 949, -18, 949, 949, 994, 949, 949, |
| 135572 | | - /* 210 */ 949, 949, 949, 949, 949, 949, 949, 949, 772, 1118, |
| 135573 | | - /* 220 */ 712, 712, 712, 810, 45, 769, 1219, 1133, 418, 418, |
| 135574 | | - /* 230 */ 569, 1133, 569, 830, 607, 663, 882, 418, 693, 882, |
| 135575 | | - /* 240 */ 882, 848, 1152, 1065, 1286, 1238, 1238, 1287, 1287, 1238, |
| 135576 | | - /* 250 */ 1344, 1341, 1239, 1353, 1353, 1353, 1353, 1238, 1355, 1239, |
| 135577 | | - /* 260 */ 1344, 1341, 1341, 1239, 1238, 1355, 1243, 1312, 1238, 1238, |
| 135578 | | - /* 270 */ 1355, 1370, 1238, 1355, 1238, 1355, 1370, 1290, 1290, 1290, |
| 135579 | | - /* 280 */ 1327, 1370, 1290, 1301, 1290, 1327, 1290, 1290, 1284, 1304, |
| 135580 | | - /* 290 */ 1284, 1304, 1284, 1304, 1284, 1304, 1238, 1391, 1238, 1280, |
| 135581 | | - /* 300 */ 1370, 1366, 1366, 1370, 1302, 1308, 1310, 1309, 1239, 1414, |
| 135582 | | - /* 310 */ 1416, 1431, 1431, 1440, 1440, 1440, 1440, 1567, 1567, 1567, |
| 135583 | | - /* 320 */ 1567, 1567, 1567, 1567, 1567, 519, 978, 1210, 1225, 104, |
| 135584 | | - /* 330 */ 1141, 1189, 1246, 1248, 1251, 1252, 1253, 1257, 1258, 1273, |
| 135585 | | - /* 340 */ 1003, 1187, 1293, 1170, 1272, 1279, 1234, 1281, 1176, 1177, |
| 135586 | | - /* 350 */ 1289, 1242, 1195, 1453, 1455, 1437, 1319, 1447, 1369, 1452, |
| 135587 | | - /* 360 */ 1446, 1448, 1352, 1345, 1364, 1354, 1458, 1356, 1463, 1479, |
| 135588 | | - /* 370 */ 1359, 1357, 1449, 1450, 1454, 1456, 1372, 1428, 1421, 1367, |
| 135589 | | - /* 380 */ 1489, 1487, 1472, 1388, 1358, 1417, 1470, 1419, 1413, 1429, |
| 135590 | | - /* 390 */ 1395, 1480, 1483, 1486, 1394, 1402, 1488, 1430, 1490, 1491, |
| 135591 | | - /* 400 */ 1485, 1492, 1432, 1457, 1494, 1438, 1451, 1495, 1497, 1498, |
| 135592 | | - /* 410 */ 1496, 1407, 1502, 1503, 1505, 1499, 1406, 1506, 1507, 1475, |
| 135593 | | - /* 420 */ 1468, 1511, 1410, 1509, 1473, 1510, 1474, 1516, 1509, 1517, |
| 135594 | | - /* 430 */ 1518, 1519, 1520, 1521, 1523, 1532, 1524, 1526, 1525, 1527, |
| 135595 | | - /* 440 */ 1528, 1530, 1531, 1527, 1533, 1535, 1536, 1537, 1539, 1436, |
| 135596 | | - /* 450 */ 1441, 1442, 1443, 1543, 1547, 1549, |
| 136003 | + /* 0 */ 5, 1117, 1312, 1128, 1274, 1274, 1274, 1274, 61, -19, |
| 136004 | + /* 10 */ 57, 57, 183, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136005 | + /* 20 */ 66, 66, 201, -29, 331, 318, 133, 259, 335, 411, |
| 136006 | + /* 30 */ 487, 563, 639, 689, 765, 841, 891, 891, 891, 891, |
| 136007 | + /* 40 */ 891, 891, 891, 891, 891, 891, 891, 891, 891, 891, |
| 136008 | + /* 50 */ 891, 891, 891, 941, 891, 991, 1041, 1041, 1217, 1274, |
| 136009 | + /* 60 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136010 | + /* 70 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136011 | + /* 80 */ 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136012 | + /* 90 */ 1363, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, 1274, |
| 136013 | + /* 100 */ 1274, 1274, 1274, 1274, -70, -47, -47, -47, -47, -47, |
| 136014 | + /* 110 */ 24, 11, 146, 296, 524, 444, 529, 529, 296, 3, |
| 136015 | + /* 120 */ 2, -30, 1566, 1566, 1566, -17, -17, -17, 145, 145, |
| 136016 | + /* 130 */ 497, 497, 265, 603, 653, 296, 296, 296, 296, 296, |
| 136017 | + /* 140 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, |
| 136018 | + /* 150 */ 296, 296, 296, 296, 296, 701, 1078, 147, 147, 2, |
| 136019 | + /* 160 */ 164, 164, 164, 164, 164, 164, 1566, 1566, 1566, 223, |
| 136020 | + /* 170 */ 56, 56, 268, 269, 220, 347, 351, 415, 359, 296, |
| 136021 | + /* 180 */ 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, |
| 136022 | + /* 190 */ 296, 296, 296, 296, 296, 632, 632, 632, 296, 296, |
| 136023 | + /* 200 */ 498, 296, 296, 296, 570, 296, 296, 654, 296, 296, |
| 136024 | + /* 210 */ 296, 296, 296, 296, 296, 296, 296, 296, 636, 200, |
| 136025 | + /* 220 */ 596, 596, 596, 575, -114, 971, 740, 454, 503, 503, |
| 136026 | + /* 230 */ 1134, 454, 1134, 353, 588, 628, 762, 503, 189, 762, |
| 136027 | + /* 240 */ 762, 916, 330, 668, 1245, 1167, 1167, 1255, 1255, 1167, |
| 136028 | + /* 250 */ 1277, 1230, 1172, 1291, 1291, 1291, 1291, 1167, 1310, 1172, |
| 136029 | + /* 260 */ 1277, 1230, 1230, 1172, 1167, 1310, 1204, 1299, 1167, 1167, |
| 136030 | + /* 270 */ 1310, 1335, 1167, 1310, 1167, 1310, 1335, 1258, 1258, 1258, |
| 136031 | + /* 280 */ 1329, 1335, 1258, 1273, 1258, 1329, 1258, 1258, 1256, 1288, |
| 136032 | + /* 290 */ 1256, 1288, 1256, 1288, 1256, 1288, 1167, 1375, 1167, 1267, |
| 136033 | + /* 300 */ 1335, 1320, 1320, 1335, 1287, 1295, 1294, 1301, 1172, 1407, |
| 136034 | + /* 310 */ 1408, 1422, 1422, 1433, 1433, 1433, 1433, 1566, 1566, 1566, |
| 136035 | + /* 320 */ 1566, 1566, 1566, 1566, 1566, 558, 537, 684, 719, 734, |
| 136036 | + /* 330 */ 799, 840, 1019, 14, 1020, 1021, 1025, 1026, 1027, 1070, |
| 136037 | + /* 340 */ 1072, 997, 1047, 999, 1079, 1126, 1074, 1141, 694, 819, |
| 136038 | + /* 350 */ 1174, 1136, 981, 1445, 1451, 1434, 1313, 1448, 1398, 1450, |
| 136039 | + /* 360 */ 1444, 1446, 1348, 1339, 1360, 1349, 1453, 1350, 1458, 1475, |
| 136040 | + /* 370 */ 1354, 1347, 1401, 1402, 1403, 1404, 1372, 1388, 1452, 1364, |
| 136041 | + /* 380 */ 1484, 1483, 1467, 1383, 1351, 1439, 1468, 1440, 1441, 1457, |
| 136042 | + /* 390 */ 1395, 1479, 1485, 1487, 1392, 1405, 1486, 1455, 1489, 1490, |
| 136043 | + /* 400 */ 1491, 1493, 1461, 1480, 1494, 1465, 1481, 1495, 1496, 1498, |
| 136044 | + /* 410 */ 1497, 1406, 1502, 1503, 1505, 1499, 1409, 1506, 1507, 1432, |
| 136045 | + /* 420 */ 1500, 1510, 1410, 1511, 1501, 1512, 1504, 1517, 1511, 1518, |
| 136046 | + /* 430 */ 1519, 1520, 1521, 1522, 1524, 1533, 1525, 1527, 1509, 1526, |
| 136047 | + /* 440 */ 1528, 1531, 1530, 1526, 1532, 1534, 1535, 1536, 1538, 1428, |
| 136048 | + /* 450 */ 1435, 1442, 1443, 1539, 1546, 1562, |
| 135597 | 136049 | }; |
| 135598 | | -#define YY_REDUCE_USE_DFLT (-130) |
| 136050 | +#define YY_REDUCE_USE_DFLT (-174) |
| 135599 | 136051 | #define YY_REDUCE_COUNT (324) |
| 135600 | | -#define YY_REDUCE_MIN (-129) |
| 135601 | | -#define YY_REDUCE_MAX (1300) |
| 136052 | +#define YY_REDUCE_MIN (-173) |
| 136053 | +#define YY_REDUCE_MAX (1293) |
| 135602 | 136054 | static const short yy_reduce_ofst[] = { |
| 135603 | | - /* 0 */ -29, 566, 525, 605, -49, 307, 491, 533, 668, 435, |
| 135604 | | - /* 10 */ 601, 644, 148, 747, 786, 795, 419, 788, 827, 790, |
| 135605 | | - /* 20 */ 454, 832, 889, 495, 824, 734, 76, 76, 76, 76, |
| 135606 | | - /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, |
| 135607 | | - /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, |
| 135608 | | - /* 50 */ 76, 76, 76, 76, 76, 76, 76, 76, 783, 898, |
| 135609 | | - /* 60 */ 905, 907, 911, 921, 933, 936, 940, 943, 947, 950, |
| 135610 | | - /* 70 */ 952, 955, 958, 962, 965, 969, 974, 977, 980, 984, |
| 135611 | | - /* 80 */ 988, 991, 993, 996, 999, 1002, 1006, 1010, 1018, 1021, |
| 135612 | | - /* 90 */ 1024, 1028, 1032, 1034, 1036, 1040, 1046, 1051, 1058, 1062, |
| 135613 | | - /* 100 */ 1064, 1068, 1070, 1073, 76, 76, 76, 76, 76, 76, |
| 135614 | | - /* 110 */ 76, 76, 76, 855, 36, 523, 235, 416, 777, 76, |
| 135615 | | - /* 120 */ 278, 76, 76, 76, 76, 700, 700, 700, 150, 220, |
| 135616 | | - /* 130 */ 147, 217, 221, 306, 306, 611, 5, 535, 556, 620, |
| 135617 | | - /* 140 */ 720, 872, 897, 116, 864, 349, 1035, 1037, 404, 1047, |
| 135618 | | - /* 150 */ 992, -129, 1050, 492, 62, 722, 879, 1072, 1089, 808, |
| 135619 | | - /* 160 */ 1066, 1094, 1095, 1096, 1097, 1098, 776, 1054, 557, 57, |
| 135620 | | - /* 170 */ 112, 131, 167, 182, 250, 272, 291, 331, 364, 438, |
| 135621 | | - /* 180 */ 497, 517, 591, 653, 690, 739, 775, 798, 892, 908, |
| 135622 | | - /* 190 */ 924, 930, 1015, 1063, 1069, 355, 784, 799, 981, 1101, |
| 135623 | | - /* 200 */ 926, 1151, 1161, 1162, 945, 1164, 1166, 1128, 1168, 1171, |
| 135624 | | - /* 210 */ 1172, 250, 1173, 1174, 1175, 1178, 1180, 1181, 1088, 1102, |
| 135625 | | - /* 220 */ 1119, 1124, 1126, 926, 1131, 1139, 1188, 1140, 1129, 1130, |
| 135626 | | - /* 230 */ 1103, 1144, 1107, 1179, 1156, 1167, 1182, 1134, 1122, 1183, |
| 135627 | | - /* 240 */ 1184, 1150, 1153, 1197, 1111, 1202, 1203, 1123, 1125, 1205, |
| 135628 | | - /* 250 */ 1147, 1185, 1169, 1186, 1190, 1191, 1192, 1213, 1217, 1193, |
| 135629 | | - /* 260 */ 1157, 1196, 1198, 1194, 1220, 1218, 1145, 1154, 1229, 1231, |
| 135630 | | - /* 270 */ 1233, 1216, 1237, 1240, 1241, 1244, 1222, 1227, 1230, 1232, |
| 135631 | | - /* 280 */ 1223, 1235, 1236, 1245, 1249, 1226, 1250, 1254, 1199, 1201, |
| 135632 | | - /* 290 */ 1204, 1207, 1209, 1211, 1214, 1212, 1255, 1208, 1259, 1215, |
| 135633 | | - /* 300 */ 1256, 1200, 1206, 1260, 1247, 1261, 1263, 1262, 1266, 1278, |
| 135634 | | - /* 310 */ 1282, 1292, 1294, 1297, 1298, 1299, 1300, 1221, 1224, 1228, |
| 135635 | | - /* 320 */ 1288, 1291, 1276, 1277, 1295, |
| 136055 | + /* 0 */ -119, 1014, 131, 1031, -12, 225, 228, 300, -40, -45, |
| 136056 | + /* 10 */ 243, 256, 293, 129, 218, 418, 79, 376, 433, 298, |
| 136057 | + /* 20 */ 16, 137, 367, 323, -38, 391, -173, -173, -173, -173, |
| 136058 | + /* 30 */ -173, -173, -173, -173, -173, -173, -173, -173, -173, -173, |
| 136059 | + /* 40 */ -173, -173, -173, -173, -173, -173, -173, -173, -173, -173, |
| 136060 | + /* 50 */ -173, -173, -173, -173, -173, -173, -173, -173, 374, 437, |
| 136061 | + /* 60 */ 443, 508, 513, 522, 532, 582, 584, 620, 633, 635, |
| 136062 | + /* 70 */ 637, 644, 646, 648, 650, 652, 659, 661, 696, 709, |
| 136063 | + /* 80 */ 711, 714, 720, 722, 724, 726, 728, 733, 772, 784, |
| 136064 | + /* 90 */ 786, 822, 834, 836, 884, 886, 922, 934, 936, 986, |
| 136065 | + /* 100 */ 989, 1008, 1016, 1018, -173, -173, -173, -173, -173, -173, |
| 136066 | + /* 110 */ -173, -173, -173, 544, -37, 274, 299, 501, 161, -173, |
| 136067 | + /* 120 */ 193, -173, -173, -173, -173, 22, 22, 22, 64, 141, |
| 136068 | + /* 130 */ 212, 342, 208, 504, 504, 132, 494, 606, 677, 678, |
| 136069 | + /* 140 */ 750, 794, 796, -58, 32, 383, 660, 737, 386, 787, |
| 136070 | + /* 150 */ 800, 441, 872, 224, 850, 803, 949, 624, 830, 669, |
| 136071 | + /* 160 */ 961, 979, 983, 1011, 1013, 1032, 753, 789, 321, 94, |
| 136072 | + /* 170 */ 116, 304, 375, 210, 388, 392, 478, 545, 649, 721, |
| 136073 | + /* 180 */ 727, 736, 752, 795, 853, 952, 958, 1004, 1040, 1046, |
| 136074 | + /* 190 */ 1049, 1050, 1056, 1059, 1067, 559, 774, 811, 1068, 1080, |
| 136075 | + /* 200 */ 938, 1082, 1083, 1088, 962, 1089, 1090, 1052, 1093, 1094, |
| 136076 | + /* 210 */ 1095, 388, 1096, 1103, 1104, 1105, 1106, 1107, 965, 998, |
| 136077 | + /* 220 */ 1055, 1057, 1058, 938, 1069, 1071, 1120, 1073, 1061, 1062, |
| 136078 | + /* 230 */ 1033, 1076, 1039, 1108, 1087, 1099, 1111, 1066, 1054, 1112, |
| 136079 | + /* 240 */ 1113, 1091, 1084, 1135, 1060, 1133, 1138, 1064, 1081, 1139, |
| 136080 | + /* 250 */ 1100, 1119, 1109, 1124, 1127, 1140, 1142, 1168, 1173, 1132, |
| 136081 | + /* 260 */ 1115, 1147, 1148, 1137, 1180, 1182, 1110, 1121, 1188, 1189, |
| 136082 | + /* 270 */ 1197, 1181, 1200, 1202, 1205, 1203, 1191, 1192, 1199, 1206, |
| 136083 | + /* 280 */ 1207, 1209, 1210, 1211, 1214, 1212, 1218, 1219, 1175, 1183, |
| 136084 | + /* 290 */ 1185, 1184, 1186, 1190, 1187, 1196, 1237, 1193, 1253, 1194, |
| 136085 | + /* 300 */ 1236, 1195, 1198, 1238, 1213, 1221, 1220, 1227, 1229, 1271, |
| 136086 | + /* 310 */ 1275, 1284, 1285, 1289, 1290, 1292, 1293, 1201, 1208, 1216, |
| 136087 | + /* 320 */ 1280, 1281, 1264, 1269, 1283, |
| 135636 | 136088 | }; |
| 135637 | 136089 | static const YYACTIONTYPE yy_default[] = { |
| 135638 | 136090 | /* 0 */ 1280, 1270, 1270, 1270, 1202, 1202, 1202, 1202, 1270, 1096, |
| 135639 | 136091 | /* 10 */ 1125, 1125, 1254, 1332, 1332, 1332, 1332, 1332, 1332, 1201, |
| 135640 | 136092 | /* 20 */ 1332, 1332, 1332, 1332, 1270, 1100, 1131, 1332, 1332, 1332, |
| | @@ -135700,104 +136152,77 @@ |
| 135700 | 136152 | */ |
| 135701 | 136153 | #ifdef YYFALLBACK |
| 135702 | 136154 | static const YYCODETYPE yyFallback[] = { |
| 135703 | 136155 | 0, /* $ => nothing */ |
| 135704 | 136156 | 0, /* SEMI => nothing */ |
| 135705 | | - 55, /* EXPLAIN => ID */ |
| 135706 | | - 55, /* QUERY => ID */ |
| 135707 | | - 55, /* PLAN => ID */ |
| 135708 | | - 55, /* BEGIN => ID */ |
| 136157 | + 27, /* EXPLAIN => ID */ |
| 136158 | + 27, /* QUERY => ID */ |
| 136159 | + 27, /* PLAN => ID */ |
| 136160 | + 27, /* BEGIN => ID */ |
| 135709 | 136161 | 0, /* TRANSACTION => nothing */ |
| 135710 | | - 55, /* DEFERRED => ID */ |
| 135711 | | - 55, /* IMMEDIATE => ID */ |
| 135712 | | - 55, /* EXCLUSIVE => ID */ |
| 136162 | + 27, /* DEFERRED => ID */ |
| 136163 | + 27, /* IMMEDIATE => ID */ |
| 136164 | + 27, /* EXCLUSIVE => ID */ |
| 135713 | 136165 | 0, /* COMMIT => nothing */ |
| 135714 | | - 55, /* END => ID */ |
| 135715 | | - 55, /* ROLLBACK => ID */ |
| 135716 | | - 55, /* SAVEPOINT => ID */ |
| 135717 | | - 55, /* RELEASE => ID */ |
| 136166 | + 27, /* END => ID */ |
| 136167 | + 27, /* ROLLBACK => ID */ |
| 136168 | + 27, /* SAVEPOINT => ID */ |
| 136169 | + 27, /* RELEASE => ID */ |
| 135718 | 136170 | 0, /* TO => nothing */ |
| 135719 | 136171 | 0, /* TABLE => nothing */ |
| 135720 | 136172 | 0, /* CREATE => nothing */ |
| 135721 | | - 55, /* IF => ID */ |
| 136173 | + 27, /* IF => ID */ |
| 135722 | 136174 | 0, /* NOT => nothing */ |
| 135723 | 136175 | 0, /* EXISTS => nothing */ |
| 135724 | | - 55, /* TEMP => ID */ |
| 136176 | + 27, /* TEMP => ID */ |
| 135725 | 136177 | 0, /* LP => nothing */ |
| 135726 | 136178 | 0, /* RP => nothing */ |
| 135727 | 136179 | 0, /* AS => nothing */ |
| 135728 | | - 55, /* WITHOUT => ID */ |
| 136180 | + 27, /* WITHOUT => ID */ |
| 135729 | 136181 | 0, /* COMMA => nothing */ |
| 135730 | | - 0, /* OR => nothing */ |
| 135731 | | - 0, /* AND => nothing */ |
| 135732 | | - 0, /* IS => nothing */ |
| 135733 | | - 55, /* MATCH => ID */ |
| 135734 | | - 55, /* LIKE_KW => ID */ |
| 135735 | | - 0, /* BETWEEN => nothing */ |
| 135736 | | - 0, /* IN => nothing */ |
| 135737 | | - 0, /* ISNULL => nothing */ |
| 135738 | | - 0, /* NOTNULL => nothing */ |
| 135739 | | - 0, /* NE => nothing */ |
| 135740 | | - 0, /* EQ => nothing */ |
| 135741 | | - 0, /* GT => nothing */ |
| 135742 | | - 0, /* LE => nothing */ |
| 135743 | | - 0, /* LT => nothing */ |
| 135744 | | - 0, /* GE => nothing */ |
| 135745 | | - 0, /* ESCAPE => nothing */ |
| 135746 | | - 0, /* BITAND => nothing */ |
| 135747 | | - 0, /* BITOR => nothing */ |
| 135748 | | - 0, /* LSHIFT => nothing */ |
| 135749 | | - 0, /* RSHIFT => nothing */ |
| 135750 | | - 0, /* PLUS => nothing */ |
| 135751 | | - 0, /* MINUS => nothing */ |
| 135752 | | - 0, /* STAR => nothing */ |
| 135753 | | - 0, /* SLASH => nothing */ |
| 135754 | | - 0, /* REM => nothing */ |
| 135755 | | - 0, /* CONCAT => nothing */ |
| 135756 | | - 0, /* COLLATE => nothing */ |
| 135757 | | - 0, /* BITNOT => nothing */ |
| 135758 | 136182 | 0, /* ID => nothing */ |
| 135759 | | - 0, /* INDEXED => nothing */ |
| 135760 | | - 55, /* ABORT => ID */ |
| 135761 | | - 55, /* ACTION => ID */ |
| 135762 | | - 55, /* AFTER => ID */ |
| 135763 | | - 55, /* ANALYZE => ID */ |
| 135764 | | - 55, /* ASC => ID */ |
| 135765 | | - 55, /* ATTACH => ID */ |
| 135766 | | - 55, /* BEFORE => ID */ |
| 135767 | | - 55, /* BY => ID */ |
| 135768 | | - 55, /* CASCADE => ID */ |
| 135769 | | - 55, /* CAST => ID */ |
| 135770 | | - 55, /* COLUMNKW => ID */ |
| 135771 | | - 55, /* CONFLICT => ID */ |
| 135772 | | - 55, /* DATABASE => ID */ |
| 135773 | | - 55, /* DESC => ID */ |
| 135774 | | - 55, /* DETACH => ID */ |
| 135775 | | - 55, /* EACH => ID */ |
| 135776 | | - 55, /* FAIL => ID */ |
| 135777 | | - 55, /* FOR => ID */ |
| 135778 | | - 55, /* IGNORE => ID */ |
| 135779 | | - 55, /* INITIALLY => ID */ |
| 135780 | | - 55, /* INSTEAD => ID */ |
| 135781 | | - 55, /* NO => ID */ |
| 135782 | | - 55, /* KEY => ID */ |
| 135783 | | - 55, /* OF => ID */ |
| 135784 | | - 55, /* OFFSET => ID */ |
| 135785 | | - 55, /* PRAGMA => ID */ |
| 135786 | | - 55, /* RAISE => ID */ |
| 135787 | | - 55, /* RECURSIVE => ID */ |
| 135788 | | - 55, /* REPLACE => ID */ |
| 135789 | | - 55, /* RESTRICT => ID */ |
| 135790 | | - 55, /* ROW => ID */ |
| 135791 | | - 55, /* TRIGGER => ID */ |
| 135792 | | - 55, /* VACUUM => ID */ |
| 135793 | | - 55, /* VIEW => ID */ |
| 135794 | | - 55, /* VIRTUAL => ID */ |
| 135795 | | - 55, /* WITH => ID */ |
| 135796 | | - 55, /* REINDEX => ID */ |
| 135797 | | - 55, /* RENAME => ID */ |
| 135798 | | - 55, /* CTIME_KW => ID */ |
| 136183 | + 27, /* ABORT => ID */ |
| 136184 | + 27, /* ACTION => ID */ |
| 136185 | + 27, /* AFTER => ID */ |
| 136186 | + 27, /* ANALYZE => ID */ |
| 136187 | + 27, /* ASC => ID */ |
| 136188 | + 27, /* ATTACH => ID */ |
| 136189 | + 27, /* BEFORE => ID */ |
| 136190 | + 27, /* BY => ID */ |
| 136191 | + 27, /* CASCADE => ID */ |
| 136192 | + 27, /* CAST => ID */ |
| 136193 | + 27, /* COLUMNKW => ID */ |
| 136194 | + 27, /* CONFLICT => ID */ |
| 136195 | + 27, /* DATABASE => ID */ |
| 136196 | + 27, /* DESC => ID */ |
| 136197 | + 27, /* DETACH => ID */ |
| 136198 | + 27, /* EACH => ID */ |
| 136199 | + 27, /* FAIL => ID */ |
| 136200 | + 27, /* FOR => ID */ |
| 136201 | + 27, /* IGNORE => ID */ |
| 136202 | + 27, /* INITIALLY => ID */ |
| 136203 | + 27, /* INSTEAD => ID */ |
| 136204 | + 27, /* LIKE_KW => ID */ |
| 136205 | + 27, /* MATCH => ID */ |
| 136206 | + 27, /* NO => ID */ |
| 136207 | + 27, /* KEY => ID */ |
| 136208 | + 27, /* OF => ID */ |
| 136209 | + 27, /* OFFSET => ID */ |
| 136210 | + 27, /* PRAGMA => ID */ |
| 136211 | + 27, /* RAISE => ID */ |
| 136212 | + 27, /* RECURSIVE => ID */ |
| 136213 | + 27, /* REPLACE => ID */ |
| 136214 | + 27, /* RESTRICT => ID */ |
| 136215 | + 27, /* ROW => ID */ |
| 136216 | + 27, /* TRIGGER => ID */ |
| 136217 | + 27, /* VACUUM => ID */ |
| 136218 | + 27, /* VIEW => ID */ |
| 136219 | + 27, /* VIRTUAL => ID */ |
| 136220 | + 27, /* WITH => ID */ |
| 136221 | + 27, /* REINDEX => ID */ |
| 136222 | + 27, /* RENAME => ID */ |
| 136223 | + 27, /* CTIME_KW => ID */ |
| 135799 | 136224 | }; |
| 135800 | 136225 | #endif /* YYFALLBACK */ |
| 135801 | 136226 | |
| 135802 | 136227 | /* The following structure represents a single element of the |
| 135803 | 136228 | ** parser's stack. Information stored includes: |
| | @@ -135885,29 +136310,29 @@ |
| 135885 | 136310 | "PLAN", "BEGIN", "TRANSACTION", "DEFERRED", |
| 135886 | 136311 | "IMMEDIATE", "EXCLUSIVE", "COMMIT", "END", |
| 135887 | 136312 | "ROLLBACK", "SAVEPOINT", "RELEASE", "TO", |
| 135888 | 136313 | "TABLE", "CREATE", "IF", "NOT", |
| 135889 | 136314 | "EXISTS", "TEMP", "LP", "RP", |
| 135890 | | - "AS", "WITHOUT", "COMMA", "OR", |
| 135891 | | - "AND", "IS", "MATCH", "LIKE_KW", |
| 135892 | | - "BETWEEN", "IN", "ISNULL", "NOTNULL", |
| 135893 | | - "NE", "EQ", "GT", "LE", |
| 135894 | | - "LT", "GE", "ESCAPE", "BITAND", |
| 135895 | | - "BITOR", "LSHIFT", "RSHIFT", "PLUS", |
| 135896 | | - "MINUS", "STAR", "SLASH", "REM", |
| 135897 | | - "CONCAT", "COLLATE", "BITNOT", "ID", |
| 135898 | | - "INDEXED", "ABORT", "ACTION", "AFTER", |
| 135899 | | - "ANALYZE", "ASC", "ATTACH", "BEFORE", |
| 135900 | | - "BY", "CASCADE", "CAST", "COLUMNKW", |
| 135901 | | - "CONFLICT", "DATABASE", "DESC", "DETACH", |
| 135902 | | - "EACH", "FAIL", "FOR", "IGNORE", |
| 135903 | | - "INITIALLY", "INSTEAD", "NO", "KEY", |
| 135904 | | - "OF", "OFFSET", "PRAGMA", "RAISE", |
| 135905 | | - "RECURSIVE", "REPLACE", "RESTRICT", "ROW", |
| 135906 | | - "TRIGGER", "VACUUM", "VIEW", "VIRTUAL", |
| 135907 | | - "WITH", "REINDEX", "RENAME", "CTIME_KW", |
| 135908 | | - "ANY", "STRING", "JOIN_KW", "CONSTRAINT", |
| 136315 | + "AS", "WITHOUT", "COMMA", "ID", |
| 136316 | + "ABORT", "ACTION", "AFTER", "ANALYZE", |
| 136317 | + "ASC", "ATTACH", "BEFORE", "BY", |
| 136318 | + "CASCADE", "CAST", "COLUMNKW", "CONFLICT", |
| 136319 | + "DATABASE", "DESC", "DETACH", "EACH", |
| 136320 | + "FAIL", "FOR", "IGNORE", "INITIALLY", |
| 136321 | + "INSTEAD", "LIKE_KW", "MATCH", "NO", |
| 136322 | + "KEY", "OF", "OFFSET", "PRAGMA", |
| 136323 | + "RAISE", "RECURSIVE", "REPLACE", "RESTRICT", |
| 136324 | + "ROW", "TRIGGER", "VACUUM", "VIEW", |
| 136325 | + "VIRTUAL", "WITH", "REINDEX", "RENAME", |
| 136326 | + "CTIME_KW", "ANY", "OR", "AND", |
| 136327 | + "IS", "BETWEEN", "IN", "ISNULL", |
| 136328 | + "NOTNULL", "NE", "EQ", "GT", |
| 136329 | + "LE", "LT", "GE", "ESCAPE", |
| 136330 | + "BITAND", "BITOR", "LSHIFT", "RSHIFT", |
| 136331 | + "PLUS", "MINUS", "STAR", "SLASH", |
| 136332 | + "REM", "CONCAT", "COLLATE", "BITNOT", |
| 136333 | + "INDEXED", "STRING", "JOIN_KW", "CONSTRAINT", |
| 135909 | 136334 | "DEFAULT", "NULL", "PRIMARY", "UNIQUE", |
| 135910 | 136335 | "CHECK", "REFERENCES", "AUTOINCR", "ON", |
| 135911 | 136336 | "INSERT", "DELETE", "UPDATE", "SET", |
| 135912 | 136337 | "DEFERRABLE", "FOREIGN", "DROP", "UNION", |
| 135913 | 136338 | "ALL", "EXCEPT", "INTERSECT", "SELECT", |
| | @@ -139502,11 +139927,11 @@ |
| 139502 | 139927 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
| 139503 | 139928 | sqlite3DbFree(db, pParse->pVList); |
| 139504 | 139929 | while( pParse->pAinc ){ |
| 139505 | 139930 | AutoincInfo *p = pParse->pAinc; |
| 139506 | 139931 | pParse->pAinc = p->pNext; |
| 139507 | | - sqlite3DbFree(db, p); |
| 139932 | + sqlite3DbFreeNN(db, p); |
| 139508 | 139933 | } |
| 139509 | 139934 | while( pParse->pZombieTab ){ |
| 139510 | 139935 | Table *p = pParse->pZombieTab; |
| 139511 | 139936 | pParse->pZombieTab = p->pNextZombie; |
| 139512 | 139937 | sqlite3DeleteTable(db, p); |
| | @@ -145610,12 +146035,12 @@ |
| 145610 | 146035 | *v = b; |
| 145611 | 146036 | return (int)(p - pStart); |
| 145612 | 146037 | } |
| 145613 | 146038 | |
| 145614 | 146039 | /* |
| 145615 | | -** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to a |
| 145616 | | -** 32-bit integer before it is returned. |
| 146040 | +** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to |
| 146041 | +** a non-negative 32-bit integer before it is returned. |
| 145617 | 146042 | */ |
| 145618 | 146043 | SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){ |
| 145619 | 146044 | u32 a; |
| 145620 | 146045 | |
| 145621 | 146046 | #ifndef fts3GetVarint32 |
| | @@ -145627,11 +146052,13 @@ |
| 145627 | 146052 | |
| 145628 | 146053 | GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *pi, 2); |
| 145629 | 146054 | GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *pi, 3); |
| 145630 | 146055 | GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4); |
| 145631 | 146056 | a = (a & 0x0FFFFFFF ); |
| 145632 | | - *pi = (int)(a | ((u32)(*p & 0x0F) << 28)); |
| 146057 | + *pi = (int)(a | ((u32)(*p & 0x07) << 28)); |
| 146058 | + assert( 0==(a & 0x80000000) ); |
| 146059 | + assert( *pi>=0 ); |
| 145633 | 146060 | return 5; |
| 145634 | 146061 | } |
| 145635 | 146062 | |
| 145636 | 146063 | /* |
| 145637 | 146064 | ** Return the number of bytes required to encode v as a varint |
| | @@ -146457,69 +146884,70 @@ |
| 146457 | 146884 | struct Fts4Option *pOp = &aFts4Opt[iOpt]; |
| 146458 | 146885 | if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){ |
| 146459 | 146886 | break; |
| 146460 | 146887 | } |
| 146461 | 146888 | } |
| 146462 | | - if( iOpt==SizeofArray(aFts4Opt) ){ |
| 146463 | | - sqlite3Fts3ErrMsg(pzErr, "unrecognized parameter: %s", z); |
| 146464 | | - rc = SQLITE_ERROR; |
| 146465 | | - }else{ |
| 146466 | | - switch( iOpt ){ |
| 146467 | | - case 0: /* MATCHINFO */ |
| 146468 | | - if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "fts3", 4) ){ |
| 146469 | | - sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo: %s", zVal); |
| 146470 | | - rc = SQLITE_ERROR; |
| 146471 | | - } |
| 146472 | | - bNoDocsize = 1; |
| 146473 | | - break; |
| 146474 | | - |
| 146475 | | - case 1: /* PREFIX */ |
| 146476 | | - sqlite3_free(zPrefix); |
| 146477 | | - zPrefix = zVal; |
| 146478 | | - zVal = 0; |
| 146479 | | - break; |
| 146480 | | - |
| 146481 | | - case 2: /* COMPRESS */ |
| 146482 | | - sqlite3_free(zCompress); |
| 146483 | | - zCompress = zVal; |
| 146484 | | - zVal = 0; |
| 146485 | | - break; |
| 146486 | | - |
| 146487 | | - case 3: /* UNCOMPRESS */ |
| 146488 | | - sqlite3_free(zUncompress); |
| 146489 | | - zUncompress = zVal; |
| 146490 | | - zVal = 0; |
| 146491 | | - break; |
| 146492 | | - |
| 146493 | | - case 4: /* ORDER */ |
| 146494 | | - if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3)) |
| 146495 | | - && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4)) |
| 146496 | | - ){ |
| 146497 | | - sqlite3Fts3ErrMsg(pzErr, "unrecognized order: %s", zVal); |
| 146498 | | - rc = SQLITE_ERROR; |
| 146499 | | - } |
| 146500 | | - bDescIdx = (zVal[0]=='d' || zVal[0]=='D'); |
| 146501 | | - break; |
| 146502 | | - |
| 146503 | | - case 5: /* CONTENT */ |
| 146504 | | - sqlite3_free(zContent); |
| 146505 | | - zContent = zVal; |
| 146506 | | - zVal = 0; |
| 146507 | | - break; |
| 146508 | | - |
| 146509 | | - case 6: /* LANGUAGEID */ |
| 146510 | | - assert( iOpt==6 ); |
| 146511 | | - sqlite3_free(zLanguageid); |
| 146512 | | - zLanguageid = zVal; |
| 146513 | | - zVal = 0; |
| 146514 | | - break; |
| 146515 | | - |
| 146516 | | - case 7: /* NOTINDEXED */ |
| 146517 | | - azNotindexed[nNotindexed++] = zVal; |
| 146518 | | - zVal = 0; |
| 146519 | | - break; |
| 146520 | | - } |
| 146889 | + switch( iOpt ){ |
| 146890 | + case 0: /* MATCHINFO */ |
| 146891 | + if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "fts3", 4) ){ |
| 146892 | + sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo: %s", zVal); |
| 146893 | + rc = SQLITE_ERROR; |
| 146894 | + } |
| 146895 | + bNoDocsize = 1; |
| 146896 | + break; |
| 146897 | + |
| 146898 | + case 1: /* PREFIX */ |
| 146899 | + sqlite3_free(zPrefix); |
| 146900 | + zPrefix = zVal; |
| 146901 | + zVal = 0; |
| 146902 | + break; |
| 146903 | + |
| 146904 | + case 2: /* COMPRESS */ |
| 146905 | + sqlite3_free(zCompress); |
| 146906 | + zCompress = zVal; |
| 146907 | + zVal = 0; |
| 146908 | + break; |
| 146909 | + |
| 146910 | + case 3: /* UNCOMPRESS */ |
| 146911 | + sqlite3_free(zUncompress); |
| 146912 | + zUncompress = zVal; |
| 146913 | + zVal = 0; |
| 146914 | + break; |
| 146915 | + |
| 146916 | + case 4: /* ORDER */ |
| 146917 | + if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3)) |
| 146918 | + && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4)) |
| 146919 | + ){ |
| 146920 | + sqlite3Fts3ErrMsg(pzErr, "unrecognized order: %s", zVal); |
| 146921 | + rc = SQLITE_ERROR; |
| 146922 | + } |
| 146923 | + bDescIdx = (zVal[0]=='d' || zVal[0]=='D'); |
| 146924 | + break; |
| 146925 | + |
| 146926 | + case 5: /* CONTENT */ |
| 146927 | + sqlite3_free(zContent); |
| 146928 | + zContent = zVal; |
| 146929 | + zVal = 0; |
| 146930 | + break; |
| 146931 | + |
| 146932 | + case 6: /* LANGUAGEID */ |
| 146933 | + assert( iOpt==6 ); |
| 146934 | + sqlite3_free(zLanguageid); |
| 146935 | + zLanguageid = zVal; |
| 146936 | + zVal = 0; |
| 146937 | + break; |
| 146938 | + |
| 146939 | + case 7: /* NOTINDEXED */ |
| 146940 | + azNotindexed[nNotindexed++] = zVal; |
| 146941 | + zVal = 0; |
| 146942 | + break; |
| 146943 | + |
| 146944 | + default: |
| 146945 | + assert( iOpt==SizeofArray(aFts4Opt) ); |
| 146946 | + sqlite3Fts3ErrMsg(pzErr, "unrecognized parameter: %s", z); |
| 146947 | + rc = SQLITE_ERROR; |
| 146948 | + break; |
| 146521 | 146949 | } |
| 146522 | 146950 | sqlite3_free(zVal); |
| 146523 | 146951 | } |
| 146524 | 146952 | } |
| 146525 | 146953 | |
| | @@ -147084,11 +147512,12 @@ |
| 147084 | 147512 | zCsr += fts3GetVarint32(zCsr, &nPrefix); |
| 147085 | 147513 | } |
| 147086 | 147514 | isFirstTerm = 0; |
| 147087 | 147515 | zCsr += fts3GetVarint32(zCsr, &nSuffix); |
| 147088 | 147516 | |
| 147089 | | - if( nPrefix<0 || nSuffix<0 || &zCsr[nSuffix]>zEnd ){ |
| 147517 | + assert( nPrefix>=0 && nSuffix>=0 ); |
| 147518 | + if( &zCsr[nSuffix]>zEnd ){ |
| 147090 | 147519 | rc = FTS_CORRUPT_VTAB; |
| 147091 | 147520 | goto finish_scan; |
| 147092 | 147521 | } |
| 147093 | 147522 | if( nPrefix+nSuffix>nAlloc ){ |
| 147094 | 147523 | char *zNew; |
| | @@ -147894,11 +148323,11 @@ |
| 147894 | 148323 | bWritten = 1; |
| 147895 | 148324 | } |
| 147896 | 148325 | fts3ColumnlistCopy(0, &p); |
| 147897 | 148326 | } |
| 147898 | 148327 | |
| 147899 | | - while( p<pEnd && *p==0x01 ){ |
| 148328 | + while( p<pEnd ){ |
| 147900 | 148329 | sqlite3_int64 iCol; |
| 147901 | 148330 | p++; |
| 147902 | 148331 | p += sqlite3Fts3GetVarint(p, &iCol); |
| 147903 | 148332 | if( *p==0x02 ){ |
| 147904 | 148333 | if( bWritten==0 ){ |
| | @@ -148574,37 +149003,42 @@ |
| 148574 | 149003 | Fts3Table *p = (Fts3Table *)pCursor->pVtab; |
| 148575 | 149004 | |
| 148576 | 149005 | /* The column value supplied by SQLite must be in range. */ |
| 148577 | 149006 | assert( iCol>=0 && iCol<=p->nColumn+2 ); |
| 148578 | 149007 | |
| 148579 | | - if( iCol==p->nColumn+1 ){ |
| 148580 | | - /* This call is a request for the "docid" column. Since "docid" is an |
| 148581 | | - ** alias for "rowid", use the xRowid() method to obtain the value. |
| 148582 | | - */ |
| 148583 | | - sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| 148584 | | - }else if( iCol==p->nColumn ){ |
| 148585 | | - /* The extra column whose name is the same as the table. |
| 148586 | | - ** Return a blob which is a pointer to the cursor. */ |
| 148587 | | - sqlite3_result_blob(pCtx, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT); |
| 148588 | | - }else if( iCol==p->nColumn+2 && pCsr->pExpr ){ |
| 148589 | | - sqlite3_result_int64(pCtx, pCsr->iLangid); |
| 148590 | | - }else{ |
| 148591 | | - /* The requested column is either a user column (one that contains |
| 148592 | | - ** indexed data), or the language-id column. */ |
| 148593 | | - rc = fts3CursorSeek(0, pCsr); |
| 148594 | | - |
| 148595 | | - if( rc==SQLITE_OK ){ |
| 148596 | | - if( iCol==p->nColumn+2 ){ |
| 148597 | | - int iLangid = 0; |
| 148598 | | - if( p->zLanguageid ){ |
| 148599 | | - iLangid = sqlite3_column_int(pCsr->pStmt, p->nColumn+1); |
| 148600 | | - } |
| 148601 | | - sqlite3_result_int(pCtx, iLangid); |
| 148602 | | - }else if( sqlite3_data_count(pCsr->pStmt)>(iCol+1) ){ |
| 149008 | + switch( iCol-p->nColumn ){ |
| 149009 | + case 0: |
| 149010 | + /* The special 'table-name' column */ |
| 149011 | + sqlite3_result_blob(pCtx, &pCsr, sizeof(Fts3Cursor*), SQLITE_TRANSIENT); |
| 149012 | + sqlite3_result_subtype(pCtx, SQLITE_BLOB); |
| 149013 | + break; |
| 149014 | + |
| 149015 | + case 1: |
| 149016 | + /* The docid column */ |
| 149017 | + sqlite3_result_int64(pCtx, pCsr->iPrevId); |
| 149018 | + break; |
| 149019 | + |
| 149020 | + case 2: |
| 149021 | + if( pCsr->pExpr ){ |
| 149022 | + sqlite3_result_int64(pCtx, pCsr->iLangid); |
| 149023 | + break; |
| 149024 | + }else if( p->zLanguageid==0 ){ |
| 149025 | + sqlite3_result_int(pCtx, 0); |
| 149026 | + break; |
| 149027 | + }else{ |
| 149028 | + iCol = p->nColumn; |
| 149029 | + /* fall-through */ |
| 149030 | + } |
| 149031 | + |
| 149032 | + default: |
| 149033 | + /* A user column. Or, if this is a full-table scan, possibly the |
| 149034 | + ** language-id column. Seek the cursor. */ |
| 149035 | + rc = fts3CursorSeek(0, pCsr); |
| 149036 | + if( rc==SQLITE_OK && sqlite3_data_count(pCsr->pStmt)-1>iCol ){ |
| 148603 | 149037 | sqlite3_result_value(pCtx, sqlite3_column_value(pCsr->pStmt, iCol+1)); |
| 148604 | 149038 | } |
| 148605 | | - } |
| 149039 | + break; |
| 148606 | 149040 | } |
| 148607 | 149041 | |
| 148608 | 149042 | assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 ); |
| 148609 | 149043 | return rc; |
| 148610 | 149044 | } |
| | @@ -148680,21 +149114,15 @@ |
| 148680 | 149114 | ** if an error occurs. |
| 148681 | 149115 | */ |
| 148682 | 149116 | static int fts3SetHasStat(Fts3Table *p){ |
| 148683 | 149117 | int rc = SQLITE_OK; |
| 148684 | 149118 | if( p->bHasStat==2 ){ |
| 148685 | | - const char *zFmt ="SELECT 1 FROM %Q.sqlite_master WHERE tbl_name='%q_stat'"; |
| 148686 | | - char *zSql = sqlite3_mprintf(zFmt, p->zDb, p->zName); |
| 148687 | | - if( zSql ){ |
| 148688 | | - sqlite3_stmt *pStmt = 0; |
| 148689 | | - rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 148690 | | - if( rc==SQLITE_OK ){ |
| 148691 | | - int bHasStat = (sqlite3_step(pStmt)==SQLITE_ROW); |
| 148692 | | - rc = sqlite3_finalize(pStmt); |
| 148693 | | - if( rc==SQLITE_OK ) p->bHasStat = (u8)bHasStat; |
| 148694 | | - } |
| 148695 | | - sqlite3_free(zSql); |
| 149119 | + char *zTbl = sqlite3_mprintf("%s_stat", p->zName); |
| 149120 | + if( zTbl ){ |
| 149121 | + int res = sqlite3_table_column_metadata(p->db, p->zDb, zTbl, 0,0,0,0,0,0); |
| 149122 | + sqlite3_free(zTbl); |
| 149123 | + p->bHasStat = (res==SQLITE_OK); |
| 148696 | 149124 | }else{ |
| 148697 | 149125 | rc = SQLITE_NOMEM; |
| 148698 | 149126 | } |
| 148699 | 149127 | } |
| 148700 | 149128 | return rc; |
| | @@ -148797,22 +149225,20 @@ |
| 148797 | 149225 | sqlite3_context *pContext, /* SQL function call context */ |
| 148798 | 149226 | const char *zFunc, /* Function name */ |
| 148799 | 149227 | sqlite3_value *pVal, /* argv[0] passed to function */ |
| 148800 | 149228 | Fts3Cursor **ppCsr /* OUT: Store cursor handle here */ |
| 148801 | 149229 | ){ |
| 148802 | | - Fts3Cursor *pRet; |
| 148803 | | - if( sqlite3_value_type(pVal)!=SQLITE_BLOB |
| 148804 | | - || sqlite3_value_bytes(pVal)!=sizeof(Fts3Cursor *) |
| 148805 | | - ){ |
| 149230 | + int rc = SQLITE_OK; |
| 149231 | + if( sqlite3_value_subtype(pVal)==SQLITE_BLOB ){ |
| 149232 | + *ppCsr = *(Fts3Cursor**)sqlite3_value_blob(pVal); |
| 149233 | + }else{ |
| 148806 | 149234 | char *zErr = sqlite3_mprintf("illegal first argument to %s", zFunc); |
| 148807 | 149235 | sqlite3_result_error(pContext, zErr, -1); |
| 148808 | 149236 | sqlite3_free(zErr); |
| 148809 | | - return SQLITE_ERROR; |
| 149237 | + rc = SQLITE_ERROR; |
| 148810 | 149238 | } |
| 148811 | | - memcpy(&pRet, sqlite3_value_blob(pVal), sizeof(Fts3Cursor *)); |
| 148812 | | - *ppCsr = pRet; |
| 148813 | | - return SQLITE_OK; |
| 149239 | + return rc; |
| 148814 | 149240 | } |
| 148815 | 149241 | |
| 148816 | 149242 | /* |
| 148817 | 149243 | ** Implementation of the snippet() function for FTS3 |
| 148818 | 149244 | */ |
| | @@ -149195,11 +149621,11 @@ |
| 149195 | 149621 | rc = sqlite3Fts3ExprInitTestInterface(db); |
| 149196 | 149622 | } |
| 149197 | 149623 | #endif |
| 149198 | 149624 | |
| 149199 | 149625 | /* Create the virtual table wrapper around the hash-table and overload |
| 149200 | | - ** the two scalar functions. If this is successful, register the |
| 149626 | + ** the four scalar functions. If this is successful, register the |
| 149201 | 149627 | ** module with sqlite. |
| 149202 | 149628 | */ |
| 149203 | 149629 | if( SQLITE_OK==rc |
| 149204 | 149630 | && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer")) |
| 149205 | 149631 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) |
| | @@ -149778,11 +150204,11 @@ |
| 149778 | 150204 | |
| 149779 | 150205 | /* This is only called if it is guaranteed that the phrase has at least |
| 149780 | 150206 | ** one incremental token. In which case the bIncr flag is set. */ |
| 149781 | 150207 | assert( p->bIncr==1 ); |
| 149782 | 150208 | |
| 149783 | | - if( p->nToken==1 && p->bIncr ){ |
| 150209 | + if( p->nToken==1 ){ |
| 149784 | 150210 | rc = sqlite3Fts3MsrIncrNext(pTab, p->aToken[0].pSegcsr, |
| 149785 | 150211 | &pDL->iDocid, &pDL->pList, &pDL->nList |
| 149786 | 150212 | ); |
| 149787 | 150213 | if( pDL->pList==0 ) bEof = 1; |
| 149788 | 150214 | }else{ |
| | @@ -150011,10 +150437,11 @@ |
| 150011 | 150437 | ** of data that will fit on a single leaf page of an intkey table in |
| 150012 | 150438 | ** this database, then the average docsize is 1. Otherwise, it is 1 plus |
| 150013 | 150439 | ** the number of overflow pages consumed by a record B bytes in size. |
| 150014 | 150440 | */ |
| 150015 | 150441 | static int fts3EvalAverageDocsize(Fts3Cursor *pCsr, int *pnPage){ |
| 150442 | + int rc = SQLITE_OK; |
| 150016 | 150443 | if( pCsr->nRowAvg==0 ){ |
| 150017 | 150444 | /* The average document size, which is required to calculate the cost |
| 150018 | 150445 | ** of each doclist, has not yet been determined. Read the required |
| 150019 | 150446 | ** data from the %_stat table to calculate it. |
| 150020 | 150447 | ** |
| | @@ -150023,11 +150450,10 @@ |
| 150023 | 150450 | ** The first varint is the number of documents currently stored in |
| 150024 | 150451 | ** the table. The following nCol varints contain the total amount of |
| 150025 | 150452 | ** data stored in all rows of each column of the table, from left |
| 150026 | 150453 | ** to right. |
| 150027 | 150454 | */ |
| 150028 | | - int rc; |
| 150029 | 150455 | Fts3Table *p = (Fts3Table*)pCsr->base.pVtab; |
| 150030 | 150456 | sqlite3_stmt *pStmt; |
| 150031 | 150457 | sqlite3_int64 nDoc = 0; |
| 150032 | 150458 | sqlite3_int64 nByte = 0; |
| 150033 | 150459 | const char *pEnd; |
| | @@ -150050,15 +150476,14 @@ |
| 150050 | 150476 | |
| 150051 | 150477 | pCsr->nDoc = nDoc; |
| 150052 | 150478 | pCsr->nRowAvg = (int)(((nByte / nDoc) + p->nPgsz) / p->nPgsz); |
| 150053 | 150479 | assert( pCsr->nRowAvg>0 ); |
| 150054 | 150480 | rc = sqlite3_reset(pStmt); |
| 150055 | | - if( rc!=SQLITE_OK ) return rc; |
| 150056 | 150481 | } |
| 150057 | 150482 | |
| 150058 | 150483 | *pnPage = pCsr->nRowAvg; |
| 150059 | | - return SQLITE_OK; |
| 150484 | + return rc; |
| 150060 | 150485 | } |
| 150061 | 150486 | |
| 150062 | 150487 | /* |
| 150063 | 150488 | ** This function is called to select the tokens (if any) that will be |
| 150064 | 150489 | ** deferred. The array aTC[] has already been populated when this is |
| | @@ -150404,11 +150829,12 @@ |
| 150404 | 150829 | } |
| 150405 | 150830 | } |
| 150406 | 150831 | pExpr->iDocid = pLeft->iDocid; |
| 150407 | 150832 | pExpr->bEof = (pLeft->bEof || pRight->bEof); |
| 150408 | 150833 | if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){ |
| 150409 | | - if( pRight->pPhrase && pRight->pPhrase->doclist.aAll ){ |
| 150834 | + assert( pRight->eType==FTSQUERY_PHRASE ); |
| 150835 | + if( pRight->pPhrase->doclist.aAll ){ |
| 150410 | 150836 | Fts3Doclist *pDl = &pRight->pPhrase->doclist; |
| 150411 | 150837 | while( *pRc==SQLITE_OK && pRight->bEof==0 ){ |
| 150412 | 150838 | memset(pDl->pList, 0, pDl->nList); |
| 150413 | 150839 | fts3EvalNextRow(pCsr, pRight, pRc); |
| 150414 | 150840 | } |
| | @@ -150433,11 +150859,11 @@ |
| 150433 | 150859 | assert( pLeft->bStart || pLeft->iDocid==pRight->iDocid ); |
| 150434 | 150860 | assert( pRight->bStart || pLeft->iDocid==pRight->iDocid ); |
| 150435 | 150861 | |
| 150436 | 150862 | if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){ |
| 150437 | 150863 | fts3EvalNextRow(pCsr, pLeft, pRc); |
| 150438 | | - }else if( pLeft->bEof || (pRight->bEof==0 && iCmp>0) ){ |
| 150864 | + }else if( pLeft->bEof || iCmp>0 ){ |
| 150439 | 150865 | fts3EvalNextRow(pCsr, pRight, pRc); |
| 150440 | 150866 | }else{ |
| 150441 | 150867 | fts3EvalNextRow(pCsr, pLeft, pRc); |
| 150442 | 150868 | fts3EvalNextRow(pCsr, pRight, pRc); |
| 150443 | 150869 | } |
| | @@ -150525,55 +150951,51 @@ |
| 150525 | 150951 | ** left-hand child may be either a phrase or a NEAR node. There are |
| 150526 | 150952 | ** no exceptions to this - it's the way the parser in fts3_expr.c works. |
| 150527 | 150953 | */ |
| 150528 | 150954 | if( *pRc==SQLITE_OK |
| 150529 | 150955 | && pExpr->eType==FTSQUERY_NEAR |
| 150530 | | - && pExpr->bEof==0 |
| 150531 | 150956 | && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR) |
| 150532 | 150957 | ){ |
| 150533 | 150958 | Fts3Expr *p; |
| 150534 | 150959 | int nTmp = 0; /* Bytes of temp space */ |
| 150535 | 150960 | char *aTmp; /* Temp space for PoslistNearMerge() */ |
| 150536 | 150961 | |
| 150537 | 150962 | /* Allocate temporary working space. */ |
| 150538 | 150963 | for(p=pExpr; p->pLeft; p=p->pLeft){ |
| 150964 | + assert( p->pRight->pPhrase->doclist.nList>0 ); |
| 150539 | 150965 | nTmp += p->pRight->pPhrase->doclist.nList; |
| 150540 | 150966 | } |
| 150541 | 150967 | nTmp += p->pPhrase->doclist.nList; |
| 150542 | | - if( nTmp==0 ){ |
| 150543 | | - res = 0; |
| 150544 | | - }else{ |
| 150545 | | - aTmp = sqlite3_malloc(nTmp*2); |
| 150546 | | - if( !aTmp ){ |
| 150547 | | - *pRc = SQLITE_NOMEM; |
| 150548 | | - res = 0; |
| 150549 | | - }else{ |
| 150550 | | - char *aPoslist = p->pPhrase->doclist.pList; |
| 150551 | | - int nToken = p->pPhrase->nToken; |
| 150552 | | - |
| 150553 | | - for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){ |
| 150554 | | - Fts3Phrase *pPhrase = p->pRight->pPhrase; |
| 150555 | | - int nNear = p->nNear; |
| 150556 | | - res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 150557 | | - } |
| 150558 | | - |
| 150559 | | - aPoslist = pExpr->pRight->pPhrase->doclist.pList; |
| 150560 | | - nToken = pExpr->pRight->pPhrase->nToken; |
| 150561 | | - for(p=pExpr->pLeft; p && res; p=p->pLeft){ |
| 150562 | | - int nNear; |
| 150563 | | - Fts3Phrase *pPhrase; |
| 150564 | | - assert( p->pParent && p->pParent->pLeft==p ); |
| 150565 | | - nNear = p->pParent->nNear; |
| 150566 | | - pPhrase = ( |
| 150567 | | - p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase |
| 150568 | | - ); |
| 150569 | | - res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 150570 | | - } |
| 150571 | | - } |
| 150572 | | - |
| 150573 | | - sqlite3_free(aTmp); |
| 150574 | | - } |
| 150968 | + aTmp = sqlite3_malloc(nTmp*2); |
| 150969 | + if( !aTmp ){ |
| 150970 | + *pRc = SQLITE_NOMEM; |
| 150971 | + res = 0; |
| 150972 | + }else{ |
| 150973 | + char *aPoslist = p->pPhrase->doclist.pList; |
| 150974 | + int nToken = p->pPhrase->nToken; |
| 150975 | + |
| 150976 | + for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){ |
| 150977 | + Fts3Phrase *pPhrase = p->pRight->pPhrase; |
| 150978 | + int nNear = p->nNear; |
| 150979 | + res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 150980 | + } |
| 150981 | + |
| 150982 | + aPoslist = pExpr->pRight->pPhrase->doclist.pList; |
| 150983 | + nToken = pExpr->pRight->pPhrase->nToken; |
| 150984 | + for(p=pExpr->pLeft; p && res; p=p->pLeft){ |
| 150985 | + int nNear; |
| 150986 | + Fts3Phrase *pPhrase; |
| 150987 | + assert( p->pParent && p->pParent->pLeft==p ); |
| 150988 | + nNear = p->pParent->nNear; |
| 150989 | + pPhrase = ( |
| 150990 | + p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase |
| 150991 | + ); |
| 150992 | + res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); |
| 150993 | + } |
| 150994 | + } |
| 150995 | + |
| 150996 | + sqlite3_free(aTmp); |
| 150575 | 150997 | } |
| 150576 | 150998 | |
| 150577 | 150999 | return res; |
| 150578 | 151000 | } |
| 150579 | 151001 | |
| | @@ -166676,16 +167098,39 @@ |
| 166676 | 167098 | , pRtree->zDb, pRtree->zName, zNewName |
| 166677 | 167099 | , pRtree->zDb, pRtree->zName, zNewName |
| 166678 | 167100 | , pRtree->zDb, pRtree->zName, zNewName |
| 166679 | 167101 | ); |
| 166680 | 167102 | if( zSql ){ |
| 167103 | + nodeBlobReset(pRtree); |
| 166681 | 167104 | rc = sqlite3_exec(pRtree->db, zSql, 0, 0, 0); |
| 166682 | 167105 | sqlite3_free(zSql); |
| 166683 | 167106 | } |
| 166684 | 167107 | return rc; |
| 166685 | 167108 | } |
| 166686 | 167109 | |
| 167110 | +/* |
| 167111 | +** The xSavepoint method. |
| 167112 | +** |
| 167113 | +** This module does not need to do anything to support savepoints. However, |
| 167114 | +** it uses this hook to close any open blob handle. This is done because a |
| 167115 | +** DROP TABLE command - which fortunately always opens a savepoint - cannot |
| 167116 | +** succeed if there are any open blob handles. i.e. if the blob handle were |
| 167117 | +** not closed here, the following would fail: |
| 167118 | +** |
| 167119 | +** BEGIN; |
| 167120 | +** INSERT INTO rtree... |
| 167121 | +** DROP TABLE <tablename>; -- Would fail with SQLITE_LOCKED |
| 167122 | +** COMMIT; |
| 167123 | +*/ |
| 167124 | +static int rtreeSavepoint(sqlite3_vtab *pVtab, int iSavepoint){ |
| 167125 | + Rtree *pRtree = (Rtree *)pVtab; |
| 167126 | + int iwt = pRtree->inWrTrans; |
| 167127 | + pRtree->inWrTrans = 0; |
| 167128 | + nodeBlobReset(pRtree); |
| 167129 | + pRtree->inWrTrans = iwt; |
| 167130 | + return SQLITE_OK; |
| 167131 | +} |
| 166687 | 167132 | |
| 166688 | 167133 | /* |
| 166689 | 167134 | ** This function populates the pRtree->nRowEst variable with an estimate |
| 166690 | 167135 | ** of the number of rows in the virtual table. If possible, this is based |
| 166691 | 167136 | ** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST. |
| | @@ -166728,11 +167173,11 @@ |
| 166728 | 167173 | |
| 166729 | 167174 | return rc; |
| 166730 | 167175 | } |
| 166731 | 167176 | |
| 166732 | 167177 | static sqlite3_module rtreeModule = { |
| 166733 | | - 0, /* iVersion */ |
| 167178 | + 2, /* iVersion */ |
| 166734 | 167179 | rtreeCreate, /* xCreate - create a table */ |
| 166735 | 167180 | rtreeConnect, /* xConnect - connect to an existing table */ |
| 166736 | 167181 | rtreeBestIndex, /* xBestIndex - Determine search strategy */ |
| 166737 | 167182 | rtreeDisconnect, /* xDisconnect - Disconnect from a table */ |
| 166738 | 167183 | rtreeDestroy, /* xDestroy - Drop a table */ |
| | @@ -166748,11 +167193,11 @@ |
| 166748 | 167193 | rtreeEndTransaction, /* xSync - sync transaction */ |
| 166749 | 167194 | rtreeEndTransaction, /* xCommit - commit transaction */ |
| 166750 | 167195 | rtreeEndTransaction, /* xRollback - rollback transaction */ |
| 166751 | 167196 | 0, /* xFindFunction - function overloading */ |
| 166752 | 167197 | rtreeRename, /* xRename - rename the table */ |
| 166753 | | - 0, /* xSavepoint */ |
| 167198 | + rtreeSavepoint, /* xSavepoint */ |
| 166754 | 167199 | 0, /* xRelease */ |
| 166755 | 167200 | 0, /* xRollbackTo */ |
| 166756 | 167201 | }; |
| 166757 | 167202 | |
| 166758 | 167203 | static int rtreeSqlInit( |
| | @@ -178905,10 +179350,11 @@ |
| 178905 | 179350 | #ifndef SQLITE_AMALGAMATION |
| 178906 | 179351 | /* Unsigned integer types. These are already defined in the sqliteInt.h, |
| 178907 | 179352 | ** but the definitions need to be repeated for separate compilation. */ |
| 178908 | 179353 | typedef sqlite3_uint64 u64; |
| 178909 | 179354 | typedef unsigned int u32; |
| 179355 | + typedef unsigned short int u16; |
| 178910 | 179356 | typedef unsigned char u8; |
| 178911 | 179357 | #endif |
| 178912 | 179358 | |
| 178913 | 179359 | /* Objects */ |
| 178914 | 179360 | typedef struct JsonString JsonString; |
| | @@ -178984,12 +179430,22 @@ |
| 178984 | 179430 | JsonNode *aNode; /* Array of nodes containing the parse */ |
| 178985 | 179431 | const char *zJson; /* Original JSON string */ |
| 178986 | 179432 | u32 *aUp; /* Index of parent of each node */ |
| 178987 | 179433 | u8 oom; /* Set to true if out of memory */ |
| 178988 | 179434 | u8 nErr; /* Number of errors seen */ |
| 179435 | + u16 iDepth; /* Nesting depth */ |
| 178989 | 179436 | }; |
| 178990 | 179437 | |
| 179438 | +/* |
| 179439 | +** Maximum nesting depth of JSON for this implementation. |
| 179440 | +** |
| 179441 | +** This limit is needed to avoid a stack overflow in the recursive |
| 179442 | +** descent parser. A depth of 2000 is far deeper than any sane JSON |
| 179443 | +** should go. |
| 179444 | +*/ |
| 179445 | +#define JSON_MAX_DEPTH 2000 |
| 179446 | + |
| 178991 | 179447 | /************************************************************************** |
| 178992 | 179448 | ** Utility routines for dealing with JsonString objects |
| 178993 | 179449 | **************************************************************************/ |
| 178994 | 179450 | |
| 178995 | 179451 | /* Set the JsonString object to an empty string |
| | @@ -179542,35 +179998,39 @@ |
| 179542 | 179998 | char c; |
| 179543 | 179999 | u32 j; |
| 179544 | 180000 | int iThis; |
| 179545 | 180001 | int x; |
| 179546 | 180002 | JsonNode *pNode; |
| 179547 | | - while( safe_isspace(pParse->zJson[i]) ){ i++; } |
| 179548 | | - if( (c = pParse->zJson[i])=='{' ){ |
| 180003 | + const char *z = pParse->zJson; |
| 180004 | + while( safe_isspace(z[i]) ){ i++; } |
| 180005 | + if( (c = z[i])=='{' ){ |
| 179549 | 180006 | /* Parse object */ |
| 179550 | 180007 | iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); |
| 179551 | 180008 | if( iThis<0 ) return -1; |
| 179552 | 180009 | for(j=i+1;;j++){ |
| 179553 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 180010 | + while( safe_isspace(z[j]) ){ j++; } |
| 180011 | + if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; |
| 179554 | 180012 | x = jsonParseValue(pParse, j); |
| 179555 | 180013 | if( x<0 ){ |
| 180014 | + pParse->iDepth--; |
| 179556 | 180015 | if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1; |
| 179557 | 180016 | return -1; |
| 179558 | 180017 | } |
| 179559 | 180018 | if( pParse->oom ) return -1; |
| 179560 | 180019 | pNode = &pParse->aNode[pParse->nNode-1]; |
| 179561 | 180020 | if( pNode->eType!=JSON_STRING ) return -1; |
| 179562 | 180021 | pNode->jnFlags |= JNODE_LABEL; |
| 179563 | 180022 | j = x; |
| 179564 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 179565 | | - if( pParse->zJson[j]!=':' ) return -1; |
| 180023 | + while( safe_isspace(z[j]) ){ j++; } |
| 180024 | + if( z[j]!=':' ) return -1; |
| 179566 | 180025 | j++; |
| 179567 | 180026 | x = jsonParseValue(pParse, j); |
| 180027 | + pParse->iDepth--; |
| 179568 | 180028 | if( x<0 ) return -1; |
| 179569 | 180029 | j = x; |
| 179570 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 179571 | | - c = pParse->zJson[j]; |
| 180030 | + while( safe_isspace(z[j]) ){ j++; } |
| 180031 | + c = z[j]; |
| 179572 | 180032 | if( c==',' ) continue; |
| 179573 | 180033 | if( c!='}' ) return -1; |
| 179574 | 180034 | break; |
| 179575 | 180035 | } |
| 179576 | 180036 | pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; |
| | @@ -179578,19 +180038,21 @@ |
| 179578 | 180038 | }else if( c=='[' ){ |
| 179579 | 180039 | /* Parse array */ |
| 179580 | 180040 | iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); |
| 179581 | 180041 | if( iThis<0 ) return -1; |
| 179582 | 180042 | for(j=i+1;;j++){ |
| 179583 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 180043 | + while( safe_isspace(z[j]) ){ j++; } |
| 180044 | + if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; |
| 179584 | 180045 | x = jsonParseValue(pParse, j); |
| 180046 | + pParse->iDepth--; |
| 179585 | 180047 | if( x<0 ){ |
| 179586 | 180048 | if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1; |
| 179587 | 180049 | return -1; |
| 179588 | 180050 | } |
| 179589 | 180051 | j = x; |
| 179590 | | - while( safe_isspace(pParse->zJson[j]) ){ j++; } |
| 179591 | | - c = pParse->zJson[j]; |
| 180052 | + while( safe_isspace(z[j]) ){ j++; } |
| 180053 | + c = z[j]; |
| 179592 | 180054 | if( c==',' ) continue; |
| 179593 | 180055 | if( c!=']' ) return -1; |
| 179594 | 180056 | break; |
| 179595 | 180057 | } |
| 179596 | 180058 | pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; |
| | @@ -179598,75 +180060,83 @@ |
| 179598 | 180060 | }else if( c=='"' ){ |
| 179599 | 180061 | /* Parse string */ |
| 179600 | 180062 | u8 jnFlags = 0; |
| 179601 | 180063 | j = i+1; |
| 179602 | 180064 | for(;;){ |
| 179603 | | - c = pParse->zJson[j]; |
| 179604 | | - if( c==0 ) return -1; |
| 180065 | + c = z[j]; |
| 180066 | + if( (c & ~0x1f)==0 ){ |
| 180067 | + /* Control characters are not allowed in strings */ |
| 180068 | + return -1; |
| 180069 | + } |
| 179605 | 180070 | if( c=='\\' ){ |
| 179606 | | - c = pParse->zJson[++j]; |
| 180071 | + c = z[++j]; |
| 179607 | 180072 | if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' |
| 179608 | 180073 | || c=='n' || c=='r' || c=='t' |
| 179609 | | - || (c=='u' && jsonIs4Hex(pParse->zJson+j+1)) ){ |
| 180074 | + || (c=='u' && jsonIs4Hex(z+j+1)) ){ |
| 179610 | 180075 | jnFlags = JNODE_ESCAPE; |
| 179611 | 180076 | }else{ |
| 179612 | 180077 | return -1; |
| 179613 | 180078 | } |
| 179614 | 180079 | }else if( c=='"' ){ |
| 179615 | 180080 | break; |
| 179616 | 180081 | } |
| 179617 | 180082 | j++; |
| 179618 | 180083 | } |
| 179619 | | - jsonParseAddNode(pParse, JSON_STRING, j+1-i, &pParse->zJson[i]); |
| 180084 | + jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]); |
| 179620 | 180085 | if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags; |
| 179621 | 180086 | return j+1; |
| 179622 | 180087 | }else if( c=='n' |
| 179623 | | - && strncmp(pParse->zJson+i,"null",4)==0 |
| 179624 | | - && !safe_isalnum(pParse->zJson[i+4]) ){ |
| 180088 | + && strncmp(z+i,"null",4)==0 |
| 180089 | + && !safe_isalnum(z[i+4]) ){ |
| 179625 | 180090 | jsonParseAddNode(pParse, JSON_NULL, 0, 0); |
| 179626 | 180091 | return i+4; |
| 179627 | 180092 | }else if( c=='t' |
| 179628 | | - && strncmp(pParse->zJson+i,"true",4)==0 |
| 179629 | | - && !safe_isalnum(pParse->zJson[i+4]) ){ |
| 180093 | + && strncmp(z+i,"true",4)==0 |
| 180094 | + && !safe_isalnum(z[i+4]) ){ |
| 179630 | 180095 | jsonParseAddNode(pParse, JSON_TRUE, 0, 0); |
| 179631 | 180096 | return i+4; |
| 179632 | 180097 | }else if( c=='f' |
| 179633 | | - && strncmp(pParse->zJson+i,"false",5)==0 |
| 179634 | | - && !safe_isalnum(pParse->zJson[i+5]) ){ |
| 180098 | + && strncmp(z+i,"false",5)==0 |
| 180099 | + && !safe_isalnum(z[i+5]) ){ |
| 179635 | 180100 | jsonParseAddNode(pParse, JSON_FALSE, 0, 0); |
| 179636 | 180101 | return i+5; |
| 179637 | 180102 | }else if( c=='-' || (c>='0' && c<='9') ){ |
| 179638 | 180103 | /* Parse number */ |
| 179639 | 180104 | u8 seenDP = 0; |
| 179640 | 180105 | u8 seenE = 0; |
| 180106 | + assert( '-' < '0' ); |
| 180107 | + if( c<='0' ){ |
| 180108 | + j = c=='-' ? i+1 : i; |
| 180109 | + if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1; |
| 180110 | + } |
| 179641 | 180111 | j = i+1; |
| 179642 | 180112 | for(;; j++){ |
| 179643 | | - c = pParse->zJson[j]; |
| 180113 | + c = z[j]; |
| 179644 | 180114 | if( c>='0' && c<='9' ) continue; |
| 179645 | 180115 | if( c=='.' ){ |
| 179646 | | - if( pParse->zJson[j-1]=='-' ) return -1; |
| 180116 | + if( z[j-1]=='-' ) return -1; |
| 179647 | 180117 | if( seenDP ) return -1; |
| 179648 | 180118 | seenDP = 1; |
| 179649 | 180119 | continue; |
| 179650 | 180120 | } |
| 179651 | 180121 | if( c=='e' || c=='E' ){ |
| 179652 | | - if( pParse->zJson[j-1]<'0' ) return -1; |
| 180122 | + if( z[j-1]<'0' ) return -1; |
| 179653 | 180123 | if( seenE ) return -1; |
| 179654 | 180124 | seenDP = seenE = 1; |
| 179655 | | - c = pParse->zJson[j+1]; |
| 180125 | + c = z[j+1]; |
| 179656 | 180126 | if( c=='+' || c=='-' ){ |
| 179657 | 180127 | j++; |
| 179658 | | - c = pParse->zJson[j+1]; |
| 180128 | + c = z[j+1]; |
| 179659 | 180129 | } |
| 179660 | 180130 | if( c<'0' || c>'9' ) return -1; |
| 179661 | 180131 | continue; |
| 179662 | 180132 | } |
| 179663 | 180133 | break; |
| 179664 | 180134 | } |
| 179665 | | - if( pParse->zJson[j-1]<'0' ) return -1; |
| 180135 | + if( z[j-1]<'0' ) return -1; |
| 179666 | 180136 | jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT, |
| 179667 | | - j - i, &pParse->zJson[i]); |
| 180137 | + j - i, &z[i]); |
| 179668 | 180138 | return j; |
| 179669 | 180139 | }else if( c=='}' ){ |
| 179670 | 180140 | return -2; /* End of {...} */ |
| 179671 | 180141 | }else if( c==']' ){ |
| 179672 | 180142 | return -3; /* End of [...] */ |
| | @@ -179694,10 +180164,11 @@ |
| 179694 | 180164 | if( zJson==0 ) return 1; |
| 179695 | 180165 | pParse->zJson = zJson; |
| 179696 | 180166 | i = jsonParseValue(pParse, 0); |
| 179697 | 180167 | if( pParse->oom ) i = -1; |
| 179698 | 180168 | if( i>0 ){ |
| 180169 | + assert( pParse->iDepth==0 ); |
| 179699 | 180170 | while( safe_isspace(zJson[i]) ) i++; |
| 179700 | 180171 | if( zJson[i] ) i = -1; |
| 179701 | 180172 | } |
| 179702 | 180173 | if( i<=0 ){ |
| 179703 | 180174 | if( pCtx!=0 ){ |
| | @@ -180194,11 +180665,11 @@ |
| 180194 | 180665 | |
| 180195 | 180666 | /* This is the RFC 7396 MergePatch algorithm. |
| 180196 | 180667 | */ |
| 180197 | 180668 | static JsonNode *jsonMergePatch( |
| 180198 | 180669 | JsonParse *pParse, /* The JSON parser that contains the TARGET */ |
| 180199 | | - int iTarget, /* Node of the TARGET in pParse */ |
| 180670 | + u32 iTarget, /* Node of the TARGET in pParse */ |
| 180200 | 180671 | JsonNode *pPatch /* The PATCH */ |
| 180201 | 180672 | ){ |
| 180202 | 180673 | u32 i, j; |
| 180203 | 180674 | u32 iRoot; |
| 180204 | 180675 | JsonNode *pTarget; |
| | @@ -182203,13 +182674,13 @@ |
| 182203 | 182674 | i64 iDocid /* Docid to add or remove data from */ |
| 182204 | 182675 | ); |
| 182205 | 182676 | |
| 182206 | 182677 | /* |
| 182207 | 182678 | ** Flush any data stored in the in-memory hash tables to the database. |
| 182208 | | -** If the bCommit flag is true, also close any open blob handles. |
| 182679 | +** Also close any open blob handles. |
| 182209 | 182680 | */ |
| 182210 | | -static int sqlite3Fts5IndexSync(Fts5Index *p, int bCommit); |
| 182681 | +static int sqlite3Fts5IndexSync(Fts5Index *p); |
| 182211 | 182682 | |
| 182212 | 182683 | /* |
| 182213 | 182684 | ** Discard any data stored in the in-memory hash tables. Do not write it |
| 182214 | 182685 | ** to the database. Additionally, assume that the contents of the %_data |
| 182215 | 182686 | ** table may have changed on disk. So any in-memory caches of %_data |
| | @@ -182375,11 +182846,11 @@ |
| 182375 | 182846 | |
| 182376 | 182847 | static int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol); |
| 182377 | 182848 | static int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnAvg); |
| 182378 | 182849 | static int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow); |
| 182379 | 182850 | |
| 182380 | | -static int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit); |
| 182851 | +static int sqlite3Fts5StorageSync(Fts5Storage *p); |
| 182381 | 182852 | static int sqlite3Fts5StorageRollback(Fts5Storage *p); |
| 182382 | 182853 | |
| 182383 | 182854 | static int sqlite3Fts5StorageConfigValue( |
| 182384 | 182855 | Fts5Storage *p, const char*, sqlite3_value*, int |
| 182385 | 182856 | ); |
| | @@ -182411,10 +182882,11 @@ |
| 182411 | 182882 | }; |
| 182412 | 182883 | |
| 182413 | 182884 | /* Parse a MATCH expression. */ |
| 182414 | 182885 | static int sqlite3Fts5ExprNew( |
| 182415 | 182886 | Fts5Config *pConfig, |
| 182887 | + int iCol, /* Column on LHS of MATCH operator */ |
| 182416 | 182888 | const char *zExpr, |
| 182417 | 182889 | Fts5Expr **ppNew, |
| 182418 | 182890 | char **pzErr |
| 182419 | 182891 | ); |
| 182420 | 182892 | |
| | @@ -182495,11 +182967,11 @@ |
| 182495 | 182967 | static void sqlite3Fts5ParsePhraseFree(Fts5ExprPhrase*); |
| 182496 | 182968 | static void sqlite3Fts5ParseNearsetFree(Fts5ExprNearset*); |
| 182497 | 182969 | static void sqlite3Fts5ParseNodeFree(Fts5ExprNode*); |
| 182498 | 182970 | |
| 182499 | 182971 | static void sqlite3Fts5ParseSetDistance(Fts5Parse*, Fts5ExprNearset*, Fts5Token*); |
| 182500 | | -static void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNearset*, Fts5Colset*); |
| 182972 | +static void sqlite3Fts5ParseSetColset(Fts5Parse*, Fts5ExprNode*, Fts5Colset*); |
| 182501 | 182973 | static Fts5Colset *sqlite3Fts5ParseColsetInvert(Fts5Parse*, Fts5Colset*); |
| 182502 | 182974 | static void sqlite3Fts5ParseFinished(Fts5Parse *pParse, Fts5ExprNode *p); |
| 182503 | 182975 | static void sqlite3Fts5ParseNear(Fts5Parse *pParse, Fts5Token*); |
| 182504 | 182976 | |
| 182505 | 182977 | /* |
| | @@ -182552,16 +183024,16 @@ |
| 182552 | 183024 | #define FTS5_OR 1 |
| 182553 | 183025 | #define FTS5_AND 2 |
| 182554 | 183026 | #define FTS5_NOT 3 |
| 182555 | 183027 | #define FTS5_TERM 4 |
| 182556 | 183028 | #define FTS5_COLON 5 |
| 182557 | | -#define FTS5_LP 6 |
| 182558 | | -#define FTS5_RP 7 |
| 182559 | | -#define FTS5_MINUS 8 |
| 182560 | | -#define FTS5_LCP 9 |
| 182561 | | -#define FTS5_RCP 10 |
| 182562 | | -#define FTS5_STRING 11 |
| 183029 | +#define FTS5_MINUS 6 |
| 183030 | +#define FTS5_LCP 7 |
| 183031 | +#define FTS5_RCP 8 |
| 183032 | +#define FTS5_STRING 9 |
| 183033 | +#define FTS5_LP 10 |
| 183034 | +#define FTS5_RP 11 |
| 182563 | 183035 | #define FTS5_COMMA 12 |
| 182564 | 183036 | #define FTS5_PLUS 13 |
| 182565 | 183037 | #define FTS5_STAR 14 |
| 182566 | 183038 | |
| 182567 | 183039 | /* |
| | @@ -182693,20 +183165,20 @@ |
| 182693 | 183165 | #endif |
| 182694 | 183166 | #define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse; |
| 182695 | 183167 | #define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse |
| 182696 | 183168 | #define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse = fts5yypParser->pParse |
| 182697 | 183169 | #define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse = pParse |
| 182698 | | -#define fts5YYNSTATE 29 |
| 182699 | | -#define fts5YYNRULE 26 |
| 182700 | | -#define fts5YY_MAX_SHIFT 28 |
| 182701 | | -#define fts5YY_MIN_SHIFTREDUCE 45 |
| 182702 | | -#define fts5YY_MAX_SHIFTREDUCE 70 |
| 182703 | | -#define fts5YY_MIN_REDUCE 71 |
| 182704 | | -#define fts5YY_MAX_REDUCE 96 |
| 182705 | | -#define fts5YY_ERROR_ACTION 97 |
| 182706 | | -#define fts5YY_ACCEPT_ACTION 98 |
| 182707 | | -#define fts5YY_NO_ACTION 99 |
| 183170 | +#define fts5YYNSTATE 33 |
| 183171 | +#define fts5YYNRULE 27 |
| 183172 | +#define fts5YY_MAX_SHIFT 32 |
| 183173 | +#define fts5YY_MIN_SHIFTREDUCE 50 |
| 183174 | +#define fts5YY_MAX_SHIFTREDUCE 76 |
| 183175 | +#define fts5YY_MIN_REDUCE 77 |
| 183176 | +#define fts5YY_MAX_REDUCE 103 |
| 183177 | +#define fts5YY_ERROR_ACTION 104 |
| 183178 | +#define fts5YY_ACCEPT_ACTION 105 |
| 183179 | +#define fts5YY_NO_ACTION 106 |
| 182708 | 183180 | /************* End control #defines *******************************************/ |
| 182709 | 183181 | |
| 182710 | 183182 | /* Define the fts5yytestcase() macro to be a no-op if is not already defined |
| 182711 | 183183 | ** otherwise. |
| 182712 | 183184 | ** |
| | @@ -182774,54 +183246,58 @@ |
| 182774 | 183246 | ** fts5yy_reduce_ofst[] For each state, the offset into fts5yy_action for |
| 182775 | 183247 | ** shifting non-terminals after a reduce. |
| 182776 | 183248 | ** fts5yy_default[] Default action for each state. |
| 182777 | 183249 | ** |
| 182778 | 183250 | *********** Begin parsing tables **********************************************/ |
| 182779 | | -#define fts5YY_ACTTAB_COUNT (85) |
| 183251 | +#define fts5YY_ACTTAB_COUNT (98) |
| 182780 | 183252 | static const fts5YYACTIONTYPE fts5yy_action[] = { |
| 182781 | | - /* 0 */ 98, 16, 51, 5, 53, 27, 83, 7, 26, 15, |
| 182782 | | - /* 10 */ 51, 5, 53, 27, 13, 69, 26, 48, 51, 5, |
| 182783 | | - /* 20 */ 53, 27, 19, 11, 26, 9, 20, 51, 5, 53, |
| 182784 | | - /* 30 */ 27, 13, 22, 26, 28, 51, 5, 53, 27, 68, |
| 182785 | | - /* 40 */ 1, 26, 19, 11, 17, 9, 52, 10, 53, 27, |
| 182786 | | - /* 50 */ 23, 24, 26, 54, 3, 4, 2, 26, 6, 21, |
| 182787 | | - /* 60 */ 49, 71, 3, 4, 2, 7, 56, 59, 55, 59, |
| 182788 | | - /* 70 */ 4, 2, 12, 69, 58, 60, 18, 67, 62, 69, |
| 182789 | | - /* 80 */ 25, 66, 8, 14, 2, |
| 183253 | + /* 0 */ 105, 19, 63, 6, 26, 66, 65, 24, 24, 17, |
| 183254 | + /* 10 */ 63, 6, 26, 16, 65, 54, 24, 18, 63, 6, |
| 183255 | + /* 20 */ 26, 10, 65, 12, 24, 75, 59, 63, 6, 26, |
| 183256 | + /* 30 */ 13, 65, 75, 24, 20, 63, 6, 26, 74, 65, |
| 183257 | + /* 40 */ 56, 24, 27, 63, 6, 26, 73, 65, 21, 24, |
| 183258 | + /* 50 */ 23, 15, 30, 11, 1, 64, 22, 25, 9, 65, |
| 183259 | + /* 60 */ 7, 24, 3, 4, 5, 3, 4, 5, 3, 77, |
| 183260 | + /* 70 */ 4, 5, 3, 61, 23, 15, 60, 11, 80, 12, |
| 183261 | + /* 80 */ 2, 13, 68, 10, 29, 52, 55, 75, 31, 32, |
| 183262 | + /* 90 */ 8, 28, 5, 3, 51, 55, 72, 14, |
| 182790 | 183263 | }; |
| 182791 | 183264 | static const fts5YYCODETYPE fts5yy_lookahead[] = { |
| 182792 | | - /* 0 */ 16, 17, 18, 19, 20, 21, 5, 6, 24, 17, |
| 182793 | | - /* 10 */ 18, 19, 20, 21, 11, 14, 24, 17, 18, 19, |
| 182794 | | - /* 20 */ 20, 21, 8, 9, 24, 11, 17, 18, 19, 20, |
| 182795 | | - /* 30 */ 21, 11, 12, 24, 17, 18, 19, 20, 21, 26, |
| 182796 | | - /* 40 */ 6, 24, 8, 9, 22, 11, 18, 11, 20, 21, |
| 182797 | | - /* 50 */ 24, 25, 24, 20, 1, 2, 3, 24, 23, 24, |
| 182798 | | - /* 60 */ 7, 0, 1, 2, 3, 6, 10, 11, 10, 11, |
| 182799 | | - /* 70 */ 2, 3, 9, 14, 11, 11, 22, 26, 7, 14, |
| 182800 | | - /* 80 */ 13, 11, 5, 11, 3, |
| 183265 | + /* 0 */ 16, 17, 18, 19, 20, 22, 22, 24, 24, 17, |
| 183266 | + /* 10 */ 18, 19, 20, 7, 22, 9, 24, 17, 18, 19, |
| 183267 | + /* 20 */ 20, 10, 22, 9, 24, 14, 17, 18, 19, 20, |
| 183268 | + /* 30 */ 9, 22, 14, 24, 17, 18, 19, 20, 26, 22, |
| 183269 | + /* 40 */ 9, 24, 17, 18, 19, 20, 26, 22, 21, 24, |
| 183270 | + /* 50 */ 6, 7, 13, 9, 10, 18, 21, 20, 5, 22, |
| 183271 | + /* 60 */ 5, 24, 3, 1, 2, 3, 1, 2, 3, 0, |
| 183272 | + /* 70 */ 1, 2, 3, 11, 6, 7, 11, 9, 5, 9, |
| 183273 | + /* 80 */ 10, 9, 11, 10, 12, 8, 9, 14, 24, 25, |
| 183274 | + /* 90 */ 23, 24, 2, 3, 8, 9, 9, 9, |
| 182801 | 183275 | }; |
| 182802 | | -#define fts5YY_SHIFT_USE_DFLT (85) |
| 182803 | | -#define fts5YY_SHIFT_COUNT (28) |
| 183276 | +#define fts5YY_SHIFT_USE_DFLT (98) |
| 183277 | +#define fts5YY_SHIFT_COUNT (32) |
| 182804 | 183278 | #define fts5YY_SHIFT_MIN (0) |
| 182805 | | -#define fts5YY_SHIFT_MAX (81) |
| 183279 | +#define fts5YY_SHIFT_MAX (90) |
| 182806 | 183280 | static const unsigned char fts5yy_shift_ofst[] = { |
| 182807 | | - /* 0 */ 34, 34, 34, 34, 34, 14, 20, 3, 36, 1, |
| 182808 | | - /* 10 */ 59, 64, 64, 65, 65, 53, 61, 56, 58, 63, |
| 182809 | | - /* 20 */ 68, 67, 70, 67, 71, 72, 67, 77, 81, |
| 183281 | + /* 0 */ 44, 44, 44, 44, 44, 44, 68, 70, 72, 14, |
| 183282 | + /* 10 */ 21, 73, 11, 18, 18, 31, 31, 62, 65, 69, |
| 183283 | + /* 20 */ 90, 77, 86, 6, 39, 53, 55, 59, 39, 87, |
| 183284 | + /* 30 */ 88, 39, 71, |
| 182810 | 183285 | }; |
| 182811 | | -#define fts5YY_REDUCE_USE_DFLT (-17) |
| 182812 | | -#define fts5YY_REDUCE_COUNT (14) |
| 182813 | | -#define fts5YY_REDUCE_MIN (-16) |
| 182814 | | -#define fts5YY_REDUCE_MAX (54) |
| 183286 | +#define fts5YY_REDUCE_USE_DFLT (-18) |
| 183287 | +#define fts5YY_REDUCE_COUNT (16) |
| 183288 | +#define fts5YY_REDUCE_MIN (-17) |
| 183289 | +#define fts5YY_REDUCE_MAX (67) |
| 182815 | 183290 | static const signed char fts5yy_reduce_ofst[] = { |
| 182816 | | - /* 0 */ -16, -8, 0, 9, 17, 28, 26, 35, 33, 13, |
| 182817 | | - /* 10 */ 13, 22, 54, 13, 51, |
| 183291 | + /* 0 */ -16, -8, 0, 9, 17, 25, 37, -17, 64, -17, |
| 183292 | + /* 10 */ 67, 12, 12, 12, 20, 27, 35, |
| 182818 | 183293 | }; |
| 182819 | 183294 | static const fts5YYACTIONTYPE fts5yy_default[] = { |
| 182820 | | - /* 0 */ 97, 97, 97, 97, 97, 76, 91, 97, 97, 96, |
| 182821 | | - /* 10 */ 96, 97, 97, 96, 96, 97, 97, 97, 97, 97, |
| 182822 | | - /* 20 */ 73, 89, 97, 90, 97, 97, 87, 97, 72, |
| 183295 | + /* 0 */ 104, 104, 104, 104, 104, 104, 89, 104, 98, 104, |
| 183296 | + /* 10 */ 104, 103, 103, 103, 103, 104, 104, 104, 104, 104, |
| 183297 | + /* 20 */ 85, 104, 104, 104, 94, 104, 104, 84, 96, 104, |
| 183298 | + /* 30 */ 104, 97, 104, |
| 182823 | 183299 | }; |
| 182824 | 183300 | /********** End of lemon-generated parsing tables *****************************/ |
| 182825 | 183301 | |
| 182826 | 183302 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 182827 | 183303 | ** If a construct like the following: |
| | @@ -182923,49 +183399,50 @@ |
| 182923 | 183399 | #ifndef NDEBUG |
| 182924 | 183400 | /* For tracing shifts, the names of all terminals and nonterminals |
| 182925 | 183401 | ** are required. The following table supplies these names */ |
| 182926 | 183402 | static const char *const fts5yyTokenName[] = { |
| 182927 | 183403 | "$", "OR", "AND", "NOT", |
| 182928 | | - "TERM", "COLON", "LP", "RP", |
| 182929 | | - "MINUS", "LCP", "RCP", "STRING", |
| 183404 | + "TERM", "COLON", "MINUS", "LCP", |
| 183405 | + "RCP", "STRING", "LP", "RP", |
| 182930 | 183406 | "COMMA", "PLUS", "STAR", "error", |
| 182931 | 183407 | "input", "expr", "cnearset", "exprlist", |
| 182932 | | - "nearset", "colset", "colsetlist", "nearphrases", |
| 183408 | + "colset", "colsetlist", "nearset", "nearphrases", |
| 182933 | 183409 | "phrase", "neardist_opt", "star_opt", |
| 182934 | 183410 | }; |
| 182935 | 183411 | #endif /* NDEBUG */ |
| 182936 | 183412 | |
| 182937 | 183413 | #ifndef NDEBUG |
| 182938 | 183414 | /* For tracing reduce actions, the names of all rules are required. |
| 182939 | 183415 | */ |
| 182940 | 183416 | static const char *const fts5yyRuleName[] = { |
| 182941 | 183417 | /* 0 */ "input ::= expr", |
| 182942 | | - /* 1 */ "expr ::= expr AND expr", |
| 182943 | | - /* 2 */ "expr ::= expr OR expr", |
| 182944 | | - /* 3 */ "expr ::= expr NOT expr", |
| 182945 | | - /* 4 */ "expr ::= LP expr RP", |
| 182946 | | - /* 5 */ "expr ::= exprlist", |
| 182947 | | - /* 6 */ "exprlist ::= cnearset", |
| 182948 | | - /* 7 */ "exprlist ::= exprlist cnearset", |
| 182949 | | - /* 8 */ "cnearset ::= nearset", |
| 182950 | | - /* 9 */ "cnearset ::= colset COLON nearset", |
| 182951 | | - /* 10 */ "colset ::= MINUS LCP colsetlist RCP", |
| 182952 | | - /* 11 */ "colset ::= LCP colsetlist RCP", |
| 182953 | | - /* 12 */ "colset ::= STRING", |
| 182954 | | - /* 13 */ "colset ::= MINUS STRING", |
| 182955 | | - /* 14 */ "colsetlist ::= colsetlist STRING", |
| 182956 | | - /* 15 */ "colsetlist ::= STRING", |
| 182957 | | - /* 16 */ "nearset ::= phrase", |
| 182958 | | - /* 17 */ "nearset ::= STRING LP nearphrases neardist_opt RP", |
| 182959 | | - /* 18 */ "nearphrases ::= phrase", |
| 182960 | | - /* 19 */ "nearphrases ::= nearphrases phrase", |
| 182961 | | - /* 20 */ "neardist_opt ::=", |
| 182962 | | - /* 21 */ "neardist_opt ::= COMMA STRING", |
| 182963 | | - /* 22 */ "phrase ::= phrase PLUS STRING star_opt", |
| 182964 | | - /* 23 */ "phrase ::= STRING star_opt", |
| 182965 | | - /* 24 */ "star_opt ::= STAR", |
| 182966 | | - /* 25 */ "star_opt ::=", |
| 183418 | + /* 1 */ "colset ::= MINUS LCP colsetlist RCP", |
| 183419 | + /* 2 */ "colset ::= LCP colsetlist RCP", |
| 183420 | + /* 3 */ "colset ::= STRING", |
| 183421 | + /* 4 */ "colset ::= MINUS STRING", |
| 183422 | + /* 5 */ "colsetlist ::= colsetlist STRING", |
| 183423 | + /* 6 */ "colsetlist ::= STRING", |
| 183424 | + /* 7 */ "expr ::= expr AND expr", |
| 183425 | + /* 8 */ "expr ::= expr OR expr", |
| 183426 | + /* 9 */ "expr ::= expr NOT expr", |
| 183427 | + /* 10 */ "expr ::= colset COLON LP expr RP", |
| 183428 | + /* 11 */ "expr ::= LP expr RP", |
| 183429 | + /* 12 */ "expr ::= exprlist", |
| 183430 | + /* 13 */ "exprlist ::= cnearset", |
| 183431 | + /* 14 */ "exprlist ::= exprlist cnearset", |
| 183432 | + /* 15 */ "cnearset ::= nearset", |
| 183433 | + /* 16 */ "cnearset ::= colset COLON nearset", |
| 183434 | + /* 17 */ "nearset ::= phrase", |
| 183435 | + /* 18 */ "nearset ::= STRING LP nearphrases neardist_opt RP", |
| 183436 | + /* 19 */ "nearphrases ::= phrase", |
| 183437 | + /* 20 */ "nearphrases ::= nearphrases phrase", |
| 183438 | + /* 21 */ "neardist_opt ::=", |
| 183439 | + /* 22 */ "neardist_opt ::= COMMA STRING", |
| 183440 | + /* 23 */ "phrase ::= phrase PLUS STRING star_opt", |
| 183441 | + /* 24 */ "phrase ::= STRING star_opt", |
| 183442 | + /* 25 */ "star_opt ::= STAR", |
| 183443 | + /* 26 */ "star_opt ::=", |
| 182967 | 183444 | }; |
| 182968 | 183445 | #endif /* NDEBUG */ |
| 182969 | 183446 | |
| 182970 | 183447 | |
| 182971 | 183448 | #if fts5YYSTACKDEPTH<=0 |
| | @@ -183091,21 +183568,21 @@ |
| 183091 | 183568 | case 19: /* exprlist */ |
| 183092 | 183569 | { |
| 183093 | 183570 | sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); |
| 183094 | 183571 | } |
| 183095 | 183572 | break; |
| 183096 | | - case 20: /* nearset */ |
| 183573 | + case 20: /* colset */ |
| 183574 | + case 21: /* colsetlist */ |
| 183575 | +{ |
| 183576 | + sqlite3_free((fts5yypminor->fts5yy11)); |
| 183577 | +} |
| 183578 | + break; |
| 183579 | + case 22: /* nearset */ |
| 183097 | 183580 | case 23: /* nearphrases */ |
| 183098 | 183581 | { |
| 183099 | 183582 | sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); |
| 183100 | 183583 | } |
| 183101 | | - break; |
| 183102 | | - case 21: /* colset */ |
| 183103 | | - case 22: /* colsetlist */ |
| 183104 | | -{ |
| 183105 | | - sqlite3_free((fts5yypminor->fts5yy11)); |
| 183106 | | -} |
| 183107 | 183584 | break; |
| 183108 | 183585 | case 24: /* phrase */ |
| 183109 | 183586 | { |
| 183110 | 183587 | sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); |
| 183111 | 183588 | } |
| | @@ -183360,27 +183837,28 @@ |
| 183360 | 183837 | static const struct { |
| 183361 | 183838 | fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ |
| 183362 | 183839 | unsigned char nrhs; /* Number of right-hand side symbols in the rule */ |
| 183363 | 183840 | } fts5yyRuleInfo[] = { |
| 183364 | 183841 | { 16, 1 }, |
| 183842 | + { 20, 4 }, |
| 183843 | + { 20, 3 }, |
| 183844 | + { 20, 1 }, |
| 183845 | + { 20, 2 }, |
| 183846 | + { 21, 2 }, |
| 183847 | + { 21, 1 }, |
| 183365 | 183848 | { 17, 3 }, |
| 183366 | 183849 | { 17, 3 }, |
| 183367 | 183850 | { 17, 3 }, |
| 183851 | + { 17, 5 }, |
| 183368 | 183852 | { 17, 3 }, |
| 183369 | 183853 | { 17, 1 }, |
| 183370 | 183854 | { 19, 1 }, |
| 183371 | 183855 | { 19, 2 }, |
| 183372 | 183856 | { 18, 1 }, |
| 183373 | 183857 | { 18, 3 }, |
| 183374 | | - { 21, 4 }, |
| 183375 | | - { 21, 3 }, |
| 183376 | | - { 21, 1 }, |
| 183377 | | - { 21, 2 }, |
| 183378 | | - { 22, 2 }, |
| 183379 | 183858 | { 22, 1 }, |
| 183380 | | - { 20, 1 }, |
| 183381 | | - { 20, 5 }, |
| 183859 | + { 22, 5 }, |
| 183382 | 183860 | { 23, 1 }, |
| 183383 | 183861 | { 23, 2 }, |
| 183384 | 183862 | { 25, 0 }, |
| 183385 | 183863 | { 25, 2 }, |
| 183386 | 183864 | { 24, 4 }, |
| | @@ -183451,132 +183929,139 @@ |
| 183451 | 183929 | /********** Begin reduce actions **********************************************/ |
| 183452 | 183930 | fts5YYMINORTYPE fts5yylhsminor; |
| 183453 | 183931 | case 0: /* input ::= expr */ |
| 183454 | 183932 | { sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); } |
| 183455 | 183933 | break; |
| 183456 | | - case 1: /* expr ::= expr AND expr */ |
| 183457 | | -{ |
| 183458 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183459 | | -} |
| 183460 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183461 | | - break; |
| 183462 | | - case 2: /* expr ::= expr OR expr */ |
| 183463 | | -{ |
| 183464 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183465 | | -} |
| 183466 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183467 | | - break; |
| 183468 | | - case 3: /* expr ::= expr NOT expr */ |
| 183469 | | -{ |
| 183470 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183471 | | -} |
| 183472 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183473 | | - break; |
| 183474 | | - case 4: /* expr ::= LP expr RP */ |
| 183475 | | -{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;} |
| 183476 | | - break; |
| 183477 | | - case 5: /* expr ::= exprlist */ |
| 183478 | | - case 6: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==6); |
| 183479 | | -{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;} |
| 183480 | | - fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183481 | | - break; |
| 183482 | | - case 7: /* exprlist ::= exprlist cnearset */ |
| 183483 | | -{ |
| 183484 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24); |
| 183485 | | -} |
| 183486 | | - fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183487 | | - break; |
| 183488 | | - case 8: /* cnearset ::= nearset */ |
| 183489 | | -{ |
| 183490 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 183491 | | -} |
| 183492 | | - fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183493 | | - break; |
| 183494 | | - case 9: /* cnearset ::= colset COLON nearset */ |
| 183495 | | -{ |
| 183496 | | - sqlite3Fts5ParseSetColset(pParse, fts5yymsp[0].minor.fts5yy46, fts5yymsp[-2].minor.fts5yy11); |
| 183497 | | - fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 183498 | | -} |
| 183499 | | - fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183500 | | - break; |
| 183501 | | - case 10: /* colset ::= MINUS LCP colsetlist RCP */ |
| 183502 | | -{ |
| 183503 | | - fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 183504 | | -} |
| 183505 | | - break; |
| 183506 | | - case 11: /* colset ::= LCP colsetlist RCP */ |
| 183507 | | -{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; } |
| 183508 | | - break; |
| 183509 | | - case 12: /* colset ::= STRING */ |
| 183510 | | -{ |
| 183511 | | - fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183512 | | -} |
| 183513 | | - fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183514 | | - break; |
| 183515 | | - case 13: /* colset ::= MINUS STRING */ |
| 183516 | | -{ |
| 183517 | | - fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183518 | | - fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 183519 | | -} |
| 183520 | | - break; |
| 183521 | | - case 14: /* colsetlist ::= colsetlist STRING */ |
| 183522 | | -{ |
| 183523 | | - fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); } |
| 183524 | | - fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183525 | | - break; |
| 183526 | | - case 15: /* colsetlist ::= STRING */ |
| 183527 | | -{ |
| 183528 | | - fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183529 | | -} |
| 183530 | | - fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183531 | | - break; |
| 183532 | | - case 16: /* nearset ::= phrase */ |
| 183533 | | -{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } |
| 183534 | | - fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183535 | | - break; |
| 183536 | | - case 17: /* nearset ::= STRING LP nearphrases neardist_opt RP */ |
| 183934 | + case 1: /* colset ::= MINUS LCP colsetlist RCP */ |
| 183935 | +{ |
| 183936 | + fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 183937 | +} |
| 183938 | + break; |
| 183939 | + case 2: /* colset ::= LCP colsetlist RCP */ |
| 183940 | +{ fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; } |
| 183941 | + break; |
| 183942 | + case 3: /* colset ::= STRING */ |
| 183943 | +{ |
| 183944 | + fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183945 | +} |
| 183946 | + fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183947 | + break; |
| 183948 | + case 4: /* colset ::= MINUS STRING */ |
| 183949 | +{ |
| 183950 | + fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183951 | + fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); |
| 183952 | +} |
| 183953 | + break; |
| 183954 | + case 5: /* colsetlist ::= colsetlist STRING */ |
| 183955 | +{ |
| 183956 | + fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); } |
| 183957 | + fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183958 | + break; |
| 183959 | + case 6: /* colsetlist ::= STRING */ |
| 183960 | +{ |
| 183961 | + fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); |
| 183962 | +} |
| 183963 | + fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; |
| 183964 | + break; |
| 183965 | + case 7: /* expr ::= expr AND expr */ |
| 183966 | +{ |
| 183967 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183968 | +} |
| 183969 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183970 | + break; |
| 183971 | + case 8: /* expr ::= expr OR expr */ |
| 183972 | +{ |
| 183973 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183974 | +} |
| 183975 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183976 | + break; |
| 183977 | + case 9: /* expr ::= expr NOT expr */ |
| 183978 | +{ |
| 183979 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); |
| 183980 | +} |
| 183981 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183982 | + break; |
| 183983 | + case 10: /* expr ::= colset COLON LP expr RP */ |
| 183984 | +{ |
| 183985 | + sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11); |
| 183986 | + fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24; |
| 183987 | +} |
| 183988 | + fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183989 | + break; |
| 183990 | + case 11: /* expr ::= LP expr RP */ |
| 183991 | +{fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;} |
| 183992 | + break; |
| 183993 | + case 12: /* expr ::= exprlist */ |
| 183994 | + case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13); |
| 183995 | +{fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;} |
| 183996 | + fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 183997 | + break; |
| 183998 | + case 14: /* exprlist ::= exprlist cnearset */ |
| 183999 | +{ |
| 184000 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24); |
| 184001 | +} |
| 184002 | + fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184003 | + break; |
| 184004 | + case 15: /* cnearset ::= nearset */ |
| 184005 | +{ |
| 184006 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 184007 | +} |
| 184008 | + fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184009 | + break; |
| 184010 | + case 16: /* cnearset ::= colset COLON nearset */ |
| 184011 | +{ |
| 184012 | + fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); |
| 184013 | + sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11); |
| 184014 | +} |
| 184015 | + fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; |
| 184016 | + break; |
| 184017 | + case 17: /* nearset ::= phrase */ |
| 184018 | +{ fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } |
| 184019 | + fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 184020 | + break; |
| 184021 | + case 18: /* nearset ::= STRING LP nearphrases neardist_opt RP */ |
| 183537 | 184022 | { |
| 183538 | 184023 | sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0); |
| 183539 | 184024 | sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0); |
| 183540 | 184025 | fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46; |
| 183541 | 184026 | } |
| 183542 | 184027 | fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183543 | 184028 | break; |
| 183544 | | - case 18: /* nearphrases ::= phrase */ |
| 184029 | + case 19: /* nearphrases ::= phrase */ |
| 183545 | 184030 | { |
| 183546 | 184031 | fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); |
| 183547 | 184032 | } |
| 183548 | 184033 | fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183549 | 184034 | break; |
| 183550 | | - case 19: /* nearphrases ::= nearphrases phrase */ |
| 184035 | + case 20: /* nearphrases ::= nearphrases phrase */ |
| 183551 | 184036 | { |
| 183552 | 184037 | fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53); |
| 183553 | 184038 | } |
| 183554 | 184039 | fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46; |
| 183555 | 184040 | break; |
| 183556 | | - case 20: /* neardist_opt ::= */ |
| 184041 | + case 21: /* neardist_opt ::= */ |
| 183557 | 184042 | { fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; } |
| 183558 | 184043 | break; |
| 183559 | | - case 21: /* neardist_opt ::= COMMA STRING */ |
| 184044 | + case 22: /* neardist_opt ::= COMMA STRING */ |
| 183560 | 184045 | { fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; } |
| 183561 | 184046 | break; |
| 183562 | | - case 22: /* phrase ::= phrase PLUS STRING star_opt */ |
| 184047 | + case 23: /* phrase ::= phrase PLUS STRING star_opt */ |
| 183563 | 184048 | { |
| 183564 | 184049 | fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); |
| 183565 | 184050 | } |
| 183566 | 184051 | fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53; |
| 183567 | 184052 | break; |
| 183568 | | - case 23: /* phrase ::= STRING star_opt */ |
| 184053 | + case 24: /* phrase ::= STRING star_opt */ |
| 183569 | 184054 | { |
| 183570 | 184055 | fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); |
| 183571 | 184056 | } |
| 183572 | 184057 | fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53; |
| 183573 | 184058 | break; |
| 183574 | | - case 24: /* star_opt ::= STAR */ |
| 184059 | + case 25: /* star_opt ::= STAR */ |
| 183575 | 184060 | { fts5yymsp[0].minor.fts5yy4 = 1; } |
| 183576 | 184061 | break; |
| 183577 | | - case 25: /* star_opt ::= */ |
| 184062 | + case 26: /* star_opt ::= */ |
| 183578 | 184063 | { fts5yymsp[1].minor.fts5yy4 = 0; } |
| 183579 | 184064 | break; |
| 183580 | 184065 | default: |
| 183581 | 184066 | break; |
| 183582 | 184067 | /********** End reduce actions ************************************************/ |
| | @@ -186115,10 +186600,11 @@ |
| 186115 | 186600 | static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc((int)t); } |
| 186116 | 186601 | static void fts5ParseFree(void *p){ sqlite3_free(p); } |
| 186117 | 186602 | |
| 186118 | 186603 | static int sqlite3Fts5ExprNew( |
| 186119 | 186604 | Fts5Config *pConfig, /* FTS5 Configuration */ |
| 186605 | + int iCol, |
| 186120 | 186606 | const char *zExpr, /* Expression text */ |
| 186121 | 186607 | Fts5Expr **ppNew, |
| 186122 | 186608 | char **pzErr |
| 186123 | 186609 | ){ |
| 186124 | 186610 | Fts5Parse sParse; |
| | @@ -186138,10 +186624,22 @@ |
| 186138 | 186624 | do { |
| 186139 | 186625 | t = fts5ExprGetToken(&sParse, &z, &token); |
| 186140 | 186626 | sqlite3Fts5Parser(pEngine, t, token, &sParse); |
| 186141 | 186627 | }while( sParse.rc==SQLITE_OK && t!=FTS5_EOF ); |
| 186142 | 186628 | sqlite3Fts5ParserFree(pEngine, fts5ParseFree); |
| 186629 | + |
| 186630 | + /* If the LHS of the MATCH expression was a user column, apply the |
| 186631 | + ** implicit column-filter. */ |
| 186632 | + if( iCol<pConfig->nCol && sParse.pExpr && sParse.rc==SQLITE_OK ){ |
| 186633 | + int n = sizeof(Fts5Colset); |
| 186634 | + Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&sParse.rc, n); |
| 186635 | + if( pColset ){ |
| 186636 | + pColset->nCol = 1; |
| 186637 | + pColset->aiCol[0] = iCol; |
| 186638 | + sqlite3Fts5ParseSetColset(&sParse, sParse.pExpr, pColset); |
| 186639 | + } |
| 186640 | + } |
| 186143 | 186641 | |
| 186144 | 186642 | assert( sParse.rc!=SQLITE_OK || sParse.zErr==0 ); |
| 186145 | 186643 | if( sParse.rc==SQLITE_OK ){ |
| 186146 | 186644 | *ppNew = pNew = sqlite3_malloc(sizeof(Fts5Expr)); |
| 186147 | 186645 | if( pNew==0 ){ |
| | @@ -187788,29 +188286,114 @@ |
| 187788 | 188286 | } |
| 187789 | 188287 | |
| 187790 | 188288 | return pRet; |
| 187791 | 188289 | } |
| 187792 | 188290 | |
| 188291 | +/* |
| 188292 | +** If argument pOrig is NULL, or if (*pRc) is set to anything other than |
| 188293 | +** SQLITE_OK when this function is called, NULL is returned. |
| 188294 | +** |
| 188295 | +** Otherwise, a copy of (*pOrig) is made into memory obtained from |
| 188296 | +** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation |
| 188297 | +** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned. |
| 188298 | +*/ |
| 188299 | +static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){ |
| 188300 | + Fts5Colset *pRet; |
| 188301 | + if( pOrig ){ |
| 188302 | + int nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int); |
| 188303 | + pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte); |
| 188304 | + if( pRet ){ |
| 188305 | + memcpy(pRet, pOrig, nByte); |
| 188306 | + } |
| 188307 | + }else{ |
| 188308 | + pRet = 0; |
| 188309 | + } |
| 188310 | + return pRet; |
| 188311 | +} |
| 188312 | + |
| 188313 | +/* |
| 188314 | +** Remove from colset pColset any columns that are not also in colset pMerge. |
| 188315 | +*/ |
| 188316 | +static void fts5MergeColset(Fts5Colset *pColset, Fts5Colset *pMerge){ |
| 188317 | + int iIn = 0; /* Next input in pColset */ |
| 188318 | + int iMerge = 0; /* Next input in pMerge */ |
| 188319 | + int iOut = 0; /* Next output slot in pColset */ |
| 188320 | + |
| 188321 | + while( iIn<pColset->nCol && iMerge<pMerge->nCol ){ |
| 188322 | + int iDiff = pColset->aiCol[iIn] - pMerge->aiCol[iMerge]; |
| 188323 | + if( iDiff==0 ){ |
| 188324 | + pColset->aiCol[iOut++] = pMerge->aiCol[iMerge]; |
| 188325 | + iMerge++; |
| 188326 | + iIn++; |
| 188327 | + }else if( iDiff>0 ){ |
| 188328 | + iMerge++; |
| 188329 | + }else{ |
| 188330 | + iIn++; |
| 188331 | + } |
| 188332 | + } |
| 188333 | + pColset->nCol = iOut; |
| 188334 | +} |
| 188335 | + |
| 188336 | +/* |
| 188337 | +** Recursively apply colset pColset to expression node pNode and all of |
| 188338 | +** its decendents. If (*ppFree) is not NULL, it contains a spare copy |
| 188339 | +** of pColset. This function may use the spare copy and set (*ppFree) to |
| 188340 | +** zero, or it may create copies of pColset using fts5CloneColset(). |
| 188341 | +*/ |
| 188342 | +static void fts5ParseSetColset( |
| 188343 | + Fts5Parse *pParse, |
| 188344 | + Fts5ExprNode *pNode, |
| 188345 | + Fts5Colset *pColset, |
| 188346 | + Fts5Colset **ppFree |
| 188347 | +){ |
| 188348 | + if( pParse->rc==SQLITE_OK ){ |
| 188349 | + assert( pNode->eType==FTS5_TERM || pNode->eType==FTS5_STRING |
| 188350 | + || pNode->eType==FTS5_AND || pNode->eType==FTS5_OR |
| 188351 | + || pNode->eType==FTS5_NOT || pNode->eType==FTS5_EOF |
| 188352 | + ); |
| 188353 | + if( pNode->eType==FTS5_STRING || pNode->eType==FTS5_TERM ){ |
| 188354 | + Fts5ExprNearset *pNear = pNode->pNear; |
| 188355 | + if( pNear->pColset ){ |
| 188356 | + fts5MergeColset(pNear->pColset, pColset); |
| 188357 | + if( pNear->pColset->nCol==0 ){ |
| 188358 | + pNode->eType = FTS5_EOF; |
| 188359 | + pNode->xNext = 0; |
| 188360 | + } |
| 188361 | + }else if( *ppFree ){ |
| 188362 | + pNear->pColset = pColset; |
| 188363 | + *ppFree = 0; |
| 188364 | + }else{ |
| 188365 | + pNear->pColset = fts5CloneColset(&pParse->rc, pColset); |
| 188366 | + } |
| 188367 | + }else{ |
| 188368 | + int i; |
| 188369 | + assert( pNode->eType!=FTS5_EOF || pNode->nChild==0 ); |
| 188370 | + for(i=0; i<pNode->nChild; i++){ |
| 188371 | + fts5ParseSetColset(pParse, pNode->apChild[i], pColset, ppFree); |
| 188372 | + } |
| 188373 | + } |
| 188374 | + } |
| 188375 | +} |
| 188376 | + |
| 188377 | +/* |
| 188378 | +** Apply colset pColset to expression node pExpr and all of its descendents. |
| 188379 | +*/ |
| 187793 | 188380 | static void sqlite3Fts5ParseSetColset( |
| 187794 | 188381 | Fts5Parse *pParse, |
| 187795 | | - Fts5ExprNearset *pNear, |
| 188382 | + Fts5ExprNode *pExpr, |
| 187796 | 188383 | Fts5Colset *pColset |
| 187797 | 188384 | ){ |
| 188385 | + Fts5Colset *pFree = pColset; |
| 187798 | 188386 | if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){ |
| 187799 | 188387 | pParse->rc = SQLITE_ERROR; |
| 187800 | 188388 | pParse->zErr = sqlite3_mprintf( |
| 187801 | 188389 | "fts5: column queries are not supported (detail=none)" |
| 187802 | 188390 | ); |
| 187803 | | - sqlite3_free(pColset); |
| 187804 | | - return; |
| 187805 | | - } |
| 187806 | | - |
| 187807 | | - if( pNear ){ |
| 187808 | | - pNear->pColset = pColset; |
| 187809 | | - }else{ |
| 187810 | | - sqlite3_free(pColset); |
| 187811 | | - } |
| 188391 | + }else{ |
| 188392 | + fts5ParseSetColset(pParse, pExpr, pColset, &pFree); |
| 188393 | + } |
| 188394 | + sqlite3_free(pFree); |
| 187812 | 188395 | } |
| 187813 | 188396 | |
| 187814 | 188397 | static void fts5ExprAssignXNext(Fts5ExprNode *pNode){ |
| 187815 | 188398 | switch( pNode->eType ){ |
| 187816 | 188399 | case FTS5_STRING: { |
| | @@ -188260,11 +188843,11 @@ |
| 188260 | 188843 | |
| 188261 | 188844 | zExpr = (const char*)sqlite3_value_text(apVal[0]); |
| 188262 | 188845 | |
| 188263 | 188846 | rc = sqlite3Fts5ConfigParse(pGlobal, db, nConfig, azConfig, &pConfig, &zErr); |
| 188264 | 188847 | if( rc==SQLITE_OK ){ |
| 188265 | | - rc = sqlite3Fts5ExprNew(pConfig, zExpr, &pExpr, &zErr); |
| 188848 | + rc = sqlite3Fts5ExprNew(pConfig, pConfig->nCol, zExpr, &pExpr, &zErr); |
| 188266 | 188849 | } |
| 188267 | 188850 | if( rc==SQLITE_OK ){ |
| 188268 | 188851 | char *zText; |
| 188269 | 188852 | if( pExpr->pRoot->xNext==0 ){ |
| 188270 | 188853 | zText = sqlite3_mprintf(""); |
| | @@ -189776,11 +190359,10 @@ |
| 189776 | 190359 | sqlite3_blob *pReader = p->pReader; |
| 189777 | 190360 | p->pReader = 0; |
| 189778 | 190361 | sqlite3_blob_close(pReader); |
| 189779 | 190362 | } |
| 189780 | 190363 | } |
| 189781 | | - |
| 189782 | 190364 | |
| 189783 | 190365 | /* |
| 189784 | 190366 | ** Retrieve a record from the %_data table. |
| 189785 | 190367 | ** |
| 189786 | 190368 | ** If an error occurs, NULL is returned and an error left in the |
| | @@ -192028,11 +192610,12 @@ |
| 192028 | 192610 | Fts5Iter *pIter, |
| 192029 | 192611 | int *pbNewTerm /* OUT: True if *might* be new term */ |
| 192030 | 192612 | ){ |
| 192031 | 192613 | assert( pIter->bSkipEmpty ); |
| 192032 | 192614 | if( p->rc==SQLITE_OK ){ |
| 192033 | | - do { |
| 192615 | + *pbNewTerm = 0; |
| 192616 | + do{ |
| 192034 | 192617 | int iFirst = pIter->aFirst[1].iFirst; |
| 192035 | 192618 | Fts5SegIter *pSeg = &pIter->aSeg[iFirst]; |
| 192036 | 192619 | int bNewTerm = 0; |
| 192037 | 192620 | |
| 192038 | 192621 | assert( p->rc==SQLITE_OK ); |
| | @@ -192041,12 +192624,10 @@ |
| 192041 | 192624 | || fts5MultiIterAdvanceRowid(pIter, iFirst, &pSeg) |
| 192042 | 192625 | ){ |
| 192043 | 192626 | fts5MultiIterAdvanced(p, pIter, iFirst, 1); |
| 192044 | 192627 | fts5MultiIterSetEof(pIter); |
| 192045 | 192628 | *pbNewTerm = 1; |
| 192046 | | - }else{ |
| 192047 | | - *pbNewTerm = 0; |
| 192048 | 192629 | } |
| 192049 | 192630 | fts5AssertMultiIterSetup(p, pIter); |
| 192050 | 192631 | |
| 192051 | 192632 | }while( fts5MultiIterIsEmpty(p, pIter) ); |
| 192052 | 192633 | } |
| | @@ -192308,27 +192889,27 @@ |
| 192308 | 192889 | } |
| 192309 | 192890 | |
| 192310 | 192891 | return p - (*pa); |
| 192311 | 192892 | } |
| 192312 | 192893 | |
| 192313 | | -static int fts5IndexExtractColset ( |
| 192894 | +static void fts5IndexExtractColset( |
| 192895 | + int *pRc, |
| 192314 | 192896 | Fts5Colset *pColset, /* Colset to filter on */ |
| 192315 | 192897 | const u8 *pPos, int nPos, /* Position list */ |
| 192316 | 192898 | Fts5Buffer *pBuf /* Output buffer */ |
| 192317 | 192899 | ){ |
| 192318 | | - int rc = SQLITE_OK; |
| 192319 | | - int i; |
| 192320 | | - |
| 192321 | | - fts5BufferZero(pBuf); |
| 192322 | | - for(i=0; i<pColset->nCol; i++){ |
| 192323 | | - const u8 *pSub = pPos; |
| 192324 | | - int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]); |
| 192325 | | - if( nSub ){ |
| 192326 | | - fts5BufferAppendBlob(&rc, pBuf, nSub, pSub); |
| 192900 | + if( *pRc==SQLITE_OK ){ |
| 192901 | + int i; |
| 192902 | + fts5BufferZero(pBuf); |
| 192903 | + for(i=0; i<pColset->nCol; i++){ |
| 192904 | + const u8 *pSub = pPos; |
| 192905 | + int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]); |
| 192906 | + if( nSub ){ |
| 192907 | + fts5BufferAppendBlob(pRc, pBuf, nSub, pSub); |
| 192908 | + } |
| 192327 | 192909 | } |
| 192328 | 192910 | } |
| 192329 | | - return rc; |
| 192330 | 192911 | } |
| 192331 | 192912 | |
| 192332 | 192913 | /* |
| 192333 | 192914 | ** xSetOutputs callback used by detail=none tables. |
| 192334 | 192915 | */ |
| | @@ -192448,12 +193029,13 @@ |
| 192448 | 193029 | const u8 *a = &pSeg->pLeaf->p[pSeg->iLeafOffset]; |
| 192449 | 193030 | if( pColset->nCol==1 ){ |
| 192450 | 193031 | pIter->base.nData = fts5IndexExtractCol(&a, pSeg->nPos,pColset->aiCol[0]); |
| 192451 | 193032 | pIter->base.pData = a; |
| 192452 | 193033 | }else{ |
| 193034 | + int *pRc = &pIter->pIndex->rc; |
| 192453 | 193035 | fts5BufferZero(&pIter->poslist); |
| 192454 | | - fts5IndexExtractColset(pColset, a, pSeg->nPos, &pIter->poslist); |
| 193036 | + fts5IndexExtractColset(pRc, pColset, a, pSeg->nPos, &pIter->poslist); |
| 192455 | 193037 | pIter->base.pData = pIter->poslist.p; |
| 192456 | 193038 | pIter->base.nData = pIter->poslist.n; |
| 192457 | 193039 | } |
| 192458 | 193040 | }else{ |
| 192459 | 193041 | /* The data is distributed over two or more pages. Copy it into the |
| | @@ -192994,13 +193576,10 @@ |
| 192994 | 193576 | static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){ |
| 192995 | 193577 | static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 }; |
| 192996 | 193578 | Fts5PageWriter *pPage = &pWriter->writer; |
| 192997 | 193579 | i64 iRowid; |
| 192998 | 193580 | |
| 192999 | | -static int nCall = 0; |
| 193000 | | -nCall++; |
| 193001 | | - |
| 193002 | 193581 | assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) ); |
| 193003 | 193582 | |
| 193004 | 193583 | /* Set the szLeaf header field. */ |
| 193005 | 193584 | assert( 0==fts5GetU16(&pPage->buf.p[2]) ); |
| 193006 | 193585 | fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n); |
| | @@ -194280,14 +194859,14 @@ |
| 194280 | 194859 | } |
| 194281 | 194860 | |
| 194282 | 194861 | /* |
| 194283 | 194862 | ** Commit data to disk. |
| 194284 | 194863 | */ |
| 194285 | | -static int sqlite3Fts5IndexSync(Fts5Index *p, int bCommit){ |
| 194864 | +static int sqlite3Fts5IndexSync(Fts5Index *p){ |
| 194286 | 194865 | assert( p->rc==SQLITE_OK ); |
| 194287 | 194866 | fts5IndexFlush(p); |
| 194288 | | - if( bCommit ) fts5CloseReader(p); |
| 194867 | + fts5CloseReader(p); |
| 194289 | 194868 | return fts5IndexReturn(p); |
| 194290 | 194869 | } |
| 194291 | 194870 | |
| 194292 | 194871 | /* |
| 194293 | 194872 | ** Discard any data stored in the in-memory hash tables. Do not write it |
| | @@ -196147,10 +196726,11 @@ |
| 196147 | 196726 | ** Costs are not modified by the ORDER BY clause. |
| 196148 | 196727 | */ |
| 196149 | 196728 | static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){ |
| 196150 | 196729 | Fts5Table *pTab = (Fts5Table*)pVTab; |
| 196151 | 196730 | Fts5Config *pConfig = pTab->pConfig; |
| 196731 | + const int nCol = pConfig->nCol; |
| 196152 | 196732 | int idxFlags = 0; /* Parameter passed through to xFilter() */ |
| 196153 | 196733 | int bHasMatch; |
| 196154 | 196734 | int iNext; |
| 196155 | 196735 | int i; |
| 196156 | 196736 | |
| | @@ -196172,28 +196752,38 @@ |
| 196172 | 196752 | FTS5_BI_ROWID_GE, 0, 0, -1}, |
| 196173 | 196753 | }; |
| 196174 | 196754 | |
| 196175 | 196755 | int aColMap[3]; |
| 196176 | 196756 | aColMap[0] = -1; |
| 196177 | | - aColMap[1] = pConfig->nCol; |
| 196178 | | - aColMap[2] = pConfig->nCol+1; |
| 196757 | + aColMap[1] = nCol; |
| 196758 | + aColMap[2] = nCol+1; |
| 196179 | 196759 | |
| 196180 | 196760 | /* Set idxFlags flags for all WHERE clause terms that will be used. */ |
| 196181 | 196761 | for(i=0; i<pInfo->nConstraint; i++){ |
| 196182 | 196762 | struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; |
| 196183 | | - int j; |
| 196184 | | - for(j=0; j<ArraySize(aConstraint); j++){ |
| 196185 | | - struct Constraint *pC = &aConstraint[j]; |
| 196186 | | - if( p->iColumn==aColMap[pC->iCol] && p->op & pC->op ){ |
| 196187 | | - if( p->usable ){ |
| 196763 | + int iCol = p->iColumn; |
| 196764 | + |
| 196765 | + if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol) |
| 196766 | + || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol) |
| 196767 | + ){ |
| 196768 | + /* A MATCH operator or equivalent */ |
| 196769 | + if( p->usable ){ |
| 196770 | + idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16); |
| 196771 | + aConstraint[0].iConsIndex = i; |
| 196772 | + }else{ |
| 196773 | + /* As there exists an unusable MATCH constraint this is an |
| 196774 | + ** unusable plan. Set a prohibitively high cost. */ |
| 196775 | + pInfo->estimatedCost = 1e50; |
| 196776 | + return SQLITE_OK; |
| 196777 | + } |
| 196778 | + }else{ |
| 196779 | + int j; |
| 196780 | + for(j=1; j<ArraySize(aConstraint); j++){ |
| 196781 | + struct Constraint *pC = &aConstraint[j]; |
| 196782 | + if( iCol==aColMap[pC->iCol] && p->op & pC->op && p->usable ){ |
| 196188 | 196783 | pC->iConsIndex = i; |
| 196189 | 196784 | idxFlags |= pC->fts5op; |
| 196190 | | - }else if( j==0 ){ |
| 196191 | | - /* As there exists an unusable MATCH constraint this is an |
| 196192 | | - ** unusable plan. Set a prohibitively high cost. */ |
| 196193 | | - pInfo->estimatedCost = 1e50; |
| 196194 | | - return SQLITE_OK; |
| 196195 | 196785 | } |
| 196196 | 196786 | } |
| 196197 | 196787 | } |
| 196198 | 196788 | } |
| 196199 | 196789 | |
| | @@ -196764,10 +197354,11 @@ |
| 196764 | 197354 | sqlite3_value *pMatch = 0; /* <tbl> MATCH ? expression (or NULL) */ |
| 196765 | 197355 | sqlite3_value *pRank = 0; /* rank MATCH ? expression (or NULL) */ |
| 196766 | 197356 | sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */ |
| 196767 | 197357 | sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */ |
| 196768 | 197358 | sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */ |
| 197359 | + int iCol; /* Column on LHS of MATCH operator */ |
| 196769 | 197360 | char **pzErrmsg = pConfig->pzErrmsg; |
| 196770 | 197361 | |
| 196771 | 197362 | UNUSED_PARAM(zUnused); |
| 196772 | 197363 | UNUSED_PARAM(nVal); |
| 196773 | 197364 | |
| | @@ -196794,10 +197385,12 @@ |
| 196794 | 197385 | if( BitFlagTest(idxNum, FTS5_BI_MATCH) ) pMatch = apVal[iVal++]; |
| 196795 | 197386 | if( BitFlagTest(idxNum, FTS5_BI_RANK) ) pRank = apVal[iVal++]; |
| 196796 | 197387 | if( BitFlagTest(idxNum, FTS5_BI_ROWID_EQ) ) pRowidEq = apVal[iVal++]; |
| 196797 | 197388 | if( BitFlagTest(idxNum, FTS5_BI_ROWID_LE) ) pRowidLe = apVal[iVal++]; |
| 196798 | 197389 | if( BitFlagTest(idxNum, FTS5_BI_ROWID_GE) ) pRowidGe = apVal[iVal++]; |
| 197390 | + iCol = (idxNum>>16); |
| 197391 | + assert( iCol>=0 && iCol<=pConfig->nCol ); |
| 196799 | 197392 | assert( iVal==nVal ); |
| 196800 | 197393 | bOrderByRank = ((idxNum & FTS5_BI_ORDER_RANK) ? 1 : 0); |
| 196801 | 197394 | pCsr->bDesc = bDesc = ((idxNum & FTS5_BI_ORDER_DESC) ? 1 : 0); |
| 196802 | 197395 | |
| 196803 | 197396 | /* Set the cursor upper and lower rowid limits. Only some strategies |
| | @@ -196840,11 +197433,11 @@ |
| 196840 | 197433 | ** indicates that the MATCH expression is not a full text query, |
| 196841 | 197434 | ** but a request for an internal parameter. */ |
| 196842 | 197435 | rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]); |
| 196843 | 197436 | }else{ |
| 196844 | 197437 | char **pzErr = &pTab->base.zErrMsg; |
| 196845 | | - rc = sqlite3Fts5ExprNew(pConfig, zExpr, &pCsr->pExpr, pzErr); |
| 197438 | + rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr); |
| 196846 | 197439 | if( rc==SQLITE_OK ){ |
| 196847 | 197440 | if( bOrderByRank ){ |
| 196848 | 197441 | pCsr->ePlan = FTS5_PLAN_SORTED_MATCH; |
| 196849 | 197442 | rc = fts5CursorFirstSorted(pTab, pCsr, bDesc); |
| 196850 | 197443 | }else{ |
| | @@ -197220,11 +197813,11 @@ |
| 197220 | 197813 | int rc; |
| 197221 | 197814 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 197222 | 197815 | fts5CheckTransactionState(pTab, FTS5_SYNC, 0); |
| 197223 | 197816 | pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg; |
| 197224 | 197817 | fts5TripCursors(pTab); |
| 197225 | | - rc = sqlite3Fts5StorageSync(pTab->pStorage, 1); |
| 197818 | + rc = sqlite3Fts5StorageSync(pTab->pStorage); |
| 197226 | 197819 | pTab->pConfig->pzErrmsg = 0; |
| 197227 | 197820 | return rc; |
| 197228 | 197821 | } |
| 197229 | 197822 | |
| 197230 | 197823 | /* |
| | @@ -198031,11 +198624,11 @@ |
| 198031 | 198624 | static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 198032 | 198625 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 198033 | 198626 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 198034 | 198627 | fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint); |
| 198035 | 198628 | fts5TripCursors(pTab); |
| 198036 | | - return sqlite3Fts5StorageSync(pTab->pStorage, 0); |
| 198629 | + return sqlite3Fts5StorageSync(pTab->pStorage); |
| 198037 | 198630 | } |
| 198038 | 198631 | |
| 198039 | 198632 | /* |
| 198040 | 198633 | ** The xRelease() method. |
| 198041 | 198634 | ** |
| | @@ -198044,11 +198637,11 @@ |
| 198044 | 198637 | static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 198045 | 198638 | Fts5Table *pTab = (Fts5Table*)pVtab; |
| 198046 | 198639 | UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */ |
| 198047 | 198640 | fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint); |
| 198048 | 198641 | fts5TripCursors(pTab); |
| 198049 | | - return sqlite3Fts5StorageSync(pTab->pStorage, 0); |
| 198642 | + return sqlite3Fts5StorageSync(pTab->pStorage); |
| 198050 | 198643 | } |
| 198051 | 198644 | |
| 198052 | 198645 | /* |
| 198053 | 198646 | ** The xRollbackTo() method. |
| 198054 | 198647 | ** |
| | @@ -198255,11 +198848,11 @@ |
| 198255 | 198848 | int nArg, /* Number of args */ |
| 198256 | 198849 | sqlite3_value **apUnused /* Function arguments */ |
| 198257 | 198850 | ){ |
| 198258 | 198851 | assert( nArg==0 ); |
| 198259 | 198852 | UNUSED_PARAM2(nArg, apUnused); |
| 198260 | | - sqlite3_result_text(pCtx, "fts5: 2017-03-28 18:48:43 424a0d380332858ee55bdebc4af3789f74e70a2b3ba1cf29d84b9b4bcf3e2e37", -1, SQLITE_TRANSIENT); |
| 198853 | + sqlite3_result_text(pCtx, "fts5: 2017-05-02 18:00:31 430f539cbb3f806fb89191e0b759a5f8b49d9e5b6c95fe9a4b55a1aa0875762a", -1, SQLITE_TRANSIENT); |
| 198261 | 198854 | } |
| 198262 | 198855 | |
| 198263 | 198856 | static int fts5Init(sqlite3 *db){ |
| 198264 | 198857 | static const sqlite3_module fts5Mod = { |
| 198265 | 198858 | /* iVersion */ 2, |
| | @@ -198591,11 +199184,11 @@ |
| 198591 | 199184 | } |
| 198592 | 199185 | } |
| 198593 | 199186 | |
| 198594 | 199187 | static int sqlite3Fts5StorageRename(Fts5Storage *pStorage, const char *zName){ |
| 198595 | 199188 | Fts5Config *pConfig = pStorage->pConfig; |
| 198596 | | - int rc = sqlite3Fts5StorageSync(pStorage, 1); |
| 199189 | + int rc = sqlite3Fts5StorageSync(pStorage); |
| 198597 | 199190 | |
| 198598 | 199191 | fts5StorageRenameOne(pConfig, &rc, "data", zName); |
| 198599 | 199192 | fts5StorageRenameOne(pConfig, &rc, "idx", zName); |
| 198600 | 199193 | fts5StorageRenameOne(pConfig, &rc, "config", zName); |
| 198601 | 199194 | if( pConfig->bColumnsize ){ |
| | @@ -199454,19 +200047,19 @@ |
| 199454 | 200047 | } |
| 199455 | 200048 | |
| 199456 | 200049 | /* |
| 199457 | 200050 | ** Flush any data currently held in-memory to disk. |
| 199458 | 200051 | */ |
| 199459 | | -static int sqlite3Fts5StorageSync(Fts5Storage *p, int bCommit){ |
| 200052 | +static int sqlite3Fts5StorageSync(Fts5Storage *p){ |
| 199460 | 200053 | int rc = SQLITE_OK; |
| 199461 | 200054 | i64 iLastRowid = sqlite3_last_insert_rowid(p->pConfig->db); |
| 199462 | 200055 | if( p->bTotalsValid ){ |
| 199463 | 200056 | rc = fts5StorageSaveTotals(p); |
| 199464 | | - if( bCommit ) p->bTotalsValid = 0; |
| 200057 | + p->bTotalsValid = 0; |
| 199465 | 200058 | } |
| 199466 | 200059 | if( rc==SQLITE_OK ){ |
| 199467 | | - rc = sqlite3Fts5IndexSync(p->pIndex, bCommit); |
| 200060 | + rc = sqlite3Fts5IndexSync(p->pIndex); |
| 199468 | 200061 | } |
| 199469 | 200062 | sqlite3_set_last_insert_rowid(p->pConfig->db, iLastRowid); |
| 199470 | 200063 | return rc; |
| 199471 | 200064 | } |
| 199472 | 200065 | |
| 199473 | 200066 | |