| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.8.1. By combining all the individual C code files into this |
| 3 | +** version 3.8.2. 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. |
| | @@ -133,13 +133,13 @@ |
| 133 | 133 | ** |
| 134 | 134 | ** See also: [sqlite3_libversion()], |
| 135 | 135 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 136 | 136 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 137 | 137 | */ |
| 138 | | -#define SQLITE_VERSION "3.8.1" |
| 139 | | -#define SQLITE_VERSION_NUMBER 3008001 |
| 140 | | -#define SQLITE_SOURCE_ID "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a" |
| 138 | +#define SQLITE_VERSION "3.8.2" |
| 139 | +#define SQLITE_VERSION_NUMBER 3008002 |
| 140 | +#define SQLITE_SOURCE_ID "2013-11-11 16:55:52 924d63b283a3d059838114c95d42c6feaf913529" |
| 141 | 141 | |
| 142 | 142 | /* |
| 143 | 143 | ** CAPI3REF: Run-Time Library Version Numbers |
| 144 | 144 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 145 | 145 | ** |
| | @@ -527,10 +527,11 @@ |
| 527 | 527 | #define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8)) |
| 528 | 528 | #define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) |
| 529 | 529 | #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) |
| 530 | 530 | #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) |
| 531 | 531 | #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) |
| 532 | +#define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) |
| 532 | 533 | #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) |
| 533 | 534 | #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) |
| 534 | 535 | #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) |
| 535 | 536 | |
| 536 | 537 | /* |
| | @@ -938,10 +939,18 @@ |
| 938 | 939 | ** pointer is overwritten with the old value. The limit is not changed if |
| 939 | 940 | ** the value originally pointed to is negative, and so the current limit |
| 940 | 941 | ** can be queried by passing in a pointer to a negative number. This |
| 941 | 942 | ** file-control is used internally to implement [PRAGMA mmap_size]. |
| 942 | 943 | ** |
| 944 | +** <li>[[SQLITE_FCNTL_TRACE]] |
| 945 | +** The [SQLITE_FCNTL_TRACE] file control provides advisory information |
| 946 | +** to the VFS about what the higher layers of the SQLite stack are doing. |
| 947 | +** This file control is used by some VFS activity tracing [shims]. |
| 948 | +** The argument is a zero-terminated string. Higher layers in the |
| 949 | +** SQLite stack may generate instances of this file control if |
| 950 | +** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled. |
| 951 | +** |
| 943 | 952 | ** </ul> |
| 944 | 953 | */ |
| 945 | 954 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 946 | 955 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 947 | 956 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| | @@ -957,10 +966,11 @@ |
| 957 | 966 | #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 |
| 958 | 967 | #define SQLITE_FCNTL_PRAGMA 14 |
| 959 | 968 | #define SQLITE_FCNTL_BUSYHANDLER 15 |
| 960 | 969 | #define SQLITE_FCNTL_TEMPFILENAME 16 |
| 961 | 970 | #define SQLITE_FCNTL_MMAP_SIZE 18 |
| 971 | +#define SQLITE_FCNTL_TRACE 19 |
| 962 | 972 | |
| 963 | 973 | /* |
| 964 | 974 | ** CAPI3REF: Mutex Handle |
| 965 | 975 | ** |
| 966 | 976 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| | @@ -1803,23 +1813,25 @@ |
| 1803 | 1813 | SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); |
| 1804 | 1814 | |
| 1805 | 1815 | /* |
| 1806 | 1816 | ** CAPI3REF: Last Insert Rowid |
| 1807 | 1817 | ** |
| 1808 | | -** ^Each entry in an SQLite table has a unique 64-bit signed |
| 1818 | +** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables) |
| 1819 | +** has a unique 64-bit signed |
| 1809 | 1820 | ** integer key called the [ROWID | "rowid"]. ^The rowid is always available |
| 1810 | 1821 | ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those |
| 1811 | 1822 | ** names are not also used by explicitly declared columns. ^If |
| 1812 | 1823 | ** the table has a column of type [INTEGER PRIMARY KEY] then that column |
| 1813 | 1824 | ** is another alias for the rowid. |
| 1814 | 1825 | ** |
| 1815 | | -** ^This routine returns the [rowid] of the most recent |
| 1816 | | -** successful [INSERT] into the database from the [database connection] |
| 1817 | | -** in the first argument. ^As of SQLite version 3.7.7, this routines |
| 1818 | | -** records the last insert rowid of both ordinary tables and [virtual tables]. |
| 1819 | | -** ^If no successful [INSERT]s |
| 1820 | | -** have ever occurred on that database connection, zero is returned. |
| 1826 | +** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the |
| 1827 | +** most recent successful [INSERT] into a rowid table or [virtual table] |
| 1828 | +** on database connection D. |
| 1829 | +** ^Inserts into [WITHOUT ROWID] tables are not recorded. |
| 1830 | +** ^If no successful [INSERT]s into rowid tables |
| 1831 | +** have ever occurred on the database connection D, |
| 1832 | +** then sqlite3_last_insert_rowid(D) returns zero. |
| 1821 | 1833 | ** |
| 1822 | 1834 | ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] |
| 1823 | 1835 | ** method, then this routine will return the [rowid] of the inserted |
| 1824 | 1836 | ** row as long as the trigger or virtual table method is running. |
| 1825 | 1837 | ** But once the trigger or virtual table method ends, the value returned |
| | @@ -4832,16 +4844,17 @@ |
| 4832 | 4844 | /* |
| 4833 | 4845 | ** CAPI3REF: Data Change Notification Callbacks |
| 4834 | 4846 | ** |
| 4835 | 4847 | ** ^The sqlite3_update_hook() interface registers a callback function |
| 4836 | 4848 | ** with the [database connection] identified by the first argument |
| 4837 | | -** to be invoked whenever a row is updated, inserted or deleted. |
| 4849 | +** to be invoked whenever a row is updated, inserted or deleted in |
| 4850 | +** a rowid table. |
| 4838 | 4851 | ** ^Any callback set by a previous call to this function |
| 4839 | 4852 | ** for the same database connection is overridden. |
| 4840 | 4853 | ** |
| 4841 | 4854 | ** ^The second argument is a pointer to the function to invoke when a |
| 4842 | | -** row is updated, inserted or deleted. |
| 4855 | +** row is updated, inserted or deleted in a rowid table. |
| 4843 | 4856 | ** ^The first argument to the callback is a copy of the third argument |
| 4844 | 4857 | ** to sqlite3_update_hook(). |
| 4845 | 4858 | ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], |
| 4846 | 4859 | ** or [SQLITE_UPDATE], depending on the operation that caused the callback |
| 4847 | 4860 | ** to be invoked. |
| | @@ -4850,10 +4863,11 @@ |
| 4850 | 4863 | ** ^The final callback parameter is the [rowid] of the row. |
| 4851 | 4864 | ** ^In the case of an update, this is the [rowid] after the update takes place. |
| 4852 | 4865 | ** |
| 4853 | 4866 | ** ^(The update hook is not invoked when internal system tables are |
| 4854 | 4867 | ** modified (i.e. sqlite_master and sqlite_sequence).)^ |
| 4868 | +** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified. |
| 4855 | 4869 | ** |
| 4856 | 4870 | ** ^In the current implementation, the update hook |
| 4857 | 4871 | ** is not invoked when duplication rows are deleted because of an |
| 4858 | 4872 | ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook |
| 4859 | 4873 | ** invoked when rows are deleted using the [truncate optimization]. |
| | @@ -5539,10 +5553,13 @@ |
| 5539 | 5553 | ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of |
| 5540 | 5554 | ** the opened blob. ^The size of a blob may not be changed by this |
| 5541 | 5555 | ** interface. Use the [UPDATE] SQL command to change the size of a |
| 5542 | 5556 | ** blob. |
| 5543 | 5557 | ** |
| 5558 | +** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID] |
| 5559 | +** table. Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables. |
| 5560 | +** |
| 5544 | 5561 | ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces |
| 5545 | 5562 | ** and the built-in [zeroblob] SQL function can be used, if desired, |
| 5546 | 5563 | ** to create an empty, zero-filled blob in which to read or write using |
| 5547 | 5564 | ** this interface. |
| 5548 | 5565 | ** |
| | @@ -7756,10 +7773,17 @@ |
| 7756 | 7773 | #endif |
| 7757 | 7774 | #if defined(NDEBUG) && defined(SQLITE_DEBUG) |
| 7758 | 7775 | # undef NDEBUG |
| 7759 | 7776 | #endif |
| 7760 | 7777 | |
| 7778 | +/* |
| 7779 | +** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on. |
| 7780 | +*/ |
| 7781 | +#if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG) |
| 7782 | +# define SQLITE_ENABLE_EXPLAIN_COMMENTS 1 |
| 7783 | +#endif |
| 7784 | + |
| 7761 | 7785 | /* |
| 7762 | 7786 | ** The testcase() macro is used to aid in coverage testing. When |
| 7763 | 7787 | ** doing coverage testing, the condition inside the argument to |
| 7764 | 7788 | ** testcase() must be evaluated both true and false in order to |
| 7765 | 7789 | ** get full branch coverage. The testcase() macro is inserted |
| | @@ -7972,143 +7996,144 @@ |
| 7972 | 7996 | #define TK_EXISTS 20 |
| 7973 | 7997 | #define TK_TEMP 21 |
| 7974 | 7998 | #define TK_LP 22 |
| 7975 | 7999 | #define TK_RP 23 |
| 7976 | 8000 | #define TK_AS 24 |
| 7977 | | -#define TK_COMMA 25 |
| 7978 | | -#define TK_ID 26 |
| 7979 | | -#define TK_INDEXED 27 |
| 7980 | | -#define TK_ABORT 28 |
| 7981 | | -#define TK_ACTION 29 |
| 7982 | | -#define TK_AFTER 30 |
| 7983 | | -#define TK_ANALYZE 31 |
| 7984 | | -#define TK_ASC 32 |
| 7985 | | -#define TK_ATTACH 33 |
| 7986 | | -#define TK_BEFORE 34 |
| 7987 | | -#define TK_BY 35 |
| 7988 | | -#define TK_CASCADE 36 |
| 7989 | | -#define TK_CAST 37 |
| 7990 | | -#define TK_COLUMNKW 38 |
| 7991 | | -#define TK_CONFLICT 39 |
| 7992 | | -#define TK_DATABASE 40 |
| 7993 | | -#define TK_DESC 41 |
| 7994 | | -#define TK_DETACH 42 |
| 7995 | | -#define TK_EACH 43 |
| 7996 | | -#define TK_FAIL 44 |
| 7997 | | -#define TK_FOR 45 |
| 7998 | | -#define TK_IGNORE 46 |
| 7999 | | -#define TK_INITIALLY 47 |
| 8000 | | -#define TK_INSTEAD 48 |
| 8001 | | -#define TK_LIKE_KW 49 |
| 8002 | | -#define TK_MATCH 50 |
| 8003 | | -#define TK_NO 51 |
| 8004 | | -#define TK_KEY 52 |
| 8005 | | -#define TK_OF 53 |
| 8006 | | -#define TK_OFFSET 54 |
| 8007 | | -#define TK_PRAGMA 55 |
| 8008 | | -#define TK_RAISE 56 |
| 8009 | | -#define TK_REPLACE 57 |
| 8010 | | -#define TK_RESTRICT 58 |
| 8011 | | -#define TK_ROW 59 |
| 8012 | | -#define TK_TRIGGER 60 |
| 8013 | | -#define TK_VACUUM 61 |
| 8014 | | -#define TK_VIEW 62 |
| 8015 | | -#define TK_VIRTUAL 63 |
| 8016 | | -#define TK_REINDEX 64 |
| 8017 | | -#define TK_RENAME 65 |
| 8018 | | -#define TK_CTIME_KW 66 |
| 8019 | | -#define TK_ANY 67 |
| 8020 | | -#define TK_OR 68 |
| 8021 | | -#define TK_AND 69 |
| 8022 | | -#define TK_IS 70 |
| 8023 | | -#define TK_BETWEEN 71 |
| 8024 | | -#define TK_IN 72 |
| 8025 | | -#define TK_ISNULL 73 |
| 8026 | | -#define TK_NOTNULL 74 |
| 8027 | | -#define TK_NE 75 |
| 8028 | | -#define TK_EQ 76 |
| 8029 | | -#define TK_GT 77 |
| 8030 | | -#define TK_LE 78 |
| 8031 | | -#define TK_LT 79 |
| 8032 | | -#define TK_GE 80 |
| 8033 | | -#define TK_ESCAPE 81 |
| 8034 | | -#define TK_BITAND 82 |
| 8035 | | -#define TK_BITOR 83 |
| 8036 | | -#define TK_LSHIFT 84 |
| 8037 | | -#define TK_RSHIFT 85 |
| 8038 | | -#define TK_PLUS 86 |
| 8039 | | -#define TK_MINUS 87 |
| 8040 | | -#define TK_STAR 88 |
| 8041 | | -#define TK_SLASH 89 |
| 8042 | | -#define TK_REM 90 |
| 8043 | | -#define TK_CONCAT 91 |
| 8044 | | -#define TK_COLLATE 92 |
| 8045 | | -#define TK_BITNOT 93 |
| 8046 | | -#define TK_STRING 94 |
| 8047 | | -#define TK_JOIN_KW 95 |
| 8048 | | -#define TK_CONSTRAINT 96 |
| 8049 | | -#define TK_DEFAULT 97 |
| 8050 | | -#define TK_NULL 98 |
| 8051 | | -#define TK_PRIMARY 99 |
| 8052 | | -#define TK_UNIQUE 100 |
| 8053 | | -#define TK_CHECK 101 |
| 8054 | | -#define TK_REFERENCES 102 |
| 8055 | | -#define TK_AUTOINCR 103 |
| 8056 | | -#define TK_ON 104 |
| 8057 | | -#define TK_INSERT 105 |
| 8058 | | -#define TK_DELETE 106 |
| 8059 | | -#define TK_UPDATE 107 |
| 8060 | | -#define TK_SET 108 |
| 8061 | | -#define TK_DEFERRABLE 109 |
| 8062 | | -#define TK_FOREIGN 110 |
| 8063 | | -#define TK_DROP 111 |
| 8064 | | -#define TK_UNION 112 |
| 8065 | | -#define TK_ALL 113 |
| 8066 | | -#define TK_EXCEPT 114 |
| 8067 | | -#define TK_INTERSECT 115 |
| 8068 | | -#define TK_SELECT 116 |
| 8069 | | -#define TK_DISTINCT 117 |
| 8070 | | -#define TK_DOT 118 |
| 8071 | | -#define TK_FROM 119 |
| 8072 | | -#define TK_JOIN 120 |
| 8073 | | -#define TK_USING 121 |
| 8074 | | -#define TK_ORDER 122 |
| 8075 | | -#define TK_GROUP 123 |
| 8076 | | -#define TK_HAVING 124 |
| 8077 | | -#define TK_LIMIT 125 |
| 8078 | | -#define TK_WHERE 126 |
| 8079 | | -#define TK_INTO 127 |
| 8080 | | -#define TK_VALUES 128 |
| 8081 | | -#define TK_INTEGER 129 |
| 8082 | | -#define TK_FLOAT 130 |
| 8083 | | -#define TK_BLOB 131 |
| 8084 | | -#define TK_REGISTER 132 |
| 8085 | | -#define TK_VARIABLE 133 |
| 8086 | | -#define TK_CASE 134 |
| 8087 | | -#define TK_WHEN 135 |
| 8088 | | -#define TK_THEN 136 |
| 8089 | | -#define TK_ELSE 137 |
| 8090 | | -#define TK_INDEX 138 |
| 8091 | | -#define TK_ALTER 139 |
| 8092 | | -#define TK_ADD 140 |
| 8093 | | -#define TK_TO_TEXT 141 |
| 8094 | | -#define TK_TO_BLOB 142 |
| 8095 | | -#define TK_TO_NUMERIC 143 |
| 8096 | | -#define TK_TO_INT 144 |
| 8097 | | -#define TK_TO_REAL 145 |
| 8098 | | -#define TK_ISNOT 146 |
| 8099 | | -#define TK_END_OF_FILE 147 |
| 8100 | | -#define TK_ILLEGAL 148 |
| 8101 | | -#define TK_SPACE 149 |
| 8102 | | -#define TK_UNCLOSED_STRING 150 |
| 8103 | | -#define TK_FUNCTION 151 |
| 8104 | | -#define TK_COLUMN 152 |
| 8105 | | -#define TK_AGG_FUNCTION 153 |
| 8106 | | -#define TK_AGG_COLUMN 154 |
| 8107 | | -#define TK_CONST_FUNC 155 |
| 8108 | | -#define TK_UMINUS 156 |
| 8109 | | -#define TK_UPLUS 157 |
| 8001 | +#define TK_WITHOUT 25 |
| 8002 | +#define TK_COMMA 26 |
| 8003 | +#define TK_ID 27 |
| 8004 | +#define TK_INDEXED 28 |
| 8005 | +#define TK_ABORT 29 |
| 8006 | +#define TK_ACTION 30 |
| 8007 | +#define TK_AFTER 31 |
| 8008 | +#define TK_ANALYZE 32 |
| 8009 | +#define TK_ASC 33 |
| 8010 | +#define TK_ATTACH 34 |
| 8011 | +#define TK_BEFORE 35 |
| 8012 | +#define TK_BY 36 |
| 8013 | +#define TK_CASCADE 37 |
| 8014 | +#define TK_CAST 38 |
| 8015 | +#define TK_COLUMNKW 39 |
| 8016 | +#define TK_CONFLICT 40 |
| 8017 | +#define TK_DATABASE 41 |
| 8018 | +#define TK_DESC 42 |
| 8019 | +#define TK_DETACH 43 |
| 8020 | +#define TK_EACH 44 |
| 8021 | +#define TK_FAIL 45 |
| 8022 | +#define TK_FOR 46 |
| 8023 | +#define TK_IGNORE 47 |
| 8024 | +#define TK_INITIALLY 48 |
| 8025 | +#define TK_INSTEAD 49 |
| 8026 | +#define TK_LIKE_KW 50 |
| 8027 | +#define TK_MATCH 51 |
| 8028 | +#define TK_NO 52 |
| 8029 | +#define TK_KEY 53 |
| 8030 | +#define TK_OF 54 |
| 8031 | +#define TK_OFFSET 55 |
| 8032 | +#define TK_PRAGMA 56 |
| 8033 | +#define TK_RAISE 57 |
| 8034 | +#define TK_REPLACE 58 |
| 8035 | +#define TK_RESTRICT 59 |
| 8036 | +#define TK_ROW 60 |
| 8037 | +#define TK_TRIGGER 61 |
| 8038 | +#define TK_VACUUM 62 |
| 8039 | +#define TK_VIEW 63 |
| 8040 | +#define TK_VIRTUAL 64 |
| 8041 | +#define TK_REINDEX 65 |
| 8042 | +#define TK_RENAME 66 |
| 8043 | +#define TK_CTIME_KW 67 |
| 8044 | +#define TK_ANY 68 |
| 8045 | +#define TK_OR 69 |
| 8046 | +#define TK_AND 70 |
| 8047 | +#define TK_IS 71 |
| 8048 | +#define TK_BETWEEN 72 |
| 8049 | +#define TK_IN 73 |
| 8050 | +#define TK_ISNULL 74 |
| 8051 | +#define TK_NOTNULL 75 |
| 8052 | +#define TK_NE 76 |
| 8053 | +#define TK_EQ 77 |
| 8054 | +#define TK_GT 78 |
| 8055 | +#define TK_LE 79 |
| 8056 | +#define TK_LT 80 |
| 8057 | +#define TK_GE 81 |
| 8058 | +#define TK_ESCAPE 82 |
| 8059 | +#define TK_BITAND 83 |
| 8060 | +#define TK_BITOR 84 |
| 8061 | +#define TK_LSHIFT 85 |
| 8062 | +#define TK_RSHIFT 86 |
| 8063 | +#define TK_PLUS 87 |
| 8064 | +#define TK_MINUS 88 |
| 8065 | +#define TK_STAR 89 |
| 8066 | +#define TK_SLASH 90 |
| 8067 | +#define TK_REM 91 |
| 8068 | +#define TK_CONCAT 92 |
| 8069 | +#define TK_COLLATE 93 |
| 8070 | +#define TK_BITNOT 94 |
| 8071 | +#define TK_STRING 95 |
| 8072 | +#define TK_JOIN_KW 96 |
| 8073 | +#define TK_CONSTRAINT 97 |
| 8074 | +#define TK_DEFAULT 98 |
| 8075 | +#define TK_NULL 99 |
| 8076 | +#define TK_PRIMARY 100 |
| 8077 | +#define TK_UNIQUE 101 |
| 8078 | +#define TK_CHECK 102 |
| 8079 | +#define TK_REFERENCES 103 |
| 8080 | +#define TK_AUTOINCR 104 |
| 8081 | +#define TK_ON 105 |
| 8082 | +#define TK_INSERT 106 |
| 8083 | +#define TK_DELETE 107 |
| 8084 | +#define TK_UPDATE 108 |
| 8085 | +#define TK_SET 109 |
| 8086 | +#define TK_DEFERRABLE 110 |
| 8087 | +#define TK_FOREIGN 111 |
| 8088 | +#define TK_DROP 112 |
| 8089 | +#define TK_UNION 113 |
| 8090 | +#define TK_ALL 114 |
| 8091 | +#define TK_EXCEPT 115 |
| 8092 | +#define TK_INTERSECT 116 |
| 8093 | +#define TK_SELECT 117 |
| 8094 | +#define TK_DISTINCT 118 |
| 8095 | +#define TK_DOT 119 |
| 8096 | +#define TK_FROM 120 |
| 8097 | +#define TK_JOIN 121 |
| 8098 | +#define TK_USING 122 |
| 8099 | +#define TK_ORDER 123 |
| 8100 | +#define TK_GROUP 124 |
| 8101 | +#define TK_HAVING 125 |
| 8102 | +#define TK_LIMIT 126 |
| 8103 | +#define TK_WHERE 127 |
| 8104 | +#define TK_INTO 128 |
| 8105 | +#define TK_VALUES 129 |
| 8106 | +#define TK_INTEGER 130 |
| 8107 | +#define TK_FLOAT 131 |
| 8108 | +#define TK_BLOB 132 |
| 8109 | +#define TK_REGISTER 133 |
| 8110 | +#define TK_VARIABLE 134 |
| 8111 | +#define TK_CASE 135 |
| 8112 | +#define TK_WHEN 136 |
| 8113 | +#define TK_THEN 137 |
| 8114 | +#define TK_ELSE 138 |
| 8115 | +#define TK_INDEX 139 |
| 8116 | +#define TK_ALTER 140 |
| 8117 | +#define TK_ADD 141 |
| 8118 | +#define TK_TO_TEXT 142 |
| 8119 | +#define TK_TO_BLOB 143 |
| 8120 | +#define TK_TO_NUMERIC 144 |
| 8121 | +#define TK_TO_INT 145 |
| 8122 | +#define TK_TO_REAL 146 |
| 8123 | +#define TK_ISNOT 147 |
| 8124 | +#define TK_END_OF_FILE 148 |
| 8125 | +#define TK_ILLEGAL 149 |
| 8126 | +#define TK_SPACE 150 |
| 8127 | +#define TK_UNCLOSED_STRING 151 |
| 8128 | +#define TK_FUNCTION 152 |
| 8129 | +#define TK_COLUMN 153 |
| 8130 | +#define TK_AGG_FUNCTION 154 |
| 8131 | +#define TK_AGG_COLUMN 155 |
| 8132 | +#define TK_CONST_FUNC 156 |
| 8133 | +#define TK_UMINUS 157 |
| 8134 | +#define TK_UPLUS 158 |
| 8110 | 8135 | |
| 8111 | 8136 | /************** End of parse.h ***********************************************/ |
| 8112 | 8137 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8113 | 8138 | #include <stdio.h> |
| 8114 | 8139 | #include <stdlib.h> |
| | @@ -8881,11 +8906,11 @@ |
| 8881 | 8906 | KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ |
| 8882 | 8907 | int *ai; /* Used when p4type is P4_INTARRAY */ |
| 8883 | 8908 | SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ |
| 8884 | 8909 | int (*xAdvance)(BtCursor *, int *); |
| 8885 | 8910 | } p4; |
| 8886 | | -#ifdef SQLITE_DEBUG |
| 8911 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 8887 | 8912 | char *zComment; /* Comment to improve readability */ |
| 8888 | 8913 | #endif |
| 8889 | 8914 | #ifdef VDBE_PROFILE |
| 8890 | 8915 | int cnt; /* Number of times this instruction was executed */ |
| 8891 | 8916 | u64 cycles; /* Total time spent executing this instruction */ |
| | @@ -8937,19 +8962,15 @@ |
| 8937 | 8962 | #define P4_INT32 (-14) /* P4 is a 32-bit signed integer */ |
| 8938 | 8963 | #define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ |
| 8939 | 8964 | #define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ |
| 8940 | 8965 | #define P4_ADVANCE (-19) /* P4 is a pointer to BtreeNext() or BtreePrev() */ |
| 8941 | 8966 | |
| 8942 | | -/* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure |
| 8943 | | -** is made. That copy is freed when the Vdbe is finalized. But if the |
| 8944 | | -** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still |
| 8945 | | -** gets freed when the Vdbe is finalized so it still should be obtained |
| 8946 | | -** from a single sqliteMalloc(). But no copy is made and the calling |
| 8947 | | -** function should *not* try to free the KeyInfo. |
| 8948 | | -*/ |
| 8949 | | -#define P4_KEYINFO_HANDOFF (-16) |
| 8950 | | -#define P4_KEYINFO_STATIC (-17) |
| 8967 | +/* Error message codes for OP_Halt */ |
| 8968 | +#define P5_ConstraintNotNull 1 |
| 8969 | +#define P5_ConstraintUnique 2 |
| 8970 | +#define P5_ConstraintCheck 3 |
| 8971 | +#define P5_ConstraintFK 4 |
| 8951 | 8972 | |
| 8952 | 8973 | /* |
| 8953 | 8974 | ** The Vdbe.aColName array contains 5n Mem structures, where n is the |
| 8954 | 8975 | ** number of columns of data returned by the statement. |
| 8955 | 8976 | */ |
| | @@ -8982,160 +9003,160 @@ |
| 8982 | 9003 | */ |
| 8983 | 9004 | /************** Include opcodes.h in the middle of vdbe.h ********************/ |
| 8984 | 9005 | /************** Begin file opcodes.h *****************************************/ |
| 8985 | 9006 | /* Automatically generated. Do not edit */ |
| 8986 | 9007 | /* See the mkopcodeh.awk script for details */ |
| 8987 | | -#define OP_Function 1 |
| 8988 | | -#define OP_Savepoint 2 |
| 8989 | | -#define OP_AutoCommit 3 |
| 8990 | | -#define OP_Transaction 4 |
| 8991 | | -#define OP_SorterNext 5 |
| 8992 | | -#define OP_Prev 6 |
| 8993 | | -#define OP_Next 7 |
| 8994 | | -#define OP_AggStep 8 |
| 8995 | | -#define OP_Checkpoint 9 |
| 8996 | | -#define OP_JournalMode 10 |
| 8997 | | -#define OP_Vacuum 11 |
| 8998 | | -#define OP_VFilter 12 |
| 8999 | | -#define OP_VUpdate 13 |
| 9000 | | -#define OP_Goto 14 |
| 9001 | | -#define OP_Gosub 15 |
| 9002 | | -#define OP_Return 16 |
| 9003 | | -#define OP_Yield 17 |
| 9004 | | -#define OP_HaltIfNull 18 |
| 9005 | | -#define OP_Not 19 /* same as TK_NOT */ |
| 9006 | | -#define OP_Halt 20 |
| 9007 | | -#define OP_Integer 21 |
| 9008 | | -#define OP_Int64 22 |
| 9009 | | -#define OP_String 23 |
| 9010 | | -#define OP_Null 24 |
| 9011 | | -#define OP_Blob 25 |
| 9012 | | -#define OP_Variable 26 |
| 9013 | | -#define OP_Move 27 |
| 9014 | | -#define OP_Copy 28 |
| 9015 | | -#define OP_SCopy 29 |
| 9016 | | -#define OP_ResultRow 30 |
| 9017 | | -#define OP_CollSeq 31 |
| 9018 | | -#define OP_AddImm 32 |
| 9019 | | -#define OP_MustBeInt 33 |
| 9020 | | -#define OP_RealAffinity 34 |
| 9021 | | -#define OP_Permutation 35 |
| 9022 | | -#define OP_Compare 36 |
| 9023 | | -#define OP_Jump 37 |
| 9024 | | -#define OP_Once 38 |
| 9025 | | -#define OP_If 39 |
| 9026 | | -#define OP_IfNot 40 |
| 9027 | | -#define OP_Column 41 |
| 9028 | | -#define OP_Affinity 42 |
| 9029 | | -#define OP_MakeRecord 43 |
| 9030 | | -#define OP_Count 44 |
| 9031 | | -#define OP_ReadCookie 45 |
| 9032 | | -#define OP_SetCookie 46 |
| 9033 | | -#define OP_VerifyCookie 47 |
| 9034 | | -#define OP_OpenRead 48 |
| 9035 | | -#define OP_OpenWrite 49 |
| 9036 | | -#define OP_OpenAutoindex 50 |
| 9037 | | -#define OP_OpenEphemeral 51 |
| 9038 | | -#define OP_SorterOpen 52 |
| 9039 | | -#define OP_OpenPseudo 53 |
| 9040 | | -#define OP_Close 54 |
| 9041 | | -#define OP_SeekLt 55 |
| 9042 | | -#define OP_SeekLe 56 |
| 9043 | | -#define OP_SeekGe 57 |
| 9044 | | -#define OP_SeekGt 58 |
| 9045 | | -#define OP_Seek 59 |
| 9046 | | -#define OP_NotFound 60 |
| 9047 | | -#define OP_Found 61 |
| 9048 | | -#define OP_IsUnique 62 |
| 9049 | | -#define OP_NotExists 63 |
| 9050 | | -#define OP_Sequence 64 |
| 9051 | | -#define OP_NewRowid 65 |
| 9052 | | -#define OP_Insert 66 |
| 9053 | | -#define OP_InsertInt 67 |
| 9054 | | -#define OP_Or 68 /* same as TK_OR */ |
| 9055 | | -#define OP_And 69 /* same as TK_AND */ |
| 9056 | | -#define OP_Delete 70 |
| 9057 | | -#define OP_ResetCount 71 |
| 9058 | | -#define OP_SorterCompare 72 |
| 9059 | | -#define OP_IsNull 73 /* same as TK_ISNULL */ |
| 9060 | | -#define OP_NotNull 74 /* same as TK_NOTNULL */ |
| 9061 | | -#define OP_Ne 75 /* same as TK_NE */ |
| 9062 | | -#define OP_Eq 76 /* same as TK_EQ */ |
| 9063 | | -#define OP_Gt 77 /* same as TK_GT */ |
| 9064 | | -#define OP_Le 78 /* same as TK_LE */ |
| 9065 | | -#define OP_Lt 79 /* same as TK_LT */ |
| 9066 | | -#define OP_Ge 80 /* same as TK_GE */ |
| 9067 | | -#define OP_SorterData 81 |
| 9068 | | -#define OP_BitAnd 82 /* same as TK_BITAND */ |
| 9069 | | -#define OP_BitOr 83 /* same as TK_BITOR */ |
| 9070 | | -#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ |
| 9071 | | -#define OP_ShiftRight 85 /* same as TK_RSHIFT */ |
| 9072 | | -#define OP_Add 86 /* same as TK_PLUS */ |
| 9073 | | -#define OP_Subtract 87 /* same as TK_MINUS */ |
| 9074 | | -#define OP_Multiply 88 /* same as TK_STAR */ |
| 9075 | | -#define OP_Divide 89 /* same as TK_SLASH */ |
| 9076 | | -#define OP_Remainder 90 /* same as TK_REM */ |
| 9077 | | -#define OP_Concat 91 /* same as TK_CONCAT */ |
| 9078 | | -#define OP_RowKey 92 |
| 9079 | | -#define OP_BitNot 93 /* same as TK_BITNOT */ |
| 9080 | | -#define OP_String8 94 /* same as TK_STRING */ |
| 9081 | | -#define OP_RowData 95 |
| 9082 | | -#define OP_Rowid 96 |
| 9083 | | -#define OP_NullRow 97 |
| 9084 | | -#define OP_Last 98 |
| 9085 | | -#define OP_SorterSort 99 |
| 9086 | | -#define OP_Sort 100 |
| 9087 | | -#define OP_Rewind 101 |
| 9088 | | -#define OP_SorterInsert 102 |
| 9089 | | -#define OP_IdxInsert 103 |
| 9090 | | -#define OP_IdxDelete 104 |
| 9091 | | -#define OP_IdxRowid 105 |
| 9092 | | -#define OP_IdxLT 106 |
| 9093 | | -#define OP_IdxGE 107 |
| 9094 | | -#define OP_Destroy 108 |
| 9095 | | -#define OP_Clear 109 |
| 9096 | | -#define OP_CreateIndex 110 |
| 9097 | | -#define OP_CreateTable 111 |
| 9098 | | -#define OP_ParseSchema 112 |
| 9099 | | -#define OP_LoadAnalysis 113 |
| 9100 | | -#define OP_DropTable 114 |
| 9101 | | -#define OP_DropIndex 115 |
| 9102 | | -#define OP_DropTrigger 116 |
| 9103 | | -#define OP_IntegrityCk 117 |
| 9104 | | -#define OP_RowSetAdd 118 |
| 9105 | | -#define OP_RowSetRead 119 |
| 9106 | | -#define OP_RowSetTest 120 |
| 9107 | | -#define OP_Program 121 |
| 9108 | | -#define OP_Param 122 |
| 9109 | | -#define OP_FkCounter 123 |
| 9110 | | -#define OP_FkIfZero 124 |
| 9111 | | -#define OP_MemMax 125 |
| 9112 | | -#define OP_IfPos 126 |
| 9113 | | -#define OP_IfNeg 127 |
| 9114 | | -#define OP_IfZero 128 |
| 9115 | | -#define OP_AggFinal 129 |
| 9116 | | -#define OP_Real 130 /* same as TK_FLOAT */ |
| 9117 | | -#define OP_IncrVacuum 131 |
| 9118 | | -#define OP_Expire 132 |
| 9119 | | -#define OP_TableLock 133 |
| 9120 | | -#define OP_VBegin 134 |
| 9121 | | -#define OP_VCreate 135 |
| 9122 | | -#define OP_VDestroy 136 |
| 9123 | | -#define OP_VOpen 137 |
| 9124 | | -#define OP_VColumn 138 |
| 9125 | | -#define OP_VNext 139 |
| 9126 | | -#define OP_VRename 140 |
| 9127 | | -#define OP_ToText 141 /* same as TK_TO_TEXT */ |
| 9128 | | -#define OP_ToBlob 142 /* same as TK_TO_BLOB */ |
| 9129 | | -#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ |
| 9130 | | -#define OP_ToInt 144 /* same as TK_TO_INT */ |
| 9131 | | -#define OP_ToReal 145 /* same as TK_TO_REAL */ |
| 9132 | | -#define OP_Pagecount 146 |
| 9133 | | -#define OP_MaxPgcnt 147 |
| 9134 | | -#define OP_Trace 148 |
| 9135 | | -#define OP_Noop 149 |
| 9136 | | -#define OP_Explain 150 |
| 9008 | +#define OP_Function 1 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 9009 | +#define OP_Savepoint 2 |
| 9010 | +#define OP_AutoCommit 3 |
| 9011 | +#define OP_Transaction 4 |
| 9012 | +#define OP_SorterNext 5 |
| 9013 | +#define OP_Prev 6 |
| 9014 | +#define OP_Next 7 |
| 9015 | +#define OP_AggStep 8 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 9016 | +#define OP_Checkpoint 9 |
| 9017 | +#define OP_JournalMode 10 |
| 9018 | +#define OP_Vacuum 11 |
| 9019 | +#define OP_VFilter 12 /* synopsis: iPlan=r[P3] zPlan='P4' */ |
| 9020 | +#define OP_VUpdate 13 /* synopsis: data=r[P3@P2] */ |
| 9021 | +#define OP_Goto 14 |
| 9022 | +#define OP_Gosub 15 |
| 9023 | +#define OP_Return 16 |
| 9024 | +#define OP_Yield 17 |
| 9025 | +#define OP_HaltIfNull 18 /* synopsis: if r[P3] null then halt */ |
| 9026 | +#define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */ |
| 9027 | +#define OP_Halt 20 |
| 9028 | +#define OP_Integer 21 /* synopsis: r[P2]=P1 */ |
| 9029 | +#define OP_Int64 22 /* synopsis: r[P2]=P4 */ |
| 9030 | +#define OP_String 23 /* synopsis: r[P2]='P4' (len=P1) */ |
| 9031 | +#define OP_Null 24 /* synopsis: r[P2..P3]=NULL */ |
| 9032 | +#define OP_Blob 25 /* synopsis: r[P2]=P4 (len=P1) */ |
| 9033 | +#define OP_Variable 26 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 9034 | +#define OP_Move 27 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 9035 | +#define OP_Copy 28 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 9036 | +#define OP_SCopy 29 /* synopsis: r[P2]=r[P1] */ |
| 9037 | +#define OP_ResultRow 30 /* synopsis: output=r[P1@P2] */ |
| 9038 | +#define OP_CollSeq 31 |
| 9039 | +#define OP_AddImm 32 /* synopsis: r[P1]=r[P1]+P2 */ |
| 9040 | +#define OP_MustBeInt 33 |
| 9041 | +#define OP_RealAffinity 34 |
| 9042 | +#define OP_Permutation 35 |
| 9043 | +#define OP_Compare 36 |
| 9044 | +#define OP_Jump 37 |
| 9045 | +#define OP_Once 38 |
| 9046 | +#define OP_If 39 |
| 9047 | +#define OP_IfNot 40 |
| 9048 | +#define OP_Column 41 /* synopsis: r[P3]=PX */ |
| 9049 | +#define OP_Affinity 42 /* synopsis: affinity(r[P1@P2]) */ |
| 9050 | +#define OP_MakeRecord 43 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 9051 | +#define OP_Count 44 /* synopsis: r[P2]=count() */ |
| 9052 | +#define OP_ReadCookie 45 |
| 9053 | +#define OP_SetCookie 46 |
| 9054 | +#define OP_VerifyCookie 47 |
| 9055 | +#define OP_OpenRead 48 /* synopsis: root=P2 iDb=P3 */ |
| 9056 | +#define OP_OpenWrite 49 /* synopsis: root=P2 iDb=P3 */ |
| 9057 | +#define OP_OpenAutoindex 50 /* synopsis: nColumn=P2 */ |
| 9058 | +#define OP_OpenEphemeral 51 /* synopsis: nColumn=P2 */ |
| 9059 | +#define OP_SorterOpen 52 |
| 9060 | +#define OP_OpenPseudo 53 /* synopsis: content in r[P2@P3] */ |
| 9061 | +#define OP_Close 54 |
| 9062 | +#define OP_SeekLt 55 /* synopsis: key=r[P3@P4] */ |
| 9063 | +#define OP_SeekLe 56 /* synopsis: key=r[P3@P4] */ |
| 9064 | +#define OP_SeekGe 57 /* synopsis: key=r[P3@P4] */ |
| 9065 | +#define OP_SeekGt 58 /* synopsis: key=r[P3@P4] */ |
| 9066 | +#define OP_Seek 59 /* synopsis: intkey=r[P2] */ |
| 9067 | +#define OP_NoConflict 60 /* synopsis: key=r[P3@P4] */ |
| 9068 | +#define OP_NotFound 61 /* synopsis: key=r[P3@P4] */ |
| 9069 | +#define OP_Found 62 /* synopsis: key=r[P3@P4] */ |
| 9070 | +#define OP_NotExists 63 /* synopsis: intkey=r[P3] */ |
| 9071 | +#define OP_Sequence 64 /* synopsis: r[P2]=rowid */ |
| 9072 | +#define OP_NewRowid 65 /* synopsis: r[P2]=rowid */ |
| 9073 | +#define OP_Insert 66 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 9074 | +#define OP_InsertInt 67 /* synopsis: intkey=P3 data=r[P2] */ |
| 9075 | +#define OP_Delete 68 |
| 9076 | +#define OP_Or 69 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 9077 | +#define OP_And 70 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 9078 | +#define OP_ResetCount 71 |
| 9079 | +#define OP_SorterCompare 72 /* synopsis: if key(P1)!=rtrim(r[P3],P4) goto P2 */ |
| 9080 | +#define OP_SorterData 73 /* synopsis: r[P2]=data */ |
| 9081 | +#define OP_IsNull 74 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 9082 | +#define OP_NotNull 75 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 9083 | +#define OP_Ne 76 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */ |
| 9084 | +#define OP_Eq 77 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */ |
| 9085 | +#define OP_Gt 78 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */ |
| 9086 | +#define OP_Le 79 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */ |
| 9087 | +#define OP_Lt 80 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P3 */ |
| 9088 | +#define OP_Ge 81 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */ |
| 9089 | +#define OP_RowKey 82 /* synopsis: r[P2]=key */ |
| 9090 | +#define OP_BitAnd 83 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 9091 | +#define OP_BitOr 84 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 9092 | +#define OP_ShiftLeft 85 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 9093 | +#define OP_ShiftRight 86 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 9094 | +#define OP_Add 87 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 9095 | +#define OP_Subtract 88 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 9096 | +#define OP_Multiply 89 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 9097 | +#define OP_Divide 90 /* same as TK_SLASH, synopsis: r[P3]=r[P1]/r[P2] */ |
| 9098 | +#define OP_Remainder 91 /* same as TK_REM, synopsis: r[P3]=r[P1]%r[P2] */ |
| 9099 | +#define OP_Concat 92 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 9100 | +#define OP_RowData 93 /* synopsis: r[P2]=data */ |
| 9101 | +#define OP_BitNot 94 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 9102 | +#define OP_String8 95 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 9103 | +#define OP_Rowid 96 /* synopsis: r[P2]=rowid */ |
| 9104 | +#define OP_NullRow 97 |
| 9105 | +#define OP_Last 98 |
| 9106 | +#define OP_SorterSort 99 |
| 9107 | +#define OP_Sort 100 |
| 9108 | +#define OP_Rewind 101 |
| 9109 | +#define OP_SorterInsert 102 |
| 9110 | +#define OP_IdxInsert 103 /* synopsis: key=r[P2] */ |
| 9111 | +#define OP_IdxDelete 104 /* synopsis: key=r[P2@P3] */ |
| 9112 | +#define OP_IdxRowid 105 /* synopsis: r[P2]=rowid */ |
| 9113 | +#define OP_IdxLT 106 /* synopsis: key=r[P3@P4] */ |
| 9114 | +#define OP_IdxGE 107 /* synopsis: key=r[P3@P4] */ |
| 9115 | +#define OP_Destroy 108 |
| 9116 | +#define OP_Clear 109 |
| 9117 | +#define OP_CreateIndex 110 /* synopsis: r[P2]=root iDb=P1 */ |
| 9118 | +#define OP_CreateTable 111 /* synopsis: r[P2]=root iDb=P1 */ |
| 9119 | +#define OP_ParseSchema 112 |
| 9120 | +#define OP_LoadAnalysis 113 |
| 9121 | +#define OP_DropTable 114 |
| 9122 | +#define OP_DropIndex 115 |
| 9123 | +#define OP_DropTrigger 116 |
| 9124 | +#define OP_IntegrityCk 117 |
| 9125 | +#define OP_RowSetAdd 118 /* synopsis: rowset(P1)=r[P2] */ |
| 9126 | +#define OP_RowSetRead 119 /* synopsis: r[P3]=rowset(P1) */ |
| 9127 | +#define OP_RowSetTest 120 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 9128 | +#define OP_Program 121 |
| 9129 | +#define OP_Param 122 |
| 9130 | +#define OP_FkCounter 123 /* synopsis: fkctr[P1]+=P2 */ |
| 9131 | +#define OP_FkIfZero 124 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 9132 | +#define OP_MemMax 125 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 9133 | +#define OP_IfPos 126 /* synopsis: if r[P1]>0 goto P2 */ |
| 9134 | +#define OP_IfNeg 127 /* synopsis: if r[P1]<0 goto P2 */ |
| 9135 | +#define OP_IfZero 128 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */ |
| 9136 | +#define OP_AggFinal 129 /* synopsis: accum=r[P1] N=P2 */ |
| 9137 | +#define OP_IncrVacuum 130 |
| 9138 | +#define OP_Real 131 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 9139 | +#define OP_Expire 132 |
| 9140 | +#define OP_TableLock 133 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 9141 | +#define OP_VBegin 134 |
| 9142 | +#define OP_VCreate 135 |
| 9143 | +#define OP_VDestroy 136 |
| 9144 | +#define OP_VOpen 137 |
| 9145 | +#define OP_VColumn 138 /* synopsis: r[P3]=vcolumn(P2) */ |
| 9146 | +#define OP_VNext 139 |
| 9147 | +#define OP_VRename 140 |
| 9148 | +#define OP_Pagecount 141 |
| 9149 | +#define OP_ToText 142 /* same as TK_TO_TEXT */ |
| 9150 | +#define OP_ToBlob 143 /* same as TK_TO_BLOB */ |
| 9151 | +#define OP_ToNumeric 144 /* same as TK_TO_NUMERIC */ |
| 9152 | +#define OP_ToInt 145 /* same as TK_TO_INT */ |
| 9153 | +#define OP_ToReal 146 /* same as TK_TO_REAL */ |
| 9154 | +#define OP_MaxPgcnt 147 |
| 9155 | +#define OP_Trace 148 |
| 9156 | +#define OP_Noop 149 |
| 9157 | +#define OP_Explain 150 |
| 9137 | 9158 | |
| 9138 | 9159 | |
| 9139 | 9160 | /* Properties such as "out2" or "jump" that are specified in |
| 9140 | 9161 | ** comments following the "case" for each opcode in the vdbe.c |
| 9141 | 9162 | ** are encoded into bitvectors as follows: |
| | @@ -9149,26 +9170,26 @@ |
| 9149 | 9170 | #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ |
| 9150 | 9171 | #define OPFLG_INITIALIZER {\ |
| 9151 | 9172 | /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\ |
| 9152 | 9173 | /* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\ |
| 9153 | 9174 | /* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\ |
| 9154 | | -/* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\ |
| 9175 | +/* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x20, 0x00, 0x00,\ |
| 9155 | 9176 | /* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\ |
| 9156 | 9177 | /* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\ |
| 9157 | 9178 | /* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\ |
| 9158 | 9179 | /* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\ |
| 9159 | | -/* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\ |
| 9160 | | -/* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\ |
| 9161 | | -/* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\ |
| 9162 | | -/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\ |
| 9180 | +/* 64 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x4c, 0x4c, 0x00,\ |
| 9181 | +/* 72 */ 0x00, 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15,\ |
| 9182 | +/* 80 */ 0x15, 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\ |
| 9183 | +/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02,\ |
| 9163 | 9184 | /* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\ |
| 9164 | 9185 | /* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\ |
| 9165 | 9186 | /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\ |
| 9166 | 9187 | /* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\ |
| 9167 | | -/* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\ |
| 9168 | | -/* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\ |
| 9169 | | -/* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,} |
| 9188 | +/* 128 */ 0x05, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00,\ |
| 9189 | +/* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x04, 0x04,\ |
| 9190 | +/* 144 */ 0x04, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00,} |
| 9170 | 9191 | |
| 9171 | 9192 | /************** End of opcodes.h *********************************************/ |
| 9172 | 9193 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 9173 | 9194 | |
| 9174 | 9195 | /* |
| | @@ -9189,10 +9210,11 @@ |
| 9189 | 9210 | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3); |
| 9190 | 9211 | SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5); |
| 9191 | 9212 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); |
| 9192 | 9213 | SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr); |
| 9193 | 9214 | SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); |
| 9215 | +SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); |
| 9194 | 9216 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); |
| 9195 | 9217 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
| 9196 | 9218 | SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*); |
| 9197 | 9219 | SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*); |
| 9198 | 9220 | SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*); |
| | @@ -9227,19 +9249,31 @@ |
| 9227 | 9249 | |
| 9228 | 9250 | #ifndef SQLITE_OMIT_TRIGGER |
| 9229 | 9251 | SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 9230 | 9252 | #endif |
| 9231 | 9253 | |
| 9232 | | - |
| 9233 | | -#ifndef NDEBUG |
| 9254 | +/* Use SQLITE_ENABLE_COMMENTS to enable generation of extra comments on |
| 9255 | +** each VDBE opcode. |
| 9256 | +** |
| 9257 | +** Use the SQLITE_ENABLE_MODULE_COMMENTS macro to see some extra no-op |
| 9258 | +** comments in VDBE programs that show key decision points in the code |
| 9259 | +** generator. |
| 9260 | +*/ |
| 9261 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 9234 | 9262 | SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe*, const char*, ...); |
| 9235 | 9263 | # define VdbeComment(X) sqlite3VdbeComment X |
| 9236 | 9264 | SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); |
| 9237 | 9265 | # define VdbeNoopComment(X) sqlite3VdbeNoopComment X |
| 9266 | +# ifdef SQLITE_ENABLE_MODULE_COMMENTS |
| 9267 | +# define VdbeModuleComment(X) sqlite3VdbeNoopComment X |
| 9268 | +# else |
| 9269 | +# define VdbeModuleComment(X) |
| 9270 | +# endif |
| 9238 | 9271 | #else |
| 9239 | 9272 | # define VdbeComment(X) |
| 9240 | 9273 | # define VdbeNoopComment(X) |
| 9274 | +# define VdbeModuleComment(X) |
| 9241 | 9275 | #endif |
| 9242 | 9276 | |
| 9243 | 9277 | #endif |
| 9244 | 9278 | |
| 9245 | 9279 | /************** End of vdbe.h ************************************************/ |
| | @@ -10631,10 +10665,11 @@ |
| 10631 | 10665 | #define TF_Readonly 0x01 /* Read-only system table */ |
| 10632 | 10666 | #define TF_Ephemeral 0x02 /* An ephemeral table */ |
| 10633 | 10667 | #define TF_HasPrimaryKey 0x04 /* Table has a primary key */ |
| 10634 | 10668 | #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ |
| 10635 | 10669 | #define TF_Virtual 0x10 /* Is a virtual table */ |
| 10670 | +#define TF_WithoutRowid 0x20 /* No rowid used. PRIMARY KEY is the key */ |
| 10636 | 10671 | |
| 10637 | 10672 | |
| 10638 | 10673 | /* |
| 10639 | 10674 | ** Test to see whether or not a table is a virtual table. This is |
| 10640 | 10675 | ** done as a macro so that it will be optimized out when virtual |
| | @@ -10646,10 +10681,13 @@ |
| 10646 | 10681 | #else |
| 10647 | 10682 | # define IsVirtual(X) 0 |
| 10648 | 10683 | # define IsHiddenColumn(X) 0 |
| 10649 | 10684 | #endif |
| 10650 | 10685 | |
| 10686 | +/* Does the table have a rowid */ |
| 10687 | +#define HasRowid(X) (((X)->tabFlags & TF_WithoutRowid)==0) |
| 10688 | + |
| 10651 | 10689 | /* |
| 10652 | 10690 | ** Each foreign key constraint is an instance of the following structure. |
| 10653 | 10691 | ** |
| 10654 | 10692 | ** A foreign key is associated with two tables. The "from" table is |
| 10655 | 10693 | ** the table that contains the REFERENCES clause that creates the foreign |
| | @@ -10660,30 +10698,39 @@ |
| 10660 | 10698 | ** a INTEGER PRIMARY KEY, |
| 10661 | 10699 | ** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) |
| 10662 | 10700 | ** ); |
| 10663 | 10701 | ** |
| 10664 | 10702 | ** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". |
| 10703 | +** Equivalent names: |
| 10704 | +** |
| 10705 | +** from-table == child-table |
| 10706 | +** to-table == parent-table |
| 10665 | 10707 | ** |
| 10666 | 10708 | ** Each REFERENCES clause generates an instance of the following structure |
| 10667 | 10709 | ** which is attached to the from-table. The to-table need not exist when |
| 10668 | 10710 | ** the from-table is created. The existence of the to-table is not checked. |
| 10711 | +** |
| 10712 | +** The list of all parents for child Table X is held at X.pFKey. |
| 10713 | +** |
| 10714 | +** A list of all children for a table named Z (which might not even exist) |
| 10715 | +** is held in Schema.fkeyHash with a hash key of Z. |
| 10669 | 10716 | */ |
| 10670 | 10717 | struct FKey { |
| 10671 | 10718 | Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */ |
| 10672 | | - FKey *pNextFrom; /* Next foreign key in pFrom */ |
| 10719 | + FKey *pNextFrom; /* Next FKey with the same in pFrom. Next parent of pFrom */ |
| 10673 | 10720 | char *zTo; /* Name of table that the key points to (aka: Parent) */ |
| 10674 | | - FKey *pNextTo; /* Next foreign key on table named zTo */ |
| 10675 | | - FKey *pPrevTo; /* Previous foreign key on table named zTo */ |
| 10721 | + FKey *pNextTo; /* Next with the same zTo. Next child of zTo. */ |
| 10722 | + FKey *pPrevTo; /* Previous with the same zTo */ |
| 10676 | 10723 | int nCol; /* Number of columns in this key */ |
| 10677 | 10724 | /* EV: R-30323-21917 */ |
| 10678 | | - u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ |
| 10679 | | - u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */ |
| 10680 | | - Trigger *apTrigger[2]; /* Triggers for aAction[] actions */ |
| 10681 | | - struct sColMap { /* Mapping of columns in pFrom to columns in zTo */ |
| 10682 | | - int iFrom; /* Index of column in pFrom */ |
| 10683 | | - char *zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ |
| 10684 | | - } aCol[1]; /* One entry for each of nCol column s */ |
| 10725 | + u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ |
| 10726 | + u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */ |
| 10727 | + Trigger *apTrigger[2];/* Triggers for aAction[] actions */ |
| 10728 | + struct sColMap { /* Mapping of columns in pFrom to columns in zTo */ |
| 10729 | + int iFrom; /* Index of column in pFrom */ |
| 10730 | + char *zCol; /* Name of column in zTo. If NULL use PRIMARY KEY */ |
| 10731 | + } aCol[1]; /* One entry for each of nCol columns */ |
| 10685 | 10732 | }; |
| 10686 | 10733 | |
| 10687 | 10734 | /* |
| 10688 | 10735 | ** SQLite supports many different ways to resolve a constraint |
| 10689 | 10736 | ** error. ROLLBACK processing means that a constraint violation |
| | @@ -10732,13 +10779,15 @@ |
| 10732 | 10779 | ** Note that aSortOrder[] and aColl[] have nField+1 slots. There |
| 10733 | 10780 | ** are nField slots for the columns of an index then one extra slot |
| 10734 | 10781 | ** for the rowid at the end. |
| 10735 | 10782 | */ |
| 10736 | 10783 | struct KeyInfo { |
| 10737 | | - sqlite3 *db; /* The database connection */ |
| 10784 | + u32 nRef; /* Number of references to this KeyInfo object */ |
| 10738 | 10785 | u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ |
| 10739 | | - u16 nField; /* Maximum index for aColl[] and aSortOrder[] */ |
| 10786 | + u16 nField; /* Number of key columns in the index */ |
| 10787 | + u16 nXField; /* Number of columns beyond the key columns */ |
| 10788 | + sqlite3 *db; /* The database connection */ |
| 10740 | 10789 | u8 *aSortOrder; /* Sort order for each column. */ |
| 10741 | 10790 | CollSeq *aColl[1]; /* Collating sequence for each term of the key */ |
| 10742 | 10791 | }; |
| 10743 | 10792 | |
| 10744 | 10793 | /* |
| | @@ -10757,20 +10806,18 @@ |
| 10757 | 10806 | */ |
| 10758 | 10807 | struct UnpackedRecord { |
| 10759 | 10808 | KeyInfo *pKeyInfo; /* Collation and sort-order information */ |
| 10760 | 10809 | u16 nField; /* Number of entries in apMem[] */ |
| 10761 | 10810 | u8 flags; /* Boolean settings. UNPACKED_... below */ |
| 10762 | | - i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ |
| 10763 | 10811 | Mem *aMem; /* Values */ |
| 10764 | 10812 | }; |
| 10765 | 10813 | |
| 10766 | 10814 | /* |
| 10767 | 10815 | ** Allowed values of UnpackedRecord.flags |
| 10768 | 10816 | */ |
| 10769 | 10817 | #define UNPACKED_INCRKEY 0x01 /* Make this key an epsilon larger */ |
| 10770 | 10818 | #define UNPACKED_PREFIX_MATCH 0x02 /* A prefix match is considered OK */ |
| 10771 | | -#define UNPACKED_PREFIX_SEARCH 0x04 /* Ignore final (rowid) field */ |
| 10772 | 10819 | |
| 10773 | 10820 | /* |
| 10774 | 10821 | ** Each SQL index is represented in memory by an |
| 10775 | 10822 | ** instance of the following structure. |
| 10776 | 10823 | ** |
| | @@ -10796,26 +10843,30 @@ |
| 10796 | 10843 | ** algorithm to employ whenever an attempt is made to insert a non-unique |
| 10797 | 10844 | ** element. |
| 10798 | 10845 | */ |
| 10799 | 10846 | struct Index { |
| 10800 | 10847 | char *zName; /* Name of this index */ |
| 10801 | | - int *aiColumn; /* Which columns are used by this index. 1st is 0 */ |
| 10848 | + i16 *aiColumn; /* Which columns are used by this index. 1st is 0 */ |
| 10802 | 10849 | tRowcnt *aiRowEst; /* From ANALYZE: Est. rows selected by each column */ |
| 10803 | 10850 | Table *pTable; /* The SQL table being indexed */ |
| 10804 | 10851 | char *zColAff; /* String defining the affinity of each column */ |
| 10805 | 10852 | Index *pNext; /* The next index associated with the same table */ |
| 10806 | 10853 | Schema *pSchema; /* Schema containing this index */ |
| 10807 | 10854 | u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ |
| 10808 | 10855 | char **azColl; /* Array of collation sequence names for index */ |
| 10809 | 10856 | Expr *pPartIdxWhere; /* WHERE clause for partial indices */ |
| 10857 | + KeyInfo *pKeyInfo; /* A KeyInfo object suitable for this index */ |
| 10810 | 10858 | int tnum; /* DB Page containing root of this index */ |
| 10811 | 10859 | LogEst szIdxRow; /* Estimated average row size in bytes */ |
| 10812 | | - u16 nColumn; /* Number of columns in table used by this index */ |
| 10860 | + u16 nKeyCol; /* Number of columns forming the key */ |
| 10861 | + u16 nColumn; /* Number of columns stored in the index */ |
| 10813 | 10862 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 10814 | 10863 | unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */ |
| 10815 | 10864 | unsigned bUnordered:1; /* Use this index for == or IN queries only */ |
| 10816 | 10865 | unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */ |
| 10866 | + unsigned isResized:1; /* True if resizeIndexObject() has been called */ |
| 10867 | + unsigned isCovering:1; /* True if this is a covering index */ |
| 10817 | 10868 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 10818 | 10869 | int nSample; /* Number of elements in aSample[] */ |
| 10819 | 10870 | int nSampleCol; /* Size of IndexSample.anEq[] and so on */ |
| 10820 | 10871 | tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */ |
| 10821 | 10872 | IndexSample *aSample; /* Samples of the left-most key */ |
| | @@ -11490,10 +11541,12 @@ |
| 11490 | 11541 | AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ |
| 11491 | 11542 | |
| 11492 | 11543 | /* Information used while coding trigger programs. */ |
| 11493 | 11544 | Parse *pToplevel; /* Parse structure for main program (or NULL) */ |
| 11494 | 11545 | Table *pTriggerTab; /* Table triggers are being coded for */ |
| 11546 | + int addrCrTab; /* Address of OP_CreateTable opcode on CREATE TABLE */ |
| 11547 | + int addrSkipPK; /* Address of instruction to skip PRIMARY KEY index */ |
| 11495 | 11548 | u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ |
| 11496 | 11549 | u32 oldmask; /* Mask of old.* columns referenced */ |
| 11497 | 11550 | u32 newmask; /* Mask of new.* columns referenced */ |
| 11498 | 11551 | u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ |
| 11499 | 11552 | u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ |
| | @@ -11502,10 +11555,11 @@ |
| 11502 | 11555 | /* Above is constant between recursions. Below is reset before and after |
| 11503 | 11556 | ** each recursion */ |
| 11504 | 11557 | |
| 11505 | 11558 | int nVar; /* Number of '?' variables seen in the SQL so far */ |
| 11506 | 11559 | int nzVar; /* Number of available slots in azVar[] */ |
| 11560 | + u8 iPkSortOrder; /* ASC or DESC for INTEGER PRIMARY KEY */ |
| 11507 | 11561 | u8 explain; /* True if the EXPLAIN flag is found on the query */ |
| 11508 | 11562 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 11509 | 11563 | u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ |
| 11510 | 11564 | int nVtabLock; /* Number of virtual tables to lock */ |
| 11511 | 11565 | #endif |
| | @@ -11515,11 +11569,10 @@ |
| 11515 | 11569 | int iSelectId; /* ID of current select for EXPLAIN output */ |
| 11516 | 11570 | int iNextSelectId; /* Next available select ID for EXPLAIN output */ |
| 11517 | 11571 | #endif |
| 11518 | 11572 | char **azVar; /* Pointers to names of parameters */ |
| 11519 | 11573 | Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ |
| 11520 | | - int *aAlias; /* Register used to hold aliased result */ |
| 11521 | 11574 | const char *zTail; /* All SQL text past the last semicolon parsed */ |
| 11522 | 11575 | Table *pNewTable; /* A table being constructed by CREATE TABLE */ |
| 11523 | 11576 | Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */ |
| 11524 | 11577 | const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */ |
| 11525 | 11578 | Token sNameToken; /* Token with unqualified schema object name */ |
| | @@ -11984,19 +12037,21 @@ |
| 11984 | 12037 | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*); |
| 11985 | 12038 | SQLITE_PRIVATE void sqlite3BeginParse(Parse*,int); |
| 11986 | 12039 | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); |
| 11987 | 12040 | SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*); |
| 11988 | 12041 | SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int); |
| 12042 | +SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*); |
| 12043 | +SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16); |
| 11989 | 12044 | SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); |
| 11990 | 12045 | SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*); |
| 11991 | 12046 | SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int); |
| 11992 | 12047 | SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); |
| 11993 | 12048 | SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*); |
| 11994 | 12049 | SQLITE_PRIVATE void sqlite3AddColumnType(Parse*,Token*); |
| 11995 | 12050 | SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,ExprSpan*); |
| 11996 | 12051 | SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); |
| 11997 | | -SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,Select*); |
| 12052 | +SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); |
| 11998 | 12053 | SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, |
| 11999 | 12054 | sqlite3_vfs**,char**,char **); |
| 12000 | 12055 | SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*); |
| 12001 | 12056 | SQLITE_PRIVATE int sqlite3CodeOnce(Parse *); |
| 12002 | 12057 | |
| | @@ -12045,10 +12100,11 @@ |
| 12045 | 12100 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *); |
| 12046 | 12101 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); |
| 12047 | 12102 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
| 12048 | 12103 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); |
| 12049 | 12104 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*); |
| 12105 | +SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**); |
| 12050 | 12106 | SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 12051 | 12107 | Expr*, int, int); |
| 12052 | 12108 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 12053 | 12109 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 12054 | 12110 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| | @@ -12067,11 +12123,11 @@ |
| 12067 | 12123 | SQLITE_PRIVATE u64 sqlite3WhereOutputRowCount(WhereInfo*); |
| 12068 | 12124 | SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*); |
| 12069 | 12125 | SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*); |
| 12070 | 12126 | SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*); |
| 12071 | 12127 | SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*); |
| 12072 | | -SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*); |
| 12128 | +SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*); |
| 12073 | 12129 | SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); |
| 12074 | 12130 | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); |
| 12075 | 12131 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); |
| 12076 | 12132 | SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int); |
| 12077 | 12133 | SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*); |
| | @@ -12121,21 +12177,23 @@ |
| 12121 | 12177 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*); |
| 12122 | 12178 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| 12123 | 12179 | SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); |
| 12124 | 12180 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 12125 | 12181 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 12126 | | -SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); |
| 12127 | | -SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*); |
| 12182 | +SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8); |
| 12183 | +SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*); |
| 12128 | 12184 | SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*); |
| 12129 | | -SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, |
| 12130 | | - int*,int,int,int,int,int*); |
| 12131 | | -SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); |
| 12132 | | -SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); |
| 12185 | +SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int, |
| 12186 | + u8,u8,int,int*); |
| 12187 | +SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int); |
| 12188 | +SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int, int*, int*); |
| 12133 | 12189 | SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int); |
| 12134 | 12190 | SQLITE_PRIVATE void sqlite3MultiWrite(Parse*); |
| 12135 | 12191 | SQLITE_PRIVATE void sqlite3MayAbort(Parse*); |
| 12136 | | -SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, int); |
| 12192 | +SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8); |
| 12193 | +SQLITE_PRIVATE void sqlite3UniqueConstraint(Parse*, int, Index*); |
| 12194 | +SQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*); |
| 12137 | 12195 | SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int); |
| 12138 | 12196 | SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); |
| 12139 | 12197 | SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); |
| 12140 | 12198 | SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*); |
| 12141 | 12199 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int); |
| | @@ -12349,12 +12407,17 @@ |
| 12349 | 12407 | SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*); |
| 12350 | 12408 | SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int); |
| 12351 | 12409 | SQLITE_PRIVATE void sqlite3SchemaClear(void *); |
| 12352 | 12410 | SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *); |
| 12353 | 12411 | SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *); |
| 12354 | | -SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int); |
| 12355 | | -SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *); |
| 12412 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int); |
| 12413 | +SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*); |
| 12414 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*); |
| 12415 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*); |
| 12416 | +#ifdef SQLITE_DEBUG |
| 12417 | +SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo*); |
| 12418 | +#endif |
| 12356 | 12419 | SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, |
| 12357 | 12420 | void (*)(sqlite3_context*,int,sqlite3_value **), |
| 12358 | 12421 | void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*), |
| 12359 | 12422 | FuncDestructor *pDestructor |
| 12360 | 12423 | ); |
| | @@ -13350,12 +13413,11 @@ |
| 13350 | 13413 | i64 seqCount; /* Sequence counter */ |
| 13351 | 13414 | i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ |
| 13352 | 13415 | i64 lastRowid; /* Last rowid from a Next or NextIdx operation */ |
| 13353 | 13416 | VdbeSorter *pSorter; /* Sorter object for OP_SorterOpen cursors */ |
| 13354 | 13417 | |
| 13355 | | - /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists or |
| 13356 | | - ** OP_IsUnique opcode on this cursor. */ |
| 13418 | + /* Result of last sqlite3BtreeMoveto() done by an OP_NotExists */ |
| 13357 | 13419 | int seekResult; |
| 13358 | 13420 | |
| 13359 | 13421 | /* Cached information about the header for the data record that the |
| 13360 | 13422 | ** cursor is currently pointing to. Only valid if cacheStatus matches |
| 13361 | 13423 | ** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of |
| | @@ -13716,11 +13778,11 @@ |
| 13716 | 13778 | SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *); |
| 13717 | 13779 | SQLITE_PRIVATE int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *); |
| 13718 | 13780 | SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *); |
| 13719 | 13781 | SQLITE_PRIVATE int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *); |
| 13720 | 13782 | SQLITE_PRIVATE int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *); |
| 13721 | | -SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *); |
| 13783 | +SQLITE_PRIVATE int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int, int *); |
| 13722 | 13784 | |
| 13723 | 13785 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 |
| 13724 | 13786 | SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe*); |
| 13725 | 13787 | SQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe*); |
| 13726 | 13788 | #else |
| | @@ -22794,163 +22856,168 @@ |
| 22794 | 22856 | |
| 22795 | 22857 | /************** End of hash.c ************************************************/ |
| 22796 | 22858 | /************** Begin file opcodes.c *****************************************/ |
| 22797 | 22859 | /* Automatically generated. Do not edit */ |
| 22798 | 22860 | /* See the mkopcodec.awk script for details. */ |
| 22799 | | -#if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) |
| 22861 | +#if !defined(SQLITE_OMIT_EXPLAIN) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) |
| 22862 | +#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) || defined(SQLITE_DEBUG) |
| 22863 | +# define OpHelp(X) "\0" X |
| 22864 | +#else |
| 22865 | +# define OpHelp(X) |
| 22866 | +#endif |
| 22800 | 22867 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ |
| 22801 | 22868 | static const char *const azName[] = { "?", |
| 22802 | | - /* 1 */ "Function", |
| 22803 | | - /* 2 */ "Savepoint", |
| 22804 | | - /* 3 */ "AutoCommit", |
| 22805 | | - /* 4 */ "Transaction", |
| 22806 | | - /* 5 */ "SorterNext", |
| 22807 | | - /* 6 */ "Prev", |
| 22808 | | - /* 7 */ "Next", |
| 22809 | | - /* 8 */ "AggStep", |
| 22810 | | - /* 9 */ "Checkpoint", |
| 22811 | | - /* 10 */ "JournalMode", |
| 22812 | | - /* 11 */ "Vacuum", |
| 22813 | | - /* 12 */ "VFilter", |
| 22814 | | - /* 13 */ "VUpdate", |
| 22815 | | - /* 14 */ "Goto", |
| 22816 | | - /* 15 */ "Gosub", |
| 22817 | | - /* 16 */ "Return", |
| 22818 | | - /* 17 */ "Yield", |
| 22819 | | - /* 18 */ "HaltIfNull", |
| 22820 | | - /* 19 */ "Not", |
| 22821 | | - /* 20 */ "Halt", |
| 22822 | | - /* 21 */ "Integer", |
| 22823 | | - /* 22 */ "Int64", |
| 22824 | | - /* 23 */ "String", |
| 22825 | | - /* 24 */ "Null", |
| 22826 | | - /* 25 */ "Blob", |
| 22827 | | - /* 26 */ "Variable", |
| 22828 | | - /* 27 */ "Move", |
| 22829 | | - /* 28 */ "Copy", |
| 22830 | | - /* 29 */ "SCopy", |
| 22831 | | - /* 30 */ "ResultRow", |
| 22832 | | - /* 31 */ "CollSeq", |
| 22833 | | - /* 32 */ "AddImm", |
| 22834 | | - /* 33 */ "MustBeInt", |
| 22835 | | - /* 34 */ "RealAffinity", |
| 22836 | | - /* 35 */ "Permutation", |
| 22837 | | - /* 36 */ "Compare", |
| 22838 | | - /* 37 */ "Jump", |
| 22839 | | - /* 38 */ "Once", |
| 22840 | | - /* 39 */ "If", |
| 22841 | | - /* 40 */ "IfNot", |
| 22842 | | - /* 41 */ "Column", |
| 22843 | | - /* 42 */ "Affinity", |
| 22844 | | - /* 43 */ "MakeRecord", |
| 22845 | | - /* 44 */ "Count", |
| 22846 | | - /* 45 */ "ReadCookie", |
| 22847 | | - /* 46 */ "SetCookie", |
| 22848 | | - /* 47 */ "VerifyCookie", |
| 22849 | | - /* 48 */ "OpenRead", |
| 22850 | | - /* 49 */ "OpenWrite", |
| 22851 | | - /* 50 */ "OpenAutoindex", |
| 22852 | | - /* 51 */ "OpenEphemeral", |
| 22853 | | - /* 52 */ "SorterOpen", |
| 22854 | | - /* 53 */ "OpenPseudo", |
| 22855 | | - /* 54 */ "Close", |
| 22856 | | - /* 55 */ "SeekLt", |
| 22857 | | - /* 56 */ "SeekLe", |
| 22858 | | - /* 57 */ "SeekGe", |
| 22859 | | - /* 58 */ "SeekGt", |
| 22860 | | - /* 59 */ "Seek", |
| 22861 | | - /* 60 */ "NotFound", |
| 22862 | | - /* 61 */ "Found", |
| 22863 | | - /* 62 */ "IsUnique", |
| 22864 | | - /* 63 */ "NotExists", |
| 22865 | | - /* 64 */ "Sequence", |
| 22866 | | - /* 65 */ "NewRowid", |
| 22867 | | - /* 66 */ "Insert", |
| 22868 | | - /* 67 */ "InsertInt", |
| 22869 | | - /* 68 */ "Or", |
| 22870 | | - /* 69 */ "And", |
| 22871 | | - /* 70 */ "Delete", |
| 22872 | | - /* 71 */ "ResetCount", |
| 22873 | | - /* 72 */ "SorterCompare", |
| 22874 | | - /* 73 */ "IsNull", |
| 22875 | | - /* 74 */ "NotNull", |
| 22876 | | - /* 75 */ "Ne", |
| 22877 | | - /* 76 */ "Eq", |
| 22878 | | - /* 77 */ "Gt", |
| 22879 | | - /* 78 */ "Le", |
| 22880 | | - /* 79 */ "Lt", |
| 22881 | | - /* 80 */ "Ge", |
| 22882 | | - /* 81 */ "SorterData", |
| 22883 | | - /* 82 */ "BitAnd", |
| 22884 | | - /* 83 */ "BitOr", |
| 22885 | | - /* 84 */ "ShiftLeft", |
| 22886 | | - /* 85 */ "ShiftRight", |
| 22887 | | - /* 86 */ "Add", |
| 22888 | | - /* 87 */ "Subtract", |
| 22889 | | - /* 88 */ "Multiply", |
| 22890 | | - /* 89 */ "Divide", |
| 22891 | | - /* 90 */ "Remainder", |
| 22892 | | - /* 91 */ "Concat", |
| 22893 | | - /* 92 */ "RowKey", |
| 22894 | | - /* 93 */ "BitNot", |
| 22895 | | - /* 94 */ "String8", |
| 22896 | | - /* 95 */ "RowData", |
| 22897 | | - /* 96 */ "Rowid", |
| 22898 | | - /* 97 */ "NullRow", |
| 22899 | | - /* 98 */ "Last", |
| 22900 | | - /* 99 */ "SorterSort", |
| 22901 | | - /* 100 */ "Sort", |
| 22902 | | - /* 101 */ "Rewind", |
| 22903 | | - /* 102 */ "SorterInsert", |
| 22904 | | - /* 103 */ "IdxInsert", |
| 22905 | | - /* 104 */ "IdxDelete", |
| 22906 | | - /* 105 */ "IdxRowid", |
| 22907 | | - /* 106 */ "IdxLT", |
| 22908 | | - /* 107 */ "IdxGE", |
| 22909 | | - /* 108 */ "Destroy", |
| 22910 | | - /* 109 */ "Clear", |
| 22911 | | - /* 110 */ "CreateIndex", |
| 22912 | | - /* 111 */ "CreateTable", |
| 22913 | | - /* 112 */ "ParseSchema", |
| 22914 | | - /* 113 */ "LoadAnalysis", |
| 22915 | | - /* 114 */ "DropTable", |
| 22916 | | - /* 115 */ "DropIndex", |
| 22917 | | - /* 116 */ "DropTrigger", |
| 22918 | | - /* 117 */ "IntegrityCk", |
| 22919 | | - /* 118 */ "RowSetAdd", |
| 22920 | | - /* 119 */ "RowSetRead", |
| 22921 | | - /* 120 */ "RowSetTest", |
| 22922 | | - /* 121 */ "Program", |
| 22923 | | - /* 122 */ "Param", |
| 22924 | | - /* 123 */ "FkCounter", |
| 22925 | | - /* 124 */ "FkIfZero", |
| 22926 | | - /* 125 */ "MemMax", |
| 22927 | | - /* 126 */ "IfPos", |
| 22928 | | - /* 127 */ "IfNeg", |
| 22929 | | - /* 128 */ "IfZero", |
| 22930 | | - /* 129 */ "AggFinal", |
| 22931 | | - /* 130 */ "Real", |
| 22932 | | - /* 131 */ "IncrVacuum", |
| 22933 | | - /* 132 */ "Expire", |
| 22934 | | - /* 133 */ "TableLock", |
| 22935 | | - /* 134 */ "VBegin", |
| 22936 | | - /* 135 */ "VCreate", |
| 22937 | | - /* 136 */ "VDestroy", |
| 22938 | | - /* 137 */ "VOpen", |
| 22939 | | - /* 138 */ "VColumn", |
| 22940 | | - /* 139 */ "VNext", |
| 22941 | | - /* 140 */ "VRename", |
| 22942 | | - /* 141 */ "ToText", |
| 22943 | | - /* 142 */ "ToBlob", |
| 22944 | | - /* 143 */ "ToNumeric", |
| 22945 | | - /* 144 */ "ToInt", |
| 22946 | | - /* 145 */ "ToReal", |
| 22947 | | - /* 146 */ "Pagecount", |
| 22948 | | - /* 147 */ "MaxPgcnt", |
| 22949 | | - /* 148 */ "Trace", |
| 22950 | | - /* 149 */ "Noop", |
| 22951 | | - /* 150 */ "Explain", |
| 22869 | + /* 1 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 22870 | + /* 2 */ "Savepoint" OpHelp(""), |
| 22871 | + /* 3 */ "AutoCommit" OpHelp(""), |
| 22872 | + /* 4 */ "Transaction" OpHelp(""), |
| 22873 | + /* 5 */ "SorterNext" OpHelp(""), |
| 22874 | + /* 6 */ "Prev" OpHelp(""), |
| 22875 | + /* 7 */ "Next" OpHelp(""), |
| 22876 | + /* 8 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 22877 | + /* 9 */ "Checkpoint" OpHelp(""), |
| 22878 | + /* 10 */ "JournalMode" OpHelp(""), |
| 22879 | + /* 11 */ "Vacuum" OpHelp(""), |
| 22880 | + /* 12 */ "VFilter" OpHelp("iPlan=r[P3] zPlan='P4'"), |
| 22881 | + /* 13 */ "VUpdate" OpHelp("data=r[P3@P2]"), |
| 22882 | + /* 14 */ "Goto" OpHelp(""), |
| 22883 | + /* 15 */ "Gosub" OpHelp(""), |
| 22884 | + /* 16 */ "Return" OpHelp(""), |
| 22885 | + /* 17 */ "Yield" OpHelp(""), |
| 22886 | + /* 18 */ "HaltIfNull" OpHelp("if r[P3] null then halt"), |
| 22887 | + /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"), |
| 22888 | + /* 20 */ "Halt" OpHelp(""), |
| 22889 | + /* 21 */ "Integer" OpHelp("r[P2]=P1"), |
| 22890 | + /* 22 */ "Int64" OpHelp("r[P2]=P4"), |
| 22891 | + /* 23 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 22892 | + /* 24 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 22893 | + /* 25 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 22894 | + /* 26 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 22895 | + /* 27 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 22896 | + /* 28 */ "Copy" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 22897 | + /* 29 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 22898 | + /* 30 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 22899 | + /* 31 */ "CollSeq" OpHelp(""), |
| 22900 | + /* 32 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 22901 | + /* 33 */ "MustBeInt" OpHelp(""), |
| 22902 | + /* 34 */ "RealAffinity" OpHelp(""), |
| 22903 | + /* 35 */ "Permutation" OpHelp(""), |
| 22904 | + /* 36 */ "Compare" OpHelp(""), |
| 22905 | + /* 37 */ "Jump" OpHelp(""), |
| 22906 | + /* 38 */ "Once" OpHelp(""), |
| 22907 | + /* 39 */ "If" OpHelp(""), |
| 22908 | + /* 40 */ "IfNot" OpHelp(""), |
| 22909 | + /* 41 */ "Column" OpHelp("r[P3]=PX"), |
| 22910 | + /* 42 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 22911 | + /* 43 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 22912 | + /* 44 */ "Count" OpHelp("r[P2]=count()"), |
| 22913 | + /* 45 */ "ReadCookie" OpHelp(""), |
| 22914 | + /* 46 */ "SetCookie" OpHelp(""), |
| 22915 | + /* 47 */ "VerifyCookie" OpHelp(""), |
| 22916 | + /* 48 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 22917 | + /* 49 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 22918 | + /* 50 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 22919 | + /* 51 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 22920 | + /* 52 */ "SorterOpen" OpHelp(""), |
| 22921 | + /* 53 */ "OpenPseudo" OpHelp("content in r[P2@P3]"), |
| 22922 | + /* 54 */ "Close" OpHelp(""), |
| 22923 | + /* 55 */ "SeekLt" OpHelp("key=r[P3@P4]"), |
| 22924 | + /* 56 */ "SeekLe" OpHelp("key=r[P3@P4]"), |
| 22925 | + /* 57 */ "SeekGe" OpHelp("key=r[P3@P4]"), |
| 22926 | + /* 58 */ "SeekGt" OpHelp("key=r[P3@P4]"), |
| 22927 | + /* 59 */ "Seek" OpHelp("intkey=r[P2]"), |
| 22928 | + /* 60 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 22929 | + /* 61 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 22930 | + /* 62 */ "Found" OpHelp("key=r[P3@P4]"), |
| 22931 | + /* 63 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 22932 | + /* 64 */ "Sequence" OpHelp("r[P2]=rowid"), |
| 22933 | + /* 65 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 22934 | + /* 66 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 22935 | + /* 67 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 22936 | + /* 68 */ "Delete" OpHelp(""), |
| 22937 | + /* 69 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 22938 | + /* 70 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 22939 | + /* 71 */ "ResetCount" OpHelp(""), |
| 22940 | + /* 72 */ "SorterCompare" OpHelp("if key(P1)!=rtrim(r[P3],P4) goto P2"), |
| 22941 | + /* 73 */ "SorterData" OpHelp("r[P2]=data"), |
| 22942 | + /* 74 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 22943 | + /* 75 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 22944 | + /* 76 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"), |
| 22945 | + /* 77 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"), |
| 22946 | + /* 78 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"), |
| 22947 | + /* 79 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"), |
| 22948 | + /* 80 */ "Lt" OpHelp("if r[P1]<r[P3] goto P3"), |
| 22949 | + /* 81 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"), |
| 22950 | + /* 82 */ "RowKey" OpHelp("r[P2]=key"), |
| 22951 | + /* 83 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 22952 | + /* 84 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 22953 | + /* 85 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 22954 | + /* 86 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 22955 | + /* 87 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 22956 | + /* 88 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 22957 | + /* 89 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 22958 | + /* 90 */ "Divide" OpHelp("r[P3]=r[P1]/r[P2]"), |
| 22959 | + /* 91 */ "Remainder" OpHelp("r[P3]=r[P1]%r[P2]"), |
| 22960 | + /* 92 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 22961 | + /* 93 */ "RowData" OpHelp("r[P2]=data"), |
| 22962 | + /* 94 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 22963 | + /* 95 */ "String8" OpHelp("r[P2]='P4'"), |
| 22964 | + /* 96 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 22965 | + /* 97 */ "NullRow" OpHelp(""), |
| 22966 | + /* 98 */ "Last" OpHelp(""), |
| 22967 | + /* 99 */ "SorterSort" OpHelp(""), |
| 22968 | + /* 100 */ "Sort" OpHelp(""), |
| 22969 | + /* 101 */ "Rewind" OpHelp(""), |
| 22970 | + /* 102 */ "SorterInsert" OpHelp(""), |
| 22971 | + /* 103 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 22972 | + /* 104 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 22973 | + /* 105 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 22974 | + /* 106 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 22975 | + /* 107 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 22976 | + /* 108 */ "Destroy" OpHelp(""), |
| 22977 | + /* 109 */ "Clear" OpHelp(""), |
| 22978 | + /* 110 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 22979 | + /* 111 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 22980 | + /* 112 */ "ParseSchema" OpHelp(""), |
| 22981 | + /* 113 */ "LoadAnalysis" OpHelp(""), |
| 22982 | + /* 114 */ "DropTable" OpHelp(""), |
| 22983 | + /* 115 */ "DropIndex" OpHelp(""), |
| 22984 | + /* 116 */ "DropTrigger" OpHelp(""), |
| 22985 | + /* 117 */ "IntegrityCk" OpHelp(""), |
| 22986 | + /* 118 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 22987 | + /* 119 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 22988 | + /* 120 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 22989 | + /* 121 */ "Program" OpHelp(""), |
| 22990 | + /* 122 */ "Param" OpHelp(""), |
| 22991 | + /* 123 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 22992 | + /* 124 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 22993 | + /* 125 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 22994 | + /* 126 */ "IfPos" OpHelp("if r[P1]>0 goto P2"), |
| 22995 | + /* 127 */ "IfNeg" OpHelp("if r[P1]<0 goto P2"), |
| 22996 | + /* 128 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"), |
| 22997 | + /* 129 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 22998 | + /* 130 */ "IncrVacuum" OpHelp(""), |
| 22999 | + /* 131 */ "Real" OpHelp("r[P2]=P4"), |
| 23000 | + /* 132 */ "Expire" OpHelp(""), |
| 23001 | + /* 133 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 23002 | + /* 134 */ "VBegin" OpHelp(""), |
| 23003 | + /* 135 */ "VCreate" OpHelp(""), |
| 23004 | + /* 136 */ "VDestroy" OpHelp(""), |
| 23005 | + /* 137 */ "VOpen" OpHelp(""), |
| 23006 | + /* 138 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 23007 | + /* 139 */ "VNext" OpHelp(""), |
| 23008 | + /* 140 */ "VRename" OpHelp(""), |
| 23009 | + /* 141 */ "Pagecount" OpHelp(""), |
| 23010 | + /* 142 */ "ToText" OpHelp(""), |
| 23011 | + /* 143 */ "ToBlob" OpHelp(""), |
| 23012 | + /* 144 */ "ToNumeric" OpHelp(""), |
| 23013 | + /* 145 */ "ToInt" OpHelp(""), |
| 23014 | + /* 146 */ "ToReal" OpHelp(""), |
| 23015 | + /* 147 */ "MaxPgcnt" OpHelp(""), |
| 23016 | + /* 148 */ "Trace" OpHelp(""), |
| 23017 | + /* 149 */ "Noop" OpHelp(""), |
| 23018 | + /* 150 */ "Explain" OpHelp(""), |
| 22952 | 23019 | }; |
| 22953 | 23020 | return azName[i]; |
| 22954 | 23021 | } |
| 22955 | 23022 | #endif |
| 22956 | 23023 | |
| | @@ -25053,11 +25120,13 @@ |
| 25053 | 25120 | ** |
| 25054 | 25121 | ** If the locking level of the file descriptor is already at or below |
| 25055 | 25122 | ** the requested locking level, this routine is a no-op. |
| 25056 | 25123 | */ |
| 25057 | 25124 | static int unixUnlock(sqlite3_file *id, int eFileLock){ |
| 25125 | +#if SQLITE_MAX_MMAP_SIZE>0 |
| 25058 | 25126 | assert( eFileLock==SHARED_LOCK || ((unixFile *)id)->nFetchOut==0 ); |
| 25127 | +#endif |
| 25059 | 25128 | return posixUnlock(id, eFileLock, 0); |
| 25060 | 25129 | } |
| 25061 | 25130 | |
| 25062 | 25131 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 25063 | 25132 | static int unixMapfile(unixFile *pFd, i64 nByte); |
| | @@ -30878,38 +30947,52 @@ |
| 30878 | 30947 | #if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE) |
| 30879 | 30948 | # error "At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\ |
| 30880 | 30949 | must be defined." |
| 30881 | 30950 | #endif |
| 30882 | 30951 | |
| 30952 | +/* |
| 30953 | +** This constant should already be defined (in the "WinDef.h" SDK file). |
| 30954 | +*/ |
| 30955 | +#ifndef MAX_PATH |
| 30956 | +# define MAX_PATH (260) |
| 30957 | +#endif |
| 30958 | + |
| 30883 | 30959 | /* |
| 30884 | 30960 | ** Maximum pathname length (in chars) for Win32. This should normally be |
| 30885 | 30961 | ** MAX_PATH. |
| 30886 | 30962 | */ |
| 30887 | 30963 | #ifndef SQLITE_WIN32_MAX_PATH_CHARS |
| 30888 | 30964 | # define SQLITE_WIN32_MAX_PATH_CHARS (MAX_PATH) |
| 30889 | 30965 | #endif |
| 30890 | 30966 | |
| 30967 | +/* |
| 30968 | +** This constant should already be defined (in the "WinNT.h" SDK file). |
| 30969 | +*/ |
| 30970 | +#ifndef UNICODE_STRING_MAX_CHARS |
| 30971 | +# define UNICODE_STRING_MAX_CHARS (32767) |
| 30972 | +#endif |
| 30973 | + |
| 30891 | 30974 | /* |
| 30892 | 30975 | ** Maximum pathname length (in chars) for WinNT. This should normally be |
| 30893 | | -** 32767. |
| 30976 | +** UNICODE_STRING_MAX_CHARS. |
| 30894 | 30977 | */ |
| 30895 | 30978 | #ifndef SQLITE_WINNT_MAX_PATH_CHARS |
| 30896 | | -# define SQLITE_WINNT_MAX_PATH_CHARS (32767) |
| 30979 | +# define SQLITE_WINNT_MAX_PATH_CHARS (UNICODE_STRING_MAX_CHARS) |
| 30897 | 30980 | #endif |
| 30898 | 30981 | |
| 30899 | 30982 | /* |
| 30900 | 30983 | ** Maximum pathname length (in bytes) for Win32. The MAX_PATH macro is in |
| 30901 | | -** characters, so we allocate 3 bytes per character assuming worst-case of |
| 30984 | +** characters, so we allocate 4 bytes per character assuming worst-case of |
| 30902 | 30985 | ** 4-bytes-per-character for UTF8. |
| 30903 | 30986 | */ |
| 30904 | 30987 | #ifndef SQLITE_WIN32_MAX_PATH_BYTES |
| 30905 | 30988 | # define SQLITE_WIN32_MAX_PATH_BYTES (SQLITE_WIN32_MAX_PATH_CHARS*4) |
| 30906 | 30989 | #endif |
| 30907 | 30990 | |
| 30908 | 30991 | /* |
| 30909 | 30992 | ** Maximum pathname length (in bytes) for WinNT. This should normally be |
| 30910 | | -** 32767 * sizeof(WCHAR). |
| 30993 | +** UNICODE_STRING_MAX_CHARS * sizeof(WCHAR). |
| 30911 | 30994 | */ |
| 30912 | 30995 | #ifndef SQLITE_WINNT_MAX_PATH_BYTES |
| 30913 | 30996 | # define SQLITE_WINNT_MAX_PATH_BYTES \ |
| 30914 | 30997 | (sizeof(WCHAR) * SQLITE_WINNT_MAX_PATH_CHARS) |
| 30915 | 30998 | #endif |
| | @@ -30936,18 +31019,14 @@ |
| 30936 | 31019 | #ifndef UNUSED_VARIABLE_VALUE |
| 30937 | 31020 | # define UNUSED_VARIABLE_VALUE(x) (void)(x) |
| 30938 | 31021 | #endif |
| 30939 | 31022 | |
| 30940 | 31023 | /* |
| 30941 | | -** Returns the string that should be used as the directory separator. |
| 31024 | +** Returns the character that should be used as the directory separator. |
| 30942 | 31025 | */ |
| 30943 | | -#ifndef winGetDirDep |
| 30944 | | -# ifdef __CYGWIN__ |
| 30945 | | -# define winGetDirDep() "/" |
| 30946 | | -# else |
| 30947 | | -# define winGetDirDep() "\\" |
| 30948 | | -# endif |
| 31026 | +#ifndef winGetDirSep |
| 31027 | +# define winGetDirSep() '\\' |
| 30949 | 31028 | #endif |
| 30950 | 31029 | |
| 30951 | 31030 | /* |
| 30952 | 31031 | ** Do we need to manually define the Win32 file mapping APIs for use with WAL |
| 30953 | 31032 | ** mode (e.g. these APIs are available in the Windows CE SDK; however, they |
| | @@ -31135,34 +31214,45 @@ |
| 31135 | 31214 | ** sqlite3_mem_methods implementation. |
| 31136 | 31215 | */ |
| 31137 | 31216 | typedef struct winMemData winMemData; |
| 31138 | 31217 | struct winMemData { |
| 31139 | 31218 | #ifndef NDEBUG |
| 31140 | | - u32 magic; /* Magic number to detect structure corruption. */ |
| 31219 | + u32 magic1; /* Magic number to detect structure corruption. */ |
| 31141 | 31220 | #endif |
| 31142 | 31221 | HANDLE hHeap; /* The handle to our heap. */ |
| 31143 | 31222 | BOOL bOwned; /* Do we own the heap (i.e. destroy it on shutdown)? */ |
| 31223 | +#ifndef NDEBUG |
| 31224 | + u32 magic2; /* Magic number to detect structure corruption. */ |
| 31225 | +#endif |
| 31144 | 31226 | }; |
| 31145 | 31227 | |
| 31146 | 31228 | #ifndef NDEBUG |
| 31147 | | -#define WINMEM_MAGIC 0x42b2830b |
| 31229 | +#define WINMEM_MAGIC1 0x42b2830b |
| 31230 | +#define WINMEM_MAGIC2 0xbd4d7cf4 |
| 31148 | 31231 | #endif |
| 31149 | 31232 | |
| 31150 | 31233 | static struct winMemData win_mem_data = { |
| 31151 | 31234 | #ifndef NDEBUG |
| 31152 | | - WINMEM_MAGIC, |
| 31235 | + WINMEM_MAGIC1, |
| 31153 | 31236 | #endif |
| 31154 | 31237 | NULL, FALSE |
| 31238 | +#ifndef NDEBUG |
| 31239 | + ,WINMEM_MAGIC2 |
| 31240 | +#endif |
| 31155 | 31241 | }; |
| 31156 | 31242 | |
| 31157 | 31243 | #ifndef NDEBUG |
| 31158 | | -#define winMemAssertMagic() assert( win_mem_data.magic==WINMEM_MAGIC ) |
| 31244 | +#define winMemAssertMagic1() assert( win_mem_data.magic1==WINMEM_MAGIC1 ) |
| 31245 | +#define winMemAssertMagic2() assert( win_mem_data.magic2==WINMEM_MAGIC2 ) |
| 31246 | +#define winMemAssertMagic() winMemAssertMagic1(); winMemAssertMagic2(); |
| 31159 | 31247 | #else |
| 31160 | 31248 | #define winMemAssertMagic() |
| 31161 | 31249 | #endif |
| 31162 | 31250 | |
| 31163 | | -#define winMemGetHeap() win_mem_data.hHeap |
| 31251 | +#define winMemGetDataPtr() &win_mem_data |
| 31252 | +#define winMemGetHeap() win_mem_data.hHeap |
| 31253 | +#define winMemGetOwned() win_mem_data.bOwned |
| 31164 | 31254 | |
| 31165 | 31255 | static void *winMemMalloc(int nBytes); |
| 31166 | 31256 | static void winMemFree(void *pPrior); |
| 31167 | 31257 | static void *winMemRealloc(void *pPrior, int nBytes); |
| 31168 | 31258 | static int winMemSize(void *p); |
| | @@ -31555,44 +31645,52 @@ |
| 31555 | 31645 | #endif |
| 31556 | 31646 | |
| 31557 | 31647 | #define osHeapValidate ((BOOL(WINAPI*)(HANDLE,DWORD, \ |
| 31558 | 31648 | LPCVOID))aSyscall[42].pCurrent) |
| 31559 | 31649 | |
| 31650 | +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 31651 | + { "HeapCompact", (SYSCALL)HeapCompact, 0 }, |
| 31652 | +#else |
| 31653 | + { "HeapCompact", (SYSCALL)0, 0 }, |
| 31654 | +#endif |
| 31655 | + |
| 31656 | +#define osHeapCompact ((UINT(WINAPI*)(HANDLE,DWORD))aSyscall[43].pCurrent) |
| 31657 | + |
| 31560 | 31658 | #if defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 31561 | 31659 | { "LoadLibraryA", (SYSCALL)LoadLibraryA, 0 }, |
| 31562 | 31660 | #else |
| 31563 | 31661 | { "LoadLibraryA", (SYSCALL)0, 0 }, |
| 31564 | 31662 | #endif |
| 31565 | 31663 | |
| 31566 | | -#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[43].pCurrent) |
| 31664 | +#define osLoadLibraryA ((HMODULE(WINAPI*)(LPCSTR))aSyscall[44].pCurrent) |
| 31567 | 31665 | |
| 31568 | 31666 | #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \ |
| 31569 | 31667 | !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 31570 | 31668 | { "LoadLibraryW", (SYSCALL)LoadLibraryW, 0 }, |
| 31571 | 31669 | #else |
| 31572 | 31670 | { "LoadLibraryW", (SYSCALL)0, 0 }, |
| 31573 | 31671 | #endif |
| 31574 | 31672 | |
| 31575 | | -#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[44].pCurrent) |
| 31673 | +#define osLoadLibraryW ((HMODULE(WINAPI*)(LPCWSTR))aSyscall[45].pCurrent) |
| 31576 | 31674 | |
| 31577 | 31675 | #if !SQLITE_OS_WINRT |
| 31578 | 31676 | { "LocalFree", (SYSCALL)LocalFree, 0 }, |
| 31579 | 31677 | #else |
| 31580 | 31678 | { "LocalFree", (SYSCALL)0, 0 }, |
| 31581 | 31679 | #endif |
| 31582 | 31680 | |
| 31583 | | -#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[45].pCurrent) |
| 31681 | +#define osLocalFree ((HLOCAL(WINAPI*)(HLOCAL))aSyscall[46].pCurrent) |
| 31584 | 31682 | |
| 31585 | 31683 | #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 31586 | 31684 | { "LockFile", (SYSCALL)LockFile, 0 }, |
| 31587 | 31685 | #else |
| 31588 | 31686 | { "LockFile", (SYSCALL)0, 0 }, |
| 31589 | 31687 | #endif |
| 31590 | 31688 | |
| 31591 | 31689 | #ifndef osLockFile |
| 31592 | 31690 | #define osLockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ |
| 31593 | | - DWORD))aSyscall[46].pCurrent) |
| 31691 | + DWORD))aSyscall[47].pCurrent) |
| 31594 | 31692 | #endif |
| 31595 | 31693 | |
| 31596 | 31694 | #if !SQLITE_OS_WINCE |
| 31597 | 31695 | { "LockFileEx", (SYSCALL)LockFileEx, 0 }, |
| 31598 | 31696 | #else |
| | @@ -31599,218 +31697,218 @@ |
| 31599 | 31697 | { "LockFileEx", (SYSCALL)0, 0 }, |
| 31600 | 31698 | #endif |
| 31601 | 31699 | |
| 31602 | 31700 | #ifndef osLockFileEx |
| 31603 | 31701 | #define osLockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD,DWORD, \ |
| 31604 | | - LPOVERLAPPED))aSyscall[47].pCurrent) |
| 31702 | + LPOVERLAPPED))aSyscall[48].pCurrent) |
| 31605 | 31703 | #endif |
| 31606 | 31704 | |
| 31607 | 31705 | #if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)) |
| 31608 | 31706 | { "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 }, |
| 31609 | 31707 | #else |
| 31610 | 31708 | { "MapViewOfFile", (SYSCALL)0, 0 }, |
| 31611 | 31709 | #endif |
| 31612 | 31710 | |
| 31613 | 31711 | #define osMapViewOfFile ((LPVOID(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ |
| 31614 | | - SIZE_T))aSyscall[48].pCurrent) |
| 31712 | + SIZE_T))aSyscall[49].pCurrent) |
| 31615 | 31713 | |
| 31616 | 31714 | { "MultiByteToWideChar", (SYSCALL)MultiByteToWideChar, 0 }, |
| 31617 | 31715 | |
| 31618 | 31716 | #define osMultiByteToWideChar ((int(WINAPI*)(UINT,DWORD,LPCSTR,int,LPWSTR, \ |
| 31619 | | - int))aSyscall[49].pCurrent) |
| 31717 | + int))aSyscall[50].pCurrent) |
| 31620 | 31718 | |
| 31621 | 31719 | { "QueryPerformanceCounter", (SYSCALL)QueryPerformanceCounter, 0 }, |
| 31622 | 31720 | |
| 31623 | 31721 | #define osQueryPerformanceCounter ((BOOL(WINAPI*)( \ |
| 31624 | | - LARGE_INTEGER*))aSyscall[50].pCurrent) |
| 31722 | + LARGE_INTEGER*))aSyscall[51].pCurrent) |
| 31625 | 31723 | |
| 31626 | 31724 | { "ReadFile", (SYSCALL)ReadFile, 0 }, |
| 31627 | 31725 | |
| 31628 | 31726 | #define osReadFile ((BOOL(WINAPI*)(HANDLE,LPVOID,DWORD,LPDWORD, \ |
| 31629 | | - LPOVERLAPPED))aSyscall[51].pCurrent) |
| 31727 | + LPOVERLAPPED))aSyscall[52].pCurrent) |
| 31630 | 31728 | |
| 31631 | 31729 | { "SetEndOfFile", (SYSCALL)SetEndOfFile, 0 }, |
| 31632 | 31730 | |
| 31633 | | -#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[52].pCurrent) |
| 31731 | +#define osSetEndOfFile ((BOOL(WINAPI*)(HANDLE))aSyscall[53].pCurrent) |
| 31634 | 31732 | |
| 31635 | 31733 | #if !SQLITE_OS_WINRT |
| 31636 | 31734 | { "SetFilePointer", (SYSCALL)SetFilePointer, 0 }, |
| 31637 | 31735 | #else |
| 31638 | 31736 | { "SetFilePointer", (SYSCALL)0, 0 }, |
| 31639 | 31737 | #endif |
| 31640 | 31738 | |
| 31641 | 31739 | #define osSetFilePointer ((DWORD(WINAPI*)(HANDLE,LONG,PLONG, \ |
| 31642 | | - DWORD))aSyscall[53].pCurrent) |
| 31740 | + DWORD))aSyscall[54].pCurrent) |
| 31643 | 31741 | |
| 31644 | 31742 | #if !SQLITE_OS_WINRT |
| 31645 | 31743 | { "Sleep", (SYSCALL)Sleep, 0 }, |
| 31646 | 31744 | #else |
| 31647 | 31745 | { "Sleep", (SYSCALL)0, 0 }, |
| 31648 | 31746 | #endif |
| 31649 | 31747 | |
| 31650 | | -#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[54].pCurrent) |
| 31748 | +#define osSleep ((VOID(WINAPI*)(DWORD))aSyscall[55].pCurrent) |
| 31651 | 31749 | |
| 31652 | 31750 | { "SystemTimeToFileTime", (SYSCALL)SystemTimeToFileTime, 0 }, |
| 31653 | 31751 | |
| 31654 | 31752 | #define osSystemTimeToFileTime ((BOOL(WINAPI*)(CONST SYSTEMTIME*, \ |
| 31655 | | - LPFILETIME))aSyscall[55].pCurrent) |
| 31753 | + LPFILETIME))aSyscall[56].pCurrent) |
| 31656 | 31754 | |
| 31657 | 31755 | #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 31658 | 31756 | { "UnlockFile", (SYSCALL)UnlockFile, 0 }, |
| 31659 | 31757 | #else |
| 31660 | 31758 | { "UnlockFile", (SYSCALL)0, 0 }, |
| 31661 | 31759 | #endif |
| 31662 | 31760 | |
| 31663 | 31761 | #ifndef osUnlockFile |
| 31664 | 31762 | #define osUnlockFile ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ |
| 31665 | | - DWORD))aSyscall[56].pCurrent) |
| 31763 | + DWORD))aSyscall[57].pCurrent) |
| 31666 | 31764 | #endif |
| 31667 | 31765 | |
| 31668 | 31766 | #if !SQLITE_OS_WINCE |
| 31669 | 31767 | { "UnlockFileEx", (SYSCALL)UnlockFileEx, 0 }, |
| 31670 | 31768 | #else |
| 31671 | 31769 | { "UnlockFileEx", (SYSCALL)0, 0 }, |
| 31672 | 31770 | #endif |
| 31673 | 31771 | |
| 31674 | 31772 | #define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ |
| 31675 | | - LPOVERLAPPED))aSyscall[57].pCurrent) |
| 31773 | + LPOVERLAPPED))aSyscall[58].pCurrent) |
| 31676 | 31774 | |
| 31677 | 31775 | #if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) |
| 31678 | 31776 | { "UnmapViewOfFile", (SYSCALL)UnmapViewOfFile, 0 }, |
| 31679 | 31777 | #else |
| 31680 | 31778 | { "UnmapViewOfFile", (SYSCALL)0, 0 }, |
| 31681 | 31779 | #endif |
| 31682 | 31780 | |
| 31683 | | -#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[58].pCurrent) |
| 31781 | +#define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[59].pCurrent) |
| 31684 | 31782 | |
| 31685 | 31783 | { "WideCharToMultiByte", (SYSCALL)WideCharToMultiByte, 0 }, |
| 31686 | 31784 | |
| 31687 | 31785 | #define osWideCharToMultiByte ((int(WINAPI*)(UINT,DWORD,LPCWSTR,int,LPSTR,int, \ |
| 31688 | | - LPCSTR,LPBOOL))aSyscall[59].pCurrent) |
| 31786 | + LPCSTR,LPBOOL))aSyscall[60].pCurrent) |
| 31689 | 31787 | |
| 31690 | 31788 | { "WriteFile", (SYSCALL)WriteFile, 0 }, |
| 31691 | 31789 | |
| 31692 | 31790 | #define osWriteFile ((BOOL(WINAPI*)(HANDLE,LPCVOID,DWORD,LPDWORD, \ |
| 31693 | | - LPOVERLAPPED))aSyscall[60].pCurrent) |
| 31791 | + LPOVERLAPPED))aSyscall[61].pCurrent) |
| 31694 | 31792 | |
| 31695 | 31793 | #if SQLITE_OS_WINRT |
| 31696 | 31794 | { "CreateEventExW", (SYSCALL)CreateEventExW, 0 }, |
| 31697 | 31795 | #else |
| 31698 | 31796 | { "CreateEventExW", (SYSCALL)0, 0 }, |
| 31699 | 31797 | #endif |
| 31700 | 31798 | |
| 31701 | 31799 | #define osCreateEventExW ((HANDLE(WINAPI*)(LPSECURITY_ATTRIBUTES,LPCWSTR, \ |
| 31702 | | - DWORD,DWORD))aSyscall[61].pCurrent) |
| 31800 | + DWORD,DWORD))aSyscall[62].pCurrent) |
| 31703 | 31801 | |
| 31704 | 31802 | #if !SQLITE_OS_WINRT |
| 31705 | 31803 | { "WaitForSingleObject", (SYSCALL)WaitForSingleObject, 0 }, |
| 31706 | 31804 | #else |
| 31707 | 31805 | { "WaitForSingleObject", (SYSCALL)0, 0 }, |
| 31708 | 31806 | #endif |
| 31709 | 31807 | |
| 31710 | 31808 | #define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \ |
| 31711 | | - DWORD))aSyscall[62].pCurrent) |
| 31809 | + DWORD))aSyscall[63].pCurrent) |
| 31712 | 31810 | |
| 31713 | 31811 | #if SQLITE_OS_WINRT |
| 31714 | 31812 | { "WaitForSingleObjectEx", (SYSCALL)WaitForSingleObjectEx, 0 }, |
| 31715 | 31813 | #else |
| 31716 | 31814 | { "WaitForSingleObjectEx", (SYSCALL)0, 0 }, |
| 31717 | 31815 | #endif |
| 31718 | 31816 | |
| 31719 | 31817 | #define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \ |
| 31720 | | - BOOL))aSyscall[63].pCurrent) |
| 31818 | + BOOL))aSyscall[64].pCurrent) |
| 31721 | 31819 | |
| 31722 | 31820 | #if SQLITE_OS_WINRT |
| 31723 | 31821 | { "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 }, |
| 31724 | 31822 | #else |
| 31725 | 31823 | { "SetFilePointerEx", (SYSCALL)0, 0 }, |
| 31726 | 31824 | #endif |
| 31727 | 31825 | |
| 31728 | 31826 | #define osSetFilePointerEx ((BOOL(WINAPI*)(HANDLE,LARGE_INTEGER, \ |
| 31729 | | - PLARGE_INTEGER,DWORD))aSyscall[64].pCurrent) |
| 31827 | + PLARGE_INTEGER,DWORD))aSyscall[65].pCurrent) |
| 31730 | 31828 | |
| 31731 | 31829 | #if SQLITE_OS_WINRT |
| 31732 | 31830 | { "GetFileInformationByHandleEx", (SYSCALL)GetFileInformationByHandleEx, 0 }, |
| 31733 | 31831 | #else |
| 31734 | 31832 | { "GetFileInformationByHandleEx", (SYSCALL)0, 0 }, |
| 31735 | 31833 | #endif |
| 31736 | 31834 | |
| 31737 | 31835 | #define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \ |
| 31738 | | - FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[65].pCurrent) |
| 31836 | + FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent) |
| 31739 | 31837 | |
| 31740 | 31838 | #if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL) |
| 31741 | 31839 | { "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 }, |
| 31742 | 31840 | #else |
| 31743 | 31841 | { "MapViewOfFileFromApp", (SYSCALL)0, 0 }, |
| 31744 | 31842 | #endif |
| 31745 | 31843 | |
| 31746 | 31844 | #define osMapViewOfFileFromApp ((LPVOID(WINAPI*)(HANDLE,ULONG,ULONG64, \ |
| 31747 | | - SIZE_T))aSyscall[66].pCurrent) |
| 31845 | + SIZE_T))aSyscall[67].pCurrent) |
| 31748 | 31846 | |
| 31749 | 31847 | #if SQLITE_OS_WINRT |
| 31750 | 31848 | { "CreateFile2", (SYSCALL)CreateFile2, 0 }, |
| 31751 | 31849 | #else |
| 31752 | 31850 | { "CreateFile2", (SYSCALL)0, 0 }, |
| 31753 | 31851 | #endif |
| 31754 | 31852 | |
| 31755 | 31853 | #define osCreateFile2 ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD,DWORD, \ |
| 31756 | | - LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[67].pCurrent) |
| 31854 | + LPCREATEFILE2_EXTENDED_PARAMETERS))aSyscall[68].pCurrent) |
| 31757 | 31855 | |
| 31758 | 31856 | #if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 31759 | 31857 | { "LoadPackagedLibrary", (SYSCALL)LoadPackagedLibrary, 0 }, |
| 31760 | 31858 | #else |
| 31761 | 31859 | { "LoadPackagedLibrary", (SYSCALL)0, 0 }, |
| 31762 | 31860 | #endif |
| 31763 | 31861 | |
| 31764 | 31862 | #define osLoadPackagedLibrary ((HMODULE(WINAPI*)(LPCWSTR, \ |
| 31765 | | - DWORD))aSyscall[68].pCurrent) |
| 31863 | + DWORD))aSyscall[69].pCurrent) |
| 31766 | 31864 | |
| 31767 | 31865 | #if SQLITE_OS_WINRT |
| 31768 | 31866 | { "GetTickCount64", (SYSCALL)GetTickCount64, 0 }, |
| 31769 | 31867 | #else |
| 31770 | 31868 | { "GetTickCount64", (SYSCALL)0, 0 }, |
| 31771 | 31869 | #endif |
| 31772 | 31870 | |
| 31773 | | -#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[69].pCurrent) |
| 31871 | +#define osGetTickCount64 ((ULONGLONG(WINAPI*)(VOID))aSyscall[70].pCurrent) |
| 31774 | 31872 | |
| 31775 | 31873 | #if SQLITE_OS_WINRT |
| 31776 | 31874 | { "GetNativeSystemInfo", (SYSCALL)GetNativeSystemInfo, 0 }, |
| 31777 | 31875 | #else |
| 31778 | 31876 | { "GetNativeSystemInfo", (SYSCALL)0, 0 }, |
| 31779 | 31877 | #endif |
| 31780 | 31878 | |
| 31781 | 31879 | #define osGetNativeSystemInfo ((VOID(WINAPI*)( \ |
| 31782 | | - LPSYSTEM_INFO))aSyscall[70].pCurrent) |
| 31880 | + LPSYSTEM_INFO))aSyscall[71].pCurrent) |
| 31783 | 31881 | |
| 31784 | 31882 | #if defined(SQLITE_WIN32_HAS_ANSI) |
| 31785 | 31883 | { "OutputDebugStringA", (SYSCALL)OutputDebugStringA, 0 }, |
| 31786 | 31884 | #else |
| 31787 | 31885 | { "OutputDebugStringA", (SYSCALL)0, 0 }, |
| 31788 | 31886 | #endif |
| 31789 | 31887 | |
| 31790 | | -#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[71].pCurrent) |
| 31888 | +#define osOutputDebugStringA ((VOID(WINAPI*)(LPCSTR))aSyscall[72].pCurrent) |
| 31791 | 31889 | |
| 31792 | 31890 | #if defined(SQLITE_WIN32_HAS_WIDE) |
| 31793 | 31891 | { "OutputDebugStringW", (SYSCALL)OutputDebugStringW, 0 }, |
| 31794 | 31892 | #else |
| 31795 | 31893 | { "OutputDebugStringW", (SYSCALL)0, 0 }, |
| 31796 | 31894 | #endif |
| 31797 | 31895 | |
| 31798 | | -#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[72].pCurrent) |
| 31896 | +#define osOutputDebugStringW ((VOID(WINAPI*)(LPCWSTR))aSyscall[73].pCurrent) |
| 31799 | 31897 | |
| 31800 | 31898 | { "GetProcessHeap", (SYSCALL)GetProcessHeap, 0 }, |
| 31801 | 31899 | |
| 31802 | | -#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[73].pCurrent) |
| 31900 | +#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent) |
| 31803 | 31901 | |
| 31804 | 31902 | #if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL) |
| 31805 | 31903 | { "CreateFileMappingFromApp", (SYSCALL)CreateFileMappingFromApp, 0 }, |
| 31806 | 31904 | #else |
| 31807 | 31905 | { "CreateFileMappingFromApp", (SYSCALL)0, 0 }, |
| 31808 | 31906 | #endif |
| 31809 | 31907 | |
| 31810 | 31908 | #define osCreateFileMappingFromApp ((HANDLE(WINAPI*)(HANDLE, \ |
| 31811 | | - LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[74].pCurrent) |
| 31909 | + LPSECURITY_ATTRIBUTES,ULONG,ULONG64,LPCWSTR))aSyscall[75].pCurrent) |
| 31812 | 31910 | |
| 31813 | 31911 | }; /* End of the overrideable system calls */ |
| 31814 | 31912 | |
| 31815 | 31913 | /* |
| 31816 | 31914 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| | @@ -31893,10 +31991,98 @@ |
| 31893 | 31991 | if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName; |
| 31894 | 31992 | } |
| 31895 | 31993 | return 0; |
| 31896 | 31994 | } |
| 31897 | 31995 | |
| 31996 | +#ifdef SQLITE_WIN32_MALLOC |
| 31997 | +/* |
| 31998 | +** If a Win32 native heap has been configured, this function will attempt to |
| 31999 | +** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one |
| 32000 | +** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The |
| 32001 | +** "pnLargest" argument, if non-zero, will be used to return the size of the |
| 32002 | +** largest committed free block in the heap, in bytes. |
| 32003 | +*/ |
| 32004 | +SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){ |
| 32005 | + int rc = SQLITE_OK; |
| 32006 | + UINT nLargest = 0; |
| 32007 | + HANDLE hHeap; |
| 32008 | + |
| 32009 | + winMemAssertMagic(); |
| 32010 | + hHeap = winMemGetHeap(); |
| 32011 | + assert( hHeap!=0 ); |
| 32012 | + assert( hHeap!=INVALID_HANDLE_VALUE ); |
| 32013 | +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) |
| 32014 | + assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); |
| 32015 | +#endif |
| 32016 | +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 32017 | + if( (nLargest=osHeapCompact(hHeap, SQLITE_WIN32_HEAP_FLAGS))==0 ){ |
| 32018 | + DWORD lastErrno = osGetLastError(); |
| 32019 | + if( lastErrno==NO_ERROR ){ |
| 32020 | + sqlite3_log(SQLITE_NOMEM, "failed to HeapCompact (no space), heap=%p", |
| 32021 | + (void*)hHeap); |
| 32022 | + rc = SQLITE_NOMEM; |
| 32023 | + }else{ |
| 32024 | + sqlite3_log(SQLITE_ERROR, "failed to HeapCompact (%lu), heap=%p", |
| 32025 | + osGetLastError(), (void*)hHeap); |
| 32026 | + rc = SQLITE_ERROR; |
| 32027 | + } |
| 32028 | + } |
| 32029 | +#else |
| 32030 | + sqlite3_log(SQLITE_NOTFOUND, "failed to HeapCompact, heap=%p", |
| 32031 | + (void*)hHeap); |
| 32032 | + rc = SQLITE_NOTFOUND; |
| 32033 | +#endif |
| 32034 | + if( pnLargest ) *pnLargest = nLargest; |
| 32035 | + return rc; |
| 32036 | +} |
| 32037 | + |
| 32038 | +/* |
| 32039 | +** If a Win32 native heap has been configured, this function will attempt to |
| 32040 | +** destroy and recreate it. If the Win32 native heap is not isolated and/or |
| 32041 | +** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will |
| 32042 | +** be returned and no changes will be made to the Win32 native heap. |
| 32043 | +*/ |
| 32044 | +SQLITE_API int sqlite3_win32_reset_heap(){ |
| 32045 | + int rc; |
| 32046 | + MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ |
| 32047 | + MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */ |
| 32048 | + MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) |
| 32049 | + MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); ) |
| 32050 | + sqlite3_mutex_enter(pMaster); |
| 32051 | + sqlite3_mutex_enter(pMem); |
| 32052 | + winMemAssertMagic(); |
| 32053 | + if( winMemGetHeap()!=NULL && winMemGetOwned() && sqlite3_memory_used()==0 ){ |
| 32054 | + /* |
| 32055 | + ** At this point, there should be no outstanding memory allocations on |
| 32056 | + ** the heap. Also, since both the master and memsys locks are currently |
| 32057 | + ** being held by us, no other function (i.e. from another thread) should |
| 32058 | + ** be able to even access the heap. Attempt to destroy and recreate our |
| 32059 | + ** isolated Win32 native heap now. |
| 32060 | + */ |
| 32061 | + assert( winMemGetHeap()!=NULL ); |
| 32062 | + assert( winMemGetOwned() ); |
| 32063 | + assert( sqlite3_memory_used()==0 ); |
| 32064 | + winMemShutdown(winMemGetDataPtr()); |
| 32065 | + assert( winMemGetHeap()==NULL ); |
| 32066 | + assert( !winMemGetOwned() ); |
| 32067 | + assert( sqlite3_memory_used()==0 ); |
| 32068 | + rc = winMemInit(winMemGetDataPtr()); |
| 32069 | + assert( rc!=SQLITE_OK || winMemGetHeap()!=NULL ); |
| 32070 | + assert( rc!=SQLITE_OK || winMemGetOwned() ); |
| 32071 | + assert( rc!=SQLITE_OK || sqlite3_memory_used()==0 ); |
| 32072 | + }else{ |
| 32073 | + /* |
| 32074 | + ** The Win32 native heap cannot be modified because it may be in use. |
| 32075 | + */ |
| 32076 | + rc = SQLITE_BUSY; |
| 32077 | + } |
| 32078 | + sqlite3_mutex_leave(pMem); |
| 32079 | + sqlite3_mutex_leave(pMaster); |
| 32080 | + return rc; |
| 32081 | +} |
| 32082 | +#endif /* SQLITE_WIN32_MALLOC */ |
| 32083 | + |
| 31898 | 32084 | /* |
| 31899 | 32085 | ** This function outputs the specified (ANSI) string to the Win32 debugger |
| 31900 | 32086 | ** (if available). |
| 31901 | 32087 | */ |
| 31902 | 32088 | |
| | @@ -32001,11 +32187,11 @@ |
| 32001 | 32187 | winMemAssertMagic(); |
| 32002 | 32188 | hHeap = winMemGetHeap(); |
| 32003 | 32189 | assert( hHeap!=0 ); |
| 32004 | 32190 | assert( hHeap!=INVALID_HANDLE_VALUE ); |
| 32005 | 32191 | #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) |
| 32006 | | - assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); |
| 32192 | + assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); |
| 32007 | 32193 | #endif |
| 32008 | 32194 | assert( nBytes>=0 ); |
| 32009 | 32195 | p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes); |
| 32010 | 32196 | if( !p ){ |
| 32011 | 32197 | sqlite3_log(SQLITE_NOMEM, "failed to HeapAlloc %u bytes (%lu), heap=%p", |
| | @@ -32023,11 +32209,11 @@ |
| 32023 | 32209 | winMemAssertMagic(); |
| 32024 | 32210 | hHeap = winMemGetHeap(); |
| 32025 | 32211 | assert( hHeap!=0 ); |
| 32026 | 32212 | assert( hHeap!=INVALID_HANDLE_VALUE ); |
| 32027 | 32213 | #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) |
| 32028 | | - assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); |
| 32214 | + assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); |
| 32029 | 32215 | #endif |
| 32030 | 32216 | if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */ |
| 32031 | 32217 | if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){ |
| 32032 | 32218 | sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%lu), heap=%p", |
| 32033 | 32219 | pPrior, osGetLastError(), (void*)hHeap); |
| | @@ -32044,11 +32230,11 @@ |
| 32044 | 32230 | winMemAssertMagic(); |
| 32045 | 32231 | hHeap = winMemGetHeap(); |
| 32046 | 32232 | assert( hHeap!=0 ); |
| 32047 | 32233 | assert( hHeap!=INVALID_HANDLE_VALUE ); |
| 32048 | 32234 | #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) |
| 32049 | | - assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); |
| 32235 | + assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ); |
| 32050 | 32236 | #endif |
| 32051 | 32237 | assert( nBytes>=0 ); |
| 32052 | 32238 | if( !pPrior ){ |
| 32053 | 32239 | p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes); |
| 32054 | 32240 | }else{ |
| | @@ -32072,11 +32258,11 @@ |
| 32072 | 32258 | winMemAssertMagic(); |
| 32073 | 32259 | hHeap = winMemGetHeap(); |
| 32074 | 32260 | assert( hHeap!=0 ); |
| 32075 | 32261 | assert( hHeap!=INVALID_HANDLE_VALUE ); |
| 32076 | 32262 | #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) |
| 32077 | | - assert ( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); |
| 32263 | + assert( osHeapValidate(hHeap, SQLITE_WIN32_HEAP_FLAGS, p) ); |
| 32078 | 32264 | #endif |
| 32079 | 32265 | if( !p ) return 0; |
| 32080 | 32266 | n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p); |
| 32081 | 32267 | if( n==(SIZE_T)-1 ){ |
| 32082 | 32268 | sqlite3_log(SQLITE_NOMEM, "failed to HeapSize block %p (%lu), heap=%p", |
| | @@ -32098,11 +32284,12 @@ |
| 32098 | 32284 | */ |
| 32099 | 32285 | static int winMemInit(void *pAppData){ |
| 32100 | 32286 | winMemData *pWinMemData = (winMemData *)pAppData; |
| 32101 | 32287 | |
| 32102 | 32288 | if( !pWinMemData ) return SQLITE_ERROR; |
| 32103 | | - assert( pWinMemData->magic==WINMEM_MAGIC ); |
| 32289 | + assert( pWinMemData->magic1==WINMEM_MAGIC1 ); |
| 32290 | + assert( pWinMemData->magic2==WINMEM_MAGIC2 ); |
| 32104 | 32291 | |
| 32105 | 32292 | #if !SQLITE_OS_WINRT && SQLITE_WIN32_HEAP_CREATE |
| 32106 | 32293 | if( !pWinMemData->hHeap ){ |
| 32107 | 32294 | pWinMemData->hHeap = osHeapCreate(SQLITE_WIN32_HEAP_FLAGS, |
| 32108 | 32295 | SQLITE_WIN32_HEAP_INIT_SIZE, |
| | @@ -32140,10 +32327,13 @@ |
| 32140 | 32327 | */ |
| 32141 | 32328 | static void winMemShutdown(void *pAppData){ |
| 32142 | 32329 | winMemData *pWinMemData = (winMemData *)pAppData; |
| 32143 | 32330 | |
| 32144 | 32331 | if( !pWinMemData ) return; |
| 32332 | + assert( pWinMemData->magic1==WINMEM_MAGIC1 ); |
| 32333 | + assert( pWinMemData->magic2==WINMEM_MAGIC2 ); |
| 32334 | + |
| 32145 | 32335 | if( pWinMemData->hHeap ){ |
| 32146 | 32336 | assert( pWinMemData->hHeap!=INVALID_HANDLE_VALUE ); |
| 32147 | 32337 | #if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_MALLOC_VALIDATE) |
| 32148 | 32338 | assert( osHeapValidate(pWinMemData->hHeap, SQLITE_WIN32_HEAP_FLAGS, NULL) ); |
| 32149 | 32339 | #endif |
| | @@ -34809,16 +34999,25 @@ |
| 34809 | 34999 | return zConverted; |
| 34810 | 35000 | } |
| 34811 | 35001 | |
| 34812 | 35002 | /* |
| 34813 | 35003 | ** This function returns non-zero if the specified UTF-8 string buffer |
| 34814 | | -** ends with a directory separator character. |
| 35004 | +** ends with a directory separator character or one was successfully |
| 35005 | +** added to it. |
| 34815 | 35006 | */ |
| 34816 | | -static int winEndsInDirSep(char *zBuf){ |
| 35007 | +static int winMakeEndInDirSep(int nBuf, char *zBuf){ |
| 34817 | 35008 | if( zBuf ){ |
| 34818 | 35009 | int nLen = sqlite3Strlen30(zBuf); |
| 34819 | | - return nLen>0 && winIsDirSep(zBuf[nLen-1]); |
| 35010 | + if( nLen>0 ){ |
| 35011 | + if( winIsDirSep(zBuf[nLen-1]) ){ |
| 35012 | + return 1; |
| 35013 | + }else if( nLen+1<nBuf ){ |
| 35014 | + zBuf[nLen] = winGetDirSep(); |
| 35015 | + zBuf[nLen+1] = '\0'; |
| 35016 | + return 1; |
| 35017 | + } |
| 35018 | + } |
| 34820 | 35019 | } |
| 34821 | 35020 | return 0; |
| 34822 | 35021 | } |
| 34823 | 35022 | |
| 34824 | 35023 | /* |
| | @@ -34829,11 +35028,12 @@ |
| 34829 | 35028 | static char zChars[] = |
| 34830 | 35029 | "abcdefghijklmnopqrstuvwxyz" |
| 34831 | 35030 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 34832 | 35031 | "0123456789"; |
| 34833 | 35032 | size_t i, j; |
| 34834 | | - int nBuf, nLen; |
| 35033 | + int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX); |
| 35034 | + int nMax, nBuf, nDir, nLen; |
| 34835 | 35035 | char *zBuf; |
| 34836 | 35036 | |
| 34837 | 35037 | /* It's odd to simulate an io-error here, but really this is just |
| 34838 | 35038 | ** using the io-error infrastructure to test that SQLite handles this |
| 34839 | 35039 | ** function failing. |
| | @@ -34841,26 +35041,36 @@ |
| 34841 | 35041 | SimulateIOError( return SQLITE_IOERR ); |
| 34842 | 35042 | |
| 34843 | 35043 | /* Allocate a temporary buffer to store the fully qualified file |
| 34844 | 35044 | ** name for the temporary file. If this fails, we cannot continue. |
| 34845 | 35045 | */ |
| 34846 | | - nBuf = pVfs->mxPathname; |
| 34847 | | - zBuf = sqlite3MallocZero( nBuf+2 ); |
| 35046 | + nMax = pVfs->mxPathname; nBuf = nMax + 2; |
| 35047 | + zBuf = sqlite3MallocZero( nBuf ); |
| 34848 | 35048 | if( !zBuf ){ |
| 34849 | 35049 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34850 | 35050 | return SQLITE_IOERR_NOMEM; |
| 34851 | 35051 | } |
| 34852 | 35052 | |
| 34853 | 35053 | /* Figure out the effective temporary directory. First, check if one |
| 34854 | 35054 | ** has been explicitly set by the application; otherwise, use the one |
| 34855 | 35055 | ** configured by the operating system. |
| 34856 | 35056 | */ |
| 34857 | | - assert( nBuf>30 ); |
| 35057 | + nDir = nMax - (nPre + 15); |
| 35058 | + assert( nDir>0 ); |
| 34858 | 35059 | if( sqlite3_temp_directory ){ |
| 34859 | | - sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory, |
| 34860 | | - winEndsInDirSep(sqlite3_temp_directory) ? "" : |
| 34861 | | - winGetDirDep()); |
| 35060 | + int nDirLen = sqlite3Strlen30(sqlite3_temp_directory); |
| 35061 | + if( nDirLen>0 ){ |
| 35062 | + if( !winIsDirSep(sqlite3_temp_directory[nDirLen-1]) ){ |
| 35063 | + nDirLen++; |
| 35064 | + } |
| 35065 | + if( nDirLen>nDir ){ |
| 35066 | + sqlite3_free(zBuf); |
| 35067 | + OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); |
| 35068 | + return winLogError(SQLITE_ERROR, 0, "winGetTempname1", 0); |
| 35069 | + } |
| 35070 | + sqlite3_snprintf(nMax, zBuf, "%s", sqlite3_temp_directory); |
| 35071 | + } |
| 34862 | 35072 | } |
| 34863 | 35073 | #if defined(__CYGWIN__) |
| 34864 | 35074 | else{ |
| 34865 | 35075 | static const char *azDirs[] = { |
| 34866 | 35076 | 0, /* getenv("SQLITE_TMPDIR") */ |
| | @@ -34885,41 +35095,41 @@ |
| 34885 | 35095 | for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){ |
| 34886 | 35096 | void *zConverted; |
| 34887 | 35097 | if( zDir==0 ) continue; |
| 34888 | 35098 | /* If the path starts with a drive letter followed by the colon |
| 34889 | 35099 | ** character, assume it is already a native Win32 path; otherwise, |
| 34890 | | - ** it must be converted to a native Win32 path prior via the Cygwin |
| 34891 | | - ** API prior to using it. |
| 35100 | + ** it must be converted to a native Win32 path via the Cygwin API |
| 35101 | + ** prior to using it. |
| 34892 | 35102 | */ |
| 34893 | 35103 | if( winIsDriveLetterAndColon(zDir) ){ |
| 34894 | 35104 | zConverted = winConvertFromUtf8Filename(zDir); |
| 34895 | 35105 | if( !zConverted ){ |
| 34896 | 35106 | sqlite3_free(zBuf); |
| 34897 | 35107 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34898 | 35108 | return SQLITE_IOERR_NOMEM; |
| 34899 | 35109 | } |
| 34900 | 35110 | if( winIsDir(zConverted) ){ |
| 34901 | | - sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir); |
| 35111 | + sqlite3_snprintf(nMax, zBuf, "%s", zDir); |
| 34902 | 35112 | sqlite3_free(zConverted); |
| 34903 | 35113 | break; |
| 34904 | 35114 | } |
| 34905 | 35115 | sqlite3_free(zConverted); |
| 34906 | 35116 | }else{ |
| 34907 | | - zConverted = sqlite3MallocZero( nBuf+1 ); |
| 35117 | + zConverted = sqlite3MallocZero( nMax+1 ); |
| 34908 | 35118 | if( !zConverted ){ |
| 34909 | 35119 | sqlite3_free(zBuf); |
| 34910 | 35120 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34911 | 35121 | return SQLITE_IOERR_NOMEM; |
| 34912 | 35122 | } |
| 34913 | 35123 | if( cygwin_conv_path( |
| 34914 | 35124 | osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir, |
| 34915 | | - zConverted, nBuf+1)<0 ){ |
| 35125 | + zConverted, nMax+1)<0 ){ |
| 34916 | 35126 | sqlite3_free(zConverted); |
| 34917 | 35127 | sqlite3_free(zBuf); |
| 34918 | 35128 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n")); |
| 34919 | 35129 | return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno, |
| 34920 | | - "winGetTempname1", zDir); |
| 35130 | + "winGetTempname2", zDir); |
| 34921 | 35131 | } |
| 34922 | 35132 | if( winIsDir(zConverted) ){ |
| 34923 | 35133 | /* At this point, we know the candidate directory exists and should |
| 34924 | 35134 | ** be used. However, we may need to convert the string containing |
| 34925 | 35135 | ** its name into UTF-8 (i.e. if it is UTF-16 right now). |
| | @@ -34930,16 +35140,16 @@ |
| 34930 | 35140 | sqlite3_free(zConverted); |
| 34931 | 35141 | sqlite3_free(zBuf); |
| 34932 | 35142 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34933 | 35143 | return SQLITE_IOERR_NOMEM; |
| 34934 | 35144 | } |
| 34935 | | - sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 35145 | + sqlite3_snprintf(nMax, zBuf, "%s", zUtf8); |
| 34936 | 35146 | sqlite3_free(zUtf8); |
| 34937 | 35147 | sqlite3_free(zConverted); |
| 34938 | 35148 | break; |
| 34939 | 35149 | }else{ |
| 34940 | | - sqlite3_snprintf(nBuf-30, zBuf, "%s", zConverted); |
| 35150 | + sqlite3_snprintf(nMax, zBuf, "%s", zConverted); |
| 34941 | 35151 | sqlite3_free(zConverted); |
| 34942 | 35152 | break; |
| 34943 | 35153 | } |
| 34944 | 35154 | } |
| 34945 | 35155 | sqlite3_free(zConverted); |
| | @@ -34947,26 +35157,26 @@ |
| 34947 | 35157 | } |
| 34948 | 35158 | } |
| 34949 | 35159 | #elif !SQLITE_OS_WINRT && !defined(__CYGWIN__) |
| 34950 | 35160 | else if( osIsNT() ){ |
| 34951 | 35161 | char *zMulti; |
| 34952 | | - LPWSTR zWidePath = sqlite3MallocZero( nBuf*sizeof(WCHAR) ); |
| 35162 | + LPWSTR zWidePath = sqlite3MallocZero( nMax*sizeof(WCHAR) ); |
| 34953 | 35163 | if( !zWidePath ){ |
| 34954 | 35164 | sqlite3_free(zBuf); |
| 34955 | 35165 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34956 | 35166 | return SQLITE_IOERR_NOMEM; |
| 34957 | 35167 | } |
| 34958 | | - if( osGetTempPathW(nBuf, zWidePath)==0 ){ |
| 35168 | + if( osGetTempPathW(nMax, zWidePath)==0 ){ |
| 34959 | 35169 | sqlite3_free(zWidePath); |
| 34960 | 35170 | sqlite3_free(zBuf); |
| 34961 | 35171 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); |
| 34962 | 35172 | return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(), |
| 34963 | | - "winGetTempname1", 0); |
| 35173 | + "winGetTempname2", 0); |
| 34964 | 35174 | } |
| 34965 | 35175 | zMulti = winUnicodeToUtf8(zWidePath); |
| 34966 | 35176 | if( zMulti ){ |
| 34967 | | - sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti); |
| 35177 | + sqlite3_snprintf(nMax, zBuf, "%s", zMulti); |
| 34968 | 35178 | sqlite3_free(zMulti); |
| 34969 | 35179 | sqlite3_free(zWidePath); |
| 34970 | 35180 | }else{ |
| 34971 | 35181 | sqlite3_free(zWidePath); |
| 34972 | 35182 | sqlite3_free(zBuf); |
| | @@ -34975,25 +35185,25 @@ |
| 34975 | 35185 | } |
| 34976 | 35186 | } |
| 34977 | 35187 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 34978 | 35188 | else{ |
| 34979 | 35189 | char *zUtf8; |
| 34980 | | - char *zMbcsPath = sqlite3MallocZero( nBuf ); |
| 35190 | + char *zMbcsPath = sqlite3MallocZero( nMax ); |
| 34981 | 35191 | if( !zMbcsPath ){ |
| 34982 | 35192 | sqlite3_free(zBuf); |
| 34983 | 35193 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34984 | 35194 | return SQLITE_IOERR_NOMEM; |
| 34985 | 35195 | } |
| 34986 | | - if( osGetTempPathA(nBuf, zMbcsPath)==0 ){ |
| 35196 | + if( osGetTempPathA(nMax, zMbcsPath)==0 ){ |
| 34987 | 35197 | sqlite3_free(zBuf); |
| 34988 | 35198 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); |
| 34989 | 35199 | return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(), |
| 34990 | | - "winGetTempname2", 0); |
| 35200 | + "winGetTempname3", 0); |
| 34991 | 35201 | } |
| 34992 | 35202 | zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); |
| 34993 | 35203 | if( zUtf8 ){ |
| 34994 | | - sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8); |
| 35204 | + sqlite3_snprintf(nMax, zBuf, "%s", zUtf8); |
| 34995 | 35205 | sqlite3_free(zUtf8); |
| 34996 | 35206 | }else{ |
| 34997 | 35207 | sqlite3_free(zBuf); |
| 34998 | 35208 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34999 | 35209 | return SQLITE_IOERR_NOMEM; |
| | @@ -35000,22 +35210,40 @@ |
| 35000 | 35210 | } |
| 35001 | 35211 | } |
| 35002 | 35212 | #endif /* SQLITE_WIN32_HAS_ANSI */ |
| 35003 | 35213 | #endif /* !SQLITE_OS_WINRT */ |
| 35004 | 35214 | |
| 35005 | | - /* Check that the output buffer is large enough for the temporary file |
| 35006 | | - ** name. If it is not, return SQLITE_ERROR. |
| 35215 | + /* |
| 35216 | + ** Check to make sure the temporary directory ends with an appropriate |
| 35217 | + ** separator. If it does not and there is not enough space left to add |
| 35218 | + ** one, fail. |
| 35219 | + */ |
| 35220 | + if( !winMakeEndInDirSep(nDir+1, zBuf) ){ |
| 35221 | + sqlite3_free(zBuf); |
| 35222 | + OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); |
| 35223 | + return winLogError(SQLITE_ERROR, 0, "winGetTempname4", 0); |
| 35224 | + } |
| 35225 | + |
| 35226 | + /* |
| 35227 | + ** Check that the output buffer is large enough for the temporary file |
| 35228 | + ** name in the following format: |
| 35229 | + ** |
| 35230 | + ** "<temporary_directory>/etilqs_XXXXXXXXXXXXXXX\0\0" |
| 35231 | + ** |
| 35232 | + ** If not, return SQLITE_ERROR. The number 17 is used here in order to |
| 35233 | + ** account for the space used by the 15 character random suffix and the |
| 35234 | + ** two trailing NUL characters. The final directory separator character |
| 35235 | + ** has already added if it was not already present. |
| 35007 | 35236 | */ |
| 35008 | 35237 | nLen = sqlite3Strlen30(zBuf); |
| 35009 | | - |
| 35010 | | - if( (nLen + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){ |
| 35238 | + if( (nLen + nPre + 17) > nBuf ){ |
| 35011 | 35239 | sqlite3_free(zBuf); |
| 35012 | 35240 | OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n")); |
| 35013 | | - return winLogError(SQLITE_ERROR, 0, "winGetTempname3", 0); |
| 35241 | + return winLogError(SQLITE_ERROR, 0, "winGetTempname5", 0); |
| 35014 | 35242 | } |
| 35015 | 35243 | |
| 35016 | | - sqlite3_snprintf(nBuf-18-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX); |
| 35244 | + sqlite3_snprintf(nBuf-16-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX); |
| 35017 | 35245 | |
| 35018 | 35246 | j = sqlite3Strlen30(zBuf); |
| 35019 | 35247 | sqlite3_randomness(15, &zBuf[j]); |
| 35020 | 35248 | for(i=0; i<15; i++, j++){ |
| 35021 | 35249 | zBuf[j] = (char)zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; |
| | @@ -35066,11 +35294,11 @@ |
| 35066 | 35294 | sqlite3_file *id, /* Write the SQLite file handle here */ |
| 35067 | 35295 | int flags, /* Open mode flags */ |
| 35068 | 35296 | int *pOutFlags /* Status return flags */ |
| 35069 | 35297 | ){ |
| 35070 | 35298 | HANDLE h; |
| 35071 | | - DWORD lastErrno; |
| 35299 | + DWORD lastErrno = 0; |
| 35072 | 35300 | DWORD dwDesiredAccess; |
| 35073 | 35301 | DWORD dwShareMode; |
| 35074 | 35302 | DWORD dwCreationDisposition; |
| 35075 | 35303 | DWORD dwFlagsAndAttributes = 0; |
| 35076 | 35304 | #if SQLITE_OS_WINCE |
| | @@ -35357,11 +35585,11 @@ |
| 35357 | 35585 | int syncDir /* Not used on win32 */ |
| 35358 | 35586 | ){ |
| 35359 | 35587 | int cnt = 0; |
| 35360 | 35588 | int rc; |
| 35361 | 35589 | DWORD attr; |
| 35362 | | - DWORD lastErrno; |
| 35590 | + DWORD lastErrno = 0; |
| 35363 | 35591 | void *zConverted; |
| 35364 | 35592 | UNUSED_PARAMETER(pVfs); |
| 35365 | 35593 | UNUSED_PARAMETER(syncDir); |
| 35366 | 35594 | |
| 35367 | 35595 | SimulateIOError(return SQLITE_IOERR_DELETE); |
| | @@ -35465,11 +35693,11 @@ |
| 35465 | 35693 | int flags, /* Type of test to make on this file */ |
| 35466 | 35694 | int *pResOut /* OUT: Result */ |
| 35467 | 35695 | ){ |
| 35468 | 35696 | DWORD attr; |
| 35469 | 35697 | int rc = 0; |
| 35470 | | - DWORD lastErrno; |
| 35698 | + DWORD lastErrno = 0; |
| 35471 | 35699 | void *zConverted; |
| 35472 | 35700 | UNUSED_PARAMETER(pVfs); |
| 35473 | 35701 | |
| 35474 | 35702 | SimulateIOError( return SQLITE_IOERR_ACCESS; ); |
| 35475 | 35703 | OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n", |
| | @@ -35611,12 +35839,12 @@ |
| 35611 | 35839 | pVfs->mxPathname+1)<0 ){ |
| 35612 | 35840 | sqlite3_free(zOut); |
| 35613 | 35841 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35614 | 35842 | "winFullPathname1", zRelative); |
| 35615 | 35843 | } |
| 35616 | | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", |
| 35617 | | - sqlite3_data_directory, winGetDirDep(), zOut); |
| 35844 | + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35845 | + sqlite3_data_directory, winGetDirSep(), zOut); |
| 35618 | 35846 | sqlite3_free(zOut); |
| 35619 | 35847 | }else{ |
| 35620 | 35848 | if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ |
| 35621 | 35849 | return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, |
| 35622 | 35850 | "winFullPathname2", zRelative); |
| | @@ -35634,12 +35862,12 @@ |
| 35634 | 35862 | ** NOTE: We are dealing with a relative path name and the data |
| 35635 | 35863 | ** directory has been set. Therefore, use it as the basis |
| 35636 | 35864 | ** for converting the relative path name to an absolute |
| 35637 | 35865 | ** one by prepending the data directory and a backslash. |
| 35638 | 35866 | */ |
| 35639 | | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", |
| 35640 | | - sqlite3_data_directory, winGetDirDep(), zRelative); |
| 35867 | + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35868 | + sqlite3_data_directory, winGetDirSep(), zRelative); |
| 35641 | 35869 | }else{ |
| 35642 | 35870 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zRelative); |
| 35643 | 35871 | } |
| 35644 | 35872 | return SQLITE_OK; |
| 35645 | 35873 | #endif |
| | @@ -35667,12 +35895,12 @@ |
| 35667 | 35895 | ** NOTE: We are dealing with a relative path name and the data |
| 35668 | 35896 | ** directory has been set. Therefore, use it as the basis |
| 35669 | 35897 | ** for converting the relative path name to an absolute |
| 35670 | 35898 | ** one by prepending the data directory and a backslash. |
| 35671 | 35899 | */ |
| 35672 | | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s", |
| 35673 | | - sqlite3_data_directory, winGetDirDep(), zRelative); |
| 35900 | + sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%c%s", |
| 35901 | + sqlite3_data_directory, winGetDirSep(), zRelative); |
| 35674 | 35902 | return SQLITE_OK; |
| 35675 | 35903 | } |
| 35676 | 35904 | zConverted = winConvertFromUtf8Filename(zRelative); |
| 35677 | 35905 | if( zConverted==0 ){ |
| 35678 | 35906 | return SQLITE_IOERR_NOMEM; |
| | @@ -36006,11 +36234,11 @@ |
| 36006 | 36234 | }; |
| 36007 | 36235 | #endif |
| 36008 | 36236 | |
| 36009 | 36237 | /* Double-check that the aSyscall[] array has been constructed |
| 36010 | 36238 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 36011 | | - assert( ArraySize(aSyscall)==75 ); |
| 36239 | + assert( ArraySize(aSyscall)==76 ); |
| 36012 | 36240 | |
| 36013 | 36241 | /* get memory map allocation granularity */ |
| 36014 | 36242 | memset(&winSysInfo, 0, sizeof(SYSTEM_INFO)); |
| 36015 | 36243 | #if SQLITE_OS_WINRT |
| 36016 | 36244 | osGetNativeSystemInfo(&winSysInfo); |
| | @@ -50676,11 +50904,11 @@ |
| 50676 | 50904 | int bias, /* Bias search to the high end */ |
| 50677 | 50905 | int *pRes /* Write search results here */ |
| 50678 | 50906 | ){ |
| 50679 | 50907 | int rc; /* Status code */ |
| 50680 | 50908 | UnpackedRecord *pIdxKey; /* Unpacked index key */ |
| 50681 | | - char aSpace[150]; /* Temp space for pIdxKey - to avoid a malloc */ |
| 50909 | + char aSpace[200]; /* Temp space for pIdxKey - to avoid a malloc */ |
| 50682 | 50910 | char *pFree = 0; |
| 50683 | 50911 | |
| 50684 | 50912 | if( pKey ){ |
| 50685 | 50913 | assert( nKey==(i64)(int)nKey ); |
| 50686 | 50914 | pIdxKey = sqlite3VdbeAllocUnpackedRecord( |
| | @@ -60294,19 +60522,19 @@ |
| 60294 | 60522 | |
| 60295 | 60523 | if( pRec==0 ){ |
| 60296 | 60524 | Index *pIdx = p->pIdx; /* Index being probed */ |
| 60297 | 60525 | int nByte; /* Bytes of space to allocate */ |
| 60298 | 60526 | int i; /* Counter variable */ |
| 60299 | | - int nCol = pIdx->nColumn+1; /* Number of index columns including rowid */ |
| 60527 | + int nCol = pIdx->nColumn; /* Number of index columns including rowid */ |
| 60300 | 60528 | |
| 60301 | 60529 | nByte = sizeof(Mem) * nCol + sizeof(UnpackedRecord); |
| 60302 | 60530 | pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte); |
| 60303 | 60531 | if( pRec ){ |
| 60304 | | - pRec->pKeyInfo = sqlite3IndexKeyinfo(p->pParse, pIdx); |
| 60532 | + pRec->pKeyInfo = sqlite3KeyInfoOfIndex(p->pParse, pIdx); |
| 60305 | 60533 | if( pRec->pKeyInfo ){ |
| 60306 | | - assert( pRec->pKeyInfo->nField+1==nCol ); |
| 60307 | | - pRec->pKeyInfo->enc = ENC(db); |
| 60534 | + assert( pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField==nCol ); |
| 60535 | + assert( pRec->pKeyInfo->enc==ENC(db) ); |
| 60308 | 60536 | pRec->flags = UNPACKED_PREFIX_MATCH; |
| 60309 | 60537 | pRec->aMem = (Mem *)&pRec[1]; |
| 60310 | 60538 | for(i=0; i<nCol; i++){ |
| 60311 | 60539 | pRec->aMem[i].flags = MEM_Null; |
| 60312 | 60540 | pRec->aMem[i].type = SQLITE_NULL; |
| | @@ -60625,17 +60853,17 @@ |
| 60625 | 60853 | ** the object. |
| 60626 | 60854 | */ |
| 60627 | 60855 | SQLITE_PRIVATE void sqlite3Stat4ProbeFree(UnpackedRecord *pRec){ |
| 60628 | 60856 | if( pRec ){ |
| 60629 | 60857 | int i; |
| 60630 | | - int nCol = pRec->pKeyInfo->nField+1; |
| 60858 | + int nCol = pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField; |
| 60631 | 60859 | Mem *aMem = pRec->aMem; |
| 60632 | 60860 | sqlite3 *db = aMem[0].db; |
| 60633 | 60861 | for(i=0; i<nCol; i++){ |
| 60634 | 60862 | sqlite3DbFree(db, aMem[i].zMalloc); |
| 60635 | 60863 | } |
| 60636 | | - sqlite3DbFree(db, pRec->pKeyInfo); |
| 60864 | + sqlite3KeyInfoUnref(pRec->pKeyInfo); |
| 60637 | 60865 | sqlite3DbFree(db, pRec); |
| 60638 | 60866 | } |
| 60639 | 60867 | } |
| 60640 | 60868 | #endif /* ifdef SQLITE_ENABLE_STAT4 */ |
| 60641 | 60869 | |
| | @@ -60784,10 +61012,21 @@ |
| 60784 | 61012 | p->aOp = pNew; |
| 60785 | 61013 | } |
| 60786 | 61014 | return (pNew ? SQLITE_OK : SQLITE_NOMEM); |
| 60787 | 61015 | } |
| 60788 | 61016 | |
| 61017 | +#ifdef SQLITE_DEBUG |
| 61018 | +/* This routine is just a convenient place to set a breakpoint that will |
| 61019 | +** fire after each opcode is inserted and displayed using |
| 61020 | +** "PRAGMA vdbe_addoptrace=on". |
| 61021 | +*/ |
| 61022 | +static void test_addop_breakpoint(void){ |
| 61023 | + static int n = 0; |
| 61024 | + n++; |
| 61025 | +} |
| 61026 | +#endif |
| 61027 | + |
| 60789 | 61028 | /* |
| 60790 | 61029 | ** Add a new instruction to the list of instructions current in the |
| 60791 | 61030 | ** VDBE. Return the address of the new instruction. |
| 60792 | 61031 | ** |
| 60793 | 61032 | ** Parameters: |
| | @@ -60821,14 +61060,17 @@ |
| 60821 | 61060 | pOp->p1 = p1; |
| 60822 | 61061 | pOp->p2 = p2; |
| 60823 | 61062 | pOp->p3 = p3; |
| 60824 | 61063 | pOp->p4.p = 0; |
| 60825 | 61064 | pOp->p4type = P4_NOTUSED; |
| 60826 | | -#ifdef SQLITE_DEBUG |
| 61065 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 60827 | 61066 | pOp->zComment = 0; |
| 61067 | +#endif |
| 61068 | +#ifdef SQLITE_DEBUG |
| 60828 | 61069 | if( p->db->flags & SQLITE_VdbeAddopTrace ){ |
| 60829 | 61070 | sqlite3VdbePrintOp(0, i, &p->aOp[i]); |
| 61071 | + test_addop_breakpoint(); |
| 60830 | 61072 | } |
| 60831 | 61073 | #endif |
| 60832 | 61074 | #ifdef VDBE_PROFILE |
| 60833 | 61075 | pOp->cycles = 0; |
| 60834 | 61076 | pOp->cnt = 0; |
| | @@ -61200,21 +61442,24 @@ |
| 61200 | 61442 | for(i=0; i<nOp; i++, pIn++){ |
| 61201 | 61443 | int p2 = pIn->p2; |
| 61202 | 61444 | VdbeOp *pOut = &p->aOp[i+addr]; |
| 61203 | 61445 | pOut->opcode = pIn->opcode; |
| 61204 | 61446 | pOut->p1 = pIn->p1; |
| 61205 | | - if( p2<0 && (sqlite3OpcodeProperty[pOut->opcode] & OPFLG_JUMP)!=0 ){ |
| 61447 | + if( p2<0 ){ |
| 61448 | + assert( sqlite3OpcodeProperty[pOut->opcode] & OPFLG_JUMP ); |
| 61206 | 61449 | pOut->p2 = addr + ADDR(p2); |
| 61207 | 61450 | }else{ |
| 61208 | 61451 | pOut->p2 = p2; |
| 61209 | 61452 | } |
| 61210 | 61453 | pOut->p3 = pIn->p3; |
| 61211 | 61454 | pOut->p4type = P4_NOTUSED; |
| 61212 | 61455 | pOut->p4.p = 0; |
| 61213 | 61456 | pOut->p5 = 0; |
| 61214 | | -#ifdef SQLITE_DEBUG |
| 61457 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 61215 | 61458 | pOut->zComment = 0; |
| 61459 | +#endif |
| 61460 | +#ifdef SQLITE_DEBUG |
| 61216 | 61461 | if( p->db->flags & SQLITE_VdbeAddopTrace ){ |
| 61217 | 61462 | sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]); |
| 61218 | 61463 | } |
| 61219 | 61464 | #endif |
| 61220 | 61465 | } |
| | @@ -61298,15 +61543,17 @@ |
| 61298 | 61543 | assert( db ); |
| 61299 | 61544 | switch( p4type ){ |
| 61300 | 61545 | case P4_REAL: |
| 61301 | 61546 | case P4_INT64: |
| 61302 | 61547 | case P4_DYNAMIC: |
| 61303 | | - case P4_KEYINFO: |
| 61304 | | - case P4_INTARRAY: |
| 61305 | | - case P4_KEYINFO_HANDOFF: { |
| 61548 | + case P4_INTARRAY: { |
| 61306 | 61549 | sqlite3DbFree(db, p4); |
| 61307 | 61550 | break; |
| 61551 | + } |
| 61552 | + case P4_KEYINFO: { |
| 61553 | + if( db->pnBytesFreed==0 ) sqlite3KeyInfoUnref((KeyInfo*)p4); |
| 61554 | + break; |
| 61308 | 61555 | } |
| 61309 | 61556 | case P4_MPRINTF: { |
| 61310 | 61557 | if( db->pnBytesFreed==0 ) sqlite3_free(p4); |
| 61311 | 61558 | break; |
| 61312 | 61559 | } |
| | @@ -61340,11 +61587,11 @@ |
| 61340 | 61587 | static void vdbeFreeOpArray(sqlite3 *db, Op *aOp, int nOp){ |
| 61341 | 61588 | if( aOp ){ |
| 61342 | 61589 | Op *pOp; |
| 61343 | 61590 | for(pOp=aOp; pOp<&aOp[nOp]; pOp++){ |
| 61344 | 61591 | freeP4(db, pOp->p4type, pOp->p4.p); |
| 61345 | | -#ifdef SQLITE_DEBUG |
| 61592 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 61346 | 61593 | sqlite3DbFree(db, pOp->zComment); |
| 61347 | 61594 | #endif |
| 61348 | 61595 | } |
| 61349 | 61596 | } |
| 61350 | 61597 | sqlite3DbFree(db, aOp); |
| | @@ -61368,10 +61615,11 @@ |
| 61368 | 61615 | VdbeOp *pOp = &p->aOp[addr]; |
| 61369 | 61616 | sqlite3 *db = p->db; |
| 61370 | 61617 | freeP4(db, pOp->p4type, pOp->p4.p); |
| 61371 | 61618 | memset(pOp, 0, sizeof(pOp[0])); |
| 61372 | 61619 | pOp->opcode = OP_Noop; |
| 61620 | + if( addr==p->nOp-1 ) p->nOp--; |
| 61373 | 61621 | } |
| 61374 | 61622 | } |
| 61375 | 61623 | |
| 61376 | 61624 | /* |
| 61377 | 61625 | ** Change the value of the P4 operand for a specific instruction. |
| | @@ -61381,18 +61629,10 @@ |
| 61381 | 61629 | ** |
| 61382 | 61630 | ** If n>=0 then the P4 operand is dynamic, meaning that a copy of |
| 61383 | 61631 | ** the string is made into memory obtained from sqlite3_malloc(). |
| 61384 | 61632 | ** A value of n==0 means copy bytes of zP4 up to and including the |
| 61385 | 61633 | ** first null byte. If n>0 then copy n+1 bytes of zP4. |
| 61386 | | -** |
| 61387 | | -** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure. |
| 61388 | | -** A copy is made of the KeyInfo structure into memory obtained from |
| 61389 | | -** sqlite3_malloc, to be freed when the Vdbe is finalized. |
| 61390 | | -** n==P4_KEYINFO_HANDOFF indicates that zP4 points to a KeyInfo structure |
| 61391 | | -** stored in memory that the caller has obtained from sqlite3_malloc. The |
| 61392 | | -** caller should not free the allocation, it will be freed when the Vdbe is |
| 61393 | | -** finalized. |
| 61394 | 61634 | ** |
| 61395 | 61635 | ** Other values of n (P4_STATIC, P4_COLLSEQ etc.) indicate that zP4 points |
| 61396 | 61636 | ** to a string or structure that is guaranteed to exist for the lifetime of |
| 61397 | 61637 | ** the Vdbe. In these cases we can just copy the pointer. |
| 61398 | 61638 | ** |
| | @@ -61403,11 +61643,11 @@ |
| 61403 | 61643 | sqlite3 *db; |
| 61404 | 61644 | assert( p!=0 ); |
| 61405 | 61645 | db = p->db; |
| 61406 | 61646 | assert( p->magic==VDBE_MAGIC_INIT ); |
| 61407 | 61647 | if( p->aOp==0 || db->mallocFailed ){ |
| 61408 | | - if ( n!=P4_KEYINFO && n!=P4_VTAB ) { |
| 61648 | + if( n!=P4_VTAB ){ |
| 61409 | 61649 | freeP4(db, n, (void*)*(char**)&zP4); |
| 61410 | 61650 | } |
| 61411 | 61651 | return; |
| 61412 | 61652 | } |
| 61413 | 61653 | assert( p->nOp>0 ); |
| | @@ -61426,23 +61666,10 @@ |
| 61426 | 61666 | pOp->p4type = P4_INT32; |
| 61427 | 61667 | }else if( zP4==0 ){ |
| 61428 | 61668 | pOp->p4.p = 0; |
| 61429 | 61669 | pOp->p4type = P4_NOTUSED; |
| 61430 | 61670 | }else if( n==P4_KEYINFO ){ |
| 61431 | | - KeyInfo *pOrig, *pNew; |
| 61432 | | - |
| 61433 | | - pOrig = (KeyInfo*)zP4; |
| 61434 | | - pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField); |
| 61435 | | - if( pNew ){ |
| 61436 | | - memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0])); |
| 61437 | | - memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField); |
| 61438 | | - pOp->p4type = P4_KEYINFO; |
| 61439 | | - }else{ |
| 61440 | | - p->db->mallocFailed = 1; |
| 61441 | | - pOp->p4type = P4_NOTUSED; |
| 61442 | | - } |
| 61443 | | - }else if( n==P4_KEYINFO_HANDOFF ){ |
| 61444 | 61671 | pOp->p4.p = (void*)zP4; |
| 61445 | 61672 | pOp->p4type = P4_KEYINFO; |
| 61446 | 61673 | }else if( n==P4_VTAB ){ |
| 61447 | 61674 | pOp->p4.p = (void*)zP4; |
| 61448 | 61675 | pOp->p4type = P4_VTAB; |
| | @@ -61456,11 +61683,23 @@ |
| 61456 | 61683 | pOp->p4.z = sqlite3DbStrNDup(p->db, zP4, n); |
| 61457 | 61684 | pOp->p4type = P4_DYNAMIC; |
| 61458 | 61685 | } |
| 61459 | 61686 | } |
| 61460 | 61687 | |
| 61461 | | -#ifndef NDEBUG |
| 61688 | +/* |
| 61689 | +** Set the P4 on the most recently added opcode to the KeyInfo for the |
| 61690 | +** index given. |
| 61691 | +*/ |
| 61692 | +SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){ |
| 61693 | + Vdbe *v = pParse->pVdbe; |
| 61694 | + assert( v!=0 ); |
| 61695 | + assert( pIdx!=0 ); |
| 61696 | + sqlite3VdbeChangeP4(v, -1, (char*)sqlite3KeyInfoOfIndex(pParse, pIdx), |
| 61697 | + P4_KEYINFO); |
| 61698 | +} |
| 61699 | + |
| 61700 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 61462 | 61701 | /* |
| 61463 | 61702 | ** Change the comment on the most recently coded instruction. Or |
| 61464 | 61703 | ** insert a No-op and add the comment to that new instruction. This |
| 61465 | 61704 | ** makes the code easier to read during debugging. None of this happens |
| 61466 | 61705 | ** in a production build. |
| | @@ -61530,10 +61769,85 @@ |
| 61530 | 61769 | return (VdbeOp*)&dummy; |
| 61531 | 61770 | }else{ |
| 61532 | 61771 | return &p->aOp[addr]; |
| 61533 | 61772 | } |
| 61534 | 61773 | } |
| 61774 | + |
| 61775 | +#if defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) |
| 61776 | +/* |
| 61777 | +** Return an integer value for one of the parameters to the opcode pOp |
| 61778 | +** determined by character c. |
| 61779 | +*/ |
| 61780 | +static int translateP(char c, const Op *pOp){ |
| 61781 | + if( c=='1' ) return pOp->p1; |
| 61782 | + if( c=='2' ) return pOp->p2; |
| 61783 | + if( c=='3' ) return pOp->p3; |
| 61784 | + if( c=='4' ) return pOp->p4.i; |
| 61785 | + return pOp->p5; |
| 61786 | +} |
| 61787 | + |
| 61788 | +/* |
| 61789 | +** Compute a string for the "comment" field of a VDBE opcode listing |
| 61790 | +*/ |
| 61791 | +static int displayComment( |
| 61792 | + const Op *pOp, /* The opcode to be commented */ |
| 61793 | + const char *zP4, /* Previously obtained value for P4 */ |
| 61794 | + char *zTemp, /* Write result here */ |
| 61795 | + int nTemp /* Space available in zTemp[] */ |
| 61796 | +){ |
| 61797 | + const char *zOpName; |
| 61798 | + const char *zSynopsis; |
| 61799 | + int nOpName; |
| 61800 | + int ii, jj; |
| 61801 | + zOpName = sqlite3OpcodeName(pOp->opcode); |
| 61802 | + nOpName = sqlite3Strlen30(zOpName); |
| 61803 | + if( zOpName[nOpName+1] ){ |
| 61804 | + int seenCom = 0; |
| 61805 | + char c; |
| 61806 | + zSynopsis = zOpName += nOpName + 1; |
| 61807 | + for(ii=jj=0; jj<nTemp-1 && (c = zSynopsis[ii])!=0; ii++){ |
| 61808 | + if( c=='P' ){ |
| 61809 | + c = zSynopsis[++ii]; |
| 61810 | + if( c=='4' ){ |
| 61811 | + sqlite3_snprintf(nTemp-jj, zTemp+jj, "%s", zP4); |
| 61812 | + }else if( c=='X' ){ |
| 61813 | + sqlite3_snprintf(nTemp-jj, zTemp+jj, "%s", pOp->zComment); |
| 61814 | + seenCom = 1; |
| 61815 | + }else{ |
| 61816 | + int v1 = translateP(c, pOp); |
| 61817 | + int v2; |
| 61818 | + sqlite3_snprintf(nTemp-jj, zTemp+jj, "%d", v1); |
| 61819 | + if( strncmp(zSynopsis+ii+1, "@P", 2)==0 ){ |
| 61820 | + ii += 3; |
| 61821 | + jj += sqlite3Strlen30(zTemp+jj); |
| 61822 | + v2 = translateP(zSynopsis[ii], pOp); |
| 61823 | + if( v2>1 ) sqlite3_snprintf(nTemp-jj, zTemp+jj, "..%d", v1+v2-1); |
| 61824 | + }else if( strncmp(zSynopsis+ii+1, "..P3", 4)==0 && pOp->p3==0 ){ |
| 61825 | + ii += 4; |
| 61826 | + } |
| 61827 | + } |
| 61828 | + jj += sqlite3Strlen30(zTemp+jj); |
| 61829 | + }else{ |
| 61830 | + zTemp[jj++] = c; |
| 61831 | + } |
| 61832 | + } |
| 61833 | + if( !seenCom && jj<nTemp-5 && pOp->zComment ){ |
| 61834 | + sqlite3_snprintf(nTemp-jj, zTemp+jj, "; %s", pOp->zComment); |
| 61835 | + jj += sqlite3Strlen30(zTemp+jj); |
| 61836 | + } |
| 61837 | + if( jj<nTemp ) zTemp[jj] = 0; |
| 61838 | + }else if( pOp->zComment ){ |
| 61839 | + sqlite3_snprintf(nTemp, zTemp, "%s", pOp->zComment); |
| 61840 | + jj = sqlite3Strlen30(zTemp); |
| 61841 | + }else{ |
| 61842 | + zTemp[0] = 0; |
| 61843 | + jj = 0; |
| 61844 | + } |
| 61845 | + return jj; |
| 61846 | +} |
| 61847 | +#endif /* SQLITE_DEBUG */ |
| 61848 | + |
| 61535 | 61849 | |
| 61536 | 61850 | #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) \ |
| 61537 | 61851 | || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) |
| 61538 | 61852 | /* |
| 61539 | 61853 | ** Compute a string that describes the P4 parameter for an opcode. |
| | @@ -61541,21 +61855,24 @@ |
| 61541 | 61855 | */ |
| 61542 | 61856 | static char *displayP4(Op *pOp, char *zTemp, int nTemp){ |
| 61543 | 61857 | char *zP4 = zTemp; |
| 61544 | 61858 | assert( nTemp>=20 ); |
| 61545 | 61859 | switch( pOp->p4type ){ |
| 61546 | | - case P4_KEYINFO_STATIC: |
| 61547 | 61860 | case P4_KEYINFO: { |
| 61548 | 61861 | int i, j; |
| 61549 | 61862 | KeyInfo *pKeyInfo = pOp->p4.pKeyInfo; |
| 61550 | 61863 | assert( pKeyInfo->aSortOrder!=0 ); |
| 61551 | | - sqlite3_snprintf(nTemp, zTemp, "keyinfo(%d", pKeyInfo->nField); |
| 61864 | + sqlite3_snprintf(nTemp, zTemp, "k(%d", pKeyInfo->nField); |
| 61552 | 61865 | i = sqlite3Strlen30(zTemp); |
| 61553 | 61866 | for(j=0; j<pKeyInfo->nField; j++){ |
| 61554 | 61867 | CollSeq *pColl = pKeyInfo->aColl[j]; |
| 61555 | 61868 | const char *zColl = pColl ? pColl->zName : "nil"; |
| 61556 | 61869 | int n = sqlite3Strlen30(zColl); |
| 61870 | + if( n==6 && memcmp(zColl,"BINARY",6)==0 ){ |
| 61871 | + zColl = "B"; |
| 61872 | + n = 1; |
| 61873 | + } |
| 61557 | 61874 | if( i+n>nTemp-6 ){ |
| 61558 | 61875 | memcpy(&zTemp[i],",...",4); |
| 61559 | 61876 | break; |
| 61560 | 61877 | } |
| 61561 | 61878 | zTemp[i++] = ','; |
| | @@ -61724,20 +62041,22 @@ |
| 61724 | 62041 | ** Print a single opcode. This routine is used for debugging only. |
| 61725 | 62042 | */ |
| 61726 | 62043 | SQLITE_PRIVATE void sqlite3VdbePrintOp(FILE *pOut, int pc, Op *pOp){ |
| 61727 | 62044 | char *zP4; |
| 61728 | 62045 | char zPtr[50]; |
| 61729 | | - static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-4s %.2X %s\n"; |
| 62046 | + char zCom[100]; |
| 62047 | + static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n"; |
| 61730 | 62048 | if( pOut==0 ) pOut = stdout; |
| 61731 | 62049 | zP4 = displayP4(pOp, zPtr, sizeof(zPtr)); |
| 62050 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 62051 | + displayComment(pOp, zP4, zCom, sizeof(zCom)); |
| 62052 | +#else |
| 62053 | + zCom[0] = 0 |
| 62054 | +#endif |
| 61732 | 62055 | fprintf(pOut, zFormat1, pc, |
| 61733 | 62056 | sqlite3OpcodeName(pOp->opcode), pOp->p1, pOp->p2, pOp->p3, zP4, pOp->p5, |
| 61734 | | -#ifdef SQLITE_DEBUG |
| 61735 | | - pOp->zComment ? pOp->zComment : "" |
| 61736 | | -#else |
| 61737 | | - "" |
| 61738 | | -#endif |
| 62057 | + zCom |
| 61739 | 62058 | ); |
| 61740 | 62059 | fflush(pOut); |
| 61741 | 62060 | } |
| 61742 | 62061 | #endif |
| 61743 | 62062 | |
| | @@ -61879,11 +62198,11 @@ |
| 61879 | 62198 | }else if( db->u1.isInterrupted ){ |
| 61880 | 62199 | p->rc = SQLITE_INTERRUPT; |
| 61881 | 62200 | rc = SQLITE_ERROR; |
| 61882 | 62201 | sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc)); |
| 61883 | 62202 | }else{ |
| 61884 | | - char *z; |
| 62203 | + char *zP4; |
| 61885 | 62204 | Op *pOp; |
| 61886 | 62205 | if( i<p->nOp ){ |
| 61887 | 62206 | /* The output line number is small enough that we are still in the |
| 61888 | 62207 | ** main program. */ |
| 61889 | 62208 | pOp = &p->aOp[i]; |
| | @@ -61902,11 +62221,11 @@ |
| 61902 | 62221 | pMem->type = SQLITE_INTEGER; |
| 61903 | 62222 | pMem->u.i = i; /* Program counter */ |
| 61904 | 62223 | pMem++; |
| 61905 | 62224 | |
| 61906 | 62225 | pMem->flags = MEM_Static|MEM_Str|MEM_Term; |
| 61907 | | - pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */ |
| 62226 | + pMem->z = (char*)sqlite3OpcodeName(pOp->opcode); /* Opcode */ |
| 61908 | 62227 | assert( pMem->z!=0 ); |
| 61909 | 62228 | pMem->n = sqlite3Strlen30(pMem->z); |
| 61910 | 62229 | pMem->type = SQLITE_TEXT; |
| 61911 | 62230 | pMem->enc = SQLITE_UTF8; |
| 61912 | 62231 | pMem++; |
| | @@ -61949,13 +62268,13 @@ |
| 61949 | 62268 | if( sqlite3VdbeMemGrow(pMem, 32, 0) ){ /* P4 */ |
| 61950 | 62269 | assert( p->db->mallocFailed ); |
| 61951 | 62270 | return SQLITE_ERROR; |
| 61952 | 62271 | } |
| 61953 | 62272 | pMem->flags = MEM_Dyn|MEM_Str|MEM_Term; |
| 61954 | | - z = displayP4(pOp, pMem->z, 32); |
| 61955 | | - if( z!=pMem->z ){ |
| 61956 | | - sqlite3VdbeMemSetStr(pMem, z, -1, SQLITE_UTF8, 0); |
| 62273 | + zP4 = displayP4(pOp, pMem->z, 32); |
| 62274 | + if( zP4!=pMem->z ){ |
| 62275 | + sqlite3VdbeMemSetStr(pMem, zP4, -1, SQLITE_UTF8, 0); |
| 61957 | 62276 | }else{ |
| 61958 | 62277 | assert( pMem->z!=0 ); |
| 61959 | 62278 | pMem->n = sqlite3Strlen30(pMem->z); |
| 61960 | 62279 | pMem->enc = SQLITE_UTF8; |
| 61961 | 62280 | } |
| | @@ -61972,23 +62291,23 @@ |
| 61972 | 62291 | sqlite3_snprintf(3, pMem->z, "%.2x", pOp->p5); /* P5 */ |
| 61973 | 62292 | pMem->type = SQLITE_TEXT; |
| 61974 | 62293 | pMem->enc = SQLITE_UTF8; |
| 61975 | 62294 | pMem++; |
| 61976 | 62295 | |
| 61977 | | -#ifdef SQLITE_DEBUG |
| 61978 | | - if( pOp->zComment ){ |
| 61979 | | - pMem->flags = MEM_Str|MEM_Term; |
| 61980 | | - pMem->z = pOp->zComment; |
| 61981 | | - pMem->n = sqlite3Strlen30(pMem->z); |
| 61982 | | - pMem->enc = SQLITE_UTF8; |
| 61983 | | - pMem->type = SQLITE_TEXT; |
| 61984 | | - }else |
| 62296 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 62297 | + if( sqlite3VdbeMemGrow(pMem, 500, 0) ){ |
| 62298 | + assert( p->db->mallocFailed ); |
| 62299 | + return SQLITE_ERROR; |
| 62300 | + } |
| 62301 | + pMem->flags = MEM_Dyn|MEM_Str|MEM_Term; |
| 62302 | + pMem->n = displayComment(pOp, zP4, pMem->z, 500); |
| 62303 | + pMem->type = SQLITE_TEXT; |
| 62304 | + pMem->enc = SQLITE_UTF8; |
| 62305 | +#else |
| 62306 | + pMem->flags = MEM_Null; /* Comment */ |
| 62307 | + pMem->type = SQLITE_NULL; |
| 61985 | 62308 | #endif |
| 61986 | | - { |
| 61987 | | - pMem->flags = MEM_Null; /* Comment */ |
| 61988 | | - pMem->type = SQLITE_NULL; |
| 61989 | | - } |
| 61990 | 62309 | } |
| 61991 | 62310 | |
| 61992 | 62311 | p->nResColumn = 8 - 4*(p->explain-1); |
| 61993 | 62312 | p->pResultSet = &p->aMem[1]; |
| 61994 | 62313 | p->rc = SQLITE_OK; |
| | @@ -62775,11 +63094,11 @@ |
| 62775 | 63094 | if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0) |
| 62776 | 63095 | || (!deferred && p->nFkConstraint>0) |
| 62777 | 63096 | ){ |
| 62778 | 63097 | p->rc = SQLITE_CONSTRAINT_FOREIGNKEY; |
| 62779 | 63098 | p->errorAction = OE_Abort; |
| 62780 | | - sqlite3SetString(&p->zErrMsg, db, "foreign key constraint failed"); |
| 63099 | + sqlite3SetString(&p->zErrMsg, db, "FOREIGN KEY constraint failed"); |
| 62781 | 63100 | return SQLITE_ERROR; |
| 62782 | 63101 | } |
| 62783 | 63102 | return SQLITE_OK; |
| 62784 | 63103 | } |
| 62785 | 63104 | #endif |
| | @@ -63706,11 +64025,11 @@ |
| 63706 | 64025 | */ |
| 63707 | 64026 | /* mem1.u.i = 0; // not needed, here to silence compiler warning */ |
| 63708 | 64027 | |
| 63709 | 64028 | idx1 = getVarint32(aKey1, szHdr1); |
| 63710 | 64029 | d1 = szHdr1; |
| 63711 | | - assert( pKeyInfo->nField+1>=pPKey2->nField ); |
| 64030 | + assert( pKeyInfo->nField+pKeyInfo->nXField>=pPKey2->nField ); |
| 63712 | 64031 | assert( pKeyInfo->aSortOrder!=0 ); |
| 63713 | 64032 | while( idx1<szHdr1 && i<pPKey2->nField ){ |
| 63714 | 64033 | u32 serial_type1; |
| 63715 | 64034 | |
| 63716 | 64035 | /* Read the serial types for the next element in each key. */ |
| | @@ -63735,28 +64054,13 @@ |
| 63735 | 64054 | /* Do the comparison |
| 63736 | 64055 | */ |
| 63737 | 64056 | rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]); |
| 63738 | 64057 | if( rc!=0 ){ |
| 63739 | 64058 | assert( mem1.zMalloc==0 ); /* See comment below */ |
| 63740 | | - |
| 63741 | | - /* Invert the result if we are using DESC sort order. */ |
| 63742 | 64059 | if( pKeyInfo->aSortOrder[i] ){ |
| 63743 | | - rc = -rc; |
| 63744 | | - } |
| 63745 | | - |
| 63746 | | - /* If the PREFIX_SEARCH flag is set and all fields except the final |
| 63747 | | - ** rowid field were equal, then clear the PREFIX_SEARCH flag and set |
| 63748 | | - ** pPKey2->rowid to the value of the rowid field in (pKey1, nKey1). |
| 63749 | | - ** This is used by the OP_IsUnique opcode. |
| 63750 | | - */ |
| 63751 | | - if( (pPKey2->flags & UNPACKED_PREFIX_SEARCH) && i==(pPKey2->nField-1) ){ |
| 63752 | | - assert( idx1==szHdr1 && rc ); |
| 63753 | | - assert( mem1.flags & MEM_Int ); |
| 63754 | | - pPKey2->flags &= ~UNPACKED_PREFIX_SEARCH; |
| 63755 | | - pPKey2->rowid = mem1.u.i; |
| 63756 | | - } |
| 63757 | | - |
| 64060 | + rc = -rc; /* Invert the result for DESC sort order. */ |
| 64061 | + } |
| 63758 | 64062 | return rc; |
| 63759 | 64063 | } |
| 63760 | 64064 | i++; |
| 63761 | 64065 | } |
| 63762 | 64066 | |
| | @@ -66271,77 +66575,81 @@ |
| 66271 | 66575 | */ |
| 66272 | 66576 | union vdbeExecUnion { |
| 66273 | 66577 | struct OP_Yield_stack_vars { |
| 66274 | 66578 | int pcDest; |
| 66275 | 66579 | } aa; |
| 66580 | + struct OP_Halt_stack_vars { |
| 66581 | + const char *zType; |
| 66582 | + const char *zLogFmt; |
| 66583 | + } ab; |
| 66276 | 66584 | struct OP_Null_stack_vars { |
| 66277 | 66585 | int cnt; |
| 66278 | 66586 | u16 nullFlag; |
| 66279 | | - } ab; |
| 66587 | + } ac; |
| 66280 | 66588 | struct OP_Variable_stack_vars { |
| 66281 | 66589 | Mem *pVar; /* Value being transferred */ |
| 66282 | | - } ac; |
| 66590 | + } ad; |
| 66283 | 66591 | struct OP_Move_stack_vars { |
| 66284 | 66592 | char *zMalloc; /* Holding variable for allocated memory */ |
| 66285 | 66593 | int n; /* Number of registers left to copy */ |
| 66286 | 66594 | int p1; /* Register to copy from */ |
| 66287 | 66595 | int p2; /* Register to copy to */ |
| 66288 | | - } ad; |
| 66596 | + } ae; |
| 66289 | 66597 | struct OP_Copy_stack_vars { |
| 66290 | 66598 | int n; |
| 66291 | | - } ae; |
| 66599 | + } af; |
| 66292 | 66600 | struct OP_ResultRow_stack_vars { |
| 66293 | 66601 | Mem *pMem; |
| 66294 | 66602 | int i; |
| 66295 | | - } af; |
| 66603 | + } ag; |
| 66296 | 66604 | struct OP_Concat_stack_vars { |
| 66297 | 66605 | i64 nByte; |
| 66298 | | - } ag; |
| 66606 | + } ah; |
| 66299 | 66607 | struct OP_Remainder_stack_vars { |
| 66300 | 66608 | char bIntint; /* Started out as two integer operands */ |
| 66301 | 66609 | int flags; /* Combined MEM_* flags from both inputs */ |
| 66302 | 66610 | i64 iA; /* Integer value of left operand */ |
| 66303 | 66611 | i64 iB; /* Integer value of right operand */ |
| 66304 | 66612 | double rA; /* Real value of left operand */ |
| 66305 | 66613 | double rB; /* Real value of right operand */ |
| 66306 | | - } ah; |
| 66614 | + } ai; |
| 66307 | 66615 | struct OP_Function_stack_vars { |
| 66308 | 66616 | int i; |
| 66309 | 66617 | Mem *pArg; |
| 66310 | 66618 | sqlite3_context ctx; |
| 66311 | 66619 | sqlite3_value **apVal; |
| 66312 | 66620 | int n; |
| 66313 | | - } ai; |
| 66621 | + } aj; |
| 66314 | 66622 | struct OP_ShiftRight_stack_vars { |
| 66315 | 66623 | i64 iA; |
| 66316 | 66624 | u64 uA; |
| 66317 | 66625 | i64 iB; |
| 66318 | 66626 | u8 op; |
| 66319 | | - } aj; |
| 66627 | + } ak; |
| 66320 | 66628 | struct OP_Ge_stack_vars { |
| 66321 | 66629 | int res; /* Result of the comparison of pIn1 against pIn3 */ |
| 66322 | 66630 | char affinity; /* Affinity to use for comparison */ |
| 66323 | 66631 | u16 flags1; /* Copy of initial value of pIn1->flags */ |
| 66324 | 66632 | u16 flags3; /* Copy of initial value of pIn3->flags */ |
| 66325 | | - } ak; |
| 66633 | + } al; |
| 66326 | 66634 | struct OP_Compare_stack_vars { |
| 66327 | 66635 | int n; |
| 66328 | 66636 | int i; |
| 66329 | 66637 | int p1; |
| 66330 | 66638 | int p2; |
| 66331 | 66639 | const KeyInfo *pKeyInfo; |
| 66332 | 66640 | int idx; |
| 66333 | 66641 | CollSeq *pColl; /* Collating sequence to use on this term */ |
| 66334 | 66642 | int bRev; /* True for DESCENDING sort order */ |
| 66335 | | - } al; |
| 66643 | + } am; |
| 66336 | 66644 | struct OP_Or_stack_vars { |
| 66337 | 66645 | int v1; /* Left operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ |
| 66338 | 66646 | int v2; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ |
| 66339 | | - } am; |
| 66647 | + } an; |
| 66340 | 66648 | struct OP_IfNot_stack_vars { |
| 66341 | 66649 | int c; |
| 66342 | | - } an; |
| 66650 | + } ao; |
| 66343 | 66651 | struct OP_Column_stack_vars { |
| 66344 | 66652 | u32 payloadSize; /* Number of bytes in the record */ |
| 66345 | 66653 | i64 payloadSize64; /* Number of bytes in the record */ |
| 66346 | 66654 | int p1; /* P1 value of the opcode */ |
| 66347 | 66655 | int p2; /* column number to retrieve */ |
| | @@ -66362,15 +66670,15 @@ |
| 66362 | 66670 | u32 szField; /* Number of bytes in the content of a field */ |
| 66363 | 66671 | int szHdr; /* Size of the header size field at start of record */ |
| 66364 | 66672 | int avail; /* Number of bytes of available data */ |
| 66365 | 66673 | u32 t; /* A type code from the record header */ |
| 66366 | 66674 | Mem *pReg; /* PseudoTable input register */ |
| 66367 | | - } ao; |
| 66675 | + } ap; |
| 66368 | 66676 | struct OP_Affinity_stack_vars { |
| 66369 | 66677 | const char *zAffinity; /* The affinity to be applied */ |
| 66370 | 66678 | char cAff; /* A single character of affinity */ |
| 66371 | | - } ap; |
| 66679 | + } aq; |
| 66372 | 66680 | struct OP_MakeRecord_stack_vars { |
| 66373 | 66681 | u8 *zNewRecord; /* A buffer to hold the data for the new record */ |
| 66374 | 66682 | Mem *pRec; /* The new record */ |
| 66375 | 66683 | u64 nData; /* Number of bytes of data space */ |
| 66376 | 66684 | int nHdr; /* Number of bytes of header space */ |
| | @@ -66383,93 +66691,86 @@ |
| 66383 | 66691 | int nField; /* Number of fields in the record */ |
| 66384 | 66692 | char *zAffinity; /* The affinity string for the record */ |
| 66385 | 66693 | int file_format; /* File format to use for encoding */ |
| 66386 | 66694 | int i; /* Space used in zNewRecord[] */ |
| 66387 | 66695 | int len; /* Length of a field */ |
| 66388 | | - } aq; |
| 66696 | + } ar; |
| 66389 | 66697 | struct OP_Count_stack_vars { |
| 66390 | 66698 | i64 nEntry; |
| 66391 | 66699 | BtCursor *pCrsr; |
| 66392 | | - } ar; |
| 66700 | + } as; |
| 66393 | 66701 | struct OP_Savepoint_stack_vars { |
| 66394 | 66702 | int p1; /* Value of P1 operand */ |
| 66395 | 66703 | char *zName; /* Name of savepoint */ |
| 66396 | 66704 | int nName; |
| 66397 | 66705 | Savepoint *pNew; |
| 66398 | 66706 | Savepoint *pSavepoint; |
| 66399 | 66707 | Savepoint *pTmp; |
| 66400 | 66708 | int iSavepoint; |
| 66401 | 66709 | int ii; |
| 66402 | | - } as; |
| 66710 | + } at; |
| 66403 | 66711 | struct OP_AutoCommit_stack_vars { |
| 66404 | 66712 | int desiredAutoCommit; |
| 66405 | 66713 | int iRollback; |
| 66406 | 66714 | int turnOnAC; |
| 66407 | | - } at; |
| 66715 | + } au; |
| 66408 | 66716 | struct OP_Transaction_stack_vars { |
| 66409 | 66717 | Btree *pBt; |
| 66410 | | - } au; |
| 66718 | + } av; |
| 66411 | 66719 | struct OP_ReadCookie_stack_vars { |
| 66412 | 66720 | int iMeta; |
| 66413 | 66721 | int iDb; |
| 66414 | 66722 | int iCookie; |
| 66415 | | - } av; |
| 66723 | + } aw; |
| 66416 | 66724 | struct OP_SetCookie_stack_vars { |
| 66417 | 66725 | Db *pDb; |
| 66418 | | - } aw; |
| 66726 | + } ax; |
| 66419 | 66727 | struct OP_VerifyCookie_stack_vars { |
| 66420 | 66728 | int iMeta; |
| 66421 | 66729 | int iGen; |
| 66422 | 66730 | Btree *pBt; |
| 66423 | | - } ax; |
| 66731 | + } ay; |
| 66424 | 66732 | struct OP_OpenWrite_stack_vars { |
| 66425 | 66733 | int nField; |
| 66426 | 66734 | KeyInfo *pKeyInfo; |
| 66427 | 66735 | int p2; |
| 66428 | 66736 | int iDb; |
| 66429 | 66737 | int wrFlag; |
| 66430 | 66738 | Btree *pX; |
| 66431 | 66739 | VdbeCursor *pCur; |
| 66432 | 66740 | Db *pDb; |
| 66433 | | - } ay; |
| 66741 | + } az; |
| 66434 | 66742 | struct OP_OpenEphemeral_stack_vars { |
| 66435 | 66743 | VdbeCursor *pCx; |
| 66436 | | - } az; |
| 66744 | + KeyInfo *pKeyInfo; |
| 66745 | + } ba; |
| 66437 | 66746 | struct OP_SorterOpen_stack_vars { |
| 66438 | 66747 | VdbeCursor *pCx; |
| 66439 | | - } ba; |
| 66748 | + } bb; |
| 66440 | 66749 | struct OP_OpenPseudo_stack_vars { |
| 66441 | 66750 | VdbeCursor *pCx; |
| 66442 | | - } bb; |
| 66751 | + } bc; |
| 66443 | 66752 | struct OP_SeekGt_stack_vars { |
| 66444 | 66753 | int res; |
| 66445 | 66754 | int oc; |
| 66446 | 66755 | VdbeCursor *pC; |
| 66447 | 66756 | UnpackedRecord r; |
| 66448 | 66757 | int nField; |
| 66449 | 66758 | i64 iKey; /* The rowid we are to seek to */ |
| 66450 | | - } bc; |
| 66759 | + } bd; |
| 66451 | 66760 | struct OP_Seek_stack_vars { |
| 66452 | 66761 | VdbeCursor *pC; |
| 66453 | | - } bd; |
| 66762 | + } be; |
| 66454 | 66763 | struct OP_Found_stack_vars { |
| 66455 | 66764 | int alreadyExists; |
| 66765 | + int ii; |
| 66456 | 66766 | VdbeCursor *pC; |
| 66457 | 66767 | int res; |
| 66458 | 66768 | char *pFree; |
| 66459 | 66769 | UnpackedRecord *pIdxKey; |
| 66460 | 66770 | UnpackedRecord r; |
| 66461 | | - char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7]; |
| 66462 | | - } be; |
| 66463 | | - struct OP_IsUnique_stack_vars { |
| 66464 | | - u16 ii; |
| 66465 | | - VdbeCursor *pCx; |
| 66466 | | - BtCursor *pCrsr; |
| 66467 | | - u16 nField; |
| 66468 | | - Mem *aMx; |
| 66469 | | - UnpackedRecord r; /* B-Tree index search key */ |
| 66470 | | - i64 R; /* Rowid stored in register P3 */ |
| 66771 | + char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*4 + 7]; |
| 66471 | 66772 | } bf; |
| 66472 | 66773 | struct OP_NotExists_stack_vars { |
| 66473 | 66774 | VdbeCursor *pC; |
| 66474 | 66775 | BtCursor *pCrsr; |
| 66475 | 66776 | int res; |
| | @@ -66499,10 +66800,11 @@ |
| 66499 | 66800 | VdbeCursor *pC; |
| 66500 | 66801 | } bj; |
| 66501 | 66802 | struct OP_SorterCompare_stack_vars { |
| 66502 | 66803 | VdbeCursor *pC; |
| 66503 | 66804 | int res; |
| 66805 | + int nIgnore; |
| 66504 | 66806 | } bk; |
| 66505 | 66807 | struct OP_SorterData_stack_vars { |
| 66506 | 66808 | VdbeCursor *pC; |
| 66507 | 66809 | } bl; |
| 66508 | 66810 | struct OP_RowData_stack_vars { |
| | @@ -66939,23 +67241,25 @@ |
| 66939 | 67241 | REGISTER_TRACE(pOp->p1, pIn1); |
| 66940 | 67242 | pc = u.aa.pcDest; |
| 66941 | 67243 | break; |
| 66942 | 67244 | } |
| 66943 | 67245 | |
| 66944 | | -/* Opcode: HaltIfNull P1 P2 P3 P4 * |
| 67246 | +/* Opcode: HaltIfNull P1 P2 P3 P4 P5 |
| 67247 | +** Synopsis: if r[P3] null then halt |
| 66945 | 67248 | ** |
| 66946 | 67249 | ** Check the value in register P3. If it is NULL then Halt using |
| 66947 | 67250 | ** parameter P1, P2, and P4 as if this were a Halt instruction. If the |
| 66948 | 67251 | ** value in register P3 is not NULL, then this routine is a no-op. |
| 67252 | +** The P5 parameter should be 1. |
| 66949 | 67253 | */ |
| 66950 | 67254 | case OP_HaltIfNull: { /* in3 */ |
| 66951 | 67255 | pIn3 = &aMem[pOp->p3]; |
| 66952 | 67256 | if( (pIn3->flags & MEM_Null)==0 ) break; |
| 66953 | 67257 | /* Fall through into OP_Halt */ |
| 66954 | 67258 | } |
| 66955 | 67259 | |
| 66956 | | -/* Opcode: Halt P1 P2 * P4 * |
| 67260 | +/* Opcode: Halt P1 P2 * P4 P5 |
| 66957 | 67261 | ** |
| 66958 | 67262 | ** Exit immediately. All open cursors, etc are closed |
| 66959 | 67263 | ** automatically. |
| 66960 | 67264 | ** |
| 66961 | 67265 | ** P1 is the result code returned by sqlite3_exec(), sqlite3_reset(), |
| | @@ -66965,26 +67269,42 @@ |
| 66965 | 67269 | ** if P2==OE_Fail. Do the rollback if P2==OE_Rollback. If P2==OE_Abort, |
| 66966 | 67270 | ** then back out all changes that have occurred during this execution of the |
| 66967 | 67271 | ** VDBE, but do not rollback the transaction. |
| 66968 | 67272 | ** |
| 66969 | 67273 | ** If P4 is not null then it is an error message string. |
| 67274 | +** |
| 67275 | +** P5 is a value between 0 and 4, inclusive, that modifies the P4 string. |
| 67276 | +** |
| 67277 | +** 0: (no change) |
| 67278 | +** 1: NOT NULL contraint failed: P4 |
| 67279 | +** 2: UNIQUE constraint failed: P4 |
| 67280 | +** 3: CHECK constraint failed: P4 |
| 67281 | +** 4: FOREIGN KEY constraint failed: P4 |
| 67282 | +** |
| 67283 | +** If P5 is not zero and P4 is NULL, then everything after the ":" is |
| 67284 | +** omitted. |
| 66970 | 67285 | ** |
| 66971 | 67286 | ** There is an implied "Halt 0 0 0" instruction inserted at the very end of |
| 66972 | 67287 | ** every program. So a jump past the last instruction of the program |
| 66973 | 67288 | ** is the same as executing Halt. |
| 66974 | 67289 | */ |
| 66975 | 67290 | case OP_Halt: { |
| 67291 | +#if 0 /* local variables moved into u.ab */ |
| 67292 | + const char *zType; |
| 67293 | + const char *zLogFmt; |
| 67294 | +#endif /* local variables moved into u.ab */ |
| 67295 | + |
| 66976 | 67296 | if( pOp->p1==SQLITE_OK && p->pFrame ){ |
| 66977 | 67297 | /* Halt the sub-program. Return control to the parent frame. */ |
| 66978 | 67298 | VdbeFrame *pFrame = p->pFrame; |
| 66979 | 67299 | p->pFrame = pFrame->pParent; |
| 66980 | 67300 | p->nFrame--; |
| 66981 | 67301 | sqlite3VdbeSetChanges(db, p->nChange); |
| 66982 | 67302 | pc = sqlite3VdbeFrameRestore(pFrame); |
| 66983 | 67303 | lastRowid = db->lastRowid; |
| 66984 | 67304 | if( pOp->p2==OE_Ignore ){ |
| 66985 | | - /* Instruction pc is the OP_Program that invoked the sub-program |
| 67305 | + /* Instruction pc is the OP_Program that invoked the sub-program |
| 66986 | 67306 | ** currently being halted. If the p2 instruction of this OP_Halt |
| 66987 | 67307 | ** instruction is set to OE_Ignore, then the sub-program is throwing |
| 66988 | 67308 | ** an IGNORE exception. In this case jump to the address specified |
| 66989 | 67309 | ** as the p2 of the calling OP_Program. */ |
| 66990 | 67310 | pc = p->aOp[pc].p2-1; |
| | @@ -66991,22 +67311,37 @@ |
| 66991 | 67311 | } |
| 66992 | 67312 | aOp = p->aOp; |
| 66993 | 67313 | aMem = p->aMem; |
| 66994 | 67314 | break; |
| 66995 | 67315 | } |
| 66996 | | - |
| 66997 | 67316 | p->rc = pOp->p1; |
| 66998 | 67317 | p->errorAction = (u8)pOp->p2; |
| 66999 | 67318 | p->pc = pc; |
| 67000 | | - if( pOp->p4.z ){ |
| 67001 | | - assert( p->rc!=SQLITE_OK ); |
| 67002 | | - sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z); |
| 67003 | | - testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 67004 | | - sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pc, p->zSql, pOp->p4.z); |
| 67005 | | - }else if( p->rc ){ |
| 67006 | | - testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 67007 | | - sqlite3_log(pOp->p1, "constraint failed at %d in [%s]", pc, p->zSql); |
| 67319 | + if( p->rc ){ |
| 67320 | + if( pOp->p5 ){ |
| 67321 | + static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK", |
| 67322 | + "FOREIGN KEY" }; |
| 67323 | + assert( pOp->p5>=1 && pOp->p5<=4 ); |
| 67324 | + testcase( pOp->p5==1 ); |
| 67325 | + testcase( pOp->p5==2 ); |
| 67326 | + testcase( pOp->p5==3 ); |
| 67327 | + testcase( pOp->p5==4 ); |
| 67328 | + u.ab.zType = azType[pOp->p5-1]; |
| 67329 | + }else{ |
| 67330 | + u.ab.zType = 0; |
| 67331 | + } |
| 67332 | + assert( u.ab.zType!=0 || pOp->p4.z!=0 ); |
| 67333 | + u.ab.zLogFmt = "abort at %d in [%s]: %s"; |
| 67334 | + if( u.ab.zType && pOp->p4.z ){ |
| 67335 | + sqlite3SetString(&p->zErrMsg, db, "%s constraint failed: %s", |
| 67336 | + u.ab.zType, pOp->p4.z); |
| 67337 | + }else if( pOp->p4.z ){ |
| 67338 | + sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z); |
| 67339 | + }else{ |
| 67340 | + sqlite3SetString(&p->zErrMsg, db, "%s constraint failed", u.ab.zType); |
| 67341 | + } |
| 67342 | + sqlite3_log(pOp->p1, u.ab.zLogFmt, pc, p->zSql, p->zErrMsg); |
| 67008 | 67343 | } |
| 67009 | 67344 | rc = sqlite3VdbeHalt(p); |
| 67010 | 67345 | assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR ); |
| 67011 | 67346 | if( rc==SQLITE_BUSY ){ |
| 67012 | 67347 | p->rc = rc = SQLITE_BUSY; |
| | @@ -67017,19 +67352,21 @@ |
| 67017 | 67352 | } |
| 67018 | 67353 | goto vdbe_return; |
| 67019 | 67354 | } |
| 67020 | 67355 | |
| 67021 | 67356 | /* Opcode: Integer P1 P2 * * * |
| 67357 | +** Synopsis: r[P2]=P1 |
| 67022 | 67358 | ** |
| 67023 | 67359 | ** The 32-bit integer value P1 is written into register P2. |
| 67024 | 67360 | */ |
| 67025 | 67361 | case OP_Integer: { /* out2-prerelease */ |
| 67026 | 67362 | pOut->u.i = pOp->p1; |
| 67027 | 67363 | break; |
| 67028 | 67364 | } |
| 67029 | 67365 | |
| 67030 | 67366 | /* Opcode: Int64 * P2 * P4 * |
| 67367 | +** Synopsis: r[P2]=P4 |
| 67031 | 67368 | ** |
| 67032 | 67369 | ** P4 is a pointer to a 64-bit integer value. |
| 67033 | 67370 | ** Write that value into register P2. |
| 67034 | 67371 | */ |
| 67035 | 67372 | case OP_Int64: { /* out2-prerelease */ |
| | @@ -67038,10 +67375,11 @@ |
| 67038 | 67375 | break; |
| 67039 | 67376 | } |
| 67040 | 67377 | |
| 67041 | 67378 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 67042 | 67379 | /* Opcode: Real * P2 * P4 * |
| 67380 | +** Synopsis: r[P2]=P4 |
| 67043 | 67381 | ** |
| 67044 | 67382 | ** P4 is a pointer to a 64-bit floating point value. |
| 67045 | 67383 | ** Write that value into register P2. |
| 67046 | 67384 | */ |
| 67047 | 67385 | case OP_Real: { /* same as TK_FLOAT, out2-prerelease */ |
| | @@ -67051,10 +67389,11 @@ |
| 67051 | 67389 | break; |
| 67052 | 67390 | } |
| 67053 | 67391 | #endif |
| 67054 | 67392 | |
| 67055 | 67393 | /* Opcode: String8 * P2 * P4 * |
| 67394 | +** Synopsis: r[P2]='P4' |
| 67056 | 67395 | ** |
| 67057 | 67396 | ** P4 points to a nul terminated UTF-8 string. This opcode is transformed |
| 67058 | 67397 | ** into an OP_String before it is executed for the first time. |
| 67059 | 67398 | */ |
| 67060 | 67399 | case OP_String8: { /* same as TK_STRING, out2-prerelease */ |
| | @@ -67085,10 +67424,11 @@ |
| 67085 | 67424 | } |
| 67086 | 67425 | /* Fall through to the next case, OP_String */ |
| 67087 | 67426 | } |
| 67088 | 67427 | |
| 67089 | 67428 | /* Opcode: String P1 P2 * P4 * |
| 67429 | +** Synopsis: r[P2]='P4' (len=P1) |
| 67090 | 67430 | ** |
| 67091 | 67431 | ** The string value P4 of length P1 (bytes) is stored in register P2. |
| 67092 | 67432 | */ |
| 67093 | 67433 | case OP_String: { /* out2-prerelease */ |
| 67094 | 67434 | assert( pOp->p4.z!=0 ); |
| | @@ -67099,10 +67439,11 @@ |
| 67099 | 67439 | UPDATE_MAX_BLOBSIZE(pOut); |
| 67100 | 67440 | break; |
| 67101 | 67441 | } |
| 67102 | 67442 | |
| 67103 | 67443 | /* Opcode: Null P1 P2 P3 * * |
| 67444 | +** Synopsis: r[P2..P3]=NULL |
| 67104 | 67445 | ** |
| 67105 | 67446 | ** Write a NULL into registers P2. If P3 greater than P2, then also write |
| 67106 | 67447 | ** NULL into register P3 and every register in between P2 and P3. If P3 |
| 67107 | 67448 | ** is less than P2 (typically P3 is zero) then only register P2 is |
| 67108 | 67449 | ** set to NULL. |
| | @@ -67110,29 +67451,30 @@ |
| 67110 | 67451 | ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that |
| 67111 | 67452 | ** NULL values will not compare equal even if SQLITE_NULLEQ is set on |
| 67112 | 67453 | ** OP_Ne or OP_Eq. |
| 67113 | 67454 | */ |
| 67114 | 67455 | case OP_Null: { /* out2-prerelease */ |
| 67115 | | -#if 0 /* local variables moved into u.ab */ |
| 67456 | +#if 0 /* local variables moved into u.ac */ |
| 67116 | 67457 | int cnt; |
| 67117 | 67458 | u16 nullFlag; |
| 67118 | | -#endif /* local variables moved into u.ab */ |
| 67119 | | - u.ab.cnt = pOp->p3-pOp->p2; |
| 67459 | +#endif /* local variables moved into u.ac */ |
| 67460 | + u.ac.cnt = pOp->p3-pOp->p2; |
| 67120 | 67461 | assert( pOp->p3<=(p->nMem-p->nCursor) ); |
| 67121 | | - pOut->flags = u.ab.nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null; |
| 67122 | | - while( u.ab.cnt>0 ){ |
| 67462 | + pOut->flags = u.ac.nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null; |
| 67463 | + while( u.ac.cnt>0 ){ |
| 67123 | 67464 | pOut++; |
| 67124 | 67465 | memAboutToChange(p, pOut); |
| 67125 | 67466 | VdbeMemRelease(pOut); |
| 67126 | | - pOut->flags = u.ab.nullFlag; |
| 67127 | | - u.ab.cnt--; |
| 67467 | + pOut->flags = u.ac.nullFlag; |
| 67468 | + u.ac.cnt--; |
| 67128 | 67469 | } |
| 67129 | 67470 | break; |
| 67130 | 67471 | } |
| 67131 | 67472 | |
| 67132 | 67473 | |
| 67133 | 67474 | /* Opcode: Blob P1 P2 * P4 |
| 67475 | +** Synopsis: r[P2]=P4 (len=P1) |
| 67134 | 67476 | ** |
| 67135 | 67477 | ** P4 points to a blob of data P1 bytes long. Store this |
| 67136 | 67478 | ** blob in register P2. |
| 67137 | 67479 | */ |
| 67138 | 67480 | case OP_Blob: { /* out2-prerelease */ |
| | @@ -67142,107 +67484,111 @@ |
| 67142 | 67484 | UPDATE_MAX_BLOBSIZE(pOut); |
| 67143 | 67485 | break; |
| 67144 | 67486 | } |
| 67145 | 67487 | |
| 67146 | 67488 | /* Opcode: Variable P1 P2 * P4 * |
| 67489 | +** Synopsis: r[P2]=parameter(P1,P4) |
| 67147 | 67490 | ** |
| 67148 | 67491 | ** Transfer the values of bound parameter P1 into register P2 |
| 67149 | 67492 | ** |
| 67150 | 67493 | ** If the parameter is named, then its name appears in P4 and P3==1. |
| 67151 | 67494 | ** The P4 value is used by sqlite3_bind_parameter_name(). |
| 67152 | 67495 | */ |
| 67153 | 67496 | case OP_Variable: { /* out2-prerelease */ |
| 67154 | | -#if 0 /* local variables moved into u.ac */ |
| 67497 | +#if 0 /* local variables moved into u.ad */ |
| 67155 | 67498 | Mem *pVar; /* Value being transferred */ |
| 67156 | | -#endif /* local variables moved into u.ac */ |
| 67499 | +#endif /* local variables moved into u.ad */ |
| 67157 | 67500 | |
| 67158 | 67501 | assert( pOp->p1>0 && pOp->p1<=p->nVar ); |
| 67159 | 67502 | assert( pOp->p4.z==0 || pOp->p4.z==p->azVar[pOp->p1-1] ); |
| 67160 | | - u.ac.pVar = &p->aVar[pOp->p1 - 1]; |
| 67161 | | - if( sqlite3VdbeMemTooBig(u.ac.pVar) ){ |
| 67503 | + u.ad.pVar = &p->aVar[pOp->p1 - 1]; |
| 67504 | + if( sqlite3VdbeMemTooBig(u.ad.pVar) ){ |
| 67162 | 67505 | goto too_big; |
| 67163 | 67506 | } |
| 67164 | | - sqlite3VdbeMemShallowCopy(pOut, u.ac.pVar, MEM_Static); |
| 67507 | + sqlite3VdbeMemShallowCopy(pOut, u.ad.pVar, MEM_Static); |
| 67165 | 67508 | UPDATE_MAX_BLOBSIZE(pOut); |
| 67166 | 67509 | break; |
| 67167 | 67510 | } |
| 67168 | 67511 | |
| 67169 | 67512 | /* Opcode: Move P1 P2 P3 * * |
| 67513 | +** Synopsis: r[P2@P3]=r[P1@P3] |
| 67170 | 67514 | ** |
| 67171 | 67515 | ** Move the values in register P1..P1+P3 over into |
| 67172 | 67516 | ** registers P2..P2+P3. Registers P1..P1+P3 are |
| 67173 | 67517 | ** left holding a NULL. It is an error for register ranges |
| 67174 | 67518 | ** P1..P1+P3 and P2..P2+P3 to overlap. |
| 67175 | 67519 | */ |
| 67176 | 67520 | case OP_Move: { |
| 67177 | | -#if 0 /* local variables moved into u.ad */ |
| 67521 | +#if 0 /* local variables moved into u.ae */ |
| 67178 | 67522 | char *zMalloc; /* Holding variable for allocated memory */ |
| 67179 | 67523 | int n; /* Number of registers left to copy */ |
| 67180 | 67524 | int p1; /* Register to copy from */ |
| 67181 | 67525 | int p2; /* Register to copy to */ |
| 67182 | | -#endif /* local variables moved into u.ad */ |
| 67183 | | - |
| 67184 | | - u.ad.n = pOp->p3 + 1; |
| 67185 | | - u.ad.p1 = pOp->p1; |
| 67186 | | - u.ad.p2 = pOp->p2; |
| 67187 | | - assert( u.ad.n>0 && u.ad.p1>0 && u.ad.p2>0 ); |
| 67188 | | - assert( u.ad.p1+u.ad.n<=u.ad.p2 || u.ad.p2+u.ad.n<=u.ad.p1 ); |
| 67189 | | - |
| 67190 | | - pIn1 = &aMem[u.ad.p1]; |
| 67191 | | - pOut = &aMem[u.ad.p2]; |
| 67192 | | - while( u.ad.n-- ){ |
| 67526 | +#endif /* local variables moved into u.ae */ |
| 67527 | + |
| 67528 | + u.ae.n = pOp->p3 + 1; |
| 67529 | + u.ae.p1 = pOp->p1; |
| 67530 | + u.ae.p2 = pOp->p2; |
| 67531 | + assert( u.ae.n>0 && u.ae.p1>0 && u.ae.p2>0 ); |
| 67532 | + assert( u.ae.p1+u.ae.n<=u.ae.p2 || u.ae.p2+u.ae.n<=u.ae.p1 ); |
| 67533 | + |
| 67534 | + pIn1 = &aMem[u.ae.p1]; |
| 67535 | + pOut = &aMem[u.ae.p2]; |
| 67536 | + while( u.ae.n-- ){ |
| 67193 | 67537 | assert( pOut<=&aMem[(p->nMem-p->nCursor)] ); |
| 67194 | 67538 | assert( pIn1<=&aMem[(p->nMem-p->nCursor)] ); |
| 67195 | 67539 | assert( memIsValid(pIn1) ); |
| 67196 | 67540 | memAboutToChange(p, pOut); |
| 67197 | | - u.ad.zMalloc = pOut->zMalloc; |
| 67541 | + u.ae.zMalloc = pOut->zMalloc; |
| 67198 | 67542 | pOut->zMalloc = 0; |
| 67199 | 67543 | sqlite3VdbeMemMove(pOut, pIn1); |
| 67200 | 67544 | #ifdef SQLITE_DEBUG |
| 67201 | | - if( pOut->pScopyFrom>=&aMem[u.ad.p1] && pOut->pScopyFrom<&aMem[u.ad.p1+pOp->p3] ){ |
| 67202 | | - pOut->pScopyFrom += u.ad.p1 - pOp->p2; |
| 67545 | + if( pOut->pScopyFrom>=&aMem[u.ae.p1] && pOut->pScopyFrom<&aMem[u.ae.p1+pOp->p3] ){ |
| 67546 | + pOut->pScopyFrom += u.ae.p1 - pOp->p2; |
| 67203 | 67547 | } |
| 67204 | 67548 | #endif |
| 67205 | | - pIn1->zMalloc = u.ad.zMalloc; |
| 67206 | | - REGISTER_TRACE(u.ad.p2++, pOut); |
| 67549 | + pIn1->zMalloc = u.ae.zMalloc; |
| 67550 | + REGISTER_TRACE(u.ae.p2++, pOut); |
| 67207 | 67551 | pIn1++; |
| 67208 | 67552 | pOut++; |
| 67209 | 67553 | } |
| 67210 | 67554 | break; |
| 67211 | 67555 | } |
| 67212 | 67556 | |
| 67213 | 67557 | /* Opcode: Copy P1 P2 P3 * * |
| 67558 | +** Synopsis: r[P2@P3]=r[P1@P3] |
| 67214 | 67559 | ** |
| 67215 | 67560 | ** Make a copy of registers P1..P1+P3 into registers P2..P2+P3. |
| 67216 | 67561 | ** |
| 67217 | 67562 | ** This instruction makes a deep copy of the value. A duplicate |
| 67218 | 67563 | ** is made of any string or blob constant. See also OP_SCopy. |
| 67219 | 67564 | */ |
| 67220 | 67565 | case OP_Copy: { |
| 67221 | | -#if 0 /* local variables moved into u.ae */ |
| 67566 | +#if 0 /* local variables moved into u.af */ |
| 67222 | 67567 | int n; |
| 67223 | | -#endif /* local variables moved into u.ae */ |
| 67568 | +#endif /* local variables moved into u.af */ |
| 67224 | 67569 | |
| 67225 | | - u.ae.n = pOp->p3; |
| 67570 | + u.af.n = pOp->p3; |
| 67226 | 67571 | pIn1 = &aMem[pOp->p1]; |
| 67227 | 67572 | pOut = &aMem[pOp->p2]; |
| 67228 | 67573 | assert( pOut!=pIn1 ); |
| 67229 | 67574 | while( 1 ){ |
| 67230 | 67575 | sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); |
| 67231 | 67576 | Deephemeralize(pOut); |
| 67232 | 67577 | #ifdef SQLITE_DEBUG |
| 67233 | 67578 | pOut->pScopyFrom = 0; |
| 67234 | 67579 | #endif |
| 67235 | | - REGISTER_TRACE(pOp->p2+pOp->p3-u.ae.n, pOut); |
| 67236 | | - if( (u.ae.n--)==0 ) break; |
| 67580 | + REGISTER_TRACE(pOp->p2+pOp->p3-u.af.n, pOut); |
| 67581 | + if( (u.af.n--)==0 ) break; |
| 67237 | 67582 | pOut++; |
| 67238 | 67583 | pIn1++; |
| 67239 | 67584 | } |
| 67240 | 67585 | break; |
| 67241 | 67586 | } |
| 67242 | 67587 | |
| 67243 | 67588 | /* Opcode: SCopy P1 P2 * * * |
| 67589 | +** Synopsis: r[P2]=r[P1] |
| 67244 | 67590 | ** |
| 67245 | 67591 | ** Make a shallow copy of register P1 into register P2. |
| 67246 | 67592 | ** |
| 67247 | 67593 | ** This instruction makes a shallow copy of the value. If the value |
| 67248 | 67594 | ** is a string or blob, then the copy is only a pointer to the |
| | @@ -67250,35 +67596,35 @@ |
| 67250 | 67596 | ** Worse, if the original is deallocated, the copy becomes invalid. |
| 67251 | 67597 | ** Thus the program must guarantee that the original will not change |
| 67252 | 67598 | ** during the lifetime of the copy. Use OP_Copy to make a complete |
| 67253 | 67599 | ** copy. |
| 67254 | 67600 | */ |
| 67255 | | -case OP_SCopy: { /* in1, out2 */ |
| 67601 | +case OP_SCopy: { /* out2 */ |
| 67256 | 67602 | pIn1 = &aMem[pOp->p1]; |
| 67257 | 67603 | pOut = &aMem[pOp->p2]; |
| 67258 | 67604 | assert( pOut!=pIn1 ); |
| 67259 | 67605 | sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem); |
| 67260 | 67606 | #ifdef SQLITE_DEBUG |
| 67261 | 67607 | if( pOut->pScopyFrom==0 ) pOut->pScopyFrom = pIn1; |
| 67262 | 67608 | #endif |
| 67263 | | - REGISTER_TRACE(pOp->p2, pOut); |
| 67264 | 67609 | break; |
| 67265 | 67610 | } |
| 67266 | 67611 | |
| 67267 | 67612 | /* Opcode: ResultRow P1 P2 * * * |
| 67613 | +** Synopsis: output=r[P1@P2] |
| 67268 | 67614 | ** |
| 67269 | 67615 | ** The registers P1 through P1+P2-1 contain a single row of |
| 67270 | 67616 | ** results. This opcode causes the sqlite3_step() call to terminate |
| 67271 | 67617 | ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt |
| 67272 | 67618 | ** structure to provide access to the top P1 values as the result |
| 67273 | 67619 | ** row. |
| 67274 | 67620 | */ |
| 67275 | 67621 | case OP_ResultRow: { |
| 67276 | | -#if 0 /* local variables moved into u.af */ |
| 67622 | +#if 0 /* local variables moved into u.ag */ |
| 67277 | 67623 | Mem *pMem; |
| 67278 | 67624 | int i; |
| 67279 | | -#endif /* local variables moved into u.af */ |
| 67625 | +#endif /* local variables moved into u.ag */ |
| 67280 | 67626 | assert( p->nResColumn==pOp->p2 ); |
| 67281 | 67627 | assert( pOp->p1>0 ); |
| 67282 | 67628 | assert( pOp->p1+pOp->p2<=(p->nMem-p->nCursor)+1 ); |
| 67283 | 67629 | |
| 67284 | 67630 | /* If this statement has violated immediate foreign key constraints, do |
| | @@ -67316,19 +67662,19 @@ |
| 67316 | 67662 | |
| 67317 | 67663 | /* Make sure the results of the current row are \000 terminated |
| 67318 | 67664 | ** and have an assigned type. The results are de-ephemeralized as |
| 67319 | 67665 | ** a side effect. |
| 67320 | 67666 | */ |
| 67321 | | - u.af.pMem = p->pResultSet = &aMem[pOp->p1]; |
| 67322 | | - for(u.af.i=0; u.af.i<pOp->p2; u.af.i++){ |
| 67323 | | - assert( memIsValid(&u.af.pMem[u.af.i]) ); |
| 67324 | | - Deephemeralize(&u.af.pMem[u.af.i]); |
| 67325 | | - assert( (u.af.pMem[u.af.i].flags & MEM_Ephem)==0 |
| 67326 | | - || (u.af.pMem[u.af.i].flags & (MEM_Str|MEM_Blob))==0 ); |
| 67327 | | - sqlite3VdbeMemNulTerminate(&u.af.pMem[u.af.i]); |
| 67328 | | - sqlite3VdbeMemStoreType(&u.af.pMem[u.af.i]); |
| 67329 | | - REGISTER_TRACE(pOp->p1+u.af.i, &u.af.pMem[u.af.i]); |
| 67667 | + u.ag.pMem = p->pResultSet = &aMem[pOp->p1]; |
| 67668 | + for(u.ag.i=0; u.ag.i<pOp->p2; u.ag.i++){ |
| 67669 | + assert( memIsValid(&u.ag.pMem[u.ag.i]) ); |
| 67670 | + Deephemeralize(&u.ag.pMem[u.ag.i]); |
| 67671 | + assert( (u.ag.pMem[u.ag.i].flags & MEM_Ephem)==0 |
| 67672 | + || (u.ag.pMem[u.ag.i].flags & (MEM_Str|MEM_Blob))==0 ); |
| 67673 | + sqlite3VdbeMemNulTerminate(&u.ag.pMem[u.ag.i]); |
| 67674 | + sqlite3VdbeMemStoreType(&u.ag.pMem[u.ag.i]); |
| 67675 | + REGISTER_TRACE(pOp->p1+u.ag.i, &u.ag.pMem[u.ag.i]); |
| 67330 | 67676 | } |
| 67331 | 67677 | if( db->mallocFailed ) goto no_mem; |
| 67332 | 67678 | |
| 67333 | 67679 | /* Return SQLITE_ROW |
| 67334 | 67680 | */ |
| | @@ -67336,10 +67682,11 @@ |
| 67336 | 67682 | rc = SQLITE_ROW; |
| 67337 | 67683 | goto vdbe_return; |
| 67338 | 67684 | } |
| 67339 | 67685 | |
| 67340 | 67686 | /* Opcode: Concat P1 P2 P3 * * |
| 67687 | +** Synopsis: r[P3]=r[P2]+r[P1] |
| 67341 | 67688 | ** |
| 67342 | 67689 | ** Add the text in register P1 onto the end of the text in |
| 67343 | 67690 | ** register P2 and store the result in register P3. |
| 67344 | 67691 | ** If either the P1 or P2 text are NULL then store NULL in P3. |
| 67345 | 67692 | ** |
| | @@ -67348,13 +67695,13 @@ |
| 67348 | 67695 | ** It is illegal for P1 and P3 to be the same register. Sometimes, |
| 67349 | 67696 | ** if P3 is the same register as P2, the implementation is able |
| 67350 | 67697 | ** to avoid a memcpy(). |
| 67351 | 67698 | */ |
| 67352 | 67699 | case OP_Concat: { /* same as TK_CONCAT, in1, in2, out3 */ |
| 67353 | | -#if 0 /* local variables moved into u.ag */ |
| 67700 | +#if 0 /* local variables moved into u.ah */ |
| 67354 | 67701 | i64 nByte; |
| 67355 | | -#endif /* local variables moved into u.ag */ |
| 67702 | +#endif /* local variables moved into u.ah */ |
| 67356 | 67703 | |
| 67357 | 67704 | pIn1 = &aMem[pOp->p1]; |
| 67358 | 67705 | pIn2 = &aMem[pOp->p2]; |
| 67359 | 67706 | pOut = &aMem[pOp->p3]; |
| 67360 | 67707 | assert( pIn1!=pOut ); |
| | @@ -67363,58 +67710,63 @@ |
| 67363 | 67710 | break; |
| 67364 | 67711 | } |
| 67365 | 67712 | if( ExpandBlob(pIn1) || ExpandBlob(pIn2) ) goto no_mem; |
| 67366 | 67713 | Stringify(pIn1, encoding); |
| 67367 | 67714 | Stringify(pIn2, encoding); |
| 67368 | | - u.ag.nByte = pIn1->n + pIn2->n; |
| 67369 | | - if( u.ag.nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 67715 | + u.ah.nByte = pIn1->n + pIn2->n; |
| 67716 | + if( u.ah.nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 67370 | 67717 | goto too_big; |
| 67371 | 67718 | } |
| 67372 | 67719 | MemSetTypeFlag(pOut, MEM_Str); |
| 67373 | | - if( sqlite3VdbeMemGrow(pOut, (int)u.ag.nByte+2, pOut==pIn2) ){ |
| 67720 | + if( sqlite3VdbeMemGrow(pOut, (int)u.ah.nByte+2, pOut==pIn2) ){ |
| 67374 | 67721 | goto no_mem; |
| 67375 | 67722 | } |
| 67376 | 67723 | if( pOut!=pIn2 ){ |
| 67377 | 67724 | memcpy(pOut->z, pIn2->z, pIn2->n); |
| 67378 | 67725 | } |
| 67379 | 67726 | memcpy(&pOut->z[pIn2->n], pIn1->z, pIn1->n); |
| 67380 | | - pOut->z[u.ag.nByte] = 0; |
| 67381 | | - pOut->z[u.ag.nByte+1] = 0; |
| 67727 | + pOut->z[u.ah.nByte]=0; |
| 67728 | + pOut->z[u.ah.nByte+1] = 0; |
| 67382 | 67729 | pOut->flags |= MEM_Term; |
| 67383 | | - pOut->n = (int)u.ag.nByte; |
| 67730 | + pOut->n = (int)u.ah.nByte; |
| 67384 | 67731 | pOut->enc = encoding; |
| 67385 | 67732 | UPDATE_MAX_BLOBSIZE(pOut); |
| 67386 | 67733 | break; |
| 67387 | 67734 | } |
| 67388 | 67735 | |
| 67389 | 67736 | /* Opcode: Add P1 P2 P3 * * |
| 67737 | +** Synopsis: r[P3]=r[P1]+r[P2] |
| 67390 | 67738 | ** |
| 67391 | 67739 | ** Add the value in register P1 to the value in register P2 |
| 67392 | 67740 | ** and store the result in register P3. |
| 67393 | 67741 | ** If either input is NULL, the result is NULL. |
| 67394 | 67742 | */ |
| 67395 | 67743 | /* Opcode: Multiply P1 P2 P3 * * |
| 67744 | +** Synopsis: r[P3]=r[P1]*r[P2] |
| 67396 | 67745 | ** |
| 67397 | 67746 | ** |
| 67398 | 67747 | ** Multiply the value in register P1 by the value in register P2 |
| 67399 | 67748 | ** and store the result in register P3. |
| 67400 | 67749 | ** If either input is NULL, the result is NULL. |
| 67401 | 67750 | */ |
| 67402 | 67751 | /* Opcode: Subtract P1 P2 P3 * * |
| 67752 | +** Synopsis: r[P3]=r[P2]-r[P1] |
| 67403 | 67753 | ** |
| 67404 | 67754 | ** Subtract the value in register P1 from the value in register P2 |
| 67405 | 67755 | ** and store the result in register P3. |
| 67406 | 67756 | ** If either input is NULL, the result is NULL. |
| 67407 | 67757 | */ |
| 67408 | 67758 | /* Opcode: Divide P1 P2 P3 * * |
| 67759 | +** Synopsis: r[P3]=r[P1]/r[P2] |
| 67409 | 67760 | ** |
| 67410 | 67761 | ** Divide the value in register P1 by the value in register P2 |
| 67411 | 67762 | ** and store the result in register P3 (P3=P2/P1). If the value in |
| 67412 | 67763 | ** register P1 is zero, then the result is NULL. If either input is |
| 67413 | 67764 | ** NULL, the result is NULL. |
| 67414 | 67765 | */ |
| 67415 | 67766 | /* Opcode: Remainder P1 P2 P3 * * |
| 67767 | +** Synopsis: r[P3]=r[P1]%r[P2] |
| 67416 | 67768 | ** |
| 67417 | 67769 | ** Compute the remainder after integer division of the value in |
| 67418 | 67770 | ** register P1 by the value in register P2 and store the result in P3. |
| 67419 | 67771 | ** If the value in register P2 is zero the result is NULL. |
| 67420 | 67772 | ** If either operand is NULL, the result is NULL. |
| | @@ -67422,83 +67774,83 @@ |
| 67422 | 67774 | case OP_Add: /* same as TK_PLUS, in1, in2, out3 */ |
| 67423 | 67775 | case OP_Subtract: /* same as TK_MINUS, in1, in2, out3 */ |
| 67424 | 67776 | case OP_Multiply: /* same as TK_STAR, in1, in2, out3 */ |
| 67425 | 67777 | case OP_Divide: /* same as TK_SLASH, in1, in2, out3 */ |
| 67426 | 67778 | case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ |
| 67427 | | -#if 0 /* local variables moved into u.ah */ |
| 67779 | +#if 0 /* local variables moved into u.ai */ |
| 67428 | 67780 | char bIntint; /* Started out as two integer operands */ |
| 67429 | 67781 | int flags; /* Combined MEM_* flags from both inputs */ |
| 67430 | 67782 | i64 iA; /* Integer value of left operand */ |
| 67431 | 67783 | i64 iB; /* Integer value of right operand */ |
| 67432 | 67784 | double rA; /* Real value of left operand */ |
| 67433 | 67785 | double rB; /* Real value of right operand */ |
| 67434 | | -#endif /* local variables moved into u.ah */ |
| 67786 | +#endif /* local variables moved into u.ai */ |
| 67435 | 67787 | |
| 67436 | 67788 | pIn1 = &aMem[pOp->p1]; |
| 67437 | 67789 | applyNumericAffinity(pIn1); |
| 67438 | 67790 | pIn2 = &aMem[pOp->p2]; |
| 67439 | 67791 | applyNumericAffinity(pIn2); |
| 67440 | 67792 | pOut = &aMem[pOp->p3]; |
| 67441 | | - u.ah.flags = pIn1->flags | pIn2->flags; |
| 67442 | | - if( (u.ah.flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; |
| 67793 | + u.ai.flags = pIn1->flags | pIn2->flags; |
| 67794 | + if( (u.ai.flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; |
| 67443 | 67795 | if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){ |
| 67444 | | - u.ah.iA = pIn1->u.i; |
| 67445 | | - u.ah.iB = pIn2->u.i; |
| 67446 | | - u.ah.bIntint = 1; |
| 67796 | + u.ai.iA = pIn1->u.i; |
| 67797 | + u.ai.iB = pIn2->u.i; |
| 67798 | + u.ai.bIntint = 1; |
| 67447 | 67799 | switch( pOp->opcode ){ |
| 67448 | | - case OP_Add: if( sqlite3AddInt64(&u.ah.iB,u.ah.iA) ) goto fp_math; break; |
| 67449 | | - case OP_Subtract: if( sqlite3SubInt64(&u.ah.iB,u.ah.iA) ) goto fp_math; break; |
| 67450 | | - case OP_Multiply: if( sqlite3MulInt64(&u.ah.iB,u.ah.iA) ) goto fp_math; break; |
| 67800 | + case OP_Add: if( sqlite3AddInt64(&u.ai.iB,u.ai.iA) ) goto fp_math; break; |
| 67801 | + case OP_Subtract: if( sqlite3SubInt64(&u.ai.iB,u.ai.iA) ) goto fp_math; break; |
| 67802 | + case OP_Multiply: if( sqlite3MulInt64(&u.ai.iB,u.ai.iA) ) goto fp_math; break; |
| 67451 | 67803 | case OP_Divide: { |
| 67452 | | - if( u.ah.iA==0 ) goto arithmetic_result_is_null; |
| 67453 | | - if( u.ah.iA==-1 && u.ah.iB==SMALLEST_INT64 ) goto fp_math; |
| 67454 | | - u.ah.iB /= u.ah.iA; |
| 67804 | + if( u.ai.iA==0 ) goto arithmetic_result_is_null; |
| 67805 | + if( u.ai.iA==-1 && u.ai.iB==SMALLEST_INT64 ) goto fp_math; |
| 67806 | + u.ai.iB /= u.ai.iA; |
| 67455 | 67807 | break; |
| 67456 | 67808 | } |
| 67457 | 67809 | default: { |
| 67458 | | - if( u.ah.iA==0 ) goto arithmetic_result_is_null; |
| 67459 | | - if( u.ah.iA==-1 ) u.ah.iA = 1; |
| 67460 | | - u.ah.iB %= u.ah.iA; |
| 67810 | + if( u.ai.iA==0 ) goto arithmetic_result_is_null; |
| 67811 | + if( u.ai.iA==-1 ) u.ai.iA = 1; |
| 67812 | + u.ai.iB %= u.ai.iA; |
| 67461 | 67813 | break; |
| 67462 | 67814 | } |
| 67463 | 67815 | } |
| 67464 | | - pOut->u.i = u.ah.iB; |
| 67816 | + pOut->u.i = u.ai.iB; |
| 67465 | 67817 | MemSetTypeFlag(pOut, MEM_Int); |
| 67466 | 67818 | }else{ |
| 67467 | | - u.ah.bIntint = 0; |
| 67819 | + u.ai.bIntint = 0; |
| 67468 | 67820 | fp_math: |
| 67469 | | - u.ah.rA = sqlite3VdbeRealValue(pIn1); |
| 67470 | | - u.ah.rB = sqlite3VdbeRealValue(pIn2); |
| 67821 | + u.ai.rA = sqlite3VdbeRealValue(pIn1); |
| 67822 | + u.ai.rB = sqlite3VdbeRealValue(pIn2); |
| 67471 | 67823 | switch( pOp->opcode ){ |
| 67472 | | - case OP_Add: u.ah.rB += u.ah.rA; break; |
| 67473 | | - case OP_Subtract: u.ah.rB -= u.ah.rA; break; |
| 67474 | | - case OP_Multiply: u.ah.rB *= u.ah.rA; break; |
| 67824 | + case OP_Add: u.ai.rB += u.ai.rA; break; |
| 67825 | + case OP_Subtract: u.ai.rB -= u.ai.rA; break; |
| 67826 | + case OP_Multiply: u.ai.rB *= u.ai.rA; break; |
| 67475 | 67827 | case OP_Divide: { |
| 67476 | 67828 | /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ |
| 67477 | | - if( u.ah.rA==(double)0 ) goto arithmetic_result_is_null; |
| 67478 | | - u.ah.rB /= u.ah.rA; |
| 67829 | + if( u.ai.rA==(double)0 ) goto arithmetic_result_is_null; |
| 67830 | + u.ai.rB /= u.ai.rA; |
| 67479 | 67831 | break; |
| 67480 | 67832 | } |
| 67481 | 67833 | default: { |
| 67482 | | - u.ah.iA = (i64)u.ah.rA; |
| 67483 | | - u.ah.iB = (i64)u.ah.rB; |
| 67484 | | - if( u.ah.iA==0 ) goto arithmetic_result_is_null; |
| 67485 | | - if( u.ah.iA==-1 ) u.ah.iA = 1; |
| 67486 | | - u.ah.rB = (double)(u.ah.iB % u.ah.iA); |
| 67834 | + u.ai.iA = (i64)u.ai.rA; |
| 67835 | + u.ai.iB = (i64)u.ai.rB; |
| 67836 | + if( u.ai.iA==0 ) goto arithmetic_result_is_null; |
| 67837 | + if( u.ai.iA==-1 ) u.ai.iA = 1; |
| 67838 | + u.ai.rB = (double)(u.ai.iB % u.ai.iA); |
| 67487 | 67839 | break; |
| 67488 | 67840 | } |
| 67489 | 67841 | } |
| 67490 | 67842 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 67491 | | - pOut->u.i = u.ah.rB; |
| 67843 | + pOut->u.i = u.ai.rB; |
| 67492 | 67844 | MemSetTypeFlag(pOut, MEM_Int); |
| 67493 | 67845 | #else |
| 67494 | | - if( sqlite3IsNaN(u.ah.rB) ){ |
| 67846 | + if( sqlite3IsNaN(u.ai.rB) ){ |
| 67495 | 67847 | goto arithmetic_result_is_null; |
| 67496 | 67848 | } |
| 67497 | | - pOut->r = u.ah.rB; |
| 67849 | + pOut->r = u.ai.rB; |
| 67498 | 67850 | MemSetTypeFlag(pOut, MEM_Real); |
| 67499 | | - if( (u.ah.flags & MEM_Real)==0 && !u.ah.bIntint ){ |
| 67851 | + if( (u.ai.flags & MEM_Real)==0 && !u.ai.bIntint ){ |
| 67500 | 67852 | sqlite3VdbeIntegerAffinity(pOut); |
| 67501 | 67853 | } |
| 67502 | 67854 | #endif |
| 67503 | 67855 | } |
| 67504 | 67856 | break; |
| | @@ -67530,10 +67882,11 @@ |
| 67530 | 67882 | } |
| 67531 | 67883 | break; |
| 67532 | 67884 | } |
| 67533 | 67885 | |
| 67534 | 67886 | /* Opcode: Function P1 P2 P3 P4 P5 |
| 67887 | +** Synopsis: r[P3]=func(r[P2@P5]) |
| 67535 | 67888 | ** |
| 67536 | 67889 | ** Invoke a user function (P4 is a pointer to a Function structure that |
| 67537 | 67890 | ** defines the function) with P5 arguments taken from register P2 and |
| 67538 | 67891 | ** successors. The result of the function is stored in register P3. |
| 67539 | 67892 | ** Register P3 must not be one of the function inputs. |
| | @@ -67546,85 +67899,85 @@ |
| 67546 | 67899 | ** invocation of this opcode. |
| 67547 | 67900 | ** |
| 67548 | 67901 | ** See also: AggStep and AggFinal |
| 67549 | 67902 | */ |
| 67550 | 67903 | case OP_Function: { |
| 67551 | | -#if 0 /* local variables moved into u.ai */ |
| 67904 | +#if 0 /* local variables moved into u.aj */ |
| 67552 | 67905 | int i; |
| 67553 | 67906 | Mem *pArg; |
| 67554 | 67907 | sqlite3_context ctx; |
| 67555 | 67908 | sqlite3_value **apVal; |
| 67556 | 67909 | int n; |
| 67557 | | -#endif /* local variables moved into u.ai */ |
| 67910 | +#endif /* local variables moved into u.aj */ |
| 67558 | 67911 | |
| 67559 | | - u.ai.n = pOp->p5; |
| 67560 | | - u.ai.apVal = p->apArg; |
| 67561 | | - assert( u.ai.apVal || u.ai.n==0 ); |
| 67912 | + u.aj.n = pOp->p5; |
| 67913 | + u.aj.apVal = p->apArg; |
| 67914 | + assert( u.aj.apVal || u.aj.n==0 ); |
| 67562 | 67915 | assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) ); |
| 67563 | 67916 | pOut = &aMem[pOp->p3]; |
| 67564 | 67917 | memAboutToChange(p, pOut); |
| 67565 | 67918 | |
| 67566 | | - assert( u.ai.n==0 || (pOp->p2>0 && pOp->p2+u.ai.n<=(p->nMem-p->nCursor)+1) ); |
| 67567 | | - assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+u.ai.n ); |
| 67568 | | - u.ai.pArg = &aMem[pOp->p2]; |
| 67569 | | - for(u.ai.i=0; u.ai.i<u.ai.n; u.ai.i++, u.ai.pArg++){ |
| 67570 | | - assert( memIsValid(u.ai.pArg) ); |
| 67571 | | - u.ai.apVal[u.ai.i] = u.ai.pArg; |
| 67572 | | - Deephemeralize(u.ai.pArg); |
| 67573 | | - sqlite3VdbeMemStoreType(u.ai.pArg); |
| 67574 | | - REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg); |
| 67919 | + assert( u.aj.n==0 || (pOp->p2>0 && pOp->p2+u.aj.n<=(p->nMem-p->nCursor)+1) ); |
| 67920 | + assert( pOp->p3<pOp->p2 || pOp->p3>=pOp->p2+u.aj.n ); |
| 67921 | + u.aj.pArg = &aMem[pOp->p2]; |
| 67922 | + for(u.aj.i=0; u.aj.i<u.aj.n; u.aj.i++, u.aj.pArg++){ |
| 67923 | + assert( memIsValid(u.aj.pArg) ); |
| 67924 | + u.aj.apVal[u.aj.i] = u.aj.pArg; |
| 67925 | + Deephemeralize(u.aj.pArg); |
| 67926 | + sqlite3VdbeMemStoreType(u.aj.pArg); |
| 67927 | + REGISTER_TRACE(pOp->p2+u.aj.i, u.aj.pArg); |
| 67575 | 67928 | } |
| 67576 | 67929 | |
| 67577 | 67930 | assert( pOp->p4type==P4_FUNCDEF ); |
| 67578 | | - u.ai.ctx.pFunc = pOp->p4.pFunc; |
| 67579 | | - u.ai.ctx.s.flags = MEM_Null; |
| 67580 | | - u.ai.ctx.s.db = db; |
| 67581 | | - u.ai.ctx.s.xDel = 0; |
| 67582 | | - u.ai.ctx.s.zMalloc = 0; |
| 67583 | | - u.ai.ctx.iOp = pc; |
| 67584 | | - u.ai.ctx.pVdbe = p; |
| 67931 | + u.aj.ctx.pFunc = pOp->p4.pFunc; |
| 67932 | + u.aj.ctx.s.flags = MEM_Null; |
| 67933 | + u.aj.ctx.s.db = db; |
| 67934 | + u.aj.ctx.s.xDel = 0; |
| 67935 | + u.aj.ctx.s.zMalloc = 0; |
| 67936 | + u.aj.ctx.iOp = pc; |
| 67937 | + u.aj.ctx.pVdbe = p; |
| 67585 | 67938 | |
| 67586 | 67939 | /* The output cell may already have a buffer allocated. Move |
| 67587 | | - ** the pointer to u.ai.ctx.s so in case the user-function can use |
| 67940 | + ** the pointer to u.aj.ctx.s so in case the user-function can use |
| 67588 | 67941 | ** the already allocated buffer instead of allocating a new one. |
| 67589 | 67942 | */ |
| 67590 | | - sqlite3VdbeMemMove(&u.ai.ctx.s, pOut); |
| 67591 | | - MemSetTypeFlag(&u.ai.ctx.s, MEM_Null); |
| 67943 | + sqlite3VdbeMemMove(&u.aj.ctx.s, pOut); |
| 67944 | + MemSetTypeFlag(&u.aj.ctx.s, MEM_Null); |
| 67592 | 67945 | |
| 67593 | | - u.ai.ctx.fErrorOrAux = 0; |
| 67594 | | - if( u.ai.ctx.pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 67946 | + u.aj.ctx.fErrorOrAux = 0; |
| 67947 | + if( u.aj.ctx.pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 67595 | 67948 | assert( pOp>aOp ); |
| 67596 | 67949 | assert( pOp[-1].p4type==P4_COLLSEQ ); |
| 67597 | 67950 | assert( pOp[-1].opcode==OP_CollSeq ); |
| 67598 | | - u.ai.ctx.pColl = pOp[-1].p4.pColl; |
| 67951 | + u.aj.ctx.pColl = pOp[-1].p4.pColl; |
| 67599 | 67952 | } |
| 67600 | 67953 | db->lastRowid = lastRowid; |
| 67601 | | - (*u.ai.ctx.pFunc->xFunc)(&u.ai.ctx, u.ai.n, u.ai.apVal); /* IMP: R-24505-23230 */ |
| 67954 | + (*u.aj.ctx.pFunc->xFunc)(&u.aj.ctx, u.aj.n, u.aj.apVal); /* IMP: R-24505-23230 */ |
| 67602 | 67955 | lastRowid = db->lastRowid; |
| 67603 | 67956 | |
| 67604 | 67957 | if( db->mallocFailed ){ |
| 67605 | 67958 | /* Even though a malloc() has failed, the implementation of the |
| 67606 | 67959 | ** user function may have called an sqlite3_result_XXX() function |
| 67607 | 67960 | ** to return a value. The following call releases any resources |
| 67608 | 67961 | ** associated with such a value. |
| 67609 | 67962 | */ |
| 67610 | | - sqlite3VdbeMemRelease(&u.ai.ctx.s); |
| 67963 | + sqlite3VdbeMemRelease(&u.aj.ctx.s); |
| 67611 | 67964 | goto no_mem; |
| 67612 | 67965 | } |
| 67613 | 67966 | |
| 67614 | 67967 | /* If the function returned an error, throw an exception */ |
| 67615 | | - if( u.ai.ctx.fErrorOrAux ){ |
| 67616 | | - if( u.ai.ctx.isError ){ |
| 67617 | | - sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&u.ai.ctx.s)); |
| 67618 | | - rc = u.ai.ctx.isError; |
| 67968 | + if( u.aj.ctx.fErrorOrAux ){ |
| 67969 | + if( u.aj.ctx.isError ){ |
| 67970 | + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&u.aj.ctx.s)); |
| 67971 | + rc = u.aj.ctx.isError; |
| 67619 | 67972 | } |
| 67620 | 67973 | sqlite3VdbeDeleteAuxData(p, pc, pOp->p1); |
| 67621 | 67974 | } |
| 67622 | 67975 | |
| 67623 | 67976 | /* Copy the result of the function into register P3 */ |
| 67624 | | - sqlite3VdbeChangeEncoding(&u.ai.ctx.s, encoding); |
| 67625 | | - sqlite3VdbeMemMove(pOut, &u.ai.ctx.s); |
| 67977 | + sqlite3VdbeChangeEncoding(&u.aj.ctx.s, encoding); |
| 67978 | + sqlite3VdbeMemMove(pOut, &u.aj.ctx.s); |
| 67626 | 67979 | if( sqlite3VdbeMemTooBig(pOut) ){ |
| 67627 | 67980 | goto too_big; |
| 67628 | 67981 | } |
| 67629 | 67982 | |
| 67630 | 67983 | #if 0 |
| | @@ -67639,29 +67992,33 @@ |
| 67639 | 67992 | UPDATE_MAX_BLOBSIZE(pOut); |
| 67640 | 67993 | break; |
| 67641 | 67994 | } |
| 67642 | 67995 | |
| 67643 | 67996 | /* Opcode: BitAnd P1 P2 P3 * * |
| 67997 | +** Synopsis: r[P3]=r[P1]&r[P2] |
| 67644 | 67998 | ** |
| 67645 | 67999 | ** Take the bit-wise AND of the values in register P1 and P2 and |
| 67646 | 68000 | ** store the result in register P3. |
| 67647 | 68001 | ** If either input is NULL, the result is NULL. |
| 67648 | 68002 | */ |
| 67649 | 68003 | /* Opcode: BitOr P1 P2 P3 * * |
| 68004 | +** Synopsis: r[P3]=r[P1]|r[P2] |
| 67650 | 68005 | ** |
| 67651 | 68006 | ** Take the bit-wise OR of the values in register P1 and P2 and |
| 67652 | 68007 | ** store the result in register P3. |
| 67653 | 68008 | ** If either input is NULL, the result is NULL. |
| 67654 | 68009 | */ |
| 67655 | 68010 | /* Opcode: ShiftLeft P1 P2 P3 * * |
| 68011 | +** Synopsis: r[P3]=r[P2]<<r[P1] |
| 67656 | 68012 | ** |
| 67657 | 68013 | ** Shift the integer value in register P2 to the left by the |
| 67658 | 68014 | ** number of bits specified by the integer in register P1. |
| 67659 | 68015 | ** Store the result in register P3. |
| 67660 | 68016 | ** If either input is NULL, the result is NULL. |
| 67661 | 68017 | */ |
| 67662 | 68018 | /* Opcode: ShiftRight P1 P2 P3 * * |
| 68019 | +** Synopsis: r[P3]=r[P2]>>r[P1] |
| 67663 | 68020 | ** |
| 67664 | 68021 | ** Shift the integer value in register P2 to the right by the |
| 67665 | 68022 | ** number of bits specified by the integer in register P1. |
| 67666 | 68023 | ** Store the result in register P3. |
| 67667 | 68024 | ** If either input is NULL, the result is NULL. |
| | @@ -67668,61 +68025,62 @@ |
| 67668 | 68025 | */ |
| 67669 | 68026 | case OP_BitAnd: /* same as TK_BITAND, in1, in2, out3 */ |
| 67670 | 68027 | case OP_BitOr: /* same as TK_BITOR, in1, in2, out3 */ |
| 67671 | 68028 | case OP_ShiftLeft: /* same as TK_LSHIFT, in1, in2, out3 */ |
| 67672 | 68029 | case OP_ShiftRight: { /* same as TK_RSHIFT, in1, in2, out3 */ |
| 67673 | | -#if 0 /* local variables moved into u.aj */ |
| 68030 | +#if 0 /* local variables moved into u.ak */ |
| 67674 | 68031 | i64 iA; |
| 67675 | 68032 | u64 uA; |
| 67676 | 68033 | i64 iB; |
| 67677 | 68034 | u8 op; |
| 67678 | | -#endif /* local variables moved into u.aj */ |
| 68035 | +#endif /* local variables moved into u.ak */ |
| 67679 | 68036 | |
| 67680 | 68037 | pIn1 = &aMem[pOp->p1]; |
| 67681 | 68038 | pIn2 = &aMem[pOp->p2]; |
| 67682 | 68039 | pOut = &aMem[pOp->p3]; |
| 67683 | 68040 | if( (pIn1->flags | pIn2->flags) & MEM_Null ){ |
| 67684 | 68041 | sqlite3VdbeMemSetNull(pOut); |
| 67685 | 68042 | break; |
| 67686 | 68043 | } |
| 67687 | | - u.aj.iA = sqlite3VdbeIntValue(pIn2); |
| 67688 | | - u.aj.iB = sqlite3VdbeIntValue(pIn1); |
| 67689 | | - u.aj.op = pOp->opcode; |
| 67690 | | - if( u.aj.op==OP_BitAnd ){ |
| 67691 | | - u.aj.iA &= u.aj.iB; |
| 67692 | | - }else if( u.aj.op==OP_BitOr ){ |
| 67693 | | - u.aj.iA |= u.aj.iB; |
| 67694 | | - }else if( u.aj.iB!=0 ){ |
| 67695 | | - assert( u.aj.op==OP_ShiftRight || u.aj.op==OP_ShiftLeft ); |
| 68044 | + u.ak.iA = sqlite3VdbeIntValue(pIn2); |
| 68045 | + u.ak.iB = sqlite3VdbeIntValue(pIn1); |
| 68046 | + u.ak.op = pOp->opcode; |
| 68047 | + if( u.ak.op==OP_BitAnd ){ |
| 68048 | + u.ak.iA &= u.ak.iB; |
| 68049 | + }else if( u.ak.op==OP_BitOr ){ |
| 68050 | + u.ak.iA |= u.ak.iB; |
| 68051 | + }else if( u.ak.iB!=0 ){ |
| 68052 | + assert( u.ak.op==OP_ShiftRight || u.ak.op==OP_ShiftLeft ); |
| 67696 | 68053 | |
| 67697 | 68054 | /* If shifting by a negative amount, shift in the other direction */ |
| 67698 | | - if( u.aj.iB<0 ){ |
| 68055 | + if( u.ak.iB<0 ){ |
| 67699 | 68056 | assert( OP_ShiftRight==OP_ShiftLeft+1 ); |
| 67700 | | - u.aj.op = 2*OP_ShiftLeft + 1 - u.aj.op; |
| 67701 | | - u.aj.iB = u.aj.iB>(-64) ? -u.aj.iB : 64; |
| 68057 | + u.ak.op = 2*OP_ShiftLeft + 1 - u.ak.op; |
| 68058 | + u.ak.iB = u.ak.iB>(-64) ? -u.ak.iB : 64; |
| 67702 | 68059 | } |
| 67703 | 68060 | |
| 67704 | | - if( u.aj.iB>=64 ){ |
| 67705 | | - u.aj.iA = (u.aj.iA>=0 || u.aj.op==OP_ShiftLeft) ? 0 : -1; |
| 67706 | | - }else{ |
| 67707 | | - memcpy(&u.aj.uA, &u.aj.iA, sizeof(u.aj.uA)); |
| 67708 | | - if( u.aj.op==OP_ShiftLeft ){ |
| 67709 | | - u.aj.uA <<= u.aj.iB; |
| 67710 | | - }else{ |
| 67711 | | - u.aj.uA >>= u.aj.iB; |
| 68061 | + if( u.ak.iB>=64 ){ |
| 68062 | + u.ak.iA = (u.ak.iA>=0 || u.ak.op==OP_ShiftLeft) ? 0 : -1; |
| 68063 | + }else{ |
| 68064 | + memcpy(&u.ak.uA, &u.ak.iA, sizeof(u.ak.uA)); |
| 68065 | + if( u.ak.op==OP_ShiftLeft ){ |
| 68066 | + u.ak.uA <<= u.ak.iB; |
| 68067 | + }else{ |
| 68068 | + u.ak.uA >>= u.ak.iB; |
| 67712 | 68069 | /* Sign-extend on a right shift of a negative number */ |
| 67713 | | - if( u.aj.iA<0 ) u.aj.uA |= ((((u64)0xffffffff)<<32)|0xffffffff) << (64-u.aj.iB); |
| 68070 | + if( u.ak.iA<0 ) u.ak.uA |= ((((u64)0xffffffff)<<32)|0xffffffff) << (64-u.ak.iB); |
| 67714 | 68071 | } |
| 67715 | | - memcpy(&u.aj.iA, &u.aj.uA, sizeof(u.aj.iA)); |
| 68072 | + memcpy(&u.ak.iA, &u.ak.uA, sizeof(u.ak.iA)); |
| 67716 | 68073 | } |
| 67717 | 68074 | } |
| 67718 | | - pOut->u.i = u.aj.iA; |
| 68075 | + pOut->u.i = u.ak.iA; |
| 67719 | 68076 | MemSetTypeFlag(pOut, MEM_Int); |
| 67720 | 68077 | break; |
| 67721 | 68078 | } |
| 67722 | 68079 | |
| 67723 | 68080 | /* Opcode: AddImm P1 P2 * * * |
| 68081 | +** Synopsis: r[P1]=r[P1]+P2 |
| 67724 | 68082 | ** |
| 67725 | 68083 | ** Add the constant P2 to the value in register P1. |
| 67726 | 68084 | ** The result is always an integer. |
| 67727 | 68085 | ** |
| 67728 | 68086 | ** To force any register to be an integer, just add 0. |
| | @@ -67877,10 +68235,11 @@ |
| 67877 | 68235 | break; |
| 67878 | 68236 | } |
| 67879 | 68237 | #endif /* !defined(SQLITE_OMIT_CAST) && !defined(SQLITE_OMIT_FLOATING_POINT) */ |
| 67880 | 68238 | |
| 67881 | 68239 | /* Opcode: Lt P1 P2 P3 P4 P5 |
| 68240 | +** Synopsis: if r[P1]<r[P3] goto P3 |
| 67882 | 68241 | ** |
| 67883 | 68242 | ** Compare the values in register P1 and P3. If reg(P3)<reg(P1) then |
| 67884 | 68243 | ** jump to address P2. |
| 67885 | 68244 | ** |
| 67886 | 68245 | ** If the SQLITE_JUMPIFNULL bit of P5 is set and either reg(P1) or |
| | @@ -67911,10 +68270,11 @@ |
| 67911 | 68270 | ** If the SQLITE_NULLEQ bit is set in P5, then NULL values are considered |
| 67912 | 68271 | ** equal to one another, provided that they do not have their MEM_Cleared |
| 67913 | 68272 | ** bit set. |
| 67914 | 68273 | */ |
| 67915 | 68274 | /* Opcode: Ne P1 P2 P3 P4 P5 |
| 68275 | +** Synopsis: if r[P1]!=r[P3] goto P2 |
| 67916 | 68276 | ** |
| 67917 | 68277 | ** This works just like the Lt opcode except that the jump is taken if |
| 67918 | 68278 | ** the operands in registers P1 and P3 are not equal. See the Lt opcode for |
| 67919 | 68279 | ** additional information. |
| 67920 | 68280 | ** |
| | @@ -67923,10 +68283,11 @@ |
| 67923 | 68283 | ** of comparison is false. If either operand is NULL then the result is true. |
| 67924 | 68284 | ** If neither operand is NULL the result is the same as it would be if |
| 67925 | 68285 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 67926 | 68286 | */ |
| 67927 | 68287 | /* Opcode: Eq P1 P2 P3 P4 P5 |
| 68288 | +** Synopsis: if r[P1]==r[P3] goto P2 |
| 67928 | 68289 | ** |
| 67929 | 68290 | ** This works just like the Lt opcode except that the jump is taken if |
| 67930 | 68291 | ** the operands in registers P1 and P3 are equal. |
| 67931 | 68292 | ** See the Lt opcode for additional information. |
| 67932 | 68293 | ** |
| | @@ -67935,22 +68296,25 @@ |
| 67935 | 68296 | ** of comparison is true. If either operand is NULL then the result is false. |
| 67936 | 68297 | ** If neither operand is NULL the result is the same as it would be if |
| 67937 | 68298 | ** the SQLITE_NULLEQ flag were omitted from P5. |
| 67938 | 68299 | */ |
| 67939 | 68300 | /* Opcode: Le P1 P2 P3 P4 P5 |
| 68301 | +** Synopsis: if r[P1]<=r[P3] goto P2 |
| 67940 | 68302 | ** |
| 67941 | 68303 | ** This works just like the Lt opcode except that the jump is taken if |
| 67942 | 68304 | ** the content of register P3 is less than or equal to the content of |
| 67943 | 68305 | ** register P1. See the Lt opcode for additional information. |
| 67944 | 68306 | */ |
| 67945 | 68307 | /* Opcode: Gt P1 P2 P3 P4 P5 |
| 68308 | +** Synopsis: if r[P1]>r[P3] goto P2 |
| 67946 | 68309 | ** |
| 67947 | 68310 | ** This works just like the Lt opcode except that the jump is taken if |
| 67948 | 68311 | ** the content of register P3 is greater than the content of |
| 67949 | 68312 | ** register P1. See the Lt opcode for additional information. |
| 67950 | 68313 | */ |
| 67951 | 68314 | /* Opcode: Ge P1 P2 P3 P4 P5 |
| 68315 | +** Synopsis: if r[P1]>=r[P3] goto P2 |
| 67952 | 68316 | ** |
| 67953 | 68317 | ** This works just like the Lt opcode except that the jump is taken if |
| 67954 | 68318 | ** the content of register P3 is greater than or equal to the content of |
| 67955 | 68319 | ** register P1. See the Lt opcode for additional information. |
| 67956 | 68320 | */ |
| | @@ -67958,37 +68322,37 @@ |
| 67958 | 68322 | case OP_Ne: /* same as TK_NE, jump, in1, in3 */ |
| 67959 | 68323 | case OP_Lt: /* same as TK_LT, jump, in1, in3 */ |
| 67960 | 68324 | case OP_Le: /* same as TK_LE, jump, in1, in3 */ |
| 67961 | 68325 | case OP_Gt: /* same as TK_GT, jump, in1, in3 */ |
| 67962 | 68326 | case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ |
| 67963 | | -#if 0 /* local variables moved into u.ak */ |
| 68327 | +#if 0 /* local variables moved into u.al */ |
| 67964 | 68328 | int res; /* Result of the comparison of pIn1 against pIn3 */ |
| 67965 | 68329 | char affinity; /* Affinity to use for comparison */ |
| 67966 | 68330 | u16 flags1; /* Copy of initial value of pIn1->flags */ |
| 67967 | 68331 | u16 flags3; /* Copy of initial value of pIn3->flags */ |
| 67968 | | -#endif /* local variables moved into u.ak */ |
| 68332 | +#endif /* local variables moved into u.al */ |
| 67969 | 68333 | |
| 67970 | 68334 | pIn1 = &aMem[pOp->p1]; |
| 67971 | 68335 | pIn3 = &aMem[pOp->p3]; |
| 67972 | | - u.ak.flags1 = pIn1->flags; |
| 67973 | | - u.ak.flags3 = pIn3->flags; |
| 67974 | | - if( (u.ak.flags1 | u.ak.flags3)&MEM_Null ){ |
| 68336 | + u.al.flags1 = pIn1->flags; |
| 68337 | + u.al.flags3 = pIn3->flags; |
| 68338 | + if( (u.al.flags1 | u.al.flags3)&MEM_Null ){ |
| 67975 | 68339 | /* One or both operands are NULL */ |
| 67976 | 68340 | if( pOp->p5 & SQLITE_NULLEQ ){ |
| 67977 | 68341 | /* If SQLITE_NULLEQ is set (which will only happen if the operator is |
| 67978 | 68342 | ** OP_Eq or OP_Ne) then take the jump or not depending on whether |
| 67979 | 68343 | ** or not both operands are null. |
| 67980 | 68344 | */ |
| 67981 | 68345 | assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne ); |
| 67982 | | - assert( (u.ak.flags1 & MEM_Cleared)==0 ); |
| 67983 | | - if( (u.ak.flags1&MEM_Null)!=0 |
| 67984 | | - && (u.ak.flags3&MEM_Null)!=0 |
| 67985 | | - && (u.ak.flags3&MEM_Cleared)==0 |
| 68346 | + assert( (u.al.flags1 & MEM_Cleared)==0 ); |
| 68347 | + if( (u.al.flags1&MEM_Null)!=0 |
| 68348 | + && (u.al.flags3&MEM_Null)!=0 |
| 68349 | + && (u.al.flags3&MEM_Cleared)==0 |
| 67986 | 68350 | ){ |
| 67987 | | - u.ak.res = 0; /* Results are equal */ |
| 68351 | + u.al.res = 0; /* Results are equal */ |
| 67988 | 68352 | }else{ |
| 67989 | | - u.ak.res = 1; /* Results are not equal */ |
| 68353 | + u.al.res = 1; /* Results are not equal */ |
| 67990 | 68354 | } |
| 67991 | 68355 | }else{ |
| 67992 | 68356 | /* SQLITE_NULLEQ is clear and at least one operand is NULL, |
| 67993 | 68357 | ** then the result is always NULL. |
| 67994 | 68358 | ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. |
| | @@ -68002,44 +68366,44 @@ |
| 68002 | 68366 | } |
| 68003 | 68367 | break; |
| 68004 | 68368 | } |
| 68005 | 68369 | }else{ |
| 68006 | 68370 | /* Neither operand is NULL. Do a comparison. */ |
| 68007 | | - u.ak.affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 68008 | | - if( u.ak.affinity ){ |
| 68009 | | - applyAffinity(pIn1, u.ak.affinity, encoding); |
| 68010 | | - applyAffinity(pIn3, u.ak.affinity, encoding); |
| 68371 | + u.al.affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 68372 | + if( u.al.affinity ){ |
| 68373 | + applyAffinity(pIn1, u.al.affinity, encoding); |
| 68374 | + applyAffinity(pIn3, u.al.affinity, encoding); |
| 68011 | 68375 | if( db->mallocFailed ) goto no_mem; |
| 68012 | 68376 | } |
| 68013 | 68377 | |
| 68014 | 68378 | assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 ); |
| 68015 | 68379 | ExpandBlob(pIn1); |
| 68016 | 68380 | ExpandBlob(pIn3); |
| 68017 | | - u.ak.res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); |
| 68381 | + u.al.res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl); |
| 68018 | 68382 | } |
| 68019 | 68383 | switch( pOp->opcode ){ |
| 68020 | | - case OP_Eq: u.ak.res = u.ak.res==0; break; |
| 68021 | | - case OP_Ne: u.ak.res = u.ak.res!=0; break; |
| 68022 | | - case OP_Lt: u.ak.res = u.ak.res<0; break; |
| 68023 | | - case OP_Le: u.ak.res = u.ak.res<=0; break; |
| 68024 | | - case OP_Gt: u.ak.res = u.ak.res>0; break; |
| 68025 | | - default: u.ak.res = u.ak.res>=0; break; |
| 68384 | + case OP_Eq: u.al.res = u.al.res==0; break; |
| 68385 | + case OP_Ne: u.al.res = u.al.res!=0; break; |
| 68386 | + case OP_Lt: u.al.res = u.al.res<0; break; |
| 68387 | + case OP_Le: u.al.res = u.al.res<=0; break; |
| 68388 | + case OP_Gt: u.al.res = u.al.res>0; break; |
| 68389 | + default: u.al.res = u.al.res>=0; break; |
| 68026 | 68390 | } |
| 68027 | 68391 | |
| 68028 | 68392 | if( pOp->p5 & SQLITE_STOREP2 ){ |
| 68029 | 68393 | pOut = &aMem[pOp->p2]; |
| 68030 | 68394 | memAboutToChange(p, pOut); |
| 68031 | 68395 | MemSetTypeFlag(pOut, MEM_Int); |
| 68032 | | - pOut->u.i = u.ak.res; |
| 68396 | + pOut->u.i = u.al.res; |
| 68033 | 68397 | REGISTER_TRACE(pOp->p2, pOut); |
| 68034 | | - }else if( u.ak.res ){ |
| 68398 | + }else if( u.al.res ){ |
| 68035 | 68399 | pc = pOp->p2-1; |
| 68036 | 68400 | } |
| 68037 | 68401 | |
| 68038 | 68402 | /* Undo any changes made by applyAffinity() to the input registers. */ |
| 68039 | | - pIn1->flags = (pIn1->flags&~MEM_TypeMask) | (u.ak.flags1&MEM_TypeMask); |
| 68040 | | - pIn3->flags = (pIn3->flags&~MEM_TypeMask) | (u.ak.flags3&MEM_TypeMask); |
| 68403 | + pIn1->flags = (pIn1->flags&~MEM_TypeMask) | (u.al.flags1&MEM_TypeMask); |
| 68404 | + pIn3->flags = (pIn3->flags&~MEM_TypeMask) | (u.al.flags3&MEM_TypeMask); |
| 68041 | 68405 | break; |
| 68042 | 68406 | } |
| 68043 | 68407 | |
| 68044 | 68408 | /* Opcode: Permutation * * * P4 * |
| 68045 | 68409 | ** |
| | @@ -68075,51 +68439,51 @@ |
| 68075 | 68439 | ** The comparison is a sort comparison, so NULLs compare equal, |
| 68076 | 68440 | ** NULLs are less than numbers, numbers are less than strings, |
| 68077 | 68441 | ** and strings are less than blobs. |
| 68078 | 68442 | */ |
| 68079 | 68443 | case OP_Compare: { |
| 68080 | | -#if 0 /* local variables moved into u.al */ |
| 68444 | +#if 0 /* local variables moved into u.am */ |
| 68081 | 68445 | int n; |
| 68082 | 68446 | int i; |
| 68083 | 68447 | int p1; |
| 68084 | 68448 | int p2; |
| 68085 | 68449 | const KeyInfo *pKeyInfo; |
| 68086 | 68450 | int idx; |
| 68087 | 68451 | CollSeq *pColl; /* Collating sequence to use on this term */ |
| 68088 | 68452 | int bRev; /* True for DESCENDING sort order */ |
| 68089 | | -#endif /* local variables moved into u.al */ |
| 68453 | +#endif /* local variables moved into u.am */ |
| 68090 | 68454 | |
| 68091 | 68455 | if( (pOp->p5 & OPFLAG_PERMUTE)==0 ) aPermute = 0; |
| 68092 | | - u.al.n = pOp->p3; |
| 68093 | | - u.al.pKeyInfo = pOp->p4.pKeyInfo; |
| 68094 | | - assert( u.al.n>0 ); |
| 68095 | | - assert( u.al.pKeyInfo!=0 ); |
| 68096 | | - u.al.p1 = pOp->p1; |
| 68097 | | - u.al.p2 = pOp->p2; |
| 68456 | + u.am.n = pOp->p3; |
| 68457 | + u.am.pKeyInfo = pOp->p4.pKeyInfo; |
| 68458 | + assert( u.am.n>0 ); |
| 68459 | + assert( u.am.pKeyInfo!=0 ); |
| 68460 | + u.am.p1 = pOp->p1; |
| 68461 | + u.am.p2 = pOp->p2; |
| 68098 | 68462 | #if SQLITE_DEBUG |
| 68099 | 68463 | if( aPermute ){ |
| 68100 | 68464 | int k, mx = 0; |
| 68101 | | - for(k=0; k<u.al.n; k++) if( aPermute[k]>mx ) mx = aPermute[k]; |
| 68102 | | - assert( u.al.p1>0 && u.al.p1+mx<=(p->nMem-p->nCursor)+1 ); |
| 68103 | | - assert( u.al.p2>0 && u.al.p2+mx<=(p->nMem-p->nCursor)+1 ); |
| 68465 | + for(k=0; k<u.am.n; k++) if( aPermute[k]>mx ) mx = aPermute[k]; |
| 68466 | + assert( u.am.p1>0 && u.am.p1+mx<=(p->nMem-p->nCursor)+1 ); |
| 68467 | + assert( u.am.p2>0 && u.am.p2+mx<=(p->nMem-p->nCursor)+1 ); |
| 68104 | 68468 | }else{ |
| 68105 | | - assert( u.al.p1>0 && u.al.p1+u.al.n<=(p->nMem-p->nCursor)+1 ); |
| 68106 | | - assert( u.al.p2>0 && u.al.p2+u.al.n<=(p->nMem-p->nCursor)+1 ); |
| 68469 | + assert( u.am.p1>0 && u.am.p1+u.am.n<=(p->nMem-p->nCursor)+1 ); |
| 68470 | + assert( u.am.p2>0 && u.am.p2+u.am.n<=(p->nMem-p->nCursor)+1 ); |
| 68107 | 68471 | } |
| 68108 | 68472 | #endif /* SQLITE_DEBUG */ |
| 68109 | | - for(u.al.i=0; u.al.i<u.al.n; u.al.i++){ |
| 68110 | | - u.al.idx = aPermute ? aPermute[u.al.i] : u.al.i; |
| 68111 | | - assert( memIsValid(&aMem[u.al.p1+u.al.idx]) ); |
| 68112 | | - assert( memIsValid(&aMem[u.al.p2+u.al.idx]) ); |
| 68113 | | - REGISTER_TRACE(u.al.p1+u.al.idx, &aMem[u.al.p1+u.al.idx]); |
| 68114 | | - REGISTER_TRACE(u.al.p2+u.al.idx, &aMem[u.al.p2+u.al.idx]); |
| 68115 | | - assert( u.al.i<u.al.pKeyInfo->nField ); |
| 68116 | | - u.al.pColl = u.al.pKeyInfo->aColl[u.al.i]; |
| 68117 | | - u.al.bRev = u.al.pKeyInfo->aSortOrder[u.al.i]; |
| 68118 | | - iCompare = sqlite3MemCompare(&aMem[u.al.p1+u.al.idx], &aMem[u.al.p2+u.al.idx], u.al.pColl); |
| 68473 | + for(u.am.i=0; u.am.i<u.am.n; u.am.i++){ |
| 68474 | + u.am.idx = aPermute ? aPermute[u.am.i] : u.am.i; |
| 68475 | + assert( memIsValid(&aMem[u.am.p1+u.am.idx]) ); |
| 68476 | + assert( memIsValid(&aMem[u.am.p2+u.am.idx]) ); |
| 68477 | + REGISTER_TRACE(u.am.p1+u.am.idx, &aMem[u.am.p1+u.am.idx]); |
| 68478 | + REGISTER_TRACE(u.am.p2+u.am.idx, &aMem[u.am.p2+u.am.idx]); |
| 68479 | + assert( u.am.i<u.am.pKeyInfo->nField ); |
| 68480 | + u.am.pColl = u.am.pKeyInfo->aColl[u.am.i]; |
| 68481 | + u.am.bRev = u.am.pKeyInfo->aSortOrder[u.am.i]; |
| 68482 | + iCompare = sqlite3MemCompare(&aMem[u.am.p1+u.am.idx], &aMem[u.am.p2+u.am.idx], u.am.pColl); |
| 68119 | 68483 | if( iCompare ){ |
| 68120 | | - if( u.al.bRev ) iCompare = -iCompare; |
| 68484 | + if( u.am.bRev ) iCompare = -iCompare; |
| 68121 | 68485 | break; |
| 68122 | 68486 | } |
| 68123 | 68487 | } |
| 68124 | 68488 | aPermute = 0; |
| 68125 | 68489 | break; |
| | @@ -68141,19 +68505,21 @@ |
| 68141 | 68505 | } |
| 68142 | 68506 | break; |
| 68143 | 68507 | } |
| 68144 | 68508 | |
| 68145 | 68509 | /* Opcode: And P1 P2 P3 * * |
| 68510 | +** Synopsis: r[P3]=(r[P1] && r[P2]) |
| 68146 | 68511 | ** |
| 68147 | 68512 | ** Take the logical AND of the values in registers P1 and P2 and |
| 68148 | 68513 | ** write the result into register P3. |
| 68149 | 68514 | ** |
| 68150 | 68515 | ** If either P1 or P2 is 0 (false) then the result is 0 even if |
| 68151 | 68516 | ** the other input is NULL. A NULL and true or two NULLs give |
| 68152 | 68517 | ** a NULL output. |
| 68153 | 68518 | */ |
| 68154 | 68519 | /* Opcode: Or P1 P2 P3 * * |
| 68520 | +** Synopsis: r[P3]=(r[P1] || r[P2]) |
| 68155 | 68521 | ** |
| 68156 | 68522 | ** Take the logical OR of the values in register P1 and P2 and |
| 68157 | 68523 | ** store the answer in register P3. |
| 68158 | 68524 | ** |
| 68159 | 68525 | ** If either P1 or P2 is nonzero (true) then the result is 1 (true) |
| | @@ -68160,45 +68526,46 @@ |
| 68160 | 68526 | ** even if the other input is NULL. A NULL and false or two NULLs |
| 68161 | 68527 | ** give a NULL output. |
| 68162 | 68528 | */ |
| 68163 | 68529 | case OP_And: /* same as TK_AND, in1, in2, out3 */ |
| 68164 | 68530 | case OP_Or: { /* same as TK_OR, in1, in2, out3 */ |
| 68165 | | -#if 0 /* local variables moved into u.am */ |
| 68531 | +#if 0 /* local variables moved into u.an */ |
| 68166 | 68532 | int v1; /* Left operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ |
| 68167 | 68533 | int v2; /* Right operand: 0==FALSE, 1==TRUE, 2==UNKNOWN or NULL */ |
| 68168 | | -#endif /* local variables moved into u.am */ |
| 68534 | +#endif /* local variables moved into u.an */ |
| 68169 | 68535 | |
| 68170 | 68536 | pIn1 = &aMem[pOp->p1]; |
| 68171 | 68537 | if( pIn1->flags & MEM_Null ){ |
| 68172 | | - u.am.v1 = 2; |
| 68538 | + u.an.v1 = 2; |
| 68173 | 68539 | }else{ |
| 68174 | | - u.am.v1 = sqlite3VdbeIntValue(pIn1)!=0; |
| 68540 | + u.an.v1 = sqlite3VdbeIntValue(pIn1)!=0; |
| 68175 | 68541 | } |
| 68176 | 68542 | pIn2 = &aMem[pOp->p2]; |
| 68177 | 68543 | if( pIn2->flags & MEM_Null ){ |
| 68178 | | - u.am.v2 = 2; |
| 68544 | + u.an.v2 = 2; |
| 68179 | 68545 | }else{ |
| 68180 | | - u.am.v2 = sqlite3VdbeIntValue(pIn2)!=0; |
| 68546 | + u.an.v2 = sqlite3VdbeIntValue(pIn2)!=0; |
| 68181 | 68547 | } |
| 68182 | 68548 | if( pOp->opcode==OP_And ){ |
| 68183 | 68549 | static const unsigned char and_logic[] = { 0, 0, 0, 0, 1, 2, 0, 2, 2 }; |
| 68184 | | - u.am.v1 = and_logic[u.am.v1*3+u.am.v2]; |
| 68550 | + u.an.v1 = and_logic[u.an.v1*3+u.an.v2]; |
| 68185 | 68551 | }else{ |
| 68186 | 68552 | static const unsigned char or_logic[] = { 0, 1, 2, 1, 1, 1, 2, 1, 2 }; |
| 68187 | | - u.am.v1 = or_logic[u.am.v1*3+u.am.v2]; |
| 68553 | + u.an.v1 = or_logic[u.an.v1*3+u.an.v2]; |
| 68188 | 68554 | } |
| 68189 | 68555 | pOut = &aMem[pOp->p3]; |
| 68190 | | - if( u.am.v1==2 ){ |
| 68556 | + if( u.an.v1==2 ){ |
| 68191 | 68557 | MemSetTypeFlag(pOut, MEM_Null); |
| 68192 | 68558 | }else{ |
| 68193 | | - pOut->u.i = u.am.v1; |
| 68559 | + pOut->u.i = u.an.v1; |
| 68194 | 68560 | MemSetTypeFlag(pOut, MEM_Int); |
| 68195 | 68561 | } |
| 68196 | 68562 | break; |
| 68197 | 68563 | } |
| 68198 | 68564 | |
| 68199 | 68565 | /* Opcode: Not P1 P2 * * * |
| 68566 | +** Synopsis: r[P2]= !r[P1] |
| 68200 | 68567 | ** |
| 68201 | 68568 | ** Interpret the value in register P1 as a boolean value. Store the |
| 68202 | 68569 | ** boolean complement in register P2. If the value in register P1 is |
| 68203 | 68570 | ** NULL, then a NULL is stored in P2. |
| 68204 | 68571 | */ |
| | @@ -68212,10 +68579,11 @@ |
| 68212 | 68579 | } |
| 68213 | 68580 | break; |
| 68214 | 68581 | } |
| 68215 | 68582 | |
| 68216 | 68583 | /* Opcode: BitNot P1 P2 * * * |
| 68584 | +** Synopsis: r[P1]= ~r[P1] |
| 68217 | 68585 | ** |
| 68218 | 68586 | ** Interpret the content of register P1 as an integer. Store the |
| 68219 | 68587 | ** ones-complement of the P1 value into register P2. If P1 holds |
| 68220 | 68588 | ** a NULL then store a NULL in P2. |
| 68221 | 68589 | */ |
| | @@ -68257,31 +68625,32 @@ |
| 68257 | 68625 | ** is considered false if it has a numeric value of zero. If the value |
| 68258 | 68626 | ** in P1 is NULL then take the jump if P3 is zero. |
| 68259 | 68627 | */ |
| 68260 | 68628 | case OP_If: /* jump, in1 */ |
| 68261 | 68629 | case OP_IfNot: { /* jump, in1 */ |
| 68262 | | -#if 0 /* local variables moved into u.an */ |
| 68630 | +#if 0 /* local variables moved into u.ao */ |
| 68263 | 68631 | int c; |
| 68264 | | -#endif /* local variables moved into u.an */ |
| 68632 | +#endif /* local variables moved into u.ao */ |
| 68265 | 68633 | pIn1 = &aMem[pOp->p1]; |
| 68266 | 68634 | if( pIn1->flags & MEM_Null ){ |
| 68267 | | - u.an.c = pOp->p3; |
| 68635 | + u.ao.c = pOp->p3; |
| 68268 | 68636 | }else{ |
| 68269 | 68637 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 68270 | | - u.an.c = sqlite3VdbeIntValue(pIn1)!=0; |
| 68638 | + u.ao.c = sqlite3VdbeIntValue(pIn1)!=0; |
| 68271 | 68639 | #else |
| 68272 | | - u.an.c = sqlite3VdbeRealValue(pIn1)!=0.0; |
| 68640 | + u.ao.c = sqlite3VdbeRealValue(pIn1)!=0.0; |
| 68273 | 68641 | #endif |
| 68274 | | - if( pOp->opcode==OP_IfNot ) u.an.c = !u.an.c; |
| 68642 | + if( pOp->opcode==OP_IfNot ) u.ao.c = !u.ao.c; |
| 68275 | 68643 | } |
| 68276 | | - if( u.an.c ){ |
| 68644 | + if( u.ao.c ){ |
| 68277 | 68645 | pc = pOp->p2-1; |
| 68278 | 68646 | } |
| 68279 | 68647 | break; |
| 68280 | 68648 | } |
| 68281 | 68649 | |
| 68282 | 68650 | /* Opcode: IsNull P1 P2 * * * |
| 68651 | +** Synopsis: if r[P1]==NULL goto P2 |
| 68283 | 68652 | ** |
| 68284 | 68653 | ** Jump to P2 if the value in register P1 is NULL. |
| 68285 | 68654 | */ |
| 68286 | 68655 | case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */ |
| 68287 | 68656 | pIn1 = &aMem[pOp->p1]; |
| | @@ -68290,10 +68659,11 @@ |
| 68290 | 68659 | } |
| 68291 | 68660 | break; |
| 68292 | 68661 | } |
| 68293 | 68662 | |
| 68294 | 68663 | /* Opcode: NotNull P1 P2 * * * |
| 68664 | +** Synopsis: if r[P1]!=NULL goto P2 |
| 68295 | 68665 | ** |
| 68296 | 68666 | ** Jump to P2 if the value in register P1 is not NULL. |
| 68297 | 68667 | */ |
| 68298 | 68668 | case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */ |
| 68299 | 68669 | pIn1 = &aMem[pOp->p1]; |
| | @@ -68302,10 +68672,11 @@ |
| 68302 | 68672 | } |
| 68303 | 68673 | break; |
| 68304 | 68674 | } |
| 68305 | 68675 | |
| 68306 | 68676 | /* Opcode: Column P1 P2 P3 P4 P5 |
| 68677 | +** Synopsis: r[P3]=PX |
| 68307 | 68678 | ** |
| 68308 | 68679 | ** Interpret the data that cursor P1 points to as a structure built using |
| 68309 | 68680 | ** the MakeRecord instruction. (See the MakeRecord opcode for additional |
| 68310 | 68681 | ** information about the format of the data.) Extract the P2-th column |
| 68311 | 68682 | ** from this record. If there are less that (P2+1) |
| | @@ -68326,11 +68697,11 @@ |
| 68326 | 68697 | ** the result is guaranteed to only be used as the argument of a length() |
| 68327 | 68698 | ** or typeof() function, respectively. The loading of large blobs can be |
| 68328 | 68699 | ** skipped for length() and all content loading can be skipped for typeof(). |
| 68329 | 68700 | */ |
| 68330 | 68701 | case OP_Column: { |
| 68331 | | -#if 0 /* local variables moved into u.ao */ |
| 68702 | +#if 0 /* local variables moved into u.ap */ |
| 68332 | 68703 | u32 payloadSize; /* Number of bytes in the record */ |
| 68333 | 68704 | i64 payloadSize64; /* Number of bytes in the record */ |
| 68334 | 68705 | int p1; /* P1 value of the opcode */ |
| 68335 | 68706 | int p2; /* column number to retrieve */ |
| 68336 | 68707 | VdbeCursor *pC; /* The VDBE cursor */ |
| | @@ -68350,135 +68721,133 @@ |
| 68350 | 68721 | u32 szField; /* Number of bytes in the content of a field */ |
| 68351 | 68722 | int szHdr; /* Size of the header size field at start of record */ |
| 68352 | 68723 | int avail; /* Number of bytes of available data */ |
| 68353 | 68724 | u32 t; /* A type code from the record header */ |
| 68354 | 68725 | Mem *pReg; /* PseudoTable input register */ |
| 68355 | | -#endif /* local variables moved into u.ao */ |
| 68726 | +#endif /* local variables moved into u.ap */ |
| 68356 | 68727 | |
| 68357 | 68728 | |
| 68358 | | - u.ao.p1 = pOp->p1; |
| 68359 | | - u.ao.p2 = pOp->p2; |
| 68360 | | - u.ao.pC = 0; |
| 68361 | | - memset(&u.ao.sMem, 0, sizeof(u.ao.sMem)); |
| 68362 | | - assert( u.ao.p1<p->nCursor ); |
| 68729 | + u.ap.p1 = pOp->p1; |
| 68730 | + u.ap.p2 = pOp->p2; |
| 68731 | + u.ap.pC = 0; |
| 68732 | + memset(&u.ap.sMem, 0, sizeof(u.ap.sMem)); |
| 68733 | + assert( u.ap.p1<p->nCursor ); |
| 68363 | 68734 | assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) ); |
| 68364 | | - u.ao.pDest = &aMem[pOp->p3]; |
| 68365 | | - memAboutToChange(p, u.ao.pDest); |
| 68366 | | - u.ao.zRec = 0; |
| 68735 | + u.ap.pDest = &aMem[pOp->p3]; |
| 68736 | + memAboutToChange(p, u.ap.pDest); |
| 68737 | + u.ap.zRec = 0; |
| 68367 | 68738 | |
| 68368 | | - /* This block sets the variable u.ao.payloadSize to be the total number of |
| 68739 | + /* This block sets the variable u.ap.payloadSize to be the total number of |
| 68369 | 68740 | ** bytes in the record. |
| 68370 | 68741 | ** |
| 68371 | | - ** u.ao.zRec is set to be the complete text of the record if it is available. |
| 68742 | + ** u.ap.zRec is set to be the complete text of the record if it is available. |
| 68372 | 68743 | ** The complete record text is always available for pseudo-tables |
| 68373 | 68744 | ** If the record is stored in a cursor, the complete record text |
| 68374 | | - ** might be available in the u.ao.pC->aRow cache. Or it might not be. |
| 68375 | | - ** If the data is unavailable, u.ao.zRec is set to NULL. |
| 68745 | + ** might be available in the u.ap.pC->aRow cache. Or it might not be. |
| 68746 | + ** If the data is unavailable, u.ap.zRec is set to NULL. |
| 68376 | 68747 | ** |
| 68377 | 68748 | ** We also compute the number of columns in the record. For cursors, |
| 68378 | 68749 | ** the number of columns is stored in the VdbeCursor.nField element. |
| 68379 | 68750 | */ |
| 68380 | | - u.ao.pC = p->apCsr[u.ao.p1]; |
| 68381 | | - assert( u.ao.pC!=0 ); |
| 68751 | + u.ap.pC = p->apCsr[u.ap.p1]; |
| 68752 | + assert( u.ap.pC!=0 ); |
| 68382 | 68753 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 68383 | | - assert( u.ao.pC->pVtabCursor==0 ); |
| 68754 | + assert( u.ap.pC->pVtabCursor==0 ); |
| 68384 | 68755 | #endif |
| 68385 | | - u.ao.pCrsr = u.ao.pC->pCursor; |
| 68386 | | - if( u.ao.pCrsr!=0 ){ |
| 68756 | + u.ap.pCrsr = u.ap.pC->pCursor; |
| 68757 | + if( u.ap.pCrsr!=0 ){ |
| 68387 | 68758 | /* The record is stored in a B-Tree */ |
| 68388 | | - rc = sqlite3VdbeCursorMoveto(u.ao.pC); |
| 68759 | + rc = sqlite3VdbeCursorMoveto(u.ap.pC); |
| 68389 | 68760 | if( rc ) goto abort_due_to_error; |
| 68390 | | - if( u.ao.pC->nullRow ){ |
| 68391 | | - u.ao.payloadSize = 0; |
| 68392 | | - }else if( u.ao.pC->cacheStatus==p->cacheCtr ){ |
| 68393 | | - u.ao.payloadSize = u.ao.pC->payloadSize; |
| 68394 | | - u.ao.zRec = (char*)u.ao.pC->aRow; |
| 68395 | | - }else if( u.ao.pC->isIndex ){ |
| 68396 | | - assert( sqlite3BtreeCursorIsValid(u.ao.pCrsr) ); |
| 68397 | | - VVA_ONLY(rc =) sqlite3BtreeKeySize(u.ao.pCrsr, &u.ao.payloadSize64); |
| 68761 | + if( u.ap.pC->nullRow ){ |
| 68762 | + u.ap.payloadSize = 0; |
| 68763 | + }else if( u.ap.pC->cacheStatus==p->cacheCtr ){ |
| 68764 | + u.ap.payloadSize = u.ap.pC->payloadSize; |
| 68765 | + u.ap.zRec = (char*)u.ap.pC->aRow; |
| 68766 | + }else if( u.ap.pC->isIndex ){ |
| 68767 | + assert( sqlite3BtreeCursorIsValid(u.ap.pCrsr) ); |
| 68768 | + VVA_ONLY(rc =) sqlite3BtreeKeySize(u.ap.pCrsr, &u.ap.payloadSize64); |
| 68398 | 68769 | assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */ |
| 68399 | 68770 | /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the |
| 68400 | | - ** payload size, so it is impossible for u.ao.payloadSize64 to be |
| 68771 | + ** payload size, so it is impossible for u.ap.payloadSize64 to be |
| 68401 | 68772 | ** larger than 32 bits. */ |
| 68402 | | - assert( (u.ao.payloadSize64 & SQLITE_MAX_U32)==(u64)u.ao.payloadSize64 ); |
| 68403 | | - u.ao.payloadSize = (u32)u.ao.payloadSize64; |
| 68773 | + assert( (u.ap.payloadSize64 & SQLITE_MAX_U32)==(u64)u.ap.payloadSize64 ); |
| 68774 | + u.ap.payloadSize = (u32)u.ap.payloadSize64; |
| 68404 | 68775 | }else{ |
| 68405 | | - assert( sqlite3BtreeCursorIsValid(u.ao.pCrsr) ); |
| 68406 | | - VVA_ONLY(rc =) sqlite3BtreeDataSize(u.ao.pCrsr, &u.ao.payloadSize); |
| 68776 | + assert( sqlite3BtreeCursorIsValid(u.ap.pCrsr) ); |
| 68777 | + VVA_ONLY(rc =) sqlite3BtreeDataSize(u.ap.pCrsr, &u.ap.payloadSize); |
| 68407 | 68778 | assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ |
| 68408 | 68779 | } |
| 68409 | | - }else if( ALWAYS(u.ao.pC->pseudoTableReg>0) ){ |
| 68410 | | - u.ao.pReg = &aMem[u.ao.pC->pseudoTableReg]; |
| 68411 | | - if( u.ao.pC->multiPseudo ){ |
| 68412 | | - sqlite3VdbeMemShallowCopy(u.ao.pDest, u.ao.pReg+u.ao.p2, MEM_Ephem); |
| 68413 | | - Deephemeralize(u.ao.pDest); |
| 68780 | + }else{ |
| 68781 | + assert( u.ap.pC->pseudoTableReg>0 ); |
| 68782 | + u.ap.pReg = &aMem[u.ap.pC->pseudoTableReg]; |
| 68783 | + if( u.ap.pC->multiPseudo ){ |
| 68784 | + sqlite3VdbeMemShallowCopy(u.ap.pDest, u.ap.pReg+u.ap.p2, MEM_Ephem); |
| 68785 | + Deephemeralize(u.ap.pDest); |
| 68414 | 68786 | goto op_column_out; |
| 68415 | 68787 | } |
| 68416 | | - assert( u.ao.pReg->flags & MEM_Blob ); |
| 68417 | | - assert( memIsValid(u.ao.pReg) ); |
| 68418 | | - u.ao.payloadSize = u.ao.pReg->n; |
| 68419 | | - u.ao.zRec = u.ao.pReg->z; |
| 68420 | | - u.ao.pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr; |
| 68421 | | - assert( u.ao.payloadSize==0 || u.ao.zRec!=0 ); |
| 68422 | | - }else{ |
| 68423 | | - /* Consider the row to be NULL */ |
| 68424 | | - u.ao.payloadSize = 0; |
| 68788 | + assert( u.ap.pReg->flags & MEM_Blob ); |
| 68789 | + assert( memIsValid(u.ap.pReg) ); |
| 68790 | + u.ap.payloadSize = u.ap.pReg->n; |
| 68791 | + u.ap.zRec = u.ap.pReg->z; |
| 68792 | + u.ap.pC->cacheStatus = (pOp->p5&OPFLAG_CLEARCACHE) ? CACHE_STALE : p->cacheCtr; |
| 68793 | + assert( u.ap.payloadSize==0 || u.ap.zRec!=0 ); |
| 68425 | 68794 | } |
| 68426 | 68795 | |
| 68427 | | - /* If u.ao.payloadSize is 0, then just store a NULL. This can happen because of |
| 68796 | + /* If u.ap.payloadSize is 0, then just store a NULL. This can happen because of |
| 68428 | 68797 | ** nullRow or because of a corrupt database. */ |
| 68429 | | - if( u.ao.payloadSize==0 ){ |
| 68430 | | - MemSetTypeFlag(u.ao.pDest, MEM_Null); |
| 68798 | + if( u.ap.payloadSize==0 ){ |
| 68799 | + MemSetTypeFlag(u.ap.pDest, MEM_Null); |
| 68431 | 68800 | goto op_column_out; |
| 68432 | 68801 | } |
| 68433 | 68802 | assert( db->aLimit[SQLITE_LIMIT_LENGTH]>=0 ); |
| 68434 | | - if( u.ao.payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 68803 | + if( u.ap.payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 68435 | 68804 | goto too_big; |
| 68436 | 68805 | } |
| 68437 | 68806 | |
| 68438 | | - u.ao.nField = u.ao.pC->nField; |
| 68439 | | - assert( u.ao.p2<u.ao.nField ); |
| 68807 | + u.ap.nField = u.ap.pC->nField; |
| 68808 | + assert( u.ap.p2<u.ap.nField ); |
| 68440 | 68809 | |
| 68441 | 68810 | /* Read and parse the table header. Store the results of the parse |
| 68442 | 68811 | ** into the record header cache fields of the cursor. |
| 68443 | 68812 | */ |
| 68444 | | - u.ao.aType = u.ao.pC->aType; |
| 68445 | | - if( u.ao.pC->cacheStatus==p->cacheCtr ){ |
| 68446 | | - u.ao.aOffset = u.ao.pC->aOffset; |
| 68813 | + u.ap.aType = u.ap.pC->aType; |
| 68814 | + if( u.ap.pC->cacheStatus==p->cacheCtr ){ |
| 68815 | + u.ap.aOffset = u.ap.pC->aOffset; |
| 68447 | 68816 | }else{ |
| 68448 | | - assert(u.ao.aType); |
| 68449 | | - u.ao.avail = 0; |
| 68450 | | - u.ao.pC->aOffset = u.ao.aOffset = &u.ao.aType[u.ao.nField]; |
| 68451 | | - u.ao.pC->payloadSize = u.ao.payloadSize; |
| 68452 | | - u.ao.pC->cacheStatus = p->cacheCtr; |
| 68817 | + assert(u.ap.aType); |
| 68818 | + u.ap.avail = 0; |
| 68819 | + u.ap.pC->aOffset = u.ap.aOffset = &u.ap.aType[u.ap.nField]; |
| 68820 | + u.ap.pC->payloadSize = u.ap.payloadSize; |
| 68821 | + u.ap.pC->cacheStatus = p->cacheCtr; |
| 68453 | 68822 | |
| 68454 | 68823 | /* Figure out how many bytes are in the header */ |
| 68455 | | - if( u.ao.zRec ){ |
| 68456 | | - u.ao.zData = u.ao.zRec; |
| 68824 | + if( u.ap.zRec ){ |
| 68825 | + u.ap.zData = u.ap.zRec; |
| 68457 | 68826 | }else{ |
| 68458 | | - if( u.ao.pC->isIndex ){ |
| 68459 | | - u.ao.zData = (char*)sqlite3BtreeKeyFetch(u.ao.pCrsr, &u.ao.avail); |
| 68827 | + if( u.ap.pC->isIndex ){ |
| 68828 | + u.ap.zData = (char*)sqlite3BtreeKeyFetch(u.ap.pCrsr, &u.ap.avail); |
| 68460 | 68829 | }else{ |
| 68461 | | - u.ao.zData = (char*)sqlite3BtreeDataFetch(u.ao.pCrsr, &u.ao.avail); |
| 68830 | + u.ap.zData = (char*)sqlite3BtreeDataFetch(u.ap.pCrsr, &u.ap.avail); |
| 68462 | 68831 | } |
| 68463 | 68832 | /* If KeyFetch()/DataFetch() managed to get the entire payload, |
| 68464 | | - ** save the payload in the u.ao.pC->aRow cache. That will save us from |
| 68833 | + ** save the payload in the u.ap.pC->aRow cache. That will save us from |
| 68465 | 68834 | ** having to make additional calls to fetch the content portion of |
| 68466 | 68835 | ** the record. |
| 68467 | 68836 | */ |
| 68468 | | - assert( u.ao.avail>=0 ); |
| 68469 | | - if( u.ao.payloadSize <= (u32)u.ao.avail ){ |
| 68470 | | - u.ao.zRec = u.ao.zData; |
| 68471 | | - u.ao.pC->aRow = (u8*)u.ao.zData; |
| 68837 | + assert( u.ap.avail>=0 ); |
| 68838 | + if( u.ap.payloadSize <= (u32)u.ap.avail ){ |
| 68839 | + u.ap.zRec = u.ap.zData; |
| 68840 | + u.ap.pC->aRow = (u8*)u.ap.zData; |
| 68472 | 68841 | }else{ |
| 68473 | | - u.ao.pC->aRow = 0; |
| 68842 | + u.ap.pC->aRow = 0; |
| 68474 | 68843 | } |
| 68475 | 68844 | } |
| 68476 | 68845 | /* The following assert is true in all cases except when |
| 68477 | 68846 | ** the database file has been corrupted externally. |
| 68478 | | - ** assert( u.ao.zRec!=0 || u.ao.avail>=u.ao.payloadSize || u.ao.avail>=9 ); */ |
| 68479 | | - u.ao.szHdr = getVarint32((u8*)u.ao.zData, u.ao.offset); |
| 68847 | + ** assert( u.ap.zRec!=0 || u.ap.avail>=u.ap.payloadSize || u.ap.avail>=9 ); */ |
| 68848 | + u.ap.szHdr = getVarint32((u8*)u.ap.zData, u.ap.offset); |
| 68480 | 68849 | |
| 68481 | 68850 | /* Make sure a corrupt database has not given us an oversize header. |
| 68482 | 68851 | ** Do this now to avoid an oversize memory allocation. |
| 68483 | 68852 | ** |
| 68484 | 68853 | ** Type entries can be between 1 and 5 bytes each. But 4 and 5 byte |
| | @@ -68485,193 +68854,195 @@ |
| 68485 | 68854 | ** types use so much data space that there can only be 4096 and 32 of |
| 68486 | 68855 | ** them, respectively. So the maximum header length results from a |
| 68487 | 68856 | ** 3-byte type for each of the maximum of 32768 columns plus three |
| 68488 | 68857 | ** extra bytes for the header length itself. 32768*3 + 3 = 98307. |
| 68489 | 68858 | */ |
| 68490 | | - if( u.ao.offset > 98307 ){ |
| 68859 | + if( u.ap.offset > 98307 ){ |
| 68491 | 68860 | rc = SQLITE_CORRUPT_BKPT; |
| 68492 | 68861 | goto op_column_out; |
| 68493 | 68862 | } |
| 68494 | 68863 | |
| 68495 | | - /* Compute in u.ao.len the number of bytes of data we need to read in order |
| 68496 | | - ** to get u.ao.nField type values. u.ao.offset is an upper bound on this. But |
| 68497 | | - ** u.ao.nField might be significantly less than the true number of columns |
| 68498 | | - ** in the table, and in that case, 5*u.ao.nField+3 might be smaller than u.ao.offset. |
| 68499 | | - ** We want to minimize u.ao.len in order to limit the size of the memory |
| 68500 | | - ** allocation, especially if a corrupt database file has caused u.ao.offset |
| 68864 | + /* Compute in u.ap.len the number of bytes of data we need to read in order |
| 68865 | + ** to get u.ap.nField type values. u.ap.offset is an upper bound on this. But |
| 68866 | + ** u.ap.nField might be significantly less than the true number of columns |
| 68867 | + ** in the table, and in that case, 5*u.ap.nField+3 might be smaller than u.ap.offset. |
| 68868 | + ** We want to minimize u.ap.len in order to limit the size of the memory |
| 68869 | + ** allocation, especially if a corrupt database file has caused u.ap.offset |
| 68501 | 68870 | ** to be oversized. Offset is limited to 98307 above. But 98307 might |
| 68502 | 68871 | ** still exceed Robson memory allocation limits on some configurations. |
| 68503 | | - ** On systems that cannot tolerate large memory allocations, u.ao.nField*5+3 |
| 68504 | | - ** will likely be much smaller since u.ao.nField will likely be less than |
| 68872 | + ** On systems that cannot tolerate large memory allocations, u.ap.nField*5+3 |
| 68873 | + ** will likely be much smaller since u.ap.nField will likely be less than |
| 68505 | 68874 | ** 20 or so. This insures that Robson memory allocation limits are |
| 68506 | 68875 | ** not exceeded even for corrupt database files. |
| 68507 | 68876 | */ |
| 68508 | | - u.ao.len = u.ao.nField*5 + 3; |
| 68509 | | - if( u.ao.len > (int)u.ao.offset ) u.ao.len = (int)u.ao.offset; |
| 68877 | + u.ap.len = u.ap.nField*5 + 3; |
| 68878 | + if( u.ap.len > (int)u.ap.offset ) u.ap.len = (int)u.ap.offset; |
| 68510 | 68879 | |
| 68511 | 68880 | /* The KeyFetch() or DataFetch() above are fast and will get the entire |
| 68512 | 68881 | ** record header in most cases. But they will fail to get the complete |
| 68513 | 68882 | ** record header if the record header does not fit on a single page |
| 68514 | 68883 | ** in the B-Tree. When that happens, use sqlite3VdbeMemFromBtree() to |
| 68515 | 68884 | ** acquire the complete header text. |
| 68516 | 68885 | */ |
| 68517 | | - if( !u.ao.zRec && u.ao.avail<u.ao.len ){ |
| 68518 | | - u.ao.sMem.flags = 0; |
| 68519 | | - u.ao.sMem.db = 0; |
| 68520 | | - rc = sqlite3VdbeMemFromBtree(u.ao.pCrsr, 0, u.ao.len, u.ao.pC->isIndex, &u.ao.sMem); |
| 68886 | + if( !u.ap.zRec && u.ap.avail<u.ap.len ){ |
| 68887 | + u.ap.sMem.flags = 0; |
| 68888 | + u.ap.sMem.db = 0; |
| 68889 | + rc = sqlite3VdbeMemFromBtree(u.ap.pCrsr, 0, u.ap.len, u.ap.pC->isIndex, &u.ap.sMem); |
| 68521 | 68890 | if( rc!=SQLITE_OK ){ |
| 68522 | 68891 | goto op_column_out; |
| 68523 | 68892 | } |
| 68524 | | - u.ao.zData = u.ao.sMem.z; |
| 68525 | | - } |
| 68526 | | - u.ao.zEndHdr = (u8 *)&u.ao.zData[u.ao.len]; |
| 68527 | | - u.ao.zIdx = (u8 *)&u.ao.zData[u.ao.szHdr]; |
| 68528 | | - |
| 68529 | | - /* Scan the header and use it to fill in the u.ao.aType[] and u.ao.aOffset[] |
| 68530 | | - ** arrays. u.ao.aType[u.ao.i] will contain the type integer for the u.ao.i-th |
| 68531 | | - ** column and u.ao.aOffset[u.ao.i] will contain the u.ao.offset from the beginning |
| 68532 | | - ** of the record to the start of the data for the u.ao.i-th column |
| 68533 | | - */ |
| 68534 | | - for(u.ao.i=0; u.ao.i<u.ao.nField; u.ao.i++){ |
| 68535 | | - if( u.ao.zIdx<u.ao.zEndHdr ){ |
| 68536 | | - u.ao.aOffset[u.ao.i] = u.ao.offset; |
| 68537 | | - if( u.ao.zIdx[0]<0x80 ){ |
| 68538 | | - u.ao.t = u.ao.zIdx[0]; |
| 68539 | | - u.ao.zIdx++; |
| 68893 | + u.ap.zData = u.ap.sMem.z; |
| 68894 | + } |
| 68895 | + u.ap.zEndHdr = (u8 *)&u.ap.zData[u.ap.len]; |
| 68896 | + u.ap.zIdx = (u8 *)&u.ap.zData[u.ap.szHdr]; |
| 68897 | + |
| 68898 | + /* Scan the header and use it to fill in the u.ap.aType[] and u.ap.aOffset[] |
| 68899 | + ** arrays. u.ap.aType[u.ap.i] will contain the type integer for the u.ap.i-th |
| 68900 | + ** column and u.ap.aOffset[u.ap.i] will contain the u.ap.offset from the beginning |
| 68901 | + ** of the record to the start of the data for the u.ap.i-th column |
| 68902 | + */ |
| 68903 | + for(u.ap.i=0; u.ap.i<u.ap.nField; u.ap.i++){ |
| 68904 | + if( u.ap.zIdx<u.ap.zEndHdr ){ |
| 68905 | + u.ap.aOffset[u.ap.i] = u.ap.offset; |
| 68906 | + if( u.ap.zIdx[0]<0x80 ){ |
| 68907 | + u.ap.t = u.ap.zIdx[0]; |
| 68908 | + u.ap.zIdx++; |
| 68540 | 68909 | }else{ |
| 68541 | | - u.ao.zIdx += sqlite3GetVarint32(u.ao.zIdx, &u.ao.t); |
| 68910 | + u.ap.zIdx += sqlite3GetVarint32(u.ap.zIdx, &u.ap.t); |
| 68542 | 68911 | } |
| 68543 | | - u.ao.aType[u.ao.i] = u.ao.t; |
| 68544 | | - u.ao.szField = sqlite3VdbeSerialTypeLen(u.ao.t); |
| 68545 | | - u.ao.offset += u.ao.szField; |
| 68546 | | - if( u.ao.offset<u.ao.szField ){ /* True if u.ao.offset overflows */ |
| 68547 | | - u.ao.zIdx = &u.ao.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */ |
| 68912 | + u.ap.aType[u.ap.i] = u.ap.t; |
| 68913 | + u.ap.szField = sqlite3VdbeSerialTypeLen(u.ap.t); |
| 68914 | + u.ap.offset += u.ap.szField; |
| 68915 | + if( u.ap.offset<u.ap.szField ){ /* True if u.ap.offset overflows */ |
| 68916 | + u.ap.zIdx = &u.ap.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */ |
| 68548 | 68917 | break; |
| 68549 | 68918 | } |
| 68550 | 68919 | }else{ |
| 68551 | | - /* If u.ao.i is less that u.ao.nField, then there are fewer fields in this |
| 68920 | + /* If u.ap.i is less that u.ap.nField, then there are fewer fields in this |
| 68552 | 68921 | ** record than SetNumColumns indicated there are columns in the |
| 68553 | | - ** table. Set the u.ao.offset for any extra columns not present in |
| 68922 | + ** table. Set the u.ap.offset for any extra columns not present in |
| 68554 | 68923 | ** the record to 0. This tells code below to store the default value |
| 68555 | 68924 | ** for the column instead of deserializing a value from the record. |
| 68556 | 68925 | */ |
| 68557 | | - u.ao.aOffset[u.ao.i] = 0; |
| 68926 | + u.ap.aOffset[u.ap.i] = 0; |
| 68558 | 68927 | } |
| 68559 | 68928 | } |
| 68560 | | - sqlite3VdbeMemRelease(&u.ao.sMem); |
| 68561 | | - u.ao.sMem.flags = MEM_Null; |
| 68929 | + sqlite3VdbeMemRelease(&u.ap.sMem); |
| 68930 | + u.ap.sMem.flags = MEM_Null; |
| 68562 | 68931 | |
| 68563 | 68932 | /* If we have read more header data than was contained in the header, |
| 68564 | 68933 | ** or if the end of the last field appears to be past the end of the |
| 68565 | 68934 | ** record, or if the end of the last field appears to be before the end |
| 68566 | 68935 | ** of the record (when all fields present), then we must be dealing |
| 68567 | 68936 | ** with a corrupt database. |
| 68568 | 68937 | */ |
| 68569 | | - if( (u.ao.zIdx > u.ao.zEndHdr) || (u.ao.offset > u.ao.payloadSize) |
| 68570 | | - || (u.ao.zIdx==u.ao.zEndHdr && u.ao.offset!=u.ao.payloadSize) ){ |
| 68938 | + if( (u.ap.zIdx > u.ap.zEndHdr) || (u.ap.offset > u.ap.payloadSize) |
| 68939 | + || (u.ap.zIdx==u.ap.zEndHdr && u.ap.offset!=u.ap.payloadSize) ){ |
| 68571 | 68940 | rc = SQLITE_CORRUPT_BKPT; |
| 68572 | 68941 | goto op_column_out; |
| 68573 | 68942 | } |
| 68574 | 68943 | } |
| 68575 | 68944 | |
| 68576 | | - /* Get the column information. If u.ao.aOffset[u.ao.p2] is non-zero, then |
| 68577 | | - ** deserialize the value from the record. If u.ao.aOffset[u.ao.p2] is zero, |
| 68945 | + /* Get the column information. If u.ap.aOffset[u.ap.p2] is non-zero, then |
| 68946 | + ** deserialize the value from the record. If u.ap.aOffset[u.ap.p2] is zero, |
| 68578 | 68947 | ** then there are not enough fields in the record to satisfy the |
| 68579 | 68948 | ** request. In this case, set the value NULL or to P4 if P4 is |
| 68580 | 68949 | ** a pointer to a Mem object. |
| 68581 | 68950 | */ |
| 68582 | | - if( u.ao.aOffset[u.ao.p2] ){ |
| 68951 | + if( u.ap.aOffset[u.ap.p2] ){ |
| 68583 | 68952 | assert( rc==SQLITE_OK ); |
| 68584 | | - if( u.ao.zRec ){ |
| 68953 | + if( u.ap.zRec ){ |
| 68585 | 68954 | /* This is the common case where the whole row fits on a single page */ |
| 68586 | | - VdbeMemRelease(u.ao.pDest); |
| 68587 | | - sqlite3VdbeSerialGet((u8 *)&u.ao.zRec[u.ao.aOffset[u.ao.p2]], u.ao.aType[u.ao.p2], u.ao.pDest); |
| 68955 | + VdbeMemRelease(u.ap.pDest); |
| 68956 | + sqlite3VdbeSerialGet((u8 *)&u.ap.zRec[u.ap.aOffset[u.ap.p2]], u.ap.aType[u.ap.p2], u.ap.pDest); |
| 68588 | 68957 | }else{ |
| 68589 | 68958 | /* This branch happens only when the row overflows onto multiple pages */ |
| 68590 | | - u.ao.t = u.ao.aType[u.ao.p2]; |
| 68959 | + u.ap.t = u.ap.aType[u.ap.p2]; |
| 68591 | 68960 | if( (pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0 |
| 68592 | | - && ((u.ao.t>=12 && (u.ao.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0) |
| 68961 | + && ((u.ap.t>=12 && (u.ap.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0) |
| 68593 | 68962 | ){ |
| 68594 | 68963 | /* Content is irrelevant for the typeof() function and for |
| 68595 | 68964 | ** the length(X) function if X is a blob. So we might as well use |
| 68596 | 68965 | ** bogus content rather than reading content from disk. NULL works |
| 68597 | | - ** for text and blob and whatever is in the u.ao.payloadSize64 variable |
| 68966 | + ** for text and blob and whatever is in the u.ap.payloadSize64 variable |
| 68598 | 68967 | ** will work for everything else. */ |
| 68599 | | - u.ao.zData = u.ao.t<12 ? (char*)&u.ao.payloadSize64 : 0; |
| 68968 | + u.ap.zData = u.ap.t<12 ? (char*)&u.ap.payloadSize64 : 0; |
| 68600 | 68969 | }else{ |
| 68601 | | - u.ao.len = sqlite3VdbeSerialTypeLen(u.ao.t); |
| 68602 | | - sqlite3VdbeMemMove(&u.ao.sMem, u.ao.pDest); |
| 68603 | | - rc = sqlite3VdbeMemFromBtree(u.ao.pCrsr, u.ao.aOffset[u.ao.p2], u.ao.len, u.ao.pC->isIndex, |
| 68604 | | - &u.ao.sMem); |
| 68970 | + u.ap.len = sqlite3VdbeSerialTypeLen(u.ap.t); |
| 68971 | + sqlite3VdbeMemMove(&u.ap.sMem, u.ap.pDest); |
| 68972 | + rc = sqlite3VdbeMemFromBtree(u.ap.pCrsr, u.ap.aOffset[u.ap.p2], u.ap.len, u.ap.pC->isIndex, |
| 68973 | + &u.ap.sMem); |
| 68605 | 68974 | if( rc!=SQLITE_OK ){ |
| 68606 | 68975 | goto op_column_out; |
| 68607 | 68976 | } |
| 68608 | | - u.ao.zData = u.ao.sMem.z; |
| 68977 | + u.ap.zData = u.ap.sMem.z; |
| 68609 | 68978 | } |
| 68610 | | - sqlite3VdbeSerialGet((u8*)u.ao.zData, u.ao.t, u.ao.pDest); |
| 68979 | + sqlite3VdbeSerialGet((u8*)u.ap.zData, u.ap.t, u.ap.pDest); |
| 68611 | 68980 | } |
| 68612 | | - u.ao.pDest->enc = encoding; |
| 68981 | + u.ap.pDest->enc = encoding; |
| 68613 | 68982 | }else{ |
| 68614 | 68983 | if( pOp->p4type==P4_MEM ){ |
| 68615 | | - sqlite3VdbeMemShallowCopy(u.ao.pDest, pOp->p4.pMem, MEM_Static); |
| 68984 | + sqlite3VdbeMemShallowCopy(u.ap.pDest, pOp->p4.pMem, MEM_Static); |
| 68616 | 68985 | }else{ |
| 68617 | | - MemSetTypeFlag(u.ao.pDest, MEM_Null); |
| 68986 | + MemSetTypeFlag(u.ap.pDest, MEM_Null); |
| 68618 | 68987 | } |
| 68619 | 68988 | } |
| 68620 | 68989 | |
| 68621 | 68990 | /* If we dynamically allocated space to hold the data (in the |
| 68622 | 68991 | ** sqlite3VdbeMemFromBtree() call above) then transfer control of that |
| 68623 | | - ** dynamically allocated space over to the u.ao.pDest structure. |
| 68992 | + ** dynamically allocated space over to the u.ap.pDest structure. |
| 68624 | 68993 | ** This prevents a memory copy. |
| 68625 | 68994 | */ |
| 68626 | | - if( u.ao.sMem.zMalloc ){ |
| 68627 | | - assert( u.ao.sMem.z==u.ao.sMem.zMalloc ); |
| 68628 | | - assert( !(u.ao.pDest->flags & MEM_Dyn) ); |
| 68629 | | - assert( !(u.ao.pDest->flags & (MEM_Blob|MEM_Str)) || u.ao.pDest->z==u.ao.sMem.z ); |
| 68630 | | - u.ao.pDest->flags &= ~(MEM_Ephem|MEM_Static); |
| 68631 | | - u.ao.pDest->flags |= MEM_Term; |
| 68632 | | - u.ao.pDest->z = u.ao.sMem.z; |
| 68633 | | - u.ao.pDest->zMalloc = u.ao.sMem.zMalloc; |
| 68995 | + if( u.ap.sMem.zMalloc ){ |
| 68996 | + assert( u.ap.sMem.z==u.ap.sMem.zMalloc ); |
| 68997 | + assert( !(u.ap.pDest->flags & MEM_Dyn) ); |
| 68998 | + assert( !(u.ap.pDest->flags & (MEM_Blob|MEM_Str)) || u.ap.pDest->z==u.ap.sMem.z ); |
| 68999 | + u.ap.pDest->flags &= ~(MEM_Ephem|MEM_Static); |
| 69000 | + u.ap.pDest->flags |= MEM_Term; |
| 69001 | + u.ap.pDest->z = u.ap.sMem.z; |
| 69002 | + u.ap.pDest->zMalloc = u.ap.sMem.zMalloc; |
| 68634 | 69003 | } |
| 68635 | 69004 | |
| 68636 | | - rc = sqlite3VdbeMemMakeWriteable(u.ao.pDest); |
| 69005 | + rc = sqlite3VdbeMemMakeWriteable(u.ap.pDest); |
| 68637 | 69006 | |
| 68638 | 69007 | op_column_out: |
| 68639 | | - UPDATE_MAX_BLOBSIZE(u.ao.pDest); |
| 68640 | | - REGISTER_TRACE(pOp->p3, u.ao.pDest); |
| 69008 | + UPDATE_MAX_BLOBSIZE(u.ap.pDest); |
| 69009 | + REGISTER_TRACE(pOp->p3, u.ap.pDest); |
| 68641 | 69010 | break; |
| 68642 | 69011 | } |
| 68643 | 69012 | |
| 68644 | 69013 | /* Opcode: Affinity P1 P2 * P4 * |
| 69014 | +** Synopsis: affinity(r[P1@P2]) |
| 68645 | 69015 | ** |
| 68646 | 69016 | ** Apply affinities to a range of P2 registers starting with P1. |
| 68647 | 69017 | ** |
| 68648 | 69018 | ** P4 is a string that is P2 characters long. The nth character of the |
| 68649 | 69019 | ** string indicates the column affinity that should be used for the nth |
| 68650 | 69020 | ** memory cell in the range. |
| 68651 | 69021 | */ |
| 68652 | 69022 | case OP_Affinity: { |
| 68653 | | -#if 0 /* local variables moved into u.ap */ |
| 69023 | +#if 0 /* local variables moved into u.aq */ |
| 68654 | 69024 | const char *zAffinity; /* The affinity to be applied */ |
| 68655 | 69025 | char cAff; /* A single character of affinity */ |
| 68656 | | -#endif /* local variables moved into u.ap */ |
| 69026 | +#endif /* local variables moved into u.aq */ |
| 68657 | 69027 | |
| 68658 | | - u.ap.zAffinity = pOp->p4.z; |
| 68659 | | - assert( u.ap.zAffinity!=0 ); |
| 68660 | | - assert( u.ap.zAffinity[pOp->p2]==0 ); |
| 69028 | + u.aq.zAffinity = pOp->p4.z; |
| 69029 | + assert( u.aq.zAffinity!=0 ); |
| 69030 | + assert( u.aq.zAffinity[pOp->p2]==0 ); |
| 68661 | 69031 | pIn1 = &aMem[pOp->p1]; |
| 68662 | | - while( (u.ap.cAff = *(u.ap.zAffinity++))!=0 ){ |
| 69032 | + while( (u.aq.cAff = *(u.aq.zAffinity++))!=0 ){ |
| 68663 | 69033 | assert( pIn1 <= &p->aMem[(p->nMem-p->nCursor)] ); |
| 68664 | 69034 | assert( memIsValid(pIn1) ); |
| 68665 | 69035 | ExpandBlob(pIn1); |
| 68666 | | - applyAffinity(pIn1, u.ap.cAff, encoding); |
| 69036 | + applyAffinity(pIn1, u.aq.cAff, encoding); |
| 68667 | 69037 | pIn1++; |
| 68668 | 69038 | } |
| 68669 | 69039 | break; |
| 68670 | 69040 | } |
| 68671 | 69041 | |
| 68672 | 69042 | /* Opcode: MakeRecord P1 P2 P3 P4 * |
| 69043 | +** Synopsis: r[P3]=mkrec(r[P1@P2]) |
| 68673 | 69044 | ** |
| 68674 | 69045 | ** Convert P2 registers beginning with P1 into the [record format] |
| 68675 | 69046 | ** use as a data record in a database table or as a key |
| 68676 | 69047 | ** in an index. The OP_Column opcode can decode the record later. |
| 68677 | 69048 | ** |
| | @@ -68683,11 +69054,11 @@ |
| 68683 | 69054 | ** macros defined in sqliteInt.h. |
| 68684 | 69055 | ** |
| 68685 | 69056 | ** If P4 is NULL then all index fields have the affinity NONE. |
| 68686 | 69057 | */ |
| 68687 | 69058 | case OP_MakeRecord: { |
| 68688 | | -#if 0 /* local variables moved into u.aq */ |
| 69059 | +#if 0 /* local variables moved into u.ar */ |
| 68689 | 69060 | u8 *zNewRecord; /* A buffer to hold the data for the new record */ |
| 68690 | 69061 | Mem *pRec; /* The new record */ |
| 68691 | 69062 | u64 nData; /* Number of bytes of data space */ |
| 68692 | 69063 | int nHdr; /* Number of bytes of header space */ |
| 68693 | 69064 | i64 nByte; /* Data space required for this record */ |
| | @@ -68699,11 +69070,11 @@ |
| 68699 | 69070 | int nField; /* Number of fields in the record */ |
| 68700 | 69071 | char *zAffinity; /* The affinity string for the record */ |
| 68701 | 69072 | int file_format; /* File format to use for encoding */ |
| 68702 | 69073 | int i; /* Space used in zNewRecord[] */ |
| 68703 | 69074 | int len; /* Length of a field */ |
| 68704 | | -#endif /* local variables moved into u.aq */ |
| 69075 | +#endif /* local variables moved into u.ar */ |
| 68705 | 69076 | |
| 68706 | 69077 | /* Assuming the record contains N fields, the record format looks |
| 68707 | 69078 | ** like this: |
| 68708 | 69079 | ** |
| 68709 | 69080 | ** ------------------------------------------------------------------------ |
| | @@ -68716,114 +69087,112 @@ |
| 68716 | 69087 | ** Each type field is a varint representing the serial type of the |
| 68717 | 69088 | ** corresponding data element (see sqlite3VdbeSerialType()). The |
| 68718 | 69089 | ** hdr-size field is also a varint which is the offset from the beginning |
| 68719 | 69090 | ** of the record to data0. |
| 68720 | 69091 | */ |
| 68721 | | - u.aq.nData = 0; /* Number of bytes of data space */ |
| 68722 | | - u.aq.nHdr = 0; /* Number of bytes of header space */ |
| 68723 | | - u.aq.nZero = 0; /* Number of zero bytes at the end of the record */ |
| 68724 | | - u.aq.nField = pOp->p1; |
| 68725 | | - u.aq.zAffinity = pOp->p4.z; |
| 68726 | | - assert( u.aq.nField>0 && pOp->p2>0 && pOp->p2+u.aq.nField<=(p->nMem-p->nCursor)+1 ); |
| 68727 | | - u.aq.pData0 = &aMem[u.aq.nField]; |
| 68728 | | - u.aq.nField = pOp->p2; |
| 68729 | | - u.aq.pLast = &u.aq.pData0[u.aq.nField-1]; |
| 68730 | | - u.aq.file_format = p->minWriteFileFormat; |
| 69092 | + u.ar.nData = 0; /* Number of bytes of data space */ |
| 69093 | + u.ar.nHdr = 0; /* Number of bytes of header space */ |
| 69094 | + u.ar.nZero = 0; /* Number of zero bytes at the end of the record */ |
| 69095 | + u.ar.nField = pOp->p1; |
| 69096 | + u.ar.zAffinity = pOp->p4.z; |
| 69097 | + assert( u.ar.nField>0 && pOp->p2>0 && pOp->p2+u.ar.nField<=(p->nMem-p->nCursor)+1 ); |
| 69098 | + u.ar.pData0 = &aMem[u.ar.nField]; |
| 69099 | + u.ar.nField = pOp->p2; |
| 69100 | + u.ar.pLast = &u.ar.pData0[u.ar.nField-1]; |
| 69101 | + u.ar.file_format = p->minWriteFileFormat; |
| 68731 | 69102 | |
| 68732 | 69103 | /* Identify the output register */ |
| 68733 | 69104 | assert( pOp->p3<pOp->p1 || pOp->p3>=pOp->p1+pOp->p2 ); |
| 68734 | 69105 | pOut = &aMem[pOp->p3]; |
| 68735 | 69106 | memAboutToChange(p, pOut); |
| 68736 | 69107 | |
| 68737 | 69108 | /* Loop through the elements that will make up the record to figure |
| 68738 | 69109 | ** out how much space is required for the new record. |
| 68739 | 69110 | */ |
| 68740 | | - for(u.aq.pRec=u.aq.pData0; u.aq.pRec<=u.aq.pLast; u.aq.pRec++){ |
| 68741 | | - assert( memIsValid(u.aq.pRec) ); |
| 68742 | | - if( u.aq.zAffinity ){ |
| 68743 | | - applyAffinity(u.aq.pRec, u.aq.zAffinity[u.aq.pRec-u.aq.pData0], encoding); |
| 68744 | | - } |
| 68745 | | - if( u.aq.pRec->flags&MEM_Zero && u.aq.pRec->n>0 ){ |
| 68746 | | - sqlite3VdbeMemExpandBlob(u.aq.pRec); |
| 68747 | | - } |
| 68748 | | - u.aq.serial_type = sqlite3VdbeSerialType(u.aq.pRec, u.aq.file_format); |
| 68749 | | - u.aq.len = sqlite3VdbeSerialTypeLen(u.aq.serial_type); |
| 68750 | | - u.aq.nData += u.aq.len; |
| 68751 | | - u.aq.nHdr += sqlite3VarintLen(u.aq.serial_type); |
| 68752 | | - if( u.aq.pRec->flags & MEM_Zero ){ |
| 69111 | + for(u.ar.pRec=u.ar.pData0; u.ar.pRec<=u.ar.pLast; u.ar.pRec++){ |
| 69112 | + assert( memIsValid(u.ar.pRec) ); |
| 69113 | + if( u.ar.zAffinity ){ |
| 69114 | + applyAffinity(u.ar.pRec, u.ar.zAffinity[u.ar.pRec-u.ar.pData0], encoding); |
| 69115 | + } |
| 69116 | + if( u.ar.pRec->flags&MEM_Zero && u.ar.pRec->n>0 ){ |
| 69117 | + sqlite3VdbeMemExpandBlob(u.ar.pRec); |
| 69118 | + } |
| 69119 | + u.ar.serial_type = sqlite3VdbeSerialType(u.ar.pRec, u.ar.file_format); |
| 69120 | + u.ar.len = sqlite3VdbeSerialTypeLen(u.ar.serial_type); |
| 69121 | + u.ar.nData += u.ar.len; |
| 69122 | + u.ar.nHdr += sqlite3VarintLen(u.ar.serial_type); |
| 69123 | + if( u.ar.pRec->flags & MEM_Zero ){ |
| 68753 | 69124 | /* Only pure zero-filled BLOBs can be input to this Opcode. |
| 68754 | 69125 | ** We do not allow blobs with a prefix and a zero-filled tail. */ |
| 68755 | | - u.aq.nZero += u.aq.pRec->u.nZero; |
| 68756 | | - }else if( u.aq.len ){ |
| 68757 | | - u.aq.nZero = 0; |
| 69126 | + u.ar.nZero += u.ar.pRec->u.nZero; |
| 69127 | + }else if( u.ar.len ){ |
| 69128 | + u.ar.nZero = 0; |
| 68758 | 69129 | } |
| 68759 | 69130 | } |
| 68760 | 69131 | |
| 68761 | 69132 | /* Add the initial header varint and total the size */ |
| 68762 | | - u.aq.nHdr += u.aq.nVarint = sqlite3VarintLen(u.aq.nHdr); |
| 68763 | | - if( u.aq.nVarint<sqlite3VarintLen(u.aq.nHdr) ){ |
| 68764 | | - u.aq.nHdr++; |
| 69133 | + u.ar.nHdr += u.ar.nVarint = sqlite3VarintLen(u.ar.nHdr); |
| 69134 | + if( u.ar.nVarint<sqlite3VarintLen(u.ar.nHdr) ){ |
| 69135 | + u.ar.nHdr++; |
| 68765 | 69136 | } |
| 68766 | | - u.aq.nByte = u.aq.nHdr+u.aq.nData-u.aq.nZero; |
| 68767 | | - if( u.aq.nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 69137 | + u.ar.nByte = u.ar.nHdr+u.ar.nData-u.ar.nZero; |
| 69138 | + if( u.ar.nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 68768 | 69139 | goto too_big; |
| 68769 | 69140 | } |
| 68770 | 69141 | |
| 68771 | 69142 | /* Make sure the output register has a buffer large enough to store |
| 68772 | 69143 | ** the new record. The output register (pOp->p3) is not allowed to |
| 68773 | 69144 | ** be one of the input registers (because the following call to |
| 68774 | 69145 | ** sqlite3VdbeMemGrow() could clobber the value before it is used). |
| 68775 | 69146 | */ |
| 68776 | | - if( sqlite3VdbeMemGrow(pOut, (int)u.aq.nByte, 0) ){ |
| 69147 | + if( sqlite3VdbeMemGrow(pOut, (int)u.ar.nByte, 0) ){ |
| 68777 | 69148 | goto no_mem; |
| 68778 | 69149 | } |
| 68779 | | - u.aq.zNewRecord = (u8 *)pOut->z; |
| 69150 | + u.ar.zNewRecord = (u8 *)pOut->z; |
| 68780 | 69151 | |
| 68781 | 69152 | /* Write the record */ |
| 68782 | | - u.aq.i = putVarint32(u.aq.zNewRecord, u.aq.nHdr); |
| 68783 | | - for(u.aq.pRec=u.aq.pData0; u.aq.pRec<=u.aq.pLast; u.aq.pRec++){ |
| 68784 | | - u.aq.serial_type = sqlite3VdbeSerialType(u.aq.pRec, u.aq.file_format); |
| 68785 | | - u.aq.i += putVarint32(&u.aq.zNewRecord[u.aq.i], u.aq.serial_type); /* serial type */ |
| 68786 | | - } |
| 68787 | | - for(u.aq.pRec=u.aq.pData0; u.aq.pRec<=u.aq.pLast; u.aq.pRec++){ /* serial data */ |
| 68788 | | - u.aq.i += sqlite3VdbeSerialPut(&u.aq.zNewRecord[u.aq.i], (int)(u.aq.nByte-u.aq.i), u.aq.pRec,u.aq.file_format); |
| 68789 | | - } |
| 68790 | | - assert( u.aq.i==u.aq.nByte ); |
| 69153 | + u.ar.i = putVarint32(u.ar.zNewRecord, u.ar.nHdr); |
| 69154 | + for(u.ar.pRec=u.ar.pData0; u.ar.pRec<=u.ar.pLast; u.ar.pRec++){ |
| 69155 | + u.ar.serial_type = sqlite3VdbeSerialType(u.ar.pRec, u.ar.file_format); |
| 69156 | + u.ar.i += putVarint32(&u.ar.zNewRecord[u.ar.i], u.ar.serial_type); /* serial type */ |
| 69157 | + } |
| 69158 | + for(u.ar.pRec=u.ar.pData0; u.ar.pRec<=u.ar.pLast; u.ar.pRec++){ /* serial data */ |
| 69159 | + u.ar.i += sqlite3VdbeSerialPut(&u.ar.zNewRecord[u.ar.i], (int)(u.ar.nByte-u.ar.i), u.ar.pRec,u.ar.file_format); |
| 69160 | + } |
| 69161 | + assert( u.ar.i==u.ar.nByte ); |
| 68791 | 69162 | |
| 68792 | 69163 | assert( pOp->p3>0 && pOp->p3<=(p->nMem-p->nCursor) ); |
| 68793 | | - pOut->n = (int)u.aq.nByte; |
| 69164 | + pOut->n = (int)u.ar.nByte; |
| 68794 | 69165 | pOut->flags = MEM_Blob | MEM_Dyn; |
| 68795 | 69166 | pOut->xDel = 0; |
| 68796 | | - if( u.aq.nZero ){ |
| 68797 | | - pOut->u.nZero = u.aq.nZero; |
| 69167 | + if( u.ar.nZero ){ |
| 69168 | + pOut->u.nZero = u.ar.nZero; |
| 68798 | 69169 | pOut->flags |= MEM_Zero; |
| 68799 | 69170 | } |
| 68800 | 69171 | pOut->enc = SQLITE_UTF8; /* In case the blob is ever converted to text */ |
| 68801 | 69172 | REGISTER_TRACE(pOp->p3, pOut); |
| 68802 | 69173 | UPDATE_MAX_BLOBSIZE(pOut); |
| 68803 | 69174 | break; |
| 68804 | 69175 | } |
| 68805 | 69176 | |
| 68806 | 69177 | /* Opcode: Count P1 P2 * * * |
| 69178 | +** Synopsis: r[P2]=count() |
| 68807 | 69179 | ** |
| 68808 | 69180 | ** Store the number of entries (an integer value) in the table or index |
| 68809 | 69181 | ** opened by cursor P1 in register P2 |
| 68810 | 69182 | */ |
| 68811 | 69183 | #ifndef SQLITE_OMIT_BTREECOUNT |
| 68812 | 69184 | case OP_Count: { /* out2-prerelease */ |
| 68813 | | -#if 0 /* local variables moved into u.ar */ |
| 69185 | +#if 0 /* local variables moved into u.as */ |
| 68814 | 69186 | i64 nEntry; |
| 68815 | 69187 | BtCursor *pCrsr; |
| 68816 | | -#endif /* local variables moved into u.ar */ |
| 68817 | | - |
| 68818 | | - u.ar.pCrsr = p->apCsr[pOp->p1]->pCursor; |
| 68819 | | - if( ALWAYS(u.ar.pCrsr) ){ |
| 68820 | | - rc = sqlite3BtreeCount(u.ar.pCrsr, &u.ar.nEntry); |
| 68821 | | - }else{ |
| 68822 | | - u.ar.nEntry = 0; |
| 68823 | | - } |
| 68824 | | - pOut->u.i = u.ar.nEntry; |
| 69188 | +#endif /* local variables moved into u.as */ |
| 69189 | + |
| 69190 | + u.as.pCrsr = p->apCsr[pOp->p1]->pCursor; |
| 69191 | + assert( u.as.pCrsr ); |
| 69192 | + rc = sqlite3BtreeCount(u.as.pCrsr, &u.as.nEntry); |
| 69193 | + pOut->u.i = u.as.nEntry; |
| 68825 | 69194 | break; |
| 68826 | 69195 | } |
| 68827 | 69196 | #endif |
| 68828 | 69197 | |
| 68829 | 69198 | /* Opcode: Savepoint P1 * * P4 * |
| | @@ -68831,43 +69200,43 @@ |
| 68831 | 69200 | ** Open, release or rollback the savepoint named by parameter P4, depending |
| 68832 | 69201 | ** on the value of P1. To open a new savepoint, P1==0. To release (commit) an |
| 68833 | 69202 | ** existing savepoint, P1==1, or to rollback an existing savepoint P1==2. |
| 68834 | 69203 | */ |
| 68835 | 69204 | case OP_Savepoint: { |
| 68836 | | -#if 0 /* local variables moved into u.as */ |
| 69205 | +#if 0 /* local variables moved into u.at */ |
| 68837 | 69206 | int p1; /* Value of P1 operand */ |
| 68838 | 69207 | char *zName; /* Name of savepoint */ |
| 68839 | 69208 | int nName; |
| 68840 | 69209 | Savepoint *pNew; |
| 68841 | 69210 | Savepoint *pSavepoint; |
| 68842 | 69211 | Savepoint *pTmp; |
| 68843 | 69212 | int iSavepoint; |
| 68844 | 69213 | int ii; |
| 68845 | | -#endif /* local variables moved into u.as */ |
| 69214 | +#endif /* local variables moved into u.at */ |
| 68846 | 69215 | |
| 68847 | | - u.as.p1 = pOp->p1; |
| 68848 | | - u.as.zName = pOp->p4.z; |
| 69216 | + u.at.p1 = pOp->p1; |
| 69217 | + u.at.zName = pOp->p4.z; |
| 68849 | 69218 | |
| 68850 | | - /* Assert that the u.as.p1 parameter is valid. Also that if there is no open |
| 69219 | + /* Assert that the u.at.p1 parameter is valid. Also that if there is no open |
| 68851 | 69220 | ** transaction, then there cannot be any savepoints. |
| 68852 | 69221 | */ |
| 68853 | 69222 | assert( db->pSavepoint==0 || db->autoCommit==0 ); |
| 68854 | | - assert( u.as.p1==SAVEPOINT_BEGIN||u.as.p1==SAVEPOINT_RELEASE||u.as.p1==SAVEPOINT_ROLLBACK ); |
| 69223 | + assert( u.at.p1==SAVEPOINT_BEGIN||u.at.p1==SAVEPOINT_RELEASE||u.at.p1==SAVEPOINT_ROLLBACK ); |
| 68855 | 69224 | assert( db->pSavepoint || db->isTransactionSavepoint==0 ); |
| 68856 | 69225 | assert( checkSavepointCount(db) ); |
| 68857 | 69226 | assert( p->bIsReader ); |
| 68858 | 69227 | |
| 68859 | | - if( u.as.p1==SAVEPOINT_BEGIN ){ |
| 69228 | + if( u.at.p1==SAVEPOINT_BEGIN ){ |
| 68860 | 69229 | if( db->nVdbeWrite>0 ){ |
| 68861 | 69230 | /* A new savepoint cannot be created if there are active write |
| 68862 | 69231 | ** statements (i.e. open read/write incremental blob handles). |
| 68863 | 69232 | */ |
| 68864 | 69233 | sqlite3SetString(&p->zErrMsg, db, "cannot open savepoint - " |
| 68865 | 69234 | "SQL statements in progress"); |
| 68866 | 69235 | rc = SQLITE_BUSY; |
| 68867 | 69236 | }else{ |
| 68868 | | - u.as.nName = sqlite3Strlen30(u.as.zName); |
| 69237 | + u.at.nName = sqlite3Strlen30(u.at.zName); |
| 68869 | 69238 | |
| 68870 | 69239 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 68871 | 69240 | /* This call is Ok even if this savepoint is actually a transaction |
| 68872 | 69241 | ** savepoint (and therefore should not prompt xSavepoint()) callbacks. |
| 68873 | 69242 | ** If this is a transaction savepoint being opened, it is guaranteed |
| | @@ -68877,14 +69246,14 @@ |
| 68877 | 69246 | db->nStatement+db->nSavepoint); |
| 68878 | 69247 | if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 68879 | 69248 | #endif |
| 68880 | 69249 | |
| 68881 | 69250 | /* Create a new savepoint structure. */ |
| 68882 | | - u.as.pNew = sqlite3DbMallocRaw(db, sizeof(Savepoint)+u.as.nName+1); |
| 68883 | | - if( u.as.pNew ){ |
| 68884 | | - u.as.pNew->zName = (char *)&u.as.pNew[1]; |
| 68885 | | - memcpy(u.as.pNew->zName, u.as.zName, u.as.nName+1); |
| 69251 | + u.at.pNew = sqlite3DbMallocRaw(db, sizeof(Savepoint)+u.at.nName+1); |
| 69252 | + if( u.at.pNew ){ |
| 69253 | + u.at.pNew->zName = (char *)&u.at.pNew[1]; |
| 69254 | + memcpy(u.at.pNew->zName, u.at.zName, u.at.nName+1); |
| 68886 | 69255 | |
| 68887 | 69256 | /* If there is no open transaction, then mark this as a special |
| 68888 | 69257 | ** "transaction savepoint". */ |
| 68889 | 69258 | if( db->autoCommit ){ |
| 68890 | 69259 | db->autoCommit = 0; |
| | @@ -68892,32 +69261,32 @@ |
| 68892 | 69261 | }else{ |
| 68893 | 69262 | db->nSavepoint++; |
| 68894 | 69263 | } |
| 68895 | 69264 | |
| 68896 | 69265 | /* Link the new savepoint into the database handle's list. */ |
| 68897 | | - u.as.pNew->pNext = db->pSavepoint; |
| 68898 | | - db->pSavepoint = u.as.pNew; |
| 68899 | | - u.as.pNew->nDeferredCons = db->nDeferredCons; |
| 68900 | | - u.as.pNew->nDeferredImmCons = db->nDeferredImmCons; |
| 69266 | + u.at.pNew->pNext = db->pSavepoint; |
| 69267 | + db->pSavepoint = u.at.pNew; |
| 69268 | + u.at.pNew->nDeferredCons = db->nDeferredCons; |
| 69269 | + u.at.pNew->nDeferredImmCons = db->nDeferredImmCons; |
| 68901 | 69270 | } |
| 68902 | 69271 | } |
| 68903 | 69272 | }else{ |
| 68904 | | - u.as.iSavepoint = 0; |
| 69273 | + u.at.iSavepoint = 0; |
| 68905 | 69274 | |
| 68906 | 69275 | /* Find the named savepoint. If there is no such savepoint, then an |
| 68907 | 69276 | ** an error is returned to the user. */ |
| 68908 | 69277 | for( |
| 68909 | | - u.as.pSavepoint = db->pSavepoint; |
| 68910 | | - u.as.pSavepoint && sqlite3StrICmp(u.as.pSavepoint->zName, u.as.zName); |
| 68911 | | - u.as.pSavepoint = u.as.pSavepoint->pNext |
| 69278 | + u.at.pSavepoint = db->pSavepoint; |
| 69279 | + u.at.pSavepoint && sqlite3StrICmp(u.at.pSavepoint->zName, u.at.zName); |
| 69280 | + u.at.pSavepoint = u.at.pSavepoint->pNext |
| 68912 | 69281 | ){ |
| 68913 | | - u.as.iSavepoint++; |
| 69282 | + u.at.iSavepoint++; |
| 68914 | 69283 | } |
| 68915 | | - if( !u.as.pSavepoint ){ |
| 68916 | | - sqlite3SetString(&p->zErrMsg, db, "no such savepoint: %s", u.as.zName); |
| 69284 | + if( !u.at.pSavepoint ){ |
| 69285 | + sqlite3SetString(&p->zErrMsg, db, "no such savepoint: %s", u.at.zName); |
| 68917 | 69286 | rc = SQLITE_ERROR; |
| 68918 | | - }else if( db->nVdbeWrite>0 && u.as.p1==SAVEPOINT_RELEASE ){ |
| 69287 | + }else if( db->nVdbeWrite>0 && u.at.p1==SAVEPOINT_RELEASE ){ |
| 68919 | 69288 | /* It is not possible to release (commit) a savepoint if there are |
| 68920 | 69289 | ** active write statements. |
| 68921 | 69290 | */ |
| 68922 | 69291 | sqlite3SetString(&p->zErrMsg, db, |
| 68923 | 69292 | "cannot release savepoint - SQL statements in progress" |
| | @@ -68927,12 +69296,12 @@ |
| 68927 | 69296 | |
| 68928 | 69297 | /* Determine whether or not this is a transaction savepoint. If so, |
| 68929 | 69298 | ** and this is a RELEASE command, then the current transaction |
| 68930 | 69299 | ** is committed. |
| 68931 | 69300 | */ |
| 68932 | | - int isTransaction = u.as.pSavepoint->pNext==0 && db->isTransactionSavepoint; |
| 68933 | | - if( isTransaction && u.as.p1==SAVEPOINT_RELEASE ){ |
| 69301 | + int isTransaction = u.at.pSavepoint->pNext==0 && db->isTransactionSavepoint; |
| 69302 | + if( isTransaction && u.at.p1==SAVEPOINT_RELEASE ){ |
| 68934 | 69303 | if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){ |
| 68935 | 69304 | goto vdbe_return; |
| 68936 | 69305 | } |
| 68937 | 69306 | db->autoCommit = 1; |
| 68938 | 69307 | if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){ |
| | @@ -68942,56 +69311,56 @@ |
| 68942 | 69311 | goto vdbe_return; |
| 68943 | 69312 | } |
| 68944 | 69313 | db->isTransactionSavepoint = 0; |
| 68945 | 69314 | rc = p->rc; |
| 68946 | 69315 | }else{ |
| 68947 | | - u.as.iSavepoint = db->nSavepoint - u.as.iSavepoint - 1; |
| 68948 | | - if( u.as.p1==SAVEPOINT_ROLLBACK ){ |
| 68949 | | - for(u.as.ii=0; u.as.ii<db->nDb; u.as.ii++){ |
| 68950 | | - sqlite3BtreeTripAllCursors(db->aDb[u.as.ii].pBt, SQLITE_ABORT); |
| 69316 | + u.at.iSavepoint = db->nSavepoint - u.at.iSavepoint - 1; |
| 69317 | + if( u.at.p1==SAVEPOINT_ROLLBACK ){ |
| 69318 | + for(u.at.ii=0; u.at.ii<db->nDb; u.at.ii++){ |
| 69319 | + sqlite3BtreeTripAllCursors(db->aDb[u.at.ii].pBt, SQLITE_ABORT); |
| 68951 | 69320 | } |
| 68952 | 69321 | } |
| 68953 | | - for(u.as.ii=0; u.as.ii<db->nDb; u.as.ii++){ |
| 68954 | | - rc = sqlite3BtreeSavepoint(db->aDb[u.as.ii].pBt, u.as.p1, u.as.iSavepoint); |
| 69322 | + for(u.at.ii=0; u.at.ii<db->nDb; u.at.ii++){ |
| 69323 | + rc = sqlite3BtreeSavepoint(db->aDb[u.at.ii].pBt, u.at.p1, u.at.iSavepoint); |
| 68955 | 69324 | if( rc!=SQLITE_OK ){ |
| 68956 | 69325 | goto abort_due_to_error; |
| 68957 | 69326 | } |
| 68958 | 69327 | } |
| 68959 | | - if( u.as.p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){ |
| 69328 | + if( u.at.p1==SAVEPOINT_ROLLBACK && (db->flags&SQLITE_InternChanges)!=0 ){ |
| 68960 | 69329 | sqlite3ExpirePreparedStatements(db); |
| 68961 | 69330 | sqlite3ResetAllSchemasOfConnection(db); |
| 68962 | 69331 | db->flags = (db->flags | SQLITE_InternChanges); |
| 68963 | 69332 | } |
| 68964 | 69333 | } |
| 68965 | 69334 | |
| 68966 | 69335 | /* Regardless of whether this is a RELEASE or ROLLBACK, destroy all |
| 68967 | 69336 | ** savepoints nested inside of the savepoint being operated on. */ |
| 68968 | | - while( db->pSavepoint!=u.as.pSavepoint ){ |
| 68969 | | - u.as.pTmp = db->pSavepoint; |
| 68970 | | - db->pSavepoint = u.as.pTmp->pNext; |
| 68971 | | - sqlite3DbFree(db, u.as.pTmp); |
| 69337 | + while( db->pSavepoint!=u.at.pSavepoint ){ |
| 69338 | + u.at.pTmp = db->pSavepoint; |
| 69339 | + db->pSavepoint = u.at.pTmp->pNext; |
| 69340 | + sqlite3DbFree(db, u.at.pTmp); |
| 68972 | 69341 | db->nSavepoint--; |
| 68973 | 69342 | } |
| 68974 | 69343 | |
| 68975 | 69344 | /* If it is a RELEASE, then destroy the savepoint being operated on |
| 68976 | 69345 | ** too. If it is a ROLLBACK TO, then set the number of deferred |
| 68977 | 69346 | ** constraint violations present in the database to the value stored |
| 68978 | 69347 | ** when the savepoint was created. */ |
| 68979 | | - if( u.as.p1==SAVEPOINT_RELEASE ){ |
| 68980 | | - assert( u.as.pSavepoint==db->pSavepoint ); |
| 68981 | | - db->pSavepoint = u.as.pSavepoint->pNext; |
| 68982 | | - sqlite3DbFree(db, u.as.pSavepoint); |
| 69348 | + if( u.at.p1==SAVEPOINT_RELEASE ){ |
| 69349 | + assert( u.at.pSavepoint==db->pSavepoint ); |
| 69350 | + db->pSavepoint = u.at.pSavepoint->pNext; |
| 69351 | + sqlite3DbFree(db, u.at.pSavepoint); |
| 68983 | 69352 | if( !isTransaction ){ |
| 68984 | 69353 | db->nSavepoint--; |
| 68985 | 69354 | } |
| 68986 | 69355 | }else{ |
| 68987 | | - db->nDeferredCons = u.as.pSavepoint->nDeferredCons; |
| 68988 | | - db->nDeferredImmCons = u.as.pSavepoint->nDeferredImmCons; |
| 69356 | + db->nDeferredCons = u.at.pSavepoint->nDeferredCons; |
| 69357 | + db->nDeferredImmCons = u.at.pSavepoint->nDeferredImmCons; |
| 68989 | 69358 | } |
| 68990 | 69359 | |
| 68991 | 69360 | if( !isTransaction ){ |
| 68992 | | - rc = sqlite3VtabSavepoint(db, u.as.p1, u.as.iSavepoint); |
| 69361 | + rc = sqlite3VtabSavepoint(db, u.at.p1, u.at.iSavepoint); |
| 68993 | 69362 | if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 68994 | 69363 | } |
| 68995 | 69364 | } |
| 68996 | 69365 | } |
| 68997 | 69366 | |
| | @@ -69006,54 +69375,54 @@ |
| 69006 | 69375 | ** there are active writing VMs or active VMs that use shared cache. |
| 69007 | 69376 | ** |
| 69008 | 69377 | ** This instruction causes the VM to halt. |
| 69009 | 69378 | */ |
| 69010 | 69379 | case OP_AutoCommit: { |
| 69011 | | -#if 0 /* local variables moved into u.at */ |
| 69380 | +#if 0 /* local variables moved into u.au */ |
| 69012 | 69381 | int desiredAutoCommit; |
| 69013 | 69382 | int iRollback; |
| 69014 | 69383 | int turnOnAC; |
| 69015 | | -#endif /* local variables moved into u.at */ |
| 69384 | +#endif /* local variables moved into u.au */ |
| 69016 | 69385 | |
| 69017 | | - u.at.desiredAutoCommit = pOp->p1; |
| 69018 | | - u.at.iRollback = pOp->p2; |
| 69019 | | - u.at.turnOnAC = u.at.desiredAutoCommit && !db->autoCommit; |
| 69020 | | - assert( u.at.desiredAutoCommit==1 || u.at.desiredAutoCommit==0 ); |
| 69021 | | - assert( u.at.desiredAutoCommit==1 || u.at.iRollback==0 ); |
| 69386 | + u.au.desiredAutoCommit = pOp->p1; |
| 69387 | + u.au.iRollback = pOp->p2; |
| 69388 | + u.au.turnOnAC = u.au.desiredAutoCommit && !db->autoCommit; |
| 69389 | + assert( u.au.desiredAutoCommit==1 || u.au.desiredAutoCommit==0 ); |
| 69390 | + assert( u.au.desiredAutoCommit==1 || u.au.iRollback==0 ); |
| 69022 | 69391 | assert( db->nVdbeActive>0 ); /* At least this one VM is active */ |
| 69023 | 69392 | assert( p->bIsReader ); |
| 69024 | 69393 | |
| 69025 | 69394 | #if 0 |
| 69026 | | - if( u.at.turnOnAC && u.at.iRollback && db->nVdbeActive>1 ){ |
| 69395 | + if( u.au.turnOnAC && u.au.iRollback && db->nVdbeActive>1 ){ |
| 69027 | 69396 | /* If this instruction implements a ROLLBACK and other VMs are |
| 69028 | 69397 | ** still running, and a transaction is active, return an error indicating |
| 69029 | 69398 | ** that the other VMs must complete first. |
| 69030 | 69399 | */ |
| 69031 | 69400 | sqlite3SetString(&p->zErrMsg, db, "cannot rollback transaction - " |
| 69032 | 69401 | "SQL statements in progress"); |
| 69033 | 69402 | rc = SQLITE_BUSY; |
| 69034 | 69403 | }else |
| 69035 | 69404 | #endif |
| 69036 | | - if( u.at.turnOnAC && !u.at.iRollback && db->nVdbeWrite>0 ){ |
| 69405 | + if( u.au.turnOnAC && !u.au.iRollback && db->nVdbeWrite>0 ){ |
| 69037 | 69406 | /* If this instruction implements a COMMIT and other VMs are writing |
| 69038 | 69407 | ** return an error indicating that the other VMs must complete first. |
| 69039 | 69408 | */ |
| 69040 | 69409 | sqlite3SetString(&p->zErrMsg, db, "cannot commit transaction - " |
| 69041 | 69410 | "SQL statements in progress"); |
| 69042 | 69411 | rc = SQLITE_BUSY; |
| 69043 | | - }else if( u.at.desiredAutoCommit!=db->autoCommit ){ |
| 69044 | | - if( u.at.iRollback ){ |
| 69045 | | - assert( u.at.desiredAutoCommit==1 ); |
| 69412 | + }else if( u.au.desiredAutoCommit!=db->autoCommit ){ |
| 69413 | + if( u.au.iRollback ){ |
| 69414 | + assert( u.au.desiredAutoCommit==1 ); |
| 69046 | 69415 | sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK); |
| 69047 | 69416 | db->autoCommit = 1; |
| 69048 | 69417 | }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){ |
| 69049 | 69418 | goto vdbe_return; |
| 69050 | 69419 | }else{ |
| 69051 | | - db->autoCommit = (u8)u.at.desiredAutoCommit; |
| 69420 | + db->autoCommit = (u8)u.au.desiredAutoCommit; |
| 69052 | 69421 | if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){ |
| 69053 | 69422 | p->pc = pc; |
| 69054 | | - db->autoCommit = (u8)(1-u.at.desiredAutoCommit); |
| 69423 | + db->autoCommit = (u8)(1-u.au.desiredAutoCommit); |
| 69055 | 69424 | p->rc = rc = SQLITE_BUSY; |
| 69056 | 69425 | goto vdbe_return; |
| 69057 | 69426 | } |
| 69058 | 69427 | } |
| 69059 | 69428 | assert( db->nStatement==0 ); |
| | @@ -69064,12 +69433,12 @@ |
| 69064 | 69433 | rc = SQLITE_ERROR; |
| 69065 | 69434 | } |
| 69066 | 69435 | goto vdbe_return; |
| 69067 | 69436 | }else{ |
| 69068 | 69437 | sqlite3SetString(&p->zErrMsg, db, |
| 69069 | | - (!u.at.desiredAutoCommit)?"cannot start a transaction within a transaction":( |
| 69070 | | - (u.at.iRollback)?"cannot rollback - no transaction is active": |
| 69438 | + (!u.au.desiredAutoCommit)?"cannot start a transaction within a transaction":( |
| 69439 | + (u.au.iRollback)?"cannot rollback - no transaction is active": |
| 69071 | 69440 | "cannot commit - no transaction is active")); |
| 69072 | 69441 | |
| 69073 | 69442 | rc = SQLITE_ERROR; |
| 69074 | 69443 | } |
| 69075 | 69444 | break; |
| | @@ -69105,26 +69474,26 @@ |
| 69105 | 69474 | ** will automatically commit when the VDBE halts. |
| 69106 | 69475 | ** |
| 69107 | 69476 | ** If P2 is zero, then a read-lock is obtained on the database file. |
| 69108 | 69477 | */ |
| 69109 | 69478 | case OP_Transaction: { |
| 69110 | | -#if 0 /* local variables moved into u.au */ |
| 69479 | +#if 0 /* local variables moved into u.av */ |
| 69111 | 69480 | Btree *pBt; |
| 69112 | | -#endif /* local variables moved into u.au */ |
| 69481 | +#endif /* local variables moved into u.av */ |
| 69113 | 69482 | |
| 69114 | 69483 | assert( p->bIsReader ); |
| 69115 | 69484 | assert( p->readOnly==0 || pOp->p2==0 ); |
| 69116 | 69485 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 69117 | 69486 | assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 ); |
| 69118 | 69487 | if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){ |
| 69119 | 69488 | rc = SQLITE_READONLY; |
| 69120 | 69489 | goto abort_due_to_error; |
| 69121 | 69490 | } |
| 69122 | | - u.au.pBt = db->aDb[pOp->p1].pBt; |
| 69491 | + u.av.pBt = db->aDb[pOp->p1].pBt; |
| 69123 | 69492 | |
| 69124 | | - if( u.au.pBt ){ |
| 69125 | | - rc = sqlite3BtreeBeginTrans(u.au.pBt, pOp->p2); |
| 69493 | + if( u.av.pBt ){ |
| 69494 | + rc = sqlite3BtreeBeginTrans(u.av.pBt, pOp->p2); |
| 69126 | 69495 | if( rc==SQLITE_BUSY ){ |
| 69127 | 69496 | p->pc = pc; |
| 69128 | 69497 | p->rc = rc = SQLITE_BUSY; |
| 69129 | 69498 | goto vdbe_return; |
| 69130 | 69499 | } |
| | @@ -69133,20 +69502,20 @@ |
| 69133 | 69502 | } |
| 69134 | 69503 | |
| 69135 | 69504 | if( pOp->p2 && p->usesStmtJournal |
| 69136 | 69505 | && (db->autoCommit==0 || db->nVdbeRead>1) |
| 69137 | 69506 | ){ |
| 69138 | | - assert( sqlite3BtreeIsInTrans(u.au.pBt) ); |
| 69507 | + assert( sqlite3BtreeIsInTrans(u.av.pBt) ); |
| 69139 | 69508 | if( p->iStatement==0 ){ |
| 69140 | 69509 | assert( db->nStatement>=0 && db->nSavepoint>=0 ); |
| 69141 | 69510 | db->nStatement++; |
| 69142 | 69511 | p->iStatement = db->nSavepoint + db->nStatement; |
| 69143 | 69512 | } |
| 69144 | 69513 | |
| 69145 | 69514 | rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, p->iStatement-1); |
| 69146 | 69515 | if( rc==SQLITE_OK ){ |
| 69147 | | - rc = sqlite3BtreeBeginStmt(u.au.pBt, p->iStatement); |
| 69516 | + rc = sqlite3BtreeBeginStmt(u.av.pBt, p->iStatement); |
| 69148 | 69517 | } |
| 69149 | 69518 | |
| 69150 | 69519 | /* Store the current value of the database handles deferred constraint |
| 69151 | 69520 | ** counter. If the statement transaction needs to be rolled back, |
| 69152 | 69521 | ** the value of this counter needs to be restored too. */ |
| | @@ -69168,26 +69537,26 @@ |
| 69168 | 69537 | ** There must be a read-lock on the database (either a transaction |
| 69169 | 69538 | ** must be started or there must be an open cursor) before |
| 69170 | 69539 | ** executing this instruction. |
| 69171 | 69540 | */ |
| 69172 | 69541 | case OP_ReadCookie: { /* out2-prerelease */ |
| 69173 | | -#if 0 /* local variables moved into u.av */ |
| 69542 | +#if 0 /* local variables moved into u.aw */ |
| 69174 | 69543 | int iMeta; |
| 69175 | 69544 | int iDb; |
| 69176 | 69545 | int iCookie; |
| 69177 | | -#endif /* local variables moved into u.av */ |
| 69546 | +#endif /* local variables moved into u.aw */ |
| 69178 | 69547 | |
| 69179 | 69548 | assert( p->bIsReader ); |
| 69180 | | - u.av.iDb = pOp->p1; |
| 69181 | | - u.av.iCookie = pOp->p3; |
| 69549 | + u.aw.iDb = pOp->p1; |
| 69550 | + u.aw.iCookie = pOp->p3; |
| 69182 | 69551 | assert( pOp->p3<SQLITE_N_BTREE_META ); |
| 69183 | | - assert( u.av.iDb>=0 && u.av.iDb<db->nDb ); |
| 69184 | | - assert( db->aDb[u.av.iDb].pBt!=0 ); |
| 69185 | | - assert( (p->btreeMask & (((yDbMask)1)<<u.av.iDb))!=0 ); |
| 69552 | + assert( u.aw.iDb>=0 && u.aw.iDb<db->nDb ); |
| 69553 | + assert( db->aDb[u.aw.iDb].pBt!=0 ); |
| 69554 | + assert( (p->btreeMask & (((yDbMask)1)<<u.aw.iDb))!=0 ); |
| 69186 | 69555 | |
| 69187 | | - sqlite3BtreeGetMeta(db->aDb[u.av.iDb].pBt, u.av.iCookie, (u32 *)&u.av.iMeta); |
| 69188 | | - pOut->u.i = u.av.iMeta; |
| 69556 | + sqlite3BtreeGetMeta(db->aDb[u.aw.iDb].pBt, u.aw.iCookie, (u32 *)&u.aw.iMeta); |
| 69557 | + pOut->u.i = u.aw.iMeta; |
| 69189 | 69558 | break; |
| 69190 | 69559 | } |
| 69191 | 69560 | |
| 69192 | 69561 | /* Opcode: SetCookie P1 P2 P3 * * |
| 69193 | 69562 | ** |
| | @@ -69198,31 +69567,31 @@ |
| 69198 | 69567 | ** database file used to store temporary tables. |
| 69199 | 69568 | ** |
| 69200 | 69569 | ** A transaction must be started before executing this opcode. |
| 69201 | 69570 | */ |
| 69202 | 69571 | case OP_SetCookie: { /* in3 */ |
| 69203 | | -#if 0 /* local variables moved into u.aw */ |
| 69572 | +#if 0 /* local variables moved into u.ax */ |
| 69204 | 69573 | Db *pDb; |
| 69205 | | -#endif /* local variables moved into u.aw */ |
| 69574 | +#endif /* local variables moved into u.ax */ |
| 69206 | 69575 | assert( pOp->p2<SQLITE_N_BTREE_META ); |
| 69207 | 69576 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 69208 | 69577 | assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 ); |
| 69209 | 69578 | assert( p->readOnly==0 ); |
| 69210 | | - u.aw.pDb = &db->aDb[pOp->p1]; |
| 69211 | | - assert( u.aw.pDb->pBt!=0 ); |
| 69579 | + u.ax.pDb = &db->aDb[pOp->p1]; |
| 69580 | + assert( u.ax.pDb->pBt!=0 ); |
| 69212 | 69581 | assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) ); |
| 69213 | 69582 | pIn3 = &aMem[pOp->p3]; |
| 69214 | 69583 | sqlite3VdbeMemIntegerify(pIn3); |
| 69215 | 69584 | /* See note about index shifting on OP_ReadCookie */ |
| 69216 | | - rc = sqlite3BtreeUpdateMeta(u.aw.pDb->pBt, pOp->p2, (int)pIn3->u.i); |
| 69585 | + rc = sqlite3BtreeUpdateMeta(u.ax.pDb->pBt, pOp->p2, (int)pIn3->u.i); |
| 69217 | 69586 | if( pOp->p2==BTREE_SCHEMA_VERSION ){ |
| 69218 | 69587 | /* When the schema cookie changes, record the new cookie internally */ |
| 69219 | | - u.aw.pDb->pSchema->schema_cookie = (int)pIn3->u.i; |
| 69588 | + u.ax.pDb->pSchema->schema_cookie = (int)pIn3->u.i; |
| 69220 | 69589 | db->flags |= SQLITE_InternChanges; |
| 69221 | 69590 | }else if( pOp->p2==BTREE_FILE_FORMAT ){ |
| 69222 | 69591 | /* Record changes in the file format */ |
| 69223 | | - u.aw.pDb->pSchema->file_format = (u8)pIn3->u.i; |
| 69592 | + u.ax.pDb->pSchema->file_format = (u8)pIn3->u.i; |
| 69224 | 69593 | } |
| 69225 | 69594 | if( pOp->p1==1 ){ |
| 69226 | 69595 | /* Invalidate all prepared statements whenever the TEMP database |
| 69227 | 69596 | ** schema is changed. Ticket #1644 */ |
| 69228 | 69597 | sqlite3ExpirePreparedStatements(db); |
| | @@ -69248,28 +69617,28 @@ |
| 69248 | 69617 | ** Either a transaction needs to have been started or an OP_Open needs |
| 69249 | 69618 | ** to be executed (to establish a read lock) before this opcode is |
| 69250 | 69619 | ** invoked. |
| 69251 | 69620 | */ |
| 69252 | 69621 | case OP_VerifyCookie: { |
| 69253 | | -#if 0 /* local variables moved into u.ax */ |
| 69622 | +#if 0 /* local variables moved into u.ay */ |
| 69254 | 69623 | int iMeta; |
| 69255 | 69624 | int iGen; |
| 69256 | 69625 | Btree *pBt; |
| 69257 | | -#endif /* local variables moved into u.ax */ |
| 69626 | +#endif /* local variables moved into u.ay */ |
| 69258 | 69627 | |
| 69259 | 69628 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 69260 | 69629 | assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 ); |
| 69261 | 69630 | assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) ); |
| 69262 | 69631 | assert( p->bIsReader ); |
| 69263 | | - u.ax.pBt = db->aDb[pOp->p1].pBt; |
| 69264 | | - if( u.ax.pBt ){ |
| 69265 | | - sqlite3BtreeGetMeta(u.ax.pBt, BTREE_SCHEMA_VERSION, (u32 *)&u.ax.iMeta); |
| 69266 | | - u.ax.iGen = db->aDb[pOp->p1].pSchema->iGeneration; |
| 69632 | + u.ay.pBt = db->aDb[pOp->p1].pBt; |
| 69633 | + if( u.ay.pBt ){ |
| 69634 | + sqlite3BtreeGetMeta(u.ay.pBt, BTREE_SCHEMA_VERSION, (u32 *)&u.ay.iMeta); |
| 69635 | + u.ay.iGen = db->aDb[pOp->p1].pSchema->iGeneration; |
| 69267 | 69636 | }else{ |
| 69268 | | - u.ax.iGen = u.ax.iMeta = 0; |
| 69637 | + u.ay.iGen = u.ay.iMeta = 0; |
| 69269 | 69638 | } |
| 69270 | | - if( u.ax.iMeta!=pOp->p2 || u.ax.iGen!=pOp->p3 ){ |
| 69639 | + if( u.ay.iMeta!=pOp->p2 || u.ay.iGen!=pOp->p3 ){ |
| 69271 | 69640 | sqlite3DbFree(db, p->zErrMsg); |
| 69272 | 69641 | p->zErrMsg = sqlite3DbStrDup(db, "database schema has changed"); |
| 69273 | 69642 | /* If the schema-cookie from the database file matches the cookie |
| 69274 | 69643 | ** stored with the in-memory representation of the schema, do |
| 69275 | 69644 | ** not reload the schema from the database file. |
| | @@ -69281,11 +69650,11 @@ |
| 69281 | 69650 | ** discard the database schema, as the user code implementing the |
| 69282 | 69651 | ** v-table would have to be ready for the sqlite3_vtab structure itself |
| 69283 | 69652 | ** to be invalidated whenever sqlite3_step() is called from within |
| 69284 | 69653 | ** a v-table method. |
| 69285 | 69654 | */ |
| 69286 | | - if( db->aDb[pOp->p1].pSchema->schema_cookie!=u.ax.iMeta ){ |
| 69655 | + if( db->aDb[pOp->p1].pSchema->schema_cookie!=u.ay.iMeta ){ |
| 69287 | 69656 | sqlite3ResetOneSchema(db, pOp->p1); |
| 69288 | 69657 | } |
| 69289 | 69658 | |
| 69290 | 69659 | p->expired = 1; |
| 69291 | 69660 | rc = SQLITE_SCHEMA; |
| | @@ -69292,10 +69661,11 @@ |
| 69292 | 69661 | } |
| 69293 | 69662 | break; |
| 69294 | 69663 | } |
| 69295 | 69664 | |
| 69296 | 69665 | /* Opcode: OpenRead P1 P2 P3 P4 P5 |
| 69666 | +** Synopsis: root=P2 iDb=P3 |
| 69297 | 69667 | ** |
| 69298 | 69668 | ** Open a read-only cursor for the database table whose root page is |
| 69299 | 69669 | ** P2 in a database file. The database file is determined by P3. |
| 69300 | 69670 | ** P3==0 means the main database, P3==1 means the database used for |
| 69301 | 69671 | ** temporary tables, and P3>1 means used the corresponding attached |
| | @@ -69322,10 +69692,11 @@ |
| 69322 | 69692 | ** value, it is set to the number of columns in the table. |
| 69323 | 69693 | ** |
| 69324 | 69694 | ** See also OpenWrite. |
| 69325 | 69695 | */ |
| 69326 | 69696 | /* Opcode: OpenWrite P1 P2 P3 P4 P5 |
| 69697 | +** Synopsis: root=P2 iDb=P3 |
| 69327 | 69698 | ** |
| 69328 | 69699 | ** Open a read/write cursor named P1 on the table or index whose root |
| 69329 | 69700 | ** page is P2. Or if P5!=0 use the content of register P2 to find the |
| 69330 | 69701 | ** root page. |
| 69331 | 69702 | ** |
| | @@ -69342,20 +69713,20 @@ |
| 69342 | 69713 | ** |
| 69343 | 69714 | ** See also OpenRead. |
| 69344 | 69715 | */ |
| 69345 | 69716 | case OP_OpenRead: |
| 69346 | 69717 | case OP_OpenWrite: { |
| 69347 | | -#if 0 /* local variables moved into u.ay */ |
| 69718 | +#if 0 /* local variables moved into u.az */ |
| 69348 | 69719 | int nField; |
| 69349 | 69720 | KeyInfo *pKeyInfo; |
| 69350 | 69721 | int p2; |
| 69351 | 69722 | int iDb; |
| 69352 | 69723 | int wrFlag; |
| 69353 | 69724 | Btree *pX; |
| 69354 | 69725 | VdbeCursor *pCur; |
| 69355 | 69726 | Db *pDb; |
| 69356 | | -#endif /* local variables moved into u.ay */ |
| 69727 | +#endif /* local variables moved into u.az */ |
| 69357 | 69728 | |
| 69358 | 69729 | assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 ); |
| 69359 | 69730 | assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 ); |
| 69360 | 69731 | assert( p->bIsReader ); |
| 69361 | 69732 | assert( pOp->opcode==OP_OpenRead || p->readOnly==0 ); |
| | @@ -69363,76 +69734,78 @@ |
| 69363 | 69734 | if( p->expired ){ |
| 69364 | 69735 | rc = SQLITE_ABORT; |
| 69365 | 69736 | break; |
| 69366 | 69737 | } |
| 69367 | 69738 | |
| 69368 | | - u.ay.nField = 0; |
| 69369 | | - u.ay.pKeyInfo = 0; |
| 69370 | | - u.ay.p2 = pOp->p2; |
| 69371 | | - u.ay.iDb = pOp->p3; |
| 69372 | | - assert( u.ay.iDb>=0 && u.ay.iDb<db->nDb ); |
| 69373 | | - assert( (p->btreeMask & (((yDbMask)1)<<u.ay.iDb))!=0 ); |
| 69374 | | - u.ay.pDb = &db->aDb[u.ay.iDb]; |
| 69375 | | - u.ay.pX = u.ay.pDb->pBt; |
| 69376 | | - assert( u.ay.pX!=0 ); |
| 69739 | + u.az.nField = 0; |
| 69740 | + u.az.pKeyInfo = 0; |
| 69741 | + u.az.p2 = pOp->p2; |
| 69742 | + u.az.iDb = pOp->p3; |
| 69743 | + assert( u.az.iDb>=0 && u.az.iDb<db->nDb ); |
| 69744 | + assert( (p->btreeMask & (((yDbMask)1)<<u.az.iDb))!=0 ); |
| 69745 | + u.az.pDb = &db->aDb[u.az.iDb]; |
| 69746 | + u.az.pX = u.az.pDb->pBt; |
| 69747 | + assert( u.az.pX!=0 ); |
| 69377 | 69748 | if( pOp->opcode==OP_OpenWrite ){ |
| 69378 | | - u.ay.wrFlag = 1; |
| 69379 | | - assert( sqlite3SchemaMutexHeld(db, u.ay.iDb, 0) ); |
| 69380 | | - if( u.ay.pDb->pSchema->file_format < p->minWriteFileFormat ){ |
| 69381 | | - p->minWriteFileFormat = u.ay.pDb->pSchema->file_format; |
| 69749 | + u.az.wrFlag = 1; |
| 69750 | + assert( sqlite3SchemaMutexHeld(db, u.az.iDb, 0) ); |
| 69751 | + if( u.az.pDb->pSchema->file_format < p->minWriteFileFormat ){ |
| 69752 | + p->minWriteFileFormat = u.az.pDb->pSchema->file_format; |
| 69382 | 69753 | } |
| 69383 | 69754 | }else{ |
| 69384 | | - u.ay.wrFlag = 0; |
| 69755 | + u.az.wrFlag = 0; |
| 69385 | 69756 | } |
| 69386 | 69757 | if( pOp->p5 & OPFLAG_P2ISREG ){ |
| 69387 | | - assert( u.ay.p2>0 ); |
| 69388 | | - assert( u.ay.p2<=(p->nMem-p->nCursor) ); |
| 69389 | | - pIn2 = &aMem[u.ay.p2]; |
| 69758 | + assert( u.az.p2>0 ); |
| 69759 | + assert( u.az.p2<=(p->nMem-p->nCursor) ); |
| 69760 | + pIn2 = &aMem[u.az.p2]; |
| 69390 | 69761 | assert( memIsValid(pIn2) ); |
| 69391 | 69762 | assert( (pIn2->flags & MEM_Int)!=0 ); |
| 69392 | 69763 | sqlite3VdbeMemIntegerify(pIn2); |
| 69393 | | - u.ay.p2 = (int)pIn2->u.i; |
| 69394 | | - /* The u.ay.p2 value always comes from a prior OP_CreateTable opcode and |
| 69395 | | - ** that opcode will always set the u.ay.p2 value to 2 or more or else fail. |
| 69764 | + u.az.p2 = (int)pIn2->u.i; |
| 69765 | + /* The u.az.p2 value always comes from a prior OP_CreateTable opcode and |
| 69766 | + ** that opcode will always set the u.az.p2 value to 2 or more or else fail. |
| 69396 | 69767 | ** If there were a failure, the prepared statement would have halted |
| 69397 | 69768 | ** before reaching this instruction. */ |
| 69398 | | - if( NEVER(u.ay.p2<2) ) { |
| 69769 | + if( NEVER(u.az.p2<2) ) { |
| 69399 | 69770 | rc = SQLITE_CORRUPT_BKPT; |
| 69400 | 69771 | goto abort_due_to_error; |
| 69401 | 69772 | } |
| 69402 | 69773 | } |
| 69403 | 69774 | if( pOp->p4type==P4_KEYINFO ){ |
| 69404 | | - u.ay.pKeyInfo = pOp->p4.pKeyInfo; |
| 69405 | | - u.ay.pKeyInfo->enc = ENC(p->db); |
| 69406 | | - u.ay.nField = u.ay.pKeyInfo->nField+1; |
| 69775 | + u.az.pKeyInfo = pOp->p4.pKeyInfo; |
| 69776 | + assert( u.az.pKeyInfo->enc==ENC(db) ); |
| 69777 | + assert( u.az.pKeyInfo->db==db ); |
| 69778 | + u.az.nField = u.az.pKeyInfo->nField+u.az.pKeyInfo->nXField; |
| 69407 | 69779 | }else if( pOp->p4type==P4_INT32 ){ |
| 69408 | | - u.ay.nField = pOp->p4.i; |
| 69780 | + u.az.nField = pOp->p4.i; |
| 69409 | 69781 | } |
| 69410 | 69782 | assert( pOp->p1>=0 ); |
| 69411 | | - u.ay.pCur = allocateCursor(p, pOp->p1, u.ay.nField, u.ay.iDb, 1); |
| 69412 | | - if( u.ay.pCur==0 ) goto no_mem; |
| 69413 | | - u.ay.pCur->nullRow = 1; |
| 69414 | | - u.ay.pCur->isOrdered = 1; |
| 69415 | | - rc = sqlite3BtreeCursor(u.ay.pX, u.ay.p2, u.ay.wrFlag, u.ay.pKeyInfo, u.ay.pCur->pCursor); |
| 69416 | | - u.ay.pCur->pKeyInfo = u.ay.pKeyInfo; |
| 69783 | + u.az.pCur = allocateCursor(p, pOp->p1, u.az.nField, u.az.iDb, 1); |
| 69784 | + if( u.az.pCur==0 ) goto no_mem; |
| 69785 | + u.az.pCur->nullRow = 1; |
| 69786 | + u.az.pCur->isOrdered = 1; |
| 69787 | + rc = sqlite3BtreeCursor(u.az.pX, u.az.p2, u.az.wrFlag, u.az.pKeyInfo, u.az.pCur->pCursor); |
| 69788 | + u.az.pCur->pKeyInfo = u.az.pKeyInfo; |
| 69417 | 69789 | assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); |
| 69418 | | - sqlite3BtreeCursorHints(u.ay.pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR)); |
| 69790 | + sqlite3BtreeCursorHints(u.az.pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR)); |
| 69419 | 69791 | |
| 69420 | 69792 | /* Since it performs no memory allocation or IO, the only value that |
| 69421 | 69793 | ** sqlite3BtreeCursor() may return is SQLITE_OK. */ |
| 69422 | 69794 | assert( rc==SQLITE_OK ); |
| 69423 | 69795 | |
| 69424 | 69796 | /* Set the VdbeCursor.isTable and isIndex variables. Previous versions of |
| 69425 | 69797 | ** SQLite used to check if the root-page flags were sane at this point |
| 69426 | 69798 | ** and report database corruption if they were not, but this check has |
| 69427 | 69799 | ** since moved into the btree layer. */ |
| 69428 | | - u.ay.pCur->isTable = pOp->p4type!=P4_KEYINFO; |
| 69429 | | - u.ay.pCur->isIndex = !u.ay.pCur->isTable; |
| 69800 | + u.az.pCur->isTable = pOp->p4type!=P4_KEYINFO; |
| 69801 | + u.az.pCur->isIndex = !u.az.pCur->isTable; |
| 69430 | 69802 | break; |
| 69431 | 69803 | } |
| 69432 | 69804 | |
| 69433 | 69805 | /* Opcode: OpenEphemeral P1 P2 * P4 P5 |
| 69806 | +** Synopsis: nColumn=P2 |
| 69434 | 69807 | ** |
| 69435 | 69808 | ** Open a new cursor P1 to a transient table. |
| 69436 | 69809 | ** The cursor is always opened read/write even if |
| 69437 | 69810 | ** the main database is read-only. The ephemeral |
| 69438 | 69811 | ** table is deleted automatically when the cursor is closed. |
| | @@ -69440,98 +69813,96 @@ |
| 69440 | 69813 | ** P2 is the number of columns in the ephemeral table. |
| 69441 | 69814 | ** The cursor points to a BTree table if P4==0 and to a BTree index |
| 69442 | 69815 | ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure |
| 69443 | 69816 | ** that defines the format of keys in the index. |
| 69444 | 69817 | ** |
| 69445 | | -** This opcode was once called OpenTemp. But that created |
| 69446 | | -** confusion because the term "temp table", might refer either |
| 69447 | | -** to a TEMP table at the SQL level, or to a table opened by |
| 69448 | | -** this opcode. Then this opcode was call OpenVirtual. But |
| 69449 | | -** that created confusion with the whole virtual-table idea. |
| 69450 | | -** |
| 69451 | 69818 | ** The P5 parameter can be a mask of the BTREE_* flags defined |
| 69452 | 69819 | ** in btree.h. These flags control aspects of the operation of |
| 69453 | 69820 | ** the btree. The BTREE_OMIT_JOURNAL and BTREE_SINGLE flags are |
| 69454 | 69821 | ** added automatically. |
| 69455 | 69822 | */ |
| 69456 | 69823 | /* Opcode: OpenAutoindex P1 P2 * P4 * |
| 69824 | +** Synopsis: nColumn=P2 |
| 69457 | 69825 | ** |
| 69458 | 69826 | ** This opcode works the same as OP_OpenEphemeral. It has a |
| 69459 | 69827 | ** different name to distinguish its use. Tables created using |
| 69460 | 69828 | ** by this opcode will be used for automatically created transient |
| 69461 | 69829 | ** indices in joins. |
| 69462 | 69830 | */ |
| 69463 | 69831 | case OP_OpenAutoindex: |
| 69464 | 69832 | case OP_OpenEphemeral: { |
| 69465 | | -#if 0 /* local variables moved into u.az */ |
| 69833 | +#if 0 /* local variables moved into u.ba */ |
| 69466 | 69834 | VdbeCursor *pCx; |
| 69467 | | -#endif /* local variables moved into u.az */ |
| 69835 | + KeyInfo *pKeyInfo; |
| 69836 | +#endif /* local variables moved into u.ba */ |
| 69837 | + |
| 69468 | 69838 | static const int vfsFlags = |
| 69469 | 69839 | SQLITE_OPEN_READWRITE | |
| 69470 | 69840 | SQLITE_OPEN_CREATE | |
| 69471 | 69841 | SQLITE_OPEN_EXCLUSIVE | |
| 69472 | 69842 | SQLITE_OPEN_DELETEONCLOSE | |
| 69473 | 69843 | SQLITE_OPEN_TRANSIENT_DB; |
| 69474 | | - |
| 69475 | 69844 | assert( pOp->p1>=0 ); |
| 69476 | | - u.az.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); |
| 69477 | | - if( u.az.pCx==0 ) goto no_mem; |
| 69478 | | - u.az.pCx->nullRow = 1; |
| 69479 | | - rc = sqlite3BtreeOpen(db->pVfs, 0, db, &u.az.pCx->pBt, |
| 69845 | + u.ba.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); |
| 69846 | + if( u.ba.pCx==0 ) goto no_mem; |
| 69847 | + u.ba.pCx->nullRow = 1; |
| 69848 | + rc = sqlite3BtreeOpen(db->pVfs, 0, db, &u.ba.pCx->pBt, |
| 69480 | 69849 | BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags); |
| 69481 | 69850 | if( rc==SQLITE_OK ){ |
| 69482 | | - rc = sqlite3BtreeBeginTrans(u.az.pCx->pBt, 1); |
| 69851 | + rc = sqlite3BtreeBeginTrans(u.ba.pCx->pBt, 1); |
| 69483 | 69852 | } |
| 69484 | 69853 | if( rc==SQLITE_OK ){ |
| 69485 | 69854 | /* If a transient index is required, create it by calling |
| 69486 | 69855 | ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before |
| 69487 | 69856 | ** opening it. If a transient table is required, just use the |
| 69488 | 69857 | ** automatically created table with root-page 1 (an BLOB_INTKEY table). |
| 69489 | 69858 | */ |
| 69490 | | - if( pOp->p4.pKeyInfo ){ |
| 69859 | + if( (u.ba.pKeyInfo = pOp->p4.pKeyInfo)!=0 ){ |
| 69491 | 69860 | int pgno; |
| 69492 | 69861 | assert( pOp->p4type==P4_KEYINFO ); |
| 69493 | | - rc = sqlite3BtreeCreateTable(u.az.pCx->pBt, &pgno, BTREE_BLOBKEY | pOp->p5); |
| 69862 | + rc = sqlite3BtreeCreateTable(u.ba.pCx->pBt, &pgno, BTREE_BLOBKEY | pOp->p5); |
| 69494 | 69863 | if( rc==SQLITE_OK ){ |
| 69495 | 69864 | assert( pgno==MASTER_ROOT+1 ); |
| 69496 | | - rc = sqlite3BtreeCursor(u.az.pCx->pBt, pgno, 1, |
| 69497 | | - (KeyInfo*)pOp->p4.z, u.az.pCx->pCursor); |
| 69498 | | - u.az.pCx->pKeyInfo = pOp->p4.pKeyInfo; |
| 69499 | | - u.az.pCx->pKeyInfo->enc = ENC(p->db); |
| 69500 | | - } |
| 69501 | | - u.az.pCx->isTable = 0; |
| 69502 | | - }else{ |
| 69503 | | - rc = sqlite3BtreeCursor(u.az.pCx->pBt, MASTER_ROOT, 1, 0, u.az.pCx->pCursor); |
| 69504 | | - u.az.pCx->isTable = 1; |
| 69865 | + assert( u.ba.pKeyInfo->db==db ); |
| 69866 | + assert( u.ba.pKeyInfo->enc==ENC(db) ); |
| 69867 | + u.ba.pCx->pKeyInfo = u.ba.pKeyInfo; |
| 69868 | + rc = sqlite3BtreeCursor(u.ba.pCx->pBt, pgno, 1, u.ba.pKeyInfo, u.ba.pCx->pCursor); |
| 69869 | + } |
| 69870 | + u.ba.pCx->isTable = 0; |
| 69871 | + }else{ |
| 69872 | + rc = sqlite3BtreeCursor(u.ba.pCx->pBt, MASTER_ROOT, 1, 0, u.ba.pCx->pCursor); |
| 69873 | + u.ba.pCx->isTable = 1; |
| 69505 | 69874 | } |
| 69506 | 69875 | } |
| 69507 | | - u.az.pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED); |
| 69508 | | - u.az.pCx->isIndex = !u.az.pCx->isTable; |
| 69876 | + u.ba.pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED); |
| 69877 | + u.ba.pCx->isIndex = !u.ba.pCx->isTable; |
| 69509 | 69878 | break; |
| 69510 | 69879 | } |
| 69511 | 69880 | |
| 69512 | | -/* Opcode: SorterOpen P1 P2 * P4 * |
| 69881 | +/* Opcode: SorterOpen P1 * * P4 * |
| 69513 | 69882 | ** |
| 69514 | 69883 | ** This opcode works like OP_OpenEphemeral except that it opens |
| 69515 | 69884 | ** a transient index that is specifically designed to sort large |
| 69516 | 69885 | ** tables using an external merge-sort algorithm. |
| 69517 | 69886 | */ |
| 69518 | 69887 | case OP_SorterOpen: { |
| 69519 | | -#if 0 /* local variables moved into u.ba */ |
| 69888 | +#if 0 /* local variables moved into u.bb */ |
| 69520 | 69889 | VdbeCursor *pCx; |
| 69521 | | -#endif /* local variables moved into u.ba */ |
| 69522 | | - |
| 69523 | | - u.ba.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); |
| 69524 | | - if( u.ba.pCx==0 ) goto no_mem; |
| 69525 | | - u.ba.pCx->pKeyInfo = pOp->p4.pKeyInfo; |
| 69526 | | - u.ba.pCx->pKeyInfo->enc = ENC(p->db); |
| 69527 | | - u.ba.pCx->isSorter = 1; |
| 69528 | | - rc = sqlite3VdbeSorterInit(db, u.ba.pCx); |
| 69890 | +#endif /* local variables moved into u.bb */ |
| 69891 | + |
| 69892 | + u.bb.pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, 1); |
| 69893 | + if( u.bb.pCx==0 ) goto no_mem; |
| 69894 | + u.bb.pCx->pKeyInfo = pOp->p4.pKeyInfo; |
| 69895 | + assert( u.bb.pCx->pKeyInfo->db==db ); |
| 69896 | + assert( u.bb.pCx->pKeyInfo->enc==ENC(db) ); |
| 69897 | + u.bb.pCx->isSorter = 1; |
| 69898 | + rc = sqlite3VdbeSorterInit(db, u.bb.pCx); |
| 69529 | 69899 | break; |
| 69530 | 69900 | } |
| 69531 | 69901 | |
| 69532 | 69902 | /* Opcode: OpenPseudo P1 P2 P3 * P5 |
| 69903 | +** Synopsis: content in r[P2@P3] |
| 69533 | 69904 | ** |
| 69534 | 69905 | ** Open a new cursor that points to a fake table that contains a single |
| 69535 | 69906 | ** row of data. The content of that one row in the content of memory |
| 69536 | 69907 | ** register P2 when P5==0. In other words, cursor P1 becomes an alias for the |
| 69537 | 69908 | ** MEM_Blob content contained in register P2. When P5==1, then the |
| | @@ -69544,22 +69915,22 @@ |
| 69544 | 69915 | ** |
| 69545 | 69916 | ** P3 is the number of fields in the records that will be stored by |
| 69546 | 69917 | ** the pseudo-table. |
| 69547 | 69918 | */ |
| 69548 | 69919 | case OP_OpenPseudo: { |
| 69549 | | -#if 0 /* local variables moved into u.bb */ |
| 69920 | +#if 0 /* local variables moved into u.bc */ |
| 69550 | 69921 | VdbeCursor *pCx; |
| 69551 | | -#endif /* local variables moved into u.bb */ |
| 69922 | +#endif /* local variables moved into u.bc */ |
| 69552 | 69923 | |
| 69553 | 69924 | assert( pOp->p1>=0 ); |
| 69554 | | - u.bb.pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, 0); |
| 69555 | | - if( u.bb.pCx==0 ) goto no_mem; |
| 69556 | | - u.bb.pCx->nullRow = 1; |
| 69557 | | - u.bb.pCx->pseudoTableReg = pOp->p2; |
| 69558 | | - u.bb.pCx->isTable = 1; |
| 69559 | | - u.bb.pCx->isIndex = 0; |
| 69560 | | - u.bb.pCx->multiPseudo = pOp->p5; |
| 69925 | + u.bc.pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, 0); |
| 69926 | + if( u.bc.pCx==0 ) goto no_mem; |
| 69927 | + u.bc.pCx->nullRow = 1; |
| 69928 | + u.bc.pCx->pseudoTableReg = pOp->p2; |
| 69929 | + u.bc.pCx->isTable = 1; |
| 69930 | + u.bc.pCx->isIndex = 0; |
| 69931 | + u.bc.pCx->multiPseudo = pOp->p5; |
| 69561 | 69932 | break; |
| 69562 | 69933 | } |
| 69563 | 69934 | |
| 69564 | 69935 | /* Opcode: Close P1 * * * * |
| 69565 | 69936 | ** |
| | @@ -69572,10 +69943,11 @@ |
| 69572 | 69943 | p->apCsr[pOp->p1] = 0; |
| 69573 | 69944 | break; |
| 69574 | 69945 | } |
| 69575 | 69946 | |
| 69576 | 69947 | /* Opcode: SeekGe P1 P2 P3 P4 * |
| 69948 | +** Synopsis: key=r[P3@P4] |
| 69577 | 69949 | ** |
| 69578 | 69950 | ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), |
| 69579 | 69951 | ** use the value in register P3 as the key. If cursor P1 refers |
| 69580 | 69952 | ** to an SQL index, then P3 is the first in an array of P4 registers |
| 69581 | 69953 | ** that are used as an unpacked index key. |
| | @@ -69585,10 +69957,11 @@ |
| 69585 | 69957 | ** greater than or equal to the key and P2 is not zero, then jump to P2. |
| 69586 | 69958 | ** |
| 69587 | 69959 | ** See also: Found, NotFound, Distinct, SeekLt, SeekGt, SeekLe |
| 69588 | 69960 | */ |
| 69589 | 69961 | /* Opcode: SeekGt P1 P2 P3 P4 * |
| 69962 | +** Synopsis: key=r[P3@P4] |
| 69590 | 69963 | ** |
| 69591 | 69964 | ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), |
| 69592 | 69965 | ** use the value in register P3 as a key. If cursor P1 refers |
| 69593 | 69966 | ** to an SQL index, then P3 is the first in an array of P4 registers |
| 69594 | 69967 | ** that are used as an unpacked index key. |
| | @@ -69598,10 +69971,11 @@ |
| 69598 | 69971 | ** the key and P2 is not zero, then jump to P2. |
| 69599 | 69972 | ** |
| 69600 | 69973 | ** See also: Found, NotFound, Distinct, SeekLt, SeekGe, SeekLe |
| 69601 | 69974 | */ |
| 69602 | 69975 | /* Opcode: SeekLt P1 P2 P3 P4 * |
| 69976 | +** Synopsis: key=r[P3@P4] |
| 69603 | 69977 | ** |
| 69604 | 69978 | ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), |
| 69605 | 69979 | ** use the value in register P3 as a key. If cursor P1 refers |
| 69606 | 69980 | ** to an SQL index, then P3 is the first in an array of P4 registers |
| 69607 | 69981 | ** that are used as an unpacked index key. |
| | @@ -69611,10 +69985,11 @@ |
| 69611 | 69985 | ** the key and P2 is not zero, then jump to P2. |
| 69612 | 69986 | ** |
| 69613 | 69987 | ** See also: Found, NotFound, Distinct, SeekGt, SeekGe, SeekLe |
| 69614 | 69988 | */ |
| 69615 | 69989 | /* Opcode: SeekLe P1 P2 P3 P4 * |
| 69990 | +** Synopsis: key=r[P3@P4] |
| 69616 | 69991 | ** |
| 69617 | 69992 | ** If cursor P1 refers to an SQL table (B-Tree that uses integer keys), |
| 69618 | 69993 | ** use the value in register P3 as a key. If cursor P1 refers |
| 69619 | 69994 | ** to an SQL index, then P3 is the first in an array of P4 registers |
| 69620 | 69995 | ** that are used as an unpacked index key. |
| | @@ -69627,200 +70002,197 @@ |
| 69627 | 70002 | */ |
| 69628 | 70003 | case OP_SeekLt: /* jump, in3 */ |
| 69629 | 70004 | case OP_SeekLe: /* jump, in3 */ |
| 69630 | 70005 | case OP_SeekGe: /* jump, in3 */ |
| 69631 | 70006 | case OP_SeekGt: { /* jump, in3 */ |
| 69632 | | -#if 0 /* local variables moved into u.bc */ |
| 70007 | +#if 0 /* local variables moved into u.bd */ |
| 69633 | 70008 | int res; |
| 69634 | 70009 | int oc; |
| 69635 | 70010 | VdbeCursor *pC; |
| 69636 | 70011 | UnpackedRecord r; |
| 69637 | 70012 | int nField; |
| 69638 | 70013 | i64 iKey; /* The rowid we are to seek to */ |
| 69639 | | -#endif /* local variables moved into u.bc */ |
| 70014 | +#endif /* local variables moved into u.bd */ |
| 69640 | 70015 | |
| 69641 | 70016 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 69642 | 70017 | assert( pOp->p2!=0 ); |
| 69643 | | - u.bc.pC = p->apCsr[pOp->p1]; |
| 69644 | | - assert( u.bc.pC!=0 ); |
| 69645 | | - assert( u.bc.pC->pseudoTableReg==0 ); |
| 70018 | + u.bd.pC = p->apCsr[pOp->p1]; |
| 70019 | + assert( u.bd.pC!=0 ); |
| 70020 | + assert( u.bd.pC->pseudoTableReg==0 ); |
| 69646 | 70021 | assert( OP_SeekLe == OP_SeekLt+1 ); |
| 69647 | 70022 | assert( OP_SeekGe == OP_SeekLt+2 ); |
| 69648 | 70023 | assert( OP_SeekGt == OP_SeekLt+3 ); |
| 69649 | | - assert( u.bc.pC->isOrdered ); |
| 69650 | | - if( ALWAYS(u.bc.pC->pCursor!=0) ){ |
| 69651 | | - u.bc.oc = pOp->opcode; |
| 69652 | | - u.bc.pC->nullRow = 0; |
| 69653 | | - if( u.bc.pC->isTable ){ |
| 69654 | | - /* The input value in P3 might be of any type: integer, real, string, |
| 69655 | | - ** blob, or NULL. But it needs to be an integer before we can do |
| 69656 | | - ** the seek, so covert it. */ |
| 69657 | | - pIn3 = &aMem[pOp->p3]; |
| 69658 | | - applyNumericAffinity(pIn3); |
| 69659 | | - u.bc.iKey = sqlite3VdbeIntValue(pIn3); |
| 69660 | | - u.bc.pC->rowidIsValid = 0; |
| 69661 | | - |
| 69662 | | - /* If the P3 value could not be converted into an integer without |
| 69663 | | - ** loss of information, then special processing is required... */ |
| 69664 | | - if( (pIn3->flags & MEM_Int)==0 ){ |
| 69665 | | - if( (pIn3->flags & MEM_Real)==0 ){ |
| 69666 | | - /* If the P3 value cannot be converted into any kind of a number, |
| 69667 | | - ** then the seek is not possible, so jump to P2 */ |
| 69668 | | - pc = pOp->p2 - 1; |
| 69669 | | - break; |
| 69670 | | - } |
| 69671 | | - /* If we reach this point, then the P3 value must be a floating |
| 69672 | | - ** point number. */ |
| 69673 | | - assert( (pIn3->flags & MEM_Real)!=0 ); |
| 69674 | | - |
| 69675 | | - if( u.bc.iKey==SMALLEST_INT64 && (pIn3->r<(double)u.bc.iKey || pIn3->r>0) ){ |
| 69676 | | - /* The P3 value is too large in magnitude to be expressed as an |
| 69677 | | - ** integer. */ |
| 69678 | | - u.bc.res = 1; |
| 69679 | | - if( pIn3->r<0 ){ |
| 69680 | | - if( u.bc.oc>=OP_SeekGe ){ assert( u.bc.oc==OP_SeekGe || u.bc.oc==OP_SeekGt ); |
| 69681 | | - rc = sqlite3BtreeFirst(u.bc.pC->pCursor, &u.bc.res); |
| 69682 | | - if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 69683 | | - } |
| 69684 | | - }else{ |
| 69685 | | - if( u.bc.oc<=OP_SeekLe ){ assert( u.bc.oc==OP_SeekLt || u.bc.oc==OP_SeekLe ); |
| 69686 | | - rc = sqlite3BtreeLast(u.bc.pC->pCursor, &u.bc.res); |
| 69687 | | - if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 69688 | | - } |
| 69689 | | - } |
| 69690 | | - if( u.bc.res ){ |
| 69691 | | - pc = pOp->p2 - 1; |
| 69692 | | - } |
| 69693 | | - break; |
| 69694 | | - }else if( u.bc.oc==OP_SeekLt || u.bc.oc==OP_SeekGe ){ |
| 69695 | | - /* Use the ceiling() function to convert real->int */ |
| 69696 | | - if( pIn3->r > (double)u.bc.iKey ) u.bc.iKey++; |
| 69697 | | - }else{ |
| 69698 | | - /* Use the floor() function to convert real->int */ |
| 69699 | | - assert( u.bc.oc==OP_SeekLe || u.bc.oc==OP_SeekGt ); |
| 69700 | | - if( pIn3->r < (double)u.bc.iKey ) u.bc.iKey--; |
| 69701 | | - } |
| 69702 | | - } |
| 69703 | | - rc = sqlite3BtreeMovetoUnpacked(u.bc.pC->pCursor, 0, (u64)u.bc.iKey, 0, &u.bc.res); |
| 69704 | | - if( rc!=SQLITE_OK ){ |
| 69705 | | - goto abort_due_to_error; |
| 69706 | | - } |
| 69707 | | - if( u.bc.res==0 ){ |
| 69708 | | - u.bc.pC->rowidIsValid = 1; |
| 69709 | | - u.bc.pC->lastRowid = u.bc.iKey; |
| 69710 | | - } |
| 69711 | | - }else{ |
| 69712 | | - u.bc.nField = pOp->p4.i; |
| 69713 | | - assert( pOp->p4type==P4_INT32 ); |
| 69714 | | - assert( u.bc.nField>0 ); |
| 69715 | | - u.bc.r.pKeyInfo = u.bc.pC->pKeyInfo; |
| 69716 | | - u.bc.r.nField = (u16)u.bc.nField; |
| 69717 | | - |
| 69718 | | - /* The next line of code computes as follows, only faster: |
| 69719 | | - ** if( u.bc.oc==OP_SeekGt || u.bc.oc==OP_SeekLe ){ |
| 69720 | | - ** u.bc.r.flags = UNPACKED_INCRKEY; |
| 69721 | | - ** }else{ |
| 69722 | | - ** u.bc.r.flags = 0; |
| 69723 | | - ** } |
| 69724 | | - */ |
| 69725 | | - u.bc.r.flags = (u8)(UNPACKED_INCRKEY * (1 & (u.bc.oc - OP_SeekLt))); |
| 69726 | | - assert( u.bc.oc!=OP_SeekGt || u.bc.r.flags==UNPACKED_INCRKEY ); |
| 69727 | | - assert( u.bc.oc!=OP_SeekLe || u.bc.r.flags==UNPACKED_INCRKEY ); |
| 69728 | | - assert( u.bc.oc!=OP_SeekGe || u.bc.r.flags==0 ); |
| 69729 | | - assert( u.bc.oc!=OP_SeekLt || u.bc.r.flags==0 ); |
| 69730 | | - |
| 69731 | | - u.bc.r.aMem = &aMem[pOp->p3]; |
| 69732 | | -#ifdef SQLITE_DEBUG |
| 69733 | | - { int i; for(i=0; i<u.bc.r.nField; i++) assert( memIsValid(&u.bc.r.aMem[i]) ); } |
| 69734 | | -#endif |
| 69735 | | - ExpandBlob(u.bc.r.aMem); |
| 69736 | | - rc = sqlite3BtreeMovetoUnpacked(u.bc.pC->pCursor, &u.bc.r, 0, 0, &u.bc.res); |
| 69737 | | - if( rc!=SQLITE_OK ){ |
| 69738 | | - goto abort_due_to_error; |
| 69739 | | - } |
| 69740 | | - u.bc.pC->rowidIsValid = 0; |
| 69741 | | - } |
| 69742 | | - u.bc.pC->deferredMoveto = 0; |
| 69743 | | - u.bc.pC->cacheStatus = CACHE_STALE; |
| 69744 | | -#ifdef SQLITE_TEST |
| 69745 | | - sqlite3_search_count++; |
| 69746 | | -#endif |
| 69747 | | - if( u.bc.oc>=OP_SeekGe ){ assert( u.bc.oc==OP_SeekGe || u.bc.oc==OP_SeekGt ); |
| 69748 | | - if( u.bc.res<0 || (u.bc.res==0 && u.bc.oc==OP_SeekGt) ){ |
| 69749 | | - rc = sqlite3BtreeNext(u.bc.pC->pCursor, &u.bc.res); |
| 69750 | | - if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 69751 | | - u.bc.pC->rowidIsValid = 0; |
| 69752 | | - }else{ |
| 69753 | | - u.bc.res = 0; |
| 69754 | | - } |
| 69755 | | - }else{ |
| 69756 | | - assert( u.bc.oc==OP_SeekLt || u.bc.oc==OP_SeekLe ); |
| 69757 | | - if( u.bc.res>0 || (u.bc.res==0 && u.bc.oc==OP_SeekLt) ){ |
| 69758 | | - rc = sqlite3BtreePrevious(u.bc.pC->pCursor, &u.bc.res); |
| 69759 | | - if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 69760 | | - u.bc.pC->rowidIsValid = 0; |
| 69761 | | - }else{ |
| 69762 | | - /* u.bc.res might be negative because the table is empty. Check to |
| 69763 | | - ** see if this is the case. |
| 69764 | | - */ |
| 69765 | | - u.bc.res = sqlite3BtreeEof(u.bc.pC->pCursor); |
| 69766 | | - } |
| 69767 | | - } |
| 69768 | | - assert( pOp->p2>0 ); |
| 69769 | | - if( u.bc.res ){ |
| 69770 | | - pc = pOp->p2 - 1; |
| 69771 | | - } |
| 69772 | | - }else{ |
| 69773 | | - /* This happens when attempting to open the sqlite3_master table |
| 69774 | | - ** for read access returns SQLITE_EMPTY. In this case always |
| 69775 | | - ** take the jump (since there are no records in the table). |
| 69776 | | - */ |
| 70024 | + assert( u.bd.pC->isOrdered ); |
| 70025 | + assert( u.bd.pC->pCursor!=0 ); |
| 70026 | + u.bd.oc = pOp->opcode; |
| 70027 | + u.bd.pC->nullRow = 0; |
| 70028 | + if( u.bd.pC->isTable ){ |
| 70029 | + /* The input value in P3 might be of any type: integer, real, string, |
| 70030 | + ** blob, or NULL. But it needs to be an integer before we can do |
| 70031 | + ** the seek, so covert it. */ |
| 70032 | + pIn3 = &aMem[pOp->p3]; |
| 70033 | + applyNumericAffinity(pIn3); |
| 70034 | + u.bd.iKey = sqlite3VdbeIntValue(pIn3); |
| 70035 | + u.bd.pC->rowidIsValid = 0; |
| 70036 | + |
| 70037 | + /* If the P3 value could not be converted into an integer without |
| 70038 | + ** loss of information, then special processing is required... */ |
| 70039 | + if( (pIn3->flags & MEM_Int)==0 ){ |
| 70040 | + if( (pIn3->flags & MEM_Real)==0 ){ |
| 70041 | + /* If the P3 value cannot be converted into any kind of a number, |
| 70042 | + ** then the seek is not possible, so jump to P2 */ |
| 70043 | + pc = pOp->p2 - 1; |
| 70044 | + break; |
| 70045 | + } |
| 70046 | + /* If we reach this point, then the P3 value must be a floating |
| 70047 | + ** point number. */ |
| 70048 | + assert( (pIn3->flags & MEM_Real)!=0 ); |
| 70049 | + |
| 70050 | + if( u.bd.iKey==SMALLEST_INT64 && (pIn3->r<(double)u.bd.iKey || pIn3->r>0) ){ |
| 70051 | + /* The P3 value is too large in magnitude to be expressed as an |
| 70052 | + ** integer. */ |
| 70053 | + u.bd.res = 1; |
| 70054 | + if( pIn3->r<0 ){ |
| 70055 | + if( u.bd.oc>=OP_SeekGe ){ assert( u.bd.oc==OP_SeekGe || u.bd.oc==OP_SeekGt ); |
| 70056 | + rc = sqlite3BtreeFirst(u.bd.pC->pCursor, &u.bd.res); |
| 70057 | + if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 70058 | + } |
| 70059 | + }else{ |
| 70060 | + if( u.bd.oc<=OP_SeekLe ){ assert( u.bd.oc==OP_SeekLt || u.bd.oc==OP_SeekLe ); |
| 70061 | + rc = sqlite3BtreeLast(u.bd.pC->pCursor, &u.bd.res); |
| 70062 | + if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 70063 | + } |
| 70064 | + } |
| 70065 | + if( u.bd.res ){ |
| 70066 | + pc = pOp->p2 - 1; |
| 70067 | + } |
| 70068 | + break; |
| 70069 | + }else if( u.bd.oc==OP_SeekLt || u.bd.oc==OP_SeekGe ){ |
| 70070 | + /* Use the ceiling() function to convert real->int */ |
| 70071 | + if( pIn3->r > (double)u.bd.iKey ) u.bd.iKey++; |
| 70072 | + }else{ |
| 70073 | + /* Use the floor() function to convert real->int */ |
| 70074 | + assert( u.bd.oc==OP_SeekLe || u.bd.oc==OP_SeekGt ); |
| 70075 | + if( pIn3->r < (double)u.bd.iKey ) u.bd.iKey--; |
| 70076 | + } |
| 70077 | + } |
| 70078 | + rc = sqlite3BtreeMovetoUnpacked(u.bd.pC->pCursor, 0, (u64)u.bd.iKey, 0, &u.bd.res); |
| 70079 | + if( rc!=SQLITE_OK ){ |
| 70080 | + goto abort_due_to_error; |
| 70081 | + } |
| 70082 | + if( u.bd.res==0 ){ |
| 70083 | + u.bd.pC->rowidIsValid = 1; |
| 70084 | + u.bd.pC->lastRowid = u.bd.iKey; |
| 70085 | + } |
| 70086 | + }else{ |
| 70087 | + u.bd.nField = pOp->p4.i; |
| 70088 | + assert( pOp->p4type==P4_INT32 ); |
| 70089 | + assert( u.bd.nField>0 ); |
| 70090 | + u.bd.r.pKeyInfo = u.bd.pC->pKeyInfo; |
| 70091 | + u.bd.r.nField = (u16)u.bd.nField; |
| 70092 | + |
| 70093 | + /* The next line of code computes as follows, only faster: |
| 70094 | + ** if( u.bd.oc==OP_SeekGt || u.bd.oc==OP_SeekLe ){ |
| 70095 | + ** u.bd.r.flags = UNPACKED_INCRKEY; |
| 70096 | + ** }else{ |
| 70097 | + ** u.bd.r.flags = 0; |
| 70098 | + ** } |
| 70099 | + */ |
| 70100 | + u.bd.r.flags = (u8)(UNPACKED_INCRKEY * (1 & (u.bd.oc - OP_SeekLt))); |
| 70101 | + assert( u.bd.oc!=OP_SeekGt || u.bd.r.flags==UNPACKED_INCRKEY ); |
| 70102 | + assert( u.bd.oc!=OP_SeekLe || u.bd.r.flags==UNPACKED_INCRKEY ); |
| 70103 | + assert( u.bd.oc!=OP_SeekGe || u.bd.r.flags==0 ); |
| 70104 | + assert( u.bd.oc!=OP_SeekLt || u.bd.r.flags==0 ); |
| 70105 | + |
| 70106 | + u.bd.r.aMem = &aMem[pOp->p3]; |
| 70107 | +#ifdef SQLITE_DEBUG |
| 70108 | + { int i; for(i=0; i<u.bd.r.nField; i++) assert( memIsValid(&u.bd.r.aMem[i]) ); } |
| 70109 | +#endif |
| 70110 | + ExpandBlob(u.bd.r.aMem); |
| 70111 | + rc = sqlite3BtreeMovetoUnpacked(u.bd.pC->pCursor, &u.bd.r, 0, 0, &u.bd.res); |
| 70112 | + if( rc!=SQLITE_OK ){ |
| 70113 | + goto abort_due_to_error; |
| 70114 | + } |
| 70115 | + u.bd.pC->rowidIsValid = 0; |
| 70116 | + } |
| 70117 | + u.bd.pC->deferredMoveto = 0; |
| 70118 | + u.bd.pC->cacheStatus = CACHE_STALE; |
| 70119 | +#ifdef SQLITE_TEST |
| 70120 | + sqlite3_search_count++; |
| 70121 | +#endif |
| 70122 | + if( u.bd.oc>=OP_SeekGe ){ assert( u.bd.oc==OP_SeekGe || u.bd.oc==OP_SeekGt ); |
| 70123 | + if( u.bd.res<0 || (u.bd.res==0 && u.bd.oc==OP_SeekGt) ){ |
| 70124 | + rc = sqlite3BtreeNext(u.bd.pC->pCursor, &u.bd.res); |
| 70125 | + if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 70126 | + u.bd.pC->rowidIsValid = 0; |
| 70127 | + }else{ |
| 70128 | + u.bd.res = 0; |
| 70129 | + } |
| 70130 | + }else{ |
| 70131 | + assert( u.bd.oc==OP_SeekLt || u.bd.oc==OP_SeekLe ); |
| 70132 | + if( u.bd.res>0 || (u.bd.res==0 && u.bd.oc==OP_SeekLt) ){ |
| 70133 | + rc = sqlite3BtreePrevious(u.bd.pC->pCursor, &u.bd.res); |
| 70134 | + if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 70135 | + u.bd.pC->rowidIsValid = 0; |
| 70136 | + }else{ |
| 70137 | + /* u.bd.res might be negative because the table is empty. Check to |
| 70138 | + ** see if this is the case. |
| 70139 | + */ |
| 70140 | + u.bd.res = sqlite3BtreeEof(u.bd.pC->pCursor); |
| 70141 | + } |
| 70142 | + } |
| 70143 | + assert( pOp->p2>0 ); |
| 70144 | + if( u.bd.res ){ |
| 69777 | 70145 | pc = pOp->p2 - 1; |
| 69778 | 70146 | } |
| 69779 | 70147 | break; |
| 69780 | 70148 | } |
| 69781 | 70149 | |
| 69782 | 70150 | /* Opcode: Seek P1 P2 * * * |
| 70151 | +** Synopsis: intkey=r[P2] |
| 69783 | 70152 | ** |
| 69784 | 70153 | ** P1 is an open table cursor and P2 is a rowid integer. Arrange |
| 69785 | 70154 | ** for P1 to move so that it points to the rowid given by P2. |
| 69786 | 70155 | ** |
| 69787 | 70156 | ** This is actually a deferred seek. Nothing actually happens until |
| 69788 | 70157 | ** the cursor is used to read a record. That way, if no reads |
| 69789 | 70158 | ** occur, no unnecessary I/O happens. |
| 69790 | 70159 | */ |
| 69791 | 70160 | case OP_Seek: { /* in2 */ |
| 69792 | | -#if 0 /* local variables moved into u.bd */ |
| 70161 | +#if 0 /* local variables moved into u.be */ |
| 69793 | 70162 | VdbeCursor *pC; |
| 69794 | | -#endif /* local variables moved into u.bd */ |
| 70163 | +#endif /* local variables moved into u.be */ |
| 69795 | 70164 | |
| 69796 | 70165 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 69797 | | - u.bd.pC = p->apCsr[pOp->p1]; |
| 69798 | | - assert( u.bd.pC!=0 ); |
| 69799 | | - if( ALWAYS(u.bd.pC->pCursor!=0) ){ |
| 69800 | | - assert( u.bd.pC->isTable ); |
| 69801 | | - u.bd.pC->nullRow = 0; |
| 69802 | | - pIn2 = &aMem[pOp->p2]; |
| 69803 | | - u.bd.pC->movetoTarget = sqlite3VdbeIntValue(pIn2); |
| 69804 | | - u.bd.pC->rowidIsValid = 0; |
| 69805 | | - u.bd.pC->deferredMoveto = 1; |
| 69806 | | - } |
| 70166 | + u.be.pC = p->apCsr[pOp->p1]; |
| 70167 | + assert( u.be.pC!=0 ); |
| 70168 | + assert( u.be.pC->pCursor!=0 ); |
| 70169 | + assert( u.be.pC->isTable ); |
| 70170 | + u.be.pC->nullRow = 0; |
| 70171 | + pIn2 = &aMem[pOp->p2]; |
| 70172 | + u.be.pC->movetoTarget = sqlite3VdbeIntValue(pIn2); |
| 70173 | + u.be.pC->rowidIsValid = 0; |
| 70174 | + u.be.pC->deferredMoveto = 1; |
| 69807 | 70175 | break; |
| 69808 | 70176 | } |
| 69809 | 70177 | |
| 69810 | 70178 | |
| 69811 | 70179 | /* Opcode: Found P1 P2 P3 P4 * |
| 70180 | +** Synopsis: key=r[P3@P4] |
| 69812 | 70181 | ** |
| 69813 | 70182 | ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If |
| 69814 | 70183 | ** P4>0 then register P3 is the first of P4 registers that form an unpacked |
| 69815 | 70184 | ** record. |
| 69816 | 70185 | ** |
| 69817 | 70186 | ** Cursor P1 is on an index btree. If the record identified by P3 and P4 |
| 69818 | 70187 | ** is a prefix of any entry in P1 then a jump is made to P2 and |
| 69819 | 70188 | ** P1 is left pointing at the matching entry. |
| 70189 | +** |
| 70190 | +** See also: NotFound, NoConflict, NotExists. SeekGe |
| 69820 | 70191 | */ |
| 69821 | 70192 | /* Opcode: NotFound P1 P2 P3 P4 * |
| 70193 | +** Synopsis: key=r[P3@P4] |
| 69822 | 70194 | ** |
| 69823 | 70195 | ** If P4==0 then register P3 holds a blob constructed by MakeRecord. If |
| 69824 | 70196 | ** P4>0 then register P3 is the first of P4 registers that form an unpacked |
| 69825 | 70197 | ** record. |
| 69826 | 70198 | ** |
| | @@ -69828,177 +70200,126 @@ |
| 69828 | 70200 | ** is not the prefix of any entry in P1 then a jump is made to P2. If P1 |
| 69829 | 70201 | ** does contain an entry whose prefix matches the P3/P4 record then control |
| 69830 | 70202 | ** falls through to the next instruction and P1 is left pointing at the |
| 69831 | 70203 | ** matching entry. |
| 69832 | 70204 | ** |
| 69833 | | -** See also: Found, NotExists, IsUnique |
| 70205 | +** See also: Found, NotExists, NoConflict |
| 69834 | 70206 | */ |
| 70207 | +/* Opcode: NoConflict P1 P2 P3 P4 * |
| 70208 | +** Synopsis: key=r[P3@P4] |
| 70209 | +** |
| 70210 | +** If P4==0 then register P3 holds a blob constructed by MakeRecord. If |
| 70211 | +** P4>0 then register P3 is the first of P4 registers that form an unpacked |
| 70212 | +** record. |
| 70213 | +** |
| 70214 | +** Cursor P1 is on an index btree. If the record identified by P3 and P4 |
| 70215 | +** contains any NULL value, jump immediately to P2. If all terms of the |
| 70216 | +** record are not-NULL then a check is done to determine if any row in the |
| 70217 | +** P1 index btree has a matching key prefix. If there are no matches, jump |
| 70218 | +** immediately to P2. If there is a match, fall through and leave the P1 |
| 70219 | +** cursor pointing to the matching row. |
| 70220 | +** |
| 70221 | +** This opcode is similar to OP_NotFound with the exceptions that the |
| 70222 | +** branch is always taken if any part of the search key input is NULL. |
| 70223 | +** |
| 70224 | +** See also: NotFound, Found, NotExists |
| 70225 | +*/ |
| 70226 | +case OP_NoConflict: /* jump, in3 */ |
| 69835 | 70227 | case OP_NotFound: /* jump, in3 */ |
| 69836 | 70228 | case OP_Found: { /* jump, in3 */ |
| 69837 | | -#if 0 /* local variables moved into u.be */ |
| 70229 | +#if 0 /* local variables moved into u.bf */ |
| 69838 | 70230 | int alreadyExists; |
| 70231 | + int ii; |
| 69839 | 70232 | VdbeCursor *pC; |
| 69840 | 70233 | int res; |
| 69841 | 70234 | char *pFree; |
| 69842 | 70235 | UnpackedRecord *pIdxKey; |
| 69843 | 70236 | UnpackedRecord r; |
| 69844 | | - char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*3 + 7]; |
| 69845 | | -#endif /* local variables moved into u.be */ |
| 69846 | | - |
| 69847 | | -#ifdef SQLITE_TEST |
| 69848 | | - sqlite3_found_count++; |
| 69849 | | -#endif |
| 69850 | | - |
| 69851 | | - u.be.alreadyExists = 0; |
| 69852 | | - assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 69853 | | - assert( pOp->p4type==P4_INT32 ); |
| 69854 | | - u.be.pC = p->apCsr[pOp->p1]; |
| 69855 | | - assert( u.be.pC!=0 ); |
| 69856 | | - pIn3 = &aMem[pOp->p3]; |
| 69857 | | - if( ALWAYS(u.be.pC->pCursor!=0) ){ |
| 69858 | | - |
| 69859 | | - assert( u.be.pC->isTable==0 ); |
| 69860 | | - if( pOp->p4.i>0 ){ |
| 69861 | | - u.be.r.pKeyInfo = u.be.pC->pKeyInfo; |
| 69862 | | - u.be.r.nField = (u16)pOp->p4.i; |
| 69863 | | - u.be.r.aMem = pIn3; |
| 69864 | | -#ifdef SQLITE_DEBUG |
| 69865 | | - { int i; for(i=0; i<u.be.r.nField; i++) assert( memIsValid(&u.be.r.aMem[i]) ); } |
| 69866 | | -#endif |
| 69867 | | - u.be.r.flags = UNPACKED_PREFIX_MATCH; |
| 69868 | | - u.be.pIdxKey = &u.be.r; |
| 69869 | | - }else{ |
| 69870 | | - u.be.pIdxKey = sqlite3VdbeAllocUnpackedRecord( |
| 69871 | | - u.be.pC->pKeyInfo, u.be.aTempRec, sizeof(u.be.aTempRec), &u.be.pFree |
| 69872 | | - ); |
| 69873 | | - if( u.be.pIdxKey==0 ) goto no_mem; |
| 69874 | | - assert( pIn3->flags & MEM_Blob ); |
| 69875 | | - assert( (pIn3->flags & MEM_Zero)==0 ); /* zeroblobs already expanded */ |
| 69876 | | - sqlite3VdbeRecordUnpack(u.be.pC->pKeyInfo, pIn3->n, pIn3->z, u.be.pIdxKey); |
| 69877 | | - u.be.pIdxKey->flags |= UNPACKED_PREFIX_MATCH; |
| 69878 | | - } |
| 69879 | | - rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, u.be.pIdxKey, 0, 0, &u.be.res); |
| 69880 | | - if( pOp->p4.i==0 ){ |
| 69881 | | - sqlite3DbFree(db, u.be.pFree); |
| 69882 | | - } |
| 69883 | | - if( rc!=SQLITE_OK ){ |
| 69884 | | - break; |
| 69885 | | - } |
| 69886 | | - u.be.alreadyExists = (u.be.res==0); |
| 69887 | | - u.be.pC->deferredMoveto = 0; |
| 69888 | | - u.be.pC->cacheStatus = CACHE_STALE; |
| 69889 | | - } |
| 69890 | | - if( pOp->opcode==OP_Found ){ |
| 69891 | | - if( u.be.alreadyExists ) pc = pOp->p2 - 1; |
| 69892 | | - }else{ |
| 69893 | | - if( !u.be.alreadyExists ) pc = pOp->p2 - 1; |
| 69894 | | - } |
| 69895 | | - break; |
| 69896 | | -} |
| 69897 | | - |
| 69898 | | -/* Opcode: IsUnique P1 P2 P3 P4 * |
| 69899 | | -** |
| 69900 | | -** Cursor P1 is open on an index b-tree - that is to say, a btree which |
| 69901 | | -** no data and where the key are records generated by OP_MakeRecord with |
| 69902 | | -** the list field being the integer ROWID of the entry that the index |
| 69903 | | -** entry refers to. |
| 69904 | | -** |
| 69905 | | -** The P3 register contains an integer record number. Call this record |
| 69906 | | -** number R. Register P4 is the first in a set of N contiguous registers |
| 69907 | | -** that make up an unpacked index key that can be used with cursor P1. |
| 69908 | | -** The value of N can be inferred from the cursor. N includes the rowid |
| 69909 | | -** value appended to the end of the index record. This rowid value may |
| 69910 | | -** or may not be the same as R. |
| 69911 | | -** |
| 69912 | | -** If any of the N registers beginning with register P4 contains a NULL |
| 69913 | | -** value, jump immediately to P2. |
| 69914 | | -** |
| 69915 | | -** Otherwise, this instruction checks if cursor P1 contains an entry |
| 69916 | | -** where the first (N-1) fields match but the rowid value at the end |
| 69917 | | -** of the index entry is not R. If there is no such entry, control jumps |
| 69918 | | -** to instruction P2. Otherwise, the rowid of the conflicting index |
| 69919 | | -** entry is copied to register P3 and control falls through to the next |
| 69920 | | -** instruction. |
| 69921 | | -** |
| 69922 | | -** See also: NotFound, NotExists, Found |
| 69923 | | -*/ |
| 69924 | | -case OP_IsUnique: { /* jump, in3 */ |
| 69925 | | -#if 0 /* local variables moved into u.bf */ |
| 69926 | | - u16 ii; |
| 69927 | | - VdbeCursor *pCx; |
| 69928 | | - BtCursor *pCrsr; |
| 69929 | | - u16 nField; |
| 69930 | | - Mem *aMx; |
| 69931 | | - UnpackedRecord r; /* B-Tree index search key */ |
| 69932 | | - i64 R; /* Rowid stored in register P3 */ |
| 69933 | | -#endif /* local variables moved into u.bf */ |
| 69934 | | - |
| 69935 | | - pIn3 = &aMem[pOp->p3]; |
| 69936 | | - u.bf.aMx = &aMem[pOp->p4.i]; |
| 69937 | | - /* Assert that the values of parameters P1 and P4 are in range. */ |
| 69938 | | - assert( pOp->p4type==P4_INT32 ); |
| 69939 | | - assert( pOp->p4.i>0 && pOp->p4.i<=(p->nMem-p->nCursor) ); |
| 69940 | | - assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 69941 | | - |
| 69942 | | - /* Find the index cursor. */ |
| 69943 | | - u.bf.pCx = p->apCsr[pOp->p1]; |
| 69944 | | - assert( u.bf.pCx->deferredMoveto==0 ); |
| 69945 | | - u.bf.pCx->seekResult = 0; |
| 69946 | | - u.bf.pCx->cacheStatus = CACHE_STALE; |
| 69947 | | - u.bf.pCrsr = u.bf.pCx->pCursor; |
| 69948 | | - |
| 69949 | | - /* If any of the values are NULL, take the jump. */ |
| 69950 | | - u.bf.nField = u.bf.pCx->pKeyInfo->nField; |
| 69951 | | - for(u.bf.ii=0; u.bf.ii<u.bf.nField; u.bf.ii++){ |
| 69952 | | - if( u.bf.aMx[u.bf.ii].flags & MEM_Null ){ |
| 69953 | | - pc = pOp->p2 - 1; |
| 69954 | | - u.bf.pCrsr = 0; |
| 69955 | | - break; |
| 69956 | | - } |
| 69957 | | - } |
| 69958 | | - assert( (u.bf.aMx[u.bf.nField].flags & MEM_Null)==0 ); |
| 69959 | | - |
| 69960 | | - if( u.bf.pCrsr!=0 ){ |
| 69961 | | - /* Populate the index search key. */ |
| 69962 | | - u.bf.r.pKeyInfo = u.bf.pCx->pKeyInfo; |
| 69963 | | - u.bf.r.nField = u.bf.nField + 1; |
| 69964 | | - u.bf.r.flags = UNPACKED_PREFIX_SEARCH; |
| 69965 | | - u.bf.r.aMem = u.bf.aMx; |
| 69966 | | -#ifdef SQLITE_DEBUG |
| 69967 | | - { int i; for(i=0; i<u.bf.r.nField; i++) assert( memIsValid(&u.bf.r.aMem[i]) ); } |
| 69968 | | -#endif |
| 69969 | | - |
| 69970 | | - /* Extract the value of u.bf.R from register P3. */ |
| 69971 | | - sqlite3VdbeMemIntegerify(pIn3); |
| 69972 | | - u.bf.R = pIn3->u.i; |
| 69973 | | - |
| 69974 | | - /* Search the B-Tree index. If no conflicting record is found, jump |
| 69975 | | - ** to P2. Otherwise, copy the rowid of the conflicting record to |
| 69976 | | - ** register P3 and fall through to the next instruction. */ |
| 69977 | | - rc = sqlite3BtreeMovetoUnpacked(u.bf.pCrsr, &u.bf.r, 0, 0, &u.bf.pCx->seekResult); |
| 69978 | | - if( (u.bf.r.flags & UNPACKED_PREFIX_SEARCH) || u.bf.r.rowid==u.bf.R ){ |
| 69979 | | - pc = pOp->p2 - 1; |
| 69980 | | - }else{ |
| 69981 | | - pIn3->u.i = u.bf.r.rowid; |
| 69982 | | - } |
| 70237 | + char aTempRec[ROUND8(sizeof(UnpackedRecord)) + sizeof(Mem)*4 + 7]; |
| 70238 | +#endif /* local variables moved into u.bf */ |
| 70239 | + |
| 70240 | +#ifdef SQLITE_TEST |
| 70241 | + if( pOp->opcode!=OP_NoConflict ) sqlite3_found_count++; |
| 70242 | +#endif |
| 70243 | + |
| 70244 | + u.bf.alreadyExists = 0; |
| 70245 | + assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 70246 | + assert( pOp->p4type==P4_INT32 ); |
| 70247 | + u.bf.pC = p->apCsr[pOp->p1]; |
| 70248 | + assert( u.bf.pC!=0 ); |
| 70249 | + pIn3 = &aMem[pOp->p3]; |
| 70250 | + assert( u.bf.pC->pCursor!=0 ); |
| 70251 | + assert( u.bf.pC->isTable==0 ); |
| 70252 | + if( pOp->p4.i>0 ){ |
| 70253 | + u.bf.r.pKeyInfo = u.bf.pC->pKeyInfo; |
| 70254 | + u.bf.r.nField = (u16)pOp->p4.i; |
| 70255 | + u.bf.r.aMem = pIn3; |
| 70256 | +#ifdef SQLITE_DEBUG |
| 70257 | + { |
| 70258 | + int i; |
| 70259 | + for(i=0; i<u.bf.r.nField; i++){ |
| 70260 | + assert( memIsValid(&u.bf.r.aMem[i]) ); |
| 70261 | + if( i ) REGISTER_TRACE(pOp->p3+i, &u.bf.r.aMem[i]); |
| 70262 | + } |
| 70263 | + } |
| 70264 | +#endif |
| 70265 | + u.bf.r.flags = UNPACKED_PREFIX_MATCH; |
| 70266 | + u.bf.pIdxKey = &u.bf.r; |
| 70267 | + }else{ |
| 70268 | + u.bf.pIdxKey = sqlite3VdbeAllocUnpackedRecord( |
| 70269 | + u.bf.pC->pKeyInfo, u.bf.aTempRec, sizeof(u.bf.aTempRec), &u.bf.pFree |
| 70270 | + ); |
| 70271 | + if( u.bf.pIdxKey==0 ) goto no_mem; |
| 70272 | + assert( pIn3->flags & MEM_Blob ); |
| 70273 | + assert( (pIn3->flags & MEM_Zero)==0 ); /* zeroblobs already expanded */ |
| 70274 | + sqlite3VdbeRecordUnpack(u.bf.pC->pKeyInfo, pIn3->n, pIn3->z, u.bf.pIdxKey); |
| 70275 | + u.bf.pIdxKey->flags |= UNPACKED_PREFIX_MATCH; |
| 70276 | + } |
| 70277 | + if( pOp->opcode==OP_NoConflict ){ |
| 70278 | + /* For the OP_NoConflict opcode, take the jump if any of the |
| 70279 | + ** input fields are NULL, since any key with a NULL will not |
| 70280 | + ** conflict */ |
| 70281 | + for(u.bf.ii=0; u.bf.ii<u.bf.r.nField; u.bf.ii++){ |
| 70282 | + if( u.bf.r.aMem[u.bf.ii].flags & MEM_Null ){ |
| 70283 | + pc = pOp->p2 - 1; |
| 70284 | + break; |
| 70285 | + } |
| 70286 | + } |
| 70287 | + } |
| 70288 | + rc = sqlite3BtreeMovetoUnpacked(u.bf.pC->pCursor, u.bf.pIdxKey, 0, 0, &u.bf.res); |
| 70289 | + if( pOp->p4.i==0 ){ |
| 70290 | + sqlite3DbFree(db, u.bf.pFree); |
| 70291 | + } |
| 70292 | + if( rc!=SQLITE_OK ){ |
| 70293 | + break; |
| 70294 | + } |
| 70295 | + u.bf.pC->seekResult = u.bf.res; |
| 70296 | + u.bf.alreadyExists = (u.bf.res==0); |
| 70297 | + u.bf.pC->nullRow = 1-u.bf.alreadyExists; |
| 70298 | + u.bf.pC->deferredMoveto = 0; |
| 70299 | + u.bf.pC->cacheStatus = CACHE_STALE; |
| 70300 | + if( pOp->opcode==OP_Found ){ |
| 70301 | + if( u.bf.alreadyExists ) pc = pOp->p2 - 1; |
| 70302 | + }else{ |
| 70303 | + if( !u.bf.alreadyExists ) pc = pOp->p2 - 1; |
| 69983 | 70304 | } |
| 69984 | 70305 | break; |
| 69985 | 70306 | } |
| 69986 | 70307 | |
| 69987 | 70308 | /* Opcode: NotExists P1 P2 P3 * * |
| 69988 | | -** |
| 69989 | | -** Use the content of register P3 as an integer key. If a record |
| 69990 | | -** with that key does not exist in table of P1, then jump to P2. |
| 69991 | | -** If the record does exist, then fall through. The cursor is left |
| 69992 | | -** pointing to the record if it exists. |
| 69993 | | -** |
| 69994 | | -** The difference between this operation and NotFound is that this |
| 69995 | | -** operation assumes the key is an integer and that P1 is a table whereas |
| 69996 | | -** NotFound assumes key is a blob constructed from MakeRecord and |
| 69997 | | -** P1 is an index. |
| 69998 | | -** |
| 69999 | | -** See also: Found, NotFound, IsUnique |
| 70309 | +** Synopsis: intkey=r[P3] |
| 70310 | +** |
| 70311 | +** P1 is the index of a cursor open on an SQL table btree (with integer |
| 70312 | +** keys). P3 is an integer rowid. If P1 does not contain a record with |
| 70313 | +** rowid P3 then jump immediately to P2. If P1 does contain a record |
| 70314 | +** with rowid P3 then leave the cursor pointing at that record and fall |
| 70315 | +** through to the next instruction. |
| 70316 | +** |
| 70317 | +** The OP_NotFound opcode performs the same operation on index btrees |
| 70318 | +** (with arbitrary multi-value keys). |
| 70319 | +** |
| 70320 | +** See also: Found, NotFound, NoConflict |
| 70000 | 70321 | */ |
| 70001 | 70322 | case OP_NotExists: { /* jump, in3 */ |
| 70002 | 70323 | #if 0 /* local variables moved into u.bg */ |
| 70003 | 70324 | VdbeCursor *pC; |
| 70004 | 70325 | BtCursor *pCrsr; |
| | @@ -70012,36 +70333,29 @@ |
| 70012 | 70333 | u.bg.pC = p->apCsr[pOp->p1]; |
| 70013 | 70334 | assert( u.bg.pC!=0 ); |
| 70014 | 70335 | assert( u.bg.pC->isTable ); |
| 70015 | 70336 | assert( u.bg.pC->pseudoTableReg==0 ); |
| 70016 | 70337 | u.bg.pCrsr = u.bg.pC->pCursor; |
| 70017 | | - if( ALWAYS(u.bg.pCrsr!=0) ){ |
| 70018 | | - u.bg.res = 0; |
| 70019 | | - u.bg.iKey = pIn3->u.i; |
| 70020 | | - rc = sqlite3BtreeMovetoUnpacked(u.bg.pCrsr, 0, u.bg.iKey, 0, &u.bg.res); |
| 70021 | | - u.bg.pC->lastRowid = pIn3->u.i; |
| 70022 | | - u.bg.pC->rowidIsValid = u.bg.res==0 ?1:0; |
| 70023 | | - u.bg.pC->nullRow = 0; |
| 70024 | | - u.bg.pC->cacheStatus = CACHE_STALE; |
| 70025 | | - u.bg.pC->deferredMoveto = 0; |
| 70026 | | - if( u.bg.res!=0 ){ |
| 70027 | | - pc = pOp->p2 - 1; |
| 70028 | | - assert( u.bg.pC->rowidIsValid==0 ); |
| 70029 | | - } |
| 70030 | | - u.bg.pC->seekResult = u.bg.res; |
| 70031 | | - }else{ |
| 70032 | | - /* This happens when an attempt to open a read cursor on the |
| 70033 | | - ** sqlite_master table returns SQLITE_EMPTY. |
| 70034 | | - */ |
| 70035 | | - pc = pOp->p2 - 1; |
| 70036 | | - assert( u.bg.pC->rowidIsValid==0 ); |
| 70037 | | - u.bg.pC->seekResult = 0; |
| 70038 | | - } |
| 70338 | + assert( u.bg.pCrsr!=0 ); |
| 70339 | + u.bg.res = 0; |
| 70340 | + u.bg.iKey = pIn3->u.i; |
| 70341 | + rc = sqlite3BtreeMovetoUnpacked(u.bg.pCrsr, 0, u.bg.iKey, 0, &u.bg.res); |
| 70342 | + u.bg.pC->lastRowid = pIn3->u.i; |
| 70343 | + u.bg.pC->rowidIsValid = u.bg.res==0 ?1:0; |
| 70344 | + u.bg.pC->nullRow = 0; |
| 70345 | + u.bg.pC->cacheStatus = CACHE_STALE; |
| 70346 | + u.bg.pC->deferredMoveto = 0; |
| 70347 | + if( u.bg.res!=0 ){ |
| 70348 | + pc = pOp->p2 - 1; |
| 70349 | + assert( u.bg.pC->rowidIsValid==0 ); |
| 70350 | + } |
| 70351 | + u.bg.pC->seekResult = u.bg.res; |
| 70039 | 70352 | break; |
| 70040 | 70353 | } |
| 70041 | 70354 | |
| 70042 | 70355 | /* Opcode: Sequence P1 P2 * * * |
| 70356 | +** Synopsis: r[P2]=rowid |
| 70043 | 70357 | ** |
| 70044 | 70358 | ** Find the next available sequence number for cursor P1. |
| 70045 | 70359 | ** Write the sequence number into register P2. |
| 70046 | 70360 | ** The sequence number on the cursor is incremented after this |
| 70047 | 70361 | ** instruction. |
| | @@ -70053,10 +70367,11 @@ |
| 70053 | 70367 | break; |
| 70054 | 70368 | } |
| 70055 | 70369 | |
| 70056 | 70370 | |
| 70057 | 70371 | /* Opcode: NewRowid P1 P2 P3 * * |
| 70372 | +** Synopsis: r[P2]=rowid |
| 70058 | 70373 | ** |
| 70059 | 70374 | ** Get a new integer record number (a.k.a "rowid") used as the key to a table. |
| 70060 | 70375 | ** The record number is not previously used as a key in the database |
| 70061 | 70376 | ** table that cursor P1 points to. The new record number is written |
| 70062 | 70377 | ** written to register P2. |
| | @@ -70204,10 +70519,11 @@ |
| 70204 | 70519 | pOut->u.i = u.bh.v; |
| 70205 | 70520 | break; |
| 70206 | 70521 | } |
| 70207 | 70522 | |
| 70208 | 70523 | /* Opcode: Insert P1 P2 P3 P4 P5 |
| 70524 | +** Synopsis: intkey=r[P3] data=r[P2] |
| 70209 | 70525 | ** |
| 70210 | 70526 | ** Write an entry into the table of cursor P1. A new entry is |
| 70211 | 70527 | ** created if it doesn't already exist or the data for an existing |
| 70212 | 70528 | ** entry is overwritten. The data is the value MEM_Blob stored in register |
| 70213 | 70529 | ** number P2. The key is stored in register P3. The key must |
| | @@ -70243,10 +70559,11 @@ |
| 70243 | 70559 | ** |
| 70244 | 70560 | ** This instruction only works on tables. The equivalent instruction |
| 70245 | 70561 | ** for indices is OP_IdxInsert. |
| 70246 | 70562 | */ |
| 70247 | 70563 | /* Opcode: InsertInt P1 P2 P3 P4 P5 |
| 70564 | +** Synopsis: intkey=P3 data=r[P2] |
| 70248 | 70565 | ** |
| 70249 | 70566 | ** This works exactly like OP_Insert except that the key is the |
| 70250 | 70567 | ** integer value P3, not the value of the integer stored in register P3. |
| 70251 | 70568 | */ |
| 70252 | 70569 | case OP_Insert: |
| | @@ -70396,34 +70713,46 @@ |
| 70396 | 70713 | sqlite3VdbeSetChanges(db, p->nChange); |
| 70397 | 70714 | p->nChange = 0; |
| 70398 | 70715 | break; |
| 70399 | 70716 | } |
| 70400 | 70717 | |
| 70401 | | -/* Opcode: SorterCompare P1 P2 P3 |
| 70718 | +/* Opcode: SorterCompare P1 P2 P3 P4 |
| 70719 | +** Synopsis: if key(P1)!=rtrim(r[P3],P4) goto P2 |
| 70402 | 70720 | ** |
| 70403 | | -** P1 is a sorter cursor. This instruction compares the record blob in |
| 70404 | | -** register P3 with the entry that the sorter cursor currently points to. |
| 70405 | | -** If, excluding the rowid fields at the end, the two records are a match, |
| 70406 | | -** fall through to the next instruction. Otherwise, jump to instruction P2. |
| 70721 | +** P1 is a sorter cursor. This instruction compares a prefix of the |
| 70722 | +** the record blob in register P3 against a prefix of the entry that |
| 70723 | +** the sorter cursor currently points to. The final P4 fields of both |
| 70724 | +** the P3 and sorter record are ignored. |
| 70725 | +** |
| 70726 | +** If either P3 or the sorter contains a NULL in one of their significant |
| 70727 | +** fields (not counting the P4 fields at the end which are ignored) then |
| 70728 | +** the comparison is assumed to be equal. |
| 70729 | +** |
| 70730 | +** Fall through to next instruction if the two records compare equal to |
| 70731 | +** each other. Jump to P2 if they are different. |
| 70407 | 70732 | */ |
| 70408 | 70733 | case OP_SorterCompare: { |
| 70409 | 70734 | #if 0 /* local variables moved into u.bk */ |
| 70410 | 70735 | VdbeCursor *pC; |
| 70411 | 70736 | int res; |
| 70737 | + int nIgnore; |
| 70412 | 70738 | #endif /* local variables moved into u.bk */ |
| 70413 | 70739 | |
| 70414 | 70740 | u.bk.pC = p->apCsr[pOp->p1]; |
| 70415 | 70741 | assert( isSorter(u.bk.pC) ); |
| 70742 | + assert( pOp->p4type==P4_INT32 ); |
| 70416 | 70743 | pIn3 = &aMem[pOp->p3]; |
| 70417 | | - rc = sqlite3VdbeSorterCompare(u.bk.pC, pIn3, &u.bk.res); |
| 70744 | + u.bk.nIgnore = pOp->p4.i; |
| 70745 | + rc = sqlite3VdbeSorterCompare(u.bk.pC, pIn3, u.bk.nIgnore, &u.bk.res); |
| 70418 | 70746 | if( u.bk.res ){ |
| 70419 | 70747 | pc = pOp->p2-1; |
| 70420 | 70748 | } |
| 70421 | 70749 | break; |
| 70422 | 70750 | }; |
| 70423 | 70751 | |
| 70424 | 70752 | /* Opcode: SorterData P1 P2 * * * |
| 70753 | +** Synopsis: r[P2]=data |
| 70425 | 70754 | ** |
| 70426 | 70755 | ** Write into register P2 the current sorter data for sorter cursor P1. |
| 70427 | 70756 | */ |
| 70428 | 70757 | case OP_SorterData: { |
| 70429 | 70758 | #if 0 /* local variables moved into u.bl */ |
| | @@ -70436,10 +70765,11 @@ |
| 70436 | 70765 | rc = sqlite3VdbeSorterRowkey(u.bl.pC, pOut); |
| 70437 | 70766 | break; |
| 70438 | 70767 | } |
| 70439 | 70768 | |
| 70440 | 70769 | /* Opcode: RowData P1 P2 * * * |
| 70770 | +** Synopsis: r[P2]=data |
| 70441 | 70771 | ** |
| 70442 | 70772 | ** Write into register P2 the complete row data for cursor P1. |
| 70443 | 70773 | ** There is no interpretation of the data. |
| 70444 | 70774 | ** It is just copied onto the P2 register exactly as |
| 70445 | 70775 | ** it is found in the database file. |
| | @@ -70446,10 +70776,11 @@ |
| 70446 | 70776 | ** |
| 70447 | 70777 | ** If the P1 cursor must be pointing to a valid row (not a NULL row) |
| 70448 | 70778 | ** of a real table, not a pseudo-table. |
| 70449 | 70779 | */ |
| 70450 | 70780 | /* Opcode: RowKey P1 P2 * * * |
| 70781 | +** Synopsis: r[P2]=key |
| 70451 | 70782 | ** |
| 70452 | 70783 | ** Write into register P2 the complete row key for cursor P1. |
| 70453 | 70784 | ** There is no interpretation of the data. |
| 70454 | 70785 | ** The key is copied onto the P3 register exactly as |
| 70455 | 70786 | ** it is found in the database file. |
| | @@ -70516,14 +70847,16 @@ |
| 70516 | 70847 | }else{ |
| 70517 | 70848 | rc = sqlite3BtreeData(u.bm.pCrsr, 0, u.bm.n, pOut->z); |
| 70518 | 70849 | } |
| 70519 | 70850 | pOut->enc = SQLITE_UTF8; /* In case the blob is ever cast to text */ |
| 70520 | 70851 | UPDATE_MAX_BLOBSIZE(pOut); |
| 70852 | + REGISTER_TRACE(pOp->p2, pOut); |
| 70521 | 70853 | break; |
| 70522 | 70854 | } |
| 70523 | 70855 | |
| 70524 | 70856 | /* Opcode: Rowid P1 P2 * * * |
| 70857 | +** Synopsis: r[P2]=rowid |
| 70525 | 70858 | ** |
| 70526 | 70859 | ** Store in register P2 an integer which is the key of the table entry that |
| 70527 | 70860 | ** P1 is currently point to. |
| 70528 | 70861 | ** |
| 70529 | 70862 | ** P1 can be either an ordinary table or a virtual table. There used to |
| | @@ -70611,13 +70944,12 @@ |
| 70611 | 70944 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 70612 | 70945 | u.bp.pC = p->apCsr[pOp->p1]; |
| 70613 | 70946 | assert( u.bp.pC!=0 ); |
| 70614 | 70947 | u.bp.pCrsr = u.bp.pC->pCursor; |
| 70615 | 70948 | u.bp.res = 0; |
| 70616 | | - if( ALWAYS(u.bp.pCrsr!=0) ){ |
| 70617 | | - rc = sqlite3BtreeLast(u.bp.pCrsr, &u.bp.res); |
| 70618 | | - } |
| 70949 | + assert( u.bp.pCrsr!=0 ); |
| 70950 | + rc = sqlite3BtreeLast(u.bp.pCrsr, &u.bp.res); |
| 70619 | 70951 | u.bp.pC->nullRow = (u8)u.bp.res; |
| 70620 | 70952 | u.bp.pC->deferredMoveto = 0; |
| 70621 | 70953 | u.bp.pC->rowidIsValid = 0; |
| 70622 | 70954 | u.bp.pC->cacheStatus = CACHE_STALE; |
| 70623 | 70955 | if( pOp->p2>0 && u.bp.res ){ |
| | @@ -70685,11 +71017,11 @@ |
| 70685 | 71017 | pc = pOp->p2 - 1; |
| 70686 | 71018 | } |
| 70687 | 71019 | break; |
| 70688 | 71020 | } |
| 70689 | 71021 | |
| 70690 | | -/* Opcode: Next P1 P2 * P4 P5 |
| 71022 | +/* Opcode: Next P1 P2 * * P5 |
| 70691 | 71023 | ** |
| 70692 | 71024 | ** Advance cursor P1 so that it points to the next key/data pair in its |
| 70693 | 71025 | ** table or index. If there are no more key/value pairs then fall through |
| 70694 | 71026 | ** to the following instruction. But if the cursor advance was successful, |
| 70695 | 71027 | ** jump immediately to P2. |
| | @@ -70757,10 +71089,11 @@ |
| 70757 | 71089 | u.br.pC->rowidIsValid = 0; |
| 70758 | 71090 | goto check_for_interrupt; |
| 70759 | 71091 | } |
| 70760 | 71092 | |
| 70761 | 71093 | /* Opcode: IdxInsert P1 P2 P3 * P5 |
| 71094 | +** Synopsis: key=r[P2] |
| 70762 | 71095 | ** |
| 70763 | 71096 | ** Register P2 holds an SQL index key made using the |
| 70764 | 71097 | ** MakeRecord instructions. This opcode writes that key |
| 70765 | 71098 | ** into the index P1. Data for the entry is nil. |
| 70766 | 71099 | ** |
| | @@ -70784,31 +71117,32 @@ |
| 70784 | 71117 | assert( u.bs.pC!=0 ); |
| 70785 | 71118 | assert( u.bs.pC->isSorter==(pOp->opcode==OP_SorterInsert) ); |
| 70786 | 71119 | pIn2 = &aMem[pOp->p2]; |
| 70787 | 71120 | assert( pIn2->flags & MEM_Blob ); |
| 70788 | 71121 | u.bs.pCrsr = u.bs.pC->pCursor; |
| 70789 | | - if( ALWAYS(u.bs.pCrsr!=0) ){ |
| 70790 | | - assert( u.bs.pC->isTable==0 ); |
| 70791 | | - rc = ExpandBlob(pIn2); |
| 70792 | | - if( rc==SQLITE_OK ){ |
| 70793 | | - if( isSorter(u.bs.pC) ){ |
| 70794 | | - rc = sqlite3VdbeSorterWrite(db, u.bs.pC, pIn2); |
| 70795 | | - }else{ |
| 70796 | | - u.bs.nKey = pIn2->n; |
| 70797 | | - u.bs.zKey = pIn2->z; |
| 70798 | | - rc = sqlite3BtreeInsert(u.bs.pCrsr, u.bs.zKey, u.bs.nKey, "", 0, 0, pOp->p3, |
| 70799 | | - ((pOp->p5 & OPFLAG_USESEEKRESULT) ? u.bs.pC->seekResult : 0) |
| 70800 | | - ); |
| 70801 | | - assert( u.bs.pC->deferredMoveto==0 ); |
| 70802 | | - u.bs.pC->cacheStatus = CACHE_STALE; |
| 70803 | | - } |
| 71122 | + if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; |
| 71123 | + assert( u.bs.pCrsr!=0 ); |
| 71124 | + assert( u.bs.pC->isTable==0 ); |
| 71125 | + rc = ExpandBlob(pIn2); |
| 71126 | + if( rc==SQLITE_OK ){ |
| 71127 | + if( isSorter(u.bs.pC) ){ |
| 71128 | + rc = sqlite3VdbeSorterWrite(db, u.bs.pC, pIn2); |
| 71129 | + }else{ |
| 71130 | + u.bs.nKey = pIn2->n; |
| 71131 | + u.bs.zKey = pIn2->z; |
| 71132 | + rc = sqlite3BtreeInsert(u.bs.pCrsr, u.bs.zKey, u.bs.nKey, "", 0, 0, pOp->p3, |
| 71133 | + ((pOp->p5 & OPFLAG_USESEEKRESULT) ? u.bs.pC->seekResult : 0) |
| 71134 | + ); |
| 71135 | + assert( u.bs.pC->deferredMoveto==0 ); |
| 71136 | + u.bs.pC->cacheStatus = CACHE_STALE; |
| 70804 | 71137 | } |
| 70805 | 71138 | } |
| 70806 | 71139 | break; |
| 70807 | 71140 | } |
| 70808 | 71141 | |
| 70809 | 71142 | /* Opcode: IdxDelete P1 P2 P3 * * |
| 71143 | +** Synopsis: key=r[P2@P3] |
| 70810 | 71144 | ** |
| 70811 | 71145 | ** The content of P3 registers starting at register P2 form |
| 70812 | 71146 | ** an unpacked index key. This opcode removes that entry from the |
| 70813 | 71147 | ** index opened by cursor P1. |
| 70814 | 71148 | */ |
| | @@ -70824,29 +71158,30 @@ |
| 70824 | 71158 | assert( pOp->p2>0 && pOp->p2+pOp->p3<=(p->nMem-p->nCursor)+1 ); |
| 70825 | 71159 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 70826 | 71160 | u.bt.pC = p->apCsr[pOp->p1]; |
| 70827 | 71161 | assert( u.bt.pC!=0 ); |
| 70828 | 71162 | u.bt.pCrsr = u.bt.pC->pCursor; |
| 70829 | | - if( ALWAYS(u.bt.pCrsr!=0) ){ |
| 70830 | | - u.bt.r.pKeyInfo = u.bt.pC->pKeyInfo; |
| 70831 | | - u.bt.r.nField = (u16)pOp->p3; |
| 70832 | | - u.bt.r.flags = 0; |
| 70833 | | - u.bt.r.aMem = &aMem[pOp->p2]; |
| 71163 | + assert( u.bt.pCrsr!=0 ); |
| 71164 | + assert( pOp->p5==0 ); |
| 71165 | + u.bt.r.pKeyInfo = u.bt.pC->pKeyInfo; |
| 71166 | + u.bt.r.nField = (u16)pOp->p3; |
| 71167 | + u.bt.r.flags = UNPACKED_PREFIX_MATCH; |
| 71168 | + u.bt.r.aMem = &aMem[pOp->p2]; |
| 70834 | 71169 | #ifdef SQLITE_DEBUG |
| 70835 | | - { int i; for(i=0; i<u.bt.r.nField; i++) assert( memIsValid(&u.bt.r.aMem[i]) ); } |
| 71170 | + { int i; for(i=0; i<u.bt.r.nField; i++) assert( memIsValid(&u.bt.r.aMem[i]) ); } |
| 70836 | 71171 | #endif |
| 70837 | | - rc = sqlite3BtreeMovetoUnpacked(u.bt.pCrsr, &u.bt.r, 0, 0, &u.bt.res); |
| 70838 | | - if( rc==SQLITE_OK && u.bt.res==0 ){ |
| 70839 | | - rc = sqlite3BtreeDelete(u.bt.pCrsr); |
| 70840 | | - } |
| 70841 | | - assert( u.bt.pC->deferredMoveto==0 ); |
| 70842 | | - u.bt.pC->cacheStatus = CACHE_STALE; |
| 71172 | + rc = sqlite3BtreeMovetoUnpacked(u.bt.pCrsr, &u.bt.r, 0, 0, &u.bt.res); |
| 71173 | + if( rc==SQLITE_OK && u.bt.res==0 ){ |
| 71174 | + rc = sqlite3BtreeDelete(u.bt.pCrsr); |
| 70843 | 71175 | } |
| 71176 | + assert( u.bt.pC->deferredMoveto==0 ); |
| 71177 | + u.bt.pC->cacheStatus = CACHE_STALE; |
| 70844 | 71178 | break; |
| 70845 | 71179 | } |
| 70846 | 71180 | |
| 70847 | 71181 | /* Opcode: IdxRowid P1 P2 * * * |
| 71182 | +** Synopsis: r[P2]=rowid |
| 70848 | 71183 | ** |
| 70849 | 71184 | ** Write into register P2 an integer which is the last entry in the record at |
| 70850 | 71185 | ** the end of the index key pointed to by cursor P1. This integer should be |
| 70851 | 71186 | ** the rowid of the table entry to which this index entry points. |
| 70852 | 71187 | ** |
| | @@ -70861,29 +71196,29 @@ |
| 70861 | 71196 | |
| 70862 | 71197 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 70863 | 71198 | u.bu.pC = p->apCsr[pOp->p1]; |
| 70864 | 71199 | assert( u.bu.pC!=0 ); |
| 70865 | 71200 | u.bu.pCrsr = u.bu.pC->pCursor; |
| 71201 | + assert( u.bu.pCrsr!=0 ); |
| 70866 | 71202 | pOut->flags = MEM_Null; |
| 70867 | | - if( ALWAYS(u.bu.pCrsr!=0) ){ |
| 70868 | | - rc = sqlite3VdbeCursorMoveto(u.bu.pC); |
| 70869 | | - if( NEVER(rc) ) goto abort_due_to_error; |
| 70870 | | - assert( u.bu.pC->deferredMoveto==0 ); |
| 70871 | | - assert( u.bu.pC->isTable==0 ); |
| 70872 | | - if( !u.bu.pC->nullRow ){ |
| 70873 | | - rc = sqlite3VdbeIdxRowid(db, u.bu.pCrsr, &u.bu.rowid); |
| 70874 | | - if( rc!=SQLITE_OK ){ |
| 70875 | | - goto abort_due_to_error; |
| 70876 | | - } |
| 70877 | | - pOut->u.i = u.bu.rowid; |
| 70878 | | - pOut->flags = MEM_Int; |
| 70879 | | - } |
| 71203 | + rc = sqlite3VdbeCursorMoveto(u.bu.pC); |
| 71204 | + if( NEVER(rc) ) goto abort_due_to_error; |
| 71205 | + assert( u.bu.pC->deferredMoveto==0 ); |
| 71206 | + assert( u.bu.pC->isTable==0 ); |
| 71207 | + if( !u.bu.pC->nullRow ){ |
| 71208 | + rc = sqlite3VdbeIdxRowid(db, u.bu.pCrsr, &u.bu.rowid); |
| 71209 | + if( rc!=SQLITE_OK ){ |
| 71210 | + goto abort_due_to_error; |
| 71211 | + } |
| 71212 | + pOut->u.i = u.bu.rowid; |
| 71213 | + pOut->flags = MEM_Int; |
| 70880 | 71214 | } |
| 70881 | 71215 | break; |
| 70882 | 71216 | } |
| 70883 | 71217 | |
| 70884 | 71218 | /* Opcode: IdxGE P1 P2 P3 P4 P5 |
| 71219 | +** Synopsis: key=r[P3@P4] |
| 70885 | 71220 | ** |
| 70886 | 71221 | ** The P4 register values beginning with P3 form an unpacked index |
| 70887 | 71222 | ** key that omits the ROWID. Compare this key value against the index |
| 70888 | 71223 | ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. |
| 70889 | 71224 | ** |
| | @@ -70894,10 +71229,11 @@ |
| 70894 | 71229 | ** prior to the comparison. This make the opcode work like IdxGT except |
| 70895 | 71230 | ** that if the key from register P3 is a prefix of the key in the cursor, |
| 70896 | 71231 | ** the result is false whereas it would be true with IdxGT. |
| 70897 | 71232 | */ |
| 70898 | 71233 | /* Opcode: IdxLT P1 P2 P3 P4 P5 |
| 71234 | +** Synopsis: key=r[P3@P4] |
| 70899 | 71235 | ** |
| 70900 | 71236 | ** The P4 register values beginning with P3 form an unpacked index |
| 70901 | 71237 | ** key that omits the ROWID. Compare this key value against the index |
| 70902 | 71238 | ** that P1 is currently pointing to, ignoring the ROWID on the P1 index. |
| 70903 | 71239 | ** |
| | @@ -70917,35 +71253,34 @@ |
| 70917 | 71253 | |
| 70918 | 71254 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 70919 | 71255 | u.bv.pC = p->apCsr[pOp->p1]; |
| 70920 | 71256 | assert( u.bv.pC!=0 ); |
| 70921 | 71257 | assert( u.bv.pC->isOrdered ); |
| 70922 | | - if( ALWAYS(u.bv.pC->pCursor!=0) ){ |
| 70923 | | - assert( u.bv.pC->deferredMoveto==0 ); |
| 70924 | | - assert( pOp->p5==0 || pOp->p5==1 ); |
| 70925 | | - assert( pOp->p4type==P4_INT32 ); |
| 70926 | | - u.bv.r.pKeyInfo = u.bv.pC->pKeyInfo; |
| 70927 | | - u.bv.r.nField = (u16)pOp->p4.i; |
| 70928 | | - if( pOp->p5 ){ |
| 70929 | | - u.bv.r.flags = UNPACKED_INCRKEY | UNPACKED_PREFIX_MATCH; |
| 70930 | | - }else{ |
| 70931 | | - u.bv.r.flags = UNPACKED_PREFIX_MATCH; |
| 70932 | | - } |
| 70933 | | - u.bv.r.aMem = &aMem[pOp->p3]; |
| 71258 | + assert( u.bv.pC->pCursor!=0); |
| 71259 | + assert( u.bv.pC->deferredMoveto==0 ); |
| 71260 | + assert( pOp->p5==0 || pOp->p5==1 ); |
| 71261 | + assert( pOp->p4type==P4_INT32 ); |
| 71262 | + u.bv.r.pKeyInfo = u.bv.pC->pKeyInfo; |
| 71263 | + u.bv.r.nField = (u16)pOp->p4.i; |
| 71264 | + if( pOp->p5 ){ |
| 71265 | + u.bv.r.flags = UNPACKED_INCRKEY | UNPACKED_PREFIX_MATCH; |
| 71266 | + }else{ |
| 71267 | + u.bv.r.flags = UNPACKED_PREFIX_MATCH; |
| 71268 | + } |
| 71269 | + u.bv.r.aMem = &aMem[pOp->p3]; |
| 70934 | 71270 | #ifdef SQLITE_DEBUG |
| 70935 | | - { int i; for(i=0; i<u.bv.r.nField; i++) assert( memIsValid(&u.bv.r.aMem[i]) ); } |
| 71271 | + { int i; for(i=0; i<u.bv.r.nField; i++) assert( memIsValid(&u.bv.r.aMem[i]) ); } |
| 70936 | 71272 | #endif |
| 70937 | | - rc = sqlite3VdbeIdxKeyCompare(u.bv.pC, &u.bv.r, &u.bv.res); |
| 70938 | | - if( pOp->opcode==OP_IdxLT ){ |
| 70939 | | - u.bv.res = -u.bv.res; |
| 70940 | | - }else{ |
| 70941 | | - assert( pOp->opcode==OP_IdxGE ); |
| 70942 | | - u.bv.res++; |
| 70943 | | - } |
| 70944 | | - if( u.bv.res>0 ){ |
| 70945 | | - pc = pOp->p2 - 1 ; |
| 70946 | | - } |
| 71273 | + rc = sqlite3VdbeIdxKeyCompare(u.bv.pC, &u.bv.r, &u.bv.res); |
| 71274 | + if( pOp->opcode==OP_IdxLT ){ |
| 71275 | + u.bv.res = -u.bv.res; |
| 71276 | + }else{ |
| 71277 | + assert( pOp->opcode==OP_IdxGE ); |
| 71278 | + u.bv.res++; |
| 71279 | + } |
| 71280 | + if( u.bv.res>0 ){ |
| 71281 | + pc = pOp->p2 - 1 ; |
| 70947 | 71282 | } |
| 70948 | 71283 | break; |
| 70949 | 71284 | } |
| 70950 | 71285 | |
| 70951 | 71286 | /* Opcode: Destroy P1 P2 P3 * * |
| | @@ -71052,10 +71387,11 @@ |
| 71052 | 71387 | } |
| 71053 | 71388 | break; |
| 71054 | 71389 | } |
| 71055 | 71390 | |
| 71056 | 71391 | /* Opcode: CreateTable P1 P2 * * * |
| 71392 | +** Synopsis: r[P2]=root iDb=P1 |
| 71057 | 71393 | ** |
| 71058 | 71394 | ** Allocate a new table in the main database file if P1==0 or in the |
| 71059 | 71395 | ** auxiliary database file if P1==1 or in an attached database if |
| 71060 | 71396 | ** P1>1. Write the root page number of the new table into |
| 71061 | 71397 | ** register P2 |
| | @@ -71065,10 +71401,11 @@ |
| 71065 | 71401 | ** has an arbitrary key but no data. |
| 71066 | 71402 | ** |
| 71067 | 71403 | ** See also: CreateIndex |
| 71068 | 71404 | */ |
| 71069 | 71405 | /* Opcode: CreateIndex P1 P2 * * * |
| 71406 | +** Synopsis: r[P2]=root iDb=P1 |
| 71070 | 71407 | ** |
| 71071 | 71408 | ** Allocate a new index in the main database file if P1==0 or in the |
| 71072 | 71409 | ** auxiliary database file if P1==1 or in an attached database if |
| 71073 | 71410 | ** P1>1. Write the root page number of the new table into |
| 71074 | 71411 | ** register P2. |
| | @@ -71272,10 +71609,11 @@ |
| 71272 | 71609 | break; |
| 71273 | 71610 | } |
| 71274 | 71611 | #endif /* SQLITE_OMIT_INTEGRITY_CHECK */ |
| 71275 | 71612 | |
| 71276 | 71613 | /* Opcode: RowSetAdd P1 P2 * * * |
| 71614 | +** Synopsis: rowset(P1)=r[P2] |
| 71277 | 71615 | ** |
| 71278 | 71616 | ** Insert the integer value held by register P2 into a boolean index |
| 71279 | 71617 | ** held in register P1. |
| 71280 | 71618 | ** |
| 71281 | 71619 | ** An assertion fails if P2 is not an integer. |
| | @@ -71291,10 +71629,11 @@ |
| 71291 | 71629 | sqlite3RowSetInsert(pIn1->u.pRowSet, pIn2->u.i); |
| 71292 | 71630 | break; |
| 71293 | 71631 | } |
| 71294 | 71632 | |
| 71295 | 71633 | /* Opcode: RowSetRead P1 P2 P3 * * |
| 71634 | +** Synopsis: r[P3]=rowset(P1) |
| 71296 | 71635 | ** |
| 71297 | 71636 | ** Extract the smallest value from boolean index P1 and put that value into |
| 71298 | 71637 | ** register P3. Or, if boolean index P1 is initially empty, leave P3 |
| 71299 | 71638 | ** unchanged and jump to instruction P2. |
| 71300 | 71639 | */ |
| | @@ -71316,10 +71655,11 @@ |
| 71316 | 71655 | } |
| 71317 | 71656 | goto check_for_interrupt; |
| 71318 | 71657 | } |
| 71319 | 71658 | |
| 71320 | 71659 | /* Opcode: RowSetTest P1 P2 P3 P4 |
| 71660 | +** Synopsis: if r[P3] in rowset(P1) goto P2 |
| 71321 | 71661 | ** |
| 71322 | 71662 | ** Register P3 is assumed to hold a 64-bit integer value. If register P1 |
| 71323 | 71663 | ** contains a RowSet object and that RowSet object contains |
| 71324 | 71664 | ** the value held in P3, jump to register P2. Otherwise, insert the |
| 71325 | 71665 | ** integer in P3 into the RowSet and continue on to the |
| | @@ -71525,10 +71865,11 @@ |
| 71525 | 71865 | |
| 71526 | 71866 | #endif /* #ifndef SQLITE_OMIT_TRIGGER */ |
| 71527 | 71867 | |
| 71528 | 71868 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 71529 | 71869 | /* Opcode: FkCounter P1 P2 * * * |
| 71870 | +** Synopsis: fkctr[P1]+=P2 |
| 71530 | 71871 | ** |
| 71531 | 71872 | ** Increment a "constraint counter" by P2 (P2 may be negative or positive). |
| 71532 | 71873 | ** If P1 is non-zero, the database constraint counter is incremented |
| 71533 | 71874 | ** (deferred foreign key constraints). Otherwise, if P1 is zero, the |
| 71534 | 71875 | ** statement counter is incremented (immediate foreign key constraints). |
| | @@ -71543,10 +71884,11 @@ |
| 71543 | 71884 | } |
| 71544 | 71885 | break; |
| 71545 | 71886 | } |
| 71546 | 71887 | |
| 71547 | 71888 | /* Opcode: FkIfZero P1 P2 * * * |
| 71889 | +** Synopsis: if fkctr[P1]==0 goto P2 |
| 71548 | 71890 | ** |
| 71549 | 71891 | ** This opcode tests if a foreign key constraint-counter is currently zero. |
| 71550 | 71892 | ** If so, jump to instruction P2. Otherwise, fall through to the next |
| 71551 | 71893 | ** instruction. |
| 71552 | 71894 | ** |
| | @@ -71565,10 +71907,11 @@ |
| 71565 | 71907 | } |
| 71566 | 71908 | #endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */ |
| 71567 | 71909 | |
| 71568 | 71910 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 71569 | 71911 | /* Opcode: MemMax P1 P2 * * * |
| 71912 | +** Synopsis: r[P1]=max(r[P1],r[P2]) |
| 71570 | 71913 | ** |
| 71571 | 71914 | ** P1 is a register in the root frame of this VM (the root frame is |
| 71572 | 71915 | ** different from the current frame if this instruction is being executed |
| 71573 | 71916 | ** within a sub-program). Set the value of register P1 to the maximum of |
| 71574 | 71917 | ** its current value and the value in register P2. |
| | @@ -71597,10 +71940,11 @@ |
| 71597 | 71940 | break; |
| 71598 | 71941 | } |
| 71599 | 71942 | #endif /* SQLITE_OMIT_AUTOINCREMENT */ |
| 71600 | 71943 | |
| 71601 | 71944 | /* Opcode: IfPos P1 P2 * * * |
| 71945 | +** Synopsis: if r[P1]>0 goto P2 |
| 71602 | 71946 | ** |
| 71603 | 71947 | ** If the value of register P1 is 1 or greater, jump to P2. |
| 71604 | 71948 | ** |
| 71605 | 71949 | ** It is illegal to use this instruction on a register that does |
| 71606 | 71950 | ** not contain an integer. An assertion fault will result if you try. |
| | @@ -71613,10 +71957,11 @@ |
| 71613 | 71957 | } |
| 71614 | 71958 | break; |
| 71615 | 71959 | } |
| 71616 | 71960 | |
| 71617 | 71961 | /* Opcode: IfNeg P1 P2 * * * |
| 71962 | +** Synopsis: if r[P1]<0 goto P2 |
| 71618 | 71963 | ** |
| 71619 | 71964 | ** If the value of register P1 is less than zero, jump to P2. |
| 71620 | 71965 | ** |
| 71621 | 71966 | ** It is illegal to use this instruction on a register that does |
| 71622 | 71967 | ** not contain an integer. An assertion fault will result if you try. |
| | @@ -71629,10 +71974,11 @@ |
| 71629 | 71974 | } |
| 71630 | 71975 | break; |
| 71631 | 71976 | } |
| 71632 | 71977 | |
| 71633 | 71978 | /* Opcode: IfZero P1 P2 P3 * * |
| 71979 | +** Synopsis: r[P1]+=P3, if r[P1]==0 goto P2 |
| 71634 | 71980 | ** |
| 71635 | 71981 | ** The register P1 must contain an integer. Add literal P3 to the |
| 71636 | 71982 | ** value in register P1. If the result is exactly 0, jump to P2. |
| 71637 | 71983 | ** |
| 71638 | 71984 | ** It is illegal to use this instruction on a register that does |
| | @@ -71647,10 +71993,11 @@ |
| 71647 | 71993 | } |
| 71648 | 71994 | break; |
| 71649 | 71995 | } |
| 71650 | 71996 | |
| 71651 | 71997 | /* Opcode: AggStep * P2 P3 P4 P5 |
| 71998 | +** Synopsis: accum=r[P3] step(r[P2@P5]) |
| 71652 | 71999 | ** |
| 71653 | 72000 | ** Execute the step function for an aggregate. The |
| 71654 | 72001 | ** function has P5 arguments. P4 is a pointer to the FuncDef |
| 71655 | 72002 | ** structure that specifies the function. Use register |
| 71656 | 72003 | ** P3 as the accumulator. |
| | @@ -71712,10 +72059,11 @@ |
| 71712 | 72059 | |
| 71713 | 72060 | break; |
| 71714 | 72061 | } |
| 71715 | 72062 | |
| 71716 | 72063 | /* Opcode: AggFinal P1 P2 * P4 * |
| 72064 | +** Synopsis: accum=r[P1] N=P2 |
| 71717 | 72065 | ** |
| 71718 | 72066 | ** Execute the finalizer function for an aggregate. P1 is |
| 71719 | 72067 | ** the memory location that is the accumulator for the aggregate. |
| 71720 | 72068 | ** |
| 71721 | 72069 | ** P2 is the number of arguments that the step function takes and |
| | @@ -71947,10 +72295,11 @@ |
| 71947 | 72295 | break; |
| 71948 | 72296 | } |
| 71949 | 72297 | |
| 71950 | 72298 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 71951 | 72299 | /* Opcode: TableLock P1 P2 P3 P4 * |
| 72300 | +** Synopsis: iDb=P1 root=P2 write=P3 |
| 71952 | 72301 | ** |
| 71953 | 72302 | ** Obtain a lock on a particular table. This instruction is only used when |
| 71954 | 72303 | ** the shared-cache feature is enabled. |
| 71955 | 72304 | ** |
| 71956 | 72305 | ** P1 is the index of the database in sqlite3.aDb[] of the database |
| | @@ -72067,10 +72416,11 @@ |
| 72067 | 72416 | } |
| 72068 | 72417 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 72069 | 72418 | |
| 72070 | 72419 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 72071 | 72420 | /* Opcode: VFilter P1 P2 P3 P4 * |
| 72421 | +** Synopsis: iPlan=r[P3] zPlan='P4' |
| 72072 | 72422 | ** |
| 72073 | 72423 | ** P1 is a cursor opened using VOpen. P2 is an address to jump to if |
| 72074 | 72424 | ** the filtered result set is empty. |
| 72075 | 72425 | ** |
| 72076 | 72426 | ** P4 is either NULL or a string that was generated by the xBestIndex |
| | @@ -72143,10 +72493,11 @@ |
| 72143 | 72493 | } |
| 72144 | 72494 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 72145 | 72495 | |
| 72146 | 72496 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 72147 | 72497 | /* Opcode: VColumn P1 P2 P3 * * |
| 72498 | +** Synopsis: r[P3]=vcolumn(P2) |
| 72148 | 72499 | ** |
| 72149 | 72500 | ** Store the value of the P2-th column of |
| 72150 | 72501 | ** the row of the virtual-table that the |
| 72151 | 72502 | ** P1 cursor is pointing to into register P3. |
| 72152 | 72503 | */ |
| | @@ -72282,10 +72633,11 @@ |
| 72282 | 72633 | } |
| 72283 | 72634 | #endif |
| 72284 | 72635 | |
| 72285 | 72636 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 72286 | 72637 | /* Opcode: VUpdate P1 P2 P3 P4 * |
| 72638 | +** Synopsis: data=r[P3@P2] |
| 72287 | 72639 | ** |
| 72288 | 72640 | ** P4 is a pointer to a virtual table object, an sqlite3_vtab structure. |
| 72289 | 72641 | ** This opcode invokes the corresponding xUpdate method. P2 values |
| 72290 | 72642 | ** are contiguous memory cells starting at P3 to pass to the xUpdate |
| 72291 | 72643 | ** invocation. The value in register (P3+P2-1) corresponds to the |
| | @@ -72413,10 +72765,20 @@ |
| 72413 | 72765 | ){ |
| 72414 | 72766 | u.cs.z = sqlite3VdbeExpandSql(p, u.cs.zTrace); |
| 72415 | 72767 | db->xTrace(db->pTraceArg, u.cs.z); |
| 72416 | 72768 | sqlite3DbFree(db, u.cs.z); |
| 72417 | 72769 | } |
| 72770 | +#ifdef SQLITE_USE_FCNTL_TRACE |
| 72771 | + u.cs.zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 72772 | + if( u.cs.zTrace ){ |
| 72773 | + int i; |
| 72774 | + for(i=0; i<db->nDb; i++){ |
| 72775 | + if( ((1<<i) & p->btreeMask)==0 ) continue; |
| 72776 | + sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, u.cs.zTrace); |
| 72777 | + } |
| 72778 | + } |
| 72779 | +#endif /* SQLITE_USE_FCNTL_TRACE */ |
| 72418 | 72780 | #ifdef SQLITE_DEBUG |
| 72419 | 72781 | if( (db->flags & SQLITE_SqlTrace)!=0 |
| 72420 | 72782 | && (u.cs.zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 |
| 72421 | 72783 | ){ |
| 72422 | 72784 | sqlite3DebugPrintf("SQL-trace: %s\n", u.cs.zTrace); |
| | @@ -72727,10 +73089,14 @@ |
| 72727 | 73089 | pTab = sqlite3LocateTable(pParse, 0, zTable, zDb); |
| 72728 | 73090 | if( pTab && IsVirtual(pTab) ){ |
| 72729 | 73091 | pTab = 0; |
| 72730 | 73092 | sqlite3ErrorMsg(pParse, "cannot open virtual table: %s", zTable); |
| 72731 | 73093 | } |
| 73094 | + if( pTab && !HasRowid(pTab) ){ |
| 73095 | + pTab = 0; |
| 73096 | + sqlite3ErrorMsg(pParse, "cannot open table without rowid: %s", zTable); |
| 73097 | + } |
| 72732 | 73098 | #ifndef SQLITE_OMIT_VIEW |
| 72733 | 73099 | if( pTab && pTab->pSelect ){ |
| 72734 | 73100 | pTab = 0; |
| 72735 | 73101 | sqlite3ErrorMsg(pParse, "cannot open view: %s", zTable); |
| 72736 | 73102 | } |
| | @@ -72784,11 +73150,11 @@ |
| 72784 | 73150 | } |
| 72785 | 73151 | } |
| 72786 | 73152 | #endif |
| 72787 | 73153 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 72788 | 73154 | int j; |
| 72789 | | - for(j=0; j<pIdx->nColumn; j++){ |
| 73155 | + for(j=0; j<pIdx->nKeyCol; j++){ |
| 72790 | 73156 | if( pIdx->aiColumn[j]==iCol ){ |
| 72791 | 73157 | zFault = "indexed"; |
| 72792 | 73158 | } |
| 72793 | 73159 | } |
| 72794 | 73160 | } |
| | @@ -73405,11 +73771,11 @@ |
| 73405 | 73771 | ** If pKey2 is passed a NULL pointer, then it is assumed that the pCsr->aSpace |
| 73406 | 73772 | ** has been allocated and contains an unpacked record that is used as key2. |
| 73407 | 73773 | */ |
| 73408 | 73774 | static void vdbeSorterCompare( |
| 73409 | 73775 | const VdbeCursor *pCsr, /* Cursor object (for pKeyInfo) */ |
| 73410 | | - int bOmitRowid, /* Ignore rowid field at end of keys */ |
| 73776 | + int nIgnore, /* Ignore the last nIgnore fields */ |
| 73411 | 73777 | const void *pKey1, int nKey1, /* Left side of comparison */ |
| 73412 | 73778 | const void *pKey2, int nKey2, /* Right side of comparison */ |
| 73413 | 73779 | int *pRes /* OUT: Result of comparison */ |
| 73414 | 73780 | ){ |
| 73415 | 73781 | KeyInfo *pKeyInfo = pCsr->pKeyInfo; |
| | @@ -73419,12 +73785,12 @@ |
| 73419 | 73785 | |
| 73420 | 73786 | if( pKey2 ){ |
| 73421 | 73787 | sqlite3VdbeRecordUnpack(pKeyInfo, nKey2, pKey2, r2); |
| 73422 | 73788 | } |
| 73423 | 73789 | |
| 73424 | | - if( bOmitRowid ){ |
| 73425 | | - r2->nField = pKeyInfo->nField; |
| 73790 | + if( nIgnore ){ |
| 73791 | + r2->nField = pKeyInfo->nField - nIgnore; |
| 73426 | 73792 | assert( r2->nField>0 ); |
| 73427 | 73793 | for(i=0; i<r2->nField; i++){ |
| 73428 | 73794 | if( r2->aMem[i].flags & MEM_Null ){ |
| 73429 | 73795 | *pRes = -1; |
| 73430 | 73796 | return; |
| | @@ -74046,17 +74412,18 @@ |
| 74046 | 74412 | ** key. |
| 74047 | 74413 | */ |
| 74048 | 74414 | SQLITE_PRIVATE int sqlite3VdbeSorterCompare( |
| 74049 | 74415 | const VdbeCursor *pCsr, /* Sorter cursor */ |
| 74050 | 74416 | Mem *pVal, /* Value to compare to current sorter key */ |
| 74417 | + int nIgnore, /* Ignore this many fields at the end */ |
| 74051 | 74418 | int *pRes /* OUT: Result of comparison */ |
| 74052 | 74419 | ){ |
| 74053 | 74420 | VdbeSorter *pSorter = pCsr->pSorter; |
| 74054 | 74421 | void *pKey; int nKey; /* Sorter key to compare pVal with */ |
| 74055 | 74422 | |
| 74056 | 74423 | pKey = vdbeSorterRowkey(pSorter, &nKey); |
| 74057 | | - vdbeSorterCompare(pCsr, 1, pVal->z, pVal->n, pKey, nKey, pRes); |
| 74424 | + vdbeSorterCompare(pCsr, nIgnore, pVal->z, pVal->n, pKey, nKey, pRes); |
| 74058 | 74425 | return SQLITE_OK; |
| 74059 | 74426 | } |
| 74060 | 74427 | |
| 74061 | 74428 | /************** End of vdbesort.c ********************************************/ |
| 74062 | 74429 | /************** Begin file journal.c *****************************************/ |
| | @@ -74955,11 +75322,13 @@ |
| 74955 | 75322 | sqlite3 *db = pParse->db; /* The database connection */ |
| 74956 | 75323 | struct SrcList_item *pItem; /* Use for looping over pSrcList items */ |
| 74957 | 75324 | struct SrcList_item *pMatch = 0; /* The matching pSrcList item */ |
| 74958 | 75325 | NameContext *pTopNC = pNC; /* First namecontext in the list */ |
| 74959 | 75326 | Schema *pSchema = 0; /* Schema of the expression */ |
| 74960 | | - int isTrigger = 0; |
| 75327 | + int isTrigger = 0; /* True if resolved to a trigger column */ |
| 75328 | + Table *pTab = 0; /* Table hold the row */ |
| 75329 | + Column *pCol; /* A column of pTab */ |
| 74961 | 75330 | |
| 74962 | 75331 | assert( pNC ); /* the name context cannot be NULL. */ |
| 74963 | 75332 | assert( zCol ); /* The Z in X.Y.Z cannot be NULL */ |
| 74964 | 75333 | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); |
| 74965 | 75334 | |
| | @@ -74996,13 +75365,10 @@ |
| 74996 | 75365 | ExprList *pEList; |
| 74997 | 75366 | SrcList *pSrcList = pNC->pSrcList; |
| 74998 | 75367 | |
| 74999 | 75368 | if( pSrcList ){ |
| 75000 | 75369 | for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){ |
| 75001 | | - Table *pTab; |
| 75002 | | - Column *pCol; |
| 75003 | | - |
| 75004 | 75370 | pTab = pItem->pTab; |
| 75005 | 75371 | assert( pTab!=0 && pTab->zName!=0 ); |
| 75006 | 75372 | assert( pTab->nCol>0 ); |
| 75007 | 75373 | if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){ |
| 75008 | 75374 | int hit = 0; |
| | @@ -75058,13 +75424,12 @@ |
| 75058 | 75424 | |
| 75059 | 75425 | #ifndef SQLITE_OMIT_TRIGGER |
| 75060 | 75426 | /* If we have not already resolved the name, then maybe |
| 75061 | 75427 | ** it is a new.* or old.* trigger argument reference |
| 75062 | 75428 | */ |
| 75063 | | - if( zDb==0 && zTab!=0 && cnt==0 && pParse->pTriggerTab!=0 ){ |
| 75429 | + if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){ |
| 75064 | 75430 | int op = pParse->eTriggerOp; |
| 75065 | | - Table *pTab = 0; |
| 75066 | 75431 | assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT ); |
| 75067 | 75432 | if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){ |
| 75068 | 75433 | pExpr->iTable = 1; |
| 75069 | 75434 | pTab = pParse->pTriggerTab; |
| 75070 | 75435 | }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){ |
| | @@ -75074,20 +75439,19 @@ |
| 75074 | 75439 | |
| 75075 | 75440 | if( pTab ){ |
| 75076 | 75441 | int iCol; |
| 75077 | 75442 | pSchema = pTab->pSchema; |
| 75078 | 75443 | cntTab++; |
| 75079 | | - for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 75080 | | - Column *pCol = &pTab->aCol[iCol]; |
| 75444 | + for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){ |
| 75081 | 75445 | if( sqlite3StrICmp(pCol->zName, zCol)==0 ){ |
| 75082 | 75446 | if( iCol==pTab->iPKey ){ |
| 75083 | 75447 | iCol = -1; |
| 75084 | 75448 | } |
| 75085 | 75449 | break; |
| 75086 | 75450 | } |
| 75087 | 75451 | } |
| 75088 | | - if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) ){ |
| 75452 | + if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && HasRowid(pTab) ){ |
| 75089 | 75453 | iCol = -1; /* IMP: R-44911-55124 */ |
| 75090 | 75454 | } |
| 75091 | 75455 | if( iCol<pTab->nCol ){ |
| 75092 | 75456 | cnt++; |
| 75093 | 75457 | if( iCol<0 ){ |
| | @@ -75110,11 +75474,12 @@ |
| 75110 | 75474 | #endif /* !defined(SQLITE_OMIT_TRIGGER) */ |
| 75111 | 75475 | |
| 75112 | 75476 | /* |
| 75113 | 75477 | ** Perhaps the name is a reference to the ROWID |
| 75114 | 75478 | */ |
| 75115 | | - if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){ |
| 75479 | + assert( pTab!=0 || cntTab==0 ); |
| 75480 | + if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) && HasRowid(pTab) ){ |
| 75116 | 75481 | cnt = 1; |
| 75117 | 75482 | pExpr->iColumn = -1; /* IMP: R-44911-55124 */ |
| 75118 | 75483 | pExpr->affinity = SQLITE_AFF_INTEGER; |
| 75119 | 75484 | } |
| 75120 | 75485 | |
| | @@ -77714,20 +78079,20 @@ |
| 77714 | 78079 | p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0); |
| 77715 | 78080 | if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){ |
| 77716 | 78081 | sqlite3 *db = pParse->db; /* Database connection */ |
| 77717 | 78082 | Table *pTab; /* Table <table>. */ |
| 77718 | 78083 | Expr *pExpr; /* Expression <column> */ |
| 77719 | | - int iCol; /* Index of column <column> */ |
| 77720 | | - int iDb; /* Database idx for pTab */ |
| 78084 | + i16 iCol; /* Index of column <column> */ |
| 78085 | + i16 iDb; /* Database idx for pTab */ |
| 77721 | 78086 | |
| 77722 | 78087 | assert( p ); /* Because of isCandidateForInOpt(p) */ |
| 77723 | 78088 | assert( p->pEList!=0 ); /* Because of isCandidateForInOpt(p) */ |
| 77724 | 78089 | assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */ |
| 77725 | 78090 | assert( p->pSrc!=0 ); /* Because of isCandidateForInOpt(p) */ |
| 77726 | 78091 | pTab = p->pSrc->a[0].pTab; |
| 77727 | 78092 | pExpr = p->pEList->a[0].pExpr; |
| 77728 | | - iCol = pExpr->iColumn; |
| 78093 | + iCol = (i16)pExpr->iColumn; |
| 77729 | 78094 | |
| 77730 | 78095 | /* Code an OP_VerifyCookie and OP_TableLock for <table>. */ |
| 77731 | 78096 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 77732 | 78097 | sqlite3CodeVerifySchema(pParse, iDb); |
| 77733 | 78098 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
| | @@ -77761,20 +78126,15 @@ |
| 77761 | 78126 | int affinity_ok = sqlite3IndexAffinityOk(pX, pTab->aCol[iCol].affinity); |
| 77762 | 78127 | |
| 77763 | 78128 | for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){ |
| 77764 | 78129 | if( (pIdx->aiColumn[0]==iCol) |
| 77765 | 78130 | && sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], 0)==pReq |
| 77766 | | - && (!mustBeUnique || (pIdx->nColumn==1 && pIdx->onError!=OE_None)) |
| 78131 | + && (!mustBeUnique || (pIdx->nKeyCol==1 && pIdx->onError!=OE_None)) |
| 77767 | 78132 | ){ |
| 77768 | | - int iAddr; |
| 77769 | | - char *pKey; |
| 77770 | | - |
| 77771 | | - pKey = (char *)sqlite3IndexKeyinfo(pParse, pIdx); |
| 77772 | | - iAddr = sqlite3CodeOnce(pParse); |
| 77773 | | - |
| 77774 | | - sqlite3VdbeAddOp4(v, OP_OpenRead, iTab, pIdx->tnum, iDb, |
| 77775 | | - pKey,P4_KEYINFO_HANDOFF); |
| 78133 | + int iAddr = sqlite3CodeOnce(pParse); |
| 78134 | + sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb); |
| 78135 | + sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 77776 | 78136 | VdbeComment((v, "%s", pIdx->zName)); |
| 77777 | 78137 | assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 ); |
| 77778 | 78138 | eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0]; |
| 77779 | 78139 | |
| 77780 | 78140 | sqlite3VdbeJumpHere(v, iAddr); |
| | @@ -77910,11 +78270,11 @@ |
| 77910 | 78270 | ** is used. |
| 77911 | 78271 | */ |
| 77912 | 78272 | pExpr->iTable = pParse->nTab++; |
| 77913 | 78273 | addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid); |
| 77914 | 78274 | if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED); |
| 77915 | | - pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1); |
| 78275 | + pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1, 1); |
| 77916 | 78276 | |
| 77917 | 78277 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 77918 | 78278 | /* Case 1: expr IN (SELECT ...) |
| 77919 | 78279 | ** |
| 77920 | 78280 | ** Generate code to write the results of the select into the temporary |
| | @@ -77928,17 +78288,18 @@ |
| 77928 | 78288 | dest.affSdst = (u8)affinity; |
| 77929 | 78289 | assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); |
| 77930 | 78290 | pExpr->x.pSelect->iLimit = 0; |
| 77931 | 78291 | testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */ |
| 77932 | 78292 | if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ |
| 77933 | | - sqlite3DbFree(pParse->db, pKeyInfo); |
| 78293 | + sqlite3KeyInfoUnref(pKeyInfo); |
| 77934 | 78294 | return 0; |
| 77935 | 78295 | } |
| 77936 | 78296 | pEList = pExpr->x.pSelect->pEList; |
| 77937 | 78297 | assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */ |
| 77938 | 78298 | assert( pEList!=0 ); |
| 77939 | 78299 | assert( pEList->nExpr>0 ); |
| 78300 | + assert( sqlite3KeyInfoIsWriteable(pKeyInfo) ); |
| 77940 | 78301 | pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, |
| 77941 | 78302 | pEList->a[0].pExpr); |
| 77942 | 78303 | }else if( ALWAYS(pExpr->x.pList!=0) ){ |
| 77943 | 78304 | /* Case 2: expr IN (exprlist) |
| 77944 | 78305 | ** |
| | @@ -77954,10 +78315,11 @@ |
| 77954 | 78315 | |
| 77955 | 78316 | if( !affinity ){ |
| 77956 | 78317 | affinity = SQLITE_AFF_NONE; |
| 77957 | 78318 | } |
| 77958 | 78319 | if( pKeyInfo ){ |
| 78320 | + assert( sqlite3KeyInfoIsWriteable(pKeyInfo) ); |
| 77959 | 78321 | pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft); |
| 77960 | 78322 | } |
| 77961 | 78323 | |
| 77962 | 78324 | /* Loop through each expression in <exprlist>. */ |
| 77963 | 78325 | r1 = sqlite3GetTempReg(pParse); |
| | @@ -77995,11 +78357,11 @@ |
| 77995 | 78357 | } |
| 77996 | 78358 | sqlite3ReleaseTempReg(pParse, r1); |
| 77997 | 78359 | sqlite3ReleaseTempReg(pParse, r2); |
| 77998 | 78360 | } |
| 77999 | 78361 | if( pKeyInfo ){ |
| 78000 | | - sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF); |
| 78362 | + sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO); |
| 78001 | 78363 | } |
| 78002 | 78364 | break; |
| 78003 | 78365 | } |
| 78004 | 78366 | |
| 78005 | 78367 | case TK_EXISTS: |
| | @@ -78396,19 +78758,23 @@ |
| 78396 | 78758 | ** Generate code to extract the value of the iCol-th column of a table. |
| 78397 | 78759 | */ |
| 78398 | 78760 | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable( |
| 78399 | 78761 | Vdbe *v, /* The VDBE under construction */ |
| 78400 | 78762 | Table *pTab, /* The table containing the value */ |
| 78401 | | - int iTabCur, /* The cursor for this table */ |
| 78763 | + int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */ |
| 78402 | 78764 | int iCol, /* Index of the column to extract */ |
| 78403 | | - int regOut /* Extract the valud into this register */ |
| 78765 | + int regOut /* Extract the value into this register */ |
| 78404 | 78766 | ){ |
| 78405 | 78767 | if( iCol<0 || iCol==pTab->iPKey ){ |
| 78406 | 78768 | sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); |
| 78407 | 78769 | }else{ |
| 78408 | 78770 | int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; |
| 78409 | | - sqlite3VdbeAddOp3(v, op, iTabCur, iCol, regOut); |
| 78771 | + int x = iCol; |
| 78772 | + if( !HasRowid(pTab) ){ |
| 78773 | + x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol); |
| 78774 | + } |
| 78775 | + sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut); |
| 78410 | 78776 | } |
| 78411 | 78777 | if( iCol>=0 ){ |
| 78412 | 78778 | sqlite3ColumnDefault(v, pTab, iCol, regOut); |
| 78413 | 78779 | } |
| 78414 | 78780 | } |
| | @@ -79150,11 +79516,11 @@ |
| 79150 | 79516 | if( pExpr->affinity==OE_Ignore ){ |
| 79151 | 79517 | sqlite3VdbeAddOp4( |
| 79152 | 79518 | v, OP_Halt, SQLITE_OK, OE_Ignore, 0, pExpr->u.zToken,0); |
| 79153 | 79519 | }else{ |
| 79154 | 79520 | sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_TRIGGER, |
| 79155 | | - pExpr->affinity, pExpr->u.zToken, 0); |
| 79521 | + pExpr->affinity, pExpr->u.zToken, 0, 0); |
| 79156 | 79522 | } |
| 79157 | 79523 | |
| 79158 | 79524 | break; |
| 79159 | 79525 | } |
| 79160 | 79526 | #endif |
| | @@ -81526,12 +81892,11 @@ |
| 81526 | 81892 | } |
| 81527 | 81893 | |
| 81528 | 81894 | /* Open the sqlite_stat[134] tables for writing. */ |
| 81529 | 81895 | for(i=0; aTable[i].zCols; i++){ |
| 81530 | 81896 | assert( i<ArraySize(aTable) ); |
| 81531 | | - sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb); |
| 81532 | | - sqlite3VdbeChangeP4(v, -1, (char *)3, P4_INT32); |
| 81897 | + sqlite3VdbeAddOp4Int(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb, 3); |
| 81533 | 81898 | sqlite3VdbeChangeP5(v, aCreateTbl[i]); |
| 81534 | 81899 | } |
| 81535 | 81900 | } |
| 81536 | 81901 | |
| 81537 | 81902 | /* |
| | @@ -81551,11 +81916,15 @@ |
| 81551 | 81916 | struct Stat4Sample { |
| 81552 | 81917 | tRowcnt *anEq; /* sqlite_stat4.nEq */ |
| 81553 | 81918 | tRowcnt *anDLt; /* sqlite_stat4.nDLt */ |
| 81554 | 81919 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81555 | 81920 | tRowcnt *anLt; /* sqlite_stat4.nLt */ |
| 81556 | | - i64 iRowid; /* Rowid in main table of the key */ |
| 81921 | + union { |
| 81922 | + i64 iRowid; /* Rowid in main table of the key */ |
| 81923 | + u8 *aRowid; /* Key for WITHOUT ROWID tables */ |
| 81924 | + } u; |
| 81925 | + u32 nRowid; /* Sizeof aRowid[] */ |
| 81557 | 81926 | u8 isPSample; /* True if a periodic sample */ |
| 81558 | 81927 | int iCol; /* If !isPSample, the reason for inclusion */ |
| 81559 | 81928 | u32 iHash; /* Tiebreaker hash */ |
| 81560 | 81929 | #endif |
| 81561 | 81930 | }; |
| | @@ -81564,16 +81933,90 @@ |
| 81564 | 81933 | tRowcnt nPSample; /* How often to do a periodic sample */ |
| 81565 | 81934 | int nCol; /* Number of columns in index + rowid */ |
| 81566 | 81935 | int mxSample; /* Maximum number of samples to accumulate */ |
| 81567 | 81936 | Stat4Sample current; /* Current row as a Stat4Sample */ |
| 81568 | 81937 | u32 iPrn; /* Pseudo-random number used for sampling */ |
| 81569 | | - Stat4Sample *aBest; /* Array of (nCol-1) best samples */ |
| 81938 | + Stat4Sample *aBest; /* Array of nCol best samples */ |
| 81570 | 81939 | int iMin; /* Index in a[] of entry with minimum score */ |
| 81571 | 81940 | int nSample; /* Current number of samples */ |
| 81572 | 81941 | int iGet; /* Index of current sample accessed by stat_get() */ |
| 81573 | 81942 | Stat4Sample *a; /* Array of mxSample Stat4Sample objects */ |
| 81943 | + sqlite3 *db; /* Database connection, for malloc() */ |
| 81574 | 81944 | }; |
| 81945 | + |
| 81946 | +/* Reclaim memory used by a Stat4Sample |
| 81947 | +*/ |
| 81948 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81949 | +static void sampleClear(sqlite3 *db, Stat4Sample *p){ |
| 81950 | + assert( db!=0 ); |
| 81951 | + if( p->nRowid ){ |
| 81952 | + sqlite3DbFree(db, p->u.aRowid); |
| 81953 | + p->nRowid = 0; |
| 81954 | + } |
| 81955 | +} |
| 81956 | +#endif |
| 81957 | + |
| 81958 | +/* Initialize the BLOB value of a ROWID |
| 81959 | +*/ |
| 81960 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81961 | +static void sampleSetRowid(sqlite3 *db, Stat4Sample *p, int n, const u8 *pData){ |
| 81962 | + assert( db!=0 ); |
| 81963 | + if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid); |
| 81964 | + p->u.aRowid = sqlite3DbMallocRaw(db, n); |
| 81965 | + if( p->u.aRowid ){ |
| 81966 | + p->nRowid = n; |
| 81967 | + memcpy(p->u.aRowid, pData, n); |
| 81968 | + }else{ |
| 81969 | + p->nRowid = 0; |
| 81970 | + } |
| 81971 | +} |
| 81972 | +#endif |
| 81973 | + |
| 81974 | +/* Initialize the INTEGER value of a ROWID. |
| 81975 | +*/ |
| 81976 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81977 | +static void sampleSetRowidInt64(sqlite3 *db, Stat4Sample *p, i64 iRowid){ |
| 81978 | + assert( db!=0 ); |
| 81979 | + if( p->nRowid ) sqlite3DbFree(db, p->u.aRowid); |
| 81980 | + p->nRowid = 0; |
| 81981 | + p->u.iRowid = iRowid; |
| 81982 | +} |
| 81983 | +#endif |
| 81984 | + |
| 81985 | + |
| 81986 | +/* |
| 81987 | +** Copy the contents of object (*pFrom) into (*pTo). |
| 81988 | +*/ |
| 81989 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81990 | +static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){ |
| 81991 | + pTo->isPSample = pFrom->isPSample; |
| 81992 | + pTo->iCol = pFrom->iCol; |
| 81993 | + pTo->iHash = pFrom->iHash; |
| 81994 | + memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol); |
| 81995 | + memcpy(pTo->anLt, pFrom->anLt, sizeof(tRowcnt)*p->nCol); |
| 81996 | + memcpy(pTo->anDLt, pFrom->anDLt, sizeof(tRowcnt)*p->nCol); |
| 81997 | + if( pFrom->nRowid ){ |
| 81998 | + sampleSetRowid(p->db, pTo, pFrom->nRowid, pFrom->u.aRowid); |
| 81999 | + }else{ |
| 82000 | + sampleSetRowidInt64(p->db, pTo, pFrom->u.iRowid); |
| 82001 | + } |
| 82002 | +} |
| 82003 | +#endif |
| 82004 | + |
| 82005 | +/* |
| 82006 | +** Reclaim all memory of a Stat4Accum structure. |
| 82007 | +*/ |
| 82008 | +static void stat4Destructor(void *pOld){ |
| 82009 | + Stat4Accum *p = (Stat4Accum*)pOld; |
| 82010 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 82011 | + int i; |
| 82012 | + for(i=0; i<p->nCol; i++) sampleClear(p->db, p->aBest+i); |
| 82013 | + for(i=0; i<p->mxSample; i++) sampleClear(p->db, p->a+i); |
| 82014 | + sampleClear(p->db, &p->current); |
| 82015 | +#endif |
| 82016 | + sqlite3DbFree(p->db, p); |
| 82017 | +} |
| 81575 | 82018 | |
| 81576 | 82019 | /* |
| 81577 | 82020 | ** Implementation of the stat_init(N,C) SQL function. The two parameters |
| 81578 | 82021 | ** are the number of rows in the table or index (C) and the number of columns |
| 81579 | 82022 | ** in the index (N). The second argument (C) is only used for STAT3 and STAT4. |
| | @@ -81589,10 +82032,11 @@ |
| 81589 | 82032 | ){ |
| 81590 | 82033 | Stat4Accum *p; |
| 81591 | 82034 | int nCol; /* Number of columns in index being sampled */ |
| 81592 | 82035 | int nColUp; /* nCol rounded up for alignment */ |
| 81593 | 82036 | int n; /* Bytes of space to allocate */ |
| 82037 | + sqlite3 *db; /* Database connection */ |
| 81594 | 82038 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81595 | 82039 | int mxSample = SQLITE_STAT4_SAMPLES; |
| 81596 | 82040 | #endif |
| 81597 | 82041 | |
| 81598 | 82042 | /* Decode the three function arguments */ |
| | @@ -81605,20 +82049,22 @@ |
| 81605 | 82049 | n = sizeof(*p) |
| 81606 | 82050 | + sizeof(tRowcnt)*nColUp /* Stat4Accum.anEq */ |
| 81607 | 82051 | + sizeof(tRowcnt)*nColUp /* Stat4Accum.anDLt */ |
| 81608 | 82052 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81609 | 82053 | + sizeof(tRowcnt)*nColUp /* Stat4Accum.anLt */ |
| 81610 | | - + sizeof(Stat4Sample)*(nCol+mxSample) /* Stat4Accum.aBest[], a[] */ |
| 82054 | + + sizeof(Stat4Sample)*(nCol+mxSample) /* Stat4Accum.aBest[], a[] */ |
| 81611 | 82055 | + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample) |
| 81612 | 82056 | #endif |
| 81613 | 82057 | ; |
| 81614 | | - p = sqlite3MallocZero(n); |
| 82058 | + db = sqlite3_context_db_handle(context); |
| 82059 | + p = sqlite3DbMallocZero(db, n); |
| 81615 | 82060 | if( p==0 ){ |
| 81616 | 82061 | sqlite3_result_error_nomem(context); |
| 81617 | 82062 | return; |
| 81618 | 82063 | } |
| 81619 | 82064 | |
| 82065 | + p->db = db; |
| 81620 | 82066 | p->nRow = 0; |
| 81621 | 82067 | p->nCol = nCol; |
| 81622 | 82068 | p->current.anDLt = (tRowcnt*)&p[1]; |
| 81623 | 82069 | p->current.anEq = &p->current.anDLt[nColUp]; |
| 81624 | 82070 | |
| | @@ -81649,11 +82095,11 @@ |
| 81649 | 82095 | } |
| 81650 | 82096 | } |
| 81651 | 82097 | #endif |
| 81652 | 82098 | |
| 81653 | 82099 | /* Return a pointer to the allocated object to the caller */ |
| 81654 | | - sqlite3_result_blob(context, p, sizeof(p), sqlite3_free); |
| 82100 | + sqlite3_result_blob(context, p, sizeof(p), stat4Destructor); |
| 81655 | 82101 | } |
| 81656 | 82102 | static const FuncDef statInitFuncdef = { |
| 81657 | 82103 | 1+IsStat34, /* nArg */ |
| 81658 | 82104 | SQLITE_UTF8, /* funcFlags */ |
| 81659 | 82105 | 0, /* pUserData */ |
| | @@ -81723,29 +82169,16 @@ |
| 81723 | 82169 | #else |
| 81724 | 82170 | return (nEqNew==nEqOld && pNew->iHash>pOld->iHash); |
| 81725 | 82171 | #endif |
| 81726 | 82172 | } |
| 81727 | 82173 | |
| 81728 | | -/* |
| 81729 | | -** Copy the contents of object (*pFrom) into (*pTo). |
| 81730 | | -*/ |
| 81731 | | -static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){ |
| 81732 | | - pTo->iRowid = pFrom->iRowid; |
| 81733 | | - pTo->isPSample = pFrom->isPSample; |
| 81734 | | - pTo->iCol = pFrom->iCol; |
| 81735 | | - pTo->iHash = pFrom->iHash; |
| 81736 | | - memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol); |
| 81737 | | - memcpy(pTo->anLt, pFrom->anLt, sizeof(tRowcnt)*p->nCol); |
| 81738 | | - memcpy(pTo->anDLt, pFrom->anDLt, sizeof(tRowcnt)*p->nCol); |
| 81739 | | -} |
| 81740 | | - |
| 81741 | 82174 | /* |
| 81742 | 82175 | ** Copy the contents of sample *pNew into the p->a[] array. If necessary, |
| 81743 | 82176 | ** remove the least desirable sample from p->a[] to make room. |
| 81744 | 82177 | */ |
| 81745 | 82178 | static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){ |
| 81746 | | - Stat4Sample *pSample; |
| 82179 | + Stat4Sample *pSample = 0; |
| 81747 | 82180 | int i; |
| 81748 | 82181 | |
| 81749 | 82182 | assert( IsStat4 || nEqZero==0 ); |
| 81750 | 82183 | |
| 81751 | 82184 | #ifdef SQLITE_ENABLE_STAT4 |
| | @@ -81781,12 +82214,14 @@ |
| 81781 | 82214 | if( p->nSample>=p->mxSample ){ |
| 81782 | 82215 | Stat4Sample *pMin = &p->a[p->iMin]; |
| 81783 | 82216 | tRowcnt *anEq = pMin->anEq; |
| 81784 | 82217 | tRowcnt *anLt = pMin->anLt; |
| 81785 | 82218 | tRowcnt *anDLt = pMin->anDLt; |
| 82219 | + sampleClear(p->db, pMin); |
| 81786 | 82220 | memmove(pMin, &pMin[1], sizeof(p->a[0])*(p->nSample-p->iMin-1)); |
| 81787 | 82221 | pSample = &p->a[p->nSample-1]; |
| 82222 | + pSample->nRowid = 0; |
| 81788 | 82223 | pSample->anEq = anEq; |
| 81789 | 82224 | pSample->anDLt = anDLt; |
| 81790 | 82225 | pSample->anLt = anLt; |
| 81791 | 82226 | p->nSample = p->mxSample-1; |
| 81792 | 82227 | } |
| | @@ -81879,20 +82314,21 @@ |
| 81879 | 82314 | UNUSED_PARAMETER( iChng ); |
| 81880 | 82315 | #endif |
| 81881 | 82316 | } |
| 81882 | 82317 | |
| 81883 | 82318 | /* |
| 81884 | | -** Implementation of the stat_push SQL function: stat_push(P,R,C) |
| 82319 | +** Implementation of the stat_push SQL function: stat_push(P,C,R) |
| 81885 | 82320 | ** Arguments: |
| 81886 | 82321 | ** |
| 81887 | 82322 | ** P Pointer to the Stat4Accum object created by stat_init() |
| 81888 | 82323 | ** C Index of left-most column to differ from previous row |
| 81889 | | -** R Rowid for the current row |
| 82324 | +** R Rowid for the current row. Might be a key record for |
| 82325 | +** WITHOUT ROWID tables. |
| 81890 | 82326 | ** |
| 81891 | 82327 | ** The SQL function always returns NULL. |
| 81892 | 82328 | ** |
| 81893 | | -** The R parameter is only used for STAT3 and STAT4. |
| 82329 | +** The R parameter is only used for STAT3 and STAT4 |
| 81894 | 82330 | */ |
| 81895 | 82331 | static void statPush( |
| 81896 | 82332 | sqlite3_context *context, |
| 81897 | 82333 | int argc, |
| 81898 | 82334 | sqlite3_value **argv |
| | @@ -81928,11 +82364,16 @@ |
| 81928 | 82364 | p->current.anEq[i] = 1; |
| 81929 | 82365 | } |
| 81930 | 82366 | } |
| 81931 | 82367 | p->nRow++; |
| 81932 | 82368 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 81933 | | - p->current.iRowid = sqlite3_value_int64(argv[2]); |
| 82369 | + if( sqlite3_value_type(argv[2])==SQLITE_INTEGER ){ |
| 82370 | + sampleSetRowidInt64(p->db, &p->current, sqlite3_value_int64(argv[2])); |
| 82371 | + }else{ |
| 82372 | + sampleSetRowid(p->db, &p->current, sqlite3_value_bytes(argv[2]), |
| 82373 | + sqlite3_value_blob(argv[2])); |
| 82374 | + } |
| 81934 | 82375 | p->current.iHash = p->iPrn = p->iPrn*1103515245 + 12345; |
| 81935 | 82376 | #endif |
| 81936 | 82377 | |
| 81937 | 82378 | #ifdef SQLITE_ENABLE_STAT4 |
| 81938 | 82379 | { |
| | @@ -82052,11 +82493,17 @@ |
| 82052 | 82493 | if( p->iGet<0 ){ |
| 82053 | 82494 | samplePushPrevious(p, 0); |
| 82054 | 82495 | p->iGet = 0; |
| 82055 | 82496 | } |
| 82056 | 82497 | if( p->iGet<p->nSample ){ |
| 82057 | | - sqlite3_result_int64(context, p->a[p->iGet].iRowid); |
| 82498 | + Stat4Sample *pS = p->a + p->iGet; |
| 82499 | + if( pS->nRowid==0 ){ |
| 82500 | + sqlite3_result_int64(context, pS->u.iRowid); |
| 82501 | + }else{ |
| 82502 | + sqlite3_result_blob(context, pS->u.aRowid, pS->nRowid, |
| 82503 | + SQLITE_TRANSIENT); |
| 82504 | + } |
| 82058 | 82505 | } |
| 82059 | 82506 | }else{ |
| 82060 | 82507 | tRowcnt *aCnt = 0; |
| 82061 | 82508 | |
| 82062 | 82509 | assert( p->iGet<p->nSample ); |
| | @@ -82189,26 +82636,30 @@ |
| 82189 | 82636 | sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); |
| 82190 | 82637 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0); |
| 82191 | 82638 | |
| 82192 | 82639 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 82193 | 82640 | int nCol; /* Number of columns indexed by pIdx */ |
| 82194 | | - KeyInfo *pKey; /* KeyInfo structure for pIdx */ |
| 82195 | 82641 | int *aGotoChng; /* Array of jump instruction addresses */ |
| 82196 | 82642 | int addrRewind; /* Address of "OP_Rewind iIdxCur" */ |
| 82197 | 82643 | int addrGotoChng0; /* Address of "Goto addr_chng_0" */ |
| 82198 | 82644 | int addrNextRow; /* Address of "next_row:" */ |
| 82645 | + const char *zIdxName; /* Name of the index */ |
| 82199 | 82646 | |
| 82200 | 82647 | if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; |
| 82201 | 82648 | if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0; |
| 82202 | 82649 | VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName)); |
| 82203 | | - nCol = pIdx->nColumn; |
| 82650 | + nCol = pIdx->nKeyCol; |
| 82204 | 82651 | aGotoChng = sqlite3DbMallocRaw(db, sizeof(int)*(nCol+1)); |
| 82205 | 82652 | if( aGotoChng==0 ) continue; |
| 82206 | | - pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 82207 | 82653 | |
| 82208 | 82654 | /* Populate the register containing the index name. */ |
| 82209 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0); |
| 82655 | + if( pIdx->autoIndex==2 && !HasRowid(pTab) ){ |
| 82656 | + zIdxName = pTab->zName; |
| 82657 | + }else{ |
| 82658 | + zIdxName = pIdx->zName; |
| 82659 | + } |
| 82660 | + sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, zIdxName, 0); |
| 82210 | 82661 | |
| 82211 | 82662 | /* |
| 82212 | 82663 | ** Pseudo-code for loop that calls stat_push(): |
| 82213 | 82664 | ** |
| 82214 | 82665 | ** Rewind csr |
| | @@ -82247,11 +82698,11 @@ |
| 82247 | 82698 | pParse->nMem = MAX(pParse->nMem, regPrev+nCol); |
| 82248 | 82699 | |
| 82249 | 82700 | /* Open a read-only cursor on the index being analyzed. */ |
| 82250 | 82701 | assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) ); |
| 82251 | 82702 | sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb); |
| 82252 | | - sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF); |
| 82703 | + sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 82253 | 82704 | VdbeComment((v, "%s", pIdx->zName)); |
| 82254 | 82705 | |
| 82255 | 82706 | /* Invoke the stat_init() function. The arguments are: |
| 82256 | 82707 | ** |
| 82257 | 82708 | ** (1) the number of columns in the index including the rowid, |
| | @@ -82321,12 +82772,25 @@ |
| 82321 | 82772 | ** Next csr |
| 82322 | 82773 | ** if !eof(csr) goto next_row; |
| 82323 | 82774 | */ |
| 82324 | 82775 | sqlite3VdbeJumpHere(v, aGotoChng[nCol]); |
| 82325 | 82776 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 82326 | | - sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid); |
| 82327 | 82777 | assert( regRowid==(regStat4+2) ); |
| 82778 | + if( HasRowid(pTab) ){ |
| 82779 | + sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, regRowid); |
| 82780 | + }else{ |
| 82781 | + Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable); |
| 82782 | + int j, k, regKey; |
| 82783 | + regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol); |
| 82784 | + for(j=0; j<pPk->nKeyCol; j++){ |
| 82785 | + k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]); |
| 82786 | + sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j); |
| 82787 | + VdbeComment((v, "%s", pTab->aCol[pPk->aiColumn[j]].zName)); |
| 82788 | + } |
| 82789 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid); |
| 82790 | + sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol); |
| 82791 | + } |
| 82328 | 82792 | #endif |
| 82329 | 82793 | assert( regChng==(regStat4+1) ); |
| 82330 | 82794 | sqlite3VdbeAddOp3(v, OP_Function, 1, regStat4, regTemp); |
| 82331 | 82795 | sqlite3VdbeChangeP4(v, -1, (char*)&statPushFuncdef, P4_FUNCDEF); |
| 82332 | 82796 | sqlite3VdbeChangeP5(v, 2+IsStat34); |
| | @@ -82348,26 +82812,27 @@ |
| 82348 | 82812 | int regSample = regStat1+3; |
| 82349 | 82813 | int regCol = regStat1+4; |
| 82350 | 82814 | int regSampleRowid = regCol + nCol; |
| 82351 | 82815 | int addrNext; |
| 82352 | 82816 | int addrIsNull; |
| 82817 | + u8 seekOp = HasRowid(pTab) ? OP_NotExists : OP_NotFound; |
| 82353 | 82818 | |
| 82354 | 82819 | pParse->nMem = MAX(pParse->nMem, regCol+nCol+1); |
| 82355 | 82820 | |
| 82356 | 82821 | addrNext = sqlite3VdbeCurrentAddr(v); |
| 82357 | 82822 | callStatGet(v, regStat4, STAT_GET_ROWID, regSampleRowid); |
| 82358 | 82823 | addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regSampleRowid); |
| 82359 | 82824 | callStatGet(v, regStat4, STAT_GET_NEQ, regEq); |
| 82360 | 82825 | callStatGet(v, regStat4, STAT_GET_NLT, regLt); |
| 82361 | 82826 | callStatGet(v, regStat4, STAT_GET_NDLT, regDLt); |
| 82362 | | - sqlite3VdbeAddOp3(v, OP_NotExists, iTabCur, addrNext, regSampleRowid); |
| 82827 | + sqlite3VdbeAddOp4Int(v, seekOp, iTabCur, addrNext, regSampleRowid, 0); |
| 82363 | 82828 | #ifdef SQLITE_ENABLE_STAT3 |
| 82364 | 82829 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, |
| 82365 | 82830 | pIdx->aiColumn[0], regSample); |
| 82366 | 82831 | #else |
| 82367 | 82832 | for(i=0; i<nCol; i++){ |
| 82368 | | - int iCol = pIdx->aiColumn[i]; |
| 82833 | + i16 iCol = pIdx->aiColumn[i]; |
| 82369 | 82834 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, iCol, regCol+i); |
| 82370 | 82835 | } |
| 82371 | 82836 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol+1, regSample); |
| 82372 | 82837 | #endif |
| 82373 | 82838 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 6, regTemp, "bbbbbb", 0); |
| | @@ -82619,11 +83084,11 @@ |
| 82619 | 83084 | pIndex = 0; |
| 82620 | 83085 | } |
| 82621 | 83086 | z = argv[2]; |
| 82622 | 83087 | |
| 82623 | 83088 | if( pIndex ){ |
| 82624 | | - decodeIntArray((char*)z, pIndex->nColumn+1, pIndex->aiRowEst, pIndex); |
| 83089 | + decodeIntArray((char*)z, pIndex->nKeyCol+1, pIndex->aiRowEst, pIndex); |
| 82625 | 83090 | if( pIndex->pPartIdxWhere==0 ) pTable->nRowEst = pIndex->aiRowEst[0]; |
| 82626 | 83091 | }else{ |
| 82627 | 83092 | Index fakeIdx; |
| 82628 | 83093 | fakeIdx.szIdxRow = pTable->szTabRow; |
| 82629 | 83094 | decodeIntArray((char*)z, 1, &pTable->nRowEst, &fakeIdx); |
| | @@ -82665,11 +83130,11 @@ |
| 82665 | 83130 | static void initAvgEq(Index *pIdx){ |
| 82666 | 83131 | if( pIdx ){ |
| 82667 | 83132 | IndexSample *aSample = pIdx->aSample; |
| 82668 | 83133 | IndexSample *pFinal = &aSample[pIdx->nSample-1]; |
| 82669 | 83134 | int iCol; |
| 82670 | | - for(iCol=0; iCol<pIdx->nColumn; iCol++){ |
| 83135 | + for(iCol=0; iCol<pIdx->nKeyCol; iCol++){ |
| 82671 | 83136 | int i; /* Used to iterate through samples */ |
| 82672 | 83137 | tRowcnt sumEq = 0; /* Sum of the nEq values */ |
| 82673 | 83138 | tRowcnt nSum = 0; /* Number of terms contributing to sumEq */ |
| 82674 | 83139 | tRowcnt avgEq = 0; |
| 82675 | 83140 | tRowcnt nDLt = pFinal->anDLt[iCol]; |
| | @@ -82692,10 +83157,27 @@ |
| 82692 | 83157 | pIdx->aAvgEq[iCol] = avgEq; |
| 82693 | 83158 | if( pIdx->nSampleCol==1 ) break; |
| 82694 | 83159 | } |
| 82695 | 83160 | } |
| 82696 | 83161 | } |
| 83162 | + |
| 83163 | +/* |
| 83164 | +** Look up an index by name. Or, if the name of a WITHOUT ROWID table |
| 83165 | +** is supplied instead, find the PRIMARY KEY index for that table. |
| 83166 | +*/ |
| 83167 | +static Index *findIndexOrPrimaryKey( |
| 83168 | + sqlite3 *db, |
| 83169 | + const char *zName, |
| 83170 | + const char *zDb |
| 83171 | +){ |
| 83172 | + Index *pIdx = sqlite3FindIndex(db, zName, zDb); |
| 83173 | + if( pIdx==0 ){ |
| 83174 | + Table *pTab = sqlite3FindTable(db, zName, zDb); |
| 83175 | + if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab); |
| 83176 | + } |
| 83177 | + return pIdx; |
| 83178 | +} |
| 82697 | 83179 | |
| 82698 | 83180 | /* |
| 82699 | 83181 | ** Load the content from either the sqlite_stat4 or sqlite_stat3 table |
| 82700 | 83182 | ** into the relevant Index.aSample[] arrays. |
| 82701 | 83183 | ** |
| | @@ -82742,18 +83224,18 @@ |
| 82742 | 83224 | tRowcnt *pSpace; |
| 82743 | 83225 | |
| 82744 | 83226 | zIndex = (char *)sqlite3_column_text(pStmt, 0); |
| 82745 | 83227 | if( zIndex==0 ) continue; |
| 82746 | 83228 | nSample = sqlite3_column_int(pStmt, 1); |
| 82747 | | - pIdx = sqlite3FindIndex(db, zIndex, zDb); |
| 83229 | + pIdx = findIndexOrPrimaryKey(db, zIndex, zDb); |
| 82748 | 83230 | assert( pIdx==0 || bStat3 || pIdx->nSample==0 ); |
| 82749 | 83231 | /* Index.nSample is non-zero at this point if data has already been |
| 82750 | 83232 | ** loaded from the stat4 table. In this case ignore stat3 data. */ |
| 82751 | 83233 | if( pIdx==0 || pIdx->nSample ) continue; |
| 82752 | 83234 | if( bStat3==0 ){ |
| 82753 | | - nIdxCol = pIdx->nColumn+1; |
| 82754 | | - nAvgCol = pIdx->nColumn; |
| 83235 | + nIdxCol = pIdx->nKeyCol+1; |
| 83236 | + nAvgCol = pIdx->nKeyCol; |
| 82755 | 83237 | } |
| 82756 | 83238 | pIdx->nSampleCol = nIdxCol; |
| 82757 | 83239 | nByte = sizeof(IndexSample) * nSample; |
| 82758 | 83240 | nByte += sizeof(tRowcnt) * nIdxCol * 3 * nSample; |
| 82759 | 83241 | nByte += nAvgCol * sizeof(tRowcnt); /* Space for Index.aAvgEq[] */ |
| | @@ -82788,11 +83270,11 @@ |
| 82788 | 83270 | Index *pIdx; /* Pointer to the index object */ |
| 82789 | 83271 | int nCol = 1; /* Number of columns in index */ |
| 82790 | 83272 | |
| 82791 | 83273 | zIndex = (char *)sqlite3_column_text(pStmt, 0); |
| 82792 | 83274 | if( zIndex==0 ) continue; |
| 82793 | | - pIdx = sqlite3FindIndex(db, zIndex, zDb); |
| 83275 | + pIdx = findIndexOrPrimaryKey(db, zIndex, zDb); |
| 82794 | 83276 | if( pIdx==0 ) continue; |
| 82795 | 83277 | /* This next condition is true if data has already been loaded from |
| 82796 | 83278 | ** the sqlite_stat4 table. In this case ignore stat3 data. */ |
| 82797 | 83279 | nCol = pIdx->nSampleCol; |
| 82798 | 83280 | if( bStat3 && nCol>1 ) continue; |
| | @@ -84144,12 +84626,14 @@ |
| 84144 | 84626 | */ |
| 84145 | 84627 | static void freeIndex(sqlite3 *db, Index *p){ |
| 84146 | 84628 | #ifndef SQLITE_OMIT_ANALYZE |
| 84147 | 84629 | sqlite3DeleteIndexSamples(db, p); |
| 84148 | 84630 | #endif |
| 84631 | + if( db==0 || db->pnBytesFreed==0 ) sqlite3KeyInfoUnref(p->pKeyInfo); |
| 84149 | 84632 | sqlite3ExprDelete(db, p->pPartIdxWhere); |
| 84150 | 84633 | sqlite3DbFree(db, p->zColAff); |
| 84634 | + if( p->isResized ) sqlite3DbFree(db, p->azColl); |
| 84151 | 84635 | sqlite3DbFree(db, p); |
| 84152 | 84636 | } |
| 84153 | 84637 | |
| 84154 | 84638 | /* |
| 84155 | 84639 | ** For the index called zIdxName which is found in the database iDb, |
| | @@ -84403,12 +84887,11 @@ |
| 84403 | 84887 | ** writing. The table is opened using cursor 0. |
| 84404 | 84888 | */ |
| 84405 | 84889 | SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *p, int iDb){ |
| 84406 | 84890 | Vdbe *v = sqlite3GetVdbe(p); |
| 84407 | 84891 | sqlite3TableLock(p, iDb, MASTER_ROOT, 1, SCHEMA_TABLE(iDb)); |
| 84408 | | - sqlite3VdbeAddOp3(v, OP_OpenWrite, 0, MASTER_ROOT, iDb); |
| 84409 | | - sqlite3VdbeChangeP4(v, -1, (char *)5, P4_INT32); /* 5 column table */ |
| 84892 | + sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, MASTER_ROOT, iDb, 5); |
| 84410 | 84893 | if( p->nTab==0 ){ |
| 84411 | 84894 | p->nTab = 1; |
| 84412 | 84895 | } |
| 84413 | 84896 | } |
| 84414 | 84897 | |
| | @@ -84508,10 +84991,31 @@ |
| 84508 | 84991 | sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName); |
| 84509 | 84992 | return SQLITE_ERROR; |
| 84510 | 84993 | } |
| 84511 | 84994 | return SQLITE_OK; |
| 84512 | 84995 | } |
| 84996 | + |
| 84997 | +/* |
| 84998 | +** Return the PRIMARY KEY index of a table |
| 84999 | +*/ |
| 85000 | +SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table *pTab){ |
| 85001 | + Index *p; |
| 85002 | + for(p=pTab->pIndex; p && p->autoIndex!=2; p=p->pNext){} |
| 85003 | + return p; |
| 85004 | +} |
| 85005 | + |
| 85006 | +/* |
| 85007 | +** Return the column of index pIdx that corresponds to table |
| 85008 | +** column iCol. Return -1 if not found. |
| 85009 | +*/ |
| 85010 | +SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){ |
| 85011 | + int i; |
| 85012 | + for(i=0; i<pIdx->nColumn; i++){ |
| 85013 | + if( iCol==pIdx->aiColumn[i] ) return i; |
| 85014 | + } |
| 85015 | + return -1; |
| 85016 | +} |
| 84513 | 85017 | |
| 84514 | 85018 | /* |
| 84515 | 85019 | ** Begin constructing a new table representation in memory. This is |
| 84516 | 85020 | ** the first of several action routines that get called in response |
| 84517 | 85021 | ** to a CREATE TABLE statement. In particular, this routine is called |
| | @@ -84708,11 +85212,11 @@ |
| 84708 | 85212 | if( isView || isVirtual ){ |
| 84709 | 85213 | sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2); |
| 84710 | 85214 | }else |
| 84711 | 85215 | #endif |
| 84712 | 85216 | { |
| 84713 | | - sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2); |
| 85217 | + pParse->addrCrTab = sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2); |
| 84714 | 85218 | } |
| 84715 | 85219 | sqlite3OpenMasterTable(pParse, iDb); |
| 84716 | 85220 | sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1); |
| 84717 | 85221 | sqlite3VdbeAddOp2(v, OP_Null, 0, reg3); |
| 84718 | 85222 | sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1); |
| | @@ -84976,10 +85480,11 @@ |
| 84976 | 85480 | int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ |
| 84977 | 85481 | ){ |
| 84978 | 85482 | Table *pTab = pParse->pNewTable; |
| 84979 | 85483 | char *zType = 0; |
| 84980 | 85484 | int iCol = -1, i; |
| 85485 | + int nTerm; |
| 84981 | 85486 | if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit; |
| 84982 | 85487 | if( pTab->tabFlags & TF_HasPrimaryKey ){ |
| 84983 | 85488 | sqlite3ErrorMsg(pParse, |
| 84984 | 85489 | "table \"%s\" has more than one primary key", pTab->zName); |
| 84985 | 85490 | goto primary_key_exit; |
| | @@ -84986,43 +85491,47 @@ |
| 84986 | 85491 | } |
| 84987 | 85492 | pTab->tabFlags |= TF_HasPrimaryKey; |
| 84988 | 85493 | if( pList==0 ){ |
| 84989 | 85494 | iCol = pTab->nCol - 1; |
| 84990 | 85495 | pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; |
| 85496 | + zType = pTab->aCol[iCol].zType; |
| 85497 | + nTerm = 1; |
| 84991 | 85498 | }else{ |
| 84992 | | - for(i=0; i<pList->nExpr; i++){ |
| 85499 | + nTerm = pList->nExpr; |
| 85500 | + for(i=0; i<nTerm; i++){ |
| 84993 | 85501 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 84994 | 85502 | if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ){ |
| 85503 | + pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; |
| 85504 | + zType = pTab->aCol[iCol].zType; |
| 84995 | 85505 | break; |
| 84996 | 85506 | } |
| 84997 | 85507 | } |
| 84998 | | - if( iCol<pTab->nCol ){ |
| 84999 | | - pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; |
| 85000 | | - } |
| 85001 | | - } |
| 85002 | | - if( pList->nExpr>1 ) iCol = -1; |
| 85003 | | - } |
| 85004 | | - if( iCol>=0 && iCol<pTab->nCol ){ |
| 85005 | | - zType = pTab->aCol[iCol].zType; |
| 85006 | | - } |
| 85007 | | - if( zType && sqlite3StrICmp(zType, "INTEGER")==0 |
| 85008 | | - && sortOrder==SQLITE_SO_ASC ){ |
| 85508 | + } |
| 85509 | + } |
| 85510 | + if( nTerm==1 |
| 85511 | + && zType && sqlite3StrICmp(zType, "INTEGER")==0 |
| 85512 | + && sortOrder==SQLITE_SO_ASC |
| 85513 | + ){ |
| 85009 | 85514 | pTab->iPKey = iCol; |
| 85010 | 85515 | pTab->keyConf = (u8)onError; |
| 85011 | 85516 | assert( autoInc==0 || autoInc==1 ); |
| 85012 | 85517 | pTab->tabFlags |= autoInc*TF_Autoincrement; |
| 85518 | + if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder; |
| 85013 | 85519 | }else if( autoInc ){ |
| 85014 | 85520 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 85015 | 85521 | sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " |
| 85016 | 85522 | "INTEGER PRIMARY KEY"); |
| 85017 | 85523 | #endif |
| 85018 | 85524 | }else{ |
| 85525 | + Vdbe *v = pParse->pVdbe; |
| 85019 | 85526 | Index *p; |
| 85527 | + if( v ) pParse->addrSkipPK = sqlite3VdbeAddOp0(v, OP_Noop); |
| 85020 | 85528 | p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, |
| 85021 | 85529 | 0, sortOrder, 0); |
| 85022 | 85530 | if( p ){ |
| 85023 | 85531 | p->autoIndex = 2; |
| 85532 | + if( v ) sqlite3VdbeJumpHere(v, pParse->addrSkipPK); |
| 85024 | 85533 | } |
| 85025 | 85534 | pList = 0; |
| 85026 | 85535 | } |
| 85027 | 85536 | |
| 85028 | 85537 | primary_key_exit: |
| | @@ -85075,11 +85584,11 @@ |
| 85075 | 85584 | /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>", |
| 85076 | 85585 | ** then an index may have been created on this column before the |
| 85077 | 85586 | ** collation type was added. Correct this if it is the case. |
| 85078 | 85587 | */ |
| 85079 | 85588 | for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 85080 | | - assert( pIdx->nColumn==1 ); |
| 85589 | + assert( pIdx->nKeyCol==1 ); |
| 85081 | 85590 | if( pIdx->aiColumn[0]==i ){ |
| 85082 | 85591 | pIdx->azColl[0] = p->aCol[i].zColl; |
| 85083 | 85592 | } |
| 85084 | 85593 | } |
| 85085 | 85594 | }else{ |
| | @@ -85266,10 +85775,35 @@ |
| 85266 | 85775 | assert( k<=n ); |
| 85267 | 85776 | } |
| 85268 | 85777 | sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd); |
| 85269 | 85778 | return zStmt; |
| 85270 | 85779 | } |
| 85780 | + |
| 85781 | +/* |
| 85782 | +** Resize an Index object to hold N columns total. Return SQLITE_OK |
| 85783 | +** on success and SQLITE_NOMEM on an OOM error. |
| 85784 | +*/ |
| 85785 | +static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){ |
| 85786 | + char *zExtra; |
| 85787 | + int nByte; |
| 85788 | + if( pIdx->nColumn>=N ) return SQLITE_OK; |
| 85789 | + assert( pIdx->isResized==0 ); |
| 85790 | + nByte = (sizeof(char*) + sizeof(i16) + 1)*N; |
| 85791 | + zExtra = sqlite3DbMallocZero(db, nByte); |
| 85792 | + if( zExtra==0 ) return SQLITE_NOMEM; |
| 85793 | + memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn); |
| 85794 | + pIdx->azColl = (char**)zExtra; |
| 85795 | + zExtra += sizeof(char*)*N; |
| 85796 | + memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn); |
| 85797 | + pIdx->aiColumn = (i16*)zExtra; |
| 85798 | + zExtra += sizeof(i16)*N; |
| 85799 | + memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn); |
| 85800 | + pIdx->aSortOrder = (u8*)zExtra; |
| 85801 | + pIdx->nColumn = N; |
| 85802 | + pIdx->isResized = 1; |
| 85803 | + return SQLITE_OK; |
| 85804 | +} |
| 85271 | 85805 | |
| 85272 | 85806 | /* |
| 85273 | 85807 | ** Estimate the total row width for a table. |
| 85274 | 85808 | */ |
| 85275 | 85809 | static void estimateTableWidth(Table *pTab){ |
| | @@ -85285,19 +85819,151 @@ |
| 85285 | 85819 | |
| 85286 | 85820 | /* |
| 85287 | 85821 | ** Estimate the average size of a row for an index. |
| 85288 | 85822 | */ |
| 85289 | 85823 | static void estimateIndexWidth(Index *pIdx){ |
| 85290 | | - unsigned wIndex = 1; |
| 85824 | + unsigned wIndex = 0; |
| 85291 | 85825 | int i; |
| 85292 | 85826 | const Column *aCol = pIdx->pTable->aCol; |
| 85293 | 85827 | for(i=0; i<pIdx->nColumn; i++){ |
| 85294 | | - assert( pIdx->aiColumn[i]>=0 && pIdx->aiColumn[i]<pIdx->pTable->nCol ); |
| 85295 | | - wIndex += aCol[pIdx->aiColumn[i]].szEst; |
| 85828 | + i16 x = pIdx->aiColumn[i]; |
| 85829 | + assert( x<pIdx->pTable->nCol ); |
| 85830 | + wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst; |
| 85296 | 85831 | } |
| 85297 | 85832 | pIdx->szIdxRow = sqlite3LogEst(wIndex*4); |
| 85298 | 85833 | } |
| 85834 | + |
| 85835 | +/* Return true if value x is found any of the first nCol entries of aiCol[] |
| 85836 | +*/ |
| 85837 | +static int hasColumn(const i16 *aiCol, int nCol, int x){ |
| 85838 | + while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1; |
| 85839 | + return 0; |
| 85840 | +} |
| 85841 | + |
| 85842 | +/* |
| 85843 | +** This routine runs at the end of parsing a CREATE TABLE statement that |
| 85844 | +** has a WITHOUT ROWID clause. The job of this routine is to convert both |
| 85845 | +** internal schema data structures and the generated VDBE code so that they |
| 85846 | +** are appropriate for a WITHOUT ROWID table instead of a rowid table. |
| 85847 | +** Changes include: |
| 85848 | +** |
| 85849 | +** (1) Convert the OP_CreateTable into an OP_CreateIndex. There is |
| 85850 | +** no rowid btree for a WITHOUT ROWID. Instead, the canonical |
| 85851 | +** data storage is a covering index btree. |
| 85852 | +** (2) Bypass the creation of the sqlite_master table entry |
| 85853 | +** for the PRIMARY KEY as the the primary key index is now |
| 85854 | +** identified by the sqlite_master table entry of the table itself. |
| 85855 | +** (3) Set the Index.tnum of the PRIMARY KEY Index object in the |
| 85856 | +** schema to the rootpage from the main table. |
| 85857 | +** (4) Set all columns of the PRIMARY KEY schema object to be NOT NULL. |
| 85858 | +** (5) Add all table columns to the PRIMARY KEY Index object |
| 85859 | +** so that the PRIMARY KEY is a covering index. The surplus |
| 85860 | +** columns are part of KeyInfo.nXField and are not used for |
| 85861 | +** sorting or lookup or uniqueness checks. |
| 85862 | +** (6) Replace the rowid tail on all automatically generated UNIQUE |
| 85863 | +** indices with the PRIMARY KEY columns. |
| 85864 | +*/ |
| 85865 | +static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ |
| 85866 | + Index *pIdx; |
| 85867 | + Index *pPk; |
| 85868 | + int nPk; |
| 85869 | + int i, j; |
| 85870 | + sqlite3 *db = pParse->db; |
| 85871 | + Vdbe *v = pParse->pVdbe; |
| 85872 | + |
| 85873 | + /* Convert the OP_CreateTable opcode that would normally create the |
| 85874 | + ** root-page for the table into a OP_CreateIndex opcode. The index |
| 85875 | + ** created will become the PRIMARY KEY index. |
| 85876 | + */ |
| 85877 | + if( pParse->addrCrTab ){ |
| 85878 | + assert( v ); |
| 85879 | + sqlite3VdbeGetOp(v, pParse->addrCrTab)->opcode = OP_CreateIndex; |
| 85880 | + } |
| 85881 | + |
| 85882 | + /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master |
| 85883 | + ** table entry. |
| 85884 | + */ |
| 85885 | + if( pParse->addrSkipPK ){ |
| 85886 | + assert( v ); |
| 85887 | + sqlite3VdbeGetOp(v, pParse->addrSkipPK)->opcode = OP_Goto; |
| 85888 | + } |
| 85889 | + |
| 85890 | + /* Locate the PRIMARY KEY index. Or, if this table was originally |
| 85891 | + ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. |
| 85892 | + */ |
| 85893 | + if( pTab->iPKey>=0 ){ |
| 85894 | + ExprList *pList; |
| 85895 | + pList = sqlite3ExprListAppend(pParse, 0, 0); |
| 85896 | + if( pList==0 ) return; |
| 85897 | + pList->a[0].zName = sqlite3DbStrDup(pParse->db, |
| 85898 | + pTab->aCol[pTab->iPKey].zName); |
| 85899 | + pList->a[0].sortOrder = pParse->iPkSortOrder; |
| 85900 | + assert( pParse->pNewTable==pTab ); |
| 85901 | + pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0); |
| 85902 | + if( pPk==0 ) return; |
| 85903 | + pPk->autoIndex = 2; |
| 85904 | + pTab->iPKey = -1; |
| 85905 | + }else{ |
| 85906 | + pPk = sqlite3PrimaryKeyIndex(pTab); |
| 85907 | + } |
| 85908 | + pPk->isCovering = 1; |
| 85909 | + assert( pPk!=0 ); |
| 85910 | + nPk = pPk->nKeyCol; |
| 85911 | + |
| 85912 | + /* Make sure every column of the PRIMARY KEY is NOT NULL */ |
| 85913 | + for(i=0; i<nPk; i++){ |
| 85914 | + pTab->aCol[pPk->aiColumn[i]].notNull = 1; |
| 85915 | + } |
| 85916 | + pPk->uniqNotNull = 1; |
| 85917 | + |
| 85918 | + /* The root page of the PRIMARY KEY is the table root page */ |
| 85919 | + pPk->tnum = pTab->tnum; |
| 85920 | + |
| 85921 | + /* Update the in-memory representation of all UNIQUE indices by converting |
| 85922 | + ** the final rowid column into one or more columns of the PRIMARY KEY. |
| 85923 | + */ |
| 85924 | + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 85925 | + int n; |
| 85926 | + if( pIdx->autoIndex==2 ) continue; |
| 85927 | + for(i=n=0; i<nPk; i++){ |
| 85928 | + if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++; |
| 85929 | + } |
| 85930 | + if( n==0 ){ |
| 85931 | + /* This index is a superset of the primary key */ |
| 85932 | + pIdx->nColumn = pIdx->nKeyCol; |
| 85933 | + continue; |
| 85934 | + } |
| 85935 | + if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return; |
| 85936 | + for(i=0, j=pIdx->nKeyCol; i<nPk; i++){ |
| 85937 | + if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){ |
| 85938 | + pIdx->aiColumn[j] = pPk->aiColumn[i]; |
| 85939 | + pIdx->azColl[j] = pPk->azColl[i]; |
| 85940 | + j++; |
| 85941 | + } |
| 85942 | + } |
| 85943 | + assert( pIdx->nColumn>=pIdx->nKeyCol+n ); |
| 85944 | + assert( pIdx->nColumn>=j ); |
| 85945 | + } |
| 85946 | + |
| 85947 | + /* Add all table columns to the PRIMARY KEY index |
| 85948 | + */ |
| 85949 | + if( nPk<pTab->nCol ){ |
| 85950 | + if( resizeIndexObject(db, pPk, pTab->nCol) ) return; |
| 85951 | + for(i=0, j=nPk; i<pTab->nCol; i++){ |
| 85952 | + if( !hasColumn(pPk->aiColumn, j, i) ){ |
| 85953 | + assert( j<pPk->nColumn ); |
| 85954 | + pPk->aiColumn[j] = i; |
| 85955 | + pPk->azColl[j] = "BINARY"; |
| 85956 | + j++; |
| 85957 | + } |
| 85958 | + } |
| 85959 | + assert( pPk->nColumn==j ); |
| 85960 | + assert( pTab->nCol==j ); |
| 85961 | + }else{ |
| 85962 | + pPk->nColumn = pTab->nCol; |
| 85963 | + } |
| 85964 | +} |
| 85299 | 85965 | |
| 85300 | 85966 | /* |
| 85301 | 85967 | ** This routine is called to report the final ")" that terminates |
| 85302 | 85968 | ** a CREATE TABLE statement. |
| 85303 | 85969 | ** |
| | @@ -85318,11 +85984,12 @@ |
| 85318 | 85984 | ** the new table will match the result set of the SELECT. |
| 85319 | 85985 | */ |
| 85320 | 85986 | SQLITE_PRIVATE void sqlite3EndTable( |
| 85321 | 85987 | Parse *pParse, /* Parse context */ |
| 85322 | 85988 | Token *pCons, /* The ',' token after the last column defn. */ |
| 85323 | | - Token *pEnd, /* The final ')' token in the CREATE TABLE */ |
| 85989 | + Token *pEnd, /* The ')' before options in the CREATE TABLE */ |
| 85990 | + u8 tabOpts, /* Extra table options. Usually 0. */ |
| 85324 | 85991 | Select *pSelect /* Select from a "CREATE ... AS SELECT" */ |
| 85325 | 85992 | ){ |
| 85326 | 85993 | Table *p; /* The new table */ |
| 85327 | 85994 | sqlite3 *db = pParse->db; /* The database connection */ |
| 85328 | 85995 | int iDb; /* Database in which the table lives */ |
| | @@ -85333,10 +86000,35 @@ |
| 85333 | 86000 | } |
| 85334 | 86001 | p = pParse->pNewTable; |
| 85335 | 86002 | if( p==0 ) return; |
| 85336 | 86003 | |
| 85337 | 86004 | assert( !db->init.busy || !pSelect ); |
| 86005 | + |
| 86006 | + /* If the db->init.busy is 1 it means we are reading the SQL off the |
| 86007 | + ** "sqlite_master" or "sqlite_temp_master" table on the disk. |
| 86008 | + ** So do not write to the disk again. Extract the root page number |
| 86009 | + ** for the table from the db->init.newTnum field. (The page number |
| 86010 | + ** should have been put there by the sqliteOpenCb routine.) |
| 86011 | + */ |
| 86012 | + if( db->init.busy ){ |
| 86013 | + p->tnum = db->init.newTnum; |
| 86014 | + } |
| 86015 | + |
| 86016 | + /* Special processing for WITHOUT ROWID Tables */ |
| 86017 | + if( tabOpts & TF_WithoutRowid ){ |
| 86018 | + if( (p->tabFlags & TF_Autoincrement) ){ |
| 86019 | + sqlite3ErrorMsg(pParse, |
| 86020 | + "AUTOINCREMENT not allowed on WITHOUT ROWID tables"); |
| 86021 | + return; |
| 86022 | + } |
| 86023 | + if( (p->tabFlags & TF_HasPrimaryKey)==0 ){ |
| 86024 | + sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName); |
| 86025 | + }else{ |
| 86026 | + p->tabFlags |= TF_WithoutRowid; |
| 86027 | + convertToWithoutRowidTable(pParse, p); |
| 86028 | + } |
| 86029 | + } |
| 85338 | 86030 | |
| 85339 | 86031 | iDb = sqlite3SchemaToIndex(db, p->pSchema); |
| 85340 | 86032 | |
| 85341 | 86033 | #ifndef SQLITE_OMIT_CHECK |
| 85342 | 86034 | /* Resolve names in all CHECK constraint expressions. |
| | @@ -85350,20 +86042,10 @@ |
| 85350 | 86042 | estimateTableWidth(p); |
| 85351 | 86043 | for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 85352 | 86044 | estimateIndexWidth(pIdx); |
| 85353 | 86045 | } |
| 85354 | 86046 | |
| 85355 | | - /* If the db->init.busy is 1 it means we are reading the SQL off the |
| 85356 | | - ** "sqlite_master" or "sqlite_temp_master" table on the disk. |
| 85357 | | - ** So do not write to the disk again. Extract the root page number |
| 85358 | | - ** for the table from the db->init.newTnum field. (The page number |
| 85359 | | - ** should have been put there by the sqliteOpenCb routine.) |
| 85360 | | - */ |
| 85361 | | - if( db->init.busy ){ |
| 85362 | | - p->tnum = db->init.newTnum; |
| 85363 | | - } |
| 85364 | | - |
| 85365 | 86047 | /* If not initializing, then create a record for the new table |
| 85366 | 86048 | ** in the SQLITE_MASTER table of the database. |
| 85367 | 86049 | ** |
| 85368 | 86050 | ** If this is a TEMPORARY table, write the entry into the auxiliary |
| 85369 | 86051 | ** file instead of into the main database file. |
| | @@ -85433,11 +86115,13 @@ |
| 85433 | 86115 | |
| 85434 | 86116 | /* Compute the complete text of the CREATE statement */ |
| 85435 | 86117 | if( pSelect ){ |
| 85436 | 86118 | zStmt = createTableStmt(db, p); |
| 85437 | 86119 | }else{ |
| 85438 | | - n = (int)(pEnd->z - pParse->sNameToken.z) + 1; |
| 86120 | + Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd; |
| 86121 | + n = (int)(pEnd2->z - pParse->sNameToken.z); |
| 86122 | + if( pEnd2->z[0]!=';' ) n += pEnd2->n; |
| 85439 | 86123 | zStmt = sqlite3MPrintf(db, |
| 85440 | 86124 | "CREATE %s %.*s", zType2, n, pParse->sNameToken.z |
| 85441 | 86125 | ); |
| 85442 | 86126 | } |
| 85443 | 86127 | |
| | @@ -85476,11 +86160,11 @@ |
| 85476 | 86160 | } |
| 85477 | 86161 | #endif |
| 85478 | 86162 | |
| 85479 | 86163 | /* Reparse everything to update our internal data structures */ |
| 85480 | 86164 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 85481 | | - sqlite3MPrintf(db, "tbl_name='%q'", p->zName)); |
| 86165 | + sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName)); |
| 85482 | 86166 | } |
| 85483 | 86167 | |
| 85484 | 86168 | |
| 85485 | 86169 | /* Add the table to the in-memory representation of the database. |
| 85486 | 86170 | */ |
| | @@ -85581,11 +86265,11 @@ |
| 85581 | 86265 | while( ALWAYS(n>0) && sqlite3Isspace(z[n-1]) ){ n--; } |
| 85582 | 86266 | sEnd.z = &z[n-1]; |
| 85583 | 86267 | sEnd.n = 1; |
| 85584 | 86268 | |
| 85585 | 86269 | /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */ |
| 85586 | | - sqlite3EndTable(pParse, 0, &sEnd, 0); |
| 86270 | + sqlite3EndTable(pParse, 0, &sEnd, 0, 0); |
| 85587 | 86271 | return; |
| 85588 | 86272 | } |
| 85589 | 86273 | #endif /* SQLITE_OMIT_VIEW */ |
| 85590 | 86274 | |
| 85591 | 86275 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) |
| | @@ -86036,12 +86720,12 @@ |
| 86036 | 86720 | /* |
| 86037 | 86721 | ** This routine is called to create a new foreign key on the table |
| 86038 | 86722 | ** currently under construction. pFromCol determines which columns |
| 86039 | 86723 | ** in the current table point to the foreign key. If pFromCol==0 then |
| 86040 | 86724 | ** connect the key to the last column inserted. pTo is the name of |
| 86041 | | -** the table referred to. pToCol is a list of tables in the other |
| 86042 | | -** pTo table that the foreign key points to. flags contains all |
| 86725 | +** the table referred to (a.k.a the "parent" table). pToCol is a list |
| 86726 | +** of tables in the parent pTo table. flags contains all |
| 86043 | 86727 | ** information about the conflict resolution algorithms specified |
| 86044 | 86728 | ** in the ON DELETE, ON UPDATE and ON INSERT clauses. |
| 86045 | 86729 | ** |
| 86046 | 86730 | ** An FKey structure is created and added to the table currently |
| 86047 | 86731 | ** under construction in the pParse->pNewTable field. |
| | @@ -86220,41 +86904,43 @@ |
| 86220 | 86904 | if( v==0 ) return; |
| 86221 | 86905 | if( memRootPage>=0 ){ |
| 86222 | 86906 | tnum = memRootPage; |
| 86223 | 86907 | }else{ |
| 86224 | 86908 | tnum = pIndex->tnum; |
| 86225 | | - sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb); |
| 86226 | 86909 | } |
| 86227 | | - pKey = sqlite3IndexKeyinfo(pParse, pIndex); |
| 86228 | | - sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, |
| 86229 | | - (char *)pKey, P4_KEYINFO_HANDOFF); |
| 86230 | | - sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0)); |
| 86910 | + pKey = sqlite3KeyInfoOfIndex(pParse, pIndex); |
| 86231 | 86911 | |
| 86232 | 86912 | /* Open the sorter cursor if we are to use one. */ |
| 86233 | 86913 | iSorter = pParse->nTab++; |
| 86234 | | - sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*)pKey, P4_KEYINFO); |
| 86914 | + sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, 0, (char*) |
| 86915 | + sqlite3KeyInfoRef(pKey), P4_KEYINFO); |
| 86235 | 86916 | |
| 86236 | 86917 | /* Open the table. Loop through all rows of the table, inserting index |
| 86237 | 86918 | ** records into the sorter. */ |
| 86238 | 86919 | sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); |
| 86239 | 86920 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); |
| 86240 | 86921 | regRecord = sqlite3GetTempReg(pParse); |
| 86241 | 86922 | |
| 86242 | | - sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel); |
| 86923 | + sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 0, &iPartIdxLabel); |
| 86243 | 86924 | sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord); |
| 86244 | 86925 | sqlite3VdbeResolveLabel(v, iPartIdxLabel); |
| 86245 | 86926 | sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); |
| 86246 | 86927 | sqlite3VdbeJumpHere(v, addr1); |
| 86928 | + if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb); |
| 86929 | + sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, |
| 86930 | + (char *)pKey, P4_KEYINFO); |
| 86931 | + sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0)); |
| 86932 | + |
| 86247 | 86933 | addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); |
| 86248 | | - if( pIndex->onError!=OE_None ){ |
| 86934 | + assert( pKey!=0 || db->mallocFailed || pParse->nErr ); |
| 86935 | + if( pIndex->onError!=OE_None && pKey!=0 ){ |
| 86249 | 86936 | int j2 = sqlite3VdbeCurrentAddr(v) + 3; |
| 86250 | 86937 | sqlite3VdbeAddOp2(v, OP_Goto, 0, j2); |
| 86251 | 86938 | addr2 = sqlite3VdbeCurrentAddr(v); |
| 86252 | | - sqlite3VdbeAddOp3(v, OP_SorterCompare, iSorter, j2, regRecord); |
| 86253 | | - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE, |
| 86254 | | - OE_Abort, "indexed columns are not unique", P4_STATIC |
| 86255 | | - ); |
| 86939 | + sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord, |
| 86940 | + pKey->nField - pIndex->nKeyCol); |
| 86941 | + sqlite3UniqueConstraint(pParse, OE_Abort, pIndex); |
| 86256 | 86942 | }else{ |
| 86257 | 86943 | addr2 = sqlite3VdbeCurrentAddr(v); |
| 86258 | 86944 | } |
| 86259 | 86945 | sqlite3VdbeAddOp2(v, OP_SorterData, iSorter, regRecord); |
| 86260 | 86946 | sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1); |
| | @@ -86265,10 +86951,45 @@ |
| 86265 | 86951 | |
| 86266 | 86952 | sqlite3VdbeAddOp1(v, OP_Close, iTab); |
| 86267 | 86953 | sqlite3VdbeAddOp1(v, OP_Close, iIdx); |
| 86268 | 86954 | sqlite3VdbeAddOp1(v, OP_Close, iSorter); |
| 86269 | 86955 | } |
| 86956 | + |
| 86957 | +/* |
| 86958 | +** Allocate heap space to hold an Index object with nCol columns. |
| 86959 | +** |
| 86960 | +** Increase the allocation size to provide an extra nExtra bytes |
| 86961 | +** of 8-byte aligned space after the Index object and return a |
| 86962 | +** pointer to this extra space in *ppExtra. |
| 86963 | +*/ |
| 86964 | +SQLITE_PRIVATE Index *sqlite3AllocateIndexObject( |
| 86965 | + sqlite3 *db, /* Database connection */ |
| 86966 | + i16 nCol, /* Total number of columns in the index */ |
| 86967 | + int nExtra, /* Number of bytes of extra space to alloc */ |
| 86968 | + char **ppExtra /* Pointer to the "extra" space */ |
| 86969 | +){ |
| 86970 | + Index *p; /* Allocated index object */ |
| 86971 | + int nByte; /* Bytes of space for Index object + arrays */ |
| 86972 | + |
| 86973 | + nByte = ROUND8(sizeof(Index)) + /* Index structure */ |
| 86974 | + ROUND8(sizeof(char*)*nCol) + /* Index.azColl */ |
| 86975 | + ROUND8(sizeof(tRowcnt)*(nCol+1) + /* Index.aiRowEst */ |
| 86976 | + sizeof(i16)*nCol + /* Index.aiColumn */ |
| 86977 | + sizeof(u8)*nCol); /* Index.aSortOrder */ |
| 86978 | + p = sqlite3DbMallocZero(db, nByte + nExtra); |
| 86979 | + if( p ){ |
| 86980 | + char *pExtra = ((char*)p)+ROUND8(sizeof(Index)); |
| 86981 | + p->azColl = (char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol); |
| 86982 | + p->aiRowEst = (tRowcnt*)pExtra; pExtra += sizeof(tRowcnt)*(nCol+1); |
| 86983 | + p->aiColumn = (i16*)pExtra; pExtra += sizeof(i16)*nCol; |
| 86984 | + p->aSortOrder = (u8*)pExtra; |
| 86985 | + p->nColumn = nCol; |
| 86986 | + p->nKeyCol = nCol - 1; |
| 86987 | + *ppExtra = ((char*)p) + nByte; |
| 86988 | + } |
| 86989 | + return p; |
| 86990 | +} |
| 86270 | 86991 | |
| 86271 | 86992 | /* |
| 86272 | 86993 | ** Create a new index for an SQL table. pName1.pName2 is the name of the index |
| 86273 | 86994 | ** and pTblList is the name of the table that is to be indexed. Both will |
| 86274 | 86995 | ** be NULL for a primary key or an index that is created to satisfy a |
| | @@ -86300,22 +87021,22 @@ |
| 86300 | 87021 | Table *pTab = 0; /* Table to be indexed */ |
| 86301 | 87022 | Index *pIndex = 0; /* The index to be created */ |
| 86302 | 87023 | char *zName = 0; /* Name of the index */ |
| 86303 | 87024 | int nName; /* Number of characters in zName */ |
| 86304 | 87025 | int i, j; |
| 86305 | | - Token nullId; /* Fake token for an empty ID list */ |
| 86306 | 87026 | DbFixer sFix; /* For assigning database names to pTable */ |
| 86307 | 87027 | int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */ |
| 86308 | 87028 | sqlite3 *db = pParse->db; |
| 86309 | 87029 | Db *pDb; /* The specific table containing the indexed database */ |
| 86310 | 87030 | int iDb; /* Index of the database that is being written */ |
| 86311 | 87031 | Token *pName = 0; /* Unqualified name of the index to create */ |
| 86312 | 87032 | struct ExprList_item *pListItem; /* For looping over pList */ |
| 86313 | 87033 | const Column *pTabCol; /* A column in the table */ |
| 86314 | | - int nCol; /* Number of columns */ |
| 86315 | 87034 | int nExtra = 0; /* Space allocated for zExtra[] */ |
| 87035 | + int nExtraCol; /* Number of extra columns needed */ |
| 86316 | 87036 | char *zExtra; /* Extra space after the Index object */ |
| 87037 | + Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */ |
| 86317 | 87038 | |
| 86318 | 87039 | assert( pParse->nErr==0 ); /* Never called with prior errors */ |
| 86319 | 87040 | if( db->mallocFailed || IN_DECLARE_VTAB ){ |
| 86320 | 87041 | goto exit_create_index; |
| 86321 | 87042 | } |
| | @@ -86363,10 +87084,11 @@ |
| 86363 | 87084 | sqlite3ErrorMsg(pParse, |
| 86364 | 87085 | "cannot create a TEMP index on non-TEMP table \"%s\"", |
| 86365 | 87086 | pTab->zName); |
| 86366 | 87087 | goto exit_create_index; |
| 86367 | 87088 | } |
| 87089 | + if( !HasRowid(pTab) ) pPk = sqlite3PrimaryKeyIndex(pTab); |
| 86368 | 87090 | }else{ |
| 86369 | 87091 | assert( pName==0 ); |
| 86370 | 87092 | assert( pStart==0 ); |
| 86371 | 87093 | pTab = pParse->pNewTable; |
| 86372 | 87094 | if( !pTab ) goto exit_create_index; |
| | @@ -86458,15 +87180,14 @@ |
| 86458 | 87180 | /* If pList==0, it means this routine was called to make a primary |
| 86459 | 87181 | ** key out of the last column added to the table under construction. |
| 86460 | 87182 | ** So create a fake list to simulate this. |
| 86461 | 87183 | */ |
| 86462 | 87184 | if( pList==0 ){ |
| 86463 | | - nullId.z = pTab->aCol[pTab->nCol-1].zName; |
| 86464 | | - nullId.n = sqlite3Strlen30((char*)nullId.z); |
| 86465 | 87185 | pList = sqlite3ExprListAppend(pParse, 0, 0); |
| 86466 | 87186 | if( pList==0 ) goto exit_create_index; |
| 86467 | | - sqlite3ExprListSetName(pParse, pList, &nullId, 0); |
| 87187 | + pList->a[0].zName = sqlite3DbStrDup(pParse->db, |
| 87188 | + pTab->aCol[pTab->nCol-1].zName); |
| 86468 | 87189 | pList->a[0].sortOrder = (u8)sortOrder; |
| 86469 | 87190 | } |
| 86470 | 87191 | |
| 86471 | 87192 | /* Figure out how many bytes of space are required to store explicitly |
| 86472 | 87193 | ** specified collation sequence names. |
| | @@ -86481,40 +87202,27 @@ |
| 86481 | 87202 | |
| 86482 | 87203 | /* |
| 86483 | 87204 | ** Allocate the index structure. |
| 86484 | 87205 | */ |
| 86485 | 87206 | nName = sqlite3Strlen30(zName); |
| 86486 | | - nCol = pList->nExpr; |
| 86487 | | - pIndex = sqlite3DbMallocZero(db, |
| 86488 | | - ROUND8(sizeof(Index)) + /* Index structure */ |
| 86489 | | - ROUND8(sizeof(tRowcnt)*(nCol+1)) + /* Index.aiRowEst */ |
| 86490 | | - sizeof(char *)*nCol + /* Index.azColl */ |
| 86491 | | - sizeof(int)*nCol + /* Index.aiColumn */ |
| 86492 | | - sizeof(u8)*nCol + /* Index.aSortOrder */ |
| 86493 | | - nName + 1 + /* Index.zName */ |
| 86494 | | - nExtra /* Collation sequence names */ |
| 86495 | | - ); |
| 87207 | + nExtraCol = pPk ? pPk->nKeyCol : 1; |
| 87208 | + pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol, |
| 87209 | + nName + nExtra + 1, &zExtra); |
| 86496 | 87210 | if( db->mallocFailed ){ |
| 86497 | 87211 | goto exit_create_index; |
| 86498 | 87212 | } |
| 86499 | | - zExtra = (char*)pIndex; |
| 86500 | | - pIndex->aiRowEst = (tRowcnt*)&zExtra[ROUND8(sizeof(Index))]; |
| 86501 | | - pIndex->azColl = (char**) |
| 86502 | | - ((char*)pIndex->aiRowEst + ROUND8(sizeof(tRowcnt)*nCol+1)); |
| 86503 | 87213 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowEst) ); |
| 86504 | 87214 | assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) ); |
| 86505 | | - pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]); |
| 86506 | | - pIndex->aSortOrder = (u8 *)(&pIndex->aiColumn[nCol]); |
| 86507 | | - pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]); |
| 86508 | | - zExtra = (char *)(&pIndex->zName[nName+1]); |
| 87215 | + pIndex->zName = zExtra; |
| 87216 | + zExtra += nName + 1; |
| 86509 | 87217 | memcpy(pIndex->zName, zName, nName+1); |
| 86510 | 87218 | pIndex->pTable = pTab; |
| 86511 | | - pIndex->nColumn = pList->nExpr; |
| 86512 | 87219 | pIndex->onError = (u8)onError; |
| 86513 | | - pIndex->uniqNotNull = onError==OE_Abort; |
| 87220 | + pIndex->uniqNotNull = onError!=OE_None; |
| 86514 | 87221 | pIndex->autoIndex = (u8)(pName==0); |
| 86515 | 87222 | pIndex->pSchema = db->aDb[iDb].pSchema; |
| 87223 | + pIndex->nKeyCol = pList->nExpr; |
| 86516 | 87224 | if( pPIWhere ){ |
| 86517 | 87225 | sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0); |
| 86518 | 87226 | pIndex->pPartIdxWhere = pPIWhere; |
| 86519 | 87227 | pPIWhere = 0; |
| 86520 | 87228 | } |
| | @@ -86550,11 +87258,12 @@ |
| 86550 | 87258 | sqlite3ErrorMsg(pParse, "table %s has no column named %s", |
| 86551 | 87259 | pTab->zName, zColName); |
| 86552 | 87260 | pParse->checkSchema = 1; |
| 86553 | 87261 | goto exit_create_index; |
| 86554 | 87262 | } |
| 86555 | | - pIndex->aiColumn[i] = j; |
| 87263 | + assert( pTab->nCol<=0x7fff && j<=0x7fff ); |
| 87264 | + pIndex->aiColumn[i] = (i16)j; |
| 86556 | 87265 | if( pListItem->pExpr ){ |
| 86557 | 87266 | int nColl; |
| 86558 | 87267 | assert( pListItem->pExpr->op==TK_COLLATE ); |
| 86559 | 87268 | zColl = pListItem->pExpr->u.zToken; |
| 86560 | 87269 | nColl = sqlite3Strlen30(zColl) + 1; |
| | @@ -86573,10 +87282,27 @@ |
| 86573 | 87282 | pIndex->azColl[i] = zColl; |
| 86574 | 87283 | requestedSortOrder = pListItem->sortOrder & sortOrderMask; |
| 86575 | 87284 | pIndex->aSortOrder[i] = (u8)requestedSortOrder; |
| 86576 | 87285 | if( pTab->aCol[j].notNull==0 ) pIndex->uniqNotNull = 0; |
| 86577 | 87286 | } |
| 87287 | + if( pPk ){ |
| 87288 | + for(j=0; j<pPk->nKeyCol; j++){ |
| 87289 | + int x = pPk->aiColumn[j]; |
| 87290 | + if( hasColumn(pIndex->aiColumn, pIndex->nKeyCol, x) ){ |
| 87291 | + pIndex->nColumn--; |
| 87292 | + }else{ |
| 87293 | + pIndex->aiColumn[i] = x; |
| 87294 | + pIndex->azColl[i] = pPk->azColl[j]; |
| 87295 | + pIndex->aSortOrder[i] = pPk->aSortOrder[j]; |
| 87296 | + i++; |
| 87297 | + } |
| 87298 | + } |
| 87299 | + assert( i==pIndex->nColumn ); |
| 87300 | + }else{ |
| 87301 | + pIndex->aiColumn[i] = -1; |
| 87302 | + pIndex->azColl[i] = "BINARY"; |
| 87303 | + } |
| 86578 | 87304 | sqlite3DefaultRowEst(pIndex); |
| 86579 | 87305 | if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex); |
| 86580 | 87306 | |
| 86581 | 87307 | if( pTab==pParse->pNewTable ){ |
| 86582 | 87308 | /* This routine has been called to create an automatic index as a |
| | @@ -86605,20 +87331,20 @@ |
| 86605 | 87331 | int k; |
| 86606 | 87332 | assert( pIdx->onError!=OE_None ); |
| 86607 | 87333 | assert( pIdx->autoIndex ); |
| 86608 | 87334 | assert( pIndex->onError!=OE_None ); |
| 86609 | 87335 | |
| 86610 | | - if( pIdx->nColumn!=pIndex->nColumn ) continue; |
| 86611 | | - for(k=0; k<pIdx->nColumn; k++){ |
| 87336 | + if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue; |
| 87337 | + for(k=0; k<pIdx->nKeyCol; k++){ |
| 86612 | 87338 | const char *z1; |
| 86613 | 87339 | const char *z2; |
| 86614 | 87340 | if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break; |
| 86615 | 87341 | z1 = pIdx->azColl[k]; |
| 86616 | 87342 | z2 = pIndex->azColl[k]; |
| 86617 | 87343 | if( z1!=z2 && sqlite3StrICmp(z1, z2) ) break; |
| 86618 | 87344 | } |
| 86619 | | - if( k==pIdx->nColumn ){ |
| 87345 | + if( k==pIdx->nKeyCol ){ |
| 86620 | 87346 | if( pIdx->onError!=pIndex->onError ){ |
| 86621 | 87347 | /* This constraint creates the same index as a previous |
| 86622 | 87348 | ** constraint specified somewhere in the CREATE TABLE statement. |
| 86623 | 87349 | ** However the ON CONFLICT clauses are different. If both this |
| 86624 | 87350 | ** constraint and the previous equivalent constraint have explicit |
| | @@ -86656,26 +87382,24 @@ |
| 86656 | 87382 | if( pTblName!=0 ){ |
| 86657 | 87383 | pIndex->tnum = db->init.newTnum; |
| 86658 | 87384 | } |
| 86659 | 87385 | } |
| 86660 | 87386 | |
| 86661 | | - /* If the db->init.busy is 0 then create the index on disk. This |
| 86662 | | - ** involves writing the index into the master table and filling in the |
| 86663 | | - ** index with the current table contents. |
| 86664 | | - ** |
| 86665 | | - ** The db->init.busy is 0 when the user first enters a CREATE INDEX |
| 86666 | | - ** command. db->init.busy is 1 when a database is opened and |
| 86667 | | - ** CREATE INDEX statements are read out of the master table. In |
| 86668 | | - ** the latter case the index already exists on disk, which is why |
| 86669 | | - ** we don't want to recreate it. |
| 86670 | | - ** |
| 86671 | | - ** If pTblName==0 it means this index is generated as a primary key |
| 86672 | | - ** or UNIQUE constraint of a CREATE TABLE statement. Since the table |
| 87387 | + /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the |
| 87388 | + ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then |
| 87389 | + ** emit code to allocate the index rootpage on disk and make an entry for |
| 87390 | + ** the index in the sqlite_master table and populate the index with |
| 87391 | + ** content. But, do not do this if we are simply reading the sqlite_master |
| 87392 | + ** table to parse the schema, or if this index is the PRIMARY KEY index |
| 87393 | + ** of a WITHOUT ROWID table. |
| 87394 | + ** |
| 87395 | + ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY |
| 87396 | + ** or UNIQUE index in a CREATE TABLE statement. Since the table |
| 86673 | 87397 | ** has just been created, it contains no data and the index initialization |
| 86674 | 87398 | ** step can be skipped. |
| 86675 | 87399 | */ |
| 86676 | | - else if( pParse->nErr==0 ){ |
| 87400 | + else if( pParse->nErr==0 && (HasRowid(pTab) || pTblName!=0) ){ |
| 86677 | 87401 | Vdbe *v; |
| 86678 | 87402 | char *zStmt; |
| 86679 | 87403 | int iMem = ++pParse->nMem; |
| 86680 | 87404 | |
| 86681 | 87405 | v = sqlite3GetVdbe(pParse); |
| | @@ -86783,16 +87507,16 @@ |
| 86783 | 87507 | tRowcnt n; |
| 86784 | 87508 | assert( a!=0 ); |
| 86785 | 87509 | a[0] = pIdx->pTable->nRowEst; |
| 86786 | 87510 | if( a[0]<10 ) a[0] = 10; |
| 86787 | 87511 | n = 10; |
| 86788 | | - for(i=1; i<=pIdx->nColumn; i++){ |
| 87512 | + for(i=1; i<=pIdx->nKeyCol; i++){ |
| 86789 | 87513 | a[i] = n; |
| 86790 | 87514 | if( n>5 ) n--; |
| 86791 | 87515 | } |
| 86792 | 87516 | if( pIdx->onError!=OE_None ){ |
| 86793 | | - a[pIdx->nColumn] = 1; |
| 87517 | + a[pIdx->nKeyCol] = 1; |
| 86794 | 87518 | } |
| 86795 | 87519 | } |
| 86796 | 87520 | |
| 86797 | 87521 | /* |
| 86798 | 87522 | ** This routine will drop an existing named index. This routine |
| | @@ -87476,18 +88200,71 @@ |
| 87476 | 88200 | SQLITE_PRIVATE void sqlite3HaltConstraint( |
| 87477 | 88201 | Parse *pParse, /* Parsing context */ |
| 87478 | 88202 | int errCode, /* extended error code */ |
| 87479 | 88203 | int onError, /* Constraint type */ |
| 87480 | 88204 | char *p4, /* Error message */ |
| 87481 | | - int p4type /* P4_STATIC or P4_TRANSIENT */ |
| 88205 | + i8 p4type, /* P4_STATIC or P4_TRANSIENT */ |
| 88206 | + u8 p5Errmsg /* P5_ErrMsg type */ |
| 87482 | 88207 | ){ |
| 87483 | 88208 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 87484 | 88209 | assert( (errCode&0xff)==SQLITE_CONSTRAINT ); |
| 87485 | 88210 | if( onError==OE_Abort ){ |
| 87486 | 88211 | sqlite3MayAbort(pParse); |
| 87487 | 88212 | } |
| 87488 | 88213 | sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type); |
| 88214 | + if( p5Errmsg ) sqlite3VdbeChangeP5(v, p5Errmsg); |
| 88215 | +} |
| 88216 | + |
| 88217 | +/* |
| 88218 | +** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation. |
| 88219 | +*/ |
| 88220 | +SQLITE_PRIVATE void sqlite3UniqueConstraint( |
| 88221 | + Parse *pParse, /* Parsing context */ |
| 88222 | + int onError, /* Constraint type */ |
| 88223 | + Index *pIdx /* The index that triggers the constraint */ |
| 88224 | +){ |
| 88225 | + char *zErr; |
| 88226 | + int j; |
| 88227 | + StrAccum errMsg; |
| 88228 | + Table *pTab = pIdx->pTable; |
| 88229 | + |
| 88230 | + sqlite3StrAccumInit(&errMsg, 0, 0, 200); |
| 88231 | + errMsg.db = pParse->db; |
| 88232 | + for(j=0; j<pIdx->nKeyCol; j++){ |
| 88233 | + char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName; |
| 88234 | + if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2); |
| 88235 | + sqlite3StrAccumAppend(&errMsg, pTab->zName, -1); |
| 88236 | + sqlite3StrAccumAppend(&errMsg, ".", 1); |
| 88237 | + sqlite3StrAccumAppend(&errMsg, zCol, -1); |
| 88238 | + } |
| 88239 | + zErr = sqlite3StrAccumFinish(&errMsg); |
| 88240 | + sqlite3HaltConstraint(pParse, |
| 88241 | + (pIdx->autoIndex==2)?SQLITE_CONSTRAINT_PRIMARYKEY:SQLITE_CONSTRAINT_UNIQUE, |
| 88242 | + onError, zErr, P4_DYNAMIC, P5_ConstraintUnique); |
| 88243 | +} |
| 88244 | + |
| 88245 | + |
| 88246 | +/* |
| 88247 | +** Code an OP_Halt due to non-unique rowid. |
| 88248 | +*/ |
| 88249 | +SQLITE_PRIVATE void sqlite3RowidConstraint( |
| 88250 | + Parse *pParse, /* Parsing context */ |
| 88251 | + int onError, /* Conflict resolution algorithm */ |
| 88252 | + Table *pTab /* The table with the non-unique rowid */ |
| 88253 | +){ |
| 88254 | + char *zMsg; |
| 88255 | + int rc; |
| 88256 | + if( pTab->iPKey>=0 ){ |
| 88257 | + zMsg = sqlite3MPrintf(pParse->db, "%s.%s", pTab->zName, |
| 88258 | + pTab->aCol[pTab->iPKey].zName); |
| 88259 | + rc = SQLITE_CONSTRAINT_PRIMARYKEY; |
| 88260 | + }else{ |
| 88261 | + zMsg = sqlite3MPrintf(pParse->db, "%s.rowid", pTab->zName); |
| 88262 | + rc = SQLITE_CONSTRAINT_ROWID; |
| 88263 | + } |
| 88264 | + sqlite3HaltConstraint(pParse, rc, onError, zMsg, P4_DYNAMIC, |
| 88265 | + P5_ConstraintUnique); |
| 87489 | 88266 | } |
| 87490 | 88267 | |
| 87491 | 88268 | /* |
| 87492 | 88269 | ** Check to see if pIndex uses the collating sequence pColl. Return |
| 87493 | 88270 | ** true if it does and false if it does not. |
| | @@ -87496,12 +88273,12 @@ |
| 87496 | 88273 | static int collationMatch(const char *zColl, Index *pIndex){ |
| 87497 | 88274 | int i; |
| 87498 | 88275 | assert( zColl!=0 ); |
| 87499 | 88276 | for(i=0; i<pIndex->nColumn; i++){ |
| 87500 | 88277 | const char *z = pIndex->azColl[i]; |
| 87501 | | - assert( z!=0 ); |
| 87502 | | - if( 0==sqlite3StrICmp(z, zColl) ){ |
| 88278 | + assert( z!=0 || pIndex->aiColumn[i]<0 ); |
| 88279 | + if( pIndex->aiColumn[i]>=0 && 0==sqlite3StrICmp(z, zColl) ){ |
| 87503 | 88280 | return 1; |
| 87504 | 88281 | } |
| 87505 | 88282 | } |
| 87506 | 88283 | return 0; |
| 87507 | 88284 | } |
| | @@ -87616,39 +88393,53 @@ |
| 87616 | 88393 | sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed"); |
| 87617 | 88394 | } |
| 87618 | 88395 | #endif |
| 87619 | 88396 | |
| 87620 | 88397 | /* |
| 87621 | | -** Return a dynamicly allocated KeyInfo structure that can be used |
| 87622 | | -** with OP_OpenRead or OP_OpenWrite to access database index pIdx. |
| 87623 | | -** |
| 87624 | | -** If successful, a pointer to the new structure is returned. In this case |
| 87625 | | -** the caller is responsible for calling sqlite3DbFree(db, ) on the returned |
| 87626 | | -** pointer. If an error occurs (out of memory or missing collation |
| 87627 | | -** sequence), NULL is returned and the state of pParse updated to reflect |
| 87628 | | -** the error. |
| 87629 | | -*/ |
| 87630 | | -SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){ |
| 87631 | | - int i; |
| 87632 | | - int nCol = pIdx->nColumn; |
| 87633 | | - KeyInfo *pKey; |
| 87634 | | - |
| 87635 | | - pKey = sqlite3KeyInfoAlloc(pParse->db, nCol); |
| 87636 | | - if( pKey ){ |
| 87637 | | - for(i=0; i<nCol; i++){ |
| 87638 | | - char *zColl = pIdx->azColl[i]; |
| 87639 | | - assert( zColl ); |
| 87640 | | - pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl); |
| 87641 | | - pKey->aSortOrder[i] = pIdx->aSortOrder[i]; |
| 87642 | | - } |
| 87643 | | - } |
| 87644 | | - |
| 87645 | | - if( pParse->nErr ){ |
| 87646 | | - sqlite3DbFree(pParse->db, pKey); |
| 87647 | | - pKey = 0; |
| 87648 | | - } |
| 87649 | | - return pKey; |
| 88398 | +** Return a KeyInfo structure that is appropriate for the given Index. |
| 88399 | +** |
| 88400 | +** The KeyInfo structure for an index is cached in the Index object. |
| 88401 | +** So there might be multiple references to the returned pointer. The |
| 88402 | +** caller should not try to modify the KeyInfo object. |
| 88403 | +** |
| 88404 | +** The caller should invoke sqlite3KeyInfoUnref() on the returned object |
| 88405 | +** when it has finished using it. |
| 88406 | +*/ |
| 88407 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){ |
| 88408 | + if( pParse->nErr ) return 0; |
| 88409 | +#ifndef SQLITE_OMIT_SHARED_CACHE |
| 88410 | + if( pIdx->pKeyInfo && pIdx->pKeyInfo->db!=pParse->db ){ |
| 88411 | + sqlite3KeyInfoUnref(pIdx->pKeyInfo); |
| 88412 | + pIdx->pKeyInfo = 0; |
| 88413 | + } |
| 88414 | +#endif |
| 88415 | + if( pIdx->pKeyInfo==0 ){ |
| 88416 | + int i; |
| 88417 | + int nCol = pIdx->nColumn; |
| 88418 | + int nKey = pIdx->nKeyCol; |
| 88419 | + KeyInfo *pKey; |
| 88420 | + if( pIdx->uniqNotNull ){ |
| 88421 | + pKey = sqlite3KeyInfoAlloc(pParse->db, nKey, nCol-nKey); |
| 88422 | + }else{ |
| 88423 | + pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0); |
| 88424 | + } |
| 88425 | + if( pKey ){ |
| 88426 | + assert( sqlite3KeyInfoIsWriteable(pKey) ); |
| 88427 | + for(i=0; i<nCol; i++){ |
| 88428 | + char *zColl = pIdx->azColl[i]; |
| 88429 | + if( NEVER(zColl==0) ) zColl = "BINARY"; |
| 88430 | + pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl); |
| 88431 | + pKey->aSortOrder[i] = pIdx->aSortOrder[i]; |
| 88432 | + } |
| 88433 | + if( pParse->nErr ){ |
| 88434 | + sqlite3KeyInfoUnref(pKey); |
| 88435 | + }else{ |
| 88436 | + pIdx->pKeyInfo = pKey; |
| 88437 | + } |
| 88438 | + } |
| 88439 | + } |
| 88440 | + return sqlite3KeyInfoRef(pIdx->pKeyInfo); |
| 87650 | 88441 | } |
| 87651 | 88442 | |
| 87652 | 88443 | /************** End of build.c ***********************************************/ |
| 87653 | 88444 | /************** Begin file callback.c ****************************************/ |
| 87654 | 88445 | /* |
| | @@ -88264,11 +89055,11 @@ |
| 88264 | 89055 | SrcList *pSrc, /* the FROM clause -- which tables to scan */ |
| 88265 | 89056 | Expr *pWhere, /* The WHERE clause. May be null */ |
| 88266 | 89057 | ExprList *pOrderBy, /* The ORDER BY clause. May be null */ |
| 88267 | 89058 | Expr *pLimit, /* The LIMIT clause. May be null */ |
| 88268 | 89059 | Expr *pOffset, /* The OFFSET clause. May be null */ |
| 88269 | | - char *zStmtType /* Either DELETE or UPDATE. For error messages. */ |
| 89060 | + char *zStmtType /* Either DELETE or UPDATE. For err msgs. */ |
| 88270 | 89061 | ){ |
| 88271 | 89062 | Expr *pWhereRowid = NULL; /* WHERE rowid .. */ |
| 88272 | 89063 | Expr *pInClause = NULL; /* WHERE rowid IN ( select ) */ |
| 88273 | 89064 | Expr *pSelectRowid = NULL; /* SELECT rowid ... */ |
| 88274 | 89065 | ExprList *pEList = NULL; /* Expression list contaning only pSelectRowid */ |
| | @@ -88339,11 +89130,12 @@ |
| 88339 | 89130 | sqlite3ExprListDelete(pParse->db, pOrderBy); |
| 88340 | 89131 | sqlite3ExprDelete(pParse->db, pLimit); |
| 88341 | 89132 | sqlite3ExprDelete(pParse->db, pOffset); |
| 88342 | 89133 | return 0; |
| 88343 | 89134 | } |
| 88344 | | -#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) */ |
| 89135 | +#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) */ |
| 89136 | + /* && !defined(SQLITE_OMIT_SUBQUERY) */ |
| 88345 | 89137 | |
| 88346 | 89138 | /* |
| 88347 | 89139 | ** Generate code for a DELETE FROM statement. |
| 88348 | 89140 | ** |
| 88349 | 89141 | ** DELETE FROM table_wxyz WHERE a<5 AND b NOT NULL; |
| | @@ -88360,11 +89152,13 @@ |
| 88360 | 89152 | const char *zDb; /* Name of database holding pTab */ |
| 88361 | 89153 | int end, addr = 0; /* A couple addresses of generated code */ |
| 88362 | 89154 | int i; /* Loop counter */ |
| 88363 | 89155 | WhereInfo *pWInfo; /* Information about the WHERE clause */ |
| 88364 | 89156 | Index *pIdx; /* For looping over indices of the table */ |
| 88365 | | - int iCur; /* VDBE Cursor number for pTab */ |
| 89157 | + int iTabCur; /* Cursor number for the table */ |
| 89158 | + int iDataCur; /* VDBE cursor for the canonical data source */ |
| 89159 | + int iIdxCur; /* Cursor number of the first index */ |
| 88366 | 89160 | sqlite3 *db; /* Main database structure */ |
| 88367 | 89161 | AuthContext sContext; /* Authorization context */ |
| 88368 | 89162 | NameContext sNC; /* Name context to resolve expressions in */ |
| 88369 | 89163 | int iDb; /* Database number */ |
| 88370 | 89164 | int memCnt = -1; /* Memory cell used for change counting */ |
| | @@ -88425,11 +89219,11 @@ |
| 88425 | 89219 | assert(!isView || pTrigger); |
| 88426 | 89220 | |
| 88427 | 89221 | /* Assign cursor number to the table and all its indices. |
| 88428 | 89222 | */ |
| 88429 | 89223 | assert( pTabList->nSrc==1 ); |
| 88430 | | - iCur = pTabList->a[0].iCursor = pParse->nTab++; |
| 89224 | + iTabCur = pTabList->a[0].iCursor = pParse->nTab++; |
| 88431 | 89225 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 88432 | 89226 | pParse->nTab++; |
| 88433 | 89227 | } |
| 88434 | 89228 | |
| 88435 | 89229 | /* Start the view context |
| | @@ -88450,11 +89244,12 @@ |
| 88450 | 89244 | /* If we are trying to delete from a view, realize that view into |
| 88451 | 89245 | ** a ephemeral table. |
| 88452 | 89246 | */ |
| 88453 | 89247 | #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) |
| 88454 | 89248 | if( isView ){ |
| 88455 | | - sqlite3MaterializeView(pParse, pTab, pWhere, iCur); |
| 89249 | + sqlite3MaterializeView(pParse, pTab, pWhere, iTabCur); |
| 89250 | + iDataCur = iIdxCur = iTabCur; |
| 88456 | 89251 | } |
| 88457 | 89252 | #endif |
| 88458 | 89253 | |
| 88459 | 89254 | /* Resolve the column names in the WHERE clause. |
| 88460 | 89255 | */ |
| | @@ -88481,22 +89276,78 @@ |
| 88481 | 89276 | if( rcauth==SQLITE_OK && pWhere==0 && !pTrigger && !IsVirtual(pTab) |
| 88482 | 89277 | && 0==sqlite3FkRequired(pParse, pTab, 0, 0) |
| 88483 | 89278 | ){ |
| 88484 | 89279 | assert( !isView ); |
| 88485 | 89280 | sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName); |
| 88486 | | - sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt, |
| 88487 | | - pTab->zName, P4_STATIC); |
| 89281 | + if( HasRowid(pTab) ){ |
| 89282 | + sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt, |
| 89283 | + pTab->zName, P4_STATIC); |
| 89284 | + } |
| 88488 | 89285 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 88489 | 89286 | assert( pIdx->pSchema==pTab->pSchema ); |
| 88490 | 89287 | sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb); |
| 88491 | 89288 | } |
| 88492 | 89289 | }else |
| 88493 | 89290 | #endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */ |
| 88494 | | - /* The usual case: There is a WHERE clause so we have to scan through |
| 88495 | | - ** the table and pick which records to delete. |
| 88496 | | - */ |
| 88497 | | - { |
| 89291 | + if( !HasRowid(pTab) ){ |
| 89292 | + /* There is a WHERE clause on a WITHOUT ROWID table. |
| 89293 | + */ |
| 89294 | + Index *pPk; /* The PRIMARY KEY index on the table */ |
| 89295 | + int iPk; /* First of nPk memory cells holding PRIMARY KEY value */ |
| 89296 | + int iEph; /* Ephemeral table holding all primary key values */ |
| 89297 | + int iKey; /* Key value inserting into iEph */ |
| 89298 | + i16 nPk; /* Number of components of the PRIMARY KEY */ |
| 89299 | + |
| 89300 | + pPk = sqlite3PrimaryKeyIndex(pTab); |
| 89301 | + assert( pPk!=0 ); |
| 89302 | + nPk = pPk->nKeyCol; |
| 89303 | + iPk = pParse->nMem+1; |
| 89304 | + pParse->nMem += nPk; |
| 89305 | + iKey = ++pParse->nMem; |
| 89306 | + iEph = pParse->nTab++; |
| 89307 | + |
| 89308 | + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk); |
| 89309 | + sqlite3VdbeSetP4KeyInfo(pParse, pPk); |
| 89310 | + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, 0, 0); |
| 89311 | + if( pWInfo==0 ) goto delete_from_cleanup; |
| 89312 | + for(i=0; i<nPk; i++){ |
| 89313 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, pPk->aiColumn[i],iPk+i); |
| 89314 | + } |
| 89315 | + sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey, |
| 89316 | + sqlite3IndexAffinityStr(v, pPk), P4_TRANSIENT); |
| 89317 | + sqlite3VdbeAddOp2(v, OP_IdxInsert, iEph, iKey); |
| 89318 | + if( db->flags & SQLITE_CountRows ){ |
| 89319 | + sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1); |
| 89320 | + } |
| 89321 | + sqlite3WhereEnd(pWInfo); |
| 89322 | + |
| 89323 | + /* Open cursors for all indices of the table. |
| 89324 | + */ |
| 89325 | + sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, |
| 89326 | + iTabCur, &iDataCur, &iIdxCur); |
| 89327 | + |
| 89328 | + /* Loop over the primary keys to be deleted. */ |
| 89329 | + addr = sqlite3VdbeAddOp1(v, OP_Rewind, iEph); |
| 89330 | + sqlite3VdbeAddOp2(v, OP_RowKey, iEph, iPk); |
| 89331 | + |
| 89332 | + /* Delete the row */ |
| 89333 | + sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, |
| 89334 | + iPk, 0, 1, OE_Default, 0); |
| 89335 | + |
| 89336 | + /* End of the delete loop */ |
| 89337 | + sqlite3VdbeAddOp2(v, OP_Next, iEph, addr+1); |
| 89338 | + sqlite3VdbeJumpHere(v, addr); |
| 89339 | + |
| 89340 | + /* Close the cursors open on the table and its indexes. */ |
| 89341 | + assert( iDataCur>=iIdxCur ); |
| 89342 | + for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ |
| 89343 | + sqlite3VdbeAddOp1(v, OP_Close, iIdxCur+i); |
| 89344 | + } |
| 89345 | + }else{ |
| 89346 | + /* There is a WHERE clause on a rowid table. Run a loop that extracts |
| 89347 | + ** all rowids to be deleted into a RowSet. |
| 89348 | + */ |
| 88498 | 89349 | int iRowSet = ++pParse->nMem; /* Register for rowset of rows to delete */ |
| 88499 | 89350 | int iRowid = ++pParse->nMem; /* Used for storing rowid values. */ |
| 88500 | 89351 | int regRowid; /* Actual register containing rowids */ |
| 88501 | 89352 | |
| 88502 | 89353 | /* Collect rowids of every row to be deleted. |
| | @@ -88504,11 +89355,11 @@ |
| 88504 | 89355 | sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet); |
| 88505 | 89356 | pWInfo = sqlite3WhereBegin( |
| 88506 | 89357 | pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK, 0 |
| 88507 | 89358 | ); |
| 88508 | 89359 | if( pWInfo==0 ) goto delete_from_cleanup; |
| 88509 | | - regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0); |
| 89360 | + regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iTabCur, iRowid, 0); |
| 88510 | 89361 | sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid); |
| 88511 | 89362 | if( db->flags & SQLITE_CountRows ){ |
| 88512 | 89363 | sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1); |
| 88513 | 89364 | } |
| 88514 | 89365 | sqlite3WhereEnd(pWInfo); |
| | @@ -88521,11 +89372,14 @@ |
| 88521 | 89372 | /* Unless this is a view, open cursors for the table we are |
| 88522 | 89373 | ** deleting from and all its indices. If this is a view, then the |
| 88523 | 89374 | ** only effect this statement has is to fire the INSTEAD OF |
| 88524 | 89375 | ** triggers. */ |
| 88525 | 89376 | if( !isView ){ |
| 88526 | | - sqlite3OpenTableAndIndices(pParse, pTab, iCur, OP_OpenWrite); |
| 89377 | + sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, iTabCur, |
| 89378 | + &iDataCur, &iIdxCur); |
| 89379 | + assert( iDataCur==iTabCur ); |
| 89380 | + assert( iIdxCur==iDataCur+1 ); |
| 88527 | 89381 | } |
| 88528 | 89382 | |
| 88529 | 89383 | addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, iRowSet, end, iRowid); |
| 88530 | 89384 | |
| 88531 | 89385 | /* Delete the row */ |
| | @@ -88538,23 +89392,24 @@ |
| 88538 | 89392 | sqlite3MayAbort(pParse); |
| 88539 | 89393 | }else |
| 88540 | 89394 | #endif |
| 88541 | 89395 | { |
| 88542 | 89396 | int count = (pParse->nested==0); /* True to count changes */ |
| 88543 | | - sqlite3GenerateRowDelete(pParse, pTab, iCur, iRowid, count, pTrigger, OE_Default); |
| 89397 | + sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, |
| 89398 | + iRowid, 1, count, OE_Default, 0); |
| 88544 | 89399 | } |
| 88545 | 89400 | |
| 88546 | 89401 | /* End of the delete loop */ |
| 88547 | 89402 | sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); |
| 88548 | 89403 | sqlite3VdbeResolveLabel(v, end); |
| 88549 | 89404 | |
| 88550 | 89405 | /* Close the cursors open on the table and its indexes. */ |
| 88551 | 89406 | if( !isView && !IsVirtual(pTab) ){ |
| 88552 | | - for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ |
| 88553 | | - sqlite3VdbeAddOp2(v, OP_Close, iCur + i, pIdx->tnum); |
| 89407 | + sqlite3VdbeAddOp1(v, OP_Close, iDataCur); |
| 89408 | + for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ |
| 89409 | + sqlite3VdbeAddOp1(v, OP_Close, iIdxCur + i); |
| 88554 | 89410 | } |
| 88555 | | - sqlite3VdbeAddOp1(v, OP_Close, iCur); |
| 88556 | 89411 | } |
| 88557 | 89412 | } |
| 88558 | 89413 | |
| 88559 | 89414 | /* Update the sqlite_sequence table by storing the content of the |
| 88560 | 89415 | ** maximum rowid counter values recorded while inserting into |
| | @@ -88590,48 +89445,56 @@ |
| 88590 | 89445 | #undef pTrigger |
| 88591 | 89446 | #endif |
| 88592 | 89447 | |
| 88593 | 89448 | /* |
| 88594 | 89449 | ** This routine generates VDBE code that causes a single row of a |
| 88595 | | -** single table to be deleted. |
| 89450 | +** single table to be deleted. Both the original table entry and |
| 89451 | +** all indices are removed. |
| 88596 | 89452 | ** |
| 88597 | | -** The VDBE must be in a particular state when this routine is called. |
| 88598 | | -** These are the requirements: |
| 89453 | +** Preconditions: |
| 88599 | 89454 | ** |
| 88600 | | -** 1. A read/write cursor pointing to pTab, the table containing the row |
| 88601 | | -** to be deleted, must be opened as cursor number $iCur. |
| 89455 | +** 1. iDataCur is an open cursor on the btree that is the canonical data |
| 89456 | +** store for the table. (This will be either the table itself, |
| 89457 | +** in the case of a rowid table, or the PRIMARY KEY index in the case |
| 89458 | +** of a WITHOUT ROWID table.) |
| 88602 | 89459 | ** |
| 88603 | 89460 | ** 2. Read/write cursors for all indices of pTab must be open as |
| 88604 | | -** cursor number base+i for the i-th index. |
| 89461 | +** cursor number iIdxCur+i for the i-th index. |
| 88605 | 89462 | ** |
| 88606 | | -** 3. The record number of the row to be deleted must be stored in |
| 88607 | | -** memory cell iRowid. |
| 88608 | | -** |
| 88609 | | -** This routine generates code to remove both the table record and all |
| 88610 | | -** index entries that point to that record. |
| 89463 | +** 3. The primary key for the row to be deleted must be stored in a |
| 89464 | +** sequence of nPk memory cells starting at iPk. If nPk==0 that means |
| 89465 | +** that a search record formed from OP_MakeRecord is contained in the |
| 89466 | +** single memory location iPk. |
| 88611 | 89467 | */ |
| 88612 | 89468 | SQLITE_PRIVATE void sqlite3GenerateRowDelete( |
| 88613 | 89469 | Parse *pParse, /* Parsing context */ |
| 88614 | 89470 | Table *pTab, /* Table containing the row to be deleted */ |
| 88615 | | - int iCur, /* Cursor number for the table */ |
| 88616 | | - int iRowid, /* Memory cell that contains the rowid to delete */ |
| 88617 | | - int count, /* If non-zero, increment the row change counter */ |
| 88618 | 89471 | Trigger *pTrigger, /* List of triggers to (potentially) fire */ |
| 88619 | | - int onconf /* Default ON CONFLICT policy for triggers */ |
| 89472 | + int iDataCur, /* Cursor from which column data is extracted */ |
| 89473 | + int iIdxCur, /* First index cursor */ |
| 89474 | + int iPk, /* First memory cell containing the PRIMARY KEY */ |
| 89475 | + i16 nPk, /* Number of PRIMARY KEY memory cells */ |
| 89476 | + u8 count, /* If non-zero, increment the row change counter */ |
| 89477 | + u8 onconf, /* Default ON CONFLICT policy for triggers */ |
| 89478 | + u8 bNoSeek /* iDataCur is already pointing to the row to delete */ |
| 88620 | 89479 | ){ |
| 88621 | 89480 | Vdbe *v = pParse->pVdbe; /* Vdbe */ |
| 88622 | 89481 | int iOld = 0; /* First register in OLD.* array */ |
| 88623 | 89482 | int iLabel; /* Label resolved to end of generated code */ |
| 89483 | + u8 opSeek; /* Seek opcode */ |
| 88624 | 89484 | |
| 88625 | 89485 | /* Vdbe is guaranteed to have been allocated by this stage. */ |
| 88626 | 89486 | assert( v ); |
| 89487 | + VdbeModuleComment((v, "BEGIN: GenRowDel(%d,%d,%d,%d)", |
| 89488 | + iDataCur, iIdxCur, iPk, (int)nPk)); |
| 88627 | 89489 | |
| 88628 | 89490 | /* Seek cursor iCur to the row to delete. If this row no longer exists |
| 88629 | 89491 | ** (this can happen if a trigger program has already deleted it), do |
| 88630 | 89492 | ** not attempt to delete it or fire any DELETE triggers. */ |
| 88631 | 89493 | iLabel = sqlite3VdbeMakeLabel(v); |
| 88632 | | - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid); |
| 89494 | + opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound; |
| 89495 | + if( !bNoSeek ) sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk); |
| 88633 | 89496 | |
| 88634 | 89497 | /* If there are any triggers to fire, allocate a range of registers to |
| 88635 | 89498 | ** use for the old.* references in the triggers. */ |
| 88636 | 89499 | if( sqlite3FkRequired(pParse, pTab, 0, 0) || pTrigger ){ |
| 88637 | 89500 | u32 mask; /* Mask of OLD.* columns in use */ |
| | @@ -88646,14 +89509,14 @@ |
| 88646 | 89509 | iOld = pParse->nMem+1; |
| 88647 | 89510 | pParse->nMem += (1 + pTab->nCol); |
| 88648 | 89511 | |
| 88649 | 89512 | /* Populate the OLD.* pseudo-table register array. These values will be |
| 88650 | 89513 | ** used by any BEFORE and AFTER triggers that exist. */ |
| 88651 | | - sqlite3VdbeAddOp2(v, OP_Copy, iRowid, iOld); |
| 89514 | + sqlite3VdbeAddOp2(v, OP_Copy, iPk, iOld); |
| 88652 | 89515 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 88653 | 89516 | if( mask==0xffffffff || mask&(1<<iCol) ){ |
| 88654 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, iCol, iOld+iCol+1); |
| 89517 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, iCol, iOld+iCol+1); |
| 88655 | 89518 | } |
| 88656 | 89519 | } |
| 88657 | 89520 | |
| 88658 | 89521 | /* Invoke BEFORE DELETE trigger programs. */ |
| 88659 | 89522 | sqlite3CodeRowTrigger(pParse, pTrigger, |
| | @@ -88662,11 +89525,11 @@ |
| 88662 | 89525 | |
| 88663 | 89526 | /* Seek the cursor to the row to be deleted again. It may be that |
| 88664 | 89527 | ** the BEFORE triggers coded above have already removed the row |
| 88665 | 89528 | ** being deleted. Do not attempt to delete the row a second time, and |
| 88666 | 89529 | ** do not fire AFTER triggers. */ |
| 88667 | | - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, iLabel, iRowid); |
| 89530 | + sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk); |
| 88668 | 89531 | |
| 88669 | 89532 | /* Do FK processing. This call checks that any FK constraints that |
| 88670 | 89533 | ** refer to this table (i.e. constraints attached to other tables) |
| 88671 | 89534 | ** are not violated by deleting this row. */ |
| 88672 | 89535 | sqlite3FkCheck(pParse, pTab, iOld, 0, 0, 0); |
| | @@ -88674,12 +89537,12 @@ |
| 88674 | 89537 | |
| 88675 | 89538 | /* Delete the index and table entries. Skip this step if pTab is really |
| 88676 | 89539 | ** a view (in which case the only effect of the DELETE statement is to |
| 88677 | 89540 | ** fire the INSTEAD OF triggers). */ |
| 88678 | 89541 | if( pTab->pSelect==0 ){ |
| 88679 | | - sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, 0); |
| 88680 | | - sqlite3VdbeAddOp2(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0)); |
| 89542 | + sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, 0); |
| 89543 | + sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0)); |
| 88681 | 89544 | if( count ){ |
| 88682 | 89545 | sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT); |
| 88683 | 89546 | } |
| 88684 | 89547 | } |
| 88685 | 89548 | |
| | @@ -88695,53 +89558,65 @@ |
| 88695 | 89558 | |
| 88696 | 89559 | /* Jump here if the row had already been deleted before any BEFORE |
| 88697 | 89560 | ** trigger programs were invoked. Or if a trigger program throws a |
| 88698 | 89561 | ** RAISE(IGNORE) exception. */ |
| 88699 | 89562 | sqlite3VdbeResolveLabel(v, iLabel); |
| 89563 | + VdbeModuleComment((v, "END: GenRowDel()")); |
| 88700 | 89564 | } |
| 88701 | 89565 | |
| 88702 | 89566 | /* |
| 88703 | 89567 | ** This routine generates VDBE code that causes the deletion of all |
| 88704 | | -** index entries associated with a single row of a single table. |
| 89568 | +** index entries associated with a single row of a single table, pTab |
| 88705 | 89569 | ** |
| 88706 | | -** The VDBE must be in a particular state when this routine is called. |
| 88707 | | -** These are the requirements: |
| 89570 | +** Preconditions: |
| 88708 | 89571 | ** |
| 88709 | | -** 1. A read/write cursor pointing to pTab, the table containing the row |
| 88710 | | -** to be deleted, must be opened as cursor number "iCur". |
| 89572 | +** 1. A read/write cursor "iDataCur" must be open on the canonical storage |
| 89573 | +** btree for the table pTab. (This will be either the table itself |
| 89574 | +** for rowid tables or to the primary key index for WITHOUT ROWID |
| 89575 | +** tables.) |
| 88711 | 89576 | ** |
| 88712 | 89577 | ** 2. Read/write cursors for all indices of pTab must be open as |
| 88713 | | -** cursor number iCur+i for the i-th index. |
| 89578 | +** cursor number iIdxCur+i for the i-th index. (The pTab->pIndex |
| 89579 | +** index is the 0-th index.) |
| 88714 | 89580 | ** |
| 88715 | | -** 3. The "iCur" cursor must be pointing to the row that is to be |
| 88716 | | -** deleted. |
| 89581 | +** 3. The "iDataCur" cursor must be already be positioned on the row |
| 89582 | +** that is to be deleted. |
| 88717 | 89583 | */ |
| 88718 | 89584 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete( |
| 88719 | 89585 | Parse *pParse, /* Parsing and code generating context */ |
| 88720 | 89586 | Table *pTab, /* Table containing the row to be deleted */ |
| 88721 | | - int iCur, /* Cursor number for the table */ |
| 89587 | + int iDataCur, /* Cursor of table holding data. */ |
| 89588 | + int iIdxCur, /* First index cursor */ |
| 88722 | 89589 | int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ |
| 88723 | 89590 | ){ |
| 88724 | | - int i; |
| 88725 | | - Index *pIdx; |
| 88726 | | - int r1; |
| 88727 | | - int iPartIdxLabel; |
| 88728 | | - Vdbe *v = pParse->pVdbe; |
| 88729 | | - |
| 88730 | | - for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ |
| 88731 | | - if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue; |
| 88732 | | - r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel); |
| 88733 | | - sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1); |
| 89591 | + int i; /* Index loop counter */ |
| 89592 | + int r1; /* Register holding an index key */ |
| 89593 | + int iPartIdxLabel; /* Jump destination for skipping partial index entries */ |
| 89594 | + Index *pIdx; /* Current index */ |
| 89595 | + Vdbe *v; /* The prepared statement under construction */ |
| 89596 | + Index *pPk; /* PRIMARY KEY index, or NULL for rowid tables */ |
| 89597 | + |
| 89598 | + v = pParse->pVdbe; |
| 89599 | + pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab); |
| 89600 | + for(i=0, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ |
| 89601 | + assert( iIdxCur+i!=iDataCur || pPk==pIdx ); |
| 89602 | + if( aRegIdx!=0 && aRegIdx[i]==0 ) continue; |
| 89603 | + if( pIdx==pPk ) continue; |
| 89604 | + VdbeModuleComment((v, "GenRowIdxDel for %s", pIdx->zName)); |
| 89605 | + r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 1, &iPartIdxLabel); |
| 89606 | + sqlite3VdbeAddOp3(v, OP_IdxDelete, iIdxCur+i, r1, |
| 89607 | + pIdx->uniqNotNull ? pIdx->nKeyCol : pIdx->nColumn); |
| 88734 | 89608 | sqlite3VdbeResolveLabel(v, iPartIdxLabel); |
| 88735 | 89609 | } |
| 88736 | 89610 | } |
| 88737 | 89611 | |
| 88738 | 89612 | /* |
| 88739 | | -** Generate code that will assemble an index key and put it in register |
| 89613 | +** Generate code that will assemble an index key and stores it in register |
| 88740 | 89614 | ** regOut. The key with be for index pIdx which is an index on pTab. |
| 88741 | 89615 | ** iCur is the index of a cursor open on the pTab table and pointing to |
| 88742 | | -** the entry that needs indexing. |
| 89616 | +** the entry that needs indexing. If pTab is a WITHOUT ROWID table, then |
| 89617 | +** iCur must be the cursor of the PRIMARY KEY index. |
| 88743 | 89618 | ** |
| 88744 | 89619 | ** Return a register number which is the first in a block of |
| 88745 | 89620 | ** registers that holds the elements of the index key. The |
| 88746 | 89621 | ** block of registers has already been deallocated by the time |
| 88747 | 89622 | ** this routine returns. |
| | @@ -88754,56 +89629,58 @@ |
| 88754 | 89629 | ** sqlite3VdbeResolveLabel(). |
| 88755 | 89630 | */ |
| 88756 | 89631 | SQLITE_PRIVATE int sqlite3GenerateIndexKey( |
| 88757 | 89632 | Parse *pParse, /* Parsing context */ |
| 88758 | 89633 | Index *pIdx, /* The index for which to generate a key */ |
| 88759 | | - int iCur, /* Cursor number for the pIdx->pTable table */ |
| 88760 | | - int regOut, /* Write the new index key to this register */ |
| 88761 | | - int doMakeRec, /* Run the OP_MakeRecord instruction if true */ |
| 89634 | + int iDataCur, /* Cursor number from which to take column data */ |
| 89635 | + int regOut, /* Put the new key into this register if not 0 */ |
| 89636 | + int prefixOnly, /* Compute only a unique prefix of the key */ |
| 88762 | 89637 | int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */ |
| 88763 | 89638 | ){ |
| 88764 | 89639 | Vdbe *v = pParse->pVdbe; |
| 88765 | 89640 | int j; |
| 88766 | 89641 | Table *pTab = pIdx->pTable; |
| 88767 | 89642 | int regBase; |
| 88768 | 89643 | int nCol; |
| 89644 | + Index *pPk; |
| 88769 | 89645 | |
| 88770 | 89646 | if( piPartIdxLabel ){ |
| 88771 | 89647 | if( pIdx->pPartIdxWhere ){ |
| 88772 | 89648 | *piPartIdxLabel = sqlite3VdbeMakeLabel(v); |
| 88773 | | - pParse->iPartIdxTab = iCur; |
| 89649 | + pParse->iPartIdxTab = iDataCur; |
| 88774 | 89650 | sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, |
| 88775 | 89651 | SQLITE_JUMPIFNULL); |
| 88776 | 89652 | }else{ |
| 88777 | 89653 | *piPartIdxLabel = 0; |
| 88778 | 89654 | } |
| 88779 | 89655 | } |
| 88780 | | - nCol = pIdx->nColumn; |
| 88781 | | - regBase = sqlite3GetTempRange(pParse, nCol+1); |
| 88782 | | - sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol); |
| 89656 | + nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn; |
| 89657 | + regBase = sqlite3GetTempRange(pParse, nCol); |
| 89658 | + pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab); |
| 88783 | 89659 | for(j=0; j<nCol; j++){ |
| 88784 | | - int idx = pIdx->aiColumn[j]; |
| 88785 | | - if( idx==pTab->iPKey ){ |
| 88786 | | - sqlite3VdbeAddOp2(v, OP_SCopy, regBase+nCol, regBase+j); |
| 89660 | + i16 idx = pIdx->aiColumn[j]; |
| 89661 | + if( pPk ) idx = sqlite3ColumnOfIndex(pPk, idx); |
| 89662 | + if( idx<0 || idx==pTab->iPKey ){ |
| 89663 | + sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regBase+j); |
| 88787 | 89664 | }else{ |
| 88788 | | - sqlite3VdbeAddOp3(v, OP_Column, iCur, idx, regBase+j); |
| 88789 | | - sqlite3ColumnDefault(v, pTab, idx, -1); |
| 89665 | + sqlite3VdbeAddOp3(v, OP_Column, iDataCur, idx, regBase+j); |
| 89666 | + sqlite3ColumnDefault(v, pTab, pIdx->aiColumn[j], -1); |
| 88790 | 89667 | } |
| 88791 | 89668 | } |
| 88792 | | - if( doMakeRec ){ |
| 89669 | + if( regOut ){ |
| 88793 | 89670 | const char *zAff; |
| 88794 | 89671 | if( pTab->pSelect |
| 88795 | 89672 | || OptimizationDisabled(pParse->db, SQLITE_IdxRealAsInt) |
| 88796 | 89673 | ){ |
| 88797 | 89674 | zAff = 0; |
| 88798 | 89675 | }else{ |
| 88799 | 89676 | zAff = sqlite3IndexAffinityStr(v, pIdx); |
| 88800 | 89677 | } |
| 88801 | | - sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); |
| 89678 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut); |
| 88802 | 89679 | sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT); |
| 88803 | 89680 | } |
| 88804 | | - sqlite3ReleaseTempRange(pParse, regBase, nCol+1); |
| 89681 | + sqlite3ReleaseTempRange(pParse, regBase, nCol); |
| 88805 | 89682 | return regBase; |
| 88806 | 89683 | } |
| 88807 | 89684 | |
| 88808 | 89685 | /************** End of delete.c **********************************************/ |
| 88809 | 89686 | /************** Begin file func.c ********************************************/ |
| | @@ -88943,12 +89820,12 @@ |
| 88943 | 89820 | switch( sqlite3_value_type(argv[0]) ){ |
| 88944 | 89821 | case SQLITE_INTEGER: { |
| 88945 | 89822 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 88946 | 89823 | if( iVal<0 ){ |
| 88947 | 89824 | if( (iVal<<1)==0 ){ |
| 88948 | | - /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then |
| 88949 | | - ** abs(X) throws an integer overflow error since there is no |
| 89825 | + /* IMP: R-31676-45509 If X is the integer -9223372036854775808 |
| 89826 | + ** then abs(X) throws an integer overflow error since there is no |
| 88950 | 89827 | ** equivalent positive 64-bit two complement value. */ |
| 88951 | 89828 | sqlite3_result_error(context, "integer overflow", -1); |
| 88952 | 89829 | return; |
| 88953 | 89830 | } |
| 88954 | 89831 | iVal = -iVal; |
| | @@ -90755,11 +91632,11 @@ |
| 90755 | 91632 | if( !aiCol ) return 1; |
| 90756 | 91633 | *paiCol = aiCol; |
| 90757 | 91634 | } |
| 90758 | 91635 | |
| 90759 | 91636 | for(pIdx=pParent->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 90760 | | - if( pIdx->nColumn==nCol && pIdx->onError!=OE_None ){ |
| 91637 | + if( pIdx->nKeyCol==nCol && pIdx->onError!=OE_None ){ |
| 90761 | 91638 | /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number |
| 90762 | 91639 | ** of columns. If each indexed column corresponds to a foreign key |
| 90763 | 91640 | ** column of pFKey, then this index is a winner. */ |
| 90764 | 91641 | |
| 90765 | 91642 | if( zKey==0 ){ |
| | @@ -90778,11 +91655,11 @@ |
| 90778 | 91655 | ** map to an explicit list of columns in table pParent. Check if this |
| 90779 | 91656 | ** index matches those columns. Also, check that the index uses |
| 90780 | 91657 | ** the default collation sequences for each column. */ |
| 90781 | 91658 | int i, j; |
| 90782 | 91659 | for(i=0; i<nCol; i++){ |
| 90783 | | - int iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */ |
| 91660 | + i16 iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */ |
| 90784 | 91661 | char *zDfltColl; /* Def. collation for column */ |
| 90785 | 91662 | char *zIdxCol; /* Name of indexed column */ |
| 90786 | 91663 | |
| 90787 | 91664 | /* If the index uses a collation sequence that is different from |
| 90788 | 91665 | ** the default collation sequence for the column, this index is |
| | @@ -90909,14 +91786,13 @@ |
| 90909 | 91786 | sqlite3ReleaseTempReg(pParse, regTemp); |
| 90910 | 91787 | }else{ |
| 90911 | 91788 | int nCol = pFKey->nCol; |
| 90912 | 91789 | int regTemp = sqlite3GetTempRange(pParse, nCol); |
| 90913 | 91790 | int regRec = sqlite3GetTempReg(pParse); |
| 90914 | | - KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 90915 | 91791 | |
| 90916 | 91792 | sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb); |
| 90917 | | - sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF); |
| 91793 | + sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 90918 | 91794 | for(i=0; i<nCol; i++){ |
| 90919 | 91795 | sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i); |
| 90920 | 91796 | } |
| 90921 | 91797 | |
| 90922 | 91798 | /* If the parent table is the same as the child table, and we are about |
| | @@ -90962,12 +91838,11 @@ |
| 90962 | 91838 | ** one row into the table, raise a constraint immediately instead of |
| 90963 | 91839 | ** incrementing a counter. This is necessary as the VM code is being |
| 90964 | 91840 | ** generated for will not open a statement transaction. */ |
| 90965 | 91841 | assert( nIncr==1 ); |
| 90966 | 91842 | sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY, |
| 90967 | | - OE_Abort, "foreign key constraint failed", P4_STATIC |
| 90968 | | - ); |
| 91843 | + OE_Abort, 0, P4_STATIC, P5_ConstraintFK); |
| 90969 | 91844 | }else{ |
| 90970 | 91845 | if( nIncr>0 && pFKey->isDeferred==0 ){ |
| 90971 | 91846 | sqlite3ParseToplevel(pParse)->mayAbort = 1; |
| 90972 | 91847 | } |
| 90973 | 91848 | sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr); |
| | @@ -90975,10 +91850,66 @@ |
| 90975 | 91850 | |
| 90976 | 91851 | sqlite3VdbeResolveLabel(v, iOk); |
| 90977 | 91852 | sqlite3VdbeAddOp1(v, OP_Close, iCur); |
| 90978 | 91853 | } |
| 90979 | 91854 | |
| 91855 | + |
| 91856 | +/* |
| 91857 | +** Return an Expr object that refers to a memory register corresponding |
| 91858 | +** to column iCol of table pTab. |
| 91859 | +** |
| 91860 | +** regBase is the first of an array of register that contains the data |
| 91861 | +** for pTab. regBase itself holds the rowid. regBase+1 holds the first |
| 91862 | +** column. regBase+2 holds the second column, and so forth. |
| 91863 | +*/ |
| 91864 | +static Expr *exprTableRegister( |
| 91865 | + Parse *pParse, /* Parsing and code generating context */ |
| 91866 | + Table *pTab, /* The table whose content is at r[regBase]... */ |
| 91867 | + int regBase, /* Contents of table pTab */ |
| 91868 | + i16 iCol /* Which column of pTab is desired */ |
| 91869 | +){ |
| 91870 | + Expr *pExpr; |
| 91871 | + Column *pCol; |
| 91872 | + const char *zColl; |
| 91873 | + sqlite3 *db = pParse->db; |
| 91874 | + |
| 91875 | + pExpr = sqlite3Expr(db, TK_REGISTER, 0); |
| 91876 | + if( pExpr ){ |
| 91877 | + if( iCol>=0 && iCol!=pTab->iPKey ){ |
| 91878 | + pCol = &pTab->aCol[iCol]; |
| 91879 | + pExpr->iTable = regBase + iCol + 1; |
| 91880 | + pExpr->affinity = pCol->affinity; |
| 91881 | + zColl = pCol->zColl; |
| 91882 | + if( zColl==0 ) zColl = db->pDfltColl->zName; |
| 91883 | + pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl); |
| 91884 | + }else{ |
| 91885 | + pExpr->iTable = regBase; |
| 91886 | + pExpr->affinity = SQLITE_AFF_INTEGER; |
| 91887 | + } |
| 91888 | + } |
| 91889 | + return pExpr; |
| 91890 | +} |
| 91891 | + |
| 91892 | +/* |
| 91893 | +** Return an Expr object that refers to column iCol of table pTab which |
| 91894 | +** has cursor iCur. |
| 91895 | +*/ |
| 91896 | +static Expr *exprTableColumn( |
| 91897 | + sqlite3 *db, /* The database connection */ |
| 91898 | + Table *pTab, /* The table whose column is desired */ |
| 91899 | + int iCursor, /* The open cursor on the table */ |
| 91900 | + i16 iCol /* The column that is wanted */ |
| 91901 | +){ |
| 91902 | + Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0); |
| 91903 | + if( pExpr ){ |
| 91904 | + pExpr->pTab = pTab; |
| 91905 | + pExpr->iTable = iCursor; |
| 91906 | + pExpr->iColumn = iCol; |
| 91907 | + } |
| 91908 | + return pExpr; |
| 91909 | +} |
| 91910 | + |
| 90980 | 91911 | /* |
| 90981 | 91912 | ** This function is called to generate code executed when a row is deleted |
| 90982 | 91913 | ** from the parent table of foreign key constraint pFKey and, if pFKey is |
| 90983 | 91914 | ** deferred, when a row is inserted into the same table. When generating |
| 90984 | 91915 | ** code for an SQL UPDATE operation, this function may be called twice - |
| | @@ -90990,31 +91921,31 @@ |
| 90990 | 91921 | ** |
| 90991 | 91922 | ** Operation | FK type | Action taken |
| 90992 | 91923 | ** -------------------------------------------------------------------------- |
| 90993 | 91924 | ** DELETE immediate Increment the "immediate constraint counter". |
| 90994 | 91925 | ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, |
| 90995 | | -** throw a "foreign key constraint failed" exception. |
| 91926 | +** throw a "FOREIGN KEY constraint failed" exception. |
| 90996 | 91927 | ** |
| 90997 | 91928 | ** INSERT immediate Decrement the "immediate constraint counter". |
| 90998 | 91929 | ** |
| 90999 | 91930 | ** DELETE deferred Increment the "deferred constraint counter". |
| 91000 | 91931 | ** Or, if the ON (UPDATE|DELETE) action is RESTRICT, |
| 91001 | | -** throw a "foreign key constraint failed" exception. |
| 91932 | +** throw a "FOREIGN KEY constraint failed" exception. |
| 91002 | 91933 | ** |
| 91003 | 91934 | ** INSERT deferred Decrement the "deferred constraint counter". |
| 91004 | 91935 | ** |
| 91005 | 91936 | ** These operations are identified in the comment at the top of this file |
| 91006 | 91937 | ** (fkey.c) as "I.2" and "D.2". |
| 91007 | 91938 | */ |
| 91008 | 91939 | static void fkScanChildren( |
| 91009 | 91940 | Parse *pParse, /* Parse context */ |
| 91010 | | - SrcList *pSrc, /* SrcList containing the table to scan */ |
| 91011 | | - Table *pTab, |
| 91012 | | - Index *pIdx, /* Foreign key index */ |
| 91013 | | - FKey *pFKey, /* Foreign key relationship */ |
| 91941 | + SrcList *pSrc, /* The child table to be scanned */ |
| 91942 | + Table *pTab, /* The parent table */ |
| 91943 | + Index *pIdx, /* Index on parent covering the foreign key */ |
| 91944 | + FKey *pFKey, /* The foreign key linking pSrc to pTab */ |
| 91014 | 91945 | int *aiCol, /* Map from pIdx cols to child table cols */ |
| 91015 | | - int regData, /* Referenced table data starts here */ |
| 91946 | + int regData, /* Parent row data starts here */ |
| 91016 | 91947 | int nIncr /* Amount to increment deferred counter by */ |
| 91017 | 91948 | ){ |
| 91018 | 91949 | sqlite3 *db = pParse->db; /* Database handle */ |
| 91019 | 91950 | int i; /* Iterator variable */ |
| 91020 | 91951 | Expr *pWhere = 0; /* WHERE clause to scan with */ |
| | @@ -91021,11 +91952,13 @@ |
| 91021 | 91952 | NameContext sNameContext; /* Context used to resolve WHERE clause */ |
| 91022 | 91953 | WhereInfo *pWInfo; /* Context used by sqlite3WhereXXX() */ |
| 91023 | 91954 | int iFkIfZero = 0; /* Address of OP_FkIfZero */ |
| 91024 | 91955 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 91025 | 91956 | |
| 91026 | | - assert( !pIdx || pIdx->pTable==pTab ); |
| 91957 | + assert( pIdx==0 || pIdx->pTable==pTab ); |
| 91958 | + assert( pIdx==0 || pIdx->nKeyCol==pFKey->nCol ); |
| 91959 | + assert( pIdx!=0 || pFKey->nCol==1 ); |
| 91027 | 91960 | |
| 91028 | 91961 | if( nIncr<0 ){ |
| 91029 | 91962 | iFkIfZero = sqlite3VdbeAddOp2(v, OP_FkIfZero, pFKey->isDeferred, 0); |
| 91030 | 91963 | } |
| 91031 | 91964 | |
| | @@ -91039,59 +91972,55 @@ |
| 91039 | 91972 | */ |
| 91040 | 91973 | for(i=0; i<pFKey->nCol; i++){ |
| 91041 | 91974 | Expr *pLeft; /* Value from parent table row */ |
| 91042 | 91975 | Expr *pRight; /* Column ref to child table */ |
| 91043 | 91976 | Expr *pEq; /* Expression (pLeft = pRight) */ |
| 91044 | | - int iCol; /* Index of column in child table */ |
| 91977 | + i16 iCol; /* Index of column in child table */ |
| 91045 | 91978 | const char *zCol; /* Name of column in child table */ |
| 91046 | 91979 | |
| 91047 | | - pLeft = sqlite3Expr(db, TK_REGISTER, 0); |
| 91048 | | - if( pLeft ){ |
| 91049 | | - /* Set the collation sequence and affinity of the LHS of each TK_EQ |
| 91050 | | - ** expression to the parent key column defaults. */ |
| 91051 | | - if( pIdx ){ |
| 91052 | | - Column *pCol; |
| 91053 | | - const char *zColl; |
| 91054 | | - iCol = pIdx->aiColumn[i]; |
| 91055 | | - pCol = &pTab->aCol[iCol]; |
| 91056 | | - if( pTab->iPKey==iCol ) iCol = -1; |
| 91057 | | - pLeft->iTable = regData+iCol+1; |
| 91058 | | - pLeft->affinity = pCol->affinity; |
| 91059 | | - zColl = pCol->zColl; |
| 91060 | | - if( zColl==0 ) zColl = db->pDfltColl->zName; |
| 91061 | | - pLeft = sqlite3ExprAddCollateString(pParse, pLeft, zColl); |
| 91062 | | - }else{ |
| 91063 | | - pLeft->iTable = regData; |
| 91064 | | - pLeft->affinity = SQLITE_AFF_INTEGER; |
| 91065 | | - } |
| 91066 | | - } |
| 91980 | + iCol = pIdx ? pIdx->aiColumn[i] : -1; |
| 91981 | + pLeft = exprTableRegister(pParse, pTab, regData, iCol); |
| 91067 | 91982 | iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom; |
| 91068 | 91983 | assert( iCol>=0 ); |
| 91069 | 91984 | zCol = pFKey->pFrom->aCol[iCol].zName; |
| 91070 | 91985 | pRight = sqlite3Expr(db, TK_ID, zCol); |
| 91071 | 91986 | pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight, 0); |
| 91072 | 91987 | pWhere = sqlite3ExprAnd(db, pWhere, pEq); |
| 91073 | 91988 | } |
| 91074 | 91989 | |
| 91075 | | - /* If the child table is the same as the parent table, and this scan |
| 91076 | | - ** is taking place as part of a DELETE operation (operation D.2), omit the |
| 91077 | | - ** row being deleted from the scan by adding ($rowid != rowid) to the WHERE |
| 91078 | | - ** clause, where $rowid is the rowid of the row being deleted. */ |
| 91990 | + /* If the child table is the same as the parent table, then add terms |
| 91991 | + ** to the WHERE clause that prevent this entry from being scanned. |
| 91992 | + ** The added WHERE clause terms are like this: |
| 91993 | + ** |
| 91994 | + ** $current_rowid!=rowid |
| 91995 | + ** NOT( $current_a==a AND $current_b==b AND ... ) |
| 91996 | + ** |
| 91997 | + ** The first form is used for rowid tables. The second form is used |
| 91998 | + ** for WITHOUT ROWID tables. In the second form, the primary key is |
| 91999 | + ** (a,b,...) |
| 92000 | + */ |
| 91079 | 92001 | if( pTab==pFKey->pFrom && nIncr>0 ){ |
| 91080 | | - Expr *pEq; /* Expression (pLeft = pRight) */ |
| 92002 | + Expr *pNe; /* Expression (pLeft != pRight) */ |
| 91081 | 92003 | Expr *pLeft; /* Value from parent table row */ |
| 91082 | 92004 | Expr *pRight; /* Column ref to child table */ |
| 91083 | | - pLeft = sqlite3Expr(db, TK_REGISTER, 0); |
| 91084 | | - pRight = sqlite3Expr(db, TK_COLUMN, 0); |
| 91085 | | - if( pLeft && pRight ){ |
| 91086 | | - pLeft->iTable = regData; |
| 91087 | | - pLeft->affinity = SQLITE_AFF_INTEGER; |
| 91088 | | - pRight->iTable = pSrc->a[0].iCursor; |
| 91089 | | - pRight->iColumn = -1; |
| 91090 | | - } |
| 91091 | | - pEq = sqlite3PExpr(pParse, TK_NE, pLeft, pRight, 0); |
| 91092 | | - pWhere = sqlite3ExprAnd(db, pWhere, pEq); |
| 92005 | + if( HasRowid(pTab) ){ |
| 92006 | + pLeft = exprTableRegister(pParse, pTab, regData, -1); |
| 92007 | + pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, -1); |
| 92008 | + pNe = sqlite3PExpr(pParse, TK_NE, pLeft, pRight, 0); |
| 92009 | + }else{ |
| 92010 | + Expr *pEq, *pAll = 0; |
| 92011 | + Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 92012 | + for(i=0; i<pPk->nKeyCol; i++){ |
| 92013 | + i16 iCol = pIdx->aiColumn[i]; |
| 92014 | + pLeft = exprTableRegister(pParse, pTab, regData, iCol); |
| 92015 | + pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, iCol); |
| 92016 | + pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight, 0); |
| 92017 | + pAll = sqlite3ExprAnd(db, pAll, pEq); |
| 92018 | + } |
| 92019 | + pNe = sqlite3PExpr(pParse, TK_NOT, pAll, 0, 0); |
| 92020 | + } |
| 92021 | + pWhere = sqlite3ExprAnd(db, pWhere, pNe); |
| 91093 | 92022 | } |
| 91094 | 92023 | |
| 91095 | 92024 | /* Resolve the references in the WHERE clause. */ |
| 91096 | 92025 | memset(&sNameContext, 0, sizeof(NameContext)); |
| 91097 | 92026 | sNameContext.pSrcList = pSrc; |
| | @@ -91117,12 +92046,12 @@ |
| 91117 | 92046 | sqlite3VdbeJumpHere(v, iFkIfZero); |
| 91118 | 92047 | } |
| 91119 | 92048 | } |
| 91120 | 92049 | |
| 91121 | 92050 | /* |
| 91122 | | -** This function returns a pointer to the head of a linked list of FK |
| 91123 | | -** constraints for which table pTab is the parent table. For example, |
| 92051 | +** This function returns a linked list of FKey objects (connected by |
| 92052 | +** FKey.pNextTo) holding all children of table pTab. For example, |
| 91124 | 92053 | ** given the following schema: |
| 91125 | 92054 | ** |
| 91126 | 92055 | ** CREATE TABLE t1(a PRIMARY KEY); |
| 91127 | 92056 | ** CREATE TABLE t2(b REFERENCES t1(a); |
| 91128 | 92057 | ** |
| | @@ -91209,12 +92138,11 @@ |
| 91209 | 92138 | ** constraints are violated. |
| 91210 | 92139 | */ |
| 91211 | 92140 | if( (db->flags & SQLITE_DeferFKs)==0 ){ |
| 91212 | 92141 | sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2); |
| 91213 | 92142 | sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY, |
| 91214 | | - OE_Abort, "foreign key constraint failed", P4_STATIC |
| 91215 | | - ); |
| 92143 | + OE_Abort, 0, P4_STATIC, P5_ConstraintFK); |
| 91216 | 92144 | } |
| 91217 | 92145 | |
| 91218 | 92146 | if( iSkip ){ |
| 91219 | 92147 | sqlite3VdbeResolveLabel(v, iSkip); |
| 91220 | 92148 | } |
| | @@ -91420,11 +92348,12 @@ |
| 91420 | 92348 | } |
| 91421 | 92349 | |
| 91422 | 92350 | sqlite3DbFree(db, aiFree); |
| 91423 | 92351 | } |
| 91424 | 92352 | |
| 91425 | | - /* Loop through all the foreign key constraints that refer to this table */ |
| 92353 | + /* Loop through all the foreign key constraints that refer to this table. |
| 92354 | + ** (the "child" constraints) */ |
| 91426 | 92355 | for(pFKey = sqlite3FkReferences(pTab); pFKey; pFKey=pFKey->pNextTo){ |
| 91427 | 92356 | Index *pIdx = 0; /* Foreign key index for pFKey */ |
| 91428 | 92357 | SrcList *pSrc; |
| 91429 | 92358 | int *aiCol = 0; |
| 91430 | 92359 | |
| | @@ -91445,13 +92374,12 @@ |
| 91445 | 92374 | if( !isIgnoreErrors || db->mallocFailed ) return; |
| 91446 | 92375 | continue; |
| 91447 | 92376 | } |
| 91448 | 92377 | assert( aiCol || pFKey->nCol==1 ); |
| 91449 | 92378 | |
| 91450 | | - /* Create a SrcList structure containing a single table (the table |
| 91451 | | - ** the foreign key that refers to this table is attached to). This |
| 91452 | | - ** is required for the sqlite3WhereXXX() interface. */ |
| 92379 | + /* Create a SrcList structure containing the child table. We need the |
| 92380 | + ** child table as a SrcList for sqlite3WhereBegin() */ |
| 91453 | 92381 | pSrc = sqlite3SrcListAppend(db, 0, 0, 0); |
| 91454 | 92382 | if( pSrc ){ |
| 91455 | 92383 | struct SrcList_item *pItem = pSrc->a; |
| 91456 | 92384 | pItem->pTab = pFKey->pFrom; |
| 91457 | 92385 | pItem->zName = pFKey->pFrom->zName; |
| | @@ -91496,11 +92424,11 @@ |
| 91496 | 92424 | } |
| 91497 | 92425 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 91498 | 92426 | Index *pIdx = 0; |
| 91499 | 92427 | sqlite3FkLocateIndex(pParse, pTab, p, &pIdx, 0); |
| 91500 | 92428 | if( pIdx ){ |
| 91501 | | - for(i=0; i<pIdx->nColumn; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]); |
| 92429 | + for(i=0; i<pIdx->nKeyCol; i++) mask |= COLUMN_MASK(pIdx->aiColumn[i]); |
| 91502 | 92430 | } |
| 91503 | 92431 | } |
| 91504 | 92432 | } |
| 91505 | 92433 | return mask; |
| 91506 | 92434 | } |
| | @@ -91688,11 +92616,11 @@ |
| 91688 | 92616 | Token tFrom; |
| 91689 | 92617 | Expr *pRaise; |
| 91690 | 92618 | |
| 91691 | 92619 | tFrom.z = zFrom; |
| 91692 | 92620 | tFrom.n = nFrom; |
| 91693 | | - pRaise = sqlite3Expr(db, TK_RAISE, "foreign key constraint failed"); |
| 92621 | + pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed"); |
| 91694 | 92622 | if( pRaise ){ |
| 91695 | 92623 | pRaise->affinity = OE_Abort; |
| 91696 | 92624 | } |
| 91697 | 92625 | pSelect = sqlite3SelectNew(pParse, |
| 91698 | 92626 | sqlite3ExprListAppend(pParse, 0, pRaise), |
| | @@ -91852,27 +92780,42 @@ |
| 91852 | 92780 | ** This file contains C code routines that are called by the parser |
| 91853 | 92781 | ** to handle INSERT statements in SQLite. |
| 91854 | 92782 | */ |
| 91855 | 92783 | |
| 91856 | 92784 | /* |
| 91857 | | -** Generate code that will open a table for reading. |
| 92785 | +** Generate code that will |
| 92786 | +** |
| 92787 | +** (1) acquire a lock for table pTab then |
| 92788 | +** (2) open pTab as cursor iCur. |
| 92789 | +** |
| 92790 | +** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index |
| 92791 | +** for that table that is actually opened. |
| 91858 | 92792 | */ |
| 91859 | 92793 | SQLITE_PRIVATE void sqlite3OpenTable( |
| 91860 | | - Parse *p, /* Generate code into this VDBE */ |
| 92794 | + Parse *pParse, /* Generate code into this VDBE */ |
| 91861 | 92795 | int iCur, /* The cursor number of the table */ |
| 91862 | 92796 | int iDb, /* The database index in sqlite3.aDb[] */ |
| 91863 | 92797 | Table *pTab, /* The table to be opened */ |
| 91864 | 92798 | int opcode /* OP_OpenRead or OP_OpenWrite */ |
| 91865 | 92799 | ){ |
| 91866 | 92800 | Vdbe *v; |
| 91867 | 92801 | assert( !IsVirtual(pTab) ); |
| 91868 | | - v = sqlite3GetVdbe(p); |
| 92802 | + v = sqlite3GetVdbe(pParse); |
| 91869 | 92803 | assert( opcode==OP_OpenWrite || opcode==OP_OpenRead ); |
| 91870 | | - sqlite3TableLock(p, iDb, pTab->tnum, (opcode==OP_OpenWrite)?1:0, pTab->zName); |
| 91871 | | - sqlite3VdbeAddOp3(v, opcode, iCur, pTab->tnum, iDb); |
| 91872 | | - sqlite3VdbeChangeP4(v, -1, SQLITE_INT_TO_PTR(pTab->nCol), P4_INT32); |
| 91873 | | - VdbeComment((v, "%s", pTab->zName)); |
| 92804 | + sqlite3TableLock(pParse, iDb, pTab->tnum, |
| 92805 | + (opcode==OP_OpenWrite)?1:0, pTab->zName); |
| 92806 | + if( HasRowid(pTab) ){ |
| 92807 | + sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol); |
| 92808 | + VdbeComment((v, "%s", pTab->zName)); |
| 92809 | + }else{ |
| 92810 | + Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 92811 | + assert( pPk!=0 ); |
| 92812 | + assert( pPk->tnum=pTab->tnum ); |
| 92813 | + sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb); |
| 92814 | + sqlite3VdbeSetP4KeyInfo(pParse, pPk); |
| 92815 | + VdbeComment((v, "%s", pTab->zName)); |
| 92816 | + } |
| 91874 | 92817 | } |
| 91875 | 92818 | |
| 91876 | 92819 | /* |
| 91877 | 92820 | ** Return a pointer to the column affinity string associated with index |
| 91878 | 92821 | ** pIdx. A column affinity string has one character for each column in |
| | @@ -91904,19 +92847,19 @@ |
| 91904 | 92847 | ** up. |
| 91905 | 92848 | */ |
| 91906 | 92849 | int n; |
| 91907 | 92850 | Table *pTab = pIdx->pTable; |
| 91908 | 92851 | sqlite3 *db = sqlite3VdbeDb(v); |
| 91909 | | - pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+2); |
| 92852 | + pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1); |
| 91910 | 92853 | if( !pIdx->zColAff ){ |
| 91911 | 92854 | db->mallocFailed = 1; |
| 91912 | 92855 | return 0; |
| 91913 | 92856 | } |
| 91914 | 92857 | for(n=0; n<pIdx->nColumn; n++){ |
| 91915 | | - pIdx->zColAff[n] = pTab->aCol[pIdx->aiColumn[n]].affinity; |
| 92858 | + i16 x = pIdx->aiColumn[n]; |
| 92859 | + pIdx->zColAff[n] = x<0 ? SQLITE_AFF_INTEGER : pTab->aCol[x].affinity; |
| 91916 | 92860 | } |
| 91917 | | - pIdx->zColAff[n++] = SQLITE_AFF_INTEGER; |
| 91918 | 92861 | pIdx->zColAff[n] = 0; |
| 91919 | 92862 | } |
| 91920 | 92863 | |
| 91921 | 92864 | return pIdx->zColAff; |
| 91922 | 92865 | } |
| | @@ -92258,11 +93201,11 @@ |
| 92258 | 93201 | int onError, /* How to handle constraint errors */ |
| 92259 | 93202 | int iDbDest /* The database of pDest */ |
| 92260 | 93203 | ); |
| 92261 | 93204 | |
| 92262 | 93205 | /* |
| 92263 | | -** This routine is call to handle SQL of the following forms: |
| 93206 | +** This routine is called to handle SQL of the following forms: |
| 92264 | 93207 | ** |
| 92265 | 93208 | ** insert into TABLE (IDLIST) values(EXPRLIST) |
| 92266 | 93209 | ** insert into TABLE (IDLIST) select |
| 92267 | 93210 | ** |
| 92268 | 93211 | ** The IDLIST following the table name is always optional. If omitted, |
| | @@ -92273,16 +93216,16 @@ |
| 92273 | 93216 | ** statement above, and pSelect is NULL. For the second form, pList is |
| 92274 | 93217 | ** NULL and pSelect is a pointer to the select statement used to generate |
| 92275 | 93218 | ** data for the insert. |
| 92276 | 93219 | ** |
| 92277 | 93220 | ** The code generated follows one of four templates. For a simple |
| 92278 | | -** select with data coming from a VALUES clause, the code executes |
| 93221 | +** insert with data coming from a VALUES clause, the code executes |
| 92279 | 93222 | ** once straight down through. Pseudo-code follows (we call this |
| 92280 | 93223 | ** the "1st template"): |
| 92281 | 93224 | ** |
| 92282 | 93225 | ** open write cursor to <table> and its indices |
| 92283 | | -** puts VALUES clause expressions onto the stack |
| 93226 | +** put VALUES clause expressions into registers |
| 92284 | 93227 | ** write the resulting record into <table> |
| 92285 | 93228 | ** cleanup |
| 92286 | 93229 | ** |
| 92287 | 93230 | ** The three remaining templates assume the statement is of the form |
| 92288 | 93231 | ** |
| | @@ -92376,12 +93319,13 @@ |
| 92376 | 93319 | int i, j, idx; /* Loop counters */ |
| 92377 | 93320 | Vdbe *v; /* Generate code into this virtual machine */ |
| 92378 | 93321 | Index *pIdx; /* For looping over indices of the table */ |
| 92379 | 93322 | int nColumn; /* Number of columns in the data */ |
| 92380 | 93323 | int nHidden = 0; /* Number of hidden columns if TABLE is virtual */ |
| 92381 | | - int baseCur = 0; /* VDBE Cursor number for pTab */ |
| 92382 | | - int keyColumn = -1; /* Column that is the INTEGER PRIMARY KEY */ |
| 93324 | + int iDataCur = 0; /* VDBE cursor that is the main data repository */ |
| 93325 | + int iIdxCur = 0; /* First index cursor */ |
| 93326 | + int ipkColumn = -1; /* Column that is the INTEGER PRIMARY KEY */ |
| 92383 | 93327 | int endOfLoop; /* Label for the end of the insertion loop */ |
| 92384 | 93328 | int useTempTable = 0; /* Store SELECT results in intermediate table */ |
| 92385 | 93329 | int srcTab = 0; /* Data comes from this temporary cursor if >=0 */ |
| 92386 | 93330 | int addrInsTop = 0; /* Jump to label "D" */ |
| 92387 | 93331 | int addrCont = 0; /* Top of insert loop. Label "C" in templates 3 and 4 */ |
| | @@ -92388,10 +93332,11 @@ |
| 92388 | 93332 | int addrSelect = 0; /* Address of coroutine that implements the SELECT */ |
| 92389 | 93333 | SelectDest dest; /* Destination for SELECT on rhs of INSERT */ |
| 92390 | 93334 | int iDb; /* Index of database holding TABLE */ |
| 92391 | 93335 | Db *pDb; /* The database containing table being inserted into */ |
| 92392 | 93336 | int appendFlag = 0; /* True if the insert is likely to be an append */ |
| 93337 | + int withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */ |
| 92393 | 93338 | |
| 92394 | 93339 | /* Register allocations */ |
| 92395 | 93340 | int regFromSelect = 0;/* Base register for data coming from SELECT */ |
| 92396 | 93341 | int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */ |
| 92397 | 93342 | int regRowCount = 0; /* Memory cell used for the row counter */ |
| | @@ -92427,10 +93372,11 @@ |
| 92427 | 93372 | pDb = &db->aDb[iDb]; |
| 92428 | 93373 | zDb = pDb->zName; |
| 92429 | 93374 | if( sqlite3AuthCheck(pParse, SQLITE_INSERT, pTab->zName, 0, zDb) ){ |
| 92430 | 93375 | goto insert_cleanup; |
| 92431 | 93376 | } |
| 93377 | + withoutRowid = !HasRowid(pTab); |
| 92432 | 93378 | |
| 92433 | 93379 | /* Figure out if we have any triggers and if the table being |
| 92434 | 93380 | ** inserted into is a view |
| 92435 | 93381 | */ |
| 92436 | 93382 | #ifndef SQLITE_OMIT_TRIGGER |
| | @@ -92446,20 +93392,17 @@ |
| 92446 | 93392 | # define isView 0 |
| 92447 | 93393 | #endif |
| 92448 | 93394 | assert( (pTrigger && tmask) || (pTrigger==0 && tmask==0) ); |
| 92449 | 93395 | |
| 92450 | 93396 | /* If pTab is really a view, make sure it has been initialized. |
| 92451 | | - ** ViewGetColumnNames() is a no-op if pTab is not a view (or virtual |
| 92452 | | - ** module table). |
| 93397 | + ** ViewGetColumnNames() is a no-op if pTab is not a view. |
| 92453 | 93398 | */ |
| 92454 | 93399 | if( sqlite3ViewGetColumnNames(pParse, pTab) ){ |
| 92455 | 93400 | goto insert_cleanup; |
| 92456 | 93401 | } |
| 92457 | 93402 | |
| 92458 | | - /* Ensure that: |
| 92459 | | - * (a) the table is not read-only, |
| 92460 | | - * (b) that if it is a view then ON INSERT triggers exist |
| 93403 | + /* Cannot insert into a read-only table. |
| 92461 | 93404 | */ |
| 92462 | 93405 | if( sqlite3IsReadOnly(pParse, pTab, tmask) ){ |
| 92463 | 93406 | goto insert_cleanup; |
| 92464 | 93407 | } |
| 92465 | 93408 | |
| | @@ -92496,12 +93439,11 @@ |
| 92496 | 93439 | ** is coming from a SELECT statement, then generate a co-routine that |
| 92497 | 93440 | ** produces a single row of the SELECT on each invocation. The |
| 92498 | 93441 | ** co-routine is the common header to the 3rd and 4th templates. |
| 92499 | 93442 | */ |
| 92500 | 93443 | if( pSelect ){ |
| 92501 | | - /* Data is coming from a SELECT. Generate a co-routine to run that |
| 92502 | | - ** SELECT. */ |
| 93444 | + /* Data is coming from a SELECT. Generate a co-routine to run the SELECT */ |
| 92503 | 93445 | int rc = sqlite3CodeCoroutine(pParse, pSelect, &dest); |
| 92504 | 93446 | if( rc ) goto insert_cleanup; |
| 92505 | 93447 | |
| 92506 | 93448 | regEof = dest.iSDParm + 1; |
| 92507 | 93449 | regFromSelect = dest.iSdst; |
| | @@ -92509,11 +93451,11 @@ |
| 92509 | 93451 | nColumn = pSelect->pEList->nExpr; |
| 92510 | 93452 | assert( dest.nSdst==nColumn ); |
| 92511 | 93453 | |
| 92512 | 93454 | /* Set useTempTable to TRUE if the result of the SELECT statement |
| 92513 | 93455 | ** should be written into a temporary table (template 4). Set to |
| 92514 | | - ** FALSE if each* row of the SELECT can be written directly into |
| 93456 | + ** FALSE if each output row of the SELECT can be written directly into |
| 92515 | 93457 | ** the destination table (template 3). |
| 92516 | 93458 | ** |
| 92517 | 93459 | ** A temp table must be used if the table being updated is also one |
| 92518 | 93460 | ** of the tables being read by the SELECT statement. Also use a |
| 92519 | 93461 | ** temp table in the case of row triggers. |
| | @@ -92592,15 +93534,15 @@ |
| 92592 | 93534 | /* If the INSERT statement included an IDLIST term, then make sure |
| 92593 | 93535 | ** all elements of the IDLIST really are columns of the table and |
| 92594 | 93536 | ** remember the column indices. |
| 92595 | 93537 | ** |
| 92596 | 93538 | ** If the table has an INTEGER PRIMARY KEY column and that column |
| 92597 | | - ** is named in the IDLIST, then record in the keyColumn variable |
| 92598 | | - ** the index into IDLIST of the primary key column. keyColumn is |
| 93539 | + ** is named in the IDLIST, then record in the ipkColumn variable |
| 93540 | + ** the index into IDLIST of the primary key column. ipkColumn is |
| 92599 | 93541 | ** the index of the primary key as it appears in IDLIST, not as |
| 92600 | | - ** is appears in the original table. (The index of the primary |
| 92601 | | - ** key in the original table is pTab->iPKey.) |
| 93542 | + ** is appears in the original table. (The index of the INTEGER |
| 93543 | + ** PRIMARY KEY in the original table is pTab->iPKey.) |
| 92602 | 93544 | */ |
| 92603 | 93545 | if( pColumn ){ |
| 92604 | 93546 | for(i=0; i<pColumn->nId; i++){ |
| 92605 | 93547 | pColumn->a[i].idx = -1; |
| 92606 | 93548 | } |
| | @@ -92607,18 +93549,18 @@ |
| 92607 | 93549 | for(i=0; i<pColumn->nId; i++){ |
| 92608 | 93550 | for(j=0; j<pTab->nCol; j++){ |
| 92609 | 93551 | if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){ |
| 92610 | 93552 | pColumn->a[i].idx = j; |
| 92611 | 93553 | if( j==pTab->iPKey ){ |
| 92612 | | - keyColumn = i; |
| 93554 | + ipkColumn = i; assert( !withoutRowid ); |
| 92613 | 93555 | } |
| 92614 | 93556 | break; |
| 92615 | 93557 | } |
| 92616 | 93558 | } |
| 92617 | 93559 | if( j>=pTab->nCol ){ |
| 92618 | | - if( sqlite3IsRowid(pColumn->a[i].zName) ){ |
| 92619 | | - keyColumn = i; |
| 93560 | + if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){ |
| 93561 | + ipkColumn = i; |
| 92620 | 93562 | }else{ |
| 92621 | 93563 | sqlite3ErrorMsg(pParse, "table %S has no column named %s", |
| 92622 | 93564 | pTabList, 0, pColumn->a[i].zName); |
| 92623 | 93565 | pParse->checkSchema = 1; |
| 92624 | 93566 | goto insert_cleanup; |
| | @@ -92626,15 +93568,15 @@ |
| 92626 | 93568 | } |
| 92627 | 93569 | } |
| 92628 | 93570 | } |
| 92629 | 93571 | |
| 92630 | 93572 | /* If there is no IDLIST term but the table has an integer primary |
| 92631 | | - ** key, the set the keyColumn variable to the primary key column index |
| 92632 | | - ** in the original table definition. |
| 93573 | + ** key, the set the ipkColumn variable to the integer primary key |
| 93574 | + ** column index in the original table definition. |
| 92633 | 93575 | */ |
| 92634 | 93576 | if( pColumn==0 && nColumn>0 ){ |
| 92635 | | - keyColumn = pTab->iPKey; |
| 93577 | + ipkColumn = pTab->iPKey; |
| 92636 | 93578 | } |
| 92637 | 93579 | |
| 92638 | 93580 | /* Initialize the count of rows to be inserted |
| 92639 | 93581 | */ |
| 92640 | 93582 | if( db->flags & SQLITE_CountRows ){ |
| | @@ -92643,13 +93585,12 @@ |
| 92643 | 93585 | } |
| 92644 | 93586 | |
| 92645 | 93587 | /* If this is not a view, open the table and and all indices */ |
| 92646 | 93588 | if( !isView ){ |
| 92647 | 93589 | int nIdx; |
| 92648 | | - |
| 92649 | | - baseCur = pParse->nTab; |
| 92650 | | - nIdx = sqlite3OpenTableAndIndices(pParse, pTab, baseCur, OP_OpenWrite); |
| 93590 | + nIdx = sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, -1, |
| 93591 | + &iDataCur, &iIdxCur); |
| 92651 | 93592 | aRegIdx = sqlite3DbMallocRaw(db, sizeof(int)*(nIdx+1)); |
| 92652 | 93593 | if( aRegIdx==0 ){ |
| 92653 | 93594 | goto insert_cleanup; |
| 92654 | 93595 | } |
| 92655 | 93596 | for(i=0; i<nIdx; i++){ |
| | @@ -92705,19 +93646,20 @@ |
| 92705 | 93646 | ** PRIMARY KEY into which a NULL is being inserted, that NULL will be |
| 92706 | 93647 | ** translated into a unique ID for the row. But on a BEFORE trigger, |
| 92707 | 93648 | ** we do not know what the unique ID will be (because the insert has |
| 92708 | 93649 | ** not happened yet) so we substitute a rowid of -1 |
| 92709 | 93650 | */ |
| 92710 | | - if( keyColumn<0 ){ |
| 93651 | + if( ipkColumn<0 ){ |
| 92711 | 93652 | sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols); |
| 92712 | 93653 | }else{ |
| 92713 | 93654 | int j1; |
| 93655 | + assert( !withoutRowid ); |
| 92714 | 93656 | if( useTempTable ){ |
| 92715 | | - sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regCols); |
| 93657 | + sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regCols); |
| 92716 | 93658 | }else{ |
| 92717 | 93659 | assert( pSelect==0 ); /* Otherwise useTempTable is true */ |
| 92718 | | - sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regCols); |
| 93660 | + sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regCols); |
| 92719 | 93661 | } |
| 92720 | 93662 | j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regCols); |
| 92721 | 93663 | sqlite3VdbeAddOp2(v, OP_Integer, -1, regCols); |
| 92722 | 93664 | sqlite3VdbeJumpHere(v, j1); |
| 92723 | 93665 | sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); |
| | @@ -92763,33 +93705,31 @@ |
| 92763 | 93705 | pTab, regCols-pTab->nCol-1, onError, endOfLoop); |
| 92764 | 93706 | |
| 92765 | 93707 | sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1); |
| 92766 | 93708 | } |
| 92767 | 93709 | |
| 92768 | | - /* Push the record number for the new entry onto the stack. The |
| 92769 | | - ** record number is a randomly generate integer created by NewRowid |
| 92770 | | - ** except when the table has an INTEGER PRIMARY KEY column, in which |
| 92771 | | - ** case the record number is the same as that column. |
| 93710 | + /* Compute the content of the next row to insert into a range of |
| 93711 | + ** registers beginning at regIns. |
| 92772 | 93712 | */ |
| 92773 | 93713 | if( !isView ){ |
| 92774 | 93714 | if( IsVirtual(pTab) ){ |
| 92775 | 93715 | /* The row that the VUpdate opcode will delete: none */ |
| 92776 | 93716 | sqlite3VdbeAddOp2(v, OP_Null, 0, regIns); |
| 92777 | 93717 | } |
| 92778 | | - if( keyColumn>=0 ){ |
| 93718 | + if( ipkColumn>=0 ){ |
| 92779 | 93719 | if( useTempTable ){ |
| 92780 | | - sqlite3VdbeAddOp3(v, OP_Column, srcTab, keyColumn, regRowid); |
| 93720 | + sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid); |
| 92781 | 93721 | }else if( pSelect ){ |
| 92782 | | - sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+keyColumn, regRowid); |
| 93722 | + sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+ipkColumn, regRowid); |
| 92783 | 93723 | }else{ |
| 92784 | 93724 | VdbeOp *pOp; |
| 92785 | | - sqlite3ExprCode(pParse, pList->a[keyColumn].pExpr, regRowid); |
| 93725 | + sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid); |
| 92786 | 93726 | pOp = sqlite3VdbeGetOp(v, -1); |
| 92787 | 93727 | if( ALWAYS(pOp) && pOp->opcode==OP_Null && !IsVirtual(pTab) ){ |
| 92788 | 93728 | appendFlag = 1; |
| 92789 | 93729 | pOp->opcode = OP_NewRowid; |
| 92790 | | - pOp->p1 = baseCur; |
| 93730 | + pOp->p1 = iDataCur; |
| 92791 | 93731 | pOp->p2 = regRowid; |
| 92792 | 93732 | pOp->p3 = regAutoinc; |
| 92793 | 93733 | } |
| 92794 | 93734 | } |
| 92795 | 93735 | /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid |
| | @@ -92797,36 +93737,36 @@ |
| 92797 | 93737 | */ |
| 92798 | 93738 | if( !appendFlag ){ |
| 92799 | 93739 | int j1; |
| 92800 | 93740 | if( !IsVirtual(pTab) ){ |
| 92801 | 93741 | j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regRowid); |
| 92802 | | - sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc); |
| 93742 | + sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc); |
| 92803 | 93743 | sqlite3VdbeJumpHere(v, j1); |
| 92804 | 93744 | }else{ |
| 92805 | 93745 | j1 = sqlite3VdbeCurrentAddr(v); |
| 92806 | 93746 | sqlite3VdbeAddOp2(v, OP_IsNull, regRowid, j1+2); |
| 92807 | 93747 | } |
| 92808 | 93748 | sqlite3VdbeAddOp1(v, OP_MustBeInt, regRowid); |
| 92809 | 93749 | } |
| 92810 | | - }else if( IsVirtual(pTab) ){ |
| 93750 | + }else if( IsVirtual(pTab) || withoutRowid ){ |
| 92811 | 93751 | sqlite3VdbeAddOp2(v, OP_Null, 0, regRowid); |
| 92812 | 93752 | }else{ |
| 92813 | | - sqlite3VdbeAddOp3(v, OP_NewRowid, baseCur, regRowid, regAutoinc); |
| 93753 | + sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc); |
| 92814 | 93754 | appendFlag = 1; |
| 92815 | 93755 | } |
| 92816 | 93756 | autoIncStep(pParse, regAutoinc, regRowid); |
| 92817 | 93757 | |
| 92818 | | - /* Push onto the stack, data for all columns of the new entry, beginning |
| 93758 | + /* Compute data for all columns of the new entry, beginning |
| 92819 | 93759 | ** with the first column. |
| 92820 | 93760 | */ |
| 92821 | 93761 | nHidden = 0; |
| 92822 | 93762 | for(i=0; i<pTab->nCol; i++){ |
| 92823 | 93763 | int iRegStore = regRowid+1+i; |
| 92824 | 93764 | if( i==pTab->iPKey ){ |
| 92825 | 93765 | /* The value of the INTEGER PRIMARY KEY column is always a NULL. |
| 92826 | | - ** Whenever this column is read, the record number will be substituted |
| 92827 | | - ** in its place. So will fill this column with a NULL to avoid |
| 93766 | + ** Whenever this column is read, the rowid will be substituted |
| 93767 | + ** in its place. Hence, fill this column with a NULL to avoid |
| 92828 | 93768 | ** taking up data space with information that will never be used. */ |
| 92829 | 93769 | sqlite3VdbeAddOp2(v, OP_Null, 0, iRegStore); |
| 92830 | 93770 | continue; |
| 92831 | 93771 | } |
| 92832 | 93772 | if( pColumn==0 ){ |
| | @@ -92865,17 +93805,16 @@ |
| 92865 | 93805 | sqlite3MayAbort(pParse); |
| 92866 | 93806 | }else |
| 92867 | 93807 | #endif |
| 92868 | 93808 | { |
| 92869 | 93809 | int isReplace; /* Set to true if constraints may cause a replace */ |
| 92870 | | - sqlite3GenerateConstraintChecks(pParse, pTab, baseCur, regIns, aRegIdx, |
| 92871 | | - keyColumn>=0, 0, onError, endOfLoop, &isReplace |
| 93810 | + sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, |
| 93811 | + regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace |
| 92872 | 93812 | ); |
| 92873 | 93813 | sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0); |
| 92874 | | - sqlite3CompleteInsertion( |
| 92875 | | - pParse, pTab, baseCur, regIns, aRegIdx, 0, appendFlag, isReplace==0 |
| 92876 | | - ); |
| 93814 | + sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur, |
| 93815 | + regIns, aRegIdx, 0, appendFlag, isReplace==0); |
| 92877 | 93816 | } |
| 92878 | 93817 | } |
| 92879 | 93818 | |
| 92880 | 93819 | /* Update the count of rows that are inserted |
| 92881 | 93820 | */ |
| | @@ -92902,13 +93841,13 @@ |
| 92902 | 93841 | sqlite3VdbeJumpHere(v, addrInsTop); |
| 92903 | 93842 | } |
| 92904 | 93843 | |
| 92905 | 93844 | if( !IsVirtual(pTab) && !isView ){ |
| 92906 | 93845 | /* Close all tables opened */ |
| 92907 | | - sqlite3VdbeAddOp1(v, OP_Close, baseCur); |
| 92908 | | - for(idx=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){ |
| 92909 | | - sqlite3VdbeAddOp1(v, OP_Close, idx+baseCur); |
| 93846 | + if( iDataCur<iIdxCur ) sqlite3VdbeAddOp1(v, OP_Close, iDataCur); |
| 93847 | + for(idx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, idx++){ |
| 93848 | + sqlite3VdbeAddOp1(v, OP_Close, idx+iIdxCur); |
| 92910 | 93849 | } |
| 92911 | 93850 | } |
| 92912 | 93851 | |
| 92913 | 93852 | insert_end: |
| 92914 | 93853 | /* Update the sqlite_sequence table by storing the content of the |
| | @@ -92949,65 +93888,78 @@ |
| 92949 | 93888 | #endif |
| 92950 | 93889 | #ifdef tmask |
| 92951 | 93890 | #undef tmask |
| 92952 | 93891 | #endif |
| 92953 | 93892 | |
| 92954 | | - |
| 92955 | 93893 | /* |
| 92956 | | -** Generate code to do constraint checks prior to an INSERT or an UPDATE. |
| 92957 | | -** |
| 92958 | | -** The input is a range of consecutive registers as follows: |
| 92959 | | -** |
| 92960 | | -** 1. The rowid of the row after the update. |
| 92961 | | -** |
| 92962 | | -** 2. The data in the first column of the entry after the update. |
| 92963 | | -** |
| 92964 | | -** i. Data from middle columns... |
| 92965 | | -** |
| 92966 | | -** N. The data in the last column of the entry after the update. |
| 92967 | | -** |
| 92968 | | -** The regRowid parameter is the index of the register containing (1). |
| 92969 | | -** |
| 92970 | | -** If isUpdate is true and rowidChng is non-zero, then rowidChng contains |
| 92971 | | -** the address of a register containing the rowid before the update takes |
| 92972 | | -** place. isUpdate is true for UPDATEs and false for INSERTs. If isUpdate |
| 92973 | | -** is false, indicating an INSERT statement, then a non-zero rowidChng |
| 92974 | | -** indicates that the rowid was explicitly specified as part of the |
| 92975 | | -** INSERT statement. If rowidChng is false, it means that the rowid is |
| 92976 | | -** computed automatically in an insert or that the rowid value is not |
| 92977 | | -** modified by an update. |
| 92978 | | -** |
| 92979 | | -** The code generated by this routine store new index entries into |
| 93894 | +** Generate code to do constraint checks prior to an INSERT or an UPDATE |
| 93895 | +** on table pTab. |
| 93896 | +** |
| 93897 | +** The regNewData parameter is the first register in a range that contains |
| 93898 | +** the data to be inserted or the data after the update. There will be |
| 93899 | +** pTab->nCol+1 registers in this range. The first register (the one |
| 93900 | +** that regNewData points to) will contain the new rowid, or NULL in the |
| 93901 | +** case of a WITHOUT ROWID table. The second register in the range will |
| 93902 | +** contain the content of the first table column. The third register will |
| 93903 | +** contain the content of the second table column. And so forth. |
| 93904 | +** |
| 93905 | +** The regOldData parameter is similar to regNewData except that it contains |
| 93906 | +** the data prior to an UPDATE rather than afterwards. regOldData is zero |
| 93907 | +** for an INSERT. This routine can distinguish between UPDATE and INSERT by |
| 93908 | +** checking regOldData for zero. |
| 93909 | +** |
| 93910 | +** For an UPDATE, the pkChng boolean is true if the true primary key (the |
| 93911 | +** rowid for a normal table or the PRIMARY KEY for a WITHOUT ROWID table) |
| 93912 | +** might be modified by the UPDATE. If pkChng is false, then the key of |
| 93913 | +** the iDataCur content table is guaranteed to be unchanged by the UPDATE. |
| 93914 | +** |
| 93915 | +** For an INSERT, the pkChng boolean indicates whether or not the rowid |
| 93916 | +** was explicitly specified as part of the INSERT statement. If pkChng |
| 93917 | +** is zero, it means that the either rowid is computed automatically or |
| 93918 | +** that the table is a WITHOUT ROWID table and has no rowid. On an INSERT, |
| 93919 | +** pkChng will only be true if the INSERT statement provides an integer |
| 93920 | +** value for either the rowid column or its INTEGER PRIMARY KEY alias. |
| 93921 | +** |
| 93922 | +** The code generated by this routine will store new index entries into |
| 92980 | 93923 | ** registers identified by aRegIdx[]. No index entry is created for |
| 92981 | 93924 | ** indices where aRegIdx[i]==0. The order of indices in aRegIdx[] is |
| 92982 | 93925 | ** the same as the order of indices on the linked list of indices |
| 92983 | | -** attached to the table. |
| 93926 | +** at pTab->pIndex. |
| 93927 | +** |
| 93928 | +** The caller must have already opened writeable cursors on the main |
| 93929 | +** table and all applicable indices (that is to say, all indices for which |
| 93930 | +** aRegIdx[] is not zero). iDataCur is the cursor for the main table when |
| 93931 | +** inserting or updating a rowid table, or the cursor for the PRIMARY KEY |
| 93932 | +** index when operating on a WITHOUT ROWID table. iIdxCur is the cursor |
| 93933 | +** for the first index in the pTab->pIndex list. Cursors for other indices |
| 93934 | +** are at iIdxCur+N for the N-th element of the pTab->pIndex list. |
| 92984 | 93935 | ** |
| 92985 | 93936 | ** This routine also generates code to check constraints. NOT NULL, |
| 92986 | 93937 | ** CHECK, and UNIQUE constraints are all checked. If a constraint fails, |
| 92987 | 93938 | ** then the appropriate action is performed. There are five possible |
| 92988 | 93939 | ** actions: ROLLBACK, ABORT, FAIL, REPLACE, and IGNORE. |
| 92989 | 93940 | ** |
| 92990 | 93941 | ** Constraint type Action What Happens |
| 92991 | 93942 | ** --------------- ---------- ---------------------------------------- |
| 92992 | 93943 | ** any ROLLBACK The current transaction is rolled back and |
| 92993 | | -** sqlite3_exec() returns immediately with a |
| 93944 | +** sqlite3_step() returns immediately with a |
| 92994 | 93945 | ** return code of SQLITE_CONSTRAINT. |
| 92995 | 93946 | ** |
| 92996 | 93947 | ** any ABORT Back out changes from the current command |
| 92997 | 93948 | ** only (do not do a complete rollback) then |
| 92998 | | -** cause sqlite3_exec() to return immediately |
| 93949 | +** cause sqlite3_step() to return immediately |
| 92999 | 93950 | ** with SQLITE_CONSTRAINT. |
| 93000 | 93951 | ** |
| 93001 | | -** any FAIL Sqlite3_exec() returns immediately with a |
| 93952 | +** any FAIL Sqlite3_step() returns immediately with a |
| 93002 | 93953 | ** return code of SQLITE_CONSTRAINT. The |
| 93003 | 93954 | ** transaction is not rolled back and any |
| 93004 | | -** prior changes are retained. |
| 93955 | +** changes to prior rows are retained. |
| 93005 | 93956 | ** |
| 93006 | | -** any IGNORE The record number and data is popped from |
| 93007 | | -** the stack and there is an immediate jump |
| 93008 | | -** to label ignoreDest. |
| 93957 | +** any IGNORE The attempt in insert or update the current |
| 93958 | +** row is skipped, without throwing an error. |
| 93959 | +** Processing continues with the next row. |
| 93960 | +** (There is an immediate jump to ignoreDest.) |
| 93009 | 93961 | ** |
| 93010 | 93962 | ** NOT NULL REPLACE The NULL value is replace by the default |
| 93011 | 93963 | ** value for that column. If the default value |
| 93012 | 93964 | ** is NULL, the action is the same as ABORT. |
| 93013 | 93965 | ** |
| | @@ -93018,48 +93970,61 @@ |
| 93018 | 93970 | ** |
| 93019 | 93971 | ** Which action to take is determined by the overrideError parameter. |
| 93020 | 93972 | ** Or if overrideError==OE_Default, then the pParse->onError parameter |
| 93021 | 93973 | ** is used. Or if pParse->onError==OE_Default then the onError value |
| 93022 | 93974 | ** for the constraint is used. |
| 93023 | | -** |
| 93024 | | -** The calling routine must open a read/write cursor for pTab with |
| 93025 | | -** cursor number "baseCur". All indices of pTab must also have open |
| 93026 | | -** read/write cursors with cursor number baseCur+i for the i-th cursor. |
| 93027 | | -** Except, if there is no possibility of a REPLACE action then |
| 93028 | | -** cursors do not need to be open for indices where aRegIdx[i]==0. |
| 93029 | 93975 | */ |
| 93030 | 93976 | SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( |
| 93031 | | - Parse *pParse, /* The parser context */ |
| 93032 | | - Table *pTab, /* the table into which we are inserting */ |
| 93033 | | - int baseCur, /* Index of a read/write cursor pointing at pTab */ |
| 93034 | | - int regRowid, /* Index of the range of input registers */ |
| 93035 | | - int *aRegIdx, /* Register used by each index. 0 for unused indices */ |
| 93036 | | - int rowidChng, /* True if the rowid might collide with existing entry */ |
| 93037 | | - int isUpdate, /* True for UPDATE, False for INSERT */ |
| 93038 | | - int overrideError, /* Override onError to this if not OE_Default */ |
| 93039 | | - int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ |
| 93040 | | - int *pbMayReplace /* OUT: Set to true if constraint may cause a replace */ |
| 93977 | + Parse *pParse, /* The parser context */ |
| 93978 | + Table *pTab, /* The table being inserted or updated */ |
| 93979 | + int *aRegIdx, /* Use register aRegIdx[i] for index i. 0 for unused */ |
| 93980 | + int iDataCur, /* Canonical data cursor (main table or PK index) */ |
| 93981 | + int iIdxCur, /* First index cursor */ |
| 93982 | + int regNewData, /* First register in a range holding values to insert */ |
| 93983 | + int regOldData, /* Previous content. 0 for INSERTs */ |
| 93984 | + u8 pkChng, /* Non-zero if the rowid or PRIMARY KEY changed */ |
| 93985 | + u8 overrideError, /* Override onError to this if not OE_Default */ |
| 93986 | + int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ |
| 93987 | + int *pbMayReplace /* OUT: Set to true if constraint may cause a replace */ |
| 93041 | 93988 | ){ |
| 93042 | | - int i; /* loop counter */ |
| 93043 | | - Vdbe *v; /* VDBE under constrution */ |
| 93044 | | - int nCol; /* Number of columns */ |
| 93045 | | - int onError; /* Conflict resolution strategy */ |
| 93046 | | - int j1; /* Addresss of jump instruction */ |
| 93047 | | - int j2 = 0, j3; /* Addresses of jump instructions */ |
| 93048 | | - int regData; /* Register containing first data column */ |
| 93049 | | - int iCur; /* Table cursor number */ |
| 93989 | + Vdbe *v; /* VDBE under constrution */ |
| 93050 | 93990 | Index *pIdx; /* Pointer to one of the indices */ |
| 93991 | + Index *pPk = 0; /* The PRIMARY KEY index */ |
| 93051 | 93992 | sqlite3 *db; /* Database connection */ |
| 93993 | + int i; /* loop counter */ |
| 93994 | + int ix; /* Index loop counter */ |
| 93995 | + int nCol; /* Number of columns */ |
| 93996 | + int onError; /* Conflict resolution strategy */ |
| 93997 | + int j1; /* Addresss of jump instruction */ |
| 93052 | 93998 | int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */ |
| 93053 | | - int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid; |
| 93999 | + int nPkField; /* Number of fields in PRIMARY KEY. 1 for ROWID tables */ |
| 94000 | + int ipkTop = 0; /* Top of the rowid change constraint check */ |
| 94001 | + int ipkBottom = 0; /* Bottom of the rowid change constraint check */ |
| 94002 | + u8 isUpdate; /* True if this is an UPDATE operation */ |
| 93054 | 94003 | |
| 94004 | + isUpdate = regOldData!=0; |
| 93055 | 94005 | db = pParse->db; |
| 93056 | 94006 | v = sqlite3GetVdbe(pParse); |
| 93057 | 94007 | assert( v!=0 ); |
| 93058 | 94008 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ |
| 93059 | 94009 | nCol = pTab->nCol; |
| 93060 | | - regData = regRowid + 1; |
| 94010 | + |
| 94011 | + /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for |
| 94012 | + ** normal rowid tables. nPkField is the number of key fields in the |
| 94013 | + ** pPk index or 1 for a rowid table. In other words, nPkField is the |
| 94014 | + ** number of fields in the true primary key of the table. */ |
| 94015 | + if( HasRowid(pTab) ){ |
| 94016 | + pPk = 0; |
| 94017 | + nPkField = 1; |
| 94018 | + }else{ |
| 94019 | + pPk = sqlite3PrimaryKeyIndex(pTab); |
| 94020 | + nPkField = pPk->nKeyCol; |
| 94021 | + } |
| 94022 | + |
| 94023 | + /* Record that this module has started */ |
| 94024 | + VdbeModuleComment((v, "BEGIN: GenCnstCks(%d,%d,%d,%d,%d)", |
| 94025 | + iDataCur, iIdxCur, regNewData, regOldData, pkChng)); |
| 93061 | 94026 | |
| 93062 | 94027 | /* Test all NOT NULL constraints. |
| 93063 | 94028 | */ |
| 93064 | 94029 | for(i=0; i<nCol; i++){ |
| 93065 | 94030 | if( i==pTab->iPKey ){ |
| | @@ -93078,28 +94043,28 @@ |
| 93078 | 94043 | assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail |
| 93079 | 94044 | || onError==OE_Ignore || onError==OE_Replace ); |
| 93080 | 94045 | switch( onError ){ |
| 93081 | 94046 | case OE_Abort: |
| 93082 | 94047 | sqlite3MayAbort(pParse); |
| 94048 | + /* Fall through */ |
| 93083 | 94049 | case OE_Rollback: |
| 93084 | 94050 | case OE_Fail: { |
| 93085 | | - char *zMsg; |
| 93086 | | - sqlite3VdbeAddOp3(v, OP_HaltIfNull, |
| 93087 | | - SQLITE_CONSTRAINT_NOTNULL, onError, regData+i); |
| 93088 | | - zMsg = sqlite3MPrintf(db, "%s.%s may not be NULL", |
| 93089 | | - pTab->zName, pTab->aCol[i].zName); |
| 93090 | | - sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC); |
| 94051 | + char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName, |
| 94052 | + pTab->aCol[i].zName); |
| 94053 | + sqlite3VdbeAddOp4(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError, |
| 94054 | + regNewData+1+i, zMsg, P4_DYNAMIC); |
| 94055 | + sqlite3VdbeChangeP5(v, P5_ConstraintNotNull); |
| 93091 | 94056 | break; |
| 93092 | 94057 | } |
| 93093 | 94058 | case OE_Ignore: { |
| 93094 | | - sqlite3VdbeAddOp2(v, OP_IsNull, regData+i, ignoreDest); |
| 94059 | + sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest); |
| 93095 | 94060 | break; |
| 93096 | 94061 | } |
| 93097 | 94062 | default: { |
| 93098 | 94063 | assert( onError==OE_Replace ); |
| 93099 | | - j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regData+i); |
| 93100 | | - sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regData+i); |
| 94064 | + j1 = sqlite3VdbeAddOp1(v, OP_NotNull, regNewData+1+i); |
| 94065 | + sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i); |
| 93101 | 94066 | sqlite3VdbeJumpHere(v, j1); |
| 93102 | 94067 | break; |
| 93103 | 94068 | } |
| 93104 | 94069 | } |
| 93105 | 94070 | } |
| | @@ -93107,59 +94072,79 @@ |
| 93107 | 94072 | /* Test all CHECK constraints |
| 93108 | 94073 | */ |
| 93109 | 94074 | #ifndef SQLITE_OMIT_CHECK |
| 93110 | 94075 | if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 93111 | 94076 | ExprList *pCheck = pTab->pCheck; |
| 93112 | | - pParse->ckBase = regData; |
| 94077 | + pParse->ckBase = regNewData+1; |
| 93113 | 94078 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 93114 | 94079 | for(i=0; i<pCheck->nExpr; i++){ |
| 93115 | 94080 | int allOk = sqlite3VdbeMakeLabel(v); |
| 93116 | 94081 | sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL); |
| 93117 | 94082 | if( onError==OE_Ignore ){ |
| 93118 | 94083 | sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 93119 | 94084 | }else{ |
| 93120 | | - char *zConsName = pCheck->a[i].zName; |
| 94085 | + char *zName = pCheck->a[i].zName; |
| 94086 | + if( zName==0 ) zName = pTab->zName; |
| 93121 | 94087 | if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */ |
| 93122 | | - if( zConsName ){ |
| 93123 | | - zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName); |
| 93124 | | - }else{ |
| 93125 | | - zConsName = 0; |
| 93126 | | - } |
| 93127 | 94088 | sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK, |
| 93128 | | - onError, zConsName, P4_DYNAMIC); |
| 94089 | + onError, zName, P4_TRANSIENT, |
| 94090 | + P5_ConstraintCheck); |
| 93129 | 94091 | } |
| 93130 | 94092 | sqlite3VdbeResolveLabel(v, allOk); |
| 93131 | 94093 | } |
| 93132 | 94094 | } |
| 93133 | 94095 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 93134 | 94096 | |
| 93135 | | - /* If we have an INTEGER PRIMARY KEY, make sure the primary key |
| 93136 | | - ** of the new record does not previously exist. Except, if this |
| 93137 | | - ** is an UPDATE and the primary key is not changing, that is OK. |
| 94097 | + /* If rowid is changing, make sure the new rowid does not previously |
| 94098 | + ** exist in the table. |
| 93138 | 94099 | */ |
| 93139 | | - if( rowidChng ){ |
| 94100 | + if( pkChng && pPk==0 ){ |
| 94101 | + int addrRowidOk = sqlite3VdbeMakeLabel(v); |
| 94102 | + |
| 94103 | + /* Figure out what action to take in case of a rowid collision */ |
| 93140 | 94104 | onError = pTab->keyConf; |
| 93141 | 94105 | if( overrideError!=OE_Default ){ |
| 93142 | 94106 | onError = overrideError; |
| 93143 | 94107 | }else if( onError==OE_Default ){ |
| 93144 | 94108 | onError = OE_Abort; |
| 93145 | 94109 | } |
| 93146 | | - |
| 94110 | + |
| 93147 | 94111 | if( isUpdate ){ |
| 93148 | | - j2 = sqlite3VdbeAddOp3(v, OP_Eq, regRowid, 0, rowidChng); |
| 94112 | + /* pkChng!=0 does not mean that the rowid has change, only that |
| 94113 | + ** it might have changed. Skip the conflict logic below if the rowid |
| 94114 | + ** is unchanged. */ |
| 94115 | + sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData); |
| 93149 | 94116 | } |
| 93150 | | - j3 = sqlite3VdbeAddOp3(v, OP_NotExists, baseCur, 0, regRowid); |
| 94117 | + |
| 94118 | + /* If the response to a rowid conflict is REPLACE but the response |
| 94119 | + ** to some other UNIQUE constraint is FAIL or IGNORE, then we need |
| 94120 | + ** to defer the running of the rowid conflict checking until after |
| 94121 | + ** the UNIQUE constraints have run. |
| 94122 | + */ |
| 94123 | + if( onError==OE_Replace && overrideError!=OE_Replace ){ |
| 94124 | + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 94125 | + if( pIdx->onError==OE_Ignore || pIdx->onError==OE_Fail ){ |
| 94126 | + ipkTop = sqlite3VdbeAddOp0(v, OP_Goto); |
| 94127 | + break; |
| 94128 | + } |
| 94129 | + } |
| 94130 | + } |
| 94131 | + |
| 94132 | + /* Check to see if the new rowid already exists in the table. Skip |
| 94133 | + ** the following conflict logic if it does not. */ |
| 94134 | + sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData); |
| 94135 | + |
| 94136 | + /* Generate code that deals with a rowid collision */ |
| 93151 | 94137 | switch( onError ){ |
| 93152 | 94138 | default: { |
| 93153 | 94139 | onError = OE_Abort; |
| 93154 | 94140 | /* Fall thru into the next case */ |
| 93155 | 94141 | } |
| 93156 | 94142 | case OE_Rollback: |
| 93157 | 94143 | case OE_Abort: |
| 93158 | 94144 | case OE_Fail: { |
| 93159 | | - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_PRIMARYKEY, |
| 93160 | | - onError, "PRIMARY KEY must be unique", P4_STATIC); |
| 94145 | + sqlite3RowidConstraint(pParse, onError, pTab); |
| 93161 | 94146 | break; |
| 93162 | 94147 | } |
| 93163 | 94148 | case OE_Replace: { |
| 93164 | 94149 | /* If there are DELETE triggers on this table and the |
| 93165 | 94150 | ** recursive-triggers flag is set, call GenerateRowDelete() to |
| | @@ -93187,123 +94172,162 @@ |
| 93187 | 94172 | if( db->flags&SQLITE_RecTriggers ){ |
| 93188 | 94173 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); |
| 93189 | 94174 | } |
| 93190 | 94175 | if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ |
| 93191 | 94176 | sqlite3MultiWrite(pParse); |
| 93192 | | - sqlite3GenerateRowDelete( |
| 93193 | | - pParse, pTab, baseCur, regRowid, 0, pTrigger, OE_Replace |
| 93194 | | - ); |
| 94177 | + sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, |
| 94178 | + regNewData, 1, 0, OE_Replace, 1); |
| 93195 | 94179 | }else if( pTab->pIndex ){ |
| 93196 | 94180 | sqlite3MultiWrite(pParse); |
| 93197 | | - sqlite3GenerateRowIndexDelete(pParse, pTab, baseCur, 0); |
| 94181 | + sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, 0); |
| 93198 | 94182 | } |
| 93199 | 94183 | seenReplace = 1; |
| 93200 | 94184 | break; |
| 93201 | 94185 | } |
| 93202 | 94186 | case OE_Ignore: { |
| 93203 | | - assert( seenReplace==0 ); |
| 94187 | + /*assert( seenReplace==0 );*/ |
| 93204 | 94188 | sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 93205 | 94189 | break; |
| 93206 | 94190 | } |
| 93207 | 94191 | } |
| 93208 | | - sqlite3VdbeJumpHere(v, j3); |
| 93209 | | - if( isUpdate ){ |
| 93210 | | - sqlite3VdbeJumpHere(v, j2); |
| 94192 | + sqlite3VdbeResolveLabel(v, addrRowidOk); |
| 94193 | + if( ipkTop ){ |
| 94194 | + ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto); |
| 94195 | + sqlite3VdbeJumpHere(v, ipkTop); |
| 93211 | 94196 | } |
| 93212 | 94197 | } |
| 93213 | 94198 | |
| 93214 | 94199 | /* Test all UNIQUE constraints by creating entries for each UNIQUE |
| 93215 | 94200 | ** index and making sure that duplicate entries do not already exist. |
| 93216 | | - ** Add the new records to the indices as we go. |
| 94201 | + ** Compute the revised record entries for indices as we go. |
| 94202 | + ** |
| 94203 | + ** This loop also handles the case of the PRIMARY KEY index for a |
| 94204 | + ** WITHOUT ROWID table. |
| 93217 | 94205 | */ |
| 93218 | | - for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){ |
| 93219 | | - int regIdx; |
| 93220 | | - int regR; |
| 93221 | | - int addrSkipRow = 0; |
| 94206 | + for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){ |
| 94207 | + int regIdx; /* Range of registers hold conent for pIdx */ |
| 94208 | + int regR; /* Range of registers holding conflicting PK */ |
| 94209 | + int iThisCur; /* Cursor for this UNIQUE index */ |
| 94210 | + int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */ |
| 93222 | 94211 | |
| 93223 | | - if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */ |
| 94212 | + if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */ |
| 94213 | + iThisCur = iIdxCur+ix; |
| 94214 | + addrUniqueOk = sqlite3VdbeMakeLabel(v); |
| 93224 | 94215 | |
| 94216 | + /* Skip partial indices for which the WHERE clause is not true */ |
| 93225 | 94217 | if( pIdx->pPartIdxWhere ){ |
| 93226 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]); |
| 93227 | | - addrSkipRow = sqlite3VdbeMakeLabel(v); |
| 93228 | | - pParse->ckBase = regData; |
| 93229 | | - sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow, |
| 94218 | + sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]); |
| 94219 | + pParse->ckBase = regNewData+1; |
| 94220 | + sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrUniqueOk, |
| 93230 | 94221 | SQLITE_JUMPIFNULL); |
| 93231 | 94222 | pParse->ckBase = 0; |
| 93232 | 94223 | } |
| 93233 | 94224 | |
| 93234 | | - /* Create a key for accessing the index entry */ |
| 93235 | | - regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1); |
| 94225 | + /* Create a record for this index entry as it should appear after |
| 94226 | + ** the insert or update. Store that record in the aRegIdx[ix] register |
| 94227 | + */ |
| 94228 | + regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn); |
| 93236 | 94229 | for(i=0; i<pIdx->nColumn; i++){ |
| 93237 | | - int idx = pIdx->aiColumn[i]; |
| 93238 | | - if( idx==pTab->iPKey ){ |
| 93239 | | - sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx+i); |
| 94230 | + int iField = pIdx->aiColumn[i]; |
| 94231 | + int x; |
| 94232 | + if( iField<0 || iField==pTab->iPKey ){ |
| 94233 | + x = regNewData; |
| 93240 | 94234 | }else{ |
| 93241 | | - sqlite3VdbeAddOp2(v, OP_SCopy, regData+idx, regIdx+i); |
| 94235 | + x = iField + regNewData + 1; |
| 93242 | 94236 | } |
| 94237 | + sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i); |
| 94238 | + VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName)); |
| 93243 | 94239 | } |
| 93244 | | - sqlite3VdbeAddOp2(v, OP_SCopy, regRowid, regIdx+i); |
| 93245 | | - sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn+1, aRegIdx[iCur]); |
| 94240 | + sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]); |
| 93246 | 94241 | sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), P4_TRANSIENT); |
| 93247 | | - sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn+1); |
| 94242 | + VdbeComment((v, "for %s", pIdx->zName)); |
| 94243 | + sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn); |
| 93248 | 94244 | |
| 93249 | | - /* Find out what action to take in case there is an indexing conflict */ |
| 94245 | + /* In an UPDATE operation, if this index is the PRIMARY KEY index |
| 94246 | + ** of a WITHOUT ROWID table and there has been no change the |
| 94247 | + ** primary key, then no collision is possible. The collision detection |
| 94248 | + ** logic below can all be skipped. */ |
| 94249 | + if( isUpdate && pPk==pIdx && pkChng==0 ){ |
| 94250 | + sqlite3VdbeResolveLabel(v, addrUniqueOk); |
| 94251 | + continue; |
| 94252 | + } |
| 94253 | + |
| 94254 | + /* Find out what action to take in case there is a uniqueness conflict */ |
| 93250 | 94255 | onError = pIdx->onError; |
| 93251 | 94256 | if( onError==OE_None ){ |
| 93252 | | - sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1); |
| 93253 | | - sqlite3VdbeResolveLabel(v, addrSkipRow); |
| 94257 | + sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn); |
| 94258 | + sqlite3VdbeResolveLabel(v, addrUniqueOk); |
| 93254 | 94259 | continue; /* pIdx is not a UNIQUE index */ |
| 93255 | 94260 | } |
| 93256 | 94261 | if( overrideError!=OE_Default ){ |
| 93257 | 94262 | onError = overrideError; |
| 93258 | 94263 | }else if( onError==OE_Default ){ |
| 93259 | 94264 | onError = OE_Abort; |
| 93260 | 94265 | } |
| 93261 | | - if( seenReplace ){ |
| 93262 | | - if( onError==OE_Ignore ) onError = OE_Replace; |
| 93263 | | - else if( onError==OE_Fail ) onError = OE_Abort; |
| 93264 | | - } |
| 93265 | 94266 | |
| 93266 | 94267 | /* Check to see if the new index entry will be unique */ |
| 93267 | | - regR = sqlite3GetTempReg(pParse); |
| 93268 | | - sqlite3VdbeAddOp2(v, OP_SCopy, regOldRowid, regR); |
| 93269 | | - j3 = sqlite3VdbeAddOp4(v, OP_IsUnique, baseCur+iCur+1, 0, |
| 93270 | | - regR, SQLITE_INT_TO_PTR(regIdx), |
| 93271 | | - P4_INT32); |
| 93272 | | - sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1); |
| 94268 | + sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk, |
| 94269 | + regIdx, pIdx->nKeyCol); |
| 94270 | + |
| 94271 | + /* Generate code to handle collisions */ |
| 94272 | + regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField); |
| 94273 | + if( HasRowid(pTab) ){ |
| 94274 | + sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR); |
| 94275 | + /* Conflict only if the rowid of the existing index entry |
| 94276 | + ** is different from old-rowid */ |
| 94277 | + if( isUpdate ){ |
| 94278 | + sqlite3VdbeAddOp3(v, OP_Eq, regR, addrUniqueOk, regOldData); |
| 94279 | + } |
| 94280 | + }else{ |
| 94281 | + int x; |
| 94282 | + /* Extract the PRIMARY KEY from the end of the index entry and |
| 94283 | + ** store it in registers regR..regR+nPk-1 */ |
| 94284 | + if( (isUpdate || onError==OE_Replace) && pIdx!=pPk ){ |
| 94285 | + for(i=0; i<pPk->nKeyCol; i++){ |
| 94286 | + x = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]); |
| 94287 | + sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i); |
| 94288 | + VdbeComment((v, "%s.%s", pTab->zName, |
| 94289 | + pTab->aCol[pPk->aiColumn[i]].zName)); |
| 94290 | + } |
| 94291 | + } |
| 94292 | + if( isUpdate ){ |
| 94293 | + /* If currently processing the PRIMARY KEY of a WITHOUT ROWID |
| 94294 | + ** table, only conflict if the new PRIMARY KEY values are actually |
| 94295 | + ** different from the old. |
| 94296 | + ** |
| 94297 | + ** For a UNIQUE index, only conflict if the PRIMARY KEY values |
| 94298 | + ** of the matched index row are different from the original PRIMARY |
| 94299 | + ** KEY values of this row before the update. */ |
| 94300 | + int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol; |
| 94301 | + int op = OP_Ne; |
| 94302 | + int regCmp = (pIdx->autoIndex==2 ? regIdx : regR); |
| 94303 | + |
| 94304 | + for(i=0; i<pPk->nKeyCol; i++){ |
| 94305 | + char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]); |
| 94306 | + x = pPk->aiColumn[i]; |
| 94307 | + if( i==(pPk->nKeyCol-1) ){ |
| 94308 | + addrJump = addrUniqueOk; |
| 94309 | + op = OP_Eq; |
| 94310 | + } |
| 94311 | + sqlite3VdbeAddOp4(v, op, |
| 94312 | + regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ |
| 94313 | + ); |
| 94314 | + } |
| 94315 | + } |
| 94316 | + } |
| 93273 | 94317 | |
| 93274 | 94318 | /* Generate code that executes if the new index entry is not unique */ |
| 93275 | 94319 | assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail |
| 93276 | 94320 | || onError==OE_Ignore || onError==OE_Replace ); |
| 93277 | 94321 | switch( onError ){ |
| 93278 | 94322 | case OE_Rollback: |
| 93279 | 94323 | case OE_Abort: |
| 93280 | 94324 | case OE_Fail: { |
| 93281 | | - int j; |
| 93282 | | - StrAccum errMsg; |
| 93283 | | - const char *zSep; |
| 93284 | | - char *zErr; |
| 93285 | | - |
| 93286 | | - sqlite3StrAccumInit(&errMsg, 0, 0, 200); |
| 93287 | | - errMsg.db = db; |
| 93288 | | - zSep = pIdx->nColumn>1 ? "columns " : "column "; |
| 93289 | | - for(j=0; j<pIdx->nColumn; j++){ |
| 93290 | | - char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName; |
| 93291 | | - sqlite3StrAccumAppend(&errMsg, zSep, -1); |
| 93292 | | - zSep = ", "; |
| 93293 | | - sqlite3StrAccumAppend(&errMsg, zCol, -1); |
| 93294 | | - } |
| 93295 | | - sqlite3StrAccumAppend(&errMsg, |
| 93296 | | - pIdx->nColumn>1 ? " are not unique" : " is not unique", -1); |
| 93297 | | - zErr = sqlite3StrAccumFinish(&errMsg); |
| 93298 | | - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_UNIQUE, |
| 93299 | | - onError, zErr, 0); |
| 93300 | | - sqlite3DbFree(errMsg.db, zErr); |
| 94325 | + sqlite3UniqueConstraint(pParse, onError, pIdx); |
| 93301 | 94326 | break; |
| 93302 | 94327 | } |
| 93303 | 94328 | case OE_Ignore: { |
| 93304 | | - assert( seenReplace==0 ); |
| 93305 | 94329 | sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 93306 | 94330 | break; |
| 93307 | 94331 | } |
| 93308 | 94332 | default: { |
| 93309 | 94333 | Trigger *pTrigger = 0; |
| | @@ -93310,67 +94334,75 @@ |
| 93310 | 94334 | assert( onError==OE_Replace ); |
| 93311 | 94335 | sqlite3MultiWrite(pParse); |
| 93312 | 94336 | if( db->flags&SQLITE_RecTriggers ){ |
| 93313 | 94337 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); |
| 93314 | 94338 | } |
| 93315 | | - sqlite3GenerateRowDelete( |
| 93316 | | - pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace |
| 93317 | | - ); |
| 94339 | + sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, |
| 94340 | + regR, nPkField, 0, OE_Replace, pIdx==pPk); |
| 93318 | 94341 | seenReplace = 1; |
| 93319 | 94342 | break; |
| 93320 | 94343 | } |
| 93321 | 94344 | } |
| 93322 | | - sqlite3VdbeJumpHere(v, j3); |
| 93323 | | - sqlite3VdbeResolveLabel(v, addrSkipRow); |
| 93324 | | - sqlite3ReleaseTempReg(pParse, regR); |
| 94345 | + sqlite3VdbeResolveLabel(v, addrUniqueOk); |
| 94346 | + sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn); |
| 94347 | + if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField); |
| 94348 | + } |
| 94349 | + if( ipkTop ){ |
| 94350 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, ipkTop+1); |
| 94351 | + sqlite3VdbeJumpHere(v, ipkBottom); |
| 93325 | 94352 | } |
| 93326 | 94353 | |
| 93327 | | - if( pbMayReplace ){ |
| 93328 | | - *pbMayReplace = seenReplace; |
| 93329 | | - } |
| 94354 | + *pbMayReplace = seenReplace; |
| 94355 | + VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace)); |
| 93330 | 94356 | } |
| 93331 | 94357 | |
| 93332 | 94358 | /* |
| 93333 | 94359 | ** This routine generates code to finish the INSERT or UPDATE operation |
| 93334 | 94360 | ** that was started by a prior call to sqlite3GenerateConstraintChecks. |
| 93335 | | -** A consecutive range of registers starting at regRowid contains the |
| 94361 | +** A consecutive range of registers starting at regNewData contains the |
| 93336 | 94362 | ** rowid and the content to be inserted. |
| 93337 | 94363 | ** |
| 93338 | 94364 | ** The arguments to this routine should be the same as the first six |
| 93339 | 94365 | ** arguments to sqlite3GenerateConstraintChecks. |
| 93340 | 94366 | */ |
| 93341 | 94367 | SQLITE_PRIVATE void sqlite3CompleteInsertion( |
| 93342 | 94368 | Parse *pParse, /* The parser context */ |
| 93343 | 94369 | Table *pTab, /* the table into which we are inserting */ |
| 93344 | | - int baseCur, /* Index of a read/write cursor pointing at pTab */ |
| 93345 | | - int regRowid, /* Range of content */ |
| 94370 | + int iDataCur, /* Cursor of the canonical data source */ |
| 94371 | + int iIdxCur, /* First index cursor */ |
| 94372 | + int regNewData, /* Range of content */ |
| 93346 | 94373 | int *aRegIdx, /* Register used by each index. 0 for unused indices */ |
| 93347 | 94374 | int isUpdate, /* True for UPDATE, False for INSERT */ |
| 93348 | 94375 | int appendBias, /* True if this is likely to be an append */ |
| 93349 | 94376 | int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */ |
| 93350 | 94377 | ){ |
| 93351 | | - int i; |
| 93352 | | - Vdbe *v; |
| 93353 | | - Index *pIdx; |
| 93354 | | - u8 pik_flags; |
| 93355 | | - int regData; |
| 93356 | | - int regRec; |
| 94378 | + Vdbe *v; /* Prepared statements under construction */ |
| 94379 | + Index *pIdx; /* An index being inserted or updated */ |
| 94380 | + u8 pik_flags; /* flag values passed to the btree insert */ |
| 94381 | + int regData; /* Content registers (after the rowid) */ |
| 94382 | + int regRec; /* Register holding assemblied record for the table */ |
| 94383 | + int i; /* Loop counter */ |
| 93357 | 94384 | |
| 93358 | 94385 | v = sqlite3GetVdbe(pParse); |
| 93359 | 94386 | assert( v!=0 ); |
| 93360 | 94387 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ |
| 93361 | 94388 | for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 93362 | 94389 | if( aRegIdx[i]==0 ) continue; |
| 93363 | 94390 | if( pIdx->pPartIdxWhere ){ |
| 93364 | 94391 | sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2); |
| 93365 | 94392 | } |
| 93366 | | - sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]); |
| 93367 | | - if( useSeekResult ){ |
| 93368 | | - sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 94393 | + sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i]); |
| 94394 | + pik_flags = 0; |
| 94395 | + if( useSeekResult ) pik_flags = OPFLAG_USESEEKRESULT; |
| 94396 | + if( pIdx->autoIndex==2 && !HasRowid(pTab) ){ |
| 94397 | + assert( pParse->nested==0 ); |
| 94398 | + pik_flags |= OPFLAG_NCHANGE; |
| 93369 | 94399 | } |
| 94400 | + if( pik_flags ) sqlite3VdbeChangeP5(v, pik_flags); |
| 93370 | 94401 | } |
| 93371 | | - regData = regRowid + 1; |
| 94402 | + if( !HasRowid(pTab) ) return; |
| 94403 | + regData = regNewData + 1; |
| 93372 | 94404 | regRec = sqlite3GetTempReg(pParse); |
| 93373 | 94405 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regData, pTab->nCol, regRec); |
| 93374 | 94406 | sqlite3TableAffinityStr(v, pTab); |
| 93375 | 94407 | sqlite3ExprCacheAffinityChange(pParse, regData, pTab->nCol); |
| 93376 | 94408 | if( pParse->nested ){ |
| | @@ -93383,51 +94415,75 @@ |
| 93383 | 94415 | pik_flags |= OPFLAG_APPEND; |
| 93384 | 94416 | } |
| 93385 | 94417 | if( useSeekResult ){ |
| 93386 | 94418 | pik_flags |= OPFLAG_USESEEKRESULT; |
| 93387 | 94419 | } |
| 93388 | | - sqlite3VdbeAddOp3(v, OP_Insert, baseCur, regRec, regRowid); |
| 94420 | + sqlite3VdbeAddOp3(v, OP_Insert, iDataCur, regRec, regNewData); |
| 93389 | 94421 | if( !pParse->nested ){ |
| 93390 | 94422 | sqlite3VdbeChangeP4(v, -1, pTab->zName, P4_TRANSIENT); |
| 93391 | 94423 | } |
| 93392 | 94424 | sqlite3VdbeChangeP5(v, pik_flags); |
| 93393 | 94425 | } |
| 93394 | 94426 | |
| 93395 | 94427 | /* |
| 93396 | | -** Generate code that will open cursors for a table and for all |
| 93397 | | -** indices of that table. The "baseCur" parameter is the cursor number used |
| 93398 | | -** for the table. Indices are opened on subsequent cursors. |
| 94428 | +** Allocate cursors for the pTab table and all its indices and generate |
| 94429 | +** code to open and initialized those cursors. |
| 93399 | 94430 | ** |
| 93400 | | -** Return the number of indices on the table. |
| 94431 | +** The cursor for the object that contains the complete data (normally |
| 94432 | +** the table itself, but the PRIMARY KEY index in the case of a WITHOUT |
| 94433 | +** ROWID table) is returned in *piDataCur. The first index cursor is |
| 94434 | +** returned in *piIdxCur. The number of indices is returned. |
| 94435 | +** |
| 94436 | +** Use iBase as the first cursor (either the *piDataCur for rowid tables |
| 94437 | +** or the first index for WITHOUT ROWID tables) if it is non-negative. |
| 94438 | +** If iBase is negative, then allocate the next available cursor. |
| 94439 | +** |
| 94440 | +** For a rowid table, *piDataCur will be exactly one less than *piIdxCur. |
| 94441 | +** For a WITHOUT ROWID table, *piDataCur will be somewhere in the range |
| 94442 | +** of *piIdxCurs, depending on where the PRIMARY KEY index appears on the |
| 94443 | +** pTab->pIndex list. |
| 93401 | 94444 | */ |
| 93402 | 94445 | SQLITE_PRIVATE int sqlite3OpenTableAndIndices( |
| 93403 | 94446 | Parse *pParse, /* Parsing context */ |
| 93404 | 94447 | Table *pTab, /* Table to be opened */ |
| 93405 | | - int baseCur, /* Cursor number assigned to the table */ |
| 93406 | | - int op /* OP_OpenRead or OP_OpenWrite */ |
| 94448 | + int op, /* OP_OpenRead or OP_OpenWrite */ |
| 94449 | + int iBase, /* Use this for the table cursor, if there is one */ |
| 94450 | + int *piDataCur, /* Write the database source cursor number here */ |
| 94451 | + int *piIdxCur /* Write the first index cursor number here */ |
| 93407 | 94452 | ){ |
| 93408 | 94453 | int i; |
| 93409 | 94454 | int iDb; |
| 93410 | 94455 | Index *pIdx; |
| 93411 | 94456 | Vdbe *v; |
| 93412 | 94457 | |
| 93413 | | - if( IsVirtual(pTab) ) return 0; |
| 94458 | + assert( op==OP_OpenRead || op==OP_OpenWrite ); |
| 94459 | + if( IsVirtual(pTab) ){ |
| 94460 | + *piDataCur = 0; |
| 94461 | + *piIdxCur = 1; |
| 94462 | + return 0; |
| 94463 | + } |
| 93414 | 94464 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
| 93415 | 94465 | v = sqlite3GetVdbe(pParse); |
| 93416 | 94466 | assert( v!=0 ); |
| 93417 | | - sqlite3OpenTable(pParse, baseCur, iDb, pTab, op); |
| 93418 | | - for(i=1, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 93419 | | - KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 94467 | + if( iBase<0 ) iBase = pParse->nTab; |
| 94468 | + if( HasRowid(pTab) ){ |
| 94469 | + *piDataCur = iBase++; |
| 94470 | + sqlite3OpenTable(pParse, *piDataCur, iDb, pTab, op); |
| 94471 | + }else{ |
| 94472 | + sqlite3TableLock(pParse, iDb, pTab->tnum, op==OP_OpenWrite, pTab->zName); |
| 94473 | + } |
| 94474 | + *piIdxCur = iBase; |
| 94475 | + for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 94476 | + int iIdxCur = iBase++; |
| 93420 | 94477 | assert( pIdx->pSchema==pTab->pSchema ); |
| 93421 | | - sqlite3VdbeAddOp4(v, op, i+baseCur, pIdx->tnum, iDb, |
| 93422 | | - (char*)pKey, P4_KEYINFO_HANDOFF); |
| 94478 | + if( pIdx->autoIndex==2 && !HasRowid(pTab) ) *piDataCur = iIdxCur; |
| 94479 | + sqlite3VdbeAddOp3(v, op, iIdxCur, pIdx->tnum, iDb); |
| 94480 | + sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 93423 | 94481 | VdbeComment((v, "%s", pIdx->zName)); |
| 93424 | 94482 | } |
| 93425 | | - if( pParse->nTab<baseCur+i ){ |
| 93426 | | - pParse->nTab = baseCur+i; |
| 93427 | | - } |
| 93428 | | - return i-1; |
| 94483 | + if( iBase>pParse->nTab ) pParse->nTab = iBase; |
| 94484 | + return i; |
| 93429 | 94485 | } |
| 93430 | 94486 | |
| 93431 | 94487 | |
| 93432 | 94488 | #ifdef SQLITE_TEST |
| 93433 | 94489 | /* |
| | @@ -93468,17 +94524,17 @@ |
| 93468 | 94524 | */ |
| 93469 | 94525 | static int xferCompatibleIndex(Index *pDest, Index *pSrc){ |
| 93470 | 94526 | int i; |
| 93471 | 94527 | assert( pDest && pSrc ); |
| 93472 | 94528 | assert( pDest->pTable!=pSrc->pTable ); |
| 93473 | | - if( pDest->nColumn!=pSrc->nColumn ){ |
| 94529 | + if( pDest->nKeyCol!=pSrc->nKeyCol ){ |
| 93474 | 94530 | return 0; /* Different number of columns */ |
| 93475 | 94531 | } |
| 93476 | 94532 | if( pDest->onError!=pSrc->onError ){ |
| 93477 | 94533 | return 0; /* Different conflict resolution strategies */ |
| 93478 | 94534 | } |
| 93479 | | - for(i=0; i<pSrc->nColumn; i++){ |
| 94535 | + for(i=0; i<pSrc->nKeyCol; i++){ |
| 93480 | 94536 | if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){ |
| 93481 | 94537 | return 0; /* Different columns indexed */ |
| 93482 | 94538 | } |
| 93483 | 94539 | if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){ |
| 93484 | 94540 | return 0; /* Different sort orders */ |
| | @@ -93533,14 +94589,13 @@ |
| 93533 | 94589 | struct SrcList_item *pItem; /* An element of pSelect->pSrc */ |
| 93534 | 94590 | int i; /* Loop counter */ |
| 93535 | 94591 | int iDbSrc; /* The database of pSrc */ |
| 93536 | 94592 | int iSrc, iDest; /* Cursors from source and destination */ |
| 93537 | 94593 | int addr1, addr2; /* Loop addresses */ |
| 93538 | | - int emptyDestTest; /* Address of test for empty pDest */ |
| 93539 | | - int emptySrcTest; /* Address of test for empty pSrc */ |
| 94594 | + int emptyDestTest = 0; /* Address of test for empty pDest */ |
| 94595 | + int emptySrcTest = 0; /* Address of test for empty pSrc */ |
| 93540 | 94596 | Vdbe *v; /* The VDBE we are building */ |
| 93541 | | - KeyInfo *pKey; /* Key information for an index */ |
| 93542 | 94597 | int regAutoinc; /* Memory register used by AUTOINC */ |
| 93543 | 94598 | int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */ |
| 93544 | 94599 | int regData, regRowid; /* Registers holding data and rowid */ |
| 93545 | 94600 | |
| 93546 | 94601 | if( pSelect==0 ){ |
| | @@ -93606,10 +94661,13 @@ |
| 93606 | 94661 | return 0; /* FROM clause does not contain a real table */ |
| 93607 | 94662 | } |
| 93608 | 94663 | if( pSrc==pDest ){ |
| 93609 | 94664 | return 0; /* tab1 and tab2 may not be the same table */ |
| 93610 | 94665 | } |
| 94666 | + if( HasRowid(pDest)!=HasRowid(pSrc) ){ |
| 94667 | + return 0; /* source and destination must both be WITHOUT ROWID or not */ |
| 94668 | + } |
| 93611 | 94669 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 93612 | 94670 | if( pSrc->tabFlags & TF_Virtual ){ |
| 93613 | 94671 | return 0; /* tab2 must not be a virtual table */ |
| 93614 | 94672 | } |
| 93615 | 94673 | #endif |
| | @@ -93676,11 +94734,14 @@ |
| 93676 | 94734 | v = sqlite3GetVdbe(pParse); |
| 93677 | 94735 | sqlite3CodeVerifySchema(pParse, iDbSrc); |
| 93678 | 94736 | iSrc = pParse->nTab++; |
| 93679 | 94737 | iDest = pParse->nTab++; |
| 93680 | 94738 | regAutoinc = autoIncBegin(pParse, iDbDest, pDest); |
| 94739 | + regData = sqlite3GetTempReg(pParse); |
| 94740 | + regRowid = sqlite3GetTempReg(pParse); |
| 93681 | 94741 | sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite); |
| 94742 | + assert( HasRowid(pDest) || destHasUniqueIdx ); |
| 93682 | 94743 | if( (pDest->iPKey<0 && pDest->pIndex!=0) /* (1) */ |
| 93683 | 94744 | || destHasUniqueIdx /* (2) */ |
| 93684 | 94745 | || (onError!=OE_Abort && onError!=OE_Rollback) /* (3) */ |
| 93685 | 94746 | ){ |
| 93686 | 94747 | /* In some circumstances, we are able to run the xfer optimization |
| | @@ -93698,62 +94759,60 @@ |
| 93698 | 94759 | ** (3) onError is something other than OE_Abort and OE_Rollback. |
| 93699 | 94760 | */ |
| 93700 | 94761 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0); |
| 93701 | 94762 | emptyDestTest = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); |
| 93702 | 94763 | sqlite3VdbeJumpHere(v, addr1); |
| 93703 | | - }else{ |
| 93704 | | - emptyDestTest = 0; |
| 93705 | | - } |
| 93706 | | - sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead); |
| 93707 | | - emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); |
| 93708 | | - regData = sqlite3GetTempReg(pParse); |
| 93709 | | - regRowid = sqlite3GetTempReg(pParse); |
| 93710 | | - if( pDest->iPKey>=0 ){ |
| 93711 | | - addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); |
| 93712 | | - addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid); |
| 93713 | | - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_PRIMARYKEY, |
| 93714 | | - onError, "PRIMARY KEY must be unique", P4_STATIC); |
| 93715 | | - sqlite3VdbeJumpHere(v, addr2); |
| 93716 | | - autoIncStep(pParse, regAutoinc, regRowid); |
| 93717 | | - }else if( pDest->pIndex==0 ){ |
| 93718 | | - addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid); |
| 93719 | | - }else{ |
| 93720 | | - addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); |
| 93721 | | - assert( (pDest->tabFlags & TF_Autoincrement)==0 ); |
| 93722 | | - } |
| 93723 | | - sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData); |
| 93724 | | - sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid); |
| 93725 | | - sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND); |
| 93726 | | - sqlite3VdbeChangeP4(v, -1, pDest->zName, 0); |
| 93727 | | - sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); |
| 94764 | + } |
| 94765 | + if( HasRowid(pSrc) ){ |
| 94766 | + sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead); |
| 94767 | + emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); |
| 94768 | + if( pDest->iPKey>=0 ){ |
| 94769 | + addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); |
| 94770 | + addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid); |
| 94771 | + sqlite3RowidConstraint(pParse, onError, pDest); |
| 94772 | + sqlite3VdbeJumpHere(v, addr2); |
| 94773 | + autoIncStep(pParse, regAutoinc, regRowid); |
| 94774 | + }else if( pDest->pIndex==0 ){ |
| 94775 | + addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid); |
| 94776 | + }else{ |
| 94777 | + addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); |
| 94778 | + assert( (pDest->tabFlags & TF_Autoincrement)==0 ); |
| 94779 | + } |
| 94780 | + sqlite3VdbeAddOp2(v, OP_RowData, iSrc, regData); |
| 94781 | + sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid); |
| 94782 | + sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND); |
| 94783 | + sqlite3VdbeChangeP4(v, -1, pDest->zName, 0); |
| 94784 | + sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); |
| 94785 | + sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); |
| 94786 | + sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 94787 | + }else{ |
| 94788 | + sqlite3TableLock(pParse, iDbDest, pDest->tnum, 1, pDest->zName); |
| 94789 | + sqlite3TableLock(pParse, iDbSrc, pSrc->tnum, 0, pSrc->zName); |
| 94790 | + } |
| 93728 | 94791 | for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){ |
| 93729 | 94792 | for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){ |
| 93730 | 94793 | if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break; |
| 93731 | 94794 | } |
| 93732 | 94795 | assert( pSrcIdx ); |
| 93733 | | - sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); |
| 93734 | | - sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 93735 | | - pKey = sqlite3IndexKeyinfo(pParse, pSrcIdx); |
| 93736 | | - sqlite3VdbeAddOp4(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc, |
| 93737 | | - (char*)pKey, P4_KEYINFO_HANDOFF); |
| 94796 | + sqlite3VdbeAddOp3(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc); |
| 94797 | + sqlite3VdbeSetP4KeyInfo(pParse, pSrcIdx); |
| 93738 | 94798 | VdbeComment((v, "%s", pSrcIdx->zName)); |
| 93739 | | - pKey = sqlite3IndexKeyinfo(pParse, pDestIdx); |
| 93740 | | - sqlite3VdbeAddOp4(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest, |
| 93741 | | - (char*)pKey, P4_KEYINFO_HANDOFF); |
| 94799 | + sqlite3VdbeAddOp3(v, OP_OpenWrite, iDest, pDestIdx->tnum, iDbDest); |
| 94800 | + sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx); |
| 93742 | 94801 | sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR); |
| 93743 | 94802 | VdbeComment((v, "%s", pDestIdx->zName)); |
| 93744 | 94803 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); |
| 93745 | 94804 | sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData); |
| 93746 | 94805 | sqlite3VdbeAddOp3(v, OP_IdxInsert, iDest, regData, 1); |
| 93747 | 94806 | sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); |
| 93748 | 94807 | sqlite3VdbeJumpHere(v, addr1); |
| 94808 | + sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); |
| 94809 | + sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 93749 | 94810 | } |
| 93750 | 94811 | sqlite3VdbeJumpHere(v, emptySrcTest); |
| 93751 | 94812 | sqlite3ReleaseTempReg(pParse, regRowid); |
| 93752 | 94813 | sqlite3ReleaseTempReg(pParse, regData); |
| 93753 | | - sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); |
| 93754 | | - sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 93755 | 94814 | if( emptyDestTest ){ |
| 93756 | 94815 | sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_OK, 0); |
| 93757 | 94816 | sqlite3VdbeJumpHere(v, emptyDestTest); |
| 93758 | 94817 | sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| 93759 | 94818 | return 0; |
| | @@ -95251,15 +96310,17 @@ |
| 95251 | 96310 | { /* zName: */ "auto_vacuum", |
| 95252 | 96311 | /* ePragTyp: */ PragTyp_AUTO_VACUUM, |
| 95253 | 96312 | /* ePragFlag: */ PragFlag_NeedSchema, |
| 95254 | 96313 | /* iArg: */ 0 }, |
| 95255 | 96314 | #endif |
| 96315 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95256 | 96316 | #if !defined(SQLITE_OMIT_AUTOMATIC_INDEX) |
| 95257 | 96317 | { /* zName: */ "automatic_index", |
| 95258 | 96318 | /* ePragTyp: */ PragTyp_FLAG, |
| 95259 | 96319 | /* ePragFlag: */ 0, |
| 95260 | 96320 | /* iArg: */ SQLITE_AutoIndex }, |
| 96321 | +#endif |
| 95261 | 96322 | #endif |
| 95262 | 96323 | { /* zName: */ "busy_timeout", |
| 95263 | 96324 | /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, |
| 95264 | 96325 | /* ePragFlag: */ 0, |
| 95265 | 96326 | /* iArg: */ 0 }, |
| | @@ -95267,22 +96328,26 @@ |
| 95267 | 96328 | { /* zName: */ "cache_size", |
| 95268 | 96329 | /* ePragTyp: */ PragTyp_CACHE_SIZE, |
| 95269 | 96330 | /* ePragFlag: */ PragFlag_NeedSchema, |
| 95270 | 96331 | /* iArg: */ 0 }, |
| 95271 | 96332 | #endif |
| 96333 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95272 | 96334 | { /* zName: */ "cache_spill", |
| 95273 | 96335 | /* ePragTyp: */ PragTyp_FLAG, |
| 95274 | 96336 | /* ePragFlag: */ 0, |
| 95275 | 96337 | /* iArg: */ SQLITE_CacheSpill }, |
| 96338 | +#endif |
| 95276 | 96339 | { /* zName: */ "case_sensitive_like", |
| 95277 | 96340 | /* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE, |
| 95278 | 96341 | /* ePragFlag: */ 0, |
| 95279 | 96342 | /* iArg: */ 0 }, |
| 96343 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95280 | 96344 | { /* zName: */ "checkpoint_fullfsync", |
| 95281 | 96345 | /* ePragTyp: */ PragTyp_FLAG, |
| 95282 | 96346 | /* ePragFlag: */ 0, |
| 95283 | 96347 | /* iArg: */ SQLITE_CkptFullFSync }, |
| 96348 | +#endif |
| 95284 | 96349 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 95285 | 96350 | { /* zName: */ "collation_list", |
| 95286 | 96351 | /* ePragTyp: */ PragTyp_COLLATION_LIST, |
| 95287 | 96352 | /* ePragFlag: */ 0, |
| 95288 | 96353 | /* iArg: */ 0 }, |
| | @@ -95291,14 +96356,16 @@ |
| 95291 | 96356 | { /* zName: */ "compile_options", |
| 95292 | 96357 | /* ePragTyp: */ PragTyp_COMPILE_OPTIONS, |
| 95293 | 96358 | /* ePragFlag: */ 0, |
| 95294 | 96359 | /* iArg: */ 0 }, |
| 95295 | 96360 | #endif |
| 96361 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95296 | 96362 | { /* zName: */ "count_changes", |
| 95297 | 96363 | /* ePragTyp: */ PragTyp_FLAG, |
| 95298 | 96364 | /* ePragFlag: */ 0, |
| 95299 | 96365 | /* iArg: */ SQLITE_CountRows }, |
| 96366 | +#endif |
| 95300 | 96367 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN |
| 95301 | 96368 | { /* zName: */ "data_store_directory", |
| 95302 | 96369 | /* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY, |
| 95303 | 96370 | /* ePragFlag: */ 0, |
| 95304 | 96371 | /* iArg: */ 0 }, |
| | @@ -95313,20 +96380,24 @@ |
| 95313 | 96380 | { /* zName: */ "default_cache_size", |
| 95314 | 96381 | /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE, |
| 95315 | 96382 | /* ePragFlag: */ PragFlag_NeedSchema, |
| 95316 | 96383 | /* iArg: */ 0 }, |
| 95317 | 96384 | #endif |
| 96385 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95318 | 96386 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
| 95319 | 96387 | { /* zName: */ "defer_foreign_keys", |
| 95320 | 96388 | /* ePragTyp: */ PragTyp_FLAG, |
| 95321 | 96389 | /* ePragFlag: */ 0, |
| 95322 | 96390 | /* iArg: */ SQLITE_DeferFKs }, |
| 95323 | 96391 | #endif |
| 96392 | +#endif |
| 96393 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95324 | 96394 | { /* zName: */ "empty_result_callbacks", |
| 95325 | 96395 | /* ePragTyp: */ PragTyp_FLAG, |
| 95326 | 96396 | /* ePragFlag: */ 0, |
| 95327 | 96397 | /* iArg: */ SQLITE_NullCallback }, |
| 96398 | +#endif |
| 95328 | 96399 | #if !defined(SQLITE_OMIT_UTF16) |
| 95329 | 96400 | { /* zName: */ "encoding", |
| 95330 | 96401 | /* ePragTyp: */ PragTyp_ENCODING, |
| 95331 | 96402 | /* ePragFlag: */ 0, |
| 95332 | 96403 | /* iArg: */ 0 }, |
| | @@ -95341,30 +96412,34 @@ |
| 95341 | 96412 | { /* zName: */ "foreign_key_list", |
| 95342 | 96413 | /* ePragTyp: */ PragTyp_FOREIGN_KEY_LIST, |
| 95343 | 96414 | /* ePragFlag: */ PragFlag_NeedSchema, |
| 95344 | 96415 | /* iArg: */ 0 }, |
| 95345 | 96416 | #endif |
| 96417 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95346 | 96418 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER) |
| 95347 | 96419 | { /* zName: */ "foreign_keys", |
| 95348 | 96420 | /* ePragTyp: */ PragTyp_FLAG, |
| 95349 | 96421 | /* ePragFlag: */ 0, |
| 95350 | 96422 | /* iArg: */ SQLITE_ForeignKeys }, |
| 96423 | +#endif |
| 95351 | 96424 | #endif |
| 95352 | 96425 | #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) |
| 95353 | 96426 | { /* zName: */ "freelist_count", |
| 95354 | 96427 | /* ePragTyp: */ PragTyp_HEADER_VALUE, |
| 95355 | 96428 | /* ePragFlag: */ 0, |
| 95356 | 96429 | /* iArg: */ 0 }, |
| 95357 | 96430 | #endif |
| 96431 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95358 | 96432 | { /* zName: */ "full_column_names", |
| 95359 | 96433 | /* ePragTyp: */ PragTyp_FLAG, |
| 95360 | 96434 | /* ePragFlag: */ 0, |
| 95361 | 96435 | /* iArg: */ SQLITE_FullColNames }, |
| 95362 | 96436 | { /* zName: */ "fullfsync", |
| 95363 | 96437 | /* ePragTyp: */ PragTyp_FLAG, |
| 95364 | 96438 | /* ePragFlag: */ 0, |
| 95365 | 96439 | /* iArg: */ SQLITE_FullFSync }, |
| 96440 | +#endif |
| 95366 | 96441 | #if defined(SQLITE_HAS_CODEC) |
| 95367 | 96442 | { /* zName: */ "hexkey", |
| 95368 | 96443 | /* ePragTyp: */ PragTyp_HEXKEY, |
| 95369 | 96444 | /* ePragFlag: */ 0, |
| 95370 | 96445 | /* iArg: */ 0 }, |
| | @@ -95371,15 +96446,17 @@ |
| 95371 | 96446 | { /* zName: */ "hexrekey", |
| 95372 | 96447 | /* ePragTyp: */ PragTyp_HEXKEY, |
| 95373 | 96448 | /* ePragFlag: */ 0, |
| 95374 | 96449 | /* iArg: */ 0 }, |
| 95375 | 96450 | #endif |
| 96451 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95376 | 96452 | #if !defined(SQLITE_OMIT_CHECK) |
| 95377 | 96453 | { /* zName: */ "ignore_check_constraints", |
| 95378 | 96454 | /* ePragTyp: */ PragTyp_FLAG, |
| 95379 | 96455 | /* ePragFlag: */ 0, |
| 95380 | 96456 | /* iArg: */ SQLITE_IgnoreChecks }, |
| 96457 | +#endif |
| 95381 | 96458 | #endif |
| 95382 | 96459 | #if !defined(SQLITE_OMIT_AUTOVACUUM) |
| 95383 | 96460 | { /* zName: */ "incremental_vacuum", |
| 95384 | 96461 | /* ePragTyp: */ PragTyp_INCREMENTAL_VACUUM, |
| 95385 | 96462 | /* ePragFlag: */ PragFlag_NeedSchema, |
| | @@ -95415,14 +96492,16 @@ |
| 95415 | 96492 | { /* zName: */ "key", |
| 95416 | 96493 | /* ePragTyp: */ PragTyp_KEY, |
| 95417 | 96494 | /* ePragFlag: */ 0, |
| 95418 | 96495 | /* iArg: */ 0 }, |
| 95419 | 96496 | #endif |
| 96497 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95420 | 96498 | { /* zName: */ "legacy_file_format", |
| 95421 | 96499 | /* ePragTyp: */ PragTyp_FLAG, |
| 95422 | 96500 | /* ePragFlag: */ 0, |
| 95423 | 96501 | /* iArg: */ SQLITE_LegacyFileFmt }, |
| 96502 | +#endif |
| 95424 | 96503 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_ENABLE_LOCKING_STYLE |
| 95425 | 96504 | { /* zName: */ "lock_proxy_file", |
| 95426 | 96505 | /* ePragTyp: */ PragTyp_LOCK_PROXY_FILE, |
| 95427 | 96506 | /* ePragFlag: */ 0, |
| 95428 | 96507 | /* iArg: */ 0 }, |
| | @@ -95459,38 +96538,44 @@ |
| 95459 | 96538 | { /* zName: */ "parser_trace", |
| 95460 | 96539 | /* ePragTyp: */ PragTyp_PARSER_TRACE, |
| 95461 | 96540 | /* ePragFlag: */ 0, |
| 95462 | 96541 | /* iArg: */ 0 }, |
| 95463 | 96542 | #endif |
| 96543 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95464 | 96544 | { /* zName: */ "query_only", |
| 95465 | 96545 | /* ePragTyp: */ PragTyp_FLAG, |
| 95466 | 96546 | /* ePragFlag: */ 0, |
| 95467 | 96547 | /* iArg: */ SQLITE_QueryOnly }, |
| 96548 | +#endif |
| 95468 | 96549 | #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) |
| 95469 | 96550 | { /* zName: */ "quick_check", |
| 95470 | 96551 | /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, |
| 95471 | 96552 | /* ePragFlag: */ PragFlag_NeedSchema, |
| 95472 | 96553 | /* iArg: */ 0 }, |
| 95473 | 96554 | #endif |
| 96555 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95474 | 96556 | { /* zName: */ "read_uncommitted", |
| 95475 | 96557 | /* ePragTyp: */ PragTyp_FLAG, |
| 95476 | 96558 | /* ePragFlag: */ 0, |
| 95477 | 96559 | /* iArg: */ SQLITE_ReadUncommitted }, |
| 95478 | 96560 | { /* zName: */ "recursive_triggers", |
| 95479 | 96561 | /* ePragTyp: */ PragTyp_FLAG, |
| 95480 | 96562 | /* ePragFlag: */ 0, |
| 95481 | 96563 | /* iArg: */ SQLITE_RecTriggers }, |
| 96564 | +#endif |
| 95482 | 96565 | #if defined(SQLITE_HAS_CODEC) |
| 95483 | 96566 | { /* zName: */ "rekey", |
| 95484 | 96567 | /* ePragTyp: */ PragTyp_REKEY, |
| 95485 | 96568 | /* ePragFlag: */ 0, |
| 95486 | 96569 | /* iArg: */ 0 }, |
| 95487 | 96570 | #endif |
| 96571 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95488 | 96572 | { /* zName: */ "reverse_unordered_selects", |
| 95489 | 96573 | /* ePragTyp: */ PragTyp_FLAG, |
| 95490 | 96574 | /* ePragFlag: */ 0, |
| 95491 | 96575 | /* iArg: */ SQLITE_ReverseOrder }, |
| 96576 | +#endif |
| 95492 | 96577 | #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS) |
| 95493 | 96578 | { /* zName: */ "schema_version", |
| 95494 | 96579 | /* ePragTyp: */ PragTyp_HEADER_VALUE, |
| 95495 | 96580 | /* ePragFlag: */ 0, |
| 95496 | 96581 | /* iArg: */ 0 }, |
| | @@ -95499,27 +96584,31 @@ |
| 95499 | 96584 | { /* zName: */ "secure_delete", |
| 95500 | 96585 | /* ePragTyp: */ PragTyp_SECURE_DELETE, |
| 95501 | 96586 | /* ePragFlag: */ 0, |
| 95502 | 96587 | /* iArg: */ 0 }, |
| 95503 | 96588 | #endif |
| 96589 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95504 | 96590 | { /* zName: */ "short_column_names", |
| 95505 | 96591 | /* ePragTyp: */ PragTyp_FLAG, |
| 95506 | 96592 | /* ePragFlag: */ 0, |
| 95507 | 96593 | /* iArg: */ SQLITE_ShortColNames }, |
| 96594 | +#endif |
| 95508 | 96595 | { /* zName: */ "shrink_memory", |
| 95509 | 96596 | /* ePragTyp: */ PragTyp_SHRINK_MEMORY, |
| 95510 | 96597 | /* ePragFlag: */ 0, |
| 95511 | 96598 | /* iArg: */ 0 }, |
| 95512 | 96599 | { /* zName: */ "soft_heap_limit", |
| 95513 | 96600 | /* ePragTyp: */ PragTyp_SOFT_HEAP_LIMIT, |
| 95514 | 96601 | /* ePragFlag: */ 0, |
| 95515 | 96602 | /* iArg: */ 0 }, |
| 96603 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95516 | 96604 | #if defined(SQLITE_DEBUG) |
| 95517 | 96605 | { /* zName: */ "sql_trace", |
| 95518 | 96606 | /* ePragTyp: */ PragTyp_FLAG, |
| 95519 | 96607 | /* ePragFlag: */ 0, |
| 95520 | 96608 | /* iArg: */ SQLITE_SqlTrace }, |
| 96609 | +#endif |
| 95521 | 96610 | #endif |
| 95522 | 96611 | #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) |
| 95523 | 96612 | { /* zName: */ "stats", |
| 95524 | 96613 | /* ePragTyp: */ PragTyp_STATS, |
| 95525 | 96614 | /* ePragFlag: */ PragFlag_NeedSchema, |
| | @@ -95551,10 +96640,11 @@ |
| 95551 | 96640 | { /* zName: */ "user_version", |
| 95552 | 96641 | /* ePragTyp: */ PragTyp_HEADER_VALUE, |
| 95553 | 96642 | /* ePragFlag: */ 0, |
| 95554 | 96643 | /* iArg: */ 0 }, |
| 95555 | 96644 | #endif |
| 96645 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95556 | 96646 | #if defined(SQLITE_DEBUG) |
| 95557 | 96647 | { /* zName: */ "vdbe_addoptrace", |
| 95558 | 96648 | /* ePragTyp: */ PragTyp_FLAG, |
| 95559 | 96649 | /* ePragFlag: */ 0, |
| 95560 | 96650 | /* iArg: */ SQLITE_VdbeAddopTrace }, |
| | @@ -95568,10 +96658,11 @@ |
| 95568 | 96658 | /* iArg: */ SQLITE_VdbeListing }, |
| 95569 | 96659 | { /* zName: */ "vdbe_trace", |
| 95570 | 96660 | /* ePragTyp: */ PragTyp_FLAG, |
| 95571 | 96661 | /* ePragFlag: */ 0, |
| 95572 | 96662 | /* iArg: */ SQLITE_VdbeTrace }, |
| 96663 | +#endif |
| 95573 | 96664 | #endif |
| 95574 | 96665 | #if !defined(SQLITE_OMIT_WAL) |
| 95575 | 96666 | { /* zName: */ "wal_autocheckpoint", |
| 95576 | 96667 | /* ePragTyp: */ PragTyp_WAL_AUTOCHECKPOINT, |
| 95577 | 96668 | /* ePragFlag: */ 0, |
| | @@ -95579,14 +96670,16 @@ |
| 95579 | 96670 | { /* zName: */ "wal_checkpoint", |
| 95580 | 96671 | /* ePragTyp: */ PragTyp_WAL_CHECKPOINT, |
| 95581 | 96672 | /* ePragFlag: */ PragFlag_NeedSchema, |
| 95582 | 96673 | /* iArg: */ 0 }, |
| 95583 | 96674 | #endif |
| 96675 | +#if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| 95584 | 96676 | { /* zName: */ "writable_schema", |
| 95585 | 96677 | /* ePragTyp: */ PragTyp_FLAG, |
| 95586 | 96678 | /* ePragFlag: */ 0, |
| 95587 | 96679 | /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, |
| 96680 | +#endif |
| 95588 | 96681 | }; |
| 95589 | 96682 | /* Number of pragmas: 56 on by default, 68 total. */ |
| 95590 | 96683 | /* End of the automatically generated pragma table. |
| 95591 | 96684 | ***************************************************************************/ |
| 95592 | 96685 | |
| | @@ -96548,12 +97641,11 @@ |
| 96548 | 97641 | pTab = sqlite3FindTable(db, zRight, zDb); |
| 96549 | 97642 | if( pTab ){ |
| 96550 | 97643 | int i, k; |
| 96551 | 97644 | int nHidden = 0; |
| 96552 | 97645 | Column *pCol; |
| 96553 | | - Index *pPk; |
| 96554 | | - for(pPk=pTab->pIndex; pPk && pPk->autoIndex!=2; pPk=pPk->pNext){} |
| 97646 | + Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 96555 | 97647 | sqlite3VdbeSetNumCols(v, 6); |
| 96556 | 97648 | pParse->nMem = 6; |
| 96557 | 97649 | sqlite3CodeVerifySchema(pParse, iDb); |
| 96558 | 97650 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", SQLITE_STATIC); |
| 96559 | 97651 | sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); |
| | @@ -96632,12 +97724,12 @@ |
| 96632 | 97724 | pParse->nMem = 3; |
| 96633 | 97725 | sqlite3CodeVerifySchema(pParse, iDb); |
| 96634 | 97726 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC); |
| 96635 | 97727 | sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC); |
| 96636 | 97728 | sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC); |
| 96637 | | - for(i=0; i<pIdx->nColumn; i++){ |
| 96638 | | - int cnum = pIdx->aiColumn[i]; |
| 97729 | + for(i=0; i<pIdx->nKeyCol; i++){ |
| 97730 | + i16 cnum = pIdx->aiColumn[i]; |
| 96639 | 97731 | sqlite3VdbeAddOp2(v, OP_Integer, i, 1); |
| 96640 | 97732 | sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2); |
| 96641 | 97733 | assert( pTab->nCol>cnum ); |
| 96642 | 97734 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0); |
| 96643 | 97735 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); |
| | @@ -96804,13 +97896,12 @@ |
| 96804 | 97896 | x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0); |
| 96805 | 97897 | if( x==0 ){ |
| 96806 | 97898 | if( pIdx==0 ){ |
| 96807 | 97899 | sqlite3OpenTable(pParse, i, iDb, pParent, OP_OpenRead); |
| 96808 | 97900 | }else{ |
| 96809 | | - KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 96810 | 97901 | sqlite3VdbeAddOp3(v, OP_OpenRead, i, pIdx->tnum, iDb); |
| 96811 | | - sqlite3VdbeChangeP4(v, -1, (char*)pKey, P4_KEYINFO_HANDOFF); |
| 97902 | + sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 96812 | 97903 | } |
| 96813 | 97904 | }else{ |
| 96814 | 97905 | k = 0; |
| 96815 | 97906 | break; |
| 96816 | 97907 | } |
| | @@ -96970,20 +98061,24 @@ |
| 96970 | 98061 | assert( sqlite3SchemaMutexHeld(db, i, 0) ); |
| 96971 | 98062 | pTbls = &db->aDb[i].pSchema->tblHash; |
| 96972 | 98063 | for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ |
| 96973 | 98064 | Table *pTab = sqliteHashData(x); |
| 96974 | 98065 | Index *pIdx; |
| 96975 | | - sqlite3VdbeAddOp2(v, OP_Integer, pTab->tnum, 2+cnt); |
| 96976 | | - cnt++; |
| 98066 | + if( HasRowid(pTab) ){ |
| 98067 | + sqlite3VdbeAddOp2(v, OP_Integer, pTab->tnum, 2+cnt); |
| 98068 | + VdbeComment((v, "%s", pTab->zName)); |
| 98069 | + cnt++; |
| 98070 | + } |
| 96977 | 98071 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 96978 | 98072 | sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt); |
| 98073 | + VdbeComment((v, "%s", pIdx->zName)); |
| 96979 | 98074 | cnt++; |
| 96980 | 98075 | } |
| 96981 | 98076 | } |
| 96982 | 98077 | |
| 96983 | 98078 | /* Make sure sufficient number of registers have been allocated */ |
| 96984 | | - pParse->nMem = MAX( pParse->nMem, cnt+7 ); |
| 98079 | + pParse->nMem = MAX( pParse->nMem, cnt+8 ); |
| 96985 | 98080 | |
| 96986 | 98081 | /* Do the b-tree integrity checks */ |
| 96987 | 98082 | sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1); |
| 96988 | 98083 | sqlite3VdbeChangeP5(v, (u8)i); |
| 96989 | 98084 | addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); |
| | @@ -96997,62 +98092,64 @@ |
| 96997 | 98092 | |
| 96998 | 98093 | /* Make sure all the indices are constructed correctly. |
| 96999 | 98094 | */ |
| 97000 | 98095 | for(x=sqliteHashFirst(pTbls); x && !isQuick; x=sqliteHashNext(x)){ |
| 97001 | 98096 | Table *pTab = sqliteHashData(x); |
| 97002 | | - Index *pIdx; |
| 98097 | + Index *pIdx, *pPk; |
| 97003 | 98098 | int loopTop; |
| 98099 | + int iDataCur, iIdxCur; |
| 97004 | 98100 | |
| 97005 | 98101 | if( pTab->pIndex==0 ) continue; |
| 98102 | + pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab); |
| 97006 | 98103 | addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */ |
| 97007 | 98104 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 97008 | 98105 | sqlite3VdbeJumpHere(v, addr); |
| 97009 | 98106 | sqlite3ExprCacheClear(pParse); |
| 97010 | | - sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); |
| 97011 | | - for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 97012 | | - sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */ |
| 97013 | | - } |
| 97014 | | - pParse->nMem = MAX(pParse->nMem, 7+j); |
| 97015 | | - loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1; |
| 97016 | | - for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 97017 | | - int jmp2, jmp3; |
| 98107 | + sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, |
| 98108 | + 1, &iDataCur, &iIdxCur); |
| 98109 | + sqlite3VdbeAddOp2(v, OP_Integer, 0, 7); |
| 98110 | + for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 98111 | + sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */ |
| 98112 | + } |
| 98113 | + pParse->nMem = MAX(pParse->nMem, 8+j); |
| 98114 | + sqlite3VdbeAddOp2(v, OP_Rewind, iDataCur, 0); |
| 98115 | + loopTop = sqlite3VdbeAddOp2(v, OP_AddImm, 7, 1); |
| 98116 | + for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 98117 | + int jmp2, jmp3, jmp4; |
| 97018 | 98118 | int r1; |
| 97019 | | - static const VdbeOpList idxErr[] = { |
| 97020 | | - { OP_AddImm, 1, -1, 0}, |
| 97021 | | - { OP_String8, 0, 3, 0}, /* 1 */ |
| 97022 | | - { OP_Rowid, 1, 4, 0}, |
| 97023 | | - { OP_String8, 0, 5, 0}, /* 3 */ |
| 97024 | | - { OP_String8, 0, 6, 0}, /* 4 */ |
| 97025 | | - { OP_Concat, 4, 3, 3}, |
| 97026 | | - { OP_Concat, 5, 3, 3}, |
| 97027 | | - { OP_Concat, 6, 3, 3}, |
| 97028 | | - { OP_ResultRow, 3, 1, 0}, |
| 97029 | | - { OP_IfPos, 1, 0, 0}, /* 9 */ |
| 97030 | | - { OP_Halt, 0, 0, 0}, |
| 97031 | | - }; |
| 97032 | | - r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3); |
| 97033 | | - sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */ |
| 97034 | | - jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1); |
| 97035 | | - addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); |
| 97036 | | - sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC); |
| 97037 | | - sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC); |
| 97038 | | - sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT); |
| 97039 | | - sqlite3VdbeJumpHere(v, addr+9); |
| 98119 | + if( pPk==pIdx ) continue; |
| 98120 | + r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3); |
| 98121 | + sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */ |
| 98122 | + jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, 0, r1, |
| 98123 | + pIdx->nColumn); |
| 98124 | + sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */ |
| 98125 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, "row ", P4_STATIC); |
| 98126 | + sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); |
| 98127 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, " missing from index ", |
| 98128 | + P4_STATIC); |
| 98129 | + sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 98130 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, pIdx->zName, P4_TRANSIENT); |
| 98131 | + sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 98132 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1); |
| 98133 | + jmp4 = sqlite3VdbeAddOp1(v, OP_IfPos, 1); |
| 98134 | + sqlite3VdbeAddOp0(v, OP_Halt); |
| 98135 | + sqlite3VdbeJumpHere(v, jmp4); |
| 97040 | 98136 | sqlite3VdbeJumpHere(v, jmp2); |
| 97041 | 98137 | sqlite3VdbeResolveLabel(v, jmp3); |
| 97042 | 98138 | } |
| 97043 | | - sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop); |
| 98139 | + sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); |
| 97044 | 98140 | sqlite3VdbeJumpHere(v, loopTop-1); |
| 97045 | 98141 | #ifndef SQLITE_OMIT_BTREECOUNT |
| 97046 | 98142 | sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, |
| 97047 | 98143 | "wrong # of entries in index ", P4_STATIC); |
| 97048 | 98144 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 98145 | + if( pPk==pIdx ) continue; |
| 97049 | 98146 | addr = sqlite3VdbeCurrentAddr(v); |
| 97050 | 98147 | sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2); |
| 97051 | 98148 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 97052 | | - sqlite3VdbeAddOp2(v, OP_Count, j+2, 3); |
| 97053 | | - sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3); |
| 98149 | + sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3); |
| 98150 | + sqlite3VdbeAddOp3(v, OP_Eq, 8+j, addr+8, 3); |
| 97054 | 98151 | sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); |
| 97055 | 98152 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT); |
| 97056 | 98153 | sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7); |
| 97057 | 98154 | sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1); |
| 97058 | 98155 | } |
| | @@ -99096,28 +100193,61 @@ |
| 99096 | 100193 | sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); |
| 99097 | 100194 | } |
| 99098 | 100195 | } |
| 99099 | 100196 | |
| 99100 | 100197 | /* |
| 99101 | | -** Allocate a KeyInfo object sufficient for an index of N columns. |
| 99102 | | -** |
| 99103 | | -** Actually, always allocate one extra column for the rowid at the end |
| 99104 | | -** of the index. So the KeyInfo returned will have space sufficient for |
| 99105 | | -** N+1 columns. |
| 100198 | +** Allocate a KeyInfo object sufficient for an index of N key columns and |
| 100199 | +** X extra columns. |
| 99106 | 100200 | */ |
| 99107 | | -SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){ |
| 99108 | | - KeyInfo *p = sqlite3DbMallocZero(db, |
| 99109 | | - sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1)); |
| 100201 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){ |
| 100202 | + KeyInfo *p = sqlite3DbMallocZero(0, |
| 100203 | + sizeof(KeyInfo) + (N+X)*(sizeof(CollSeq*)+1)); |
| 99110 | 100204 | if( p ){ |
| 99111 | | - p->aSortOrder = (u8*)&p->aColl[N+1]; |
| 100205 | + p->aSortOrder = (u8*)&p->aColl[N+X]; |
| 99112 | 100206 | p->nField = (u16)N; |
| 100207 | + p->nXField = (u16)X; |
| 99113 | 100208 | p->enc = ENC(db); |
| 99114 | 100209 | p->db = db; |
| 100210 | + p->nRef = 1; |
| 100211 | + }else{ |
| 100212 | + db->mallocFailed = 1; |
| 100213 | + } |
| 100214 | + return p; |
| 100215 | +} |
| 100216 | + |
| 100217 | +/* |
| 100218 | +** Deallocate a KeyInfo object |
| 100219 | +*/ |
| 100220 | +SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){ |
| 100221 | + if( p ){ |
| 100222 | + assert( p->nRef>0 ); |
| 100223 | + p->nRef--; |
| 100224 | + if( p->nRef==0 ) sqlite3DbFree(0, p); |
| 100225 | + } |
| 100226 | +} |
| 100227 | + |
| 100228 | +/* |
| 100229 | +** Make a new pointer to a KeyInfo object |
| 100230 | +*/ |
| 100231 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo *p){ |
| 100232 | + if( p ){ |
| 100233 | + assert( p->nRef>0 ); |
| 100234 | + p->nRef++; |
| 99115 | 100235 | } |
| 99116 | 100236 | return p; |
| 99117 | 100237 | } |
| 99118 | 100238 | |
| 100239 | +#ifdef SQLITE_DEBUG |
| 100240 | +/* |
| 100241 | +** Return TRUE if a KeyInfo object can be change. The KeyInfo object |
| 100242 | +** can only be changed if this is just a single reference to the object. |
| 100243 | +** |
| 100244 | +** This routine is used only inside of assert() statements. |
| 100245 | +*/ |
| 100246 | +SQLITE_PRIVATE int sqlite3KeyInfoIsWriteable(KeyInfo *p){ return p->nRef==1; } |
| 100247 | +#endif /* SQLITE_DEBUG */ |
| 100248 | + |
| 99119 | 100249 | /* |
| 99120 | 100250 | ** Given an expression list, generate a KeyInfo structure that records |
| 99121 | 100251 | ** the collating sequence for each expression in that expression list. |
| 99122 | 100252 | ** |
| 99123 | 100253 | ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting |
| | @@ -99126,23 +100256,23 @@ |
| 99126 | 100256 | ** then the KeyInfo structure is appropriate for initializing a virtual |
| 99127 | 100257 | ** index to implement a DISTINCT test. |
| 99128 | 100258 | ** |
| 99129 | 100259 | ** Space to hold the KeyInfo structure is obtain from malloc. The calling |
| 99130 | 100260 | ** function is responsible for seeing that this structure is eventually |
| 99131 | | -** freed. Add the KeyInfo structure to the P4 field of an opcode using |
| 99132 | | -** P4_KEYINFO_HANDOFF is the usual way of dealing with this. |
| 100261 | +** freed. |
| 99133 | 100262 | */ |
| 99134 | 100263 | static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){ |
| 99135 | 100264 | int nExpr; |
| 99136 | 100265 | KeyInfo *pInfo; |
| 99137 | 100266 | struct ExprList_item *pItem; |
| 99138 | 100267 | sqlite3 *db = pParse->db; |
| 99139 | 100268 | int i; |
| 99140 | 100269 | |
| 99141 | 100270 | nExpr = pList->nExpr; |
| 99142 | | - pInfo = sqlite3KeyInfoAlloc(db, nExpr); |
| 100271 | + pInfo = sqlite3KeyInfoAlloc(db, nExpr, 1); |
| 99143 | 100272 | if( pInfo ){ |
| 100273 | + assert( sqlite3KeyInfoIsWriteable(pInfo) ); |
| 99144 | 100274 | for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){ |
| 99145 | 100275 | CollSeq *pColl; |
| 99146 | 100276 | pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); |
| 99147 | 100277 | if( !pColl ) pColl = db->pDfltColl; |
| 99148 | 100278 | pInfo->aColl[i] = pColl; |
| | @@ -100281,11 +101411,11 @@ |
| 100281 | 101411 | CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */ |
| 100282 | 101412 | int nCol; /* Number of columns in result set */ |
| 100283 | 101413 | |
| 100284 | 101414 | assert( p->pRightmost==p ); |
| 100285 | 101415 | nCol = p->pEList->nExpr; |
| 100286 | | - pKeyInfo = sqlite3KeyInfoAlloc(db, nCol); |
| 101416 | + pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1); |
| 100287 | 101417 | if( !pKeyInfo ){ |
| 100288 | 101418 | rc = SQLITE_NOMEM; |
| 100289 | 101419 | goto multi_select_end; |
| 100290 | 101420 | } |
| 100291 | 101421 | for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){ |
| | @@ -100303,15 +101433,16 @@ |
| 100303 | 101433 | ** always safely abort as soon as the first unused slot is found */ |
| 100304 | 101434 | assert( pLoop->addrOpenEphm[1]<0 ); |
| 100305 | 101435 | break; |
| 100306 | 101436 | } |
| 100307 | 101437 | sqlite3VdbeChangeP2(v, addr, nCol); |
| 100308 | | - sqlite3VdbeChangeP4(v, addr, (char*)pKeyInfo, P4_KEYINFO); |
| 101438 | + sqlite3VdbeChangeP4(v, addr, (char*)sqlite3KeyInfoRef(pKeyInfo), |
| 101439 | + P4_KEYINFO); |
| 100309 | 101440 | pLoop->addrOpenEphm[i] = -1; |
| 100310 | 101441 | } |
| 100311 | 101442 | } |
| 100312 | | - sqlite3DbFree(db, pKeyInfo); |
| 101443 | + sqlite3KeyInfoUnref(pKeyInfo); |
| 100313 | 101444 | } |
| 100314 | 101445 | |
| 100315 | 101446 | multi_select_end: |
| 100316 | 101447 | pDest->iSdst = dest.iSdst; |
| 100317 | 101448 | pDest->nSdst = dest.nSdst; |
| | @@ -100346,11 +101477,10 @@ |
| 100346 | 101477 | SelectDest *pIn, /* Coroutine supplying data */ |
| 100347 | 101478 | SelectDest *pDest, /* Where to send the data */ |
| 100348 | 101479 | int regReturn, /* The return address register */ |
| 100349 | 101480 | int regPrev, /* Previous result register. No uniqueness if 0 */ |
| 100350 | 101481 | KeyInfo *pKeyInfo, /* For comparing with previous entry */ |
| 100351 | | - int p4type, /* The p4 type for pKeyInfo */ |
| 100352 | 101482 | int iBreak /* Jump here if we hit the LIMIT */ |
| 100353 | 101483 | ){ |
| 100354 | 101484 | Vdbe *v = pParse->pVdbe; |
| 100355 | 101485 | int iContinue; |
| 100356 | 101486 | int addr; |
| | @@ -100362,11 +101492,11 @@ |
| 100362 | 101492 | */ |
| 100363 | 101493 | if( regPrev ){ |
| 100364 | 101494 | int j1, j2; |
| 100365 | 101495 | j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); |
| 100366 | 101496 | j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst, |
| 100367 | | - (char*)pKeyInfo, p4type); |
| 101497 | + (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO); |
| 100368 | 101498 | sqlite3VdbeAddOp3(v, OP_Jump, j2+2, iContinue, j2+2); |
| 100369 | 101499 | sqlite3VdbeJumpHere(v, j1); |
| 100370 | 101500 | sqlite3VdbeAddOp3(v, OP_Copy, pIn->iSdst, regPrev+1, pIn->nSdst-1); |
| 100371 | 101501 | sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev); |
| 100372 | 101502 | } |
| | @@ -100660,11 +101790,11 @@ |
| 100660 | 101790 | struct ExprList_item *pItem; |
| 100661 | 101791 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 100662 | 101792 | assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr ); |
| 100663 | 101793 | aPermute[i] = pItem->iOrderByCol - 1; |
| 100664 | 101794 | } |
| 100665 | | - pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy); |
| 101795 | + pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy, 1); |
| 100666 | 101796 | if( pKeyMerge ){ |
| 100667 | 101797 | for(i=0; i<nOrderBy; i++){ |
| 100668 | 101798 | CollSeq *pColl; |
| 100669 | 101799 | Expr *pTerm = pOrderBy->a[i].pExpr; |
| 100670 | 101800 | if( pTerm->flags & EP_Collate ){ |
| | @@ -100673,10 +101803,11 @@ |
| 100673 | 101803 | pColl = multiSelectCollSeq(pParse, p, aPermute[i]); |
| 100674 | 101804 | if( pColl==0 ) pColl = db->pDfltColl; |
| 100675 | 101805 | pOrderBy->a[i].pExpr = |
| 100676 | 101806 | sqlite3ExprAddCollateString(pParse, pTerm, pColl->zName); |
| 100677 | 101807 | } |
| 101808 | + assert( sqlite3KeyInfoIsWriteable(pKeyMerge) ); |
| 100678 | 101809 | pKeyMerge->aColl[i] = pColl; |
| 100679 | 101810 | pKeyMerge->aSortOrder[i] = pOrderBy->a[i].sortOrder; |
| 100680 | 101811 | } |
| 100681 | 101812 | } |
| 100682 | 101813 | }else{ |
| | @@ -100698,12 +101829,13 @@ |
| 100698 | 101829 | int nExpr = p->pEList->nExpr; |
| 100699 | 101830 | assert( nOrderBy>=nExpr || db->mallocFailed ); |
| 100700 | 101831 | regPrev = pParse->nMem+1; |
| 100701 | 101832 | pParse->nMem += nExpr+1; |
| 100702 | 101833 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev); |
| 100703 | | - pKeyDup = sqlite3KeyInfoAlloc(db, nExpr); |
| 101834 | + pKeyDup = sqlite3KeyInfoAlloc(db, nExpr, 1); |
| 100704 | 101835 | if( pKeyDup ){ |
| 101836 | + assert( sqlite3KeyInfoIsWriteable(pKeyDup) ); |
| 100705 | 101837 | for(i=0; i<nExpr; i++){ |
| 100706 | 101838 | pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i); |
| 100707 | 101839 | pKeyDup->aSortOrder[i] = 0; |
| 100708 | 101840 | } |
| 100709 | 101841 | } |
| | @@ -100781,21 +101913,22 @@ |
| 100781 | 101913 | ** select as the next output row of the compound select. |
| 100782 | 101914 | */ |
| 100783 | 101915 | VdbeNoopComment((v, "Output routine for A")); |
| 100784 | 101916 | addrOutA = generateOutputSubroutine(pParse, |
| 100785 | 101917 | p, &destA, pDest, regOutA, |
| 100786 | | - regPrev, pKeyDup, P4_KEYINFO_HANDOFF, labelEnd); |
| 101918 | + regPrev, pKeyDup, labelEnd); |
| 100787 | 101919 | |
| 100788 | 101920 | /* Generate a subroutine that outputs the current row of the B |
| 100789 | 101921 | ** select as the next output row of the compound select. |
| 100790 | 101922 | */ |
| 100791 | 101923 | if( op==TK_ALL || op==TK_UNION ){ |
| 100792 | 101924 | VdbeNoopComment((v, "Output routine for B")); |
| 100793 | 101925 | addrOutB = generateOutputSubroutine(pParse, |
| 100794 | 101926 | p, &destB, pDest, regOutB, |
| 100795 | | - regPrev, pKeyDup, P4_KEYINFO_STATIC, labelEnd); |
| 101927 | + regPrev, pKeyDup, labelEnd); |
| 100796 | 101928 | } |
| 101929 | + sqlite3KeyInfoUnref(pKeyDup); |
| 100797 | 101930 | |
| 100798 | 101931 | /* Generate a subroutine to run when the results from select A |
| 100799 | 101932 | ** are exhausted and only data in select B remains. |
| 100800 | 101933 | */ |
| 100801 | 101934 | VdbeNoopComment((v, "eof-A subroutine")); |
| | @@ -100870,11 +102003,11 @@ |
| 100870 | 102003 | /* Implement the main merge loop |
| 100871 | 102004 | */ |
| 100872 | 102005 | sqlite3VdbeResolveLabel(v, labelCmpr); |
| 100873 | 102006 | sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY); |
| 100874 | 102007 | sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy, |
| 100875 | | - (char*)pKeyMerge, P4_KEYINFO_HANDOFF); |
| 102008 | + (char*)pKeyMerge, P4_KEYINFO); |
| 100876 | 102009 | sqlite3VdbeChangeP5(v, OPFLAG_PERMUTE); |
| 100877 | 102010 | sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); |
| 100878 | 102011 | |
| 100879 | 102012 | /* Jump to the this point in order to terminate the query. |
| 100880 | 102013 | */ |
| | @@ -102096,11 +103229,11 @@ |
| 102096 | 103229 | "argument"); |
| 102097 | 103230 | pFunc->iDistinct = -1; |
| 102098 | 103231 | }else{ |
| 102099 | 103232 | KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->x.pList); |
| 102100 | 103233 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, pFunc->iDistinct, 0, 0, |
| 102101 | | - (char*)pKeyInfo, P4_KEYINFO_HANDOFF); |
| 103234 | + (char*)pKeyInfo, P4_KEYINFO); |
| 102102 | 103235 | } |
| 102103 | 103236 | } |
| 102104 | 103237 | } |
| 102105 | 103238 | } |
| 102106 | 103239 | |
| | @@ -102551,11 +103684,11 @@ |
| 102551 | 103684 | pKeyInfo = keyInfoFromExprList(pParse, pOrderBy); |
| 102552 | 103685 | pOrderBy->iECursor = pParse->nTab++; |
| 102553 | 103686 | p->addrOpenEphm[2] = addrSortIndex = |
| 102554 | 103687 | sqlite3VdbeAddOp4(v, OP_OpenEphemeral, |
| 102555 | 103688 | pOrderBy->iECursor, pOrderBy->nExpr+2, 0, |
| 102556 | | - (char*)pKeyInfo, P4_KEYINFO_HANDOFF); |
| 103689 | + (char*)pKeyInfo, P4_KEYINFO); |
| 102557 | 103690 | }else{ |
| 102558 | 103691 | addrSortIndex = -1; |
| 102559 | 103692 | } |
| 102560 | 103693 | |
| 102561 | 103694 | /* If the output is destined for a temporary table, open that table. |
| | @@ -102579,11 +103712,11 @@ |
| 102579 | 103712 | if( p->selFlags & SF_Distinct ){ |
| 102580 | 103713 | sDistinct.tabTnct = pParse->nTab++; |
| 102581 | 103714 | sDistinct.addrTnct = sqlite3VdbeAddOp4(v, OP_OpenEphemeral, |
| 102582 | 103715 | sDistinct.tabTnct, 0, 0, |
| 102583 | 103716 | (char*)keyInfoFromExprList(pParse, p->pEList), |
| 102584 | | - P4_KEYINFO_HANDOFF); |
| 103717 | + P4_KEYINFO); |
| 102585 | 103718 | sqlite3VdbeChangeP5(v, BTREE_UNORDERED); |
| 102586 | 103719 | sDistinct.eTnctType = WHERE_DISTINCT_UNORDERED; |
| 102587 | 103720 | }else{ |
| 102588 | 103721 | sDistinct.eTnctType = WHERE_DISTINCT_NOOP; |
| 102589 | 103722 | } |
| | @@ -102703,11 +103836,11 @@ |
| 102703 | 103836 | */ |
| 102704 | 103837 | sAggInfo.sortingIdx = pParse->nTab++; |
| 102705 | 103838 | pKeyInfo = keyInfoFromExprList(pParse, pGroupBy); |
| 102706 | 103839 | addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen, |
| 102707 | 103840 | sAggInfo.sortingIdx, sAggInfo.nSortingColumn, |
| 102708 | | - 0, (char*)pKeyInfo, P4_KEYINFO_HANDOFF); |
| 103841 | + 0, (char*)pKeyInfo, P4_KEYINFO); |
| 102709 | 103842 | |
| 102710 | 103843 | /* Initialize memory locations used by GROUP BY aggregate processing |
| 102711 | 103844 | */ |
| 102712 | 103845 | iUseFlag = ++pParse->nMem; |
| 102713 | 103846 | iAbortFlag = ++pParse->nMem; |
| | @@ -102817,11 +103950,11 @@ |
| 102817 | 103950 | sAggInfo.directMode = 1; |
| 102818 | 103951 | sqlite3ExprCode(pParse, pGroupBy->a[j].pExpr, iBMem+j); |
| 102819 | 103952 | } |
| 102820 | 103953 | } |
| 102821 | 103954 | sqlite3VdbeAddOp4(v, OP_Compare, iAMem, iBMem, pGroupBy->nExpr, |
| 102822 | | - (char*)pKeyInfo, P4_KEYINFO); |
| 103955 | + (char*)sqlite3KeyInfoRef(pKeyInfo), P4_KEYINFO); |
| 102823 | 103956 | j1 = sqlite3VdbeCurrentAddr(v); |
| 102824 | 103957 | sqlite3VdbeAddOp3(v, OP_Jump, j1+1, 0, j1+1); |
| 102825 | 103958 | |
| 102826 | 103959 | /* Generate code that runs whenever the GROUP BY changes. |
| 102827 | 103960 | ** Changes in the GROUP BY are detected by the previous code |
| | @@ -102943,17 +104076,17 @@ |
| 102943 | 104076 | pBest = pIdx; |
| 102944 | 104077 | } |
| 102945 | 104078 | } |
| 102946 | 104079 | if( pBest ){ |
| 102947 | 104080 | iRoot = pBest->tnum; |
| 102948 | | - pKeyInfo = sqlite3IndexKeyinfo(pParse, pBest); |
| 104081 | + pKeyInfo = sqlite3KeyInfoOfIndex(pParse, pBest); |
| 102949 | 104082 | } |
| 102950 | 104083 | |
| 102951 | 104084 | /* Open a read-only cursor, execute the OP_Count, close the cursor. */ |
| 102952 | | - sqlite3VdbeAddOp3(v, OP_OpenRead, iCsr, iRoot, iDb); |
| 104085 | + sqlite3VdbeAddOp4Int(v, OP_OpenRead, iCsr, iRoot, iDb, 1); |
| 102953 | 104086 | if( pKeyInfo ){ |
| 102954 | | - sqlite3VdbeChangeP4(v, -1, (char *)pKeyInfo, P4_KEYINFO_HANDOFF); |
| 104087 | + sqlite3VdbeChangeP4(v, -1, (char *)pKeyInfo, P4_KEYINFO); |
| 102955 | 104088 | } |
| 102956 | 104089 | sqlite3VdbeAddOp2(v, OP_Count, iCsr, sAggInfo.aFunc[0].iMem); |
| 102957 | 104090 | sqlite3VdbeAddOp1(v, OP_Close, iCsr); |
| 102958 | 104091 | explainSimpleCount(pParse, pTab, pBest); |
| 102959 | 104092 | }else |
| | @@ -104155,11 +105288,11 @@ |
| 104155 | 105288 | } |
| 104156 | 105289 | |
| 104157 | 105290 | return 0; |
| 104158 | 105291 | } |
| 104159 | 105292 | |
| 104160 | | -#ifdef SQLITE_DEBUG |
| 105293 | +#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 104161 | 105294 | /* |
| 104162 | 105295 | ** This function is used to add VdbeComment() annotations to a VDBE |
| 104163 | 105296 | ** program. It is not used in production code, only for debugging. |
| 104164 | 105297 | */ |
| 104165 | 105298 | static const char *onErrorText(int onError){ |
| | @@ -104603,44 +105736,54 @@ |
| 104603 | 105736 | Expr *pWhere, /* The WHERE clause. May be null */ |
| 104604 | 105737 | int onError /* How to handle constraint errors */ |
| 104605 | 105738 | ){ |
| 104606 | 105739 | int i, j; /* Loop counters */ |
| 104607 | 105740 | Table *pTab; /* The table to be updated */ |
| 104608 | | - int addr = 0; /* VDBE instruction address of the start of the loop */ |
| 105741 | + int addrTop = 0; /* VDBE instruction address of the start of the loop */ |
| 104609 | 105742 | WhereInfo *pWInfo; /* Information about the WHERE clause */ |
| 104610 | 105743 | Vdbe *v; /* The virtual database engine */ |
| 104611 | 105744 | Index *pIdx; /* For looping over indices */ |
| 105745 | + Index *pPk; /* The PRIMARY KEY index for WITHOUT ROWID tables */ |
| 104612 | 105746 | int nIdx; /* Number of indices that need updating */ |
| 104613 | | - int iCur; /* VDBE Cursor number of pTab */ |
| 105747 | + int iDataCur; /* Cursor for the canonical data btree */ |
| 105748 | + int iIdxCur; /* Cursor for the first index */ |
| 104614 | 105749 | sqlite3 *db; /* The database structure */ |
| 104615 | 105750 | int *aRegIdx = 0; /* One register assigned to each index to be updated */ |
| 104616 | 105751 | int *aXRef = 0; /* aXRef[i] is the index in pChanges->a[] of the |
| 104617 | 105752 | ** an expression for the i-th column of the table. |
| 104618 | 105753 | ** aXRef[i]==-1 if the i-th column is not changed. */ |
| 104619 | | - int chngRowid; /* True if the record number is being changed */ |
| 105754 | + u8 chngPk; /* PRIMARY KEY changed in a WITHOUT ROWID table */ |
| 105755 | + u8 chngRowid; /* Rowid changed in a normal table */ |
| 105756 | + u8 chngKey; /* Either chngPk or chngRowid */ |
| 104620 | 105757 | Expr *pRowidExpr = 0; /* Expression defining the new record number */ |
| 104621 | 105758 | int openAll = 0; /* True if all indices need to be opened */ |
| 104622 | 105759 | AuthContext sContext; /* The authorization context */ |
| 104623 | 105760 | NameContext sNC; /* The name-context to resolve expressions in */ |
| 104624 | 105761 | int iDb; /* Database containing the table being updated */ |
| 104625 | 105762 | int okOnePass; /* True for one-pass algorithm without the FIFO */ |
| 104626 | 105763 | int hasFK; /* True if foreign key processing is required */ |
| 105764 | + int labelBreak; /* Jump here to break out of UPDATE loop */ |
| 105765 | + int labelContinue; /* Jump here to continue next step of UPDATE loop */ |
| 104627 | 105766 | |
| 104628 | 105767 | #ifndef SQLITE_OMIT_TRIGGER |
| 104629 | 105768 | int isView; /* True when updating a view (INSTEAD OF trigger) */ |
| 104630 | 105769 | Trigger *pTrigger; /* List of triggers on pTab, if required */ |
| 104631 | 105770 | int tmask; /* Mask of TRIGGER_BEFORE|TRIGGER_AFTER */ |
| 104632 | 105771 | #endif |
| 104633 | 105772 | int newmask; /* Mask of NEW.* columns accessed by BEFORE triggers */ |
| 105773 | + int iEph = 0; /* Ephemeral table holding all primary key values */ |
| 105774 | + int nKey = 0; /* Number of elements in regKey for WITHOUT ROWID */ |
| 105775 | + int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */ |
| 104634 | 105776 | |
| 104635 | 105777 | /* Register Allocations */ |
| 104636 | 105778 | int regRowCount = 0; /* A count of rows changed */ |
| 104637 | 105779 | int regOldRowid; /* The old rowid */ |
| 104638 | 105780 | int regNewRowid; /* The new rowid */ |
| 104639 | 105781 | int regNew; /* Content of the NEW.* table in triggers */ |
| 104640 | 105782 | int regOld = 0; /* Content of OLD.* table in triggers */ |
| 104641 | 105783 | int regRowSet = 0; /* Rowset of rows to be updated */ |
| 105784 | + int regKey = 0; /* composite PRIMARY KEY value */ |
| 104642 | 105785 | |
| 104643 | 105786 | memset(&sContext, 0, sizeof(sContext)); |
| 104644 | 105787 | db = pParse->db; |
| 104645 | 105788 | if( pParse->nErr || db->mallocFailed ){ |
| 104646 | 105789 | goto update_cleanup; |
| | @@ -104683,12 +105826,18 @@ |
| 104683 | 105826 | /* Allocate a cursors for the main database table and for all indices. |
| 104684 | 105827 | ** The index cursors might not be used, but if they are used they |
| 104685 | 105828 | ** need to occur right after the database cursor. So go ahead and |
| 104686 | 105829 | ** allocate enough space, just in case. |
| 104687 | 105830 | */ |
| 104688 | | - pTabList->a[0].iCursor = iCur = pParse->nTab++; |
| 104689 | | - for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 105831 | + pTabList->a[0].iCursor = iDataCur = pParse->nTab++; |
| 105832 | + iIdxCur = iDataCur+1; |
| 105833 | + pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab); |
| 105834 | + for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ |
| 105835 | + if( pIdx->autoIndex==2 && pPk!=0 ){ |
| 105836 | + iDataCur = pParse->nTab; |
| 105837 | + pTabList->a[0].iCursor = iDataCur; |
| 105838 | + } |
| 104690 | 105839 | pParse->nTab++; |
| 104691 | 105840 | } |
| 104692 | 105841 | |
| 104693 | 105842 | /* Initialize the name-context */ |
| 104694 | 105843 | memset(&sNC, 0, sizeof(sNC)); |
| | @@ -104699,27 +105848,29 @@ |
| 104699 | 105848 | ** of the UPDATE statement. Also find the column index |
| 104700 | 105849 | ** for each column to be updated in the pChanges array. For each |
| 104701 | 105850 | ** column to be updated, make sure we have authorization to change |
| 104702 | 105851 | ** that column. |
| 104703 | 105852 | */ |
| 104704 | | - chngRowid = 0; |
| 105853 | + chngRowid = chngPk = 0; |
| 104705 | 105854 | for(i=0; i<pChanges->nExpr; i++){ |
| 104706 | 105855 | if( sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){ |
| 104707 | 105856 | goto update_cleanup; |
| 104708 | 105857 | } |
| 104709 | 105858 | for(j=0; j<pTab->nCol; j++){ |
| 104710 | 105859 | if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zName)==0 ){ |
| 104711 | 105860 | if( j==pTab->iPKey ){ |
| 104712 | 105861 | chngRowid = 1; |
| 104713 | 105862 | pRowidExpr = pChanges->a[i].pExpr; |
| 105863 | + }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){ |
| 105864 | + chngPk = 1; |
| 104714 | 105865 | } |
| 104715 | 105866 | aXRef[j] = i; |
| 104716 | 105867 | break; |
| 104717 | 105868 | } |
| 104718 | 105869 | } |
| 104719 | 105870 | if( j>=pTab->nCol ){ |
| 104720 | | - if( sqlite3IsRowid(pChanges->a[i].zName) ){ |
| 105871 | + if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zName) ){ |
| 104721 | 105872 | j = -1; |
| 104722 | 105873 | chngRowid = 1; |
| 104723 | 105874 | pRowidExpr = pChanges->a[i].pExpr; |
| 104724 | 105875 | }else{ |
| 104725 | 105876 | sqlite3ErrorMsg(pParse, "no such column: %s", pChanges->a[i].zName); |
| | @@ -104739,30 +105890,33 @@ |
| 104739 | 105890 | aXRef[j] = -1; |
| 104740 | 105891 | } |
| 104741 | 105892 | } |
| 104742 | 105893 | #endif |
| 104743 | 105894 | } |
| 105895 | + assert( (chngRowid & chngPk)==0 ); |
| 105896 | + assert( chngRowid==0 || chngRowid==1 ); |
| 105897 | + assert( chngPk==0 || chngPk==1 ); |
| 105898 | + chngKey = chngRowid + chngPk; |
| 104744 | 105899 | |
| 104745 | | - hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngRowid); |
| 105900 | + hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey); |
| 104746 | 105901 | |
| 104747 | 105902 | /* Allocate memory for the array aRegIdx[]. There is one entry in the |
| 104748 | 105903 | ** array for each index associated with table being updated. Fill in |
| 104749 | 105904 | ** the value with a register number for indices that are to be used |
| 104750 | 105905 | ** and with zero for unused indices. |
| 104751 | 105906 | */ |
| 104752 | | - for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){} |
| 104753 | 105907 | if( nIdx>0 ){ |
| 104754 | 105908 | aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx ); |
| 104755 | 105909 | if( aRegIdx==0 ) goto update_cleanup; |
| 104756 | 105910 | } |
| 104757 | 105911 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 104758 | 105912 | int reg; |
| 104759 | | - if( hasFK || chngRowid || pIdx->pPartIdxWhere ){ |
| 105913 | + if( chngKey || hasFK || pIdx->pPartIdxWhere || pIdx==pPk ){ |
| 104760 | 105914 | reg = ++pParse->nMem; |
| 104761 | 105915 | }else{ |
| 104762 | 105916 | reg = 0; |
| 104763 | | - for(i=0; i<pIdx->nColumn; i++){ |
| 105917 | + for(i=0; i<pIdx->nKeyCol; i++){ |
| 104764 | 105918 | if( aXRef[pIdx->aiColumn[i]]>=0 ){ |
| 104765 | 105919 | reg = ++pParse->nMem; |
| 104766 | 105920 | break; |
| 104767 | 105921 | } |
| 104768 | 105922 | } |
| | @@ -104788,15 +105942,15 @@ |
| 104788 | 105942 | #endif |
| 104789 | 105943 | |
| 104790 | 105944 | /* Allocate required registers. */ |
| 104791 | 105945 | regRowSet = ++pParse->nMem; |
| 104792 | 105946 | regOldRowid = regNewRowid = ++pParse->nMem; |
| 104793 | | - if( pTrigger || hasFK ){ |
| 105947 | + if( chngPk || pTrigger || hasFK ){ |
| 104794 | 105948 | regOld = pParse->nMem + 1; |
| 104795 | 105949 | pParse->nMem += pTab->nCol; |
| 104796 | 105950 | } |
| 104797 | | - if( chngRowid || pTrigger || hasFK ){ |
| 105951 | + if( chngKey || pTrigger || hasFK ){ |
| 104798 | 105952 | regNewRowid = ++pParse->nMem; |
| 104799 | 105953 | } |
| 104800 | 105954 | regNew = pParse->nMem + 1; |
| 104801 | 105955 | pParse->nMem += pTab->nCol; |
| 104802 | 105956 | |
| | @@ -104808,11 +105962,11 @@ |
| 104808 | 105962 | /* If we are trying to update a view, realize that view into |
| 104809 | 105963 | ** a ephemeral table. |
| 104810 | 105964 | */ |
| 104811 | 105965 | #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) |
| 104812 | 105966 | if( isView ){ |
| 104813 | | - sqlite3MaterializeView(pParse, pTab, pWhere, iCur); |
| 105967 | + sqlite3MaterializeView(pParse, pTab, pWhere, iDataCur); |
| 104814 | 105968 | } |
| 104815 | 105969 | #endif |
| 104816 | 105970 | |
| 104817 | 105971 | /* Resolve the column names in all the expressions in the |
| 104818 | 105972 | ** WHERE clause. |
| | @@ -104821,43 +105975,81 @@ |
| 104821 | 105975 | goto update_cleanup; |
| 104822 | 105976 | } |
| 104823 | 105977 | |
| 104824 | 105978 | /* Begin the database scan |
| 104825 | 105979 | */ |
| 104826 | | - sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid); |
| 104827 | | - pWInfo = sqlite3WhereBegin( |
| 104828 | | - pParse, pTabList, pWhere, 0, 0, WHERE_ONEPASS_DESIRED, 0 |
| 104829 | | - ); |
| 104830 | | - if( pWInfo==0 ) goto update_cleanup; |
| 104831 | | - okOnePass = sqlite3WhereOkOnePass(pWInfo); |
| 104832 | | - |
| 104833 | | - /* Remember the rowid of every item to be updated. |
| 104834 | | - */ |
| 104835 | | - sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regOldRowid); |
| 104836 | | - if( !okOnePass ){ |
| 104837 | | - sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid); |
| 104838 | | - } |
| 104839 | | - |
| 104840 | | - /* End the database scan loop. |
| 104841 | | - */ |
| 104842 | | - sqlite3WhereEnd(pWInfo); |
| 105980 | + if( HasRowid(pTab) ){ |
| 105981 | + sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid); |
| 105982 | + pWInfo = sqlite3WhereBegin( |
| 105983 | + pParse, pTabList, pWhere, 0, 0, WHERE_ONEPASS_DESIRED, iIdxCur |
| 105984 | + ); |
| 105985 | + if( pWInfo==0 ) goto update_cleanup; |
| 105986 | + okOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); |
| 105987 | + |
| 105988 | + /* Remember the rowid of every item to be updated. |
| 105989 | + */ |
| 105990 | + sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid); |
| 105991 | + if( !okOnePass ){ |
| 105992 | + sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid); |
| 105993 | + } |
| 105994 | + |
| 105995 | + /* End the database scan loop. |
| 105996 | + */ |
| 105997 | + sqlite3WhereEnd(pWInfo); |
| 105998 | + }else{ |
| 105999 | + int iPk; /* First of nPk memory cells holding PRIMARY KEY value */ |
| 106000 | + i16 nPk; /* Number of components of the PRIMARY KEY */ |
| 106001 | + int addrOpen; /* Address of the OpenEphemeral instruction */ |
| 106002 | + |
| 106003 | + assert( pPk!=0 ); |
| 106004 | + nPk = pPk->nKeyCol; |
| 106005 | + iPk = pParse->nMem+1; |
| 106006 | + pParse->nMem += nPk; |
| 106007 | + regKey = ++pParse->nMem; |
| 106008 | + iEph = pParse->nTab++; |
| 106009 | + sqlite3VdbeAddOp2(v, OP_Null, 0, iPk); |
| 106010 | + addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk); |
| 106011 | + sqlite3VdbeSetP4KeyInfo(pParse, pPk); |
| 106012 | + pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, |
| 106013 | + WHERE_ONEPASS_DESIRED, iIdxCur); |
| 106014 | + if( pWInfo==0 ) goto update_cleanup; |
| 106015 | + okOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); |
| 106016 | + for(i=0; i<nPk; i++){ |
| 106017 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, pPk->aiColumn[i], |
| 106018 | + iPk+i); |
| 106019 | + } |
| 106020 | + if( okOnePass ){ |
| 106021 | + sqlite3VdbeChangeToNoop(v, addrOpen); |
| 106022 | + nKey = nPk; |
| 106023 | + regKey = iPk; |
| 106024 | + }else{ |
| 106025 | + sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey, |
| 106026 | + sqlite3IndexAffinityStr(v, pPk), P4_TRANSIENT); |
| 106027 | + sqlite3VdbeAddOp2(v, OP_IdxInsert, iEph, regKey); |
| 106028 | + } |
| 106029 | + sqlite3WhereEnd(pWInfo); |
| 106030 | + } |
| 104843 | 106031 | |
| 104844 | 106032 | /* Initialize the count of updated rows |
| 104845 | 106033 | */ |
| 104846 | 106034 | if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab ){ |
| 104847 | 106035 | regRowCount = ++pParse->nMem; |
| 104848 | 106036 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); |
| 104849 | 106037 | } |
| 104850 | 106038 | |
| 106039 | + labelBreak = sqlite3VdbeMakeLabel(v); |
| 104851 | 106040 | if( !isView ){ |
| 104852 | 106041 | /* |
| 104853 | 106042 | ** Open every index that needs updating. Note that if any |
| 104854 | 106043 | ** index could potentially invoke a REPLACE conflict resolution |
| 104855 | 106044 | ** action, then we need to open all indices because we might need |
| 104856 | 106045 | ** to be deleting some records. |
| 104857 | 106046 | */ |
| 104858 | | - if( !okOnePass ) sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite); |
| 106047 | + if( !okOnePass && HasRowid(pTab) ){ |
| 106048 | + sqlite3OpenTable(pParse, iDataCur, iDb, pTab, OP_OpenWrite); |
| 106049 | + } |
| 106050 | + sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName); |
| 104859 | 106051 | if( onError==OE_Replace ){ |
| 104860 | 106052 | openAll = 1; |
| 104861 | 106053 | }else{ |
| 104862 | 106054 | openAll = 0; |
| 104863 | 106055 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| | @@ -104866,59 +106058,71 @@ |
| 104866 | 106058 | break; |
| 104867 | 106059 | } |
| 104868 | 106060 | } |
| 104869 | 106061 | } |
| 104870 | 106062 | for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 106063 | + int iThisCur = iIdxCur+i; |
| 104871 | 106064 | assert( aRegIdx ); |
| 104872 | | - if( openAll || aRegIdx[i]>0 ){ |
| 104873 | | - KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 104874 | | - sqlite3VdbeAddOp4(v, OP_OpenWrite, iCur+i+1, pIdx->tnum, iDb, |
| 104875 | | - (char*)pKey, P4_KEYINFO_HANDOFF); |
| 104876 | | - assert( pParse->nTab>iCur+i+1 ); |
| 106065 | + if( (openAll || aRegIdx[i]>0) |
| 106066 | + && iThisCur!=aiCurOnePass[1] |
| 106067 | + ){ |
| 106068 | + assert( iThisCur!=aiCurOnePass[0] ); |
| 106069 | + sqlite3VdbeAddOp3(v, OP_OpenWrite, iThisCur, pIdx->tnum, iDb); |
| 106070 | + sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 106071 | + assert( pParse->nTab>iThisCur ); |
| 106072 | + VdbeComment((v, "%s", pIdx->zName)); |
| 106073 | + if( okOnePass && pPk && iThisCur==iDataCur ){ |
| 106074 | + sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, |
| 106075 | + regKey, nKey); |
| 106076 | + } |
| 104877 | 106077 | } |
| 104878 | 106078 | } |
| 104879 | 106079 | } |
| 104880 | 106080 | |
| 104881 | 106081 | /* Top of the update loop */ |
| 104882 | 106082 | if( okOnePass ){ |
| 104883 | | - int a1 = sqlite3VdbeAddOp1(v, OP_NotNull, regOldRowid); |
| 104884 | | - addr = sqlite3VdbeAddOp0(v, OP_Goto); |
| 104885 | | - sqlite3VdbeJumpHere(v, a1); |
| 106083 | + labelContinue = labelBreak; |
| 106084 | + sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak); |
| 106085 | + }else if( pPk ){ |
| 106086 | + labelContinue = sqlite3VdbeMakeLabel(v); |
| 106087 | + sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); |
| 106088 | + addrTop = sqlite3VdbeAddOp2(v, OP_RowKey, iEph, regKey); |
| 106089 | + sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0); |
| 104886 | 106090 | }else{ |
| 104887 | | - addr = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, 0, regOldRowid); |
| 106091 | + labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet, labelBreak, |
| 106092 | + regOldRowid); |
| 106093 | + sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid); |
| 104888 | 106094 | } |
| 104889 | 106095 | |
| 104890 | | - /* Make cursor iCur point to the record that is being updated. If |
| 104891 | | - ** this record does not exist for some reason (deleted by a trigger, |
| 104892 | | - ** for example, then jump to the next iteration of the RowSet loop. */ |
| 104893 | | - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); |
| 104894 | | - |
| 104895 | 106096 | /* If the record number will change, set register regNewRowid to |
| 104896 | 106097 | ** contain the new value. If the record number is not being modified, |
| 104897 | 106098 | ** then regNewRowid is the same register as regOldRowid, which is |
| 104898 | 106099 | ** already populated. */ |
| 104899 | | - assert( chngRowid || pTrigger || hasFK || regOldRowid==regNewRowid ); |
| 106100 | + assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid ); |
| 104900 | 106101 | if( chngRowid ){ |
| 104901 | 106102 | sqlite3ExprCode(pParse, pRowidExpr, regNewRowid); |
| 104902 | 106103 | sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); |
| 104903 | 106104 | } |
| 104904 | 106105 | |
| 104905 | | - /* If there are triggers on this table, populate an array of registers |
| 104906 | | - ** with the required old.* column data. */ |
| 104907 | | - if( hasFK || pTrigger ){ |
| 106106 | + /* Compute the old pre-UPDATE content of the row being changed, if that |
| 106107 | + ** information is needed */ |
| 106108 | + if( chngPk || hasFK || pTrigger ){ |
| 104908 | 106109 | u32 oldmask = (hasFK ? sqlite3FkOldmask(pParse, pTab) : 0); |
| 104909 | 106110 | oldmask |= sqlite3TriggerColmask(pParse, |
| 104910 | 106111 | pTrigger, pChanges, 0, TRIGGER_BEFORE|TRIGGER_AFTER, pTab, onError |
| 104911 | 106112 | ); |
| 104912 | 106113 | for(i=0; i<pTab->nCol; i++){ |
| 104913 | | - if( aXRef[i]<0 || oldmask==0xffffffff || (i<32 && (oldmask & (1<<i))) ){ |
| 104914 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOld+i); |
| 106114 | + if( oldmask==0xffffffff |
| 106115 | + || (i<32 && (oldmask & (1<<i))) |
| 106116 | + || (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 106117 | + ){ |
| 106118 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regOld+i); |
| 104915 | 106119 | }else{ |
| 104916 | 106120 | sqlite3VdbeAddOp2(v, OP_Null, 0, regOld+i); |
| 104917 | 106121 | } |
| 104918 | 106122 | } |
| 104919 | | - if( chngRowid==0 ){ |
| 106123 | + if( chngRowid==0 && pPk==0 ){ |
| 104920 | 106124 | sqlite3VdbeAddOp2(v, OP_Copy, regOldRowid, regNewRowid); |
| 104921 | 106125 | } |
| 104922 | 106126 | } |
| 104923 | 106127 | |
| 104924 | 106128 | /* Populate the array of registers beginning at regNew with the new |
| | @@ -104951,12 +106155,11 @@ |
| 104951 | 106155 | ** if there are one or more BEFORE triggers that use this value via |
| 104952 | 106156 | ** a new.* reference in a trigger program. |
| 104953 | 106157 | */ |
| 104954 | 106158 | testcase( i==31 ); |
| 104955 | 106159 | testcase( i==32 ); |
| 104956 | | - sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i); |
| 104957 | | - sqlite3ColumnDefault(v, pTab, i, regNew+i); |
| 106160 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i); |
| 104958 | 106161 | } |
| 104959 | 106162 | } |
| 104960 | 106163 | } |
| 104961 | 106164 | |
| 104962 | 106165 | /* Fire any BEFORE UPDATE triggers. This happens before constraints are |
| | @@ -104964,67 +106167,85 @@ |
| 104964 | 106167 | */ |
| 104965 | 106168 | if( tmask&TRIGGER_BEFORE ){ |
| 104966 | 106169 | sqlite3VdbeAddOp2(v, OP_Affinity, regNew, pTab->nCol); |
| 104967 | 106170 | sqlite3TableAffinityStr(v, pTab); |
| 104968 | 106171 | sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, |
| 104969 | | - TRIGGER_BEFORE, pTab, regOldRowid, onError, addr); |
| 106172 | + TRIGGER_BEFORE, pTab, regOldRowid, onError, labelContinue); |
| 104970 | 106173 | |
| 104971 | 106174 | /* The row-trigger may have deleted the row being updated. In this |
| 104972 | 106175 | ** case, jump to the next row. No updates or AFTER triggers are |
| 104973 | 106176 | ** required. This behavior - what happens when the row being updated |
| 104974 | 106177 | ** is deleted or renamed by a BEFORE trigger - is left undefined in the |
| 104975 | 106178 | ** documentation. |
| 104976 | 106179 | */ |
| 104977 | | - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addr, regOldRowid); |
| 106180 | + if( pPk ){ |
| 106181 | + sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue,regKey,nKey); |
| 106182 | + }else{ |
| 106183 | + sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid); |
| 106184 | + } |
| 104978 | 106185 | |
| 104979 | 106186 | /* If it did not delete it, the row-trigger may still have modified |
| 104980 | 106187 | ** some of the columns of the row being updated. Load the values for |
| 104981 | 106188 | ** all columns not modified by the update statement into their |
| 104982 | 106189 | ** registers in case this has happened. |
| 104983 | 106190 | */ |
| 104984 | 106191 | for(i=0; i<pTab->nCol; i++){ |
| 104985 | 106192 | if( aXRef[i]<0 && i!=pTab->iPKey ){ |
| 104986 | | - sqlite3VdbeAddOp3(v, OP_Column, iCur, i, regNew+i); |
| 104987 | | - sqlite3ColumnDefault(v, pTab, i, regNew+i); |
| 106193 | + sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, i, regNew+i); |
| 104988 | 106194 | } |
| 104989 | 106195 | } |
| 104990 | 106196 | } |
| 104991 | 106197 | |
| 104992 | 106198 | if( !isView ){ |
| 104993 | | - int j1; /* Address of jump instruction */ |
| 106199 | + int j1 = 0; /* Address of jump instruction */ |
| 106200 | + int bReplace = 0; /* True if REPLACE conflict resolution might happen */ |
| 104994 | 106201 | |
| 104995 | 106202 | /* Do constraint checks. */ |
| 104996 | | - sqlite3GenerateConstraintChecks(pParse, pTab, iCur, regNewRowid, |
| 104997 | | - aRegIdx, (chngRowid?regOldRowid:0), 1, onError, addr, 0); |
| 106203 | + assert( regOldRowid>0 ); |
| 106204 | + sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, |
| 106205 | + regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace); |
| 104998 | 106206 | |
| 104999 | 106207 | /* Do FK constraint checks. */ |
| 105000 | 106208 | if( hasFK ){ |
| 105001 | | - sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngRowid); |
| 106209 | + sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey); |
| 105002 | 106210 | } |
| 105003 | 106211 | |
| 105004 | 106212 | /* Delete the index entries associated with the current record. */ |
| 105005 | | - j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regOldRowid); |
| 105006 | | - sqlite3GenerateRowIndexDelete(pParse, pTab, iCur, aRegIdx); |
| 106213 | + if( bReplace || chngKey ){ |
| 106214 | + if( pPk ){ |
| 106215 | + j1 = sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, 0, regKey, nKey); |
| 106216 | + }else{ |
| 106217 | + j1 = sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, 0, regOldRowid); |
| 106218 | + } |
| 106219 | + } |
| 106220 | + sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur, aRegIdx); |
| 105007 | 106221 | |
| 105008 | 106222 | /* If changing the record number, delete the old record. */ |
| 105009 | | - if( hasFK || chngRowid ){ |
| 105010 | | - sqlite3VdbeAddOp2(v, OP_Delete, iCur, 0); |
| 106223 | + if( hasFK || chngKey || pPk!=0 ){ |
| 106224 | + sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, 0); |
| 105011 | 106225 | } |
| 105012 | | - sqlite3VdbeJumpHere(v, j1); |
| 106226 | + if( bReplace || chngKey ){ |
| 106227 | + if( sqlite3VdbeCurrentAddr(v)==j1+1 ){ |
| 106228 | + sqlite3VdbeChangeToNoop(v, j1); |
| 106229 | + }else{ |
| 106230 | + sqlite3VdbeJumpHere(v, j1); |
| 106231 | + } |
| 106232 | + } |
| 105013 | 106233 | |
| 105014 | 106234 | if( hasFK ){ |
| 105015 | | - sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngRowid); |
| 106235 | + sqlite3FkCheck(pParse, pTab, 0, regNewRowid, aXRef, chngKey); |
| 105016 | 106236 | } |
| 105017 | 106237 | |
| 105018 | 106238 | /* Insert the new index entries and the new record. */ |
| 105019 | | - sqlite3CompleteInsertion(pParse, pTab, iCur, regNewRowid, aRegIdx, 1, 0, 0); |
| 106239 | + sqlite3CompleteInsertion(pParse, pTab, iDataCur, iIdxCur, |
| 106240 | + regNewRowid, aRegIdx, 1, 0, 0); |
| 105020 | 106241 | |
| 105021 | 106242 | /* Do any ON CASCADE, SET NULL or SET DEFAULT operations required to |
| 105022 | 106243 | ** handle rows (possibly in other tables) that refer via a foreign key |
| 105023 | 106244 | ** to the row just updated. */ |
| 105024 | 106245 | if( hasFK ){ |
| 105025 | | - sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngRowid); |
| 106246 | + sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey); |
| 105026 | 106247 | } |
| 105027 | 106248 | } |
| 105028 | 106249 | |
| 105029 | 106250 | /* Increment the row counter |
| 105030 | 106251 | */ |
| | @@ -105031,26 +106252,33 @@ |
| 105031 | 106252 | if( (db->flags & SQLITE_CountRows) && !pParse->pTriggerTab){ |
| 105032 | 106253 | sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); |
| 105033 | 106254 | } |
| 105034 | 106255 | |
| 105035 | 106256 | sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, |
| 105036 | | - TRIGGER_AFTER, pTab, regOldRowid, onError, addr); |
| 106257 | + TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue); |
| 105037 | 106258 | |
| 105038 | 106259 | /* Repeat the above with the next record to be updated, until |
| 105039 | 106260 | ** all record selected by the WHERE clause have been updated. |
| 105040 | 106261 | */ |
| 105041 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addr); |
| 105042 | | - sqlite3VdbeJumpHere(v, addr); |
| 106262 | + if( okOnePass ){ |
| 106263 | + /* Nothing to do at end-of-loop for a single-pass */ |
| 106264 | + }else if( pPk ){ |
| 106265 | + sqlite3VdbeResolveLabel(v, labelContinue); |
| 106266 | + sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); |
| 106267 | + }else{ |
| 106268 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, labelContinue); |
| 106269 | + } |
| 106270 | + sqlite3VdbeResolveLabel(v, labelBreak); |
| 105043 | 106271 | |
| 105044 | 106272 | /* Close all tables */ |
| 105045 | 106273 | for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 105046 | 106274 | assert( aRegIdx ); |
| 105047 | 106275 | if( openAll || aRegIdx[i]>0 ){ |
| 105048 | | - sqlite3VdbeAddOp2(v, OP_Close, iCur+i+1, 0); |
| 106276 | + sqlite3VdbeAddOp2(v, OP_Close, iIdxCur+i, 0); |
| 105049 | 106277 | } |
| 105050 | 106278 | } |
| 105051 | | - sqlite3VdbeAddOp2(v, OP_Close, iCur, 0); |
| 106279 | + if( iDataCur<iIdxCur ) sqlite3VdbeAddOp2(v, OP_Close, iDataCur, 0); |
| 105052 | 106280 | |
| 105053 | 106281 | /* Update the sqlite_sequence table by storing the content of the |
| 105054 | 106282 | ** maximum rowid counter values recorded while inserting into |
| 105055 | 106283 | ** autoincrement tables. |
| 105056 | 106284 | */ |
| | @@ -105418,11 +106646,11 @@ |
| 105418 | 106646 | ** in the temporary database. |
| 105419 | 106647 | */ |
| 105420 | 106648 | rc = execExecSql(db, pzErrMsg, |
| 105421 | 106649 | "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) " |
| 105422 | 106650 | " FROM sqlite_master WHERE type='table' AND name!='sqlite_sequence'" |
| 105423 | | - " AND rootpage>0" |
| 106651 | + " AND coalesce(rootpage,1)>0" |
| 105424 | 106652 | ); |
| 105425 | 106653 | if( rc!=SQLITE_OK ) goto end_of_vacuum; |
| 105426 | 106654 | rc = execExecSql(db, pzErrMsg, |
| 105427 | 106655 | "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)" |
| 105428 | 106656 | " FROM sqlite_master WHERE sql LIKE 'CREATE INDEX %' "); |
| | @@ -105439,11 +106667,11 @@ |
| 105439 | 106667 | rc = execExecSql(db, pzErrMsg, |
| 105440 | 106668 | "SELECT 'INSERT INTO vacuum_db.' || quote(name) " |
| 105441 | 106669 | "|| ' SELECT * FROM main.' || quote(name) || ';'" |
| 105442 | 106670 | "FROM main.sqlite_master " |
| 105443 | 106671 | "WHERE type = 'table' AND name!='sqlite_sequence' " |
| 105444 | | - " AND rootpage>0" |
| 106672 | + " AND coalesce(rootpage,1)>0" |
| 105445 | 106673 | ); |
| 105446 | 106674 | if( rc!=SQLITE_OK ) goto end_of_vacuum; |
| 105447 | 106675 | |
| 105448 | 106676 | /* Copy over the sequence table |
| 105449 | 106677 | */ |
| | @@ -107062,10 +108290,11 @@ |
| 107062 | 108290 | u8 nLevel; /* Number of nested loop */ |
| 107063 | 108291 | int iTop; /* The very beginning of the WHERE loop */ |
| 107064 | 108292 | int iContinue; /* Jump here to continue with next record */ |
| 107065 | 108293 | int iBreak; /* Jump here to break out of the loop */ |
| 107066 | 108294 | int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
| 108295 | + int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ |
| 107067 | 108296 | WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */ |
| 107068 | 108297 | WhereClause sWC; /* Decomposition of the WHERE clause */ |
| 107069 | 108298 | WhereLevel a[1]; /* Information about each nest loop in WHERE */ |
| 107070 | 108299 | }; |
| 107071 | 108300 | |
| | @@ -107154,12 +108383,23 @@ |
| 107154 | 108383 | |
| 107155 | 108384 | /* |
| 107156 | 108385 | ** Return TRUE if an UPDATE or DELETE statement can operate directly on |
| 107157 | 108386 | ** the rowids returned by a WHERE clause. Return FALSE if doing an |
| 107158 | 108387 | ** UPDATE or DELETE might change subsequent WHERE clause results. |
| 108388 | +** |
| 108389 | +** If the ONEPASS optimization is used (if this routine returns true) |
| 108390 | +** then also write the indices of open cursors used by ONEPASS |
| 108391 | +** into aiCur[0] and aiCur[1]. iaCur[0] gets the cursor of the data |
| 108392 | +** table and iaCur[1] gets the cursor used by an auxiliary index. |
| 108393 | +** Either value may be -1, indicating that cursor is not used. |
| 108394 | +** Any cursors returned will have been opened for writing. |
| 108395 | +** |
| 108396 | +** aiCur[0] and aiCur[1] both get -1 if the where-clause logic is |
| 108397 | +** unable to use the ONEPASS optimization. |
| 107159 | 108398 | */ |
| 107160 | | -SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo *pWInfo){ |
| 108399 | +SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo *pWInfo, int *aiCur){ |
| 108400 | + memcpy(aiCur, pWInfo->aiCurOnePass, sizeof(int)*2); |
| 107161 | 108401 | return pWInfo->okOnePass; |
| 107162 | 108402 | } |
| 107163 | 108403 | |
| 107164 | 108404 | /* |
| 107165 | 108405 | ** Move the content of pSrc into pDest |
| | @@ -107531,11 +108771,14 @@ |
| 107531 | 108771 | while( pScan->iEquiv<=pScan->nEquiv ){ |
| 107532 | 108772 | iCur = pScan->aEquiv[pScan->iEquiv-2]; |
| 107533 | 108773 | iColumn = pScan->aEquiv[pScan->iEquiv-1]; |
| 107534 | 108774 | while( (pWC = pScan->pWC)!=0 ){ |
| 107535 | 108775 | for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){ |
| 107536 | | - if( pTerm->leftCursor==iCur && pTerm->u.leftColumn==iColumn ){ |
| 108776 | + if( pTerm->leftCursor==iCur |
| 108777 | + && pTerm->u.leftColumn==iColumn |
| 108778 | + && (pScan->iEquiv<=2 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin)) |
| 108779 | + ){ |
| 107537 | 108780 | if( (pTerm->eOperator & WO_EQUIV)!=0 |
| 107538 | 108781 | && pScan->nEquiv<ArraySize(pScan->aEquiv) |
| 107539 | 108782 | ){ |
| 107540 | 108783 | int j; |
| 107541 | 108784 | pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight); |
| | @@ -107621,11 +108864,11 @@ |
| 107621 | 108864 | pScan->pOrigWC = pWC; |
| 107622 | 108865 | pScan->pWC = pWC; |
| 107623 | 108866 | if( pIdx && iColumn>=0 ){ |
| 107624 | 108867 | pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity; |
| 107625 | 108868 | for(j=0; pIdx->aiColumn[j]!=iColumn; j++){ |
| 107626 | | - if( NEVER(j>=pIdx->nColumn) ) return 0; |
| 108869 | + if( NEVER(j>=pIdx->nKeyCol) ) return 0; |
| 107627 | 108870 | } |
| 107628 | 108871 | pScan->zCollName = pIdx->azColl[j]; |
| 107629 | 108872 | }else{ |
| 107630 | 108873 | pScan->idxaff = 0; |
| 107631 | 108874 | pScan->zCollName = 0; |
| | @@ -108551,20 +109794,20 @@ |
| 108551 | 109794 | ** 3. All of those index columns for which the WHERE clause does not |
| 108552 | 109795 | ** contain a "col=X" term are subject to a NOT NULL constraint. |
| 108553 | 109796 | */ |
| 108554 | 109797 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 108555 | 109798 | if( pIdx->onError==OE_None ) continue; |
| 108556 | | - for(i=0; i<pIdx->nColumn; i++){ |
| 108557 | | - int iCol = pIdx->aiColumn[i]; |
| 109799 | + for(i=0; i<pIdx->nKeyCol; i++){ |
| 109800 | + i16 iCol = pIdx->aiColumn[i]; |
| 108558 | 109801 | if( 0==findTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx) ){ |
| 108559 | 109802 | int iIdxCol = findIndexCol(pParse, pDistinct, iBase, pIdx, i); |
| 108560 | | - if( iIdxCol<0 || pTab->aCol[pIdx->aiColumn[i]].notNull==0 ){ |
| 109803 | + if( iIdxCol<0 || pTab->aCol[iCol].notNull==0 ){ |
| 108561 | 109804 | break; |
| 108562 | 109805 | } |
| 108563 | 109806 | } |
| 108564 | 109807 | } |
| 108565 | | - if( i==pIdx->nColumn ){ |
| 109808 | + if( i==pIdx->nKeyCol ){ |
| 108566 | 109809 | /* This index implies that the DISTINCT qualifier is redundant. */ |
| 108567 | 109810 | return 1; |
| 108568 | 109811 | } |
| 108569 | 109812 | } |
| 108570 | 109813 | |
| | @@ -108658,26 +109901,25 @@ |
| 108658 | 109901 | WhereClause *pWC, /* The WHERE clause */ |
| 108659 | 109902 | struct SrcList_item *pSrc, /* The FROM clause term to get the next index */ |
| 108660 | 109903 | Bitmask notReady, /* Mask of cursors that are not available */ |
| 108661 | 109904 | WhereLevel *pLevel /* Write new index here */ |
| 108662 | 109905 | ){ |
| 108663 | | - int nColumn; /* Number of columns in the constructed index */ |
| 109906 | + int nKeyCol; /* Number of columns in the constructed index */ |
| 108664 | 109907 | WhereTerm *pTerm; /* A single term of the WHERE clause */ |
| 108665 | 109908 | WhereTerm *pWCEnd; /* End of pWC->a[] */ |
| 108666 | | - int nByte; /* Byte of memory needed for pIdx */ |
| 108667 | 109909 | Index *pIdx; /* Object describing the transient index */ |
| 108668 | 109910 | Vdbe *v; /* Prepared statement under construction */ |
| 108669 | 109911 | int addrInit; /* Address of the initialization bypass jump */ |
| 108670 | 109912 | Table *pTable; /* The table being indexed */ |
| 108671 | | - KeyInfo *pKeyinfo; /* Key information for the index */ |
| 108672 | 109913 | int addrTop; /* Top of the index fill loop */ |
| 108673 | 109914 | int regRecord; /* Register holding an index record */ |
| 108674 | 109915 | int n; /* Column counter */ |
| 108675 | 109916 | int i; /* Loop counter */ |
| 108676 | 109917 | int mxBitCol; /* Maximum column in pSrc->colUsed */ |
| 108677 | 109918 | CollSeq *pColl; /* Collating sequence to on a column */ |
| 108678 | 109919 | WhereLoop *pLoop; /* The Loop object */ |
| 109920 | + char *zNotUsed; /* Extra space on the end of pIdx */ |
| 108679 | 109921 | Bitmask idxCols; /* Bitmap of columns used for indexing */ |
| 108680 | 109922 | Bitmask extraCols; /* Bitmap of additional columns */ |
| 108681 | 109923 | u8 sentWarning = 0; /* True if a warnning has been issued */ |
| 108682 | 109924 | |
| 108683 | 109925 | /* Generate code to skip over the creation and initialization of the |
| | @@ -108686,11 +109928,11 @@ |
| 108686 | 109928 | assert( v!=0 ); |
| 108687 | 109929 | addrInit = sqlite3CodeOnce(pParse); |
| 108688 | 109930 | |
| 108689 | 109931 | /* Count the number of columns that will be added to the index |
| 108690 | 109932 | ** and used to match WHERE clause constraints */ |
| 108691 | | - nColumn = 0; |
| 109933 | + nKeyCol = 0; |
| 108692 | 109934 | pTable = pSrc->pTab; |
| 108693 | 109935 | pWCEnd = &pWC->a[pWC->nTerm]; |
| 108694 | 109936 | pLoop = pLevel->pWLoop; |
| 108695 | 109937 | idxCols = 0; |
| 108696 | 109938 | for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){ |
| | @@ -108704,18 +109946,18 @@ |
| 108704 | 109946 | "automatic index on %s(%s)", pTable->zName, |
| 108705 | 109947 | pTable->aCol[iCol].zName); |
| 108706 | 109948 | sentWarning = 1; |
| 108707 | 109949 | } |
| 108708 | 109950 | if( (idxCols & cMask)==0 ){ |
| 108709 | | - if( whereLoopResize(pParse->db, pLoop, nColumn+1) ) return; |
| 108710 | | - pLoop->aLTerm[nColumn++] = pTerm; |
| 109951 | + if( whereLoopResize(pParse->db, pLoop, nKeyCol+1) ) return; |
| 109952 | + pLoop->aLTerm[nKeyCol++] = pTerm; |
| 108711 | 109953 | idxCols |= cMask; |
| 108712 | 109954 | } |
| 108713 | 109955 | } |
| 108714 | 109956 | } |
| 108715 | | - assert( nColumn>0 ); |
| 108716 | | - pLoop->u.btree.nEq = pLoop->nLTerm = nColumn; |
| 109957 | + assert( nKeyCol>0 ); |
| 109958 | + pLoop->u.btree.nEq = pLoop->nLTerm = nKeyCol; |
| 108717 | 109959 | pLoop->wsFlags = WHERE_COLUMN_EQ | WHERE_IDX_ONLY | WHERE_INDEXED |
| 108718 | 109960 | | WHERE_AUTO_INDEX; |
| 108719 | 109961 | |
| 108720 | 109962 | /* Count the number of additional columns needed to create a |
| 108721 | 109963 | ** covering index. A "covering index" is an index that contains all |
| | @@ -108728,30 +109970,22 @@ |
| 108728 | 109970 | extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1)); |
| 108729 | 109971 | mxBitCol = (pTable->nCol >= BMS-1) ? BMS-1 : pTable->nCol; |
| 108730 | 109972 | testcase( pTable->nCol==BMS-1 ); |
| 108731 | 109973 | testcase( pTable->nCol==BMS-2 ); |
| 108732 | 109974 | for(i=0; i<mxBitCol; i++){ |
| 108733 | | - if( extraCols & MASKBIT(i) ) nColumn++; |
| 109975 | + if( extraCols & MASKBIT(i) ) nKeyCol++; |
| 108734 | 109976 | } |
| 108735 | 109977 | if( pSrc->colUsed & MASKBIT(BMS-1) ){ |
| 108736 | | - nColumn += pTable->nCol - BMS + 1; |
| 109978 | + nKeyCol += pTable->nCol - BMS + 1; |
| 108737 | 109979 | } |
| 108738 | 109980 | pLoop->wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY; |
| 108739 | 109981 | |
| 108740 | 109982 | /* Construct the Index object to describe this index */ |
| 108741 | | - nByte = sizeof(Index); |
| 108742 | | - nByte += nColumn*sizeof(int); /* Index.aiColumn */ |
| 108743 | | - nByte += nColumn*sizeof(char*); /* Index.azColl */ |
| 108744 | | - nByte += nColumn; /* Index.aSortOrder */ |
| 108745 | | - pIdx = sqlite3DbMallocZero(pParse->db, nByte); |
| 109983 | + pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed); |
| 108746 | 109984 | if( pIdx==0 ) return; |
| 108747 | 109985 | pLoop->u.btree.pIndex = pIdx; |
| 108748 | | - pIdx->azColl = (char**)&pIdx[1]; |
| 108749 | | - pIdx->aiColumn = (int*)&pIdx->azColl[nColumn]; |
| 108750 | | - pIdx->aSortOrder = (u8*)&pIdx->aiColumn[nColumn]; |
| 108751 | 109986 | pIdx->zName = "auto-index"; |
| 108752 | | - pIdx->nColumn = nColumn; |
| 108753 | 109987 | pIdx->pTable = pTable; |
| 108754 | 109988 | n = 0; |
| 108755 | 109989 | idxCols = 0; |
| 108756 | 109990 | for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){ |
| 108757 | 109991 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ |
| | @@ -108785,24 +110019,25 @@ |
| 108785 | 110019 | pIdx->aiColumn[n] = i; |
| 108786 | 110020 | pIdx->azColl[n] = "BINARY"; |
| 108787 | 110021 | n++; |
| 108788 | 110022 | } |
| 108789 | 110023 | } |
| 108790 | | - assert( n==nColumn ); |
| 110024 | + assert( n==nKeyCol ); |
| 110025 | + pIdx->aiColumn[n] = -1; |
| 110026 | + pIdx->azColl[n] = "BINARY"; |
| 108791 | 110027 | |
| 108792 | 110028 | /* Create the automatic index */ |
| 108793 | | - pKeyinfo = sqlite3IndexKeyinfo(pParse, pIdx); |
| 108794 | 110029 | assert( pLevel->iIdxCur>=0 ); |
| 108795 | 110030 | pLevel->iIdxCur = pParse->nTab++; |
| 108796 | | - sqlite3VdbeAddOp4(v, OP_OpenAutoindex, pLevel->iIdxCur, nColumn+1, 0, |
| 108797 | | - (char*)pKeyinfo, P4_KEYINFO_HANDOFF); |
| 110031 | + sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1); |
| 110032 | + sqlite3VdbeSetP4KeyInfo(pParse, pIdx); |
| 108798 | 110033 | VdbeComment((v, "for %s", pTable->zName)); |
| 108799 | 110034 | |
| 108800 | 110035 | /* Fill the automatic index with content */ |
| 108801 | 110036 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); |
| 108802 | 110037 | regRecord = sqlite3GetTempReg(pParse); |
| 108803 | | - sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0); |
| 110038 | + sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0); |
| 108804 | 110039 | sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord); |
| 108805 | 110040 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 108806 | 110041 | sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); |
| 108807 | 110042 | sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); |
| 108808 | 110043 | sqlite3VdbeJumpHere(v, addrTop); |
| | @@ -109045,11 +110280,11 @@ |
| 109045 | 110280 | iUpper = aSample[0].anLt[iCol]; |
| 109046 | 110281 | }else{ |
| 109047 | 110282 | iUpper = i>=pIdx->nSample ? pIdx->aiRowEst[0] : aSample[i].anLt[iCol]; |
| 109048 | 110283 | iLower = aSample[i-1].anEq[iCol] + aSample[i-1].anLt[iCol]; |
| 109049 | 110284 | } |
| 109050 | | - aStat[1] = (pIdx->nColumn>iCol ? pIdx->aAvgEq[iCol] : 1); |
| 110285 | + aStat[1] = (pIdx->nKeyCol>iCol ? pIdx->aAvgEq[iCol] : 1); |
| 109051 | 110286 | if( iLower>=iUpper ){ |
| 109052 | 110287 | iGap = 0; |
| 109053 | 110288 | }else{ |
| 109054 | 110289 | iGap = iUpper - iLower; |
| 109055 | 110290 | } |
| | @@ -109145,11 +110380,11 @@ |
| 109145 | 110380 | ** of iUpper are requested of whereKeyStats() and the smaller used. |
| 109146 | 110381 | */ |
| 109147 | 110382 | tRowcnt iLower; |
| 109148 | 110383 | tRowcnt iUpper; |
| 109149 | 110384 | |
| 109150 | | - if( nEq==p->nColumn ){ |
| 110385 | + if( nEq==p->nKeyCol ){ |
| 109151 | 110386 | aff = SQLITE_AFF_INTEGER; |
| 109152 | 110387 | }else{ |
| 109153 | 110388 | aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; |
| 109154 | 110389 | } |
| 109155 | 110390 | /* Determine iLower and iUpper using ($P) only. */ |
| | @@ -109203,11 +110438,11 @@ |
| 109203 | 110438 | } |
| 109204 | 110439 | if( nNew<nOut ){ |
| 109205 | 110440 | nOut = nNew; |
| 109206 | 110441 | } |
| 109207 | 110442 | pLoop->nOut = (LogEst)nOut; |
| 109208 | | - WHERETRACE(0x100, ("range scan regions: %u..%u est=%d\n", |
| 110443 | + WHERETRACE(0x10, ("range scan regions: %u..%u est=%d\n", |
| 109209 | 110444 | (u32)iLower, (u32)iUpper, nOut)); |
| 109210 | 110445 | return SQLITE_OK; |
| 109211 | 110446 | } |
| 109212 | 110447 | } |
| 109213 | 110448 | #else |
| | @@ -109263,11 +110498,11 @@ |
| 109263 | 110498 | int rc; /* Subfunction return code */ |
| 109264 | 110499 | tRowcnt a[2]; /* Statistics */ |
| 109265 | 110500 | int bOk; |
| 109266 | 110501 | |
| 109267 | 110502 | assert( nEq>=1 ); |
| 109268 | | - assert( nEq<=(p->nColumn+1) ); |
| 110503 | + assert( nEq<=(p->nKeyCol+1) ); |
| 109269 | 110504 | assert( p->aSample!=0 ); |
| 109270 | 110505 | assert( p->nSample>0 ); |
| 109271 | 110506 | assert( pBuilder->nRecValid<nEq ); |
| 109272 | 110507 | |
| 109273 | 110508 | /* If values are not available for all fields of the index to the left |
| | @@ -109276,11 +110511,11 @@ |
| 109276 | 110511 | return SQLITE_NOTFOUND; |
| 109277 | 110512 | } |
| 109278 | 110513 | |
| 109279 | 110514 | /* This is an optimization only. The call to sqlite3Stat4ProbeSetValue() |
| 109280 | 110515 | ** below would return the same value. */ |
| 109281 | | - if( nEq>p->nColumn ){ |
| 110516 | + if( nEq>p->nKeyCol ){ |
| 109282 | 110517 | *pnRow = 1; |
| 109283 | 110518 | return SQLITE_OK; |
| 109284 | 110519 | } |
| 109285 | 110520 | |
| 109286 | 110521 | aff = p->pTable->aCol[p->aiColumn[nEq-1]].affinity; |
| | @@ -109289,11 +110524,11 @@ |
| 109289 | 110524 | if( rc!=SQLITE_OK ) return rc; |
| 109290 | 110525 | if( bOk==0 ) return SQLITE_NOTFOUND; |
| 109291 | 110526 | pBuilder->nRecValid = nEq; |
| 109292 | 110527 | |
| 109293 | 110528 | whereKeyStats(pParse, p, pRec, 0, a); |
| 109294 | | - WHERETRACE(0x100,("equality scan regions: %d\n", (int)a[1])); |
| 110529 | + WHERETRACE(0x10,("equality scan regions: %d\n", (int)a[1])); |
| 109295 | 110530 | *pnRow = a[1]; |
| 109296 | 110531 | |
| 109297 | 110532 | return rc; |
| 109298 | 110533 | } |
| 109299 | 110534 | #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ |
| | @@ -109337,11 +110572,11 @@ |
| 109337 | 110572 | } |
| 109338 | 110573 | |
| 109339 | 110574 | if( rc==SQLITE_OK ){ |
| 109340 | 110575 | if( nRowEst > p->aiRowEst[0] ) nRowEst = p->aiRowEst[0]; |
| 109341 | 110576 | *pnRow = nRowEst; |
| 109342 | | - WHERETRACE(0x100,("IN row estimate: est=%g\n", nRowEst)); |
| 110577 | + WHERETRACE(0x10,("IN row estimate: est=%g\n", nRowEst)); |
| 109343 | 110578 | } |
| 109344 | 110579 | assert( pBuilder->nRecValid==nRecValid ); |
| 109345 | 110580 | return rc; |
| 109346 | 110581 | } |
| 109347 | 110582 | #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ |
| | @@ -109663,31 +110898,31 @@ |
| 109663 | 110898 | static char *explainIndexRange(sqlite3 *db, WhereLoop *pLoop, Table *pTab){ |
| 109664 | 110899 | Index *pIndex = pLoop->u.btree.pIndex; |
| 109665 | 110900 | int nEq = pLoop->u.btree.nEq; |
| 109666 | 110901 | int i, j; |
| 109667 | 110902 | Column *aCol = pTab->aCol; |
| 109668 | | - int *aiColumn = pIndex->aiColumn; |
| 110903 | + i16 *aiColumn = pIndex->aiColumn; |
| 109669 | 110904 | StrAccum txt; |
| 109670 | 110905 | |
| 109671 | 110906 | if( nEq==0 && (pLoop->wsFlags & (WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ){ |
| 109672 | 110907 | return 0; |
| 109673 | 110908 | } |
| 109674 | 110909 | sqlite3StrAccumInit(&txt, 0, 0, SQLITE_MAX_LENGTH); |
| 109675 | 110910 | txt.db = db; |
| 109676 | 110911 | sqlite3StrAccumAppend(&txt, " (", 2); |
| 109677 | 110912 | for(i=0; i<nEq; i++){ |
| 109678 | | - char *z = (i==pIndex->nColumn ) ? "rowid" : aCol[aiColumn[i]].zName; |
| 110913 | + char *z = (i==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[i]].zName; |
| 109679 | 110914 | explainAppendTerm(&txt, i, z, "="); |
| 109680 | 110915 | } |
| 109681 | 110916 | |
| 109682 | 110917 | j = i; |
| 109683 | 110918 | if( pLoop->wsFlags&WHERE_BTM_LIMIT ){ |
| 109684 | | - char *z = (j==pIndex->nColumn ) ? "rowid" : aCol[aiColumn[j]].zName; |
| 110919 | + char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName; |
| 109685 | 110920 | explainAppendTerm(&txt, i++, z, ">"); |
| 109686 | 110921 | } |
| 109687 | 110922 | if( pLoop->wsFlags&WHERE_TOP_LIMIT ){ |
| 109688 | | - char *z = (j==pIndex->nColumn ) ? "rowid" : aCol[aiColumn[j]].zName; |
| 110923 | + char *z = (j==pIndex->nKeyCol ) ? "rowid" : aCol[aiColumn[j]].zName; |
| 109689 | 110924 | explainAppendTerm(&txt, i, z, "<"); |
| 109690 | 110925 | } |
| 109691 | 110926 | sqlite3StrAccumAppend(&txt, ")", 1); |
| 109692 | 110927 | return sqlite3StrAccumFinish(&txt); |
| 109693 | 110928 | } |
| | @@ -109810,11 +111045,11 @@ |
| 109810 | 111045 | iCur = pTabItem->iCursor; |
| 109811 | 111046 | pLevel->notReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur); |
| 109812 | 111047 | bRev = (pWInfo->revMask>>iLevel)&1; |
| 109813 | 111048 | omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 |
| 109814 | 111049 | && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0; |
| 109815 | | - VdbeNoopComment((v, "Begin Join Loop %d", iLevel)); |
| 111050 | + VdbeNoopComment((v, "Begin WHERE-Loop %d: %s", iLevel,pTabItem->pTab->zName)); |
| 109816 | 111051 | |
| 109817 | 111052 | /* Create labels for the "break" and "continue" instructions |
| 109818 | 111053 | ** for the current loop. Jump to addrBrk to break out of a loop. |
| 109819 | 111054 | ** Jump to cont to go immediately to the next iteration of the |
| 109820 | 111055 | ** loop. |
| | @@ -110067,11 +111302,11 @@ |
| 110067 | 111302 | ** the first one after the nEq equality constraints in the index, |
| 110068 | 111303 | ** this requires some special handling. |
| 110069 | 111304 | */ |
| 110070 | 111305 | if( (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)!=0 |
| 110071 | 111306 | && (pWInfo->bOBSat!=0) |
| 110072 | | - && (pIdx->nColumn>nEq) |
| 111307 | + && (pIdx->nKeyCol>nEq) |
| 110073 | 111308 | ){ |
| 110074 | 111309 | /* assert( pOrderBy->nExpr==1 ); */ |
| 110075 | 111310 | /* assert( pOrderBy->a[0].pExpr->iColumn==pIdx->aiColumn[nEq] ); */ |
| 110076 | 111311 | isMinQuery = 1; |
| 110077 | 111312 | nExtraReg = 1; |
| | @@ -110100,12 +111335,12 @@ |
| 110100 | 111335 | |
| 110101 | 111336 | /* If we are doing a reverse order scan on an ascending index, or |
| 110102 | 111337 | ** a forward order scan on a descending index, interchange the |
| 110103 | 111338 | ** start and end terms (pRangeStart and pRangeEnd). |
| 110104 | 111339 | */ |
| 110105 | | - if( (nEq<pIdx->nColumn && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) |
| 110106 | | - || (bRev && pIdx->nColumn==nEq) |
| 111340 | + if( (nEq<pIdx->nKeyCol && bRev==(pIdx->aSortOrder[nEq]==SQLITE_SO_ASC)) |
| 111341 | + || (bRev && pIdx->nKeyCol==nEq) |
| 110107 | 111342 | ){ |
| 110108 | 111343 | SWAP(WhereTerm *, pRangeEnd, pRangeStart); |
| 110109 | 111344 | } |
| 110110 | 111345 | |
| 110111 | 111346 | testcase( pRangeStart && (pRangeStart->eOperator & WO_LE)!=0 ); |
| | @@ -110210,15 +111445,26 @@ |
| 110210 | 111445 | sqlite3ReleaseTempReg(pParse, r1); |
| 110211 | 111446 | |
| 110212 | 111447 | /* Seek the table cursor, if required */ |
| 110213 | 111448 | disableTerm(pLevel, pRangeStart); |
| 110214 | 111449 | disableTerm(pLevel, pRangeEnd); |
| 110215 | | - if( !omitTable ){ |
| 111450 | + if( omitTable ){ |
| 111451 | + /* pIdx is a covering index. No need to access the main table. */ |
| 111452 | + }else if( HasRowid(pIdx->pTable) ){ |
| 110216 | 111453 | iRowidReg = iReleaseReg = sqlite3GetTempReg(pParse); |
| 110217 | 111454 | sqlite3VdbeAddOp2(v, OP_IdxRowid, iIdxCur, iRowidReg); |
| 110218 | 111455 | sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); |
| 110219 | 111456 | sqlite3VdbeAddOp2(v, OP_Seek, iCur, iRowidReg); /* Deferred seek */ |
| 111457 | + }else{ |
| 111458 | + Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable); |
| 111459 | + iRowidReg = sqlite3GetTempRange(pParse, pPk->nKeyCol); |
| 111460 | + for(j=0; j<pPk->nKeyCol; j++){ |
| 111461 | + k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]); |
| 111462 | + sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, iRowidReg+j); |
| 111463 | + } |
| 111464 | + sqlite3VdbeAddOp4Int(v, OP_NotFound, iCur, addrCont, |
| 111465 | + iRowidReg, pPk->nKeyCol); |
| 110220 | 111466 | } |
| 110221 | 111467 | |
| 110222 | 111468 | /* Record the instruction used to terminate the loop. Disable |
| 110223 | 111469 | ** WHERE clause terms made redundant by the index range scan. |
| 110224 | 111470 | */ |
| | @@ -110541,27 +111787,43 @@ |
| 110541 | 111787 | } |
| 110542 | 111788 | sqlite3ReleaseTempReg(pParse, iReleaseReg); |
| 110543 | 111789 | |
| 110544 | 111790 | return pLevel->notReady; |
| 110545 | 111791 | } |
| 111792 | + |
| 111793 | +#if defined(WHERETRACE_ENABLED) && defined(SQLITE_ENABLE_TREE_EXPLAIN) |
| 111794 | +/* |
| 111795 | +** Generate "Explanation" text for a WhereTerm. |
| 111796 | +*/ |
| 111797 | +static void whereExplainTerm(Vdbe *v, WhereTerm *pTerm){ |
| 111798 | + char zType[4]; |
| 111799 | + memcpy(zType, "...", 4); |
| 111800 | + if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V'; |
| 111801 | + if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E'; |
| 111802 | + if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L'; |
| 111803 | + sqlite3ExplainPrintf(v, "%s ", zType); |
| 111804 | + sqlite3ExplainExpr(v, pTerm->pExpr); |
| 111805 | +} |
| 111806 | +#endif /* WHERETRACE_ENABLED && SQLITE_ENABLE_TREE_EXPLAIN */ |
| 111807 | + |
| 110546 | 111808 | |
| 110547 | 111809 | #ifdef WHERETRACE_ENABLED |
| 110548 | 111810 | /* |
| 110549 | 111811 | ** Print a WhereLoop object for debugging purposes |
| 110550 | 111812 | */ |
| 110551 | | -static void whereLoopPrint(WhereLoop *p, SrcList *pTabList){ |
| 110552 | | - int nb = 1+(pTabList->nSrc+7)/8; |
| 110553 | | - struct SrcList_item *pItem = pTabList->a + p->iTab; |
| 111813 | +static void whereLoopPrint(WhereLoop *p, WhereClause *pWC){ |
| 111814 | + WhereInfo *pWInfo = pWC->pWInfo; |
| 111815 | + int nb = 1+(pWInfo->pTabList->nSrc+7)/8; |
| 111816 | + struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab; |
| 110554 | 111817 | Table *pTab = pItem->pTab; |
| 110555 | 111818 | sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId, |
| 110556 | 111819 | p->iTab, nb, p->maskSelf, nb, p->prereq); |
| 110557 | 111820 | sqlite3DebugPrintf(" %12s", |
| 110558 | 111821 | pItem->zAlias ? pItem->zAlias : pTab->zName); |
| 110559 | 111822 | if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){ |
| 110560 | | - if( p->u.btree.pIndex ){ |
| 110561 | | - const char *zName = p->u.btree.pIndex->zName; |
| 110562 | | - if( zName==0 ) zName = "ipk"; |
| 111823 | + const char *zName; |
| 111824 | + if( p->u.btree.pIndex && (zName = p->u.btree.pIndex->zName)!=0 ){ |
| 110563 | 111825 | if( strncmp(zName, "sqlite_autoindex_", 17)==0 ){ |
| 110564 | 111826 | int i = sqlite3Strlen30(zName) - 1; |
| 110565 | 111827 | while( zName[i]!='_' ) i--; |
| 110566 | 111828 | zName += i; |
| 110567 | 111829 | } |
| | @@ -110580,10 +111842,30 @@ |
| 110580 | 111842 | sqlite3DebugPrintf(" %-19s", z); |
| 110581 | 111843 | sqlite3_free(z); |
| 110582 | 111844 | } |
| 110583 | 111845 | sqlite3DebugPrintf(" f %04x N %d", p->wsFlags, p->nLTerm); |
| 110584 | 111846 | sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut); |
| 111847 | +#ifdef SQLITE_ENABLE_TREE_EXPLAIN |
| 111848 | + /* If the 0x100 bit of wheretracing is set, then show all of the constraint |
| 111849 | + ** expressions in the WhereLoop.aLTerm[] array. |
| 111850 | + */ |
| 111851 | + if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){ /* WHERETRACE 0x100 */ |
| 111852 | + int i; |
| 111853 | + Vdbe *v = pWInfo->pParse->pVdbe; |
| 111854 | + sqlite3ExplainBegin(v); |
| 111855 | + for(i=0; i<p->nLTerm; i++){ |
| 111856 | + WhereTerm *pTerm = p->aLTerm[i]; |
| 111857 | + sqlite3ExplainPrintf(v, " (%d) #%-2d ", i+1, (int)(pTerm-pWC->a)); |
| 111858 | + sqlite3ExplainPush(v); |
| 111859 | + whereExplainTerm(v, pTerm); |
| 111860 | + sqlite3ExplainPop(v); |
| 111861 | + sqlite3ExplainNL(v); |
| 111862 | + } |
| 111863 | + sqlite3ExplainFinish(v); |
| 111864 | + sqlite3DebugPrintf("%s", sqlite3VdbeExplanation(v)); |
| 111865 | + } |
| 111866 | +#endif |
| 110585 | 111867 | } |
| 110586 | 111868 | #endif |
| 110587 | 111869 | |
| 110588 | 111870 | /* |
| 110589 | 111871 | ** Convert bulk memory into a valid WhereLoop that can be passed |
| | @@ -110605,10 +111887,11 @@ |
| 110605 | 111887 | sqlite3_free(p->u.vtab.idxStr); |
| 110606 | 111888 | p->u.vtab.needFree = 0; |
| 110607 | 111889 | p->u.vtab.idxStr = 0; |
| 110608 | 111890 | }else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){ |
| 110609 | 111891 | sqlite3DbFree(db, p->u.btree.pIndex->zColAff); |
| 111892 | + sqlite3KeyInfoUnref(p->u.btree.pIndex->pKeyInfo); |
| 110610 | 111893 | sqlite3DbFree(db, p->u.btree.pIndex); |
| 110611 | 111894 | p->u.btree.pIndex = 0; |
| 110612 | 111895 | } |
| 110613 | 111896 | } |
| 110614 | 111897 | } |
| | @@ -110719,14 +112002,14 @@ |
| 110719 | 112002 | u16 n = pBuilder->pOrSet->n; |
| 110720 | 112003 | int x = |
| 110721 | 112004 | #endif |
| 110722 | 112005 | whereOrInsert(pBuilder->pOrSet, pTemplate->prereq, pTemplate->rRun, |
| 110723 | 112006 | pTemplate->nOut); |
| 110724 | | -#if WHERETRACE_ENABLED |
| 112007 | +#if WHERETRACE_ENABLED /* 0x8 */ |
| 110725 | 112008 | if( sqlite3WhereTrace & 0x8 ){ |
| 110726 | 112009 | sqlite3DebugPrintf(x?" or-%d: ":" or-X: ", n); |
| 110727 | | - whereLoopPrint(pTemplate, pWInfo->pTabList); |
| 112010 | + whereLoopPrint(pTemplate, pBuilder->pWC); |
| 110728 | 112011 | } |
| 110729 | 112012 | #endif |
| 110730 | 112013 | return SQLITE_OK; |
| 110731 | 112014 | } |
| 110732 | 112015 | |
| | @@ -110792,18 +112075,18 @@ |
| 110792 | 112075 | |
| 110793 | 112076 | /* If we reach this point it means that either p[] should be overwritten |
| 110794 | 112077 | ** with pTemplate[] if p[] exists, or if p==NULL then allocate a new |
| 110795 | 112078 | ** WhereLoop and insert it. |
| 110796 | 112079 | */ |
| 110797 | | -#if WHERETRACE_ENABLED |
| 112080 | +#if WHERETRACE_ENABLED /* 0x8 */ |
| 110798 | 112081 | if( sqlite3WhereTrace & 0x8 ){ |
| 110799 | 112082 | if( p!=0 ){ |
| 110800 | 112083 | sqlite3DebugPrintf("ins-del: "); |
| 110801 | | - whereLoopPrint(p, pWInfo->pTabList); |
| 112084 | + whereLoopPrint(p, pBuilder->pWC); |
| 110802 | 112085 | } |
| 110803 | 112086 | sqlite3DebugPrintf("ins-new: "); |
| 110804 | | - whereLoopPrint(pTemplate, pWInfo->pTabList); |
| 112087 | + whereLoopPrint(pTemplate, pBuilder->pWC); |
| 110805 | 112088 | } |
| 110806 | 112089 | #endif |
| 110807 | 112090 | if( p==0 ){ |
| 110808 | 112091 | p = sqlite3DbMallocRaw(db, sizeof(WhereLoop)); |
| 110809 | 112092 | if( p==0 ) return SQLITE_NOMEM; |
| | @@ -110820,14 +112103,14 @@ |
| 110820 | 112103 | } |
| 110821 | 112104 | return SQLITE_OK; |
| 110822 | 112105 | |
| 110823 | 112106 | /* Jump here if the insert is a no-op */ |
| 110824 | 112107 | whereLoopInsert_noop: |
| 110825 | | -#if WHERETRACE_ENABLED |
| 112108 | +#if WHERETRACE_ENABLED /* 0x8 */ |
| 110826 | 112109 | if( sqlite3WhereTrace & 0x8 ){ |
| 110827 | 112110 | sqlite3DebugPrintf("ins-noop: "); |
| 110828 | | - whereLoopPrint(pTemplate, pWInfo->pTabList); |
| 112111 | + whereLoopPrint(pTemplate, pBuilder->pWC); |
| 110829 | 112112 | } |
| 110830 | 112113 | #endif |
| 110831 | 112114 | return SQLITE_OK; |
| 110832 | 112115 | } |
| 110833 | 112116 | |
| | @@ -110904,12 +112187,12 @@ |
| 110904 | 112187 | }else{ |
| 110905 | 112188 | opMask = WO_EQ|WO_IN|WO_ISNULL|WO_GT|WO_GE|WO_LT|WO_LE; |
| 110906 | 112189 | } |
| 110907 | 112190 | if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); |
| 110908 | 112191 | |
| 110909 | | - assert( pNew->u.btree.nEq<=pProbe->nColumn ); |
| 110910 | | - if( pNew->u.btree.nEq < pProbe->nColumn ){ |
| 112192 | + assert( pNew->u.btree.nEq<=pProbe->nKeyCol ); |
| 112193 | + if( pNew->u.btree.nEq < pProbe->nKeyCol ){ |
| 110911 | 112194 | iCol = pProbe->aiColumn[pNew->u.btree.nEq]; |
| 110912 | 112195 | nRowEst = sqlite3LogEst(pProbe->aiRowEst[pNew->u.btree.nEq+1]); |
| 110913 | 112196 | if( nRowEst==0 && pProbe->onError==OE_None ) nRowEst = 1; |
| 110914 | 112197 | }else{ |
| 110915 | 112198 | iCol = -1; |
| | @@ -110962,11 +112245,11 @@ |
| 110962 | 112245 | assert( (pNew->wsFlags & (WHERE_COLUMN_NULL|WHERE_COLUMN_IN))!=0 |
| 110963 | 112246 | || nInMul==0 ); |
| 110964 | 112247 | pNew->wsFlags |= WHERE_COLUMN_EQ; |
| 110965 | 112248 | if( iCol<0 |
| 110966 | 112249 | || (pProbe->onError!=OE_None && nInMul==0 |
| 110967 | | - && pNew->u.btree.nEq==pProbe->nColumn-1) |
| 112250 | + && pNew->u.btree.nEq==pProbe->nKeyCol-1) |
| 110968 | 112251 | ){ |
| 110969 | 112252 | assert( (pNew->wsFlags & WHERE_COLUMN_IN)==0 || iCol<0 ); |
| 110970 | 112253 | pNew->wsFlags |= WHERE_ONEROW; |
| 110971 | 112254 | } |
| 110972 | 112255 | pNew->u.btree.nEq++; |
| | @@ -111028,11 +112311,11 @@ |
| 111028 | 112311 | /* Step cost for each output row */ |
| 111029 | 112312 | pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut); |
| 111030 | 112313 | whereLoopOutputAdjust(pBuilder->pWC, pNew); |
| 111031 | 112314 | rc = whereLoopInsert(pBuilder, pNew); |
| 111032 | 112315 | if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 |
| 111033 | | - && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0)) |
| 112316 | + && pNew->u.btree.nEq<(pProbe->nKeyCol + (pProbe->zName!=0)) |
| 111034 | 112317 | ){ |
| 111035 | 112318 | whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn); |
| 111036 | 112319 | } |
| 111037 | 112320 | pNew->nOut = saved_nOut; |
| 111038 | 112321 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| | @@ -111067,11 +112350,11 @@ |
| 111067 | 112350 | if( (pOB = pBuilder->pWInfo->pOrderBy)==0 ) return 0; |
| 111068 | 112351 | for(ii=0; ii<pOB->nExpr; ii++){ |
| 111069 | 112352 | Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr); |
| 111070 | 112353 | if( pExpr->op!=TK_COLUMN ) return 0; |
| 111071 | 112354 | if( pExpr->iTable==iCursor ){ |
| 111072 | | - for(jj=0; jj<pIndex->nColumn; jj++){ |
| 112355 | + for(jj=0; jj<pIndex->nKeyCol; jj++){ |
| 111073 | 112356 | if( pExpr->iColumn==pIndex->aiColumn[jj] ) return 1; |
| 111074 | 112357 | } |
| 111075 | 112358 | } |
| 111076 | 112359 | } |
| 111077 | 112360 | return 0; |
| | @@ -111084,14 +112367,15 @@ |
| 111084 | 112367 | static Bitmask columnsInIndex(Index *pIdx){ |
| 111085 | 112368 | Bitmask m = 0; |
| 111086 | 112369 | int j; |
| 111087 | 112370 | for(j=pIdx->nColumn-1; j>=0; j--){ |
| 111088 | 112371 | int x = pIdx->aiColumn[j]; |
| 111089 | | - assert( x>=0 ); |
| 111090 | | - testcase( x==BMS-1 ); |
| 111091 | | - testcase( x==BMS-2 ); |
| 111092 | | - if( x<BMS-1 ) m |= MASKBIT(x); |
| 112372 | + if( x>=0 ){ |
| 112373 | + testcase( x==BMS-1 ); |
| 112374 | + testcase( x==BMS-2 ); |
| 112375 | + if( x<BMS-1 ) m |= MASKBIT(x); |
| 112376 | + } |
| 111093 | 112377 | } |
| 111094 | 112378 | return m; |
| 111095 | 112379 | } |
| 111096 | 112380 | |
| 111097 | 112381 | /* Check to see if a partial index with pPartIndexWhere can be used |
| | @@ -111117,11 +112401,11 @@ |
| 111117 | 112401 | ){ |
| 111118 | 112402 | WhereInfo *pWInfo; /* WHERE analysis context */ |
| 111119 | 112403 | Index *pProbe; /* An index we are evaluating */ |
| 111120 | 112404 | Index sPk; /* A fake index object for the primary key */ |
| 111121 | 112405 | tRowcnt aiRowEstPk[2]; /* The aiRowEst[] value for the sPk index */ |
| 111122 | | - int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ |
| 112406 | + i16 aiColumnPk = -1; /* The aColumn[] value for the sPk index */ |
| 111123 | 112407 | SrcList *pTabList; /* The FROM clause */ |
| 111124 | 112408 | struct SrcList_item *pSrc; /* The FROM clause btree term to add */ |
| 111125 | 112409 | WhereLoop *pNew; /* Template WhereLoop object */ |
| 111126 | 112410 | int rc = SQLITE_OK; /* Return code */ |
| 111127 | 112411 | int iSortIdx = 1; /* Index number */ |
| | @@ -111140,18 +112424,20 @@ |
| 111140 | 112424 | assert( !IsVirtual(pSrc->pTab) ); |
| 111141 | 112425 | |
| 111142 | 112426 | if( pSrc->pIndex ){ |
| 111143 | 112427 | /* An INDEXED BY clause specifies a particular index to use */ |
| 111144 | 112428 | pProbe = pSrc->pIndex; |
| 112429 | + }else if( !HasRowid(pTab) ){ |
| 112430 | + pProbe = pTab->pIndex; |
| 111145 | 112431 | }else{ |
| 111146 | 112432 | /* There is no INDEXED BY clause. Create a fake Index object in local |
| 111147 | 112433 | ** variable sPk to represent the rowid primary key index. Make this |
| 111148 | 112434 | ** fake index the first in a chain of Index objects with all of the real |
| 111149 | 112435 | ** indices to follow */ |
| 111150 | 112436 | Index *pFirst; /* First of real indices on the table */ |
| 111151 | 112437 | memset(&sPk, 0, sizeof(Index)); |
| 111152 | | - sPk.nColumn = 1; |
| 112438 | + sPk.nKeyCol = 1; |
| 111153 | 112439 | sPk.aiColumn = &aiColumnPk; |
| 111154 | 112440 | sPk.aiRowEst = aiRowEstPk; |
| 111155 | 112441 | sPk.onError = OE_Replace; |
| 111156 | 112442 | sPk.pTable = pTab; |
| 111157 | 112443 | aiRowEstPk[0] = pTab->nRowEst; |
| | @@ -111172,10 +112458,11 @@ |
| 111172 | 112458 | if( !pBuilder->pOrSet |
| 111173 | 112459 | && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 |
| 111174 | 112460 | && pSrc->pIndex==0 |
| 111175 | 112461 | && !pSrc->viaCoroutine |
| 111176 | 112462 | && !pSrc->notIndexed |
| 112463 | + && HasRowid(pTab) |
| 111177 | 112464 | && !pSrc->isCorrelated |
| 111178 | 112465 | ){ |
| 111179 | 112466 | /* Generate auto-index WhereLoops */ |
| 111180 | 112467 | WhereTerm *pTerm; |
| 111181 | 112468 | WhereTerm *pWCEnd = pWC->a + pWC->nTerm; |
| | @@ -111234,18 +112521,25 @@ |
| 111234 | 112521 | whereLoopOutputAdjust(pWC, pNew); |
| 111235 | 112522 | rc = whereLoopInsert(pBuilder, pNew); |
| 111236 | 112523 | pNew->nOut = rSize; |
| 111237 | 112524 | if( rc ) break; |
| 111238 | 112525 | }else{ |
| 111239 | | - Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe); |
| 111240 | | - pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED; |
| 112526 | + Bitmask m; |
| 112527 | + if( pProbe->isCovering ){ |
| 112528 | + pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED; |
| 112529 | + m = 0; |
| 112530 | + }else{ |
| 112531 | + m = pSrc->colUsed & ~columnsInIndex(pProbe); |
| 112532 | + pNew->wsFlags = (m==0) ? (WHERE_IDX_ONLY|WHERE_INDEXED) : WHERE_INDEXED; |
| 112533 | + } |
| 111241 | 112534 | |
| 111242 | 112535 | /* Full scan via index */ |
| 111243 | 112536 | if( b |
| 112537 | + || !HasRowid(pTab) |
| 111244 | 112538 | || ( m==0 |
| 111245 | 112539 | && pProbe->bUnordered==0 |
| 111246 | | - && pProbe->szIdxRow<pTab->szTabRow |
| 112540 | + && (pProbe->szIdxRow<pTab->szTabRow) |
| 111247 | 112541 | && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 |
| 111248 | 112542 | && sqlite3GlobalConfig.bUseCis |
| 111249 | 112543 | && OptimizationEnabled(pWInfo->pParse->db, SQLITE_CoverIdxScan) |
| 111250 | 112544 | ) |
| 111251 | 112545 | ){ |
| | @@ -111257,11 +112551,10 @@ |
| 111257 | 112551 | ** is smaller for smaller indices, thus favoring them. |
| 111258 | 112552 | */ |
| 111259 | 112553 | pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 1 + |
| 111260 | 112554 | (15*pProbe->szIdxRow)/pTab->szTabRow; |
| 111261 | 112555 | }else{ |
| 111262 | | - assert( b!=0 ); |
| 111263 | 112556 | /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N) |
| 111264 | 112557 | ** which we will simplify to just N*log2(N) */ |
| 111265 | 112558 | pNew->rRun = rSize + rLogSize; |
| 111266 | 112559 | } |
| 111267 | 112560 | whereLoopOutputAdjust(pWC, pNew); |
| | @@ -111473,10 +112766,11 @@ |
| 111473 | 112766 | if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK; |
| 111474 | 112767 | pWCEnd = pWC->a + pWC->nTerm; |
| 111475 | 112768 | pNew = pBuilder->pNew; |
| 111476 | 112769 | memset(&sSum, 0, sizeof(sSum)); |
| 111477 | 112770 | pItem = pWInfo->pTabList->a + pNew->iTab; |
| 112771 | + if( !HasRowid(pItem->pTab) ) return SQLITE_OK; |
| 111478 | 112772 | iCur = pItem->iCursor; |
| 111479 | 112773 | |
| 111480 | 112774 | for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){ |
| 111481 | 112775 | if( (pTerm->eOperator & WO_OR)!=0 |
| 111482 | 112776 | && (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0 |
| | @@ -111622,11 +112916,12 @@ |
| 111622 | 112916 | u8 rev; /* Composite sort order */ |
| 111623 | 112917 | u8 revIdx; /* Index sort order */ |
| 111624 | 112918 | u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */ |
| 111625 | 112919 | u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */ |
| 111626 | 112920 | u8 isMatch; /* iColumn matches a term of the ORDER BY clause */ |
| 111627 | | - u16 nColumn; /* Number of columns in pIndex */ |
| 112921 | + u16 nKeyCol; /* Number of key columns in pIndex */ |
| 112922 | + u16 nColumn; /* Total number of ordered columns in the index */ |
| 111628 | 112923 | u16 nOrderBy; /* Number terms in the ORDER BY clause */ |
| 111629 | 112924 | int iLoop; /* Index of WhereLoop in pPath being processed */ |
| 111630 | 112925 | int i, j; /* Loop counters */ |
| 111631 | 112926 | int iCur; /* Cursor number for current WhereLoop */ |
| 111632 | 112927 | int iColumn; /* A column number within table iCur */ |
| | @@ -111714,24 +113009,28 @@ |
| 111714 | 113009 | } |
| 111715 | 113010 | |
| 111716 | 113011 | if( (pLoop->wsFlags & WHERE_ONEROW)==0 ){ |
| 111717 | 113012 | if( pLoop->wsFlags & WHERE_IPK ){ |
| 111718 | 113013 | pIndex = 0; |
| 111719 | | - nColumn = 0; |
| 113014 | + nKeyCol = 0; |
| 113015 | + nColumn = 1; |
| 111720 | 113016 | }else if( (pIndex = pLoop->u.btree.pIndex)==0 || pIndex->bUnordered ){ |
| 111721 | 113017 | return 0; |
| 111722 | 113018 | }else{ |
| 113019 | + nKeyCol = pIndex->nKeyCol; |
| 111723 | 113020 | nColumn = pIndex->nColumn; |
| 113021 | + assert( nColumn==nKeyCol+1 || !HasRowid(pIndex->pTable) ); |
| 113022 | + assert( pIndex->aiColumn[nColumn-1]==(-1) || !HasRowid(pIndex->pTable)); |
| 111724 | 113023 | isOrderDistinct = pIndex->onError!=OE_None; |
| 111725 | 113024 | } |
| 111726 | 113025 | |
| 111727 | 113026 | /* Loop through all columns of the index and deal with the ones |
| 111728 | 113027 | ** that are not constrained by == or IN. |
| 111729 | 113028 | */ |
| 111730 | 113029 | rev = revSet = 0; |
| 111731 | 113030 | distinctColumns = 0; |
| 111732 | | - for(j=0; j<=nColumn; j++){ |
| 113031 | + for(j=0; j<nColumn; j++){ |
| 111733 | 113032 | u8 bOnce; /* True to run the ORDER BY search loop */ |
| 111734 | 113033 | |
| 111735 | 113034 | /* Skip over == and IS NULL terms */ |
| 111736 | 113035 | if( j<pLoop->u.btree.nEq |
| 111737 | 113036 | && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL))!=0 |
| | @@ -111744,24 +113043,21 @@ |
| 111744 | 113043 | } |
| 111745 | 113044 | |
| 111746 | 113045 | /* Get the column number in the table (iColumn) and sort order |
| 111747 | 113046 | ** (revIdx) for the j-th column of the index. |
| 111748 | 113047 | */ |
| 111749 | | - if( j<nColumn ){ |
| 111750 | | - /* Normal index columns */ |
| 113048 | + if( pIndex ){ |
| 111751 | 113049 | iColumn = pIndex->aiColumn[j]; |
| 111752 | 113050 | revIdx = pIndex->aSortOrder[j]; |
| 111753 | 113051 | if( iColumn==pIndex->pTable->iPKey ) iColumn = -1; |
| 111754 | 113052 | }else{ |
| 111755 | | - /* The ROWID column at the end */ |
| 111756 | | - assert( j==nColumn ); |
| 111757 | 113053 | iColumn = -1; |
| 111758 | 113054 | revIdx = 0; |
| 111759 | 113055 | } |
| 111760 | 113056 | |
| 111761 | 113057 | /* An unconstrained column that might be NULL means that this |
| 111762 | | - ** WhereLoop is not well-ordered |
| 113058 | + ** WhereLoop is not well-ordered |
| 111763 | 113059 | */ |
| 111764 | 113060 | if( isOrderDistinct |
| 111765 | 113061 | && iColumn>=0 |
| 111766 | 113062 | && j>=pLoop->u.btree.nEq |
| 111767 | 113063 | && pIndex->pTable->aCol[iColumn].notNull==0 |
| | @@ -111808,11 +113104,11 @@ |
| 111808 | 113104 | revSet = 1; |
| 111809 | 113105 | } |
| 111810 | 113106 | } |
| 111811 | 113107 | }else{ |
| 111812 | 113108 | /* No match found */ |
| 111813 | | - if( j==0 || j<nColumn ){ |
| 113109 | + if( j==0 || j<nKeyCol ){ |
| 111814 | 113110 | testcase( isOrderDistinct!=0 ); |
| 111815 | 113111 | isOrderDistinct = 0; |
| 111816 | 113112 | } |
| 111817 | 113113 | break; |
| 111818 | 113114 | } |
| | @@ -111981,11 +113277,11 @@ |
| 111981 | 113277 | break; |
| 111982 | 113278 | } |
| 111983 | 113279 | } |
| 111984 | 113280 | if( jj>=nTo ){ |
| 111985 | 113281 | if( nTo>=mxChoice && rCost>=mxCost ){ |
| 111986 | | -#ifdef WHERETRACE_ENABLED |
| 113282 | +#ifdef WHERETRACE_ENABLED /* 0x4 */ |
| 111987 | 113283 | if( sqlite3WhereTrace&0x4 ){ |
| 111988 | 113284 | sqlite3DebugPrintf("Skip %s cost=%-3d,%3d order=%c\n", |
| 111989 | 113285 | wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, |
| 111990 | 113286 | isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?'); |
| 111991 | 113287 | } |
| | @@ -111999,20 +113295,20 @@ |
| 111999 | 113295 | }else{ |
| 112000 | 113296 | /* New path replaces the prior worst to keep count below mxChoice */ |
| 112001 | 113297 | jj = mxI; |
| 112002 | 113298 | } |
| 112003 | 113299 | pTo = &aTo[jj]; |
| 112004 | | -#ifdef WHERETRACE_ENABLED |
| 113300 | +#ifdef WHERETRACE_ENABLED /* 0x4 */ |
| 112005 | 113301 | if( sqlite3WhereTrace&0x4 ){ |
| 112006 | 113302 | sqlite3DebugPrintf("New %s cost=%-3d,%3d order=%c\n", |
| 112007 | 113303 | wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, |
| 112008 | 113304 | isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?'); |
| 112009 | 113305 | } |
| 112010 | 113306 | #endif |
| 112011 | 113307 | }else{ |
| 112012 | 113308 | if( pTo->rCost<=rCost && pTo->nRow<=nOut ){ |
| 112013 | | -#ifdef WHERETRACE_ENABLED |
| 113309 | +#ifdef WHERETRACE_ENABLED /* 0x4 */ |
| 112014 | 113310 | if( sqlite3WhereTrace&0x4 ){ |
| 112015 | 113311 | sqlite3DebugPrintf( |
| 112016 | 113312 | "Skip %s cost=%-3d,%3d order=%c", |
| 112017 | 113313 | wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, |
| 112018 | 113314 | isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?'); |
| | @@ -112024,11 +113320,11 @@ |
| 112024 | 113320 | testcase( pTo->rCost==rCost ); |
| 112025 | 113321 | continue; |
| 112026 | 113322 | } |
| 112027 | 113323 | testcase( pTo->rCost==rCost+1 ); |
| 112028 | 113324 | /* A new and better score for a previously created equivalent path */ |
| 112029 | | -#ifdef WHERETRACE_ENABLED |
| 113325 | +#ifdef WHERETRACE_ENABLED /* 0x4 */ |
| 112030 | 113326 | if( sqlite3WhereTrace&0x4 ){ |
| 112031 | 113327 | sqlite3DebugPrintf( |
| 112032 | 113328 | "Update %s cost=%-3d,%3d order=%c", |
| 112033 | 113329 | wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, |
| 112034 | 113330 | isOrderedValid ? (isOrdered ? 'Y' : 'N') : '?'); |
| | @@ -112060,11 +113356,11 @@ |
| 112060 | 113356 | } |
| 112061 | 113357 | } |
| 112062 | 113358 | } |
| 112063 | 113359 | } |
| 112064 | 113360 | |
| 112065 | | -#ifdef WHERETRACE_ENABLED |
| 113361 | +#ifdef WHERETRACE_ENABLED /* >=2 */ |
| 112066 | 113362 | if( sqlite3WhereTrace>=2 ){ |
| 112067 | 113363 | sqlite3DebugPrintf("---- after round %d ----\n", iLoop); |
| 112068 | 113364 | for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){ |
| 112069 | 113365 | sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c", |
| 112070 | 113366 | wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow, |
| | @@ -112174,20 +113470,20 @@ |
| 112174 | 113470 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 112175 | 113471 | assert( pLoop->aLTermSpace==pLoop->aLTerm ); |
| 112176 | 113472 | assert( ArraySize(pLoop->aLTermSpace)==4 ); |
| 112177 | 113473 | if( pIdx->onError==OE_None |
| 112178 | 113474 | || pIdx->pPartIdxWhere!=0 |
| 112179 | | - || pIdx->nColumn>ArraySize(pLoop->aLTermSpace) |
| 113475 | + || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace) |
| 112180 | 113476 | ) continue; |
| 112181 | | - for(j=0; j<pIdx->nColumn; j++){ |
| 113477 | + for(j=0; j<pIdx->nKeyCol; j++){ |
| 112182 | 113478 | pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx); |
| 112183 | 113479 | if( pTerm==0 ) break; |
| 112184 | 113480 | pLoop->aLTerm[j] = pTerm; |
| 112185 | 113481 | } |
| 112186 | | - if( j!=pIdx->nColumn ) continue; |
| 113482 | + if( j!=pIdx->nKeyCol ) continue; |
| 112187 | 113483 | pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED; |
| 112188 | | - if( (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){ |
| 113484 | + if( pIdx->isCovering || (pItem->colUsed & ~columnsInIndex(pIdx))==0 ){ |
| 112189 | 113485 | pLoop->wsFlags |= WHERE_IDX_ONLY; |
| 112190 | 113486 | } |
| 112191 | 113487 | pLoop->nLTerm = j; |
| 112192 | 113488 | pLoop->u.btree.nEq = j; |
| 112193 | 113489 | pLoop->u.btree.pIndex = pIdx; |
| | @@ -112291,10 +113587,18 @@ |
| 112291 | 113587 | ** |
| 112292 | 113588 | ** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause |
| 112293 | 113589 | ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement |
| 112294 | 113590 | ** if there is one. If there is no ORDER BY clause or if this routine |
| 112295 | 113591 | ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL. |
| 113592 | +** |
| 113593 | +** The iIdxCur parameter is the cursor number of an index. If |
| 113594 | +** WHERE_ONETABLE_ONLY is set, iIdxCur is the cursor number of an index |
| 113595 | +** to use for OR clause processing. The WHERE clause should use this |
| 113596 | +** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is |
| 113597 | +** the first cursor in an array of cursors for all indices. iIdxCur should |
| 113598 | +** be used to compute the appropriate cursor depending on which index is |
| 113599 | +** used. |
| 112296 | 113600 | */ |
| 112297 | 113601 | SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( |
| 112298 | 113602 | Parse *pParse, /* The parser context */ |
| 112299 | 113603 | SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */ |
| 112300 | 113604 | Expr *pWhere, /* The WHERE clause */ |
| | @@ -112356,10 +113660,11 @@ |
| 112356 | 113660 | if( db->mallocFailed ){ |
| 112357 | 113661 | sqlite3DbFree(db, pWInfo); |
| 112358 | 113662 | pWInfo = 0; |
| 112359 | 113663 | goto whereBeginError; |
| 112360 | 113664 | } |
| 113665 | + pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; |
| 112361 | 113666 | pWInfo->nLevel = nTabList; |
| 112362 | 113667 | pWInfo->pParse = pParse; |
| 112363 | 113668 | pWInfo->pTabList = pTabList; |
| 112364 | 113669 | pWInfo->pOrderBy = pOrderBy; |
| 112365 | 113670 | pWInfo->pResultSet = pResultSet; |
| | @@ -112469,24 +113774,41 @@ |
| 112469 | 113774 | } |
| 112470 | 113775 | } |
| 112471 | 113776 | |
| 112472 | 113777 | /* Construct the WhereLoop objects */ |
| 112473 | 113778 | WHERETRACE(0xffff,("*** Optimizer Start ***\n")); |
| 113779 | + /* Display all terms of the WHERE clause */ |
| 113780 | +#if defined(WHERETRACE_ENABLED) && defined(SQLITE_ENABLE_TREE_EXPLAIN) |
| 113781 | + if( sqlite3WhereTrace & 0x100 ){ |
| 113782 | + int i; |
| 113783 | + Vdbe *v = pParse->pVdbe; |
| 113784 | + sqlite3ExplainBegin(v); |
| 113785 | + for(i=0; i<sWLB.pWC->nTerm; i++){ |
| 113786 | + sqlite3ExplainPrintf(v, "#%-2d ", i); |
| 113787 | + sqlite3ExplainPush(v); |
| 113788 | + whereExplainTerm(v, &sWLB.pWC->a[i]); |
| 113789 | + sqlite3ExplainPop(v); |
| 113790 | + sqlite3ExplainNL(v); |
| 113791 | + } |
| 113792 | + sqlite3ExplainFinish(v); |
| 113793 | + sqlite3DebugPrintf("%s", sqlite3VdbeExplanation(v)); |
| 113794 | + } |
| 113795 | +#endif |
| 112474 | 113796 | if( nTabList!=1 || whereShortCut(&sWLB)==0 ){ |
| 112475 | 113797 | rc = whereLoopAddAll(&sWLB); |
| 112476 | 113798 | if( rc ) goto whereBeginError; |
| 112477 | 113799 | |
| 112478 | 113800 | /* Display all of the WhereLoop objects if wheretrace is enabled */ |
| 112479 | | -#ifdef WHERETRACE_ENABLED |
| 113801 | +#ifdef WHERETRACE_ENABLED /* !=0 */ |
| 112480 | 113802 | if( sqlite3WhereTrace ){ |
| 112481 | 113803 | WhereLoop *p; |
| 112482 | 113804 | int i; |
| 112483 | 113805 | static char zLabel[] = "0123456789abcdefghijklmnopqrstuvwyxz" |
| 112484 | 113806 | "ABCDEFGHIJKLMNOPQRSTUVWYXZ"; |
| 112485 | 113807 | for(p=pWInfo->pLoops, i=0; p; p=p->pNextLoop, i++){ |
| 112486 | 113808 | p->cId = zLabel[i%sizeof(zLabel)]; |
| 112487 | | - whereLoopPrint(p, pTabList); |
| 113809 | + whereLoopPrint(p, sWLB.pWC); |
| 112488 | 113810 | } |
| 112489 | 113811 | } |
| 112490 | 113812 | #endif |
| 112491 | 113813 | |
| 112492 | 113814 | wherePathSolver(pWInfo, 0); |
| | @@ -112500,11 +113822,11 @@ |
| 112500 | 113822 | pWInfo->revMask = (Bitmask)(-1); |
| 112501 | 113823 | } |
| 112502 | 113824 | if( pParse->nErr || NEVER(db->mallocFailed) ){ |
| 112503 | 113825 | goto whereBeginError; |
| 112504 | 113826 | } |
| 112505 | | -#ifdef WHERETRACE_ENABLED |
| 113827 | +#ifdef WHERETRACE_ENABLED /* !=0 */ |
| 112506 | 113828 | if( sqlite3WhereTrace ){ |
| 112507 | 113829 | int ii; |
| 112508 | 113830 | sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut); |
| 112509 | 113831 | if( pWInfo->bOBSat ){ |
| 112510 | 113832 | sqlite3DebugPrintf(" ORDERBY=0x%llx", pWInfo->revMask); |
| | @@ -112523,11 +113845,11 @@ |
| 112523 | 113845 | break; |
| 112524 | 113846 | } |
| 112525 | 113847 | } |
| 112526 | 113848 | sqlite3DebugPrintf("\n"); |
| 112527 | 113849 | for(ii=0; ii<pWInfo->nLevel; ii++){ |
| 112528 | | - whereLoopPrint(pWInfo->a[ii].pWLoop, pTabList); |
| 113850 | + whereLoopPrint(pWInfo->a[ii].pWLoop, sWLB.pWC); |
| 112529 | 113851 | } |
| 112530 | 113852 | } |
| 112531 | 113853 | #endif |
| 112532 | 113854 | /* Attempt to omit tables from the join that do not effect the result */ |
| 112533 | 113855 | if( pWInfo->nLevel>=2 |
| | @@ -112570,11 +113892,13 @@ |
| 112570 | 113892 | */ |
| 112571 | 113893 | assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 ); |
| 112572 | 113894 | if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 |
| 112573 | 113895 | && (pWInfo->a[0].pWLoop->wsFlags & WHERE_ONEROW)!=0 ){ |
| 112574 | 113896 | pWInfo->okOnePass = 1; |
| 112575 | | - pWInfo->a[0].pWLoop->wsFlags &= ~WHERE_IDX_ONLY; |
| 113897 | + if( HasRowid(pTabList->a[0].pTab) ){ |
| 113898 | + pWInfo->a[0].pWLoop->wsFlags &= ~WHERE_IDX_ONLY; |
| 113899 | + } |
| 112576 | 113900 | } |
| 112577 | 113901 | |
| 112578 | 113902 | /* Open all tables in the pTabList and any indices selected for |
| 112579 | 113903 | ** searching those tables. |
| 112580 | 113904 | */ |
| | @@ -112600,15 +113924,20 @@ |
| 112600 | 113924 | /* noop */ |
| 112601 | 113925 | }else |
| 112602 | 113926 | #endif |
| 112603 | 113927 | if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 |
| 112604 | 113928 | && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){ |
| 112605 | | - int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead; |
| 113929 | + int op = OP_OpenRead; |
| 113930 | + if( pWInfo->okOnePass ){ |
| 113931 | + op = OP_OpenWrite; |
| 113932 | + pWInfo->aiCurOnePass[0] = pTabItem->iCursor; |
| 113933 | + }; |
| 112606 | 113934 | sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op); |
| 113935 | + assert( pTabItem->iCursor==pLevel->iTabCur ); |
| 112607 | 113936 | testcase( !pWInfo->okOnePass && pTab->nCol==BMS-1 ); |
| 112608 | 113937 | testcase( !pWInfo->okOnePass && pTab->nCol==BMS ); |
| 112609 | | - if( !pWInfo->okOnePass && pTab->nCol<BMS ){ |
| 113938 | + if( !pWInfo->okOnePass && pTab->nCol<BMS && HasRowid(pTab) ){ |
| 112610 | 113939 | Bitmask b = pTabItem->colUsed; |
| 112611 | 113940 | int n = 0; |
| 112612 | 113941 | for(; b; b=b>>1, n++){} |
| 112613 | 113942 | sqlite3VdbeChangeP4(v, sqlite3VdbeCurrentAddr(v)-1, |
| 112614 | 113943 | SQLITE_INT_TO_PTR(n), P4_INT32); |
| | @@ -112617,17 +113946,34 @@ |
| 112617 | 113946 | }else{ |
| 112618 | 113947 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
| 112619 | 113948 | } |
| 112620 | 113949 | if( pLoop->wsFlags & WHERE_INDEXED ){ |
| 112621 | 113950 | Index *pIx = pLoop->u.btree.pIndex; |
| 112622 | | - KeyInfo *pKey = sqlite3IndexKeyinfo(pParse, pIx); |
| 112623 | | - /* FIXME: As an optimization use pTabItem->iCursor if WHERE_IDX_ONLY */ |
| 112624 | | - int iIndexCur = pLevel->iIdxCur = iIdxCur ? iIdxCur : pParse->nTab++; |
| 113951 | + int iIndexCur; |
| 113952 | + int op = OP_OpenRead; |
| 113953 | + /* iIdxCur is always set if to a positive value if ONEPASS is possible */ |
| 113954 | + assert( iIdxCur!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 ); |
| 113955 | + if( pWInfo->okOnePass ){ |
| 113956 | + Index *pJ = pTabItem->pTab->pIndex; |
| 113957 | + iIndexCur = iIdxCur; |
| 113958 | + assert( wctrlFlags & WHERE_ONEPASS_DESIRED ); |
| 113959 | + while( ALWAYS(pJ) && pJ!=pIx ){ |
| 113960 | + iIndexCur++; |
| 113961 | + pJ = pJ->pNext; |
| 113962 | + } |
| 113963 | + op = OP_OpenWrite; |
| 113964 | + pWInfo->aiCurOnePass[1] = iIndexCur; |
| 113965 | + }else if( iIdxCur && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){ |
| 113966 | + iIndexCur = iIdxCur; |
| 113967 | + }else{ |
| 113968 | + iIndexCur = pParse->nTab++; |
| 113969 | + } |
| 113970 | + pLevel->iIdxCur = iIndexCur; |
| 112625 | 113971 | assert( pIx->pSchema==pTab->pSchema ); |
| 112626 | 113972 | assert( iIndexCur>=0 ); |
| 112627 | | - sqlite3VdbeAddOp4(v, OP_OpenRead, iIndexCur, pIx->tnum, iDb, |
| 112628 | | - (char*)pKey, P4_KEYINFO_HANDOFF); |
| 113973 | + sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb); |
| 113974 | + sqlite3VdbeSetP4KeyInfo(pParse, pIx); |
| 112629 | 113975 | VdbeComment((v, "%s", pIx->zName)); |
| 112630 | 113976 | } |
| 112631 | 113977 | sqlite3CodeVerifySchema(pParse, iDb); |
| 112632 | 113978 | notReady &= ~getMask(&pWInfo->sMaskSet, pTabItem->iCursor); |
| 112633 | 113979 | } |
| | @@ -112718,35 +114064,44 @@ |
| 112718 | 114064 | }else{ |
| 112719 | 114065 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrFirst); |
| 112720 | 114066 | } |
| 112721 | 114067 | sqlite3VdbeJumpHere(v, addr); |
| 112722 | 114068 | } |
| 114069 | + VdbeNoopComment((v, "End WHERE-Loop %d: %s", i, |
| 114070 | + pWInfo->pTabList->a[pLevel->iFrom].pTab->zName)); |
| 112723 | 114071 | } |
| 112724 | 114072 | |
| 112725 | 114073 | /* The "break" point is here, just past the end of the outer loop. |
| 112726 | 114074 | ** Set it. |
| 112727 | 114075 | */ |
| 112728 | 114076 | sqlite3VdbeResolveLabel(v, pWInfo->iBreak); |
| 112729 | 114077 | |
| 112730 | | - /* Close all of the cursors that were opened by sqlite3WhereBegin. |
| 112731 | | - */ |
| 112732 | 114078 | assert( pWInfo->nLevel<=pTabList->nSrc ); |
| 112733 | 114079 | for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){ |
| 112734 | 114080 | Index *pIdx = 0; |
| 112735 | 114081 | struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom]; |
| 112736 | 114082 | Table *pTab = pTabItem->pTab; |
| 112737 | 114083 | assert( pTab!=0 ); |
| 112738 | 114084 | pLoop = pLevel->pWLoop; |
| 114085 | + |
| 114086 | + /* Close all of the cursors that were opened by sqlite3WhereBegin. |
| 114087 | + ** Except, do not close cursors that will be reused by the OR optimization |
| 114088 | + ** (WHERE_OMIT_OPEN_CLOSE). And do not close the OP_OpenWrite cursors |
| 114089 | + ** created for the ONEPASS optimization. |
| 114090 | + */ |
| 112739 | 114091 | if( (pTab->tabFlags & TF_Ephemeral)==0 |
| 112740 | 114092 | && pTab->pSelect==0 |
| 112741 | 114093 | && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 |
| 112742 | 114094 | ){ |
| 112743 | 114095 | int ws = pLoop->wsFlags; |
| 112744 | 114096 | if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){ |
| 112745 | 114097 | sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor); |
| 112746 | 114098 | } |
| 112747 | | - if( (ws & WHERE_INDEXED)!=0 && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 ){ |
| 114099 | + if( (ws & WHERE_INDEXED)!=0 |
| 114100 | + && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 |
| 114101 | + && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1] |
| 114102 | + ){ |
| 112748 | 114103 | sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur); |
| 112749 | 114104 | } |
| 112750 | 114105 | } |
| 112751 | 114106 | |
| 112752 | 114107 | /* If this scan uses an index, make VDBE code substitutions to read data |
| | @@ -112764,27 +114119,31 @@ |
| 112764 | 114119 | pIdx = pLoop->u.btree.pIndex; |
| 112765 | 114120 | }else if( pLoop->wsFlags & WHERE_MULTI_OR ){ |
| 112766 | 114121 | pIdx = pLevel->u.pCovidx; |
| 112767 | 114122 | } |
| 112768 | 114123 | if( pIdx && !db->mallocFailed ){ |
| 112769 | | - int k, j, last; |
| 114124 | + int k, last; |
| 112770 | 114125 | VdbeOp *pOp; |
| 112771 | 114126 | |
| 112772 | 114127 | last = sqlite3VdbeCurrentAddr(v); |
| 112773 | 114128 | k = pLevel->addrBody; |
| 112774 | 114129 | pOp = sqlite3VdbeGetOp(v, k); |
| 112775 | 114130 | for(; k<last; k++, pOp++){ |
| 112776 | 114131 | if( pOp->p1!=pLevel->iTabCur ) continue; |
| 112777 | 114132 | if( pOp->opcode==OP_Column ){ |
| 112778 | | - for(j=0; j<pIdx->nColumn; j++){ |
| 112779 | | - if( pOp->p2==pIdx->aiColumn[j] ){ |
| 112780 | | - pOp->p2 = j; |
| 112781 | | - pOp->p1 = pLevel->iIdxCur; |
| 112782 | | - break; |
| 112783 | | - } |
| 112784 | | - } |
| 112785 | | - assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || j<pIdx->nColumn ); |
| 114133 | + int x = pOp->p2; |
| 114134 | + assert( pIdx->pTable==pTab ); |
| 114135 | + if( !HasRowid(pTab) ){ |
| 114136 | + Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 114137 | + x = pPk->aiColumn[x]; |
| 114138 | + } |
| 114139 | + x = sqlite3ColumnOfIndex(pIdx, x); |
| 114140 | + if( x>=0 ){ |
| 114141 | + pOp->p2 = x; |
| 114142 | + pOp->p1 = pLevel->iIdxCur; |
| 114143 | + } |
| 114144 | + assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0 ); |
| 112786 | 114145 | }else if( pOp->opcode==OP_Rowid ){ |
| 112787 | 114146 | pOp->p1 = pLevel->iIdxCur; |
| 112788 | 114147 | pOp->opcode = OP_IdxRowid; |
| 112789 | 114148 | } |
| 112790 | 114149 | } |
| | @@ -112988,42 +114347,42 @@ |
| 112988 | 114347 | ** YYNRULE the number of rules in the grammar |
| 112989 | 114348 | ** YYERRORSYMBOL is the code number of the error symbol. If not |
| 112990 | 114349 | ** defined, then do no error processing. |
| 112991 | 114350 | */ |
| 112992 | 114351 | #define YYCODETYPE unsigned char |
| 112993 | | -#define YYNOCODE 251 |
| 114352 | +#define YYNOCODE 253 |
| 112994 | 114353 | #define YYACTIONTYPE unsigned short int |
| 112995 | | -#define YYWILDCARD 67 |
| 114354 | +#define YYWILDCARD 68 |
| 112996 | 114355 | #define sqlite3ParserTOKENTYPE Token |
| 112997 | 114356 | typedef union { |
| 112998 | 114357 | int yyinit; |
| 112999 | 114358 | sqlite3ParserTOKENTYPE yy0; |
| 113000 | | - struct LimitVal yy64; |
| 113001 | | - Expr* yy122; |
| 113002 | | - Select* yy159; |
| 113003 | | - IdList* yy180; |
| 113004 | | - struct {int value; int mask;} yy207; |
| 113005 | | - u8 yy258; |
| 113006 | | - u16 yy305; |
| 113007 | | - struct LikeOp yy318; |
| 113008 | | - TriggerStep* yy327; |
| 113009 | | - ExprSpan yy342; |
| 113010 | | - SrcList* yy347; |
| 113011 | | - int yy392; |
| 113012 | | - struct TrigEvent yy410; |
| 113013 | | - ExprList* yy442; |
| 113014 | | - struct ValueList yy487; |
| 114359 | + int yy4; |
| 114360 | + struct TrigEvent yy90; |
| 114361 | + ExprSpan yy118; |
| 114362 | + u16 yy177; |
| 114363 | + TriggerStep* yy203; |
| 114364 | + u8 yy210; |
| 114365 | + struct {int value; int mask;} yy215; |
| 114366 | + SrcList* yy259; |
| 114367 | + struct ValueList yy260; |
| 114368 | + struct LimitVal yy292; |
| 114369 | + Expr* yy314; |
| 114370 | + ExprList* yy322; |
| 114371 | + struct LikeOp yy342; |
| 114372 | + IdList* yy384; |
| 114373 | + Select* yy387; |
| 113015 | 114374 | } YYMINORTYPE; |
| 113016 | 114375 | #ifndef YYSTACKDEPTH |
| 113017 | 114376 | #define YYSTACKDEPTH 100 |
| 113018 | 114377 | #endif |
| 113019 | 114378 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 113020 | 114379 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 113021 | 114380 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 113022 | 114381 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 113023 | | -#define YYNSTATE 628 |
| 113024 | | -#define YYNRULE 327 |
| 114382 | +#define YYNSTATE 631 |
| 114383 | +#define YYNRULE 329 |
| 113025 | 114384 | #define YYFALLBACK 1 |
| 113026 | 114385 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 113027 | 114386 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 113028 | 114387 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| 113029 | 114388 | |
| | @@ -113089,478 +114448,484 @@ |
| 113089 | 114448 | ** shifting terminals. |
| 113090 | 114449 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 113091 | 114450 | ** shifting non-terminals after a reduce. |
| 113092 | 114451 | ** yy_default[] Default action for each state. |
| 113093 | 114452 | */ |
| 113094 | | -#define YY_ACTTAB_COUNT (1564) |
| 114453 | +#define YY_ACTTAB_COUNT (1582) |
| 113095 | 114454 | static const YYACTIONTYPE yy_action[] = { |
| 113096 | | - /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56, |
| 113097 | | - /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52, |
| 113098 | | - /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234, |
| 113099 | | - /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54, |
| 113100 | | - /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57, |
| 113101 | | - /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 113102 | | - /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52, |
| 113103 | | - /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194, |
| 113104 | | - /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 113105 | | - /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377, |
| 113106 | | - /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59, |
| 113107 | | - /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146, |
| 113108 | | - /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581, |
| 113109 | | - /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54, |
| 113110 | | - /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223, |
| 113111 | | - /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168, |
| 113112 | | - /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439, |
| 113113 | | - /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582, |
| 113114 | | - /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440, |
| 113115 | | - /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48, |
| 113116 | | - /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 113117 | | - /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 113118 | | - /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386, |
| 113119 | | - /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263, |
| 113120 | | - /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569, |
| 113121 | | - /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381, |
| 113122 | | - /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593, |
| 113123 | | - /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 113124 | | - /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53, |
| 113125 | | - /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617, |
| 113126 | | - /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549, |
| 113127 | | - /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619, |
| 113128 | | - /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599, |
| 113129 | | - /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513, |
| 113130 | | - /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579, |
| 113131 | | - /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54, |
| 113132 | | - /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 113133 | | - /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618, |
| 113134 | | - /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620, |
| 113135 | | - /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490, |
| 113136 | | - /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470, |
| 113137 | | - /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57, |
| 113138 | | - /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 113139 | | - /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52, |
| 113140 | | - /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577, |
| 113141 | | - /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505, |
| 113142 | | - /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181, |
| 113143 | | - /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562, |
| 113144 | | - /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599, |
| 113145 | | - /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581, |
| 113146 | | - /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54, |
| 113147 | | - /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328, |
| 113148 | | - /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248, |
| 113149 | | - /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558, |
| 113150 | | - /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582, |
| 113151 | | - /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69, |
| 113152 | | - /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48, |
| 113153 | | - /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 113154 | | - /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 113155 | | - /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598, |
| 113156 | | - /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614, |
| 113157 | | - /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47, |
| 113158 | | - /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556, |
| 113159 | | - /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424, |
| 113160 | | - /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 113161 | | - /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53, |
| 113162 | | - /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261, |
| 113163 | | - /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421, |
| 113164 | | - /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595, |
| 113165 | | - /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599, |
| 113166 | | - /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50, |
| 113167 | | - /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579, |
| 113168 | | - /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54, |
| 113169 | | - /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 113170 | | - /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363, |
| 113171 | | - /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413, |
| 113172 | | - /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413, |
| 113173 | | - /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522, |
| 113174 | | - /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57, |
| 113175 | | - /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 113176 | | - /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52, |
| 113177 | | - /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50, |
| 113178 | | - /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338, |
| 113179 | | - /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98, |
| 113180 | | - /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619, |
| 113181 | | - /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93, |
| 113182 | | - /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581, |
| 113183 | | - /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54, |
| 113184 | | - /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410, |
| 113185 | | - /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599, |
| 113186 | | - /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228, |
| 113187 | | - /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582, |
| 113188 | | - /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136, |
| 113189 | | - /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48, |
| 113190 | | - /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 113191 | | - /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 113192 | | - /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598, |
| 113193 | | - /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619, |
| 113194 | | - /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599, |
| 113195 | | - /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599, |
| 113196 | | - /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598, |
| 113197 | | - /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55, |
| 113198 | | - /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53, |
| 113199 | | - /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413, |
| 113200 | | - /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371, |
| 113201 | | - /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619, |
| 113202 | | - /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619, |
| 113203 | | - /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85, |
| 113204 | | - /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579, |
| 113205 | | - /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54, |
| 113206 | | - /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 113207 | | - /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592, |
| 113208 | | - /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413, |
| 113209 | | - /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413, |
| 113210 | | - /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258, |
| 113211 | | - /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448, |
| 113212 | | - /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 113213 | | - /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52, |
| 113214 | | - /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460, |
| 113215 | | - /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349, |
| 113216 | | - /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619, |
| 113217 | | - /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413, |
| 113218 | | - /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216, |
| 113219 | | - /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619, |
| 113220 | | - /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123, |
| 113221 | | - /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412, |
| 113222 | | - /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599, |
| 113223 | | - /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599, |
| 113224 | | - /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598, |
| 113225 | | - /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13, |
| 113226 | | - /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3, |
| 113227 | | - /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591, |
| 113228 | | - /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34, |
| 113229 | | - /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331, |
| 113230 | | - /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79, |
| 113231 | | - /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611, |
| 113232 | | - /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235, |
| 113233 | | - /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619, |
| 113234 | | - /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61, |
| 113235 | | - /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619, |
| 113236 | | - /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31, |
| 113237 | | - /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590, |
| 113238 | | - /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300, |
| 113239 | | - /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591, |
| 113240 | | - /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534, |
| 113241 | | - /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240, |
| 113242 | | - /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487, |
| 113243 | | - /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372, |
| 113244 | | - /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477, |
| 113245 | | - /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116, |
| 113246 | | - /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111, |
| 113247 | | - /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427, |
| 113248 | | - /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594, |
| 113249 | | - /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403, |
| 113250 | | - /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5, |
| 113251 | | - /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369, |
| 113252 | | - /* 1560 */ 400, 499, 523, 233, |
| 114455 | + /* 0 */ 312, 961, 185, 420, 2, 171, 516, 515, 597, 56, |
| 114456 | + /* 10 */ 56, 56, 56, 49, 54, 54, 54, 54, 53, 53, |
| 114457 | + /* 20 */ 52, 52, 52, 51, 234, 197, 196, 195, 624, 623, |
| 114458 | + /* 30 */ 301, 590, 584, 56, 56, 56, 56, 156, 54, 54, |
| 114459 | + /* 40 */ 54, 54, 53, 53, 52, 52, 52, 51, 234, 628, |
| 114460 | + /* 50 */ 57, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114461 | + /* 60 */ 56, 56, 56, 466, 54, 54, 54, 54, 53, 53, |
| 114462 | + /* 70 */ 52, 52, 52, 51, 234, 312, 597, 52, 52, 52, |
| 114463 | + /* 80 */ 51, 234, 33, 54, 54, 54, 54, 53, 53, 52, |
| 114464 | + /* 90 */ 52, 52, 51, 234, 624, 623, 621, 620, 165, 624, |
| 114465 | + /* 100 */ 623, 383, 380, 379, 214, 328, 590, 584, 624, 623, |
| 114466 | + /* 110 */ 467, 59, 378, 619, 618, 617, 53, 53, 52, 52, |
| 114467 | + /* 120 */ 52, 51, 234, 506, 507, 57, 58, 48, 582, 581, |
| 114468 | + /* 130 */ 583, 583, 55, 55, 56, 56, 56, 56, 30, 54, |
| 114469 | + /* 140 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114470 | + /* 150 */ 312, 50, 47, 146, 233, 232, 207, 474, 256, 349, |
| 114471 | + /* 160 */ 255, 475, 621, 620, 554, 438, 298, 621, 620, 236, |
| 114472 | + /* 170 */ 674, 435, 440, 553, 439, 366, 621, 620, 540, 224, |
| 114473 | + /* 180 */ 551, 590, 584, 176, 138, 282, 386, 277, 385, 168, |
| 114474 | + /* 190 */ 600, 422, 951, 548, 622, 951, 273, 572, 572, 566, |
| 114475 | + /* 200 */ 57, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114476 | + /* 210 */ 56, 56, 56, 354, 54, 54, 54, 54, 53, 53, |
| 114477 | + /* 220 */ 52, 52, 52, 51, 234, 312, 561, 526, 62, 675, |
| 114478 | + /* 230 */ 132, 595, 410, 348, 579, 579, 492, 426, 577, 419, |
| 114479 | + /* 240 */ 627, 65, 329, 560, 441, 237, 676, 123, 607, 67, |
| 114480 | + /* 250 */ 542, 532, 622, 170, 205, 500, 590, 584, 166, 559, |
| 114481 | + /* 260 */ 622, 403, 593, 593, 593, 442, 443, 271, 422, 950, |
| 114482 | + /* 270 */ 166, 223, 950, 483, 190, 57, 58, 48, 582, 581, |
| 114483 | + /* 280 */ 583, 583, 55, 55, 56, 56, 56, 56, 600, 54, |
| 114484 | + /* 290 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114485 | + /* 300 */ 312, 441, 412, 376, 175, 165, 166, 391, 383, 380, |
| 114486 | + /* 310 */ 379, 342, 412, 203, 426, 66, 392, 622, 415, 378, |
| 114487 | + /* 320 */ 597, 166, 442, 338, 444, 571, 601, 74, 415, 624, |
| 114488 | + /* 330 */ 623, 590, 584, 624, 623, 174, 601, 92, 333, 171, |
| 114489 | + /* 340 */ 1, 410, 597, 579, 579, 624, 623, 600, 306, 425, |
| 114490 | + /* 350 */ 57, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114491 | + /* 360 */ 56, 56, 56, 580, 54, 54, 54, 54, 53, 53, |
| 114492 | + /* 370 */ 52, 52, 52, 51, 234, 312, 472, 262, 399, 68, |
| 114493 | + /* 380 */ 412, 339, 571, 389, 624, 623, 578, 602, 597, 589, |
| 114494 | + /* 390 */ 588, 603, 412, 622, 423, 533, 415, 621, 620, 513, |
| 114495 | + /* 400 */ 257, 621, 620, 166, 601, 91, 590, 584, 415, 45, |
| 114496 | + /* 410 */ 597, 586, 585, 621, 620, 250, 601, 92, 39, 347, |
| 114497 | + /* 420 */ 576, 336, 597, 547, 567, 57, 58, 48, 582, 581, |
| 114498 | + /* 430 */ 583, 583, 55, 55, 56, 56, 56, 56, 587, 54, |
| 114499 | + /* 440 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114500 | + /* 450 */ 312, 561, 621, 620, 531, 291, 470, 188, 399, 375, |
| 114501 | + /* 460 */ 247, 492, 249, 350, 412, 476, 476, 368, 560, 299, |
| 114502 | + /* 470 */ 334, 412, 281, 482, 67, 565, 410, 622, 579, 579, |
| 114503 | + /* 480 */ 415, 590, 584, 280, 559, 467, 520, 415, 601, 92, |
| 114504 | + /* 490 */ 597, 167, 544, 36, 877, 601, 16, 519, 564, 6, |
| 114505 | + /* 500 */ 57, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114506 | + /* 510 */ 56, 56, 56, 200, 54, 54, 54, 54, 53, 53, |
| 114507 | + /* 520 */ 52, 52, 52, 51, 234, 312, 183, 412, 236, 528, |
| 114508 | + /* 530 */ 395, 535, 358, 256, 349, 255, 397, 412, 248, 182, |
| 114509 | + /* 540 */ 353, 359, 549, 415, 236, 317, 563, 50, 47, 146, |
| 114510 | + /* 550 */ 273, 601, 73, 415, 7, 311, 590, 584, 568, 493, |
| 114511 | + /* 560 */ 213, 601, 92, 233, 232, 410, 173, 579, 579, 330, |
| 114512 | + /* 570 */ 575, 574, 631, 629, 332, 57, 58, 48, 582, 581, |
| 114513 | + /* 580 */ 583, 583, 55, 55, 56, 56, 56, 56, 199, 54, |
| 114514 | + /* 590 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114515 | + /* 600 */ 312, 492, 340, 320, 511, 505, 572, 572, 460, 562, |
| 114516 | + /* 610 */ 549, 170, 145, 430, 67, 558, 410, 622, 579, 579, |
| 114517 | + /* 620 */ 384, 236, 600, 412, 408, 575, 574, 504, 572, 572, |
| 114518 | + /* 630 */ 571, 590, 584, 353, 198, 143, 268, 549, 316, 415, |
| 114519 | + /* 640 */ 306, 424, 207, 50, 47, 146, 167, 601, 69, 546, |
| 114520 | + /* 650 */ 57, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114521 | + /* 660 */ 56, 56, 56, 555, 54, 54, 54, 54, 53, 53, |
| 114522 | + /* 670 */ 52, 52, 52, 51, 234, 312, 600, 326, 412, 270, |
| 114523 | + /* 680 */ 145, 264, 274, 266, 459, 571, 423, 35, 412, 568, |
| 114524 | + /* 690 */ 407, 213, 428, 388, 415, 308, 212, 143, 622, 354, |
| 114525 | + /* 700 */ 317, 12, 601, 94, 415, 549, 590, 584, 50, 47, |
| 114526 | + /* 710 */ 146, 365, 601, 97, 552, 362, 318, 147, 602, 361, |
| 114527 | + /* 720 */ 325, 15, 603, 187, 206, 57, 58, 48, 582, 581, |
| 114528 | + /* 730 */ 583, 583, 55, 55, 56, 56, 56, 56, 412, 54, |
| 114529 | + /* 740 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114530 | + /* 750 */ 312, 412, 35, 412, 415, 22, 630, 2, 600, 50, |
| 114531 | + /* 760 */ 47, 146, 601, 95, 412, 485, 510, 415, 412, 415, |
| 114532 | + /* 770 */ 412, 11, 235, 486, 412, 601, 104, 601, 103, 19, |
| 114533 | + /* 780 */ 415, 590, 584, 352, 415, 40, 415, 38, 601, 105, |
| 114534 | + /* 790 */ 415, 32, 601, 106, 601, 133, 544, 169, 601, 134, |
| 114535 | + /* 800 */ 57, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114536 | + /* 810 */ 56, 56, 56, 412, 54, 54, 54, 54, 53, 53, |
| 114537 | + /* 820 */ 52, 52, 52, 51, 234, 312, 412, 274, 412, 415, |
| 114538 | + /* 830 */ 412, 274, 274, 274, 201, 230, 721, 601, 98, 484, |
| 114539 | + /* 840 */ 427, 307, 415, 622, 415, 540, 415, 622, 622, 622, |
| 114540 | + /* 850 */ 601, 102, 601, 101, 601, 93, 590, 584, 262, 21, |
| 114541 | + /* 860 */ 129, 622, 522, 521, 554, 222, 469, 521, 600, 324, |
| 114542 | + /* 870 */ 323, 322, 211, 553, 622, 57, 58, 48, 582, 581, |
| 114543 | + /* 880 */ 583, 583, 55, 55, 56, 56, 56, 56, 412, 54, |
| 114544 | + /* 890 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114545 | + /* 900 */ 312, 412, 261, 412, 415, 412, 600, 210, 625, 367, |
| 114546 | + /* 910 */ 51, 234, 601, 100, 538, 606, 142, 415, 355, 415, |
| 114547 | + /* 920 */ 412, 415, 412, 496, 622, 601, 77, 601, 96, 601, |
| 114548 | + /* 930 */ 137, 590, 584, 530, 622, 529, 415, 141, 415, 28, |
| 114549 | + /* 940 */ 524, 600, 229, 544, 601, 136, 601, 135, 604, 204, |
| 114550 | + /* 950 */ 57, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114551 | + /* 960 */ 56, 56, 56, 412, 54, 54, 54, 54, 53, 53, |
| 114552 | + /* 970 */ 52, 52, 52, 51, 234, 312, 412, 360, 412, 415, |
| 114553 | + /* 980 */ 412, 360, 286, 600, 503, 220, 127, 601, 76, 629, |
| 114554 | + /* 990 */ 332, 382, 415, 622, 415, 540, 415, 622, 412, 613, |
| 114555 | + /* 1000 */ 601, 90, 601, 89, 601, 75, 590, 584, 341, 272, |
| 114556 | + /* 1010 */ 377, 622, 126, 27, 415, 622, 164, 544, 125, 280, |
| 114557 | + /* 1020 */ 373, 122, 601, 88, 480, 57, 46, 48, 582, 581, |
| 114558 | + /* 1030 */ 583, 583, 55, 55, 56, 56, 56, 56, 412, 54, |
| 114559 | + /* 1040 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114560 | + /* 1050 */ 312, 412, 360, 412, 415, 412, 284, 186, 369, 321, |
| 114561 | + /* 1060 */ 477, 170, 601, 87, 121, 473, 221, 415, 622, 415, |
| 114562 | + /* 1070 */ 254, 415, 412, 355, 412, 601, 99, 601, 86, 601, |
| 114563 | + /* 1080 */ 17, 590, 584, 259, 612, 120, 159, 158, 415, 622, |
| 114564 | + /* 1090 */ 415, 14, 465, 157, 462, 25, 601, 85, 601, 84, |
| 114565 | + /* 1100 */ 622, 58, 48, 582, 581, 583, 583, 55, 55, 56, |
| 114566 | + /* 1110 */ 56, 56, 56, 412, 54, 54, 54, 54, 53, 53, |
| 114567 | + /* 1120 */ 52, 52, 52, 51, 234, 312, 412, 262, 412, 415, |
| 114568 | + /* 1130 */ 412, 262, 118, 611, 117, 24, 10, 601, 83, 351, |
| 114569 | + /* 1140 */ 216, 219, 415, 622, 415, 608, 415, 622, 412, 622, |
| 114570 | + /* 1150 */ 601, 72, 601, 71, 601, 82, 590, 584, 262, 4, |
| 114571 | + /* 1160 */ 605, 622, 458, 115, 415, 456, 252, 154, 452, 110, |
| 114572 | + /* 1170 */ 108, 453, 601, 81, 622, 451, 622, 48, 582, 581, |
| 114573 | + /* 1180 */ 583, 583, 55, 55, 56, 56, 56, 56, 412, 54, |
| 114574 | + /* 1190 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 114575 | + /* 1200 */ 44, 406, 450, 3, 415, 412, 262, 107, 416, 623, |
| 114576 | + /* 1210 */ 446, 437, 601, 80, 436, 335, 238, 189, 411, 409, |
| 114577 | + /* 1220 */ 594, 415, 622, 44, 406, 401, 3, 412, 557, 601, |
| 114578 | + /* 1230 */ 70, 416, 623, 412, 622, 149, 622, 421, 404, 64, |
| 114579 | + /* 1240 */ 412, 622, 409, 415, 622, 331, 139, 148, 566, 415, |
| 114580 | + /* 1250 */ 449, 601, 18, 228, 124, 626, 415, 601, 79, 315, |
| 114581 | + /* 1260 */ 181, 404, 412, 545, 601, 78, 262, 541, 41, 42, |
| 114582 | + /* 1270 */ 534, 566, 390, 202, 262, 43, 414, 413, 415, 622, |
| 114583 | + /* 1280 */ 595, 314, 622, 622, 180, 539, 601, 92, 415, 276, |
| 114584 | + /* 1290 */ 622, 41, 42, 509, 616, 615, 601, 9, 43, 414, |
| 114585 | + /* 1300 */ 413, 622, 418, 595, 262, 622, 275, 600, 614, 622, |
| 114586 | + /* 1310 */ 218, 593, 593, 593, 592, 591, 13, 178, 217, 417, |
| 114587 | + /* 1320 */ 622, 236, 622, 44, 406, 490, 3, 269, 399, 267, |
| 114588 | + /* 1330 */ 609, 416, 623, 400, 593, 593, 593, 592, 591, 13, |
| 114589 | + /* 1340 */ 265, 622, 409, 622, 263, 622, 34, 406, 244, 3, |
| 114590 | + /* 1350 */ 258, 363, 464, 463, 416, 623, 622, 356, 251, 8, |
| 114591 | + /* 1360 */ 622, 404, 177, 599, 455, 409, 622, 622, 622, 622, |
| 114592 | + /* 1370 */ 445, 566, 243, 622, 622, 236, 295, 240, 31, 239, |
| 114593 | + /* 1380 */ 622, 431, 30, 396, 404, 290, 622, 294, 622, 293, |
| 114594 | + /* 1390 */ 144, 41, 42, 622, 566, 622, 394, 622, 43, 414, |
| 114595 | + /* 1400 */ 413, 622, 289, 595, 398, 60, 622, 292, 37, 231, |
| 114596 | + /* 1410 */ 598, 172, 622, 29, 41, 42, 393, 523, 622, 556, |
| 114597 | + /* 1420 */ 184, 43, 414, 413, 287, 387, 595, 543, 285, 518, |
| 114598 | + /* 1430 */ 537, 536, 517, 327, 593, 593, 593, 592, 591, 13, |
| 114599 | + /* 1440 */ 215, 283, 278, 514, 513, 304, 303, 302, 179, 300, |
| 114600 | + /* 1450 */ 512, 310, 454, 128, 227, 226, 309, 593, 593, 593, |
| 114601 | + /* 1460 */ 592, 591, 13, 494, 489, 225, 488, 150, 487, 242, |
| 114602 | + /* 1470 */ 163, 61, 374, 481, 162, 161, 624, 623, 241, 372, |
| 114603 | + /* 1480 */ 209, 479, 370, 260, 26, 160, 478, 364, 468, 471, |
| 114604 | + /* 1490 */ 140, 152, 119, 467, 131, 116, 155, 153, 345, 457, |
| 114605 | + /* 1500 */ 151, 346, 130, 114, 113, 112, 111, 448, 319, 23, |
| 114606 | + /* 1510 */ 109, 434, 20, 433, 432, 429, 566, 610, 573, 596, |
| 114607 | + /* 1520 */ 63, 405, 191, 279, 510, 296, 498, 288, 570, 495, |
| 114608 | + /* 1530 */ 499, 497, 461, 194, 5, 305, 193, 192, 381, 569, |
| 114609 | + /* 1540 */ 357, 256, 344, 245, 526, 246, 253, 313, 595, 343, |
| 114610 | + /* 1550 */ 447, 297, 236, 402, 550, 491, 508, 502, 501, 527, |
| 114611 | + /* 1560 */ 234, 208, 525, 962, 962, 962, 371, 962, 962, 962, |
| 114612 | + /* 1570 */ 962, 962, 962, 962, 962, 337, 962, 962, 962, 593, |
| 114613 | + /* 1580 */ 593, 593, |
| 113253 | 114614 | }; |
| 113254 | 114615 | static const YYCODETYPE yy_lookahead[] = { |
| 113255 | | - /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78, |
| 114616 | + /* 0 */ 19, 143, 144, 145, 146, 24, 7, 8, 27, 78, |
| 113256 | 114617 | /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, |
| 113257 | | - /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197, |
| 113258 | | - /* 30 */ 49, 50, 77, 78, 79, 80, 204, 82, 83, 84, |
| 113259 | | - /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 23, 68, |
| 114618 | + /* 20 */ 89, 90, 91, 92, 93, 106, 107, 108, 27, 28, |
| 114619 | + /* 30 */ 15, 50, 51, 78, 79, 80, 81, 26, 83, 84, |
| 114620 | + /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 1, |
| 113260 | 114621 | /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 113261 | | - /* 60 */ 79, 80, 166, 82, 83, 84, 85, 86, 87, 88, |
| 113262 | | - /* 70 */ 89, 90, 91, 92, 19, 94, 19, 105, 106, 107, |
| 113263 | | - /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 113264 | | - /* 90 */ 91, 92, 94, 95, 96, 94, 95, 99, 100, 101, |
| 113265 | | - /* 100 */ 112, 205, 114, 115, 49, 50, 22, 23, 110, 54, |
| 113266 | | - /* 110 */ 86, 87, 88, 89, 90, 91, 92, 221, 222, 223, |
| 113267 | | - /* 120 */ 23, 120, 25, 68, 69, 70, 71, 72, 73, 74, |
| 113268 | | - /* 130 */ 75, 76, 77, 78, 79, 80, 22, 82, 83, 84, |
| 113269 | | - /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92, |
| 113270 | | - /* 150 */ 23, 67, 25, 96, 97, 98, 99, 100, 101, 102, |
| 113271 | | - /* 160 */ 150, 32, 150, 118, 26, 27, 109, 150, 150, 150, |
| 113272 | | - /* 170 */ 41, 161, 162, 180, 181, 165, 113, 165, 49, 50, |
| 113273 | | - /* 180 */ 117, 188, 165, 165, 165, 173, 174, 170, 171, 170, |
| 113274 | | - /* 190 */ 171, 173, 174, 118, 184, 16, 186, 68, 69, 70, |
| 113275 | | - /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 113276 | | - /* 210 */ 118, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 113277 | | - /* 220 */ 91, 92, 19, 98, 86, 87, 22, 24, 160, 88, |
| 113278 | | - /* 230 */ 26, 27, 94, 95, 109, 97, 224, 66, 118, 60, |
| 113279 | | - /* 240 */ 150, 62, 104, 23, 106, 25, 229, 230, 229, 230, |
| 113280 | | - /* 250 */ 160, 150, 49, 50, 113, 165, 96, 26, 117, 99, |
| 113281 | | - /* 260 */ 100, 101, 194, 173, 174, 94, 165, 129, 130, 98, |
| 113282 | | - /* 270 */ 110, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 113283 | | - /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86, |
| 113284 | | - /* 290 */ 87, 88, 89, 90, 91, 92, 19, 11, 94, 95, |
| 113285 | | - /* 300 */ 129, 130, 131, 118, 150, 215, 150, 150, 150, 25, |
| 113286 | | - /* 310 */ 220, 26, 27, 22, 213, 26, 27, 26, 27, 165, |
| 113287 | | - /* 320 */ 25, 165, 165, 165, 30, 94, 49, 50, 34, 173, |
| 113288 | | - /* 330 */ 174, 173, 174, 88, 89, 90, 91, 92, 7, 8, |
| 113289 | | - /* 340 */ 160, 187, 48, 57, 187, 68, 69, 70, 71, 72, |
| 113290 | | - /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 23, 82, |
| 113291 | | - /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 113292 | | - /* 370 */ 19, 215, 150, 215, 194, 19, 220, 88, 220, 94, |
| 113293 | | - /* 380 */ 95, 23, 160, 94, 95, 94, 95, 165, 26, 27, |
| 113294 | | - /* 390 */ 95, 105, 106, 107, 113, 173, 174, 217, 22, 150, |
| 113295 | | - /* 400 */ 49, 50, 116, 119, 57, 120, 50, 158, 22, 21, |
| 113296 | | - /* 410 */ 161, 162, 232, 136, 165, 120, 194, 237, 23, 68, |
| 113297 | | - /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 113298 | | - /* 430 */ 79, 80, 22, 82, 83, 84, 85, 86, 87, 88, |
| 113299 | | - /* 440 */ 89, 90, 91, 92, 19, 23, 12, 112, 23, 114, |
| 113300 | | - /* 450 */ 115, 63, 105, 106, 107, 23, 94, 95, 97, 98, |
| 113301 | | - /* 460 */ 104, 150, 28, 116, 25, 109, 150, 150, 23, 23, |
| 113302 | | - /* 470 */ 112, 25, 114, 115, 49, 50, 165, 150, 44, 11, |
| 113303 | | - /* 480 */ 46, 165, 165, 16, 173, 174, 76, 136, 100, 173, |
| 113304 | | - /* 490 */ 174, 57, 165, 68, 69, 70, 71, 72, 73, 74, |
| 113305 | | - /* 500 */ 75, 76, 77, 78, 79, 80, 166, 82, 83, 84, |
| 113306 | | - /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 169, |
| 113307 | | - /* 520 */ 170, 171, 23, 12, 23, 214, 138, 60, 150, 62, |
| 113308 | | - /* 530 */ 24, 215, 26, 216, 112, 150, 114, 115, 36, 28, |
| 113309 | | - /* 540 */ 213, 95, 103, 165, 112, 205, 114, 115, 49, 50, |
| 113310 | | - /* 550 */ 165, 173, 174, 51, 23, 44, 25, 46, 173, 174, |
| 113311 | | - /* 560 */ 58, 22, 23, 22, 25, 160, 120, 68, 69, 70, |
| 113312 | | - /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 113313 | | - /* 580 */ 230, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 113314 | | - /* 590 */ 91, 92, 19, 215, 22, 23, 23, 25, 163, 194, |
| 113315 | | - /* 600 */ 94, 166, 167, 168, 25, 138, 67, 7, 8, 9, |
| 113316 | | - /* 610 */ 108, 206, 207, 169, 170, 171, 150, 22, 221, 222, |
| 113317 | | - /* 620 */ 223, 26, 49, 50, 86, 87, 23, 161, 162, 23, |
| 113318 | | - /* 630 */ 22, 165, 24, 120, 22, 23, 25, 160, 241, 67, |
| 113319 | | - /* 640 */ 176, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 113320 | | - /* 650 */ 77, 78, 79, 80, 160, 82, 83, 84, 85, 86, |
| 113321 | | - /* 660 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 150, |
| 113322 | | - /* 670 */ 23, 194, 35, 23, 230, 25, 150, 155, 150, 67, |
| 113323 | | - /* 680 */ 150, 105, 106, 107, 165, 221, 222, 223, 194, 94, |
| 113324 | | - /* 690 */ 23, 165, 25, 165, 217, 165, 49, 50, 25, 173, |
| 113325 | | - /* 700 */ 174, 173, 174, 173, 174, 0, 1, 2, 118, 221, |
| 113326 | | - /* 710 */ 222, 223, 193, 219, 237, 68, 69, 70, 71, 72, |
| 113327 | | - /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82, |
| 113328 | | - /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 113329 | | - /* 740 */ 19, 150, 19, 165, 150, 24, 166, 167, 168, 227, |
| 113330 | | - /* 750 */ 27, 173, 174, 231, 150, 25, 165, 150, 172, 165, |
| 113331 | | - /* 760 */ 150, 242, 129, 130, 173, 174, 180, 173, 174, 165, |
| 113332 | | - /* 770 */ 49, 50, 165, 150, 176, 165, 35, 173, 174, 165, |
| 113333 | | - /* 780 */ 173, 174, 35, 23, 23, 25, 25, 173, 165, 68, |
| 113334 | | - /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 113335 | | - /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88, |
| 113336 | | - /* 810 */ 89, 90, 91, 92, 19, 150, 193, 165, 150, 221, |
| 113337 | | - /* 820 */ 222, 223, 150, 213, 19, 173, 174, 23, 150, 97, |
| 113338 | | - /* 830 */ 165, 150, 27, 165, 150, 150, 150, 165, 173, 174, |
| 113339 | | - /* 840 */ 22, 173, 174, 165, 49, 50, 165, 52, 116, 165, |
| 113340 | | - /* 850 */ 165, 165, 206, 207, 173, 174, 126, 50, 173, 174, |
| 113341 | | - /* 860 */ 128, 27, 160, 68, 69, 70, 71, 72, 73, 74, |
| 113342 | | - /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84, |
| 113343 | | - /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150, |
| 113344 | | - /* 890 */ 23, 165, 150, 23, 216, 25, 194, 32, 39, 173, |
| 113345 | | - /* 900 */ 174, 135, 150, 137, 165, 150, 41, 165, 150, 52, |
| 113346 | | - /* 910 */ 238, 104, 173, 174, 29, 173, 174, 165, 49, 50, |
| 113347 | | - /* 920 */ 165, 219, 238, 165, 238, 173, 174, 52, 173, 174, |
| 113348 | | - /* 930 */ 22, 173, 174, 23, 23, 160, 25, 68, 69, 70, |
| 113349 | | - /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 113350 | | - /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 113351 | | - /* 960 */ 91, 92, 19, 150, 150, 165, 150, 245, 246, 194, |
| 113352 | | - /* 970 */ 150, 144, 145, 173, 174, 160, 150, 22, 165, 165, |
| 113353 | | - /* 980 */ 22, 165, 150, 150, 116, 165, 173, 174, 52, 173, |
| 113354 | | - /* 990 */ 174, 165, 49, 50, 22, 150, 128, 165, 165, 173, |
| 113355 | | - /* 1000 */ 174, 187, 166, 166, 22, 173, 174, 187, 109, 194, |
| 113356 | | - /* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 113357 | | - /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86, |
| 113358 | | - /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165, |
| 113359 | | - /* 1040 */ 102, 205, 205, 150, 150, 247, 248, 173, 174, 19, |
| 113360 | | - /* 1050 */ 150, 20, 165, 150, 150, 150, 150, 150, 165, 165, |
| 113361 | | - /* 1060 */ 173, 174, 49, 50, 104, 165, 49, 50, 165, 165, |
| 113362 | | - /* 1070 */ 165, 165, 165, 173, 174, 43, 173, 174, 173, 174, |
| 113363 | | - /* 1080 */ 187, 24, 190, 191, 71, 72, 69, 70, 71, 72, |
| 113364 | | - /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82, |
| 113365 | | - /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 113366 | | - /* 1110 */ 19, 98, 150, 165, 150, 150, 150, 150, 150, 150, |
| 113367 | | - /* 1120 */ 59, 173, 174, 25, 150, 190, 191, 165, 53, 165, |
| 113368 | | - /* 1130 */ 165, 165, 165, 165, 165, 173, 174, 173, 174, 165, |
| 113369 | | - /* 1140 */ 49, 50, 91, 92, 1, 2, 53, 173, 174, 138, |
| 113370 | | - /* 1150 */ 104, 22, 5, 1, 35, 118, 127, 150, 193, 193, |
| 113371 | | - /* 1160 */ 193, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 113372 | | - /* 1170 */ 79, 80, 165, 82, 83, 84, 85, 86, 87, 88, |
| 113373 | | - /* 1180 */ 89, 90, 91, 92, 19, 20, 150, 22, 150, 27, |
| 113374 | | - /* 1190 */ 150, 26, 27, 108, 150, 22, 76, 76, 150, 25, |
| 113375 | | - /* 1200 */ 193, 165, 37, 165, 150, 165, 22, 19, 20, 165, |
| 113376 | | - /* 1210 */ 22, 173, 174, 165, 26, 27, 23, 150, 119, 165, |
| 113377 | | - /* 1220 */ 150, 56, 150, 150, 150, 37, 16, 173, 174, 193, |
| 113378 | | - /* 1230 */ 150, 66, 165, 193, 1, 165, 121, 165, 165, 165, |
| 113379 | | - /* 1240 */ 20, 146, 147, 119, 56, 165, 150, 152, 16, 154, |
| 113380 | | - /* 1250 */ 150, 86, 87, 88, 66, 160, 150, 150, 93, 94, |
| 113381 | | - /* 1260 */ 95, 165, 150, 98, 108, 165, 127, 23, 65, 173, |
| 113382 | | - /* 1270 */ 174, 165, 165, 150, 86, 87, 128, 165, 150, 173, |
| 113383 | | - /* 1280 */ 174, 93, 94, 95, 23, 150, 98, 15, 165, 194, |
| 113384 | | - /* 1290 */ 150, 140, 22, 165, 129, 130, 131, 132, 133, 134, |
| 113385 | | - /* 1300 */ 165, 173, 174, 3, 116, 165, 19, 20, 150, 22, |
| 113386 | | - /* 1310 */ 4, 150, 217, 26, 27, 179, 179, 129, 130, 131, |
| 113387 | | - /* 1320 */ 132, 133, 134, 165, 37, 150, 165, 150, 164, 19, |
| 113388 | | - /* 1330 */ 20, 150, 22, 246, 149, 249, 26, 27, 249, 244, |
| 113389 | | - /* 1340 */ 165, 150, 165, 56, 6, 150, 165, 37, 173, 174, |
| 113390 | | - /* 1350 */ 173, 174, 150, 66, 173, 174, 165, 149, 149, 13, |
| 113391 | | - /* 1360 */ 165, 25, 150, 150, 150, 149, 56, 165, 150, 116, |
| 113392 | | - /* 1370 */ 151, 150, 150, 86, 87, 150, 66, 165, 165, 165, |
| 113393 | | - /* 1380 */ 93, 94, 95, 165, 150, 98, 165, 165, 151, 22, |
| 113394 | | - /* 1390 */ 165, 194, 150, 26, 27, 150, 86, 87, 159, 165, |
| 113395 | | - /* 1400 */ 199, 126, 123, 93, 94, 95, 200, 165, 98, 124, |
| 113396 | | - /* 1410 */ 165, 122, 201, 125, 225, 135, 129, 130, 131, 132, |
| 113397 | | - /* 1420 */ 133, 134, 5, 157, 157, 202, 118, 10, 11, 12, |
| 113398 | | - /* 1430 */ 13, 14, 203, 66, 17, 104, 210, 121, 211, 129, |
| 113399 | | - /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211, |
| 113400 | | - /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42, |
| 113401 | | - /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175, |
| 113402 | | - /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18, |
| 113403 | | - /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157, |
| 113404 | | - /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22, |
| 113405 | | - /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192, |
| 113406 | | - /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38, |
| 113407 | | - /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166, |
| 113408 | | - /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226, |
| 113409 | | - /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196, |
| 113410 | | - /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234, |
| 113411 | | - /* 1560 */ 191, 182, 173, 92, |
| 113412 | | -}; |
| 113413 | | -#define YY_SHIFT_USE_DFLT (-70) |
| 113414 | | -#define YY_SHIFT_COUNT (417) |
| 113415 | | -#define YY_SHIFT_MIN (-69) |
| 113416 | | -#define YY_SHIFT_MAX (1487) |
| 114622 | + /* 60 */ 79, 80, 81, 11, 83, 84, 85, 86, 87, 88, |
| 114623 | + /* 70 */ 89, 90, 91, 92, 93, 19, 95, 89, 90, 91, |
| 114624 | + /* 80 */ 92, 93, 26, 83, 84, 85, 86, 87, 88, 89, |
| 114625 | + /* 90 */ 90, 91, 92, 93, 27, 28, 95, 96, 97, 27, |
| 114626 | + /* 100 */ 28, 100, 101, 102, 22, 19, 50, 51, 27, 28, |
| 114627 | + /* 110 */ 58, 55, 111, 7, 8, 9, 87, 88, 89, 90, |
| 114628 | + /* 120 */ 91, 92, 93, 98, 99, 69, 70, 71, 72, 73, |
| 114629 | + /* 130 */ 74, 75, 76, 77, 78, 79, 80, 81, 127, 83, |
| 114630 | + /* 140 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114631 | + /* 150 */ 19, 223, 224, 225, 87, 88, 162, 31, 106, 107, |
| 114632 | + /* 160 */ 108, 35, 95, 96, 33, 98, 23, 95, 96, 117, |
| 114633 | + /* 170 */ 119, 243, 105, 42, 107, 49, 95, 96, 151, 93, |
| 114634 | + /* 180 */ 26, 50, 51, 97, 98, 99, 100, 101, 102, 103, |
| 114635 | + /* 190 */ 196, 22, 23, 121, 167, 26, 110, 130, 131, 67, |
| 114636 | + /* 200 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 114637 | + /* 210 */ 79, 80, 81, 219, 83, 84, 85, 86, 87, 88, |
| 114638 | + /* 220 */ 89, 90, 91, 92, 93, 19, 12, 95, 234, 119, |
| 114639 | + /* 230 */ 24, 99, 113, 239, 115, 116, 151, 68, 23, 147, |
| 114640 | + /* 240 */ 148, 26, 215, 29, 151, 153, 119, 155, 163, 164, |
| 114641 | + /* 250 */ 23, 23, 167, 26, 162, 23, 50, 51, 26, 45, |
| 114642 | + /* 260 */ 167, 47, 130, 131, 132, 172, 173, 23, 22, 23, |
| 114643 | + /* 270 */ 26, 186, 26, 188, 120, 69, 70, 71, 72, 73, |
| 114644 | + /* 280 */ 74, 75, 76, 77, 78, 79, 80, 81, 196, 83, |
| 114645 | + /* 290 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114646 | + /* 300 */ 19, 151, 151, 23, 119, 97, 26, 19, 100, 101, |
| 114647 | + /* 310 */ 102, 219, 151, 162, 68, 22, 28, 167, 167, 111, |
| 114648 | + /* 320 */ 27, 26, 172, 173, 231, 232, 175, 176, 167, 27, |
| 114649 | + /* 330 */ 28, 50, 51, 27, 28, 119, 175, 176, 246, 24, |
| 114650 | + /* 340 */ 22, 113, 27, 115, 116, 27, 28, 196, 22, 23, |
| 114651 | + /* 350 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 114652 | + /* 360 */ 79, 80, 81, 114, 83, 84, 85, 86, 87, 88, |
| 114653 | + /* 370 */ 89, 90, 91, 92, 93, 19, 21, 151, 217, 22, |
| 114654 | + /* 380 */ 151, 231, 232, 222, 27, 28, 23, 114, 95, 50, |
| 114655 | + /* 390 */ 51, 118, 151, 167, 68, 89, 167, 95, 96, 104, |
| 114656 | + /* 400 */ 23, 95, 96, 26, 175, 176, 50, 51, 167, 22, |
| 114657 | + /* 410 */ 95, 72, 73, 95, 96, 16, 175, 176, 137, 64, |
| 114658 | + /* 420 */ 23, 195, 27, 121, 23, 69, 70, 71, 72, 73, |
| 114659 | + /* 430 */ 74, 75, 76, 77, 78, 79, 80, 81, 99, 83, |
| 114660 | + /* 440 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114661 | + /* 450 */ 19, 12, 95, 96, 23, 226, 101, 22, 217, 19, |
| 114662 | + /* 460 */ 61, 151, 63, 222, 151, 106, 107, 108, 29, 159, |
| 114663 | + /* 470 */ 244, 151, 99, 163, 164, 23, 113, 167, 115, 116, |
| 114664 | + /* 480 */ 167, 50, 51, 110, 45, 58, 47, 167, 175, 176, |
| 114665 | + /* 490 */ 95, 51, 168, 137, 139, 175, 176, 58, 11, 22, |
| 114666 | + /* 500 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 114667 | + /* 510 */ 79, 80, 81, 22, 83, 84, 85, 86, 87, 88, |
| 114668 | + /* 520 */ 89, 90, 91, 92, 93, 19, 23, 151, 117, 23, |
| 114669 | + /* 530 */ 217, 207, 19, 106, 107, 108, 216, 151, 139, 23, |
| 114670 | + /* 540 */ 129, 28, 26, 167, 117, 105, 23, 223, 224, 225, |
| 114671 | + /* 550 */ 110, 175, 176, 167, 77, 165, 50, 51, 168, 169, |
| 114672 | + /* 560 */ 170, 175, 176, 87, 88, 113, 26, 115, 116, 171, |
| 114673 | + /* 570 */ 172, 173, 0, 1, 2, 69, 70, 71, 72, 73, |
| 114674 | + /* 580 */ 74, 75, 76, 77, 78, 79, 80, 81, 162, 83, |
| 114675 | + /* 590 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114676 | + /* 600 */ 19, 151, 98, 217, 23, 37, 130, 131, 23, 23, |
| 114677 | + /* 610 */ 26, 26, 96, 163, 164, 23, 113, 167, 115, 116, |
| 114678 | + /* 620 */ 52, 117, 196, 151, 171, 172, 173, 59, 130, 131, |
| 114679 | + /* 630 */ 232, 50, 51, 129, 208, 209, 16, 121, 156, 167, |
| 114680 | + /* 640 */ 22, 23, 162, 223, 224, 225, 51, 175, 176, 121, |
| 114681 | + /* 650 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 114682 | + /* 660 */ 79, 80, 81, 178, 83, 84, 85, 86, 87, 88, |
| 114683 | + /* 670 */ 89, 90, 91, 92, 93, 19, 196, 109, 151, 23, |
| 114684 | + /* 680 */ 96, 61, 151, 63, 23, 232, 68, 26, 151, 168, |
| 114685 | + /* 690 */ 169, 170, 23, 89, 167, 26, 208, 209, 167, 219, |
| 114686 | + /* 700 */ 105, 36, 175, 176, 167, 121, 50, 51, 223, 224, |
| 114687 | + /* 710 */ 225, 229, 175, 176, 178, 233, 247, 248, 114, 239, |
| 114688 | + /* 720 */ 189, 22, 118, 24, 162, 69, 70, 71, 72, 73, |
| 114689 | + /* 730 */ 74, 75, 76, 77, 78, 79, 80, 81, 151, 83, |
| 114690 | + /* 740 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114691 | + /* 750 */ 19, 151, 26, 151, 167, 24, 145, 146, 196, 223, |
| 114692 | + /* 760 */ 224, 225, 175, 176, 151, 182, 183, 167, 151, 167, |
| 114693 | + /* 770 */ 151, 36, 199, 190, 151, 175, 176, 175, 176, 206, |
| 114694 | + /* 780 */ 167, 50, 51, 221, 167, 136, 167, 138, 175, 176, |
| 114695 | + /* 790 */ 167, 26, 175, 176, 175, 176, 168, 36, 175, 176, |
| 114696 | + /* 800 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 114697 | + /* 810 */ 79, 80, 81, 151, 83, 84, 85, 86, 87, 88, |
| 114698 | + /* 820 */ 89, 90, 91, 92, 93, 19, 151, 151, 151, 167, |
| 114699 | + /* 830 */ 151, 151, 151, 151, 162, 207, 23, 175, 176, 26, |
| 114700 | + /* 840 */ 249, 250, 167, 167, 167, 151, 167, 167, 167, 167, |
| 114701 | + /* 850 */ 175, 176, 175, 176, 175, 176, 50, 51, 151, 53, |
| 114702 | + /* 860 */ 22, 167, 192, 193, 33, 189, 192, 193, 196, 189, |
| 114703 | + /* 870 */ 189, 189, 162, 42, 167, 69, 70, 71, 72, 73, |
| 114704 | + /* 880 */ 74, 75, 76, 77, 78, 79, 80, 81, 151, 83, |
| 114705 | + /* 890 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114706 | + /* 900 */ 19, 151, 195, 151, 167, 151, 196, 162, 151, 215, |
| 114707 | + /* 910 */ 92, 93, 175, 176, 28, 174, 119, 167, 151, 167, |
| 114708 | + /* 920 */ 151, 167, 151, 182, 167, 175, 176, 175, 176, 175, |
| 114709 | + /* 930 */ 176, 50, 51, 23, 167, 23, 167, 40, 167, 22, |
| 114710 | + /* 940 */ 167, 196, 53, 168, 175, 176, 175, 176, 175, 162, |
| 114711 | + /* 950 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 114712 | + /* 960 */ 79, 80, 81, 151, 83, 84, 85, 86, 87, 88, |
| 114713 | + /* 970 */ 89, 90, 91, 92, 93, 19, 151, 151, 151, 167, |
| 114714 | + /* 980 */ 151, 151, 207, 196, 30, 218, 22, 175, 176, 1, |
| 114715 | + /* 990 */ 2, 53, 167, 167, 167, 151, 167, 167, 151, 151, |
| 114716 | + /* 1000 */ 175, 176, 175, 176, 175, 176, 50, 51, 221, 23, |
| 114717 | + /* 1010 */ 53, 167, 22, 22, 167, 167, 103, 168, 22, 110, |
| 114718 | + /* 1020 */ 19, 105, 175, 176, 20, 69, 70, 71, 72, 73, |
| 114719 | + /* 1030 */ 74, 75, 76, 77, 78, 79, 80, 81, 151, 83, |
| 114720 | + /* 1040 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114721 | + /* 1050 */ 19, 151, 151, 151, 167, 151, 207, 24, 44, 215, |
| 114722 | + /* 1060 */ 60, 26, 175, 176, 54, 54, 240, 167, 167, 167, |
| 114723 | + /* 1070 */ 240, 167, 151, 151, 151, 175, 176, 175, 176, 175, |
| 114724 | + /* 1080 */ 176, 50, 51, 139, 151, 22, 105, 119, 167, 167, |
| 114725 | + /* 1090 */ 167, 5, 1, 36, 28, 77, 175, 176, 175, 176, |
| 114726 | + /* 1100 */ 167, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 114727 | + /* 1110 */ 79, 80, 81, 151, 83, 84, 85, 86, 87, 88, |
| 114728 | + /* 1120 */ 89, 90, 91, 92, 93, 19, 151, 151, 151, 167, |
| 114729 | + /* 1130 */ 151, 151, 109, 151, 128, 77, 22, 175, 176, 26, |
| 114730 | + /* 1140 */ 218, 240, 167, 167, 167, 151, 167, 167, 151, 167, |
| 114731 | + /* 1150 */ 175, 176, 175, 176, 175, 176, 50, 51, 151, 22, |
| 114732 | + /* 1160 */ 151, 167, 23, 120, 167, 1, 16, 122, 20, 120, |
| 114733 | + /* 1170 */ 109, 195, 175, 176, 167, 195, 167, 71, 72, 73, |
| 114734 | + /* 1180 */ 74, 75, 76, 77, 78, 79, 80, 81, 151, 83, |
| 114735 | + /* 1190 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 114736 | + /* 1200 */ 19, 20, 195, 22, 167, 151, 151, 128, 27, 28, |
| 114737 | + /* 1210 */ 129, 23, 175, 176, 23, 66, 141, 22, 151, 38, |
| 114738 | + /* 1220 */ 151, 167, 167, 19, 20, 151, 22, 151, 151, 175, |
| 114739 | + /* 1230 */ 176, 27, 28, 151, 167, 15, 167, 4, 57, 16, |
| 114740 | + /* 1240 */ 151, 167, 38, 167, 167, 3, 166, 248, 67, 167, |
| 114741 | + /* 1250 */ 195, 175, 176, 181, 181, 150, 167, 175, 176, 251, |
| 114742 | + /* 1260 */ 6, 57, 151, 151, 175, 176, 151, 151, 87, 88, |
| 114743 | + /* 1270 */ 89, 67, 151, 162, 151, 94, 95, 96, 167, 167, |
| 114744 | + /* 1280 */ 99, 251, 167, 167, 152, 151, 175, 176, 167, 151, |
| 114745 | + /* 1290 */ 167, 87, 88, 151, 150, 150, 175, 176, 94, 95, |
| 114746 | + /* 1300 */ 96, 167, 150, 99, 151, 167, 151, 196, 13, 167, |
| 114747 | + /* 1310 */ 195, 130, 131, 132, 133, 134, 135, 152, 195, 160, |
| 114748 | + /* 1320 */ 167, 117, 167, 19, 20, 151, 22, 151, 217, 151, |
| 114749 | + /* 1330 */ 161, 27, 28, 222, 130, 131, 132, 133, 134, 135, |
| 114750 | + /* 1340 */ 151, 167, 38, 167, 151, 167, 19, 20, 195, 22, |
| 114751 | + /* 1350 */ 151, 151, 151, 151, 27, 28, 167, 151, 151, 26, |
| 114752 | + /* 1360 */ 167, 57, 25, 196, 151, 38, 167, 167, 167, 167, |
| 114753 | + /* 1370 */ 151, 67, 151, 167, 167, 117, 201, 151, 125, 151, |
| 114754 | + /* 1380 */ 167, 151, 127, 124, 57, 151, 167, 202, 167, 203, |
| 114755 | + /* 1390 */ 151, 87, 88, 167, 67, 167, 151, 167, 94, 95, |
| 114756 | + /* 1400 */ 96, 167, 151, 99, 123, 126, 167, 204, 136, 227, |
| 114757 | + /* 1410 */ 205, 119, 167, 105, 87, 88, 122, 177, 167, 158, |
| 114758 | + /* 1420 */ 158, 94, 95, 96, 212, 105, 99, 213, 212, 177, |
| 114759 | + /* 1430 */ 213, 213, 185, 48, 130, 131, 132, 133, 134, 135, |
| 114760 | + /* 1440 */ 5, 212, 177, 179, 104, 10, 11, 12, 13, 14, |
| 114761 | + /* 1450 */ 177, 180, 17, 22, 230, 93, 180, 130, 131, 132, |
| 114762 | + /* 1460 */ 133, 134, 135, 185, 177, 230, 177, 32, 177, 34, |
| 114763 | + /* 1470 */ 157, 22, 18, 158, 157, 157, 27, 28, 43, 158, |
| 114764 | + /* 1480 */ 158, 158, 46, 237, 136, 157, 238, 158, 191, 201, |
| 114765 | + /* 1490 */ 69, 56, 191, 58, 220, 22, 157, 62, 18, 201, |
| 114766 | + /* 1500 */ 65, 158, 220, 194, 194, 194, 194, 201, 158, 242, |
| 114767 | + /* 1510 */ 191, 41, 242, 158, 158, 39, 67, 154, 232, 168, |
| 114768 | + /* 1520 */ 245, 228, 198, 178, 183, 200, 168, 211, 232, 168, |
| 114769 | + /* 1530 */ 178, 178, 201, 187, 198, 149, 87, 88, 179, 168, |
| 114770 | + /* 1540 */ 241, 106, 107, 108, 95, 211, 241, 112, 99, 211, |
| 114771 | + /* 1550 */ 201, 197, 117, 193, 210, 188, 184, 184, 184, 175, |
| 114772 | + /* 1560 */ 93, 235, 175, 252, 252, 252, 236, 252, 252, 252, |
| 114773 | + /* 1570 */ 252, 252, 252, 252, 252, 140, 252, 252, 252, 130, |
| 114774 | + /* 1580 */ 131, 132, |
| 114775 | +}; |
| 114776 | +#define YY_SHIFT_USE_DFLT (-82) |
| 114777 | +#define YY_SHIFT_COUNT (419) |
| 114778 | +#define YY_SHIFT_MIN (-81) |
| 114779 | +#define YY_SHIFT_MAX (1480) |
| 113417 | 114780 | static const short yy_shift_ofst[] = { |
| 113418 | | - /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19, |
| 113419 | | - /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165, |
| 113420 | | - /* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, |
| 113421 | | - /* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, |
| 113422 | | - /* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287, |
| 113423 | | - /* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, |
| 113424 | | - /* 60 */ 1287, 1287, 286, 362, 362, 538, 538, 231, 1253, 55, |
| 113425 | | - /* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869, |
| 113426 | | - /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869, |
| 113427 | | - /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45, |
| 113428 | | - /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362, |
| 113429 | | - /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 113430 | | - /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362, |
| 113431 | | - /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57, |
| 113432 | | - /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362, |
| 113433 | | - /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 113434 | | - /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 113435 | | - /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 113436 | | - /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70, |
| 113437 | | - /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511, |
| 113438 | | - /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12, |
| 113439 | | - /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730, |
| 113440 | | - /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723, |
| 113441 | | - /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308, |
| 113442 | | - /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487, |
| 113443 | | - /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355, |
| 113444 | | - /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, |
| 113445 | | - /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, |
| 113446 | | - /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, |
| 113447 | | - /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, |
| 113448 | | - /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, |
| 113449 | | - /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760, |
| 113450 | | - /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306, |
| 113451 | | - /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, |
| 113452 | | - /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, |
| 113453 | | - /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, |
| 113454 | | - /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, |
| 113455 | | - /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910, |
| 113456 | | - /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834, |
| 113457 | | - /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603, |
| 113458 | | - /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185, |
| 113459 | | - /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5, |
| 114781 | + /* 0 */ 988, 1204, 1435, 1204, 1304, 1304, 67, 67, 1, -19, |
| 114782 | + /* 10 */ 1304, 1304, 1304, 1304, 427, 81, 131, 131, 806, 1181, |
| 114783 | + /* 20 */ 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, |
| 114784 | + /* 30 */ 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, |
| 114785 | + /* 40 */ 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1327, 1304, |
| 114786 | + /* 50 */ 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, |
| 114787 | + /* 60 */ 1304, 1304, 52, 81, 81, 476, 476, 395, 1258, 56, |
| 114788 | + /* 70 */ 731, 656, 581, 506, 431, 356, 281, 206, 881, 881, |
| 114789 | + /* 80 */ 881, 881, 881, 881, 881, 881, 881, 881, 881, 881, |
| 114790 | + /* 90 */ 881, 881, 881, 956, 881, 1031, 1106, 1106, -69, -45, |
| 114791 | + /* 100 */ -45, -45, -45, -45, 0, 29, -12, 81, 81, 81, |
| 114792 | + /* 110 */ 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, |
| 114793 | + /* 120 */ 81, 81, 81, 355, 440, 81, 81, 81, 81, 81, |
| 114794 | + /* 130 */ 504, 411, 395, 818, 1467, -82, -82, -82, 1449, 86, |
| 114795 | + /* 140 */ 439, 439, 306, 357, 302, 72, 318, 246, 169, 81, |
| 114796 | + /* 150 */ 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, |
| 114797 | + /* 160 */ 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, |
| 114798 | + /* 170 */ 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, |
| 114799 | + /* 180 */ 81, 81, 315, 315, 315, 572, 1258, 1258, 1258, -82, |
| 114800 | + /* 190 */ -82, -82, 132, 132, 208, 568, 568, 568, 516, 503, |
| 114801 | + /* 200 */ 214, 452, 363, 228, 119, 119, 119, 119, 359, 126, |
| 114802 | + /* 210 */ 119, 119, 584, 293, 604, 106, 11, 288, 288, 513, |
| 114803 | + /* 220 */ 11, 513, 295, 813, 395, 831, 395, 831, 595, 831, |
| 114804 | + /* 230 */ 288, 649, 498, 498, 395, 154, 273, 699, 1476, 1292, |
| 114805 | + /* 240 */ 1292, 1470, 1470, 1292, 1473, 1421, 1255, 1480, 1480, 1480, |
| 114806 | + /* 250 */ 1480, 1292, 1454, 1255, 1473, 1421, 1421, 1255, 1292, 1454, |
| 114807 | + /* 260 */ 1348, 1436, 1292, 1292, 1454, 1292, 1454, 1292, 1454, 1431, |
| 114808 | + /* 270 */ 1320, 1320, 1320, 1385, 1362, 1362, 1431, 1320, 1340, 1320, |
| 114809 | + /* 280 */ 1385, 1320, 1320, 1294, 1308, 1294, 1308, 1294, 1308, 1292, |
| 114810 | + /* 290 */ 1292, 1272, 1279, 1281, 1253, 1259, 1255, 1258, 1337, 1333, |
| 114811 | + /* 300 */ 1295, 1295, 1254, 1254, 1254, 1254, -82, -82, -82, -82, |
| 114812 | + /* 310 */ -82, -82, 339, 399, 618, 326, 620, -81, 669, 477, |
| 114813 | + /* 320 */ 661, 585, 377, 280, 244, 232, 25, -1, 373, 227, |
| 114814 | + /* 330 */ 215, 1233, 1242, 1195, 1075, 1220, 1149, 1223, 1191, 1188, |
| 114815 | + /* 340 */ 1081, 1113, 1079, 1061, 1049, 1148, 1045, 1150, 1164, 1043, |
| 114816 | + /* 350 */ 1139, 1137, 1113, 1114, 1006, 1058, 1018, 1023, 1066, 1057, |
| 114817 | + /* 360 */ 968, 1091, 1086, 1063, 981, 944, 1011, 1035, 1010, 1000, |
| 114818 | + /* 370 */ 1014, 916, 1033, 1004, 1001, 909, 913, 996, 957, 991, |
| 114819 | + /* 380 */ 990, 986, 964, 938, 954, 917, 889, 897, 912, 910, |
| 114820 | + /* 390 */ 797, 886, 761, 838, 528, 726, 735, 765, 665, 726, |
| 114821 | + /* 400 */ 592, 586, 540, 523, 491, 487, 435, 401, 397, 387, |
| 114822 | + /* 410 */ 249, 216, 185, 127, 110, 51, 82, 143, 15, 48, |
| 113460 | 114823 | }; |
| 113461 | | -#define YY_REDUCE_USE_DFLT (-169) |
| 113462 | | -#define YY_REDUCE_COUNT (309) |
| 113463 | | -#define YY_REDUCE_MIN (-168) |
| 113464 | | -#define YY_REDUCE_MAX (1397) |
| 114824 | +#define YY_REDUCE_USE_DFLT (-143) |
| 114825 | +#define YY_REDUCE_COUNT (311) |
| 114826 | +#define YY_REDUCE_MIN (-142) |
| 114827 | +#define YY_REDUCE_MAX (1387) |
| 113465 | 114828 | static const short yy_reduce_ofst[] = { |
| 113466 | | - /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104, |
| 113467 | | - /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181, |
| 113468 | | - /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962, |
| 113469 | | - /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813, |
| 113470 | | - /* 40 */ 800, 758, 755, 752, 742, 739, 726, 685, 681, 668, |
| 113471 | | - /* 50 */ 665, 652, 607, 604, 594, 591, 578, 530, 528, 526, |
| 113472 | | - /* 60 */ 385, 18, 477, 466, 519, 444, 350, 435, 405, 488, |
| 113473 | | - /* 70 */ 488, 488, 488, 488, 488, 488, 488, 488, 488, 488, |
| 113474 | | - /* 80 */ 488, 488, 488, 488, 488, 488, 488, 488, 488, 488, |
| 113475 | | - /* 90 */ 488, 488, 488, 488, 488, 488, 488, 488, 488, 488, |
| 113476 | | - /* 100 */ 488, 488, 488, 488, 488, 488, 488, 1040, 678, 1036, |
| 113477 | | - /* 110 */ 1007, 967, 966, 965, 845, 686, 610, 684, 317, 672, |
| 113478 | | - /* 120 */ 893, 327, 623, 522, -7, 820, 814, 157, 154, 101, |
| 113479 | | - /* 130 */ 702, 494, 580, 488, 488, 488, 488, 488, 614, 586, |
| 113480 | | - /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222, |
| 113481 | | - /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158, |
| 113482 | | - /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072, |
| 113483 | | - /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894, |
| 113484 | | - /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646, |
| 113485 | | - /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369, |
| 113486 | | - /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352, |
| 113487 | | - /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341, |
| 113488 | | - /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318, |
| 113489 | | - /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358, |
| 113490 | | - /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312, |
| 113491 | | - /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252, |
| 113492 | | - /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, |
| 113493 | | - /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, |
| 113494 | | - /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, |
| 113495 | | - /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, |
| 113496 | | - /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164, |
| 114829 | + /* 0 */ -142, 1111, 92, 151, 241, 161, 150, 93, 85, 324, |
| 114830 | + /* 10 */ 386, 313, 320, 229, -6, 310, 536, 485, -72, 1121, |
| 114831 | + /* 20 */ 1089, 1082, 1076, 1054, 1037, 997, 979, 977, 975, 962, |
| 114832 | + /* 30 */ 923, 921, 904, 902, 900, 887, 847, 829, 827, 825, |
| 114833 | + /* 40 */ 812, 771, 769, 754, 752, 750, 737, 679, 677, 675, |
| 114834 | + /* 50 */ 662, 623, 619, 617, 613, 602, 600, 587, 537, 527, |
| 114835 | + /* 60 */ 472, 376, 480, 450, 226, 453, 398, 390, 426, 420, |
| 114836 | + /* 70 */ 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, |
| 114837 | + /* 80 */ 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, |
| 114838 | + /* 90 */ 420, 420, 420, 420, 420, 420, 420, 420, 420, 420, |
| 114839 | + /* 100 */ 420, 420, 420, 420, 420, 420, 420, 1153, 922, 1123, |
| 114840 | + /* 110 */ 1115, 1055, 1007, 980, 976, 901, 844, 830, 767, 826, |
| 114841 | + /* 120 */ 682, 694, 707, 482, 583, 681, 680, 676, 531, 27, |
| 114842 | + /* 130 */ 787, 562, 521, 420, 420, 420, 420, 420, 773, 741, |
| 114843 | + /* 140 */ 674, 670, 1067, 1251, 1245, 1239, 1234, 591, 591, 1230, |
| 114844 | + /* 150 */ 1228, 1226, 1221, 1219, 1213, 1207, 1206, 1202, 1201, 1200, |
| 114845 | + /* 160 */ 1199, 1193, 1189, 1178, 1176, 1174, 1155, 1142, 1138, 1134, |
| 114846 | + /* 170 */ 1116, 1112, 1077, 1074, 1069, 1067, 1009, 994, 982, 933, |
| 114847 | + /* 180 */ 848, 757, 849, 775, 628, 611, 745, 710, 672, 469, |
| 114848 | + /* 190 */ 488, 573, 1387, 1384, 1367, 1374, 1373, 1372, 1344, 1354, |
| 114849 | + /* 200 */ 1360, 1354, 1354, 1354, 1354, 1354, 1354, 1354, 1330, 1326, |
| 114850 | + /* 210 */ 1354, 1354, 1344, 1371, 1336, 1386, 1349, 1338, 1334, 1305, |
| 114851 | + /* 220 */ 1331, 1299, 1359, 1346, 1361, 1353, 1358, 1352, 1341, 1345, |
| 114852 | + /* 230 */ 1316, 1293, 1296, 1286, 1351, 1325, 1324, 1363, 1275, 1356, |
| 114853 | + /* 240 */ 1355, 1270, 1267, 1350, 1282, 1319, 1306, 1312, 1311, 1310, |
| 114854 | + /* 250 */ 1309, 1343, 1339, 1298, 1274, 1301, 1297, 1288, 1329, 1328, |
| 114855 | + /* 260 */ 1248, 1246, 1323, 1322, 1318, 1321, 1317, 1315, 1313, 1276, |
| 114856 | + /* 270 */ 1291, 1289, 1287, 1278, 1235, 1224, 1271, 1273, 1264, 1265, |
| 114857 | + /* 280 */ 1247, 1252, 1240, 1218, 1229, 1217, 1216, 1214, 1212, 1262, |
| 114858 | + /* 290 */ 1261, 1182, 1205, 1203, 1186, 1185, 1175, 1167, 1169, 1159, |
| 114859 | + /* 300 */ 1165, 1132, 1152, 1145, 1144, 1105, 1030, 1008, 999, 1073, |
| 114860 | + /* 310 */ 1072, 1080, |
| 113497 | 114861 | }; |
| 113498 | 114862 | static const YYACTIONTYPE yy_default[] = { |
| 113499 | | - /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757, |
| 113500 | | - /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955, |
| 113501 | | - /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113502 | | - /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113503 | | - /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113504 | | - /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113505 | | - /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791, |
| 113506 | | - /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930, |
| 113507 | | - /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862, |
| 113508 | | - /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844, |
| 113509 | | - /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955, |
| 113510 | | - /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113511 | | - /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955, |
| 113512 | | - /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664, |
| 113513 | | - /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113514 | | - /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955, |
| 113515 | | - /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113516 | | - /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113517 | | - /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761, |
| 113518 | | - /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113519 | | - /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738, |
| 113520 | | - /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795, |
| 113521 | | - /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774, |
| 113522 | | - /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765, |
| 113523 | | - /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737, |
| 113524 | | - /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907, |
| 113525 | | - /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728, |
| 113526 | | - /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712, |
| 113527 | | - /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765, |
| 113528 | | - /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649, |
| 113529 | | - /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682, |
| 113530 | | - /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955, |
| 113531 | | - /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113532 | | - /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800, |
| 113533 | | - /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113534 | | - /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955, |
| 113535 | | - /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955, |
| 113536 | | - /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113537 | | - /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 113538 | | - /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955, |
| 113539 | | - /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816, |
| 113540 | | - /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635, |
| 113541 | | - /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937, |
| 113542 | | - /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888, |
| 113543 | | - /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739, |
| 113544 | | - /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916, |
| 113545 | | - /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870, |
| 113546 | | - /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654, |
| 113547 | | - /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717, |
| 113548 | | - /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704, |
| 113549 | | - /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693, |
| 113550 | | - /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732, |
| 113551 | | - /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812, |
| 113552 | | - /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809, |
| 113553 | | - /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750, |
| 113554 | | - /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923, |
| 113555 | | - /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893, |
| 113556 | | - /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852, |
| 113557 | | - /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821, |
| 113558 | | - /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811, |
| 113559 | | - /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650, |
| 113560 | | - /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669, |
| 113561 | | - /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629, |
| 114863 | + /* 0 */ 636, 872, 960, 960, 872, 872, 960, 960, 960, 762, |
| 114864 | + /* 10 */ 960, 960, 960, 870, 960, 960, 790, 790, 934, 960, |
| 114865 | + /* 20 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114866 | + /* 30 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114867 | + /* 40 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114868 | + /* 50 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114869 | + /* 60 */ 960, 960, 960, 960, 960, 960, 960, 677, 766, 796, |
| 114870 | + /* 70 */ 960, 960, 960, 960, 960, 960, 960, 960, 933, 935, |
| 114871 | + /* 80 */ 804, 803, 913, 777, 801, 794, 798, 873, 866, 867, |
| 114872 | + /* 90 */ 865, 869, 874, 960, 797, 833, 850, 832, 844, 849, |
| 114873 | + /* 100 */ 856, 848, 845, 835, 834, 836, 837, 960, 960, 960, |
| 114874 | + /* 110 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114875 | + /* 120 */ 960, 960, 960, 662, 731, 960, 960, 960, 960, 960, |
| 114876 | + /* 130 */ 960, 960, 960, 838, 839, 853, 852, 851, 960, 669, |
| 114877 | + /* 140 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114878 | + /* 150 */ 940, 938, 960, 885, 960, 960, 960, 960, 960, 960, |
| 114879 | + /* 160 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114880 | + /* 170 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114881 | + /* 180 */ 960, 642, 762, 762, 762, 636, 960, 960, 960, 952, |
| 114882 | + /* 190 */ 766, 756, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114883 | + /* 200 */ 960, 960, 960, 960, 806, 745, 923, 925, 960, 906, |
| 114884 | + /* 210 */ 743, 664, 764, 679, 754, 644, 800, 779, 779, 918, |
| 114885 | + /* 220 */ 800, 918, 702, 725, 960, 790, 960, 790, 699, 790, |
| 114886 | + /* 230 */ 779, 868, 960, 960, 960, 763, 754, 960, 945, 770, |
| 114887 | + /* 240 */ 770, 937, 937, 770, 812, 735, 800, 742, 742, 742, |
| 114888 | + /* 250 */ 742, 770, 659, 800, 812, 735, 735, 800, 770, 659, |
| 114889 | + /* 260 */ 912, 910, 770, 770, 659, 770, 659, 770, 659, 878, |
| 114890 | + /* 270 */ 733, 733, 733, 717, 882, 882, 878, 733, 702, 733, |
| 114891 | + /* 280 */ 717, 733, 733, 783, 778, 783, 778, 783, 778, 770, |
| 114892 | + /* 290 */ 770, 960, 795, 784, 793, 791, 800, 960, 665, 720, |
| 114893 | + /* 300 */ 652, 652, 641, 641, 641, 641, 957, 957, 952, 704, |
| 114894 | + /* 310 */ 704, 687, 960, 960, 960, 960, 960, 960, 960, 887, |
| 114895 | + /* 320 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114896 | + /* 330 */ 960, 960, 637, 947, 960, 960, 944, 960, 960, 960, |
| 114897 | + /* 340 */ 960, 805, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114898 | + /* 350 */ 960, 960, 922, 960, 960, 960, 960, 960, 960, 960, |
| 114899 | + /* 360 */ 916, 960, 960, 960, 960, 960, 960, 909, 908, 960, |
| 114900 | + /* 370 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114901 | + /* 380 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114902 | + /* 390 */ 960, 960, 960, 960, 960, 792, 960, 785, 960, 871, |
| 114903 | + /* 400 */ 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, |
| 114904 | + /* 410 */ 748, 821, 960, 820, 824, 819, 671, 960, 650, 960, |
| 114905 | + /* 420 */ 633, 638, 956, 959, 958, 955, 954, 953, 948, 946, |
| 114906 | + /* 430 */ 943, 942, 941, 939, 936, 932, 891, 889, 896, 895, |
| 114907 | + /* 440 */ 894, 893, 892, 890, 888, 886, 807, 802, 799, 931, |
| 114908 | + /* 450 */ 884, 744, 741, 740, 658, 949, 915, 924, 811, 810, |
| 114909 | + /* 460 */ 813, 921, 920, 919, 917, 914, 901, 809, 808, 736, |
| 114910 | + /* 470 */ 876, 875, 661, 905, 904, 903, 907, 911, 902, 772, |
| 114911 | + /* 480 */ 660, 657, 668, 723, 724, 732, 730, 729, 728, 727, |
| 114912 | + /* 490 */ 726, 722, 670, 678, 716, 701, 700, 881, 883, 880, |
| 114913 | + /* 500 */ 879, 709, 708, 714, 713, 712, 711, 710, 707, 706, |
| 114914 | + /* 510 */ 705, 698, 697, 703, 696, 719, 718, 715, 695, 739, |
| 114915 | + /* 520 */ 738, 737, 734, 694, 693, 692, 824, 691, 690, 830, |
| 114916 | + /* 530 */ 829, 817, 860, 759, 758, 757, 769, 768, 781, 780, |
| 114917 | + /* 540 */ 815, 814, 782, 767, 761, 760, 776, 775, 774, 773, |
| 114918 | + /* 550 */ 765, 755, 787, 789, 788, 786, 862, 771, 859, 930, |
| 114919 | + /* 560 */ 929, 928, 927, 926, 864, 863, 831, 828, 682, 683, |
| 114920 | + /* 570 */ 899, 898, 900, 897, 685, 684, 681, 680, 861, 750, |
| 114921 | + /* 580 */ 749, 857, 854, 846, 842, 858, 855, 847, 843, 841, |
| 114922 | + /* 590 */ 840, 826, 825, 823, 822, 818, 827, 673, 751, 747, |
| 114923 | + /* 600 */ 746, 816, 753, 752, 689, 688, 686, 667, 666, 663, |
| 114924 | + /* 610 */ 656, 654, 653, 655, 651, 649, 648, 647, 646, 645, |
| 114925 | + /* 620 */ 676, 675, 674, 672, 671, 643, 640, 639, 635, 634, |
| 114926 | + /* 630 */ 632, |
| 113562 | 114927 | }; |
| 113563 | 114928 | |
| 113564 | 114929 | /* The next table maps tokens into fallback tokens. If a construct |
| 113565 | 114930 | ** like the following: |
| 113566 | 114931 | ** |
| | @@ -113573,75 +114938,76 @@ |
| 113573 | 114938 | */ |
| 113574 | 114939 | #ifdef YYFALLBACK |
| 113575 | 114940 | static const YYCODETYPE yyFallback[] = { |
| 113576 | 114941 | 0, /* $ => nothing */ |
| 113577 | 114942 | 0, /* SEMI => nothing */ |
| 113578 | | - 26, /* EXPLAIN => ID */ |
| 113579 | | - 26, /* QUERY => ID */ |
| 113580 | | - 26, /* PLAN => ID */ |
| 113581 | | - 26, /* BEGIN => ID */ |
| 114943 | + 27, /* EXPLAIN => ID */ |
| 114944 | + 27, /* QUERY => ID */ |
| 114945 | + 27, /* PLAN => ID */ |
| 114946 | + 27, /* BEGIN => ID */ |
| 113582 | 114947 | 0, /* TRANSACTION => nothing */ |
| 113583 | | - 26, /* DEFERRED => ID */ |
| 113584 | | - 26, /* IMMEDIATE => ID */ |
| 113585 | | - 26, /* EXCLUSIVE => ID */ |
| 114948 | + 27, /* DEFERRED => ID */ |
| 114949 | + 27, /* IMMEDIATE => ID */ |
| 114950 | + 27, /* EXCLUSIVE => ID */ |
| 113586 | 114951 | 0, /* COMMIT => nothing */ |
| 113587 | | - 26, /* END => ID */ |
| 113588 | | - 26, /* ROLLBACK => ID */ |
| 113589 | | - 26, /* SAVEPOINT => ID */ |
| 113590 | | - 26, /* RELEASE => ID */ |
| 114952 | + 27, /* END => ID */ |
| 114953 | + 27, /* ROLLBACK => ID */ |
| 114954 | + 27, /* SAVEPOINT => ID */ |
| 114955 | + 27, /* RELEASE => ID */ |
| 113591 | 114956 | 0, /* TO => nothing */ |
| 113592 | 114957 | 0, /* TABLE => nothing */ |
| 113593 | 114958 | 0, /* CREATE => nothing */ |
| 113594 | | - 26, /* IF => ID */ |
| 114959 | + 27, /* IF => ID */ |
| 113595 | 114960 | 0, /* NOT => nothing */ |
| 113596 | 114961 | 0, /* EXISTS => nothing */ |
| 113597 | | - 26, /* TEMP => ID */ |
| 114962 | + 27, /* TEMP => ID */ |
| 113598 | 114963 | 0, /* LP => nothing */ |
| 113599 | 114964 | 0, /* RP => nothing */ |
| 113600 | 114965 | 0, /* AS => nothing */ |
| 114966 | + 27, /* WITHOUT => ID */ |
| 113601 | 114967 | 0, /* COMMA => nothing */ |
| 113602 | 114968 | 0, /* ID => nothing */ |
| 113603 | 114969 | 0, /* INDEXED => nothing */ |
| 113604 | | - 26, /* ABORT => ID */ |
| 113605 | | - 26, /* ACTION => ID */ |
| 113606 | | - 26, /* AFTER => ID */ |
| 113607 | | - 26, /* ANALYZE => ID */ |
| 113608 | | - 26, /* ASC => ID */ |
| 113609 | | - 26, /* ATTACH => ID */ |
| 113610 | | - 26, /* BEFORE => ID */ |
| 113611 | | - 26, /* BY => ID */ |
| 113612 | | - 26, /* CASCADE => ID */ |
| 113613 | | - 26, /* CAST => ID */ |
| 113614 | | - 26, /* COLUMNKW => ID */ |
| 113615 | | - 26, /* CONFLICT => ID */ |
| 113616 | | - 26, /* DATABASE => ID */ |
| 113617 | | - 26, /* DESC => ID */ |
| 113618 | | - 26, /* DETACH => ID */ |
| 113619 | | - 26, /* EACH => ID */ |
| 113620 | | - 26, /* FAIL => ID */ |
| 113621 | | - 26, /* FOR => ID */ |
| 113622 | | - 26, /* IGNORE => ID */ |
| 113623 | | - 26, /* INITIALLY => ID */ |
| 113624 | | - 26, /* INSTEAD => ID */ |
| 113625 | | - 26, /* LIKE_KW => ID */ |
| 113626 | | - 26, /* MATCH => ID */ |
| 113627 | | - 26, /* NO => ID */ |
| 113628 | | - 26, /* KEY => ID */ |
| 113629 | | - 26, /* OF => ID */ |
| 113630 | | - 26, /* OFFSET => ID */ |
| 113631 | | - 26, /* PRAGMA => ID */ |
| 113632 | | - 26, /* RAISE => ID */ |
| 113633 | | - 26, /* REPLACE => ID */ |
| 113634 | | - 26, /* RESTRICT => ID */ |
| 113635 | | - 26, /* ROW => ID */ |
| 113636 | | - 26, /* TRIGGER => ID */ |
| 113637 | | - 26, /* VACUUM => ID */ |
| 113638 | | - 26, /* VIEW => ID */ |
| 113639 | | - 26, /* VIRTUAL => ID */ |
| 113640 | | - 26, /* REINDEX => ID */ |
| 113641 | | - 26, /* RENAME => ID */ |
| 113642 | | - 26, /* CTIME_KW => ID */ |
| 114970 | + 27, /* ABORT => ID */ |
| 114971 | + 27, /* ACTION => ID */ |
| 114972 | + 27, /* AFTER => ID */ |
| 114973 | + 27, /* ANALYZE => ID */ |
| 114974 | + 27, /* ASC => ID */ |
| 114975 | + 27, /* ATTACH => ID */ |
| 114976 | + 27, /* BEFORE => ID */ |
| 114977 | + 27, /* BY => ID */ |
| 114978 | + 27, /* CASCADE => ID */ |
| 114979 | + 27, /* CAST => ID */ |
| 114980 | + 27, /* COLUMNKW => ID */ |
| 114981 | + 27, /* CONFLICT => ID */ |
| 114982 | + 27, /* DATABASE => ID */ |
| 114983 | + 27, /* DESC => ID */ |
| 114984 | + 27, /* DETACH => ID */ |
| 114985 | + 27, /* EACH => ID */ |
| 114986 | + 27, /* FAIL => ID */ |
| 114987 | + 27, /* FOR => ID */ |
| 114988 | + 27, /* IGNORE => ID */ |
| 114989 | + 27, /* INITIALLY => ID */ |
| 114990 | + 27, /* INSTEAD => ID */ |
| 114991 | + 27, /* LIKE_KW => ID */ |
| 114992 | + 27, /* MATCH => ID */ |
| 114993 | + 27, /* NO => ID */ |
| 114994 | + 27, /* KEY => ID */ |
| 114995 | + 27, /* OF => ID */ |
| 114996 | + 27, /* OFFSET => ID */ |
| 114997 | + 27, /* PRAGMA => ID */ |
| 114998 | + 27, /* RAISE => ID */ |
| 114999 | + 27, /* REPLACE => ID */ |
| 115000 | + 27, /* RESTRICT => ID */ |
| 115001 | + 27, /* ROW => ID */ |
| 115002 | + 27, /* TRIGGER => ID */ |
| 115003 | + 27, /* VACUUM => ID */ |
| 115004 | + 27, /* VIEW => ID */ |
| 115005 | + 27, /* VIRTUAL => ID */ |
| 115006 | + 27, /* REINDEX => ID */ |
| 115007 | + 27, /* RENAME => ID */ |
| 115008 | + 27, /* CTIME_KW => ID */ |
| 113643 | 115009 | }; |
| 113644 | 115010 | #endif /* YYFALLBACK */ |
| 113645 | 115011 | |
| 113646 | 115012 | /* The following structure represents a single element of the |
| 113647 | 115013 | ** parser's stack. Information stored includes: |
| | @@ -113722,67 +115088,67 @@ |
| 113722 | 115088 | "PLAN", "BEGIN", "TRANSACTION", "DEFERRED", |
| 113723 | 115089 | "IMMEDIATE", "EXCLUSIVE", "COMMIT", "END", |
| 113724 | 115090 | "ROLLBACK", "SAVEPOINT", "RELEASE", "TO", |
| 113725 | 115091 | "TABLE", "CREATE", "IF", "NOT", |
| 113726 | 115092 | "EXISTS", "TEMP", "LP", "RP", |
| 113727 | | - "AS", "COMMA", "ID", "INDEXED", |
| 113728 | | - "ABORT", "ACTION", "AFTER", "ANALYZE", |
| 113729 | | - "ASC", "ATTACH", "BEFORE", "BY", |
| 113730 | | - "CASCADE", "CAST", "COLUMNKW", "CONFLICT", |
| 113731 | | - "DATABASE", "DESC", "DETACH", "EACH", |
| 113732 | | - "FAIL", "FOR", "IGNORE", "INITIALLY", |
| 113733 | | - "INSTEAD", "LIKE_KW", "MATCH", "NO", |
| 113734 | | - "KEY", "OF", "OFFSET", "PRAGMA", |
| 113735 | | - "RAISE", "REPLACE", "RESTRICT", "ROW", |
| 113736 | | - "TRIGGER", "VACUUM", "VIEW", "VIRTUAL", |
| 113737 | | - "REINDEX", "RENAME", "CTIME_KW", "ANY", |
| 113738 | | - "OR", "AND", "IS", "BETWEEN", |
| 113739 | | - "IN", "ISNULL", "NOTNULL", "NE", |
| 113740 | | - "EQ", "GT", "LE", "LT", |
| 113741 | | - "GE", "ESCAPE", "BITAND", "BITOR", |
| 113742 | | - "LSHIFT", "RSHIFT", "PLUS", "MINUS", |
| 113743 | | - "STAR", "SLASH", "REM", "CONCAT", |
| 113744 | | - "COLLATE", "BITNOT", "STRING", "JOIN_KW", |
| 113745 | | - "CONSTRAINT", "DEFAULT", "NULL", "PRIMARY", |
| 113746 | | - "UNIQUE", "CHECK", "REFERENCES", "AUTOINCR", |
| 113747 | | - "ON", "INSERT", "DELETE", "UPDATE", |
| 113748 | | - "SET", "DEFERRABLE", "FOREIGN", "DROP", |
| 113749 | | - "UNION", "ALL", "EXCEPT", "INTERSECT", |
| 113750 | | - "SELECT", "DISTINCT", "DOT", "FROM", |
| 113751 | | - "JOIN", "USING", "ORDER", "GROUP", |
| 113752 | | - "HAVING", "LIMIT", "WHERE", "INTO", |
| 113753 | | - "VALUES", "INTEGER", "FLOAT", "BLOB", |
| 113754 | | - "REGISTER", "VARIABLE", "CASE", "WHEN", |
| 113755 | | - "THEN", "ELSE", "INDEX", "ALTER", |
| 113756 | | - "ADD", "error", "input", "cmdlist", |
| 113757 | | - "ecmd", "explain", "cmdx", "cmd", |
| 113758 | | - "transtype", "trans_opt", "nm", "savepoint_opt", |
| 113759 | | - "create_table", "create_table_args", "createkw", "temp", |
| 113760 | | - "ifnotexists", "dbnm", "columnlist", "conslist_opt", |
| 113761 | | - "select", "column", "columnid", "type", |
| 113762 | | - "carglist", "id", "ids", "typetoken", |
| 113763 | | - "typename", "signed", "plus_num", "minus_num", |
| 113764 | | - "ccons", "term", "expr", "onconf", |
| 113765 | | - "sortorder", "autoinc", "idxlist_opt", "refargs", |
| 113766 | | - "defer_subclause", "refarg", "refact", "init_deferred_pred_opt", |
| 113767 | | - "conslist", "tconscomma", "tcons", "idxlist", |
| 113768 | | - "defer_subclause_opt", "orconf", "resolvetype", "raisetype", |
| 113769 | | - "ifexists", "fullname", "oneselect", "multiselect_op", |
| 113770 | | - "distinct", "selcollist", "from", "where_opt", |
| 113771 | | - "groupby_opt", "having_opt", "orderby_opt", "limit_opt", |
| 113772 | | - "sclp", "as", "seltablist", "stl_prefix", |
| 113773 | | - "joinop", "indexed_opt", "on_opt", "using_opt", |
| 113774 | | - "joinop2", "inscollist", "sortlist", "nexprlist", |
| 113775 | | - "setlist", "insert_cmd", "inscollist_opt", "valuelist", |
| 113776 | | - "exprlist", "likeop", "between_op", "in_op", |
| 113777 | | - "case_operand", "case_exprlist", "case_else", "uniqueflag", |
| 113778 | | - "collate", "nmnum", "number", "trigger_decl", |
| 113779 | | - "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause", |
| 113780 | | - "when_clause", "trigger_cmd", "trnm", "tridxby", |
| 113781 | | - "database_kw_opt", "key_opt", "add_column_fullname", "kwcolumn_opt", |
| 113782 | | - "create_vtab", "vtabarglist", "vtabarg", "vtabargtoken", |
| 113783 | | - "lp", "anylist", |
| 115093 | + "AS", "WITHOUT", "COMMA", "ID", |
| 115094 | + "INDEXED", "ABORT", "ACTION", "AFTER", |
| 115095 | + "ANALYZE", "ASC", "ATTACH", "BEFORE", |
| 115096 | + "BY", "CASCADE", "CAST", "COLUMNKW", |
| 115097 | + "CONFLICT", "DATABASE", "DESC", "DETACH", |
| 115098 | + "EACH", "FAIL", "FOR", "IGNORE", |
| 115099 | + "INITIALLY", "INSTEAD", "LIKE_KW", "MATCH", |
| 115100 | + "NO", "KEY", "OF", "OFFSET", |
| 115101 | + "PRAGMA", "RAISE", "REPLACE", "RESTRICT", |
| 115102 | + "ROW", "TRIGGER", "VACUUM", "VIEW", |
| 115103 | + "VIRTUAL", "REINDEX", "RENAME", "CTIME_KW", |
| 115104 | + "ANY", "OR", "AND", "IS", |
| 115105 | + "BETWEEN", "IN", "ISNULL", "NOTNULL", |
| 115106 | + "NE", "EQ", "GT", "LE", |
| 115107 | + "LT", "GE", "ESCAPE", "BITAND", |
| 115108 | + "BITOR", "LSHIFT", "RSHIFT", "PLUS", |
| 115109 | + "MINUS", "STAR", "SLASH", "REM", |
| 115110 | + "CONCAT", "COLLATE", "BITNOT", "STRING", |
| 115111 | + "JOIN_KW", "CONSTRAINT", "DEFAULT", "NULL", |
| 115112 | + "PRIMARY", "UNIQUE", "CHECK", "REFERENCES", |
| 115113 | + "AUTOINCR", "ON", "INSERT", "DELETE", |
| 115114 | + "UPDATE", "SET", "DEFERRABLE", "FOREIGN", |
| 115115 | + "DROP", "UNION", "ALL", "EXCEPT", |
| 115116 | + "INTERSECT", "SELECT", "DISTINCT", "DOT", |
| 115117 | + "FROM", "JOIN", "USING", "ORDER", |
| 115118 | + "GROUP", "HAVING", "LIMIT", "WHERE", |
| 115119 | + "INTO", "VALUES", "INTEGER", "FLOAT", |
| 115120 | + "BLOB", "REGISTER", "VARIABLE", "CASE", |
| 115121 | + "WHEN", "THEN", "ELSE", "INDEX", |
| 115122 | + "ALTER", "ADD", "error", "input", |
| 115123 | + "cmdlist", "ecmd", "explain", "cmdx", |
| 115124 | + "cmd", "transtype", "trans_opt", "nm", |
| 115125 | + "savepoint_opt", "create_table", "create_table_args", "createkw", |
| 115126 | + "temp", "ifnotexists", "dbnm", "columnlist", |
| 115127 | + "conslist_opt", "table_options", "select", "column", |
| 115128 | + "columnid", "type", "carglist", "id", |
| 115129 | + "ids", "typetoken", "typename", "signed", |
| 115130 | + "plus_num", "minus_num", "ccons", "term", |
| 115131 | + "expr", "onconf", "sortorder", "autoinc", |
| 115132 | + "idxlist_opt", "refargs", "defer_subclause", "refarg", |
| 115133 | + "refact", "init_deferred_pred_opt", "conslist", "tconscomma", |
| 115134 | + "tcons", "idxlist", "defer_subclause_opt", "orconf", |
| 115135 | + "resolvetype", "raisetype", "ifexists", "fullname", |
| 115136 | + "oneselect", "multiselect_op", "distinct", "selcollist", |
| 115137 | + "from", "where_opt", "groupby_opt", "having_opt", |
| 115138 | + "orderby_opt", "limit_opt", "sclp", "as", |
| 115139 | + "seltablist", "stl_prefix", "joinop", "indexed_opt", |
| 115140 | + "on_opt", "using_opt", "joinop2", "idlist", |
| 115141 | + "sortlist", "nexprlist", "setlist", "insert_cmd", |
| 115142 | + "inscollist_opt", "valuelist", "exprlist", "likeop", |
| 115143 | + "between_op", "in_op", "case_operand", "case_exprlist", |
| 115144 | + "case_else", "uniqueflag", "collate", "nmnum", |
| 115145 | + "number", "trigger_decl", "trigger_cmd_list", "trigger_time", |
| 115146 | + "trigger_event", "foreach_clause", "when_clause", "trigger_cmd", |
| 115147 | + "trnm", "tridxby", "database_kw_opt", "key_opt", |
| 115148 | + "add_column_fullname", "kwcolumn_opt", "create_vtab", "vtabarglist", |
| 115149 | + "vtabarg", "vtabargtoken", "lp", "anylist", |
| 113784 | 115150 | }; |
| 113785 | 115151 | #endif /* NDEBUG */ |
| 113786 | 115152 | |
| 113787 | 115153 | #ifndef NDEBUG |
| 113788 | 115154 | /* For tracing reduce actions, the names of all rules are required. |
| | @@ -113818,305 +115184,307 @@ |
| 113818 | 115184 | /* 27 */ "createkw ::= CREATE", |
| 113819 | 115185 | /* 28 */ "ifnotexists ::=", |
| 113820 | 115186 | /* 29 */ "ifnotexists ::= IF NOT EXISTS", |
| 113821 | 115187 | /* 30 */ "temp ::= TEMP", |
| 113822 | 115188 | /* 31 */ "temp ::=", |
| 113823 | | - /* 32 */ "create_table_args ::= LP columnlist conslist_opt RP", |
| 115189 | + /* 32 */ "create_table_args ::= LP columnlist conslist_opt RP table_options", |
| 113824 | 115190 | /* 33 */ "create_table_args ::= AS select", |
| 113825 | | - /* 34 */ "columnlist ::= columnlist COMMA column", |
| 113826 | | - /* 35 */ "columnlist ::= column", |
| 113827 | | - /* 36 */ "column ::= columnid type carglist", |
| 113828 | | - /* 37 */ "columnid ::= nm", |
| 113829 | | - /* 38 */ "id ::= ID", |
| 113830 | | - /* 39 */ "id ::= INDEXED", |
| 113831 | | - /* 40 */ "ids ::= ID|STRING", |
| 113832 | | - /* 41 */ "nm ::= id", |
| 113833 | | - /* 42 */ "nm ::= STRING", |
| 113834 | | - /* 43 */ "nm ::= JOIN_KW", |
| 113835 | | - /* 44 */ "type ::=", |
| 113836 | | - /* 45 */ "type ::= typetoken", |
| 113837 | | - /* 46 */ "typetoken ::= typename", |
| 113838 | | - /* 47 */ "typetoken ::= typename LP signed RP", |
| 113839 | | - /* 48 */ "typetoken ::= typename LP signed COMMA signed RP", |
| 113840 | | - /* 49 */ "typename ::= ids", |
| 113841 | | - /* 50 */ "typename ::= typename ids", |
| 113842 | | - /* 51 */ "signed ::= plus_num", |
| 113843 | | - /* 52 */ "signed ::= minus_num", |
| 113844 | | - /* 53 */ "carglist ::= carglist ccons", |
| 113845 | | - /* 54 */ "carglist ::=", |
| 113846 | | - /* 55 */ "ccons ::= CONSTRAINT nm", |
| 113847 | | - /* 56 */ "ccons ::= DEFAULT term", |
| 113848 | | - /* 57 */ "ccons ::= DEFAULT LP expr RP", |
| 113849 | | - /* 58 */ "ccons ::= DEFAULT PLUS term", |
| 113850 | | - /* 59 */ "ccons ::= DEFAULT MINUS term", |
| 113851 | | - /* 60 */ "ccons ::= DEFAULT id", |
| 113852 | | - /* 61 */ "ccons ::= NULL onconf", |
| 113853 | | - /* 62 */ "ccons ::= NOT NULL onconf", |
| 113854 | | - /* 63 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc", |
| 113855 | | - /* 64 */ "ccons ::= UNIQUE onconf", |
| 113856 | | - /* 65 */ "ccons ::= CHECK LP expr RP", |
| 113857 | | - /* 66 */ "ccons ::= REFERENCES nm idxlist_opt refargs", |
| 113858 | | - /* 67 */ "ccons ::= defer_subclause", |
| 113859 | | - /* 68 */ "ccons ::= COLLATE ids", |
| 113860 | | - /* 69 */ "autoinc ::=", |
| 113861 | | - /* 70 */ "autoinc ::= AUTOINCR", |
| 113862 | | - /* 71 */ "refargs ::=", |
| 113863 | | - /* 72 */ "refargs ::= refargs refarg", |
| 113864 | | - /* 73 */ "refarg ::= MATCH nm", |
| 113865 | | - /* 74 */ "refarg ::= ON INSERT refact", |
| 113866 | | - /* 75 */ "refarg ::= ON DELETE refact", |
| 113867 | | - /* 76 */ "refarg ::= ON UPDATE refact", |
| 113868 | | - /* 77 */ "refact ::= SET NULL", |
| 113869 | | - /* 78 */ "refact ::= SET DEFAULT", |
| 113870 | | - /* 79 */ "refact ::= CASCADE", |
| 113871 | | - /* 80 */ "refact ::= RESTRICT", |
| 113872 | | - /* 81 */ "refact ::= NO ACTION", |
| 113873 | | - /* 82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", |
| 113874 | | - /* 83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", |
| 113875 | | - /* 84 */ "init_deferred_pred_opt ::=", |
| 113876 | | - /* 85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", |
| 113877 | | - /* 86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", |
| 113878 | | - /* 87 */ "conslist_opt ::=", |
| 113879 | | - /* 88 */ "conslist_opt ::= COMMA conslist", |
| 113880 | | - /* 89 */ "conslist ::= conslist tconscomma tcons", |
| 113881 | | - /* 90 */ "conslist ::= tcons", |
| 113882 | | - /* 91 */ "tconscomma ::= COMMA", |
| 113883 | | - /* 92 */ "tconscomma ::=", |
| 113884 | | - /* 93 */ "tcons ::= CONSTRAINT nm", |
| 113885 | | - /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf", |
| 113886 | | - /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf", |
| 113887 | | - /* 96 */ "tcons ::= CHECK LP expr RP onconf", |
| 113888 | | - /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt", |
| 113889 | | - /* 98 */ "defer_subclause_opt ::=", |
| 113890 | | - /* 99 */ "defer_subclause_opt ::= defer_subclause", |
| 113891 | | - /* 100 */ "onconf ::=", |
| 113892 | | - /* 101 */ "onconf ::= ON CONFLICT resolvetype", |
| 113893 | | - /* 102 */ "orconf ::=", |
| 113894 | | - /* 103 */ "orconf ::= OR resolvetype", |
| 113895 | | - /* 104 */ "resolvetype ::= raisetype", |
| 113896 | | - /* 105 */ "resolvetype ::= IGNORE", |
| 113897 | | - /* 106 */ "resolvetype ::= REPLACE", |
| 113898 | | - /* 107 */ "cmd ::= DROP TABLE ifexists fullname", |
| 113899 | | - /* 108 */ "ifexists ::= IF EXISTS", |
| 113900 | | - /* 109 */ "ifexists ::=", |
| 113901 | | - /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select", |
| 113902 | | - /* 111 */ "cmd ::= DROP VIEW ifexists fullname", |
| 113903 | | - /* 112 */ "cmd ::= select", |
| 113904 | | - /* 113 */ "select ::= oneselect", |
| 113905 | | - /* 114 */ "select ::= select multiselect_op oneselect", |
| 113906 | | - /* 115 */ "multiselect_op ::= UNION", |
| 113907 | | - /* 116 */ "multiselect_op ::= UNION ALL", |
| 113908 | | - /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT", |
| 113909 | | - /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", |
| 113910 | | - /* 119 */ "distinct ::= DISTINCT", |
| 113911 | | - /* 120 */ "distinct ::= ALL", |
| 113912 | | - /* 121 */ "distinct ::=", |
| 113913 | | - /* 122 */ "sclp ::= selcollist COMMA", |
| 113914 | | - /* 123 */ "sclp ::=", |
| 113915 | | - /* 124 */ "selcollist ::= sclp expr as", |
| 113916 | | - /* 125 */ "selcollist ::= sclp STAR", |
| 113917 | | - /* 126 */ "selcollist ::= sclp nm DOT STAR", |
| 113918 | | - /* 127 */ "as ::= AS nm", |
| 113919 | | - /* 128 */ "as ::= ids", |
| 113920 | | - /* 129 */ "as ::=", |
| 113921 | | - /* 130 */ "from ::=", |
| 113922 | | - /* 131 */ "from ::= FROM seltablist", |
| 113923 | | - /* 132 */ "stl_prefix ::= seltablist joinop", |
| 113924 | | - /* 133 */ "stl_prefix ::=", |
| 113925 | | - /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", |
| 113926 | | - /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 113927 | | - /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 113928 | | - /* 137 */ "dbnm ::=", |
| 113929 | | - /* 138 */ "dbnm ::= DOT nm", |
| 113930 | | - /* 139 */ "fullname ::= nm dbnm", |
| 113931 | | - /* 140 */ "joinop ::= COMMA|JOIN", |
| 113932 | | - /* 141 */ "joinop ::= JOIN_KW JOIN", |
| 113933 | | - /* 142 */ "joinop ::= JOIN_KW nm JOIN", |
| 113934 | | - /* 143 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 113935 | | - /* 144 */ "on_opt ::= ON expr", |
| 113936 | | - /* 145 */ "on_opt ::=", |
| 113937 | | - /* 146 */ "indexed_opt ::=", |
| 113938 | | - /* 147 */ "indexed_opt ::= INDEXED BY nm", |
| 113939 | | - /* 148 */ "indexed_opt ::= NOT INDEXED", |
| 113940 | | - /* 149 */ "using_opt ::= USING LP inscollist RP", |
| 113941 | | - /* 150 */ "using_opt ::=", |
| 113942 | | - /* 151 */ "orderby_opt ::=", |
| 113943 | | - /* 152 */ "orderby_opt ::= ORDER BY sortlist", |
| 113944 | | - /* 153 */ "sortlist ::= sortlist COMMA expr sortorder", |
| 113945 | | - /* 154 */ "sortlist ::= expr sortorder", |
| 113946 | | - /* 155 */ "sortorder ::= ASC", |
| 113947 | | - /* 156 */ "sortorder ::= DESC", |
| 113948 | | - /* 157 */ "sortorder ::=", |
| 113949 | | - /* 158 */ "groupby_opt ::=", |
| 113950 | | - /* 159 */ "groupby_opt ::= GROUP BY nexprlist", |
| 113951 | | - /* 160 */ "having_opt ::=", |
| 113952 | | - /* 161 */ "having_opt ::= HAVING expr", |
| 113953 | | - /* 162 */ "limit_opt ::=", |
| 113954 | | - /* 163 */ "limit_opt ::= LIMIT expr", |
| 113955 | | - /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 113956 | | - /* 165 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 113957 | | - /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt", |
| 113958 | | - /* 167 */ "where_opt ::=", |
| 113959 | | - /* 168 */ "where_opt ::= WHERE expr", |
| 113960 | | - /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt", |
| 113961 | | - /* 170 */ "setlist ::= setlist COMMA nm EQ expr", |
| 113962 | | - /* 171 */ "setlist ::= nm EQ expr", |
| 113963 | | - /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist", |
| 113964 | | - /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select", |
| 113965 | | - /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES", |
| 113966 | | - /* 175 */ "insert_cmd ::= INSERT orconf", |
| 113967 | | - /* 176 */ "insert_cmd ::= REPLACE", |
| 113968 | | - /* 177 */ "valuelist ::= VALUES LP nexprlist RP", |
| 113969 | | - /* 178 */ "valuelist ::= valuelist COMMA LP exprlist RP", |
| 113970 | | - /* 179 */ "inscollist_opt ::=", |
| 113971 | | - /* 180 */ "inscollist_opt ::= LP inscollist RP", |
| 113972 | | - /* 181 */ "inscollist ::= inscollist COMMA nm", |
| 113973 | | - /* 182 */ "inscollist ::= nm", |
| 113974 | | - /* 183 */ "expr ::= term", |
| 113975 | | - /* 184 */ "expr ::= LP expr RP", |
| 113976 | | - /* 185 */ "term ::= NULL", |
| 113977 | | - /* 186 */ "expr ::= id", |
| 113978 | | - /* 187 */ "expr ::= JOIN_KW", |
| 113979 | | - /* 188 */ "expr ::= nm DOT nm", |
| 113980 | | - /* 189 */ "expr ::= nm DOT nm DOT nm", |
| 113981 | | - /* 190 */ "term ::= INTEGER|FLOAT|BLOB", |
| 113982 | | - /* 191 */ "term ::= STRING", |
| 113983 | | - /* 192 */ "expr ::= REGISTER", |
| 113984 | | - /* 193 */ "expr ::= VARIABLE", |
| 113985 | | - /* 194 */ "expr ::= expr COLLATE ids", |
| 113986 | | - /* 195 */ "expr ::= CAST LP expr AS typetoken RP", |
| 113987 | | - /* 196 */ "expr ::= ID LP distinct exprlist RP", |
| 113988 | | - /* 197 */ "expr ::= ID LP STAR RP", |
| 113989 | | - /* 198 */ "term ::= CTIME_KW", |
| 113990 | | - /* 199 */ "expr ::= expr AND expr", |
| 113991 | | - /* 200 */ "expr ::= expr OR expr", |
| 113992 | | - /* 201 */ "expr ::= expr LT|GT|GE|LE expr", |
| 113993 | | - /* 202 */ "expr ::= expr EQ|NE expr", |
| 113994 | | - /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 113995 | | - /* 204 */ "expr ::= expr PLUS|MINUS expr", |
| 113996 | | - /* 205 */ "expr ::= expr STAR|SLASH|REM expr", |
| 113997 | | - /* 206 */ "expr ::= expr CONCAT expr", |
| 113998 | | - /* 207 */ "likeop ::= LIKE_KW", |
| 113999 | | - /* 208 */ "likeop ::= NOT LIKE_KW", |
| 114000 | | - /* 209 */ "likeop ::= MATCH", |
| 114001 | | - /* 210 */ "likeop ::= NOT MATCH", |
| 114002 | | - /* 211 */ "expr ::= expr likeop expr", |
| 114003 | | - /* 212 */ "expr ::= expr likeop expr ESCAPE expr", |
| 114004 | | - /* 213 */ "expr ::= expr ISNULL|NOTNULL", |
| 114005 | | - /* 214 */ "expr ::= expr NOT NULL", |
| 114006 | | - /* 215 */ "expr ::= expr IS expr", |
| 114007 | | - /* 216 */ "expr ::= expr IS NOT expr", |
| 114008 | | - /* 217 */ "expr ::= NOT expr", |
| 114009 | | - /* 218 */ "expr ::= BITNOT expr", |
| 114010 | | - /* 219 */ "expr ::= MINUS expr", |
| 114011 | | - /* 220 */ "expr ::= PLUS expr", |
| 114012 | | - /* 221 */ "between_op ::= BETWEEN", |
| 114013 | | - /* 222 */ "between_op ::= NOT BETWEEN", |
| 114014 | | - /* 223 */ "expr ::= expr between_op expr AND expr", |
| 114015 | | - /* 224 */ "in_op ::= IN", |
| 114016 | | - /* 225 */ "in_op ::= NOT IN", |
| 114017 | | - /* 226 */ "expr ::= expr in_op LP exprlist RP", |
| 114018 | | - /* 227 */ "expr ::= LP select RP", |
| 114019 | | - /* 228 */ "expr ::= expr in_op LP select RP", |
| 114020 | | - /* 229 */ "expr ::= expr in_op nm dbnm", |
| 114021 | | - /* 230 */ "expr ::= EXISTS LP select RP", |
| 114022 | | - /* 231 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 114023 | | - /* 232 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 114024 | | - /* 233 */ "case_exprlist ::= WHEN expr THEN expr", |
| 114025 | | - /* 234 */ "case_else ::= ELSE expr", |
| 114026 | | - /* 235 */ "case_else ::=", |
| 114027 | | - /* 236 */ "case_operand ::= expr", |
| 114028 | | - /* 237 */ "case_operand ::=", |
| 114029 | | - /* 238 */ "exprlist ::= nexprlist", |
| 114030 | | - /* 239 */ "exprlist ::=", |
| 114031 | | - /* 240 */ "nexprlist ::= nexprlist COMMA expr", |
| 114032 | | - /* 241 */ "nexprlist ::= expr", |
| 114033 | | - /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt", |
| 114034 | | - /* 243 */ "uniqueflag ::= UNIQUE", |
| 114035 | | - /* 244 */ "uniqueflag ::=", |
| 114036 | | - /* 245 */ "idxlist_opt ::=", |
| 114037 | | - /* 246 */ "idxlist_opt ::= LP idxlist RP", |
| 114038 | | - /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder", |
| 114039 | | - /* 248 */ "idxlist ::= nm collate sortorder", |
| 114040 | | - /* 249 */ "collate ::=", |
| 114041 | | - /* 250 */ "collate ::= COLLATE ids", |
| 114042 | | - /* 251 */ "cmd ::= DROP INDEX ifexists fullname", |
| 114043 | | - /* 252 */ "cmd ::= VACUUM", |
| 114044 | | - /* 253 */ "cmd ::= VACUUM nm", |
| 114045 | | - /* 254 */ "cmd ::= PRAGMA nm dbnm", |
| 114046 | | - /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 114047 | | - /* 256 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 114048 | | - /* 257 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 114049 | | - /* 258 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 114050 | | - /* 259 */ "nmnum ::= plus_num", |
| 114051 | | - /* 260 */ "nmnum ::= nm", |
| 114052 | | - /* 261 */ "nmnum ::= ON", |
| 114053 | | - /* 262 */ "nmnum ::= DELETE", |
| 114054 | | - /* 263 */ "nmnum ::= DEFAULT", |
| 114055 | | - /* 264 */ "plus_num ::= PLUS number", |
| 114056 | | - /* 265 */ "plus_num ::= number", |
| 114057 | | - /* 266 */ "minus_num ::= MINUS number", |
| 114058 | | - /* 267 */ "number ::= INTEGER|FLOAT", |
| 114059 | | - /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 114060 | | - /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 114061 | | - /* 270 */ "trigger_time ::= BEFORE", |
| 114062 | | - /* 271 */ "trigger_time ::= AFTER", |
| 114063 | | - /* 272 */ "trigger_time ::= INSTEAD OF", |
| 114064 | | - /* 273 */ "trigger_time ::=", |
| 114065 | | - /* 274 */ "trigger_event ::= DELETE|INSERT", |
| 114066 | | - /* 275 */ "trigger_event ::= UPDATE", |
| 114067 | | - /* 276 */ "trigger_event ::= UPDATE OF inscollist", |
| 114068 | | - /* 277 */ "foreach_clause ::=", |
| 114069 | | - /* 278 */ "foreach_clause ::= FOR EACH ROW", |
| 114070 | | - /* 279 */ "when_clause ::=", |
| 114071 | | - /* 280 */ "when_clause ::= WHEN expr", |
| 114072 | | - /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 114073 | | - /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 114074 | | - /* 283 */ "trnm ::= nm", |
| 114075 | | - /* 284 */ "trnm ::= nm DOT nm", |
| 114076 | | - /* 285 */ "tridxby ::=", |
| 114077 | | - /* 286 */ "tridxby ::= INDEXED BY nm", |
| 114078 | | - /* 287 */ "tridxby ::= NOT INDEXED", |
| 114079 | | - /* 288 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 114080 | | - /* 289 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist", |
| 114081 | | - /* 290 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select", |
| 114082 | | - /* 291 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 114083 | | - /* 292 */ "trigger_cmd ::= select", |
| 114084 | | - /* 293 */ "expr ::= RAISE LP IGNORE RP", |
| 114085 | | - /* 294 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 114086 | | - /* 295 */ "raisetype ::= ROLLBACK", |
| 114087 | | - /* 296 */ "raisetype ::= ABORT", |
| 114088 | | - /* 297 */ "raisetype ::= FAIL", |
| 114089 | | - /* 298 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 114090 | | - /* 299 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 114091 | | - /* 300 */ "cmd ::= DETACH database_kw_opt expr", |
| 114092 | | - /* 301 */ "key_opt ::=", |
| 114093 | | - /* 302 */ "key_opt ::= KEY expr", |
| 114094 | | - /* 303 */ "database_kw_opt ::= DATABASE", |
| 114095 | | - /* 304 */ "database_kw_opt ::=", |
| 114096 | | - /* 305 */ "cmd ::= REINDEX", |
| 114097 | | - /* 306 */ "cmd ::= REINDEX nm dbnm", |
| 114098 | | - /* 307 */ "cmd ::= ANALYZE", |
| 114099 | | - /* 308 */ "cmd ::= ANALYZE nm dbnm", |
| 114100 | | - /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 114101 | | - /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column", |
| 114102 | | - /* 311 */ "add_column_fullname ::= fullname", |
| 114103 | | - /* 312 */ "kwcolumn_opt ::=", |
| 114104 | | - /* 313 */ "kwcolumn_opt ::= COLUMNKW", |
| 114105 | | - /* 314 */ "cmd ::= create_vtab", |
| 114106 | | - /* 315 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 114107 | | - /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 114108 | | - /* 317 */ "vtabarglist ::= vtabarg", |
| 114109 | | - /* 318 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 114110 | | - /* 319 */ "vtabarg ::=", |
| 114111 | | - /* 320 */ "vtabarg ::= vtabarg vtabargtoken", |
| 114112 | | - /* 321 */ "vtabargtoken ::= ANY", |
| 114113 | | - /* 322 */ "vtabargtoken ::= lp anylist RP", |
| 114114 | | - /* 323 */ "lp ::= LP", |
| 114115 | | - /* 324 */ "anylist ::=", |
| 114116 | | - /* 325 */ "anylist ::= anylist LP anylist RP", |
| 114117 | | - /* 326 */ "anylist ::= anylist ANY", |
| 115191 | + /* 34 */ "table_options ::=", |
| 115192 | + /* 35 */ "table_options ::= WITHOUT nm", |
| 115193 | + /* 36 */ "columnlist ::= columnlist COMMA column", |
| 115194 | + /* 37 */ "columnlist ::= column", |
| 115195 | + /* 38 */ "column ::= columnid type carglist", |
| 115196 | + /* 39 */ "columnid ::= nm", |
| 115197 | + /* 40 */ "id ::= ID", |
| 115198 | + /* 41 */ "id ::= INDEXED", |
| 115199 | + /* 42 */ "ids ::= ID|STRING", |
| 115200 | + /* 43 */ "nm ::= id", |
| 115201 | + /* 44 */ "nm ::= STRING", |
| 115202 | + /* 45 */ "nm ::= JOIN_KW", |
| 115203 | + /* 46 */ "type ::=", |
| 115204 | + /* 47 */ "type ::= typetoken", |
| 115205 | + /* 48 */ "typetoken ::= typename", |
| 115206 | + /* 49 */ "typetoken ::= typename LP signed RP", |
| 115207 | + /* 50 */ "typetoken ::= typename LP signed COMMA signed RP", |
| 115208 | + /* 51 */ "typename ::= ids", |
| 115209 | + /* 52 */ "typename ::= typename ids", |
| 115210 | + /* 53 */ "signed ::= plus_num", |
| 115211 | + /* 54 */ "signed ::= minus_num", |
| 115212 | + /* 55 */ "carglist ::= carglist ccons", |
| 115213 | + /* 56 */ "carglist ::=", |
| 115214 | + /* 57 */ "ccons ::= CONSTRAINT nm", |
| 115215 | + /* 58 */ "ccons ::= DEFAULT term", |
| 115216 | + /* 59 */ "ccons ::= DEFAULT LP expr RP", |
| 115217 | + /* 60 */ "ccons ::= DEFAULT PLUS term", |
| 115218 | + /* 61 */ "ccons ::= DEFAULT MINUS term", |
| 115219 | + /* 62 */ "ccons ::= DEFAULT id", |
| 115220 | + /* 63 */ "ccons ::= NULL onconf", |
| 115221 | + /* 64 */ "ccons ::= NOT NULL onconf", |
| 115222 | + /* 65 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc", |
| 115223 | + /* 66 */ "ccons ::= UNIQUE onconf", |
| 115224 | + /* 67 */ "ccons ::= CHECK LP expr RP", |
| 115225 | + /* 68 */ "ccons ::= REFERENCES nm idxlist_opt refargs", |
| 115226 | + /* 69 */ "ccons ::= defer_subclause", |
| 115227 | + /* 70 */ "ccons ::= COLLATE ids", |
| 115228 | + /* 71 */ "autoinc ::=", |
| 115229 | + /* 72 */ "autoinc ::= AUTOINCR", |
| 115230 | + /* 73 */ "refargs ::=", |
| 115231 | + /* 74 */ "refargs ::= refargs refarg", |
| 115232 | + /* 75 */ "refarg ::= MATCH nm", |
| 115233 | + /* 76 */ "refarg ::= ON INSERT refact", |
| 115234 | + /* 77 */ "refarg ::= ON DELETE refact", |
| 115235 | + /* 78 */ "refarg ::= ON UPDATE refact", |
| 115236 | + /* 79 */ "refact ::= SET NULL", |
| 115237 | + /* 80 */ "refact ::= SET DEFAULT", |
| 115238 | + /* 81 */ "refact ::= CASCADE", |
| 115239 | + /* 82 */ "refact ::= RESTRICT", |
| 115240 | + /* 83 */ "refact ::= NO ACTION", |
| 115241 | + /* 84 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", |
| 115242 | + /* 85 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", |
| 115243 | + /* 86 */ "init_deferred_pred_opt ::=", |
| 115244 | + /* 87 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", |
| 115245 | + /* 88 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", |
| 115246 | + /* 89 */ "conslist_opt ::=", |
| 115247 | + /* 90 */ "conslist_opt ::= COMMA conslist", |
| 115248 | + /* 91 */ "conslist ::= conslist tconscomma tcons", |
| 115249 | + /* 92 */ "conslist ::= tcons", |
| 115250 | + /* 93 */ "tconscomma ::= COMMA", |
| 115251 | + /* 94 */ "tconscomma ::=", |
| 115252 | + /* 95 */ "tcons ::= CONSTRAINT nm", |
| 115253 | + /* 96 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf", |
| 115254 | + /* 97 */ "tcons ::= UNIQUE LP idxlist RP onconf", |
| 115255 | + /* 98 */ "tcons ::= CHECK LP expr RP onconf", |
| 115256 | + /* 99 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt", |
| 115257 | + /* 100 */ "defer_subclause_opt ::=", |
| 115258 | + /* 101 */ "defer_subclause_opt ::= defer_subclause", |
| 115259 | + /* 102 */ "onconf ::=", |
| 115260 | + /* 103 */ "onconf ::= ON CONFLICT resolvetype", |
| 115261 | + /* 104 */ "orconf ::=", |
| 115262 | + /* 105 */ "orconf ::= OR resolvetype", |
| 115263 | + /* 106 */ "resolvetype ::= raisetype", |
| 115264 | + /* 107 */ "resolvetype ::= IGNORE", |
| 115265 | + /* 108 */ "resolvetype ::= REPLACE", |
| 115266 | + /* 109 */ "cmd ::= DROP TABLE ifexists fullname", |
| 115267 | + /* 110 */ "ifexists ::= IF EXISTS", |
| 115268 | + /* 111 */ "ifexists ::=", |
| 115269 | + /* 112 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select", |
| 115270 | + /* 113 */ "cmd ::= DROP VIEW ifexists fullname", |
| 115271 | + /* 114 */ "cmd ::= select", |
| 115272 | + /* 115 */ "select ::= oneselect", |
| 115273 | + /* 116 */ "select ::= select multiselect_op oneselect", |
| 115274 | + /* 117 */ "multiselect_op ::= UNION", |
| 115275 | + /* 118 */ "multiselect_op ::= UNION ALL", |
| 115276 | + /* 119 */ "multiselect_op ::= EXCEPT|INTERSECT", |
| 115277 | + /* 120 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", |
| 115278 | + /* 121 */ "distinct ::= DISTINCT", |
| 115279 | + /* 122 */ "distinct ::= ALL", |
| 115280 | + /* 123 */ "distinct ::=", |
| 115281 | + /* 124 */ "sclp ::= selcollist COMMA", |
| 115282 | + /* 125 */ "sclp ::=", |
| 115283 | + /* 126 */ "selcollist ::= sclp expr as", |
| 115284 | + /* 127 */ "selcollist ::= sclp STAR", |
| 115285 | + /* 128 */ "selcollist ::= sclp nm DOT STAR", |
| 115286 | + /* 129 */ "as ::= AS nm", |
| 115287 | + /* 130 */ "as ::= ids", |
| 115288 | + /* 131 */ "as ::=", |
| 115289 | + /* 132 */ "from ::=", |
| 115290 | + /* 133 */ "from ::= FROM seltablist", |
| 115291 | + /* 134 */ "stl_prefix ::= seltablist joinop", |
| 115292 | + /* 135 */ "stl_prefix ::=", |
| 115293 | + /* 136 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", |
| 115294 | + /* 137 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 115295 | + /* 138 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 115296 | + /* 139 */ "dbnm ::=", |
| 115297 | + /* 140 */ "dbnm ::= DOT nm", |
| 115298 | + /* 141 */ "fullname ::= nm dbnm", |
| 115299 | + /* 142 */ "joinop ::= COMMA|JOIN", |
| 115300 | + /* 143 */ "joinop ::= JOIN_KW JOIN", |
| 115301 | + /* 144 */ "joinop ::= JOIN_KW nm JOIN", |
| 115302 | + /* 145 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 115303 | + /* 146 */ "on_opt ::= ON expr", |
| 115304 | + /* 147 */ "on_opt ::=", |
| 115305 | + /* 148 */ "indexed_opt ::=", |
| 115306 | + /* 149 */ "indexed_opt ::= INDEXED BY nm", |
| 115307 | + /* 150 */ "indexed_opt ::= NOT INDEXED", |
| 115308 | + /* 151 */ "using_opt ::= USING LP idlist RP", |
| 115309 | + /* 152 */ "using_opt ::=", |
| 115310 | + /* 153 */ "orderby_opt ::=", |
| 115311 | + /* 154 */ "orderby_opt ::= ORDER BY sortlist", |
| 115312 | + /* 155 */ "sortlist ::= sortlist COMMA expr sortorder", |
| 115313 | + /* 156 */ "sortlist ::= expr sortorder", |
| 115314 | + /* 157 */ "sortorder ::= ASC", |
| 115315 | + /* 158 */ "sortorder ::= DESC", |
| 115316 | + /* 159 */ "sortorder ::=", |
| 115317 | + /* 160 */ "groupby_opt ::=", |
| 115318 | + /* 161 */ "groupby_opt ::= GROUP BY nexprlist", |
| 115319 | + /* 162 */ "having_opt ::=", |
| 115320 | + /* 163 */ "having_opt ::= HAVING expr", |
| 115321 | + /* 164 */ "limit_opt ::=", |
| 115322 | + /* 165 */ "limit_opt ::= LIMIT expr", |
| 115323 | + /* 166 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 115324 | + /* 167 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 115325 | + /* 168 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt", |
| 115326 | + /* 169 */ "where_opt ::=", |
| 115327 | + /* 170 */ "where_opt ::= WHERE expr", |
| 115328 | + /* 171 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt", |
| 115329 | + /* 172 */ "setlist ::= setlist COMMA nm EQ expr", |
| 115330 | + /* 173 */ "setlist ::= nm EQ expr", |
| 115331 | + /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist", |
| 115332 | + /* 175 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select", |
| 115333 | + /* 176 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES", |
| 115334 | + /* 177 */ "insert_cmd ::= INSERT orconf", |
| 115335 | + /* 178 */ "insert_cmd ::= REPLACE", |
| 115336 | + /* 179 */ "valuelist ::= VALUES LP nexprlist RP", |
| 115337 | + /* 180 */ "valuelist ::= valuelist COMMA LP exprlist RP", |
| 115338 | + /* 181 */ "inscollist_opt ::=", |
| 115339 | + /* 182 */ "inscollist_opt ::= LP idlist RP", |
| 115340 | + /* 183 */ "idlist ::= idlist COMMA nm", |
| 115341 | + /* 184 */ "idlist ::= nm", |
| 115342 | + /* 185 */ "expr ::= term", |
| 115343 | + /* 186 */ "expr ::= LP expr RP", |
| 115344 | + /* 187 */ "term ::= NULL", |
| 115345 | + /* 188 */ "expr ::= id", |
| 115346 | + /* 189 */ "expr ::= JOIN_KW", |
| 115347 | + /* 190 */ "expr ::= nm DOT nm", |
| 115348 | + /* 191 */ "expr ::= nm DOT nm DOT nm", |
| 115349 | + /* 192 */ "term ::= INTEGER|FLOAT|BLOB", |
| 115350 | + /* 193 */ "term ::= STRING", |
| 115351 | + /* 194 */ "expr ::= REGISTER", |
| 115352 | + /* 195 */ "expr ::= VARIABLE", |
| 115353 | + /* 196 */ "expr ::= expr COLLATE ids", |
| 115354 | + /* 197 */ "expr ::= CAST LP expr AS typetoken RP", |
| 115355 | + /* 198 */ "expr ::= ID LP distinct exprlist RP", |
| 115356 | + /* 199 */ "expr ::= ID LP STAR RP", |
| 115357 | + /* 200 */ "term ::= CTIME_KW", |
| 115358 | + /* 201 */ "expr ::= expr AND expr", |
| 115359 | + /* 202 */ "expr ::= expr OR expr", |
| 115360 | + /* 203 */ "expr ::= expr LT|GT|GE|LE expr", |
| 115361 | + /* 204 */ "expr ::= expr EQ|NE expr", |
| 115362 | + /* 205 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 115363 | + /* 206 */ "expr ::= expr PLUS|MINUS expr", |
| 115364 | + /* 207 */ "expr ::= expr STAR|SLASH|REM expr", |
| 115365 | + /* 208 */ "expr ::= expr CONCAT expr", |
| 115366 | + /* 209 */ "likeop ::= LIKE_KW", |
| 115367 | + /* 210 */ "likeop ::= NOT LIKE_KW", |
| 115368 | + /* 211 */ "likeop ::= MATCH", |
| 115369 | + /* 212 */ "likeop ::= NOT MATCH", |
| 115370 | + /* 213 */ "expr ::= expr likeop expr", |
| 115371 | + /* 214 */ "expr ::= expr likeop expr ESCAPE expr", |
| 115372 | + /* 215 */ "expr ::= expr ISNULL|NOTNULL", |
| 115373 | + /* 216 */ "expr ::= expr NOT NULL", |
| 115374 | + /* 217 */ "expr ::= expr IS expr", |
| 115375 | + /* 218 */ "expr ::= expr IS NOT expr", |
| 115376 | + /* 219 */ "expr ::= NOT expr", |
| 115377 | + /* 220 */ "expr ::= BITNOT expr", |
| 115378 | + /* 221 */ "expr ::= MINUS expr", |
| 115379 | + /* 222 */ "expr ::= PLUS expr", |
| 115380 | + /* 223 */ "between_op ::= BETWEEN", |
| 115381 | + /* 224 */ "between_op ::= NOT BETWEEN", |
| 115382 | + /* 225 */ "expr ::= expr between_op expr AND expr", |
| 115383 | + /* 226 */ "in_op ::= IN", |
| 115384 | + /* 227 */ "in_op ::= NOT IN", |
| 115385 | + /* 228 */ "expr ::= expr in_op LP exprlist RP", |
| 115386 | + /* 229 */ "expr ::= LP select RP", |
| 115387 | + /* 230 */ "expr ::= expr in_op LP select RP", |
| 115388 | + /* 231 */ "expr ::= expr in_op nm dbnm", |
| 115389 | + /* 232 */ "expr ::= EXISTS LP select RP", |
| 115390 | + /* 233 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 115391 | + /* 234 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 115392 | + /* 235 */ "case_exprlist ::= WHEN expr THEN expr", |
| 115393 | + /* 236 */ "case_else ::= ELSE expr", |
| 115394 | + /* 237 */ "case_else ::=", |
| 115395 | + /* 238 */ "case_operand ::= expr", |
| 115396 | + /* 239 */ "case_operand ::=", |
| 115397 | + /* 240 */ "exprlist ::= nexprlist", |
| 115398 | + /* 241 */ "exprlist ::=", |
| 115399 | + /* 242 */ "nexprlist ::= nexprlist COMMA expr", |
| 115400 | + /* 243 */ "nexprlist ::= expr", |
| 115401 | + /* 244 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt", |
| 115402 | + /* 245 */ "uniqueflag ::= UNIQUE", |
| 115403 | + /* 246 */ "uniqueflag ::=", |
| 115404 | + /* 247 */ "idxlist_opt ::=", |
| 115405 | + /* 248 */ "idxlist_opt ::= LP idxlist RP", |
| 115406 | + /* 249 */ "idxlist ::= idxlist COMMA nm collate sortorder", |
| 115407 | + /* 250 */ "idxlist ::= nm collate sortorder", |
| 115408 | + /* 251 */ "collate ::=", |
| 115409 | + /* 252 */ "collate ::= COLLATE ids", |
| 115410 | + /* 253 */ "cmd ::= DROP INDEX ifexists fullname", |
| 115411 | + /* 254 */ "cmd ::= VACUUM", |
| 115412 | + /* 255 */ "cmd ::= VACUUM nm", |
| 115413 | + /* 256 */ "cmd ::= PRAGMA nm dbnm", |
| 115414 | + /* 257 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 115415 | + /* 258 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 115416 | + /* 259 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 115417 | + /* 260 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 115418 | + /* 261 */ "nmnum ::= plus_num", |
| 115419 | + /* 262 */ "nmnum ::= nm", |
| 115420 | + /* 263 */ "nmnum ::= ON", |
| 115421 | + /* 264 */ "nmnum ::= DELETE", |
| 115422 | + /* 265 */ "nmnum ::= DEFAULT", |
| 115423 | + /* 266 */ "plus_num ::= PLUS number", |
| 115424 | + /* 267 */ "plus_num ::= number", |
| 115425 | + /* 268 */ "minus_num ::= MINUS number", |
| 115426 | + /* 269 */ "number ::= INTEGER|FLOAT", |
| 115427 | + /* 270 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 115428 | + /* 271 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 115429 | + /* 272 */ "trigger_time ::= BEFORE", |
| 115430 | + /* 273 */ "trigger_time ::= AFTER", |
| 115431 | + /* 274 */ "trigger_time ::= INSTEAD OF", |
| 115432 | + /* 275 */ "trigger_time ::=", |
| 115433 | + /* 276 */ "trigger_event ::= DELETE|INSERT", |
| 115434 | + /* 277 */ "trigger_event ::= UPDATE", |
| 115435 | + /* 278 */ "trigger_event ::= UPDATE OF idlist", |
| 115436 | + /* 279 */ "foreach_clause ::=", |
| 115437 | + /* 280 */ "foreach_clause ::= FOR EACH ROW", |
| 115438 | + /* 281 */ "when_clause ::=", |
| 115439 | + /* 282 */ "when_clause ::= WHEN expr", |
| 115440 | + /* 283 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 115441 | + /* 284 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 115442 | + /* 285 */ "trnm ::= nm", |
| 115443 | + /* 286 */ "trnm ::= nm DOT nm", |
| 115444 | + /* 287 */ "tridxby ::=", |
| 115445 | + /* 288 */ "tridxby ::= INDEXED BY nm", |
| 115446 | + /* 289 */ "tridxby ::= NOT INDEXED", |
| 115447 | + /* 290 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 115448 | + /* 291 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist", |
| 115449 | + /* 292 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select", |
| 115450 | + /* 293 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 115451 | + /* 294 */ "trigger_cmd ::= select", |
| 115452 | + /* 295 */ "expr ::= RAISE LP IGNORE RP", |
| 115453 | + /* 296 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 115454 | + /* 297 */ "raisetype ::= ROLLBACK", |
| 115455 | + /* 298 */ "raisetype ::= ABORT", |
| 115456 | + /* 299 */ "raisetype ::= FAIL", |
| 115457 | + /* 300 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 115458 | + /* 301 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 115459 | + /* 302 */ "cmd ::= DETACH database_kw_opt expr", |
| 115460 | + /* 303 */ "key_opt ::=", |
| 115461 | + /* 304 */ "key_opt ::= KEY expr", |
| 115462 | + /* 305 */ "database_kw_opt ::= DATABASE", |
| 115463 | + /* 306 */ "database_kw_opt ::=", |
| 115464 | + /* 307 */ "cmd ::= REINDEX", |
| 115465 | + /* 308 */ "cmd ::= REINDEX nm dbnm", |
| 115466 | + /* 309 */ "cmd ::= ANALYZE", |
| 115467 | + /* 310 */ "cmd ::= ANALYZE nm dbnm", |
| 115468 | + /* 311 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 115469 | + /* 312 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column", |
| 115470 | + /* 313 */ "add_column_fullname ::= fullname", |
| 115471 | + /* 314 */ "kwcolumn_opt ::=", |
| 115472 | + /* 315 */ "kwcolumn_opt ::= COLUMNKW", |
| 115473 | + /* 316 */ "cmd ::= create_vtab", |
| 115474 | + /* 317 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 115475 | + /* 318 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 115476 | + /* 319 */ "vtabarglist ::= vtabarg", |
| 115477 | + /* 320 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 115478 | + /* 321 */ "vtabarg ::=", |
| 115479 | + /* 322 */ "vtabarg ::= vtabarg vtabargtoken", |
| 115480 | + /* 323 */ "vtabargtoken ::= ANY", |
| 115481 | + /* 324 */ "vtabargtoken ::= lp anylist RP", |
| 115482 | + /* 325 */ "lp ::= LP", |
| 115483 | + /* 326 */ "anylist ::=", |
| 115484 | + /* 327 */ "anylist ::= anylist LP anylist RP", |
| 115485 | + /* 328 */ "anylist ::= anylist ANY", |
| 114118 | 115486 | }; |
| 114119 | 115487 | #endif /* NDEBUG */ |
| 114120 | 115488 | |
| 114121 | 115489 | |
| 114122 | 115490 | #if YYSTACKDEPTH<=0 |
| | @@ -114191,80 +115559,80 @@ |
| 114191 | 115559 | ** |
| 114192 | 115560 | ** Note: during a reduce, the only symbols destroyed are those |
| 114193 | 115561 | ** which appear on the RHS of the rule, but which are not used |
| 114194 | 115562 | ** inside the C code. |
| 114195 | 115563 | */ |
| 114196 | | - case 160: /* select */ |
| 114197 | | - case 194: /* oneselect */ |
| 114198 | | -{ |
| 114199 | | -sqlite3SelectDelete(pParse->db, (yypminor->yy159)); |
| 114200 | | -} |
| 114201 | | - break; |
| 114202 | | - case 173: /* term */ |
| 114203 | | - case 174: /* expr */ |
| 114204 | | -{ |
| 114205 | | -sqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr); |
| 114206 | | -} |
| 114207 | | - break; |
| 114208 | | - case 178: /* idxlist_opt */ |
| 114209 | | - case 187: /* idxlist */ |
| 114210 | | - case 197: /* selcollist */ |
| 114211 | | - case 200: /* groupby_opt */ |
| 114212 | | - case 202: /* orderby_opt */ |
| 114213 | | - case 204: /* sclp */ |
| 114214 | | - case 214: /* sortlist */ |
| 114215 | | - case 215: /* nexprlist */ |
| 114216 | | - case 216: /* setlist */ |
| 114217 | | - case 220: /* exprlist */ |
| 114218 | | - case 225: /* case_exprlist */ |
| 114219 | | -{ |
| 114220 | | -sqlite3ExprListDelete(pParse->db, (yypminor->yy442)); |
| 114221 | | -} |
| 114222 | | - break; |
| 114223 | | - case 193: /* fullname */ |
| 114224 | | - case 198: /* from */ |
| 114225 | | - case 206: /* seltablist */ |
| 114226 | | - case 207: /* stl_prefix */ |
| 114227 | | -{ |
| 114228 | | -sqlite3SrcListDelete(pParse->db, (yypminor->yy347)); |
| 114229 | | -} |
| 114230 | | - break; |
| 114231 | | - case 199: /* where_opt */ |
| 114232 | | - case 201: /* having_opt */ |
| 114233 | | - case 210: /* on_opt */ |
| 114234 | | - case 224: /* case_operand */ |
| 114235 | | - case 226: /* case_else */ |
| 114236 | | - case 236: /* when_clause */ |
| 114237 | | - case 241: /* key_opt */ |
| 114238 | | -{ |
| 114239 | | -sqlite3ExprDelete(pParse->db, (yypminor->yy122)); |
| 114240 | | -} |
| 114241 | | - break; |
| 114242 | | - case 211: /* using_opt */ |
| 114243 | | - case 213: /* inscollist */ |
| 114244 | | - case 218: /* inscollist_opt */ |
| 114245 | | -{ |
| 114246 | | -sqlite3IdListDelete(pParse->db, (yypminor->yy180)); |
| 114247 | | -} |
| 114248 | | - break; |
| 114249 | | - case 219: /* valuelist */ |
| 114250 | | -{ |
| 114251 | | - |
| 114252 | | - sqlite3ExprListDelete(pParse->db, (yypminor->yy487).pList); |
| 114253 | | - sqlite3SelectDelete(pParse->db, (yypminor->yy487).pSelect); |
| 114254 | | - |
| 114255 | | -} |
| 114256 | | - break; |
| 114257 | | - case 232: /* trigger_cmd_list */ |
| 114258 | | - case 237: /* trigger_cmd */ |
| 114259 | | -{ |
| 114260 | | -sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy327)); |
| 114261 | | -} |
| 114262 | | - break; |
| 114263 | | - case 234: /* trigger_event */ |
| 114264 | | -{ |
| 114265 | | -sqlite3IdListDelete(pParse->db, (yypminor->yy410).b); |
| 115564 | + case 162: /* select */ |
| 115565 | + case 196: /* oneselect */ |
| 115566 | +{ |
| 115567 | +sqlite3SelectDelete(pParse->db, (yypminor->yy387)); |
| 115568 | +} |
| 115569 | + break; |
| 115570 | + case 175: /* term */ |
| 115571 | + case 176: /* expr */ |
| 115572 | +{ |
| 115573 | +sqlite3ExprDelete(pParse->db, (yypminor->yy118).pExpr); |
| 115574 | +} |
| 115575 | + break; |
| 115576 | + case 180: /* idxlist_opt */ |
| 115577 | + case 189: /* idxlist */ |
| 115578 | + case 199: /* selcollist */ |
| 115579 | + case 202: /* groupby_opt */ |
| 115580 | + case 204: /* orderby_opt */ |
| 115581 | + case 206: /* sclp */ |
| 115582 | + case 216: /* sortlist */ |
| 115583 | + case 217: /* nexprlist */ |
| 115584 | + case 218: /* setlist */ |
| 115585 | + case 222: /* exprlist */ |
| 115586 | + case 227: /* case_exprlist */ |
| 115587 | +{ |
| 115588 | +sqlite3ExprListDelete(pParse->db, (yypminor->yy322)); |
| 115589 | +} |
| 115590 | + break; |
| 115591 | + case 195: /* fullname */ |
| 115592 | + case 200: /* from */ |
| 115593 | + case 208: /* seltablist */ |
| 115594 | + case 209: /* stl_prefix */ |
| 115595 | +{ |
| 115596 | +sqlite3SrcListDelete(pParse->db, (yypminor->yy259)); |
| 115597 | +} |
| 115598 | + break; |
| 115599 | + case 201: /* where_opt */ |
| 115600 | + case 203: /* having_opt */ |
| 115601 | + case 212: /* on_opt */ |
| 115602 | + case 226: /* case_operand */ |
| 115603 | + case 228: /* case_else */ |
| 115604 | + case 238: /* when_clause */ |
| 115605 | + case 243: /* key_opt */ |
| 115606 | +{ |
| 115607 | +sqlite3ExprDelete(pParse->db, (yypminor->yy314)); |
| 115608 | +} |
| 115609 | + break; |
| 115610 | + case 213: /* using_opt */ |
| 115611 | + case 215: /* idlist */ |
| 115612 | + case 220: /* inscollist_opt */ |
| 115613 | +{ |
| 115614 | +sqlite3IdListDelete(pParse->db, (yypminor->yy384)); |
| 115615 | +} |
| 115616 | + break; |
| 115617 | + case 221: /* valuelist */ |
| 115618 | +{ |
| 115619 | + |
| 115620 | + sqlite3ExprListDelete(pParse->db, (yypminor->yy260).pList); |
| 115621 | + sqlite3SelectDelete(pParse->db, (yypminor->yy260).pSelect); |
| 115622 | + |
| 115623 | +} |
| 115624 | + break; |
| 115625 | + case 234: /* trigger_cmd_list */ |
| 115626 | + case 239: /* trigger_cmd */ |
| 115627 | +{ |
| 115628 | +sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203)); |
| 115629 | +} |
| 115630 | + break; |
| 115631 | + case 236: /* trigger_event */ |
| 115632 | +{ |
| 115633 | +sqlite3IdListDelete(pParse->db, (yypminor->yy90).b); |
| 114266 | 115634 | } |
| 114267 | 115635 | break; |
| 114268 | 115636 | default: break; /* If no destructor action specified: do nothing */ |
| 114269 | 115637 | } |
| 114270 | 115638 | } |
| | @@ -114505,337 +115873,339 @@ |
| 114505 | 115873 | */ |
| 114506 | 115874 | static const struct { |
| 114507 | 115875 | YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ |
| 114508 | 115876 | unsigned char nrhs; /* Number of right-hand side symbols in the rule */ |
| 114509 | 115877 | } yyRuleInfo[] = { |
| 114510 | | - { 142, 1 }, |
| 114511 | | - { 143, 2 }, |
| 114512 | | - { 143, 1 }, |
| 114513 | | - { 144, 1 }, |
| 114514 | | - { 144, 3 }, |
| 114515 | | - { 145, 0 }, |
| 114516 | | - { 145, 1 }, |
| 114517 | | - { 145, 3 }, |
| 114518 | | - { 146, 1 }, |
| 114519 | | - { 147, 3 }, |
| 114520 | | - { 149, 0 }, |
| 114521 | | - { 149, 1 }, |
| 114522 | | - { 149, 2 }, |
| 114523 | | - { 148, 0 }, |
| 114524 | | - { 148, 1 }, |
| 114525 | | - { 148, 1 }, |
| 114526 | | - { 148, 1 }, |
| 114527 | | - { 147, 2 }, |
| 114528 | | - { 147, 2 }, |
| 114529 | | - { 147, 2 }, |
| 114530 | | - { 151, 1 }, |
| 114531 | | - { 151, 0 }, |
| 114532 | | - { 147, 2 }, |
| 114533 | | - { 147, 3 }, |
| 114534 | | - { 147, 5 }, |
| 114535 | | - { 147, 2 }, |
| 114536 | | - { 152, 6 }, |
| 114537 | | - { 154, 1 }, |
| 114538 | | - { 156, 0 }, |
| 114539 | | - { 156, 3 }, |
| 114540 | | - { 155, 1 }, |
| 114541 | | - { 155, 0 }, |
| 114542 | | - { 153, 4 }, |
| 114543 | | - { 153, 2 }, |
| 114544 | | - { 158, 3 }, |
| 114545 | | - { 158, 1 }, |
| 114546 | | - { 161, 3 }, |
| 114547 | | - { 162, 1 }, |
| 114548 | | - { 165, 1 }, |
| 114549 | | - { 165, 1 }, |
| 114550 | | - { 166, 1 }, |
| 114551 | | - { 150, 1 }, |
| 114552 | | - { 150, 1 }, |
| 114553 | | - { 150, 1 }, |
| 114554 | | - { 163, 0 }, |
| 114555 | | - { 163, 1 }, |
| 114556 | | - { 167, 1 }, |
| 114557 | | - { 167, 4 }, |
| 114558 | | - { 167, 6 }, |
| 114559 | | - { 168, 1 }, |
| 114560 | | - { 168, 2 }, |
| 114561 | | - { 169, 1 }, |
| 114562 | | - { 169, 1 }, |
| 114563 | | - { 164, 2 }, |
| 114564 | | - { 164, 0 }, |
| 114565 | | - { 172, 2 }, |
| 114566 | | - { 172, 2 }, |
| 114567 | | - { 172, 4 }, |
| 114568 | | - { 172, 3 }, |
| 114569 | | - { 172, 3 }, |
| 114570 | | - { 172, 2 }, |
| 114571 | | - { 172, 2 }, |
| 114572 | | - { 172, 3 }, |
| 114573 | | - { 172, 5 }, |
| 114574 | | - { 172, 2 }, |
| 114575 | | - { 172, 4 }, |
| 114576 | | - { 172, 4 }, |
| 114577 | | - { 172, 1 }, |
| 114578 | | - { 172, 2 }, |
| 114579 | | - { 177, 0 }, |
| 114580 | | - { 177, 1 }, |
| 114581 | | - { 179, 0 }, |
| 114582 | | - { 179, 2 }, |
| 114583 | | - { 181, 2 }, |
| 114584 | | - { 181, 3 }, |
| 114585 | | - { 181, 3 }, |
| 114586 | | - { 181, 3 }, |
| 114587 | | - { 182, 2 }, |
| 114588 | | - { 182, 2 }, |
| 114589 | | - { 182, 1 }, |
| 114590 | | - { 182, 1 }, |
| 114591 | | - { 182, 2 }, |
| 114592 | | - { 180, 3 }, |
| 114593 | | - { 180, 2 }, |
| 114594 | | - { 183, 0 }, |
| 114595 | | - { 183, 2 }, |
| 114596 | | - { 183, 2 }, |
| 114597 | | - { 159, 0 }, |
| 114598 | | - { 159, 2 }, |
| 114599 | | - { 184, 3 }, |
| 114600 | | - { 184, 1 }, |
| 114601 | | - { 185, 1 }, |
| 114602 | | - { 185, 0 }, |
| 114603 | | - { 186, 2 }, |
| 114604 | | - { 186, 7 }, |
| 114605 | | - { 186, 5 }, |
| 114606 | | - { 186, 5 }, |
| 114607 | | - { 186, 10 }, |
| 114608 | | - { 188, 0 }, |
| 114609 | | - { 188, 1 }, |
| 114610 | | - { 175, 0 }, |
| 114611 | | - { 175, 3 }, |
| 114612 | | - { 189, 0 }, |
| 114613 | | - { 189, 2 }, |
| 114614 | | - { 190, 1 }, |
| 114615 | | - { 190, 1 }, |
| 114616 | | - { 190, 1 }, |
| 114617 | | - { 147, 4 }, |
| 114618 | | - { 192, 2 }, |
| 114619 | | - { 192, 0 }, |
| 114620 | | - { 147, 8 }, |
| 114621 | | - { 147, 4 }, |
| 114622 | | - { 147, 1 }, |
| 114623 | | - { 160, 1 }, |
| 114624 | | - { 160, 3 }, |
| 114625 | | - { 195, 1 }, |
| 114626 | | - { 195, 2 }, |
| 114627 | | - { 195, 1 }, |
| 114628 | | - { 194, 9 }, |
| 114629 | | - { 196, 1 }, |
| 114630 | | - { 196, 1 }, |
| 114631 | | - { 196, 0 }, |
| 114632 | | - { 204, 2 }, |
| 114633 | | - { 204, 0 }, |
| 114634 | | - { 197, 3 }, |
| 114635 | | - { 197, 2 }, |
| 114636 | | - { 197, 4 }, |
| 114637 | | - { 205, 2 }, |
| 114638 | | - { 205, 1 }, |
| 114639 | | - { 205, 0 }, |
| 114640 | | - { 198, 0 }, |
| 114641 | | - { 198, 2 }, |
| 114642 | | - { 207, 2 }, |
| 114643 | | - { 207, 0 }, |
| 114644 | | - { 206, 7 }, |
| 114645 | | - { 206, 7 }, |
| 114646 | | - { 206, 7 }, |
| 114647 | | - { 157, 0 }, |
| 114648 | | - { 157, 2 }, |
| 114649 | | - { 193, 2 }, |
| 114650 | | - { 208, 1 }, |
| 114651 | | - { 208, 2 }, |
| 114652 | | - { 208, 3 }, |
| 114653 | | - { 208, 4 }, |
| 114654 | | - { 210, 2 }, |
| 114655 | | - { 210, 0 }, |
| 114656 | | - { 209, 0 }, |
| 114657 | | - { 209, 3 }, |
| 114658 | | - { 209, 2 }, |
| 114659 | | - { 211, 4 }, |
| 114660 | | - { 211, 0 }, |
| 114661 | | - { 202, 0 }, |
| 114662 | | - { 202, 3 }, |
| 114663 | | - { 214, 4 }, |
| 114664 | | - { 214, 2 }, |
| 114665 | | - { 176, 1 }, |
| 114666 | | - { 176, 1 }, |
| 114667 | | - { 176, 0 }, |
| 114668 | | - { 200, 0 }, |
| 114669 | | - { 200, 3 }, |
| 114670 | | - { 201, 0 }, |
| 114671 | | - { 201, 2 }, |
| 114672 | | - { 203, 0 }, |
| 114673 | | - { 203, 2 }, |
| 114674 | | - { 203, 4 }, |
| 114675 | | - { 203, 4 }, |
| 114676 | | - { 147, 5 }, |
| 114677 | | - { 199, 0 }, |
| 114678 | | - { 199, 2 }, |
| 114679 | | - { 147, 7 }, |
| 114680 | | - { 216, 5 }, |
| 114681 | | - { 216, 3 }, |
| 114682 | | - { 147, 5 }, |
| 114683 | | - { 147, 5 }, |
| 114684 | | - { 147, 6 }, |
| 114685 | | - { 217, 2 }, |
| 114686 | | - { 217, 1 }, |
| 114687 | | - { 219, 4 }, |
| 114688 | | - { 219, 5 }, |
| 114689 | | - { 218, 0 }, |
| 114690 | | - { 218, 3 }, |
| 114691 | | - { 213, 3 }, |
| 114692 | | - { 213, 1 }, |
| 114693 | | - { 174, 1 }, |
| 114694 | | - { 174, 3 }, |
| 114695 | | - { 173, 1 }, |
| 114696 | | - { 174, 1 }, |
| 114697 | | - { 174, 1 }, |
| 114698 | | - { 174, 3 }, |
| 114699 | | - { 174, 5 }, |
| 114700 | | - { 173, 1 }, |
| 114701 | | - { 173, 1 }, |
| 114702 | | - { 174, 1 }, |
| 114703 | | - { 174, 1 }, |
| 114704 | | - { 174, 3 }, |
| 114705 | | - { 174, 6 }, |
| 114706 | | - { 174, 5 }, |
| 114707 | | - { 174, 4 }, |
| 114708 | | - { 173, 1 }, |
| 114709 | | - { 174, 3 }, |
| 114710 | | - { 174, 3 }, |
| 114711 | | - { 174, 3 }, |
| 114712 | | - { 174, 3 }, |
| 114713 | | - { 174, 3 }, |
| 114714 | | - { 174, 3 }, |
| 114715 | | - { 174, 3 }, |
| 114716 | | - { 174, 3 }, |
| 114717 | | - { 221, 1 }, |
| 114718 | | - { 221, 2 }, |
| 114719 | | - { 221, 1 }, |
| 114720 | | - { 221, 2 }, |
| 114721 | | - { 174, 3 }, |
| 114722 | | - { 174, 5 }, |
| 114723 | | - { 174, 2 }, |
| 114724 | | - { 174, 3 }, |
| 114725 | | - { 174, 3 }, |
| 114726 | | - { 174, 4 }, |
| 114727 | | - { 174, 2 }, |
| 114728 | | - { 174, 2 }, |
| 114729 | | - { 174, 2 }, |
| 114730 | | - { 174, 2 }, |
| 114731 | | - { 222, 1 }, |
| 114732 | | - { 222, 2 }, |
| 114733 | | - { 174, 5 }, |
| 114734 | | - { 223, 1 }, |
| 114735 | | - { 223, 2 }, |
| 114736 | | - { 174, 5 }, |
| 114737 | | - { 174, 3 }, |
| 114738 | | - { 174, 5 }, |
| 114739 | | - { 174, 4 }, |
| 114740 | | - { 174, 4 }, |
| 114741 | | - { 174, 5 }, |
| 114742 | | - { 225, 5 }, |
| 114743 | | - { 225, 4 }, |
| 114744 | | - { 226, 2 }, |
| 114745 | | - { 226, 0 }, |
| 114746 | | - { 224, 1 }, |
| 114747 | | - { 224, 0 }, |
| 114748 | | - { 220, 1 }, |
| 114749 | | - { 220, 0 }, |
| 114750 | | - { 215, 3 }, |
| 114751 | | - { 215, 1 }, |
| 114752 | | - { 147, 12 }, |
| 114753 | | - { 227, 1 }, |
| 114754 | | - { 227, 0 }, |
| 114755 | | - { 178, 0 }, |
| 114756 | | - { 178, 3 }, |
| 114757 | | - { 187, 5 }, |
| 114758 | | - { 187, 3 }, |
| 114759 | | - { 228, 0 }, |
| 114760 | | - { 228, 2 }, |
| 114761 | | - { 147, 4 }, |
| 114762 | | - { 147, 1 }, |
| 114763 | | - { 147, 2 }, |
| 114764 | | - { 147, 3 }, |
| 114765 | | - { 147, 5 }, |
| 114766 | | - { 147, 6 }, |
| 114767 | | - { 147, 5 }, |
| 114768 | | - { 147, 6 }, |
| 114769 | | - { 229, 1 }, |
| 114770 | | - { 229, 1 }, |
| 114771 | | - { 229, 1 }, |
| 114772 | | - { 229, 1 }, |
| 114773 | | - { 229, 1 }, |
| 114774 | | - { 170, 2 }, |
| 114775 | | - { 170, 1 }, |
| 114776 | | - { 171, 2 }, |
| 114777 | | - { 230, 1 }, |
| 114778 | | - { 147, 5 }, |
| 114779 | | - { 231, 11 }, |
| 114780 | | - { 233, 1 }, |
| 114781 | | - { 233, 1 }, |
| 114782 | | - { 233, 2 }, |
| 114783 | | - { 233, 0 }, |
| 114784 | | - { 234, 1 }, |
| 114785 | | - { 234, 1 }, |
| 114786 | | - { 234, 3 }, |
| 114787 | | - { 235, 0 }, |
| 114788 | | - { 235, 3 }, |
| 114789 | | - { 236, 0 }, |
| 114790 | | - { 236, 2 }, |
| 114791 | | - { 232, 3 }, |
| 114792 | | - { 232, 2 }, |
| 114793 | | - { 238, 1 }, |
| 114794 | | - { 238, 3 }, |
| 114795 | | - { 239, 0 }, |
| 114796 | | - { 239, 3 }, |
| 114797 | | - { 239, 2 }, |
| 114798 | | - { 237, 7 }, |
| 114799 | | - { 237, 5 }, |
| 114800 | | - { 237, 5 }, |
| 114801 | | - { 237, 5 }, |
| 114802 | | - { 237, 1 }, |
| 114803 | | - { 174, 4 }, |
| 114804 | | - { 174, 6 }, |
| 114805 | | - { 191, 1 }, |
| 114806 | | - { 191, 1 }, |
| 114807 | | - { 191, 1 }, |
| 114808 | | - { 147, 4 }, |
| 114809 | | - { 147, 6 }, |
| 114810 | | - { 147, 3 }, |
| 114811 | | - { 241, 0 }, |
| 114812 | | - { 241, 2 }, |
| 114813 | | - { 240, 1 }, |
| 114814 | | - { 240, 0 }, |
| 114815 | | - { 147, 1 }, |
| 114816 | | - { 147, 3 }, |
| 114817 | | - { 147, 1 }, |
| 114818 | | - { 147, 3 }, |
| 114819 | | - { 147, 6 }, |
| 114820 | | - { 147, 6 }, |
| 114821 | | - { 242, 1 }, |
| 114822 | | - { 243, 0 }, |
| 114823 | | - { 243, 1 }, |
| 114824 | | - { 147, 1 }, |
| 114825 | | - { 147, 4 }, |
| 114826 | | - { 244, 8 }, |
| 114827 | | - { 245, 1 }, |
| 114828 | | - { 245, 3 }, |
| 114829 | | - { 246, 0 }, |
| 114830 | | - { 246, 2 }, |
| 114831 | | - { 247, 1 }, |
| 114832 | | - { 247, 3 }, |
| 114833 | | - { 248, 1 }, |
| 114834 | | - { 249, 0 }, |
| 114835 | | - { 249, 4 }, |
| 114836 | | - { 249, 2 }, |
| 115878 | + { 143, 1 }, |
| 115879 | + { 144, 2 }, |
| 115880 | + { 144, 1 }, |
| 115881 | + { 145, 1 }, |
| 115882 | + { 145, 3 }, |
| 115883 | + { 146, 0 }, |
| 115884 | + { 146, 1 }, |
| 115885 | + { 146, 3 }, |
| 115886 | + { 147, 1 }, |
| 115887 | + { 148, 3 }, |
| 115888 | + { 150, 0 }, |
| 115889 | + { 150, 1 }, |
| 115890 | + { 150, 2 }, |
| 115891 | + { 149, 0 }, |
| 115892 | + { 149, 1 }, |
| 115893 | + { 149, 1 }, |
| 115894 | + { 149, 1 }, |
| 115895 | + { 148, 2 }, |
| 115896 | + { 148, 2 }, |
| 115897 | + { 148, 2 }, |
| 115898 | + { 152, 1 }, |
| 115899 | + { 152, 0 }, |
| 115900 | + { 148, 2 }, |
| 115901 | + { 148, 3 }, |
| 115902 | + { 148, 5 }, |
| 115903 | + { 148, 2 }, |
| 115904 | + { 153, 6 }, |
| 115905 | + { 155, 1 }, |
| 115906 | + { 157, 0 }, |
| 115907 | + { 157, 3 }, |
| 115908 | + { 156, 1 }, |
| 115909 | + { 156, 0 }, |
| 115910 | + { 154, 5 }, |
| 115911 | + { 154, 2 }, |
| 115912 | + { 161, 0 }, |
| 115913 | + { 161, 2 }, |
| 115914 | + { 159, 3 }, |
| 115915 | + { 159, 1 }, |
| 115916 | + { 163, 3 }, |
| 115917 | + { 164, 1 }, |
| 115918 | + { 167, 1 }, |
| 115919 | + { 167, 1 }, |
| 115920 | + { 168, 1 }, |
| 115921 | + { 151, 1 }, |
| 115922 | + { 151, 1 }, |
| 115923 | + { 151, 1 }, |
| 115924 | + { 165, 0 }, |
| 115925 | + { 165, 1 }, |
| 115926 | + { 169, 1 }, |
| 115927 | + { 169, 4 }, |
| 115928 | + { 169, 6 }, |
| 115929 | + { 170, 1 }, |
| 115930 | + { 170, 2 }, |
| 115931 | + { 171, 1 }, |
| 115932 | + { 171, 1 }, |
| 115933 | + { 166, 2 }, |
| 115934 | + { 166, 0 }, |
| 115935 | + { 174, 2 }, |
| 115936 | + { 174, 2 }, |
| 115937 | + { 174, 4 }, |
| 115938 | + { 174, 3 }, |
| 115939 | + { 174, 3 }, |
| 115940 | + { 174, 2 }, |
| 115941 | + { 174, 2 }, |
| 115942 | + { 174, 3 }, |
| 115943 | + { 174, 5 }, |
| 115944 | + { 174, 2 }, |
| 115945 | + { 174, 4 }, |
| 115946 | + { 174, 4 }, |
| 115947 | + { 174, 1 }, |
| 115948 | + { 174, 2 }, |
| 115949 | + { 179, 0 }, |
| 115950 | + { 179, 1 }, |
| 115951 | + { 181, 0 }, |
| 115952 | + { 181, 2 }, |
| 115953 | + { 183, 2 }, |
| 115954 | + { 183, 3 }, |
| 115955 | + { 183, 3 }, |
| 115956 | + { 183, 3 }, |
| 115957 | + { 184, 2 }, |
| 115958 | + { 184, 2 }, |
| 115959 | + { 184, 1 }, |
| 115960 | + { 184, 1 }, |
| 115961 | + { 184, 2 }, |
| 115962 | + { 182, 3 }, |
| 115963 | + { 182, 2 }, |
| 115964 | + { 185, 0 }, |
| 115965 | + { 185, 2 }, |
| 115966 | + { 185, 2 }, |
| 115967 | + { 160, 0 }, |
| 115968 | + { 160, 2 }, |
| 115969 | + { 186, 3 }, |
| 115970 | + { 186, 1 }, |
| 115971 | + { 187, 1 }, |
| 115972 | + { 187, 0 }, |
| 115973 | + { 188, 2 }, |
| 115974 | + { 188, 7 }, |
| 115975 | + { 188, 5 }, |
| 115976 | + { 188, 5 }, |
| 115977 | + { 188, 10 }, |
| 115978 | + { 190, 0 }, |
| 115979 | + { 190, 1 }, |
| 115980 | + { 177, 0 }, |
| 115981 | + { 177, 3 }, |
| 115982 | + { 191, 0 }, |
| 115983 | + { 191, 2 }, |
| 115984 | + { 192, 1 }, |
| 115985 | + { 192, 1 }, |
| 115986 | + { 192, 1 }, |
| 115987 | + { 148, 4 }, |
| 115988 | + { 194, 2 }, |
| 115989 | + { 194, 0 }, |
| 115990 | + { 148, 8 }, |
| 115991 | + { 148, 4 }, |
| 115992 | + { 148, 1 }, |
| 115993 | + { 162, 1 }, |
| 115994 | + { 162, 3 }, |
| 115995 | + { 197, 1 }, |
| 115996 | + { 197, 2 }, |
| 115997 | + { 197, 1 }, |
| 115998 | + { 196, 9 }, |
| 115999 | + { 198, 1 }, |
| 116000 | + { 198, 1 }, |
| 116001 | + { 198, 0 }, |
| 116002 | + { 206, 2 }, |
| 116003 | + { 206, 0 }, |
| 116004 | + { 199, 3 }, |
| 116005 | + { 199, 2 }, |
| 116006 | + { 199, 4 }, |
| 116007 | + { 207, 2 }, |
| 116008 | + { 207, 1 }, |
| 116009 | + { 207, 0 }, |
| 116010 | + { 200, 0 }, |
| 116011 | + { 200, 2 }, |
| 116012 | + { 209, 2 }, |
| 116013 | + { 209, 0 }, |
| 116014 | + { 208, 7 }, |
| 116015 | + { 208, 7 }, |
| 116016 | + { 208, 7 }, |
| 116017 | + { 158, 0 }, |
| 116018 | + { 158, 2 }, |
| 116019 | + { 195, 2 }, |
| 116020 | + { 210, 1 }, |
| 116021 | + { 210, 2 }, |
| 116022 | + { 210, 3 }, |
| 116023 | + { 210, 4 }, |
| 116024 | + { 212, 2 }, |
| 116025 | + { 212, 0 }, |
| 116026 | + { 211, 0 }, |
| 116027 | + { 211, 3 }, |
| 116028 | + { 211, 2 }, |
| 116029 | + { 213, 4 }, |
| 116030 | + { 213, 0 }, |
| 116031 | + { 204, 0 }, |
| 116032 | + { 204, 3 }, |
| 116033 | + { 216, 4 }, |
| 116034 | + { 216, 2 }, |
| 116035 | + { 178, 1 }, |
| 116036 | + { 178, 1 }, |
| 116037 | + { 178, 0 }, |
| 116038 | + { 202, 0 }, |
| 116039 | + { 202, 3 }, |
| 116040 | + { 203, 0 }, |
| 116041 | + { 203, 2 }, |
| 116042 | + { 205, 0 }, |
| 116043 | + { 205, 2 }, |
| 116044 | + { 205, 4 }, |
| 116045 | + { 205, 4 }, |
| 116046 | + { 148, 5 }, |
| 116047 | + { 201, 0 }, |
| 116048 | + { 201, 2 }, |
| 116049 | + { 148, 7 }, |
| 116050 | + { 218, 5 }, |
| 116051 | + { 218, 3 }, |
| 116052 | + { 148, 5 }, |
| 116053 | + { 148, 5 }, |
| 116054 | + { 148, 6 }, |
| 116055 | + { 219, 2 }, |
| 116056 | + { 219, 1 }, |
| 116057 | + { 221, 4 }, |
| 116058 | + { 221, 5 }, |
| 116059 | + { 220, 0 }, |
| 116060 | + { 220, 3 }, |
| 116061 | + { 215, 3 }, |
| 116062 | + { 215, 1 }, |
| 116063 | + { 176, 1 }, |
| 116064 | + { 176, 3 }, |
| 116065 | + { 175, 1 }, |
| 116066 | + { 176, 1 }, |
| 116067 | + { 176, 1 }, |
| 116068 | + { 176, 3 }, |
| 116069 | + { 176, 5 }, |
| 116070 | + { 175, 1 }, |
| 116071 | + { 175, 1 }, |
| 116072 | + { 176, 1 }, |
| 116073 | + { 176, 1 }, |
| 116074 | + { 176, 3 }, |
| 116075 | + { 176, 6 }, |
| 116076 | + { 176, 5 }, |
| 116077 | + { 176, 4 }, |
| 116078 | + { 175, 1 }, |
| 116079 | + { 176, 3 }, |
| 116080 | + { 176, 3 }, |
| 116081 | + { 176, 3 }, |
| 116082 | + { 176, 3 }, |
| 116083 | + { 176, 3 }, |
| 116084 | + { 176, 3 }, |
| 116085 | + { 176, 3 }, |
| 116086 | + { 176, 3 }, |
| 116087 | + { 223, 1 }, |
| 116088 | + { 223, 2 }, |
| 116089 | + { 223, 1 }, |
| 116090 | + { 223, 2 }, |
| 116091 | + { 176, 3 }, |
| 116092 | + { 176, 5 }, |
| 116093 | + { 176, 2 }, |
| 116094 | + { 176, 3 }, |
| 116095 | + { 176, 3 }, |
| 116096 | + { 176, 4 }, |
| 116097 | + { 176, 2 }, |
| 116098 | + { 176, 2 }, |
| 116099 | + { 176, 2 }, |
| 116100 | + { 176, 2 }, |
| 116101 | + { 224, 1 }, |
| 116102 | + { 224, 2 }, |
| 116103 | + { 176, 5 }, |
| 116104 | + { 225, 1 }, |
| 116105 | + { 225, 2 }, |
| 116106 | + { 176, 5 }, |
| 116107 | + { 176, 3 }, |
| 116108 | + { 176, 5 }, |
| 116109 | + { 176, 4 }, |
| 116110 | + { 176, 4 }, |
| 116111 | + { 176, 5 }, |
| 116112 | + { 227, 5 }, |
| 116113 | + { 227, 4 }, |
| 116114 | + { 228, 2 }, |
| 116115 | + { 228, 0 }, |
| 116116 | + { 226, 1 }, |
| 116117 | + { 226, 0 }, |
| 116118 | + { 222, 1 }, |
| 116119 | + { 222, 0 }, |
| 116120 | + { 217, 3 }, |
| 116121 | + { 217, 1 }, |
| 116122 | + { 148, 12 }, |
| 116123 | + { 229, 1 }, |
| 116124 | + { 229, 0 }, |
| 116125 | + { 180, 0 }, |
| 116126 | + { 180, 3 }, |
| 116127 | + { 189, 5 }, |
| 116128 | + { 189, 3 }, |
| 116129 | + { 230, 0 }, |
| 116130 | + { 230, 2 }, |
| 116131 | + { 148, 4 }, |
| 116132 | + { 148, 1 }, |
| 116133 | + { 148, 2 }, |
| 116134 | + { 148, 3 }, |
| 116135 | + { 148, 5 }, |
| 116136 | + { 148, 6 }, |
| 116137 | + { 148, 5 }, |
| 116138 | + { 148, 6 }, |
| 116139 | + { 231, 1 }, |
| 116140 | + { 231, 1 }, |
| 116141 | + { 231, 1 }, |
| 116142 | + { 231, 1 }, |
| 116143 | + { 231, 1 }, |
| 116144 | + { 172, 2 }, |
| 116145 | + { 172, 1 }, |
| 116146 | + { 173, 2 }, |
| 116147 | + { 232, 1 }, |
| 116148 | + { 148, 5 }, |
| 116149 | + { 233, 11 }, |
| 116150 | + { 235, 1 }, |
| 116151 | + { 235, 1 }, |
| 116152 | + { 235, 2 }, |
| 116153 | + { 235, 0 }, |
| 116154 | + { 236, 1 }, |
| 116155 | + { 236, 1 }, |
| 116156 | + { 236, 3 }, |
| 116157 | + { 237, 0 }, |
| 116158 | + { 237, 3 }, |
| 116159 | + { 238, 0 }, |
| 116160 | + { 238, 2 }, |
| 116161 | + { 234, 3 }, |
| 116162 | + { 234, 2 }, |
| 116163 | + { 240, 1 }, |
| 116164 | + { 240, 3 }, |
| 116165 | + { 241, 0 }, |
| 116166 | + { 241, 3 }, |
| 116167 | + { 241, 2 }, |
| 116168 | + { 239, 7 }, |
| 116169 | + { 239, 5 }, |
| 116170 | + { 239, 5 }, |
| 116171 | + { 239, 5 }, |
| 116172 | + { 239, 1 }, |
| 116173 | + { 176, 4 }, |
| 116174 | + { 176, 6 }, |
| 116175 | + { 193, 1 }, |
| 116176 | + { 193, 1 }, |
| 116177 | + { 193, 1 }, |
| 116178 | + { 148, 4 }, |
| 116179 | + { 148, 6 }, |
| 116180 | + { 148, 3 }, |
| 116181 | + { 243, 0 }, |
| 116182 | + { 243, 2 }, |
| 116183 | + { 242, 1 }, |
| 116184 | + { 242, 0 }, |
| 116185 | + { 148, 1 }, |
| 116186 | + { 148, 3 }, |
| 116187 | + { 148, 1 }, |
| 116188 | + { 148, 3 }, |
| 116189 | + { 148, 6 }, |
| 116190 | + { 148, 6 }, |
| 116191 | + { 244, 1 }, |
| 116192 | + { 245, 0 }, |
| 116193 | + { 245, 1 }, |
| 116194 | + { 148, 1 }, |
| 116195 | + { 148, 4 }, |
| 116196 | + { 246, 8 }, |
| 116197 | + { 247, 1 }, |
| 116198 | + { 247, 3 }, |
| 116199 | + { 248, 0 }, |
| 116200 | + { 248, 2 }, |
| 116201 | + { 249, 1 }, |
| 116202 | + { 249, 3 }, |
| 116203 | + { 250, 1 }, |
| 116204 | + { 251, 0 }, |
| 116205 | + { 251, 4 }, |
| 116206 | + { 251, 2 }, |
| 114837 | 116207 | }; |
| 114838 | 116208 | |
| 114839 | 116209 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| 114840 | 116210 | |
| 114841 | 116211 | /* |
| | @@ -114899,21 +116269,21 @@ |
| 114899 | 116269 | break; |
| 114900 | 116270 | case 8: /* cmdx ::= cmd */ |
| 114901 | 116271 | { sqlite3FinishCoding(pParse); } |
| 114902 | 116272 | break; |
| 114903 | 116273 | case 9: /* cmd ::= BEGIN transtype trans_opt */ |
| 114904 | | -{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy392);} |
| 116274 | +{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);} |
| 114905 | 116275 | break; |
| 114906 | 116276 | case 13: /* transtype ::= */ |
| 114907 | | -{yygotominor.yy392 = TK_DEFERRED;} |
| 116277 | +{yygotominor.yy4 = TK_DEFERRED;} |
| 114908 | 116278 | break; |
| 114909 | 116279 | case 14: /* transtype ::= DEFERRED */ |
| 114910 | 116280 | case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15); |
| 114911 | 116281 | case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16); |
| 114912 | | - case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115); |
| 114913 | | - case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117); |
| 114914 | | -{yygotominor.yy392 = yymsp[0].major;} |
| 116282 | + case 117: /* multiselect_op ::= UNION */ yytestcase(yyruleno==117); |
| 116283 | + case 119: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==119); |
| 116284 | +{yygotominor.yy4 = yymsp[0].major;} |
| 114915 | 116285 | break; |
| 114916 | 116286 | case 17: /* cmd ::= COMMIT trans_opt */ |
| 114917 | 116287 | case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18); |
| 114918 | 116288 | {sqlite3CommitTransaction(pParse);} |
| 114919 | 116289 | break; |
| | @@ -114935,11 +116305,11 @@ |
| 114935 | 116305 | sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); |
| 114936 | 116306 | } |
| 114937 | 116307 | break; |
| 114938 | 116308 | case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 114939 | 116309 | { |
| 114940 | | - sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy392,0,0,yymsp[-2].minor.yy392); |
| 116310 | + sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4); |
| 114941 | 116311 | } |
| 114942 | 116312 | break; |
| 114943 | 116313 | case 27: /* createkw ::= CREATE */ |
| 114944 | 116314 | { |
| 114945 | 116315 | pParse->db->lookaside.bEnabled = 0; |
| | @@ -114946,1051 +116316,1064 @@ |
| 114946 | 116316 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 114947 | 116317 | } |
| 114948 | 116318 | break; |
| 114949 | 116319 | case 28: /* ifnotexists ::= */ |
| 114950 | 116320 | case 31: /* temp ::= */ yytestcase(yyruleno==31); |
| 114951 | | - case 69: /* autoinc ::= */ yytestcase(yyruleno==69); |
| 114952 | | - case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82); |
| 114953 | | - case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84); |
| 114954 | | - case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86); |
| 114955 | | - case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98); |
| 114956 | | - case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 114957 | | - case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221); |
| 114958 | | - case 224: /* in_op ::= IN */ yytestcase(yyruleno==224); |
| 114959 | | -{yygotominor.yy392 = 0;} |
| 116321 | + case 71: /* autoinc ::= */ yytestcase(yyruleno==71); |
| 116322 | + case 84: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==84); |
| 116323 | + case 86: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==86); |
| 116324 | + case 88: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==88); |
| 116325 | + case 100: /* defer_subclause_opt ::= */ yytestcase(yyruleno==100); |
| 116326 | + case 111: /* ifexists ::= */ yytestcase(yyruleno==111); |
| 116327 | + case 223: /* between_op ::= BETWEEN */ yytestcase(yyruleno==223); |
| 116328 | + case 226: /* in_op ::= IN */ yytestcase(yyruleno==226); |
| 116329 | +{yygotominor.yy4 = 0;} |
| 114960 | 116330 | break; |
| 114961 | 116331 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 114962 | 116332 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 114963 | | - case 70: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==70); |
| 114964 | | - case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85); |
| 114965 | | - case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 114966 | | - case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222); |
| 114967 | | - case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225); |
| 114968 | | -{yygotominor.yy392 = 1;} |
| 116333 | + case 72: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==72); |
| 116334 | + case 87: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==87); |
| 116335 | + case 110: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==110); |
| 116336 | + case 224: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==224); |
| 116337 | + case 227: /* in_op ::= NOT IN */ yytestcase(yyruleno==227); |
| 116338 | +{yygotominor.yy4 = 1;} |
| 114969 | 116339 | break; |
| 114970 | | - case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| 116340 | + case 32: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 114971 | 116341 | { |
| 114972 | | - sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); |
| 116342 | + sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy210,0); |
| 114973 | 116343 | } |
| 114974 | 116344 | break; |
| 114975 | 116345 | case 33: /* create_table_args ::= AS select */ |
| 114976 | 116346 | { |
| 114977 | | - sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy159); |
| 114978 | | - sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159); |
| 116347 | + sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy387); |
| 116348 | + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 114979 | 116349 | } |
| 114980 | 116350 | break; |
| 114981 | | - case 36: /* column ::= columnid type carglist */ |
| 116351 | + case 34: /* table_options ::= */ |
| 116352 | +{yygotominor.yy210 = 0;} |
| 116353 | + break; |
| 116354 | + case 35: /* table_options ::= WITHOUT nm */ |
| 116355 | +{ |
| 116356 | + if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ |
| 116357 | + yygotominor.yy210 = TF_WithoutRowid; |
| 116358 | + }else{ |
| 116359 | + yygotominor.yy210 = 0; |
| 116360 | + sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 116361 | + } |
| 116362 | +} |
| 116363 | + break; |
| 116364 | + case 38: /* column ::= columnid type carglist */ |
| 114982 | 116365 | { |
| 114983 | 116366 | yygotominor.yy0.z = yymsp[-2].minor.yy0.z; |
| 114984 | 116367 | yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n; |
| 114985 | 116368 | } |
| 114986 | 116369 | break; |
| 114987 | | - case 37: /* columnid ::= nm */ |
| 116370 | + case 39: /* columnid ::= nm */ |
| 114988 | 116371 | { |
| 114989 | 116372 | sqlite3AddColumn(pParse,&yymsp[0].minor.yy0); |
| 114990 | 116373 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 114991 | 116374 | pParse->constraintName.n = 0; |
| 114992 | 116375 | } |
| 114993 | 116376 | break; |
| 114994 | | - case 38: /* id ::= ID */ |
| 114995 | | - case 39: /* id ::= INDEXED */ yytestcase(yyruleno==39); |
| 114996 | | - case 40: /* ids ::= ID|STRING */ yytestcase(yyruleno==40); |
| 114997 | | - case 41: /* nm ::= id */ yytestcase(yyruleno==41); |
| 114998 | | - case 42: /* nm ::= STRING */ yytestcase(yyruleno==42); |
| 114999 | | - case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43); |
| 115000 | | - case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46); |
| 115001 | | - case 49: /* typename ::= ids */ yytestcase(yyruleno==49); |
| 115002 | | - case 127: /* as ::= AS nm */ yytestcase(yyruleno==127); |
| 115003 | | - case 128: /* as ::= ids */ yytestcase(yyruleno==128); |
| 115004 | | - case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138); |
| 115005 | | - case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147); |
| 115006 | | - case 250: /* collate ::= COLLATE ids */ yytestcase(yyruleno==250); |
| 115007 | | - case 259: /* nmnum ::= plus_num */ yytestcase(yyruleno==259); |
| 115008 | | - case 260: /* nmnum ::= nm */ yytestcase(yyruleno==260); |
| 115009 | | - case 261: /* nmnum ::= ON */ yytestcase(yyruleno==261); |
| 115010 | | - case 262: /* nmnum ::= DELETE */ yytestcase(yyruleno==262); |
| 115011 | | - case 263: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==263); |
| 115012 | | - case 264: /* plus_num ::= PLUS number */ yytestcase(yyruleno==264); |
| 115013 | | - case 265: /* plus_num ::= number */ yytestcase(yyruleno==265); |
| 115014 | | - case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266); |
| 115015 | | - case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267); |
| 115016 | | - case 283: /* trnm ::= nm */ yytestcase(yyruleno==283); |
| 116377 | + case 40: /* id ::= ID */ |
| 116378 | + case 41: /* id ::= INDEXED */ yytestcase(yyruleno==41); |
| 116379 | + case 42: /* ids ::= ID|STRING */ yytestcase(yyruleno==42); |
| 116380 | + case 43: /* nm ::= id */ yytestcase(yyruleno==43); |
| 116381 | + case 44: /* nm ::= STRING */ yytestcase(yyruleno==44); |
| 116382 | + case 45: /* nm ::= JOIN_KW */ yytestcase(yyruleno==45); |
| 116383 | + case 48: /* typetoken ::= typename */ yytestcase(yyruleno==48); |
| 116384 | + case 51: /* typename ::= ids */ yytestcase(yyruleno==51); |
| 116385 | + case 129: /* as ::= AS nm */ yytestcase(yyruleno==129); |
| 116386 | + case 130: /* as ::= ids */ yytestcase(yyruleno==130); |
| 116387 | + case 140: /* dbnm ::= DOT nm */ yytestcase(yyruleno==140); |
| 116388 | + case 149: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==149); |
| 116389 | + case 252: /* collate ::= COLLATE ids */ yytestcase(yyruleno==252); |
| 116390 | + case 261: /* nmnum ::= plus_num */ yytestcase(yyruleno==261); |
| 116391 | + case 262: /* nmnum ::= nm */ yytestcase(yyruleno==262); |
| 116392 | + case 263: /* nmnum ::= ON */ yytestcase(yyruleno==263); |
| 116393 | + case 264: /* nmnum ::= DELETE */ yytestcase(yyruleno==264); |
| 116394 | + case 265: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==265); |
| 116395 | + case 266: /* plus_num ::= PLUS number */ yytestcase(yyruleno==266); |
| 116396 | + case 267: /* plus_num ::= number */ yytestcase(yyruleno==267); |
| 116397 | + case 268: /* minus_num ::= MINUS number */ yytestcase(yyruleno==268); |
| 116398 | + case 269: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==269); |
| 116399 | + case 285: /* trnm ::= nm */ yytestcase(yyruleno==285); |
| 115017 | 116400 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 115018 | 116401 | break; |
| 115019 | | - case 45: /* type ::= typetoken */ |
| 116402 | + case 47: /* type ::= typetoken */ |
| 115020 | 116403 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 115021 | 116404 | break; |
| 115022 | | - case 47: /* typetoken ::= typename LP signed RP */ |
| 116405 | + case 49: /* typetoken ::= typename LP signed RP */ |
| 115023 | 116406 | { |
| 115024 | 116407 | yygotominor.yy0.z = yymsp[-3].minor.yy0.z; |
| 115025 | 116408 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); |
| 115026 | 116409 | } |
| 115027 | 116410 | break; |
| 115028 | | - case 48: /* typetoken ::= typename LP signed COMMA signed RP */ |
| 116411 | + case 50: /* typetoken ::= typename LP signed COMMA signed RP */ |
| 115029 | 116412 | { |
| 115030 | 116413 | yygotominor.yy0.z = yymsp[-5].minor.yy0.z; |
| 115031 | 116414 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); |
| 115032 | 116415 | } |
| 115033 | 116416 | break; |
| 115034 | | - case 50: /* typename ::= typename ids */ |
| 116417 | + case 52: /* typename ::= typename ids */ |
| 115035 | 116418 | {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 115036 | 116419 | break; |
| 115037 | | - case 55: /* ccons ::= CONSTRAINT nm */ |
| 115038 | | - case 93: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93); |
| 116420 | + case 57: /* ccons ::= CONSTRAINT nm */ |
| 116421 | + case 95: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==95); |
| 115039 | 116422 | {pParse->constraintName = yymsp[0].minor.yy0;} |
| 115040 | 116423 | break; |
| 115041 | | - case 56: /* ccons ::= DEFAULT term */ |
| 115042 | | - case 58: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==58); |
| 115043 | | -{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);} |
| 115044 | | - break; |
| 115045 | | - case 57: /* ccons ::= DEFAULT LP expr RP */ |
| 115046 | | -{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy342);} |
| 115047 | | - break; |
| 115048 | | - case 59: /* ccons ::= DEFAULT MINUS term */ |
| 116424 | + case 58: /* ccons ::= DEFAULT term */ |
| 116425 | + case 60: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==60); |
| 116426 | +{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy118);} |
| 116427 | + break; |
| 116428 | + case 59: /* ccons ::= DEFAULT LP expr RP */ |
| 116429 | +{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy118);} |
| 116430 | + break; |
| 116431 | + case 61: /* ccons ::= DEFAULT MINUS term */ |
| 115049 | 116432 | { |
| 115050 | 116433 | ExprSpan v; |
| 115051 | | - v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0); |
| 116434 | + v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0); |
| 115052 | 116435 | v.zStart = yymsp[-1].minor.yy0.z; |
| 115053 | | - v.zEnd = yymsp[0].minor.yy342.zEnd; |
| 116436 | + v.zEnd = yymsp[0].minor.yy118.zEnd; |
| 115054 | 116437 | sqlite3AddDefaultValue(pParse,&v); |
| 115055 | 116438 | } |
| 115056 | 116439 | break; |
| 115057 | | - case 60: /* ccons ::= DEFAULT id */ |
| 116440 | + case 62: /* ccons ::= DEFAULT id */ |
| 115058 | 116441 | { |
| 115059 | 116442 | ExprSpan v; |
| 115060 | 116443 | spanExpr(&v, pParse, TK_STRING, &yymsp[0].minor.yy0); |
| 115061 | 116444 | sqlite3AddDefaultValue(pParse,&v); |
| 115062 | 116445 | } |
| 115063 | 116446 | break; |
| 115064 | | - case 62: /* ccons ::= NOT NULL onconf */ |
| 115065 | | -{sqlite3AddNotNull(pParse, yymsp[0].minor.yy392);} |
| 115066 | | - break; |
| 115067 | | - case 63: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 115068 | | -{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy392,yymsp[0].minor.yy392,yymsp[-2].minor.yy392);} |
| 115069 | | - break; |
| 115070 | | - case 64: /* ccons ::= UNIQUE onconf */ |
| 115071 | | -{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy392,0,0,0,0);} |
| 115072 | | - break; |
| 115073 | | - case 65: /* ccons ::= CHECK LP expr RP */ |
| 115074 | | -{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);} |
| 115075 | | - break; |
| 115076 | | - case 66: /* ccons ::= REFERENCES nm idxlist_opt refargs */ |
| 115077 | | -{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy392);} |
| 115078 | | - break; |
| 115079 | | - case 67: /* ccons ::= defer_subclause */ |
| 115080 | | -{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy392);} |
| 115081 | | - break; |
| 115082 | | - case 68: /* ccons ::= COLLATE ids */ |
| 116447 | + case 64: /* ccons ::= NOT NULL onconf */ |
| 116448 | +{sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);} |
| 116449 | + break; |
| 116450 | + case 65: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 116451 | +{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);} |
| 116452 | + break; |
| 116453 | + case 66: /* ccons ::= UNIQUE onconf */ |
| 116454 | +{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0);} |
| 116455 | + break; |
| 116456 | + case 67: /* ccons ::= CHECK LP expr RP */ |
| 116457 | +{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy118.pExpr);} |
| 116458 | + break; |
| 116459 | + case 68: /* ccons ::= REFERENCES nm idxlist_opt refargs */ |
| 116460 | +{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);} |
| 116461 | + break; |
| 116462 | + case 69: /* ccons ::= defer_subclause */ |
| 116463 | +{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);} |
| 116464 | + break; |
| 116465 | + case 70: /* ccons ::= COLLATE ids */ |
| 115083 | 116466 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 115084 | 116467 | break; |
| 115085 | | - case 71: /* refargs ::= */ |
| 115086 | | -{ yygotominor.yy392 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 115087 | | - break; |
| 115088 | | - case 72: /* refargs ::= refargs refarg */ |
| 115089 | | -{ yygotominor.yy392 = (yymsp[-1].minor.yy392 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; } |
| 115090 | | - break; |
| 115091 | | - case 73: /* refarg ::= MATCH nm */ |
| 115092 | | - case 74: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==74); |
| 115093 | | -{ yygotominor.yy207.value = 0; yygotominor.yy207.mask = 0x000000; } |
| 115094 | | - break; |
| 115095 | | - case 75: /* refarg ::= ON DELETE refact */ |
| 115096 | | -{ yygotominor.yy207.value = yymsp[0].minor.yy392; yygotominor.yy207.mask = 0x0000ff; } |
| 115097 | | - break; |
| 115098 | | - case 76: /* refarg ::= ON UPDATE refact */ |
| 115099 | | -{ yygotominor.yy207.value = yymsp[0].minor.yy392<<8; yygotominor.yy207.mask = 0x00ff00; } |
| 115100 | | - break; |
| 115101 | | - case 77: /* refact ::= SET NULL */ |
| 115102 | | -{ yygotominor.yy392 = OE_SetNull; /* EV: R-33326-45252 */} |
| 115103 | | - break; |
| 115104 | | - case 78: /* refact ::= SET DEFAULT */ |
| 115105 | | -{ yygotominor.yy392 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 115106 | | - break; |
| 115107 | | - case 79: /* refact ::= CASCADE */ |
| 115108 | | -{ yygotominor.yy392 = OE_Cascade; /* EV: R-33326-45252 */} |
| 115109 | | - break; |
| 115110 | | - case 80: /* refact ::= RESTRICT */ |
| 115111 | | -{ yygotominor.yy392 = OE_Restrict; /* EV: R-33326-45252 */} |
| 115112 | | - break; |
| 115113 | | - case 81: /* refact ::= NO ACTION */ |
| 115114 | | -{ yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */} |
| 115115 | | - break; |
| 115116 | | - case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 115117 | | - case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99); |
| 115118 | | - case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101); |
| 115119 | | - case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104); |
| 115120 | | -{yygotominor.yy392 = yymsp[0].minor.yy392;} |
| 115121 | | - break; |
| 115122 | | - case 87: /* conslist_opt ::= */ |
| 116468 | + case 73: /* refargs ::= */ |
| 116469 | +{ yygotominor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 116470 | + break; |
| 116471 | + case 74: /* refargs ::= refargs refarg */ |
| 116472 | +{ yygotominor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; } |
| 116473 | + break; |
| 116474 | + case 75: /* refarg ::= MATCH nm */ |
| 116475 | + case 76: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==76); |
| 116476 | +{ yygotominor.yy215.value = 0; yygotominor.yy215.mask = 0x000000; } |
| 116477 | + break; |
| 116478 | + case 77: /* refarg ::= ON DELETE refact */ |
| 116479 | +{ yygotominor.yy215.value = yymsp[0].minor.yy4; yygotominor.yy215.mask = 0x0000ff; } |
| 116480 | + break; |
| 116481 | + case 78: /* refarg ::= ON UPDATE refact */ |
| 116482 | +{ yygotominor.yy215.value = yymsp[0].minor.yy4<<8; yygotominor.yy215.mask = 0x00ff00; } |
| 116483 | + break; |
| 116484 | + case 79: /* refact ::= SET NULL */ |
| 116485 | +{ yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */} |
| 116486 | + break; |
| 116487 | + case 80: /* refact ::= SET DEFAULT */ |
| 116488 | +{ yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 116489 | + break; |
| 116490 | + case 81: /* refact ::= CASCADE */ |
| 116491 | +{ yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */} |
| 116492 | + break; |
| 116493 | + case 82: /* refact ::= RESTRICT */ |
| 116494 | +{ yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */} |
| 116495 | + break; |
| 116496 | + case 83: /* refact ::= NO ACTION */ |
| 116497 | +{ yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */} |
| 116498 | + break; |
| 116499 | + case 85: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 116500 | + case 101: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==101); |
| 116501 | + case 103: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==103); |
| 116502 | + case 106: /* resolvetype ::= raisetype */ yytestcase(yyruleno==106); |
| 116503 | +{yygotominor.yy4 = yymsp[0].minor.yy4;} |
| 116504 | + break; |
| 116505 | + case 89: /* conslist_opt ::= */ |
| 115123 | 116506 | {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;} |
| 115124 | 116507 | break; |
| 115125 | | - case 88: /* conslist_opt ::= COMMA conslist */ |
| 116508 | + case 90: /* conslist_opt ::= COMMA conslist */ |
| 115126 | 116509 | {yygotominor.yy0 = yymsp[-1].minor.yy0;} |
| 115127 | 116510 | break; |
| 115128 | | - case 91: /* tconscomma ::= COMMA */ |
| 116511 | + case 93: /* tconscomma ::= COMMA */ |
| 115129 | 116512 | {pParse->constraintName.n = 0;} |
| 115130 | 116513 | break; |
| 115131 | | - case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 115132 | | -{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);} |
| 115133 | | - break; |
| 115134 | | - case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 115135 | | -{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);} |
| 115136 | | - break; |
| 115137 | | - case 96: /* tcons ::= CHECK LP expr RP onconf */ |
| 115138 | | -{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);} |
| 115139 | | - break; |
| 115140 | | - case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 115141 | | -{ |
| 115142 | | - sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392); |
| 115143 | | - sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392); |
| 115144 | | -} |
| 115145 | | - break; |
| 115146 | | - case 100: /* onconf ::= */ |
| 115147 | | -{yygotominor.yy392 = OE_Default;} |
| 115148 | | - break; |
| 115149 | | - case 102: /* orconf ::= */ |
| 115150 | | -{yygotominor.yy258 = OE_Default;} |
| 115151 | | - break; |
| 115152 | | - case 103: /* orconf ::= OR resolvetype */ |
| 115153 | | -{yygotominor.yy258 = (u8)yymsp[0].minor.yy392;} |
| 115154 | | - break; |
| 115155 | | - case 105: /* resolvetype ::= IGNORE */ |
| 115156 | | -{yygotominor.yy392 = OE_Ignore;} |
| 115157 | | - break; |
| 115158 | | - case 106: /* resolvetype ::= REPLACE */ |
| 115159 | | -{yygotominor.yy392 = OE_Replace;} |
| 115160 | | - break; |
| 115161 | | - case 107: /* cmd ::= DROP TABLE ifexists fullname */ |
| 115162 | | -{ |
| 115163 | | - sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392); |
| 115164 | | -} |
| 115165 | | - break; |
| 115166 | | - case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 115167 | | -{ |
| 115168 | | - sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392); |
| 115169 | | -} |
| 115170 | | - break; |
| 115171 | | - case 111: /* cmd ::= DROP VIEW ifexists fullname */ |
| 115172 | | -{ |
| 115173 | | - sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392); |
| 115174 | | -} |
| 115175 | | - break; |
| 115176 | | - case 112: /* cmd ::= select */ |
| 116514 | + case 96: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 116515 | +{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);} |
| 116516 | + break; |
| 116517 | + case 97: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 116518 | +{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0);} |
| 116519 | + break; |
| 116520 | + case 98: /* tcons ::= CHECK LP expr RP onconf */ |
| 116521 | +{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy118.pExpr);} |
| 116522 | + break; |
| 116523 | + case 99: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 116524 | +{ |
| 116525 | + sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4); |
| 116526 | + sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); |
| 116527 | +} |
| 116528 | + break; |
| 116529 | + case 102: /* onconf ::= */ |
| 116530 | +{yygotominor.yy4 = OE_Default;} |
| 116531 | + break; |
| 116532 | + case 104: /* orconf ::= */ |
| 116533 | +{yygotominor.yy210 = OE_Default;} |
| 116534 | + break; |
| 116535 | + case 105: /* orconf ::= OR resolvetype */ |
| 116536 | +{yygotominor.yy210 = (u8)yymsp[0].minor.yy4;} |
| 116537 | + break; |
| 116538 | + case 107: /* resolvetype ::= IGNORE */ |
| 116539 | +{yygotominor.yy4 = OE_Ignore;} |
| 116540 | + break; |
| 116541 | + case 108: /* resolvetype ::= REPLACE */ |
| 116542 | +{yygotominor.yy4 = OE_Replace;} |
| 116543 | + break; |
| 116544 | + case 109: /* cmd ::= DROP TABLE ifexists fullname */ |
| 116545 | +{ |
| 116546 | + sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4); |
| 116547 | +} |
| 116548 | + break; |
| 116549 | + case 112: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 116550 | +{ |
| 116551 | + sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4); |
| 116552 | +} |
| 116553 | + break; |
| 116554 | + case 113: /* cmd ::= DROP VIEW ifexists fullname */ |
| 116555 | +{ |
| 116556 | + sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4); |
| 116557 | +} |
| 116558 | + break; |
| 116559 | + case 114: /* cmd ::= select */ |
| 115177 | 116560 | { |
| 115178 | 116561 | SelectDest dest = {SRT_Output, 0, 0, 0, 0}; |
| 115179 | | - sqlite3Select(pParse, yymsp[0].minor.yy159, &dest); |
| 116562 | + sqlite3Select(pParse, yymsp[0].minor.yy387, &dest); |
| 115180 | 116563 | sqlite3ExplainBegin(pParse->pVdbe); |
| 115181 | | - sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159); |
| 116564 | + sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy387); |
| 115182 | 116565 | sqlite3ExplainFinish(pParse->pVdbe); |
| 115183 | | - sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159); |
| 115184 | | -} |
| 115185 | | - break; |
| 115186 | | - case 113: /* select ::= oneselect */ |
| 115187 | | -{yygotominor.yy159 = yymsp[0].minor.yy159;} |
| 115188 | | - break; |
| 115189 | | - case 114: /* select ::= select multiselect_op oneselect */ |
| 115190 | | -{ |
| 115191 | | - if( yymsp[0].minor.yy159 ){ |
| 115192 | | - yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392; |
| 115193 | | - yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159; |
| 115194 | | - if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1; |
| 115195 | | - }else{ |
| 115196 | | - sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159); |
| 115197 | | - } |
| 115198 | | - yygotominor.yy159 = yymsp[0].minor.yy159; |
| 115199 | | -} |
| 115200 | | - break; |
| 115201 | | - case 116: /* multiselect_op ::= UNION ALL */ |
| 115202 | | -{yygotominor.yy392 = TK_ALL;} |
| 115203 | | - break; |
| 115204 | | - case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 115205 | | -{ |
| 115206 | | - yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy305,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset); |
| 115207 | | -} |
| 115208 | | - break; |
| 115209 | | - case 119: /* distinct ::= DISTINCT */ |
| 115210 | | -{yygotominor.yy305 = SF_Distinct;} |
| 115211 | | - break; |
| 115212 | | - case 120: /* distinct ::= ALL */ |
| 115213 | | - case 121: /* distinct ::= */ yytestcase(yyruleno==121); |
| 115214 | | -{yygotominor.yy305 = 0;} |
| 115215 | | - break; |
| 115216 | | - case 122: /* sclp ::= selcollist COMMA */ |
| 115217 | | - case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246); |
| 115218 | | -{yygotominor.yy442 = yymsp[-1].minor.yy442;} |
| 115219 | | - break; |
| 115220 | | - case 123: /* sclp ::= */ |
| 115221 | | - case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151); |
| 115222 | | - case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158); |
| 115223 | | - case 239: /* exprlist ::= */ yytestcase(yyruleno==239); |
| 115224 | | - case 245: /* idxlist_opt ::= */ yytestcase(yyruleno==245); |
| 115225 | | -{yygotominor.yy442 = 0;} |
| 115226 | | - break; |
| 115227 | | - case 124: /* selcollist ::= sclp expr as */ |
| 115228 | | -{ |
| 115229 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr); |
| 115230 | | - if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1); |
| 115231 | | - sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342); |
| 115232 | | -} |
| 115233 | | - break; |
| 115234 | | - case 125: /* selcollist ::= sclp STAR */ |
| 116566 | + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 116567 | +} |
| 116568 | + break; |
| 116569 | + case 115: /* select ::= oneselect */ |
| 116570 | +{yygotominor.yy387 = yymsp[0].minor.yy387;} |
| 116571 | + break; |
| 116572 | + case 116: /* select ::= select multiselect_op oneselect */ |
| 116573 | +{ |
| 116574 | + if( yymsp[0].minor.yy387 ){ |
| 116575 | + yymsp[0].minor.yy387->op = (u8)yymsp[-1].minor.yy4; |
| 116576 | + yymsp[0].minor.yy387->pPrior = yymsp[-2].minor.yy387; |
| 116577 | + if( yymsp[-1].minor.yy4!=TK_ALL ) pParse->hasCompound = 1; |
| 116578 | + }else{ |
| 116579 | + sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy387); |
| 116580 | + } |
| 116581 | + yygotominor.yy387 = yymsp[0].minor.yy387; |
| 116582 | +} |
| 116583 | + break; |
| 116584 | + case 118: /* multiselect_op ::= UNION ALL */ |
| 116585 | +{yygotominor.yy4 = TK_ALL;} |
| 116586 | + break; |
| 116587 | + case 120: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 116588 | +{ |
| 116589 | + yygotominor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy177,yymsp[0].minor.yy292.pLimit,yymsp[0].minor.yy292.pOffset); |
| 116590 | +} |
| 116591 | + break; |
| 116592 | + case 121: /* distinct ::= DISTINCT */ |
| 116593 | +{yygotominor.yy177 = SF_Distinct;} |
| 116594 | + break; |
| 116595 | + case 122: /* distinct ::= ALL */ |
| 116596 | + case 123: /* distinct ::= */ yytestcase(yyruleno==123); |
| 116597 | +{yygotominor.yy177 = 0;} |
| 116598 | + break; |
| 116599 | + case 124: /* sclp ::= selcollist COMMA */ |
| 116600 | + case 248: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==248); |
| 116601 | +{yygotominor.yy322 = yymsp[-1].minor.yy322;} |
| 116602 | + break; |
| 116603 | + case 125: /* sclp ::= */ |
| 116604 | + case 153: /* orderby_opt ::= */ yytestcase(yyruleno==153); |
| 116605 | + case 160: /* groupby_opt ::= */ yytestcase(yyruleno==160); |
| 116606 | + case 241: /* exprlist ::= */ yytestcase(yyruleno==241); |
| 116607 | + case 247: /* idxlist_opt ::= */ yytestcase(yyruleno==247); |
| 116608 | +{yygotominor.yy322 = 0;} |
| 116609 | + break; |
| 116610 | + case 126: /* selcollist ::= sclp expr as */ |
| 116611 | +{ |
| 116612 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr); |
| 116613 | + if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[0].minor.yy0, 1); |
| 116614 | + sqlite3ExprListSetSpan(pParse,yygotominor.yy322,&yymsp[-1].minor.yy118); |
| 116615 | +} |
| 116616 | + break; |
| 116617 | + case 127: /* selcollist ::= sclp STAR */ |
| 115235 | 116618 | { |
| 115236 | 116619 | Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0); |
| 115237 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p); |
| 116620 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy322, p); |
| 115238 | 116621 | } |
| 115239 | 116622 | break; |
| 115240 | | - case 126: /* selcollist ::= sclp nm DOT STAR */ |
| 116623 | + case 128: /* selcollist ::= sclp nm DOT STAR */ |
| 115241 | 116624 | { |
| 115242 | 116625 | Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0); |
| 115243 | 116626 | Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 115244 | 116627 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); |
| 115245 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot); |
| 116628 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, pDot); |
| 115246 | 116629 | } |
| 115247 | 116630 | break; |
| 115248 | | - case 129: /* as ::= */ |
| 116631 | + case 131: /* as ::= */ |
| 115249 | 116632 | {yygotominor.yy0.n = 0;} |
| 115250 | 116633 | break; |
| 115251 | | - case 130: /* from ::= */ |
| 115252 | | -{yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));} |
| 115253 | | - break; |
| 115254 | | - case 131: /* from ::= FROM seltablist */ |
| 115255 | | -{ |
| 115256 | | - yygotominor.yy347 = yymsp[0].minor.yy347; |
| 115257 | | - sqlite3SrcListShiftJoinType(yygotominor.yy347); |
| 115258 | | -} |
| 115259 | | - break; |
| 115260 | | - case 132: /* stl_prefix ::= seltablist joinop */ |
| 115261 | | -{ |
| 115262 | | - yygotominor.yy347 = yymsp[-1].minor.yy347; |
| 115263 | | - if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392; |
| 115264 | | -} |
| 115265 | | - break; |
| 115266 | | - case 133: /* stl_prefix ::= */ |
| 115267 | | -{yygotominor.yy347 = 0;} |
| 115268 | | - break; |
| 115269 | | - case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 115270 | | -{ |
| 115271 | | - yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 115272 | | - sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0); |
| 115273 | | -} |
| 115274 | | - break; |
| 115275 | | - case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 115276 | | -{ |
| 115277 | | - yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 115278 | | - } |
| 115279 | | - break; |
| 115280 | | - case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 115281 | | -{ |
| 115282 | | - if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){ |
| 115283 | | - yygotominor.yy347 = yymsp[-4].minor.yy347; |
| 115284 | | - }else if( yymsp[-4].minor.yy347->nSrc==1 ){ |
| 115285 | | - yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 115286 | | - if( yygotominor.yy347 ){ |
| 115287 | | - struct SrcList_item *pNew = &yygotominor.yy347->a[yygotominor.yy347->nSrc-1]; |
| 115288 | | - struct SrcList_item *pOld = yymsp[-4].minor.yy347->a; |
| 116634 | + case 132: /* from ::= */ |
| 116635 | +{yygotominor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy259));} |
| 116636 | + break; |
| 116637 | + case 133: /* from ::= FROM seltablist */ |
| 116638 | +{ |
| 116639 | + yygotominor.yy259 = yymsp[0].minor.yy259; |
| 116640 | + sqlite3SrcListShiftJoinType(yygotominor.yy259); |
| 116641 | +} |
| 116642 | + break; |
| 116643 | + case 134: /* stl_prefix ::= seltablist joinop */ |
| 116644 | +{ |
| 116645 | + yygotominor.yy259 = yymsp[-1].minor.yy259; |
| 116646 | + if( ALWAYS(yygotominor.yy259 && yygotominor.yy259->nSrc>0) ) yygotominor.yy259->a[yygotominor.yy259->nSrc-1].jointype = (u8)yymsp[0].minor.yy4; |
| 116647 | +} |
| 116648 | + break; |
| 116649 | + case 135: /* stl_prefix ::= */ |
| 116650 | +{yygotominor.yy259 = 0;} |
| 116651 | + break; |
| 116652 | + case 136: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 116653 | +{ |
| 116654 | + yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 116655 | + sqlite3SrcListIndexedBy(pParse, yygotominor.yy259, &yymsp[-2].minor.yy0); |
| 116656 | +} |
| 116657 | + break; |
| 116658 | + case 137: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 116659 | +{ |
| 116660 | + yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 116661 | + } |
| 116662 | + break; |
| 116663 | + case 138: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 116664 | +{ |
| 116665 | + if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){ |
| 116666 | + yygotominor.yy259 = yymsp[-4].minor.yy259; |
| 116667 | + }else if( yymsp[-4].minor.yy259->nSrc==1 ){ |
| 116668 | + yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 116669 | + if( yygotominor.yy259 ){ |
| 116670 | + struct SrcList_item *pNew = &yygotominor.yy259->a[yygotominor.yy259->nSrc-1]; |
| 116671 | + struct SrcList_item *pOld = yymsp[-4].minor.yy259->a; |
| 115289 | 116672 | pNew->zName = pOld->zName; |
| 115290 | 116673 | pNew->zDatabase = pOld->zDatabase; |
| 115291 | 116674 | pNew->pSelect = pOld->pSelect; |
| 115292 | 116675 | pOld->zName = pOld->zDatabase = 0; |
| 115293 | 116676 | pOld->pSelect = 0; |
| 115294 | 116677 | } |
| 115295 | | - sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347); |
| 116678 | + sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy259); |
| 115296 | 116679 | }else{ |
| 115297 | 116680 | Select *pSubquery; |
| 115298 | | - sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347); |
| 115299 | | - pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0); |
| 115300 | | - yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 116681 | + sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259); |
| 116682 | + pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,SF_NestedFrom,0,0); |
| 116683 | + yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 115301 | 116684 | } |
| 115302 | 116685 | } |
| 115303 | 116686 | break; |
| 115304 | | - case 137: /* dbnm ::= */ |
| 115305 | | - case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146); |
| 116687 | + case 139: /* dbnm ::= */ |
| 116688 | + case 148: /* indexed_opt ::= */ yytestcase(yyruleno==148); |
| 115306 | 116689 | {yygotominor.yy0.z=0; yygotominor.yy0.n=0;} |
| 115307 | 116690 | break; |
| 115308 | | - case 139: /* fullname ::= nm dbnm */ |
| 115309 | | -{yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 115310 | | - break; |
| 115311 | | - case 140: /* joinop ::= COMMA|JOIN */ |
| 115312 | | -{ yygotominor.yy392 = JT_INNER; } |
| 115313 | | - break; |
| 115314 | | - case 141: /* joinop ::= JOIN_KW JOIN */ |
| 115315 | | -{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 115316 | | - break; |
| 115317 | | - case 142: /* joinop ::= JOIN_KW nm JOIN */ |
| 115318 | | -{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 115319 | | - break; |
| 115320 | | - case 143: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 115321 | | -{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 115322 | | - break; |
| 115323 | | - case 144: /* on_opt ::= ON expr */ |
| 115324 | | - case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161); |
| 115325 | | - case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168); |
| 115326 | | - case 234: /* case_else ::= ELSE expr */ yytestcase(yyruleno==234); |
| 115327 | | - case 236: /* case_operand ::= expr */ yytestcase(yyruleno==236); |
| 115328 | | -{yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;} |
| 115329 | | - break; |
| 115330 | | - case 145: /* on_opt ::= */ |
| 115331 | | - case 160: /* having_opt ::= */ yytestcase(yyruleno==160); |
| 115332 | | - case 167: /* where_opt ::= */ yytestcase(yyruleno==167); |
| 115333 | | - case 235: /* case_else ::= */ yytestcase(yyruleno==235); |
| 115334 | | - case 237: /* case_operand ::= */ yytestcase(yyruleno==237); |
| 115335 | | -{yygotominor.yy122 = 0;} |
| 115336 | | - break; |
| 115337 | | - case 148: /* indexed_opt ::= NOT INDEXED */ |
| 116691 | + case 141: /* fullname ::= nm dbnm */ |
| 116692 | +{yygotominor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 116693 | + break; |
| 116694 | + case 142: /* joinop ::= COMMA|JOIN */ |
| 116695 | +{ yygotominor.yy4 = JT_INNER; } |
| 116696 | + break; |
| 116697 | + case 143: /* joinop ::= JOIN_KW JOIN */ |
| 116698 | +{ yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 116699 | + break; |
| 116700 | + case 144: /* joinop ::= JOIN_KW nm JOIN */ |
| 116701 | +{ yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 116702 | + break; |
| 116703 | + case 145: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 116704 | +{ yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 116705 | + break; |
| 116706 | + case 146: /* on_opt ::= ON expr */ |
| 116707 | + case 163: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==163); |
| 116708 | + case 170: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==170); |
| 116709 | + case 236: /* case_else ::= ELSE expr */ yytestcase(yyruleno==236); |
| 116710 | + case 238: /* case_operand ::= expr */ yytestcase(yyruleno==238); |
| 116711 | +{yygotominor.yy314 = yymsp[0].minor.yy118.pExpr;} |
| 116712 | + break; |
| 116713 | + case 147: /* on_opt ::= */ |
| 116714 | + case 162: /* having_opt ::= */ yytestcase(yyruleno==162); |
| 116715 | + case 169: /* where_opt ::= */ yytestcase(yyruleno==169); |
| 116716 | + case 237: /* case_else ::= */ yytestcase(yyruleno==237); |
| 116717 | + case 239: /* case_operand ::= */ yytestcase(yyruleno==239); |
| 116718 | +{yygotominor.yy314 = 0;} |
| 116719 | + break; |
| 116720 | + case 150: /* indexed_opt ::= NOT INDEXED */ |
| 115338 | 116721 | {yygotominor.yy0.z=0; yygotominor.yy0.n=1;} |
| 115339 | 116722 | break; |
| 115340 | | - case 149: /* using_opt ::= USING LP inscollist RP */ |
| 115341 | | - case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180); |
| 115342 | | -{yygotominor.yy180 = yymsp[-1].minor.yy180;} |
| 115343 | | - break; |
| 115344 | | - case 150: /* using_opt ::= */ |
| 115345 | | - case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179); |
| 115346 | | -{yygotominor.yy180 = 0;} |
| 115347 | | - break; |
| 115348 | | - case 152: /* orderby_opt ::= ORDER BY sortlist */ |
| 115349 | | - case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159); |
| 115350 | | - case 238: /* exprlist ::= nexprlist */ yytestcase(yyruleno==238); |
| 115351 | | -{yygotominor.yy442 = yymsp[0].minor.yy442;} |
| 115352 | | - break; |
| 115353 | | - case 153: /* sortlist ::= sortlist COMMA expr sortorder */ |
| 115354 | | -{ |
| 115355 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr); |
| 115356 | | - if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392; |
| 115357 | | -} |
| 115358 | | - break; |
| 115359 | | - case 154: /* sortlist ::= expr sortorder */ |
| 115360 | | -{ |
| 115361 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr); |
| 115362 | | - if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392; |
| 115363 | | -} |
| 115364 | | - break; |
| 115365 | | - case 155: /* sortorder ::= ASC */ |
| 115366 | | - case 157: /* sortorder ::= */ yytestcase(yyruleno==157); |
| 115367 | | -{yygotominor.yy392 = SQLITE_SO_ASC;} |
| 115368 | | - break; |
| 115369 | | - case 156: /* sortorder ::= DESC */ |
| 115370 | | -{yygotominor.yy392 = SQLITE_SO_DESC;} |
| 115371 | | - break; |
| 115372 | | - case 162: /* limit_opt ::= */ |
| 115373 | | -{yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;} |
| 115374 | | - break; |
| 115375 | | - case 163: /* limit_opt ::= LIMIT expr */ |
| 115376 | | -{yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;} |
| 115377 | | - break; |
| 115378 | | - case 164: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 115379 | | -{yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;} |
| 115380 | | - break; |
| 115381 | | - case 165: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 115382 | | -{yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;} |
| 115383 | | - break; |
| 115384 | | - case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ |
| 115385 | | -{ |
| 115386 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0); |
| 115387 | | - sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122); |
| 115388 | | -} |
| 115389 | | - break; |
| 115390 | | - case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 115391 | | -{ |
| 115392 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0); |
| 115393 | | - sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list"); |
| 115394 | | - sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258); |
| 115395 | | -} |
| 115396 | | - break; |
| 115397 | | - case 170: /* setlist ::= setlist COMMA nm EQ expr */ |
| 115398 | | -{ |
| 115399 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr); |
| 115400 | | - sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1); |
| 115401 | | -} |
| 115402 | | - break; |
| 115403 | | - case 171: /* setlist ::= nm EQ expr */ |
| 115404 | | -{ |
| 115405 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr); |
| 115406 | | - sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1); |
| 115407 | | -} |
| 115408 | | - break; |
| 115409 | | - case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */ |
| 115410 | | -{sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);} |
| 115411 | | - break; |
| 115412 | | - case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ |
| 115413 | | -{sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);} |
| 115414 | | - break; |
| 115415 | | - case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 115416 | | -{sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);} |
| 115417 | | - break; |
| 115418 | | - case 175: /* insert_cmd ::= INSERT orconf */ |
| 115419 | | -{yygotominor.yy258 = yymsp[0].minor.yy258;} |
| 115420 | | - break; |
| 115421 | | - case 176: /* insert_cmd ::= REPLACE */ |
| 115422 | | -{yygotominor.yy258 = OE_Replace;} |
| 115423 | | - break; |
| 115424 | | - case 177: /* valuelist ::= VALUES LP nexprlist RP */ |
| 115425 | | -{ |
| 115426 | | - yygotominor.yy487.pList = yymsp[-1].minor.yy442; |
| 115427 | | - yygotominor.yy487.pSelect = 0; |
| 115428 | | -} |
| 115429 | | - break; |
| 115430 | | - case 178: /* valuelist ::= valuelist COMMA LP exprlist RP */ |
| 115431 | | -{ |
| 115432 | | - Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0); |
| 115433 | | - if( yymsp[-4].minor.yy487.pList ){ |
| 115434 | | - yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0); |
| 115435 | | - yymsp[-4].minor.yy487.pList = 0; |
| 115436 | | - } |
| 115437 | | - yygotominor.yy487.pList = 0; |
| 115438 | | - if( yymsp[-4].minor.yy487.pSelect==0 || pRight==0 ){ |
| 116723 | + case 151: /* using_opt ::= USING LP idlist RP */ |
| 116724 | + case 182: /* inscollist_opt ::= LP idlist RP */ yytestcase(yyruleno==182); |
| 116725 | +{yygotominor.yy384 = yymsp[-1].minor.yy384;} |
| 116726 | + break; |
| 116727 | + case 152: /* using_opt ::= */ |
| 116728 | + case 181: /* inscollist_opt ::= */ yytestcase(yyruleno==181); |
| 116729 | +{yygotominor.yy384 = 0;} |
| 116730 | + break; |
| 116731 | + case 154: /* orderby_opt ::= ORDER BY sortlist */ |
| 116732 | + case 161: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==161); |
| 116733 | + case 240: /* exprlist ::= nexprlist */ yytestcase(yyruleno==240); |
| 116734 | +{yygotominor.yy322 = yymsp[0].minor.yy322;} |
| 116735 | + break; |
| 116736 | + case 155: /* sortlist ::= sortlist COMMA expr sortorder */ |
| 116737 | +{ |
| 116738 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy118.pExpr); |
| 116739 | + if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 116740 | +} |
| 116741 | + break; |
| 116742 | + case 156: /* sortlist ::= expr sortorder */ |
| 116743 | +{ |
| 116744 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy118.pExpr); |
| 116745 | + if( yygotominor.yy322 && ALWAYS(yygotominor.yy322->a) ) yygotominor.yy322->a[0].sortOrder = (u8)yymsp[0].minor.yy4; |
| 116746 | +} |
| 116747 | + break; |
| 116748 | + case 157: /* sortorder ::= ASC */ |
| 116749 | + case 159: /* sortorder ::= */ yytestcase(yyruleno==159); |
| 116750 | +{yygotominor.yy4 = SQLITE_SO_ASC;} |
| 116751 | + break; |
| 116752 | + case 158: /* sortorder ::= DESC */ |
| 116753 | +{yygotominor.yy4 = SQLITE_SO_DESC;} |
| 116754 | + break; |
| 116755 | + case 164: /* limit_opt ::= */ |
| 116756 | +{yygotominor.yy292.pLimit = 0; yygotominor.yy292.pOffset = 0;} |
| 116757 | + break; |
| 116758 | + case 165: /* limit_opt ::= LIMIT expr */ |
| 116759 | +{yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; yygotominor.yy292.pOffset = 0;} |
| 116760 | + break; |
| 116761 | + case 166: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 116762 | +{yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr;} |
| 116763 | + break; |
| 116764 | + case 167: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 116765 | +{yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr;} |
| 116766 | + break; |
| 116767 | + case 168: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ |
| 116768 | +{ |
| 116769 | + sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0); |
| 116770 | + sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314); |
| 116771 | +} |
| 116772 | + break; |
| 116773 | + case 171: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 116774 | +{ |
| 116775 | + sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0); |
| 116776 | + sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); |
| 116777 | + sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy210); |
| 116778 | +} |
| 116779 | + break; |
| 116780 | + case 172: /* setlist ::= setlist COMMA nm EQ expr */ |
| 116781 | +{ |
| 116782 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr); |
| 116783 | + sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 116784 | +} |
| 116785 | + break; |
| 116786 | + case 173: /* setlist ::= nm EQ expr */ |
| 116787 | +{ |
| 116788 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); |
| 116789 | + sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 116790 | +} |
| 116791 | + break; |
| 116792 | + case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */ |
| 116793 | +{sqlite3Insert(pParse, yymsp[-2].minor.yy259, yymsp[0].minor.yy260.pList, yymsp[0].minor.yy260.pSelect, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210);} |
| 116794 | + break; |
| 116795 | + case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ |
| 116796 | +{sqlite3Insert(pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210);} |
| 116797 | + break; |
| 116798 | + case 176: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 116799 | +{sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210);} |
| 116800 | + break; |
| 116801 | + case 177: /* insert_cmd ::= INSERT orconf */ |
| 116802 | +{yygotominor.yy210 = yymsp[0].minor.yy210;} |
| 116803 | + break; |
| 116804 | + case 178: /* insert_cmd ::= REPLACE */ |
| 116805 | +{yygotominor.yy210 = OE_Replace;} |
| 116806 | + break; |
| 116807 | + case 179: /* valuelist ::= VALUES LP nexprlist RP */ |
| 116808 | +{ |
| 116809 | + yygotominor.yy260.pList = yymsp[-1].minor.yy322; |
| 116810 | + yygotominor.yy260.pSelect = 0; |
| 116811 | +} |
| 116812 | + break; |
| 116813 | + case 180: /* valuelist ::= valuelist COMMA LP exprlist RP */ |
| 116814 | +{ |
| 116815 | + Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy322, 0, 0, 0, 0, 0, 0, 0, 0); |
| 116816 | + if( yymsp[-4].minor.yy260.pList ){ |
| 116817 | + yymsp[-4].minor.yy260.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy260.pList, 0, 0, 0, 0, 0, 0, 0, 0); |
| 116818 | + yymsp[-4].minor.yy260.pList = 0; |
| 116819 | + } |
| 116820 | + yygotominor.yy260.pList = 0; |
| 116821 | + if( yymsp[-4].minor.yy260.pSelect==0 || pRight==0 ){ |
| 115439 | 116822 | sqlite3SelectDelete(pParse->db, pRight); |
| 115440 | | - sqlite3SelectDelete(pParse->db, yymsp[-4].minor.yy487.pSelect); |
| 115441 | | - yygotominor.yy487.pSelect = 0; |
| 116823 | + sqlite3SelectDelete(pParse->db, yymsp[-4].minor.yy260.pSelect); |
| 116824 | + yygotominor.yy260.pSelect = 0; |
| 115442 | 116825 | }else{ |
| 115443 | 116826 | pRight->op = TK_ALL; |
| 115444 | | - pRight->pPrior = yymsp[-4].minor.yy487.pSelect; |
| 116827 | + pRight->pPrior = yymsp[-4].minor.yy260.pSelect; |
| 115445 | 116828 | pRight->selFlags |= SF_Values; |
| 115446 | 116829 | pRight->pPrior->selFlags |= SF_Values; |
| 115447 | | - yygotominor.yy487.pSelect = pRight; |
| 115448 | | - } |
| 115449 | | -} |
| 115450 | | - break; |
| 115451 | | - case 181: /* inscollist ::= inscollist COMMA nm */ |
| 115452 | | -{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);} |
| 115453 | | - break; |
| 115454 | | - case 182: /* inscollist ::= nm */ |
| 115455 | | -{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 115456 | | - break; |
| 115457 | | - case 183: /* expr ::= term */ |
| 115458 | | -{yygotominor.yy342 = yymsp[0].minor.yy342;} |
| 115459 | | - break; |
| 115460 | | - case 184: /* expr ::= LP expr RP */ |
| 115461 | | -{yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 115462 | | - break; |
| 115463 | | - case 185: /* term ::= NULL */ |
| 115464 | | - case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190); |
| 115465 | | - case 191: /* term ::= STRING */ yytestcase(yyruleno==191); |
| 115466 | | -{spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 115467 | | - break; |
| 115468 | | - case 186: /* expr ::= id */ |
| 115469 | | - case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187); |
| 115470 | | -{spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 115471 | | - break; |
| 115472 | | - case 188: /* expr ::= nm DOT nm */ |
| 116830 | + yygotominor.yy260.pSelect = pRight; |
| 116831 | + } |
| 116832 | +} |
| 116833 | + break; |
| 116834 | + case 183: /* idlist ::= idlist COMMA nm */ |
| 116835 | +{yygotominor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);} |
| 116836 | + break; |
| 116837 | + case 184: /* idlist ::= nm */ |
| 116838 | +{yygotominor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 116839 | + break; |
| 116840 | + case 185: /* expr ::= term */ |
| 116841 | +{yygotominor.yy118 = yymsp[0].minor.yy118;} |
| 116842 | + break; |
| 116843 | + case 186: /* expr ::= LP expr RP */ |
| 116844 | +{yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 116845 | + break; |
| 116846 | + case 187: /* term ::= NULL */ |
| 116847 | + case 192: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==192); |
| 116848 | + case 193: /* term ::= STRING */ yytestcase(yyruleno==193); |
| 116849 | +{spanExpr(&yygotominor.yy118, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 116850 | + break; |
| 116851 | + case 188: /* expr ::= id */ |
| 116852 | + case 189: /* expr ::= JOIN_KW */ yytestcase(yyruleno==189); |
| 116853 | +{spanExpr(&yygotominor.yy118, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 116854 | + break; |
| 116855 | + case 190: /* expr ::= nm DOT nm */ |
| 115473 | 116856 | { |
| 115474 | 116857 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 115475 | 116858 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 115476 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 115477 | | - spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 116859 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 116860 | + spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 115478 | 116861 | } |
| 115479 | 116862 | break; |
| 115480 | | - case 189: /* expr ::= nm DOT nm DOT nm */ |
| 116863 | + case 191: /* expr ::= nm DOT nm DOT nm */ |
| 115481 | 116864 | { |
| 115482 | 116865 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 115483 | 116866 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 115484 | 116867 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 115485 | 116868 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 115486 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 115487 | | - spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 116869 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 116870 | + spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 115488 | 116871 | } |
| 115489 | 116872 | break; |
| 115490 | | - case 192: /* expr ::= REGISTER */ |
| 116873 | + case 194: /* expr ::= REGISTER */ |
| 115491 | 116874 | { |
| 115492 | 116875 | /* When doing a nested parse, one can include terms in an expression |
| 115493 | 116876 | ** that look like this: #1 #2 ... These terms refer to registers |
| 115494 | 116877 | ** in the virtual machine. #N is the N-th register. */ |
| 115495 | 116878 | if( pParse->nested==0 ){ |
| 115496 | 116879 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &yymsp[0].minor.yy0); |
| 115497 | | - yygotominor.yy342.pExpr = 0; |
| 115498 | | - }else{ |
| 115499 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0); |
| 115500 | | - if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable); |
| 115501 | | - } |
| 115502 | | - spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 115503 | | -} |
| 115504 | | - break; |
| 115505 | | - case 193: /* expr ::= VARIABLE */ |
| 115506 | | -{ |
| 115507 | | - spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0); |
| 115508 | | - sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr); |
| 115509 | | - spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 115510 | | -} |
| 115511 | | - break; |
| 115512 | | - case 194: /* expr ::= expr COLLATE ids */ |
| 115513 | | -{ |
| 115514 | | - yygotominor.yy342.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0); |
| 115515 | | - yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart; |
| 115516 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115517 | | -} |
| 115518 | | - break; |
| 115519 | | - case 195: /* expr ::= CAST LP expr AS typetoken RP */ |
| 115520 | | -{ |
| 115521 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0); |
| 115522 | | - spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 115523 | | -} |
| 115524 | | - break; |
| 115525 | | - case 196: /* expr ::= ID LP distinct exprlist RP */ |
| 115526 | | -{ |
| 115527 | | - if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 116880 | + yygotominor.yy118.pExpr = 0; |
| 116881 | + }else{ |
| 116882 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0); |
| 116883 | + if( yygotominor.yy118.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy118.pExpr->iTable); |
| 116884 | + } |
| 116885 | + spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 116886 | +} |
| 116887 | + break; |
| 116888 | + case 195: /* expr ::= VARIABLE */ |
| 116889 | +{ |
| 116890 | + spanExpr(&yygotominor.yy118, pParse, TK_VARIABLE, &yymsp[0].minor.yy0); |
| 116891 | + sqlite3ExprAssignVarNumber(pParse, yygotominor.yy118.pExpr); |
| 116892 | + spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 116893 | +} |
| 116894 | + break; |
| 116895 | + case 196: /* expr ::= expr COLLATE ids */ |
| 116896 | +{ |
| 116897 | + yygotominor.yy118.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy118.pExpr, &yymsp[0].minor.yy0); |
| 116898 | + yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 116899 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 116900 | +} |
| 116901 | + break; |
| 116902 | + case 197: /* expr ::= CAST LP expr AS typetoken RP */ |
| 116903 | +{ |
| 116904 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, &yymsp[-1].minor.yy0); |
| 116905 | + spanSet(&yygotominor.yy118,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 116906 | +} |
| 116907 | + break; |
| 116908 | + case 198: /* expr ::= ID LP distinct exprlist RP */ |
| 116909 | +{ |
| 116910 | + if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 115528 | 116911 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 115529 | 116912 | } |
| 115530 | | - yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0); |
| 115531 | | - spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 115532 | | - if( yymsp[-2].minor.yy305 && yygotominor.yy342.pExpr ){ |
| 115533 | | - yygotominor.yy342.pExpr->flags |= EP_Distinct; |
| 115534 | | - } |
| 115535 | | -} |
| 115536 | | - break; |
| 115537 | | - case 197: /* expr ::= ID LP STAR RP */ |
| 115538 | | -{ |
| 115539 | | - yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 115540 | | - spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 115541 | | -} |
| 115542 | | - break; |
| 115543 | | - case 198: /* term ::= CTIME_KW */ |
| 116913 | + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| 116914 | + spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 116915 | + if( yymsp[-2].minor.yy177 && yygotominor.yy118.pExpr ){ |
| 116916 | + yygotominor.yy118.pExpr->flags |= EP_Distinct; |
| 116917 | + } |
| 116918 | +} |
| 116919 | + break; |
| 116920 | + case 199: /* expr ::= ID LP STAR RP */ |
| 116921 | +{ |
| 116922 | + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 116923 | + spanSet(&yygotominor.yy118,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 116924 | +} |
| 116925 | + break; |
| 116926 | + case 200: /* term ::= CTIME_KW */ |
| 115544 | 116927 | { |
| 115545 | 116928 | /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are |
| 115546 | 116929 | ** treated as functions that return constants */ |
| 115547 | | - yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0); |
| 115548 | | - if( yygotominor.yy342.pExpr ){ |
| 115549 | | - yygotominor.yy342.pExpr->op = TK_CONST_FUNC; |
| 115550 | | - } |
| 115551 | | - spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 115552 | | -} |
| 115553 | | - break; |
| 115554 | | - case 199: /* expr ::= expr AND expr */ |
| 115555 | | - case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200); |
| 115556 | | - case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201); |
| 115557 | | - case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202); |
| 115558 | | - case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203); |
| 115559 | | - case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204); |
| 115560 | | - case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205); |
| 115561 | | - case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206); |
| 115562 | | -{spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);} |
| 115563 | | - break; |
| 115564 | | - case 207: /* likeop ::= LIKE_KW */ |
| 115565 | | - case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209); |
| 115566 | | -{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 0;} |
| 115567 | | - break; |
| 115568 | | - case 208: /* likeop ::= NOT LIKE_KW */ |
| 115569 | | - case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210); |
| 115570 | | -{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 1;} |
| 115571 | | - break; |
| 115572 | | - case 211: /* expr ::= expr likeop expr */ |
| 115573 | | -{ |
| 115574 | | - ExprList *pList; |
| 115575 | | - pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr); |
| 115576 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr); |
| 115577 | | - yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator); |
| 115578 | | - if( yymsp[-1].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 115579 | | - yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart; |
| 115580 | | - yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 115581 | | - if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc; |
| 115582 | | -} |
| 115583 | | - break; |
| 115584 | | - case 212: /* expr ::= expr likeop expr ESCAPE expr */ |
| 115585 | | -{ |
| 115586 | | - ExprList *pList; |
| 115587 | | - pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 115588 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr); |
| 115589 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr); |
| 115590 | | - yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator); |
| 115591 | | - if( yymsp[-3].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 115592 | | - yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 115593 | | - yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 115594 | | - if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc; |
| 115595 | | -} |
| 115596 | | - break; |
| 115597 | | - case 213: /* expr ::= expr ISNULL|NOTNULL */ |
| 115598 | | -{spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);} |
| 115599 | | - break; |
| 115600 | | - case 214: /* expr ::= expr NOT NULL */ |
| 115601 | | -{spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);} |
| 115602 | | - break; |
| 115603 | | - case 215: /* expr ::= expr IS expr */ |
| 115604 | | -{ |
| 115605 | | - spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342); |
| 115606 | | - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL); |
| 115607 | | -} |
| 115608 | | - break; |
| 115609 | | - case 216: /* expr ::= expr IS NOT expr */ |
| 115610 | | -{ |
| 115611 | | - spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342); |
| 115612 | | - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL); |
| 115613 | | -} |
| 115614 | | - break; |
| 115615 | | - case 217: /* expr ::= NOT expr */ |
| 115616 | | - case 218: /* expr ::= BITNOT expr */ yytestcase(yyruleno==218); |
| 115617 | | -{spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);} |
| 115618 | | - break; |
| 115619 | | - case 219: /* expr ::= MINUS expr */ |
| 115620 | | -{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);} |
| 115621 | | - break; |
| 115622 | | - case 220: /* expr ::= PLUS expr */ |
| 115623 | | -{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);} |
| 115624 | | - break; |
| 115625 | | - case 223: /* expr ::= expr between_op expr AND expr */ |
| 115626 | | -{ |
| 115627 | | - ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 115628 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr); |
| 115629 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 115630 | | - if( yygotominor.yy342.pExpr ){ |
| 115631 | | - yygotominor.yy342.pExpr->x.pList = pList; |
| 116930 | + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0); |
| 116931 | + if( yygotominor.yy118.pExpr ){ |
| 116932 | + yygotominor.yy118.pExpr->op = TK_CONST_FUNC; |
| 116933 | + } |
| 116934 | + spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 116935 | +} |
| 116936 | + break; |
| 116937 | + case 201: /* expr ::= expr AND expr */ |
| 116938 | + case 202: /* expr ::= expr OR expr */ yytestcase(yyruleno==202); |
| 116939 | + case 203: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==203); |
| 116940 | + case 204: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==204); |
| 116941 | + case 205: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==205); |
| 116942 | + case 206: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==206); |
| 116943 | + case 207: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==207); |
| 116944 | + case 208: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==208); |
| 116945 | +{spanBinaryExpr(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118);} |
| 116946 | + break; |
| 116947 | + case 209: /* likeop ::= LIKE_KW */ |
| 116948 | + case 211: /* likeop ::= MATCH */ yytestcase(yyruleno==211); |
| 116949 | +{yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.bNot = 0;} |
| 116950 | + break; |
| 116951 | + case 210: /* likeop ::= NOT LIKE_KW */ |
| 116952 | + case 212: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==212); |
| 116953 | +{yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.bNot = 1;} |
| 116954 | + break; |
| 116955 | + case 213: /* expr ::= expr likeop expr */ |
| 116956 | +{ |
| 116957 | + ExprList *pList; |
| 116958 | + pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy118.pExpr); |
| 116959 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy118.pExpr); |
| 116960 | + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy342.eOperator); |
| 116961 | + if( yymsp[-1].minor.yy342.bNot ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 116962 | + yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 116963 | + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 116964 | + if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 116965 | +} |
| 116966 | + break; |
| 116967 | + case 214: /* expr ::= expr likeop expr ESCAPE expr */ |
| 116968 | +{ |
| 116969 | + ExprList *pList; |
| 116970 | + pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 116971 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy118.pExpr); |
| 116972 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| 116973 | + yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy342.eOperator); |
| 116974 | + if( yymsp[-3].minor.yy342.bNot ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 116975 | + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 116976 | + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 116977 | + if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 116978 | +} |
| 116979 | + break; |
| 116980 | + case 215: /* expr ::= expr ISNULL|NOTNULL */ |
| 116981 | +{spanUnaryPostfix(&yygotominor.yy118,pParse,yymsp[0].major,&yymsp[-1].minor.yy118,&yymsp[0].minor.yy0);} |
| 116982 | + break; |
| 116983 | + case 216: /* expr ::= expr NOT NULL */ |
| 116984 | +{spanUnaryPostfix(&yygotominor.yy118,pParse,TK_NOTNULL,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy0);} |
| 116985 | + break; |
| 116986 | + case 217: /* expr ::= expr IS expr */ |
| 116987 | +{ |
| 116988 | + spanBinaryExpr(&yygotominor.yy118,pParse,TK_IS,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118); |
| 116989 | + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL); |
| 116990 | +} |
| 116991 | + break; |
| 116992 | + case 218: /* expr ::= expr IS NOT expr */ |
| 116993 | +{ |
| 116994 | + spanBinaryExpr(&yygotominor.yy118,pParse,TK_ISNOT,&yymsp[-3].minor.yy118,&yymsp[0].minor.yy118); |
| 116995 | + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL); |
| 116996 | +} |
| 116997 | + break; |
| 116998 | + case 219: /* expr ::= NOT expr */ |
| 116999 | + case 220: /* expr ::= BITNOT expr */ yytestcase(yyruleno==220); |
| 117000 | +{spanUnaryPrefix(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 117001 | + break; |
| 117002 | + case 221: /* expr ::= MINUS expr */ |
| 117003 | +{spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UMINUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 117004 | + break; |
| 117005 | + case 222: /* expr ::= PLUS expr */ |
| 117006 | +{spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UPLUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 117007 | + break; |
| 117008 | + case 225: /* expr ::= expr between_op expr AND expr */ |
| 117009 | +{ |
| 117010 | + ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 117011 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| 117012 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 117013 | + if( yygotominor.yy118.pExpr ){ |
| 117014 | + yygotominor.yy118.pExpr->x.pList = pList; |
| 115632 | 117015 | }else{ |
| 115633 | 117016 | sqlite3ExprListDelete(pParse->db, pList); |
| 115634 | 117017 | } |
| 115635 | | - if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 115636 | | - yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 115637 | | - yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 115638 | | -} |
| 115639 | | - break; |
| 115640 | | - case 226: /* expr ::= expr in_op LP exprlist RP */ |
| 115641 | | -{ |
| 115642 | | - if( yymsp[-1].minor.yy442==0 ){ |
| 117018 | + if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 117019 | + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 117020 | + yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 117021 | +} |
| 117022 | + break; |
| 117023 | + case 228: /* expr ::= expr in_op LP exprlist RP */ |
| 117024 | +{ |
| 117025 | + if( yymsp[-1].minor.yy322==0 ){ |
| 115643 | 117026 | /* Expressions of the form |
| 115644 | 117027 | ** |
| 115645 | 117028 | ** expr1 IN () |
| 115646 | 117029 | ** expr1 NOT IN () |
| 115647 | 117030 | ** |
| 115648 | 117031 | ** simplify to constants 0 (false) and 1 (true), respectively, |
| 115649 | 117032 | ** regardless of the value of expr1. |
| 115650 | 117033 | */ |
| 115651 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]); |
| 115652 | | - sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr); |
| 115653 | | - }else{ |
| 115654 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 115655 | | - if( yygotominor.yy342.pExpr ){ |
| 115656 | | - yygotominor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442; |
| 115657 | | - sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr); |
| 115658 | | - }else{ |
| 115659 | | - sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442); |
| 115660 | | - } |
| 115661 | | - if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 115662 | | - } |
| 115663 | | - yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 115664 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115665 | | - } |
| 115666 | | - break; |
| 115667 | | - case 227: /* expr ::= LP select RP */ |
| 115668 | | -{ |
| 115669 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 115670 | | - if( yygotominor.yy342.pExpr ){ |
| 115671 | | - yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159; |
| 115672 | | - ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect); |
| 115673 | | - sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr); |
| 115674 | | - }else{ |
| 115675 | | - sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy159); |
| 115676 | | - } |
| 115677 | | - yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z; |
| 115678 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115679 | | - } |
| 115680 | | - break; |
| 115681 | | - case 228: /* expr ::= expr in_op LP select RP */ |
| 115682 | | -{ |
| 115683 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 115684 | | - if( yygotominor.yy342.pExpr ){ |
| 115685 | | - yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159; |
| 115686 | | - ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect); |
| 115687 | | - sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr); |
| 115688 | | - }else{ |
| 115689 | | - sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy159); |
| 115690 | | - } |
| 115691 | | - if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 115692 | | - yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 115693 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115694 | | - } |
| 115695 | | - break; |
| 115696 | | - case 229: /* expr ::= expr in_op nm dbnm */ |
| 117034 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy4]); |
| 117035 | + sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy118.pExpr); |
| 117036 | + }else{ |
| 117037 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 117038 | + if( yygotominor.yy118.pExpr ){ |
| 117039 | + yygotominor.yy118.pExpr->x.pList = yymsp[-1].minor.yy322; |
| 117040 | + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| 117041 | + }else{ |
| 117042 | + sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322); |
| 117043 | + } |
| 117044 | + if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 117045 | + } |
| 117046 | + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 117047 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 117048 | + } |
| 117049 | + break; |
| 117050 | + case 229: /* expr ::= LP select RP */ |
| 117051 | +{ |
| 117052 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 117053 | + if( yygotominor.yy118.pExpr ){ |
| 117054 | + yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 117055 | + ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| 117056 | + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| 117057 | + }else{ |
| 117058 | + sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 117059 | + } |
| 117060 | + yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; |
| 117061 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 117062 | + } |
| 117063 | + break; |
| 117064 | + case 230: /* expr ::= expr in_op LP select RP */ |
| 117065 | +{ |
| 117066 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 117067 | + if( yygotominor.yy118.pExpr ){ |
| 117068 | + yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 117069 | + ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| 117070 | + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| 117071 | + }else{ |
| 117072 | + sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 117073 | + } |
| 117074 | + if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 117075 | + yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 117076 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 117077 | + } |
| 117078 | + break; |
| 117079 | + case 231: /* expr ::= expr in_op nm dbnm */ |
| 115697 | 117080 | { |
| 115698 | 117081 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 115699 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0); |
| 115700 | | - if( yygotominor.yy342.pExpr ){ |
| 115701 | | - yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| 115702 | | - ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect); |
| 115703 | | - sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr); |
| 117082 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0); |
| 117083 | + if( yygotominor.yy118.pExpr ){ |
| 117084 | + yygotominor.yy118.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| 117085 | + ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| 117086 | + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| 115704 | 117087 | }else{ |
| 115705 | 117088 | sqlite3SrcListDelete(pParse->db, pSrc); |
| 115706 | 117089 | } |
| 115707 | | - if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 115708 | | - yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart; |
| 115709 | | - yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]; |
| 115710 | | - } |
| 115711 | | - break; |
| 115712 | | - case 230: /* expr ::= EXISTS LP select RP */ |
| 115713 | | -{ |
| 115714 | | - Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 117090 | + if( yymsp[-2].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 117091 | + yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; |
| 117092 | + yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]; |
| 117093 | + } |
| 117094 | + break; |
| 117095 | + case 232: /* expr ::= EXISTS LP select RP */ |
| 117096 | +{ |
| 117097 | + Expr *p = yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 115715 | 117098 | if( p ){ |
| 115716 | | - p->x.pSelect = yymsp[-1].minor.yy159; |
| 117099 | + p->x.pSelect = yymsp[-1].minor.yy387; |
| 115717 | 117100 | ExprSetProperty(p, EP_xIsSelect); |
| 115718 | 117101 | sqlite3ExprSetHeight(pParse, p); |
| 115719 | 117102 | }else{ |
| 115720 | | - sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy159); |
| 115721 | | - } |
| 115722 | | - yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z; |
| 115723 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115724 | | - } |
| 115725 | | - break; |
| 115726 | | - case 231: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 115727 | | -{ |
| 115728 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, 0, 0); |
| 115729 | | - if( yygotominor.yy342.pExpr ){ |
| 115730 | | - yygotominor.yy342.pExpr->x.pList = yymsp[-1].minor.yy122 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy122) : yymsp[-2].minor.yy442; |
| 115731 | | - sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr); |
| 115732 | | - }else{ |
| 115733 | | - sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442); |
| 115734 | | - sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy122); |
| 115735 | | - } |
| 115736 | | - yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z; |
| 115737 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115738 | | -} |
| 115739 | | - break; |
| 115740 | | - case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 115741 | | -{ |
| 115742 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr); |
| 115743 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr); |
| 115744 | | -} |
| 115745 | | - break; |
| 115746 | | - case 233: /* case_exprlist ::= WHEN expr THEN expr */ |
| 115747 | | -{ |
| 115748 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 115749 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr); |
| 115750 | | -} |
| 115751 | | - break; |
| 115752 | | - case 240: /* nexprlist ::= nexprlist COMMA expr */ |
| 115753 | | -{yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);} |
| 115754 | | - break; |
| 115755 | | - case 241: /* nexprlist ::= expr */ |
| 115756 | | -{yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);} |
| 115757 | | - break; |
| 115758 | | - case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */ |
| 117103 | + sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 117104 | + } |
| 117105 | + yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 117106 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 117107 | + } |
| 117108 | + break; |
| 117109 | + case 233: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 117110 | +{ |
| 117111 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, 0, 0); |
| 117112 | + if( yygotominor.yy118.pExpr ){ |
| 117113 | + yygotominor.yy118.pExpr->x.pList = yymsp[-1].minor.yy314 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy314) : yymsp[-2].minor.yy322; |
| 117114 | + sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| 117115 | + }else{ |
| 117116 | + sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322); |
| 117117 | + sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy314); |
| 117118 | + } |
| 117119 | + yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; |
| 117120 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 117121 | +} |
| 117122 | + break; |
| 117123 | + case 234: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 117124 | +{ |
| 117125 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr); |
| 117126 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 117127 | +} |
| 117128 | + break; |
| 117129 | + case 235: /* case_exprlist ::= WHEN expr THEN expr */ |
| 117130 | +{ |
| 117131 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 117132 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 117133 | +} |
| 117134 | + break; |
| 117135 | + case 242: /* nexprlist ::= nexprlist COMMA expr */ |
| 117136 | +{yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy118.pExpr);} |
| 117137 | + break; |
| 117138 | + case 243: /* nexprlist ::= expr */ |
| 117139 | +{yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy118.pExpr);} |
| 117140 | + break; |
| 117141 | + case 244: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */ |
| 115759 | 117142 | { |
| 115760 | 117143 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 115761 | | - sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392, |
| 115762 | | - &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392); |
| 115763 | | -} |
| 115764 | | - break; |
| 115765 | | - case 243: /* uniqueflag ::= UNIQUE */ |
| 115766 | | - case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296); |
| 115767 | | -{yygotominor.yy392 = OE_Abort;} |
| 115768 | | - break; |
| 115769 | | - case 244: /* uniqueflag ::= */ |
| 115770 | | -{yygotominor.yy392 = OE_None;} |
| 115771 | | - break; |
| 115772 | | - case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 115773 | | -{ |
| 115774 | | - Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0); |
| 115775 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, p); |
| 115776 | | - sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1); |
| 115777 | | - sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index"); |
| 115778 | | - if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392; |
| 115779 | | -} |
| 115780 | | - break; |
| 115781 | | - case 248: /* idxlist ::= nm collate sortorder */ |
| 115782 | | -{ |
| 115783 | | - Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0); |
| 115784 | | - yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, p); |
| 115785 | | - sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1); |
| 115786 | | - sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index"); |
| 115787 | | - if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392; |
| 115788 | | -} |
| 115789 | | - break; |
| 115790 | | - case 249: /* collate ::= */ |
| 117144 | + sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy4, |
| 117145 | + &yymsp[-11].minor.yy0, yymsp[0].minor.yy314, SQLITE_SO_ASC, yymsp[-8].minor.yy4); |
| 117146 | +} |
| 117147 | + break; |
| 117148 | + case 245: /* uniqueflag ::= UNIQUE */ |
| 117149 | + case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298); |
| 117150 | +{yygotominor.yy4 = OE_Abort;} |
| 117151 | + break; |
| 117152 | + case 246: /* uniqueflag ::= */ |
| 117153 | +{yygotominor.yy4 = OE_None;} |
| 117154 | + break; |
| 117155 | + case 249: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 117156 | +{ |
| 117157 | + Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0); |
| 117158 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, p); |
| 117159 | + sqlite3ExprListSetName(pParse,yygotominor.yy322,&yymsp[-2].minor.yy0,1); |
| 117160 | + sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 117161 | + if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 117162 | +} |
| 117163 | + break; |
| 117164 | + case 250: /* idxlist ::= nm collate sortorder */ |
| 117165 | +{ |
| 117166 | + Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0); |
| 117167 | + yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, p); |
| 117168 | + sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 117169 | + sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 117170 | + if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 117171 | +} |
| 117172 | + break; |
| 117173 | + case 251: /* collate ::= */ |
| 115791 | 117174 | {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;} |
| 115792 | 117175 | break; |
| 115793 | | - case 251: /* cmd ::= DROP INDEX ifexists fullname */ |
| 115794 | | -{sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);} |
| 117176 | + case 253: /* cmd ::= DROP INDEX ifexists fullname */ |
| 117177 | +{sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);} |
| 115795 | 117178 | break; |
| 115796 | | - case 252: /* cmd ::= VACUUM */ |
| 115797 | | - case 253: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==253); |
| 117179 | + case 254: /* cmd ::= VACUUM */ |
| 117180 | + case 255: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==255); |
| 115798 | 117181 | {sqlite3Vacuum(pParse);} |
| 115799 | 117182 | break; |
| 115800 | | - case 254: /* cmd ::= PRAGMA nm dbnm */ |
| 117183 | + case 256: /* cmd ::= PRAGMA nm dbnm */ |
| 115801 | 117184 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 115802 | 117185 | break; |
| 115803 | | - case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 117186 | + case 257: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 115804 | 117187 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 115805 | 117188 | break; |
| 115806 | | - case 256: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 117189 | + case 258: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 115807 | 117190 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 115808 | 117191 | break; |
| 115809 | | - case 257: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 117192 | + case 259: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 115810 | 117193 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 115811 | 117194 | break; |
| 115812 | | - case 258: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 117195 | + case 260: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 115813 | 117196 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 115814 | 117197 | break; |
| 115815 | | - case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 117198 | + case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 115816 | 117199 | { |
| 115817 | 117200 | Token all; |
| 115818 | 117201 | all.z = yymsp[-3].minor.yy0.z; |
| 115819 | 117202 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 115820 | | - sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all); |
| 117203 | + sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all); |
| 115821 | 117204 | } |
| 115822 | 117205 | break; |
| 115823 | | - case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 117206 | + case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 115824 | 117207 | { |
| 115825 | | - sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392); |
| 117208 | + sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4); |
| 115826 | 117209 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 115827 | 117210 | } |
| 115828 | 117211 | break; |
| 115829 | | - case 270: /* trigger_time ::= BEFORE */ |
| 115830 | | - case 273: /* trigger_time ::= */ yytestcase(yyruleno==273); |
| 115831 | | -{ yygotominor.yy392 = TK_BEFORE; } |
| 115832 | | - break; |
| 115833 | | - case 271: /* trigger_time ::= AFTER */ |
| 115834 | | -{ yygotominor.yy392 = TK_AFTER; } |
| 115835 | | - break; |
| 115836 | | - case 272: /* trigger_time ::= INSTEAD OF */ |
| 115837 | | -{ yygotominor.yy392 = TK_INSTEAD;} |
| 115838 | | - break; |
| 115839 | | - case 274: /* trigger_event ::= DELETE|INSERT */ |
| 115840 | | - case 275: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==275); |
| 115841 | | -{yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;} |
| 115842 | | - break; |
| 115843 | | - case 276: /* trigger_event ::= UPDATE OF inscollist */ |
| 115844 | | -{yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;} |
| 115845 | | - break; |
| 115846 | | - case 279: /* when_clause ::= */ |
| 115847 | | - case 301: /* key_opt ::= */ yytestcase(yyruleno==301); |
| 115848 | | -{ yygotominor.yy122 = 0; } |
| 115849 | | - break; |
| 115850 | | - case 280: /* when_clause ::= WHEN expr */ |
| 115851 | | - case 302: /* key_opt ::= KEY expr */ yytestcase(yyruleno==302); |
| 115852 | | -{ yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; } |
| 115853 | | - break; |
| 115854 | | - case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 115855 | | -{ |
| 115856 | | - assert( yymsp[-2].minor.yy327!=0 ); |
| 115857 | | - yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327; |
| 115858 | | - yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327; |
| 115859 | | - yygotominor.yy327 = yymsp[-2].minor.yy327; |
| 115860 | | -} |
| 115861 | | - break; |
| 115862 | | - case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 115863 | | -{ |
| 115864 | | - assert( yymsp[-1].minor.yy327!=0 ); |
| 115865 | | - yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327; |
| 115866 | | - yygotominor.yy327 = yymsp[-1].minor.yy327; |
| 115867 | | -} |
| 115868 | | - break; |
| 115869 | | - case 284: /* trnm ::= nm DOT nm */ |
| 117212 | + case 272: /* trigger_time ::= BEFORE */ |
| 117213 | + case 275: /* trigger_time ::= */ yytestcase(yyruleno==275); |
| 117214 | +{ yygotominor.yy4 = TK_BEFORE; } |
| 117215 | + break; |
| 117216 | + case 273: /* trigger_time ::= AFTER */ |
| 117217 | +{ yygotominor.yy4 = TK_AFTER; } |
| 117218 | + break; |
| 117219 | + case 274: /* trigger_time ::= INSTEAD OF */ |
| 117220 | +{ yygotominor.yy4 = TK_INSTEAD;} |
| 117221 | + break; |
| 117222 | + case 276: /* trigger_event ::= DELETE|INSERT */ |
| 117223 | + case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277); |
| 117224 | +{yygotominor.yy90.a = yymsp[0].major; yygotominor.yy90.b = 0;} |
| 117225 | + break; |
| 117226 | + case 278: /* trigger_event ::= UPDATE OF idlist */ |
| 117227 | +{yygotominor.yy90.a = TK_UPDATE; yygotominor.yy90.b = yymsp[0].minor.yy384;} |
| 117228 | + break; |
| 117229 | + case 281: /* when_clause ::= */ |
| 117230 | + case 303: /* key_opt ::= */ yytestcase(yyruleno==303); |
| 117231 | +{ yygotominor.yy314 = 0; } |
| 117232 | + break; |
| 117233 | + case 282: /* when_clause ::= WHEN expr */ |
| 117234 | + case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304); |
| 117235 | +{ yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; } |
| 117236 | + break; |
| 117237 | + case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 117238 | +{ |
| 117239 | + assert( yymsp[-2].minor.yy203!=0 ); |
| 117240 | + yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203; |
| 117241 | + yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 117242 | + yygotominor.yy203 = yymsp[-2].minor.yy203; |
| 117243 | +} |
| 117244 | + break; |
| 117245 | + case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 117246 | +{ |
| 117247 | + assert( yymsp[-1].minor.yy203!=0 ); |
| 117248 | + yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 117249 | + yygotominor.yy203 = yymsp[-1].minor.yy203; |
| 117250 | +} |
| 117251 | + break; |
| 117252 | + case 286: /* trnm ::= nm DOT nm */ |
| 115870 | 117253 | { |
| 115871 | 117254 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 115872 | 117255 | sqlite3ErrorMsg(pParse, |
| 115873 | 117256 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 115874 | 117257 | "statements within triggers"); |
| 115875 | 117258 | } |
| 115876 | 117259 | break; |
| 115877 | | - case 286: /* tridxby ::= INDEXED BY nm */ |
| 117260 | + case 288: /* tridxby ::= INDEXED BY nm */ |
| 115878 | 117261 | { |
| 115879 | 117262 | sqlite3ErrorMsg(pParse, |
| 115880 | 117263 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 115881 | 117264 | "within triggers"); |
| 115882 | 117265 | } |
| 115883 | 117266 | break; |
| 115884 | | - case 287: /* tridxby ::= NOT INDEXED */ |
| 117267 | + case 289: /* tridxby ::= NOT INDEXED */ |
| 115885 | 117268 | { |
| 115886 | 117269 | sqlite3ErrorMsg(pParse, |
| 115887 | 117270 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 115888 | 117271 | "within triggers"); |
| 115889 | 117272 | } |
| 115890 | 117273 | break; |
| 115891 | | - case 288: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 115892 | | -{ yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); } |
| 115893 | | - break; |
| 115894 | | - case 289: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */ |
| 115895 | | -{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);} |
| 115896 | | - break; |
| 115897 | | - case 290: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 115898 | | -{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);} |
| 115899 | | - break; |
| 115900 | | - case 291: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 115901 | | -{yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);} |
| 115902 | | - break; |
| 115903 | | - case 292: /* trigger_cmd ::= select */ |
| 115904 | | -{yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); } |
| 115905 | | - break; |
| 115906 | | - case 293: /* expr ::= RAISE LP IGNORE RP */ |
| 115907 | | -{ |
| 115908 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 115909 | | - if( yygotominor.yy342.pExpr ){ |
| 115910 | | - yygotominor.yy342.pExpr->affinity = OE_Ignore; |
| 115911 | | - } |
| 115912 | | - yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z; |
| 115913 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115914 | | -} |
| 115915 | | - break; |
| 115916 | | - case 294: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 115917 | | -{ |
| 115918 | | - yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 115919 | | - if( yygotominor.yy342.pExpr ) { |
| 115920 | | - yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392; |
| 115921 | | - } |
| 115922 | | - yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z; |
| 115923 | | - yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 115924 | | -} |
| 115925 | | - break; |
| 115926 | | - case 295: /* raisetype ::= ROLLBACK */ |
| 115927 | | -{yygotominor.yy392 = OE_Rollback;} |
| 115928 | | - break; |
| 115929 | | - case 297: /* raisetype ::= FAIL */ |
| 115930 | | -{yygotominor.yy392 = OE_Fail;} |
| 115931 | | - break; |
| 115932 | | - case 298: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 115933 | | -{ |
| 115934 | | - sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392); |
| 115935 | | -} |
| 115936 | | - break; |
| 115937 | | - case 299: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 115938 | | -{ |
| 115939 | | - sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122); |
| 115940 | | -} |
| 115941 | | - break; |
| 115942 | | - case 300: /* cmd ::= DETACH database_kw_opt expr */ |
| 115943 | | -{ |
| 115944 | | - sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr); |
| 115945 | | -} |
| 115946 | | - break; |
| 115947 | | - case 305: /* cmd ::= REINDEX */ |
| 117274 | + case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 117275 | +{ yygotominor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); } |
| 117276 | + break; |
| 117277 | + case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */ |
| 117278 | +{yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, yymsp[0].minor.yy260.pList, yymsp[0].minor.yy260.pSelect, yymsp[-4].minor.yy210);} |
| 117279 | + break; |
| 117280 | + case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 117281 | +{yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210);} |
| 117282 | + break; |
| 117283 | + case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 117284 | +{yygotominor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy314);} |
| 117285 | + break; |
| 117286 | + case 294: /* trigger_cmd ::= select */ |
| 117287 | +{yygotominor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy387); } |
| 117288 | + break; |
| 117289 | + case 295: /* expr ::= RAISE LP IGNORE RP */ |
| 117290 | +{ |
| 117291 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 117292 | + if( yygotominor.yy118.pExpr ){ |
| 117293 | + yygotominor.yy118.pExpr->affinity = OE_Ignore; |
| 117294 | + } |
| 117295 | + yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 117296 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 117297 | +} |
| 117298 | + break; |
| 117299 | + case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 117300 | +{ |
| 117301 | + yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 117302 | + if( yygotominor.yy118.pExpr ) { |
| 117303 | + yygotominor.yy118.pExpr->affinity = (char)yymsp[-3].minor.yy4; |
| 117304 | + } |
| 117305 | + yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; |
| 117306 | + yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 117307 | +} |
| 117308 | + break; |
| 117309 | + case 297: /* raisetype ::= ROLLBACK */ |
| 117310 | +{yygotominor.yy4 = OE_Rollback;} |
| 117311 | + break; |
| 117312 | + case 299: /* raisetype ::= FAIL */ |
| 117313 | +{yygotominor.yy4 = OE_Fail;} |
| 117314 | + break; |
| 117315 | + case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 117316 | +{ |
| 117317 | + sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4); |
| 117318 | +} |
| 117319 | + break; |
| 117320 | + case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 117321 | +{ |
| 117322 | + sqlite3Attach(pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314); |
| 117323 | +} |
| 117324 | + break; |
| 117325 | + case 302: /* cmd ::= DETACH database_kw_opt expr */ |
| 117326 | +{ |
| 117327 | + sqlite3Detach(pParse, yymsp[0].minor.yy118.pExpr); |
| 117328 | +} |
| 117329 | + break; |
| 117330 | + case 307: /* cmd ::= REINDEX */ |
| 115948 | 117331 | {sqlite3Reindex(pParse, 0, 0);} |
| 115949 | 117332 | break; |
| 115950 | | - case 306: /* cmd ::= REINDEX nm dbnm */ |
| 117333 | + case 308: /* cmd ::= REINDEX nm dbnm */ |
| 115951 | 117334 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 115952 | 117335 | break; |
| 115953 | | - case 307: /* cmd ::= ANALYZE */ |
| 117336 | + case 309: /* cmd ::= ANALYZE */ |
| 115954 | 117337 | {sqlite3Analyze(pParse, 0, 0);} |
| 115955 | 117338 | break; |
| 115956 | | - case 308: /* cmd ::= ANALYZE nm dbnm */ |
| 117339 | + case 310: /* cmd ::= ANALYZE nm dbnm */ |
| 115957 | 117340 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 115958 | 117341 | break; |
| 115959 | | - case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 117342 | + case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 115960 | 117343 | { |
| 115961 | | - sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0); |
| 117344 | + sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0); |
| 115962 | 117345 | } |
| 115963 | 117346 | break; |
| 115964 | | - case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 117347 | + case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 115965 | 117348 | { |
| 115966 | 117349 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 115967 | 117350 | } |
| 115968 | 117351 | break; |
| 115969 | | - case 311: /* add_column_fullname ::= fullname */ |
| 117352 | + case 313: /* add_column_fullname ::= fullname */ |
| 115970 | 117353 | { |
| 115971 | 117354 | pParse->db->lookaside.bEnabled = 0; |
| 115972 | | - sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347); |
| 117355 | + sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259); |
| 115973 | 117356 | } |
| 115974 | 117357 | break; |
| 115975 | | - case 314: /* cmd ::= create_vtab */ |
| 117358 | + case 316: /* cmd ::= create_vtab */ |
| 115976 | 117359 | {sqlite3VtabFinishParse(pParse,0);} |
| 115977 | 117360 | break; |
| 115978 | | - case 315: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 117361 | + case 317: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 115979 | 117362 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 115980 | 117363 | break; |
| 115981 | | - case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 117364 | + case 318: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 115982 | 117365 | { |
| 115983 | | - sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392); |
| 117366 | + sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy4); |
| 115984 | 117367 | } |
| 115985 | 117368 | break; |
| 115986 | | - case 319: /* vtabarg ::= */ |
| 117369 | + case 321: /* vtabarg ::= */ |
| 115987 | 117370 | {sqlite3VtabArgInit(pParse);} |
| 115988 | 117371 | break; |
| 115989 | | - case 321: /* vtabargtoken ::= ANY */ |
| 115990 | | - case 322: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==322); |
| 115991 | | - case 323: /* lp ::= LP */ yytestcase(yyruleno==323); |
| 117372 | + case 323: /* vtabargtoken ::= ANY */ |
| 117373 | + case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324); |
| 117374 | + case 325: /* lp ::= LP */ yytestcase(yyruleno==325); |
| 115992 | 117375 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 115993 | 117376 | break; |
| 115994 | 117377 | default: |
| 115995 | 117378 | /* (0) input ::= cmdlist */ yytestcase(yyruleno==0); |
| 115996 | 117379 | /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1); |
| | @@ -116001,34 +117384,34 @@ |
| 116001 | 117384 | /* (11) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==11); |
| 116002 | 117385 | /* (12) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==12); |
| 116003 | 117386 | /* (20) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==20); |
| 116004 | 117387 | /* (21) savepoint_opt ::= */ yytestcase(yyruleno==21); |
| 116005 | 117388 | /* (25) cmd ::= create_table create_table_args */ yytestcase(yyruleno==25); |
| 116006 | | - /* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34); |
| 116007 | | - /* (35) columnlist ::= column */ yytestcase(yyruleno==35); |
| 116008 | | - /* (44) type ::= */ yytestcase(yyruleno==44); |
| 116009 | | - /* (51) signed ::= plus_num */ yytestcase(yyruleno==51); |
| 116010 | | - /* (52) signed ::= minus_num */ yytestcase(yyruleno==52); |
| 116011 | | - /* (53) carglist ::= carglist ccons */ yytestcase(yyruleno==53); |
| 116012 | | - /* (54) carglist ::= */ yytestcase(yyruleno==54); |
| 116013 | | - /* (61) ccons ::= NULL onconf */ yytestcase(yyruleno==61); |
| 116014 | | - /* (89) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==89); |
| 116015 | | - /* (90) conslist ::= tcons */ yytestcase(yyruleno==90); |
| 116016 | | - /* (92) tconscomma ::= */ yytestcase(yyruleno==92); |
| 116017 | | - /* (277) foreach_clause ::= */ yytestcase(yyruleno==277); |
| 116018 | | - /* (278) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==278); |
| 116019 | | - /* (285) tridxby ::= */ yytestcase(yyruleno==285); |
| 116020 | | - /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303); |
| 116021 | | - /* (304) database_kw_opt ::= */ yytestcase(yyruleno==304); |
| 116022 | | - /* (312) kwcolumn_opt ::= */ yytestcase(yyruleno==312); |
| 116023 | | - /* (313) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==313); |
| 116024 | | - /* (317) vtabarglist ::= vtabarg */ yytestcase(yyruleno==317); |
| 116025 | | - /* (318) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==318); |
| 116026 | | - /* (320) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==320); |
| 116027 | | - /* (324) anylist ::= */ yytestcase(yyruleno==324); |
| 116028 | | - /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325); |
| 116029 | | - /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326); |
| 117389 | + /* (36) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==36); |
| 117390 | + /* (37) columnlist ::= column */ yytestcase(yyruleno==37); |
| 117391 | + /* (46) type ::= */ yytestcase(yyruleno==46); |
| 117392 | + /* (53) signed ::= plus_num */ yytestcase(yyruleno==53); |
| 117393 | + /* (54) signed ::= minus_num */ yytestcase(yyruleno==54); |
| 117394 | + /* (55) carglist ::= carglist ccons */ yytestcase(yyruleno==55); |
| 117395 | + /* (56) carglist ::= */ yytestcase(yyruleno==56); |
| 117396 | + /* (63) ccons ::= NULL onconf */ yytestcase(yyruleno==63); |
| 117397 | + /* (91) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==91); |
| 117398 | + /* (92) conslist ::= tcons */ yytestcase(yyruleno==92); |
| 117399 | + /* (94) tconscomma ::= */ yytestcase(yyruleno==94); |
| 117400 | + /* (279) foreach_clause ::= */ yytestcase(yyruleno==279); |
| 117401 | + /* (280) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==280); |
| 117402 | + /* (287) tridxby ::= */ yytestcase(yyruleno==287); |
| 117403 | + /* (305) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==305); |
| 117404 | + /* (306) database_kw_opt ::= */ yytestcase(yyruleno==306); |
| 117405 | + /* (314) kwcolumn_opt ::= */ yytestcase(yyruleno==314); |
| 117406 | + /* (315) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==315); |
| 117407 | + /* (319) vtabarglist ::= vtabarg */ yytestcase(yyruleno==319); |
| 117408 | + /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==320); |
| 117409 | + /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322); |
| 117410 | + /* (326) anylist ::= */ yytestcase(yyruleno==326); |
| 117411 | + /* (327) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==327); |
| 117412 | + /* (328) anylist ::= anylist ANY */ yytestcase(yyruleno==328); |
| 116030 | 117413 | break; |
| 116031 | 117414 | }; |
| 116032 | 117415 | assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); |
| 116033 | 117416 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 116034 | 117417 | yysize = yyRuleInfo[yyruleno].nrhs; |
| | @@ -116363,24 +117746,24 @@ |
| 116363 | 117746 | ** might be implemented more directly using a hand-written hash table. |
| 116364 | 117747 | ** But by using this automatically generated code, the size of the code |
| 116365 | 117748 | ** is substantially reduced. This is important for embedded applications |
| 116366 | 117749 | ** on platforms with limited memory. |
| 116367 | 117750 | */ |
| 116368 | | -/* Hash score: 175 */ |
| 117751 | +/* Hash score: 177 */ |
| 116369 | 117752 | static int keywordCode(const char *z, int n){ |
| 116370 | | - /* zText[] encodes 811 bytes of keywords in 541 bytes */ |
| 117753 | + /* zText[] encodes 819 bytes of keywords in 545 bytes */ |
| 116371 | 117754 | /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ |
| 116372 | 117755 | /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */ |
| 116373 | 117756 | /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */ |
| 116374 | | - /* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */ |
| 116375 | | - /* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */ |
| 116376 | | - /* SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME */ |
| 116377 | | - /* AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */ |
| 116378 | | - /* CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF */ |
| 116379 | | - /* ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */ |
| 117757 | + /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERENAMEBETWEEN */ |
| 117758 | + /* OTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */ |
| 117759 | + /* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */ |
| 117760 | + /* WHEREPLACEAFTERESTRICTANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */ |
| 117761 | + /* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */ |
| 117762 | + /* FROMFULLGLOBYIFISNULLORDERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */ |
| 116380 | 117763 | /* INITIALLY */ |
| 116381 | | - static const char zText[540] = { |
| 117764 | + static const char zText[544] = { |
| 116382 | 117765 | 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H', |
| 116383 | 117766 | 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G', |
| 116384 | 117767 | 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A', |
| 116385 | 117768 | 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F', |
| 116386 | 117769 | 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N', |
| | @@ -116387,105 +117770,106 @@ |
| 116387 | 117770 | 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I', |
| 116388 | 117771 | 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E', |
| 116389 | 117772 | 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E', |
| 116390 | 117773 | 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T', |
| 116391 | 117774 | 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q', |
| 116392 | | - 'U','E','R','Y','A','T','T','A','C','H','A','V','I','N','G','R','O','U', |
| 116393 | | - 'P','D','A','T','E','B','E','G','I','N','N','E','R','E','L','E','A','S', |
| 116394 | | - 'E','B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C', |
| 116395 | | - 'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L', |
| 116396 | | - 'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D', |
| 116397 | | - 'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E', |
| 116398 | | - 'J','O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A', |
| 116399 | | - 'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U', |
| 116400 | | - 'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W', |
| 116401 | | - 'H','E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C', |
| 116402 | | - 'E','A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R', |
| 116403 | | - 'E','M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M', |
| 116404 | | - 'M','I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U', |
| 116405 | | - 'R','R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M', |
| 116406 | | - 'A','R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T', |
| 116407 | | - 'D','R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L', |
| 116408 | | - 'O','B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S', |
| 116409 | | - 'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L', |
| 116410 | | - 'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V', |
| 116411 | | - 'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y', |
| 117775 | + 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S', |
| 117776 | + 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A', |
| 117777 | + 'T','E','B','E','G','I','N','N','E','R','E','N','A','M','E','B','E','T', |
| 117778 | + 'W','E','E','N','O','T','N','U','L','L','I','K','E','C','A','S','C','A', |
| 117779 | + 'D','E','L','E','T','E','C','A','S','E','C','O','L','L','A','T','E','C', |
| 117780 | + 'R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E','D', |
| 117781 | + 'E','T','A','C','H','I','M','M','E','D','I','A','T','E','J','O','I','N', |
| 117782 | + 'S','E','R','T','M','A','T','C','H','P','L','A','N','A','L','Y','Z','E', |
| 117783 | + 'P','R','A','G','M','A','B','O','R','T','V','A','L','U','E','S','V','I', |
| 117784 | + 'R','T','U','A','L','I','M','I','T','W','H','E','N','W','H','E','R','E', |
| 117785 | + 'P','L','A','C','E','A','F','T','E','R','E','S','T','R','I','C','T','A', |
| 117786 | + 'N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E','M', |
| 117787 | + 'E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M','I', |
| 117788 | + 'T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R','R', |
| 117789 | + 'E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A','R', |
| 117790 | + 'Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D','R', |
| 117791 | + 'O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O','B', |
| 117792 | + 'Y','I','F','I','S','N','U','L','L','O','R','D','E','R','I','G','H','T', |
| 117793 | + 'R','O','L','L','B','A','C','K','R','O','W','U','N','I','O','N','U','S', |
| 117794 | + 'I','N','G','V','A','C','U','U','M','V','I','E','W','I','N','I','T','I', |
| 117795 | + 'A','L','L','Y', |
| 116412 | 117796 | }; |
| 116413 | 117797 | static const unsigned char aHash[127] = { |
| 116414 | | - 72, 101, 114, 70, 0, 45, 0, 0, 78, 0, 73, 0, 0, |
| 116415 | | - 42, 12, 74, 15, 0, 113, 81, 50, 108, 0, 19, 0, 0, |
| 116416 | | - 118, 0, 116, 111, 0, 22, 89, 0, 9, 0, 0, 66, 67, |
| 116417 | | - 0, 65, 6, 0, 48, 86, 98, 0, 115, 97, 0, 0, 44, |
| 116418 | | - 0, 99, 24, 0, 17, 0, 119, 49, 23, 0, 5, 106, 25, |
| 116419 | | - 92, 0, 0, 121, 102, 56, 120, 53, 28, 51, 0, 87, 0, |
| 116420 | | - 96, 26, 0, 95, 0, 0, 0, 91, 88, 93, 84, 105, 14, |
| 116421 | | - 39, 104, 0, 77, 0, 18, 85, 107, 32, 0, 117, 76, 109, |
| 116422 | | - 58, 46, 80, 0, 0, 90, 40, 0, 112, 0, 36, 0, 0, |
| 116423 | | - 29, 0, 82, 59, 60, 0, 20, 57, 0, 52, |
| 117798 | + 75, 104, 115, 73, 0, 45, 0, 0, 81, 0, 76, 0, 0, |
| 117799 | + 42, 12, 77, 15, 0, 114, 84, 53, 111, 0, 19, 0, 0, |
| 117800 | + 119, 0, 117, 88, 0, 22, 92, 0, 9, 0, 0, 69, 70, |
| 117801 | + 0, 68, 6, 0, 48, 89, 101, 0, 116, 100, 0, 0, 44, |
| 117802 | + 0, 102, 24, 0, 17, 0, 120, 52, 23, 0, 5, 109, 25, |
| 117803 | + 95, 0, 0, 122, 105, 59, 121, 56, 28, 54, 0, 90, 0, |
| 117804 | + 99, 26, 0, 98, 0, 0, 0, 94, 91, 96, 87, 108, 14, |
| 117805 | + 39, 107, 0, 80, 0, 18, 86, 110, 32, 0, 118, 79, 112, |
| 117806 | + 61, 46, 83, 0, 0, 93, 40, 0, 113, 0, 36, 0, 0, |
| 117807 | + 29, 0, 85, 62, 63, 0, 20, 60, 0, 55, |
| 116424 | 117808 | }; |
| 116425 | | - static const unsigned char aNext[121] = { |
| 117809 | + static const unsigned char aNext[122] = { |
| 116426 | 117810 | 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, |
| 116427 | 117811 | 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, |
| 116428 | 117812 | 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 116429 | | - 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 43, 3, 47, |
| 116430 | | - 0, 0, 0, 0, 30, 0, 54, 0, 38, 0, 0, 0, 1, |
| 116431 | | - 62, 0, 0, 63, 0, 41, 0, 0, 0, 0, 0, 0, 0, |
| 116432 | | - 61, 0, 0, 0, 0, 31, 55, 16, 34, 10, 0, 0, 0, |
| 116433 | | - 0, 0, 0, 0, 11, 68, 75, 0, 8, 0, 100, 94, 0, |
| 116434 | | - 103, 0, 83, 0, 71, 0, 0, 110, 27, 37, 69, 79, 0, |
| 116435 | | - 35, 64, 0, 0, |
| 117813 | + 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 0, |
| 117814 | + 43, 3, 47, 0, 0, 0, 0, 30, 0, 57, 0, 38, 0, |
| 117815 | + 0, 0, 1, 65, 0, 0, 66, 0, 41, 0, 0, 0, 0, |
| 117816 | + 0, 0, 49, 64, 0, 0, 0, 51, 31, 0, 16, 34, 10, |
| 117817 | + 0, 0, 0, 0, 0, 0, 0, 11, 71, 78, 0, 8, 0, |
| 117818 | + 103, 97, 0, 106, 0, 58, 0, 74, 50, 27, 37, 72, 82, |
| 117819 | + 0, 35, 67, 0, 0, |
| 116436 | 117820 | }; |
| 116437 | | - static const unsigned char aLen[121] = { |
| 117821 | + static const unsigned char aLen[122] = { |
| 116438 | 117822 | 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, |
| 116439 | 117823 | 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6, |
| 116440 | 117824 | 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, |
| 116441 | | - 4, 6, 2, 3, 9, 4, 2, 6, 5, 6, 6, 5, 6, |
| 116442 | | - 5, 5, 7, 7, 7, 3, 2, 4, 4, 7, 3, 6, 4, |
| 116443 | | - 7, 6, 12, 6, 9, 4, 6, 5, 4, 7, 6, 5, 6, |
| 116444 | | - 7, 5, 4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4, |
| 116445 | | - 6, 6, 8, 5, 17, 12, 7, 8, 8, 2, 4, 4, 4, |
| 116446 | | - 4, 4, 2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5, |
| 116447 | | - 6, 4, 9, 3, |
| 117825 | + 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 5, 7, 6, |
| 117826 | + 6, 5, 6, 5, 5, 6, 7, 7, 3, 2, 4, 4, 7, |
| 117827 | + 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4, 7, |
| 117828 | + 6, 5, 6, 7, 5, 4, 5, 7, 5, 8, 3, 7, 13, |
| 117829 | + 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8, 2, |
| 117830 | + 4, 4, 4, 4, 4, 2, 2, 6, 5, 5, 8, 3, 5, |
| 117831 | + 5, 6, 4, 9, 3, |
| 116448 | 117832 | }; |
| 116449 | | - static const unsigned short int aOffset[121] = { |
| 117833 | + static const unsigned short int aOffset[122] = { |
| 116450 | 117834 | 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, |
| 116451 | 117835 | 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, |
| 116452 | 117836 | 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, |
| 116453 | | - 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197, |
| 116454 | | - 203, 206, 210, 217, 223, 223, 223, 226, 229, 233, 234, 238, 244, |
| 116455 | | - 248, 255, 261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320, |
| 116456 | | - 326, 332, 337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383, |
| 116457 | | - 387, 393, 399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458, |
| 116458 | | - 462, 466, 469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516, |
| 116459 | | - 521, 527, 531, 536, |
| 117837 | + 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 188, 192, 199, |
| 117838 | + 204, 209, 212, 218, 221, 225, 231, 237, 237, 237, 240, 243, 247, |
| 117839 | + 248, 252, 258, 262, 269, 275, 287, 293, 302, 304, 310, 315, 317, |
| 117840 | + 324, 329, 334, 340, 346, 351, 355, 358, 365, 369, 377, 379, 386, |
| 117841 | + 388, 390, 399, 403, 409, 415, 423, 428, 428, 444, 451, 458, 459, |
| 117842 | + 466, 470, 474, 478, 482, 485, 487, 489, 495, 499, 504, 512, 515, |
| 117843 | + 520, 525, 531, 535, 540, |
| 116460 | 117844 | }; |
| 116461 | | - static const unsigned char aCode[121] = { |
| 117845 | + static const unsigned char aCode[122] = { |
| 116462 | 117846 | TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, |
| 116463 | 117847 | TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, |
| 116464 | 117848 | TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, |
| 116465 | 117849 | TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, |
| 116466 | 117850 | TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, |
| 116467 | 117851 | TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, |
| 116468 | 117852 | TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, |
| 116469 | 117853 | TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, |
| 116470 | 117854 | TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP, |
| 116471 | | - TK_OR, TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, |
| 116472 | | - TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, |
| 116473 | | - TK_BETWEEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, |
| 116474 | | - TK_LIKE_KW, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, |
| 116475 | | - TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, |
| 116476 | | - TK_JOIN, TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, |
| 116477 | | - TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, |
| 116478 | | - TK_WHEN, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, |
| 116479 | | - TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, |
| 116480 | | - TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, |
| 116481 | | - TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, |
| 116482 | | - TK_IS, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, |
| 116483 | | - TK_LIKE_KW, TK_BY, TK_IF, TK_ISNULL, TK_ORDER, |
| 116484 | | - TK_RESTRICT, TK_JOIN_KW, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, |
| 116485 | | - TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY, |
| 116486 | | - TK_ALL, |
| 117855 | + TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_JOIN_KW, |
| 117856 | + TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP, TK_UPDATE, |
| 117857 | + TK_BEGIN, TK_JOIN_KW, TK_RENAME, TK_BETWEEN, TK_NOTNULL, |
| 117858 | + TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW, TK_CASCADE, |
| 117859 | + TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, |
| 117860 | + TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, |
| 117861 | + TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, |
| 117862 | + TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_WHERE, |
| 117863 | + TK_REPLACE, TK_AFTER, TK_RESTRICT, TK_AND, TK_DEFAULT, |
| 117864 | + TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, |
| 117865 | + TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, |
| 117866 | + TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP, |
| 117867 | + TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW, TK_BY, |
| 117868 | + TK_IF, TK_ISNULL, TK_ORDER, TK_JOIN_KW, TK_ROLLBACK, |
| 117869 | + TK_ROW, TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, |
| 117870 | + TK_INITIALLY, TK_ALL, |
| 116487 | 117871 | }; |
| 116488 | 117872 | int h, i; |
| 116489 | 117873 | if( n<2 ) return TK_ID; |
| 116490 | 117874 | h = ((charMap(z[0])*4) ^ |
| 116491 | 117875 | (charMap(z[n-1])*3) ^ |
| | @@ -116538,92 +117922,93 @@ |
| 116538 | 117922 | testcase( i==43 ); /* TEMPORARY */ |
| 116539 | 117923 | testcase( i==44 ); /* TEMP */ |
| 116540 | 117924 | testcase( i==45 ); /* OR */ |
| 116541 | 117925 | testcase( i==46 ); /* UNIQUE */ |
| 116542 | 117926 | testcase( i==47 ); /* QUERY */ |
| 116543 | | - testcase( i==48 ); /* ATTACH */ |
| 116544 | | - testcase( i==49 ); /* HAVING */ |
| 116545 | | - testcase( i==50 ); /* GROUP */ |
| 116546 | | - testcase( i==51 ); /* UPDATE */ |
| 116547 | | - testcase( i==52 ); /* BEGIN */ |
| 116548 | | - testcase( i==53 ); /* INNER */ |
| 116549 | | - testcase( i==54 ); /* RELEASE */ |
| 116550 | | - testcase( i==55 ); /* BETWEEN */ |
| 116551 | | - testcase( i==56 ); /* NOTNULL */ |
| 116552 | | - testcase( i==57 ); /* NOT */ |
| 116553 | | - testcase( i==58 ); /* NO */ |
| 116554 | | - testcase( i==59 ); /* NULL */ |
| 116555 | | - testcase( i==60 ); /* LIKE */ |
| 116556 | | - testcase( i==61 ); /* CASCADE */ |
| 116557 | | - testcase( i==62 ); /* ASC */ |
| 116558 | | - testcase( i==63 ); /* DELETE */ |
| 116559 | | - testcase( i==64 ); /* CASE */ |
| 116560 | | - testcase( i==65 ); /* COLLATE */ |
| 116561 | | - testcase( i==66 ); /* CREATE */ |
| 116562 | | - testcase( i==67 ); /* CURRENT_DATE */ |
| 116563 | | - testcase( i==68 ); /* DETACH */ |
| 116564 | | - testcase( i==69 ); /* IMMEDIATE */ |
| 116565 | | - testcase( i==70 ); /* JOIN */ |
| 116566 | | - testcase( i==71 ); /* INSERT */ |
| 116567 | | - testcase( i==72 ); /* MATCH */ |
| 116568 | | - testcase( i==73 ); /* PLAN */ |
| 116569 | | - testcase( i==74 ); /* ANALYZE */ |
| 116570 | | - testcase( i==75 ); /* PRAGMA */ |
| 116571 | | - testcase( i==76 ); /* ABORT */ |
| 116572 | | - testcase( i==77 ); /* VALUES */ |
| 116573 | | - testcase( i==78 ); /* VIRTUAL */ |
| 116574 | | - testcase( i==79 ); /* LIMIT */ |
| 116575 | | - testcase( i==80 ); /* WHEN */ |
| 116576 | | - testcase( i==81 ); /* WHERE */ |
| 116577 | | - testcase( i==82 ); /* RENAME */ |
| 116578 | | - testcase( i==83 ); /* AFTER */ |
| 116579 | | - testcase( i==84 ); /* REPLACE */ |
| 116580 | | - testcase( i==85 ); /* AND */ |
| 116581 | | - testcase( i==86 ); /* DEFAULT */ |
| 116582 | | - testcase( i==87 ); /* AUTOINCREMENT */ |
| 116583 | | - testcase( i==88 ); /* TO */ |
| 116584 | | - testcase( i==89 ); /* IN */ |
| 116585 | | - testcase( i==90 ); /* CAST */ |
| 116586 | | - testcase( i==91 ); /* COLUMN */ |
| 116587 | | - testcase( i==92 ); /* COMMIT */ |
| 116588 | | - testcase( i==93 ); /* CONFLICT */ |
| 116589 | | - testcase( i==94 ); /* CROSS */ |
| 116590 | | - testcase( i==95 ); /* CURRENT_TIMESTAMP */ |
| 116591 | | - testcase( i==96 ); /* CURRENT_TIME */ |
| 116592 | | - testcase( i==97 ); /* PRIMARY */ |
| 116593 | | - testcase( i==98 ); /* DEFERRED */ |
| 116594 | | - testcase( i==99 ); /* DISTINCT */ |
| 116595 | | - testcase( i==100 ); /* IS */ |
| 116596 | | - testcase( i==101 ); /* DROP */ |
| 116597 | | - testcase( i==102 ); /* FAIL */ |
| 116598 | | - testcase( i==103 ); /* FROM */ |
| 116599 | | - testcase( i==104 ); /* FULL */ |
| 116600 | | - testcase( i==105 ); /* GLOB */ |
| 116601 | | - testcase( i==106 ); /* BY */ |
| 116602 | | - testcase( i==107 ); /* IF */ |
| 116603 | | - testcase( i==108 ); /* ISNULL */ |
| 116604 | | - testcase( i==109 ); /* ORDER */ |
| 116605 | | - testcase( i==110 ); /* RESTRICT */ |
| 116606 | | - testcase( i==111 ); /* OUTER */ |
| 116607 | | - testcase( i==112 ); /* RIGHT */ |
| 116608 | | - testcase( i==113 ); /* ROLLBACK */ |
| 116609 | | - testcase( i==114 ); /* ROW */ |
| 116610 | | - testcase( i==115 ); /* UNION */ |
| 116611 | | - testcase( i==116 ); /* USING */ |
| 116612 | | - testcase( i==117 ); /* VACUUM */ |
| 116613 | | - testcase( i==118 ); /* VIEW */ |
| 116614 | | - testcase( i==119 ); /* INITIALLY */ |
| 116615 | | - testcase( i==120 ); /* ALL */ |
| 117927 | + testcase( i==48 ); /* WITHOUT */ |
| 117928 | + testcase( i==49 ); /* OUTER */ |
| 117929 | + testcase( i==50 ); /* RELEASE */ |
| 117930 | + testcase( i==51 ); /* ATTACH */ |
| 117931 | + testcase( i==52 ); /* HAVING */ |
| 117932 | + testcase( i==53 ); /* GROUP */ |
| 117933 | + testcase( i==54 ); /* UPDATE */ |
| 117934 | + testcase( i==55 ); /* BEGIN */ |
| 117935 | + testcase( i==56 ); /* INNER */ |
| 117936 | + testcase( i==57 ); /* RENAME */ |
| 117937 | + testcase( i==58 ); /* BETWEEN */ |
| 117938 | + testcase( i==59 ); /* NOTNULL */ |
| 117939 | + testcase( i==60 ); /* NOT */ |
| 117940 | + testcase( i==61 ); /* NO */ |
| 117941 | + testcase( i==62 ); /* NULL */ |
| 117942 | + testcase( i==63 ); /* LIKE */ |
| 117943 | + testcase( i==64 ); /* CASCADE */ |
| 117944 | + testcase( i==65 ); /* ASC */ |
| 117945 | + testcase( i==66 ); /* DELETE */ |
| 117946 | + testcase( i==67 ); /* CASE */ |
| 117947 | + testcase( i==68 ); /* COLLATE */ |
| 117948 | + testcase( i==69 ); /* CREATE */ |
| 117949 | + testcase( i==70 ); /* CURRENT_DATE */ |
| 117950 | + testcase( i==71 ); /* DETACH */ |
| 117951 | + testcase( i==72 ); /* IMMEDIATE */ |
| 117952 | + testcase( i==73 ); /* JOIN */ |
| 117953 | + testcase( i==74 ); /* INSERT */ |
| 117954 | + testcase( i==75 ); /* MATCH */ |
| 117955 | + testcase( i==76 ); /* PLAN */ |
| 117956 | + testcase( i==77 ); /* ANALYZE */ |
| 117957 | + testcase( i==78 ); /* PRAGMA */ |
| 117958 | + testcase( i==79 ); /* ABORT */ |
| 117959 | + testcase( i==80 ); /* VALUES */ |
| 117960 | + testcase( i==81 ); /* VIRTUAL */ |
| 117961 | + testcase( i==82 ); /* LIMIT */ |
| 117962 | + testcase( i==83 ); /* WHEN */ |
| 117963 | + testcase( i==84 ); /* WHERE */ |
| 117964 | + testcase( i==85 ); /* REPLACE */ |
| 117965 | + testcase( i==86 ); /* AFTER */ |
| 117966 | + testcase( i==87 ); /* RESTRICT */ |
| 117967 | + testcase( i==88 ); /* AND */ |
| 117968 | + testcase( i==89 ); /* DEFAULT */ |
| 117969 | + testcase( i==90 ); /* AUTOINCREMENT */ |
| 117970 | + testcase( i==91 ); /* TO */ |
| 117971 | + testcase( i==92 ); /* IN */ |
| 117972 | + testcase( i==93 ); /* CAST */ |
| 117973 | + testcase( i==94 ); /* COLUMN */ |
| 117974 | + testcase( i==95 ); /* COMMIT */ |
| 117975 | + testcase( i==96 ); /* CONFLICT */ |
| 117976 | + testcase( i==97 ); /* CROSS */ |
| 117977 | + testcase( i==98 ); /* CURRENT_TIMESTAMP */ |
| 117978 | + testcase( i==99 ); /* CURRENT_TIME */ |
| 117979 | + testcase( i==100 ); /* PRIMARY */ |
| 117980 | + testcase( i==101 ); /* DEFERRED */ |
| 117981 | + testcase( i==102 ); /* DISTINCT */ |
| 117982 | + testcase( i==103 ); /* IS */ |
| 117983 | + testcase( i==104 ); /* DROP */ |
| 117984 | + testcase( i==105 ); /* FAIL */ |
| 117985 | + testcase( i==106 ); /* FROM */ |
| 117986 | + testcase( i==107 ); /* FULL */ |
| 117987 | + testcase( i==108 ); /* GLOB */ |
| 117988 | + testcase( i==109 ); /* BY */ |
| 117989 | + testcase( i==110 ); /* IF */ |
| 117990 | + testcase( i==111 ); /* ISNULL */ |
| 117991 | + testcase( i==112 ); /* ORDER */ |
| 117992 | + testcase( i==113 ); /* RIGHT */ |
| 117993 | + testcase( i==114 ); /* ROLLBACK */ |
| 117994 | + testcase( i==115 ); /* ROW */ |
| 117995 | + testcase( i==116 ); /* UNION */ |
| 117996 | + testcase( i==117 ); /* USING */ |
| 117997 | + testcase( i==118 ); /* VACUUM */ |
| 117998 | + testcase( i==119 ); /* VIEW */ |
| 117999 | + testcase( i==120 ); /* INITIALLY */ |
| 118000 | + testcase( i==121 ); /* ALL */ |
| 116616 | 118001 | return aCode[i]; |
| 116617 | 118002 | } |
| 116618 | 118003 | } |
| 116619 | 118004 | return TK_ID; |
| 116620 | 118005 | } |
| 116621 | 118006 | SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){ |
| 116622 | 118007 | return keywordCode((char*)z, n); |
| 116623 | 118008 | } |
| 116624 | | -#define SQLITE_N_KEYWORD 121 |
| 118009 | +#define SQLITE_N_KEYWORD 122 |
| 116625 | 118010 | |
| 116626 | 118011 | /************** End of keywordhash.h *****************************************/ |
| 116627 | 118012 | /************** Continuing where we left off in tokenize.c *******************/ |
| 116628 | 118013 | |
| 116629 | 118014 | |
| | @@ -117066,11 +118451,10 @@ |
| 117066 | 118451 | } |
| 117067 | 118452 | |
| 117068 | 118453 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
| 117069 | 118454 | for(i=pParse->nzVar-1; i>=0; i--) sqlite3DbFree(db, pParse->azVar[i]); |
| 117070 | 118455 | sqlite3DbFree(db, pParse->azVar); |
| 117071 | | - sqlite3DbFree(db, pParse->aAlias); |
| 117072 | 118456 | while( pParse->pAinc ){ |
| 117073 | 118457 | AutoincInfo *p = pParse->pAinc; |
| 117074 | 118458 | pParse->pAinc = p->pNext; |
| 117075 | 118459 | sqlite3DbFree(db, p); |
| 117076 | 118460 | } |
| | @@ -118594,10 +119978,11 @@ |
| 118594 | 119978 | case SQLITE_CONSTRAINT_COMMITHOOK: |
| 118595 | 119979 | zName = "SQLITE_CONSTRAINT_COMMITHOOK"; break; |
| 118596 | 119980 | case SQLITE_CONSTRAINT_VTAB: zName = "SQLITE_CONSTRAINT_VTAB"; break; |
| 118597 | 119981 | case SQLITE_CONSTRAINT_FUNCTION: |
| 118598 | 119982 | zName = "SQLITE_CONSTRAINT_FUNCTION"; break; |
| 119983 | + case SQLITE_CONSTRAINT_ROWID: zName = "SQLITE_CONSTRAINT_ROWID"; break; |
| 118599 | 119984 | case SQLITE_MISMATCH: zName = "SQLITE_MISMATCH"; break; |
| 118600 | 119985 | case SQLITE_MISUSE: zName = "SQLITE_MISUSE"; break; |
| 118601 | 119986 | case SQLITE_NOLFS: zName = "SQLITE_NOLFS"; break; |
| 118602 | 119987 | case SQLITE_AUTH: zName = "SQLITE_AUTH"; break; |
| 118603 | 119988 | case SQLITE_FORMAT: zName = "SQLITE_FORMAT"; break; |
| | @@ -119408,10 +120793,36 @@ |
| 119408 | 120793 | ** function. |
| 119409 | 120794 | */ |
| 119410 | 120795 | SQLITE_API const char *sqlite3_errstr(int rc){ |
| 119411 | 120796 | return sqlite3ErrStr(rc); |
| 119412 | 120797 | } |
| 120798 | + |
| 120799 | +/* |
| 120800 | +** Invalidate all cached KeyInfo objects for database connection "db" |
| 120801 | +*/ |
| 120802 | +static void invalidateCachedKeyInfo(sqlite3 *db){ |
| 120803 | + Db *pDb; /* A single database */ |
| 120804 | + int iDb; /* The database index number */ |
| 120805 | + HashElem *k; /* For looping over tables in pDb */ |
| 120806 | + Table *pTab; /* A table in the database */ |
| 120807 | + Index *pIdx; /* Each index */ |
| 120808 | + |
| 120809 | + for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){ |
| 120810 | + if( pDb->pBt==0 ) continue; |
| 120811 | + sqlite3BtreeEnter(pDb->pBt); |
| 120812 | + for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 120813 | + pTab = (Table*)sqliteHashData(k); |
| 120814 | + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 120815 | + if( pIdx->pKeyInfo && pIdx->pKeyInfo->db==db ){ |
| 120816 | + sqlite3KeyInfoUnref(pIdx->pKeyInfo); |
| 120817 | + pIdx->pKeyInfo = 0; |
| 120818 | + } |
| 120819 | + } |
| 120820 | + } |
| 120821 | + sqlite3BtreeLeave(pDb->pBt); |
| 120822 | + } |
| 120823 | +} |
| 119413 | 120824 | |
| 119414 | 120825 | /* |
| 119415 | 120826 | ** Create a new collating function for database "db". The name is zName |
| 119416 | 120827 | ** and the encoding is enc. |
| 119417 | 120828 | */ |
| | @@ -119453,10 +120864,11 @@ |
| 119453 | 120864 | sqlite3Error(db, SQLITE_BUSY, |
| 119454 | 120865 | "unable to delete/modify collation sequence due to active statements"); |
| 119455 | 120866 | return SQLITE_BUSY; |
| 119456 | 120867 | } |
| 119457 | 120868 | sqlite3ExpirePreparedStatements(db); |
| 120869 | + invalidateCachedKeyInfo(db); |
| 119458 | 120870 | |
| 119459 | 120871 | /* If collation sequence pColl was created directly by a call to |
| 119460 | 120872 | ** sqlite3_create_collation, and not generated by synthCollSeq(), |
| 119461 | 120873 | ** then any copies made by synthCollSeq() need to be invalidated. |
| 119462 | 120874 | ** Also, collation destructor - CollSeq.xDel() - function may need |
| | @@ -128435,10 +129847,15 @@ |
| 128435 | 129847 | } |
| 128436 | 129848 | *ppCsr = pCsr; |
| 128437 | 129849 | return rc; |
| 128438 | 129850 | } |
| 128439 | 129851 | |
| 129852 | +/* |
| 129853 | +** Function getNextNode(), which is called by fts3ExprParse(), may itself |
| 129854 | +** call fts3ExprParse(). So this forward declaration is required. |
| 129855 | +*/ |
| 129856 | +static int fts3ExprParse(ParseContext *, const char *, int, Fts3Expr **, int *); |
| 128440 | 129857 | |
| 128441 | 129858 | /* |
| 128442 | 129859 | ** Extract the next token from buffer z (length n) using the tokenizer |
| 128443 | 129860 | ** and other information (column names etc.) in pParse. Create an Fts3Expr |
| 128444 | 129861 | ** structure of type FTSQUERY_PHRASE containing a phrase consisting of this |
| | @@ -128469,11 +129886,35 @@ |
| 128469 | 129886 | const char *zToken; |
| 128470 | 129887 | int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0; |
| 128471 | 129888 | int nByte; /* total space to allocate */ |
| 128472 | 129889 | |
| 128473 | 129890 | rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition); |
| 128474 | | - if( rc==SQLITE_OK ){ |
| 129891 | + |
| 129892 | + if( (rc==SQLITE_OK || rc==SQLITE_DONE) && sqlite3_fts3_enable_parentheses ){ |
| 129893 | + int i; |
| 129894 | + if( rc==SQLITE_DONE ) iStart = n; |
| 129895 | + for(i=0; i<iStart; i++){ |
| 129896 | + if( z[i]=='(' ){ |
| 129897 | + pParse->nNest++; |
| 129898 | + rc = fts3ExprParse(pParse, &z[i+1], n-i-1, &pRet, &nConsumed); |
| 129899 | + if( rc==SQLITE_OK && !pRet ){ |
| 129900 | + rc = SQLITE_DONE; |
| 129901 | + } |
| 129902 | + nConsumed = (int)(i + 1 + nConsumed); |
| 129903 | + break; |
| 129904 | + } |
| 129905 | + |
| 129906 | + if( z[i]==')' ){ |
| 129907 | + rc = SQLITE_DONE; |
| 129908 | + pParse->nNest--; |
| 129909 | + nConsumed = i+1; |
| 129910 | + break; |
| 129911 | + } |
| 129912 | + } |
| 129913 | + } |
| 129914 | + |
| 129915 | + if( nConsumed==0 && rc==SQLITE_OK ){ |
| 128475 | 129916 | nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken; |
| 128476 | 129917 | pRet = (Fts3Expr *)fts3MallocZero(nByte); |
| 128477 | 129918 | if( !pRet ){ |
| 128478 | 129919 | rc = SQLITE_NOMEM; |
| 128479 | 129920 | }else{ |
| | @@ -128649,16 +130090,10 @@ |
| 128649 | 130090 | sqlite3_free(p); |
| 128650 | 130091 | *ppExpr = 0; |
| 128651 | 130092 | return SQLITE_NOMEM; |
| 128652 | 130093 | } |
| 128653 | 130094 | |
| 128654 | | -/* |
| 128655 | | -** Function getNextNode(), which is called by fts3ExprParse(), may itself |
| 128656 | | -** call fts3ExprParse(). So this forward declaration is required. |
| 128657 | | -*/ |
| 128658 | | -static int fts3ExprParse(ParseContext *, const char *, int, Fts3Expr **, int *); |
| 128659 | | - |
| 128660 | 130095 | /* |
| 128661 | 130096 | ** The output variable *ppExpr is populated with an allocated Fts3Expr |
| 128662 | 130097 | ** structure, or set to 0 if the end of the input buffer is reached. |
| 128663 | 130098 | ** |
| 128664 | 130099 | ** Returns an SQLite error code. SQLITE_OK if everything works, SQLITE_NOMEM |
| | @@ -128751,31 +130186,10 @@ |
| 128751 | 130186 | ** user has supplied a token such as "ORacle". Continue. |
| 128752 | 130187 | */ |
| 128753 | 130188 | } |
| 128754 | 130189 | } |
| 128755 | 130190 | |
| 128756 | | - /* Check for an open bracket. */ |
| 128757 | | - if( sqlite3_fts3_enable_parentheses ){ |
| 128758 | | - if( *zInput=='(' ){ |
| 128759 | | - int nConsumed; |
| 128760 | | - pParse->nNest++; |
| 128761 | | - rc = fts3ExprParse(pParse, &zInput[1], nInput-1, ppExpr, &nConsumed); |
| 128762 | | - if( rc==SQLITE_OK && !*ppExpr ){ |
| 128763 | | - rc = SQLITE_DONE; |
| 128764 | | - } |
| 128765 | | - *pnConsumed = (int)((zInput - z) + 1 + nConsumed); |
| 128766 | | - return rc; |
| 128767 | | - } |
| 128768 | | - |
| 128769 | | - /* Check for a close bracket. */ |
| 128770 | | - if( *zInput==')' ){ |
| 128771 | | - pParse->nNest--; |
| 128772 | | - *pnConsumed = (int)((zInput - z) + 1); |
| 128773 | | - return SQLITE_DONE; |
| 128774 | | - } |
| 128775 | | - } |
| 128776 | | - |
| 128777 | 130191 | /* See if we are dealing with a quoted phrase. If this is the case, then |
| 128778 | 130192 | ** search for the closing quote and pass the whole string to getNextString() |
| 128779 | 130193 | ** for processing. This is easy to do, as fts3 has no syntax for escaping |
| 128780 | 130194 | ** a quote character embedded in a string. |
| 128781 | 130195 | */ |
| 128782 | 130196 | |