diff options
| -rw-r--r-- | build.zig | 6 | ||||
| -rw-r--r-- | c/sqlite3.c (renamed from sqlite3.c) | 11517 | ||||
| -rw-r--r-- | c/sqlite3.h (renamed from sqlite3.h) | 61 |
3 files changed, 6992 insertions, 4592 deletions
| @@ -23,7 +23,7 @@ pub fn build(b: *std.build.Builder) void { | |||
| 23 | // Build sqlite from source if asked | 23 | // Build sqlite from source if asked |
| 24 | if (use_bundled) { | 24 | if (use_bundled) { |
| 25 | const lib = b.addStaticLibrary("sqlite", null); | 25 | const lib = b.addStaticLibrary("sqlite", null); |
| 26 | lib.addCSourceFile("sqlite3.c", &[_][]const u8{"-std=c99"}); | 26 | lib.addCSourceFile("c/sqlite3.c", &[_][]const u8{"-std=c99"}); |
| 27 | lib.linkLibC(); | 27 | lib.linkLibC(); |
| 28 | lib.setTarget(target); | 28 | lib.setTarget(target); |
| 29 | lib.setBuildMode(mode); | 29 | lib.setBuildMode(mode); |
| @@ -31,14 +31,14 @@ pub fn build(b: *std.build.Builder) void { | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | const lib = b.addStaticLibrary("zig-sqlite", "sqlite.zig"); | 33 | const lib = b.addStaticLibrary("zig-sqlite", "sqlite.zig"); |
| 34 | lib.addIncludeDir("."); | 34 | lib.addIncludeDir("c"); |
| 35 | linkSqlite(lib); | 35 | linkSqlite(lib); |
| 36 | lib.setTarget(target); | 36 | lib.setTarget(target); |
| 37 | lib.setBuildMode(mode); | 37 | lib.setBuildMode(mode); |
| 38 | lib.install(); | 38 | lib.install(); |
| 39 | 39 | ||
| 40 | var main_tests = b.addTest("sqlite.zig"); | 40 | var main_tests = b.addTest("sqlite.zig"); |
| 41 | main_tests.addIncludeDir("."); | 41 | main_tests.addIncludeDir("c"); |
| 42 | linkSqlite(main_tests); | 42 | linkSqlite(main_tests); |
| 43 | main_tests.setBuildMode(mode); | 43 | main_tests.setBuildMode(mode); |
| 44 | main_tests.setTarget(target); | 44 | main_tests.setTarget(target); |
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.34.0. By combining all the individual C code files into this | 3 | ** version 3.35.0. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements | 6 | ** possible if the files were compiled separately. Performance improvements |
| @@ -284,6 +284,9 @@ static const char * const sqlite3azCompileOpt[] = { | |||
| 284 | #ifdef SQLITE_ENABLE_LOCKING_STYLE | 284 | #ifdef SQLITE_ENABLE_LOCKING_STYLE |
| 285 | "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), | 285 | "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), |
| 286 | #endif | 286 | #endif |
| 287 | #if SQLITE_ENABLE_MATH_FUNCTIONS | ||
| 288 | "ENABLE_MATH_FUNCTIONS", | ||
| 289 | #endif | ||
| 287 | #if SQLITE_ENABLE_MEMORY_MANAGEMENT | 290 | #if SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 288 | "ENABLE_MEMORY_MANAGEMENT", | 291 | "ENABLE_MEMORY_MANAGEMENT", |
| 289 | #endif | 292 | #endif |
| @@ -990,6 +993,18 @@ SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){ | |||
| 990 | # define MSVC_VERSION 0 | 993 | # define MSVC_VERSION 0 |
| 991 | #endif | 994 | #endif |
| 992 | 995 | ||
| 996 | /* | ||
| 997 | ** Some C99 functions in "math.h" are only present for MSVC when its version | ||
| 998 | ** is associated with Visual Studio 2013 or higher. | ||
| 999 | */ | ||
| 1000 | #ifndef SQLITE_HAVE_C99_MATH_FUNCS | ||
| 1001 | # if MSVC_VERSION==0 || MSVC_VERSION>=1800 | ||
| 1002 | # define SQLITE_HAVE_C99_MATH_FUNCS (1) | ||
| 1003 | # else | ||
| 1004 | # define SQLITE_HAVE_C99_MATH_FUNCS (0) | ||
| 1005 | # endif | ||
| 1006 | #endif | ||
| 1007 | |||
| 993 | /* Needed for various definitions... */ | 1008 | /* Needed for various definitions... */ |
| 994 | #if defined(__GNUC__) && !defined(_GNU_SOURCE) | 1009 | #if defined(__GNUC__) && !defined(_GNU_SOURCE) |
| 995 | # define _GNU_SOURCE | 1010 | # define _GNU_SOURCE |
| @@ -1171,9 +1186,9 @@ extern "C" { | |||
| 1171 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 1186 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1172 | ** [sqlite_version()] and [sqlite_source_id()]. | 1187 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1173 | */ | 1188 | */ |
| 1174 | #define SQLITE_VERSION "3.34.0" | 1189 | #define SQLITE_VERSION "3.35.0" |
| 1175 | #define SQLITE_VERSION_NUMBER 3034000 | 1190 | #define SQLITE_VERSION_NUMBER 3035000 |
| 1176 | #define SQLITE_SOURCE_ID "2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b" | 1191 | #define SQLITE_SOURCE_ID "2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115500b" |
| 1177 | 1192 | ||
| 1178 | /* | 1193 | /* |
| 1179 | ** CAPI3REF: Run-Time Library Version Numbers | 1194 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -3163,7 +3178,13 @@ struct sqlite3_mem_methods { | |||
| 3163 | ** The second parameter is a pointer to an integer into which | 3178 | ** The second parameter is a pointer to an integer into which |
| 3164 | ** is written 0 or 1 to indicate whether triggers are disabled or enabled | 3179 | ** is written 0 or 1 to indicate whether triggers are disabled or enabled |
| 3165 | ** following this call. The second parameter may be a NULL pointer, in | 3180 | ** following this call. The second parameter may be a NULL pointer, in |
| 3166 | ** which case the trigger setting is not reported back. </dd> | 3181 | ** which case the trigger setting is not reported back. |
| 3182 | ** | ||
| 3183 | ** <p>Originally this option disabled all triggers. ^(However, since | ||
| 3184 | ** SQLite version 3.35.0, TEMP triggers are still allowed even if | ||
| 3185 | ** this option is off. So, in other words, this option now only disables | ||
| 3186 | ** triggers in the main database schema or in the schemas of ATTACH-ed | ||
| 3187 | ** databases.)^ </dd> | ||
| 3167 | ** | 3188 | ** |
| 3168 | ** [[SQLITE_DBCONFIG_ENABLE_VIEW]] | 3189 | ** [[SQLITE_DBCONFIG_ENABLE_VIEW]] |
| 3169 | ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt> | 3190 | ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt> |
| @@ -3174,7 +3195,13 @@ struct sqlite3_mem_methods { | |||
| 3174 | ** The second parameter is a pointer to an integer into which | 3195 | ** The second parameter is a pointer to an integer into which |
| 3175 | ** is written 0 or 1 to indicate whether views are disabled or enabled | 3196 | ** is written 0 or 1 to indicate whether views are disabled or enabled |
| 3176 | ** following this call. The second parameter may be a NULL pointer, in | 3197 | ** following this call. The second parameter may be a NULL pointer, in |
| 3177 | ** which case the view setting is not reported back. </dd> | 3198 | ** which case the view setting is not reported back. |
| 3199 | ** | ||
| 3200 | ** <p>Originally this option disabled all views. ^(However, since | ||
| 3201 | ** SQLite version 3.35.0, TEMP views are still allowed even if | ||
| 3202 | ** this option is off. So, in other words, this option now only disables | ||
| 3203 | ** views in the main database schema or in the schemas of ATTACH-ed | ||
| 3204 | ** databases.)^ </dd> | ||
| 3178 | ** | 3205 | ** |
| 3179 | ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]] | 3206 | ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]] |
| 3180 | ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt> | 3207 | ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt> |
| @@ -4547,6 +4574,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); | |||
| 4547 | ** that uses dot-files in place of posix advisory locking. | 4574 | ** that uses dot-files in place of posix advisory locking. |
| 4548 | ** <tr><td> file:data.db?mode=readonly <td> | 4575 | ** <tr><td> file:data.db?mode=readonly <td> |
| 4549 | ** An error. "readonly" is not a valid option for the "mode" parameter. | 4576 | ** An error. "readonly" is not a valid option for the "mode" parameter. |
| 4577 | ** Use "ro" instead: "file:data.db?mode=ro". | ||
| 4550 | ** </table> | 4578 | ** </table> |
| 4551 | ** | 4579 | ** |
| 4552 | ** ^URI hexadecimal escape sequences (%HH) are supported within the path and | 4580 | ** ^URI hexadecimal escape sequences (%HH) are supported within the path and |
| @@ -4745,7 +4773,7 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*); | |||
| 4745 | ** If the Y parameter to sqlite3_free_filename(Y) is anything other | 4773 | ** If the Y parameter to sqlite3_free_filename(Y) is anything other |
| 4746 | ** than a NULL pointer or a pointer previously acquired from | 4774 | ** than a NULL pointer or a pointer previously acquired from |
| 4747 | ** sqlite3_create_filename(), then bad things such as heap | 4775 | ** sqlite3_create_filename(), then bad things such as heap |
| 4748 | ** corruption or segfaults may occur. The value Y should be | 4776 | ** corruption or segfaults may occur. The value Y should not be |
| 4749 | ** used again after sqlite3_free_filename(Y) has been called. This means | 4777 | ** used again after sqlite3_free_filename(Y) has been called. This means |
| 4750 | ** that if the [sqlite3_vfs.xOpen()] method of a VFS has been called using Y, | 4778 | ** that if the [sqlite3_vfs.xOpen()] method of a VFS has been called using Y, |
| 4751 | ** then the corresponding [sqlite3_module.xClose() method should also be | 4779 | ** then the corresponding [sqlite3_module.xClose() method should also be |
| @@ -8813,7 +8841,8 @@ SQLITE_API int sqlite3_test_control(int op, ...); | |||
| 8813 | #define SQLITE_TESTCTRL_PRNG_SEED 28 | 8841 | #define SQLITE_TESTCTRL_PRNG_SEED 28 |
| 8814 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 | 8842 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 |
| 8815 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 | 8843 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 |
| 8816 | #define SQLITE_TESTCTRL_LAST 30 /* Largest TESTCTRL */ | 8844 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 |
| 8845 | #define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */ | ||
| 8817 | 8846 | ||
| 8818 | /* | 8847 | /* |
| 8819 | ** CAPI3REF: SQL Keyword Checking | 8848 | ** CAPI3REF: SQL Keyword Checking |
| @@ -11487,6 +11516,14 @@ SQLITE_API int sqlite3session_patchset( | |||
| 11487 | SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); | 11516 | SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); |
| 11488 | 11517 | ||
| 11489 | /* | 11518 | /* |
| 11519 | ** CAPI3REF: Query for the amount of heap memory used by a session object. | ||
| 11520 | ** | ||
| 11521 | ** This API returns the total amount of heap memory in bytes currently | ||
| 11522 | ** used by the session object passed as the only argument. | ||
| 11523 | */ | ||
| 11524 | SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession); | ||
| 11525 | |||
| 11526 | /* | ||
| 11490 | ** CAPI3REF: Create An Iterator To Traverse A Changeset | 11527 | ** CAPI3REF: Create An Iterator To Traverse A Changeset |
| 11491 | ** CONSTRUCTOR: sqlite3_changeset_iter | 11528 | ** CONSTRUCTOR: sqlite3_changeset_iter |
| 11492 | ** | 11529 | ** |
| @@ -11588,18 +11625,23 @@ SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter); | |||
| 11588 | ** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this | 11625 | ** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this |
| 11589 | ** is not the case, this function returns [SQLITE_MISUSE]. | 11626 | ** is not the case, this function returns [SQLITE_MISUSE]. |
| 11590 | ** | 11627 | ** |
| 11591 | ** If argument pzTab is not NULL, then *pzTab is set to point to a | 11628 | ** Arguments pOp, pnCol and pzTab may not be NULL. Upon return, three |
| 11592 | ** nul-terminated utf-8 encoded string containing the name of the table | 11629 | ** outputs are set through these pointers: |
| 11593 | ** affected by the current change. The buffer remains valid until either | 11630 | ** |
| 11594 | ** sqlite3changeset_next() is called on the iterator or until the | 11631 | ** *pOp is set to one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], |
| 11595 | ** conflict-handler function returns. If pnCol is not NULL, then *pnCol is | 11632 | ** depending on the type of change that the iterator currently points to; |
| 11596 | ** set to the number of columns in the table affected by the change. If | 11633 | ** |
| 11597 | ** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change | 11634 | ** *pnCol is set to the number of columns in the table affected by the change; and |
| 11635 | ** | ||
| 11636 | ** *pzTab is set to point to a nul-terminated utf-8 encoded string containing | ||
| 11637 | ** the name of the table affected by the current change. The buffer remains | ||
| 11638 | ** valid until either sqlite3changeset_next() is called on the iterator | ||
| 11639 | ** or until the conflict-handler function returns. | ||
| 11640 | ** | ||
| 11641 | ** If pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change | ||
| 11598 | ** is an indirect change, or false (0) otherwise. See the documentation for | 11642 | ** is an indirect change, or false (0) otherwise. See the documentation for |
| 11599 | ** [sqlite3session_indirect()] for a description of direct and indirect | 11643 | ** [sqlite3session_indirect()] for a description of direct and indirect |
| 11600 | ** changes. Finally, if pOp is not NULL, then *pOp is set to one of | 11644 | ** changes. |
| 11601 | ** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the | ||
| 11602 | ** type of change that the iterator currently points to. | ||
| 11603 | ** | 11645 | ** |
| 11604 | ** If no error occurs, SQLITE_OK is returned. If an error does occur, an | 11646 | ** If no error occurs, SQLITE_OK is returned. If an error does occur, an |
| 11605 | ** SQLite error code is returned. The values of the output variables may not | 11647 | ** SQLite error code is returned. The values of the output variables may not |
| @@ -13528,7 +13570,8 @@ struct fts5_api { | |||
| 13528 | #ifndef __has_extension | 13570 | #ifndef __has_extension |
| 13529 | # define __has_extension(x) 0 /* compatibility with non-clang compilers */ | 13571 | # define __has_extension(x) 0 /* compatibility with non-clang compilers */ |
| 13530 | #endif | 13572 | #endif |
| 13531 | #if GCC_VERSION>=4007000 || __has_extension(c_atomic) | 13573 | #if GCC_VERSION>=4007000 || \ |
| 13574 | (__has_extension(c_atomic) && __has_extension(c_atomic_store_n)) | ||
| 13532 | # define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED) | 13575 | # define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED) |
| 13533 | # define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED) | 13576 | # define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED) |
| 13534 | #else | 13577 | #else |
| @@ -14095,90 +14138,92 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*); | |||
| 14095 | #define TK_TIES 94 | 14138 | #define TK_TIES 94 |
| 14096 | #define TK_GENERATED 95 | 14139 | #define TK_GENERATED 95 |
| 14097 | #define TK_ALWAYS 96 | 14140 | #define TK_ALWAYS 96 |
| 14098 | #define TK_REINDEX 97 | 14141 | #define TK_MATERIALIZED 97 |
| 14099 | #define TK_RENAME 98 | 14142 | #define TK_REINDEX 98 |
| 14100 | #define TK_CTIME_KW 99 | 14143 | #define TK_RENAME 99 |
| 14101 | #define TK_ANY 100 | 14144 | #define TK_CTIME_KW 100 |
| 14102 | #define TK_BITAND 101 | 14145 | #define TK_ANY 101 |
| 14103 | #define TK_BITOR 102 | 14146 | #define TK_BITAND 102 |
| 14104 | #define TK_LSHIFT 103 | 14147 | #define TK_BITOR 103 |
| 14105 | #define TK_RSHIFT 104 | 14148 | #define TK_LSHIFT 104 |
| 14106 | #define TK_PLUS 105 | 14149 | #define TK_RSHIFT 105 |
| 14107 | #define TK_MINUS 106 | 14150 | #define TK_PLUS 106 |
| 14108 | #define TK_STAR 107 | 14151 | #define TK_MINUS 107 |
| 14109 | #define TK_SLASH 108 | 14152 | #define TK_STAR 108 |
| 14110 | #define TK_REM 109 | 14153 | #define TK_SLASH 109 |
| 14111 | #define TK_CONCAT 110 | 14154 | #define TK_REM 110 |
| 14112 | #define TK_COLLATE 111 | 14155 | #define TK_CONCAT 111 |
| 14113 | #define TK_BITNOT 112 | 14156 | #define TK_COLLATE 112 |
| 14114 | #define TK_ON 113 | 14157 | #define TK_BITNOT 113 |
| 14115 | #define TK_INDEXED 114 | 14158 | #define TK_ON 114 |
| 14116 | #define TK_STRING 115 | 14159 | #define TK_INDEXED 115 |
| 14117 | #define TK_JOIN_KW 116 | 14160 | #define TK_STRING 116 |
| 14118 | #define TK_CONSTRAINT 117 | 14161 | #define TK_JOIN_KW 117 |
| 14119 | #define TK_DEFAULT 118 | 14162 | #define TK_CONSTRAINT 118 |
| 14120 | #define TK_NULL 119 | 14163 | #define TK_DEFAULT 119 |
| 14121 | #define TK_PRIMARY 120 | 14164 | #define TK_NULL 120 |
| 14122 | #define TK_UNIQUE 121 | 14165 | #define TK_PRIMARY 121 |
| 14123 | #define TK_CHECK 122 | 14166 | #define TK_UNIQUE 122 |
| 14124 | #define TK_REFERENCES 123 | 14167 | #define TK_CHECK 123 |
| 14125 | #define TK_AUTOINCR 124 | 14168 | #define TK_REFERENCES 124 |
| 14126 | #define TK_INSERT 125 | 14169 | #define TK_AUTOINCR 125 |
| 14127 | #define TK_DELETE 126 | 14170 | #define TK_INSERT 126 |
| 14128 | #define TK_UPDATE 127 | 14171 | #define TK_DELETE 127 |
| 14129 | #define TK_SET 128 | 14172 | #define TK_UPDATE 128 |
| 14130 | #define TK_DEFERRABLE 129 | 14173 | #define TK_SET 129 |
| 14131 | #define TK_FOREIGN 130 | 14174 | #define TK_DEFERRABLE 130 |
| 14132 | #define TK_DROP 131 | 14175 | #define TK_FOREIGN 131 |
| 14133 | #define TK_UNION 132 | 14176 | #define TK_DROP 132 |
| 14134 | #define TK_ALL 133 | 14177 | #define TK_UNION 133 |
| 14135 | #define TK_EXCEPT 134 | 14178 | #define TK_ALL 134 |
| 14136 | #define TK_INTERSECT 135 | 14179 | #define TK_EXCEPT 135 |
| 14137 | #define TK_SELECT 136 | 14180 | #define TK_INTERSECT 136 |
| 14138 | #define TK_VALUES 137 | 14181 | #define TK_SELECT 137 |
| 14139 | #define TK_DISTINCT 138 | 14182 | #define TK_VALUES 138 |
| 14140 | #define TK_DOT 139 | 14183 | #define TK_DISTINCT 139 |
| 14141 | #define TK_FROM 140 | 14184 | #define TK_DOT 140 |
| 14142 | #define TK_JOIN 141 | 14185 | #define TK_FROM 141 |
| 14143 | #define TK_USING 142 | 14186 | #define TK_JOIN 142 |
| 14144 | #define TK_ORDER 143 | 14187 | #define TK_USING 143 |
| 14145 | #define TK_GROUP 144 | 14188 | #define TK_ORDER 144 |
| 14146 | #define TK_HAVING 145 | 14189 | #define TK_GROUP 145 |
| 14147 | #define TK_LIMIT 146 | 14190 | #define TK_HAVING 146 |
| 14148 | #define TK_WHERE 147 | 14191 | #define TK_LIMIT 147 |
| 14149 | #define TK_INTO 148 | 14192 | #define TK_WHERE 148 |
| 14150 | #define TK_NOTHING 149 | 14193 | #define TK_RETURNING 149 |
| 14151 | #define TK_FLOAT 150 | 14194 | #define TK_INTO 150 |
| 14152 | #define TK_BLOB 151 | 14195 | #define TK_NOTHING 151 |
| 14153 | #define TK_INTEGER 152 | 14196 | #define TK_FLOAT 152 |
| 14154 | #define TK_VARIABLE 153 | 14197 | #define TK_BLOB 153 |
| 14155 | #define TK_CASE 154 | 14198 | #define TK_INTEGER 154 |
| 14156 | #define TK_WHEN 155 | 14199 | #define TK_VARIABLE 155 |
| 14157 | #define TK_THEN 156 | 14200 | #define TK_CASE 156 |
| 14158 | #define TK_ELSE 157 | 14201 | #define TK_WHEN 157 |
| 14159 | #define TK_INDEX 158 | 14202 | #define TK_THEN 158 |
| 14160 | #define TK_ALTER 159 | 14203 | #define TK_ELSE 159 |
| 14161 | #define TK_ADD 160 | 14204 | #define TK_INDEX 160 |
| 14162 | #define TK_WINDOW 161 | 14205 | #define TK_ALTER 161 |
| 14163 | #define TK_OVER 162 | 14206 | #define TK_ADD 162 |
| 14164 | #define TK_FILTER 163 | 14207 | #define TK_WINDOW 163 |
| 14165 | #define TK_COLUMN 164 | 14208 | #define TK_OVER 164 |
| 14166 | #define TK_AGG_FUNCTION 165 | 14209 | #define TK_FILTER 165 |
| 14167 | #define TK_AGG_COLUMN 166 | 14210 | #define TK_COLUMN 166 |
| 14168 | #define TK_TRUEFALSE 167 | 14211 | #define TK_AGG_FUNCTION 167 |
| 14169 | #define TK_ISNOT 168 | 14212 | #define TK_AGG_COLUMN 168 |
| 14170 | #define TK_FUNCTION 169 | 14213 | #define TK_TRUEFALSE 169 |
| 14171 | #define TK_UMINUS 170 | 14214 | #define TK_ISNOT 170 |
| 14172 | #define TK_UPLUS 171 | 14215 | #define TK_FUNCTION 171 |
| 14173 | #define TK_TRUTH 172 | 14216 | #define TK_UMINUS 172 |
| 14174 | #define TK_REGISTER 173 | 14217 | #define TK_UPLUS 173 |
| 14175 | #define TK_VECTOR 174 | 14218 | #define TK_TRUTH 174 |
| 14176 | #define TK_SELECT_COLUMN 175 | 14219 | #define TK_REGISTER 175 |
| 14177 | #define TK_IF_NULL_ROW 176 | 14220 | #define TK_VECTOR 176 |
| 14178 | #define TK_ASTERISK 177 | 14221 | #define TK_SELECT_COLUMN 177 |
| 14179 | #define TK_SPAN 178 | 14222 | #define TK_IF_NULL_ROW 178 |
| 14180 | #define TK_SPACE 179 | 14223 | #define TK_ASTERISK 179 |
| 14181 | #define TK_ILLEGAL 180 | 14224 | #define TK_SPAN 180 |
| 14225 | #define TK_SPACE 181 | ||
| 14226 | #define TK_ILLEGAL 182 | ||
| 14182 | 14227 | ||
| 14183 | /************** End of parse.h ***********************************************/ | 14228 | /************** End of parse.h ***********************************************/ |
| 14184 | /************** Continuing where we left off in sqliteInt.h ******************/ | 14229 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| @@ -14594,15 +14639,14 @@ typedef INT16_TYPE LogEst; | |||
| 14594 | ** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not | 14639 | ** SELECTTRACE_ENABLED will be either 1 or 0 depending on whether or not |
| 14595 | ** the Select query generator tracing logic is turned on. | 14640 | ** the Select query generator tracing logic is turned on. |
| 14596 | */ | 14641 | */ |
| 14597 | #if defined(SQLITE_ENABLE_SELECTTRACE) | 14642 | #if !defined(SQLITE_AMALGAMATION) |
| 14598 | # define SELECTTRACE_ENABLED 1 | 14643 | SQLITE_PRIVATE u32 sqlite3SelectTrace; |
| 14599 | #else | ||
| 14600 | # define SELECTTRACE_ENABLED 0 | ||
| 14601 | #endif | 14644 | #endif |
| 14602 | #if defined(SQLITE_ENABLE_SELECTTRACE) | 14645 | #if defined(SQLITE_DEBUG) \ |
| 14646 | && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_SELECTTRACE)) | ||
| 14603 | # define SELECTTRACE_ENABLED 1 | 14647 | # define SELECTTRACE_ENABLED 1 |
| 14604 | # define SELECTTRACE(K,P,S,X) \ | 14648 | # define SELECTTRACE(K,P,S,X) \ |
| 14605 | if(sqlite3_unsupported_selecttrace&(K)) \ | 14649 | if(sqlite3SelectTrace&(K)) \ |
| 14606 | sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\ | 14650 | sqlite3DebugPrintf("%u/%d/%p: ",(S)->selId,(P)->addrExplain,(S)),\ |
| 14607 | sqlite3DebugPrintf X | 14651 | sqlite3DebugPrintf X |
| 14608 | #else | 14652 | #else |
| @@ -14611,6 +14655,19 @@ typedef INT16_TYPE LogEst; | |||
| 14611 | #endif | 14655 | #endif |
| 14612 | 14656 | ||
| 14613 | /* | 14657 | /* |
| 14658 | ** Macros for "wheretrace" | ||
| 14659 | */ | ||
| 14660 | SQLITE_PRIVATE u32 sqlite3WhereTrace; | ||
| 14661 | #if defined(SQLITE_DEBUG) \ | ||
| 14662 | && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE)) | ||
| 14663 | # define WHERETRACE(K,X) if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X | ||
| 14664 | # define WHERETRACE_ENABLED 1 | ||
| 14665 | #else | ||
| 14666 | # define WHERETRACE(K,X) | ||
| 14667 | #endif | ||
| 14668 | |||
| 14669 | |||
| 14670 | /* | ||
| 14614 | ** An instance of the following structure is used to store the busy-handler | 14671 | ** An instance of the following structure is used to store the busy-handler |
| 14615 | ** callback for a given sqlite handle. | 14672 | ** callback for a given sqlite handle. |
| 14616 | ** | 14673 | ** |
| @@ -14721,7 +14778,10 @@ typedef struct AutoincInfo AutoincInfo; | |||
| 14721 | typedef struct Bitvec Bitvec; | 14778 | typedef struct Bitvec Bitvec; |
| 14722 | typedef struct CollSeq CollSeq; | 14779 | typedef struct CollSeq CollSeq; |
| 14723 | typedef struct Column Column; | 14780 | typedef struct Column Column; |
| 14781 | typedef struct Cte Cte; | ||
| 14782 | typedef struct CteUse CteUse; | ||
| 14724 | typedef struct Db Db; | 14783 | typedef struct Db Db; |
| 14784 | typedef struct DbFixer DbFixer; | ||
| 14725 | typedef struct Schema Schema; | 14785 | typedef struct Schema Schema; |
| 14726 | typedef struct Expr Expr; | 14786 | typedef struct Expr Expr; |
| 14727 | typedef struct ExprList ExprList; | 14787 | typedef struct ExprList ExprList; |
| @@ -14739,14 +14799,17 @@ typedef struct LookasideSlot LookasideSlot; | |||
| 14739 | typedef struct Module Module; | 14799 | typedef struct Module Module; |
| 14740 | typedef struct NameContext NameContext; | 14800 | typedef struct NameContext NameContext; |
| 14741 | typedef struct Parse Parse; | 14801 | typedef struct Parse Parse; |
| 14802 | typedef struct ParseCleanup ParseCleanup; | ||
| 14742 | typedef struct PreUpdate PreUpdate; | 14803 | typedef struct PreUpdate PreUpdate; |
| 14743 | typedef struct PrintfArguments PrintfArguments; | 14804 | typedef struct PrintfArguments PrintfArguments; |
| 14744 | typedef struct RenameToken RenameToken; | 14805 | typedef struct RenameToken RenameToken; |
| 14806 | typedef struct Returning Returning; | ||
| 14745 | typedef struct RowSet RowSet; | 14807 | typedef struct RowSet RowSet; |
| 14746 | typedef struct Savepoint Savepoint; | 14808 | typedef struct Savepoint Savepoint; |
| 14747 | typedef struct Select Select; | 14809 | typedef struct Select Select; |
| 14748 | typedef struct SQLiteThread SQLiteThread; | 14810 | typedef struct SQLiteThread SQLiteThread; |
| 14749 | typedef struct SelectDest SelectDest; | 14811 | typedef struct SelectDest SelectDest; |
| 14812 | typedef struct SrcItem SrcItem; | ||
| 14750 | typedef struct SrcList SrcList; | 14813 | typedef struct SrcList SrcList; |
| 14751 | typedef struct sqlite3_str StrAccum; /* Internal alias for sqlite3_str */ | 14814 | typedef struct sqlite3_str StrAccum; /* Internal alias for sqlite3_str */ |
| 14752 | typedef struct Table Table; | 14815 | typedef struct Table Table; |
| @@ -15318,6 +15381,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags); | |||
| 15318 | #define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */ | 15381 | #define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */ |
| 15319 | #define BTREE_AUXDELETE 0x04 /* not the primary delete operation */ | 15382 | #define BTREE_AUXDELETE 0x04 /* not the primary delete operation */ |
| 15320 | #define BTREE_APPEND 0x08 /* Insert is likely an append */ | 15383 | #define BTREE_APPEND 0x08 /* Insert is likely an append */ |
| 15384 | #define BTREE_PREFORMAT 0x80 /* Inserted data is a preformated cell */ | ||
| 15321 | 15385 | ||
| 15322 | /* An instance of the BtreePayload object describes the content of a single | 15386 | /* An instance of the BtreePayload object describes the content of a single |
| 15323 | ** entry in either an index or table btree. | 15387 | ** entry in either an index or table btree. |
| @@ -15417,6 +15481,8 @@ SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*); | |||
| 15417 | SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree*, int, int *, int *); | 15481 | SQLITE_PRIVATE int sqlite3BtreeCheckpoint(Btree*, int, int *, int *); |
| 15418 | #endif | 15482 | #endif |
| 15419 | 15483 | ||
| 15484 | SQLITE_PRIVATE int sqlite3BtreeTransferRow(BtCursor*, BtCursor*, i64); | ||
| 15485 | |||
| 15420 | /* | 15486 | /* |
| 15421 | ** If we are not using shared cache, then there is no need to | 15487 | ** If we are not using shared cache, then there is no need to |
| 15422 | ** use mutexes to access the BtShared structures. So make the | 15488 | ** use mutexes to access the BtShared structures. So make the |
| @@ -15716,103 +15782,105 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15716 | #define OP_Copy 77 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ | 15782 | #define OP_Copy 77 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 15717 | #define OP_SCopy 78 /* synopsis: r[P2]=r[P1] */ | 15783 | #define OP_SCopy 78 /* synopsis: r[P2]=r[P1] */ |
| 15718 | #define OP_IntCopy 79 /* synopsis: r[P2]=r[P1] */ | 15784 | #define OP_IntCopy 79 /* synopsis: r[P2]=r[P1] */ |
| 15719 | #define OP_ResultRow 80 /* synopsis: output=r[P1@P2] */ | 15785 | #define OP_ChngCntRow 80 /* synopsis: output=r[P1] */ |
| 15720 | #define OP_CollSeq 81 | 15786 | #define OP_ResultRow 81 /* synopsis: output=r[P1@P2] */ |
| 15721 | #define OP_AddImm 82 /* synopsis: r[P1]=r[P1]+P2 */ | 15787 | #define OP_CollSeq 82 |
| 15722 | #define OP_RealAffinity 83 | 15788 | #define OP_AddImm 83 /* synopsis: r[P1]=r[P1]+P2 */ |
| 15723 | #define OP_Cast 84 /* synopsis: affinity(r[P1]) */ | 15789 | #define OP_RealAffinity 84 |
| 15724 | #define OP_Permutation 85 | 15790 | #define OP_Cast 85 /* synopsis: affinity(r[P1]) */ |
| 15725 | #define OP_Compare 86 /* synopsis: r[P1@P3] <-> r[P2@P3] */ | 15791 | #define OP_Permutation 86 |
| 15726 | #define OP_IsTrue 87 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ | 15792 | #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 15727 | #define OP_Offset 88 /* synopsis: r[P3] = sqlite_offset(P1) */ | 15793 | #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 15728 | #define OP_Column 89 /* synopsis: r[P3]=PX */ | 15794 | #define OP_Offset 89 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 15729 | #define OP_Affinity 90 /* synopsis: affinity(r[P1@P2]) */ | 15795 | #define OP_Column 90 /* synopsis: r[P3]=PX */ |
| 15730 | #define OP_MakeRecord 91 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ | 15796 | #define OP_Affinity 91 /* synopsis: affinity(r[P1@P2]) */ |
| 15731 | #define OP_Count 92 /* synopsis: r[P2]=count() */ | 15797 | #define OP_MakeRecord 92 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 15732 | #define OP_ReadCookie 93 | 15798 | #define OP_Count 93 /* synopsis: r[P2]=count() */ |
| 15733 | #define OP_SetCookie 94 | 15799 | #define OP_ReadCookie 94 |
| 15734 | #define OP_ReopenIdx 95 /* synopsis: root=P2 iDb=P3 */ | 15800 | #define OP_SetCookie 95 |
| 15735 | #define OP_OpenRead 96 /* synopsis: root=P2 iDb=P3 */ | 15801 | #define OP_ReopenIdx 96 /* synopsis: root=P2 iDb=P3 */ |
| 15736 | #define OP_OpenWrite 97 /* synopsis: root=P2 iDb=P3 */ | 15802 | #define OP_OpenRead 97 /* synopsis: root=P2 iDb=P3 */ |
| 15737 | #define OP_OpenDup 98 | 15803 | #define OP_OpenWrite 98 /* synopsis: root=P2 iDb=P3 */ |
| 15738 | #define OP_OpenAutoindex 99 /* synopsis: nColumn=P2 */ | 15804 | #define OP_OpenDup 99 |
| 15739 | #define OP_OpenEphemeral 100 /* synopsis: nColumn=P2 */ | 15805 | #define OP_OpenAutoindex 100 /* synopsis: nColumn=P2 */ |
| 15740 | #define OP_BitAnd 101 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ | 15806 | #define OP_OpenEphemeral 101 /* synopsis: nColumn=P2 */ |
| 15741 | #define OP_BitOr 102 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ | 15807 | #define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 15742 | #define OP_ShiftLeft 103 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ | 15808 | #define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 15743 | #define OP_ShiftRight 104 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ | 15809 | #define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 15744 | #define OP_Add 105 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ | 15810 | #define OP_ShiftRight 105 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 15745 | #define OP_Subtract 106 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ | 15811 | #define OP_Add 106 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| 15746 | #define OP_Multiply 107 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ | 15812 | #define OP_Subtract 107 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 15747 | #define OP_Divide 108 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ | 15813 | #define OP_Multiply 108 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 15748 | #define OP_Remainder 109 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ | 15814 | #define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 15749 | #define OP_Concat 110 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ | 15815 | #define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 15750 | #define OP_SorterOpen 111 | 15816 | #define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 15751 | #define OP_BitNot 112 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ | 15817 | #define OP_SorterOpen 112 |
| 15752 | #define OP_SequenceTest 113 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ | 15818 | #define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 15753 | #define OP_OpenPseudo 114 /* synopsis: P3 columns in r[P2] */ | 15819 | #define OP_SequenceTest 114 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 15754 | #define OP_String8 115 /* same as TK_STRING, synopsis: r[P2]='P4' */ | 15820 | #define OP_OpenPseudo 115 /* synopsis: P3 columns in r[P2] */ |
| 15755 | #define OP_Close 116 | 15821 | #define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 15756 | #define OP_ColumnsUsed 117 | 15822 | #define OP_Close 117 |
| 15757 | #define OP_SeekScan 118 /* synopsis: Scan-ahead up to P1 rows */ | 15823 | #define OP_ColumnsUsed 118 |
| 15758 | #define OP_SeekHit 119 /* synopsis: set P2<=seekHit<=P3 */ | 15824 | #define OP_SeekScan 119 /* synopsis: Scan-ahead up to P1 rows */ |
| 15759 | #define OP_Sequence 120 /* synopsis: r[P2]=cursor[P1].ctr++ */ | 15825 | #define OP_SeekHit 120 /* synopsis: set P2<=seekHit<=P3 */ |
| 15760 | #define OP_NewRowid 121 /* synopsis: r[P2]=rowid */ | 15826 | #define OP_Sequence 121 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 15761 | #define OP_Insert 122 /* synopsis: intkey=r[P3] data=r[P2] */ | 15827 | #define OP_NewRowid 122 /* synopsis: r[P2]=rowid */ |
| 15762 | #define OP_Delete 123 | 15828 | #define OP_Insert 123 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 15763 | #define OP_ResetCount 124 | 15829 | #define OP_RowCell 124 |
| 15764 | #define OP_SorterCompare 125 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ | 15830 | #define OP_Delete 125 |
| 15765 | #define OP_SorterData 126 /* synopsis: r[P2]=data */ | 15831 | #define OP_ResetCount 126 |
| 15766 | #define OP_RowData 127 /* synopsis: r[P2]=data */ | 15832 | #define OP_SorterCompare 127 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 15767 | #define OP_Rowid 128 /* synopsis: r[P2]=rowid */ | 15833 | #define OP_SorterData 128 /* synopsis: r[P2]=data */ |
| 15768 | #define OP_NullRow 129 | 15834 | #define OP_RowData 129 /* synopsis: r[P2]=data */ |
| 15769 | #define OP_SeekEnd 130 | 15835 | #define OP_Rowid 130 /* synopsis: r[P2]=rowid */ |
| 15770 | #define OP_IdxInsert 131 /* synopsis: key=r[P2] */ | 15836 | #define OP_NullRow 131 |
| 15771 | #define OP_SorterInsert 132 /* synopsis: key=r[P2] */ | 15837 | #define OP_SeekEnd 132 |
| 15772 | #define OP_IdxDelete 133 /* synopsis: key=r[P2@P3] */ | 15838 | #define OP_IdxInsert 133 /* synopsis: key=r[P2] */ |
| 15773 | #define OP_DeferredSeek 134 /* synopsis: Move P3 to P1.rowid if needed */ | 15839 | #define OP_SorterInsert 134 /* synopsis: key=r[P2] */ |
| 15774 | #define OP_IdxRowid 135 /* synopsis: r[P2]=rowid */ | 15840 | #define OP_IdxDelete 135 /* synopsis: key=r[P2@P3] */ |
| 15775 | #define OP_FinishSeek 136 | 15841 | #define OP_DeferredSeek 136 /* synopsis: Move P3 to P1.rowid if needed */ |
| 15776 | #define OP_Destroy 137 | 15842 | #define OP_IdxRowid 137 /* synopsis: r[P2]=rowid */ |
| 15777 | #define OP_Clear 138 | 15843 | #define OP_FinishSeek 138 |
| 15778 | #define OP_ResetSorter 139 | 15844 | #define OP_Destroy 139 |
| 15779 | #define OP_CreateBtree 140 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ | 15845 | #define OP_Clear 140 |
| 15780 | #define OP_SqlExec 141 | 15846 | #define OP_ResetSorter 141 |
| 15781 | #define OP_ParseSchema 142 | 15847 | #define OP_CreateBtree 142 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ |
| 15782 | #define OP_LoadAnalysis 143 | 15848 | #define OP_SqlExec 143 |
| 15783 | #define OP_DropTable 144 | 15849 | #define OP_ParseSchema 144 |
| 15784 | #define OP_DropIndex 145 | 15850 | #define OP_LoadAnalysis 145 |
| 15785 | #define OP_DropTrigger 146 | 15851 | #define OP_DropTable 146 |
| 15786 | #define OP_IntegrityCk 147 | 15852 | #define OP_DropIndex 147 |
| 15787 | #define OP_RowSetAdd 148 /* synopsis: rowset(P1)=r[P2] */ | 15853 | #define OP_DropTrigger 148 |
| 15788 | #define OP_Param 149 | 15854 | #define OP_IntegrityCk 149 |
| 15789 | #define OP_Real 150 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ | 15855 | #define OP_RowSetAdd 150 /* synopsis: rowset(P1)=r[P2] */ |
| 15790 | #define OP_FkCounter 151 /* synopsis: fkctr[P1]+=P2 */ | 15856 | #define OP_Param 151 |
| 15791 | #define OP_MemMax 152 /* synopsis: r[P1]=max(r[P1],r[P2]) */ | 15857 | #define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 15792 | #define OP_OffsetLimit 153 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ | 15858 | #define OP_FkCounter 153 /* synopsis: fkctr[P1]+=P2 */ |
| 15793 | #define OP_AggInverse 154 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ | 15859 | #define OP_MemMax 154 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 15794 | #define OP_AggStep 155 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | 15860 | #define OP_OffsetLimit 155 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 15795 | #define OP_AggStep1 156 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | 15861 | #define OP_AggInverse 156 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ |
| 15796 | #define OP_AggValue 157 /* synopsis: r[P3]=value N=P2 */ | 15862 | #define OP_AggStep 157 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15797 | #define OP_AggFinal 158 /* synopsis: accum=r[P1] N=P2 */ | 15863 | #define OP_AggStep1 158 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15798 | #define OP_Expire 159 | 15864 | #define OP_AggValue 159 /* synopsis: r[P3]=value N=P2 */ |
| 15799 | #define OP_CursorLock 160 | 15865 | #define OP_AggFinal 160 /* synopsis: accum=r[P1] N=P2 */ |
| 15800 | #define OP_CursorUnlock 161 | 15866 | #define OP_Expire 161 |
| 15801 | #define OP_TableLock 162 /* synopsis: iDb=P1 root=P2 write=P3 */ | 15867 | #define OP_CursorLock 162 |
| 15802 | #define OP_VBegin 163 | 15868 | #define OP_CursorUnlock 163 |
| 15803 | #define OP_VCreate 164 | 15869 | #define OP_TableLock 164 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 15804 | #define OP_VDestroy 165 | 15870 | #define OP_VBegin 165 |
| 15805 | #define OP_VOpen 166 | 15871 | #define OP_VCreate 166 |
| 15806 | #define OP_VColumn 167 /* synopsis: r[P3]=vcolumn(P2) */ | 15872 | #define OP_VDestroy 167 |
| 15807 | #define OP_VRename 168 | 15873 | #define OP_VOpen 168 |
| 15808 | #define OP_Pagecount 169 | 15874 | #define OP_VColumn 169 /* synopsis: r[P3]=vcolumn(P2) */ |
| 15809 | #define OP_MaxPgcnt 170 | 15875 | #define OP_VRename 170 |
| 15810 | #define OP_Trace 171 | 15876 | #define OP_Pagecount 171 |
| 15811 | #define OP_CursorHint 172 | 15877 | #define OP_MaxPgcnt 172 |
| 15812 | #define OP_ReleaseReg 173 /* synopsis: release r[P1@P2] mask P3 */ | 15878 | #define OP_Trace 173 |
| 15813 | #define OP_Noop 174 | 15879 | #define OP_CursorHint 174 |
| 15814 | #define OP_Explain 175 | 15880 | #define OP_ReleaseReg 175 /* synopsis: release r[P1@P2] mask P3 */ |
| 15815 | #define OP_Abortable 176 | 15881 | #define OP_Noop 176 |
| 15882 | #define OP_Explain 177 | ||
| 15883 | #define OP_Abortable 178 | ||
| 15816 | 15884 | ||
| 15817 | /* Properties such as "out2" or "jump" that are specified in | 15885 | /* Properties such as "out2" or "jump" that are specified in |
| 15818 | ** comments following the "case" for each opcode in the vdbe.c | 15886 | ** comments following the "case" for each opcode in the vdbe.c |
| @@ -15835,19 +15903,19 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15835 | /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00,\ | 15903 | /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00,\ |
| 15836 | /* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ | 15904 | /* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ |
| 15837 | /* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ | 15905 | /* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ |
| 15838 | /* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x12,\ | 15906 | /* 80 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ |
| 15839 | /* 88 */ 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ | 15907 | /* 88 */ 0x12, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ |
| 15840 | /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26,\ | 15908 | /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26,\ |
| 15841 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\ | 15909 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 15842 | /* 112 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ | 15910 | /* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ |
| 15843 | /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 15911 | /* 120 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15844 | /* 128 */ 0x10, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\ | 15912 | /* 128 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x04, 0x04, 0x00,\ |
| 15845 | /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ | 15913 | /* 136 */ 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00,\ |
| 15846 | /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00,\ | 15914 | /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10,\ |
| 15847 | /* 152 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 15915 | /* 152 */ 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00,\ |
| 15848 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 15916 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 15849 | /* 168 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 15917 | /* 168 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\ |
| 15850 | /* 176 */ 0x00,} | 15918 | /* 176 */ 0x00, 0x00, 0x00,} |
| 15851 | 15919 | ||
| 15852 | /* The sqlite3P2Values() routine is able to run faster if it knows | 15920 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 15853 | ** the value of the largest JUMP opcode. The smaller the maximum | 15921 | ** the value of the largest JUMP opcode. The smaller the maximum |
| @@ -15915,7 +15983,7 @@ SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char*,const char*); | |||
| 15915 | #else | 15983 | #else |
| 15916 | # define sqlite3ExplainBreakpoint(A,B) /*no-op*/ | 15984 | # define sqlite3ExplainBreakpoint(A,B) /*no-op*/ |
| 15917 | #endif | 15985 | #endif |
| 15918 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); | 15986 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*, int, char*, u16); |
| 15919 | SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, int addr, u8); | 15987 | SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, int addr, u8); |
| 15920 | SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); | 15988 | SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); |
| 15921 | SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); | 15989 | SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); |
| @@ -16887,6 +16955,11 @@ SQLITE_PRIVATE void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**); | |||
| 16887 | #endif /* SQLITE_OMIT_DEPRECATED */ | 16955 | #endif /* SQLITE_OMIT_DEPRECATED */ |
| 16888 | #define SQLITE_TRACE_NONLEGACY_MASK 0x0f /* Normal flags */ | 16956 | #define SQLITE_TRACE_NONLEGACY_MASK 0x0f /* Normal flags */ |
| 16889 | 16957 | ||
| 16958 | /* | ||
| 16959 | ** Maximum number of sqlite3.aDb[] entries. This is the number of attached | ||
| 16960 | ** databases plus 2 for "main" and "temp". | ||
| 16961 | */ | ||
| 16962 | #define SQLITE_MAX_DB (SQLITE_MAX_ATTACHED+2) | ||
| 16890 | 16963 | ||
| 16891 | /* | 16964 | /* |
| 16892 | ** Each database connection is an instance of the following structure. | 16965 | ** Each database connection is an instance of the following structure. |
| @@ -16907,7 +16980,7 @@ struct sqlite3 { | |||
| 16907 | int errCode; /* Most recent error code (SQLITE_*) */ | 16980 | int errCode; /* Most recent error code (SQLITE_*) */ |
| 16908 | int errMask; /* & result codes with this before returning */ | 16981 | int errMask; /* & result codes with this before returning */ |
| 16909 | int iSysErrno; /* Errno value from last system error */ | 16982 | int iSysErrno; /* Errno value from last system error */ |
| 16910 | u16 dbOptFlags; /* Flags to enable/disable optimizations */ | 16983 | u32 dbOptFlags; /* Flags to enable/disable optimizations */ |
| 16911 | u8 enc; /* Text encoding */ | 16984 | u8 enc; /* Text encoding */ |
| 16912 | u8 autoCommit; /* The auto-commit flag. */ | 16985 | u8 autoCommit; /* The auto-commit flag. */ |
| 16913 | u8 temp_store; /* 1: file 2: memory 0: default */ | 16986 | u8 temp_store; /* 1: file 2: memory 0: default */ |
| @@ -17114,24 +17187,26 @@ struct sqlite3 { | |||
| 17114 | ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to | 17187 | ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to |
| 17115 | ** selectively disable various optimizations. | 17188 | ** selectively disable various optimizations. |
| 17116 | */ | 17189 | */ |
| 17117 | #define SQLITE_QueryFlattener 0x0001 /* Query flattening */ | 17190 | #define SQLITE_QueryFlattener 0x00000001 /* Query flattening */ |
| 17118 | #define SQLITE_WindowFunc 0x0002 /* Use xInverse for window functions */ | 17191 | #define SQLITE_WindowFunc 0x00000002 /* Use xInverse for window functions */ |
| 17119 | #define SQLITE_GroupByOrder 0x0004 /* GROUPBY cover of ORDERBY */ | 17192 | #define SQLITE_GroupByOrder 0x00000004 /* GROUPBY cover of ORDERBY */ |
| 17120 | #define SQLITE_FactorOutConst 0x0008 /* Constant factoring */ | 17193 | #define SQLITE_FactorOutConst 0x00000008 /* Constant factoring */ |
| 17121 | #define SQLITE_DistinctOpt 0x0010 /* DISTINCT using indexes */ | 17194 | #define SQLITE_DistinctOpt 0x00000010 /* DISTINCT using indexes */ |
| 17122 | #define SQLITE_CoverIdxScan 0x0020 /* Covering index scans */ | 17195 | #define SQLITE_CoverIdxScan 0x00000020 /* Covering index scans */ |
| 17123 | #define SQLITE_OrderByIdxJoin 0x0040 /* ORDER BY of joins via index */ | 17196 | #define SQLITE_OrderByIdxJoin 0x00000040 /* ORDER BY of joins via index */ |
| 17124 | #define SQLITE_Transitive 0x0080 /* Transitive constraints */ | 17197 | #define SQLITE_Transitive 0x00000080 /* Transitive constraints */ |
| 17125 | #define SQLITE_OmitNoopJoin 0x0100 /* Omit unused tables in joins */ | 17198 | #define SQLITE_OmitNoopJoin 0x00000100 /* Omit unused tables in joins */ |
| 17126 | #define SQLITE_CountOfView 0x0200 /* The count-of-view optimization */ | 17199 | #define SQLITE_CountOfView 0x00000200 /* The count-of-view optimization */ |
| 17127 | #define SQLITE_CursorHints 0x0400 /* Add OP_CursorHint opcodes */ | 17200 | #define SQLITE_CursorHints 0x00000400 /* Add OP_CursorHint opcodes */ |
| 17128 | #define SQLITE_Stat4 0x0800 /* Use STAT4 data */ | 17201 | #define SQLITE_Stat4 0x00000800 /* Use STAT4 data */ |
| 17129 | /* TH3 expects the Stat4 ^^^^^^ value to be 0x0800. Don't change it */ | 17202 | /* TH3 expects this value ^^^^^^^^^^ to be 0x0000800. Don't change it */ |
| 17130 | #define SQLITE_PushDown 0x1000 /* The push-down optimization */ | 17203 | #define SQLITE_PushDown 0x00001000 /* The push-down optimization */ |
| 17131 | #define SQLITE_SimplifyJoin 0x2000 /* Convert LEFT JOIN to JOIN */ | 17204 | #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */ |
| 17132 | #define SQLITE_SkipScan 0x4000 /* Skip-scans */ | 17205 | #define SQLITE_SkipScan 0x00004000 /* Skip-scans */ |
| 17133 | #define SQLITE_PropagateConst 0x8000 /* The constant propagation opt */ | 17206 | #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ |
| 17134 | #define SQLITE_AllOpts 0xffff /* All optimizations */ | 17207 | #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ |
| 17208 | #define SQLITE_ExistsToIN 0x00020000 /* The EXISTS-to-IN optimization */ | ||
| 17209 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ | ||
| 17135 | 17210 | ||
| 17136 | /* | 17211 | /* |
| 17137 | ** Macros for testing whether or not optimizations are enabled or disabled. | 17212 | ** Macros for testing whether or not optimizations are enabled or disabled. |
| @@ -17287,6 +17362,9 @@ struct FuncDestructor { | |||
| 17287 | ** a single query. The iArg is ignored. The user-data is always set | 17362 | ** a single query. The iArg is ignored. The user-data is always set |
| 17288 | ** to a NULL pointer. The bNC parameter is not used. | 17363 | ** to a NULL pointer. The bNC parameter is not used. |
| 17289 | ** | 17364 | ** |
| 17365 | ** MFUNCTION(zName, nArg, xPtr, xFunc) | ||
| 17366 | ** For math-library functions. xPtr is an arbitrary pointer. | ||
| 17367 | ** | ||
| 17290 | ** PURE_DATE(zName, nArg, iArg, bNC, xFunc) | 17368 | ** PURE_DATE(zName, nArg, iArg, bNC, xFunc) |
| 17291 | ** Used for "pure" date/time functions, this macro is like DFUNCTION | 17369 | ** Used for "pure" date/time functions, this macro is like DFUNCTION |
| 17292 | ** except that it does set the SQLITE_FUNC_CONSTANT flags. iArg is | 17370 | ** except that it does set the SQLITE_FUNC_CONSTANT flags. iArg is |
| @@ -17322,6 +17400,9 @@ struct FuncDestructor { | |||
| 17322 | #define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \ | 17400 | #define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 17323 | {nArg, SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \ | 17401 | {nArg, SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \ |
| 17324 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } | 17402 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17403 | #define MFUNCTION(zName, nArg, xPtr, xFunc) \ | ||
| 17404 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \ | ||
| 17405 | xPtr, 0, xFunc, 0, 0, 0, #zName, {0} } | ||
| 17325 | #define INLINE_FUNC(zName, nArg, iArg, mFlags) \ | 17406 | #define INLINE_FUNC(zName, nArg, iArg, mFlags) \ |
| 17326 | {nArg, SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ | 17407 | {nArg, SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ |
| 17327 | SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } | 17408 | SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } |
| @@ -17416,7 +17497,12 @@ struct Column { | |||
| 17416 | u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */ | 17497 | u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */ |
| 17417 | }; | 17498 | }; |
| 17418 | 17499 | ||
| 17419 | /* Allowed values for Column.colFlags: | 17500 | /* Allowed values for Column.colFlags. |
| 17501 | ** | ||
| 17502 | ** Constraints: | ||
| 17503 | ** TF_HasVirtual == COLFLAG_VIRTUAL | ||
| 17504 | ** TF_HasStored == COLFLAG_STORED | ||
| 17505 | ** TF_HasHidden == COLFLAG_HIDDEN | ||
| 17420 | */ | 17506 | */ |
| 17421 | #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ | 17507 | #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ |
| 17422 | #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ | 17508 | #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ |
| @@ -17592,7 +17678,6 @@ struct Table { | |||
| 17592 | #endif | 17678 | #endif |
| 17593 | Trigger *pTrigger; /* List of triggers stored in pSchema */ | 17679 | Trigger *pTrigger; /* List of triggers stored in pSchema */ |
| 17594 | Schema *pSchema; /* Schema that contains this table */ | 17680 | Schema *pSchema; /* Schema that contains this table */ |
| 17595 | Table *pNextZombie; /* Next on the Parse.pZombieTab list */ | ||
| 17596 | }; | 17681 | }; |
| 17597 | 17682 | ||
| 17598 | /* | 17683 | /* |
| @@ -17606,11 +17691,12 @@ struct Table { | |||
| 17606 | ** | 17691 | ** |
| 17607 | ** Constraints: | 17692 | ** Constraints: |
| 17608 | ** | 17693 | ** |
| 17609 | ** TF_HasVirtual == COLFLAG_Virtual | 17694 | ** TF_HasVirtual == COLFLAG_VIRTUAL |
| 17610 | ** TF_HasStored == COLFLAG_Stored | 17695 | ** TF_HasStored == COLFLAG_STORED |
| 17696 | ** TF_HasHidden == COLFLAG_HIDDEN | ||
| 17611 | */ | 17697 | */ |
| 17612 | #define TF_Readonly 0x0001 /* Read-only system table */ | 17698 | #define TF_Readonly 0x0001 /* Read-only system table */ |
| 17613 | #define TF_Ephemeral 0x0002 /* An ephemeral table */ | 17699 | #define TF_HasHidden 0x0002 /* Has one or more hidden columns */ |
| 17614 | #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */ | 17700 | #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */ |
| 17615 | #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */ | 17701 | #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */ |
| 17616 | #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */ | 17702 | #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */ |
| @@ -17625,6 +17711,7 @@ struct Table { | |||
| 17625 | #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */ | 17711 | #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */ |
| 17626 | #define TF_Shadow 0x1000 /* True for a shadow table */ | 17712 | #define TF_Shadow 0x1000 /* True for a shadow table */ |
| 17627 | #define TF_HasStat4 0x2000 /* STAT4 info available for this table */ | 17713 | #define TF_HasStat4 0x2000 /* STAT4 info available for this table */ |
| 17714 | #define TF_Ephemeral 0x4000 /* An ephemeral table */ | ||
| 17628 | 17715 | ||
| 17629 | /* | 17716 | /* |
| 17630 | ** Test to see whether or not a table is a virtual table. This is | 17717 | ** Test to see whether or not a table is a virtual table. This is |
| @@ -17721,16 +17808,22 @@ struct FKey { | |||
| 17721 | ** is returned. REPLACE means that preexisting database rows that caused | 17808 | ** is returned. REPLACE means that preexisting database rows that caused |
| 17722 | ** a UNIQUE constraint violation are removed so that the new insert or | 17809 | ** a UNIQUE constraint violation are removed so that the new insert or |
| 17723 | ** update can proceed. Processing continues and no error is reported. | 17810 | ** update can proceed. Processing continues and no error is reported. |
| 17811 | ** UPDATE applies to insert operations only and means that the insert | ||
| 17812 | ** is omitted and the DO UPDATE clause of an upsert is run instead. | ||
| 17724 | ** | 17813 | ** |
| 17725 | ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. | 17814 | ** RESTRICT, SETNULL, SETDFLT, and CASCADE actions apply only to foreign keys. |
| 17726 | ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the | 17815 | ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the |
| 17727 | ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign | 17816 | ** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign |
| 17728 | ** key is set to NULL. CASCADE means that a DELETE or UPDATE of the | 17817 | ** key is set to NULL. SETDFLT means that the foreign key is set |
| 17818 | ** to its default value. CASCADE means that a DELETE or UPDATE of the | ||
| 17729 | ** referenced table row is propagated into the row that holds the | 17819 | ** referenced table row is propagated into the row that holds the |
| 17730 | ** foreign key. | 17820 | ** foreign key. |
| 17731 | ** | 17821 | ** |
| 17822 | ** The OE_Default value is a place holder that means to use whatever | ||
| 17823 | ** conflict resolution algorthm is required from context. | ||
| 17824 | ** | ||
| 17732 | ** The following symbolic values are used to record which type | 17825 | ** The following symbolic values are used to record which type |
| 17733 | ** of action to take. | 17826 | ** of conflict resolution action to take. |
| 17734 | */ | 17827 | */ |
| 17735 | #define OE_None 0 /* There is no constraint to check */ | 17828 | #define OE_None 0 /* There is no constraint to check */ |
| 17736 | #define OE_Rollback 1 /* Fail the operation and rollback the transaction */ | 17829 | #define OE_Rollback 1 /* Fail the operation and rollback the transaction */ |
| @@ -17987,7 +18080,6 @@ struct AggInfo { | |||
| 17987 | } *aFunc; | 18080 | } *aFunc; |
| 17988 | int nFunc; /* Number of entries in aFunc[] */ | 18081 | int nFunc; /* Number of entries in aFunc[] */ |
| 17989 | u32 selId; /* Select to which this AggInfo belongs */ | 18082 | u32 selId; /* Select to which this AggInfo belongs */ |
| 17990 | AggInfo *pNext; /* Next in list of them all */ | ||
| 17991 | }; | 18083 | }; |
| 17992 | 18084 | ||
| 17993 | /* | 18085 | /* |
| @@ -18116,7 +18208,7 @@ struct Expr { | |||
| 18116 | ** TK_VARIABLE: variable number (always >= 1). | 18208 | ** TK_VARIABLE: variable number (always >= 1). |
| 18117 | ** TK_SELECT_COLUMN: column of the result vector */ | 18209 | ** TK_SELECT_COLUMN: column of the result vector */ |
| 18118 | i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ | 18210 | i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ |
| 18119 | i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ | 18211 | int iRightJoinTable; /* If EP_FromJoin, the right table of the join */ |
| 18120 | AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ | 18212 | AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ |
| 18121 | union { | 18213 | union { |
| 18122 | Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL | 18214 | Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL |
| @@ -18158,7 +18250,7 @@ struct Expr { | |||
| 18158 | #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ | 18250 | #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
| 18159 | #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ | 18251 | #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ |
| 18160 | #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */ | 18252 | #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */ |
| 18161 | #define EP_Alias 0x400000 /* Is an alias for a result set column */ | 18253 | /* 0x400000 // Available */ |
| 18162 | #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */ | 18254 | #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */ |
| 18163 | #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */ | 18255 | #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */ |
| 18164 | #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */ | 18256 | #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */ |
| @@ -18307,6 +18399,45 @@ struct IdList { | |||
| 18307 | }; | 18399 | }; |
| 18308 | 18400 | ||
| 18309 | /* | 18401 | /* |
| 18402 | ** The SrcItem object represents a single term in the FROM clause of a query. | ||
| 18403 | ** The SrcList object is mostly an array of SrcItems. | ||
| 18404 | */ | ||
| 18405 | struct SrcItem { | ||
| 18406 | Schema *pSchema; /* Schema to which this item is fixed */ | ||
| 18407 | char *zDatabase; /* Name of database holding this table */ | ||
| 18408 | char *zName; /* Name of the table */ | ||
| 18409 | char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ | ||
| 18410 | Table *pTab; /* An SQL table corresponding to zName */ | ||
| 18411 | Select *pSelect; /* A SELECT statement used in place of a table name */ | ||
| 18412 | int addrFillSub; /* Address of subroutine to manifest a subquery */ | ||
| 18413 | int regReturn; /* Register holding return address of addrFillSub */ | ||
| 18414 | int regResult; /* Registers holding results of a co-routine */ | ||
| 18415 | struct { | ||
| 18416 | u8 jointype; /* Type of join between this table and the previous */ | ||
| 18417 | unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ | ||
| 18418 | unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ | ||
| 18419 | unsigned isTabFunc :1; /* True if table-valued-function syntax */ | ||
| 18420 | unsigned isCorrelated :1; /* True if sub-query is correlated */ | ||
| 18421 | unsigned viaCoroutine :1; /* Implemented as a co-routine */ | ||
| 18422 | unsigned isRecursive :1; /* True for recursive reference in WITH */ | ||
| 18423 | unsigned fromDDL :1; /* Comes from sqlite_schema */ | ||
| 18424 | unsigned isCte :1; /* This is a CTE */ | ||
| 18425 | } fg; | ||
| 18426 | int iCursor; /* The VDBE cursor number used to access this table */ | ||
| 18427 | Expr *pOn; /* The ON clause of a join */ | ||
| 18428 | IdList *pUsing; /* The USING clause of a join */ | ||
| 18429 | Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ | ||
| 18430 | union { | ||
| 18431 | char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */ | ||
| 18432 | ExprList *pFuncArg; /* Arguments to table-valued-function */ | ||
| 18433 | } u1; | ||
| 18434 | union { | ||
| 18435 | Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */ | ||
| 18436 | CteUse *pCteUse; /* CTE Usage info info fg.isCte is true */ | ||
| 18437 | } u2; | ||
| 18438 | }; | ||
| 18439 | |||
| 18440 | /* | ||
| 18310 | ** The following structure describes the FROM clause of a SELECT statement. | 18441 | ** The following structure describes the FROM clause of a SELECT statement. |
| 18311 | ** Each table or subquery in the FROM clause is a separate element of | 18442 | ** Each table or subquery in the FROM clause is a separate element of |
| 18312 | ** the SrcList.a[] array. | 18443 | ** the SrcList.a[] array. |
| @@ -18328,36 +18459,7 @@ struct IdList { | |||
| 18328 | struct SrcList { | 18459 | struct SrcList { |
| 18329 | int nSrc; /* Number of tables or subqueries in the FROM clause */ | 18460 | int nSrc; /* Number of tables or subqueries in the FROM clause */ |
| 18330 | u32 nAlloc; /* Number of entries allocated in a[] below */ | 18461 | u32 nAlloc; /* Number of entries allocated in a[] below */ |
| 18331 | struct SrcList_item { | 18462 | SrcItem a[1]; /* One entry for each identifier on the list */ |
| 18332 | Schema *pSchema; /* Schema to which this item is fixed */ | ||
| 18333 | char *zDatabase; /* Name of database holding this table */ | ||
| 18334 | char *zName; /* Name of the table */ | ||
| 18335 | char *zAlias; /* The "B" part of a "A AS B" phrase. zName is the "A" */ | ||
| 18336 | Table *pTab; /* An SQL table corresponding to zName */ | ||
| 18337 | Select *pSelect; /* A SELECT statement used in place of a table name */ | ||
| 18338 | int addrFillSub; /* Address of subroutine to manifest a subquery */ | ||
| 18339 | int regReturn; /* Register holding return address of addrFillSub */ | ||
| 18340 | int regResult; /* Registers holding results of a co-routine */ | ||
| 18341 | struct { | ||
| 18342 | u8 jointype; /* Type of join between this table and the previous */ | ||
| 18343 | unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ | ||
| 18344 | unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ | ||
| 18345 | unsigned isTabFunc :1; /* True if table-valued-function syntax */ | ||
| 18346 | unsigned isCorrelated :1; /* True if sub-query is correlated */ | ||
| 18347 | unsigned viaCoroutine :1; /* Implemented as a co-routine */ | ||
| 18348 | unsigned isRecursive :1; /* True for recursive reference in WITH */ | ||
| 18349 | unsigned fromDDL :1; /* Comes from sqlite_schema */ | ||
| 18350 | } fg; | ||
| 18351 | int iCursor; /* The VDBE cursor number used to access this table */ | ||
| 18352 | Expr *pOn; /* The ON clause of a join */ | ||
| 18353 | IdList *pUsing; /* The USING clause of a join */ | ||
| 18354 | Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ | ||
| 18355 | union { | ||
| 18356 | char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */ | ||
| 18357 | ExprList *pFuncArg; /* Arguments to table-valued-function */ | ||
| 18358 | } u1; | ||
| 18359 | Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */ | ||
| 18360 | } a[1]; /* One entry for each identifier on the list */ | ||
| 18361 | }; | 18463 | }; |
| 18362 | 18464 | ||
| 18363 | /* | 18465 | /* |
| @@ -18433,6 +18535,7 @@ struct NameContext { | |||
| 18433 | ExprList *pEList; /* Optional list of result-set columns */ | 18535 | ExprList *pEList; /* Optional list of result-set columns */ |
| 18434 | AggInfo *pAggInfo; /* Information about aggregates at this level */ | 18536 | AggInfo *pAggInfo; /* Information about aggregates at this level */ |
| 18435 | Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */ | 18537 | Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */ |
| 18538 | int iBaseReg; /* For TK_REGISTER when parsing RETURNING */ | ||
| 18436 | } uNC; | 18539 | } uNC; |
| 18437 | NameContext *pNext; /* Next outer name context. NULL for outermost */ | 18540 | NameContext *pNext; /* Next outer name context. NULL for outermost */ |
| 18438 | int nRef; /* Number of names resolved by this context */ | 18541 | int nRef; /* Number of names resolved by this context */ |
| @@ -18461,6 +18564,7 @@ struct NameContext { | |||
| 18461 | #define NC_UEList 0x00080 /* True if uNC.pEList is used */ | 18564 | #define NC_UEList 0x00080 /* True if uNC.pEList is used */ |
| 18462 | #define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */ | 18565 | #define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */ |
| 18463 | #define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */ | 18566 | #define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */ |
| 18567 | #define NC_UBaseReg 0x00400 /* True if uNC.iBaseReg is used */ | ||
| 18464 | #define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */ | 18568 | #define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */ |
| 18465 | #define NC_Complex 0x02000 /* True if a function or subquery seen */ | 18569 | #define NC_Complex 0x02000 /* True if a function or subquery seen */ |
| 18466 | #define NC_AllowWin 0x04000 /* Window functions are allowed here */ | 18570 | #define NC_AllowWin 0x04000 /* Window functions are allowed here */ |
| @@ -18484,15 +18588,21 @@ struct NameContext { | |||
| 18484 | ** WHERE clause is omitted. | 18588 | ** WHERE clause is omitted. |
| 18485 | */ | 18589 | */ |
| 18486 | struct Upsert { | 18590 | struct Upsert { |
| 18487 | ExprList *pUpsertTarget; /* Optional description of conflicting index */ | 18591 | ExprList *pUpsertTarget; /* Optional description of conflict target */ |
| 18488 | Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */ | 18592 | Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */ |
| 18489 | ExprList *pUpsertSet; /* The SET clause from an ON CONFLICT UPDATE */ | 18593 | ExprList *pUpsertSet; /* The SET clause from an ON CONFLICT UPDATE */ |
| 18490 | Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */ | 18594 | Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */ |
| 18491 | /* The fields above comprise the parse tree for the upsert clause. | 18595 | Upsert *pNextUpsert; /* Next ON CONFLICT clause in the list */ |
| 18492 | ** The fields below are used to transfer information from the INSERT | 18596 | u8 isDoUpdate; /* True for DO UPDATE. False for DO NOTHING */ |
| 18493 | ** processing down into the UPDATE processing while generating code. | 18597 | /* Above this point is the parse tree for the ON CONFLICT clauses. |
| 18494 | ** Upsert owns the memory allocated above, but not the memory below. */ | 18598 | ** The next group of fields stores intermediate data. */ |
| 18495 | Index *pUpsertIdx; /* Constraint that pUpsertTarget identifies */ | 18599 | void *pToFree; /* Free memory when deleting the Upsert object */ |
| 18600 | /* All fields above are owned by the Upsert object and must be freed | ||
| 18601 | ** when the Upsert is destroyed. The fields below are used to transfer | ||
| 18602 | ** information from the INSERT processing down into the UPDATE processing | ||
| 18603 | ** while generating code. The fields below are owned by the INSERT | ||
| 18604 | ** statement and will be freed by INSERT processing. */ | ||
| 18605 | Index *pUpsertIdx; /* UNIQUE constraint specified by pUpsertTarget */ | ||
| 18496 | SrcList *pUpsertSrc; /* Table to be updated */ | 18606 | SrcList *pUpsertSrc; /* Table to be updated */ |
| 18497 | int regData; /* First register holding array of VALUES */ | 18607 | int regData; /* First register holding array of VALUES */ |
| 18498 | int iDataCur; /* Index of the data cursor */ | 18608 | int iDataCur; /* Index of the data cursor */ |
| @@ -18572,6 +18682,8 @@ struct Select { | |||
| 18572 | #define SF_View 0x0200000 /* SELECT statement is a view */ | 18682 | #define SF_View 0x0200000 /* SELECT statement is a view */ |
| 18573 | #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */ | 18683 | #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */ |
| 18574 | #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */ | 18684 | #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */ |
| 18685 | #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ | ||
| 18686 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ | ||
| 18575 | 18687 | ||
| 18576 | /* | 18688 | /* |
| 18577 | ** The results of a SELECT can be distributed in several ways, as defined | 18689 | ** The results of a SELECT can be distributed in several ways, as defined |
| @@ -18743,6 +18855,17 @@ struct TriggerPrg { | |||
| 18743 | #endif | 18855 | #endif |
| 18744 | 18856 | ||
| 18745 | /* | 18857 | /* |
| 18858 | ** An instance of the ParseCleanup object specifies an operation that | ||
| 18859 | ** should be performed after parsing to deallocation resources obtained | ||
| 18860 | ** during the parse and which are no longer needed. | ||
| 18861 | */ | ||
| 18862 | struct ParseCleanup { | ||
| 18863 | ParseCleanup *pNext; /* Next cleanup task */ | ||
| 18864 | void *pPtr; /* Pointer to object to deallocate */ | ||
| 18865 | void (*xCleanup)(sqlite3*,void*); /* Deallocation routine */ | ||
| 18866 | }; | ||
| 18867 | |||
| 18868 | /* | ||
| 18746 | ** An SQL parser context. A copy of this structure is passed through | 18869 | ** An SQL parser context. A copy of this structure is passed through |
| 18747 | ** the parser and down into all the parser action routine in order to | 18870 | ** the parser and down into all the parser action routine in order to |
| 18748 | ** carry around information that is global to the entire parse. | 18871 | ** carry around information that is global to the entire parse. |
| @@ -18773,6 +18896,9 @@ struct Parse { | |||
| 18773 | u8 okConstFactor; /* OK to factor out constants */ | 18896 | u8 okConstFactor; /* OK to factor out constants */ |
| 18774 | u8 disableLookaside; /* Number of times lookaside has been disabled */ | 18897 | u8 disableLookaside; /* Number of times lookaside has been disabled */ |
| 18775 | u8 disableVtab; /* Disable all virtual tables for this parse */ | 18898 | u8 disableVtab; /* Disable all virtual tables for this parse */ |
| 18899 | #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) | ||
| 18900 | u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */ | ||
| 18901 | #endif | ||
| 18776 | int nRangeReg; /* Size of the temporary register block */ | 18902 | int nRangeReg; /* Size of the temporary register block */ |
| 18777 | int iRangeReg; /* First register in temporary register block */ | 18903 | int iRangeReg; /* First register in temporary register block */ |
| 18778 | int nErr; /* Number of errors seen */ | 18904 | int nErr; /* Number of errors seen */ |
| @@ -18800,12 +18926,15 @@ struct Parse { | |||
| 18800 | Parse *pToplevel; /* Parse structure for main program (or NULL) */ | 18926 | Parse *pToplevel; /* Parse structure for main program (or NULL) */ |
| 18801 | Table *pTriggerTab; /* Table triggers are being coded for */ | 18927 | Table *pTriggerTab; /* Table triggers are being coded for */ |
| 18802 | Parse *pParentParse; /* Parent parser if this parser is nested */ | 18928 | Parse *pParentParse; /* Parent parser if this parser is nested */ |
| 18803 | AggInfo *pAggList; /* List of all AggInfo objects */ | 18929 | union { |
| 18804 | int addrCrTab; /* Address of OP_CreateBtree opcode on CREATE TABLE */ | 18930 | int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */ |
| 18931 | Returning *pReturning; /* The RETURNING clause */ | ||
| 18932 | } u1; | ||
| 18805 | u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ | 18933 | u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ |
| 18806 | u32 oldmask; /* Mask of old.* columns referenced */ | 18934 | u32 oldmask; /* Mask of old.* columns referenced */ |
| 18807 | u32 newmask; /* Mask of new.* columns referenced */ | 18935 | u32 newmask; /* Mask of new.* columns referenced */ |
| 18808 | u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ | 18936 | u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ |
| 18937 | u8 bReturning; /* Coding a RETURNING trigger */ | ||
| 18809 | u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ | 18938 | u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ |
| 18810 | u8 disableTriggers; /* True to disable triggers */ | 18939 | u8 disableTriggers; /* True to disable triggers */ |
| 18811 | 18940 | ||
| @@ -18851,10 +18980,9 @@ struct Parse { | |||
| 18851 | Token sArg; /* Complete text of a module argument */ | 18980 | Token sArg; /* Complete text of a module argument */ |
| 18852 | Table **apVtabLock; /* Pointer to virtual tables needing locking */ | 18981 | Table **apVtabLock; /* Pointer to virtual tables needing locking */ |
| 18853 | #endif | 18982 | #endif |
| 18854 | Table *pZombieTab; /* List of Table objects to delete after code gen */ | ||
| 18855 | TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */ | 18983 | TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */ |
| 18856 | With *pWith; /* Current WITH clause, or NULL */ | 18984 | With *pWith; /* Current WITH clause, or NULL */ |
| 18857 | With *pWithToFree; /* Free this WITH object at the end of the parse */ | 18985 | ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */ |
| 18858 | #ifndef SQLITE_OMIT_ALTERTABLE | 18986 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 18859 | RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */ | 18987 | RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */ |
| 18860 | #endif | 18988 | #endif |
| @@ -18934,6 +19062,7 @@ struct AuthContext { | |||
| 18934 | #define OPFLAG_SAVEPOSITION 0x02 /* OP_Delete/Insert: save cursor pos */ | 19062 | #define OPFLAG_SAVEPOSITION 0x02 /* OP_Delete/Insert: save cursor pos */ |
| 18935 | #define OPFLAG_AUXDELETE 0x04 /* OP_Delete: index in a DELETE op */ | 19063 | #define OPFLAG_AUXDELETE 0x04 /* OP_Delete: index in a DELETE op */ |
| 18936 | #define OPFLAG_NOCHNG_MAGIC 0x6d /* OP_MakeRecord: serialtype 10 is ok */ | 19064 | #define OPFLAG_NOCHNG_MAGIC 0x6d /* OP_MakeRecord: serialtype 10 is ok */ |
| 19065 | #define OPFLAG_PREFORMAT 0x80 /* OP_Insert uses preformatted cell */ | ||
| 18937 | 19066 | ||
| 18938 | /* | 19067 | /* |
| 18939 | * Each trigger present in the database schema is stored as an instance of | 19068 | * Each trigger present in the database schema is stored as an instance of |
| @@ -18955,6 +19084,7 @@ struct Trigger { | |||
| 18955 | char *table; /* The table or view to which the trigger applies */ | 19084 | char *table; /* The table or view to which the trigger applies */ |
| 18956 | u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ | 19085 | u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT */ |
| 18957 | u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ | 19086 | u8 tr_tm; /* One of TRIGGER_BEFORE, TRIGGER_AFTER */ |
| 19087 | u8 bReturning; /* This trigger implements a RETURNING clause */ | ||
| 18958 | Expr *pWhen; /* The WHEN clause of the expression (may be NULL) */ | 19088 | Expr *pWhen; /* The WHEN clause of the expression (may be NULL) */ |
| 18959 | IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger, | 19089 | IdList *pColumns; /* If this is an UPDATE OF <column-list> trigger, |
| 18960 | the <column-list> is stored here */ | 19090 | the <column-list> is stored here */ |
| @@ -19013,14 +19143,15 @@ struct Trigger { | |||
| 19013 | * | 19143 | * |
| 19014 | */ | 19144 | */ |
| 19015 | struct TriggerStep { | 19145 | struct TriggerStep { |
| 19016 | u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ | 19146 | u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT, |
| 19147 | ** or TK_RETURNING */ | ||
| 19017 | u8 orconf; /* OE_Rollback etc. */ | 19148 | u8 orconf; /* OE_Rollback etc. */ |
| 19018 | Trigger *pTrig; /* The trigger that this step is a part of */ | 19149 | Trigger *pTrig; /* The trigger that this step is a part of */ |
| 19019 | Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */ | 19150 | Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */ |
| 19020 | char *zTarget; /* Target table for DELETE, UPDATE, INSERT */ | 19151 | char *zTarget; /* Target table for DELETE, UPDATE, INSERT */ |
| 19021 | SrcList *pFrom; /* FROM clause for UPDATE statement (if any) */ | 19152 | SrcList *pFrom; /* FROM clause for UPDATE statement (if any) */ |
| 19022 | Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */ | 19153 | Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */ |
| 19023 | ExprList *pExprList; /* SET clause for UPDATE */ | 19154 | ExprList *pExprList; /* SET clause for UPDATE, or RETURNING clause */ |
| 19024 | IdList *pIdList; /* Column names for INSERT */ | 19155 | IdList *pIdList; /* Column names for INSERT */ |
| 19025 | Upsert *pUpsert; /* Upsert clauses on an INSERT */ | 19156 | Upsert *pUpsert; /* Upsert clauses on an INSERT */ |
| 19026 | char *zSpan; /* Original SQL text of this command */ | 19157 | char *zSpan; /* Original SQL text of this command */ |
| @@ -19029,18 +19160,16 @@ struct TriggerStep { | |||
| 19029 | }; | 19160 | }; |
| 19030 | 19161 | ||
| 19031 | /* | 19162 | /* |
| 19032 | ** The following structure contains information used by the sqliteFix... | 19163 | ** Information about a RETURNING clause |
| 19033 | ** routines as they walk the parse tree to make database references | ||
| 19034 | ** explicit. | ||
| 19035 | */ | 19164 | */ |
| 19036 | typedef struct DbFixer DbFixer; | 19165 | struct Returning { |
| 19037 | struct DbFixer { | 19166 | Parse *pParse; /* The parse that includes the RETURNING clause */ |
| 19038 | Parse *pParse; /* The parsing context. Error messages written here */ | 19167 | ExprList *pReturnEL; /* List of expressions to return */ |
| 19039 | Schema *pSchema; /* Fix items to this schema */ | 19168 | Trigger retTrig; /* The transient trigger that implements RETURNING */ |
| 19040 | u8 bTemp; /* True for TEMP schema entries */ | 19169 | TriggerStep retTStep; /* The trigger step */ |
| 19041 | const char *zDb; /* Make sure all objects are contained in this database */ | 19170 | int iRetCur; /* Transient table holding RETURNING results */ |
| 19042 | const char *zType; /* Type of the container - used for error messages */ | 19171 | int nRetCol; /* Number of in pReturnEL after expansion */ |
| 19043 | const Token *pName; /* Name of the container - used for error messages */ | 19172 | int iRetReg; /* Register array for holding a row of RETURNING */ |
| 19044 | }; | 19173 | }; |
| 19045 | 19174 | ||
| 19046 | /* | 19175 | /* |
| @@ -19080,7 +19209,8 @@ typedef struct { | |||
| 19080 | /* | 19209 | /* |
| 19081 | ** Allowed values for mInitFlags | 19210 | ** Allowed values for mInitFlags |
| 19082 | */ | 19211 | */ |
| 19083 | #define INITFLAG_AlterTable 0x0001 /* This is a reparse after ALTER TABLE */ | 19212 | #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */ |
| 19213 | #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */ | ||
| 19084 | 19214 | ||
| 19085 | /* | 19215 | /* |
| 19086 | ** Structure containing global configuration data for the SQLite library. | 19216 | ** Structure containing global configuration data for the SQLite library. |
| @@ -19192,10 +19322,26 @@ struct Walker { | |||
| 19192 | struct WhereConst *pConst; /* WHERE clause constants */ | 19322 | struct WhereConst *pConst; /* WHERE clause constants */ |
| 19193 | struct RenameCtx *pRename; /* RENAME COLUMN context */ | 19323 | struct RenameCtx *pRename; /* RENAME COLUMN context */ |
| 19194 | struct Table *pTab; /* Table of generated column */ | 19324 | struct Table *pTab; /* Table of generated column */ |
| 19195 | struct SrcList_item *pSrcItem; /* A single FROM clause item */ | 19325 | SrcItem *pSrcItem; /* A single FROM clause item */ |
| 19326 | DbFixer *pFix; | ||
| 19196 | } u; | 19327 | } u; |
| 19197 | }; | 19328 | }; |
| 19198 | 19329 | ||
| 19330 | /* | ||
| 19331 | ** The following structure contains information used by the sqliteFix... | ||
| 19332 | ** routines as they walk the parse tree to make database references | ||
| 19333 | ** explicit. | ||
| 19334 | */ | ||
| 19335 | struct DbFixer { | ||
| 19336 | Parse *pParse; /* The parsing context. Error messages written here */ | ||
| 19337 | Walker w; /* Walker object */ | ||
| 19338 | Schema *pSchema; /* Fix items to this schema */ | ||
| 19339 | u8 bTemp; /* True for TEMP schema entries */ | ||
| 19340 | const char *zDb; /* Make sure all objects are contained in this database */ | ||
| 19341 | const char *zType; /* Type of the container - used for error messages */ | ||
| 19342 | const Token *pName; /* Name of the container - used for error messages */ | ||
| 19343 | }; | ||
| 19344 | |||
| 19199 | /* Forward declarations */ | 19345 | /* Forward declarations */ |
| 19200 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); | 19346 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); |
| 19201 | SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*); | 19347 | SQLITE_PRIVATE int sqlite3WalkExprList(Walker*, ExprList*); |
| @@ -19221,20 +19367,55 @@ SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*); | |||
| 19221 | #define WRC_Abort 2 /* Abandon the tree walk */ | 19367 | #define WRC_Abort 2 /* Abandon the tree walk */ |
| 19222 | 19368 | ||
| 19223 | /* | 19369 | /* |
| 19224 | ** An instance of this structure represents a set of one or more CTEs | 19370 | ** A single common table expression |
| 19225 | ** (common table expressions) created by a single WITH clause. | 19371 | */ |
| 19372 | struct Cte { | ||
| 19373 | char *zName; /* Name of this CTE */ | ||
| 19374 | ExprList *pCols; /* List of explicit column names, or NULL */ | ||
| 19375 | Select *pSelect; /* The definition of this CTE */ | ||
| 19376 | const char *zCteErr; /* Error message for circular references */ | ||
| 19377 | CteUse *pUse; /* Usage information for this CTE */ | ||
| 19378 | u8 eM10d; /* The MATERIALIZED flag */ | ||
| 19379 | }; | ||
| 19380 | |||
| 19381 | /* | ||
| 19382 | ** Allowed values for the materialized flag (eM10d): | ||
| 19383 | */ | ||
| 19384 | #define M10d_Yes 0 /* AS MATERIALIZED */ | ||
| 19385 | #define M10d_Any 1 /* Not specified. Query planner's choice */ | ||
| 19386 | #define M10d_No 2 /* AS NOT MATERIALIZED */ | ||
| 19387 | |||
| 19388 | /* | ||
| 19389 | ** An instance of the With object represents a WITH clause containing | ||
| 19390 | ** one or more CTEs (common table expressions). | ||
| 19226 | */ | 19391 | */ |
| 19227 | struct With { | 19392 | struct With { |
| 19228 | int nCte; /* Number of CTEs in the WITH clause */ | 19393 | int nCte; /* Number of CTEs in the WITH clause */ |
| 19229 | With *pOuter; /* Containing WITH clause, or NULL */ | 19394 | With *pOuter; /* Containing WITH clause, or NULL */ |
| 19230 | struct Cte { /* For each CTE in the WITH clause.... */ | 19395 | Cte a[1]; /* For each CTE in the WITH clause.... */ |
| 19231 | char *zName; /* Name of this CTE */ | ||
| 19232 | ExprList *pCols; /* List of explicit column names, or NULL */ | ||
| 19233 | Select *pSelect; /* The definition of this CTE */ | ||
| 19234 | const char *zCteErr; /* Error message for circular references */ | ||
| 19235 | } a[1]; | ||
| 19236 | }; | 19396 | }; |
| 19237 | 19397 | ||
| 19398 | /* | ||
| 19399 | ** The Cte object is not guaranteed to persist for the entire duration | ||
| 19400 | ** of code generation. (The query flattener or other parser tree | ||
| 19401 | ** edits might delete it.) The following object records information | ||
| 19402 | ** about each Common Table Expression that must be preserved for the | ||
| 19403 | ** duration of the parse. | ||
| 19404 | ** | ||
| 19405 | ** The CteUse objects are freed using sqlite3ParserAddCleanup() rather | ||
| 19406 | ** than sqlite3SelectDelete(), which is what enables them to persist | ||
| 19407 | ** until the end of code generation. | ||
| 19408 | */ | ||
| 19409 | struct CteUse { | ||
| 19410 | int nUse; /* Number of users of this CTE */ | ||
| 19411 | int addrM9e; /* Start of subroutine to compute materialization */ | ||
| 19412 | int regRtn; /* Return address register for addrM9e subroutine */ | ||
| 19413 | int iCur; /* Ephemeral table holding the materialization */ | ||
| 19414 | LogEst nRowEst; /* Estimated number of rows in the table */ | ||
| 19415 | u8 eM10d; /* The MATERIALIZED flag */ | ||
| 19416 | }; | ||
| 19417 | |||
| 19418 | |||
| 19238 | #ifdef SQLITE_DEBUG | 19419 | #ifdef SQLITE_DEBUG |
| 19239 | /* | 19420 | /* |
| 19240 | ** An instance of the TreeView object is used for printing the content of | 19421 | ** An instance of the TreeView object is used for printing the content of |
| @@ -19312,7 +19493,6 @@ SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*, int); | |||
| 19312 | SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Select*); | 19493 | SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Select*); |
| 19313 | SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int); | 19494 | SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int); |
| 19314 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*); | 19495 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*); |
| 19315 | SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, struct SrcList_item*); | ||
| 19316 | SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*); | 19496 | SQLITE_PRIVATE void sqlite3WindowUpdate(Parse*, Window*, Window*, FuncDef*); |
| 19317 | SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p); | 19497 | SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p); |
| 19318 | SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p); | 19498 | SQLITE_PRIVATE Window *sqlite3WindowListDup(sqlite3 *db, Window *p); |
| @@ -19629,6 +19809,7 @@ SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*) | |||
| 19629 | SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); | 19809 | SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); |
| 19630 | SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*); | 19810 | SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*); |
| 19631 | SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); | 19811 | SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); |
| 19812 | SQLITE_PRIVATE void sqlite3AddReturning(Parse*,ExprList*); | ||
| 19632 | SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, | 19813 | SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, |
| 19633 | sqlite3_vfs**,char**,char **); | 19814 | sqlite3_vfs**,char**,char **); |
| 19634 | #define sqlite3CodecQueryParameters(A,B,C) 0 | 19815 | #define sqlite3CodecQueryParameters(A,B,C) 0 |
| @@ -19694,7 +19875,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, T | |||
| 19694 | Token*, Select*, Expr*, IdList*); | 19875 | Token*, Select*, Expr*, IdList*); |
| 19695 | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *); | 19876 | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *); |
| 19696 | SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*); | 19877 | SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*); |
| 19697 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *); | 19878 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, SrcItem *); |
| 19698 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); | 19879 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); |
| 19699 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); | 19880 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
| 19700 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); | 19881 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); |
| @@ -19722,6 +19903,7 @@ SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*); | |||
| 19722 | SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*); | 19903 | SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*); |
| 19723 | SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*); | 19904 | SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*); |
| 19724 | SQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo*); | 19905 | SQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo*); |
| 19906 | SQLITE_PRIVATE void sqlite3WhereMinMaxOptEarlyOut(Vdbe*,WhereInfo*); | ||
| 19725 | SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*); | 19907 | SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*); |
| 19726 | SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*); | 19908 | SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*); |
| 19727 | SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*); | 19909 | SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*); |
| @@ -19755,7 +19937,7 @@ SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*); | |||
| 19755 | #define LOCATE_VIEW 0x01 | 19937 | #define LOCATE_VIEW 0x01 |
| 19756 | #define LOCATE_NOERR 0x02 | 19938 | #define LOCATE_NOERR 0x02 |
| 19757 | SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*); | 19939 | SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*); |
| 19758 | SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *); | 19940 | SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,SrcItem *); |
| 19759 | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); | 19941 | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); |
| 19760 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); | 19942 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); |
| 19761 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); | 19943 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
| @@ -19883,6 +20065,7 @@ SQLITE_PRIVATE SrcList *sqlite3TriggerStepSrc(Parse*, TriggerStep*); | |||
| 19883 | #endif | 20065 | #endif |
| 19884 | 20066 | ||
| 19885 | SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*); | 20067 | SQLITE_PRIVATE int sqlite3JoinType(Parse*, Token*, Token*, Token*); |
| 20068 | SQLITE_PRIVATE int sqlite3ColumnIndex(Table *pTab, const char *zCol); | ||
| 19886 | SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int); | 20069 | SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr*,int); |
| 19887 | SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); | 20070 | SQLITE_PRIVATE void sqlite3CreateForeignKey(Parse*, ExprList*, Token*, ExprList*, int); |
| 19888 | SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int); | 20071 | SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse*, int); |
| @@ -19905,7 +20088,6 @@ SQLITE_PRIVATE void sqlite3FixInit(DbFixer*, Parse*, int, const char*, const Tok | |||
| 19905 | SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*); | 20088 | SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*); |
| 19906 | SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*); | 20089 | SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*); |
| 19907 | SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*); | 20090 | SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*); |
| 19908 | SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*); | ||
| 19909 | SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); | 20091 | SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*); |
| 19910 | SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64); | 20092 | SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64); |
| 19911 | SQLITE_PRIVATE void sqlite3Int64ToText(i64,char*); | 20093 | SQLITE_PRIVATE void sqlite3Int64ToText(i64,char*); |
| @@ -19968,6 +20150,7 @@ SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8); | |||
| 19968 | SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*); | 20150 | SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*); |
| 19969 | SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...); | 20151 | SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...); |
| 19970 | SQLITE_PRIVATE void sqlite3Error(sqlite3*,int); | 20152 | SQLITE_PRIVATE void sqlite3Error(sqlite3*,int); |
| 20153 | SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3*); | ||
| 19971 | SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int); | 20154 | SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int); |
| 19972 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); | 20155 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
| 19973 | SQLITE_PRIVATE u8 sqlite3HexToInt(int h); | 20156 | SQLITE_PRIVATE u8 sqlite3HexToInt(int h); |
| @@ -20031,7 +20214,6 @@ SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[]; | |||
| 20031 | SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[]; | 20214 | SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[]; |
| 20032 | SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config; | 20215 | SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config; |
| 20033 | SQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions; | 20216 | SQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions; |
| 20034 | SQLITE_API extern u32 sqlite3_unsupported_selecttrace; | ||
| 20035 | #ifndef SQLITE_OMIT_WSD | 20217 | #ifndef SQLITE_OMIT_WSD |
| 20036 | SQLITE_PRIVATE int sqlite3PendingByte; | 20218 | SQLITE_PRIVATE int sqlite3PendingByte; |
| 20037 | #endif | 20219 | #endif |
| @@ -20050,6 +20232,7 @@ SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int); | |||
| 20050 | SQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int); | 20232 | SQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int); |
| 20051 | SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*); | 20233 | SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*); |
| 20052 | SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); | 20234 | SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); |
| 20235 | SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse*, SrcItem*); | ||
| 20053 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); | 20236 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
| 20054 | SQLITE_PRIVATE int sqlite3MatchEName( | 20237 | SQLITE_PRIVATE int sqlite3MatchEName( |
| 20055 | const struct ExprList_item*, | 20238 | const struct ExprList_item*, |
| @@ -20067,6 +20250,7 @@ SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const | |||
| 20067 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); | 20250 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); |
| 20068 | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); | 20251 | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); |
| 20069 | SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); | 20252 | SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); |
| 20253 | SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse*, SrcList*, Token*); | ||
| 20070 | SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse*, void*, Token*); | 20254 | SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse*, void*, Token*); |
| 20071 | SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, void *pTo, void *pFrom); | 20255 | SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, void *pTo, void *pFrom); |
| 20072 | SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*); | 20256 | SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*); |
| @@ -20090,6 +20274,7 @@ SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo*); | |||
| 20090 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*); | 20274 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoRef(KeyInfo*); |
| 20091 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*); | 20275 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*); |
| 20092 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int); | 20276 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList(Parse*, ExprList*, int, int); |
| 20277 | SQLITE_PRIVATE const char *sqlite3SelectOpName(int); | ||
| 20093 | SQLITE_PRIVATE int sqlite3HasExplicitNulls(Parse*, ExprList*); | 20278 | SQLITE_PRIVATE int sqlite3HasExplicitNulls(Parse*, ExprList*); |
| 20094 | 20279 | ||
| 20095 | #ifdef SQLITE_DEBUG | 20280 | #ifdef SQLITE_DEBUG |
| @@ -20220,6 +20405,7 @@ SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*); | |||
| 20220 | SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); | 20405 | SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); |
| 20221 | SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *); | 20406 | SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *); |
| 20222 | SQLITE_PRIVATE void sqlite3ParserReset(Parse*); | 20407 | SQLITE_PRIVATE void sqlite3ParserReset(Parse*); |
| 20408 | SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*); | ||
| 20223 | #ifdef SQLITE_ENABLE_NORMALIZE | 20409 | #ifdef SQLITE_ENABLE_NORMALIZE |
| 20224 | SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*); | 20410 | SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*); |
| 20225 | #endif | 20411 | #endif |
| @@ -20234,23 +20420,32 @@ SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*); | |||
| 20234 | SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); | 20420 | SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int); |
| 20235 | #endif | 20421 | #endif |
| 20236 | #ifndef SQLITE_OMIT_CTE | 20422 | #ifndef SQLITE_OMIT_CTE |
| 20237 | SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*); | 20423 | SQLITE_PRIVATE Cte *sqlite3CteNew(Parse*,Token*,ExprList*,Select*,u8); |
| 20424 | SQLITE_PRIVATE void sqlite3CteDelete(sqlite3*,Cte*); | ||
| 20425 | SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Cte*); | ||
| 20238 | SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); | 20426 | SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); |
| 20239 | SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8); | 20427 | SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8); |
| 20240 | #else | 20428 | #else |
| 20241 | #define sqlite3WithPush(x,y,z) | 20429 | # define sqlite3CteNew(P,T,E,S) ((void*)0) |
| 20242 | #define sqlite3WithDelete(x,y) | 20430 | # define sqlite3CteDelete(D,C) |
| 20431 | # define sqlite3CteWithAdd(P,W,C) ((void*)0) | ||
| 20432 | # define sqlite3WithDelete(x,y) | ||
| 20433 | # define sqlite3WithPush(x,y,z) | ||
| 20243 | #endif | 20434 | #endif |
| 20244 | #ifndef SQLITE_OMIT_UPSERT | 20435 | #ifndef SQLITE_OMIT_UPSERT |
| 20245 | SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*); | 20436 | SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*); |
| 20246 | SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3*,Upsert*); | 20437 | SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3*,Upsert*); |
| 20247 | SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3*,Upsert*); | 20438 | SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3*,Upsert*); |
| 20248 | SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*); | 20439 | SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*); |
| 20249 | SQLITE_PRIVATE void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int); | 20440 | SQLITE_PRIVATE void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int); |
| 20441 | SQLITE_PRIVATE Upsert *sqlite3UpsertOfIndex(Upsert*,Index*); | ||
| 20442 | SQLITE_PRIVATE int sqlite3UpsertNextIsIPK(Upsert*); | ||
| 20250 | #else | 20443 | #else |
| 20251 | #define sqlite3UpsertNew(v,w,x,y,z) ((Upsert*)0) | 20444 | #define sqlite3UpsertNew(u,v,w,x,y,z) ((Upsert*)0) |
| 20252 | #define sqlite3UpsertDelete(x,y) | 20445 | #define sqlite3UpsertDelete(x,y) |
| 20253 | #define sqlite3UpsertDup(x,y) ((Upsert*)0) | 20446 | #define sqlite3UpsertDup(x,y) ((Upsert*)0) |
| 20447 | #define sqlite3UpsertOfIndex(x,y) ((Upsert*)0) | ||
| 20448 | #define sqlite3UpsertNextIsIPK(x) 0 | ||
| 20254 | #endif | 20449 | #endif |
| 20255 | 20450 | ||
| 20256 | 20451 | ||
| @@ -20746,9 +20941,10 @@ SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000; | |||
| 20746 | #endif | 20941 | #endif |
| 20747 | 20942 | ||
| 20748 | /* | 20943 | /* |
| 20749 | ** Flags for select tracing and the ".selecttrace" macro of the CLI | 20944 | ** Tracing flags set by SQLITE_TESTCTRL_TRACEFLAGS. |
| 20750 | */ | 20945 | */ |
| 20751 | SQLITE_API u32 sqlite3_unsupported_selecttrace = 0; | 20946 | SQLITE_PRIVATE u32 sqlite3SelectTrace = 0; |
| 20947 | SQLITE_PRIVATE u32 sqlite3WhereTrace = 0; | ||
| 20752 | 20948 | ||
| 20753 | /* #include "opcodes.h" */ | 20949 | /* #include "opcodes.h" */ |
| 20754 | /* | 20950 | /* |
| @@ -21167,7 +21363,7 @@ struct Vdbe { | |||
| 21167 | Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ | 21363 | Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ |
| 21168 | Parse *pParse; /* Parsing context used to create this Vdbe */ | 21364 | Parse *pParse; /* Parsing context used to create this Vdbe */ |
| 21169 | ynVar nVar; /* Number of entries in aVar[] */ | 21365 | ynVar nVar; /* Number of entries in aVar[] */ |
| 21170 | u32 magic; /* Magic number for sanity checking */ | 21366 | u32 iVdbeMagic; /* Magic number defining state of the SQL statement */ |
| 21171 | int nMem; /* Number of memory locations currently allocated */ | 21367 | int nMem; /* Number of memory locations currently allocated */ |
| 21172 | int nCursor; /* Number of slots in apCsr[] */ | 21368 | int nCursor; /* Number of slots in apCsr[] */ |
| 21173 | u32 cacheCtr; /* VdbeCursor row cache generation counter */ | 21369 | u32 cacheCtr; /* VdbeCursor row cache generation counter */ |
| @@ -23172,6 +23368,8 @@ SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){ | |||
| 23172 | #ifdef SQLITE_TEST | 23368 | #ifdef SQLITE_TEST |
| 23173 | if( op!=SQLITE_FCNTL_COMMIT_PHASETWO | 23369 | if( op!=SQLITE_FCNTL_COMMIT_PHASETWO |
| 23174 | && op!=SQLITE_FCNTL_LOCK_TIMEOUT | 23370 | && op!=SQLITE_FCNTL_LOCK_TIMEOUT |
| 23371 | && op!=SQLITE_FCNTL_CKPT_DONE | ||
| 23372 | && op!=SQLITE_FCNTL_CKPT_START | ||
| 23175 | ){ | 23373 | ){ |
| 23176 | /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite | 23374 | /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite |
| 23177 | ** is using a regular VFS, it is called after the corresponding | 23375 | ** is using a regular VFS, it is called after the corresponding |
| @@ -23182,7 +23380,12 @@ SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){ | |||
| 23182 | ** The core must call OsFileControl() though, not OsFileControlHint(), | 23380 | ** The core must call OsFileControl() though, not OsFileControlHint(), |
| 23183 | ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably | 23381 | ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably |
| 23184 | ** means the commit really has failed and an error should be returned | 23382 | ** means the commit really has failed and an error should be returned |
| 23185 | ** to the user. */ | 23383 | ** to the user. |
| 23384 | ** | ||
| 23385 | ** The CKPT_DONE and CKPT_START file-controls are write-only signals | ||
| 23386 | ** to the cksumvfs. Their return code is meaningless and is ignored | ||
| 23387 | ** by the SQLite core, so there is no point in simulating OOMs for them. | ||
| 23388 | */ | ||
| 23186 | DO_OS_MALLOC_TEST(id); | 23389 | DO_OS_MALLOC_TEST(id); |
| 23187 | } | 23390 | } |
| 23188 | #endif | 23391 | #endif |
| @@ -29081,7 +29284,7 @@ SQLITE_API void sqlite3_str_vappendf( | |||
| 29081 | case etSRCLIST: { | 29284 | case etSRCLIST: { |
| 29082 | SrcList *pSrc; | 29285 | SrcList *pSrc; |
| 29083 | int k; | 29286 | int k; |
| 29084 | struct SrcList_item *pItem; | 29287 | SrcItem *pItem; |
| 29085 | if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return; | 29288 | if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return; |
| 29086 | pSrc = va_arg(ap, SrcList*); | 29289 | pSrc = va_arg(ap, SrcList*); |
| 29087 | k = va_arg(ap, int); | 29290 | k = va_arg(ap, int); |
| @@ -29146,7 +29349,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ | |||
| 29146 | }else{ | 29349 | }else{ |
| 29147 | char *zOld = isMalloced(p) ? p->zText : 0; | 29350 | char *zOld = isMalloced(p) ? p->zText : 0; |
| 29148 | i64 szNew = p->nChar; | 29351 | i64 szNew = p->nChar; |
| 29149 | szNew += N + 1; | 29352 | szNew += (sqlite3_int64)N + 1; |
| 29150 | if( szNew+p->nChar<=p->mxAlloc ){ | 29353 | if( szNew+p->nChar<=p->mxAlloc ){ |
| 29151 | /* Force exponential buffer size growth as long as it does not overflow, | 29354 | /* Force exponential buffer size growth as long as it does not overflow, |
| 29152 | ** to avoid having to call this routine too often */ | 29355 | ** to avoid having to call this routine too often */ |
| @@ -29649,7 +29852,10 @@ SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 m | |||
| 29649 | } | 29852 | } |
| 29650 | sqlite3_str_appendf(&x, ")"); | 29853 | sqlite3_str_appendf(&x, ")"); |
| 29651 | } | 29854 | } |
| 29652 | sqlite3_str_appendf(&x, " AS"); | 29855 | if( pCte->pUse ){ |
| 29856 | sqlite3_str_appendf(&x, " (pUse=0x%p, nUse=%d)", pCte->pUse, | ||
| 29857 | pCte->pUse->nUse); | ||
| 29858 | } | ||
| 29653 | sqlite3StrAccumFinish(&x); | 29859 | sqlite3StrAccumFinish(&x); |
| 29654 | sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1); | 29860 | sqlite3TreeViewItem(pView, zLine, i<pWith->nCte-1); |
| 29655 | sqlite3TreeViewSelect(pView, pCte->pSelect, 0); | 29861 | sqlite3TreeViewSelect(pView, pCte->pSelect, 0); |
| @@ -29665,7 +29871,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWith(TreeView *pView, const With *pWith, u8 m | |||
| 29665 | SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ | 29871 | SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){ |
| 29666 | int i; | 29872 | int i; |
| 29667 | for(i=0; i<pSrc->nSrc; i++){ | 29873 | for(i=0; i<pSrc->nSrc; i++){ |
| 29668 | const struct SrcList_item *pItem = &pSrc->a[i]; | 29874 | const SrcItem *pItem = &pSrc->a[i]; |
| 29669 | StrAccum x; | 29875 | StrAccum x; |
| 29670 | char zLine[100]; | 29876 | char zLine[100]; |
| 29671 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); | 29877 | sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| @@ -29688,6 +29894,9 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc) | |||
| 29688 | if( pItem->fg.fromDDL ){ | 29894 | if( pItem->fg.fromDDL ){ |
| 29689 | sqlite3_str_appendf(&x, " DDL"); | 29895 | sqlite3_str_appendf(&x, " DDL"); |
| 29690 | } | 29896 | } |
| 29897 | if( pItem->fg.isCte ){ | ||
| 29898 | sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse); | ||
| 29899 | } | ||
| 29691 | sqlite3StrAccumFinish(&x); | 29900 | sqlite3StrAccumFinish(&x); |
| 29692 | sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); | 29901 | sqlite3TreeViewItem(pView, zLine, i<pSrc->nSrc-1); |
| 29693 | if( pItem->pSelect ){ | 29902 | if( pItem->pSelect ){ |
| @@ -31385,6 +31594,16 @@ SQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){ | |||
| 31385 | } | 31594 | } |
| 31386 | 31595 | ||
| 31387 | /* | 31596 | /* |
| 31597 | ** The equivalent of sqlite3Error(db, SQLITE_OK). Clear the error state | ||
| 31598 | ** and error message. | ||
| 31599 | */ | ||
| 31600 | SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3 *db){ | ||
| 31601 | assert( db!=0 ); | ||
| 31602 | db->errCode = SQLITE_OK; | ||
| 31603 | if( db->pErr ) sqlite3ValueSetNull(db->pErr); | ||
| 31604 | } | ||
| 31605 | |||
| 31606 | /* | ||
| 31388 | ** Load the sqlite3.iSysErrno field if that is an appropriate thing | 31607 | ** Load the sqlite3.iSysErrno field if that is an appropriate thing |
| 31389 | ** to do based on the SQLite error code in rc. | 31608 | ** to do based on the SQLite error code in rc. |
| 31390 | */ | 31609 | */ |
| @@ -33330,103 +33549,105 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 33330 | /* 77 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), | 33549 | /* 77 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 33331 | /* 78 */ "SCopy" OpHelp("r[P2]=r[P1]"), | 33550 | /* 78 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 33332 | /* 79 */ "IntCopy" OpHelp("r[P2]=r[P1]"), | 33551 | /* 79 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 33333 | /* 80 */ "ResultRow" OpHelp("output=r[P1@P2]"), | 33552 | /* 80 */ "ChngCntRow" OpHelp("output=r[P1]"), |
| 33334 | /* 81 */ "CollSeq" OpHelp(""), | 33553 | /* 81 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 33335 | /* 82 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), | 33554 | /* 82 */ "CollSeq" OpHelp(""), |
| 33336 | /* 83 */ "RealAffinity" OpHelp(""), | 33555 | /* 83 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 33337 | /* 84 */ "Cast" OpHelp("affinity(r[P1])"), | 33556 | /* 84 */ "RealAffinity" OpHelp(""), |
| 33338 | /* 85 */ "Permutation" OpHelp(""), | 33557 | /* 85 */ "Cast" OpHelp("affinity(r[P1])"), |
| 33339 | /* 86 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), | 33558 | /* 86 */ "Permutation" OpHelp(""), |
| 33340 | /* 87 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), | 33559 | /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 33341 | /* 88 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), | 33560 | /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 33342 | /* 89 */ "Column" OpHelp("r[P3]=PX"), | 33561 | /* 89 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 33343 | /* 90 */ "Affinity" OpHelp("affinity(r[P1@P2])"), | 33562 | /* 90 */ "Column" OpHelp("r[P3]=PX"), |
| 33344 | /* 91 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), | 33563 | /* 91 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 33345 | /* 92 */ "Count" OpHelp("r[P2]=count()"), | 33564 | /* 92 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 33346 | /* 93 */ "ReadCookie" OpHelp(""), | 33565 | /* 93 */ "Count" OpHelp("r[P2]=count()"), |
| 33347 | /* 94 */ "SetCookie" OpHelp(""), | 33566 | /* 94 */ "ReadCookie" OpHelp(""), |
| 33348 | /* 95 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), | 33567 | /* 95 */ "SetCookie" OpHelp(""), |
| 33349 | /* 96 */ "OpenRead" OpHelp("root=P2 iDb=P3"), | 33568 | /* 96 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 33350 | /* 97 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), | 33569 | /* 97 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 33351 | /* 98 */ "OpenDup" OpHelp(""), | 33570 | /* 98 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 33352 | /* 99 */ "OpenAutoindex" OpHelp("nColumn=P2"), | 33571 | /* 99 */ "OpenDup" OpHelp(""), |
| 33353 | /* 100 */ "OpenEphemeral" OpHelp("nColumn=P2"), | 33572 | /* 100 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 33354 | /* 101 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), | 33573 | /* 101 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 33355 | /* 102 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), | 33574 | /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 33356 | /* 103 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), | 33575 | /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 33357 | /* 104 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), | 33576 | /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 33358 | /* 105 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), | 33577 | /* 105 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 33359 | /* 106 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), | 33578 | /* 106 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| 33360 | /* 107 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), | 33579 | /* 107 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 33361 | /* 108 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), | 33580 | /* 108 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 33362 | /* 109 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), | 33581 | /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 33363 | /* 110 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), | 33582 | /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 33364 | /* 111 */ "SorterOpen" OpHelp(""), | 33583 | /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 33365 | /* 112 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), | 33584 | /* 112 */ "SorterOpen" OpHelp(""), |
| 33366 | /* 113 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), | 33585 | /* 113 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 33367 | /* 114 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), | 33586 | /* 114 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 33368 | /* 115 */ "String8" OpHelp("r[P2]='P4'"), | 33587 | /* 115 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 33369 | /* 116 */ "Close" OpHelp(""), | 33588 | /* 116 */ "String8" OpHelp("r[P2]='P4'"), |
| 33370 | /* 117 */ "ColumnsUsed" OpHelp(""), | 33589 | /* 117 */ "Close" OpHelp(""), |
| 33371 | /* 118 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), | 33590 | /* 118 */ "ColumnsUsed" OpHelp(""), |
| 33372 | /* 119 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), | 33591 | /* 119 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), |
| 33373 | /* 120 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), | 33592 | /* 120 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), |
| 33374 | /* 121 */ "NewRowid" OpHelp("r[P2]=rowid"), | 33593 | /* 121 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 33375 | /* 122 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), | 33594 | /* 122 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 33376 | /* 123 */ "Delete" OpHelp(""), | 33595 | /* 123 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 33377 | /* 124 */ "ResetCount" OpHelp(""), | 33596 | /* 124 */ "RowCell" OpHelp(""), |
| 33378 | /* 125 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), | 33597 | /* 125 */ "Delete" OpHelp(""), |
| 33379 | /* 126 */ "SorterData" OpHelp("r[P2]=data"), | 33598 | /* 126 */ "ResetCount" OpHelp(""), |
| 33380 | /* 127 */ "RowData" OpHelp("r[P2]=data"), | 33599 | /* 127 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 33381 | /* 128 */ "Rowid" OpHelp("r[P2]=rowid"), | 33600 | /* 128 */ "SorterData" OpHelp("r[P2]=data"), |
| 33382 | /* 129 */ "NullRow" OpHelp(""), | 33601 | /* 129 */ "RowData" OpHelp("r[P2]=data"), |
| 33383 | /* 130 */ "SeekEnd" OpHelp(""), | 33602 | /* 130 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 33384 | /* 131 */ "IdxInsert" OpHelp("key=r[P2]"), | 33603 | /* 131 */ "NullRow" OpHelp(""), |
| 33385 | /* 132 */ "SorterInsert" OpHelp("key=r[P2]"), | 33604 | /* 132 */ "SeekEnd" OpHelp(""), |
| 33386 | /* 133 */ "IdxDelete" OpHelp("key=r[P2@P3]"), | 33605 | /* 133 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 33387 | /* 134 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), | 33606 | /* 134 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 33388 | /* 135 */ "IdxRowid" OpHelp("r[P2]=rowid"), | 33607 | /* 135 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 33389 | /* 136 */ "FinishSeek" OpHelp(""), | 33608 | /* 136 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 33390 | /* 137 */ "Destroy" OpHelp(""), | 33609 | /* 137 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 33391 | /* 138 */ "Clear" OpHelp(""), | 33610 | /* 138 */ "FinishSeek" OpHelp(""), |
| 33392 | /* 139 */ "ResetSorter" OpHelp(""), | 33611 | /* 139 */ "Destroy" OpHelp(""), |
| 33393 | /* 140 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), | 33612 | /* 140 */ "Clear" OpHelp(""), |
| 33394 | /* 141 */ "SqlExec" OpHelp(""), | 33613 | /* 141 */ "ResetSorter" OpHelp(""), |
| 33395 | /* 142 */ "ParseSchema" OpHelp(""), | 33614 | /* 142 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), |
| 33396 | /* 143 */ "LoadAnalysis" OpHelp(""), | 33615 | /* 143 */ "SqlExec" OpHelp(""), |
| 33397 | /* 144 */ "DropTable" OpHelp(""), | 33616 | /* 144 */ "ParseSchema" OpHelp(""), |
| 33398 | /* 145 */ "DropIndex" OpHelp(""), | 33617 | /* 145 */ "LoadAnalysis" OpHelp(""), |
| 33399 | /* 146 */ "DropTrigger" OpHelp(""), | 33618 | /* 146 */ "DropTable" OpHelp(""), |
| 33400 | /* 147 */ "IntegrityCk" OpHelp(""), | 33619 | /* 147 */ "DropIndex" OpHelp(""), |
| 33401 | /* 148 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), | 33620 | /* 148 */ "DropTrigger" OpHelp(""), |
| 33402 | /* 149 */ "Param" OpHelp(""), | 33621 | /* 149 */ "IntegrityCk" OpHelp(""), |
| 33403 | /* 150 */ "Real" OpHelp("r[P2]=P4"), | 33622 | /* 150 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 33404 | /* 151 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), | 33623 | /* 151 */ "Param" OpHelp(""), |
| 33405 | /* 152 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), | 33624 | /* 152 */ "Real" OpHelp("r[P2]=P4"), |
| 33406 | /* 153 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), | 33625 | /* 153 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 33407 | /* 154 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), | 33626 | /* 154 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 33408 | /* 155 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), | 33627 | /* 155 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 33409 | /* 156 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), | 33628 | /* 156 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), |
| 33410 | /* 157 */ "AggValue" OpHelp("r[P3]=value N=P2"), | 33629 | /* 157 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 33411 | /* 158 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), | 33630 | /* 158 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 33412 | /* 159 */ "Expire" OpHelp(""), | 33631 | /* 159 */ "AggValue" OpHelp("r[P3]=value N=P2"), |
| 33413 | /* 160 */ "CursorLock" OpHelp(""), | 33632 | /* 160 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 33414 | /* 161 */ "CursorUnlock" OpHelp(""), | 33633 | /* 161 */ "Expire" OpHelp(""), |
| 33415 | /* 162 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), | 33634 | /* 162 */ "CursorLock" OpHelp(""), |
| 33416 | /* 163 */ "VBegin" OpHelp(""), | 33635 | /* 163 */ "CursorUnlock" OpHelp(""), |
| 33417 | /* 164 */ "VCreate" OpHelp(""), | 33636 | /* 164 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 33418 | /* 165 */ "VDestroy" OpHelp(""), | 33637 | /* 165 */ "VBegin" OpHelp(""), |
| 33419 | /* 166 */ "VOpen" OpHelp(""), | 33638 | /* 166 */ "VCreate" OpHelp(""), |
| 33420 | /* 167 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | 33639 | /* 167 */ "VDestroy" OpHelp(""), |
| 33421 | /* 168 */ "VRename" OpHelp(""), | 33640 | /* 168 */ "VOpen" OpHelp(""), |
| 33422 | /* 169 */ "Pagecount" OpHelp(""), | 33641 | /* 169 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 33423 | /* 170 */ "MaxPgcnt" OpHelp(""), | 33642 | /* 170 */ "VRename" OpHelp(""), |
| 33424 | /* 171 */ "Trace" OpHelp(""), | 33643 | /* 171 */ "Pagecount" OpHelp(""), |
| 33425 | /* 172 */ "CursorHint" OpHelp(""), | 33644 | /* 172 */ "MaxPgcnt" OpHelp(""), |
| 33426 | /* 173 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | 33645 | /* 173 */ "Trace" OpHelp(""), |
| 33427 | /* 174 */ "Noop" OpHelp(""), | 33646 | /* 174 */ "CursorHint" OpHelp(""), |
| 33428 | /* 175 */ "Explain" OpHelp(""), | 33647 | /* 175 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 33429 | /* 176 */ "Abortable" OpHelp(""), | 33648 | /* 176 */ "Noop" OpHelp(""), |
| 33649 | /* 177 */ "Explain" OpHelp(""), | ||
| 33650 | /* 178 */ "Abortable" OpHelp(""), | ||
| 33430 | }; | 33651 | }; |
| 33431 | return azName[i]; | 33652 | return azName[i]; |
| 33432 | } | 33653 | } |
| @@ -50435,6 +50656,7 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){ | |||
| 50435 | p->page.pExtra = &p[1]; | 50656 | p->page.pExtra = &p[1]; |
| 50436 | p->isBulkLocal = 0; | 50657 | p->isBulkLocal = 0; |
| 50437 | p->isAnchor = 0; | 50658 | p->isAnchor = 0; |
| 50659 | p->pLruPrev = 0; /* Initializing this saves a valgrind error */ | ||
| 50438 | } | 50660 | } |
| 50439 | (*pCache->pnPurgeable)++; | 50661 | (*pCache->pnPurgeable)++; |
| 50440 | return p; | 50662 | return p; |
| @@ -52353,6 +52575,7 @@ struct PagerSavepoint { | |||
| 52353 | Bitvec *pInSavepoint; /* Set of pages in this savepoint */ | 52575 | Bitvec *pInSavepoint; /* Set of pages in this savepoint */ |
| 52354 | Pgno nOrig; /* Original number of pages in file */ | 52576 | Pgno nOrig; /* Original number of pages in file */ |
| 52355 | Pgno iSubRec; /* Index of first record in sub-journal */ | 52577 | Pgno iSubRec; /* Index of first record in sub-journal */ |
| 52578 | int bTruncateOnRelease; /* If stmt journal may be truncated on RELEASE */ | ||
| 52356 | #ifndef SQLITE_OMIT_WAL | 52579 | #ifndef SQLITE_OMIT_WAL |
| 52357 | u32 aWalData[WAL_SAVEPOINT_NDATA]; /* WAL savepoint context */ | 52580 | u32 aWalData[WAL_SAVEPOINT_NDATA]; /* WAL savepoint context */ |
| 52358 | #endif | 52581 | #endif |
| @@ -52988,6 +53211,9 @@ static int subjRequiresPage(PgHdr *pPg){ | |||
| 52988 | for(i=0; i<pPager->nSavepoint; i++){ | 53211 | for(i=0; i<pPager->nSavepoint; i++){ |
| 52989 | p = &pPager->aSavepoint[i]; | 53212 | p = &pPager->aSavepoint[i]; |
| 52990 | if( p->nOrig>=pgno && 0==sqlite3BitvecTestNotNull(p->pInSavepoint, pgno) ){ | 53213 | if( p->nOrig>=pgno && 0==sqlite3BitvecTestNotNull(p->pInSavepoint, pgno) ){ |
| 53214 | for(i=i+1; i<pPager->nSavepoint; i++){ | ||
| 53215 | pPager->aSavepoint[i].bTruncateOnRelease = 0; | ||
| 53216 | } | ||
| 52991 | return 1; | 53217 | return 1; |
| 52992 | } | 53218 | } |
| 52993 | } | 53219 | } |
| @@ -58766,6 +58992,7 @@ static SQLITE_NOINLINE int pagerOpenSavepoint(Pager *pPager, int nSavepoint){ | |||
| 58766 | } | 58992 | } |
| 58767 | aNew[ii].iSubRec = pPager->nSubRec; | 58993 | aNew[ii].iSubRec = pPager->nSubRec; |
| 58768 | aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize); | 58994 | aNew[ii].pInSavepoint = sqlite3BitvecCreate(pPager->dbSize); |
| 58995 | aNew[ii].bTruncateOnRelease = 1; | ||
| 58769 | if( !aNew[ii].pInSavepoint ){ | 58996 | if( !aNew[ii].pInSavepoint ){ |
| 58770 | return SQLITE_NOMEM_BKPT; | 58997 | return SQLITE_NOMEM_BKPT; |
| 58771 | } | 58998 | } |
| @@ -58847,13 +59074,15 @@ SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){ | |||
| 58847 | /* If this is a release of the outermost savepoint, truncate | 59074 | /* If this is a release of the outermost savepoint, truncate |
| 58848 | ** the sub-journal to zero bytes in size. */ | 59075 | ** the sub-journal to zero bytes in size. */ |
| 58849 | if( op==SAVEPOINT_RELEASE ){ | 59076 | if( op==SAVEPOINT_RELEASE ){ |
| 58850 | if( nNew==0 && isOpen(pPager->sjfd) ){ | 59077 | PagerSavepoint *pRel = &pPager->aSavepoint[nNew]; |
| 59078 | if( pRel->bTruncateOnRelease && isOpen(pPager->sjfd) ){ | ||
| 58851 | /* Only truncate if it is an in-memory sub-journal. */ | 59079 | /* Only truncate if it is an in-memory sub-journal. */ |
| 58852 | if( sqlite3JournalIsInMemory(pPager->sjfd) ){ | 59080 | if( sqlite3JournalIsInMemory(pPager->sjfd) ){ |
| 58853 | rc = sqlite3OsTruncate(pPager->sjfd, 0); | 59081 | i64 sz = (pPager->pageSize+4)*pRel->iSubRec; |
| 59082 | rc = sqlite3OsTruncate(pPager->sjfd, sz); | ||
| 58854 | assert( rc==SQLITE_OK ); | 59083 | assert( rc==SQLITE_OK ); |
| 58855 | } | 59084 | } |
| 58856 | pPager->nSubRec = 0; | 59085 | pPager->nSubRec = pRel->iSubRec; |
| 58857 | } | 59086 | } |
| 58858 | } | 59087 | } |
| 58859 | /* Else this is a rollback operation, playback the specified savepoint. | 59088 | /* Else this is a rollback operation, playback the specified savepoint. |
| @@ -64149,6 +64378,7 @@ struct BtShared { | |||
| 64149 | Btree *pWriter; /* Btree with currently open write transaction */ | 64378 | Btree *pWriter; /* Btree with currently open write transaction */ |
| 64150 | #endif | 64379 | #endif |
| 64151 | u8 *pTmpSpace; /* Temp space sufficient to hold a single cell */ | 64380 | u8 *pTmpSpace; /* Temp space sufficient to hold a single cell */ |
| 64381 | int nPreformatSize; /* Size of last cell written by TransferRow() */ | ||
| 64152 | }; | 64382 | }; |
| 64153 | 64383 | ||
| 64154 | /* | 64384 | /* |
| @@ -65863,6 +66093,24 @@ static SQLITE_NOINLINE void btreeParseCellAdjustSizeForOverflow( | |||
| 65863 | } | 66093 | } |
| 65864 | 66094 | ||
| 65865 | /* | 66095 | /* |
| 66096 | ** Given a record with nPayload bytes of payload stored within btree | ||
| 66097 | ** page pPage, return the number of bytes of payload stored locally. | ||
| 66098 | */ | ||
| 66099 | static int btreePayloadToLocal(MemPage *pPage, i64 nPayload){ | ||
| 66100 | int maxLocal; /* Maximum amount of payload held locally */ | ||
| 66101 | maxLocal = pPage->maxLocal; | ||
| 66102 | if( nPayload<=maxLocal ){ | ||
| 66103 | return nPayload; | ||
| 66104 | }else{ | ||
| 66105 | int minLocal; /* Minimum amount of payload held locally */ | ||
| 66106 | int surplus; /* Overflow payload available for local storage */ | ||
| 66107 | minLocal = pPage->minLocal; | ||
| 66108 | surplus = minLocal + (nPayload - minLocal)%(pPage->pBt->usableSize-4); | ||
| 66109 | return ( surplus <= maxLocal ) ? surplus : minLocal; | ||
| 66110 | } | ||
| 66111 | } | ||
| 66112 | |||
| 66113 | /* | ||
| 65866 | ** The following routines are implementations of the MemPage.xParseCell() | 66114 | ** The following routines are implementations of the MemPage.xParseCell() |
| 65867 | ** method. | 66115 | ** method. |
| 65868 | ** | 66116 | ** |
| @@ -67602,6 +67850,7 @@ SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve, | |||
| 67602 | ((pageSize-1)&pageSize)==0 ){ | 67850 | ((pageSize-1)&pageSize)==0 ){ |
| 67603 | assert( (pageSize & 7)==0 ); | 67851 | assert( (pageSize & 7)==0 ); |
| 67604 | assert( !pBt->pCursor ); | 67852 | assert( !pBt->pCursor ); |
| 67853 | if( nReserve>32 && pageSize==512 ) pageSize = 1024; | ||
| 67605 | pBt->pageSize = (u32)pageSize; | 67854 | pBt->pageSize = (u32)pageSize; |
| 67606 | freeTempSpace(pBt); | 67855 | freeTempSpace(pBt); |
| 67607 | } | 67856 | } |
| @@ -72337,7 +72586,9 @@ static int balance_nonroot( | |||
| 72337 | } | 72586 | } |
| 72338 | pgno = get4byte(pRight); | 72587 | pgno = get4byte(pRight); |
| 72339 | while( 1 ){ | 72588 | while( 1 ){ |
| 72340 | rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0); | 72589 | if( rc==SQLITE_OK ){ |
| 72590 | rc = getAndInitPage(pBt, pgno, &apOld[i], 0, 0); | ||
| 72591 | } | ||
| 72341 | if( rc ){ | 72592 | if( rc ){ |
| 72342 | memset(apOld, 0, (i+1)*sizeof(MemPage*)); | 72593 | memset(apOld, 0, (i+1)*sizeof(MemPage*)); |
| 72343 | goto balance_cleanup; | 72594 | goto balance_cleanup; |
| @@ -72376,12 +72627,10 @@ static int balance_nonroot( | |||
| 72376 | if( pBt->btsFlags & BTS_FAST_SECURE ){ | 72627 | if( pBt->btsFlags & BTS_FAST_SECURE ){ |
| 72377 | int iOff; | 72628 | int iOff; |
| 72378 | 72629 | ||
| 72630 | /* If the following if() condition is not true, the db is corrupted. | ||
| 72631 | ** The call to dropCell() below will detect this. */ | ||
| 72379 | iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData); | 72632 | iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData); |
| 72380 | if( (iOff+szNew[i])>(int)pBt->usableSize ){ | 72633 | if( (iOff+szNew[i])<=(int)pBt->usableSize ){ |
| 72381 | rc = SQLITE_CORRUPT_BKPT; | ||
| 72382 | memset(apOld, 0, (i+1)*sizeof(MemPage*)); | ||
| 72383 | goto balance_cleanup; | ||
| 72384 | }else{ | ||
| 72385 | memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); | 72634 | memcpy(&aOvflSpace[iOff], apDiv[i], szNew[i]); |
| 72386 | apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData]; | 72635 | apDiv[i] = &aOvflSpace[apDiv[i]-pParent->aData]; |
| 72387 | } | 72636 | } |
| @@ -72675,6 +72924,9 @@ static int balance_nonroot( | |||
| 72675 | apOld[i] = 0; | 72924 | apOld[i] = 0; |
| 72676 | rc = sqlite3PagerWrite(pNew->pDbPage); | 72925 | rc = sqlite3PagerWrite(pNew->pDbPage); |
| 72677 | nNew++; | 72926 | nNew++; |
| 72927 | if( sqlite3PagerPageRefcount(pNew->pDbPage)!=1+(i==(iParentIdx-nxDiv)) ){ | ||
| 72928 | rc = SQLITE_CORRUPT_BKPT; | ||
| 72929 | } | ||
| 72678 | if( rc ) goto balance_cleanup; | 72930 | if( rc ) goto balance_cleanup; |
| 72679 | }else{ | 72931 | }else{ |
| 72680 | assert( i>0 ); | 72932 | assert( i>0 ); |
| @@ -72711,7 +72963,7 @@ static int balance_nonroot( | |||
| 72711 | aPgOrder[i] = aPgno[i] = apNew[i]->pgno; | 72963 | aPgOrder[i] = aPgno[i] = apNew[i]->pgno; |
| 72712 | aPgFlags[i] = apNew[i]->pDbPage->flags; | 72964 | aPgFlags[i] = apNew[i]->pDbPage->flags; |
| 72713 | for(j=0; j<i; j++){ | 72965 | for(j=0; j<i; j++){ |
| 72714 | if( aPgno[j]==aPgno[i] ){ | 72966 | if( NEVER(aPgno[j]==aPgno[i]) ){ |
| 72715 | /* This branch is taken if the set of sibling pages somehow contains | 72967 | /* This branch is taken if the set of sibling pages somehow contains |
| 72716 | ** duplicate entries. This can happen if the database is corrupt. | 72968 | ** duplicate entries. This can happen if the database is corrupt. |
| 72717 | ** It would be simpler to detect this as part of the loop below, but | 72969 | ** It would be simpler to detect this as part of the loop below, but |
| @@ -73379,7 +73631,8 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73379 | unsigned char *oldCell; | 73631 | unsigned char *oldCell; |
| 73380 | unsigned char *newCell = 0; | 73632 | unsigned char *newCell = 0; |
| 73381 | 73633 | ||
| 73382 | assert( (flags & (BTREE_SAVEPOSITION|BTREE_APPEND))==flags ); | 73634 | assert( (flags & (BTREE_SAVEPOSITION|BTREE_APPEND|BTREE_PREFORMAT))==flags ); |
| 73635 | assert( (flags & BTREE_PREFORMAT)==0 || seekResult || pCur->pKeyInfo==0 ); | ||
| 73383 | 73636 | ||
| 73384 | if( pCur->eState==CURSOR_FAULT ){ | 73637 | if( pCur->eState==CURSOR_FAULT ){ |
| 73385 | assert( pCur->skipNext!=SQLITE_OK ); | 73638 | assert( pCur->skipNext!=SQLITE_OK ); |
| @@ -73397,7 +73650,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73397 | ** keys with no associated data. If the cursor was opened expecting an | 73650 | ** keys with no associated data. If the cursor was opened expecting an |
| 73398 | ** intkey table, the caller should be inserting integer keys with a | 73651 | ** intkey table, the caller should be inserting integer keys with a |
| 73399 | ** blob of associated data. */ | 73652 | ** blob of associated data. */ |
| 73400 | assert( (pX->pKey==0)==(pCur->pKeyInfo==0) ); | 73653 | assert( (flags & BTREE_PREFORMAT) || (pX->pKey==0)==(pCur->pKeyInfo==0) ); |
| 73401 | 73654 | ||
| 73402 | /* Save the positions of any other cursors open on this table. | 73655 | /* Save the positions of any other cursors open on this table. |
| 73403 | ** | 73656 | ** |
| @@ -73507,7 +73760,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73507 | || CORRUPT_DB ); | 73760 | || CORRUPT_DB ); |
| 73508 | 73761 | ||
| 73509 | pPage = pCur->pPage; | 73762 | pPage = pCur->pPage; |
| 73510 | assert( pPage->intKey || pX->nKey>=0 ); | 73763 | assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) ); |
| 73511 | assert( pPage->leaf || !pPage->intKey ); | 73764 | assert( pPage->leaf || !pPage->intKey ); |
| 73512 | if( pPage->nFree<0 ){ | 73765 | if( pPage->nFree<0 ){ |
| 73513 | if( pCur->eState>CURSOR_INVALID ){ | 73766 | if( pCur->eState>CURSOR_INVALID ){ |
| @@ -73524,7 +73777,21 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 73524 | assert( pPage->isInit ); | 73777 | assert( pPage->isInit ); |
| 73525 | newCell = pBt->pTmpSpace; | 73778 | newCell = pBt->pTmpSpace; |
| 73526 | assert( newCell!=0 ); | 73779 | assert( newCell!=0 ); |
| 73527 | rc = fillInCell(pPage, newCell, pX, &szNew); | 73780 | if( flags & BTREE_PREFORMAT ){ |
| 73781 | rc = SQLITE_OK; | ||
| 73782 | szNew = pBt->nPreformatSize; | ||
| 73783 | if( szNew<4 ) szNew = 4; | ||
| 73784 | if( ISAUTOVACUUM && szNew>pPage->maxLocal ){ | ||
| 73785 | CellInfo info; | ||
| 73786 | pPage->xParseCell(pPage, newCell, &info); | ||
| 73787 | if( info.nPayload!=info.nLocal ){ | ||
| 73788 | Pgno ovfl = get4byte(&newCell[szNew-4]); | ||
| 73789 | ptrmapPut(pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, &rc); | ||
| 73790 | } | ||
| 73791 | } | ||
| 73792 | }else{ | ||
| 73793 | rc = fillInCell(pPage, newCell, pX, &szNew); | ||
| 73794 | } | ||
| 73528 | if( rc ) goto end_insert; | 73795 | if( rc ) goto end_insert; |
| 73529 | assert( szNew==pPage->xCellSize(pPage, newCell) ); | 73796 | assert( szNew==pPage->xCellSize(pPage, newCell) ); |
| 73530 | assert( szNew <= MX_CELL_SIZE(pBt) ); | 73797 | assert( szNew <= MX_CELL_SIZE(pBt) ); |
| @@ -73632,6 +73899,114 @@ end_insert: | |||
| 73632 | } | 73899 | } |
| 73633 | 73900 | ||
| 73634 | /* | 73901 | /* |
| 73902 | ** This function is used as part of copying the current row from cursor | ||
| 73903 | ** pSrc into cursor pDest. If the cursors are open on intkey tables, then | ||
| 73904 | ** parameter iKey is used as the rowid value when the record is copied | ||
| 73905 | ** into pDest. Otherwise, the record is copied verbatim. | ||
| 73906 | ** | ||
| 73907 | ** This function does not actually write the new value to cursor pDest. | ||
| 73908 | ** Instead, it creates and populates any required overflow pages and | ||
| 73909 | ** writes the data for the new cell into the BtShared.pTmpSpace buffer | ||
| 73910 | ** for the destination database. The size of the cell, in bytes, is left | ||
| 73911 | ** in BtShared.nPreformatSize. The caller completes the insertion by | ||
| 73912 | ** calling sqlite3BtreeInsert() with the BTREE_PREFORMAT flag specified. | ||
| 73913 | ** | ||
| 73914 | ** SQLITE_OK is returned if successful, or an SQLite error code otherwise. | ||
| 73915 | */ | ||
| 73916 | SQLITE_PRIVATE int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64 iKey){ | ||
| 73917 | int rc = SQLITE_OK; | ||
| 73918 | BtShared *pBt = pDest->pBt; | ||
| 73919 | u8 *aOut = pBt->pTmpSpace; /* Pointer to next output buffer */ | ||
| 73920 | const u8 *aIn; /* Pointer to next input buffer */ | ||
| 73921 | u32 nIn; /* Size of input buffer aIn[] */ | ||
| 73922 | u32 nRem; /* Bytes of data still to copy */ | ||
| 73923 | |||
| 73924 | getCellInfo(pSrc); | ||
| 73925 | aOut += putVarint32(aOut, pSrc->info.nPayload); | ||
| 73926 | if( pDest->pKeyInfo==0 ) aOut += putVarint(aOut, iKey); | ||
| 73927 | nIn = pSrc->info.nLocal; | ||
| 73928 | aIn = pSrc->info.pPayload; | ||
| 73929 | if( aIn+nIn>pSrc->pPage->aDataEnd ){ | ||
| 73930 | return SQLITE_CORRUPT_BKPT; | ||
| 73931 | } | ||
| 73932 | nRem = pSrc->info.nPayload; | ||
| 73933 | if( nIn==nRem && nIn<pDest->pPage->maxLocal ){ | ||
| 73934 | memcpy(aOut, aIn, nIn); | ||
| 73935 | pBt->nPreformatSize = nIn + (aOut - pBt->pTmpSpace); | ||
| 73936 | }else{ | ||
| 73937 | Pager *pSrcPager = pSrc->pBt->pPager; | ||
| 73938 | u8 *pPgnoOut = 0; | ||
| 73939 | Pgno ovflIn = 0; | ||
| 73940 | DbPage *pPageIn = 0; | ||
| 73941 | MemPage *pPageOut = 0; | ||
| 73942 | u32 nOut; /* Size of output buffer aOut[] */ | ||
| 73943 | |||
| 73944 | nOut = btreePayloadToLocal(pDest->pPage, pSrc->info.nPayload); | ||
| 73945 | pBt->nPreformatSize = nOut + (aOut - pBt->pTmpSpace); | ||
| 73946 | if( nOut<pSrc->info.nPayload ){ | ||
| 73947 | pPgnoOut = &aOut[nOut]; | ||
| 73948 | pBt->nPreformatSize += 4; | ||
| 73949 | } | ||
| 73950 | |||
| 73951 | if( nRem>nIn ){ | ||
| 73952 | if( aIn+nIn+4>pSrc->pPage->aDataEnd ){ | ||
| 73953 | return SQLITE_CORRUPT_BKPT; | ||
| 73954 | } | ||
| 73955 | ovflIn = get4byte(&pSrc->info.pPayload[nIn]); | ||
| 73956 | } | ||
| 73957 | |||
| 73958 | do { | ||
| 73959 | nRem -= nOut; | ||
| 73960 | do{ | ||
| 73961 | assert( nOut>0 ); | ||
| 73962 | if( nIn>0 ){ | ||
| 73963 | int nCopy = MIN(nOut, nIn); | ||
| 73964 | memcpy(aOut, aIn, nCopy); | ||
| 73965 | nOut -= nCopy; | ||
| 73966 | nIn -= nCopy; | ||
| 73967 | aOut += nCopy; | ||
| 73968 | aIn += nCopy; | ||
| 73969 | } | ||
| 73970 | if( nOut>0 ){ | ||
| 73971 | sqlite3PagerUnref(pPageIn); | ||
| 73972 | pPageIn = 0; | ||
| 73973 | rc = sqlite3PagerGet(pSrcPager, ovflIn, &pPageIn, PAGER_GET_READONLY); | ||
| 73974 | if( rc==SQLITE_OK ){ | ||
| 73975 | aIn = (const u8*)sqlite3PagerGetData(pPageIn); | ||
| 73976 | ovflIn = get4byte(aIn); | ||
| 73977 | aIn += 4; | ||
| 73978 | nIn = pSrc->pBt->usableSize - 4; | ||
| 73979 | } | ||
| 73980 | } | ||
| 73981 | }while( rc==SQLITE_OK && nOut>0 ); | ||
| 73982 | |||
| 73983 | if( rc==SQLITE_OK && nRem>0 ){ | ||
| 73984 | Pgno pgnoNew; | ||
| 73985 | MemPage *pNew = 0; | ||
| 73986 | rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0); | ||
| 73987 | put4byte(pPgnoOut, pgnoNew); | ||
| 73988 | if( ISAUTOVACUUM && pPageOut ){ | ||
| 73989 | ptrmapPut(pBt, pgnoNew, PTRMAP_OVERFLOW2, pPageOut->pgno, &rc); | ||
| 73990 | } | ||
| 73991 | releasePage(pPageOut); | ||
| 73992 | pPageOut = pNew; | ||
| 73993 | if( pPageOut ){ | ||
| 73994 | pPgnoOut = pPageOut->aData; | ||
| 73995 | put4byte(pPgnoOut, 0); | ||
| 73996 | aOut = &pPgnoOut[4]; | ||
| 73997 | nOut = MIN(pBt->usableSize - 4, nRem); | ||
| 73998 | } | ||
| 73999 | } | ||
| 74000 | }while( nRem>0 && rc==SQLITE_OK ); | ||
| 74001 | |||
| 74002 | releasePage(pPageOut); | ||
| 74003 | sqlite3PagerUnref(pPageIn); | ||
| 74004 | } | ||
| 74005 | |||
| 74006 | return rc; | ||
| 74007 | } | ||
| 74008 | |||
| 74009 | /* | ||
| 73635 | ** Delete the entry that the cursor is pointing to. | 74010 | ** Delete the entry that the cursor is pointing to. |
| 73636 | ** | 74011 | ** |
| 73637 | ** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then | 74012 | ** If the BTREE_SAVEPOSITION bit of the flags parameter is zero, then |
| @@ -78019,7 +78394,7 @@ SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){ | |||
| 78019 | p->pNext = db->pVdbe; | 78394 | p->pNext = db->pVdbe; |
| 78020 | p->pPrev = 0; | 78395 | p->pPrev = 0; |
| 78021 | db->pVdbe = p; | 78396 | db->pVdbe = p; |
| 78022 | p->magic = VDBE_MAGIC_INIT; | 78397 | p->iVdbeMagic = VDBE_MAGIC_INIT; |
| 78023 | p->pParse = pParse; | 78398 | p->pParse = pParse; |
| 78024 | pParse->pVdbe = p; | 78399 | pParse->pVdbe = p; |
| 78025 | assert( pParse->aLabel==0 ); | 78400 | assert( pParse->aLabel==0 ); |
| @@ -78220,7 +78595,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ | |||
| 78220 | VdbeOp *pOp; | 78595 | VdbeOp *pOp; |
| 78221 | 78596 | ||
| 78222 | i = p->nOp; | 78597 | i = p->nOp; |
| 78223 | assert( p->magic==VDBE_MAGIC_INIT ); | 78598 | assert( p->iVdbeMagic==VDBE_MAGIC_INIT ); |
| 78224 | assert( op>=0 && op<0xff ); | 78599 | assert( op>=0 && op<0xff ); |
| 78225 | if( p->nOpAlloc<=i ){ | 78600 | if( p->nOpAlloc<=i ){ |
| 78226 | return growOp3(p, op, p1, p2, p3); | 78601 | return growOp3(p, op, p1, p2, p3); |
| @@ -78455,9 +78830,10 @@ SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse *pParse){ | |||
| 78455 | ** The zWhere string must have been obtained from sqlite3_malloc(). | 78830 | ** The zWhere string must have been obtained from sqlite3_malloc(). |
| 78456 | ** This routine will take ownership of the allocated memory. | 78831 | ** This routine will take ownership of the allocated memory. |
| 78457 | */ | 78832 | */ |
| 78458 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere){ | 78833 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe *p, int iDb, char *zWhere, u16 p5){ |
| 78459 | int j; | 78834 | int j; |
| 78460 | sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC); | 78835 | sqlite3VdbeAddOp4(p, OP_ParseSchema, iDb, 0, 0, zWhere, P4_DYNAMIC); |
| 78836 | sqlite3VdbeChangeP5(p, p5); | ||
| 78461 | for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j); | 78837 | for(j=0; j<p->db->nDb; j++) sqlite3VdbeUsesBtree(p, j); |
| 78462 | sqlite3MayAbort(p->pParse); | 78838 | sqlite3MayAbort(p->pParse); |
| 78463 | } | 78839 | } |
| @@ -78549,7 +78925,7 @@ static SQLITE_NOINLINE void resizeResolveLabel(Parse *p, Vdbe *v, int j){ | |||
| 78549 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){ | 78925 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){ |
| 78550 | Parse *p = v->pParse; | 78926 | Parse *p = v->pParse; |
| 78551 | int j = ADDR(x); | 78927 | int j = ADDR(x); |
| 78552 | assert( v->magic==VDBE_MAGIC_INIT ); | 78928 | assert( v->iVdbeMagic==VDBE_MAGIC_INIT ); |
| 78553 | assert( j<-p->nLabel ); | 78929 | assert( j<-p->nLabel ); |
| 78554 | assert( j>=0 ); | 78930 | assert( j>=0 ); |
| 78555 | #ifdef SQLITE_DEBUG | 78931 | #ifdef SQLITE_DEBUG |
| @@ -78874,7 +79250,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ | |||
| 78874 | ** Return the address of the next instruction to be inserted. | 79250 | ** Return the address of the next instruction to be inserted. |
| 78875 | */ | 79251 | */ |
| 78876 | SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){ | 79252 | SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){ |
| 78877 | assert( p->magic==VDBE_MAGIC_INIT ); | 79253 | assert( p->iVdbeMagic==VDBE_MAGIC_INIT ); |
| 78878 | return p->nOp; | 79254 | return p->nOp; |
| 78879 | } | 79255 | } |
| 78880 | 79256 | ||
| @@ -78959,7 +79335,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList( | |||
| 78959 | int i; | 79335 | int i; |
| 78960 | VdbeOp *pOut, *pFirst; | 79336 | VdbeOp *pOut, *pFirst; |
| 78961 | assert( nOp>0 ); | 79337 | assert( nOp>0 ); |
| 78962 | assert( p->magic==VDBE_MAGIC_INIT ); | 79338 | assert( p->iVdbeMagic==VDBE_MAGIC_INIT ); |
| 78963 | if( p->nOp + nOp > p->nOpAlloc && growOpArray(p, nOp) ){ | 79339 | if( p->nOp + nOp > p->nOpAlloc && growOpArray(p, nOp) ){ |
| 78964 | return 0; | 79340 | return 0; |
| 78965 | } | 79341 | } |
| @@ -79283,7 +79659,7 @@ SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int | |||
| 79283 | sqlite3 *db; | 79659 | sqlite3 *db; |
| 79284 | assert( p!=0 ); | 79660 | assert( p!=0 ); |
| 79285 | db = p->db; | 79661 | db = p->db; |
| 79286 | assert( p->magic==VDBE_MAGIC_INIT ); | 79662 | assert( p->iVdbeMagic==VDBE_MAGIC_INIT ); |
| 79287 | assert( p->aOp!=0 || db->mallocFailed ); | 79663 | assert( p->aOp!=0 || db->mallocFailed ); |
| 79288 | if( db->mallocFailed ){ | 79664 | if( db->mallocFailed ){ |
| 79289 | if( n!=P4_VTAB ) freeP4(db, n, (void*)*(char**)&zP4); | 79665 | if( n!=P4_VTAB ) freeP4(db, n, (void*)*(char**)&zP4); |
| @@ -79412,7 +79788,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){ | |||
| 79412 | /* C89 specifies that the constant "dummy" will be initialized to all | 79788 | /* C89 specifies that the constant "dummy" will be initialized to all |
| 79413 | ** zeros, which is correct. MSVC generates a warning, nevertheless. */ | 79789 | ** zeros, which is correct. MSVC generates a warning, nevertheless. */ |
| 79414 | static VdbeOp dummy; /* Ignore the MSVC warning about no initializer */ | 79790 | static VdbeOp dummy; /* Ignore the MSVC warning about no initializer */ |
| 79415 | assert( p->magic==VDBE_MAGIC_INIT ); | 79791 | assert( p->iVdbeMagic==VDBE_MAGIC_INIT ); |
| 79416 | if( addr<0 ){ | 79792 | if( addr<0 ){ |
| 79417 | addr = p->nOp - 1; | 79793 | addr = p->nOp - 1; |
| 79418 | } | 79794 | } |
| @@ -80097,7 +80473,7 @@ SQLITE_PRIVATE int sqlite3VdbeList( | |||
| 80097 | Op *pOp; /* Current opcode */ | 80473 | Op *pOp; /* Current opcode */ |
| 80098 | 80474 | ||
| 80099 | assert( p->explain ); | 80475 | assert( p->explain ); |
| 80100 | assert( p->magic==VDBE_MAGIC_RUN ); | 80476 | assert( p->iVdbeMagic==VDBE_MAGIC_RUN ); |
| 80101 | assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM ); | 80477 | assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM ); |
| 80102 | 80478 | ||
| 80103 | /* Even though this opcode does not use dynamic strings for | 80479 | /* Even though this opcode does not use dynamic strings for |
| @@ -80277,14 +80653,14 @@ SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe *p){ | |||
| 80277 | int i; | 80653 | int i; |
| 80278 | #endif | 80654 | #endif |
| 80279 | assert( p!=0 ); | 80655 | assert( p!=0 ); |
| 80280 | assert( p->magic==VDBE_MAGIC_INIT || p->magic==VDBE_MAGIC_RESET ); | 80656 | assert( p->iVdbeMagic==VDBE_MAGIC_INIT || p->iVdbeMagic==VDBE_MAGIC_RESET ); |
| 80281 | 80657 | ||
| 80282 | /* There should be at least one opcode. | 80658 | /* There should be at least one opcode. |
| 80283 | */ | 80659 | */ |
| 80284 | assert( p->nOp>0 ); | 80660 | assert( p->nOp>0 ); |
| 80285 | 80661 | ||
| 80286 | /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */ | 80662 | /* Set the magic to VDBE_MAGIC_RUN sooner rather than later. */ |
| 80287 | p->magic = VDBE_MAGIC_RUN; | 80663 | p->iVdbeMagic = VDBE_MAGIC_RUN; |
| 80288 | 80664 | ||
| 80289 | #ifdef SQLITE_DEBUG | 80665 | #ifdef SQLITE_DEBUG |
| 80290 | for(i=0; i<p->nMem; i++){ | 80666 | for(i=0; i<p->nMem; i++){ |
| @@ -80340,8 +80716,10 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady( | |||
| 80340 | assert( p!=0 ); | 80716 | assert( p!=0 ); |
| 80341 | assert( p->nOp>0 ); | 80717 | assert( p->nOp>0 ); |
| 80342 | assert( pParse!=0 ); | 80718 | assert( pParse!=0 ); |
| 80343 | assert( p->magic==VDBE_MAGIC_INIT ); | 80719 | assert( p->iVdbeMagic==VDBE_MAGIC_INIT ); |
| 80344 | assert( pParse==p->pParse ); | 80720 | assert( pParse==p->pParse ); |
| 80721 | p->pVList = pParse->pVList; | ||
| 80722 | pParse->pVList = 0; | ||
| 80345 | db = p->db; | 80723 | db = p->db; |
| 80346 | assert( db->mallocFailed==0 ); | 80724 | assert( db->mallocFailed==0 ); |
| 80347 | nVar = pParse->nVar; | 80725 | nVar = pParse->nVar; |
| @@ -80426,8 +80804,6 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady( | |||
| 80426 | } | 80804 | } |
| 80427 | } | 80805 | } |
| 80428 | 80806 | ||
| 80429 | p->pVList = pParse->pVList; | ||
| 80430 | pParse->pVList = 0; | ||
| 80431 | if( db->mallocFailed ){ | 80807 | if( db->mallocFailed ){ |
| 80432 | p->nVar = 0; | 80808 | p->nVar = 0; |
| 80433 | p->nCursor = 0; | 80809 | p->nCursor = 0; |
| @@ -81025,7 +81401,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){ | |||
| 81025 | ** one, or the complete transaction if there is no statement transaction. | 81401 | ** one, or the complete transaction if there is no statement transaction. |
| 81026 | */ | 81402 | */ |
| 81027 | 81403 | ||
| 81028 | if( p->magic!=VDBE_MAGIC_RUN ){ | 81404 | if( p->iVdbeMagic!=VDBE_MAGIC_RUN ){ |
| 81029 | return SQLITE_OK; | 81405 | return SQLITE_OK; |
| 81030 | } | 81406 | } |
| 81031 | if( db->mallocFailed ){ | 81407 | if( db->mallocFailed ){ |
| @@ -81183,7 +81559,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){ | |||
| 81183 | assert( db->nVdbeRead>=db->nVdbeWrite ); | 81559 | assert( db->nVdbeRead>=db->nVdbeWrite ); |
| 81184 | assert( db->nVdbeWrite>=0 ); | 81560 | assert( db->nVdbeWrite>=0 ); |
| 81185 | } | 81561 | } |
| 81186 | p->magic = VDBE_MAGIC_HALT; | 81562 | p->iVdbeMagic = VDBE_MAGIC_HALT; |
| 81187 | checkActiveVdbeCnt(db); | 81563 | checkActiveVdbeCnt(db); |
| 81188 | if( db->mallocFailed ){ | 81564 | if( db->mallocFailed ){ |
| 81189 | p->rc = SQLITE_NOMEM_BKPT; | 81565 | p->rc = SQLITE_NOMEM_BKPT; |
| @@ -81356,7 +81732,7 @@ SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){ | |||
| 81356 | } | 81732 | } |
| 81357 | } | 81733 | } |
| 81358 | #endif | 81734 | #endif |
| 81359 | p->magic = VDBE_MAGIC_RESET; | 81735 | p->iVdbeMagic = VDBE_MAGIC_RESET; |
| 81360 | return p->rc & db->errMask; | 81736 | return p->rc & db->errMask; |
| 81361 | } | 81737 | } |
| 81362 | 81738 | ||
| @@ -81366,7 +81742,7 @@ SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe *p){ | |||
| 81366 | */ | 81742 | */ |
| 81367 | SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe *p){ | 81743 | SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe *p){ |
| 81368 | int rc = SQLITE_OK; | 81744 | int rc = SQLITE_OK; |
| 81369 | if( p->magic==VDBE_MAGIC_RUN || p->magic==VDBE_MAGIC_HALT ){ | 81745 | if( p->iVdbeMagic==VDBE_MAGIC_RUN || p->iVdbeMagic==VDBE_MAGIC_HALT ){ |
| 81370 | rc = sqlite3VdbeReset(p); | 81746 | rc = sqlite3VdbeReset(p); |
| 81371 | assert( (rc & p->db->errMask)==rc ); | 81747 | assert( (rc & p->db->errMask)==rc ); |
| 81372 | } | 81748 | } |
| @@ -81427,7 +81803,7 @@ SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){ | |||
| 81427 | vdbeFreeOpArray(db, pSub->aOp, pSub->nOp); | 81803 | vdbeFreeOpArray(db, pSub->aOp, pSub->nOp); |
| 81428 | sqlite3DbFree(db, pSub); | 81804 | sqlite3DbFree(db, pSub); |
| 81429 | } | 81805 | } |
| 81430 | if( p->magic!=VDBE_MAGIC_INIT ){ | 81806 | if( p->iVdbeMagic!=VDBE_MAGIC_INIT ){ |
| 81431 | releaseMemArray(p->aVar, p->nVar); | 81807 | releaseMemArray(p->aVar, p->nVar); |
| 81432 | sqlite3DbFree(db, p->pVList); | 81808 | sqlite3DbFree(db, p->pVList); |
| 81433 | sqlite3DbFree(db, p->pFree); | 81809 | sqlite3DbFree(db, p->pFree); |
| @@ -81475,7 +81851,7 @@ SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe *p){ | |||
| 81475 | if( p->pNext ){ | 81851 | if( p->pNext ){ |
| 81476 | p->pNext->pPrev = p->pPrev; | 81852 | p->pNext->pPrev = p->pPrev; |
| 81477 | } | 81853 | } |
| 81478 | p->magic = VDBE_MAGIC_DEAD; | 81854 | p->iVdbeMagic = VDBE_MAGIC_DEAD; |
| 81479 | p->db = 0; | 81855 | p->db = 0; |
| 81480 | sqlite3DbFreeNN(db, p); | 81856 | sqlite3DbFreeNN(db, p); |
| 81481 | } | 81857 | } |
| @@ -83854,7 +84230,7 @@ static int sqlite3Step(Vdbe *p){ | |||
| 83854 | int rc; | 84230 | int rc; |
| 83855 | 84231 | ||
| 83856 | assert(p); | 84232 | assert(p); |
| 83857 | if( p->magic!=VDBE_MAGIC_RUN ){ | 84233 | if( p->iVdbeMagic!=VDBE_MAGIC_RUN ){ |
| 83858 | /* We used to require that sqlite3_reset() be called before retrying | 84234 | /* We used to require that sqlite3_reset() be called before retrying |
| 83859 | ** sqlite3_step() after any error or after SQLITE_DONE. But beginning | 84235 | ** sqlite3_step() after any error or after SQLITE_DONE. But beginning |
| 83860 | ** with version 3.7.0, we changed this so that sqlite3_reset() would | 84236 | ** with version 3.7.0, we changed this so that sqlite3_reset() would |
| @@ -84570,7 +84946,7 @@ static int vdbeUnbind(Vdbe *p, int i){ | |||
| 84570 | return SQLITE_MISUSE_BKPT; | 84946 | return SQLITE_MISUSE_BKPT; |
| 84571 | } | 84947 | } |
| 84572 | sqlite3_mutex_enter(p->db->mutex); | 84948 | sqlite3_mutex_enter(p->db->mutex); |
| 84573 | if( p->magic!=VDBE_MAGIC_RUN || p->pc>=0 ){ | 84949 | if( p->iVdbeMagic!=VDBE_MAGIC_RUN || p->pc>=0 ){ |
| 84574 | sqlite3Error(p->db, SQLITE_MISUSE); | 84950 | sqlite3Error(p->db, SQLITE_MISUSE); |
| 84575 | sqlite3_mutex_leave(p->db->mutex); | 84951 | sqlite3_mutex_leave(p->db->mutex); |
| 84576 | sqlite3_log(SQLITE_MISUSE, | 84952 | sqlite3_log(SQLITE_MISUSE, |
| @@ -84924,7 +85300,7 @@ SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt){ | |||
| 84924 | */ | 85300 | */ |
| 84925 | SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){ | 85301 | SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){ |
| 84926 | Vdbe *v = (Vdbe*)pStmt; | 85302 | Vdbe *v = (Vdbe*)pStmt; |
| 84927 | return v!=0 && v->magic==VDBE_MAGIC_RUN && v->pc>=0; | 85303 | return v!=0 && v->iVdbeMagic==VDBE_MAGIC_RUN && v->pc>=0; |
| 84928 | } | 85304 | } |
| 84929 | 85305 | ||
| 84930 | /* | 85306 | /* |
| @@ -85416,7 +85792,7 @@ SQLITE_PRIVATE char *sqlite3VdbeExpandSql( | |||
| 85416 | assert( idx>0 ); | 85792 | assert( idx>0 ); |
| 85417 | } | 85793 | } |
| 85418 | zRawSql += nToken; | 85794 | zRawSql += nToken; |
| 85419 | nextIndex = idx + 1; | 85795 | nextIndex = MAX(idx + 1, nextIndex); |
| 85420 | assert( idx>0 && idx<=p->nVar ); | 85796 | assert( idx>0 && idx<=p->nVar ); |
| 85421 | pVar = &p->aVar[idx-1]; | 85797 | pVar = &p->aVar[idx-1]; |
| 85422 | if( pVar->flags & MEM_Null ){ | 85798 | if( pVar->flags & MEM_Null ){ |
| @@ -86262,7 +86638,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec( | |||
| 86262 | #endif | 86638 | #endif |
| 86263 | /*** INSERT STACK UNION HERE ***/ | 86639 | /*** INSERT STACK UNION HERE ***/ |
| 86264 | 86640 | ||
| 86265 | assert( p->magic==VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */ | 86641 | assert( p->iVdbeMagic==VDBE_MAGIC_RUN ); /* sqlite3_step() verifies this */ |
| 86266 | sqlite3VdbeEnter(p); | 86642 | sqlite3VdbeEnter(p); |
| 86267 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK | 86643 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 86268 | if( db->xProgress ){ | 86644 | if( db->xProgress ){ |
| @@ -87022,6 +87398,26 @@ case OP_IntCopy: { /* out2 */ | |||
| 87022 | break; | 87398 | break; |
| 87023 | } | 87399 | } |
| 87024 | 87400 | ||
| 87401 | /* Opcode: ChngCntRow P1 P2 * * * | ||
| 87402 | ** Synopsis: output=r[P1] | ||
| 87403 | ** | ||
| 87404 | ** Output value in register P1 as the chance count for a DML statement, | ||
| 87405 | ** due to the "PRAGMA count_changes=ON" setting. Or, if there was a | ||
| 87406 | ** foreign key error in the statement, trigger the error now. | ||
| 87407 | ** | ||
| 87408 | ** This opcode is a variant of OP_ResultRow that checks the foreign key | ||
| 87409 | ** immediate constraint count and throws an error if the count is | ||
| 87410 | ** non-zero. The P2 opcode must be 1. | ||
| 87411 | */ | ||
| 87412 | case OP_ChngCntRow: { | ||
| 87413 | assert( pOp->p2==1 ); | ||
| 87414 | if( (rc = sqlite3VdbeCheckFk(p,0))!=SQLITE_OK ){ | ||
| 87415 | goto abort_due_to_error; | ||
| 87416 | } | ||
| 87417 | /* Fall through to the next case, OP_ResultRow */ | ||
| 87418 | /* no break */ deliberate_fall_through | ||
| 87419 | } | ||
| 87420 | |||
| 87025 | /* Opcode: ResultRow P1 P2 * * * | 87421 | /* Opcode: ResultRow P1 P2 * * * |
| 87026 | ** Synopsis: output=r[P1@P2] | 87422 | ** Synopsis: output=r[P1@P2] |
| 87027 | ** | 87423 | ** |
| @@ -87038,34 +87434,6 @@ case OP_ResultRow: { | |||
| 87038 | assert( pOp->p1>0 ); | 87434 | assert( pOp->p1>0 ); |
| 87039 | assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 ); | 87435 | assert( pOp->p1+pOp->p2<=(p->nMem+1 - p->nCursor)+1 ); |
| 87040 | 87436 | ||
| 87041 | /* If this statement has violated immediate foreign key constraints, do | ||
| 87042 | ** not return the number of rows modified. And do not RELEASE the statement | ||
| 87043 | ** transaction. It needs to be rolled back. */ | ||
| 87044 | if( SQLITE_OK!=(rc = sqlite3VdbeCheckFk(p, 0)) ){ | ||
| 87045 | assert( db->flags&SQLITE_CountRows ); | ||
| 87046 | assert( p->usesStmtJournal ); | ||
| 87047 | goto abort_due_to_error; | ||
| 87048 | } | ||
| 87049 | |||
| 87050 | /* If the SQLITE_CountRows flag is set in sqlite3.flags mask, then | ||
| 87051 | ** DML statements invoke this opcode to return the number of rows | ||
| 87052 | ** modified to the user. This is the only way that a VM that | ||
| 87053 | ** opens a statement transaction may invoke this opcode. | ||
| 87054 | ** | ||
| 87055 | ** In case this is such a statement, close any statement transaction | ||
| 87056 | ** opened by this VM before returning control to the user. This is to | ||
| 87057 | ** ensure that statement-transactions are always nested, not overlapping. | ||
| 87058 | ** If the open statement-transaction is not closed here, then the user | ||
| 87059 | ** may step another VM that opens its own statement transaction. This | ||
| 87060 | ** may lead to overlapping statement transactions. | ||
| 87061 | ** | ||
| 87062 | ** The statement transaction is never a top-level transaction. Hence | ||
| 87063 | ** the RELEASE call below can never fail. | ||
| 87064 | */ | ||
| 87065 | assert( p->iStatement==0 || db->flags&SQLITE_CountRows ); | ||
| 87066 | rc = sqlite3VdbeCloseStatement(p, SAVEPOINT_RELEASE); | ||
| 87067 | assert( rc==SQLITE_OK ); | ||
| 87068 | |||
| 87069 | /* Invalidate all ephemeral cursor row caches */ | 87437 | /* Invalidate all ephemeral cursor row caches */ |
| 87070 | p->cacheCtr = (p->cacheCtr + 2)|1; | 87438 | p->cacheCtr = (p->cacheCtr + 2)|1; |
| 87071 | 87439 | ||
| @@ -89534,7 +89902,7 @@ case OP_OpenEphemeral: { | |||
| 89534 | aMem[pOp->p3].z = ""; | 89902 | aMem[pOp->p3].z = ""; |
| 89535 | } | 89903 | } |
| 89536 | pCx = p->apCsr[pOp->p1]; | 89904 | pCx = p->apCsr[pOp->p1]; |
| 89537 | if( pCx && pCx->pBtx ){ | 89905 | if( pCx && ALWAYS(pCx->pBtx) ){ |
| 89538 | /* If the ephermeral table is already open, erase all existing content | 89906 | /* If the ephermeral table is already open, erase all existing content |
| 89539 | ** so that the table is empty again, rather than creating a new table. */ | 89907 | ** so that the table is empty again, rather than creating a new table. */ |
| 89540 | assert( pCx->isEphemeral ); | 89908 | assert( pCx->isEphemeral ); |
| @@ -90486,8 +90854,10 @@ case OP_NewRowid: { /* out2 */ | |||
| 90486 | VdbeCursor *pC; /* Cursor of table to get the new rowid */ | 90854 | VdbeCursor *pC; /* Cursor of table to get the new rowid */ |
| 90487 | int res; /* Result of an sqlite3BtreeLast() */ | 90855 | int res; /* Result of an sqlite3BtreeLast() */ |
| 90488 | int cnt; /* Counter to limit the number of searches */ | 90856 | int cnt; /* Counter to limit the number of searches */ |
| 90857 | #ifndef SQLITE_OMIT_AUTOINCREMENT | ||
| 90489 | Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */ | 90858 | Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */ |
| 90490 | VdbeFrame *pFrame; /* Root frame of VDBE */ | 90859 | VdbeFrame *pFrame; /* Root frame of VDBE */ |
| 90860 | #endif | ||
| 90491 | 90861 | ||
| 90492 | v = 0; | 90862 | v = 0; |
| 90493 | res = 0; | 90863 | res = 0; |
| @@ -90703,7 +91073,8 @@ case OP_Insert: { | |||
| 90703 | } | 91073 | } |
| 90704 | x.pKey = 0; | 91074 | x.pKey = 0; |
| 90705 | rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, | 91075 | rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, |
| 90706 | (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), seekResult | 91076 | (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION|OPFLAG_PREFORMAT)), |
| 91077 | seekResult | ||
| 90707 | ); | 91078 | ); |
| 90708 | pC->deferredMoveto = 0; | 91079 | pC->deferredMoveto = 0; |
| 90709 | pC->cacheStatus = CACHE_STALE; | 91080 | pC->cacheStatus = CACHE_STALE; |
| @@ -90720,6 +91091,33 @@ case OP_Insert: { | |||
| 90720 | break; | 91091 | break; |
| 90721 | } | 91092 | } |
| 90722 | 91093 | ||
| 91094 | /* Opcode: RowCell P1 P2 P3 * * | ||
| 91095 | ** | ||
| 91096 | ** P1 and P2 are both open cursors. Both must be opened on the same type | ||
| 91097 | ** of table - intkey or index. This opcode is used as part of copying | ||
| 91098 | ** the current row from P2 into P1. If the cursors are opened on intkey | ||
| 91099 | ** tables, register P3 contains the rowid to use with the new record in | ||
| 91100 | ** P1. If they are opened on index tables, P3 is not used. | ||
| 91101 | ** | ||
| 91102 | ** This opcode must be followed by either an Insert or InsertIdx opcode | ||
| 91103 | ** with the OPFLAG_PREFORMAT flag set to complete the insert operation. | ||
| 91104 | */ | ||
| 91105 | case OP_RowCell: { | ||
| 91106 | VdbeCursor *pDest; /* Cursor to write to */ | ||
| 91107 | VdbeCursor *pSrc; /* Cursor to read from */ | ||
| 91108 | i64 iKey; /* Rowid value to insert with */ | ||
| 91109 | assert( pOp[1].opcode==OP_Insert || pOp[1].opcode==OP_IdxInsert ); | ||
| 91110 | assert( pOp[1].opcode==OP_Insert || pOp->p3==0 ); | ||
| 91111 | assert( pOp[1].opcode==OP_IdxInsert || pOp->p3>0 ); | ||
| 91112 | assert( pOp[1].p5 & OPFLAG_PREFORMAT ); | ||
| 91113 | pDest = p->apCsr[pOp->p1]; | ||
| 91114 | pSrc = p->apCsr[pOp->p2]; | ||
| 91115 | iKey = pOp->p3 ? aMem[pOp->p3].u.i : 0; | ||
| 91116 | rc = sqlite3BtreeTransferRow(pDest->uc.pCursor, pSrc->uc.pCursor, iKey); | ||
| 91117 | if( rc!=SQLITE_OK ) goto abort_due_to_error; | ||
| 91118 | break; | ||
| 91119 | }; | ||
| 91120 | |||
| 90723 | /* Opcode: Delete P1 P2 P3 P4 P5 | 91121 | /* Opcode: Delete P1 P2 P3 P4 P5 |
| 90724 | ** | 91122 | ** |
| 90725 | ** Delete the record at which the P1 cursor is currently pointing. | 91123 | ** Delete the record at which the P1 cursor is currently pointing. |
| @@ -91375,7 +91773,7 @@ case OP_IdxInsert: { /* in2 */ | |||
| 91375 | assert( pC!=0 ); | 91773 | assert( pC!=0 ); |
| 91376 | assert( !isSorter(pC) ); | 91774 | assert( !isSorter(pC) ); |
| 91377 | pIn2 = &aMem[pOp->p2]; | 91775 | pIn2 = &aMem[pOp->p2]; |
| 91378 | assert( pIn2->flags & MEM_Blob ); | 91776 | assert( (pIn2->flags & MEM_Blob) || (pOp->p5 & OPFLAG_PREFORMAT) ); |
| 91379 | if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; | 91777 | if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; |
| 91380 | assert( pC->eCurType==CURTYPE_BTREE ); | 91778 | assert( pC->eCurType==CURTYPE_BTREE ); |
| 91381 | assert( pC->isTable==0 ); | 91779 | assert( pC->isTable==0 ); |
| @@ -91386,7 +91784,7 @@ case OP_IdxInsert: { /* in2 */ | |||
| 91386 | x.aMem = aMem + pOp->p3; | 91784 | x.aMem = aMem + pOp->p3; |
| 91387 | x.nMem = (u16)pOp->p4.i; | 91785 | x.nMem = (u16)pOp->p4.i; |
| 91388 | rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, | 91786 | rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, |
| 91389 | (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION)), | 91787 | (pOp->p5 & (OPFLAG_APPEND|OPFLAG_SAVEPOSITION|OPFLAG_PREFORMAT)), |
| 91390 | ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) | 91788 | ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) |
| 91391 | ); | 91789 | ); |
| 91392 | assert( pC->deferredMoveto==0 ); | 91790 | assert( pC->deferredMoveto==0 ); |
| @@ -91459,7 +91857,7 @@ case OP_IdxDelete: { | |||
| 91459 | rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE); | 91857 | rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE); |
| 91460 | if( rc ) goto abort_due_to_error; | 91858 | if( rc ) goto abort_due_to_error; |
| 91461 | }else if( pOp->p5 ){ | 91859 | }else if( pOp->p5 ){ |
| 91462 | rc = SQLITE_CORRUPT_INDEX; | 91860 | rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption"); |
| 91463 | goto abort_due_to_error; | 91861 | goto abort_due_to_error; |
| 91464 | } | 91862 | } |
| 91465 | assert( pC->deferredMoveto==0 ); | 91863 | assert( pC->deferredMoveto==0 ); |
| @@ -91885,7 +92283,7 @@ case OP_ParseSchema: { | |||
| 91885 | if( pOp->p4.z==0 ){ | 92283 | if( pOp->p4.z==0 ){ |
| 91886 | sqlite3SchemaClear(db->aDb[iDb].pSchema); | 92284 | sqlite3SchemaClear(db->aDb[iDb].pSchema); |
| 91887 | db->mDbFlags &= ~DBFLAG_SchemaKnownOk; | 92285 | db->mDbFlags &= ~DBFLAG_SchemaKnownOk; |
| 91888 | rc = sqlite3InitOne(db, iDb, &p->zErrMsg, INITFLAG_AlterTable); | 92286 | rc = sqlite3InitOne(db, iDb, &p->zErrMsg, pOp->p5); |
| 91889 | db->mDbFlags |= DBFLAG_SchemaChange; | 92287 | db->mDbFlags |= DBFLAG_SchemaChange; |
| 91890 | p->expired = 0; | 92288 | p->expired = 0; |
| 91891 | }else | 92289 | }else |
| @@ -97593,7 +97991,6 @@ struct MemJournal { | |||
| 97593 | int nChunkSize; /* In-memory chunk-size */ | 97991 | int nChunkSize; /* In-memory chunk-size */ |
| 97594 | 97992 | ||
| 97595 | int nSpill; /* Bytes of data before flushing */ | 97993 | int nSpill; /* Bytes of data before flushing */ |
| 97596 | int nSize; /* Bytes of data currently in memory */ | ||
| 97597 | FileChunk *pFirst; /* Head of in-memory chunk-list */ | 97994 | FileChunk *pFirst; /* Head of in-memory chunk-list */ |
| 97598 | FilePoint endpoint; /* Pointer to the end of the file */ | 97995 | FilePoint endpoint; /* Pointer to the end of the file */ |
| 97599 | FilePoint readpoint; /* Pointer to the end of the last xRead() */ | 97996 | FilePoint readpoint; /* Pointer to the end of the last xRead() */ |
| @@ -97654,14 +98051,13 @@ static int memjrnlRead( | |||
| 97654 | /* | 98051 | /* |
| 97655 | ** Free the list of FileChunk structures headed at MemJournal.pFirst. | 98052 | ** Free the list of FileChunk structures headed at MemJournal.pFirst. |
| 97656 | */ | 98053 | */ |
| 97657 | static void memjrnlFreeChunks(MemJournal *p){ | 98054 | static void memjrnlFreeChunks(FileChunk *pFirst){ |
| 97658 | FileChunk *pIter; | 98055 | FileChunk *pIter; |
| 97659 | FileChunk *pNext; | 98056 | FileChunk *pNext; |
| 97660 | for(pIter=p->pFirst; pIter; pIter=pNext){ | 98057 | for(pIter=pFirst; pIter; pIter=pNext){ |
| 97661 | pNext = pIter->pNext; | 98058 | pNext = pIter->pNext; |
| 97662 | sqlite3_free(pIter); | 98059 | sqlite3_free(pIter); |
| 97663 | } | 98060 | } |
| 97664 | p->pFirst = 0; | ||
| 97665 | } | 98061 | } |
| 97666 | 98062 | ||
| 97667 | /* | 98063 | /* |
| @@ -97688,7 +98084,7 @@ static int memjrnlCreateFile(MemJournal *p){ | |||
| 97688 | } | 98084 | } |
| 97689 | if( rc==SQLITE_OK ){ | 98085 | if( rc==SQLITE_OK ){ |
| 97690 | /* No error has occurred. Free the in-memory buffers. */ | 98086 | /* No error has occurred. Free the in-memory buffers. */ |
| 97691 | memjrnlFreeChunks(©); | 98087 | memjrnlFreeChunks(copy.pFirst); |
| 97692 | } | 98088 | } |
| 97693 | } | 98089 | } |
| 97694 | if( rc!=SQLITE_OK ){ | 98090 | if( rc!=SQLITE_OK ){ |
| @@ -97771,7 +98167,6 @@ static int memjrnlWrite( | |||
| 97771 | nWrite -= iSpace; | 98167 | nWrite -= iSpace; |
| 97772 | p->endpoint.iOffset += iSpace; | 98168 | p->endpoint.iOffset += iSpace; |
| 97773 | } | 98169 | } |
| 97774 | p->nSize = iAmt + iOfst; | ||
| 97775 | } | 98170 | } |
| 97776 | } | 98171 | } |
| 97777 | 98172 | ||
| @@ -97779,22 +98174,30 @@ static int memjrnlWrite( | |||
| 97779 | } | 98174 | } |
| 97780 | 98175 | ||
| 97781 | /* | 98176 | /* |
| 97782 | ** Truncate the file. | 98177 | ** Truncate the in-memory file. |
| 97783 | ** | ||
| 97784 | ** If the journal file is already on disk, truncate it there. Or, if it | ||
| 97785 | ** is still in main memory but is being truncated to zero bytes in size, | ||
| 97786 | ** ignore | ||
| 97787 | */ | 98178 | */ |
| 97788 | static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ | 98179 | static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ |
| 97789 | MemJournal *p = (MemJournal *)pJfd; | 98180 | MemJournal *p = (MemJournal *)pJfd; |
| 97790 | if( ALWAYS(size==0) ){ | 98181 | FileChunk *pIter = 0; |
| 97791 | memjrnlFreeChunks(p); | 98182 | |
| 97792 | p->nSize = 0; | 98183 | if( size==0 ){ |
| 97793 | p->endpoint.pChunk = 0; | 98184 | memjrnlFreeChunks(p->pFirst); |
| 97794 | p->endpoint.iOffset = 0; | 98185 | p->pFirst = 0; |
| 97795 | p->readpoint.pChunk = 0; | 98186 | }else{ |
| 97796 | p->readpoint.iOffset = 0; | 98187 | i64 iOff = p->nChunkSize; |
| 98188 | for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){ | ||
| 98189 | iOff += p->nChunkSize; | ||
| 98190 | } | ||
| 98191 | if( ALWAYS(pIter) ){ | ||
| 98192 | memjrnlFreeChunks(pIter->pNext); | ||
| 98193 | pIter->pNext = 0; | ||
| 98194 | } | ||
| 97797 | } | 98195 | } |
| 98196 | |||
| 98197 | p->endpoint.pChunk = pIter; | ||
| 98198 | p->endpoint.iOffset = size; | ||
| 98199 | p->readpoint.pChunk = 0; | ||
| 98200 | p->readpoint.iOffset = 0; | ||
| 97798 | return SQLITE_OK; | 98201 | return SQLITE_OK; |
| 97799 | } | 98202 | } |
| 97800 | 98203 | ||
| @@ -97803,7 +98206,7 @@ static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ | |||
| 97803 | */ | 98206 | */ |
| 97804 | static int memjrnlClose(sqlite3_file *pJfd){ | 98207 | static int memjrnlClose(sqlite3_file *pJfd){ |
| 97805 | MemJournal *p = (MemJournal *)pJfd; | 98208 | MemJournal *p = (MemJournal *)pJfd; |
| 97806 | memjrnlFreeChunks(p); | 98209 | memjrnlFreeChunks(p->pFirst); |
| 97807 | return SQLITE_OK; | 98210 | return SQLITE_OK; |
| 97808 | } | 98211 | } |
| 97809 | 98212 | ||
| @@ -97977,7 +98380,7 @@ SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *pVfs){ | |||
| 97977 | ** Walk all expressions linked into the list of Window objects passed | 98380 | ** Walk all expressions linked into the list of Window objects passed |
| 97978 | ** as the second argument. | 98381 | ** as the second argument. |
| 97979 | */ | 98382 | */ |
| 97980 | static int walkWindowList(Walker *pWalker, Window *pList){ | 98383 | static int walkWindowList(Walker *pWalker, Window *pList, int bOneOnly){ |
| 97981 | Window *pWin; | 98384 | Window *pWin; |
| 97982 | for(pWin=pList; pWin; pWin=pWin->pNextWin){ | 98385 | for(pWin=pList; pWin; pWin=pWin->pNextWin){ |
| 97983 | int rc; | 98386 | int rc; |
| @@ -97996,6 +98399,7 @@ static int walkWindowList(Walker *pWalker, Window *pList){ | |||
| 97996 | if( NEVER(rc) ) return WRC_Abort; | 98399 | if( NEVER(rc) ) return WRC_Abort; |
| 97997 | rc = sqlite3WalkExpr(pWalker, pWin->pEnd); | 98400 | rc = sqlite3WalkExpr(pWalker, pWin->pEnd); |
| 97998 | if( NEVER(rc) ) return WRC_Abort; | 98401 | if( NEVER(rc) ) return WRC_Abort; |
| 98402 | if( bOneOnly ) break; | ||
| 97999 | } | 98403 | } |
| 98000 | return WRC_Continue; | 98404 | return WRC_Continue; |
| 98001 | } | 98405 | } |
| @@ -98043,7 +98447,7 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ | |||
| 98043 | } | 98447 | } |
| 98044 | #ifndef SQLITE_OMIT_WINDOWFUNC | 98448 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 98045 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ | 98449 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 98046 | if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort; | 98450 | if( walkWindowList(pWalker, pExpr->y.pWin, 1) ) return WRC_Abort; |
| 98047 | } | 98451 | } |
| 98048 | #endif | 98452 | #endif |
| 98049 | } | 98453 | } |
| @@ -98090,7 +98494,7 @@ SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){ | |||
| 98090 | if( pParse && IN_RENAME_OBJECT ){ | 98494 | if( pParse && IN_RENAME_OBJECT ){ |
| 98091 | /* The following may return WRC_Abort if there are unresolvable | 98495 | /* The following may return WRC_Abort if there are unresolvable |
| 98092 | ** symbols (e.g. a table that does not exist) in a window definition. */ | 98496 | ** symbols (e.g. a table that does not exist) in a window definition. */ |
| 98093 | int rc = walkWindowList(pWalker, p->pWinDefn); | 98497 | int rc = walkWindowList(pWalker, p->pWinDefn, 0); |
| 98094 | return rc; | 98498 | return rc; |
| 98095 | } | 98499 | } |
| 98096 | } | 98500 | } |
| @@ -98108,7 +98512,7 @@ SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){ | |||
| 98108 | SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){ | 98512 | SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){ |
| 98109 | SrcList *pSrc; | 98513 | SrcList *pSrc; |
| 98110 | int i; | 98514 | int i; |
| 98111 | struct SrcList_item *pItem; | 98515 | SrcItem *pItem; |
| 98112 | 98516 | ||
| 98113 | pSrc = p->pSrc; | 98517 | pSrc = p->pSrc; |
| 98114 | if( pSrc ){ | 98518 | if( pSrc ){ |
| @@ -98274,7 +98678,6 @@ static void resolveAlias( | |||
| 98274 | ExprList *pEList, /* A result set */ | 98678 | ExprList *pEList, /* A result set */ |
| 98275 | int iCol, /* A column in the result set. 0..pEList->nExpr-1 */ | 98679 | int iCol, /* A column in the result set. 0..pEList->nExpr-1 */ |
| 98276 | Expr *pExpr, /* Transform this into an alias to the result set */ | 98680 | Expr *pExpr, /* Transform this into an alias to the result set */ |
| 98277 | const char *zType, /* "GROUP" or "ORDER" or "" */ | ||
| 98278 | int nSubquery /* Number of subqueries that the label is moving */ | 98681 | int nSubquery /* Number of subqueries that the label is moving */ |
| 98279 | ){ | 98682 | ){ |
| 98280 | Expr *pOrig; /* The iCol-th column of the result set */ | 98683 | Expr *pOrig; /* The iCol-th column of the result set */ |
| @@ -98287,7 +98690,7 @@ static void resolveAlias( | |||
| 98287 | db = pParse->db; | 98690 | db = pParse->db; |
| 98288 | pDup = sqlite3ExprDup(db, pOrig, 0); | 98691 | pDup = sqlite3ExprDup(db, pOrig, 0); |
| 98289 | if( pDup!=0 ){ | 98692 | if( pDup!=0 ){ |
| 98290 | if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery); | 98693 | incrAggFunctionDepth(pDup, nSubquery); |
| 98291 | if( pExpr->op==TK_COLLATE ){ | 98694 | if( pExpr->op==TK_COLLATE ){ |
| 98292 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); | 98695 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); |
| 98293 | } | 98696 | } |
| @@ -98316,7 +98719,6 @@ static void resolveAlias( | |||
| 98316 | } | 98719 | } |
| 98317 | sqlite3DbFree(db, pDup); | 98720 | sqlite3DbFree(db, pDup); |
| 98318 | } | 98721 | } |
| 98319 | ExprSetProperty(pExpr, EP_Alias); | ||
| 98320 | } | 98722 | } |
| 98321 | 98723 | ||
| 98322 | 98724 | ||
| @@ -98451,8 +98853,8 @@ static int lookupName( | |||
| 98451 | int cntTab = 0; /* Number of matching table names */ | 98853 | int cntTab = 0; /* Number of matching table names */ |
| 98452 | int nSubquery = 0; /* How many levels of subquery */ | 98854 | int nSubquery = 0; /* How many levels of subquery */ |
| 98453 | sqlite3 *db = pParse->db; /* The database connection */ | 98855 | sqlite3 *db = pParse->db; /* The database connection */ |
| 98454 | struct SrcList_item *pItem; /* Use for looping over pSrcList items */ | 98856 | SrcItem *pItem; /* Use for looping over pSrcList items */ |
| 98455 | struct SrcList_item *pMatch = 0; /* The matching pSrcList item */ | 98857 | SrcItem *pMatch = 0; /* The matching pSrcList item */ |
| 98456 | NameContext *pTopNC = pNC; /* First namecontext in the list */ | 98858 | NameContext *pTopNC = pNC; /* First namecontext in the list */ |
| 98457 | Schema *pSchema = 0; /* Schema of the expression */ | 98859 | Schema *pSchema = 0; /* Schema of the expression */ |
| 98458 | int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */ | 98860 | int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */ |
| @@ -98573,25 +98975,29 @@ static int lookupName( | |||
| 98573 | #if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) | 98975 | #if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) |
| 98574 | /* If we have not already resolved the name, then maybe | 98976 | /* If we have not already resolved the name, then maybe |
| 98575 | ** it is a new.* or old.* trigger argument reference. Or | 98977 | ** it is a new.* or old.* trigger argument reference. Or |
| 98576 | ** maybe it is an excluded.* from an upsert. | 98978 | ** maybe it is an excluded.* from an upsert. Or maybe it is |
| 98979 | ** a reference in the RETURNING clause to a table being modified. | ||
| 98577 | */ | 98980 | */ |
| 98578 | if( zDb==0 && zTab!=0 && cntTab==0 ){ | 98981 | if( cnt==0 && zDb==0 ){ |
| 98579 | pTab = 0; | 98982 | pTab = 0; |
| 98580 | #ifndef SQLITE_OMIT_TRIGGER | 98983 | #ifndef SQLITE_OMIT_TRIGGER |
| 98581 | if( pParse->pTriggerTab!=0 ){ | 98984 | if( pParse->pTriggerTab!=0 ){ |
| 98582 | int op = pParse->eTriggerOp; | 98985 | int op = pParse->eTriggerOp; |
| 98583 | assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT ); | 98986 | assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT ); |
| 98584 | if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){ | 98987 | if( op!=TK_DELETE && zTab && sqlite3StrICmp("new",zTab) == 0 ){ |
| 98585 | pExpr->iTable = 1; | 98988 | pExpr->iTable = 1; |
| 98586 | pTab = pParse->pTriggerTab; | 98989 | pTab = pParse->pTriggerTab; |
| 98587 | }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){ | 98990 | }else if( op!=TK_INSERT && zTab && sqlite3StrICmp("old",zTab)==0 ){ |
| 98588 | pExpr->iTable = 0; | 98991 | pExpr->iTable = 0; |
| 98589 | pTab = pParse->pTriggerTab; | 98992 | pTab = pParse->pTriggerTab; |
| 98993 | }else if( pParse->bReturning && (pNC->ncFlags & NC_UBaseReg)!=0 ){ | ||
| 98994 | pExpr->iTable = op!=TK_DELETE; | ||
| 98995 | pTab = pParse->pTriggerTab; | ||
| 98590 | } | 98996 | } |
| 98591 | } | 98997 | } |
| 98592 | #endif /* SQLITE_OMIT_TRIGGER */ | 98998 | #endif /* SQLITE_OMIT_TRIGGER */ |
| 98593 | #ifndef SQLITE_OMIT_UPSERT | 98999 | #ifndef SQLITE_OMIT_UPSERT |
| 98594 | if( (pNC->ncFlags & NC_UUpsert)!=0 ){ | 99000 | if( (pNC->ncFlags & NC_UUpsert)!=0 && zTab!=0 ){ |
| 98595 | Upsert *pUpsert = pNC->uNC.pUpsert; | 99001 | Upsert *pUpsert = pNC->uNC.pUpsert; |
| 98596 | if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){ | 99002 | if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){ |
| 98597 | pTab = pUpsert->pUpsertSrc->a[0].pTab; | 99003 | pTab = pUpsert->pUpsertSrc->a[0].pTab; |
| @@ -98619,6 +99025,7 @@ static int lookupName( | |||
| 98619 | } | 99025 | } |
| 98620 | if( iCol<pTab->nCol ){ | 99026 | if( iCol<pTab->nCol ){ |
| 98621 | cnt++; | 99027 | cnt++; |
| 99028 | pMatch = 0; | ||
| 98622 | #ifndef SQLITE_OMIT_UPSERT | 99029 | #ifndef SQLITE_OMIT_UPSERT |
| 98623 | if( pExpr->iTable==EXCLUDED_TABLE_NUMBER ){ | 99030 | if( pExpr->iTable==EXCLUDED_TABLE_NUMBER ){ |
| 98624 | testcase( iCol==(-1) ); | 99031 | testcase( iCol==(-1) ); |
| @@ -98630,27 +99037,32 @@ static int lookupName( | |||
| 98630 | pExpr->iTable = pNC->uNC.pUpsert->regData + | 99037 | pExpr->iTable = pNC->uNC.pUpsert->regData + |
| 98631 | sqlite3TableColumnToStorage(pTab, iCol); | 99038 | sqlite3TableColumnToStorage(pTab, iCol); |
| 98632 | eNewExprOp = TK_REGISTER; | 99039 | eNewExprOp = TK_REGISTER; |
| 98633 | ExprSetProperty(pExpr, EP_Alias); | ||
| 98634 | } | 99040 | } |
| 98635 | }else | 99041 | }else |
| 98636 | #endif /* SQLITE_OMIT_UPSERT */ | 99042 | #endif /* SQLITE_OMIT_UPSERT */ |
| 98637 | { | 99043 | { |
| 98638 | #ifndef SQLITE_OMIT_TRIGGER | ||
| 98639 | if( iCol<0 ){ | ||
| 98640 | pExpr->affExpr = SQLITE_AFF_INTEGER; | ||
| 98641 | }else if( pExpr->iTable==0 ){ | ||
| 98642 | testcase( iCol==31 ); | ||
| 98643 | testcase( iCol==32 ); | ||
| 98644 | pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol)); | ||
| 98645 | }else{ | ||
| 98646 | testcase( iCol==31 ); | ||
| 98647 | testcase( iCol==32 ); | ||
| 98648 | pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol)); | ||
| 98649 | } | ||
| 98650 | pExpr->y.pTab = pTab; | 99044 | pExpr->y.pTab = pTab; |
| 98651 | pExpr->iColumn = (i16)iCol; | 99045 | if( pParse->bReturning ){ |
| 98652 | eNewExprOp = TK_TRIGGER; | 99046 | eNewExprOp = TK_REGISTER; |
| 99047 | pExpr->iTable = pNC->uNC.iBaseReg + (pTab->nCol+1)*pExpr->iTable + | ||
| 99048 | sqlite3TableColumnToStorage(pTab, iCol) + 1; | ||
| 99049 | }else{ | ||
| 99050 | pExpr->iColumn = (i16)iCol; | ||
| 99051 | eNewExprOp = TK_TRIGGER; | ||
| 99052 | #ifndef SQLITE_OMIT_TRIGGER | ||
| 99053 | if( iCol<0 ){ | ||
| 99054 | pExpr->affExpr = SQLITE_AFF_INTEGER; | ||
| 99055 | }else if( pExpr->iTable==0 ){ | ||
| 99056 | testcase( iCol==31 ); | ||
| 99057 | testcase( iCol==32 ); | ||
| 99058 | pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol)); | ||
| 99059 | }else{ | ||
| 99060 | testcase( iCol==31 ); | ||
| 99061 | testcase( iCol==32 ); | ||
| 99062 | pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol)); | ||
| 99063 | } | ||
| 98653 | #endif /* SQLITE_OMIT_TRIGGER */ | 99064 | #endif /* SQLITE_OMIT_TRIGGER */ |
| 99065 | } | ||
| 98654 | } | 99066 | } |
| 98655 | } | 99067 | } |
| 98656 | } | 99068 | } |
| @@ -98720,7 +99132,7 @@ static int lookupName( | |||
| 98720 | sqlite3ErrorMsg(pParse, "row value misused"); | 99132 | sqlite3ErrorMsg(pParse, "row value misused"); |
| 98721 | return WRC_Abort; | 99133 | return WRC_Abort; |
| 98722 | } | 99134 | } |
| 98723 | resolveAlias(pParse, pEList, j, pExpr, "", nSubquery); | 99135 | resolveAlias(pParse, pEList, j, pExpr, nSubquery); |
| 98724 | cnt = 1; | 99136 | cnt = 1; |
| 98725 | pMatch = 0; | 99137 | pMatch = 0; |
| 98726 | assert( zTab==0 && zDb==0 ); | 99138 | assert( zTab==0 && zDb==0 ); |
| @@ -98822,18 +99234,24 @@ static int lookupName( | |||
| 98822 | 99234 | ||
| 98823 | /* Clean up and return | 99235 | /* Clean up and return |
| 98824 | */ | 99236 | */ |
| 98825 | sqlite3ExprDelete(db, pExpr->pLeft); | 99237 | if( !ExprHasProperty(pExpr,(EP_TokenOnly|EP_Leaf)) ){ |
| 98826 | pExpr->pLeft = 0; | 99238 | sqlite3ExprDelete(db, pExpr->pLeft); |
| 98827 | sqlite3ExprDelete(db, pExpr->pRight); | 99239 | pExpr->pLeft = 0; |
| 98828 | pExpr->pRight = 0; | 99240 | sqlite3ExprDelete(db, pExpr->pRight); |
| 99241 | pExpr->pRight = 0; | ||
| 99242 | } | ||
| 98829 | pExpr->op = eNewExprOp; | 99243 | pExpr->op = eNewExprOp; |
| 98830 | ExprSetProperty(pExpr, EP_Leaf); | 99244 | ExprSetProperty(pExpr, EP_Leaf); |
| 98831 | lookupname_end: | 99245 | lookupname_end: |
| 98832 | if( cnt==1 ){ | 99246 | if( cnt==1 ){ |
| 98833 | assert( pNC!=0 ); | 99247 | assert( pNC!=0 ); |
| 98834 | if( !ExprHasProperty(pExpr, EP_Alias) ){ | 99248 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 99249 | if( pParse->db->xAuth | ||
| 99250 | && (pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER) | ||
| 99251 | ){ | ||
| 98835 | sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList); | 99252 | sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList); |
| 98836 | } | 99253 | } |
| 99254 | #endif | ||
| 98837 | /* Increment the nRef value on all name contexts from TopNC up to | 99255 | /* Increment the nRef value on all name contexts from TopNC up to |
| 98838 | ** the point where the name matched. */ | 99256 | ** the point where the name matched. */ |
| 98839 | for(;;){ | 99257 | for(;;){ |
| @@ -98855,7 +99273,7 @@ lookupname_end: | |||
| 98855 | SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){ | 99273 | SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSrc, int iCol){ |
| 98856 | Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0); | 99274 | Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0); |
| 98857 | if( p ){ | 99275 | if( p ){ |
| 98858 | struct SrcList_item *pItem = &pSrc->a[iSrc]; | 99276 | SrcItem *pItem = &pSrc->a[iSrc]; |
| 98859 | Table *pTab = p->y.pTab = pItem->pTab; | 99277 | Table *pTab = p->y.pTab = pItem->pTab; |
| 98860 | p->iTable = pItem->iCursor; | 99278 | p->iTable = pItem->iCursor; |
| 98861 | if( p->y.pTab->iPKey==iCol ){ | 99279 | if( p->y.pTab->iPKey==iCol ){ |
| @@ -98967,7 +99385,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 98967 | */ | 99385 | */ |
| 98968 | case TK_ROW: { | 99386 | case TK_ROW: { |
| 98969 | SrcList *pSrcList = pNC->pSrcList; | 99387 | SrcList *pSrcList = pNC->pSrcList; |
| 98970 | struct SrcList_item *pItem; | 99388 | SrcItem *pItem; |
| 98971 | assert( pSrcList && pSrcList->nSrc>=1 ); | 99389 | assert( pSrcList && pSrcList->nSrc>=1 ); |
| 98972 | pItem = pSrcList->a; | 99390 | pItem = pSrcList->a; |
| 98973 | pExpr->op = TK_COLUMN; | 99391 | pExpr->op = TK_COLUMN; |
| @@ -98978,6 +99396,47 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 98978 | break; | 99396 | break; |
| 98979 | } | 99397 | } |
| 98980 | 99398 | ||
| 99399 | /* An optimization: Attempt to convert | ||
| 99400 | ** | ||
| 99401 | ** "expr IS NOT NULL" --> "TRUE" | ||
| 99402 | ** "expr IS NULL" --> "FALSE" | ||
| 99403 | ** | ||
| 99404 | ** if we can prove that "expr" is never NULL. Call this the | ||
| 99405 | ** "NOT NULL strength reduction optimization". | ||
| 99406 | ** | ||
| 99407 | ** If this optimization occurs, also restore the NameContext ref-counts | ||
| 99408 | ** to the state they where in before the "column" LHS expression was | ||
| 99409 | ** resolved. This prevents "column" from being counted as having been | ||
| 99410 | ** referenced, which might prevent a SELECT from being erroneously | ||
| 99411 | ** marked as correlated. | ||
| 99412 | */ | ||
| 99413 | case TK_NOTNULL: | ||
| 99414 | case TK_ISNULL: { | ||
| 99415 | int anRef[8]; | ||
| 99416 | NameContext *p; | ||
| 99417 | int i; | ||
| 99418 | for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){ | ||
| 99419 | anRef[i] = p->nRef; | ||
| 99420 | } | ||
| 99421 | sqlite3WalkExpr(pWalker, pExpr->pLeft); | ||
| 99422 | if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ | ||
| 99423 | if( pExpr->op==TK_NOTNULL ){ | ||
| 99424 | pExpr->u.zToken = "true"; | ||
| 99425 | ExprSetProperty(pExpr, EP_IsTrue); | ||
| 99426 | }else{ | ||
| 99427 | pExpr->u.zToken = "false"; | ||
| 99428 | ExprSetProperty(pExpr, EP_IsFalse); | ||
| 99429 | } | ||
| 99430 | pExpr->op = TK_TRUEFALSE; | ||
| 99431 | for(i=0, p=pNC; p && i<ArraySize(anRef); p=p->pNext, i++){ | ||
| 99432 | p->nRef = anRef[i]; | ||
| 99433 | } | ||
| 99434 | sqlite3ExprDelete(pParse->db, pExpr->pLeft); | ||
| 99435 | pExpr->pLeft = 0; | ||
| 99436 | } | ||
| 99437 | return WRC_Prune; | ||
| 99438 | } | ||
| 99439 | |||
| 98981 | /* A column name: ID | 99440 | /* A column name: ID |
| 98982 | ** Or table name and column name: ID.ID | 99441 | ** Or table name and column name: ID.ID |
| 98983 | ** Or a database, table and column: ID.ID.ID | 99442 | ** Or a database, table and column: ID.ID.ID |
| @@ -99205,6 +99664,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99205 | assert( pWin==pExpr->y.pWin ); | 99664 | assert( pWin==pExpr->y.pWin ); |
| 99206 | if( IN_RENAME_OBJECT==0 ){ | 99665 | if( IN_RENAME_OBJECT==0 ){ |
| 99207 | sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); | 99666 | sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); |
| 99667 | if( pParse->db->mallocFailed ) break; | ||
| 99208 | } | 99668 | } |
| 99209 | sqlite3WalkExprList(pWalker, pWin->pPartition); | 99669 | sqlite3WalkExprList(pWalker, pWin->pPartition); |
| 99210 | sqlite3WalkExprList(pWalker, pWin->pOrderBy); | 99670 | sqlite3WalkExprList(pWalker, pWin->pOrderBy); |
| @@ -99279,7 +99739,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99279 | assert( !ExprHasProperty(pExpr, EP_Reduced) ); | 99739 | assert( !ExprHasProperty(pExpr, EP_Reduced) ); |
| 99280 | /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", | 99740 | /* Handle special cases of "x IS TRUE", "x IS FALSE", "x IS NOT TRUE", |
| 99281 | ** and "x IS NOT FALSE". */ | 99741 | ** and "x IS NOT FALSE". */ |
| 99282 | if( pRight && (pRight->op==TK_ID || pRight->op==TK_TRUEFALSE) ){ | 99742 | if( ALWAYS(pRight) && (pRight->op==TK_ID || pRight->op==TK_TRUEFALSE) ){ |
| 99283 | int rc = resolveExprStep(pWalker, pRight); | 99743 | int rc = resolveExprStep(pWalker, pRight); |
| 99284 | if( rc==WRC_Abort ) return WRC_Abort; | 99744 | if( rc==WRC_Abort ) return WRC_Abort; |
| 99285 | if( pRight->op==TK_TRUEFALSE ){ | 99745 | if( pRight->op==TK_TRUEFALSE ){ |
| @@ -99595,8 +100055,7 @@ SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy( | |||
| 99595 | resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr); | 100055 | resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr); |
| 99596 | return 1; | 100056 | return 1; |
| 99597 | } | 100057 | } |
| 99598 | resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr, | 100058 | resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,0); |
| 99599 | zType,0); | ||
| 99600 | } | 100059 | } |
| 99601 | } | 100060 | } |
| 99602 | return 0; | 100061 | return 0; |
| @@ -99781,27 +100240,26 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 99781 | /* Recursively resolve names in all subqueries | 100240 | /* Recursively resolve names in all subqueries |
| 99782 | */ | 100241 | */ |
| 99783 | for(i=0; i<p->pSrc->nSrc; i++){ | 100242 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 99784 | struct SrcList_item *pItem = &p->pSrc->a[i]; | 100243 | SrcItem *pItem = &p->pSrc->a[i]; |
| 99785 | if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ | 100244 | if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){ |
| 99786 | NameContext *pNC; /* Used to iterate name contexts */ | 100245 | int nRef = pOuterNC ? pOuterNC->nRef : 0; |
| 99787 | int nRef = 0; /* Refcount for pOuterNC and outer contexts */ | ||
| 99788 | const char *zSavedContext = pParse->zAuthContext; | 100246 | const char *zSavedContext = pParse->zAuthContext; |
| 99789 | 100247 | ||
| 99790 | /* Count the total number of references to pOuterNC and all of its | ||
| 99791 | ** parent contexts. After resolving references to expressions in | ||
| 99792 | ** pItem->pSelect, check if this value has changed. If so, then | ||
| 99793 | ** SELECT statement pItem->pSelect must be correlated. Set the | ||
| 99794 | ** pItem->fg.isCorrelated flag if this is the case. */ | ||
| 99795 | for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef += pNC->nRef; | ||
| 99796 | |||
| 99797 | if( pItem->zName ) pParse->zAuthContext = pItem->zName; | 100248 | if( pItem->zName ) pParse->zAuthContext = pItem->zName; |
| 99798 | sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC); | 100249 | sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC); |
| 99799 | pParse->zAuthContext = zSavedContext; | 100250 | pParse->zAuthContext = zSavedContext; |
| 99800 | if( pParse->nErr || db->mallocFailed ) return WRC_Abort; | 100251 | if( pParse->nErr || db->mallocFailed ) return WRC_Abort; |
| 99801 | 100252 | ||
| 99802 | for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef; | 100253 | /* If the number of references to the outer context changed when |
| 99803 | assert( pItem->fg.isCorrelated==0 && nRef<=0 ); | 100254 | ** expressions in the sub-select were resolved, the sub-select |
| 99804 | pItem->fg.isCorrelated = (nRef!=0); | 100255 | ** is correlated. It is not required to check the refcount on any |
| 100256 | ** but the innermost outer context object, as lookupName() increments | ||
| 100257 | ** the refcount on all contexts between the current one and the | ||
| 100258 | ** context containing the column when it resolves a name. */ | ||
| 100259 | if( pOuterNC ){ | ||
| 100260 | assert( pItem->fg.isCorrelated==0 && pOuterNC->nRef>=nRef ); | ||
| 100261 | pItem->fg.isCorrelated = (pOuterNC->nRef>nRef); | ||
| 100262 | } | ||
| 99805 | } | 100263 | } |
| 99806 | } | 100264 | } |
| 99807 | 100265 | ||
| @@ -99843,7 +100301,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 99843 | ** Minor point: If this is the case, then the expression will be | 100301 | ** Minor point: If this is the case, then the expression will be |
| 99844 | ** re-evaluated for each reference to it. | 100302 | ** re-evaluated for each reference to it. |
| 99845 | */ | 100303 | */ |
| 99846 | assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert))==0 ); | 100304 | assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert|NC_UBaseReg))==0 ); |
| 99847 | sNC.uNC.pEList = p->pEList; | 100305 | sNC.uNC.pEList = p->pEList; |
| 99848 | sNC.ncFlags |= NC_UEList; | 100306 | sNC.ncFlags |= NC_UEList; |
| 99849 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; | 100307 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| @@ -99851,7 +100309,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 99851 | 100309 | ||
| 99852 | /* Resolve names in table-valued-function arguments */ | 100310 | /* Resolve names in table-valued-function arguments */ |
| 99853 | for(i=0; i<p->pSrc->nSrc; i++){ | 100311 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 99854 | struct SrcList_item *pItem = &p->pSrc->a[i]; | 100312 | SrcItem *pItem = &p->pSrc->a[i]; |
| 99855 | if( pItem->fg.isTabFunc | 100313 | if( pItem->fg.isTabFunc |
| 99856 | && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) | 100314 | && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) |
| 99857 | ){ | 100315 | ){ |
| @@ -100260,7 +100718,18 @@ SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken( | |||
| 100260 | const Token *pCollName, /* Name of collating sequence */ | 100718 | const Token *pCollName, /* Name of collating sequence */ |
| 100261 | int dequote /* True to dequote pCollName */ | 100719 | int dequote /* True to dequote pCollName */ |
| 100262 | ){ | 100720 | ){ |
| 100263 | if( pCollName->n>0 ){ | 100721 | assert( pExpr!=0 || pParse->db->mallocFailed ); |
| 100722 | if( pExpr==0 ) return 0; | ||
| 100723 | if( pExpr->op==TK_VECTOR ){ | ||
| 100724 | ExprList *pList = pExpr->x.pList; | ||
| 100725 | if( ALWAYS(pList!=0) ){ | ||
| 100726 | int i; | ||
| 100727 | for(i=0; i<pList->nExpr; i++){ | ||
| 100728 | pList->a[i].pExpr = sqlite3ExprAddCollateToken(pParse,pList->a[i].pExpr, | ||
| 100729 | pCollName, dequote); | ||
| 100730 | } | ||
| 100731 | } | ||
| 100732 | }else if( pCollName->n>0 ){ | ||
| 100264 | Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote); | 100733 | Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote); |
| 100265 | if( pNew ){ | 100734 | if( pNew ){ |
| 100266 | pNew->pLeft = pExpr; | 100735 | pNew->pLeft = pExpr; |
| @@ -101684,8 +102153,8 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){ | |||
| 101684 | if( pNew==0 ) return 0; | 102153 | if( pNew==0 ) return 0; |
| 101685 | pNew->nSrc = pNew->nAlloc = p->nSrc; | 102154 | pNew->nSrc = pNew->nAlloc = p->nSrc; |
| 101686 | for(i=0; i<p->nSrc; i++){ | 102155 | for(i=0; i<p->nSrc; i++){ |
| 101687 | struct SrcList_item *pNewItem = &pNew->a[i]; | 102156 | SrcItem *pNewItem = &pNew->a[i]; |
| 101688 | struct SrcList_item *pOldItem = &p->a[i]; | 102157 | SrcItem *pOldItem = &p->a[i]; |
| 101689 | Table *pTab; | 102158 | Table *pTab; |
| 101690 | pNewItem->pSchema = pOldItem->pSchema; | 102159 | pNewItem->pSchema = pOldItem->pSchema; |
| 101691 | pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase); | 102160 | pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase); |
| @@ -101698,7 +102167,10 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){ | |||
| 101698 | if( pNewItem->fg.isIndexedBy ){ | 102167 | if( pNewItem->fg.isIndexedBy ){ |
| 101699 | pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); | 102168 | pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); |
| 101700 | } | 102169 | } |
| 101701 | pNewItem->pIBIndex = pOldItem->pIBIndex; | 102170 | pNewItem->u2 = pOldItem->u2; |
| 102171 | if( pNewItem->fg.isCte ){ | ||
| 102172 | pNewItem->u2.pCteUse->nUse++; | ||
| 102173 | } | ||
| 101702 | if( pNewItem->fg.isTabFunc ){ | 102174 | if( pNewItem->fg.isTabFunc ){ |
| 101703 | pNewItem->u1.pFuncArg = | 102175 | pNewItem->u1.pFuncArg = |
| 101704 | sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags); | 102176 | sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags); |
| @@ -102736,7 +103208,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex( | |||
| 102736 | 103208 | ||
| 102737 | /* Code an OP_Transaction and OP_TableLock for <table>. */ | 103209 | /* Code an OP_Transaction and OP_TableLock for <table>. */ |
| 102738 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 103210 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 102739 | assert( iDb>=0 && iDb<SQLITE_MAX_ATTACHED ); | 103211 | assert( iDb>=0 && iDb<SQLITE_MAX_DB ); |
| 102740 | sqlite3CodeVerifySchema(pParse, iDb); | 103212 | sqlite3CodeVerifySchema(pParse, iDb); |
| 102741 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); | 103213 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
| 102742 | 103214 | ||
| @@ -106015,7 +106487,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ | |||
| 106015 | /* Check to see if the column is in one of the tables in the FROM | 106487 | /* Check to see if the column is in one of the tables in the FROM |
| 106016 | ** clause of the aggregate query */ | 106488 | ** clause of the aggregate query */ |
| 106017 | if( ALWAYS(pSrcList!=0) ){ | 106489 | if( ALWAYS(pSrcList!=0) ){ |
| 106018 | struct SrcList_item *pItem = pSrcList->a; | 106490 | SrcItem *pItem = pSrcList->a; |
| 106019 | for(i=0; i<pSrcList->nSrc; i++, pItem++){ | 106491 | for(i=0; i<pSrcList->nSrc; i++, pItem++){ |
| 106020 | struct AggInfo_col *pCol; | 106492 | struct AggInfo_col *pCol; |
| 106021 | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); | 106493 | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); |
| @@ -106304,15 +106776,21 @@ static int isAlterableTable(Parse *pParse, Table *pTab){ | |||
| 106304 | ** statement to ensure that the operation has not rendered any schema | 106776 | ** statement to ensure that the operation has not rendered any schema |
| 106305 | ** objects unusable. | 106777 | ** objects unusable. |
| 106306 | */ | 106778 | */ |
| 106307 | static void renameTestSchema(Parse *pParse, const char *zDb, int bTemp){ | 106779 | static void renameTestSchema( |
| 106780 | Parse *pParse, /* Parse context */ | ||
| 106781 | const char *zDb, /* Name of db to verify schema of */ | ||
| 106782 | int bTemp, /* True if this is the temp db */ | ||
| 106783 | const char *zWhen /* "when" part of error message */ | ||
| 106784 | ){ | ||
| 106785 | pParse->colNamesSet = 1; | ||
| 106308 | sqlite3NestedParse(pParse, | 106786 | sqlite3NestedParse(pParse, |
| 106309 | "SELECT 1 " | 106787 | "SELECT 1 " |
| 106310 | "FROM \"%w\"." DFLT_SCHEMA_TABLE " " | 106788 | "FROM \"%w\"." DFLT_SCHEMA_TABLE " " |
| 106311 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 106789 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 106312 | " AND sql NOT LIKE 'create virtual%%'" | 106790 | " AND sql NOT LIKE 'create virtual%%'" |
| 106313 | " AND sqlite_rename_test(%Q, sql, type, name, %d)=NULL ", | 106791 | " AND sqlite_rename_test(%Q, sql, type, name, %d, %Q)=NULL ", |
| 106314 | zDb, | 106792 | zDb, |
| 106315 | zDb, bTemp | 106793 | zDb, bTemp, zWhen |
| 106316 | ); | 106794 | ); |
| 106317 | 106795 | ||
| 106318 | if( bTemp==0 ){ | 106796 | if( bTemp==0 ){ |
| @@ -106321,8 +106799,8 @@ static void renameTestSchema(Parse *pParse, const char *zDb, int bTemp){ | |||
| 106321 | "FROM temp." DFLT_SCHEMA_TABLE " " | 106799 | "FROM temp." DFLT_SCHEMA_TABLE " " |
| 106322 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 106800 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 106323 | " AND sql NOT LIKE 'create virtual%%'" | 106801 | " AND sql NOT LIKE 'create virtual%%'" |
| 106324 | " AND sqlite_rename_test(%Q, sql, type, name, 1)=NULL ", | 106802 | " AND sqlite_rename_test(%Q, sql, type, name, 1, %Q)=NULL ", |
| 106325 | zDb | 106803 | zDb, zWhen |
| 106326 | ); | 106804 | ); |
| 106327 | } | 106805 | } |
| 106328 | } | 106806 | } |
| @@ -106331,12 +106809,12 @@ static void renameTestSchema(Parse *pParse, const char *zDb, int bTemp){ | |||
| 106331 | ** Generate code to reload the schema for database iDb. And, if iDb!=1, for | 106809 | ** Generate code to reload the schema for database iDb. And, if iDb!=1, for |
| 106332 | ** the temp database as well. | 106810 | ** the temp database as well. |
| 106333 | */ | 106811 | */ |
| 106334 | static void renameReloadSchema(Parse *pParse, int iDb){ | 106812 | static void renameReloadSchema(Parse *pParse, int iDb, u16 p5){ |
| 106335 | Vdbe *v = pParse->pVdbe; | 106813 | Vdbe *v = pParse->pVdbe; |
| 106336 | if( v ){ | 106814 | if( v ){ |
| 106337 | sqlite3ChangeCookie(pParse, iDb); | 106815 | sqlite3ChangeCookie(pParse, iDb); |
| 106338 | sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, iDb, 0); | 106816 | sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, iDb, 0, p5); |
| 106339 | if( iDb!=1 ) sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, 1, 0); | 106817 | if( iDb!=1 ) sqlite3VdbeAddParseSchemaOp(pParse->pVdbe, 1, 0, p5); |
| 106340 | } | 106818 | } |
| 106341 | } | 106819 | } |
| 106342 | 106820 | ||
| @@ -106485,7 +106963,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 106485 | "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), " | 106963 | "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), " |
| 106486 | "tbl_name = " | 106964 | "tbl_name = " |
| 106487 | "CASE WHEN tbl_name=%Q COLLATE nocase AND " | 106965 | "CASE WHEN tbl_name=%Q COLLATE nocase AND " |
| 106488 | " sqlite_rename_test(%Q, sql, type, name, 1) " | 106966 | " sqlite_rename_test(%Q, sql, type, name, 1, 'after rename') " |
| 106489 | "THEN %Q ELSE tbl_name END " | 106967 | "THEN %Q ELSE tbl_name END " |
| 106490 | "WHERE type IN ('view', 'trigger')" | 106968 | "WHERE type IN ('view', 'trigger')" |
| 106491 | , zDb, zTabName, zName, zTabName, zDb, zName); | 106969 | , zDb, zTabName, zName, zTabName, zDb, zName); |
| @@ -106504,8 +106982,8 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 106504 | } | 106982 | } |
| 106505 | #endif | 106983 | #endif |
| 106506 | 106984 | ||
| 106507 | renameReloadSchema(pParse, iDb); | 106985 | renameReloadSchema(pParse, iDb, INITFLAG_AlterRename); |
| 106508 | renameTestSchema(pParse, zDb, iDb==1); | 106986 | renameTestSchema(pParse, zDb, iDb==1, "after rename"); |
| 106509 | 106987 | ||
| 106510 | exit_rename_table: | 106988 | exit_rename_table: |
| 106511 | sqlite3SrcListDelete(db, pSrc); | 106989 | sqlite3SrcListDelete(db, pSrc); |
| @@ -106636,11 +107114,14 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ | |||
| 106636 | *zEnd-- = '\0'; | 107114 | *zEnd-- = '\0'; |
| 106637 | } | 107115 | } |
| 106638 | db->mDbFlags |= DBFLAG_PreferBuiltin; | 107116 | db->mDbFlags |= DBFLAG_PreferBuiltin; |
| 107117 | /* substr() operations on characters, but addColOffset is in bytes. So we | ||
| 107118 | ** have to use printf() to translate between these units: */ | ||
| 106639 | sqlite3NestedParse(pParse, | 107119 | sqlite3NestedParse(pParse, |
| 106640 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " | 107120 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " |
| 106641 | "sql = substr(sql,1,%d) || ', ' || %Q || substr(sql,%d) " | 107121 | "sql = printf('%%.%ds, ',sql) || %Q" |
| 107122 | " || substr(sql,1+length(printf('%%.%ds',sql))) " | ||
| 106642 | "WHERE type = 'table' AND name = %Q", | 107123 | "WHERE type = 'table' AND name = %Q", |
| 106643 | zDb, pNew->addColOffset, zCol, pNew->addColOffset+1, | 107124 | zDb, pNew->addColOffset, zCol, pNew->addColOffset, |
| 106644 | zTab | 107125 | zTab |
| 106645 | ); | 107126 | ); |
| 106646 | sqlite3DbFree(db, zCol); | 107127 | sqlite3DbFree(db, zCol); |
| @@ -106664,7 +107145,7 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ | |||
| 106664 | } | 107145 | } |
| 106665 | 107146 | ||
| 106666 | /* Reload the table definition */ | 107147 | /* Reload the table definition */ |
| 106667 | renameReloadSchema(pParse, iDb); | 107148 | renameReloadSchema(pParse, iDb, INITFLAG_AlterRename); |
| 106668 | } | 107149 | } |
| 106669 | 107150 | ||
| 106670 | /* | 107151 | /* |
| @@ -106764,7 +107245,7 @@ exit_begin_add_column: | |||
| 106764 | ** Or, if pTab is not a view or virtual table, zero is returned. | 107245 | ** Or, if pTab is not a view or virtual table, zero is returned. |
| 106765 | */ | 107246 | */ |
| 106766 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) | 107247 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 106767 | static int isRealTable(Parse *pParse, Table *pTab){ | 107248 | static int isRealTable(Parse *pParse, Table *pTab, int bDrop){ |
| 106768 | const char *zType = 0; | 107249 | const char *zType = 0; |
| 106769 | #ifndef SQLITE_OMIT_VIEW | 107250 | #ifndef SQLITE_OMIT_VIEW |
| 106770 | if( pTab->pSelect ){ | 107251 | if( pTab->pSelect ){ |
| @@ -106777,15 +107258,16 @@ static int isRealTable(Parse *pParse, Table *pTab){ | |||
| 106777 | } | 107258 | } |
| 106778 | #endif | 107259 | #endif |
| 106779 | if( zType ){ | 107260 | if( zType ){ |
| 106780 | sqlite3ErrorMsg( | 107261 | sqlite3ErrorMsg(pParse, "cannot %s %s \"%s\"", |
| 106781 | pParse, "cannot rename columns of %s \"%s\"", zType, pTab->zName | 107262 | (bDrop ? "drop column from" : "rename columns of"), |
| 107263 | zType, pTab->zName | ||
| 106782 | ); | 107264 | ); |
| 106783 | return 1; | 107265 | return 1; |
| 106784 | } | 107266 | } |
| 106785 | return 0; | 107267 | return 0; |
| 106786 | } | 107268 | } |
| 106787 | #else /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */ | 107269 | #else /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */ |
| 106788 | # define isRealTable(x,y) (0) | 107270 | # define isRealTable(x,y,z) (0) |
| 106789 | #endif | 107271 | #endif |
| 106790 | 107272 | ||
| 106791 | /* | 107273 | /* |
| @@ -106814,7 +107296,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn( | |||
| 106814 | 107296 | ||
| 106815 | /* Cannot alter a system table */ | 107297 | /* Cannot alter a system table */ |
| 106816 | if( SQLITE_OK!=isAlterableTable(pParse, pTab) ) goto exit_rename_column; | 107298 | if( SQLITE_OK!=isAlterableTable(pParse, pTab) ) goto exit_rename_column; |
| 106817 | if( SQLITE_OK!=isRealTable(pParse, pTab) ) goto exit_rename_column; | 107299 | if( SQLITE_OK!=isRealTable(pParse, pTab, 0) ) goto exit_rename_column; |
| 106818 | 107300 | ||
| 106819 | /* Which schema holds the table to be altered */ | 107301 | /* Which schema holds the table to be altered */ |
| 106820 | iSchema = sqlite3SchemaToIndex(db, pTab->pSchema); | 107302 | iSchema = sqlite3SchemaToIndex(db, pTab->pSchema); |
| @@ -106868,8 +107350,8 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn( | |||
| 106868 | ); | 107350 | ); |
| 106869 | 107351 | ||
| 106870 | /* Drop and reload the database schema. */ | 107352 | /* Drop and reload the database schema. */ |
| 106871 | renameReloadSchema(pParse, iSchema); | 107353 | renameReloadSchema(pParse, iSchema, INITFLAG_AlterRename); |
| 106872 | renameTestSchema(pParse, zDb, iSchema==1); | 107354 | renameTestSchema(pParse, zDb, iSchema==1, "after rename"); |
| 106873 | 107355 | ||
| 106874 | exit_rename_column: | 107356 | exit_rename_column: |
| 106875 | sqlite3SrcListDelete(db, pSrc); | 107357 | sqlite3SrcListDelete(db, pSrc); |
| @@ -107121,23 +107603,33 @@ static void renameTokenFree(sqlite3 *db, RenameToken *pToken){ | |||
| 107121 | 107603 | ||
| 107122 | /* | 107604 | /* |
| 107123 | ** Search the Parse object passed as the first argument for a RenameToken | 107605 | ** Search the Parse object passed as the first argument for a RenameToken |
| 107124 | ** object associated with parse tree element pPtr. If found, remove it | 107606 | ** object associated with parse tree element pPtr. If found, return a pointer |
| 107125 | ** from the Parse object and add it to the list maintained by the | 107607 | ** to it. Otherwise, return NULL. |
| 107126 | ** RenameCtx object passed as the second argument. | 107608 | ** |
| 107609 | ** If the second argument passed to this function is not NULL and a matching | ||
| 107610 | ** RenameToken object is found, remove it from the Parse object and add it to | ||
| 107611 | ** the list maintained by the RenameCtx object. | ||
| 107127 | */ | 107612 | */ |
| 107128 | static void renameTokenFind(Parse *pParse, struct RenameCtx *pCtx, void *pPtr){ | 107613 | static RenameToken *renameTokenFind( |
| 107614 | Parse *pParse, | ||
| 107615 | struct RenameCtx *pCtx, | ||
| 107616 | void *pPtr | ||
| 107617 | ){ | ||
| 107129 | RenameToken **pp; | 107618 | RenameToken **pp; |
| 107130 | assert( pPtr!=0 ); | 107619 | assert( pPtr!=0 ); |
| 107131 | for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){ | 107620 | for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){ |
| 107132 | if( (*pp)->p==pPtr ){ | 107621 | if( (*pp)->p==pPtr ){ |
| 107133 | RenameToken *pToken = *pp; | 107622 | RenameToken *pToken = *pp; |
| 107134 | *pp = pToken->pNext; | 107623 | if( pCtx ){ |
| 107135 | pToken->pNext = pCtx->pList; | 107624 | *pp = pToken->pNext; |
| 107136 | pCtx->pList = pToken; | 107625 | pToken->pNext = pCtx->pList; |
| 107137 | pCtx->nList++; | 107626 | pCtx->pList = pToken; |
| 107138 | break; | 107627 | pCtx->nList++; |
| 107628 | } | ||
| 107629 | return pToken; | ||
| 107139 | } | 107630 | } |
| 107140 | } | 107631 | } |
| 107632 | return 0; | ||
| 107141 | } | 107633 | } |
| 107142 | 107634 | ||
| 107143 | /* | 107635 | /* |
| @@ -107208,7 +107700,7 @@ static RenameToken *renameColumnTokenNext(RenameCtx *pCtx){ | |||
| 107208 | */ | 107700 | */ |
| 107209 | static void renameColumnParseError( | 107701 | static void renameColumnParseError( |
| 107210 | sqlite3_context *pCtx, | 107702 | sqlite3_context *pCtx, |
| 107211 | int bPost, | 107703 | const char *zWhen, |
| 107212 | sqlite3_value *pType, | 107704 | sqlite3_value *pType, |
| 107213 | sqlite3_value *pObject, | 107705 | sqlite3_value *pObject, |
| 107214 | Parse *pParse | 107706 | Parse *pParse |
| @@ -107217,8 +107709,8 @@ static void renameColumnParseError( | |||
| 107217 | const char *zN = (const char*)sqlite3_value_text(pObject); | 107709 | const char *zN = (const char*)sqlite3_value_text(pObject); |
| 107218 | char *zErr; | 107710 | char *zErr; |
| 107219 | 107711 | ||
| 107220 | zErr = sqlite3_mprintf("error in %s %s%s: %s", | 107712 | zErr = sqlite3_mprintf("error in %s %s%s%s: %s", |
| 107221 | zT, zN, (bPost ? " after rename" : ""), | 107713 | zT, zN, (zWhen[0] ? " " : ""), zWhen, |
| 107222 | pParse->zErrMsg | 107714 | pParse->zErrMsg |
| 107223 | ); | 107715 | ); |
| 107224 | sqlite3_result_error(pCtx, zErr, -1); | 107716 | sqlite3_result_error(pCtx, zErr, -1); |
| @@ -107297,7 +107789,7 @@ static int renameParseSql( | |||
| 107297 | p->eParseMode = PARSE_MODE_RENAME; | 107789 | p->eParseMode = PARSE_MODE_RENAME; |
| 107298 | p->db = db; | 107790 | p->db = db; |
| 107299 | p->nQueryLoop = 1; | 107791 | p->nQueryLoop = 1; |
| 107300 | rc = sqlite3RunParser(p, zSql, &zErr); | 107792 | rc = zSql ? sqlite3RunParser(p, zSql, &zErr) : SQLITE_NOMEM; |
| 107301 | assert( p->zErrMsg==0 ); | 107793 | assert( p->zErrMsg==0 ); |
| 107302 | assert( rc!=SQLITE_OK || zErr==0 ); | 107794 | assert( rc!=SQLITE_OK || zErr==0 ); |
| 107303 | p->zErrMsg = zErr; | 107795 | p->zErrMsg = zErr; |
| @@ -107450,7 +107942,7 @@ static int renameResolveTrigger(Parse *pParse){ | |||
| 107450 | if( pSrc ){ | 107942 | if( pSrc ){ |
| 107451 | int i; | 107943 | int i; |
| 107452 | for(i=0; i<pSrc->nSrc && rc==SQLITE_OK; i++){ | 107944 | for(i=0; i<pSrc->nSrc && rc==SQLITE_OK; i++){ |
| 107453 | struct SrcList_item *p = &pSrc->a[i]; | 107945 | SrcItem *p = &pSrc->a[i]; |
| 107454 | p->iCursor = pParse->nTab++; | 107946 | p->iCursor = pParse->nTab++; |
| 107455 | if( p->pSelect ){ | 107947 | if( p->pSelect ){ |
| 107456 | sqlite3SelectPrep(pParse, p->pSelect, 0); | 107948 | sqlite3SelectPrep(pParse, p->pSelect, 0); |
| @@ -107476,9 +107968,8 @@ static int renameResolveTrigger(Parse *pParse){ | |||
| 107476 | rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList); | 107968 | rc = sqlite3ResolveExprListNames(&sNC, pStep->pExprList); |
| 107477 | } | 107969 | } |
| 107478 | assert( !pStep->pUpsert || (!pStep->pWhere && !pStep->pExprList) ); | 107970 | assert( !pStep->pUpsert || (!pStep->pWhere && !pStep->pExprList) ); |
| 107479 | if( pStep->pUpsert ){ | 107971 | if( pStep->pUpsert && rc==SQLITE_OK ){ |
| 107480 | Upsert *pUpsert = pStep->pUpsert; | 107972 | Upsert *pUpsert = pStep->pUpsert; |
| 107481 | assert( rc==SQLITE_OK ); | ||
| 107482 | pUpsert->pUpsertSrc = pSrc; | 107973 | pUpsert->pUpsertSrc = pSrc; |
| 107483 | sNC.uNC.pUpsert = pUpsert; | 107974 | sNC.uNC.pUpsert = pUpsert; |
| 107484 | sNC.ncFlags = NC_UUpsert; | 107975 | sNC.ncFlags = NC_UUpsert; |
| @@ -107724,7 +108215,7 @@ static void renameColumnFunc( | |||
| 107724 | renameColumnFunc_done: | 108215 | renameColumnFunc_done: |
| 107725 | if( rc!=SQLITE_OK ){ | 108216 | if( rc!=SQLITE_OK ){ |
| 107726 | if( sParse.zErrMsg ){ | 108217 | if( sParse.zErrMsg ){ |
| 107727 | renameColumnParseError(context, 0, argv[1], argv[2], &sParse); | 108218 | renameColumnParseError(context, "", argv[1], argv[2], &sParse); |
| 107728 | }else{ | 108219 | }else{ |
| 107729 | sqlite3_result_error_code(context, rc); | 108220 | sqlite3_result_error_code(context, rc); |
| 107730 | } | 108221 | } |
| @@ -107762,7 +108253,7 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ | |||
| 107762 | return WRC_Abort; | 108253 | return WRC_Abort; |
| 107763 | } | 108254 | } |
| 107764 | for(i=0; i<pSrc->nSrc; i++){ | 108255 | for(i=0; i<pSrc->nSrc; i++){ |
| 107765 | struct SrcList_item *pItem = &pSrc->a[i]; | 108256 | SrcItem *pItem = &pSrc->a[i]; |
| 107766 | if( pItem->pTab==p->pTab ){ | 108257 | if( pItem->pTab==p->pTab ){ |
| 107767 | renameTokenFind(pWalker->pParse, p, pItem->zName); | 108258 | renameTokenFind(pWalker->pParse, p, pItem->zName); |
| 107768 | } | 108259 | } |
| @@ -107913,7 +108404,7 @@ static void renameTableFunc( | |||
| 107913 | } | 108404 | } |
| 107914 | if( rc!=SQLITE_OK ){ | 108405 | if( rc!=SQLITE_OK ){ |
| 107915 | if( sParse.zErrMsg ){ | 108406 | if( sParse.zErrMsg ){ |
| 107916 | renameColumnParseError(context, 0, argv[1], argv[2], &sParse); | 108407 | renameColumnParseError(context, "", argv[1], argv[2], &sParse); |
| 107917 | }else{ | 108408 | }else{ |
| 107918 | sqlite3_result_error_code(context, rc); | 108409 | sqlite3_result_error_code(context, rc); |
| 107919 | } | 108410 | } |
| @@ -107942,6 +108433,7 @@ static void renameTableFunc( | |||
| 107942 | ** 2: Object type ("view", "table", "trigger" or "index"). | 108433 | ** 2: Object type ("view", "table", "trigger" or "index"). |
| 107943 | ** 3: Object name. | 108434 | ** 3: Object name. |
| 107944 | ** 4: True if object is from temp schema. | 108435 | ** 4: True if object is from temp schema. |
| 108436 | ** 5: "when" part of error message. | ||
| 107945 | ** | 108437 | ** |
| 107946 | ** Unless it finds an error, this function normally returns NULL. However, it | 108438 | ** Unless it finds an error, this function normally returns NULL. However, it |
| 107947 | ** returns integer value 1 if: | 108439 | ** returns integer value 1 if: |
| @@ -107959,6 +108451,7 @@ static void renameTableTest( | |||
| 107959 | char const *zInput = (const char*)sqlite3_value_text(argv[1]); | 108451 | char const *zInput = (const char*)sqlite3_value_text(argv[1]); |
| 107960 | int bTemp = sqlite3_value_int(argv[4]); | 108452 | int bTemp = sqlite3_value_int(argv[4]); |
| 107961 | int isLegacy = (db->flags & SQLITE_LegacyAlter); | 108453 | int isLegacy = (db->flags & SQLITE_LegacyAlter); |
| 108454 | char const *zWhen = (const char*)sqlite3_value_text(argv[5]); | ||
| 107962 | 108455 | ||
| 107963 | #ifndef SQLITE_OMIT_AUTHORIZATION | 108456 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| 107964 | sqlite3_xauth xAuth = db->xAuth; | 108457 | sqlite3_xauth xAuth = db->xAuth; |
| @@ -107991,8 +108484,8 @@ static void renameTableTest( | |||
| 107991 | } | 108484 | } |
| 107992 | } | 108485 | } |
| 107993 | 108486 | ||
| 107994 | if( rc!=SQLITE_OK ){ | 108487 | if( rc!=SQLITE_OK && zWhen ){ |
| 107995 | renameColumnParseError(context, 1, argv[2], argv[3], &sParse); | 108488 | renameColumnParseError(context, zWhen, argv[2], argv[3],&sParse); |
| 107996 | } | 108489 | } |
| 107997 | renameParseCleanup(&sParse); | 108490 | renameParseCleanup(&sParse); |
| 107998 | } | 108491 | } |
| @@ -108003,13 +108496,205 @@ static void renameTableTest( | |||
| 108003 | } | 108496 | } |
| 108004 | 108497 | ||
| 108005 | /* | 108498 | /* |
| 108499 | ** The implementation of internal UDF sqlite_drop_column(). | ||
| 108500 | ** | ||
| 108501 | ** Arguments: | ||
| 108502 | ** | ||
| 108503 | ** argv[0]: An integer - the index of the schema containing the table | ||
| 108504 | ** argv[1]: CREATE TABLE statement to modify. | ||
| 108505 | ** argv[2]: An integer - the index of the column to remove. | ||
| 108506 | ** | ||
| 108507 | ** The value returned is a string containing the CREATE TABLE statement | ||
| 108508 | ** with column argv[2] removed. | ||
| 108509 | */ | ||
| 108510 | static void dropColumnFunc( | ||
| 108511 | sqlite3_context *context, | ||
| 108512 | int NotUsed, | ||
| 108513 | sqlite3_value **argv | ||
| 108514 | ){ | ||
| 108515 | sqlite3 *db = sqlite3_context_db_handle(context); | ||
| 108516 | int iSchema = sqlite3_value_int(argv[0]); | ||
| 108517 | const char *zSql = (const char*)sqlite3_value_text(argv[1]); | ||
| 108518 | int iCol = sqlite3_value_int(argv[2]); | ||
| 108519 | const char *zDb = db->aDb[iSchema].zDbSName; | ||
| 108520 | int rc; | ||
| 108521 | Parse sParse; | ||
| 108522 | RenameToken *pCol; | ||
| 108523 | Table *pTab; | ||
| 108524 | const char *zEnd; | ||
| 108525 | char *zNew = 0; | ||
| 108526 | |||
| 108527 | #ifndef SQLITE_OMIT_AUTHORIZATION | ||
| 108528 | sqlite3_xauth xAuth = db->xAuth; | ||
| 108529 | db->xAuth = 0; | ||
| 108530 | #endif | ||
| 108531 | |||
| 108532 | UNUSED_PARAMETER(NotUsed); | ||
| 108533 | rc = renameParseSql(&sParse, zDb, db, zSql, iSchema==1); | ||
| 108534 | if( rc!=SQLITE_OK ) goto drop_column_done; | ||
| 108535 | pTab = sParse.pNewTable; | ||
| 108536 | if( pTab==0 || pTab->nCol==1 || iCol>=pTab->nCol ){ | ||
| 108537 | /* This can happen if the sqlite_schema table is corrupt */ | ||
| 108538 | rc = SQLITE_CORRUPT_BKPT; | ||
| 108539 | goto drop_column_done; | ||
| 108540 | } | ||
| 108541 | |||
| 108542 | pCol = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol].zName); | ||
| 108543 | if( iCol<pTab->nCol-1 ){ | ||
| 108544 | RenameToken *pEnd; | ||
| 108545 | pEnd = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol+1].zName); | ||
| 108546 | zEnd = (const char*)pEnd->t.z; | ||
| 108547 | }else{ | ||
| 108548 | zEnd = (const char*)&zSql[pTab->addColOffset]; | ||
| 108549 | while( ALWAYS(pCol->t.z[0]!=0) && pCol->t.z[0]!=',' ) pCol->t.z--; | ||
| 108550 | } | ||
| 108551 | |||
| 108552 | zNew = sqlite3MPrintf(db, "%.*s%s", pCol->t.z-zSql, zSql, zEnd); | ||
| 108553 | sqlite3_result_text(context, zNew, -1, SQLITE_TRANSIENT); | ||
| 108554 | sqlite3_free(zNew); | ||
| 108555 | |||
| 108556 | drop_column_done: | ||
| 108557 | renameParseCleanup(&sParse); | ||
| 108558 | #ifndef SQLITE_OMIT_AUTHORIZATION | ||
| 108559 | db->xAuth = xAuth; | ||
| 108560 | #endif | ||
| 108561 | if( rc!=SQLITE_OK ){ | ||
| 108562 | sqlite3_result_error_code(context, rc); | ||
| 108563 | } | ||
| 108564 | } | ||
| 108565 | |||
| 108566 | /* | ||
| 108567 | ** This function is called by the parser upon parsing an | ||
| 108568 | ** | ||
| 108569 | ** ALTER TABLE pSrc DROP COLUMN pName | ||
| 108570 | ** | ||
| 108571 | ** statement. Argument pSrc contains the possibly qualified name of the | ||
| 108572 | ** table being edited, and token pName the name of the column to drop. | ||
| 108573 | */ | ||
| 108574 | SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token *pName){ | ||
| 108575 | sqlite3 *db = pParse->db; /* Database handle */ | ||
| 108576 | Table *pTab; /* Table to modify */ | ||
| 108577 | int iDb; /* Index of db containing pTab in aDb[] */ | ||
| 108578 | const char *zDb; /* Database containing pTab ("main" etc.) */ | ||
| 108579 | char *zCol = 0; /* Name of column to drop */ | ||
| 108580 | int iCol; /* Index of column zCol in pTab->aCol[] */ | ||
| 108581 | |||
| 108582 | /* Look up the table being altered. */ | ||
| 108583 | assert( pParse->pNewTable==0 ); | ||
| 108584 | assert( sqlite3BtreeHoldsAllMutexes(db) ); | ||
| 108585 | if( NEVER(db->mallocFailed) ) goto exit_drop_column; | ||
| 108586 | pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]); | ||
| 108587 | if( !pTab ) goto exit_drop_column; | ||
| 108588 | |||
| 108589 | /* Make sure this is not an attempt to ALTER a view, virtual table or | ||
| 108590 | ** system table. */ | ||
| 108591 | if( SQLITE_OK!=isAlterableTable(pParse, pTab) ) goto exit_drop_column; | ||
| 108592 | if( SQLITE_OK!=isRealTable(pParse, pTab, 1) ) goto exit_drop_column; | ||
| 108593 | |||
| 108594 | /* Find the index of the column being dropped. */ | ||
| 108595 | zCol = sqlite3NameFromToken(db, pName); | ||
| 108596 | if( zCol==0 ){ | ||
| 108597 | assert( db->mallocFailed ); | ||
| 108598 | goto exit_drop_column; | ||
| 108599 | } | ||
| 108600 | iCol = sqlite3ColumnIndex(pTab, zCol); | ||
| 108601 | if( iCol<0 ){ | ||
| 108602 | sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zCol); | ||
| 108603 | goto exit_drop_column; | ||
| 108604 | } | ||
| 108605 | |||
| 108606 | /* Do not allow the user to drop a PRIMARY KEY column or a column | ||
| 108607 | ** constrained by a UNIQUE constraint. */ | ||
| 108608 | if( pTab->aCol[iCol].colFlags & (COLFLAG_PRIMKEY|COLFLAG_UNIQUE) ){ | ||
| 108609 | sqlite3ErrorMsg(pParse, "cannot drop %s column: \"%s\"", | ||
| 108610 | (pTab->aCol[iCol].colFlags&COLFLAG_PRIMKEY) ? "PRIMARY KEY" : "UNIQUE", | ||
| 108611 | zCol | ||
| 108612 | ); | ||
| 108613 | goto exit_drop_column; | ||
| 108614 | } | ||
| 108615 | |||
| 108616 | /* Do not allow the number of columns to go to zero */ | ||
| 108617 | if( pTab->nCol<=1 ){ | ||
| 108618 | sqlite3ErrorMsg(pParse, "cannot drop column \"%s\": no other columns exist",zCol); | ||
| 108619 | goto exit_drop_column; | ||
| 108620 | } | ||
| 108621 | |||
| 108622 | /* Edit the sqlite_schema table */ | ||
| 108623 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | ||
| 108624 | assert( iDb>=0 ); | ||
| 108625 | zDb = db->aDb[iDb].zDbSName; | ||
| 108626 | renameTestSchema(pParse, zDb, iDb==1, ""); | ||
| 108627 | sqlite3NestedParse(pParse, | ||
| 108628 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " | ||
| 108629 | "sql = sqlite_drop_column(%d, sql, %d) " | ||
| 108630 | "WHERE (type=='table' AND tbl_name=%Q COLLATE nocase)" | ||
| 108631 | , zDb, iDb, iCol, pTab->zName | ||
| 108632 | ); | ||
| 108633 | |||
| 108634 | /* Drop and reload the database schema. */ | ||
| 108635 | renameReloadSchema(pParse, iDb, INITFLAG_AlterDrop); | ||
| 108636 | renameTestSchema(pParse, zDb, iDb==1, "after drop column"); | ||
| 108637 | |||
| 108638 | /* Edit rows of table on disk */ | ||
| 108639 | if( pParse->nErr==0 && (pTab->aCol[iCol].colFlags & COLFLAG_VIRTUAL)==0 ){ | ||
| 108640 | int i; | ||
| 108641 | int addr; | ||
| 108642 | int reg; | ||
| 108643 | int regRec; | ||
| 108644 | Index *pPk = 0; | ||
| 108645 | int nField = 0; /* Number of non-virtual columns after drop */ | ||
| 108646 | int iCur; | ||
| 108647 | Vdbe *v = sqlite3GetVdbe(pParse); | ||
| 108648 | iCur = pParse->nTab++; | ||
| 108649 | sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenWrite); | ||
| 108650 | addr = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v); | ||
| 108651 | reg = ++pParse->nMem; | ||
| 108652 | pParse->nMem += pTab->nCol; | ||
| 108653 | if( HasRowid(pTab) ){ | ||
| 108654 | sqlite3VdbeAddOp2(v, OP_Rowid, iCur, reg); | ||
| 108655 | }else{ | ||
| 108656 | pPk = sqlite3PrimaryKeyIndex(pTab); | ||
| 108657 | } | ||
| 108658 | for(i=0; i<pTab->nCol; i++){ | ||
| 108659 | if( i!=iCol && (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ){ | ||
| 108660 | int regOut; | ||
| 108661 | if( pPk ){ | ||
| 108662 | int iPos = sqlite3TableColumnToIndex(pPk, i); | ||
| 108663 | int iColPos = sqlite3TableColumnToIndex(pPk, iCol); | ||
| 108664 | regOut = reg+1+iPos-(iPos>iColPos); | ||
| 108665 | }else{ | ||
| 108666 | regOut = reg+1+nField; | ||
| 108667 | } | ||
| 108668 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iCur, i, regOut); | ||
| 108669 | nField++; | ||
| 108670 | } | ||
| 108671 | } | ||
| 108672 | regRec = reg + pTab->nCol; | ||
| 108673 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec); | ||
| 108674 | if( pPk ){ | ||
| 108675 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol); | ||
| 108676 | }else{ | ||
| 108677 | sqlite3VdbeAddOp3(v, OP_Insert, iCur, regRec, reg); | ||
| 108678 | } | ||
| 108679 | |||
| 108680 | sqlite3VdbeAddOp2(v, OP_Next, iCur, addr+1); VdbeCoverage(v); | ||
| 108681 | sqlite3VdbeJumpHere(v, addr); | ||
| 108682 | } | ||
| 108683 | |||
| 108684 | exit_drop_column: | ||
| 108685 | sqlite3DbFree(db, zCol); | ||
| 108686 | sqlite3SrcListDelete(db, pSrc); | ||
| 108687 | } | ||
| 108688 | |||
| 108689 | /* | ||
| 108006 | ** Register built-in functions used to help implement ALTER TABLE | 108690 | ** Register built-in functions used to help implement ALTER TABLE |
| 108007 | */ | 108691 | */ |
| 108008 | SQLITE_PRIVATE void sqlite3AlterFunctions(void){ | 108692 | SQLITE_PRIVATE void sqlite3AlterFunctions(void){ |
| 108009 | static FuncDef aAlterTableFuncs[] = { | 108693 | static FuncDef aAlterTableFuncs[] = { |
| 108010 | INTERNAL_FUNCTION(sqlite_rename_column, 9, renameColumnFunc), | 108694 | INTERNAL_FUNCTION(sqlite_rename_column, 9, renameColumnFunc), |
| 108011 | INTERNAL_FUNCTION(sqlite_rename_table, 7, renameTableFunc), | 108695 | INTERNAL_FUNCTION(sqlite_rename_table, 7, renameTableFunc), |
| 108012 | INTERNAL_FUNCTION(sqlite_rename_test, 5, renameTableTest), | 108696 | INTERNAL_FUNCTION(sqlite_rename_test, 6, renameTableTest), |
| 108697 | INTERNAL_FUNCTION(sqlite_drop_column, 3, dropColumnFunc), | ||
| 108013 | }; | 108698 | }; |
| 108014 | sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs)); | 108699 | sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs)); |
| 108015 | } | 108700 | } |
| @@ -110399,6 +111084,62 @@ SQLITE_PRIVATE void sqlite3Attach(Parse *pParse, Expr *p, Expr *pDbname, Expr *p | |||
| 110399 | #endif /* SQLITE_OMIT_ATTACH */ | 111084 | #endif /* SQLITE_OMIT_ATTACH */ |
| 110400 | 111085 | ||
| 110401 | /* | 111086 | /* |
| 111087 | ** Expression callback used by sqlite3FixAAAA() routines. | ||
| 111088 | */ | ||
| 111089 | static int fixExprCb(Walker *p, Expr *pExpr){ | ||
| 111090 | DbFixer *pFix = p->u.pFix; | ||
| 111091 | if( !pFix->bTemp ) ExprSetProperty(pExpr, EP_FromDDL); | ||
| 111092 | if( pExpr->op==TK_VARIABLE ){ | ||
| 111093 | if( pFix->pParse->db->init.busy ){ | ||
| 111094 | pExpr->op = TK_NULL; | ||
| 111095 | }else{ | ||
| 111096 | sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType); | ||
| 111097 | return WRC_Abort; | ||
| 111098 | } | ||
| 111099 | } | ||
| 111100 | return WRC_Continue; | ||
| 111101 | } | ||
| 111102 | |||
| 111103 | /* | ||
| 111104 | ** Select callback used by sqlite3FixAAAA() routines. | ||
| 111105 | */ | ||
| 111106 | static int fixSelectCb(Walker *p, Select *pSelect){ | ||
| 111107 | DbFixer *pFix = p->u.pFix; | ||
| 111108 | int i; | ||
| 111109 | SrcItem *pItem; | ||
| 111110 | sqlite3 *db = pFix->pParse->db; | ||
| 111111 | int iDb = sqlite3FindDbName(db, pFix->zDb); | ||
| 111112 | SrcList *pList = pSelect->pSrc; | ||
| 111113 | |||
| 111114 | if( NEVER(pList==0) ) return WRC_Continue; | ||
| 111115 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ | ||
| 111116 | if( pFix->bTemp==0 ){ | ||
| 111117 | if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){ | ||
| 111118 | sqlite3ErrorMsg(pFix->pParse, | ||
| 111119 | "%s %T cannot reference objects in database %s", | ||
| 111120 | pFix->zType, pFix->pName, pItem->zDatabase); | ||
| 111121 | return WRC_Abort; | ||
| 111122 | } | ||
| 111123 | sqlite3DbFree(db, pItem->zDatabase); | ||
| 111124 | pItem->zDatabase = 0; | ||
| 111125 | pItem->pSchema = pFix->pSchema; | ||
| 111126 | pItem->fg.fromDDL = 1; | ||
| 111127 | } | ||
| 111128 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) | ||
| 111129 | if( sqlite3WalkExpr(&pFix->w, pList->a[i].pOn) ) return WRC_Abort; | ||
| 111130 | #endif | ||
| 111131 | } | ||
| 111132 | if( pSelect->pWith ){ | ||
| 111133 | for(i=0; i<pSelect->pWith->nCte; i++){ | ||
| 111134 | if( sqlite3WalkSelect(p, pSelect->pWith->a[i].pSelect) ){ | ||
| 111135 | return WRC_Abort; | ||
| 111136 | } | ||
| 111137 | } | ||
| 111138 | } | ||
| 111139 | return WRC_Continue; | ||
| 111140 | } | ||
| 111141 | |||
| 111142 | /* | ||
| 110402 | ** Initialize a DbFixer structure. This routine must be called prior | 111143 | ** Initialize a DbFixer structure. This routine must be called prior |
| 110403 | ** to passing the structure to one of the sqliteFixAAAA() routines below. | 111144 | ** to passing the structure to one of the sqliteFixAAAA() routines below. |
| 110404 | */ | 111145 | */ |
| @@ -110409,9 +111150,7 @@ SQLITE_PRIVATE void sqlite3FixInit( | |||
| 110409 | const char *zType, /* "view", "trigger", or "index" */ | 111150 | const char *zType, /* "view", "trigger", or "index" */ |
| 110410 | const Token *pName /* Name of the view, trigger, or index */ | 111151 | const Token *pName /* Name of the view, trigger, or index */ |
| 110411 | ){ | 111152 | ){ |
| 110412 | sqlite3 *db; | 111153 | sqlite3 *db = pParse->db; |
| 110413 | |||
| 110414 | db = pParse->db; | ||
| 110415 | assert( db->nDb>iDb ); | 111154 | assert( db->nDb>iDb ); |
| 110416 | pFix->pParse = pParse; | 111155 | pFix->pParse = pParse; |
| 110417 | pFix->zDb = db->aDb[iDb].zDbSName; | 111156 | pFix->zDb = db->aDb[iDb].zDbSName; |
| @@ -110419,6 +111158,13 @@ SQLITE_PRIVATE void sqlite3FixInit( | |||
| 110419 | pFix->zType = zType; | 111158 | pFix->zType = zType; |
| 110420 | pFix->pName = pName; | 111159 | pFix->pName = pName; |
| 110421 | pFix->bTemp = (iDb==1); | 111160 | pFix->bTemp = (iDb==1); |
| 111161 | pFix->w.pParse = pParse; | ||
| 111162 | pFix->w.xExprCallback = fixExprCb; | ||
| 111163 | pFix->w.xSelectCallback = fixSelectCb; | ||
| 111164 | pFix->w.xSelectCallback2 = 0; | ||
| 111165 | pFix->w.walkerDepth = 0; | ||
| 111166 | pFix->w.eCode = 0; | ||
| 111167 | pFix->w.u.pFix = pFix; | ||
| 110422 | } | 111168 | } |
| 110423 | 111169 | ||
| 110424 | /* | 111170 | /* |
| @@ -110439,115 +111185,27 @@ SQLITE_PRIVATE int sqlite3FixSrcList( | |||
| 110439 | DbFixer *pFix, /* Context of the fixation */ | 111185 | DbFixer *pFix, /* Context of the fixation */ |
| 110440 | SrcList *pList /* The Source list to check and modify */ | 111186 | SrcList *pList /* The Source list to check and modify */ |
| 110441 | ){ | 111187 | ){ |
| 110442 | int i; | 111188 | int res = 0; |
| 110443 | struct SrcList_item *pItem; | 111189 | if( pList ){ |
| 110444 | sqlite3 *db = pFix->pParse->db; | 111190 | Select s; |
| 110445 | int iDb = sqlite3FindDbName(db, pFix->zDb); | 111191 | memset(&s, 0, sizeof(s)); |
| 110446 | 111192 | s.pSrc = pList; | |
| 110447 | if( NEVER(pList==0) ) return 0; | 111193 | res = sqlite3WalkSelect(&pFix->w, &s); |
| 110448 | |||
| 110449 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ | ||
| 110450 | if( pFix->bTemp==0 ){ | ||
| 110451 | if( pItem->zDatabase && iDb!=sqlite3FindDbName(db, pItem->zDatabase) ){ | ||
| 110452 | sqlite3ErrorMsg(pFix->pParse, | ||
| 110453 | "%s %T cannot reference objects in database %s", | ||
| 110454 | pFix->zType, pFix->pName, pItem->zDatabase); | ||
| 110455 | return 1; | ||
| 110456 | } | ||
| 110457 | sqlite3DbFree(db, pItem->zDatabase); | ||
| 110458 | pItem->zDatabase = 0; | ||
| 110459 | pItem->pSchema = pFix->pSchema; | ||
| 110460 | pItem->fg.fromDDL = 1; | ||
| 110461 | } | ||
| 110462 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) | ||
| 110463 | if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1; | ||
| 110464 | if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1; | ||
| 110465 | #endif | ||
| 110466 | if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){ | ||
| 110467 | return 1; | ||
| 110468 | } | ||
| 110469 | } | 111194 | } |
| 110470 | return 0; | 111195 | return res; |
| 110471 | } | 111196 | } |
| 110472 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) | 111197 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) |
| 110473 | SQLITE_PRIVATE int sqlite3FixSelect( | 111198 | SQLITE_PRIVATE int sqlite3FixSelect( |
| 110474 | DbFixer *pFix, /* Context of the fixation */ | 111199 | DbFixer *pFix, /* Context of the fixation */ |
| 110475 | Select *pSelect /* The SELECT statement to be fixed to one database */ | 111200 | Select *pSelect /* The SELECT statement to be fixed to one database */ |
| 110476 | ){ | 111201 | ){ |
| 110477 | while( pSelect ){ | 111202 | return sqlite3WalkSelect(&pFix->w, pSelect); |
| 110478 | if( sqlite3FixExprList(pFix, pSelect->pEList) ){ | ||
| 110479 | return 1; | ||
| 110480 | } | ||
| 110481 | if( sqlite3FixSrcList(pFix, pSelect->pSrc) ){ | ||
| 110482 | return 1; | ||
| 110483 | } | ||
| 110484 | if( sqlite3FixExpr(pFix, pSelect->pWhere) ){ | ||
| 110485 | return 1; | ||
| 110486 | } | ||
| 110487 | if( sqlite3FixExprList(pFix, pSelect->pGroupBy) ){ | ||
| 110488 | return 1; | ||
| 110489 | } | ||
| 110490 | if( sqlite3FixExpr(pFix, pSelect->pHaving) ){ | ||
| 110491 | return 1; | ||
| 110492 | } | ||
| 110493 | if( sqlite3FixExprList(pFix, pSelect->pOrderBy) ){ | ||
| 110494 | return 1; | ||
| 110495 | } | ||
| 110496 | if( sqlite3FixExpr(pFix, pSelect->pLimit) ){ | ||
| 110497 | return 1; | ||
| 110498 | } | ||
| 110499 | if( pSelect->pWith ){ | ||
| 110500 | int i; | ||
| 110501 | for(i=0; i<pSelect->pWith->nCte; i++){ | ||
| 110502 | if( sqlite3FixSelect(pFix, pSelect->pWith->a[i].pSelect) ){ | ||
| 110503 | return 1; | ||
| 110504 | } | ||
| 110505 | } | ||
| 110506 | } | ||
| 110507 | pSelect = pSelect->pPrior; | ||
| 110508 | } | ||
| 110509 | return 0; | ||
| 110510 | } | 111203 | } |
| 110511 | SQLITE_PRIVATE int sqlite3FixExpr( | 111204 | SQLITE_PRIVATE int sqlite3FixExpr( |
| 110512 | DbFixer *pFix, /* Context of the fixation */ | 111205 | DbFixer *pFix, /* Context of the fixation */ |
| 110513 | Expr *pExpr /* The expression to be fixed to one database */ | 111206 | Expr *pExpr /* The expression to be fixed to one database */ |
| 110514 | ){ | 111207 | ){ |
| 110515 | while( pExpr ){ | 111208 | return sqlite3WalkExpr(&pFix->w, pExpr); |
| 110516 | if( !pFix->bTemp ) ExprSetProperty(pExpr, EP_FromDDL); | ||
| 110517 | if( pExpr->op==TK_VARIABLE ){ | ||
| 110518 | if( pFix->pParse->db->init.busy ){ | ||
| 110519 | pExpr->op = TK_NULL; | ||
| 110520 | }else{ | ||
| 110521 | sqlite3ErrorMsg(pFix->pParse, "%s cannot use variables", pFix->zType); | ||
| 110522 | return 1; | ||
| 110523 | } | ||
| 110524 | } | ||
| 110525 | if( ExprHasProperty(pExpr, EP_TokenOnly|EP_Leaf) ) break; | ||
| 110526 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | ||
| 110527 | if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1; | ||
| 110528 | }else{ | ||
| 110529 | if( sqlite3FixExprList(pFix, pExpr->x.pList) ) return 1; | ||
| 110530 | } | ||
| 110531 | if( sqlite3FixExpr(pFix, pExpr->pRight) ){ | ||
| 110532 | return 1; | ||
| 110533 | } | ||
| 110534 | pExpr = pExpr->pLeft; | ||
| 110535 | } | ||
| 110536 | return 0; | ||
| 110537 | } | ||
| 110538 | SQLITE_PRIVATE int sqlite3FixExprList( | ||
| 110539 | DbFixer *pFix, /* Context of the fixation */ | ||
| 110540 | ExprList *pList /* The expression to be fixed to one database */ | ||
| 110541 | ){ | ||
| 110542 | int i; | ||
| 110543 | struct ExprList_item *pItem; | ||
| 110544 | if( pList==0 ) return 0; | ||
| 110545 | for(i=0, pItem=pList->a; i<pList->nExpr; i++, pItem++){ | ||
| 110546 | if( sqlite3FixExpr(pFix, pItem->pExpr) ){ | ||
| 110547 | return 1; | ||
| 110548 | } | ||
| 110549 | } | ||
| 110550 | return 0; | ||
| 110551 | } | 111209 | } |
| 110552 | #endif | 111210 | #endif |
| 110553 | 111211 | ||
| @@ -110557,25 +111215,20 @@ SQLITE_PRIVATE int sqlite3FixTriggerStep( | |||
| 110557 | TriggerStep *pStep /* The trigger step be fixed to one database */ | 111215 | TriggerStep *pStep /* The trigger step be fixed to one database */ |
| 110558 | ){ | 111216 | ){ |
| 110559 | while( pStep ){ | 111217 | while( pStep ){ |
| 110560 | if( sqlite3FixSelect(pFix, pStep->pSelect) ){ | 111218 | if( sqlite3WalkSelect(&pFix->w, pStep->pSelect) |
| 110561 | return 1; | 111219 | || sqlite3WalkExpr(&pFix->w, pStep->pWhere) |
| 110562 | } | 111220 | || sqlite3WalkExprList(&pFix->w, pStep->pExprList) |
| 110563 | if( sqlite3FixExpr(pFix, pStep->pWhere) ){ | 111221 | || sqlite3FixSrcList(pFix, pStep->pFrom) |
| 110564 | return 1; | 111222 | ){ |
| 110565 | } | ||
| 110566 | if( sqlite3FixExprList(pFix, pStep->pExprList) ){ | ||
| 110567 | return 1; | ||
| 110568 | } | ||
| 110569 | if( pStep->pFrom && sqlite3FixSrcList(pFix, pStep->pFrom) ){ | ||
| 110570 | return 1; | 111223 | return 1; |
| 110571 | } | 111224 | } |
| 110572 | #ifndef SQLITE_OMIT_UPSERT | 111225 | #ifndef SQLITE_OMIT_UPSERT |
| 110573 | if( pStep->pUpsert ){ | 111226 | if( pStep->pUpsert ){ |
| 110574 | Upsert *pUp = pStep->pUpsert; | 111227 | Upsert *pUp = pStep->pUpsert; |
| 110575 | if( sqlite3FixExprList(pFix, pUp->pUpsertTarget) | 111228 | if( sqlite3WalkExprList(&pFix->w, pUp->pUpsertTarget) |
| 110576 | || sqlite3FixExpr(pFix, pUp->pUpsertTargetWhere) | 111229 | || sqlite3WalkExpr(&pFix->w, pUp->pUpsertTargetWhere) |
| 110577 | || sqlite3FixExprList(pFix, pUp->pUpsertSet) | 111230 | || sqlite3WalkExprList(&pFix->w, pUp->pUpsertSet) |
| 110578 | || sqlite3FixExpr(pFix, pUp->pUpsertWhere) | 111231 | || sqlite3WalkExpr(&pFix->w, pUp->pUpsertWhere) |
| 110579 | ){ | 111232 | ){ |
| 110580 | return 1; | 111233 | return 1; |
| 110581 | } | 111234 | } |
| @@ -110583,6 +111236,7 @@ SQLITE_PRIVATE int sqlite3FixTriggerStep( | |||
| 110583 | #endif | 111236 | #endif |
| 110584 | pStep = pStep->pNext; | 111237 | pStep = pStep->pNext; |
| 110585 | } | 111238 | } |
| 111239 | |||
| 110586 | return 0; | 111240 | return 0; |
| 110587 | } | 111241 | } |
| 110588 | #endif | 111242 | #endif |
| @@ -110734,7 +111388,6 @@ SQLITE_PRIVATE void sqlite3AuthRead( | |||
| 110734 | Schema *pSchema, /* The schema of the expression */ | 111388 | Schema *pSchema, /* The schema of the expression */ |
| 110735 | SrcList *pTabList /* All table that pExpr might refer to */ | 111389 | SrcList *pTabList /* All table that pExpr might refer to */ |
| 110736 | ){ | 111390 | ){ |
| 110737 | sqlite3 *db = pParse->db; | ||
| 110738 | Table *pTab = 0; /* The table being read */ | 111391 | Table *pTab = 0; /* The table being read */ |
| 110739 | const char *zCol; /* Name of the column of the table */ | 111392 | const char *zCol; /* Name of the column of the table */ |
| 110740 | int iSrc; /* Index in pTabList->a[] of table being read */ | 111393 | int iSrc; /* Index in pTabList->a[] of table being read */ |
| @@ -110742,8 +111395,8 @@ SQLITE_PRIVATE void sqlite3AuthRead( | |||
| 110742 | int iCol; /* Index of column in table */ | 111395 | int iCol; /* Index of column in table */ |
| 110743 | 111396 | ||
| 110744 | assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER ); | 111397 | assert( pExpr->op==TK_COLUMN || pExpr->op==TK_TRIGGER ); |
| 110745 | assert( !IN_RENAME_OBJECT || db->xAuth==0 ); | 111398 | assert( !IN_RENAME_OBJECT ); |
| 110746 | if( db->xAuth==0 ) return; | 111399 | assert( pParse->db->xAuth!=0 ); |
| 110747 | iDb = sqlite3SchemaToIndex(pParse->db, pSchema); | 111400 | iDb = sqlite3SchemaToIndex(pParse->db, pSchema); |
| 110748 | if( iDb<0 ){ | 111401 | if( iDb<0 ){ |
| 110749 | /* An attempt to read a column out of a subquery or other | 111402 | /* An attempt to read a column out of a subquery or other |
| @@ -110755,7 +111408,7 @@ SQLITE_PRIVATE void sqlite3AuthRead( | |||
| 110755 | pTab = pParse->pTriggerTab; | 111408 | pTab = pParse->pTriggerTab; |
| 110756 | }else{ | 111409 | }else{ |
| 110757 | assert( pTabList ); | 111410 | assert( pTabList ); |
| 110758 | for(iSrc=0; ALWAYS(iSrc<pTabList->nSrc); iSrc++){ | 111411 | for(iSrc=0; iSrc<pTabList->nSrc; iSrc++){ |
| 110759 | if( pExpr->iTable==pTabList->a[iSrc].iCursor ){ | 111412 | if( pExpr->iTable==pTabList->a[iSrc].iCursor ){ |
| 110760 | pTab = pTabList->a[iSrc].pTab; | 111413 | pTab = pTabList->a[iSrc].pTab; |
| 110761 | break; | 111414 | break; |
| @@ -110763,7 +111416,7 @@ SQLITE_PRIVATE void sqlite3AuthRead( | |||
| 110763 | } | 111416 | } |
| 110764 | } | 111417 | } |
| 110765 | iCol = pExpr->iColumn; | 111418 | iCol = pExpr->iColumn; |
| 110766 | if( NEVER(pTab==0) ) return; | 111419 | if( pTab==0 ) return; |
| 110767 | 111420 | ||
| 110768 | if( iCol>=0 ){ | 111421 | if( iCol>=0 ){ |
| 110769 | assert( iCol<pTab->nCol ); | 111422 | assert( iCol<pTab->nCol ); |
| @@ -110774,7 +111427,7 @@ SQLITE_PRIVATE void sqlite3AuthRead( | |||
| 110774 | }else{ | 111427 | }else{ |
| 110775 | zCol = "ROWID"; | 111428 | zCol = "ROWID"; |
| 110776 | } | 111429 | } |
| 110777 | assert( iDb>=0 && iDb<db->nDb ); | 111430 | assert( iDb>=0 && iDb<pParse->db->nDb ); |
| 110778 | if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){ | 111431 | if( SQLITE_IGNORE==sqlite3AuthReadCol(pParse, pTab->zName, zCol, iDb) ){ |
| 110779 | pExpr->op = TK_NULL; | 111432 | pExpr->op = TK_NULL; |
| 110780 | } | 111433 | } |
| @@ -110800,11 +111453,7 @@ SQLITE_PRIVATE int sqlite3AuthCheck( | |||
| 110800 | ** or if the parser is being invoked from within sqlite3_declare_vtab. | 111453 | ** or if the parser is being invoked from within sqlite3_declare_vtab. |
| 110801 | */ | 111454 | */ |
| 110802 | assert( !IN_RENAME_OBJECT || db->xAuth==0 ); | 111455 | assert( !IN_RENAME_OBJECT || db->xAuth==0 ); |
| 110803 | if( db->init.busy || IN_SPECIAL_PARSE ){ | 111456 | if( db->xAuth==0 || db->init.busy || IN_SPECIAL_PARSE ){ |
| 110804 | return SQLITE_OK; | ||
| 110805 | } | ||
| 110806 | |||
| 110807 | if( db->xAuth==0 ){ | ||
| 110808 | return SQLITE_OK; | 111457 | return SQLITE_OK; |
| 110809 | } | 111458 | } |
| 110810 | 111459 | ||
| @@ -111010,10 +111659,36 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ | |||
| 111010 | /* Begin by generating some termination code at the end of the | 111659 | /* Begin by generating some termination code at the end of the |
| 111011 | ** vdbe program | 111660 | ** vdbe program |
| 111012 | */ | 111661 | */ |
| 111013 | v = sqlite3GetVdbe(pParse); | 111662 | v = pParse->pVdbe; |
| 111663 | if( v==0 ){ | ||
| 111664 | if( db->init.busy ){ | ||
| 111665 | pParse->rc = SQLITE_DONE; | ||
| 111666 | return; | ||
| 111667 | } | ||
| 111668 | v = sqlite3GetVdbe(pParse); | ||
| 111669 | if( v==0 ) pParse->rc = SQLITE_ERROR; | ||
| 111670 | } | ||
| 111014 | assert( !pParse->isMultiWrite | 111671 | assert( !pParse->isMultiWrite |
| 111015 | || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort)); | 111672 | || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort)); |
| 111016 | if( v ){ | 111673 | if( v ){ |
| 111674 | if( pParse->bReturning ){ | ||
| 111675 | Returning *pReturning = pParse->u1.pReturning; | ||
| 111676 | int addrRewind; | ||
| 111677 | int i; | ||
| 111678 | int reg; | ||
| 111679 | |||
| 111680 | addrRewind = | ||
| 111681 | sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur); | ||
| 111682 | VdbeCoverage(v); | ||
| 111683 | reg = pReturning->iRetReg; | ||
| 111684 | for(i=0; i<pReturning->nRetCol; i++){ | ||
| 111685 | sqlite3VdbeAddOp3(v, OP_Column, pReturning->iRetCur, i, reg+i); | ||
| 111686 | } | ||
| 111687 | sqlite3VdbeAddOp2(v, OP_ResultRow, reg, i); | ||
| 111688 | sqlite3VdbeAddOp2(v, OP_Next, pReturning->iRetCur, addrRewind+1); | ||
| 111689 | VdbeCoverage(v); | ||
| 111690 | sqlite3VdbeJumpHere(v, addrRewind); | ||
| 111691 | } | ||
| 111017 | sqlite3VdbeAddOp0(v, OP_Halt); | 111692 | sqlite3VdbeAddOp0(v, OP_Halt); |
| 111018 | 111693 | ||
| 111019 | #if SQLITE_USER_AUTHENTICATION | 111694 | #if SQLITE_USER_AUTHENTICATION |
| @@ -111091,12 +111766,16 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ | |||
| 111091 | } | 111766 | } |
| 111092 | } | 111767 | } |
| 111093 | 111768 | ||
| 111769 | if( pParse->bReturning ){ | ||
| 111770 | Returning *pRet = pParse->u1.pReturning; | ||
| 111771 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol); | ||
| 111772 | } | ||
| 111773 | |||
| 111094 | /* Finally, jump back to the beginning of the executable code. */ | 111774 | /* Finally, jump back to the beginning of the executable code. */ |
| 111095 | sqlite3VdbeGoto(v, 1); | 111775 | sqlite3VdbeGoto(v, 1); |
| 111096 | } | 111776 | } |
| 111097 | } | 111777 | } |
| 111098 | 111778 | ||
| 111099 | |||
| 111100 | /* Get the VDBE program ready for execution | 111779 | /* Get the VDBE program ready for execution |
| 111101 | */ | 111780 | */ |
| 111102 | if( v && pParse->nErr==0 && !db->mallocFailed ){ | 111781 | if( v && pParse->nErr==0 && !db->mallocFailed ){ |
| @@ -111315,7 +111994,7 @@ SQLITE_PRIVATE Table *sqlite3LocateTable( | |||
| 111315 | SQLITE_PRIVATE Table *sqlite3LocateTableItem( | 111994 | SQLITE_PRIVATE Table *sqlite3LocateTableItem( |
| 111316 | Parse *pParse, | 111995 | Parse *pParse, |
| 111317 | u32 flags, | 111996 | u32 flags, |
| 111318 | struct SrcList_item *p | 111997 | SrcItem *p |
| 111319 | ){ | 111998 | ){ |
| 111320 | const char *zDb; | 111999 | const char *zDb; |
| 111321 | assert( p->pSchema==0 || p->zDatabase==0 ); | 112000 | assert( p->pSchema==0 || p->zDatabase==0 ); |
| @@ -112073,7 +112752,8 @@ SQLITE_PRIVATE void sqlite3StartTable( | |||
| 112073 | }else | 112752 | }else |
| 112074 | #endif | 112753 | #endif |
| 112075 | { | 112754 | { |
| 112076 | pParse->addrCrTab = | 112755 | assert( !pParse->bReturning ); |
| 112756 | pParse->u1.addrCrTab = | ||
| 112077 | sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY); | 112757 | sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY); |
| 112078 | } | 112758 | } |
| 112079 | sqlite3OpenSchemaTable(pParse, iDb); | 112759 | sqlite3OpenSchemaTable(pParse, iDb); |
| @@ -112100,12 +112780,85 @@ begin_table_error: | |||
| 112100 | SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ | 112780 | SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ |
| 112101 | if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){ | 112781 | if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){ |
| 112102 | pCol->colFlags |= COLFLAG_HIDDEN; | 112782 | pCol->colFlags |= COLFLAG_HIDDEN; |
| 112783 | if( pTab ) pTab->tabFlags |= TF_HasHidden; | ||
| 112103 | }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){ | 112784 | }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){ |
| 112104 | pTab->tabFlags |= TF_OOOHidden; | 112785 | pTab->tabFlags |= TF_OOOHidden; |
| 112105 | } | 112786 | } |
| 112106 | } | 112787 | } |
| 112107 | #endif | 112788 | #endif |
| 112108 | 112789 | ||
| 112790 | /* | ||
| 112791 | ** Name of the special TEMP trigger used to implement RETURNING. The | ||
| 112792 | ** name begins with "sqlite_" so that it is guaranteed not to collide | ||
| 112793 | ** with any application-generated triggers. | ||
| 112794 | */ | ||
| 112795 | #define RETURNING_TRIGGER_NAME "sqlite_returning" | ||
| 112796 | |||
| 112797 | /* | ||
| 112798 | ** Clean up the data structures associated with the RETURNING clause. | ||
| 112799 | */ | ||
| 112800 | static void sqlite3DeleteReturning(sqlite3 *db, Returning *pRet){ | ||
| 112801 | Hash *pHash; | ||
| 112802 | pHash = &(db->aDb[1].pSchema->trigHash); | ||
| 112803 | sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, 0); | ||
| 112804 | sqlite3ExprListDelete(db, pRet->pReturnEL); | ||
| 112805 | sqlite3DbFree(db, pRet); | ||
| 112806 | } | ||
| 112807 | |||
| 112808 | /* | ||
| 112809 | ** Add the RETURNING clause to the parse currently underway. | ||
| 112810 | ** | ||
| 112811 | ** This routine creates a special TEMP trigger that will fire for each row | ||
| 112812 | ** of the DML statement. That TEMP trigger contains a single SELECT | ||
| 112813 | ** statement with a result set that is the argument of the RETURNING clause. | ||
| 112814 | ** The trigger has the Trigger.bReturning flag and an opcode of | ||
| 112815 | ** TK_RETURNING instead of TK_SELECT, so that the trigger code generator | ||
| 112816 | ** knows to handle it specially. The TEMP trigger is automatically | ||
| 112817 | ** removed at the end of the parse. | ||
| 112818 | ** | ||
| 112819 | ** When this routine is called, we do not yet know if the RETURNING clause | ||
| 112820 | ** is attached to a DELETE, INSERT, or UPDATE, so construct it as a | ||
| 112821 | ** RETURNING trigger instead. It will then be converted into the appropriate | ||
| 112822 | ** type on the first call to sqlite3TriggersExist(). | ||
| 112823 | */ | ||
| 112824 | SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ | ||
| 112825 | Returning *pRet; | ||
| 112826 | Hash *pHash; | ||
| 112827 | sqlite3 *db = pParse->db; | ||
| 112828 | if( pParse->pNewTrigger ){ | ||
| 112829 | sqlite3ErrorMsg(pParse, "cannot use RETURNING in a trigger"); | ||
| 112830 | }else{ | ||
| 112831 | assert( pParse->bReturning==0 ); | ||
| 112832 | } | ||
| 112833 | pParse->bReturning = 1; | ||
| 112834 | pRet = sqlite3DbMallocZero(db, sizeof(*pRet)); | ||
| 112835 | if( pRet==0 ){ | ||
| 112836 | sqlite3ExprListDelete(db, pList); | ||
| 112837 | return; | ||
| 112838 | } | ||
| 112839 | pParse->u1.pReturning = pRet; | ||
| 112840 | pRet->pParse = pParse; | ||
| 112841 | pRet->pReturnEL = pList; | ||
| 112842 | sqlite3ParserAddCleanup(pParse, | ||
| 112843 | (void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet); | ||
| 112844 | testcase( pParse->earlyCleanup ); | ||
| 112845 | if( db->mallocFailed ) return; | ||
| 112846 | pRet->retTrig.zName = RETURNING_TRIGGER_NAME; | ||
| 112847 | pRet->retTrig.op = TK_RETURNING; | ||
| 112848 | pRet->retTrig.tr_tm = TRIGGER_AFTER; | ||
| 112849 | pRet->retTrig.bReturning = 1; | ||
| 112850 | pRet->retTrig.pSchema = db->aDb[1].pSchema; | ||
| 112851 | pRet->retTrig.step_list = &pRet->retTStep; | ||
| 112852 | pRet->retTStep.op = TK_RETURNING; | ||
| 112853 | pRet->retTStep.pTrig = &pRet->retTrig; | ||
| 112854 | pRet->retTStep.pExprList = pList; | ||
| 112855 | pHash = &(db->aDb[1].pSchema->trigHash); | ||
| 112856 | assert( sqlite3HashFind(pHash, RETURNING_TRIGGER_NAME)==0 || pParse->nErr ); | ||
| 112857 | if( sqlite3HashInsert(pHash, RETURNING_TRIGGER_NAME, &pRet->retTrig) | ||
| 112858 | ==&pRet->retTrig ){ | ||
| 112859 | sqlite3OomFault(db); | ||
| 112860 | } | ||
| 112861 | } | ||
| 112109 | 112862 | ||
| 112110 | /* | 112863 | /* |
| 112111 | ** Add a new column to the table currently being constructed. | 112864 | ** Add a new column to the table currently being constructed. |
| @@ -112122,6 +112875,8 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){ | |||
| 112122 | char *zType; | 112875 | char *zType; |
| 112123 | Column *pCol; | 112876 | Column *pCol; |
| 112124 | sqlite3 *db = pParse->db; | 112877 | sqlite3 *db = pParse->db; |
| 112878 | u8 hName; | ||
| 112879 | |||
| 112125 | if( (p = pParse->pNewTable)==0 ) return; | 112880 | if( (p = pParse->pNewTable)==0 ) return; |
| 112126 | if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){ | 112881 | if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){ |
| 112127 | sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName); | 112882 | sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName); |
| @@ -112133,8 +112888,9 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){ | |||
| 112133 | memcpy(z, pName->z, pName->n); | 112888 | memcpy(z, pName->z, pName->n); |
| 112134 | z[pName->n] = 0; | 112889 | z[pName->n] = 0; |
| 112135 | sqlite3Dequote(z); | 112890 | sqlite3Dequote(z); |
| 112891 | hName = sqlite3StrIHash(z); | ||
| 112136 | for(i=0; i<p->nCol; i++){ | 112892 | for(i=0; i<p->nCol; i++){ |
| 112137 | if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){ | 112893 | if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zName)==0 ){ |
| 112138 | sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); | 112894 | sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); |
| 112139 | sqlite3DbFree(db, z); | 112895 | sqlite3DbFree(db, z); |
| 112140 | return; | 112896 | return; |
| @@ -112152,7 +112908,7 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){ | |||
| 112152 | pCol = &p->aCol[p->nCol]; | 112908 | pCol = &p->aCol[p->nCol]; |
| 112153 | memset(pCol, 0, sizeof(p->aCol[0])); | 112909 | memset(pCol, 0, sizeof(p->aCol[0])); |
| 112154 | pCol->zName = z; | 112910 | pCol->zName = z; |
| 112155 | pCol->hName = sqlite3StrIHash(z); | 112911 | pCol->hName = hName; |
| 112156 | sqlite3ColumnPropertiesFromName(p, pCol); | 112912 | sqlite3ColumnPropertiesFromName(p, pCol); |
| 112157 | 112913 | ||
| 112158 | if( pType->n==0 ){ | 112914 | if( pType->n==0 ){ |
| @@ -112935,9 +113691,10 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ | |||
| 112935 | /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY | 113691 | /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY |
| 112936 | ** into BTREE_BLOBKEY. | 113692 | ** into BTREE_BLOBKEY. |
| 112937 | */ | 113693 | */ |
| 112938 | if( pParse->addrCrTab ){ | 113694 | assert( !pParse->bReturning ); |
| 113695 | if( pParse->u1.addrCrTab ){ | ||
| 112939 | assert( v ); | 113696 | assert( v ); |
| 112940 | sqlite3VdbeChangeP3(v, pParse->addrCrTab, BTREE_BLOBKEY); | 113697 | sqlite3VdbeChangeP3(v, pParse->u1.addrCrTab, BTREE_BLOBKEY); |
| 112941 | } | 113698 | } |
| 112942 | 113699 | ||
| 112943 | /* Locate the PRIMARY KEY index. Or, if this table was originally | 113700 | /* Locate the PRIMARY KEY index. Or, if this table was originally |
| @@ -113401,7 +114158,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 113401 | 114158 | ||
| 113402 | /* Reparse everything to update our internal data structures */ | 114159 | /* Reparse everything to update our internal data structures */ |
| 113403 | sqlite3VdbeAddParseSchemaOp(v, iDb, | 114160 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 113404 | sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName)); | 114161 | sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName),0); |
| 113405 | } | 114162 | } |
| 113406 | 114163 | ||
| 113407 | /* Add the table to the in-memory representation of the database. | 114164 | /* Add the table to the in-memory representation of the database. |
| @@ -113418,20 +114175,17 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 113418 | } | 114175 | } |
| 113419 | pParse->pNewTable = 0; | 114176 | pParse->pNewTable = 0; |
| 113420 | db->mDbFlags |= DBFLAG_SchemaChange; | 114177 | db->mDbFlags |= DBFLAG_SchemaChange; |
| 114178 | } | ||
| 113421 | 114179 | ||
| 113422 | #ifndef SQLITE_OMIT_ALTERTABLE | 114180 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 113423 | if( !p->pSelect ){ | 114181 | if( !pSelect && !p->pSelect ){ |
| 113424 | const char *zName = (const char *)pParse->sNameToken.z; | 114182 | assert( pCons && pEnd ); |
| 113425 | int nName; | 114183 | if( pCons->z==0 ){ |
| 113426 | assert( !pSelect && pCons && pEnd ); | 114184 | pCons = pEnd; |
| 113427 | if( pCons->z==0 ){ | ||
| 113428 | pCons = pEnd; | ||
| 113429 | } | ||
| 113430 | nName = (int)((const char *)pCons->z - zName); | ||
| 113431 | p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName); | ||
| 113432 | } | 114185 | } |
| 113433 | #endif | 114186 | p->addColOffset = 13 + (int)(pCons->z - pParse->sNameToken.z); |
| 113434 | } | 114187 | } |
| 114188 | #endif | ||
| 113435 | } | 114189 | } |
| 113436 | 114190 | ||
| 113437 | #ifndef SQLITE_OMIT_VIEW | 114191 | #ifndef SQLITE_OMIT_VIEW |
| @@ -113622,6 +114376,7 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ | |||
| 113622 | assert( pTable->aCol==0 ); | 114376 | assert( pTable->aCol==0 ); |
| 113623 | pTable->nCol = pSelTab->nCol; | 114377 | pTable->nCol = pSelTab->nCol; |
| 113624 | pTable->aCol = pSelTab->aCol; | 114378 | pTable->aCol = pSelTab->aCol; |
| 114379 | pTable->tabFlags |= (pSelTab->tabFlags & COLFLAG_NOINSERT); | ||
| 113625 | pSelTab->nCol = 0; | 114380 | pSelTab->nCol = 0; |
| 113626 | pSelTab->aCol = 0; | 114381 | pSelTab->aCol = 0; |
| 113627 | assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); | 114382 | assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); |
| @@ -114889,7 +115644,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 114889 | sqlite3RefillIndex(pParse, pIndex, iMem); | 115644 | sqlite3RefillIndex(pParse, pIndex, iMem); |
| 114890 | sqlite3ChangeCookie(pParse, iDb); | 115645 | sqlite3ChangeCookie(pParse, iDb); |
| 114891 | sqlite3VdbeAddParseSchemaOp(v, iDb, | 115646 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 114892 | sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName)); | 115647 | sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName), 0); |
| 114893 | sqlite3VdbeAddOp2(v, OP_Expire, 0, 1); | 115648 | sqlite3VdbeAddOp2(v, OP_Expire, 0, 1); |
| 114894 | } | 115649 | } |
| 114895 | 115650 | ||
| @@ -115282,7 +116037,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppend( | |||
| 115282 | Token *pTable, /* Table to append */ | 116037 | Token *pTable, /* Table to append */ |
| 115283 | Token *pDatabase /* Database of the table */ | 116038 | Token *pDatabase /* Database of the table */ |
| 115284 | ){ | 116039 | ){ |
| 115285 | struct SrcList_item *pItem; | 116040 | SrcItem *pItem; |
| 115286 | sqlite3 *db; | 116041 | sqlite3 *db; |
| 115287 | assert( pDatabase==0 || pTable!=0 ); /* Cannot have C without B */ | 116042 | assert( pDatabase==0 || pTable!=0 ); /* Cannot have C without B */ |
| 115288 | assert( pParse!=0 ); | 116043 | assert( pParse!=0 ); |
| @@ -115323,7 +116078,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppend( | |||
| 115323 | */ | 116078 | */ |
| 115324 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ | 116079 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ |
| 115325 | int i; | 116080 | int i; |
| 115326 | struct SrcList_item *pItem; | 116081 | SrcItem *pItem; |
| 115327 | assert(pList || pParse->db->mallocFailed ); | 116082 | assert(pList || pParse->db->mallocFailed ); |
| 115328 | if( pList ){ | 116083 | if( pList ){ |
| 115329 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ | 116084 | for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){ |
| @@ -115341,7 +116096,7 @@ SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){ | |||
| 115341 | */ | 116096 | */ |
| 115342 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ | 116097 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){ |
| 115343 | int i; | 116098 | int i; |
| 115344 | struct SrcList_item *pItem; | 116099 | SrcItem *pItem; |
| 115345 | if( pList==0 ) return; | 116100 | if( pList==0 ) return; |
| 115346 | for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){ | 116101 | for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){ |
| 115347 | if( pItem->zDatabase ) sqlite3DbFreeNN(db, pItem->zDatabase); | 116102 | if( pItem->zDatabase ) sqlite3DbFreeNN(db, pItem->zDatabase); |
| @@ -115383,7 +116138,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm( | |||
| 115383 | Expr *pOn, /* The ON clause of a join */ | 116138 | Expr *pOn, /* The ON clause of a join */ |
| 115384 | IdList *pUsing /* The USING clause of a join */ | 116139 | IdList *pUsing /* The USING clause of a join */ |
| 115385 | ){ | 116140 | ){ |
| 115386 | struct SrcList_item *pItem; | 116141 | SrcItem *pItem; |
| 115387 | sqlite3 *db = pParse->db; | 116142 | sqlite3 *db = pParse->db; |
| 115388 | if( !p && (pOn || pUsing) ){ | 116143 | if( !p && (pOn || pUsing) ){ |
| 115389 | sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", | 116144 | sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", |
| @@ -115427,7 +116182,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm( | |||
| 115427 | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){ | 116182 | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){ |
| 115428 | assert( pIndexedBy!=0 ); | 116183 | assert( pIndexedBy!=0 ); |
| 115429 | if( p && pIndexedBy->n>0 ){ | 116184 | if( p && pIndexedBy->n>0 ){ |
| 115430 | struct SrcList_item *pItem; | 116185 | SrcItem *pItem; |
| 115431 | assert( p->nSrc>0 ); | 116186 | assert( p->nSrc>0 ); |
| 115432 | pItem = &p->a[p->nSrc-1]; | 116187 | pItem = &p->a[p->nSrc-1]; |
| 115433 | assert( pItem->fg.notIndexed==0 ); | 116188 | assert( pItem->fg.notIndexed==0 ); |
| @@ -115457,7 +116212,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, Src | |||
| 115457 | sqlite3SrcListDelete(pParse->db, p2); | 116212 | sqlite3SrcListDelete(pParse->db, p2); |
| 115458 | }else{ | 116213 | }else{ |
| 115459 | p1 = pNew; | 116214 | p1 = pNew; |
| 115460 | memcpy(&p1->a[1], p2->a, p2->nSrc*sizeof(struct SrcList_item)); | 116215 | memcpy(&p1->a[1], p2->a, p2->nSrc*sizeof(SrcItem)); |
| 115461 | sqlite3DbFree(pParse->db, p2); | 116216 | sqlite3DbFree(pParse->db, p2); |
| 115462 | } | 116217 | } |
| 115463 | } | 116218 | } |
| @@ -115470,7 +116225,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, Src | |||
| 115470 | */ | 116225 | */ |
| 115471 | SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){ | 116226 | SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){ |
| 115472 | if( p ){ | 116227 | if( p ){ |
| 115473 | struct SrcList_item *pItem = &p->a[p->nSrc-1]; | 116228 | SrcItem *pItem = &p->a[p->nSrc-1]; |
| 115474 | assert( pItem->fg.notIndexed==0 ); | 116229 | assert( pItem->fg.notIndexed==0 ); |
| 115475 | assert( pItem->fg.isIndexedBy==0 ); | 116230 | assert( pItem->fg.isIndexedBy==0 ); |
| 115476 | assert( pItem->fg.isTabFunc==0 ); | 116231 | assert( pItem->fg.isTabFunc==0 ); |
| @@ -115625,7 +116380,7 @@ SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *pParse){ | |||
| 115625 | static void sqlite3CodeVerifySchemaAtToplevel(Parse *pToplevel, int iDb){ | 116380 | static void sqlite3CodeVerifySchemaAtToplevel(Parse *pToplevel, int iDb){ |
| 115626 | assert( iDb>=0 && iDb<pToplevel->db->nDb ); | 116381 | assert( iDb>=0 && iDb<pToplevel->db->nDb ); |
| 115627 | assert( pToplevel->db->aDb[iDb].pBt!=0 || iDb==1 ); | 116382 | assert( pToplevel->db->aDb[iDb].pBt!=0 || iDb==1 ); |
| 115628 | assert( iDb<SQLITE_MAX_ATTACHED+2 ); | 116383 | assert( iDb<SQLITE_MAX_DB ); |
| 115629 | assert( sqlite3SchemaMutexHeld(pToplevel->db, iDb, 0) ); | 116384 | assert( sqlite3SchemaMutexHeld(pToplevel->db, iDb, 0) ); |
| 115630 | if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){ | 116385 | if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){ |
| 115631 | DbMaskSet(pToplevel->cookieMask, iDb); | 116386 | DbMaskSet(pToplevel->cookieMask, iDb); |
| @@ -115968,23 +116723,75 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){ | |||
| 115968 | 116723 | ||
| 115969 | #ifndef SQLITE_OMIT_CTE | 116724 | #ifndef SQLITE_OMIT_CTE |
| 115970 | /* | 116725 | /* |
| 116726 | ** Create a new CTE object | ||
| 116727 | */ | ||
| 116728 | SQLITE_PRIVATE Cte *sqlite3CteNew( | ||
| 116729 | Parse *pParse, /* Parsing context */ | ||
| 116730 | Token *pName, /* Name of the common-table */ | ||
| 116731 | ExprList *pArglist, /* Optional column name list for the table */ | ||
| 116732 | Select *pQuery, /* Query used to initialize the table */ | ||
| 116733 | u8 eM10d /* The MATERIALIZED flag */ | ||
| 116734 | ){ | ||
| 116735 | Cte *pNew; | ||
| 116736 | sqlite3 *db = pParse->db; | ||
| 116737 | |||
| 116738 | pNew = sqlite3DbMallocZero(db, sizeof(*pNew)); | ||
| 116739 | assert( pNew!=0 || db->mallocFailed ); | ||
| 116740 | |||
| 116741 | if( db->mallocFailed ){ | ||
| 116742 | sqlite3ExprListDelete(db, pArglist); | ||
| 116743 | sqlite3SelectDelete(db, pQuery); | ||
| 116744 | }else{ | ||
| 116745 | pNew->pSelect = pQuery; | ||
| 116746 | pNew->pCols = pArglist; | ||
| 116747 | pNew->zName = sqlite3NameFromToken(pParse->db, pName); | ||
| 116748 | pNew->eM10d = eM10d; | ||
| 116749 | } | ||
| 116750 | return pNew; | ||
| 116751 | } | ||
| 116752 | |||
| 116753 | /* | ||
| 116754 | ** Clear information from a Cte object, but do not deallocate storage | ||
| 116755 | ** for the object itself. | ||
| 116756 | */ | ||
| 116757 | static void cteClear(sqlite3 *db, Cte *pCte){ | ||
| 116758 | assert( pCte!=0 ); | ||
| 116759 | sqlite3ExprListDelete(db, pCte->pCols); | ||
| 116760 | sqlite3SelectDelete(db, pCte->pSelect); | ||
| 116761 | sqlite3DbFree(db, pCte->zName); | ||
| 116762 | } | ||
| 116763 | |||
| 116764 | /* | ||
| 116765 | ** Free the contents of the CTE object passed as the second argument. | ||
| 116766 | */ | ||
| 116767 | SQLITE_PRIVATE void sqlite3CteDelete(sqlite3 *db, Cte *pCte){ | ||
| 116768 | assert( pCte!=0 ); | ||
| 116769 | cteClear(db, pCte); | ||
| 116770 | sqlite3DbFree(db, pCte); | ||
| 116771 | } | ||
| 116772 | |||
| 116773 | /* | ||
| 115971 | ** This routine is invoked once per CTE by the parser while parsing a | 116774 | ** This routine is invoked once per CTE by the parser while parsing a |
| 115972 | ** WITH clause. | 116775 | ** WITH clause. The CTE described by teh third argument is added to |
| 116776 | ** the WITH clause of the second argument. If the second argument is | ||
| 116777 | ** NULL, then a new WITH argument is created. | ||
| 115973 | */ | 116778 | */ |
| 115974 | SQLITE_PRIVATE With *sqlite3WithAdd( | 116779 | SQLITE_PRIVATE With *sqlite3WithAdd( |
| 115975 | Parse *pParse, /* Parsing context */ | 116780 | Parse *pParse, /* Parsing context */ |
| 115976 | With *pWith, /* Existing WITH clause, or NULL */ | 116781 | With *pWith, /* Existing WITH clause, or NULL */ |
| 115977 | Token *pName, /* Name of the common-table */ | 116782 | Cte *pCte /* CTE to add to the WITH clause */ |
| 115978 | ExprList *pArglist, /* Optional column name list for the table */ | ||
| 115979 | Select *pQuery /* Query used to initialize the table */ | ||
| 115980 | ){ | 116783 | ){ |
| 115981 | sqlite3 *db = pParse->db; | 116784 | sqlite3 *db = pParse->db; |
| 115982 | With *pNew; | 116785 | With *pNew; |
| 115983 | char *zName; | 116786 | char *zName; |
| 115984 | 116787 | ||
| 116788 | if( pCte==0 ){ | ||
| 116789 | return pWith; | ||
| 116790 | } | ||
| 116791 | |||
| 115985 | /* Check that the CTE name is unique within this WITH clause. If | 116792 | /* Check that the CTE name is unique within this WITH clause. If |
| 115986 | ** not, store an error in the Parse structure. */ | 116793 | ** not, store an error in the Parse structure. */ |
| 115987 | zName = sqlite3NameFromToken(pParse->db, pName); | 116794 | zName = pCte->zName; |
| 115988 | if( zName && pWith ){ | 116795 | if( zName && pWith ){ |
| 115989 | int i; | 116796 | int i; |
| 115990 | for(i=0; i<pWith->nCte; i++){ | 116797 | for(i=0; i<pWith->nCte; i++){ |
| @@ -116003,16 +116810,11 @@ SQLITE_PRIVATE With *sqlite3WithAdd( | |||
| 116003 | assert( (pNew!=0 && zName!=0) || db->mallocFailed ); | 116810 | assert( (pNew!=0 && zName!=0) || db->mallocFailed ); |
| 116004 | 116811 | ||
| 116005 | if( db->mallocFailed ){ | 116812 | if( db->mallocFailed ){ |
| 116006 | sqlite3ExprListDelete(db, pArglist); | 116813 | sqlite3CteDelete(db, pCte); |
| 116007 | sqlite3SelectDelete(db, pQuery); | ||
| 116008 | sqlite3DbFree(db, zName); | ||
| 116009 | pNew = pWith; | 116814 | pNew = pWith; |
| 116010 | }else{ | 116815 | }else{ |
| 116011 | pNew->a[pNew->nCte].pSelect = pQuery; | 116816 | pNew->a[pNew->nCte++] = *pCte; |
| 116012 | pNew->a[pNew->nCte].pCols = pArglist; | 116817 | sqlite3DbFree(db, pCte); |
| 116013 | pNew->a[pNew->nCte].zName = zName; | ||
| 116014 | pNew->a[pNew->nCte].zCteErr = 0; | ||
| 116015 | pNew->nCte++; | ||
| 116016 | } | 116818 | } |
| 116017 | 116819 | ||
| 116018 | return pNew; | 116820 | return pNew; |
| @@ -116025,10 +116827,7 @@ SQLITE_PRIVATE void sqlite3WithDelete(sqlite3 *db, With *pWith){ | |||
| 116025 | if( pWith ){ | 116827 | if( pWith ){ |
| 116026 | int i; | 116828 | int i; |
| 116027 | for(i=0; i<pWith->nCte; i++){ | 116829 | for(i=0; i<pWith->nCte; i++){ |
| 116028 | struct Cte *pCte = &pWith->a[i]; | 116830 | cteClear(db, &pWith->a[i]); |
| 116029 | sqlite3ExprListDelete(db, pCte->pCols); | ||
| 116030 | sqlite3SelectDelete(db, pCte->pSelect); | ||
| 116031 | sqlite3DbFree(db, pCte->zName); | ||
| 116032 | } | 116831 | } |
| 116033 | sqlite3DbFree(db, pWith); | 116832 | sqlite3DbFree(db, pWith); |
| 116034 | } | 116833 | } |
| @@ -116607,7 +117406,7 @@ SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *db, Btree *pBt){ | |||
| 116607 | ** | 117406 | ** |
| 116608 | */ | 117407 | */ |
| 116609 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ | 117408 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ |
| 116610 | struct SrcList_item *pItem = pSrc->a; | 117409 | SrcItem *pItem = pSrc->a; |
| 116611 | Table *pTab; | 117410 | Table *pTab; |
| 116612 | assert( pItem && pSrc->nSrc>=1 ); | 117411 | assert( pItem && pSrc->nSrc>=1 ); |
| 116613 | pTab = sqlite3LocateTableItem(pParse, 0, pItem); | 117412 | pTab = sqlite3LocateTableItem(pParse, 0, pItem); |
| @@ -116615,9 +117414,9 @@ SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){ | |||
| 116615 | pItem->pTab = pTab; | 117414 | pItem->pTab = pTab; |
| 116616 | if( pTab ){ | 117415 | if( pTab ){ |
| 116617 | pTab->nTabRef++; | 117416 | pTab->nTabRef++; |
| 116618 | } | 117417 | if( pItem->fg.isIndexedBy && sqlite3IndexedByLookup(pParse, pItem) ){ |
| 116619 | if( sqlite3IndexedByLookup(pParse, pItem) ){ | 117418 | pTab = 0; |
| 116620 | pTab = 0; | 117419 | } |
| 116621 | } | 117420 | } |
| 116622 | return pTab; | 117421 | return pTab; |
| 116623 | } | 117422 | } |
| @@ -116785,9 +117584,15 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere( | |||
| 116785 | /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree | 117584 | /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree |
| 116786 | ** and the SELECT subtree. */ | 117585 | ** and the SELECT subtree. */ |
| 116787 | pSrc->a[0].pTab = 0; | 117586 | pSrc->a[0].pTab = 0; |
| 116788 | pSelectSrc = sqlite3SrcListDup(pParse->db, pSrc, 0); | 117587 | pSelectSrc = sqlite3SrcListDup(db, pSrc, 0); |
| 116789 | pSrc->a[0].pTab = pTab; | 117588 | pSrc->a[0].pTab = pTab; |
| 116790 | pSrc->a[0].pIBIndex = 0; | 117589 | if( pSrc->a[0].fg.isIndexedBy ){ |
| 117590 | pSrc->a[0].u2.pIBIndex = 0; | ||
| 117591 | pSrc->a[0].fg.isIndexedBy = 0; | ||
| 117592 | sqlite3DbFree(db, pSrc->a[0].u1.zIndexedBy); | ||
| 117593 | }else if( pSrc->a[0].fg.isCte ){ | ||
| 117594 | pSrc->a[0].u2.pCteUse->nUse++; | ||
| 117595 | } | ||
| 116791 | 117596 | ||
| 116792 | /* generate the SELECT expression tree. */ | 117597 | /* generate the SELECT expression tree. */ |
| 116793 | pSelect = sqlite3SelectNew(pParse, pEList, pSelectSrc, pWhere, 0 ,0, | 117598 | pSelect = sqlite3SelectNew(pParse, pEList, pSelectSrc, pWhere, 0 ,0, |
| @@ -116965,6 +117770,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom( | |||
| 116965 | if( (db->flags & SQLITE_CountRows)!=0 | 117770 | if( (db->flags & SQLITE_CountRows)!=0 |
| 116966 | && !pParse->nested | 117771 | && !pParse->nested |
| 116967 | && !pParse->pTriggerTab | 117772 | && !pParse->pTriggerTab |
| 117773 | && !pParse->bReturning | ||
| 116968 | ){ | 117774 | ){ |
| 116969 | memCnt = ++pParse->nMem; | 117775 | memCnt = ++pParse->nMem; |
| 116970 | sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt); | 117776 | sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt); |
| @@ -117186,7 +117992,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom( | |||
| 117186 | ** invoke the callback function. | 117992 | ** invoke the callback function. |
| 117187 | */ | 117993 | */ |
| 117188 | if( memCnt ){ | 117994 | if( memCnt ){ |
| 117189 | sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1); | 117995 | sqlite3VdbeAddOp2(v, OP_ChngCntRow, memCnt, 1); |
| 117190 | sqlite3VdbeSetNumCols(v, 1); | 117996 | sqlite3VdbeSetNumCols(v, 1); |
| 117191 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC); | 117997 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC); |
| 117192 | } | 117998 | } |
| @@ -118234,7 +119040,8 @@ static int patternCompare( | |||
| 118234 | /* Skip over multiple "*" characters in the pattern. If there | 119040 | /* Skip over multiple "*" characters in the pattern. If there |
| 118235 | ** are also "?" characters, skip those as well, but consume a | 119041 | ** are also "?" characters, skip those as well, but consume a |
| 118236 | ** single character of the input string for each "?" skipped */ | 119042 | ** single character of the input string for each "?" skipped */ |
| 118237 | while( (c=Utf8Read(zPattern)) == matchAll || c == matchOne ){ | 119043 | while( (c=Utf8Read(zPattern)) == matchAll |
| 119044 | || (c == matchOne && matchOne!=0) ){ | ||
| 118238 | if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){ | 119045 | if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){ |
| 118239 | return SQLITE_NOWILDCARDMATCH; | 119046 | return SQLITE_NOWILDCARDMATCH; |
| 118240 | } | 119047 | } |
| @@ -119405,7 +120212,9 @@ SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive) | |||
| 119405 | SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){ | 120212 | SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){ |
| 119406 | FuncDef *pDef; | 120213 | FuncDef *pDef; |
| 119407 | int nExpr; | 120214 | int nExpr; |
| 119408 | if( pExpr->op!=TK_FUNCTION || !pExpr->x.pList ){ | 120215 | assert( pExpr!=0 ); |
| 120216 | assert( pExpr->op==TK_FUNCTION ); | ||
| 120217 | if( !pExpr->x.pList ){ | ||
| 119409 | return 0; | 120218 | return 0; |
| 119410 | } | 120219 | } |
| 119411 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 120220 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| @@ -119444,6 +120253,203 @@ SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocas | |||
| 119444 | return 1; | 120253 | return 1; |
| 119445 | } | 120254 | } |
| 119446 | 120255 | ||
| 120256 | /* Mathematical Constants */ | ||
| 120257 | #ifndef M_PI | ||
| 120258 | # define M_PI 3.141592653589793238462643383279502884 | ||
| 120259 | #endif | ||
| 120260 | #ifndef M_LN10 | ||
| 120261 | # define M_LN10 2.302585092994045684017991454684364208 | ||
| 120262 | #endif | ||
| 120263 | #ifndef M_LN2 | ||
| 120264 | # define M_LN2 0.693147180559945309417232121458176568 | ||
| 120265 | #endif | ||
| 120266 | |||
| 120267 | |||
| 120268 | /* Extra math functions that require linking with -lm | ||
| 120269 | */ | ||
| 120270 | #ifdef SQLITE_ENABLE_MATH_FUNCTIONS | ||
| 120271 | /* | ||
| 120272 | ** Implementation SQL functions: | ||
| 120273 | ** | ||
| 120274 | ** ceil(X) | ||
| 120275 | ** ceiling(X) | ||
| 120276 | ** floor(X) | ||
| 120277 | ** | ||
| 120278 | ** The sqlite3_user_data() pointer is a pointer to the libm implementation | ||
| 120279 | ** of the underlying C function. | ||
| 120280 | */ | ||
| 120281 | static void ceilingFunc( | ||
| 120282 | sqlite3_context *context, | ||
| 120283 | int argc, | ||
| 120284 | sqlite3_value **argv | ||
| 120285 | ){ | ||
| 120286 | assert( argc==1 ); | ||
| 120287 | switch( sqlite3_value_numeric_type(argv[0]) ){ | ||
| 120288 | case SQLITE_INTEGER: { | ||
| 120289 | sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); | ||
| 120290 | break; | ||
| 120291 | } | ||
| 120292 | case SQLITE_FLOAT: { | ||
| 120293 | double (*x)(double) = (double(*)(double))sqlite3_user_data(context); | ||
| 120294 | sqlite3_result_double(context, x(sqlite3_value_double(argv[0]))); | ||
| 120295 | break; | ||
| 120296 | } | ||
| 120297 | default: { | ||
| 120298 | break; | ||
| 120299 | } | ||
| 120300 | } | ||
| 120301 | } | ||
| 120302 | |||
| 120303 | /* | ||
| 120304 | ** On some systems, ceil() and floor() are intrinsic function. You are | ||
| 120305 | ** unable to take a pointer to these functions. Hence, we here wrap them | ||
| 120306 | ** in our own actual functions. | ||
| 120307 | */ | ||
| 120308 | static double xCeil(double x){ return ceil(x); } | ||
| 120309 | static double xFloor(double x){ return floor(x); } | ||
| 120310 | |||
| 120311 | /* | ||
| 120312 | ** Implementation of SQL functions: | ||
| 120313 | ** | ||
| 120314 | ** ln(X) - natural logarithm | ||
| 120315 | ** log(X) - log X base 10 | ||
| 120316 | ** log10(X) - log X base 10 | ||
| 120317 | ** log(B,X) - log X base B | ||
| 120318 | */ | ||
| 120319 | static void logFunc( | ||
| 120320 | sqlite3_context *context, | ||
| 120321 | int argc, | ||
| 120322 | sqlite3_value **argv | ||
| 120323 | ){ | ||
| 120324 | double x, b, ans; | ||
| 120325 | assert( argc==1 || argc==2 ); | ||
| 120326 | switch( sqlite3_value_numeric_type(argv[0]) ){ | ||
| 120327 | case SQLITE_INTEGER: | ||
| 120328 | case SQLITE_FLOAT: | ||
| 120329 | x = sqlite3_value_double(argv[0]); | ||
| 120330 | if( x<=0.0 ) return; | ||
| 120331 | break; | ||
| 120332 | default: | ||
| 120333 | return; | ||
| 120334 | } | ||
| 120335 | if( argc==2 ){ | ||
| 120336 | switch( sqlite3_value_numeric_type(argv[0]) ){ | ||
| 120337 | case SQLITE_INTEGER: | ||
| 120338 | case SQLITE_FLOAT: | ||
| 120339 | b = log(x); | ||
| 120340 | if( b<=0.0 ) return; | ||
| 120341 | x = sqlite3_value_double(argv[1]); | ||
| 120342 | if( x<=0.0 ) return; | ||
| 120343 | break; | ||
| 120344 | default: | ||
| 120345 | return; | ||
| 120346 | } | ||
| 120347 | ans = log(x)/b; | ||
| 120348 | }else{ | ||
| 120349 | ans = log(x); | ||
| 120350 | switch( SQLITE_PTR_TO_INT(sqlite3_user_data(context)) ){ | ||
| 120351 | case 1: | ||
| 120352 | /* Convert from natural logarithm to log base 10 */ | ||
| 120353 | ans *= 1.0/M_LN10; | ||
| 120354 | break; | ||
| 120355 | case 2: | ||
| 120356 | /* Convert from natural logarithm to log base 2 */ | ||
| 120357 | ans *= 1.0/M_LN2; | ||
| 120358 | break; | ||
| 120359 | default: | ||
| 120360 | break; | ||
| 120361 | } | ||
| 120362 | } | ||
| 120363 | sqlite3_result_double(context, ans); | ||
| 120364 | } | ||
| 120365 | |||
| 120366 | /* | ||
| 120367 | ** Functions to converts degrees to radians and radians to degrees. | ||
| 120368 | */ | ||
| 120369 | static double degToRad(double x){ return x*(M_PI/180.0); } | ||
| 120370 | static double radToDeg(double x){ return x*(180.0/M_PI); } | ||
| 120371 | |||
| 120372 | /* | ||
| 120373 | ** Implementation of 1-argument SQL math functions: | ||
| 120374 | ** | ||
| 120375 | ** exp(X) - Compute e to the X-th power | ||
| 120376 | */ | ||
| 120377 | static void math1Func( | ||
| 120378 | sqlite3_context *context, | ||
| 120379 | int argc, | ||
| 120380 | sqlite3_value **argv | ||
| 120381 | ){ | ||
| 120382 | int type0; | ||
| 120383 | double v0, ans; | ||
| 120384 | double (*x)(double); | ||
| 120385 | assert( argc==1 ); | ||
| 120386 | type0 = sqlite3_value_numeric_type(argv[0]); | ||
| 120387 | if( type0!=SQLITE_INTEGER && type0!=SQLITE_FLOAT ) return; | ||
| 120388 | v0 = sqlite3_value_double(argv[0]); | ||
| 120389 | x = (double(*)(double))sqlite3_user_data(context); | ||
| 120390 | ans = x(v0); | ||
| 120391 | sqlite3_result_double(context, ans); | ||
| 120392 | } | ||
| 120393 | |||
| 120394 | /* | ||
| 120395 | ** Implementation of 2-argument SQL math functions: | ||
| 120396 | ** | ||
| 120397 | ** power(X,Y) - Compute X to the Y-th power | ||
| 120398 | */ | ||
| 120399 | static void math2Func( | ||
| 120400 | sqlite3_context *context, | ||
| 120401 | int argc, | ||
| 120402 | sqlite3_value **argv | ||
| 120403 | ){ | ||
| 120404 | int type0, type1; | ||
| 120405 | double v0, v1, ans; | ||
| 120406 | double (*x)(double,double); | ||
| 120407 | assert( argc==2 ); | ||
| 120408 | type0 = sqlite3_value_numeric_type(argv[0]); | ||
| 120409 | if( type0!=SQLITE_INTEGER && type0!=SQLITE_FLOAT ) return; | ||
| 120410 | type1 = sqlite3_value_numeric_type(argv[1]); | ||
| 120411 | if( type1!=SQLITE_INTEGER && type1!=SQLITE_FLOAT ) return; | ||
| 120412 | v0 = sqlite3_value_double(argv[0]); | ||
| 120413 | v1 = sqlite3_value_double(argv[1]); | ||
| 120414 | x = (double(*)(double,double))sqlite3_user_data(context); | ||
| 120415 | ans = x(v0, v1); | ||
| 120416 | sqlite3_result_double(context, ans); | ||
| 120417 | } | ||
| 120418 | |||
| 120419 | /* | ||
| 120420 | ** Implementation of 2-argument SQL math functions: | ||
| 120421 | ** | ||
| 120422 | ** power(X,Y) - Compute X to the Y-th power | ||
| 120423 | */ | ||
| 120424 | static void piFunc( | ||
| 120425 | sqlite3_context *context, | ||
| 120426 | int argc, | ||
| 120427 | sqlite3_value **argv | ||
| 120428 | ){ | ||
| 120429 | assert( argc==0 ); | ||
| 120430 | sqlite3_result_double(context, M_PI); | ||
| 120431 | } | ||
| 120432 | |||
| 120433 | #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ | ||
| 120434 | |||
| 120435 | /* | ||
| 120436 | ** Implementation of sign(X) function. | ||
| 120437 | */ | ||
| 120438 | static void signFunc( | ||
| 120439 | sqlite3_context *context, | ||
| 120440 | int argc, | ||
| 120441 | sqlite3_value **argv | ||
| 120442 | ){ | ||
| 120443 | int type0; | ||
| 120444 | double x; | ||
| 120445 | UNUSED_PARAMETER(argc); | ||
| 120446 | assert( argc==1 ); | ||
| 120447 | type0 = sqlite3_value_numeric_type(argv[0]); | ||
| 120448 | if( type0!=SQLITE_INTEGER && type0!=SQLITE_FLOAT ) return; | ||
| 120449 | x = sqlite3_value_double(argv[0]); | ||
| 120450 | sqlite3_result_int(context, x<0.0 ? -1 : x>0.0 ? +1 : 0); | ||
| 120451 | } | ||
| 120452 | |||
| 119447 | /* | 120453 | /* |
| 119448 | ** All of the FuncDef structures in the aBuiltinFunc[] array above | 120454 | ** All of the FuncDef structures in the aBuiltinFunc[] array above |
| 119449 | ** to the global function hash table. This occurs at start-time (as | 120455 | ** to the global function hash table. This occurs at start-time (as |
| @@ -119562,6 +120568,43 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ | |||
| 119562 | #endif | 120568 | #endif |
| 119563 | FUNCTION(coalesce, 1, 0, 0, 0 ), | 120569 | FUNCTION(coalesce, 1, 0, 0, 0 ), |
| 119564 | FUNCTION(coalesce, 0, 0, 0, 0 ), | 120570 | FUNCTION(coalesce, 0, 0, 0, 0 ), |
| 120571 | #ifdef SQLITE_ENABLE_MATH_FUNCTIONS | ||
| 120572 | MFUNCTION(ceil, 1, xCeil, ceilingFunc ), | ||
| 120573 | MFUNCTION(ceiling, 1, xCeil, ceilingFunc ), | ||
| 120574 | MFUNCTION(floor, 1, xFloor, ceilingFunc ), | ||
| 120575 | #if SQLITE_HAVE_C99_MATH_FUNCS | ||
| 120576 | MFUNCTION(trunc, 1, trunc, ceilingFunc ), | ||
| 120577 | #endif | ||
| 120578 | FUNCTION(ln, 1, 0, 0, logFunc ), | ||
| 120579 | FUNCTION(log, 1, 1, 0, logFunc ), | ||
| 120580 | FUNCTION(log10, 1, 1, 0, logFunc ), | ||
| 120581 | FUNCTION(log2, 1, 2, 0, logFunc ), | ||
| 120582 | FUNCTION(log, 2, 0, 0, logFunc ), | ||
| 120583 | MFUNCTION(exp, 1, exp, math1Func ), | ||
| 120584 | MFUNCTION(pow, 2, pow, math2Func ), | ||
| 120585 | MFUNCTION(power, 2, pow, math2Func ), | ||
| 120586 | MFUNCTION(mod, 2, fmod, math2Func ), | ||
| 120587 | MFUNCTION(acos, 1, acos, math1Func ), | ||
| 120588 | MFUNCTION(asin, 1, asin, math1Func ), | ||
| 120589 | MFUNCTION(atan, 1, atan, math1Func ), | ||
| 120590 | MFUNCTION(atan2, 2, atan2, math2Func ), | ||
| 120591 | MFUNCTION(cos, 1, cos, math1Func ), | ||
| 120592 | MFUNCTION(sin, 1, sin, math1Func ), | ||
| 120593 | MFUNCTION(tan, 1, tan, math1Func ), | ||
| 120594 | MFUNCTION(cosh, 1, cosh, math1Func ), | ||
| 120595 | MFUNCTION(sinh, 1, sinh, math1Func ), | ||
| 120596 | MFUNCTION(tanh, 1, tanh, math1Func ), | ||
| 120597 | #if SQLITE_HAVE_C99_MATH_FUNCS | ||
| 120598 | MFUNCTION(acosh, 1, acosh, math1Func ), | ||
| 120599 | MFUNCTION(asinh, 1, asinh, math1Func ), | ||
| 120600 | MFUNCTION(atanh, 1, atanh, math1Func ), | ||
| 120601 | #endif | ||
| 120602 | MFUNCTION(sqrt, 1, sqrt, math1Func ), | ||
| 120603 | MFUNCTION(radians, 1, degToRad, math1Func ), | ||
| 120604 | MFUNCTION(degrees, 1, radToDeg, math1Func ), | ||
| 120605 | FUNCTION(pi, 0, 0, 0, piFunc ), | ||
| 120606 | #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ | ||
| 120607 | FUNCTION(sign, 1, 0, 0, signFunc ), | ||
| 119565 | INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), | 120608 | INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), |
| 119566 | INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), | 120609 | INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), |
| 119567 | }; | 120610 | }; |
| @@ -120617,7 +121660,7 @@ SQLITE_PRIVATE void sqlite3FkCheck( | |||
| 120617 | ** child table as a SrcList for sqlite3WhereBegin() */ | 121660 | ** child table as a SrcList for sqlite3WhereBegin() */ |
| 120618 | pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); | 121661 | pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 120619 | if( pSrc ){ | 121662 | if( pSrc ){ |
| 120620 | struct SrcList_item *pItem = pSrc->a; | 121663 | SrcItem *pItem = pSrc->a; |
| 120621 | pItem->pTab = pFKey->pFrom; | 121664 | pItem->pTab = pFKey->pFrom; |
| 120622 | pItem->zName = pFKey->pFrom->zName; | 121665 | pItem->zName = pFKey->pFrom->zName; |
| 120623 | pItem->pTab->nTabRef++; | 121666 | pItem->pTab->nTabRef++; |
| @@ -120705,7 +121748,9 @@ SQLITE_PRIVATE u32 sqlite3FkOldmask( | |||
| 120705 | ** | 121748 | ** |
| 120706 | ** For an UPDATE, this function returns 2 if: | 121749 | ** For an UPDATE, this function returns 2 if: |
| 120707 | ** | 121750 | ** |
| 120708 | ** * There are any FKs for which pTab is the child and the parent table, or | 121751 | ** * There are any FKs for which pTab is the child and the parent table |
| 121752 | ** and any FK processing at all is required (even of a different FK), or | ||
| 121753 | ** | ||
| 120709 | ** * the UPDATE modifies one or more parent keys for which the action is | 121754 | ** * the UPDATE modifies one or more parent keys for which the action is |
| 120710 | ** not "NO ACTION" (i.e. is CASCADE, SET DEFAULT or SET NULL). | 121755 | ** not "NO ACTION" (i.e. is CASCADE, SET DEFAULT or SET NULL). |
| 120711 | ** | 121756 | ** |
| @@ -120717,13 +121762,14 @@ SQLITE_PRIVATE int sqlite3FkRequired( | |||
| 120717 | int *aChange, /* Non-NULL for UPDATE operations */ | 121762 | int *aChange, /* Non-NULL for UPDATE operations */ |
| 120718 | int chngRowid /* True for UPDATE that affects rowid */ | 121763 | int chngRowid /* True for UPDATE that affects rowid */ |
| 120719 | ){ | 121764 | ){ |
| 120720 | int eRet = 0; | 121765 | int eRet = 1; /* Value to return if bHaveFK is true */ |
| 121766 | int bHaveFK = 0; /* If FK processing is required */ | ||
| 120721 | if( pParse->db->flags&SQLITE_ForeignKeys ){ | 121767 | if( pParse->db->flags&SQLITE_ForeignKeys ){ |
| 120722 | if( !aChange ){ | 121768 | if( !aChange ){ |
| 120723 | /* A DELETE operation. Foreign key processing is required if the | 121769 | /* A DELETE operation. Foreign key processing is required if the |
| 120724 | ** table in question is either the child or parent table for any | 121770 | ** table in question is either the child or parent table for any |
| 120725 | ** foreign key constraint. */ | 121771 | ** foreign key constraint. */ |
| 120726 | eRet = (sqlite3FkReferences(pTab) || pTab->pFKey); | 121772 | bHaveFK = (sqlite3FkReferences(pTab) || pTab->pFKey); |
| 120727 | }else{ | 121773 | }else{ |
| 120728 | /* This is an UPDATE. Foreign key processing is only required if the | 121774 | /* This is an UPDATE. Foreign key processing is only required if the |
| 120729 | ** operation modifies one or more child or parent key columns. */ | 121775 | ** operation modifies one or more child or parent key columns. */ |
| @@ -120731,9 +121777,9 @@ SQLITE_PRIVATE int sqlite3FkRequired( | |||
| 120731 | 121777 | ||
| 120732 | /* Check if any child key columns are being modified. */ | 121778 | /* Check if any child key columns are being modified. */ |
| 120733 | for(p=pTab->pFKey; p; p=p->pNextFrom){ | 121779 | for(p=pTab->pFKey; p; p=p->pNextFrom){ |
| 120734 | if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) return 2; | ||
| 120735 | if( fkChildIsModified(pTab, p, aChange, chngRowid) ){ | 121780 | if( fkChildIsModified(pTab, p, aChange, chngRowid) ){ |
| 120736 | eRet = 1; | 121781 | if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) eRet = 2; |
| 121782 | bHaveFK = 1; | ||
| 120737 | } | 121783 | } |
| 120738 | } | 121784 | } |
| 120739 | 121785 | ||
| @@ -120741,12 +121787,12 @@ SQLITE_PRIVATE int sqlite3FkRequired( | |||
| 120741 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ | 121787 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| 120742 | if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ | 121788 | if( fkParentIsModified(pTab, p, aChange, chngRowid) ){ |
| 120743 | if( p->aAction[1]!=OE_None ) return 2; | 121789 | if( p->aAction[1]!=OE_None ) return 2; |
| 120744 | eRet = 1; | 121790 | bHaveFK = 1; |
| 120745 | } | 121791 | } |
| 120746 | } | 121792 | } |
| 120747 | } | 121793 | } |
| 120748 | } | 121794 | } |
| 120749 | return eRet; | 121795 | return bHaveFK ? eRet : 0; |
| 120750 | } | 121796 | } |
| 120751 | 121797 | ||
| 120752 | /* | 121798 | /* |
| @@ -121415,7 +122461,9 @@ static int autoIncBegin( | |||
| 121415 | while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; } | 122461 | while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; } |
| 121416 | if( pInfo==0 ){ | 122462 | if( pInfo==0 ){ |
| 121417 | pInfo = sqlite3DbMallocRawNN(pParse->db, sizeof(*pInfo)); | 122463 | pInfo = sqlite3DbMallocRawNN(pParse->db, sizeof(*pInfo)); |
| 121418 | if( pInfo==0 ) return 0; | 122464 | sqlite3ParserAddCleanup(pToplevel, sqlite3DbFree, pInfo); |
| 122465 | testcase( pParse->earlyCleanup ); | ||
| 122466 | if( pParse->db->mallocFailed ) return 0; | ||
| 121419 | pInfo->pNext = pToplevel->pAinc; | 122467 | pInfo->pNext = pToplevel->pAinc; |
| 121420 | pToplevel->pAinc = pInfo; | 122468 | pToplevel->pAinc = pInfo; |
| 121421 | pInfo->pTab = pTab; | 122469 | pInfo->pTab = pTab; |
| @@ -121973,19 +123021,24 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 121973 | } | 123021 | } |
| 121974 | } | 123022 | } |
| 121975 | #endif | 123023 | #endif |
| 121976 | } | ||
| 121977 | 123024 | ||
| 121978 | /* Make sure the number of columns in the source data matches the number | 123025 | /* Make sure the number of columns in the source data matches the number |
| 121979 | ** of columns to be inserted into the table. | 123026 | ** of columns to be inserted into the table. |
| 121980 | */ | 123027 | */ |
| 121981 | for(i=0; i<pTab->nCol; i++){ | 123028 | assert( TF_HasHidden==COLFLAG_HIDDEN ); |
| 121982 | if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++; | 123029 | assert( TF_HasGenerated==COLFLAG_GENERATED ); |
| 121983 | } | 123030 | assert( COLFLAG_NOINSERT==(COLFLAG_GENERATED|COLFLAG_HIDDEN) ); |
| 121984 | if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){ | 123031 | if( (pTab->tabFlags & (TF_HasGenerated|TF_HasHidden))!=0 ){ |
| 121985 | sqlite3ErrorMsg(pParse, | 123032 | for(i=0; i<pTab->nCol; i++){ |
| 121986 | "table %S has %d columns but %d values were supplied", | 123033 | if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++; |
| 121987 | pTabList, 0, pTab->nCol-nHidden, nColumn); | 123034 | } |
| 121988 | goto insert_cleanup; | 123035 | } |
| 123036 | if( nColumn!=(pTab->nCol-nHidden) ){ | ||
| 123037 | sqlite3ErrorMsg(pParse, | ||
| 123038 | "table %S has %d columns but %d values were supplied", | ||
| 123039 | pTabList, 0, pTab->nCol-nHidden, nColumn); | ||
| 123040 | goto insert_cleanup; | ||
| 123041 | } | ||
| 121989 | } | 123042 | } |
| 121990 | if( pColumn!=0 && nColumn!=pColumn->nId ){ | 123043 | if( pColumn!=0 && nColumn!=pColumn->nId ){ |
| 121991 | sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId); | 123044 | sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId); |
| @@ -121997,6 +123050,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 121997 | if( (db->flags & SQLITE_CountRows)!=0 | 123050 | if( (db->flags & SQLITE_CountRows)!=0 |
| 121998 | && !pParse->nested | 123051 | && !pParse->nested |
| 121999 | && !pParse->pTriggerTab | 123052 | && !pParse->pTriggerTab |
| 123053 | && !pParse->bReturning | ||
| 122000 | ){ | 123054 | ){ |
| 122001 | regRowCount = ++pParse->nMem; | 123055 | regRowCount = ++pParse->nMem; |
| 122002 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); | 123056 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); |
| @@ -122020,6 +123074,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 122020 | } | 123074 | } |
| 122021 | #ifndef SQLITE_OMIT_UPSERT | 123075 | #ifndef SQLITE_OMIT_UPSERT |
| 122022 | if( pUpsert ){ | 123076 | if( pUpsert ){ |
| 123077 | Upsert *pNx; | ||
| 122023 | if( IsVirtual(pTab) ){ | 123078 | if( IsVirtual(pTab) ){ |
| 122024 | sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"", | 123079 | sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"", |
| 122025 | pTab->zName); | 123080 | pTab->zName); |
| @@ -122033,13 +123088,17 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 122033 | goto insert_cleanup; | 123088 | goto insert_cleanup; |
| 122034 | } | 123089 | } |
| 122035 | pTabList->a[0].iCursor = iDataCur; | 123090 | pTabList->a[0].iCursor = iDataCur; |
| 122036 | pUpsert->pUpsertSrc = pTabList; | 123091 | pNx = pUpsert; |
| 122037 | pUpsert->regData = regData; | 123092 | do{ |
| 122038 | pUpsert->iDataCur = iDataCur; | 123093 | pNx->pUpsertSrc = pTabList; |
| 122039 | pUpsert->iIdxCur = iIdxCur; | 123094 | pNx->regData = regData; |
| 122040 | if( pUpsert->pUpsertTarget ){ | 123095 | pNx->iDataCur = iDataCur; |
| 122041 | sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert); | 123096 | pNx->iIdxCur = iIdxCur; |
| 122042 | } | 123097 | if( pNx->pUpsertTarget ){ |
| 123098 | sqlite3UpsertAnalyzeTarget(pParse, pTabList, pNx); | ||
| 123099 | } | ||
| 123100 | pNx = pNx->pNextUpsert; | ||
| 123101 | }while( pNx!=0 ); | ||
| 122043 | } | 123102 | } |
| 122044 | #endif | 123103 | #endif |
| 122045 | 123104 | ||
| @@ -122180,11 +123239,6 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 122180 | sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); VdbeCoverage(v); | 123239 | sqlite3VdbeAddOp1(v, OP_MustBeInt, regCols); VdbeCoverage(v); |
| 122181 | } | 123240 | } |
| 122182 | 123241 | ||
| 122183 | /* Cannot have triggers on a virtual table. If it were possible, | ||
| 122184 | ** this block would have to account for hidden column. | ||
| 122185 | */ | ||
| 122186 | assert( !IsVirtual(pTab) ); | ||
| 122187 | |||
| 122188 | /* Copy the new data already generated. */ | 123242 | /* Copy the new data already generated. */ |
| 122189 | assert( pTab->nNVCol>0 ); | 123243 | assert( pTab->nNVCol>0 ); |
| 122190 | sqlite3VdbeAddOp3(v, OP_Copy, regRowid+1, regCols+1, pTab->nNVCol-1); | 123244 | sqlite3VdbeAddOp3(v, OP_Copy, regRowid+1, regCols+1, pTab->nNVCol-1); |
| @@ -122339,7 +123393,9 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 122339 | sqlite3VdbeJumpHere(v, addrInsTop); | 123393 | sqlite3VdbeJumpHere(v, addrInsTop); |
| 122340 | } | 123394 | } |
| 122341 | 123395 | ||
| 123396 | #ifndef SQLITE_OMIT_XFER_OPT | ||
| 122342 | insert_end: | 123397 | insert_end: |
| 123398 | #endif /* SQLITE_OMIT_XFER_OPT */ | ||
| 122343 | /* Update the sqlite_sequence table by storing the content of the | 123399 | /* Update the sqlite_sequence table by storing the content of the |
| 122344 | ** maximum rowid counter values recorded while inserting into | 123400 | ** maximum rowid counter values recorded while inserting into |
| 122345 | ** autoincrement tables. | 123401 | ** autoincrement tables. |
| @@ -122354,7 +123410,7 @@ insert_end: | |||
| 122354 | ** invoke the callback function. | 123410 | ** invoke the callback function. |
| 122355 | */ | 123411 | */ |
| 122356 | if( regRowCount ){ | 123412 | if( regRowCount ){ |
| 122357 | sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); | 123413 | sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1); |
| 122358 | sqlite3VdbeSetNumCols(v, 1); | 123414 | sqlite3VdbeSetNumCols(v, 1); |
| 122359 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC); | 123415 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC); |
| 122360 | } | 123416 | } |
| @@ -122445,6 +123501,70 @@ SQLITE_PRIVATE int sqlite3ExprReferencesUpdatedColumn( | |||
| 122445 | } | 123501 | } |
| 122446 | 123502 | ||
| 122447 | /* | 123503 | /* |
| 123504 | ** The sqlite3GenerateConstraintChecks() routine usually wants to visit | ||
| 123505 | ** the indexes of a table in the order provided in the Table->pIndex list. | ||
| 123506 | ** However, sometimes (rarely - when there is an upsert) it wants to visit | ||
| 123507 | ** the indexes in a different order. The following data structures accomplish | ||
| 123508 | ** this. | ||
| 123509 | ** | ||
| 123510 | ** The IndexIterator object is used to walk through all of the indexes | ||
| 123511 | ** of a table in either Index.pNext order, or in some other order established | ||
| 123512 | ** by an array of IndexListTerm objects. | ||
| 123513 | */ | ||
| 123514 | typedef struct IndexListTerm IndexListTerm; | ||
| 123515 | typedef struct IndexIterator IndexIterator; | ||
| 123516 | struct IndexIterator { | ||
| 123517 | int eType; /* 0 for Index.pNext list. 1 for an array of IndexListTerm */ | ||
| 123518 | int i; /* Index of the current item from the list */ | ||
| 123519 | union { | ||
| 123520 | struct { /* Use this object for eType==0: A Index.pNext list */ | ||
| 123521 | Index *pIdx; /* The current Index */ | ||
| 123522 | } lx; | ||
| 123523 | struct { /* Use this object for eType==1; Array of IndexListTerm */ | ||
| 123524 | int nIdx; /* Size of the array */ | ||
| 123525 | IndexListTerm *aIdx; /* Array of IndexListTerms */ | ||
| 123526 | } ax; | ||
| 123527 | } u; | ||
| 123528 | }; | ||
| 123529 | |||
| 123530 | /* When IndexIterator.eType==1, then each index is an array of instances | ||
| 123531 | ** of the following object | ||
| 123532 | */ | ||
| 123533 | struct IndexListTerm { | ||
| 123534 | Index *p; /* The index */ | ||
| 123535 | int ix; /* Which entry in the original Table.pIndex list is this index*/ | ||
| 123536 | }; | ||
| 123537 | |||
| 123538 | /* Return the first index on the list */ | ||
| 123539 | static Index *indexIteratorFirst(IndexIterator *pIter, int *pIx){ | ||
| 123540 | assert( pIter->i==0 ); | ||
| 123541 | if( pIter->eType ){ | ||
| 123542 | *pIx = pIter->u.ax.aIdx[0].ix; | ||
| 123543 | return pIter->u.ax.aIdx[0].p; | ||
| 123544 | }else{ | ||
| 123545 | *pIx = 0; | ||
| 123546 | return pIter->u.lx.pIdx; | ||
| 123547 | } | ||
| 123548 | } | ||
| 123549 | |||
| 123550 | /* Return the next index from the list. Return NULL when out of indexes */ | ||
| 123551 | static Index *indexIteratorNext(IndexIterator *pIter, int *pIx){ | ||
| 123552 | if( pIter->eType ){ | ||
| 123553 | int i = ++pIter->i; | ||
| 123554 | if( i>=pIter->u.ax.nIdx ){ | ||
| 123555 | *pIx = i; | ||
| 123556 | return 0; | ||
| 123557 | } | ||
| 123558 | *pIx = pIter->u.ax.aIdx[i].ix; | ||
| 123559 | return pIter->u.ax.aIdx[i].p; | ||
| 123560 | }else{ | ||
| 123561 | ++(*pIx); | ||
| 123562 | pIter->u.lx.pIdx = pIter->u.lx.pIdx->pNext; | ||
| 123563 | return pIter->u.lx.pIdx; | ||
| 123564 | } | ||
| 123565 | } | ||
| 123566 | |||
| 123567 | /* | ||
| 122448 | ** Generate code to do constraint checks prior to an INSERT or an UPDATE | 123568 | ** Generate code to do constraint checks prior to an INSERT or an UPDATE |
| 122449 | ** on table pTab. | 123569 | ** on table pTab. |
| 122450 | ** | 123570 | ** |
| @@ -122552,7 +123672,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122552 | ){ | 123672 | ){ |
| 122553 | Vdbe *v; /* VDBE under constrution */ | 123673 | Vdbe *v; /* VDBE under constrution */ |
| 122554 | Index *pIdx; /* Pointer to one of the indices */ | 123674 | Index *pIdx; /* Pointer to one of the indices */ |
| 122555 | Index *pPk = 0; /* The PRIMARY KEY index */ | 123675 | Index *pPk = 0; /* The PRIMARY KEY index for WITHOUT ROWID tables */ |
| 122556 | sqlite3 *db; /* Database connection */ | 123676 | sqlite3 *db; /* Database connection */ |
| 122557 | int i; /* loop counter */ | 123677 | int i; /* loop counter */ |
| 122558 | int ix; /* Index loop counter */ | 123678 | int ix; /* Index loop counter */ |
| @@ -122560,11 +123680,11 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122560 | int onError; /* Conflict resolution strategy */ | 123680 | int onError; /* Conflict resolution strategy */ |
| 122561 | int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */ | 123681 | int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */ |
| 122562 | int nPkField; /* Number of fields in PRIMARY KEY. 1 for ROWID tables */ | 123682 | int nPkField; /* Number of fields in PRIMARY KEY. 1 for ROWID tables */ |
| 122563 | Index *pUpIdx = 0; /* Index to which to apply the upsert */ | 123683 | Upsert *pUpsertClause = 0; /* The specific ON CONFLICT clause for pIdx */ |
| 122564 | u8 isUpdate; /* True if this is an UPDATE operation */ | 123684 | u8 isUpdate; /* True if this is an UPDATE operation */ |
| 122565 | u8 bAffinityDone = 0; /* True if the OP_Affinity operation has been run */ | 123685 | u8 bAffinityDone = 0; /* True if the OP_Affinity operation has been run */ |
| 122566 | int upsertBypass = 0; /* Address of Goto to bypass upsert subroutine */ | 123686 | int upsertIpkReturn = 0; /* Address of Goto at end of IPK uniqueness check */ |
| 122567 | int upsertJump = 0; /* Address of Goto that jumps into upsert subroutine */ | 123687 | int upsertIpkDelay = 0; /* Address of Goto to bypass initial IPK check */ |
| 122568 | int ipkTop = 0; /* Top of the IPK uniqueness check */ | 123688 | int ipkTop = 0; /* Top of the IPK uniqueness check */ |
| 122569 | int ipkBottom = 0; /* OP_Goto at the end of the IPK uniqueness check */ | 123689 | int ipkBottom = 0; /* OP_Goto at the end of the IPK uniqueness check */ |
| 122570 | /* Variables associated with retesting uniqueness constraints after | 123690 | /* Variables associated with retesting uniqueness constraints after |
| @@ -122574,6 +123694,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122574 | int lblRecheckOk = 0; /* Each recheck jumps to this label if it passes */ | 123694 | int lblRecheckOk = 0; /* Each recheck jumps to this label if it passes */ |
| 122575 | Trigger *pTrigger; /* List of DELETE triggers on the table pTab */ | 123695 | Trigger *pTrigger; /* List of DELETE triggers on the table pTab */ |
| 122576 | int nReplaceTrig = 0; /* Number of replace triggers coded */ | 123696 | int nReplaceTrig = 0; /* Number of replace triggers coded */ |
| 123697 | IndexIterator sIdxIter; /* Index iterator */ | ||
| 122577 | 123698 | ||
| 122578 | isUpdate = regOldData!=0; | 123699 | isUpdate = regOldData!=0; |
| 122579 | db = pParse->db; | 123700 | db = pParse->db; |
| @@ -122771,19 +123892,63 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122771 | ** list of indexes attached to a table puts all OE_Replace indexes last | 123892 | ** list of indexes attached to a table puts all OE_Replace indexes last |
| 122772 | ** in the list. See sqlite3CreateIndex() for where that happens. | 123893 | ** in the list. See sqlite3CreateIndex() for where that happens. |
| 122773 | */ | 123894 | */ |
| 122774 | 123895 | sIdxIter.eType = 0; | |
| 123896 | sIdxIter.i = 0; | ||
| 123897 | sIdxIter.u.ax.aIdx = 0; /* Silence harmless compiler warning */ | ||
| 123898 | sIdxIter.u.lx.pIdx = pTab->pIndex; | ||
| 122775 | if( pUpsert ){ | 123899 | if( pUpsert ){ |
| 122776 | if( pUpsert->pUpsertTarget==0 ){ | 123900 | if( pUpsert->pUpsertTarget==0 ){ |
| 122777 | /* An ON CONFLICT DO NOTHING clause, without a constraint-target. | 123901 | /* There is just on ON CONFLICT clause and it has no constraint-target */ |
| 122778 | ** Make all unique constraint resolution be OE_Ignore */ | 123902 | assert( pUpsert->pNextUpsert==0 ); |
| 122779 | assert( pUpsert->pUpsertSet==0 ); | 123903 | if( pUpsert->isDoUpdate==0 ){ |
| 122780 | overrideError = OE_Ignore; | 123904 | /* A single ON CONFLICT DO NOTHING clause, without a constraint-target. |
| 122781 | pUpsert = 0; | 123905 | ** Make all unique constraint resolution be OE_Ignore */ |
| 122782 | }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){ | 123906 | overrideError = OE_Ignore; |
| 122783 | /* If the constraint-target uniqueness check must be run first. | 123907 | pUpsert = 0; |
| 122784 | ** Jump to that uniqueness check now */ | 123908 | }else{ |
| 122785 | upsertJump = sqlite3VdbeAddOp0(v, OP_Goto); | 123909 | /* A single ON CONFLICT DO UPDATE. Make all resolutions OE_Update */ |
| 122786 | VdbeComment((v, "UPSERT constraint goes first")); | 123910 | overrideError = OE_Update; |
| 123911 | } | ||
| 123912 | }else if( pTab->pIndex!=0 ){ | ||
| 123913 | /* Otherwise, we'll need to run the IndexListTerm array version of the | ||
| 123914 | ** iterator to ensure that all of the ON CONFLICT conditions are | ||
| 123915 | ** checked first and in order. */ | ||
| 123916 | int nIdx, jj; | ||
| 123917 | u64 nByte; | ||
| 123918 | Upsert *pTerm; | ||
| 123919 | u8 *bUsed; | ||
| 123920 | for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ | ||
| 123921 | assert( aRegIdx[nIdx]>0 ); | ||
| 123922 | } | ||
| 123923 | sIdxIter.eType = 1; | ||
| 123924 | sIdxIter.u.ax.nIdx = nIdx; | ||
| 123925 | nByte = (sizeof(IndexListTerm)+1)*nIdx + nIdx; | ||
| 123926 | sIdxIter.u.ax.aIdx = sqlite3DbMallocZero(db, nByte); | ||
| 123927 | if( sIdxIter.u.ax.aIdx==0 ) return; /* OOM */ | ||
| 123928 | bUsed = (u8*)&sIdxIter.u.ax.aIdx[nIdx]; | ||
| 123929 | pUpsert->pToFree = sIdxIter.u.ax.aIdx; | ||
| 123930 | for(i=0, pTerm=pUpsert; pTerm; pTerm=pTerm->pNextUpsert){ | ||
| 123931 | if( pTerm->pUpsertTarget==0 ) break; | ||
| 123932 | if( pTerm->pUpsertIdx==0 ) continue; /* Skip ON CONFLICT for the IPK */ | ||
| 123933 | jj = 0; | ||
| 123934 | pIdx = pTab->pIndex; | ||
| 123935 | while( ALWAYS(pIdx!=0) && pIdx!=pTerm->pUpsertIdx ){ | ||
| 123936 | pIdx = pIdx->pNext; | ||
| 123937 | jj++; | ||
| 123938 | } | ||
| 123939 | if( bUsed[jj] ) continue; /* Duplicate ON CONFLICT clause ignored */ | ||
| 123940 | bUsed[jj] = 1; | ||
| 123941 | sIdxIter.u.ax.aIdx[i].p = pIdx; | ||
| 123942 | sIdxIter.u.ax.aIdx[i].ix = jj; | ||
| 123943 | i++; | ||
| 123944 | } | ||
| 123945 | for(jj=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, jj++){ | ||
| 123946 | if( bUsed[jj] ) continue; | ||
| 123947 | sIdxIter.u.ax.aIdx[i].p = pIdx; | ||
| 123948 | sIdxIter.u.ax.aIdx[i].ix = jj; | ||
| 123949 | i++; | ||
| 123950 | } | ||
| 123951 | assert( i==nIdx ); | ||
| 122787 | } | 123952 | } |
| 122788 | } | 123953 | } |
| 122789 | 123954 | ||
| @@ -122846,11 +124011,20 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122846 | } | 124011 | } |
| 122847 | 124012 | ||
| 122848 | /* figure out whether or not upsert applies in this case */ | 124013 | /* figure out whether or not upsert applies in this case */ |
| 122849 | if( pUpsert && pUpsert->pUpsertIdx==0 ){ | 124014 | if( pUpsert ){ |
| 122850 | if( pUpsert->pUpsertSet==0 ){ | 124015 | pUpsertClause = sqlite3UpsertOfIndex(pUpsert,0); |
| 122851 | onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */ | 124016 | if( pUpsertClause!=0 ){ |
| 122852 | }else{ | 124017 | if( pUpsertClause->isDoUpdate==0 ){ |
| 122853 | onError = OE_Update; /* DO UPDATE */ | 124018 | onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */ |
| 124019 | }else{ | ||
| 124020 | onError = OE_Update; /* DO UPDATE */ | ||
| 124021 | } | ||
| 124022 | } | ||
| 124023 | if( pUpsertClause!=pUpsert ){ | ||
| 124024 | /* The first ON CONFLICT clause has a conflict target other than | ||
| 124025 | ** the IPK. We have to jump ahead to that first ON CONFLICT clause | ||
| 124026 | ** and then come back here and deal with the IPK afterwards */ | ||
| 124027 | upsertIpkDelay = sqlite3VdbeAddOp0(v, OP_Goto); | ||
| 122854 | } | 124028 | } |
| 122855 | } | 124029 | } |
| 122856 | 124030 | ||
| @@ -122860,7 +124034,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122860 | ** the UNIQUE constraints have run. | 124034 | ** the UNIQUE constraints have run. |
| 122861 | */ | 124035 | */ |
| 122862 | if( onError==OE_Replace /* IPK rule is REPLACE */ | 124036 | if( onError==OE_Replace /* IPK rule is REPLACE */ |
| 122863 | && onError!=overrideError /* Rules for other contraints are different */ | 124037 | && onError!=overrideError /* Rules for other constraints are different */ |
| 122864 | && pTab->pIndex /* There exist other constraints */ | 124038 | && pTab->pIndex /* There exist other constraints */ |
| 122865 | ){ | 124039 | ){ |
| 122866 | ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1; | 124040 | ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1; |
| @@ -122957,7 +124131,9 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122957 | } | 124131 | } |
| 122958 | } | 124132 | } |
| 122959 | sqlite3VdbeResolveLabel(v, addrRowidOk); | 124133 | sqlite3VdbeResolveLabel(v, addrRowidOk); |
| 122960 | if( ipkTop ){ | 124134 | if( pUpsert && pUpsertClause!=pUpsert ){ |
| 124135 | upsertIpkReturn = sqlite3VdbeAddOp0(v, OP_Goto); | ||
| 124136 | }else if( ipkTop ){ | ||
| 122961 | ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto); | 124137 | ipkBottom = sqlite3VdbeAddOp0(v, OP_Goto); |
| 122962 | sqlite3VdbeJumpHere(v, ipkTop-1); | 124138 | sqlite3VdbeJumpHere(v, ipkTop-1); |
| 122963 | } | 124139 | } |
| @@ -122970,7 +124146,10 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122970 | ** This loop also handles the case of the PRIMARY KEY index for a | 124146 | ** This loop also handles the case of the PRIMARY KEY index for a |
| 122971 | ** WITHOUT ROWID table. | 124147 | ** WITHOUT ROWID table. |
| 122972 | */ | 124148 | */ |
| 122973 | for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){ | 124149 | for(pIdx = indexIteratorFirst(&sIdxIter, &ix); |
| 124150 | pIdx; | ||
| 124151 | pIdx = indexIteratorNext(&sIdxIter, &ix) | ||
| 124152 | ){ | ||
| 122974 | int regIdx; /* Range of registers hold conent for pIdx */ | 124153 | int regIdx; /* Range of registers hold conent for pIdx */ |
| 122975 | int regR; /* Range of registers holding conflicting PK */ | 124154 | int regR; /* Range of registers holding conflicting PK */ |
| 122976 | int iThisCur; /* Cursor for this UNIQUE index */ | 124155 | int iThisCur; /* Cursor for this UNIQUE index */ |
| @@ -122978,15 +124157,14 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 122978 | int addrConflictCk; /* First opcode in the conflict check logic */ | 124157 | int addrConflictCk; /* First opcode in the conflict check logic */ |
| 122979 | 124158 | ||
| 122980 | if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */ | 124159 | if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */ |
| 122981 | if( pUpIdx==pIdx ){ | 124160 | if( pUpsert ){ |
| 122982 | addrUniqueOk = upsertJump+1; | 124161 | pUpsertClause = sqlite3UpsertOfIndex(pUpsert, pIdx); |
| 122983 | upsertBypass = sqlite3VdbeGoto(v, 0); | 124162 | if( upsertIpkDelay && pUpsertClause==pUpsert ){ |
| 122984 | VdbeComment((v, "Skip upsert subroutine")); | 124163 | sqlite3VdbeJumpHere(v, upsertIpkDelay); |
| 122985 | sqlite3VdbeJumpHere(v, upsertJump); | 124164 | } |
| 122986 | }else{ | ||
| 122987 | addrUniqueOk = sqlite3VdbeMakeLabel(pParse); | ||
| 122988 | } | 124165 | } |
| 122989 | if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){ | 124166 | addrUniqueOk = sqlite3VdbeMakeLabel(pParse); |
| 124167 | if( bAffinityDone==0 ){ | ||
| 122990 | sqlite3TableAffinity(v, pTab, regNewData+1); | 124168 | sqlite3TableAffinity(v, pTab, regNewData+1); |
| 122991 | bAffinityDone = 1; | 124169 | bAffinityDone = 1; |
| 122992 | } | 124170 | } |
| @@ -123057,8 +124235,8 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 123057 | } | 124235 | } |
| 123058 | 124236 | ||
| 123059 | /* Figure out if the upsert clause applies to this index */ | 124237 | /* Figure out if the upsert clause applies to this index */ |
| 123060 | if( pUpIdx==pIdx ){ | 124238 | if( pUpsertClause ){ |
| 123061 | if( pUpsert->pUpsertSet==0 ){ | 124239 | if( pUpsertClause->isDoUpdate==0 ){ |
| 123062 | onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */ | 124240 | onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */ |
| 123063 | }else{ | 124241 | }else{ |
| 123064 | onError = OE_Update; /* DO UPDATE */ | 124242 | onError = OE_Update; /* DO UPDATE */ |
| @@ -123096,7 +124274,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 123096 | regIdx, pIdx->nKeyCol); VdbeCoverage(v); | 124274 | regIdx, pIdx->nKeyCol); VdbeCoverage(v); |
| 123097 | 124275 | ||
| 123098 | /* Generate code to handle collisions */ | 124276 | /* Generate code to handle collisions */ |
| 123099 | regR = (pIdx==pPk) ? regIdx : sqlite3GetTempRange(pParse, nPkField); | 124277 | regR = pIdx==pPk ? regIdx : sqlite3GetTempRange(pParse, nPkField); |
| 123100 | if( isUpdate || onError==OE_Replace ){ | 124278 | if( isUpdate || onError==OE_Replace ){ |
| 123101 | if( HasRowid(pTab) ){ | 124279 | if( HasRowid(pTab) ){ |
| 123102 | sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR); | 124280 | sqlite3VdbeAddOp2(v, OP_IdxRowid, iThisCur, regR); |
| @@ -123248,13 +124426,16 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 123248 | break; | 124426 | break; |
| 123249 | } | 124427 | } |
| 123250 | } | 124428 | } |
| 123251 | if( pUpIdx==pIdx ){ | 124429 | sqlite3VdbeResolveLabel(v, addrUniqueOk); |
| 123252 | sqlite3VdbeGoto(v, upsertJump+1); | ||
| 123253 | sqlite3VdbeJumpHere(v, upsertBypass); | ||
| 123254 | }else{ | ||
| 123255 | sqlite3VdbeResolveLabel(v, addrUniqueOk); | ||
| 123256 | } | ||
| 123257 | if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField); | 124430 | if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField); |
| 124431 | if( pUpsertClause | ||
| 124432 | && upsertIpkReturn | ||
| 124433 | && sqlite3UpsertNextIsIPK(pUpsertClause) | ||
| 124434 | ){ | ||
| 124435 | sqlite3VdbeGoto(v, upsertIpkDelay+1); | ||
| 124436 | sqlite3VdbeJumpHere(v, upsertIpkReturn); | ||
| 124437 | upsertIpkReturn = 0; | ||
| 124438 | } | ||
| 123258 | } | 124439 | } |
| 123259 | 124440 | ||
| 123260 | /* If the IPK constraint is a REPLACE, run it last */ | 124441 | /* If the IPK constraint is a REPLACE, run it last */ |
| @@ -123321,6 +124502,32 @@ SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){ | |||
| 123321 | #endif | 124502 | #endif |
| 123322 | 124503 | ||
| 123323 | /* | 124504 | /* |
| 124505 | ** Table pTab is a WITHOUT ROWID table that is being written to. The cursor | ||
| 124506 | ** number is iCur, and register regData contains the new record for the | ||
| 124507 | ** PK index. This function adds code to invoke the pre-update hook, | ||
| 124508 | ** if one is registered. | ||
| 124509 | */ | ||
| 124510 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | ||
| 124511 | static void codeWithoutRowidPreupdate( | ||
| 124512 | Parse *pParse, /* Parse context */ | ||
| 124513 | Table *pTab, /* Table being updated */ | ||
| 124514 | int iCur, /* Cursor number for table */ | ||
| 124515 | int regData /* Data containing new record */ | ||
| 124516 | ){ | ||
| 124517 | Vdbe *v = pParse->pVdbe; | ||
| 124518 | int r = sqlite3GetTempReg(pParse); | ||
| 124519 | assert( !HasRowid(pTab) ); | ||
| 124520 | assert( 0==(pParse->db->mDbFlags & DBFLAG_Vacuum) ); | ||
| 124521 | sqlite3VdbeAddOp2(v, OP_Integer, 0, r); | ||
| 124522 | sqlite3VdbeAddOp4(v, OP_Insert, iCur, regData, r, (char*)pTab, P4_TABLE); | ||
| 124523 | sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP); | ||
| 124524 | sqlite3ReleaseTempReg(pParse, r); | ||
| 124525 | } | ||
| 124526 | #else | ||
| 124527 | # define codeWithoutRowidPreupdate(a,b,c,d) | ||
| 124528 | #endif | ||
| 124529 | |||
| 124530 | /* | ||
| 123324 | ** This routine generates code to finish the INSERT or UPDATE operation | 124531 | ** This routine generates code to finish the INSERT or UPDATE operation |
| 123325 | ** that was started by a prior call to sqlite3GenerateConstraintChecks. | 124532 | ** that was started by a prior call to sqlite3GenerateConstraintChecks. |
| 123326 | ** A consecutive range of registers starting at regNewData contains the | 124533 | ** A consecutive range of registers starting at regNewData contains the |
| @@ -123368,17 +124575,9 @@ SQLITE_PRIVATE void sqlite3CompleteInsertion( | |||
| 123368 | assert( pParse->nested==0 ); | 124575 | assert( pParse->nested==0 ); |
| 123369 | pik_flags |= OPFLAG_NCHANGE; | 124576 | pik_flags |= OPFLAG_NCHANGE; |
| 123370 | pik_flags |= (update_flags & OPFLAG_SAVEPOSITION); | 124577 | pik_flags |= (update_flags & OPFLAG_SAVEPOSITION); |
| 123371 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | ||
| 123372 | if( update_flags==0 ){ | 124578 | if( update_flags==0 ){ |
| 123373 | int r = sqlite3GetTempReg(pParse); | 124579 | codeWithoutRowidPreupdate(pParse, pTab, iIdxCur+i, aRegIdx[i]); |
| 123374 | sqlite3VdbeAddOp2(v, OP_Integer, 0, r); | ||
| 123375 | sqlite3VdbeAddOp4(v, OP_Insert, | ||
| 123376 | iIdxCur+i, aRegIdx[i], r, (char*)pTab, P4_TABLE | ||
| 123377 | ); | ||
| 123378 | sqlite3VdbeChangeP5(v, OPFLAG_ISNOOP); | ||
| 123379 | sqlite3ReleaseTempReg(pParse, r); | ||
| 123380 | } | 124580 | } |
| 123381 | #endif | ||
| 123382 | } | 124581 | } |
| 123383 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i], | 124582 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iIdxCur+i, aRegIdx[i], |
| 123384 | aRegIdx[i]+1, | 124583 | aRegIdx[i]+1, |
| @@ -123576,7 +124775,7 @@ static int xferOptimization( | |||
| 123576 | ExprList *pEList; /* The result set of the SELECT */ | 124775 | ExprList *pEList; /* The result set of the SELECT */ |
| 123577 | Table *pSrc; /* The table in the FROM clause of SELECT */ | 124776 | Table *pSrc; /* The table in the FROM clause of SELECT */ |
| 123578 | Index *pSrcIdx, *pDestIdx; /* Source and destination indices */ | 124777 | Index *pSrcIdx, *pDestIdx; /* Source and destination indices */ |
| 123579 | struct SrcList_item *pItem; /* An element of pSelect->pSrc */ | 124778 | SrcItem *pItem; /* An element of pSelect->pSrc */ |
| 123580 | int i; /* Loop counter */ | 124779 | int i; /* Loop counter */ |
| 123581 | int iDbSrc; /* The database of pSrc */ | 124780 | int iDbSrc; /* The database of pSrc */ |
| 123582 | int iSrc, iDest; /* Cursors from source and destination */ | 124781 | int iSrc, iDest; /* Cursors from source and destination */ |
| @@ -123793,6 +124992,7 @@ static int xferOptimization( | |||
| 123793 | iDest = pParse->nTab++; | 124992 | iDest = pParse->nTab++; |
| 123794 | regAutoinc = autoIncBegin(pParse, iDbDest, pDest); | 124993 | regAutoinc = autoIncBegin(pParse, iDbDest, pDest); |
| 123795 | regData = sqlite3GetTempReg(pParse); | 124994 | regData = sqlite3GetTempReg(pParse); |
| 124995 | sqlite3VdbeAddOp2(v, OP_Null, 0, regData); | ||
| 123796 | regRowid = sqlite3GetTempReg(pParse); | 124996 | regRowid = sqlite3GetTempReg(pParse); |
| 123797 | sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite); | 124997 | sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite); |
| 123798 | assert( HasRowid(pDest) || destHasUniqueIdx ); | 124998 | assert( HasRowid(pDest) || destHasUniqueIdx ); |
| @@ -123828,11 +125028,13 @@ static int xferOptimization( | |||
| 123828 | emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v); | 125028 | emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v); |
| 123829 | if( pDest->iPKey>=0 ){ | 125029 | if( pDest->iPKey>=0 ){ |
| 123830 | addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); | 125030 | addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); |
| 123831 | sqlite3VdbeVerifyAbortable(v, onError); | 125031 | if( (db->mDbFlags & DBFLAG_Vacuum)==0 ){ |
| 123832 | addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid); | 125032 | sqlite3VdbeVerifyAbortable(v, onError); |
| 123833 | VdbeCoverage(v); | 125033 | addr2 = sqlite3VdbeAddOp3(v, OP_NotExists, iDest, 0, regRowid); |
| 123834 | sqlite3RowidConstraint(pParse, onError, pDest); | 125034 | VdbeCoverage(v); |
| 123835 | sqlite3VdbeJumpHere(v, addr2); | 125035 | sqlite3RowidConstraint(pParse, onError, pDest); |
| 125036 | sqlite3VdbeJumpHere(v, addr2); | ||
| 125037 | } | ||
| 123836 | autoIncStep(pParse, regAutoinc, regRowid); | 125038 | autoIncStep(pParse, regAutoinc, regRowid); |
| 123837 | }else if( pDest->pIndex==0 && !(db->mDbFlags & DBFLAG_VacuumInto) ){ | 125039 | }else if( pDest->pIndex==0 && !(db->mDbFlags & DBFLAG_VacuumInto) ){ |
| 123838 | addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid); | 125040 | addr1 = sqlite3VdbeAddOp2(v, OP_NewRowid, iDest, regRowid); |
| @@ -123840,16 +125042,28 @@ static int xferOptimization( | |||
| 123840 | addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); | 125042 | addr1 = sqlite3VdbeAddOp2(v, OP_Rowid, iSrc, regRowid); |
| 123841 | assert( (pDest->tabFlags & TF_Autoincrement)==0 ); | 125043 | assert( (pDest->tabFlags & TF_Autoincrement)==0 ); |
| 123842 | } | 125044 | } |
| 125045 | |||
| 123843 | if( db->mDbFlags & DBFLAG_Vacuum ){ | 125046 | if( db->mDbFlags & DBFLAG_Vacuum ){ |
| 123844 | sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest); | 125047 | sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest); |
| 123845 | insFlags = OPFLAG_APPEND|OPFLAG_USESEEKRESULT; | 125048 | insFlags = OPFLAG_APPEND|OPFLAG_USESEEKRESULT|OPFLAG_PREFORMAT; |
| 123846 | }else{ | 125049 | }else{ |
| 123847 | insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND; | 125050 | insFlags = OPFLAG_NCHANGE|OPFLAG_LASTROWID|OPFLAG_APPEND|OPFLAG_PREFORMAT; |
| 125051 | } | ||
| 125052 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | ||
| 125053 | if( (db->mDbFlags & DBFLAG_Vacuum)==0 ){ | ||
| 125054 | sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1); | ||
| 125055 | insFlags &= ~OPFLAG_PREFORMAT; | ||
| 125056 | }else | ||
| 125057 | #endif | ||
| 125058 | { | ||
| 125059 | sqlite3VdbeAddOp3(v, OP_RowCell, iDest, iSrc, regRowid); | ||
| 125060 | } | ||
| 125061 | sqlite3VdbeAddOp3(v, OP_Insert, iDest, regData, regRowid); | ||
| 125062 | if( (db->mDbFlags & DBFLAG_Vacuum)==0 ){ | ||
| 125063 | sqlite3VdbeChangeP4(v, -1, (char*)pDest, P4_TABLE); | ||
| 123848 | } | 125064 | } |
| 123849 | sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1); | ||
| 123850 | sqlite3VdbeAddOp4(v, OP_Insert, iDest, regData, regRowid, | ||
| 123851 | (char*)pDest, P4_TABLE); | ||
| 123852 | sqlite3VdbeChangeP5(v, insFlags); | 125065 | sqlite3VdbeChangeP5(v, insFlags); |
| 125066 | |||
| 123853 | sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); VdbeCoverage(v); | 125067 | sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1); VdbeCoverage(v); |
| 123854 | sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); | 125068 | sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0); |
| 123855 | sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); | 125069 | sqlite3VdbeAddOp2(v, OP_Close, iDest, 0); |
| @@ -123891,13 +125105,22 @@ static int xferOptimization( | |||
| 123891 | if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break; | 125105 | if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break; |
| 123892 | } | 125106 | } |
| 123893 | if( i==pSrcIdx->nColumn ){ | 125107 | if( i==pSrcIdx->nColumn ){ |
| 123894 | idxInsFlags = OPFLAG_USESEEKRESULT; | 125108 | idxInsFlags = OPFLAG_USESEEKRESULT|OPFLAG_PREFORMAT; |
| 123895 | sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest); | 125109 | sqlite3VdbeAddOp1(v, OP_SeekEnd, iDest); |
| 125110 | sqlite3VdbeAddOp2(v, OP_RowCell, iDest, iSrc); | ||
| 123896 | } | 125111 | } |
| 123897 | }else if( !HasRowid(pSrc) && pDestIdx->idxType==SQLITE_IDXTYPE_PRIMARYKEY ){ | 125112 | }else if( !HasRowid(pSrc) && pDestIdx->idxType==SQLITE_IDXTYPE_PRIMARYKEY ){ |
| 123898 | idxInsFlags |= OPFLAG_NCHANGE; | 125113 | idxInsFlags |= OPFLAG_NCHANGE; |
| 123899 | } | 125114 | } |
| 123900 | sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1); | 125115 | if( idxInsFlags!=(OPFLAG_USESEEKRESULT|OPFLAG_PREFORMAT) ){ |
| 125116 | sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1); | ||
| 125117 | if( (db->mDbFlags & DBFLAG_Vacuum)==0 | ||
| 125118 | && !HasRowid(pDest) | ||
| 125119 | && IsPrimaryKeyIndex(pDestIdx) | ||
| 125120 | ){ | ||
| 125121 | codeWithoutRowidPreupdate(pParse, pDest, iDest, regData); | ||
| 125122 | } | ||
| 125123 | } | ||
| 123901 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iDest, regData); | 125124 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iDest, regData); |
| 123902 | sqlite3VdbeChangeP5(v, idxInsFlags|OPFLAG_APPEND); | 125125 | sqlite3VdbeChangeP5(v, idxInsFlags|OPFLAG_APPEND); |
| 123903 | sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v); | 125126 | sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v); |
| @@ -128213,7 +129436,7 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 128213 | ** Checkpoint the database. | 129436 | ** Checkpoint the database. |
| 128214 | */ | 129437 | */ |
| 128215 | case PragTyp_WAL_CHECKPOINT: { | 129438 | case PragTyp_WAL_CHECKPOINT: { |
| 128216 | int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED); | 129439 | int iBt = (pId2->z?iDb:SQLITE_MAX_DB); |
| 128217 | int eMode = SQLITE_CHECKPOINT_PASSIVE; | 129440 | int eMode = SQLITE_CHECKPOINT_PASSIVE; |
| 128218 | if( zRight ){ | 129441 | if( zRight ){ |
| 128219 | if( sqlite3StrICmp(zRight, "full")==0 ){ | 129442 | if( sqlite3StrICmp(zRight, "full")==0 ){ |
| @@ -128861,7 +130084,7 @@ SQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3 *db, const char *zName) | |||
| 128861 | */ | 130084 | */ |
| 128862 | static void corruptSchema( | 130085 | static void corruptSchema( |
| 128863 | InitData *pData, /* Initialization context */ | 130086 | InitData *pData, /* Initialization context */ |
| 128864 | const char *zObj, /* Object being parsed at the point of error */ | 130087 | char **azObj, /* Type and name of object being parsed */ |
| 128865 | const char *zExtra /* Error information */ | 130088 | const char *zExtra /* Error information */ |
| 128866 | ){ | 130089 | ){ |
| 128867 | sqlite3 *db = pData->db; | 130090 | sqlite3 *db = pData->db; |
| @@ -128869,14 +130092,18 @@ static void corruptSchema( | |||
| 128869 | pData->rc = SQLITE_NOMEM_BKPT; | 130092 | pData->rc = SQLITE_NOMEM_BKPT; |
| 128870 | }else if( pData->pzErrMsg[0]!=0 ){ | 130093 | }else if( pData->pzErrMsg[0]!=0 ){ |
| 128871 | /* A error message has already been generated. Do not overwrite it */ | 130094 | /* A error message has already been generated. Do not overwrite it */ |
| 128872 | }else if( pData->mInitFlags & INITFLAG_AlterTable ){ | 130095 | }else if( pData->mInitFlags & (INITFLAG_AlterRename|INITFLAG_AlterDrop) ){ |
| 128873 | *pData->pzErrMsg = sqlite3DbStrDup(db, zExtra); | 130096 | *pData->pzErrMsg = sqlite3MPrintf(db, |
| 130097 | "error in %s %s after %s: %s", azObj[0], azObj[1], | ||
| 130098 | (pData->mInitFlags & INITFLAG_AlterRename) ? "rename" : "drop column", | ||
| 130099 | zExtra | ||
| 130100 | ); | ||
| 128874 | pData->rc = SQLITE_ERROR; | 130101 | pData->rc = SQLITE_ERROR; |
| 128875 | }else if( db->flags & SQLITE_WriteSchema ){ | 130102 | }else if( db->flags & SQLITE_WriteSchema ){ |
| 128876 | pData->rc = SQLITE_CORRUPT_BKPT; | 130103 | pData->rc = SQLITE_CORRUPT_BKPT; |
| 128877 | }else{ | 130104 | }else{ |
| 128878 | char *z; | 130105 | char *z; |
| 128879 | if( zObj==0 ) zObj = "?"; | 130106 | const char *zObj = azObj[1] ? azObj[1] : "?"; |
| 128880 | z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); | 130107 | z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); |
| 128881 | if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); | 130108 | if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); |
| 128882 | *pData->pzErrMsg = z; | 130109 | *pData->pzErrMsg = z; |
| @@ -128934,19 +130161,26 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 128934 | db->mDbFlags |= DBFLAG_EncodingFixed; | 130161 | db->mDbFlags |= DBFLAG_EncodingFixed; |
| 128935 | pData->nInitRow++; | 130162 | pData->nInitRow++; |
| 128936 | if( db->mallocFailed ){ | 130163 | if( db->mallocFailed ){ |
| 128937 | corruptSchema(pData, argv[1], 0); | 130164 | corruptSchema(pData, argv, 0); |
| 128938 | return 1; | 130165 | return 1; |
| 128939 | } | 130166 | } |
| 128940 | 130167 | ||
| 128941 | assert( iDb>=0 && iDb<db->nDb ); | 130168 | assert( iDb>=0 && iDb<db->nDb ); |
| 128942 | if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ | 130169 | if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ |
| 128943 | if( argv[3]==0 ){ | 130170 | if( argv[3]==0 ){ |
| 128944 | corruptSchema(pData, argv[1], 0); | 130171 | corruptSchema(pData, argv, 0); |
| 128945 | }else if( sqlite3_strnicmp(argv[4],"create ",7)==0 ){ | 130172 | }else if( argv[4] |
| 130173 | && 'c'==sqlite3UpperToLower[(unsigned char)argv[4][0]] | ||
| 130174 | && 'r'==sqlite3UpperToLower[(unsigned char)argv[4][1]] ){ | ||
| 128946 | /* Call the parser to process a CREATE TABLE, INDEX or VIEW. | 130175 | /* Call the parser to process a CREATE TABLE, INDEX or VIEW. |
| 128947 | ** But because db->init.busy is set to 1, no VDBE code is generated | 130176 | ** But because db->init.busy is set to 1, no VDBE code is generated |
| 128948 | ** or executed. All the parser does is build the internal data | 130177 | ** or executed. All the parser does is build the internal data |
| 128949 | ** structures that describe the table, index, or view. | 130178 | ** structures that describe the table, index, or view. |
| 130179 | ** | ||
| 130180 | ** No other valid SQL statement, other than the variable CREATE statements, | ||
| 130181 | ** can begin with the letters "C" and "R". Thus, it is not possible run | ||
| 130182 | ** any other kind of statement while parsing the schema, even a corrupt | ||
| 130183 | ** schema. | ||
| 128950 | */ | 130184 | */ |
| 128951 | int rc; | 130185 | int rc; |
| 128952 | u8 saved_iDb = db->init.iDb; | 130186 | u8 saved_iDb = db->init.iDb; |
| @@ -128959,7 +130193,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 128959 | || (db->init.newTnum>pData->mxPage && pData->mxPage>0) | 130193 | || (db->init.newTnum>pData->mxPage && pData->mxPage>0) |
| 128960 | ){ | 130194 | ){ |
| 128961 | if( sqlite3Config.bExtraSchemaChecks ){ | 130195 | if( sqlite3Config.bExtraSchemaChecks ){ |
| 128962 | corruptSchema(pData, argv[1], "invalid rootpage"); | 130196 | corruptSchema(pData, argv, "invalid rootpage"); |
| 128963 | } | 130197 | } |
| 128964 | } | 130198 | } |
| 128965 | db->init.orphanTrigger = 0; | 130199 | db->init.orphanTrigger = 0; |
| @@ -128978,13 +130212,13 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 128978 | if( rc==SQLITE_NOMEM ){ | 130212 | if( rc==SQLITE_NOMEM ){ |
| 128979 | sqlite3OomFault(db); | 130213 | sqlite3OomFault(db); |
| 128980 | }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){ | 130214 | }else if( rc!=SQLITE_INTERRUPT && (rc&0xFF)!=SQLITE_LOCKED ){ |
| 128981 | corruptSchema(pData, argv[1], sqlite3_errmsg(db)); | 130215 | corruptSchema(pData, argv, sqlite3_errmsg(db)); |
| 128982 | } | 130216 | } |
| 128983 | } | 130217 | } |
| 128984 | } | 130218 | } |
| 128985 | sqlite3_finalize(pStmt); | 130219 | sqlite3_finalize(pStmt); |
| 128986 | }else if( argv[1]==0 || (argv[4]!=0 && argv[4][0]!=0) ){ | 130220 | }else if( argv[1]==0 || (argv[4]!=0 && argv[4][0]!=0) ){ |
| 128987 | corruptSchema(pData, argv[1], 0); | 130221 | corruptSchema(pData, argv, 0); |
| 128988 | }else{ | 130222 | }else{ |
| 128989 | /* If the SQL column is blank it means this is an index that | 130223 | /* If the SQL column is blank it means this is an index that |
| 128990 | ** was created to be the PRIMARY KEY or to fulfill a UNIQUE | 130224 | ** was created to be the PRIMARY KEY or to fulfill a UNIQUE |
| @@ -128995,7 +130229,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 128995 | Index *pIndex; | 130229 | Index *pIndex; |
| 128996 | pIndex = sqlite3FindIndex(db, argv[1], db->aDb[iDb].zDbSName); | 130230 | pIndex = sqlite3FindIndex(db, argv[1], db->aDb[iDb].zDbSName); |
| 128997 | if( pIndex==0 ){ | 130231 | if( pIndex==0 ){ |
| 128998 | corruptSchema(pData, argv[1], "orphan index"); | 130232 | corruptSchema(pData, argv, "orphan index"); |
| 128999 | }else | 130233 | }else |
| 129000 | if( sqlite3GetUInt32(argv[3],&pIndex->tnum)==0 | 130234 | if( sqlite3GetUInt32(argv[3],&pIndex->tnum)==0 |
| 129001 | || pIndex->tnum<2 | 130235 | || pIndex->tnum<2 |
| @@ -129003,7 +130237,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 129003 | || sqlite3IndexHasDuplicateRootPage(pIndex) | 130237 | || sqlite3IndexHasDuplicateRootPage(pIndex) |
| 129004 | ){ | 130238 | ){ |
| 129005 | if( sqlite3Config.bExtraSchemaChecks ){ | 130239 | if( sqlite3Config.bExtraSchemaChecks ){ |
| 129006 | corruptSchema(pData, argv[1], "invalid rootpage"); | 130240 | corruptSchema(pData, argv, "invalid rootpage"); |
| 129007 | } | 130241 | } |
| 129008 | } | 130242 | } |
| 129009 | } | 130243 | } |
| @@ -129384,27 +130618,20 @@ SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){ | |||
| 129384 | } | 130618 | } |
| 129385 | 130619 | ||
| 129386 | /* | 130620 | /* |
| 129387 | ** Deallocate a single AggInfo object | ||
| 129388 | */ | ||
| 129389 | static void agginfoFree(sqlite3 *db, AggInfo *p){ | ||
| 129390 | sqlite3DbFree(db, p->aCol); | ||
| 129391 | sqlite3DbFree(db, p->aFunc); | ||
| 129392 | sqlite3DbFree(db, p); | ||
| 129393 | } | ||
| 129394 | |||
| 129395 | /* | ||
| 129396 | ** Free all memory allocations in the pParse object | 130621 | ** Free all memory allocations in the pParse object |
| 129397 | */ | 130622 | */ |
| 129398 | SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){ | 130623 | SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){ |
| 129399 | sqlite3 *db = pParse->db; | 130624 | sqlite3 *db = pParse->db; |
| 129400 | AggInfo *pThis = pParse->pAggList; | 130625 | while( pParse->pCleanup ){ |
| 129401 | while( pThis ){ | 130626 | ParseCleanup *pCleanup = pParse->pCleanup; |
| 129402 | AggInfo *pNext = pThis->pNext; | 130627 | pParse->pCleanup = pCleanup->pNext; |
| 129403 | agginfoFree(db, pThis); | 130628 | pCleanup->xCleanup(db, pCleanup->pPtr); |
| 129404 | pThis = pNext; | 130629 | sqlite3DbFreeNN(db, pCleanup); |
| 129405 | } | 130630 | } |
| 129406 | sqlite3DbFree(db, pParse->aLabel); | 130631 | sqlite3DbFree(db, pParse->aLabel); |
| 129407 | sqlite3ExprListDelete(db, pParse->pConstExpr); | 130632 | if( pParse->pConstExpr ){ |
| 130633 | sqlite3ExprListDelete(db, pParse->pConstExpr); | ||
| 130634 | } | ||
| 129408 | if( db ){ | 130635 | if( db ){ |
| 129409 | assert( db->lookaside.bDisable >= pParse->disableLookaside ); | 130636 | assert( db->lookaside.bDisable >= pParse->disableLookaside ); |
| 129410 | db->lookaside.bDisable -= pParse->disableLookaside; | 130637 | db->lookaside.bDisable -= pParse->disableLookaside; |
| @@ -129414,6 +130641,55 @@ SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){ | |||
| 129414 | } | 130641 | } |
| 129415 | 130642 | ||
| 129416 | /* | 130643 | /* |
| 130644 | ** Add a new cleanup operation to a Parser. The cleanup should happen when | ||
| 130645 | ** the parser object is destroyed. But, beware: the cleanup might happen | ||
| 130646 | ** immediately. | ||
| 130647 | ** | ||
| 130648 | ** Use this mechanism for uncommon cleanups. There is a higher setup | ||
| 130649 | ** cost for this mechansim (an extra malloc), so it should not be used | ||
| 130650 | ** for common cleanups that happen on most calls. But for less | ||
| 130651 | ** common cleanups, we save a single NULL-pointer comparison in | ||
| 130652 | ** sqlite3ParserReset(), which reduces the total CPU cycle count. | ||
| 130653 | ** | ||
| 130654 | ** If a memory allocation error occurs, then the cleanup happens immediately. | ||
| 130655 | ** When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the | ||
| 130656 | ** pParse->earlyCleanup flag is set in that case. Calling code show verify | ||
| 130657 | ** that test cases exist for which this happens, to guard against possible | ||
| 130658 | ** use-after-free errors following an OOM. The preferred way to do this is | ||
| 130659 | ** to immediately follow the call to this routine with: | ||
| 130660 | ** | ||
| 130661 | ** testcase( pParse->earlyCleanup ); | ||
| 130662 | ** | ||
| 130663 | ** This routine returns a copy of its pPtr input (the third parameter) | ||
| 130664 | ** except if an early cleanup occurs, in which case it returns NULL. So | ||
| 130665 | ** another way to check for early cleanup is to check the return value. | ||
| 130666 | ** Or, stop using the pPtr parameter with this call and use only its | ||
| 130667 | ** return value thereafter. Something like this: | ||
| 130668 | ** | ||
| 130669 | ** pObj = sqlite3ParserAddCleanup(pParse, destructor, pObj); | ||
| 130670 | */ | ||
| 130671 | SQLITE_PRIVATE void *sqlite3ParserAddCleanup( | ||
| 130672 | Parse *pParse, /* Destroy when this Parser finishes */ | ||
| 130673 | void (*xCleanup)(sqlite3*,void*), /* The cleanup routine */ | ||
| 130674 | void *pPtr /* Pointer to object to be cleaned up */ | ||
| 130675 | ){ | ||
| 130676 | ParseCleanup *pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup)); | ||
| 130677 | if( pCleanup ){ | ||
| 130678 | pCleanup->pNext = pParse->pCleanup; | ||
| 130679 | pParse->pCleanup = pCleanup; | ||
| 130680 | pCleanup->pPtr = pPtr; | ||
| 130681 | pCleanup->xCleanup = xCleanup; | ||
| 130682 | }else{ | ||
| 130683 | xCleanup(pParse->db, pPtr); | ||
| 130684 | pPtr = 0; | ||
| 130685 | #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) | ||
| 130686 | pParse->earlyCleanup = 1; | ||
| 130687 | #endif | ||
| 130688 | } | ||
| 130689 | return pPtr; | ||
| 130690 | } | ||
| 130691 | |||
| 130692 | /* | ||
| 129417 | ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. | 130693 | ** Compile the UTF-8 encoded SQL statement zSql into a statement handle. |
| 129418 | */ | 130694 | */ |
| 129419 | static int sqlite3Prepare( | 130695 | static int sqlite3Prepare( |
| @@ -129511,12 +130787,6 @@ static int sqlite3Prepare( | |||
| 129511 | } | 130787 | } |
| 129512 | assert( 0==sParse.nQueryLoop ); | 130788 | assert( 0==sParse.nQueryLoop ); |
| 129513 | 130789 | ||
| 129514 | if( sParse.rc==SQLITE_DONE ){ | ||
| 129515 | sParse.rc = SQLITE_OK; | ||
| 129516 | } | ||
| 129517 | if( sParse.checkSchema ){ | ||
| 129518 | schemaIsValid(&sParse); | ||
| 129519 | } | ||
| 129520 | if( pzTail ){ | 130790 | if( pzTail ){ |
| 129521 | *pzTail = sParse.zTail; | 130791 | *pzTail = sParse.zTail; |
| 129522 | } | 130792 | } |
| @@ -129527,20 +130797,28 @@ static int sqlite3Prepare( | |||
| 129527 | if( db->mallocFailed ){ | 130797 | if( db->mallocFailed ){ |
| 129528 | sParse.rc = SQLITE_NOMEM_BKPT; | 130798 | sParse.rc = SQLITE_NOMEM_BKPT; |
| 129529 | } | 130799 | } |
| 129530 | rc = sParse.rc; | 130800 | if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){ |
| 129531 | if( rc!=SQLITE_OK ){ | 130801 | if( sParse.checkSchema ){ |
| 129532 | if( sParse.pVdbe ) sqlite3VdbeFinalize(sParse.pVdbe); | 130802 | schemaIsValid(&sParse); |
| 129533 | assert(!(*ppStmt)); | 130803 | } |
| 130804 | if( sParse.pVdbe ){ | ||
| 130805 | sqlite3VdbeFinalize(sParse.pVdbe); | ||
| 130806 | } | ||
| 130807 | assert( 0==(*ppStmt) ); | ||
| 130808 | rc = sParse.rc; | ||
| 130809 | if( zErrMsg ){ | ||
| 130810 | sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg); | ||
| 130811 | sqlite3DbFree(db, zErrMsg); | ||
| 130812 | }else{ | ||
| 130813 | sqlite3Error(db, rc); | ||
| 130814 | } | ||
| 129534 | }else{ | 130815 | }else{ |
| 130816 | assert( zErrMsg==0 ); | ||
| 129535 | *ppStmt = (sqlite3_stmt*)sParse.pVdbe; | 130817 | *ppStmt = (sqlite3_stmt*)sParse.pVdbe; |
| 130818 | rc = SQLITE_OK; | ||
| 130819 | sqlite3ErrorClear(db); | ||
| 129536 | } | 130820 | } |
| 129537 | 130821 | ||
| 129538 | if( zErrMsg ){ | ||
| 129539 | sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg); | ||
| 129540 | sqlite3DbFree(db, zErrMsg); | ||
| 129541 | }else{ | ||
| 129542 | sqlite3Error(db, rc); | ||
| 129543 | } | ||
| 129544 | 130822 | ||
| 129545 | /* Delete any TriggerPrg structures allocated while parsing this statement. */ | 130823 | /* Delete any TriggerPrg structures allocated while parsing this statement. */ |
| 129546 | while( sParse.pTriggerPrg ){ | 130824 | while( sParse.pTriggerPrg ){ |
| @@ -129886,12 +131164,16 @@ static void clearSelect(sqlite3 *db, Select *p, int bFree){ | |||
| 129886 | sqlite3ExprDelete(db, p->pHaving); | 131164 | sqlite3ExprDelete(db, p->pHaving); |
| 129887 | sqlite3ExprListDelete(db, p->pOrderBy); | 131165 | sqlite3ExprListDelete(db, p->pOrderBy); |
| 129888 | sqlite3ExprDelete(db, p->pLimit); | 131166 | sqlite3ExprDelete(db, p->pLimit); |
| 131167 | if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith); | ||
| 129889 | #ifndef SQLITE_OMIT_WINDOWFUNC | 131168 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 129890 | if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){ | 131169 | if( OK_IF_ALWAYS_TRUE(p->pWinDefn) ){ |
| 129891 | sqlite3WindowListDelete(db, p->pWinDefn); | 131170 | sqlite3WindowListDelete(db, p->pWinDefn); |
| 129892 | } | 131171 | } |
| 131172 | while( p->pWin ){ | ||
| 131173 | assert( p->pWin->ppThis==&p->pWin ); | ||
| 131174 | sqlite3WindowUnlinkFromSelect(p->pWin); | ||
| 131175 | } | ||
| 129893 | #endif | 131176 | #endif |
| 129894 | if( OK_IF_ALWAYS_TRUE(p->pWith) ) sqlite3WithDelete(db, p->pWith); | ||
| 129895 | if( bFree ) sqlite3DbFreeNN(db, p); | 131177 | if( bFree ) sqlite3DbFreeNN(db, p); |
| 129896 | p = pPrior; | 131178 | p = pPrior; |
| 129897 | bFree = 1; | 131179 | bFree = 1; |
| @@ -130063,7 +131345,7 @@ SQLITE_PRIVATE int sqlite3JoinType(Parse *pParse, Token *pA, Token *pB, Token *p | |||
| 130063 | ** Return the index of a column in a table. Return -1 if the column | 131345 | ** Return the index of a column in a table. Return -1 if the column |
| 130064 | ** is not contained in the table. | 131346 | ** is not contained in the table. |
| 130065 | */ | 131347 | */ |
| 130066 | static int columnIndex(Table *pTab, const char *zCol){ | 131348 | SQLITE_PRIVATE int sqlite3ColumnIndex(Table *pTab, const char *zCol){ |
| 130067 | int i; | 131349 | int i; |
| 130068 | u8 h = sqlite3StrIHash(zCol); | 131350 | u8 h = sqlite3StrIHash(zCol); |
| 130069 | Column *pCol; | 131351 | Column *pCol; |
| @@ -130095,7 +131377,7 @@ static int tableAndColumnIndex( | |||
| 130095 | 131377 | ||
| 130096 | assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */ | 131378 | assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */ |
| 130097 | for(i=0; i<N; i++){ | 131379 | for(i=0; i<N; i++){ |
| 130098 | iCol = columnIndex(pSrc->a[i].pTab, zCol); | 131380 | iCol = sqlite3ColumnIndex(pSrc->a[i].pTab, zCol); |
| 130099 | if( iCol>=0 | 131381 | if( iCol>=0 |
| 130100 | && (bIgnoreHidden==0 || IsHiddenColumn(&pSrc->a[i].pTab->aCol[iCol])==0) | 131382 | && (bIgnoreHidden==0 || IsHiddenColumn(&pSrc->a[i].pTab->aCol[iCol])==0) |
| 130101 | ){ | 131383 | ){ |
| @@ -130148,7 +131430,7 @@ static void addWhereTerm( | |||
| 130148 | ExprSetProperty(pEq, EP_FromJoin); | 131430 | ExprSetProperty(pEq, EP_FromJoin); |
| 130149 | assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); | 131431 | assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); |
| 130150 | ExprSetVVAProperty(pEq, EP_NoReduce); | 131432 | ExprSetVVAProperty(pEq, EP_NoReduce); |
| 130151 | pEq->iRightJoinTable = (i16)pE2->iTable; | 131433 | pEq->iRightJoinTable = pE2->iTable; |
| 130152 | } | 131434 | } |
| 130153 | *ppWhere = sqlite3ExprAnd(pParse, *ppWhere, pEq); | 131435 | *ppWhere = sqlite3ExprAnd(pParse, *ppWhere, pEq); |
| 130154 | } | 131436 | } |
| @@ -130184,7 +131466,7 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){ | |||
| 130184 | ExprSetProperty(p, EP_FromJoin); | 131466 | ExprSetProperty(p, EP_FromJoin); |
| 130185 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); | 131467 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); |
| 130186 | ExprSetVVAProperty(p, EP_NoReduce); | 131468 | ExprSetVVAProperty(p, EP_NoReduce); |
| 130187 | p->iRightJoinTable = (i16)iTable; | 131469 | p->iRightJoinTable = iTable; |
| 130188 | if( p->op==TK_FUNCTION && p->x.pList ){ | 131470 | if( p->op==TK_FUNCTION && p->x.pList ){ |
| 130189 | int i; | 131471 | int i; |
| 130190 | for(i=0; i<p->x.pList->nExpr; i++){ | 131472 | for(i=0; i<p->x.pList->nExpr; i++){ |
| @@ -130208,6 +131490,9 @@ static void unsetJoinExpr(Expr *p, int iTable){ | |||
| 130208 | && (iTable<0 || p->iRightJoinTable==iTable) ){ | 131490 | && (iTable<0 || p->iRightJoinTable==iTable) ){ |
| 130209 | ExprClearProperty(p, EP_FromJoin); | 131491 | ExprClearProperty(p, EP_FromJoin); |
| 130210 | } | 131492 | } |
| 131493 | if( p->op==TK_COLUMN && p->iTable==iTable ){ | ||
| 131494 | ExprClearProperty(p, EP_CanBeNull); | ||
| 131495 | } | ||
| 130211 | if( p->op==TK_FUNCTION && p->x.pList ){ | 131496 | if( p->op==TK_FUNCTION && p->x.pList ){ |
| 130212 | int i; | 131497 | int i; |
| 130213 | for(i=0; i<p->x.pList->nExpr; i++){ | 131498 | for(i=0; i<p->x.pList->nExpr; i++){ |
| @@ -130236,8 +131521,8 @@ static void unsetJoinExpr(Expr *p, int iTable){ | |||
| 130236 | static int sqliteProcessJoin(Parse *pParse, Select *p){ | 131521 | static int sqliteProcessJoin(Parse *pParse, Select *p){ |
| 130237 | SrcList *pSrc; /* All tables in the FROM clause */ | 131522 | SrcList *pSrc; /* All tables in the FROM clause */ |
| 130238 | int i, j; /* Loop counters */ | 131523 | int i, j; /* Loop counters */ |
| 130239 | struct SrcList_item *pLeft; /* Left table being joined */ | 131524 | SrcItem *pLeft; /* Left table being joined */ |
| 130240 | struct SrcList_item *pRight; /* Right table being joined */ | 131525 | SrcItem *pRight; /* Right table being joined */ |
| 130241 | 131526 | ||
| 130242 | pSrc = p->pSrc; | 131527 | pSrc = p->pSrc; |
| 130243 | pLeft = &pSrc->a[0]; | 131528 | pLeft = &pSrc->a[0]; |
| @@ -130305,7 +131590,7 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){ | |||
| 130305 | int iRightCol; /* Column number of matching column on the right */ | 131590 | int iRightCol; /* Column number of matching column on the right */ |
| 130306 | 131591 | ||
| 130307 | zName = pList->a[j].zName; | 131592 | zName = pList->a[j].zName; |
| 130308 | iRightCol = columnIndex(pRightTab, zName); | 131593 | iRightCol = sqlite3ColumnIndex(pRightTab, zName); |
| 130309 | if( iRightCol<0 | 131594 | if( iRightCol<0 |
| 130310 | || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 0) | 131595 | || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 0) |
| 130311 | ){ | 131596 | ){ |
| @@ -131184,7 +132469,7 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoFromExprList( | |||
| 131184 | /* | 132469 | /* |
| 131185 | ** Name of the connection operator, used for error messages. | 132470 | ** Name of the connection operator, used for error messages. |
| 131186 | */ | 132471 | */ |
| 131187 | static const char *selectOpName(int id){ | 132472 | SQLITE_PRIVATE const char *sqlite3SelectOpName(int id){ |
| 131188 | char *z; | 132473 | char *z; |
| 131189 | switch( id ){ | 132474 | switch( id ){ |
| 131190 | case TK_ALL: z = "UNION ALL"; break; | 132475 | case TK_ALL: z = "UNION ALL"; break; |
| @@ -131887,6 +133172,7 @@ SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation( | |||
| 131887 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ | 133172 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 131888 | const char *zType; | 133173 | const char *zType; |
| 131889 | int n, m; | 133174 | int n, m; |
| 133175 | pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); | ||
| 131890 | p = a[i].pExpr; | 133176 | p = a[i].pExpr; |
| 131891 | zType = columnType(&sNC, p, 0, 0, 0); | 133177 | zType = columnType(&sNC, p, 0, 0, 0); |
| 131892 | /* pCol->szEst = ... // Column size est for SELECT tables never used */ | 133178 | /* pCol->szEst = ... // Column size est for SELECT tables never used */ |
| @@ -132402,12 +133688,8 @@ static int multiSelect( | |||
| 132402 | db = pParse->db; | 133688 | db = pParse->db; |
| 132403 | pPrior = p->pPrior; | 133689 | pPrior = p->pPrior; |
| 132404 | dest = *pDest; | 133690 | dest = *pDest; |
| 132405 | if( pPrior->pOrderBy || pPrior->pLimit ){ | 133691 | assert( pPrior->pOrderBy==0 ); |
| 132406 | sqlite3ErrorMsg(pParse,"%s clause should come after %s not before", | 133692 | assert( pPrior->pLimit==0 ); |
| 132407 | pPrior->pOrderBy!=0 ? "ORDER BY" : "LIMIT", selectOpName(p->op)); | ||
| 132408 | rc = 1; | ||
| 132409 | goto multi_select_end; | ||
| 132410 | } | ||
| 132411 | 133693 | ||
| 132412 | v = sqlite3GetVdbe(pParse); | 133694 | v = sqlite3GetVdbe(pParse); |
| 132413 | assert( v!=0 ); /* The VDBE already created by calling function */ | 133695 | assert( v!=0 ); /* The VDBE already created by calling function */ |
| @@ -132464,7 +133746,7 @@ static int multiSelect( | |||
| 132464 | pPrior->iOffset = p->iOffset; | 133746 | pPrior->iOffset = p->iOffset; |
| 132465 | pPrior->pLimit = p->pLimit; | 133747 | pPrior->pLimit = p->pLimit; |
| 132466 | rc = sqlite3Select(pParse, pPrior, &dest); | 133748 | rc = sqlite3Select(pParse, pPrior, &dest); |
| 132467 | p->pLimit = 0; | 133749 | pPrior->pLimit = 0; |
| 132468 | if( rc ){ | 133750 | if( rc ){ |
| 132469 | goto multi_select_end; | 133751 | goto multi_select_end; |
| 132470 | } | 133752 | } |
| @@ -132485,8 +133767,8 @@ static int multiSelect( | |||
| 132485 | pDelete = p->pPrior; | 133767 | pDelete = p->pPrior; |
| 132486 | p->pPrior = pPrior; | 133768 | p->pPrior = pPrior; |
| 132487 | p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); | 133769 | p->nSelectRow = sqlite3LogEstAdd(p->nSelectRow, pPrior->nSelectRow); |
| 132488 | if( pPrior->pLimit | 133770 | if( p->pLimit |
| 132489 | && sqlite3ExprIsInteger(pPrior->pLimit->pLeft, &nLimit) | 133771 | && sqlite3ExprIsInteger(p->pLimit->pLeft, &nLimit) |
| 132490 | && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) | 133772 | && nLimit>0 && p->nSelectRow > sqlite3LogEst((u64)nLimit) |
| 132491 | ){ | 133773 | ){ |
| 132492 | p->nSelectRow = sqlite3LogEst((u64)nLimit); | 133774 | p->nSelectRow = sqlite3LogEst((u64)nLimit); |
| @@ -132550,7 +133832,7 @@ static int multiSelect( | |||
| 132550 | p->pLimit = 0; | 133832 | p->pLimit = 0; |
| 132551 | uniondest.eDest = op; | 133833 | uniondest.eDest = op; |
| 132552 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", | 133834 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", |
| 132553 | selectOpName(p->op))); | 133835 | sqlite3SelectOpName(p->op))); |
| 132554 | rc = sqlite3Select(pParse, p, &uniondest); | 133836 | rc = sqlite3Select(pParse, p, &uniondest); |
| 132555 | testcase( rc!=SQLITE_OK ); | 133837 | testcase( rc!=SQLITE_OK ); |
| 132556 | assert( p->pOrderBy==0 ); | 133838 | assert( p->pOrderBy==0 ); |
| @@ -132626,7 +133908,7 @@ static int multiSelect( | |||
| 132626 | p->pLimit = 0; | 133908 | p->pLimit = 0; |
| 132627 | intersectdest.iSDParm = tab2; | 133909 | intersectdest.iSDParm = tab2; |
| 132628 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", | 133910 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", |
| 132629 | selectOpName(p->op))); | 133911 | sqlite3SelectOpName(p->op))); |
| 132630 | rc = sqlite3Select(pParse, p, &intersectdest); | 133912 | rc = sqlite3Select(pParse, p, &intersectdest); |
| 132631 | testcase( rc!=SQLITE_OK ); | 133913 | testcase( rc!=SQLITE_OK ); |
| 132632 | pDelete = p->pPrior; | 133914 | pDelete = p->pPrior; |
| @@ -132735,7 +134017,8 @@ SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p){ | |||
| 132735 | sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms"); | 134017 | sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms"); |
| 132736 | }else{ | 134018 | }else{ |
| 132737 | sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" | 134019 | sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s" |
| 132738 | " do not have the same number of result columns", selectOpName(p->op)); | 134020 | " do not have the same number of result columns", |
| 134021 | sqlite3SelectOpName(p->op)); | ||
| 132739 | } | 134022 | } |
| 132740 | } | 134023 | } |
| 132741 | 134024 | ||
| @@ -132832,10 +134115,8 @@ static int generateOutputSubroutine( | |||
| 132832 | ** if it is the RHS of a row-value IN operator. | 134115 | ** if it is the RHS of a row-value IN operator. |
| 132833 | */ | 134116 | */ |
| 132834 | case SRT_Mem: { | 134117 | case SRT_Mem: { |
| 132835 | if( pParse->nErr==0 ){ | 134118 | testcase( pIn->nSdst>1 ); |
| 132836 | testcase( pIn->nSdst>1 ); | 134119 | sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, pIn->nSdst); |
| 132837 | sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, pIn->nSdst); | ||
| 132838 | } | ||
| 132839 | /* The LIMIT clause will jump out of the loop for us */ | 134120 | /* The LIMIT clause will jump out of the loop for us */ |
| 132840 | break; | 134121 | break; |
| 132841 | } | 134122 | } |
| @@ -133127,7 +134408,7 @@ static int multiSelectOrderBy( | |||
| 133127 | sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA); | 134408 | sqlite3SelectDestInit(&destA, SRT_Coroutine, regAddrA); |
| 133128 | sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB); | 134409 | sqlite3SelectDestInit(&destB, SRT_Coroutine, regAddrB); |
| 133129 | 134410 | ||
| 133130 | ExplainQueryPlan((pParse, 1, "MERGE (%s)", selectOpName(p->op))); | 134411 | ExplainQueryPlan((pParse, 1, "MERGE (%s)", sqlite3SelectOpName(p->op))); |
| 133131 | 134412 | ||
| 133132 | /* Generate a coroutine to evaluate the SELECT statement to the | 134413 | /* Generate a coroutine to evaluate the SELECT statement to the |
| 133133 | ** left of the compound operator - the "A" select. | 134414 | ** left of the compound operator - the "A" select. |
| @@ -133397,7 +134678,7 @@ static void substSelect( | |||
| 133397 | int doPrior /* Do substitutes on p->pPrior too */ | 134678 | int doPrior /* Do substitutes on p->pPrior too */ |
| 133398 | ){ | 134679 | ){ |
| 133399 | SrcList *pSrc; | 134680 | SrcList *pSrc; |
| 133400 | struct SrcList_item *pItem; | 134681 | SrcItem *pItem; |
| 133401 | int i; | 134682 | int i; |
| 133402 | if( !p ) return; | 134683 | if( !p ) return; |
| 133403 | do{ | 134684 | do{ |
| @@ -133427,7 +134708,7 @@ static void substSelect( | |||
| 133427 | ** pSrcItem->colUsed mask. | 134708 | ** pSrcItem->colUsed mask. |
| 133428 | */ | 134709 | */ |
| 133429 | static int recomputeColumnsUsedExpr(Walker *pWalker, Expr *pExpr){ | 134710 | static int recomputeColumnsUsedExpr(Walker *pWalker, Expr *pExpr){ |
| 133430 | struct SrcList_item *pItem; | 134711 | SrcItem *pItem; |
| 133431 | if( pExpr->op!=TK_COLUMN ) return WRC_Continue; | 134712 | if( pExpr->op!=TK_COLUMN ) return WRC_Continue; |
| 133432 | pItem = pWalker->u.pSrcItem; | 134713 | pItem = pWalker->u.pSrcItem; |
| 133433 | if( pItem->iCursor!=pExpr->iTable ) return WRC_Continue; | 134714 | if( pItem->iCursor!=pExpr->iTable ) return WRC_Continue; |
| @@ -133437,7 +134718,7 @@ static int recomputeColumnsUsedExpr(Walker *pWalker, Expr *pExpr){ | |||
| 133437 | } | 134718 | } |
| 133438 | static void recomputeColumnsUsed( | 134719 | static void recomputeColumnsUsed( |
| 133439 | Select *pSelect, /* The complete SELECT statement */ | 134720 | Select *pSelect, /* The complete SELECT statement */ |
| 133440 | struct SrcList_item *pSrcItem /* Which FROM clause item to recompute */ | 134721 | SrcItem *pSrcItem /* Which FROM clause item to recompute */ |
| 133441 | ){ | 134722 | ){ |
| 133442 | Walker w; | 134723 | Walker w; |
| 133443 | if( NEVER(pSrcItem->pTab==0) ) return; | 134724 | if( NEVER(pSrcItem->pTab==0) ) return; |
| @@ -133452,6 +134733,89 @@ static void recomputeColumnsUsed( | |||
| 133452 | 134733 | ||
| 133453 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) | 134734 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 133454 | /* | 134735 | /* |
| 134736 | ** Assign new cursor numbers to each of the items in pSrc. For each | ||
| 134737 | ** new cursor number assigned, set an entry in the aCsrMap[] array | ||
| 134738 | ** to map the old cursor number to the new: | ||
| 134739 | ** | ||
| 134740 | ** aCsrMap[iOld] = iNew; | ||
| 134741 | ** | ||
| 134742 | ** The array is guaranteed by the caller to be large enough for all | ||
| 134743 | ** existing cursor numbers in pSrc. | ||
| 134744 | ** | ||
| 134745 | ** If pSrc contains any sub-selects, call this routine recursively | ||
| 134746 | ** on the FROM clause of each such sub-select, with iExcept set to -1. | ||
| 134747 | */ | ||
| 134748 | static void srclistRenumberCursors( | ||
| 134749 | Parse *pParse, /* Parse context */ | ||
| 134750 | int *aCsrMap, /* Array to store cursor mappings in */ | ||
| 134751 | SrcList *pSrc, /* FROM clause to renumber */ | ||
| 134752 | int iExcept /* FROM clause item to skip */ | ||
| 134753 | ){ | ||
| 134754 | int i; | ||
| 134755 | SrcItem *pItem; | ||
| 134756 | for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){ | ||
| 134757 | if( i!=iExcept ){ | ||
| 134758 | Select *p; | ||
| 134759 | pItem->iCursor = aCsrMap[pItem->iCursor] = pParse->nTab++; | ||
| 134760 | for(p=pItem->pSelect; p; p=p->pPrior){ | ||
| 134761 | srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); | ||
| 134762 | } | ||
| 134763 | } | ||
| 134764 | } | ||
| 134765 | } | ||
| 134766 | |||
| 134767 | /* | ||
| 134768 | ** Expression walker callback used by renumberCursors() to update | ||
| 134769 | ** Expr objects to match newly assigned cursor numbers. | ||
| 134770 | */ | ||
| 134771 | static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){ | ||
| 134772 | int *aCsrMap = pWalker->u.aiCol; | ||
| 134773 | int op = pExpr->op; | ||
| 134774 | if( (op==TK_COLUMN || op==TK_IF_NULL_ROW) && aCsrMap[pExpr->iTable] ){ | ||
| 134775 | pExpr->iTable = aCsrMap[pExpr->iTable]; | ||
| 134776 | } | ||
| 134777 | if( ExprHasProperty(pExpr, EP_FromJoin) && aCsrMap[pExpr->iRightJoinTable] ){ | ||
| 134778 | pExpr->iRightJoinTable = aCsrMap[pExpr->iRightJoinTable]; | ||
| 134779 | } | ||
| 134780 | return WRC_Continue; | ||
| 134781 | } | ||
| 134782 | |||
| 134783 | /* | ||
| 134784 | ** Assign a new cursor number to each cursor in the FROM clause (Select.pSrc) | ||
| 134785 | ** of the SELECT statement passed as the second argument, and to each | ||
| 134786 | ** cursor in the FROM clause of any FROM clause sub-selects, recursively. | ||
| 134787 | ** Except, do not assign a new cursor number to the iExcept'th element in | ||
| 134788 | ** the FROM clause of (*p). Update all expressions and other references | ||
| 134789 | ** to refer to the new cursor numbers. | ||
| 134790 | ** | ||
| 134791 | ** Argument aCsrMap is an array that may be used for temporary working | ||
| 134792 | ** space. Two guarantees are made by the caller: | ||
| 134793 | ** | ||
| 134794 | ** * the array is larger than the largest cursor number used within the | ||
| 134795 | ** select statement passed as an argument, and | ||
| 134796 | ** | ||
| 134797 | ** * the array entries for all cursor numbers that do *not* appear in | ||
| 134798 | ** FROM clauses of the select statement as described above are | ||
| 134799 | ** initialized to zero. | ||
| 134800 | */ | ||
| 134801 | static void renumberCursors( | ||
| 134802 | Parse *pParse, /* Parse context */ | ||
| 134803 | Select *p, /* Select to renumber cursors within */ | ||
| 134804 | int iExcept, /* FROM clause item to skip */ | ||
| 134805 | int *aCsrMap /* Working space */ | ||
| 134806 | ){ | ||
| 134807 | Walker w; | ||
| 134808 | srclistRenumberCursors(pParse, aCsrMap, p->pSrc, iExcept); | ||
| 134809 | memset(&w, 0, sizeof(w)); | ||
| 134810 | w.u.aiCol = aCsrMap; | ||
| 134811 | w.xExprCallback = renumberCursorsCb; | ||
| 134812 | w.xSelectCallback = sqlite3SelectWalkNoop; | ||
| 134813 | sqlite3WalkSelect(&w, p); | ||
| 134814 | } | ||
| 134815 | #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */ | ||
| 134816 | |||
| 134817 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) | ||
| 134818 | /* | ||
| 133455 | ** This routine attempts to flatten subqueries as a performance optimization. | 134819 | ** This routine attempts to flatten subqueries as a performance optimization. |
| 133456 | ** This routine returns 1 if it makes changes and 0 if no flattening occurs. | 134820 | ** This routine returns 1 if it makes changes and 0 if no flattening occurs. |
| 133457 | ** | 134821 | ** |
| @@ -133544,9 +134908,9 @@ static void recomputeColumnsUsed( | |||
| 133544 | ** (17c) every term within the subquery compound must have a FROM clause | 134908 | ** (17c) every term within the subquery compound must have a FROM clause |
| 133545 | ** (17d) the outer query may not be | 134909 | ** (17d) the outer query may not be |
| 133546 | ** (17d1) aggregate, or | 134910 | ** (17d1) aggregate, or |
| 133547 | ** (17d2) DISTINCT, or | 134911 | ** (17d2) DISTINCT |
| 133548 | ** (17d3) a join. | 134912 | ** (17e) the subquery may not contain window functions, and |
| 133549 | ** (17e) the subquery may not contain window functions | 134913 | ** (17f) the subquery must not be the RHS of a LEFT JOIN. |
| 133550 | ** | 134914 | ** |
| 133551 | ** The parent and sub-query may contain WHERE clauses. Subject to | 134915 | ** The parent and sub-query may contain WHERE clauses. Subject to |
| 133552 | ** rules (11), (13) and (14), they may also contain ORDER BY, | 134916 | ** rules (11), (13) and (14), they may also contain ORDER BY, |
| @@ -133562,8 +134926,8 @@ static void recomputeColumnsUsed( | |||
| 133562 | ** syntax error and return a detailed message. | 134926 | ** syntax error and return a detailed message. |
| 133563 | ** | 134927 | ** |
| 133564 | ** (18) If the sub-query is a compound select, then all terms of the | 134928 | ** (18) If the sub-query is a compound select, then all terms of the |
| 133565 | ** ORDER BY clause of the parent must be simple references to | 134929 | ** ORDER BY clause of the parent must be copies of a term returned |
| 133566 | ** columns of the sub-query. | 134930 | ** by the parent query. |
| 133567 | ** | 134931 | ** |
| 133568 | ** (19) If the subquery uses LIMIT then the outer query may not | 134932 | ** (19) If the subquery uses LIMIT then the outer query may not |
| 133569 | ** have a WHERE clause. | 134933 | ** have a WHERE clause. |
| @@ -133579,9 +134943,8 @@ static void recomputeColumnsUsed( | |||
| 133579 | ** | 134943 | ** |
| 133580 | ** (22) The subquery may not be a recursive CTE. | 134944 | ** (22) The subquery may not be a recursive CTE. |
| 133581 | ** | 134945 | ** |
| 133582 | ** (**) Subsumed into restriction (17d3). Was: If the outer query is | 134946 | ** (23) If the outer query is a recursive CTE, then the sub-query may not be |
| 133583 | ** a recursive CTE, then the sub-query may not be a compound query. | 134947 | ** a compound query. This restriction is because transforming the |
| 133584 | ** This restriction is because transforming the | ||
| 133585 | ** parent to a compound query confuses the code that handles | 134948 | ** parent to a compound query confuses the code that handles |
| 133586 | ** recursive queries in multiSelect(). | 134949 | ** recursive queries in multiSelect(). |
| 133587 | ** | 134950 | ** |
| @@ -133623,9 +134986,10 @@ static int flattenSubquery( | |||
| 133623 | int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */ | 134986 | int isLeftJoin = 0; /* True if pSub is the right side of a LEFT JOIN */ |
| 133624 | int i; /* Loop counter */ | 134987 | int i; /* Loop counter */ |
| 133625 | Expr *pWhere; /* The WHERE clause */ | 134988 | Expr *pWhere; /* The WHERE clause */ |
| 133626 | struct SrcList_item *pSubitem; /* The subquery */ | 134989 | SrcItem *pSubitem; /* The subquery */ |
| 133627 | sqlite3 *db = pParse->db; | 134990 | sqlite3 *db = pParse->db; |
| 133628 | Walker w; /* Walker to persist agginfo data */ | 134991 | Walker w; /* Walker to persist agginfo data */ |
| 134992 | int *aCsrMap = 0; | ||
| 133629 | 134993 | ||
| 133630 | /* Check to see if flattening is permitted. Return 0 if not. | 134994 | /* Check to see if flattening is permitted. Return 0 if not. |
| 133631 | */ | 134995 | */ |
| @@ -133721,13 +135085,14 @@ static int flattenSubquery( | |||
| 133721 | if( pSub->pOrderBy ){ | 135085 | if( pSub->pOrderBy ){ |
| 133722 | return 0; /* Restriction (20) */ | 135086 | return 0; /* Restriction (20) */ |
| 133723 | } | 135087 | } |
| 133724 | if( isAgg || (p->selFlags & SF_Distinct)!=0 || pSrc->nSrc!=1 ){ | 135088 | if( isAgg || (p->selFlags & SF_Distinct)!=0 || isLeftJoin>0 ){ |
| 133725 | return 0; /* (17d1), (17d2), or (17d3) */ | 135089 | return 0; /* (17d1), (17d2), or (17f) */ |
| 133726 | } | 135090 | } |
| 133727 | for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){ | 135091 | for(pSub1=pSub; pSub1; pSub1=pSub1->pPrior){ |
| 133728 | testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct ); | 135092 | testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct ); |
| 133729 | testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate ); | 135093 | testcase( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))==SF_Aggregate ); |
| 133730 | assert( pSub->pSrc!=0 ); | 135094 | assert( pSub->pSrc!=0 ); |
| 135095 | assert( (pSub->selFlags & SF_Recursive)==0 ); | ||
| 133731 | assert( pSub->pEList->nExpr==pSub1->pEList->nExpr ); | 135096 | assert( pSub->pEList->nExpr==pSub1->pEList->nExpr ); |
| 133732 | if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0 /* (17b) */ | 135097 | if( (pSub1->selFlags & (SF_Distinct|SF_Aggregate))!=0 /* (17b) */ |
| 133733 | || (pSub1->pPrior && pSub1->op!=TK_ALL) /* (17a) */ | 135098 | || (pSub1->pPrior && pSub1->op!=TK_ALL) /* (17a) */ |
| @@ -133748,15 +135113,14 @@ static int flattenSubquery( | |||
| 133748 | if( p->pOrderBy->a[ii].u.x.iOrderByCol==0 ) return 0; | 135113 | if( p->pOrderBy->a[ii].u.x.iOrderByCol==0 ) return 0; |
| 133749 | } | 135114 | } |
| 133750 | } | 135115 | } |
| 133751 | } | ||
| 133752 | 135116 | ||
| 133753 | /* Ex-restriction (23): | 135117 | /* Restriction (23) */ |
| 133754 | ** The only way that the recursive part of a CTE can contain a compound | 135118 | if( (p->selFlags & SF_Recursive) ) return 0; |
| 133755 | ** subquery is for the subquery to be one term of a join. But if the | 135119 | |
| 133756 | ** subquery is a join, then the flattening has already been stopped by | 135120 | if( pSrc->nSrc>1 ){ |
| 133757 | ** restriction (17d3) | 135121 | aCsrMap = sqlite3DbMallocZero(db, pParse->nTab*sizeof(int)); |
| 133758 | */ | 135122 | } |
| 133759 | assert( (p->selFlags & SF_Recursive)==0 || pSub->pPrior==0 ); | 135123 | } |
| 133760 | 135124 | ||
| 133761 | /***** If we reach this point, flattening is permitted. *****/ | 135125 | /***** If we reach this point, flattening is permitted. *****/ |
| 133762 | SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n", | 135126 | SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n", |
| @@ -133768,6 +135132,17 @@ static int flattenSubquery( | |||
| 133768 | testcase( i==SQLITE_DENY ); | 135132 | testcase( i==SQLITE_DENY ); |
| 133769 | pParse->zAuthContext = zSavedAuthContext; | 135133 | pParse->zAuthContext = zSavedAuthContext; |
| 133770 | 135134 | ||
| 135135 | /* Delete the transient structures associated with thesubquery */ | ||
| 135136 | pSub1 = pSubitem->pSelect; | ||
| 135137 | sqlite3DbFree(db, pSubitem->zDatabase); | ||
| 135138 | sqlite3DbFree(db, pSubitem->zName); | ||
| 135139 | sqlite3DbFree(db, pSubitem->zAlias); | ||
| 135140 | pSubitem->zDatabase = 0; | ||
| 135141 | pSubitem->zName = 0; | ||
| 135142 | pSubitem->zAlias = 0; | ||
| 135143 | pSubitem->pSelect = 0; | ||
| 135144 | assert( pSubitem->pOn==0 ); | ||
| 135145 | |||
| 133771 | /* If the sub-query is a compound SELECT statement, then (by restrictions | 135146 | /* If the sub-query is a compound SELECT statement, then (by restrictions |
| 133772 | ** 17 and 18 above) it must be a UNION ALL and the parent query must | 135147 | ** 17 and 18 above) it must be a UNION ALL and the parent query must |
| 133773 | ** be of the form: | 135148 | ** be of the form: |
| @@ -133806,18 +135181,22 @@ static int flattenSubquery( | |||
| 133806 | ExprList *pOrderBy = p->pOrderBy; | 135181 | ExprList *pOrderBy = p->pOrderBy; |
| 133807 | Expr *pLimit = p->pLimit; | 135182 | Expr *pLimit = p->pLimit; |
| 133808 | Select *pPrior = p->pPrior; | 135183 | Select *pPrior = p->pPrior; |
| 135184 | Table *pItemTab = pSubitem->pTab; | ||
| 135185 | pSubitem->pTab = 0; | ||
| 133809 | p->pOrderBy = 0; | 135186 | p->pOrderBy = 0; |
| 133810 | p->pSrc = 0; | ||
| 133811 | p->pPrior = 0; | 135187 | p->pPrior = 0; |
| 133812 | p->pLimit = 0; | 135188 | p->pLimit = 0; |
| 133813 | pNew = sqlite3SelectDup(db, p, 0); | 135189 | pNew = sqlite3SelectDup(db, p, 0); |
| 133814 | p->pLimit = pLimit; | 135190 | p->pLimit = pLimit; |
| 133815 | p->pOrderBy = pOrderBy; | 135191 | p->pOrderBy = pOrderBy; |
| 133816 | p->pSrc = pSrc; | ||
| 133817 | p->op = TK_ALL; | 135192 | p->op = TK_ALL; |
| 135193 | pSubitem->pTab = pItemTab; | ||
| 133818 | if( pNew==0 ){ | 135194 | if( pNew==0 ){ |
| 133819 | p->pPrior = pPrior; | 135195 | p->pPrior = pPrior; |
| 133820 | }else{ | 135196 | }else{ |
| 135197 | if( aCsrMap && db->mallocFailed==0 ){ | ||
| 135198 | renumberCursors(pParse, pNew, iFrom, aCsrMap); | ||
| 135199 | } | ||
| 133821 | pNew->pPrior = pPrior; | 135200 | pNew->pPrior = pPrior; |
| 133822 | if( pPrior ) pPrior->pNext = pNew; | 135201 | if( pPrior ) pPrior->pNext = pNew; |
| 133823 | pNew->pNext = p; | 135202 | pNew->pNext = p; |
| @@ -133825,24 +135204,13 @@ static int flattenSubquery( | |||
| 133825 | SELECTTRACE(2,pParse,p,("compound-subquery flattener" | 135204 | SELECTTRACE(2,pParse,p,("compound-subquery flattener" |
| 133826 | " creates %u as peer\n",pNew->selId)); | 135205 | " creates %u as peer\n",pNew->selId)); |
| 133827 | } | 135206 | } |
| 133828 | if( db->mallocFailed ) return 1; | 135207 | assert( pSubitem->pSelect==0 ); |
| 135208 | } | ||
| 135209 | sqlite3DbFree(db, aCsrMap); | ||
| 135210 | if( db->mallocFailed ){ | ||
| 135211 | pSubitem->pSelect = pSub1; | ||
| 135212 | return 1; | ||
| 133829 | } | 135213 | } |
| 133830 | |||
| 133831 | /* Begin flattening the iFrom-th entry of the FROM clause | ||
| 133832 | ** in the outer query. | ||
| 133833 | */ | ||
| 133834 | pSub = pSub1 = pSubitem->pSelect; | ||
| 133835 | |||
| 133836 | /* Delete the transient table structure associated with the | ||
| 133837 | ** subquery | ||
| 133838 | */ | ||
| 133839 | sqlite3DbFree(db, pSubitem->zDatabase); | ||
| 133840 | sqlite3DbFree(db, pSubitem->zName); | ||
| 133841 | sqlite3DbFree(db, pSubitem->zAlias); | ||
| 133842 | pSubitem->zDatabase = 0; | ||
| 133843 | pSubitem->zName = 0; | ||
| 133844 | pSubitem->zAlias = 0; | ||
| 133845 | pSubitem->pSelect = 0; | ||
| 133846 | 135214 | ||
| 133847 | /* Defer deleting the Table object associated with the | 135215 | /* Defer deleting the Table object associated with the |
| 133848 | ** subquery until code generation is | 135216 | ** subquery until code generation is |
| @@ -133855,8 +135223,10 @@ static int flattenSubquery( | |||
| 133855 | Table *pTabToDel = pSubitem->pTab; | 135223 | Table *pTabToDel = pSubitem->pTab; |
| 133856 | if( pTabToDel->nTabRef==1 ){ | 135224 | if( pTabToDel->nTabRef==1 ){ |
| 133857 | Parse *pToplevel = sqlite3ParseToplevel(pParse); | 135225 | Parse *pToplevel = sqlite3ParseToplevel(pParse); |
| 133858 | pTabToDel->pNextZombie = pToplevel->pZombieTab; | 135226 | sqlite3ParserAddCleanup(pToplevel, |
| 133859 | pToplevel->pZombieTab = pTabToDel; | 135227 | (void(*)(sqlite3*,void*))sqlite3DeleteTable, |
| 135228 | pTabToDel); | ||
| 135229 | testcase( pToplevel->earlyCleanup ); | ||
| 133860 | }else{ | 135230 | }else{ |
| 133861 | pTabToDel->nTabRef--; | 135231 | pTabToDel->nTabRef--; |
| 133862 | } | 135232 | } |
| @@ -133876,6 +135246,7 @@ static int flattenSubquery( | |||
| 133876 | ** those references with expressions that resolve to the subquery FROM | 135246 | ** those references with expressions that resolve to the subquery FROM |
| 133877 | ** elements we are now copying in. | 135247 | ** elements we are now copying in. |
| 133878 | */ | 135248 | */ |
| 135249 | pSub = pSub1; | ||
| 133879 | for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){ | 135250 | for(pParent=p; pParent; pParent=pParent->pPrior, pSub=pSub->pPrior){ |
| 133880 | int nSubSrc; | 135251 | int nSubSrc; |
| 133881 | u8 jointype = 0; | 135252 | u8 jointype = 0; |
| @@ -133884,14 +135255,8 @@ static int flattenSubquery( | |||
| 133884 | nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */ | 135255 | nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */ |
| 133885 | pSrc = pParent->pSrc; /* FROM clause of the outer query */ | 135256 | pSrc = pParent->pSrc; /* FROM clause of the outer query */ |
| 133886 | 135257 | ||
| 133887 | if( pSrc ){ | 135258 | if( pParent==p ){ |
| 133888 | assert( pParent==p ); /* First time through the loop */ | 135259 | jointype = pSubitem->fg.jointype; /* First time through the loop */ |
| 133889 | jointype = pSubitem->fg.jointype; | ||
| 133890 | }else{ | ||
| 133891 | assert( pParent!=p ); /* 2nd and subsequent times through the loop */ | ||
| 133892 | pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); | ||
| 133893 | if( pSrc==0 ) break; | ||
| 133894 | pParent->pSrc = pSrc; | ||
| 133895 | } | 135260 | } |
| 133896 | 135261 | ||
| 133897 | /* The subquery uses a single slot of the FROM clause of the outer | 135262 | /* The subquery uses a single slot of the FROM clause of the outer |
| @@ -134011,7 +135376,7 @@ static int flattenSubquery( | |||
| 134011 | sqlite3SelectDelete(db, pSub1); | 135376 | sqlite3SelectDelete(db, pSub1); |
| 134012 | 135377 | ||
| 134013 | #if SELECTTRACE_ENABLED | 135378 | #if SELECTTRACE_ENABLED |
| 134014 | if( sqlite3_unsupported_selecttrace & 0x100 ){ | 135379 | if( sqlite3SelectTrace & 0x100 ){ |
| 134015 | SELECTTRACE(0x100,pParse,p,("After flattening:\n")); | 135380 | SELECTTRACE(0x100,pParse,p,("After flattening:\n")); |
| 134016 | sqlite3TreeViewSelect(0, p, 0); | 135381 | sqlite3TreeViewSelect(0, p, 0); |
| 134017 | } | 135382 | } |
| @@ -134206,6 +135571,35 @@ static int propagateConstants( | |||
| 134206 | } | 135571 | } |
| 134207 | 135572 | ||
| 134208 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) | 135573 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 135574 | # if !defined(SQLITE_OMIT_WINDOWFUNC) | ||
| 135575 | /* | ||
| 135576 | ** This function is called to determine whether or not it is safe to | ||
| 135577 | ** push WHERE clause expression pExpr down to FROM clause sub-query | ||
| 135578 | ** pSubq, which contains at least one window function. Return 1 | ||
| 135579 | ** if it is safe and the expression should be pushed down, or 0 | ||
| 135580 | ** otherwise. | ||
| 135581 | ** | ||
| 135582 | ** It is only safe to push the expression down if it consists only | ||
| 135583 | ** of constants and copies of expressions that appear in the PARTITION | ||
| 135584 | ** BY clause of all window function used by the sub-query. It is safe | ||
| 135585 | ** to filter out entire partitions, but not rows within partitions, as | ||
| 135586 | ** this may change the results of the window functions. | ||
| 135587 | ** | ||
| 135588 | ** At the time this function is called it is guaranteed that | ||
| 135589 | ** | ||
| 135590 | ** * the sub-query uses only one distinct window frame, and | ||
| 135591 | ** * that the window frame has a PARTITION BY clase. | ||
| 135592 | */ | ||
| 135593 | static int pushDownWindowCheck(Parse *pParse, Select *pSubq, Expr *pExpr){ | ||
| 135594 | assert( pSubq->pWin->pPartition ); | ||
| 135595 | assert( (pSubq->selFlags & SF_MultiPart)==0 ); | ||
| 135596 | assert( pSubq->pPrior==0 ); | ||
| 135597 | return sqlite3ExprIsConstantOrGroupBy(pParse, pExpr, pSubq->pWin->pPartition); | ||
| 135598 | } | ||
| 135599 | # endif /* SQLITE_OMIT_WINDOWFUNC */ | ||
| 135600 | #endif /* !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) */ | ||
| 135601 | |||
| 135602 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) | ||
| 134209 | /* | 135603 | /* |
| 134210 | ** Make copies of relevant WHERE clause terms of the outer query into | 135604 | ** Make copies of relevant WHERE clause terms of the outer query into |
| 134211 | ** the WHERE clause of subquery. Example: | 135605 | ** the WHERE clause of subquery. Example: |
| @@ -134252,9 +135646,24 @@ static int propagateConstants( | |||
| 134252 | ** But if the (b2=2) term were to be pushed down into the bb subquery, | 135646 | ** But if the (b2=2) term were to be pushed down into the bb subquery, |
| 134253 | ** then the (1,1,NULL) row would be suppressed. | 135647 | ** then the (1,1,NULL) row would be suppressed. |
| 134254 | ** | 135648 | ** |
| 134255 | ** (6) The inner query features one or more window-functions (since | 135649 | ** (6) Window functions make things tricky as changes to the WHERE clause |
| 134256 | ** changes to the WHERE clause of the inner query could change the | 135650 | ** of the inner query could change the window over which window |
| 134257 | ** window over which window functions are calculated). | 135651 | ** functions are calculated. Therefore, do not attempt the optimization |
| 135652 | ** if: | ||
| 135653 | ** | ||
| 135654 | ** (6a) The inner query uses multiple incompatible window partitions. | ||
| 135655 | ** | ||
| 135656 | ** (6b) The inner query is a compound and uses window-functions. | ||
| 135657 | ** | ||
| 135658 | ** (6c) The WHERE clause does not consist entirely of constants and | ||
| 135659 | ** copies of expressions found in the PARTITION BY clause of | ||
| 135660 | ** all window-functions used by the sub-query. It is safe to | ||
| 135661 | ** filter out entire partitions, as this does not change the | ||
| 135662 | ** window over which any window-function is calculated. | ||
| 135663 | ** | ||
| 135664 | ** (7) The inner query is a Common Table Expression (CTE) that should | ||
| 135665 | ** be materialized. (This restriction is implemented in the calling | ||
| 135666 | ** routine.) | ||
| 134258 | ** | 135667 | ** |
| 134259 | ** Return 0 if no changes are made and non-zero if one or more WHERE clause | 135668 | ** Return 0 if no changes are made and non-zero if one or more WHERE clause |
| 134260 | ** terms are duplicated into the subquery. | 135669 | ** terms are duplicated into the subquery. |
| @@ -134268,13 +135677,17 @@ static int pushDownWhereTerms( | |||
| 134268 | ){ | 135677 | ){ |
| 134269 | Expr *pNew; | 135678 | Expr *pNew; |
| 134270 | int nChng = 0; | 135679 | int nChng = 0; |
| 134271 | Select *pSel; | ||
| 134272 | if( pWhere==0 ) return 0; | 135680 | if( pWhere==0 ) return 0; |
| 134273 | if( pSubq->selFlags & SF_Recursive ) return 0; /* restriction (2) */ | 135681 | if( pSubq->selFlags & (SF_Recursive|SF_MultiPart) ) return 0; |
| 134274 | 135682 | ||
| 134275 | #ifndef SQLITE_OMIT_WINDOWFUNC | 135683 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 134276 | for(pSel=pSubq; pSel; pSel=pSel->pPrior){ | 135684 | if( pSubq->pPrior ){ |
| 134277 | if( pSel->pWin ) return 0; /* restriction (6) */ | 135685 | Select *pSel; |
| 135686 | for(pSel=pSubq; pSel; pSel=pSel->pPrior){ | ||
| 135687 | if( pSel->pWin ) return 0; /* restriction (6b) */ | ||
| 135688 | } | ||
| 135689 | }else{ | ||
| 135690 | if( pSubq->pWin && pSubq->pWin->pPartition==0 ) return 0; | ||
| 134278 | } | 135691 | } |
| 134279 | #endif | 135692 | #endif |
| 134280 | 135693 | ||
| @@ -134310,6 +135723,7 @@ static int pushDownWhereTerms( | |||
| 134310 | } | 135723 | } |
| 134311 | if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ | 135724 | if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ |
| 134312 | nChng++; | 135725 | nChng++; |
| 135726 | pSubq->selFlags |= SF_PushDown; | ||
| 134313 | while( pSubq ){ | 135727 | while( pSubq ){ |
| 134314 | SubstContext x; | 135728 | SubstContext x; |
| 134315 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); | 135729 | pNew = sqlite3ExprDup(pParse->db, pWhere, 0); |
| @@ -134320,6 +135734,14 @@ static int pushDownWhereTerms( | |||
| 134320 | x.isLeftJoin = 0; | 135734 | x.isLeftJoin = 0; |
| 134321 | x.pEList = pSubq->pEList; | 135735 | x.pEList = pSubq->pEList; |
| 134322 | pNew = substExpr(&x, pNew); | 135736 | pNew = substExpr(&x, pNew); |
| 135737 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 135738 | if( pSubq->pWin && 0==pushDownWindowCheck(pParse, pSubq, pNew) ){ | ||
| 135739 | /* Restriction 6c has prevented push-down in this case */ | ||
| 135740 | sqlite3ExprDelete(pParse->db, pNew); | ||
| 135741 | nChng--; | ||
| 135742 | break; | ||
| 135743 | } | ||
| 135744 | #endif | ||
| 134323 | if( pSubq->selFlags & SF_Aggregate ){ | 135745 | if( pSubq->selFlags & SF_Aggregate ){ |
| 134324 | pSubq->pHaving = sqlite3ExprAnd(pParse, pSubq->pHaving, pNew); | 135746 | pSubq->pHaving = sqlite3ExprAnd(pParse, pSubq->pHaving, pNew); |
| 134325 | }else{ | 135747 | }else{ |
| @@ -134358,7 +135780,11 @@ static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){ | |||
| 134358 | assert( *ppMinMax==0 ); | 135780 | assert( *ppMinMax==0 ); |
| 134359 | assert( pFunc->op==TK_AGG_FUNCTION ); | 135781 | assert( pFunc->op==TK_AGG_FUNCTION ); |
| 134360 | assert( !IsWindowFunc(pFunc) ); | 135782 | assert( !IsWindowFunc(pFunc) ); |
| 134361 | if( pEList==0 || pEList->nExpr!=1 || ExprHasProperty(pFunc, EP_WinFunc) ){ | 135783 | if( pEList==0 |
| 135784 | || pEList->nExpr!=1 | ||
| 135785 | || ExprHasProperty(pFunc, EP_WinFunc) | ||
| 135786 | || OptimizationDisabled(db, SQLITE_MinMaxOpt) | ||
| 135787 | ){ | ||
| 134362 | return eRet; | 135788 | return eRet; |
| 134363 | } | 135789 | } |
| 134364 | zFunc = pFunc->u.zToken; | 135790 | zFunc = pFunc->u.zToken; |
| @@ -134421,24 +135847,26 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ | |||
| 134421 | ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate | 135847 | ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate |
| 134422 | ** pFrom->pIndex and return SQLITE_OK. | 135848 | ** pFrom->pIndex and return SQLITE_OK. |
| 134423 | */ | 135849 | */ |
| 134424 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){ | 135850 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, SrcItem *pFrom){ |
| 134425 | if( pFrom->pTab && pFrom->fg.isIndexedBy ){ | 135851 | Table *pTab = pFrom->pTab; |
| 134426 | Table *pTab = pFrom->pTab; | 135852 | char *zIndexedBy = pFrom->u1.zIndexedBy; |
| 134427 | char *zIndexedBy = pFrom->u1.zIndexedBy; | 135853 | Index *pIdx; |
| 134428 | Index *pIdx; | 135854 | assert( pTab!=0 ); |
| 134429 | for(pIdx=pTab->pIndex; | 135855 | assert( pFrom->fg.isIndexedBy!=0 ); |
| 134430 | pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy); | 135856 | |
| 134431 | pIdx=pIdx->pNext | 135857 | for(pIdx=pTab->pIndex; |
| 134432 | ); | 135858 | pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy); |
| 134433 | if( !pIdx ){ | 135859 | pIdx=pIdx->pNext |
| 134434 | sqlite3ErrorMsg(pParse, "no such index: %s", zIndexedBy, 0); | 135860 | ); |
| 134435 | pParse->checkSchema = 1; | 135861 | if( !pIdx ){ |
| 134436 | return SQLITE_ERROR; | 135862 | sqlite3ErrorMsg(pParse, "no such index: %s", zIndexedBy, 0); |
| 134437 | } | 135863 | pParse->checkSchema = 1; |
| 134438 | pFrom->pIBIndex = pIdx; | 135864 | return SQLITE_ERROR; |
| 134439 | } | 135865 | } |
| 135866 | pFrom->u2.pIBIndex = pIdx; | ||
| 134440 | return SQLITE_OK; | 135867 | return SQLITE_OK; |
| 134441 | } | 135868 | } |
| 135869 | |||
| 134442 | /* | 135870 | /* |
| 134443 | ** Detect compound SELECT statements that use an ORDER BY clause with | 135871 | ** Detect compound SELECT statements that use an ORDER BY clause with |
| 134444 | ** an alternative collating sequence. | 135872 | ** an alternative collating sequence. |
| @@ -134525,7 +135953,7 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){ | |||
| 134525 | ** arguments. If it does, leave an error message in pParse and return | 135953 | ** arguments. If it does, leave an error message in pParse and return |
| 134526 | ** non-zero, since pFrom is not allowed to be a table-valued function. | 135954 | ** non-zero, since pFrom is not allowed to be a table-valued function. |
| 134527 | */ | 135955 | */ |
| 134528 | static int cannotBeFunction(Parse *pParse, struct SrcList_item *pFrom){ | 135956 | static int cannotBeFunction(Parse *pParse, SrcItem *pFrom){ |
| 134529 | if( pFrom->fg.isTabFunc ){ | 135957 | if( pFrom->fg.isTabFunc ){ |
| 134530 | sqlite3ErrorMsg(pParse, "'%s' is not a function", pFrom->zName); | 135958 | sqlite3ErrorMsg(pParse, "'%s' is not a function", pFrom->zName); |
| 134531 | return 1; | 135959 | return 1; |
| @@ -134546,19 +135974,19 @@ static int cannotBeFunction(Parse *pParse, struct SrcList_item *pFrom){ | |||
| 134546 | */ | 135974 | */ |
| 134547 | static struct Cte *searchWith( | 135975 | static struct Cte *searchWith( |
| 134548 | With *pWith, /* Current innermost WITH clause */ | 135976 | With *pWith, /* Current innermost WITH clause */ |
| 134549 | struct SrcList_item *pItem, /* FROM clause element to resolve */ | 135977 | SrcItem *pItem, /* FROM clause element to resolve */ |
| 134550 | With **ppContext /* OUT: WITH clause return value belongs to */ | 135978 | With **ppContext /* OUT: WITH clause return value belongs to */ |
| 134551 | ){ | 135979 | ){ |
| 134552 | const char *zName; | 135980 | const char *zName = pItem->zName; |
| 134553 | if( pItem->zDatabase==0 && (zName = pItem->zName)!=0 ){ | 135981 | With *p; |
| 134554 | With *p; | 135982 | assert( pItem->zDatabase==0 ); |
| 134555 | for(p=pWith; p; p=p->pOuter){ | 135983 | assert( zName!=0 ); |
| 134556 | int i; | 135984 | for(p=pWith; p; p=p->pOuter){ |
| 134557 | for(i=0; i<p->nCte; i++){ | 135985 | int i; |
| 134558 | if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){ | 135986 | for(i=0; i<p->nCte; i++){ |
| 134559 | *ppContext = p; | 135987 | if( sqlite3StrICmp(zName, p->a[i].zName)==0 ){ |
| 134560 | return &p->a[i]; | 135988 | *ppContext = p; |
| 134561 | } | 135989 | return &p->a[i]; |
| 134562 | } | 135990 | } |
| 134563 | } | 135991 | } |
| 134564 | } | 135992 | } |
| @@ -134576,46 +136004,54 @@ static struct Cte *searchWith( | |||
| 134576 | ** statement with which it is associated. | 136004 | ** statement with which it is associated. |
| 134577 | */ | 136005 | */ |
| 134578 | SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ | 136006 | SQLITE_PRIVATE void sqlite3WithPush(Parse *pParse, With *pWith, u8 bFree){ |
| 134579 | assert( bFree==0 || (pParse->pWith==0 && pParse->pWithToFree==0) ); | ||
| 134580 | if( pWith ){ | 136007 | if( pWith ){ |
| 134581 | assert( pParse->pWith!=pWith ); | 136008 | assert( pParse->pWith!=pWith ); |
| 134582 | pWith->pOuter = pParse->pWith; | 136009 | pWith->pOuter = pParse->pWith; |
| 134583 | pParse->pWith = pWith; | 136010 | pParse->pWith = pWith; |
| 134584 | if( bFree ) pParse->pWithToFree = pWith; | 136011 | if( bFree ){ |
| 136012 | sqlite3ParserAddCleanup(pParse, | ||
| 136013 | (void(*)(sqlite3*,void*))sqlite3WithDelete, | ||
| 136014 | pWith); | ||
| 136015 | testcase( pParse->earlyCleanup ); | ||
| 136016 | } | ||
| 134585 | } | 136017 | } |
| 134586 | } | 136018 | } |
| 134587 | 136019 | ||
| 134588 | /* | 136020 | /* |
| 134589 | ** This function checks if argument pFrom refers to a CTE declared by | 136021 | ** This function checks if argument pFrom refers to a CTE declared by |
| 134590 | ** a WITH clause on the stack currently maintained by the parser. And, | 136022 | ** a WITH clause on the stack currently maintained by the parser (on the |
| 134591 | ** if currently processing a CTE expression, if it is a recursive | 136023 | ** pParse->pWith linked list). And if currently processing a CTE |
| 134592 | ** reference to the current CTE. | 136024 | ** CTE expression, through routine checks to see if the reference is |
| 136025 | ** a recursive reference to the CTE. | ||
| 134593 | ** | 136026 | ** |
| 134594 | ** If pFrom falls into either of the two categories above, pFrom->pTab | 136027 | ** If pFrom matches a CTE according to either of these two above, pFrom->pTab |
| 134595 | ** and other fields are populated accordingly. The caller should check | 136028 | ** and other fields are populated accordingly. |
| 134596 | ** (pFrom->pTab!=0) to determine whether or not a successful match | ||
| 134597 | ** was found. | ||
| 134598 | ** | 136029 | ** |
| 134599 | ** Whether or not a match is found, SQLITE_OK is returned if no error | 136030 | ** Return 0 if no match is found. |
| 134600 | ** occurs. If an error does occur, an error message is stored in the | 136031 | ** Return 1 if a match is found. |
| 134601 | ** parser and some error code other than SQLITE_OK returned. | 136032 | ** Return 2 if an error condition is detected. |
| 134602 | */ | 136033 | */ |
| 134603 | static int withExpand( | 136034 | static int resolveFromTermToCte( |
| 134604 | Walker *pWalker, | 136035 | Parse *pParse, /* The parsing context */ |
| 134605 | struct SrcList_item *pFrom | 136036 | Walker *pWalker, /* Current tree walker */ |
| 136037 | SrcItem *pFrom /* The FROM clause term to check */ | ||
| 134606 | ){ | 136038 | ){ |
| 134607 | Parse *pParse = pWalker->pParse; | 136039 | Cte *pCte; /* Matched CTE (or NULL if no match) */ |
| 134608 | sqlite3 *db = pParse->db; | 136040 | With *pWith; /* The matching WITH */ |
| 134609 | struct Cte *pCte; /* Matched CTE (or NULL if no match) */ | ||
| 134610 | With *pWith; /* WITH clause that pCte belongs to */ | ||
| 134611 | 136041 | ||
| 134612 | assert( pFrom->pTab==0 ); | 136042 | assert( pFrom->pTab==0 ); |
| 134613 | if( pParse->nErr ){ | 136043 | if( pParse->pWith==0 ){ |
| 134614 | return SQLITE_ERROR; | 136044 | /* There are no WITH clauses in the stack. No match is possible */ |
| 136045 | return 0; | ||
| 136046 | } | ||
| 136047 | if( pFrom->zDatabase!=0 ){ | ||
| 136048 | /* The FROM term contains a schema qualifier (ex: main.t1) and so | ||
| 136049 | ** it cannot possibly be a CTE reference. */ | ||
| 136050 | return 0; | ||
| 134615 | } | 136051 | } |
| 134616 | |||
| 134617 | pCte = searchWith(pParse->pWith, pFrom, &pWith); | 136052 | pCte = searchWith(pParse->pWith, pFrom, &pWith); |
| 134618 | if( pCte ){ | 136053 | if( pCte ){ |
| 136054 | sqlite3 *db = pParse->db; | ||
| 134619 | Table *pTab; | 136055 | Table *pTab; |
| 134620 | ExprList *pEList; | 136056 | ExprList *pEList; |
| 134621 | Select *pSel; | 136057 | Select *pSel; |
| @@ -134624,6 +136060,7 @@ static int withExpand( | |||
| 134624 | int bMayRecursive; /* True if compound joined by UNION [ALL] */ | 136060 | int bMayRecursive; /* True if compound joined by UNION [ALL] */ |
| 134625 | With *pSavedWith; /* Initial value of pParse->pWith */ | 136061 | With *pSavedWith; /* Initial value of pParse->pWith */ |
| 134626 | int iRecTab = -1; /* Cursor for recursive table */ | 136062 | int iRecTab = -1; /* Cursor for recursive table */ |
| 136063 | CteUse *pCteUse; | ||
| 134627 | 136064 | ||
| 134628 | /* If pCte->zCteErr is non-NULL at this point, then this is an illegal | 136065 | /* If pCte->zCteErr is non-NULL at this point, then this is an illegal |
| 134629 | ** recursive reference to CTE pCte. Leave an error in pParse and return | 136066 | ** recursive reference to CTE pCte. Leave an error in pParse and return |
| @@ -134631,21 +136068,39 @@ static int withExpand( | |||
| 134631 | ** In this case, proceed. */ | 136068 | ** In this case, proceed. */ |
| 134632 | if( pCte->zCteErr ){ | 136069 | if( pCte->zCteErr ){ |
| 134633 | sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName); | 136070 | sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName); |
| 134634 | return SQLITE_ERROR; | 136071 | return 2; |
| 134635 | } | 136072 | } |
| 134636 | if( cannotBeFunction(pParse, pFrom) ) return SQLITE_ERROR; | 136073 | if( cannotBeFunction(pParse, pFrom) ) return 2; |
| 134637 | 136074 | ||
| 134638 | assert( pFrom->pTab==0 ); | 136075 | assert( pFrom->pTab==0 ); |
| 134639 | pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table)); | 136076 | pTab = sqlite3DbMallocZero(db, sizeof(Table)); |
| 134640 | if( pTab==0 ) return WRC_Abort; | 136077 | if( pTab==0 ) return 2; |
| 136078 | pCteUse = pCte->pUse; | ||
| 136079 | if( pCteUse==0 ){ | ||
| 136080 | pCte->pUse = pCteUse = sqlite3DbMallocZero(db, sizeof(pCteUse[0])); | ||
| 136081 | if( pCteUse==0 | ||
| 136082 | || sqlite3ParserAddCleanup(pParse,sqlite3DbFree,pCteUse)==0 | ||
| 136083 | ){ | ||
| 136084 | sqlite3DbFree(db, pTab); | ||
| 136085 | return 2; | ||
| 136086 | } | ||
| 136087 | pCteUse->eM10d = pCte->eM10d; | ||
| 136088 | } | ||
| 136089 | pFrom->pTab = pTab; | ||
| 134641 | pTab->nTabRef = 1; | 136090 | pTab->nTabRef = 1; |
| 134642 | pTab->zName = sqlite3DbStrDup(db, pCte->zName); | 136091 | pTab->zName = sqlite3DbStrDup(db, pCte->zName); |
| 134643 | pTab->iPKey = -1; | 136092 | pTab->iPKey = -1; |
| 134644 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); | 136093 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| 134645 | pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; | 136094 | pTab->tabFlags |= TF_Ephemeral | TF_NoVisibleRowid; |
| 134646 | pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); | 136095 | pFrom->pSelect = sqlite3SelectDup(db, pCte->pSelect, 0); |
| 134647 | if( db->mallocFailed ) return SQLITE_NOMEM_BKPT; | 136096 | if( db->mallocFailed ) return 2; |
| 134648 | assert( pFrom->pSelect ); | 136097 | assert( pFrom->pSelect ); |
| 136098 | pFrom->fg.isCte = 1; | ||
| 136099 | pFrom->u2.pCteUse = pCteUse; | ||
| 136100 | pCteUse->nUse++; | ||
| 136101 | if( pCteUse->nUse>=2 && pCteUse->eM10d==M10d_Any ){ | ||
| 136102 | pCteUse->eM10d = M10d_Yes; | ||
| 136103 | } | ||
| 134649 | 136104 | ||
| 134650 | /* Check if this is a recursive CTE. */ | 136105 | /* Check if this is a recursive CTE. */ |
| 134651 | pRecTerm = pSel = pFrom->pSelect; | 136106 | pRecTerm = pSel = pFrom->pSelect; |
| @@ -134655,7 +136110,7 @@ static int withExpand( | |||
| 134655 | SrcList *pSrc = pRecTerm->pSrc; | 136110 | SrcList *pSrc = pRecTerm->pSrc; |
| 134656 | assert( pRecTerm->pPrior!=0 ); | 136111 | assert( pRecTerm->pPrior!=0 ); |
| 134657 | for(i=0; i<pSrc->nSrc; i++){ | 136112 | for(i=0; i<pSrc->nSrc; i++){ |
| 134658 | struct SrcList_item *pItem = &pSrc->a[i]; | 136113 | SrcItem *pItem = &pSrc->a[i]; |
| 134659 | if( pItem->zDatabase==0 | 136114 | if( pItem->zDatabase==0 |
| 134660 | && pItem->zName!=0 | 136115 | && pItem->zName!=0 |
| 134661 | && 0==sqlite3StrICmp(pItem->zName, pCte->zName) | 136116 | && 0==sqlite3StrICmp(pItem->zName, pCte->zName) |
| @@ -134667,7 +136122,7 @@ static int withExpand( | |||
| 134667 | sqlite3ErrorMsg(pParse, | 136122 | sqlite3ErrorMsg(pParse, |
| 134668 | "multiple references to recursive table: %s", pCte->zName | 136123 | "multiple references to recursive table: %s", pCte->zName |
| 134669 | ); | 136124 | ); |
| 134670 | return SQLITE_ERROR; | 136125 | return 2; |
| 134671 | } | 136126 | } |
| 134672 | pRecTerm->selFlags |= SF_Recursive; | 136127 | pRecTerm->selFlags |= SF_Recursive; |
| 134673 | if( iRecTab<0 ) iRecTab = pParse->nTab++; | 136128 | if( iRecTab<0 ) iRecTab = pParse->nTab++; |
| @@ -134703,7 +136158,7 @@ static int withExpand( | |||
| 134703 | pCte->zName, pEList->nExpr, pCte->pCols->nExpr | 136158 | pCte->zName, pEList->nExpr, pCte->pCols->nExpr |
| 134704 | ); | 136159 | ); |
| 134705 | pParse->pWith = pSavedWith; | 136160 | pParse->pWith = pSavedWith; |
| 134706 | return SQLITE_ERROR; | 136161 | return 2; |
| 134707 | } | 136162 | } |
| 134708 | pEList = pCte->pCols; | 136163 | pEList = pCte->pCols; |
| 134709 | } | 136164 | } |
| @@ -134719,9 +136174,9 @@ static int withExpand( | |||
| 134719 | } | 136174 | } |
| 134720 | pCte->zCteErr = 0; | 136175 | pCte->zCteErr = 0; |
| 134721 | pParse->pWith = pSavedWith; | 136176 | pParse->pWith = pSavedWith; |
| 136177 | return 1; /* Success */ | ||
| 134722 | } | 136178 | } |
| 134723 | 136179 | return 0; /* No match */ | |
| 134724 | return SQLITE_OK; | ||
| 134725 | } | 136180 | } |
| 134726 | #endif | 136181 | #endif |
| 134727 | 136182 | ||
| @@ -134755,7 +136210,7 @@ static void selectPopWith(Walker *pWalker, Select *p){ | |||
| 134755 | ** SQLITE_OK is returned. Otherwise, if an OOM error is encountered, | 136210 | ** SQLITE_OK is returned. Otherwise, if an OOM error is encountered, |
| 134756 | ** SQLITE_NOMEM. | 136211 | ** SQLITE_NOMEM. |
| 134757 | */ | 136212 | */ |
| 134758 | SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFrom){ | 136213 | SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, SrcItem *pFrom){ |
| 134759 | Select *pSel = pFrom->pSelect; | 136214 | Select *pSel = pFrom->pSelect; |
| 134760 | Table *pTab; | 136215 | Table *pTab; |
| 134761 | 136216 | ||
| @@ -134803,10 +136258,10 @@ SQLITE_PRIVATE int sqlite3ExpandSubquery(Parse *pParse, struct SrcList_item *pFr | |||
| 134803 | */ | 136258 | */ |
| 134804 | static int selectExpander(Walker *pWalker, Select *p){ | 136259 | static int selectExpander(Walker *pWalker, Select *p){ |
| 134805 | Parse *pParse = pWalker->pParse; | 136260 | Parse *pParse = pWalker->pParse; |
| 134806 | int i, j, k; | 136261 | int i, j, k, rc; |
| 134807 | SrcList *pTabList; | 136262 | SrcList *pTabList; |
| 134808 | ExprList *pEList; | 136263 | ExprList *pEList; |
| 134809 | struct SrcList_item *pFrom; | 136264 | SrcItem *pFrom; |
| 134810 | sqlite3 *db = pParse->db; | 136265 | sqlite3 *db = pParse->db; |
| 134811 | Expr *pE, *pRight, *pExpr; | 136266 | Expr *pE, *pRight, *pExpr; |
| 134812 | u16 selFlags = p->selFlags; | 136267 | u16 selFlags = p->selFlags; |
| @@ -134842,10 +136297,6 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 134842 | assert( pFrom->fg.isRecursive==0 || pFrom->pTab!=0 ); | 136297 | assert( pFrom->fg.isRecursive==0 || pFrom->pTab!=0 ); |
| 134843 | if( pFrom->pTab ) continue; | 136298 | if( pFrom->pTab ) continue; |
| 134844 | assert( pFrom->fg.isRecursive==0 ); | 136299 | assert( pFrom->fg.isRecursive==0 ); |
| 134845 | #ifndef SQLITE_OMIT_CTE | ||
| 134846 | if( withExpand(pWalker, pFrom) ) return WRC_Abort; | ||
| 134847 | if( pFrom->pTab ) {} else | ||
| 134848 | #endif | ||
| 134849 | if( pFrom->zName==0 ){ | 136300 | if( pFrom->zName==0 ){ |
| 134850 | #ifndef SQLITE_OMIT_SUBQUERY | 136301 | #ifndef SQLITE_OMIT_SUBQUERY |
| 134851 | Select *pSel = pFrom->pSelect; | 136302 | Select *pSel = pFrom->pSelect; |
| @@ -134855,6 +136306,12 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 134855 | if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort; | 136306 | if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort; |
| 134856 | if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort; | 136307 | if( sqlite3ExpandSubquery(pParse, pFrom) ) return WRC_Abort; |
| 134857 | #endif | 136308 | #endif |
| 136309 | #ifndef SQLITE_OMIT_CTE | ||
| 136310 | }else if( (rc = resolveFromTermToCte(pParse, pWalker, pFrom))!=0 ){ | ||
| 136311 | if( rc>1 ) return WRC_Abort; | ||
| 136312 | pTab = pFrom->pTab; | ||
| 136313 | assert( pTab!=0 ); | ||
| 136314 | #endif | ||
| 134858 | }else{ | 136315 | }else{ |
| 134859 | /* An ordinary table or view name in the FROM clause */ | 136316 | /* An ordinary table or view name in the FROM clause */ |
| 134860 | assert( pFrom->pTab==0 ); | 136317 | assert( pFrom->pTab==0 ); |
| @@ -134876,7 +136333,10 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 134876 | u8 eCodeOrig = pWalker->eCode; | 136333 | u8 eCodeOrig = pWalker->eCode; |
| 134877 | if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; | 136334 | if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; |
| 134878 | assert( pFrom->pSelect==0 ); | 136335 | assert( pFrom->pSelect==0 ); |
| 134879 | if( pTab->pSelect && (db->flags & SQLITE_EnableView)==0 ){ | 136336 | if( pTab->pSelect |
| 136337 | && (db->flags & SQLITE_EnableView)==0 | ||
| 136338 | && pTab->pSchema!=db->aDb[1].pSchema | ||
| 136339 | ){ | ||
| 134880 | sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", | 136340 | sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", |
| 134881 | pTab->zName); | 136341 | pTab->zName); |
| 134882 | } | 136342 | } |
| @@ -134902,7 +136362,7 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 134902 | } | 136362 | } |
| 134903 | 136363 | ||
| 134904 | /* Locate the index named by the INDEXED BY clause, if any. */ | 136364 | /* Locate the index named by the INDEXED BY clause, if any. */ |
| 134905 | if( sqlite3IndexedByLookup(pParse, pFrom) ){ | 136365 | if( pFrom->fg.isIndexedBy && sqlite3IndexedByLookup(pParse, pFrom) ){ |
| 134906 | return WRC_Abort; | 136366 | return WRC_Abort; |
| 134907 | } | 136367 | } |
| 134908 | } | 136368 | } |
| @@ -135145,7 +136605,7 @@ static void selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){ | |||
| 135145 | Parse *pParse; | 136605 | Parse *pParse; |
| 135146 | int i; | 136606 | int i; |
| 135147 | SrcList *pTabList; | 136607 | SrcList *pTabList; |
| 135148 | struct SrcList_item *pFrom; | 136608 | SrcItem *pFrom; |
| 135149 | 136609 | ||
| 135150 | assert( p->selFlags & SF_Resolved ); | 136610 | assert( p->selFlags & SF_Resolved ); |
| 135151 | if( p->selFlags & SF_HasTypeInfo ) return; | 136611 | if( p->selFlags & SF_HasTypeInfo ) return; |
| @@ -135416,7 +136876,9 @@ static void explainSimpleCount( | |||
| 135416 | static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ | 136876 | static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ |
| 135417 | if( pExpr->op!=TK_AND ){ | 136877 | if( pExpr->op!=TK_AND ){ |
| 135418 | Select *pS = pWalker->u.pSelect; | 136878 | Select *pS = pWalker->u.pSelect; |
| 135419 | if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy) ){ | 136879 | if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy) |
| 136880 | && ExprAlwaysFalse(pExpr)==0 | ||
| 136881 | ){ | ||
| 135420 | sqlite3 *db = pWalker->pParse->db; | 136882 | sqlite3 *db = pWalker->pParse->db; |
| 135421 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1"); | 136883 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1"); |
| 135422 | if( pNew ){ | 136884 | if( pNew ){ |
| @@ -135455,7 +136917,7 @@ static void havingToWhere(Parse *pParse, Select *p){ | |||
| 135455 | sWalker.u.pSelect = p; | 136917 | sWalker.u.pSelect = p; |
| 135456 | sqlite3WalkExpr(&sWalker, p->pHaving); | 136918 | sqlite3WalkExpr(&sWalker, p->pHaving); |
| 135457 | #if SELECTTRACE_ENABLED | 136919 | #if SELECTTRACE_ENABLED |
| 135458 | if( sWalker.eCode && (sqlite3_unsupported_selecttrace & 0x100)!=0 ){ | 136920 | if( sWalker.eCode && (sqlite3SelectTrace & 0x100)!=0 ){ |
| 135459 | SELECTTRACE(0x100,pParse,p,("Move HAVING terms into WHERE:\n")); | 136921 | SELECTTRACE(0x100,pParse,p,("Move HAVING terms into WHERE:\n")); |
| 135460 | sqlite3TreeViewSelect(0, p, 0); | 136922 | sqlite3TreeViewSelect(0, p, 0); |
| 135461 | } | 136923 | } |
| @@ -135467,11 +136929,13 @@ static void havingToWhere(Parse *pParse, Select *p){ | |||
| 135467 | ** If it is, then return the SrcList_item for the prior view. If it is not, | 136929 | ** If it is, then return the SrcList_item for the prior view. If it is not, |
| 135468 | ** then return 0. | 136930 | ** then return 0. |
| 135469 | */ | 136931 | */ |
| 135470 | static struct SrcList_item *isSelfJoinView( | 136932 | static SrcItem *isSelfJoinView( |
| 135471 | SrcList *pTabList, /* Search for self-joins in this FROM clause */ | 136933 | SrcList *pTabList, /* Search for self-joins in this FROM clause */ |
| 135472 | struct SrcList_item *pThis /* Search for prior reference to this subquery */ | 136934 | SrcItem *pThis /* Search for prior reference to this subquery */ |
| 135473 | ){ | 136935 | ){ |
| 135474 | struct SrcList_item *pItem; | 136936 | SrcItem *pItem; |
| 136937 | assert( pThis->pSelect!=0 ); | ||
| 136938 | if( pThis->pSelect->selFlags & SF_PushDown ) return 0; | ||
| 135475 | for(pItem = pTabList->a; pItem<pThis; pItem++){ | 136939 | for(pItem = pTabList->a; pItem<pThis; pItem++){ |
| 135476 | Select *pS1; | 136940 | Select *pS1; |
| 135477 | if( pItem->pSelect==0 ) continue; | 136941 | if( pItem->pSelect==0 ) continue; |
| @@ -135487,9 +136951,7 @@ static struct SrcList_item *isSelfJoinView( | |||
| 135487 | ** names in the same FROM clause. */ | 136951 | ** names in the same FROM clause. */ |
| 135488 | continue; | 136952 | continue; |
| 135489 | } | 136953 | } |
| 135490 | if( sqlite3ExprCompare(0, pThis->pSelect->pWhere, pS1->pWhere, -1) | 136954 | if( pItem->pSelect->selFlags & SF_PushDown ){ |
| 135491 | || sqlite3ExprCompare(0, pThis->pSelect->pHaving, pS1->pHaving, -1) | ||
| 135492 | ){ | ||
| 135493 | /* The view was modified by some other optimization such as | 136955 | /* The view was modified by some other optimization such as |
| 135494 | ** pushDownWhereTerms() */ | 136956 | ** pushDownWhereTerms() */ |
| 135495 | continue; | 136957 | continue; |
| @@ -135499,6 +136961,15 @@ static struct SrcList_item *isSelfJoinView( | |||
| 135499 | return 0; | 136961 | return 0; |
| 135500 | } | 136962 | } |
| 135501 | 136963 | ||
| 136964 | /* | ||
| 136965 | ** Deallocate a single AggInfo object | ||
| 136966 | */ | ||
| 136967 | static void agginfoFree(sqlite3 *db, AggInfo *p){ | ||
| 136968 | sqlite3DbFree(db, p->aCol); | ||
| 136969 | sqlite3DbFree(db, p->aFunc); | ||
| 136970 | sqlite3DbFreeNN(db, p); | ||
| 136971 | } | ||
| 136972 | |||
| 135502 | #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION | 136973 | #ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION |
| 135503 | /* | 136974 | /* |
| 135504 | ** Attempt to transform a query of the form | 136975 | ** Attempt to transform a query of the form |
| @@ -135577,7 +137048,7 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ | |||
| 135577 | p->selFlags &= ~SF_Aggregate; | 137048 | p->selFlags &= ~SF_Aggregate; |
| 135578 | 137049 | ||
| 135579 | #if SELECTTRACE_ENABLED | 137050 | #if SELECTTRACE_ENABLED |
| 135580 | if( sqlite3_unsupported_selecttrace & 0x400 ){ | 137051 | if( sqlite3SelectTrace & 0x400 ){ |
| 135581 | SELECTTRACE(0x400,pParse,p,("After count-of-view optimization:\n")); | 137052 | SELECTTRACE(0x400,pParse,p,("After count-of-view optimization:\n")); |
| 135582 | sqlite3TreeViewSelect(0, p, 0); | 137053 | sqlite3TreeViewSelect(0, p, 0); |
| 135583 | } | 137054 | } |
| @@ -135630,7 +137101,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135630 | if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1; | 137101 | if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1; |
| 135631 | #if SELECTTRACE_ENABLED | 137102 | #if SELECTTRACE_ENABLED |
| 135632 | SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain)); | 137103 | SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain)); |
| 135633 | if( sqlite3_unsupported_selecttrace & 0x100 ){ | 137104 | if( sqlite3SelectTrace & 0x100 ){ |
| 135634 | sqlite3TreeViewSelect(0, p, 0); | 137105 | sqlite3TreeViewSelect(0, p, 0); |
| 135635 | } | 137106 | } |
| 135636 | #endif | 137107 | #endif |
| @@ -135644,8 +137115,19 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135644 | pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard || | 137115 | pDest->eDest==SRT_Except || pDest->eDest==SRT_Discard || |
| 135645 | pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_DistFifo ); | 137116 | pDest->eDest==SRT_DistQueue || pDest->eDest==SRT_DistFifo ); |
| 135646 | /* All of these destinations are also able to ignore the ORDER BY clause */ | 137117 | /* All of these destinations are also able to ignore the ORDER BY clause */ |
| 135647 | sqlite3ExprListDelete(db, p->pOrderBy); | 137118 | if( p->pOrderBy ){ |
| 135648 | p->pOrderBy = 0; | 137119 | #if SELECTTRACE_ENABLED |
| 137120 | SELECTTRACE(1,pParse,p, ("dropping superfluous ORDER BY:\n")); | ||
| 137121 | if( sqlite3SelectTrace & 0x100 ){ | ||
| 137122 | sqlite3TreeViewExprList(0, p->pOrderBy, 0, "ORDERBY"); | ||
| 137123 | } | ||
| 137124 | #endif | ||
| 137125 | sqlite3ParserAddCleanup(pParse, | ||
| 137126 | (void(*)(sqlite3*,void*))sqlite3ExprListDelete, | ||
| 137127 | p->pOrderBy); | ||
| 137128 | testcase( pParse->earlyCleanup ); | ||
| 137129 | p->pOrderBy = 0; | ||
| 137130 | } | ||
| 135649 | p->selFlags &= ~SF_Distinct; | 137131 | p->selFlags &= ~SF_Distinct; |
| 135650 | p->selFlags |= SF_NoopOrderBy; | 137132 | p->selFlags |= SF_NoopOrderBy; |
| 135651 | } | 137133 | } |
| @@ -135655,7 +137137,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135655 | } | 137137 | } |
| 135656 | assert( p->pEList!=0 ); | 137138 | assert( p->pEList!=0 ); |
| 135657 | #if SELECTTRACE_ENABLED | 137139 | #if SELECTTRACE_ENABLED |
| 135658 | if( sqlite3_unsupported_selecttrace & 0x104 ){ | 137140 | if( sqlite3SelectTrace & 0x104 ){ |
| 135659 | SELECTTRACE(0x104,pParse,p, ("after name resolution:\n")); | 137141 | SELECTTRACE(0x104,pParse,p, ("after name resolution:\n")); |
| 135660 | sqlite3TreeViewSelect(0, p, 0); | 137142 | sqlite3TreeViewSelect(0, p, 0); |
| 135661 | } | 137143 | } |
| @@ -135666,9 +137148,9 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135666 | ** In this case, it is an error if the target object (pSrc->a[0]) name | 137148 | ** In this case, it is an error if the target object (pSrc->a[0]) name |
| 135667 | ** or alias is duplicated within FROM clause (pSrc->a[1..n]). */ | 137149 | ** or alias is duplicated within FROM clause (pSrc->a[1..n]). */ |
| 135668 | if( p->selFlags & SF_UpdateFrom ){ | 137150 | if( p->selFlags & SF_UpdateFrom ){ |
| 135669 | struct SrcList_item *p0 = &p->pSrc->a[0]; | 137151 | SrcItem *p0 = &p->pSrc->a[0]; |
| 135670 | for(i=1; i<p->pSrc->nSrc; i++){ | 137152 | for(i=1; i<p->pSrc->nSrc; i++){ |
| 135671 | struct SrcList_item *p1 = &p->pSrc->a[i]; | 137153 | SrcItem *p1 = &p->pSrc->a[i]; |
| 135672 | if( p0->pTab==p1->pTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){ | 137154 | if( p0->pTab==p1->pTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){ |
| 135673 | sqlite3ErrorMsg(pParse, | 137155 | sqlite3ErrorMsg(pParse, |
| 135674 | "target object/alias may not appear in FROM clause: %s", | 137156 | "target object/alias may not appear in FROM clause: %s", |
| @@ -135690,7 +137172,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135690 | goto select_end; | 137172 | goto select_end; |
| 135691 | } | 137173 | } |
| 135692 | #if SELECTTRACE_ENABLED | 137174 | #if SELECTTRACE_ENABLED |
| 135693 | if( p->pWin && (sqlite3_unsupported_selecttrace & 0x108)!=0 ){ | 137175 | if( p->pWin && (sqlite3SelectTrace & 0x108)!=0 ){ |
| 135694 | SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n")); | 137176 | SELECTTRACE(0x104,pParse,p, ("after window rewrite:\n")); |
| 135695 | sqlite3TreeViewSelect(0, p, 0); | 137177 | sqlite3TreeViewSelect(0, p, 0); |
| 135696 | } | 137178 | } |
| @@ -135706,7 +137188,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135706 | */ | 137188 | */ |
| 135707 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) | 137189 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| 135708 | for(i=0; !p->pPrior && i<pTabList->nSrc; i++){ | 137190 | for(i=0; !p->pPrior && i<pTabList->nSrc; i++){ |
| 135709 | struct SrcList_item *pItem = &pTabList->a[i]; | 137191 | SrcItem *pItem = &pTabList->a[i]; |
| 135710 | Select *pSub = pItem->pSelect; | 137192 | Select *pSub = pItem->pSelect; |
| 135711 | Table *pTab = pItem->pTab; | 137193 | Table *pTab = pItem->pTab; |
| 135712 | 137194 | ||
| @@ -135797,7 +137279,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135797 | rc = multiSelect(pParse, p, pDest); | 137279 | rc = multiSelect(pParse, p, pDest); |
| 135798 | #if SELECTTRACE_ENABLED | 137280 | #if SELECTTRACE_ENABLED |
| 135799 | SELECTTRACE(0x1,pParse,p,("end compound-select processing\n")); | 137281 | SELECTTRACE(0x1,pParse,p,("end compound-select processing\n")); |
| 135800 | if( (sqlite3_unsupported_selecttrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ | 137282 | if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ |
| 135801 | sqlite3TreeViewSelect(0, p, 0); | 137283 | sqlite3TreeViewSelect(0, p, 0); |
| 135802 | } | 137284 | } |
| 135803 | #endif | 137285 | #endif |
| @@ -135816,7 +137298,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135816 | && propagateConstants(pParse, p) | 137298 | && propagateConstants(pParse, p) |
| 135817 | ){ | 137299 | ){ |
| 135818 | #if SELECTTRACE_ENABLED | 137300 | #if SELECTTRACE_ENABLED |
| 135819 | if( sqlite3_unsupported_selecttrace & 0x100 ){ | 137301 | if( sqlite3SelectTrace & 0x100 ){ |
| 135820 | SELECTTRACE(0x100,pParse,p,("After constant propagation:\n")); | 137302 | SELECTTRACE(0x100,pParse,p,("After constant propagation:\n")); |
| 135821 | sqlite3TreeViewSelect(0, p, 0); | 137303 | sqlite3TreeViewSelect(0, p, 0); |
| 135822 | } | 137304 | } |
| @@ -135840,7 +137322,8 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135840 | ** (2) Generate code for all sub-queries | 137322 | ** (2) Generate code for all sub-queries |
| 135841 | */ | 137323 | */ |
| 135842 | for(i=0; i<pTabList->nSrc; i++){ | 137324 | for(i=0; i<pTabList->nSrc; i++){ |
| 135843 | struct SrcList_item *pItem = &pTabList->a[i]; | 137325 | SrcItem *pItem = &pTabList->a[i]; |
| 137326 | SrcItem *pPrior; | ||
| 135844 | SelectDest dest; | 137327 | SelectDest dest; |
| 135845 | Select *pSub; | 137328 | Select *pSub; |
| 135846 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) | 137329 | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) |
| @@ -135900,16 +137383,18 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135900 | ** inside the subquery. This can help the subquery to run more efficiently. | 137383 | ** inside the subquery. This can help the subquery to run more efficiently. |
| 135901 | */ | 137384 | */ |
| 135902 | if( OptimizationEnabled(db, SQLITE_PushDown) | 137385 | if( OptimizationEnabled(db, SQLITE_PushDown) |
| 137386 | && (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes) | ||
| 135903 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, | 137387 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, |
| 135904 | (pItem->fg.jointype & JT_OUTER)!=0) | 137388 | (pItem->fg.jointype & JT_OUTER)!=0) |
| 135905 | ){ | 137389 | ){ |
| 135906 | #if SELECTTRACE_ENABLED | 137390 | #if SELECTTRACE_ENABLED |
| 135907 | if( sqlite3_unsupported_selecttrace & 0x100 ){ | 137391 | if( sqlite3SelectTrace & 0x100 ){ |
| 135908 | SELECTTRACE(0x100,pParse,p, | 137392 | SELECTTRACE(0x100,pParse,p, |
| 135909 | ("After WHERE-clause push-down into subquery %d:\n", pSub->selId)); | 137393 | ("After WHERE-clause push-down into subquery %d:\n", pSub->selId)); |
| 135910 | sqlite3TreeViewSelect(0, p, 0); | 137394 | sqlite3TreeViewSelect(0, p, 0); |
| 135911 | } | 137395 | } |
| 135912 | #endif | 137396 | #endif |
| 137397 | assert( pItem->pSelect && (pItem->pSelect->selFlags & SF_PushDown)!=0 ); | ||
| 135913 | }else{ | 137398 | }else{ |
| 135914 | SELECTTRACE(0x100,pParse,p,("Push-down not possible\n")); | 137399 | SELECTTRACE(0x100,pParse,p,("Push-down not possible\n")); |
| 135915 | } | 137400 | } |
| @@ -135919,16 +137404,18 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135919 | 137404 | ||
| 135920 | /* Generate code to implement the subquery | 137405 | /* Generate code to implement the subquery |
| 135921 | ** | 137406 | ** |
| 135922 | ** The subquery is implemented as a co-routine if the subquery is | 137407 | ** The subquery is implemented as a co-routine if: |
| 135923 | ** guaranteed to be the outer loop (so that it does not need to be | 137408 | ** (1) the subquery is guaranteed to be the outer loop (so that |
| 135924 | ** computed more than once) | 137409 | ** it does not need to be computed more than once), and |
| 137410 | ** (2) the subquery is not a CTE that should be materialized | ||
| 135925 | ** | 137411 | ** |
| 135926 | ** TODO: Are there other reasons beside (1) to use a co-routine | 137412 | ** TODO: Are there other reasons beside (1) and (2) to use a co-routine |
| 135927 | ** implementation? | 137413 | ** implementation? |
| 135928 | */ | 137414 | */ |
| 135929 | if( i==0 | 137415 | if( i==0 |
| 135930 | && (pTabList->nSrc==1 | 137416 | && (pTabList->nSrc==1 |
| 135931 | || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0) /* (1) */ | 137417 | || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0) /* (1) */ |
| 137418 | && (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes) /* (2) */ | ||
| 135932 | ){ | 137419 | ){ |
| 135933 | /* Implement a co-routine that will return a single row of the result | 137420 | /* Implement a co-routine that will return a single row of the result |
| 135934 | ** set on each invocation. | 137421 | ** set on each invocation. |
| @@ -135948,16 +137435,30 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135948 | sqlite3VdbeEndCoroutine(v, pItem->regReturn); | 137435 | sqlite3VdbeEndCoroutine(v, pItem->regReturn); |
| 135949 | sqlite3VdbeJumpHere(v, addrTop-1); | 137436 | sqlite3VdbeJumpHere(v, addrTop-1); |
| 135950 | sqlite3ClearTempRegCache(pParse); | 137437 | sqlite3ClearTempRegCache(pParse); |
| 135951 | }else{ | 137438 | }else if( pItem->fg.isCte && pItem->u2.pCteUse->addrM9e>0 ){ |
| 135952 | /* Generate a subroutine that will fill an ephemeral table with | 137439 | /* This is a CTE for which materialization code has already been |
| 135953 | ** the content of this subquery. pItem->addrFillSub will point | 137440 | ** generated. Invoke the subroutine to compute the materialization, |
| 135954 | ** to the address of the generated subroutine. pItem->regReturn | 137441 | ** the make the pItem->iCursor be a copy of the ephemerial table that |
| 135955 | ** is a register allocated to hold the subroutine return address | 137442 | ** holds the result of the materialization. */ |
| 135956 | */ | 137443 | CteUse *pCteUse = pItem->u2.pCteUse; |
| 137444 | sqlite3VdbeAddOp2(v, OP_Gosub, pCteUse->regRtn, pCteUse->addrM9e); | ||
| 137445 | if( pItem->iCursor!=pCteUse->iCur ){ | ||
| 137446 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pCteUse->iCur); | ||
| 137447 | } | ||
| 137448 | pSub->nSelectRow = pCteUse->nRowEst; | ||
| 137449 | }else if( (pPrior = isSelfJoinView(pTabList, pItem))!=0 ){ | ||
| 137450 | /* This view has already been materialized by a prior entry in | ||
| 137451 | ** this same FROM clause. Reuse it. */ | ||
| 137452 | if( pPrior->addrFillSub ){ | ||
| 137453 | sqlite3VdbeAddOp2(v, OP_Gosub, pPrior->regReturn, pPrior->addrFillSub); | ||
| 137454 | } | ||
| 137455 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); | ||
| 137456 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; | ||
| 137457 | }else{ | ||
| 137458 | /* Generate a subroutine that will materialize the view. */ | ||
| 135957 | int topAddr; | 137459 | int topAddr; |
| 135958 | int onceAddr = 0; | 137460 | int onceAddr = 0; |
| 135959 | int retAddr; | 137461 | int retAddr; |
| 135960 | struct SrcList_item *pPrior; | ||
| 135961 | 137462 | ||
| 135962 | testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */ | 137463 | testcase( pItem->addrFillSub==0 ); /* Ticket c52b09c7f38903b1311 */ |
| 135963 | pItem->regReturn = ++pParse->nMem; | 137464 | pItem->regReturn = ++pParse->nMem; |
| @@ -135972,22 +137473,22 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 135972 | }else{ | 137473 | }else{ |
| 135973 | VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName)); | 137474 | VdbeNoopComment((v, "materialize \"%s\"", pItem->pTab->zName)); |
| 135974 | } | 137475 | } |
| 135975 | pPrior = isSelfJoinView(pTabList, pItem); | 137476 | sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); |
| 135976 | if( pPrior ){ | 137477 | ExplainQueryPlan((pParse, 1, "MATERIALIZE %u", pSub->selId)); |
| 135977 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pPrior->iCursor); | 137478 | sqlite3Select(pParse, pSub, &dest); |
| 135978 | assert( pPrior->pSelect!=0 ); | ||
| 135979 | pSub->nSelectRow = pPrior->pSelect->nSelectRow; | ||
| 135980 | }else{ | ||
| 135981 | sqlite3SelectDestInit(&dest, SRT_EphemTab, pItem->iCursor); | ||
| 135982 | ExplainQueryPlan((pParse, 1, "MATERIALIZE %u", pSub->selId)); | ||
| 135983 | sqlite3Select(pParse, pSub, &dest); | ||
| 135984 | } | ||
| 135985 | pItem->pTab->nRowLogEst = pSub->nSelectRow; | 137479 | pItem->pTab->nRowLogEst = pSub->nSelectRow; |
| 135986 | if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); | 137480 | if( onceAddr ) sqlite3VdbeJumpHere(v, onceAddr); |
| 135987 | retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn); | 137481 | retAddr = sqlite3VdbeAddOp1(v, OP_Return, pItem->regReturn); |
| 135988 | VdbeComment((v, "end %s", pItem->pTab->zName)); | 137482 | VdbeComment((v, "end %s", pItem->pTab->zName)); |
| 135989 | sqlite3VdbeChangeP1(v, topAddr, retAddr); | 137483 | sqlite3VdbeChangeP1(v, topAddr, retAddr); |
| 135990 | sqlite3ClearTempRegCache(pParse); | 137484 | sqlite3ClearTempRegCache(pParse); |
| 137485 | if( pItem->fg.isCte ){ | ||
| 137486 | CteUse *pCteUse = pItem->u2.pCteUse; | ||
| 137487 | pCteUse->addrM9e = pItem->addrFillSub; | ||
| 137488 | pCteUse->regRtn = pItem->regReturn; | ||
| 137489 | pCteUse->iCur = pItem->iCursor; | ||
| 137490 | pCteUse->nRowEst = pSub->nSelectRow; | ||
| 137491 | } | ||
| 135991 | } | 137492 | } |
| 135992 | if( db->mallocFailed ) goto select_end; | 137493 | if( db->mallocFailed ) goto select_end; |
| 135993 | pParse->nHeight -= sqlite3SelectExprHeight(p); | 137494 | pParse->nHeight -= sqlite3SelectExprHeight(p); |
| @@ -136004,7 +137505,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136004 | sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0; | 137505 | sDistinct.isTnct = (p->selFlags & SF_Distinct)!=0; |
| 136005 | 137506 | ||
| 136006 | #if SELECTTRACE_ENABLED | 137507 | #if SELECTTRACE_ENABLED |
| 136007 | if( sqlite3_unsupported_selecttrace & 0x400 ){ | 137508 | if( sqlite3SelectTrace & 0x400 ){ |
| 136008 | SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n")); | 137509 | SELECTTRACE(0x400,pParse,p,("After all FROM-clause analysis:\n")); |
| 136009 | sqlite3TreeViewSelect(0, p, 0); | 137510 | sqlite3TreeViewSelect(0, p, 0); |
| 136010 | } | 137511 | } |
| @@ -136040,7 +137541,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136040 | assert( sDistinct.isTnct ); | 137541 | assert( sDistinct.isTnct ); |
| 136041 | 137542 | ||
| 136042 | #if SELECTTRACE_ENABLED | 137543 | #if SELECTTRACE_ENABLED |
| 136043 | if( sqlite3_unsupported_selecttrace & 0x400 ){ | 137544 | if( sqlite3SelectTrace & 0x400 ){ |
| 136044 | SELECTTRACE(0x400,pParse,p,("Transform DISTINCT into GROUP BY:\n")); | 137545 | SELECTTRACE(0x400,pParse,p,("Transform DISTINCT into GROUP BY:\n")); |
| 136045 | sqlite3TreeViewSelect(0, p, 0); | 137546 | sqlite3TreeViewSelect(0, p, 0); |
| 136046 | } | 137547 | } |
| @@ -136132,6 +137633,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136132 | sSort.pOrderBy = 0; | 137633 | sSort.pOrderBy = 0; |
| 136133 | } | 137634 | } |
| 136134 | } | 137635 | } |
| 137636 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); | ||
| 136135 | 137637 | ||
| 136136 | /* If sorting index that was created by a prior OP_OpenEphemeral | 137638 | /* If sorting index that was created by a prior OP_OpenEphemeral |
| 136137 | ** instruction ended up not being needed, then change the OP_OpenEphemeral | 137639 | ** instruction ended up not being needed, then change the OP_OpenEphemeral |
| @@ -136170,6 +137672,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136170 | 137672 | ||
| 136171 | /* End the database scan loop. | 137673 | /* End the database scan loop. |
| 136172 | */ | 137674 | */ |
| 137675 | SELECTTRACE(1,pParse,p,("WhereEnd\n")); | ||
| 136173 | sqlite3WhereEnd(pWInfo); | 137676 | sqlite3WhereEnd(pWInfo); |
| 136174 | } | 137677 | } |
| 136175 | }else{ | 137678 | }else{ |
| @@ -136240,11 +137743,14 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136240 | ** SELECT statement. | 137743 | ** SELECT statement. |
| 136241 | */ | 137744 | */ |
| 136242 | pAggInfo = sqlite3DbMallocZero(db, sizeof(*pAggInfo) ); | 137745 | pAggInfo = sqlite3DbMallocZero(db, sizeof(*pAggInfo) ); |
| 136243 | if( pAggInfo==0 ){ | 137746 | if( pAggInfo ){ |
| 137747 | sqlite3ParserAddCleanup(pParse, | ||
| 137748 | (void(*)(sqlite3*,void*))agginfoFree, pAggInfo); | ||
| 137749 | testcase( pParse->earlyCleanup ); | ||
| 137750 | } | ||
| 137751 | if( db->mallocFailed ){ | ||
| 136244 | goto select_end; | 137752 | goto select_end; |
| 136245 | } | 137753 | } |
| 136246 | pAggInfo->pNext = pParse->pAggList; | ||
| 136247 | pParse->pAggList = pAggInfo; | ||
| 136248 | pAggInfo->selId = p->selId; | 137754 | pAggInfo->selId = p->selId; |
| 136249 | memset(&sNC, 0, sizeof(sNC)); | 137755 | memset(&sNC, 0, sizeof(sNC)); |
| 136250 | sNC.pParse = pParse; | 137756 | sNC.pParse = pParse; |
| @@ -136288,10 +137794,14 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136288 | pAggInfo->mxReg = pParse->nMem; | 137794 | pAggInfo->mxReg = pParse->nMem; |
| 136289 | if( db->mallocFailed ) goto select_end; | 137795 | if( db->mallocFailed ) goto select_end; |
| 136290 | #if SELECTTRACE_ENABLED | 137796 | #if SELECTTRACE_ENABLED |
| 136291 | if( sqlite3_unsupported_selecttrace & 0x400 ){ | 137797 | if( sqlite3SelectTrace & 0x400 ){ |
| 136292 | int ii; | 137798 | int ii; |
| 136293 | SELECTTRACE(0x400,pParse,p,("After aggregate analysis %p:\n", pAggInfo)); | 137799 | SELECTTRACE(0x400,pParse,p,("After aggregate analysis %p:\n", pAggInfo)); |
| 136294 | sqlite3TreeViewSelect(0, p, 0); | 137800 | sqlite3TreeViewSelect(0, p, 0); |
| 137801 | if( minMaxFlag ){ | ||
| 137802 | sqlite3DebugPrintf("MIN/MAX Optimization (0x%02x) adds:\n", minMaxFlag); | ||
| 137803 | sqlite3TreeViewExprList(0, pMinMaxOrderBy, 0, "ORDERBY"); | ||
| 137804 | } | ||
| 136295 | for(ii=0; ii<pAggInfo->nColumn; ii++){ | 137805 | for(ii=0; ii<pAggInfo->nColumn; ii++){ |
| 136296 | sqlite3DebugPrintf("agg-column[%d] iMem=%d\n", | 137806 | sqlite3DebugPrintf("agg-column[%d] iMem=%d\n", |
| 136297 | ii, pAggInfo->aCol[ii].iMem); | 137807 | ii, pAggInfo->aCol[ii].iMem); |
| @@ -136359,6 +137869,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136359 | WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0), 0 | 137869 | WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0), 0 |
| 136360 | ); | 137870 | ); |
| 136361 | if( pWInfo==0 ) goto select_end; | 137871 | if( pWInfo==0 ) goto select_end; |
| 137872 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); | ||
| 136362 | if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){ | 137873 | if( sqlite3WhereIsOrdered(pWInfo)==pGroupBy->nExpr ){ |
| 136363 | /* The optimizer is able to deliver rows in group by order so | 137874 | /* The optimizer is able to deliver rows in group by order so |
| 136364 | ** we do not have to sort. The OP_OpenEphemeral table will be | 137875 | ** we do not have to sort. The OP_OpenEphemeral table will be |
| @@ -136407,6 +137918,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136407 | sqlite3VdbeAddOp2(v, OP_SorterInsert, pAggInfo->sortingIdx, regRecord); | 137918 | sqlite3VdbeAddOp2(v, OP_SorterInsert, pAggInfo->sortingIdx, regRecord); |
| 136408 | sqlite3ReleaseTempReg(pParse, regRecord); | 137919 | sqlite3ReleaseTempReg(pParse, regRecord); |
| 136409 | sqlite3ReleaseTempRange(pParse, regBase, nCol); | 137920 | sqlite3ReleaseTempRange(pParse, regBase, nCol); |
| 137921 | SELECTTRACE(1,pParse,p,("WhereEnd\n")); | ||
| 136410 | sqlite3WhereEnd(pWInfo); | 137922 | sqlite3WhereEnd(pWInfo); |
| 136411 | pAggInfo->sortingIdxPTab = sortPTab = pParse->nTab++; | 137923 | pAggInfo->sortingIdxPTab = sortPTab = pParse->nTab++; |
| 136412 | sortOut = sqlite3GetTempReg(pParse); | 137924 | sortOut = sqlite3GetTempReg(pParse); |
| @@ -136481,9 +137993,10 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136481 | /* End of the loop | 137993 | /* End of the loop |
| 136482 | */ | 137994 | */ |
| 136483 | if( groupBySort ){ | 137995 | if( groupBySort ){ |
| 136484 | sqlite3VdbeAddOp2(v, OP_SorterNext, pAggInfo->sortingIdx, addrTopOfLoop); | 137996 | sqlite3VdbeAddOp2(v, OP_SorterNext, pAggInfo->sortingIdx,addrTopOfLoop); |
| 136485 | VdbeCoverage(v); | 137997 | VdbeCoverage(v); |
| 136486 | }else{ | 137998 | }else{ |
| 137999 | SELECTTRACE(1,pParse,p,("WhereEnd\n")); | ||
| 136487 | sqlite3WhereEnd(pWInfo); | 138000 | sqlite3WhereEnd(pWInfo); |
| 136488 | sqlite3VdbeChangeToNoop(v, addrSortingIdx); | 138001 | sqlite3VdbeChangeToNoop(v, addrSortingIdx); |
| 136489 | } | 138002 | } |
| @@ -136593,7 +138106,6 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136593 | explainSimpleCount(pParse, pTab, pBest); | 138106 | explainSimpleCount(pParse, pTab, pBest); |
| 136594 | }else{ | 138107 | }else{ |
| 136595 | int regAcc = 0; /* "populate accumulators" flag */ | 138108 | int regAcc = 0; /* "populate accumulators" flag */ |
| 136596 | int addrSkip; | ||
| 136597 | 138109 | ||
| 136598 | /* If there are accumulator registers but no min() or max() functions | 138110 | /* If there are accumulator registers but no min() or max() functions |
| 136599 | ** without FILTER clauses, allocate register regAcc. Register regAcc | 138111 | ** without FILTER clauses, allocate register regAcc. Register regAcc |
| @@ -136640,12 +138152,13 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 136640 | if( pWInfo==0 ){ | 138152 | if( pWInfo==0 ){ |
| 136641 | goto select_end; | 138153 | goto select_end; |
| 136642 | } | 138154 | } |
| 138155 | SELECTTRACE(1,pParse,p,("WhereBegin returns\n")); | ||
| 136643 | updateAccumulator(pParse, regAcc, pAggInfo); | 138156 | updateAccumulator(pParse, regAcc, pAggInfo); |
| 136644 | if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc); | 138157 | if( regAcc ) sqlite3VdbeAddOp2(v, OP_Integer, 1, regAcc); |
| 136645 | addrSkip = sqlite3WhereOrderByLimitOptLabel(pWInfo); | 138158 | if( minMaxFlag ){ |
| 136646 | if( addrSkip!=sqlite3WhereContinueLabel(pWInfo) ){ | 138159 | sqlite3WhereMinMaxOptEarlyOut(v, pWInfo); |
| 136647 | sqlite3VdbeGoto(v, addrSkip); | ||
| 136648 | } | 138160 | } |
| 138161 | SELECTTRACE(1,pParse,p,("WhereEnd\n")); | ||
| 136649 | sqlite3WhereEnd(pWInfo); | 138162 | sqlite3WhereEnd(pWInfo); |
| 136650 | finalizeAggFunctions(pParse, pAggInfo); | 138163 | finalizeAggFunctions(pParse, pAggInfo); |
| 136651 | } | 138164 | } |
| @@ -136690,15 +138203,13 @@ select_end: | |||
| 136690 | if( pAggInfo && !db->mallocFailed ){ | 138203 | if( pAggInfo && !db->mallocFailed ){ |
| 136691 | for(i=0; i<pAggInfo->nColumn; i++){ | 138204 | for(i=0; i<pAggInfo->nColumn; i++){ |
| 136692 | Expr *pExpr = pAggInfo->aCol[i].pCExpr; | 138205 | Expr *pExpr = pAggInfo->aCol[i].pCExpr; |
| 136693 | assert( pExpr!=0 || db->mallocFailed ); | 138206 | assert( pExpr!=0 ); |
| 136694 | if( pExpr==0 ) continue; | ||
| 136695 | assert( pExpr->pAggInfo==pAggInfo ); | 138207 | assert( pExpr->pAggInfo==pAggInfo ); |
| 136696 | assert( pExpr->iAgg==i ); | 138208 | assert( pExpr->iAgg==i ); |
| 136697 | } | 138209 | } |
| 136698 | for(i=0; i<pAggInfo->nFunc; i++){ | 138210 | for(i=0; i<pAggInfo->nFunc; i++){ |
| 136699 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; | 138211 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; |
| 136700 | assert( pExpr!=0 || db->mallocFailed ); | 138212 | assert( pExpr!=0 ); |
| 136701 | if( pExpr==0 ) continue; | ||
| 136702 | assert( pExpr->pAggInfo==pAggInfo ); | 138213 | assert( pExpr->pAggInfo==pAggInfo ); |
| 136703 | assert( pExpr->iAgg==i ); | 138214 | assert( pExpr->iAgg==i ); |
| 136704 | } | 138215 | } |
| @@ -136707,7 +138218,7 @@ select_end: | |||
| 136707 | 138218 | ||
| 136708 | #if SELECTTRACE_ENABLED | 138219 | #if SELECTTRACE_ENABLED |
| 136709 | SELECTTRACE(0x1,pParse,p,("end processing\n")); | 138220 | SELECTTRACE(0x1,pParse,p,("end processing\n")); |
| 136710 | if( (sqlite3_unsupported_selecttrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ | 138221 | if( (sqlite3SelectTrace & 0x2000)!=0 && ExplainQueryPlanParent(pParse)==0 ){ |
| 136711 | sqlite3TreeViewSelect(0, p, 0); | 138222 | sqlite3TreeViewSelect(0, p, 0); |
| 136712 | } | 138223 | } |
| 136713 | #endif | 138224 | #endif |
| @@ -136968,28 +138479,39 @@ SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3 *db, TriggerStep *pTriggerS | |||
| 136968 | ** pTab as well as the triggers lised in pTab->pTrigger. | 138479 | ** pTab as well as the triggers lised in pTab->pTrigger. |
| 136969 | */ | 138480 | */ |
| 136970 | SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){ | 138481 | SQLITE_PRIVATE Trigger *sqlite3TriggerList(Parse *pParse, Table *pTab){ |
| 136971 | Schema * const pTmpSchema = pParse->db->aDb[1].pSchema; | 138482 | Schema *pTmpSchema; /* Schema of the pTab table */ |
| 136972 | Trigger *pList = 0; /* List of triggers to return */ | 138483 | Trigger *pList; /* List of triggers to return */ |
| 138484 | HashElem *p; /* Loop variable for TEMP triggers */ | ||
| 136973 | 138485 | ||
| 136974 | if( pParse->disableTriggers ){ | 138486 | if( pParse->disableTriggers ){ |
| 136975 | return 0; | 138487 | return 0; |
| 136976 | } | 138488 | } |
| 136977 | 138489 | pTmpSchema = pParse->db->aDb[1].pSchema; | |
| 138490 | p = sqliteHashFirst(&pTmpSchema->trigHash); | ||
| 138491 | if( p==0 ){ | ||
| 138492 | return pTab->pTrigger; | ||
| 138493 | } | ||
| 138494 | pList = pTab->pTrigger; | ||
| 136978 | if( pTmpSchema!=pTab->pSchema ){ | 138495 | if( pTmpSchema!=pTab->pSchema ){ |
| 136979 | HashElem *p; | 138496 | while( p ){ |
| 136980 | assert( sqlite3SchemaMutexHeld(pParse->db, 0, pTmpSchema) ); | ||
| 136981 | for(p=sqliteHashFirst(&pTmpSchema->trigHash); p; p=sqliteHashNext(p)){ | ||
| 136982 | Trigger *pTrig = (Trigger *)sqliteHashData(p); | 138497 | Trigger *pTrig = (Trigger *)sqliteHashData(p); |
| 136983 | if( pTrig->pTabSchema==pTab->pSchema | 138498 | if( pTrig->pTabSchema==pTab->pSchema |
| 136984 | && 0==sqlite3StrICmp(pTrig->table, pTab->zName) | 138499 | && 0==sqlite3StrICmp(pTrig->table, pTab->zName) |
| 136985 | ){ | 138500 | ){ |
| 136986 | pTrig->pNext = (pList ? pList : pTab->pTrigger); | 138501 | pTrig->pNext = pList; |
| 138502 | pList = pTrig; | ||
| 138503 | }else if( pTrig->op==TK_RETURNING ){ | ||
| 138504 | assert( pParse->bReturning ); | ||
| 138505 | assert( &(pParse->u1.pReturning->retTrig) == pTrig ); | ||
| 138506 | pTrig->table = pTab->zName; | ||
| 138507 | pTrig->pTabSchema = pTab->pSchema; | ||
| 138508 | pTrig->pNext = pList; | ||
| 136987 | pList = pTrig; | 138509 | pList = pTrig; |
| 136988 | } | 138510 | } |
| 138511 | p = sqliteHashNext(p); | ||
| 136989 | } | 138512 | } |
| 136990 | } | 138513 | } |
| 136991 | 138514 | return pList; | |
| 136992 | return (pList ? pList : pTab->pTrigger); | ||
| 136993 | } | 138515 | } |
| 136994 | 138516 | ||
| 136995 | /* | 138517 | /* |
| @@ -137265,7 +138787,7 @@ SQLITE_PRIVATE void sqlite3FinishTrigger( | |||
| 137265 | sqlite3DbFree(db, z); | 138787 | sqlite3DbFree(db, z); |
| 137266 | sqlite3ChangeCookie(pParse, iDb); | 138788 | sqlite3ChangeCookie(pParse, iDb); |
| 137267 | sqlite3VdbeAddParseSchemaOp(v, iDb, | 138789 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 137268 | sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName)); | 138790 | sqlite3MPrintf(db, "type='trigger' AND name='%q'", zName), 0); |
| 137269 | } | 138791 | } |
| 137270 | 138792 | ||
| 137271 | if( db->init.busy ){ | 138793 | if( db->init.busy ){ |
| @@ -137478,7 +139000,7 @@ SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep( | |||
| 137478 | ** Recursively delete a Trigger structure | 139000 | ** Recursively delete a Trigger structure |
| 137479 | */ | 139001 | */ |
| 137480 | SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){ | 139002 | SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3 *db, Trigger *pTrigger){ |
| 137481 | if( pTrigger==0 ) return; | 139003 | if( pTrigger==0 || pTrigger->bReturning ) return; |
| 137482 | sqlite3DeleteTriggerStep(db, pTrigger->step_list); | 139004 | sqlite3DeleteTriggerStep(db, pTrigger->step_list); |
| 137483 | sqlite3DbFree(db, pTrigger->zName); | 139005 | sqlite3DbFree(db, pTrigger->zName); |
| 137484 | sqlite3DbFree(db, pTrigger->table); | 139006 | sqlite3DbFree(db, pTrigger->table); |
| @@ -137643,15 +139165,53 @@ SQLITE_PRIVATE Trigger *sqlite3TriggersExist( | |||
| 137643 | Trigger *pList = 0; | 139165 | Trigger *pList = 0; |
| 137644 | Trigger *p; | 139166 | Trigger *p; |
| 137645 | 139167 | ||
| 137646 | if( (pParse->db->flags & SQLITE_EnableTrigger)!=0 ){ | 139168 | pList = sqlite3TriggerList(pParse, pTab); |
| 137647 | pList = sqlite3TriggerList(pParse, pTab); | 139169 | assert( pList==0 || IsVirtual(pTab)==0 |
| 137648 | } | 139170 | || (pList->bReturning && pList->pNext==0) ); |
| 137649 | assert( pList==0 || IsVirtual(pTab)==0 ); | 139171 | if( pList!=0 ){ |
| 137650 | for(p=pList; p; p=p->pNext){ | 139172 | p = pList; |
| 137651 | if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){ | 139173 | if( (pParse->db->flags & SQLITE_EnableTrigger)==0 |
| 137652 | mask |= p->tr_tm; | 139174 | && pTab->pTrigger!=0 |
| 139175 | ){ | ||
| 139176 | /* The SQLITE_DBCONFIG_ENABLE_TRIGGER setting is off. That means that | ||
| 139177 | ** only TEMP triggers are allowed. Truncate the pList so that it | ||
| 139178 | ** includes only TEMP triggers */ | ||
| 139179 | if( pList==pTab->pTrigger ){ | ||
| 139180 | pList = 0; | ||
| 139181 | goto exit_triggers_exist; | ||
| 139182 | } | ||
| 139183 | while( ALWAYS(p->pNext) && p->pNext!=pTab->pTrigger ) p = p->pNext; | ||
| 139184 | p->pNext = 0; | ||
| 139185 | p = pList; | ||
| 137653 | } | 139186 | } |
| 139187 | do{ | ||
| 139188 | if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){ | ||
| 139189 | mask |= p->tr_tm; | ||
| 139190 | }else if( p->op==TK_RETURNING ){ | ||
| 139191 | /* The first time a RETURNING trigger is seen, the "op" value tells | ||
| 139192 | ** us what time of trigger it should be. */ | ||
| 139193 | assert( sqlite3IsToplevel(pParse) ); | ||
| 139194 | p->op = op; | ||
| 139195 | if( IsVirtual(pTab) ){ | ||
| 139196 | if( op!=TK_INSERT ){ | ||
| 139197 | sqlite3ErrorMsg(pParse, | ||
| 139198 | "%s RETURNING is not available on virtual tables", | ||
| 139199 | op==TK_DELETE ? "DELETE" : "UPDATE"); | ||
| 139200 | } | ||
| 139201 | p->tr_tm = TRIGGER_BEFORE; | ||
| 139202 | }else{ | ||
| 139203 | p->tr_tm = TRIGGER_AFTER; | ||
| 139204 | } | ||
| 139205 | mask |= p->tr_tm; | ||
| 139206 | }else if( p->bReturning && p->op==TK_INSERT && op==TK_UPDATE | ||
| 139207 | && sqlite3IsToplevel(pParse) ){ | ||
| 139208 | /* Also fire a RETURNING trigger for an UPSERT */ | ||
| 139209 | mask |= p->tr_tm; | ||
| 139210 | } | ||
| 139211 | p = p->pNext; | ||
| 139212 | }while( p ); | ||
| 137654 | } | 139213 | } |
| 139214 | exit_triggers_exist: | ||
| 137655 | if( pMask ){ | 139215 | if( pMask ){ |
| 137656 | *pMask = mask; | 139216 | *pMask = mask; |
| 137657 | } | 139217 | } |
| @@ -137694,6 +139254,111 @@ SQLITE_PRIVATE SrcList *sqlite3TriggerStepSrc( | |||
| 137694 | return pSrc; | 139254 | return pSrc; |
| 137695 | } | 139255 | } |
| 137696 | 139256 | ||
| 139257 | /* The input list pList is the list of result set terms from a RETURNING | ||
| 139258 | ** clause. The table that we are returning from is pTab. | ||
| 139259 | ** | ||
| 139260 | ** This routine makes a copy of the pList, and at the same time expands | ||
| 139261 | ** any "*" wildcards to be the complete set of columns from pTab. | ||
| 139262 | */ | ||
| 139263 | static ExprList *sqlite3ExpandReturning( | ||
| 139264 | Parse *pParse, /* Parsing context */ | ||
| 139265 | ExprList *pList, /* The arguments to RETURNING */ | ||
| 139266 | Table *pTab /* The table being updated */ | ||
| 139267 | ){ | ||
| 139268 | ExprList *pNew = 0; | ||
| 139269 | sqlite3 *db = pParse->db; | ||
| 139270 | int i; | ||
| 139271 | |||
| 139272 | for(i=0; i<pList->nExpr; i++){ | ||
| 139273 | Expr *pOldExpr = pList->a[i].pExpr; | ||
| 139274 | if( ALWAYS(pOldExpr!=0) && pOldExpr->op==TK_ASTERISK ){ | ||
| 139275 | int jj; | ||
| 139276 | for(jj=0; jj<pTab->nCol; jj++){ | ||
| 139277 | Expr *pNewExpr; | ||
| 139278 | if( IsHiddenColumn(pTab->aCol+jj) ) continue; | ||
| 139279 | pNewExpr = sqlite3Expr(db, TK_ID, pTab->aCol[jj].zName); | ||
| 139280 | pNew = sqlite3ExprListAppend(pParse, pNew, pNewExpr); | ||
| 139281 | if( !db->mallocFailed ){ | ||
| 139282 | struct ExprList_item *pItem = &pNew->a[pNew->nExpr-1]; | ||
| 139283 | pItem->zEName = sqlite3DbStrDup(db, pTab->aCol[jj].zName); | ||
| 139284 | pItem->eEName = ENAME_NAME; | ||
| 139285 | } | ||
| 139286 | } | ||
| 139287 | }else{ | ||
| 139288 | Expr *pNewExpr = sqlite3ExprDup(db, pOldExpr, 0); | ||
| 139289 | pNew = sqlite3ExprListAppend(pParse, pNew, pNewExpr); | ||
| 139290 | if( !db->mallocFailed && ALWAYS(pList->a[i].zEName!=0) ){ | ||
| 139291 | struct ExprList_item *pItem = &pNew->a[pNew->nExpr-1]; | ||
| 139292 | pItem->zEName = sqlite3DbStrDup(db, pList->a[i].zEName); | ||
| 139293 | pItem->eEName = pList->a[i].eEName; | ||
| 139294 | } | ||
| 139295 | } | ||
| 139296 | } | ||
| 139297 | if( !db->mallocFailed ){ | ||
| 139298 | Vdbe *v = pParse->pVdbe; | ||
| 139299 | assert( v!=0 ); | ||
| 139300 | sqlite3VdbeSetNumCols(v, pNew->nExpr); | ||
| 139301 | for(i=0; i<pNew->nExpr; i++){ | ||
| 139302 | sqlite3VdbeSetColName(v, i, COLNAME_NAME, pNew->a[i].zEName, | ||
| 139303 | SQLITE_TRANSIENT); | ||
| 139304 | } | ||
| 139305 | } | ||
| 139306 | return pNew; | ||
| 139307 | } | ||
| 139308 | |||
| 139309 | /* | ||
| 139310 | ** Generate code for the RETURNING trigger. Unlike other triggers | ||
| 139311 | ** that invoke a subprogram in the bytecode, the code for RETURNING | ||
| 139312 | ** is generated in-line. | ||
| 139313 | */ | ||
| 139314 | static void codeReturningTrigger( | ||
| 139315 | Parse *pParse, /* Parse context */ | ||
| 139316 | Trigger *pTrigger, /* The trigger step that defines the RETURNING */ | ||
| 139317 | Table *pTab, /* The table to code triggers from */ | ||
| 139318 | int regIn /* The first in an array of registers */ | ||
| 139319 | ){ | ||
| 139320 | Vdbe *v = pParse->pVdbe; | ||
| 139321 | ExprList *pNew; | ||
| 139322 | Returning *pReturning; | ||
| 139323 | |||
| 139324 | assert( v!=0 ); | ||
| 139325 | assert( pParse->bReturning ); | ||
| 139326 | pReturning = pParse->u1.pReturning; | ||
| 139327 | assert( pTrigger == &(pReturning->retTrig) ); | ||
| 139328 | pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); | ||
| 139329 | if( pNew ){ | ||
| 139330 | NameContext sNC; | ||
| 139331 | memset(&sNC, 0, sizeof(sNC)); | ||
| 139332 | if( pReturning->nRetCol==0 ){ | ||
| 139333 | pReturning->nRetCol = pNew->nExpr; | ||
| 139334 | pReturning->iRetCur = pParse->nTab++; | ||
| 139335 | } | ||
| 139336 | sNC.pParse = pParse; | ||
| 139337 | sNC.uNC.iBaseReg = regIn; | ||
| 139338 | sNC.ncFlags = NC_UBaseReg; | ||
| 139339 | pParse->eTriggerOp = pTrigger->op; | ||
| 139340 | pParse->pTriggerTab = pTab; | ||
| 139341 | if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK ){ | ||
| 139342 | int i; | ||
| 139343 | int nCol = pNew->nExpr; | ||
| 139344 | int reg = pParse->nMem+1; | ||
| 139345 | pParse->nMem += nCol+2; | ||
| 139346 | pReturning->iRetReg = reg; | ||
| 139347 | for(i=0; i<nCol; i++){ | ||
| 139348 | sqlite3ExprCodeFactorable(pParse, pNew->a[i].pExpr, reg+i); | ||
| 139349 | } | ||
| 139350 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i); | ||
| 139351 | sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1); | ||
| 139352 | sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1); | ||
| 139353 | } | ||
| 139354 | sqlite3ExprListDelete(pParse->db, pNew); | ||
| 139355 | pParse->eTriggerOp = 0; | ||
| 139356 | pParse->pTriggerTab = 0; | ||
| 139357 | } | ||
| 139358 | } | ||
| 139359 | |||
| 139360 | |||
| 139361 | |||
| 137697 | /* | 139362 | /* |
| 137698 | ** Generate VDBE code for the statements inside the body of a single | 139363 | ** Generate VDBE code for the statements inside the body of a single |
| 137699 | ** trigger. | 139364 | ** trigger. |
| @@ -137743,6 +139408,7 @@ static int codeTriggerProgram( | |||
| 137743 | sqlite3ExprDup(db, pStep->pWhere, 0), | 139408 | sqlite3ExprDup(db, pStep->pWhere, 0), |
| 137744 | pParse->eOrconf, 0, 0, 0 | 139409 | pParse->eOrconf, 0, 0, 0 |
| 137745 | ); | 139410 | ); |
| 139411 | sqlite3VdbeAddOp0(v, OP_ResetCount); | ||
| 137746 | break; | 139412 | break; |
| 137747 | } | 139413 | } |
| 137748 | case TK_INSERT: { | 139414 | case TK_INSERT: { |
| @@ -137753,6 +139419,7 @@ static int codeTriggerProgram( | |||
| 137753 | pParse->eOrconf, | 139419 | pParse->eOrconf, |
| 137754 | sqlite3UpsertDup(db, pStep->pUpsert) | 139420 | sqlite3UpsertDup(db, pStep->pUpsert) |
| 137755 | ); | 139421 | ); |
| 139422 | sqlite3VdbeAddOp0(v, OP_ResetCount); | ||
| 137756 | break; | 139423 | break; |
| 137757 | } | 139424 | } |
| 137758 | case TK_DELETE: { | 139425 | case TK_DELETE: { |
| @@ -137760,6 +139427,7 @@ static int codeTriggerProgram( | |||
| 137760 | sqlite3TriggerStepSrc(pParse, pStep), | 139427 | sqlite3TriggerStepSrc(pParse, pStep), |
| 137761 | sqlite3ExprDup(db, pStep->pWhere, 0), 0, 0 | 139428 | sqlite3ExprDup(db, pStep->pWhere, 0), 0, 0 |
| 137762 | ); | 139429 | ); |
| 139430 | sqlite3VdbeAddOp0(v, OP_ResetCount); | ||
| 137763 | break; | 139431 | break; |
| 137764 | } | 139432 | } |
| 137765 | default: assert( pStep->op==TK_SELECT ); { | 139433 | default: assert( pStep->op==TK_SELECT ); { |
| @@ -137771,9 +139439,6 @@ static int codeTriggerProgram( | |||
| 137771 | break; | 139439 | break; |
| 137772 | } | 139440 | } |
| 137773 | } | 139441 | } |
| 137774 | if( pStep->op!=TK_SELECT ){ | ||
| 137775 | sqlite3VdbeAddOp0(v, OP_ResetCount); | ||
| 137776 | } | ||
| 137777 | } | 139442 | } |
| 137778 | 139443 | ||
| 137779 | return 0; | 139444 | return 0; |
| @@ -137920,7 +139585,6 @@ static TriggerPrg *codeRowTrigger( | |||
| 137920 | sqlite3VdbeDelete(v); | 139585 | sqlite3VdbeDelete(v); |
| 137921 | } | 139586 | } |
| 137922 | 139587 | ||
| 137923 | assert( !pSubParse->pAinc && !pSubParse->pZombieTab ); | ||
| 137924 | assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg ); | 139588 | assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg ); |
| 137925 | sqlite3ParserReset(pSubParse); | 139589 | sqlite3ParserReset(pSubParse); |
| 137926 | sqlite3StackFree(db, pSubParse); | 139590 | sqlite3StackFree(db, pSubParse); |
| @@ -138022,7 +139686,7 @@ SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect( | |||
| 138022 | ** ... ... | 139686 | ** ... ... |
| 138023 | ** reg+N OLD.* value of right-most column of pTab | 139687 | ** reg+N OLD.* value of right-most column of pTab |
| 138024 | ** reg+N+1 NEW.rowid | 139688 | ** reg+N+1 NEW.rowid |
| 138025 | ** reg+N+2 OLD.* value of left-most column of pTab | 139689 | ** reg+N+2 NEW.* value of left-most column of pTab |
| 138026 | ** ... ... | 139690 | ** ... ... |
| 138027 | ** reg+N+N+1 NEW.* value of right-most column of pTab | 139691 | ** reg+N+N+1 NEW.* value of right-most column of pTab |
| 138028 | ** | 139692 | ** |
| @@ -138067,12 +139731,20 @@ SQLITE_PRIVATE void sqlite3CodeRowTrigger( | |||
| 138067 | assert( p->pSchema==p->pTabSchema | 139731 | assert( p->pSchema==p->pTabSchema |
| 138068 | || p->pSchema==pParse->db->aDb[1].pSchema ); | 139732 | || p->pSchema==pParse->db->aDb[1].pSchema ); |
| 138069 | 139733 | ||
| 138070 | /* Determine whether we should code this trigger */ | 139734 | /* Determine whether we should code this trigger. One of two choices: |
| 138071 | if( p->op==op | 139735 | ** 1. The trigger is an exact match to the current DML statement |
| 139736 | ** 2. This is a RETURNING trigger for INSERT but we are currently | ||
| 139737 | ** doing the UPDATE part of an UPSERT. | ||
| 139738 | */ | ||
| 139739 | if( (p->op==op || (p->bReturning && p->op==TK_INSERT && op==TK_UPDATE)) | ||
| 138072 | && p->tr_tm==tr_tm | 139740 | && p->tr_tm==tr_tm |
| 138073 | && checkColumnOverlap(p->pColumns, pChanges) | 139741 | && checkColumnOverlap(p->pColumns, pChanges) |
| 138074 | ){ | 139742 | ){ |
| 138075 | sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump); | 139743 | if( !p->bReturning ){ |
| 139744 | sqlite3CodeRowTriggerDirect(pParse, p, pTab, reg, orconf, ignoreJump); | ||
| 139745 | }else if( sqlite3IsToplevel(pParse) ){ | ||
| 139746 | codeReturningTrigger(pParse, p, pTab, reg); | ||
| 139747 | } | ||
| 138076 | } | 139748 | } |
| 138077 | } | 139749 | } |
| 138078 | } | 139750 | } |
| @@ -138117,13 +139789,18 @@ SQLITE_PRIVATE u32 sqlite3TriggerColmask( | |||
| 138117 | 139789 | ||
| 138118 | assert( isNew==1 || isNew==0 ); | 139790 | assert( isNew==1 || isNew==0 ); |
| 138119 | for(p=pTrigger; p; p=p->pNext){ | 139791 | for(p=pTrigger; p; p=p->pNext){ |
| 138120 | if( p->op==op && (tr_tm&p->tr_tm) | 139792 | if( p->op==op |
| 139793 | && (tr_tm&p->tr_tm) | ||
| 138121 | && checkColumnOverlap(p->pColumns,pChanges) | 139794 | && checkColumnOverlap(p->pColumns,pChanges) |
| 138122 | ){ | 139795 | ){ |
| 138123 | TriggerPrg *pPrg; | 139796 | if( p->bReturning ){ |
| 138124 | pPrg = getRowTrigger(pParse, p, pTab, orconf); | 139797 | mask = 0xffffffff; |
| 138125 | if( pPrg ){ | 139798 | }else{ |
| 138126 | mask |= pPrg->aColmask[isNew]; | 139799 | TriggerPrg *pPrg; |
| 139800 | pPrg = getRowTrigger(pParse, p, pTab, orconf); | ||
| 139801 | if( pPrg ){ | ||
| 139802 | mask |= pPrg->aColmask[isNew]; | ||
| 139803 | } | ||
| 138127 | } | 139804 | } |
| 138128 | } | 139805 | } |
| 138129 | } | 139806 | } |
| @@ -138780,6 +140457,7 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 138780 | if( (db->flags&SQLITE_CountRows)!=0 | 140457 | if( (db->flags&SQLITE_CountRows)!=0 |
| 138781 | && !pParse->pTriggerTab | 140458 | && !pParse->pTriggerTab |
| 138782 | && !pParse->nested | 140459 | && !pParse->nested |
| 140460 | && !pParse->bReturning | ||
| 138783 | && pUpsert==0 | 140461 | && pUpsert==0 |
| 138784 | ){ | 140462 | ){ |
| 138785 | regRowCount = ++pParse->nMem; | 140463 | regRowCount = ++pParse->nMem; |
| @@ -139243,7 +140921,7 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 139243 | ** that information. | 140921 | ** that information. |
| 139244 | */ | 140922 | */ |
| 139245 | if( regRowCount ){ | 140923 | if( regRowCount ){ |
| 139246 | sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); | 140924 | sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1); |
| 139247 | sqlite3VdbeSetNumCols(v, 1); | 140925 | sqlite3VdbeSetNumCols(v, 1); |
| 139248 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC); | 140926 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC); |
| 139249 | } | 140927 | } |
| @@ -139478,16 +141156,23 @@ static void updateVirtualTable( | |||
| 139478 | /* | 141156 | /* |
| 139479 | ** Free a list of Upsert objects | 141157 | ** Free a list of Upsert objects |
| 139480 | */ | 141158 | */ |
| 139481 | SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){ | 141159 | static void SQLITE_NOINLINE upsertDelete(sqlite3 *db, Upsert *p){ |
| 139482 | if( p ){ | 141160 | do{ |
| 141161 | Upsert *pNext = p->pNextUpsert; | ||
| 139483 | sqlite3ExprListDelete(db, p->pUpsertTarget); | 141162 | sqlite3ExprListDelete(db, p->pUpsertTarget); |
| 139484 | sqlite3ExprDelete(db, p->pUpsertTargetWhere); | 141163 | sqlite3ExprDelete(db, p->pUpsertTargetWhere); |
| 139485 | sqlite3ExprListDelete(db, p->pUpsertSet); | 141164 | sqlite3ExprListDelete(db, p->pUpsertSet); |
| 139486 | sqlite3ExprDelete(db, p->pUpsertWhere); | 141165 | sqlite3ExprDelete(db, p->pUpsertWhere); |
| 141166 | sqlite3DbFree(db, p->pToFree); | ||
| 139487 | sqlite3DbFree(db, p); | 141167 | sqlite3DbFree(db, p); |
| 139488 | } | 141168 | p = pNext; |
| 141169 | }while( p ); | ||
| 141170 | } | ||
| 141171 | SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){ | ||
| 141172 | if( p ) upsertDelete(db, p); | ||
| 139489 | } | 141173 | } |
| 139490 | 141174 | ||
| 141175 | |||
| 139491 | /* | 141176 | /* |
| 139492 | ** Duplicate an Upsert object. | 141177 | ** Duplicate an Upsert object. |
| 139493 | */ | 141178 | */ |
| @@ -139497,7 +141182,8 @@ SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){ | |||
| 139497 | sqlite3ExprListDup(db, p->pUpsertTarget, 0), | 141182 | sqlite3ExprListDup(db, p->pUpsertTarget, 0), |
| 139498 | sqlite3ExprDup(db, p->pUpsertTargetWhere, 0), | 141183 | sqlite3ExprDup(db, p->pUpsertTargetWhere, 0), |
| 139499 | sqlite3ExprListDup(db, p->pUpsertSet, 0), | 141184 | sqlite3ExprListDup(db, p->pUpsertSet, 0), |
| 139500 | sqlite3ExprDup(db, p->pUpsertWhere, 0) | 141185 | sqlite3ExprDup(db, p->pUpsertWhere, 0), |
| 141186 | sqlite3UpsertDup(db, p->pNextUpsert) | ||
| 139501 | ); | 141187 | ); |
| 139502 | } | 141188 | } |
| 139503 | 141189 | ||
| @@ -139509,22 +141195,25 @@ SQLITE_PRIVATE Upsert *sqlite3UpsertNew( | |||
| 139509 | ExprList *pTarget, /* Target argument to ON CONFLICT, or NULL */ | 141195 | ExprList *pTarget, /* Target argument to ON CONFLICT, or NULL */ |
| 139510 | Expr *pTargetWhere, /* Optional WHERE clause on the target */ | 141196 | Expr *pTargetWhere, /* Optional WHERE clause on the target */ |
| 139511 | ExprList *pSet, /* UPDATE columns, or NULL for a DO NOTHING */ | 141197 | ExprList *pSet, /* UPDATE columns, or NULL for a DO NOTHING */ |
| 139512 | Expr *pWhere /* WHERE clause for the ON CONFLICT UPDATE */ | 141198 | Expr *pWhere, /* WHERE clause for the ON CONFLICT UPDATE */ |
| 141199 | Upsert *pNext /* Next ON CONFLICT clause in the list */ | ||
| 139513 | ){ | 141200 | ){ |
| 139514 | Upsert *pNew; | 141201 | Upsert *pNew; |
| 139515 | pNew = sqlite3DbMallocRaw(db, sizeof(Upsert)); | 141202 | pNew = sqlite3DbMallocZero(db, sizeof(Upsert)); |
| 139516 | if( pNew==0 ){ | 141203 | if( pNew==0 ){ |
| 139517 | sqlite3ExprListDelete(db, pTarget); | 141204 | sqlite3ExprListDelete(db, pTarget); |
| 139518 | sqlite3ExprDelete(db, pTargetWhere); | 141205 | sqlite3ExprDelete(db, pTargetWhere); |
| 139519 | sqlite3ExprListDelete(db, pSet); | 141206 | sqlite3ExprListDelete(db, pSet); |
| 139520 | sqlite3ExprDelete(db, pWhere); | 141207 | sqlite3ExprDelete(db, pWhere); |
| 141208 | sqlite3UpsertDelete(db, pNext); | ||
| 139521 | return 0; | 141209 | return 0; |
| 139522 | }else{ | 141210 | }else{ |
| 139523 | pNew->pUpsertTarget = pTarget; | 141211 | pNew->pUpsertTarget = pTarget; |
| 139524 | pNew->pUpsertTargetWhere = pTargetWhere; | 141212 | pNew->pUpsertTargetWhere = pTargetWhere; |
| 139525 | pNew->pUpsertSet = pSet; | 141213 | pNew->pUpsertSet = pSet; |
| 139526 | pNew->pUpsertWhere = pWhere; | 141214 | pNew->pUpsertWhere = pWhere; |
| 139527 | pNew->pUpsertIdx = 0; | 141215 | pNew->isDoUpdate = pSet!=0; |
| 141216 | pNew->pNextUpsert = pNext; | ||
| 139528 | } | 141217 | } |
| 139529 | return pNew; | 141218 | return pNew; |
| 139530 | } | 141219 | } |
| @@ -139549,6 +141238,7 @@ SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget( | |||
| 139549 | Expr *pTerm; /* One term of the conflict-target clause */ | 141238 | Expr *pTerm; /* One term of the conflict-target clause */ |
| 139550 | NameContext sNC; /* Context for resolving symbolic names */ | 141239 | NameContext sNC; /* Context for resolving symbolic names */ |
| 139551 | Expr sCol[2]; /* Index column converted into an Expr */ | 141240 | Expr sCol[2]; /* Index column converted into an Expr */ |
| 141241 | int nClause = 0; /* Counter of ON CONFLICT clauses */ | ||
| 139552 | 141242 | ||
| 139553 | assert( pTabList->nSrc==1 ); | 141243 | assert( pTabList->nSrc==1 ); |
| 139554 | assert( pTabList->a[0].pTab!=0 ); | 141244 | assert( pTabList->a[0].pTab!=0 ); |
| @@ -139562,87 +141252,131 @@ SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget( | |||
| 139562 | memset(&sNC, 0, sizeof(sNC)); | 141252 | memset(&sNC, 0, sizeof(sNC)); |
| 139563 | sNC.pParse = pParse; | 141253 | sNC.pParse = pParse; |
| 139564 | sNC.pSrcList = pTabList; | 141254 | sNC.pSrcList = pTabList; |
| 139565 | rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget); | 141255 | for(; pUpsert && pUpsert->pUpsertTarget; |
| 139566 | if( rc ) return rc; | 141256 | pUpsert=pUpsert->pNextUpsert, nClause++){ |
| 139567 | rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere); | 141257 | rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget); |
| 139568 | if( rc ) return rc; | 141258 | if( rc ) return rc; |
| 141259 | rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere); | ||
| 141260 | if( rc ) return rc; | ||
| 139569 | 141261 | ||
| 139570 | /* Check to see if the conflict target matches the rowid. */ | 141262 | /* Check to see if the conflict target matches the rowid. */ |
| 139571 | pTab = pTabList->a[0].pTab; | 141263 | pTab = pTabList->a[0].pTab; |
| 139572 | pTarget = pUpsert->pUpsertTarget; | 141264 | pTarget = pUpsert->pUpsertTarget; |
| 139573 | iCursor = pTabList->a[0].iCursor; | 141265 | iCursor = pTabList->a[0].iCursor; |
| 139574 | if( HasRowid(pTab) | 141266 | if( HasRowid(pTab) |
| 139575 | && pTarget->nExpr==1 | 141267 | && pTarget->nExpr==1 |
| 139576 | && (pTerm = pTarget->a[0].pExpr)->op==TK_COLUMN | 141268 | && (pTerm = pTarget->a[0].pExpr)->op==TK_COLUMN |
| 139577 | && pTerm->iColumn==XN_ROWID | 141269 | && pTerm->iColumn==XN_ROWID |
| 139578 | ){ | 141270 | ){ |
| 139579 | /* The conflict-target is the rowid of the primary table */ | 141271 | /* The conflict-target is the rowid of the primary table */ |
| 139580 | assert( pUpsert->pUpsertIdx==0 ); | 141272 | assert( pUpsert->pUpsertIdx==0 ); |
| 139581 | return SQLITE_OK; | 141273 | continue; |
| 139582 | } | 141274 | } |
| 139583 | 141275 | ||
| 139584 | /* Initialize sCol[0..1] to be an expression parse tree for a | 141276 | /* Initialize sCol[0..1] to be an expression parse tree for a |
| 139585 | ** single column of an index. The sCol[0] node will be the TK_COLLATE | 141277 | ** single column of an index. The sCol[0] node will be the TK_COLLATE |
| 139586 | ** operator and sCol[1] will be the TK_COLUMN operator. Code below | 141278 | ** operator and sCol[1] will be the TK_COLUMN operator. Code below |
| 139587 | ** will populate the specific collation and column number values | 141279 | ** will populate the specific collation and column number values |
| 139588 | ** prior to comparing against the conflict-target expression. | 141280 | ** prior to comparing against the conflict-target expression. |
| 139589 | */ | 141281 | */ |
| 139590 | memset(sCol, 0, sizeof(sCol)); | 141282 | memset(sCol, 0, sizeof(sCol)); |
| 139591 | sCol[0].op = TK_COLLATE; | 141283 | sCol[0].op = TK_COLLATE; |
| 139592 | sCol[0].pLeft = &sCol[1]; | 141284 | sCol[0].pLeft = &sCol[1]; |
| 139593 | sCol[1].op = TK_COLUMN; | 141285 | sCol[1].op = TK_COLUMN; |
| 139594 | sCol[1].iTable = pTabList->a[0].iCursor; | 141286 | sCol[1].iTable = pTabList->a[0].iCursor; |
| 139595 | 141287 | ||
| 139596 | /* Check for matches against other indexes */ | 141288 | /* Check for matches against other indexes */ |
| 139597 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ | 141289 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 139598 | int ii, jj, nn; | 141290 | int ii, jj, nn; |
| 139599 | if( !IsUniqueIndex(pIdx) ) continue; | 141291 | if( !IsUniqueIndex(pIdx) ) continue; |
| 139600 | if( pTarget->nExpr!=pIdx->nKeyCol ) continue; | 141292 | if( pTarget->nExpr!=pIdx->nKeyCol ) continue; |
| 139601 | if( pIdx->pPartIdxWhere ){ | 141293 | if( pIdx->pPartIdxWhere ){ |
| 139602 | if( pUpsert->pUpsertTargetWhere==0 ) continue; | 141294 | if( pUpsert->pUpsertTargetWhere==0 ) continue; |
| 139603 | if( sqlite3ExprCompare(pParse, pUpsert->pUpsertTargetWhere, | 141295 | if( sqlite3ExprCompare(pParse, pUpsert->pUpsertTargetWhere, |
| 139604 | pIdx->pPartIdxWhere, iCursor)!=0 ){ | 141296 | pIdx->pPartIdxWhere, iCursor)!=0 ){ |
| 139605 | continue; | 141297 | continue; |
| 141298 | } | ||
| 139606 | } | 141299 | } |
| 139607 | } | 141300 | nn = pIdx->nKeyCol; |
| 139608 | nn = pIdx->nKeyCol; | 141301 | for(ii=0; ii<nn; ii++){ |
| 139609 | for(ii=0; ii<nn; ii++){ | 141302 | Expr *pExpr; |
| 139610 | Expr *pExpr; | 141303 | sCol[0].u.zToken = (char*)pIdx->azColl[ii]; |
| 139611 | sCol[0].u.zToken = (char*)pIdx->azColl[ii]; | 141304 | if( pIdx->aiColumn[ii]==XN_EXPR ){ |
| 139612 | if( pIdx->aiColumn[ii]==XN_EXPR ){ | 141305 | assert( pIdx->aColExpr!=0 ); |
| 139613 | assert( pIdx->aColExpr!=0 ); | 141306 | assert( pIdx->aColExpr->nExpr>ii ); |
| 139614 | assert( pIdx->aColExpr->nExpr>ii ); | 141307 | pExpr = pIdx->aColExpr->a[ii].pExpr; |
| 139615 | pExpr = pIdx->aColExpr->a[ii].pExpr; | 141308 | if( pExpr->op!=TK_COLLATE ){ |
| 139616 | if( pExpr->op!=TK_COLLATE ){ | 141309 | sCol[0].pLeft = pExpr; |
| 139617 | sCol[0].pLeft = pExpr; | 141310 | pExpr = &sCol[0]; |
| 141311 | } | ||
| 141312 | }else{ | ||
| 141313 | sCol[0].pLeft = &sCol[1]; | ||
| 141314 | sCol[1].iColumn = pIdx->aiColumn[ii]; | ||
| 139618 | pExpr = &sCol[0]; | 141315 | pExpr = &sCol[0]; |
| 139619 | } | 141316 | } |
| 139620 | }else{ | 141317 | for(jj=0; jj<nn; jj++){ |
| 139621 | sCol[0].pLeft = &sCol[1]; | 141318 | if( sqlite3ExprCompare(pParse,pTarget->a[jj].pExpr,pExpr,iCursor)<2 ){ |
| 139622 | sCol[1].iColumn = pIdx->aiColumn[ii]; | 141319 | break; /* Column ii of the index matches column jj of target */ |
| 139623 | pExpr = &sCol[0]; | 141320 | } |
| 139624 | } | 141321 | } |
| 139625 | for(jj=0; jj<nn; jj++){ | 141322 | if( jj>=nn ){ |
| 139626 | if( sqlite3ExprCompare(pParse, pTarget->a[jj].pExpr, pExpr,iCursor)<2 ){ | 141323 | /* The target contains no match for column jj of the index */ |
| 139627 | break; /* Column ii of the index matches column jj of target */ | 141324 | break; |
| 139628 | } | 141325 | } |
| 139629 | } | 141326 | } |
| 139630 | if( jj>=nn ){ | 141327 | if( ii<nn ){ |
| 139631 | /* The target contains no match for column jj of the index */ | 141328 | /* Column ii of the index did not match any term of the conflict target. |
| 139632 | break; | 141329 | ** Continue the search with the next index. */ |
| 141330 | continue; | ||
| 139633 | } | 141331 | } |
| 141332 | pUpsert->pUpsertIdx = pIdx; | ||
| 141333 | break; | ||
| 139634 | } | 141334 | } |
| 139635 | if( ii<nn ){ | 141335 | if( pUpsert->pUpsertIdx==0 ){ |
| 139636 | /* Column ii of the index did not match any term of the conflict target. | 141336 | char zWhich[16]; |
| 139637 | ** Continue the search with the next index. */ | 141337 | if( nClause==0 && pUpsert->pNextUpsert==0 ){ |
| 139638 | continue; | 141338 | zWhich[0] = 0; |
| 141339 | }else{ | ||
| 141340 | sqlite3_snprintf(sizeof(zWhich),zWhich,"%r ", nClause+1); | ||
| 141341 | } | ||
| 141342 | sqlite3ErrorMsg(pParse, "%sON CONFLICT clause does not match any " | ||
| 141343 | "PRIMARY KEY or UNIQUE constraint", zWhich); | ||
| 141344 | return SQLITE_ERROR; | ||
| 139639 | } | 141345 | } |
| 139640 | pUpsert->pUpsertIdx = pIdx; | ||
| 139641 | return SQLITE_OK; | ||
| 139642 | } | 141346 | } |
| 139643 | sqlite3ErrorMsg(pParse, "ON CONFLICT clause does not match any " | 141347 | return SQLITE_OK; |
| 139644 | "PRIMARY KEY or UNIQUE constraint"); | 141348 | } |
| 139645 | return SQLITE_ERROR; | 141349 | |
| 141350 | /* | ||
| 141351 | ** Return true if pUpsert is the last ON CONFLICT clause with a | ||
| 141352 | ** conflict target, or if pUpsert is followed by another ON CONFLICT | ||
| 141353 | ** clause that targets the INTEGER PRIMARY KEY. | ||
| 141354 | */ | ||
| 141355 | SQLITE_PRIVATE int sqlite3UpsertNextIsIPK(Upsert *pUpsert){ | ||
| 141356 | Upsert *pNext; | ||
| 141357 | if( NEVER(pUpsert==0) ) return 0; | ||
| 141358 | pNext = pUpsert->pNextUpsert; | ||
| 141359 | if( pNext==0 ) return 1; | ||
| 141360 | if( pNext->pUpsertTarget==0 ) return 1; | ||
| 141361 | if( pNext->pUpsertIdx==0 ) return 1; | ||
| 141362 | return 0; | ||
| 141363 | } | ||
| 141364 | |||
| 141365 | /* | ||
| 141366 | ** Given the list of ON CONFLICT clauses described by pUpsert, and | ||
| 141367 | ** a particular index pIdx, return a pointer to the particular ON CONFLICT | ||
| 141368 | ** clause that applies to the index. Or, if the index is not subject to | ||
| 141369 | ** any ON CONFLICT clause, return NULL. | ||
| 141370 | */ | ||
| 141371 | SQLITE_PRIVATE Upsert *sqlite3UpsertOfIndex(Upsert *pUpsert, Index *pIdx){ | ||
| 141372 | while( | ||
| 141373 | pUpsert | ||
| 141374 | && pUpsert->pUpsertTarget!=0 | ||
| 141375 | && pUpsert->pUpsertIdx!=pIdx | ||
| 141376 | ){ | ||
| 141377 | pUpsert = pUpsert->pNextUpsert; | ||
| 141378 | } | ||
| 141379 | return pUpsert; | ||
| 139646 | } | 141380 | } |
| 139647 | 141381 | ||
| 139648 | /* | 141382 | /* |
| @@ -139666,11 +141400,13 @@ SQLITE_PRIVATE void sqlite3UpsertDoUpdate( | |||
| 139666 | SrcList *pSrc; /* FROM clause for the UPDATE */ | 141400 | SrcList *pSrc; /* FROM clause for the UPDATE */ |
| 139667 | int iDataCur; | 141401 | int iDataCur; |
| 139668 | int i; | 141402 | int i; |
| 141403 | Upsert *pTop = pUpsert; | ||
| 139669 | 141404 | ||
| 139670 | assert( v!=0 ); | 141405 | assert( v!=0 ); |
| 139671 | assert( pUpsert!=0 ); | 141406 | assert( pUpsert!=0 ); |
| 139672 | VdbeNoopComment((v, "Begin DO UPDATE of UPSERT")); | ||
| 139673 | iDataCur = pUpsert->iDataCur; | 141407 | iDataCur = pUpsert->iDataCur; |
| 141408 | pUpsert = sqlite3UpsertOfIndex(pTop, pIdx); | ||
| 141409 | VdbeNoopComment((v, "Begin DO UPDATE of UPSERT")); | ||
| 139674 | if( pIdx && iCur!=iDataCur ){ | 141410 | if( pIdx && iCur!=iDataCur ){ |
| 139675 | if( HasRowid(pTab) ){ | 141411 | if( HasRowid(pTab) ){ |
| 139676 | int regRowid = sqlite3GetTempReg(pParse); | 141412 | int regRowid = sqlite3GetTempReg(pParse); |
| @@ -139700,19 +141436,17 @@ SQLITE_PRIVATE void sqlite3UpsertDoUpdate( | |||
| 139700 | sqlite3VdbeJumpHere(v, i); | 141436 | sqlite3VdbeJumpHere(v, i); |
| 139701 | } | 141437 | } |
| 139702 | } | 141438 | } |
| 139703 | /* pUpsert does not own pUpsertSrc - the outer INSERT statement does. So | 141439 | /* pUpsert does not own pTop->pUpsertSrc - the outer INSERT statement does. |
| 139704 | ** we have to make a copy before passing it down into sqlite3Update() */ | 141440 | ** So we have to make a copy before passing it down into sqlite3Update() */ |
| 139705 | pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0); | 141441 | pSrc = sqlite3SrcListDup(db, pTop->pUpsertSrc, 0); |
| 139706 | /* excluded.* columns of type REAL need to be converted to a hard real */ | 141442 | /* excluded.* columns of type REAL need to be converted to a hard real */ |
| 139707 | for(i=0; i<pTab->nCol; i++){ | 141443 | for(i=0; i<pTab->nCol; i++){ |
| 139708 | if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){ | 141444 | if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){ |
| 139709 | sqlite3VdbeAddOp1(v, OP_RealAffinity, pUpsert->regData+i); | 141445 | sqlite3VdbeAddOp1(v, OP_RealAffinity, pTop->regData+i); |
| 139710 | } | 141446 | } |
| 139711 | } | 141447 | } |
| 139712 | sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet, | 141448 | sqlite3Update(pParse, pSrc, sqlite3ExprListDup(db,pUpsert->pUpsertSet,0), |
| 139713 | pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert); | 141449 | sqlite3ExprDup(db,pUpsert->pUpsertWhere,0), OE_Abort, 0, 0, pUpsert); |
| 139714 | pUpsert->pUpsertSet = 0; /* Will have been deleted by sqlite3Update() */ | ||
| 139715 | pUpsert->pUpsertWhere = 0; /* Will have been deleted by sqlite3Update() */ | ||
| 139716 | VdbeNoopComment((v, "End DO UPDATE of UPSERT")); | 141450 | VdbeNoopComment((v, "End DO UPDATE of UPSERT")); |
| 139717 | } | 141451 | } |
| 139718 | 141452 | ||
| @@ -140618,7 +142352,7 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ | |||
| 140618 | 142352 | ||
| 140619 | sqlite3VdbeAddOp0(v, OP_Expire); | 142353 | sqlite3VdbeAddOp0(v, OP_Expire); |
| 140620 | zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt); | 142354 | zWhere = sqlite3MPrintf(db, "name=%Q AND sql=%Q", pTab->zName, zStmt); |
| 140621 | sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); | 142355 | sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere, 0); |
| 140622 | sqlite3DbFree(db, zStmt); | 142356 | sqlite3DbFree(db, zStmt); |
| 140623 | 142357 | ||
| 140624 | iReg = ++pParse->nMem; | 142358 | iReg = ++pParse->nMem; |
| @@ -140789,6 +142523,7 @@ static int vtabCallConstructor( | |||
| 140789 | zType[i-1] = '\0'; | 142523 | zType[i-1] = '\0'; |
| 140790 | } | 142524 | } |
| 140791 | pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN; | 142525 | pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN; |
| 142526 | pTab->tabFlags |= TF_HasHidden; | ||
| 140792 | oooHidden = TF_OOOHidden; | 142527 | oooHidden = TF_OOOHidden; |
| 140793 | }else{ | 142528 | }else{ |
| 140794 | pTab->tabFlags |= oooHidden; | 142529 | pTab->tabFlags |= oooHidden; |
| @@ -140957,7 +142692,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ | |||
| 140957 | Table *pNew = sParse.pNewTable; | 142692 | Table *pNew = sParse.pNewTable; |
| 140958 | Index *pIdx; | 142693 | Index *pIdx; |
| 140959 | pTab->aCol = pNew->aCol; | 142694 | pTab->aCol = pNew->aCol; |
| 140960 | pTab->nCol = pNew->nCol; | 142695 | pTab->nNVCol = pTab->nCol = pNew->nCol; |
| 140961 | pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid); | 142696 | pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid); |
| 140962 | pNew->nCol = 0; | 142697 | pNew->nCol = 0; |
| 140963 | pNew->aCol = 0; | 142698 | pNew->aCol = 0; |
| @@ -141489,19 +143224,6 @@ SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){ | |||
| 141489 | #ifndef SQLITE_WHEREINT_H | 143224 | #ifndef SQLITE_WHEREINT_H |
| 141490 | #define SQLITE_WHEREINT_H | 143225 | #define SQLITE_WHEREINT_H |
| 141491 | 143226 | ||
| 141492 | /* | ||
| 141493 | ** Trace output macros | ||
| 141494 | */ | ||
| 141495 | #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) | ||
| 141496 | /***/ extern int sqlite3WhereTrace; | ||
| 141497 | #endif | ||
| 141498 | #if defined(SQLITE_DEBUG) \ | ||
| 141499 | && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE)) | ||
| 141500 | # define WHERETRACE(K,X) if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X | ||
| 141501 | # define WHERETRACE_ENABLED 1 | ||
| 141502 | #else | ||
| 141503 | # define WHERETRACE(K,X) | ||
| 141504 | #endif | ||
| 141505 | 143227 | ||
| 141506 | /* Forward references | 143228 | /* Forward references |
| 141507 | */ | 143229 | */ |
| @@ -141755,11 +143477,7 @@ struct WhereTerm { | |||
| 141755 | #define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */ | 143477 | #define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */ |
| 141756 | #define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */ | 143478 | #define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */ |
| 141757 | #define TERM_OR_OK 0x0040 /* Used during OR-clause processing */ | 143479 | #define TERM_OR_OK 0x0040 /* Used during OR-clause processing */ |
| 141758 | #ifdef SQLITE_ENABLE_STAT4 | 143480 | #define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */ |
| 141759 | # define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */ | ||
| 141760 | #else | ||
| 141761 | # define TERM_VNULL 0x0000 /* Disabled if not using stat4 */ | ||
| 141762 | #endif | ||
| 141763 | #define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */ | 143481 | #define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */ |
| 141764 | #define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */ | 143482 | #define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */ |
| 141765 | #define TERM_LIKE 0x0400 /* The original LIKE operator */ | 143483 | #define TERM_LIKE 0x0400 /* The original LIKE operator */ |
| @@ -142029,7 +143747,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*); | |||
| 142029 | SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*); | 143747 | SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*); |
| 142030 | SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*); | 143748 | SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*); |
| 142031 | SQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*); | 143749 | SQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*); |
| 142032 | SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*); | 143750 | SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*); |
| 142033 | 143751 | ||
| 142034 | 143752 | ||
| 142035 | 143753 | ||
| @@ -142207,7 +143925,7 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan( | |||
| 142207 | if( sqlite3ParseToplevel(pParse)->explain==2 ) | 143925 | if( sqlite3ParseToplevel(pParse)->explain==2 ) |
| 142208 | #endif | 143926 | #endif |
| 142209 | { | 143927 | { |
| 142210 | struct SrcList_item *pItem = &pTabList->a[pLevel->iFrom]; | 143928 | SrcItem *pItem = &pTabList->a[pLevel->iFrom]; |
| 142211 | Vdbe *v = pParse->pVdbe; /* VM being constructed */ | 143929 | Vdbe *v = pParse->pVdbe; /* VM being constructed */ |
| 142212 | sqlite3 *db = pParse->db; /* Database handle */ | 143930 | sqlite3 *db = pParse->db; /* Database handle */ |
| 142213 | int isSearch; /* True for a SEARCH. False for SCAN. */ | 143931 | int isSearch; /* True for a SEARCH. False for SCAN. */ |
| @@ -143000,7 +144718,7 @@ static int codeCursorHintFixExpr(Walker *pWalker, Expr *pExpr){ | |||
| 143000 | ** Insert an OP_CursorHint instruction if it is appropriate to do so. | 144718 | ** Insert an OP_CursorHint instruction if it is appropriate to do so. |
| 143001 | */ | 144719 | */ |
| 143002 | static void codeCursorHint( | 144720 | static void codeCursorHint( |
| 143003 | struct SrcList_item *pTabItem, /* FROM clause item */ | 144721 | SrcItem *pTabItem, /* FROM clause item */ |
| 143004 | WhereInfo *pWInfo, /* The where clause */ | 144722 | WhereInfo *pWInfo, /* The where clause */ |
| 143005 | WhereLevel *pLevel, /* Which loop to provide hints for */ | 144723 | WhereLevel *pLevel, /* Which loop to provide hints for */ |
| 143006 | WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */ | 144724 | WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */ |
| @@ -143375,7 +145093,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 143375 | WhereClause *pWC; /* Decomposition of the entire WHERE clause */ | 145093 | WhereClause *pWC; /* Decomposition of the entire WHERE clause */ |
| 143376 | WhereTerm *pTerm; /* A WHERE clause term */ | 145094 | WhereTerm *pTerm; /* A WHERE clause term */ |
| 143377 | sqlite3 *db; /* Database connection */ | 145095 | sqlite3 *db; /* Database connection */ |
| 143378 | struct SrcList_item *pTabItem; /* FROM clause term being coded */ | 145096 | SrcItem *pTabItem; /* FROM clause term being coded */ |
| 143379 | int addrBrk; /* Jump here to break out of the loop */ | 145097 | int addrBrk; /* Jump here to break out of the loop */ |
| 143380 | int addrHalt; /* addrBrk for the outermost loop */ | 145098 | int addrHalt; /* addrBrk for the outermost loop */ |
| 143381 | int addrCont; /* Jump here to continue with next cycle */ | 145099 | int addrCont; /* Jump here to continue with next cycle */ |
| @@ -143821,6 +145539,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 143821 | SWAP(u8, nBtm, nTop); | 145539 | SWAP(u8, nBtm, nTop); |
| 143822 | } | 145540 | } |
| 143823 | 145541 | ||
| 145542 | if( iLevel>0 && (pLoop->wsFlags & WHERE_IN_SEEKSCAN)!=0 ){ | ||
| 145543 | /* In case OP_SeekScan is used, ensure that the index cursor does not | ||
| 145544 | ** point to a valid row for the first iteration of this loop. */ | ||
| 145545 | sqlite3VdbeAddOp1(v, OP_NullRow, iIdxCur); | ||
| 145546 | } | ||
| 145547 | |||
| 143824 | /* Generate code to evaluate all constraint terms using == or IN | 145548 | /* Generate code to evaluate all constraint terms using == or IN |
| 143825 | ** and store the values of those terms in an array of registers | 145549 | ** and store the values of those terms in an array of registers |
| 143826 | ** starting at regBase. | 145550 | ** starting at regBase. |
| @@ -144157,7 +145881,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 144157 | */ | 145881 | */ |
| 144158 | if( pWInfo->nLevel>1 ){ | 145882 | if( pWInfo->nLevel>1 ){ |
| 144159 | int nNotReady; /* The number of notReady tables */ | 145883 | int nNotReady; /* The number of notReady tables */ |
| 144160 | struct SrcList_item *origSrc; /* Original list of tables */ | 145884 | SrcItem *origSrc; /* Original list of tables */ |
| 144161 | nNotReady = pWInfo->nLevel - iLevel - 1; | 145885 | nNotReady = pWInfo->nLevel - iLevel - 1; |
| 144162 | pOrTab = sqlite3StackAllocRaw(db, | 145886 | pOrTab = sqlite3StackAllocRaw(db, |
| 144163 | sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0])); | 145887 | sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0])); |
| @@ -145577,6 +147301,276 @@ static int exprMightBeIndexed( | |||
| 145577 | } | 147301 | } |
| 145578 | 147302 | ||
| 145579 | /* | 147303 | /* |
| 147304 | ** Expression callback for exprUsesSrclist(). | ||
| 147305 | */ | ||
| 147306 | static int exprUsesSrclistCb(Walker *p, Expr *pExpr){ | ||
| 147307 | if( pExpr->op==TK_COLUMN ){ | ||
| 147308 | SrcList *pSrc = p->u.pSrcList; | ||
| 147309 | int iCsr = pExpr->iTable; | ||
| 147310 | int ii; | ||
| 147311 | for(ii=0; ii<pSrc->nSrc; ii++){ | ||
| 147312 | if( pSrc->a[ii].iCursor==iCsr ){ | ||
| 147313 | return p->eCode ? WRC_Abort : WRC_Continue; | ||
| 147314 | } | ||
| 147315 | } | ||
| 147316 | return p->eCode ? WRC_Continue : WRC_Abort; | ||
| 147317 | } | ||
| 147318 | return WRC_Continue; | ||
| 147319 | } | ||
| 147320 | |||
| 147321 | /* | ||
| 147322 | ** Select callback for exprUsesSrclist(). | ||
| 147323 | */ | ||
| 147324 | static int exprUsesSrclistSelectCb(Walker *NotUsed1, Select *NotUsed2){ | ||
| 147325 | UNUSED_PARAMETER(NotUsed1); | ||
| 147326 | UNUSED_PARAMETER(NotUsed2); | ||
| 147327 | return WRC_Abort; | ||
| 147328 | } | ||
| 147329 | |||
| 147330 | /* | ||
| 147331 | ** This function always returns true if expression pExpr contains | ||
| 147332 | ** a sub-select. | ||
| 147333 | ** | ||
| 147334 | ** If there is no sub-select in pExpr, then return true if pExpr | ||
| 147335 | ** contains a TK_COLUMN node for a table that is (bUses==1) | ||
| 147336 | ** or is not (bUses==0) in pSrc. | ||
| 147337 | ** | ||
| 147338 | ** Said another way: | ||
| 147339 | ** | ||
| 147340 | ** bUses Return Meaning | ||
| 147341 | ** -------- ------ ------------------------------------------------ | ||
| 147342 | ** | ||
| 147343 | ** bUses==1 true pExpr contains either a sub-select or a | ||
| 147344 | ** TK_COLUMN referencing pSrc. | ||
| 147345 | ** | ||
| 147346 | ** bUses==1 false pExpr contains no sub-selects and all TK_COLUMN | ||
| 147347 | ** nodes reference tables not found in pSrc | ||
| 147348 | ** | ||
| 147349 | ** bUses==0 true pExpr contains either a sub-select or a TK_COLUMN | ||
| 147350 | ** that references a table not in pSrc. | ||
| 147351 | ** | ||
| 147352 | ** bUses==0 false pExpr contains no sub-selects and all TK_COLUMN | ||
| 147353 | ** nodes reference pSrc | ||
| 147354 | */ | ||
| 147355 | static int exprUsesSrclist(SrcList *pSrc, Expr *pExpr, int bUses){ | ||
| 147356 | Walker sWalker; | ||
| 147357 | memset(&sWalker, 0, sizeof(Walker)); | ||
| 147358 | sWalker.eCode = bUses; | ||
| 147359 | sWalker.u.pSrcList = pSrc; | ||
| 147360 | sWalker.xExprCallback = exprUsesSrclistCb; | ||
| 147361 | sWalker.xSelectCallback = exprUsesSrclistSelectCb; | ||
| 147362 | return (sqlite3WalkExpr(&sWalker, pExpr)==WRC_Abort); | ||
| 147363 | } | ||
| 147364 | |||
| 147365 | /* | ||
| 147366 | ** Context object used by exprExistsToInIter() as it iterates through an | ||
| 147367 | ** expression tree. | ||
| 147368 | */ | ||
| 147369 | struct ExistsToInCtx { | ||
| 147370 | SrcList *pSrc; /* The tables in an EXISTS(SELECT ... FROM <here> ...) */ | ||
| 147371 | Expr *pInLhs; /* OUT: Use this as the LHS of the IN operator */ | ||
| 147372 | Expr *pEq; /* OUT: The == term that include pInLhs */ | ||
| 147373 | Expr **ppAnd; /* OUT: The AND operator that includes pEq as a child */ | ||
| 147374 | Expr **ppParent; /* The AND operator currently being examined */ | ||
| 147375 | }; | ||
| 147376 | |||
| 147377 | /* | ||
| 147378 | ** Iterate through all AND connected nodes in the expression tree | ||
| 147379 | ** headed by (*ppExpr), populating the structure passed as the first | ||
| 147380 | ** argument with the values required by exprAnalyzeExistsFindEq(). | ||
| 147381 | ** | ||
| 147382 | ** This function returns non-zero if the expression tree does not meet | ||
| 147383 | ** the two conditions described by the header comment for | ||
| 147384 | ** exprAnalyzeExistsFindEq(), or zero if it does. | ||
| 147385 | */ | ||
| 147386 | static int exprExistsToInIter(struct ExistsToInCtx *p, Expr **ppExpr){ | ||
| 147387 | Expr *pExpr = *ppExpr; | ||
| 147388 | switch( pExpr->op ){ | ||
| 147389 | case TK_AND: | ||
| 147390 | p->ppParent = ppExpr; | ||
| 147391 | if( exprExistsToInIter(p, &pExpr->pLeft) ) return 1; | ||
| 147392 | p->ppParent = ppExpr; | ||
| 147393 | if( exprExistsToInIter(p, &pExpr->pRight) ) return 1; | ||
| 147394 | break; | ||
| 147395 | case TK_EQ: { | ||
| 147396 | int bLeft = exprUsesSrclist(p->pSrc, pExpr->pLeft, 0); | ||
| 147397 | int bRight = exprUsesSrclist(p->pSrc, pExpr->pRight, 0); | ||
| 147398 | if( bLeft || bRight ){ | ||
| 147399 | if( (bLeft && bRight) || p->pInLhs ) return 1; | ||
| 147400 | p->pInLhs = bLeft ? pExpr->pLeft : pExpr->pRight; | ||
| 147401 | if( exprUsesSrclist(p->pSrc, p->pInLhs, 1) ) return 1; | ||
| 147402 | p->pEq = pExpr; | ||
| 147403 | p->ppAnd = p->ppParent; | ||
| 147404 | } | ||
| 147405 | break; | ||
| 147406 | } | ||
| 147407 | default: | ||
| 147408 | if( exprUsesSrclist(p->pSrc, pExpr, 0) ){ | ||
| 147409 | return 1; | ||
| 147410 | } | ||
| 147411 | break; | ||
| 147412 | } | ||
| 147413 | |||
| 147414 | return 0; | ||
| 147415 | } | ||
| 147416 | |||
| 147417 | /* | ||
| 147418 | ** This function is used by exprAnalyzeExists() when creating virtual IN(...) | ||
| 147419 | ** terms equivalent to user-supplied EXIST(...) clauses. It splits the WHERE | ||
| 147420 | ** clause of the Select object passed as the first argument into one or more | ||
| 147421 | ** expressions joined by AND operators, and then tests if the following are | ||
| 147422 | ** true: | ||
| 147423 | ** | ||
| 147424 | ** 1. Exactly one of the AND separated terms refers to the outer | ||
| 147425 | ** query, and it is an == (TK_EQ) expression. | ||
| 147426 | ** | ||
| 147427 | ** 2. Only one side of the == expression refers to the outer query, and | ||
| 147428 | ** it does not refer to any columns from the inner query. | ||
| 147429 | ** | ||
| 147430 | ** If both these conditions are true, then a pointer to the side of the == | ||
| 147431 | ** expression that refers to the outer query is returned. The caller will | ||
| 147432 | ** use this expression as the LHS of the IN(...) virtual term. Or, if one | ||
| 147433 | ** or both of the above conditions are not true, NULL is returned. | ||
| 147434 | ** | ||
| 147435 | ** If non-NULL is returned and ppEq is non-NULL, *ppEq is set to point | ||
| 147436 | ** to the == expression node before returning. If pppAnd is non-NULL and | ||
| 147437 | ** the == node is not the root of the WHERE clause, then *pppAnd is set | ||
| 147438 | ** to point to the pointer to the AND node that is the parent of the == | ||
| 147439 | ** node within the WHERE expression tree. | ||
| 147440 | */ | ||
| 147441 | static Expr *exprAnalyzeExistsFindEq( | ||
| 147442 | Select *pSel, /* The SELECT of the EXISTS */ | ||
| 147443 | Expr **ppEq, /* OUT: == node from WHERE clause */ | ||
| 147444 | Expr ***pppAnd /* OUT: Pointer to parent of ==, if any */ | ||
| 147445 | ){ | ||
| 147446 | struct ExistsToInCtx ctx; | ||
| 147447 | memset(&ctx, 0, sizeof(ctx)); | ||
| 147448 | ctx.pSrc = pSel->pSrc; | ||
| 147449 | if( exprExistsToInIter(&ctx, &pSel->pWhere) ){ | ||
| 147450 | return 0; | ||
| 147451 | } | ||
| 147452 | if( ppEq ) *ppEq = ctx.pEq; | ||
| 147453 | if( pppAnd ) *pppAnd = ctx.ppAnd; | ||
| 147454 | return ctx.pInLhs; | ||
| 147455 | } | ||
| 147456 | |||
| 147457 | /* | ||
| 147458 | ** Term idxTerm of the WHERE clause passed as the second argument is an | ||
| 147459 | ** EXISTS expression with a correlated SELECT statement on the RHS. | ||
| 147460 | ** This function analyzes the SELECT statement, and if possible adds an | ||
| 147461 | ** equivalent "? IN(SELECT...)" virtual term to the WHERE clause. | ||
| 147462 | ** | ||
| 147463 | ** For an EXISTS term such as the following: | ||
| 147464 | ** | ||
| 147465 | ** EXISTS (SELECT ... FROM <srclist> WHERE <e1> = <e2> AND <e3>) | ||
| 147466 | ** | ||
| 147467 | ** The virtual IN() term added is: | ||
| 147468 | ** | ||
| 147469 | ** <e1> IN (SELECT <e2> FROM <srclist> WHERE <e3>) | ||
| 147470 | ** | ||
| 147471 | ** The virtual term is only added if the following conditions are met: | ||
| 147472 | ** | ||
| 147473 | ** 1. The sub-select must not be an aggregate or use window functions, | ||
| 147474 | ** | ||
| 147475 | ** 2. The sub-select must not be a compound SELECT, | ||
| 147476 | ** | ||
| 147477 | ** 3. Expression <e1> must refer to at least one column from the outer | ||
| 147478 | ** query, and must not refer to any column from the inner query | ||
| 147479 | ** (i.e. from <srclist>). | ||
| 147480 | ** | ||
| 147481 | ** 4. <e2> and <e3> must not refer to any values from the outer query. | ||
| 147482 | ** In other words, once <e1> has been removed, the inner query | ||
| 147483 | ** must not be correlated. | ||
| 147484 | ** | ||
| 147485 | */ | ||
| 147486 | static void exprAnalyzeExists( | ||
| 147487 | SrcList *pSrc, /* the FROM clause */ | ||
| 147488 | WhereClause *pWC, /* the WHERE clause */ | ||
| 147489 | int idxTerm /* Index of the term to be analyzed */ | ||
| 147490 | ){ | ||
| 147491 | Parse *pParse = pWC->pWInfo->pParse; | ||
| 147492 | WhereTerm *pTerm = &pWC->a[idxTerm]; | ||
| 147493 | Expr *pExpr = pTerm->pExpr; | ||
| 147494 | Select *pSel = pExpr->x.pSelect; | ||
| 147495 | Expr *pDup = 0; | ||
| 147496 | Expr *pEq = 0; | ||
| 147497 | Expr *pRet = 0; | ||
| 147498 | Expr *pInLhs = 0; | ||
| 147499 | Expr **ppAnd = 0; | ||
| 147500 | int idxNew; | ||
| 147501 | sqlite3 *db = pParse->db; | ||
| 147502 | |||
| 147503 | assert( pExpr->op==TK_EXISTS ); | ||
| 147504 | assert( (pExpr->flags & EP_VarSelect) && (pExpr->flags & EP_xIsSelect) ); | ||
| 147505 | |||
| 147506 | if( pSel->selFlags & SF_Aggregate ) return; | ||
| 147507 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 147508 | if( pSel->pWin ) return; | ||
| 147509 | #endif | ||
| 147510 | if( pSel->pPrior ) return; | ||
| 147511 | if( pSel->pWhere==0 ) return; | ||
| 147512 | if( 0==exprAnalyzeExistsFindEq(pSel, 0, 0) ) return; | ||
| 147513 | |||
| 147514 | pDup = sqlite3ExprDup(db, pExpr, 0); | ||
| 147515 | if( db->mallocFailed ){ | ||
| 147516 | sqlite3ExprDelete(db, pDup); | ||
| 147517 | return; | ||
| 147518 | } | ||
| 147519 | pSel = pDup->x.pSelect; | ||
| 147520 | sqlite3ExprListDelete(db, pSel->pEList); | ||
| 147521 | pSel->pEList = 0; | ||
| 147522 | |||
| 147523 | pInLhs = exprAnalyzeExistsFindEq(pSel, &pEq, &ppAnd); | ||
| 147524 | assert( pInLhs && pEq ); | ||
| 147525 | assert( pEq==pSel->pWhere || ppAnd ); | ||
| 147526 | if( pInLhs==pEq->pLeft ){ | ||
| 147527 | pRet = pEq->pRight; | ||
| 147528 | }else{ | ||
| 147529 | CollSeq *p = sqlite3ExprCompareCollSeq(pParse, pEq); | ||
| 147530 | pInLhs = sqlite3ExprAddCollateString(pParse, pInLhs, p?p->zName:"BINARY"); | ||
| 147531 | pRet = pEq->pLeft; | ||
| 147532 | } | ||
| 147533 | |||
| 147534 | assert( pDup->pLeft==0 ); | ||
| 147535 | pDup->op = TK_IN; | ||
| 147536 | pDup->pLeft = pInLhs; | ||
| 147537 | pDup->flags &= ~EP_VarSelect; | ||
| 147538 | if( pRet->op==TK_VECTOR ){ | ||
| 147539 | pSel->pEList = pRet->x.pList; | ||
| 147540 | pRet->x.pList = 0; | ||
| 147541 | sqlite3ExprDelete(db, pRet); | ||
| 147542 | }else{ | ||
| 147543 | pSel->pEList = sqlite3ExprListAppend(pParse, 0, pRet); | ||
| 147544 | } | ||
| 147545 | pEq->pLeft = 0; | ||
| 147546 | pEq->pRight = 0; | ||
| 147547 | if( ppAnd ){ | ||
| 147548 | Expr *pAnd = *ppAnd; | ||
| 147549 | Expr *pOther = (pAnd->pLeft==pEq) ? pAnd->pRight : pAnd->pLeft; | ||
| 147550 | pAnd->pLeft = pAnd->pRight = 0; | ||
| 147551 | sqlite3ExprDelete(db, pAnd); | ||
| 147552 | *ppAnd = pOther; | ||
| 147553 | }else{ | ||
| 147554 | assert( pSel->pWhere==pEq ); | ||
| 147555 | pSel->pWhere = 0; | ||
| 147556 | } | ||
| 147557 | sqlite3ExprDelete(db, pEq); | ||
| 147558 | |||
| 147559 | #ifdef WHERETRACE_ENABLED /* 0x20 */ | ||
| 147560 | if( sqlite3WhereTrace & 0x20 ){ | ||
| 147561 | sqlite3DebugPrintf("Convert EXISTS:\n"); | ||
| 147562 | sqlite3TreeViewExpr(0, pExpr, 0); | ||
| 147563 | sqlite3DebugPrintf("into IN:\n"); | ||
| 147564 | sqlite3TreeViewExpr(0, pDup, 0); | ||
| 147565 | } | ||
| 147566 | #endif | ||
| 147567 | idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC); | ||
| 147568 | exprAnalyze(pSrc, pWC, idxNew); | ||
| 147569 | markTermAsChild(pWC, idxNew, idxTerm); | ||
| 147570 | pWC->a[idxTerm].wtFlags |= TERM_COPIED; | ||
| 147571 | } | ||
| 147572 | |||
| 147573 | /* | ||
| 145580 | ** The input to this routine is an WhereTerm structure with only the | 147574 | ** The input to this routine is an WhereTerm structure with only the |
| 145581 | ** "pExpr" field filled in. The job of this routine is to analyze the | 147575 | ** "pExpr" field filled in. The job of this routine is to analyze the |
| 145582 | ** subexpression and populate all the other fields of the WhereTerm | 147576 | ** subexpression and populate all the other fields of the WhereTerm |
| @@ -145709,6 +147703,12 @@ static void exprAnalyze( | |||
| 145709 | pNew->prereqRight = prereqLeft | extraRight; | 147703 | pNew->prereqRight = prereqLeft | extraRight; |
| 145710 | pNew->prereqAll = prereqAll; | 147704 | pNew->prereqAll = prereqAll; |
| 145711 | pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask; | 147705 | pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask; |
| 147706 | }else if( op==TK_ISNULL && 0==sqlite3ExprCanBeNull(pLeft) ){ | ||
| 147707 | pExpr->op = TK_TRUEFALSE; | ||
| 147708 | pExpr->u.zToken = "false"; | ||
| 147709 | ExprSetProperty(pExpr, EP_IsFalse); | ||
| 147710 | pTerm->prereqAll = 0; | ||
| 147711 | pTerm->eOperator = 0; | ||
| 145712 | } | 147712 | } |
| 145713 | } | 147713 | } |
| 145714 | 147714 | ||
| @@ -145761,6 +147761,52 @@ static void exprAnalyze( | |||
| 145761 | } | 147761 | } |
| 145762 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ | 147762 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
| 145763 | 147763 | ||
| 147764 | else if( pExpr->op==TK_EXISTS ){ | ||
| 147765 | /* Perhaps treat an EXISTS operator as an IN operator */ | ||
| 147766 | if( (pExpr->flags & EP_VarSelect)!=0 | ||
| 147767 | && OptimizationEnabled(db, SQLITE_ExistsToIN) | ||
| 147768 | ){ | ||
| 147769 | exprAnalyzeExists(pSrc, pWC, idxTerm); | ||
| 147770 | } | ||
| 147771 | } | ||
| 147772 | |||
| 147773 | /* The form "x IS NOT NULL" can sometimes be evaluated more efficiently | ||
| 147774 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a | ||
| 147775 | ** virtual term of that form. | ||
| 147776 | ** | ||
| 147777 | ** The virtual term must be tagged with TERM_VNULL. | ||
| 147778 | */ | ||
| 147779 | else if( pExpr->op==TK_NOTNULL ){ | ||
| 147780 | if( pExpr->pLeft->op==TK_COLUMN | ||
| 147781 | && pExpr->pLeft->iColumn>=0 | ||
| 147782 | && !ExprHasProperty(pExpr, EP_FromJoin) | ||
| 147783 | ){ | ||
| 147784 | Expr *pNewExpr; | ||
| 147785 | Expr *pLeft = pExpr->pLeft; | ||
| 147786 | int idxNew; | ||
| 147787 | WhereTerm *pNewTerm; | ||
| 147788 | |||
| 147789 | pNewExpr = sqlite3PExpr(pParse, TK_GT, | ||
| 147790 | sqlite3ExprDup(db, pLeft, 0), | ||
| 147791 | sqlite3ExprAlloc(db, TK_NULL, 0, 0)); | ||
| 147792 | |||
| 147793 | idxNew = whereClauseInsert(pWC, pNewExpr, | ||
| 147794 | TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL); | ||
| 147795 | if( idxNew ){ | ||
| 147796 | pNewTerm = &pWC->a[idxNew]; | ||
| 147797 | pNewTerm->prereqRight = 0; | ||
| 147798 | pNewTerm->leftCursor = pLeft->iTable; | ||
| 147799 | pNewTerm->u.x.leftColumn = pLeft->iColumn; | ||
| 147800 | pNewTerm->eOperator = WO_GT; | ||
| 147801 | markTermAsChild(pWC, idxNew, idxTerm); | ||
| 147802 | pTerm = &pWC->a[idxTerm]; | ||
| 147803 | pTerm->wtFlags |= TERM_COPIED; | ||
| 147804 | pNewTerm->prereqAll = pTerm->prereqAll; | ||
| 147805 | } | ||
| 147806 | } | ||
| 147807 | } | ||
| 147808 | |||
| 147809 | |||
| 145764 | #ifndef SQLITE_OMIT_LIKE_OPTIMIZATION | 147810 | #ifndef SQLITE_OMIT_LIKE_OPTIMIZATION |
| 145765 | /* Add constraints to reduce the search space on a LIKE or GLOB | 147811 | /* Add constraints to reduce the search space on a LIKE or GLOB |
| 145766 | ** operator. | 147812 | ** operator. |
| @@ -145775,7 +147821,8 @@ static void exprAnalyze( | |||
| 145775 | ** bound is made all lowercase so that the bounds also work when comparing | 147821 | ** bound is made all lowercase so that the bounds also work when comparing |
| 145776 | ** BLOBs. | 147822 | ** BLOBs. |
| 145777 | */ | 147823 | */ |
| 145778 | if( pWC->op==TK_AND | 147824 | else if( pExpr->op==TK_FUNCTION |
| 147825 | && pWC->op==TK_AND | ||
| 145779 | && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase) | 147826 | && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase) |
| 145780 | ){ | 147827 | ){ |
| 145781 | Expr *pLeft; /* LHS of LIKE/GLOB operator */ | 147828 | Expr *pLeft; /* LHS of LIKE/GLOB operator */ |
| @@ -145845,52 +147892,6 @@ static void exprAnalyze( | |||
| 145845 | } | 147892 | } |
| 145846 | #endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */ | 147893 | #endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */ |
| 145847 | 147894 | ||
| 145848 | #ifndef SQLITE_OMIT_VIRTUALTABLE | ||
| 145849 | /* Add a WO_AUX auxiliary term to the constraint set if the | ||
| 145850 | ** current expression is of the form "column OP expr" where OP | ||
| 145851 | ** is an operator that gets passed into virtual tables but which is | ||
| 145852 | ** not normally optimized for ordinary tables. In other words, OP | ||
| 145853 | ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL. | ||
| 145854 | ** This information is used by the xBestIndex methods of | ||
| 145855 | ** virtual tables. The native query optimizer does not attempt | ||
| 145856 | ** to do anything with MATCH functions. | ||
| 145857 | */ | ||
| 145858 | if( pWC->op==TK_AND ){ | ||
| 145859 | Expr *pRight = 0, *pLeft = 0; | ||
| 145860 | int res = isAuxiliaryVtabOperator(db, pExpr, &eOp2, &pLeft, &pRight); | ||
| 145861 | while( res-- > 0 ){ | ||
| 145862 | int idxNew; | ||
| 145863 | WhereTerm *pNewTerm; | ||
| 145864 | Bitmask prereqColumn, prereqExpr; | ||
| 145865 | |||
| 145866 | prereqExpr = sqlite3WhereExprUsage(pMaskSet, pRight); | ||
| 145867 | prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft); | ||
| 145868 | if( (prereqExpr & prereqColumn)==0 ){ | ||
| 145869 | Expr *pNewExpr; | ||
| 145870 | pNewExpr = sqlite3PExpr(pParse, TK_MATCH, | ||
| 145871 | 0, sqlite3ExprDup(db, pRight, 0)); | ||
| 145872 | if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){ | ||
| 145873 | ExprSetProperty(pNewExpr, EP_FromJoin); | ||
| 145874 | pNewExpr->iRightJoinTable = pExpr->iRightJoinTable; | ||
| 145875 | } | ||
| 145876 | idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); | ||
| 145877 | testcase( idxNew==0 ); | ||
| 145878 | pNewTerm = &pWC->a[idxNew]; | ||
| 145879 | pNewTerm->prereqRight = prereqExpr; | ||
| 145880 | pNewTerm->leftCursor = pLeft->iTable; | ||
| 145881 | pNewTerm->u.x.leftColumn = pLeft->iColumn; | ||
| 145882 | pNewTerm->eOperator = WO_AUX; | ||
| 145883 | pNewTerm->eMatchOp = eOp2; | ||
| 145884 | markTermAsChild(pWC, idxNew, idxTerm); | ||
| 145885 | pTerm = &pWC->a[idxTerm]; | ||
| 145886 | pTerm->wtFlags |= TERM_COPIED; | ||
| 145887 | pNewTerm->prereqAll = pTerm->prereqAll; | ||
| 145888 | } | ||
| 145889 | SWAP(Expr*, pLeft, pRight); | ||
| 145890 | } | ||
| 145891 | } | ||
| 145892 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ | ||
| 145893 | |||
| 145894 | /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create | 147895 | /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create |
| 145895 | ** new terms for each component comparison - "a = ?" and "b = ?". The | 147896 | ** new terms for each component comparison - "a = ?" and "b = ?". The |
| 145896 | ** new terms completely replace the original vector comparison, which is | 147897 | ** new terms completely replace the original vector comparison, which is |
| @@ -145898,12 +147899,12 @@ static void exprAnalyze( | |||
| 145898 | ** | 147899 | ** |
| 145899 | ** This is only required if at least one side of the comparison operation | 147900 | ** This is only required if at least one side of the comparison operation |
| 145900 | ** is not a sub-select. */ | 147901 | ** is not a sub-select. */ |
| 145901 | if( pWC->op==TK_AND | 147902 | if( (pExpr->op==TK_EQ || pExpr->op==TK_IS) |
| 145902 | && (pExpr->op==TK_EQ || pExpr->op==TK_IS) | 147903 | && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1 |
| 145903 | && (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1 | 147904 | && sqlite3ExprVectorSize(pExpr->pRight)==nLeft |
| 145904 | && sqlite3ExprVectorSize(pExpr->pRight)==nLeft | 147905 | && ( (pExpr->pLeft->flags & EP_xIsSelect)==0 |
| 145905 | && ( (pExpr->pLeft->flags & EP_xIsSelect)==0 | 147906 | || (pExpr->pRight->flags & EP_xIsSelect)==0) |
| 145906 | || (pExpr->pRight->flags & EP_xIsSelect)==0) | 147907 | && pWC->op==TK_AND |
| 145907 | ){ | 147908 | ){ |
| 145908 | int i; | 147909 | int i; |
| 145909 | for(i=0; i<nLeft; i++){ | 147910 | for(i=0; i<nLeft; i++){ |
| @@ -145931,12 +147932,14 @@ static void exprAnalyze( | |||
| 145931 | ** This only works if the RHS is a simple SELECT (not a compound) that does | 147932 | ** This only works if the RHS is a simple SELECT (not a compound) that does |
| 145932 | ** not use window functions. | 147933 | ** not use window functions. |
| 145933 | */ | 147934 | */ |
| 145934 | if( pWC->op==TK_AND && pExpr->op==TK_IN && pTerm->u.x.iField==0 | 147935 | else if( pExpr->op==TK_IN |
| 147936 | && pTerm->u.x.iField==0 | ||
| 145935 | && pExpr->pLeft->op==TK_VECTOR | 147937 | && pExpr->pLeft->op==TK_VECTOR |
| 145936 | && pExpr->x.pSelect->pPrior==0 | 147938 | && pExpr->x.pSelect->pPrior==0 |
| 145937 | #ifndef SQLITE_OMIT_WINDOWFUNC | 147939 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 145938 | && pExpr->x.pSelect->pWin==0 | 147940 | && pExpr->x.pSelect->pWin==0 |
| 145939 | #endif | 147941 | #endif |
| 147942 | && pWC->op==TK_AND | ||
| 145940 | ){ | 147943 | ){ |
| 145941 | int i; | 147944 | int i; |
| 145942 | for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){ | 147945 | for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){ |
| @@ -145948,44 +147951,51 @@ static void exprAnalyze( | |||
| 145948 | } | 147951 | } |
| 145949 | } | 147952 | } |
| 145950 | 147953 | ||
| 145951 | #ifdef SQLITE_ENABLE_STAT4 | 147954 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 145952 | /* When sqlite_stat4 histogram data is available an operator of the | 147955 | /* Add a WO_AUX auxiliary term to the constraint set if the |
| 145953 | ** form "x IS NOT NULL" can sometimes be evaluated more efficiently | 147956 | ** current expression is of the form "column OP expr" where OP |
| 145954 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a | 147957 | ** is an operator that gets passed into virtual tables but which is |
| 145955 | ** virtual term of that form. | 147958 | ** not normally optimized for ordinary tables. In other words, OP |
| 145956 | ** | 147959 | ** is one of MATCH, LIKE, GLOB, REGEXP, !=, IS, IS NOT, or NOT NULL. |
| 145957 | ** Note that the virtual term must be tagged with TERM_VNULL. | 147960 | ** This information is used by the xBestIndex methods of |
| 147961 | ** virtual tables. The native query optimizer does not attempt | ||
| 147962 | ** to do anything with MATCH functions. | ||
| 145958 | */ | 147963 | */ |
| 145959 | if( pExpr->op==TK_NOTNULL | 147964 | else if( pWC->op==TK_AND ){ |
| 145960 | && pExpr->pLeft->op==TK_COLUMN | 147965 | Expr *pRight = 0, *pLeft = 0; |
| 145961 | && pExpr->pLeft->iColumn>=0 | 147966 | int res = isAuxiliaryVtabOperator(db, pExpr, &eOp2, &pLeft, &pRight); |
| 145962 | && !ExprHasProperty(pExpr, EP_FromJoin) | 147967 | while( res-- > 0 ){ |
| 145963 | && OptimizationEnabled(db, SQLITE_Stat4) | 147968 | int idxNew; |
| 145964 | ){ | 147969 | WhereTerm *pNewTerm; |
| 145965 | Expr *pNewExpr; | 147970 | Bitmask prereqColumn, prereqExpr; |
| 145966 | Expr *pLeft = pExpr->pLeft; | 147971 | |
| 145967 | int idxNew; | 147972 | prereqExpr = sqlite3WhereExprUsage(pMaskSet, pRight); |
| 145968 | WhereTerm *pNewTerm; | 147973 | prereqColumn = sqlite3WhereExprUsage(pMaskSet, pLeft); |
| 145969 | 147974 | if( (prereqExpr & prereqColumn)==0 ){ | |
| 145970 | pNewExpr = sqlite3PExpr(pParse, TK_GT, | 147975 | Expr *pNewExpr; |
| 145971 | sqlite3ExprDup(db, pLeft, 0), | 147976 | pNewExpr = sqlite3PExpr(pParse, TK_MATCH, |
| 145972 | sqlite3ExprAlloc(db, TK_NULL, 0, 0)); | 147977 | 0, sqlite3ExprDup(db, pRight, 0)); |
| 145973 | 147978 | if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){ | |
| 145974 | idxNew = whereClauseInsert(pWC, pNewExpr, | 147979 | ExprSetProperty(pNewExpr, EP_FromJoin); |
| 145975 | TERM_VIRTUAL|TERM_DYNAMIC|TERM_VNULL); | 147980 | pNewExpr->iRightJoinTable = pExpr->iRightJoinTable; |
| 145976 | if( idxNew ){ | 147981 | } |
| 145977 | pNewTerm = &pWC->a[idxNew]; | 147982 | idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); |
| 145978 | pNewTerm->prereqRight = 0; | 147983 | testcase( idxNew==0 ); |
| 145979 | pNewTerm->leftCursor = pLeft->iTable; | 147984 | pNewTerm = &pWC->a[idxNew]; |
| 145980 | pNewTerm->u.x.leftColumn = pLeft->iColumn; | 147985 | pNewTerm->prereqRight = prereqExpr; |
| 145981 | pNewTerm->eOperator = WO_GT; | 147986 | pNewTerm->leftCursor = pLeft->iTable; |
| 145982 | markTermAsChild(pWC, idxNew, idxTerm); | 147987 | pNewTerm->u.x.leftColumn = pLeft->iColumn; |
| 145983 | pTerm = &pWC->a[idxTerm]; | 147988 | pNewTerm->eOperator = WO_AUX; |
| 145984 | pTerm->wtFlags |= TERM_COPIED; | 147989 | pNewTerm->eMatchOp = eOp2; |
| 145985 | pNewTerm->prereqAll = pTerm->prereqAll; | 147990 | markTermAsChild(pWC, idxNew, idxTerm); |
| 147991 | pTerm = &pWC->a[idxTerm]; | ||
| 147992 | pTerm->wtFlags |= TERM_COPIED; | ||
| 147993 | pNewTerm->prereqAll = pTerm->prereqAll; | ||
| 147994 | } | ||
| 147995 | SWAP(Expr*, pLeft, pRight); | ||
| 145986 | } | 147996 | } |
| 145987 | } | 147997 | } |
| 145988 | #endif /* SQLITE_ENABLE_STAT4 */ | 147998 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 145989 | 147999 | ||
| 145990 | /* Prevent ON clause terms of a LEFT JOIN from being used to drive | 148000 | /* Prevent ON clause terms of a LEFT JOIN from being used to drive |
| 145991 | ** an index for tables to the left of the join. | 148001 | ** an index for tables to the left of the join. |
| @@ -146145,7 +148155,7 @@ SQLITE_PRIVATE void sqlite3WhereExprAnalyze( | |||
| 146145 | */ | 148155 | */ |
| 146146 | SQLITE_PRIVATE void sqlite3WhereTabFuncArgs( | 148156 | SQLITE_PRIVATE void sqlite3WhereTabFuncArgs( |
| 146147 | Parse *pParse, /* Parsing context */ | 148157 | Parse *pParse, /* Parsing context */ |
| 146148 | struct SrcList_item *pItem, /* The FROM clause term to process */ | 148158 | SrcItem *pItem, /* The FROM clause term to process */ |
| 146149 | WhereClause *pWC /* Xfer function arguments to here */ | 148159 | WhereClause *pWC /* Xfer function arguments to here */ |
| 146150 | ){ | 148160 | ){ |
| 146151 | Table *pTab; | 148161 | Table *pTab; |
| @@ -146222,12 +148232,6 @@ struct HiddenIndexInfo { | |||
| 146222 | /* Forward declaration of methods */ | 148232 | /* Forward declaration of methods */ |
| 146223 | static int whereLoopResize(sqlite3*, WhereLoop*, int); | 148233 | static int whereLoopResize(sqlite3*, WhereLoop*, int); |
| 146224 | 148234 | ||
| 146225 | /* Test variable that can be set to enable WHERE tracing */ | ||
| 146226 | #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) | ||
| 146227 | /***/ int sqlite3WhereTrace = 0; | ||
| 146228 | #endif | ||
| 146229 | |||
| 146230 | |||
| 146231 | /* | 148235 | /* |
| 146232 | ** Return the estimated number of output rows from a WHERE clause | 148236 | ** Return the estimated number of output rows from a WHERE clause |
| 146233 | */ | 148237 | */ |
| @@ -146291,6 +148295,32 @@ SQLITE_PRIVATE int sqlite3WhereOrderByLimitOptLabel(WhereInfo *pWInfo){ | |||
| 146291 | } | 148295 | } |
| 146292 | 148296 | ||
| 146293 | /* | 148297 | /* |
| 148298 | ** While generating code for the min/max optimization, after handling | ||
| 148299 | ** the aggregate-step call to min() or max(), check to see if any | ||
| 148300 | ** additional looping is required. If the output order is such that | ||
| 148301 | ** we are certain that the correct answer has already been found, then | ||
| 148302 | ** code an OP_Goto to by pass subsequent processing. | ||
| 148303 | ** | ||
| 148304 | ** Any extra OP_Goto that is coded here is an optimization. The | ||
| 148305 | ** correct answer should be obtained regardless. This OP_Goto just | ||
| 148306 | ** makes the answer appear faster. | ||
| 148307 | */ | ||
| 148308 | SQLITE_PRIVATE void sqlite3WhereMinMaxOptEarlyOut(Vdbe *v, WhereInfo *pWInfo){ | ||
| 148309 | WhereLevel *pInner; | ||
| 148310 | int i; | ||
| 148311 | if( !pWInfo->bOrderedInnerLoop ) return; | ||
| 148312 | if( pWInfo->nOBSat==0 ) return; | ||
| 148313 | for(i=pWInfo->nLevel-1; i>=0; i--){ | ||
| 148314 | pInner = &pWInfo->a[i]; | ||
| 148315 | if( (pInner->pWLoop->wsFlags & WHERE_COLUMN_IN)!=0 ){ | ||
| 148316 | sqlite3VdbeGoto(v, pInner->addrNxt); | ||
| 148317 | return; | ||
| 148318 | } | ||
| 148319 | } | ||
| 148320 | sqlite3VdbeGoto(v, pWInfo->iBreak); | ||
| 148321 | } | ||
| 148322 | |||
| 148323 | /* | ||
| 146294 | ** Return the VDBE address or label to jump to in order to continue | 148324 | ** Return the VDBE address or label to jump to in order to continue |
| 146295 | ** immediately with the next row of a WHERE clause. | 148325 | ** immediately with the next row of a WHERE clause. |
| 146296 | */ | 148326 | */ |
| @@ -146859,7 +148889,7 @@ static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){ | |||
| 146859 | */ | 148889 | */ |
| 146860 | static int termCanDriveIndex( | 148890 | static int termCanDriveIndex( |
| 146861 | WhereTerm *pTerm, /* WHERE clause term to check */ | 148891 | WhereTerm *pTerm, /* WHERE clause term to check */ |
| 146862 | struct SrcList_item *pSrc, /* Table we are trying to access */ | 148892 | SrcItem *pSrc, /* Table we are trying to access */ |
| 146863 | Bitmask notReady /* Tables in outer loops of the join */ | 148893 | Bitmask notReady /* Tables in outer loops of the join */ |
| 146864 | ){ | 148894 | ){ |
| 146865 | char aff; | 148895 | char aff; |
| @@ -146893,7 +148923,7 @@ static int termCanDriveIndex( | |||
| 146893 | static void constructAutomaticIndex( | 148923 | static void constructAutomaticIndex( |
| 146894 | Parse *pParse, /* The parsing context */ | 148924 | Parse *pParse, /* The parsing context */ |
| 146895 | WhereClause *pWC, /* The WHERE clause */ | 148925 | WhereClause *pWC, /* The WHERE clause */ |
| 146896 | struct SrcList_item *pSrc, /* The FROM clause term to get the next index */ | 148926 | SrcItem *pSrc, /* The FROM clause term to get the next index */ |
| 146897 | Bitmask notReady, /* Mask of cursors that are not available */ | 148927 | Bitmask notReady, /* Mask of cursors that are not available */ |
| 146898 | WhereLevel *pLevel /* Write new index here */ | 148928 | WhereLevel *pLevel /* Write new index here */ |
| 146899 | ){ | 148929 | ){ |
| @@ -146917,7 +148947,7 @@ static void constructAutomaticIndex( | |||
| 146917 | u8 sentWarning = 0; /* True if a warnning has been issued */ | 148947 | u8 sentWarning = 0; /* True if a warnning has been issued */ |
| 146918 | Expr *pPartial = 0; /* Partial Index Expression */ | 148948 | Expr *pPartial = 0; /* Partial Index Expression */ |
| 146919 | int iContinue = 0; /* Jump here to skip excluded rows */ | 148949 | int iContinue = 0; /* Jump here to skip excluded rows */ |
| 146920 | struct SrcList_item *pTabItem; /* FROM clause term being indexed */ | 148950 | SrcItem *pTabItem; /* FROM clause term being indexed */ |
| 146921 | int addrCounter = 0; /* Address where integer counter is initialized */ | 148951 | int addrCounter = 0; /* Address where integer counter is initialized */ |
| 146922 | int regBase; /* Array of registers where record is assembled */ | 148952 | int regBase; /* Array of registers where record is assembled */ |
| 146923 | 148953 | ||
| @@ -147101,7 +149131,7 @@ static sqlite3_index_info *allocateIndexInfo( | |||
| 147101 | Parse *pParse, /* The parsing context */ | 149131 | Parse *pParse, /* The parsing context */ |
| 147102 | WhereClause *pWC, /* The WHERE clause being analyzed */ | 149132 | WhereClause *pWC, /* The WHERE clause being analyzed */ |
| 147103 | Bitmask mUnusable, /* Ignore terms with these prereqs */ | 149133 | Bitmask mUnusable, /* Ignore terms with these prereqs */ |
| 147104 | struct SrcList_item *pSrc, /* The FROM clause term that is the vtab */ | 149134 | SrcItem *pSrc, /* The FROM clause term that is the vtab */ |
| 147105 | ExprList *pOrderBy, /* The ORDER BY clause */ | 149135 | ExprList *pOrderBy, /* The ORDER BY clause */ |
| 147106 | u16 *pmNoOmit /* Mask of terms not to omit */ | 149136 | u16 *pmNoOmit /* Mask of terms not to omit */ |
| 147107 | ){ | 149137 | ){ |
| @@ -147999,7 +150029,7 @@ SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){ | |||
| 147999 | SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){ | 150029 | SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){ |
| 148000 | WhereInfo *pWInfo = pWC->pWInfo; | 150030 | WhereInfo *pWInfo = pWC->pWInfo; |
| 148001 | int nb = 1+(pWInfo->pTabList->nSrc+3)/4; | 150031 | int nb = 1+(pWInfo->pTabList->nSrc+3)/4; |
| 148002 | struct SrcList_item *pItem = pWInfo->pTabList->a + p->iTab; | 150032 | SrcItem *pItem = pWInfo->pTabList->a + p->iTab; |
| 148003 | Table *pTab = pItem->pTab; | 150033 | Table *pTab = pItem->pTab; |
| 148004 | Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1; | 150034 | Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1; |
| 148005 | sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId, | 150035 | sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId, |
| @@ -148610,7 +150640,7 @@ static int whereRangeVectorLen( | |||
| 148610 | */ | 150640 | */ |
| 148611 | static int whereLoopAddBtreeIndex( | 150641 | static int whereLoopAddBtreeIndex( |
| 148612 | WhereLoopBuilder *pBuilder, /* The WhereLoop factory */ | 150642 | WhereLoopBuilder *pBuilder, /* The WhereLoop factory */ |
| 148613 | struct SrcList_item *pSrc, /* FROM clause term being analyzed */ | 150643 | SrcItem *pSrc, /* FROM clause term being analyzed */ |
| 148614 | Index *pProbe, /* An index on pSrc */ | 150644 | Index *pProbe, /* An index on pSrc */ |
| 148615 | LogEst nInMul /* log(Number of iterations due to IN) */ | 150645 | LogEst nInMul /* log(Number of iterations due to IN) */ |
| 148616 | ){ | 150646 | ){ |
| @@ -148796,7 +150826,7 @@ static int whereLoopAddBtreeIndex( | |||
| 148796 | pBtm = pTerm; | 150826 | pBtm = pTerm; |
| 148797 | pTop = 0; | 150827 | pTop = 0; |
| 148798 | if( pTerm->wtFlags & TERM_LIKEOPT ){ | 150828 | if( pTerm->wtFlags & TERM_LIKEOPT ){ |
| 148799 | /* Range contraints that come from the LIKE optimization are | 150829 | /* Range constraints that come from the LIKE optimization are |
| 148800 | ** always used in pairs. */ | 150830 | ** always used in pairs. */ |
| 148801 | pTop = &pTerm[1]; | 150831 | pTop = &pTerm[1]; |
| 148802 | assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm ); | 150832 | assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm ); |
| @@ -149101,7 +151131,7 @@ static int whereLoopAddBtree( | |||
| 149101 | LogEst aiRowEstPk[2]; /* The aiRowLogEst[] value for the sPk index */ | 151131 | LogEst aiRowEstPk[2]; /* The aiRowLogEst[] value for the sPk index */ |
| 149102 | i16 aiColumnPk = -1; /* The aColumn[] value for the sPk index */ | 151132 | i16 aiColumnPk = -1; /* The aColumn[] value for the sPk index */ |
| 149103 | SrcList *pTabList; /* The FROM clause */ | 151133 | SrcList *pTabList; /* The FROM clause */ |
| 149104 | struct SrcList_item *pSrc; /* The FROM clause btree term to add */ | 151134 | SrcItem *pSrc; /* The FROM clause btree term to add */ |
| 149105 | WhereLoop *pNew; /* Template WhereLoop object */ | 151135 | WhereLoop *pNew; /* Template WhereLoop object */ |
| 149106 | int rc = SQLITE_OK; /* Return code */ | 151136 | int rc = SQLITE_OK; /* Return code */ |
| 149107 | int iSortIdx = 1; /* Index number */ | 151137 | int iSortIdx = 1; /* Index number */ |
| @@ -149119,9 +151149,9 @@ static int whereLoopAddBtree( | |||
| 149119 | pWC = pBuilder->pWC; | 151149 | pWC = pBuilder->pWC; |
| 149120 | assert( !IsVirtual(pSrc->pTab) ); | 151150 | assert( !IsVirtual(pSrc->pTab) ); |
| 149121 | 151151 | ||
| 149122 | if( pSrc->pIBIndex ){ | 151152 | if( pSrc->fg.isIndexedBy ){ |
| 149123 | /* An INDEXED BY clause specifies a particular index to use */ | 151153 | /* An INDEXED BY clause specifies a particular index to use */ |
| 149124 | pProbe = pSrc->pIBIndex; | 151154 | pProbe = pSrc->u2.pIBIndex; |
| 149125 | }else if( !HasRowid(pTab) ){ | 151155 | }else if( !HasRowid(pTab) ){ |
| 149126 | pProbe = pTab->pIndex; | 151156 | pProbe = pTab->pIndex; |
| 149127 | }else{ | 151157 | }else{ |
| @@ -149157,7 +151187,7 @@ static int whereLoopAddBtree( | |||
| 149157 | if( !pBuilder->pOrSet /* Not part of an OR optimization */ | 151187 | if( !pBuilder->pOrSet /* Not part of an OR optimization */ |
| 149158 | && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 | 151188 | && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 149159 | && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 | 151189 | && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 |
| 149160 | && pSrc->pIBIndex==0 /* Has no INDEXED BY clause */ | 151190 | && !pSrc->fg.isIndexedBy /* Has no INDEXED BY clause */ |
| 149161 | && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */ | 151191 | && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */ |
| 149162 | && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */ | 151192 | && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */ |
| 149163 | && !pSrc->fg.isCorrelated /* Not a correlated subquery */ | 151193 | && !pSrc->fg.isCorrelated /* Not a correlated subquery */ |
| @@ -149207,7 +151237,7 @@ static int whereLoopAddBtree( | |||
| 149207 | /* Loop over all indices. If there was an INDEXED BY clause, then only | 151237 | /* Loop over all indices. If there was an INDEXED BY clause, then only |
| 149208 | ** consider index pProbe. */ | 151238 | ** consider index pProbe. */ |
| 149209 | for(; rc==SQLITE_OK && pProbe; | 151239 | for(; rc==SQLITE_OK && pProbe; |
| 149210 | pProbe=(pSrc->pIBIndex ? 0 : pProbe->pNext), iSortIdx++ | 151240 | pProbe=(pSrc->fg.isIndexedBy ? 0 : pProbe->pNext), iSortIdx++ |
| 149211 | ){ | 151241 | ){ |
| 149212 | int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0; | 151242 | int isLeft = (pSrc->fg.jointype & JT_OUTER)!=0; |
| 149213 | if( pProbe->pPartIdxWhere!=0 | 151243 | if( pProbe->pPartIdxWhere!=0 |
| @@ -149382,7 +151412,7 @@ static int whereLoopAddVirtualOne( | |||
| 149382 | int rc = SQLITE_OK; | 151412 | int rc = SQLITE_OK; |
| 149383 | WhereLoop *pNew = pBuilder->pNew; | 151413 | WhereLoop *pNew = pBuilder->pNew; |
| 149384 | Parse *pParse = pBuilder->pWInfo->pParse; | 151414 | Parse *pParse = pBuilder->pWInfo->pParse; |
| 149385 | struct SrcList_item *pSrc = &pBuilder->pWInfo->pTabList->a[pNew->iTab]; | 151415 | SrcItem *pSrc = &pBuilder->pWInfo->pTabList->a[pNew->iTab]; |
| 149386 | int nConstraint = pIdxInfo->nConstraint; | 151416 | int nConstraint = pIdxInfo->nConstraint; |
| 149387 | 151417 | ||
| 149388 | assert( (mUsable & mPrereq)==mPrereq ); | 151418 | assert( (mUsable & mPrereq)==mPrereq ); |
| @@ -149574,7 +151604,7 @@ static int whereLoopAddVirtual( | |||
| 149574 | WhereInfo *pWInfo; /* WHERE analysis context */ | 151604 | WhereInfo *pWInfo; /* WHERE analysis context */ |
| 149575 | Parse *pParse; /* The parsing context */ | 151605 | Parse *pParse; /* The parsing context */ |
| 149576 | WhereClause *pWC; /* The WHERE clause */ | 151606 | WhereClause *pWC; /* The WHERE clause */ |
| 149577 | struct SrcList_item *pSrc; /* The FROM clause term to search */ | 151607 | SrcItem *pSrc; /* The FROM clause term to search */ |
| 149578 | sqlite3_index_info *p; /* Object to pass to xBestIndex() */ | 151608 | sqlite3_index_info *p; /* Object to pass to xBestIndex() */ |
| 149579 | int nConstraint; /* Number of constraints in p */ | 151609 | int nConstraint; /* Number of constraints in p */ |
| 149580 | int bIn; /* True if plan uses IN(...) operator */ | 151610 | int bIn; /* True if plan uses IN(...) operator */ |
| @@ -149702,7 +151732,7 @@ static int whereLoopAddOr( | |||
| 149702 | WhereClause tempWC; | 151732 | WhereClause tempWC; |
| 149703 | WhereLoopBuilder sSubBuild; | 151733 | WhereLoopBuilder sSubBuild; |
| 149704 | WhereOrSet sSum, sCur; | 151734 | WhereOrSet sSum, sCur; |
| 149705 | struct SrcList_item *pItem; | 151735 | SrcItem *pItem; |
| 149706 | 151736 | ||
| 149707 | pWC = pBuilder->pWC; | 151737 | pWC = pBuilder->pWC; |
| 149708 | pWCEnd = pWC->a + pWC->nTerm; | 151738 | pWCEnd = pWC->a + pWC->nTerm; |
| @@ -149818,8 +151848,8 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ | |||
| 149818 | Bitmask mPrior = 0; | 151848 | Bitmask mPrior = 0; |
| 149819 | int iTab; | 151849 | int iTab; |
| 149820 | SrcList *pTabList = pWInfo->pTabList; | 151850 | SrcList *pTabList = pWInfo->pTabList; |
| 149821 | struct SrcList_item *pItem; | 151851 | SrcItem *pItem; |
| 149822 | struct SrcList_item *pEnd = &pTabList->a[pWInfo->nLevel]; | 151852 | SrcItem *pEnd = &pTabList->a[pWInfo->nLevel]; |
| 149823 | sqlite3 *db = pWInfo->pParse->db; | 151853 | sqlite3 *db = pWInfo->pParse->db; |
| 149824 | int rc = SQLITE_OK; | 151854 | int rc = SQLITE_OK; |
| 149825 | WhereLoop *pNew; | 151855 | WhereLoop *pNew; |
| @@ -149842,7 +151872,7 @@ static int whereLoopAddAll(WhereLoopBuilder *pBuilder){ | |||
| 149842 | } | 151872 | } |
| 149843 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 151873 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 149844 | if( IsVirtual(pItem->pTab) ){ | 151874 | if( IsVirtual(pItem->pTab) ){ |
| 149845 | struct SrcList_item *p; | 151875 | SrcItem *p; |
| 149846 | for(p=&pItem[1]; p<pEnd; p++){ | 151876 | for(p=&pItem[1]; p<pEnd; p++){ |
| 149847 | if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){ | 151877 | if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){ |
| 149848 | mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor); | 151878 | mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor); |
| @@ -150697,7 +152727,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){ | |||
| 150697 | */ | 152727 | */ |
| 150698 | static int whereShortCut(WhereLoopBuilder *pBuilder){ | 152728 | static int whereShortCut(WhereLoopBuilder *pBuilder){ |
| 150699 | WhereInfo *pWInfo; | 152729 | WhereInfo *pWInfo; |
| 150700 | struct SrcList_item *pItem; | 152730 | SrcItem *pItem; |
| 150701 | WhereClause *pWC; | 152731 | WhereClause *pWC; |
| 150702 | WhereTerm *pTerm; | 152732 | WhereTerm *pTerm; |
| 150703 | WhereLoop *pLoop; | 152733 | WhereLoop *pLoop; |
| @@ -151156,7 +153186,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 151156 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ | 153186 | if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){ |
| 151157 | pWInfo->revMask = ALLBITS; | 153187 | pWInfo->revMask = ALLBITS; |
| 151158 | } | 153188 | } |
| 151159 | if( pParse->nErr || NEVER(db->mallocFailed) ){ | 153189 | if( pParse->nErr || db->mallocFailed ){ |
| 151160 | goto whereBeginError; | 153190 | goto whereBeginError; |
| 151161 | } | 153191 | } |
| 151162 | #ifdef WHERETRACE_ENABLED | 153192 | #ifdef WHERETRACE_ENABLED |
| @@ -151227,7 +153257,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 151227 | } | 153257 | } |
| 151228 | for(i=pWInfo->nLevel-1; i>=1; i--){ | 153258 | for(i=pWInfo->nLevel-1; i>=1; i--){ |
| 151229 | WhereTerm *pTerm, *pEnd; | 153259 | WhereTerm *pTerm, *pEnd; |
| 151230 | struct SrcList_item *pItem; | 153260 | SrcItem *pItem; |
| 151231 | pLoop = pWInfo->a[i].pWLoop; | 153261 | pLoop = pWInfo->a[i].pWLoop; |
| 151232 | pItem = &pWInfo->pTabList->a[pLoop->iTab]; | 153262 | pItem = &pWInfo->pTabList->a[pLoop->iTab]; |
| 151233 | if( (pItem->fg.jointype & JT_LEFT)==0 ) continue; | 153263 | if( (pItem->fg.jointype & JT_LEFT)==0 ) continue; |
| @@ -151317,7 +153347,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 151317 | for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){ | 153347 | for(ii=0, pLevel=pWInfo->a; ii<nTabList; ii++, pLevel++){ |
| 151318 | Table *pTab; /* Table to open */ | 153348 | Table *pTab; /* Table to open */ |
| 151319 | int iDb; /* Index of database containing table/index */ | 153349 | int iDb; /* Index of database containing table/index */ |
| 151320 | struct SrcList_item *pTabItem; | 153350 | SrcItem *pTabItem; |
| 151321 | 153351 | ||
| 151322 | pTabItem = &pTabList->a[pLevel->iFrom]; | 153352 | pTabItem = &pTabList->a[pLevel->iFrom]; |
| 151323 | pTab = pTabItem->pTab; | 153353 | pTab = pTabItem->pTab; |
| @@ -151654,7 +153684,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 151654 | int k, last; | 153684 | int k, last; |
| 151655 | VdbeOp *pOp, *pLastOp; | 153685 | VdbeOp *pOp, *pLastOp; |
| 151656 | Index *pIdx = 0; | 153686 | Index *pIdx = 0; |
| 151657 | struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom]; | 153687 | SrcItem *pTabItem = &pTabList->a[pLevel->iFrom]; |
| 151658 | Table *pTab = pTabItem->pTab; | 153688 | Table *pTab = pTabItem->pTab; |
| 151659 | assert( pTab!=0 ); | 153689 | assert( pTab!=0 ); |
| 151660 | pLoop = pLevel->pWLoop; | 153690 | pLoop = pLevel->pWLoop; |
| @@ -151730,7 +153760,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 151730 | #endif | 153760 | #endif |
| 151731 | pOp = sqlite3VdbeGetOp(v, k); | 153761 | pOp = sqlite3VdbeGetOp(v, k); |
| 151732 | pLastOp = pOp + (last - k); | 153762 | pLastOp = pOp + (last - k); |
| 151733 | assert( pOp<pLastOp ); | 153763 | assert( pOp<pLastOp || (pParse->nErr>0 && pOp==pLastOp) ); |
| 151734 | do{ | 153764 | do{ |
| 151735 | if( pOp->p1!=pLevel->iTabCur ){ | 153765 | if( pOp->p1!=pLevel->iTabCur ){ |
| 151736 | /* no-op */ | 153766 | /* no-op */ |
| @@ -153098,15 +155128,19 @@ SQLITE_PRIVATE void sqlite3WindowAttach(Parse *pParse, Expr *p, Window *pWin){ | |||
| 153098 | ** SELECT, or (b) the windows already linked use a compatible window frame. | 155128 | ** SELECT, or (b) the windows already linked use a compatible window frame. |
| 153099 | */ | 155129 | */ |
| 153100 | SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){ | 155130 | SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){ |
| 153101 | if( pSel!=0 | 155131 | if( pSel ){ |
| 153102 | && (0==pSel->pWin || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0)) | 155132 | if( 0==pSel->pWin || 0==sqlite3WindowCompare(0, pSel->pWin, pWin, 0) ){ |
| 153103 | ){ | 155133 | pWin->pNextWin = pSel->pWin; |
| 153104 | pWin->pNextWin = pSel->pWin; | 155134 | if( pSel->pWin ){ |
| 153105 | if( pSel->pWin ){ | 155135 | pSel->pWin->ppThis = &pWin->pNextWin; |
| 153106 | pSel->pWin->ppThis = &pWin->pNextWin; | 155136 | } |
| 155137 | pSel->pWin = pWin; | ||
| 155138 | pWin->ppThis = &pSel->pWin; | ||
| 155139 | }else{ | ||
| 155140 | if( sqlite3ExprListCompare(pWin->pPartition, pSel->pWin->pPartition,-1) ){ | ||
| 155141 | pSel->selFlags |= SF_MultiPart; | ||
| 155142 | } | ||
| 153107 | } | 155143 | } |
| 153108 | pSel->pWin = pWin; | ||
| 153109 | pWin->ppThis = &pSel->pWin; | ||
| 153110 | } | 155144 | } |
| 153111 | } | 155145 | } |
| 153112 | 155146 | ||
| @@ -153855,6 +155889,7 @@ static void windowCodeRangeTest( | |||
| 153855 | int regString = ++pParse->nMem; /* Reg. for constant value '' */ | 155889 | int regString = ++pParse->nMem; /* Reg. for constant value '' */ |
| 153856 | int arith = OP_Add; /* OP_Add or OP_Subtract */ | 155890 | int arith = OP_Add; /* OP_Add or OP_Subtract */ |
| 153857 | int addrGe; /* Jump destination */ | 155891 | int addrGe; /* Jump destination */ |
| 155892 | CollSeq *pColl; | ||
| 153858 | 155893 | ||
| 153859 | assert( op==OP_Ge || op==OP_Gt || op==OP_Le ); | 155894 | assert( op==OP_Ge || op==OP_Gt || op==OP_Le ); |
| 153860 | assert( pOrderBy && pOrderBy->nExpr==1 ); | 155895 | assert( pOrderBy && pOrderBy->nExpr==1 ); |
| @@ -153945,6 +155980,8 @@ static void windowCodeRangeTest( | |||
| 153945 | ** control skips over this test if the BIGNULL flag is set and either | 155980 | ** control skips over this test if the BIGNULL flag is set and either |
| 153946 | ** reg1 or reg2 contain a NULL value. */ | 155981 | ** reg1 or reg2 contain a NULL value. */ |
| 153947 | sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v); | 155982 | sqlite3VdbeAddOp3(v, op, reg2, lbl, reg1); VdbeCoverage(v); |
| 155983 | pColl = sqlite3ExprNNCollSeq(pParse, pOrderBy->a[0].pExpr); | ||
| 155984 | sqlite3VdbeAppendP4(v, (void*)pColl, P4_COLLSEQ); | ||
| 153948 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); | 155985 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 153949 | 155986 | ||
| 153950 | assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le ); | 155987 | assert( op==OP_Ge || op==OP_Gt || op==OP_Lt || op==OP_Le ); |
| @@ -154951,11 +156988,21 @@ static void updateDeleteLimitError( | |||
| 154951 | static void parserDoubleLinkSelect(Parse *pParse, Select *p){ | 156988 | static void parserDoubleLinkSelect(Parse *pParse, Select *p){ |
| 154952 | assert( p!=0 ); | 156989 | assert( p!=0 ); |
| 154953 | if( p->pPrior ){ | 156990 | if( p->pPrior ){ |
| 154954 | Select *pNext = 0, *pLoop; | 156991 | Select *pNext = 0, *pLoop = p; |
| 154955 | int mxSelect, cnt = 0; | 156992 | int mxSelect, cnt = 1; |
| 154956 | for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){ | 156993 | while(1){ |
| 154957 | pLoop->pNext = pNext; | 156994 | pLoop->pNext = pNext; |
| 154958 | pLoop->selFlags |= SF_Compound; | 156995 | pLoop->selFlags |= SF_Compound; |
| 156996 | pNext = pLoop; | ||
| 156997 | pLoop = pLoop->pPrior; | ||
| 156998 | if( pLoop==0 ) break; | ||
| 156999 | cnt++; | ||
| 157000 | if( pLoop->pOrderBy || pLoop->pLimit ){ | ||
| 157001 | sqlite3ErrorMsg(pParse,"%s clause should come after %s not before", | ||
| 157002 | pLoop->pOrderBy!=0 ? "ORDER BY" : "LIMIT", | ||
| 157003 | sqlite3SelectOpName(pNext->op)); | ||
| 157004 | break; | ||
| 157005 | } | ||
| 154959 | } | 157006 | } |
| 154960 | if( (p->selFlags & SF_MultiValue)==0 && | 157007 | if( (p->selFlags & SF_MultiValue)==0 && |
| 154961 | (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 && | 157008 | (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 && |
| @@ -154966,6 +157013,19 @@ static void updateDeleteLimitError( | |||
| 154966 | } | 157013 | } |
| 154967 | } | 157014 | } |
| 154968 | 157015 | ||
| 157016 | /* Attach a With object describing the WITH clause to a Select | ||
| 157017 | ** object describing the query for which the WITH clause is a prefix. | ||
| 157018 | */ | ||
| 157019 | static Select *attachWithToSelect(Parse *pParse, Select *pSelect, With *pWith){ | ||
| 157020 | if( pSelect ){ | ||
| 157021 | pSelect->pWith = pWith; | ||
| 157022 | parserDoubleLinkSelect(pParse, pSelect); | ||
| 157023 | }else{ | ||
| 157024 | sqlite3WithDelete(pParse->db, pWith); | ||
| 157025 | } | ||
| 157026 | return pSelect; | ||
| 157027 | } | ||
| 157028 | |||
| 154969 | 157029 | ||
| 154970 | /* Construct a new Expr object from a single identifier. Use the | 157030 | /* Construct a new Expr object from a single identifier. Use the |
| 154971 | ** new Expr to populate pOut. Set the span of pOut to be the identifier | 157031 | ** new Expr to populate pOut. Set the span of pOut to be the identifier |
| @@ -155141,90 +157201,92 @@ static void updateDeleteLimitError( | |||
| 155141 | #define TK_TIES 94 | 157201 | #define TK_TIES 94 |
| 155142 | #define TK_GENERATED 95 | 157202 | #define TK_GENERATED 95 |
| 155143 | #define TK_ALWAYS 96 | 157203 | #define TK_ALWAYS 96 |
| 155144 | #define TK_REINDEX 97 | 157204 | #define TK_MATERIALIZED 97 |
| 155145 | #define TK_RENAME 98 | 157205 | #define TK_REINDEX 98 |
| 155146 | #define TK_CTIME_KW 99 | 157206 | #define TK_RENAME 99 |
| 155147 | #define TK_ANY 100 | 157207 | #define TK_CTIME_KW 100 |
| 155148 | #define TK_BITAND 101 | 157208 | #define TK_ANY 101 |
| 155149 | #define TK_BITOR 102 | 157209 | #define TK_BITAND 102 |
| 155150 | #define TK_LSHIFT 103 | 157210 | #define TK_BITOR 103 |
| 155151 | #define TK_RSHIFT 104 | 157211 | #define TK_LSHIFT 104 |
| 155152 | #define TK_PLUS 105 | 157212 | #define TK_RSHIFT 105 |
| 155153 | #define TK_MINUS 106 | 157213 | #define TK_PLUS 106 |
| 155154 | #define TK_STAR 107 | 157214 | #define TK_MINUS 107 |
| 155155 | #define TK_SLASH 108 | 157215 | #define TK_STAR 108 |
| 155156 | #define TK_REM 109 | 157216 | #define TK_SLASH 109 |
| 155157 | #define TK_CONCAT 110 | 157217 | #define TK_REM 110 |
| 155158 | #define TK_COLLATE 111 | 157218 | #define TK_CONCAT 111 |
| 155159 | #define TK_BITNOT 112 | 157219 | #define TK_COLLATE 112 |
| 155160 | #define TK_ON 113 | 157220 | #define TK_BITNOT 113 |
| 155161 | #define TK_INDEXED 114 | 157221 | #define TK_ON 114 |
| 155162 | #define TK_STRING 115 | 157222 | #define TK_INDEXED 115 |
| 155163 | #define TK_JOIN_KW 116 | 157223 | #define TK_STRING 116 |
| 155164 | #define TK_CONSTRAINT 117 | 157224 | #define TK_JOIN_KW 117 |
| 155165 | #define TK_DEFAULT 118 | 157225 | #define TK_CONSTRAINT 118 |
| 155166 | #define TK_NULL 119 | 157226 | #define TK_DEFAULT 119 |
| 155167 | #define TK_PRIMARY 120 | 157227 | #define TK_NULL 120 |
| 155168 | #define TK_UNIQUE 121 | 157228 | #define TK_PRIMARY 121 |
| 155169 | #define TK_CHECK 122 | 157229 | #define TK_UNIQUE 122 |
| 155170 | #define TK_REFERENCES 123 | 157230 | #define TK_CHECK 123 |
| 155171 | #define TK_AUTOINCR 124 | 157231 | #define TK_REFERENCES 124 |
| 155172 | #define TK_INSERT 125 | 157232 | #define TK_AUTOINCR 125 |
| 155173 | #define TK_DELETE 126 | 157233 | #define TK_INSERT 126 |
| 155174 | #define TK_UPDATE 127 | 157234 | #define TK_DELETE 127 |
| 155175 | #define TK_SET 128 | 157235 | #define TK_UPDATE 128 |
| 155176 | #define TK_DEFERRABLE 129 | 157236 | #define TK_SET 129 |
| 155177 | #define TK_FOREIGN 130 | 157237 | #define TK_DEFERRABLE 130 |
| 155178 | #define TK_DROP 131 | 157238 | #define TK_FOREIGN 131 |
| 155179 | #define TK_UNION 132 | 157239 | #define TK_DROP 132 |
| 155180 | #define TK_ALL 133 | 157240 | #define TK_UNION 133 |
| 155181 | #define TK_EXCEPT 134 | 157241 | #define TK_ALL 134 |
| 155182 | #define TK_INTERSECT 135 | 157242 | #define TK_EXCEPT 135 |
| 155183 | #define TK_SELECT 136 | 157243 | #define TK_INTERSECT 136 |
| 155184 | #define TK_VALUES 137 | 157244 | #define TK_SELECT 137 |
| 155185 | #define TK_DISTINCT 138 | 157245 | #define TK_VALUES 138 |
| 155186 | #define TK_DOT 139 | 157246 | #define TK_DISTINCT 139 |
| 155187 | #define TK_FROM 140 | 157247 | #define TK_DOT 140 |
| 155188 | #define TK_JOIN 141 | 157248 | #define TK_FROM 141 |
| 155189 | #define TK_USING 142 | 157249 | #define TK_JOIN 142 |
| 155190 | #define TK_ORDER 143 | 157250 | #define TK_USING 143 |
| 155191 | #define TK_GROUP 144 | 157251 | #define TK_ORDER 144 |
| 155192 | #define TK_HAVING 145 | 157252 | #define TK_GROUP 145 |
| 155193 | #define TK_LIMIT 146 | 157253 | #define TK_HAVING 146 |
| 155194 | #define TK_WHERE 147 | 157254 | #define TK_LIMIT 147 |
| 155195 | #define TK_INTO 148 | 157255 | #define TK_WHERE 148 |
| 155196 | #define TK_NOTHING 149 | 157256 | #define TK_RETURNING 149 |
| 155197 | #define TK_FLOAT 150 | 157257 | #define TK_INTO 150 |
| 155198 | #define TK_BLOB 151 | 157258 | #define TK_NOTHING 151 |
| 155199 | #define TK_INTEGER 152 | 157259 | #define TK_FLOAT 152 |
| 155200 | #define TK_VARIABLE 153 | 157260 | #define TK_BLOB 153 |
| 155201 | #define TK_CASE 154 | 157261 | #define TK_INTEGER 154 |
| 155202 | #define TK_WHEN 155 | 157262 | #define TK_VARIABLE 155 |
| 155203 | #define TK_THEN 156 | 157263 | #define TK_CASE 156 |
| 155204 | #define TK_ELSE 157 | 157264 | #define TK_WHEN 157 |
| 155205 | #define TK_INDEX 158 | 157265 | #define TK_THEN 158 |
| 155206 | #define TK_ALTER 159 | 157266 | #define TK_ELSE 159 |
| 155207 | #define TK_ADD 160 | 157267 | #define TK_INDEX 160 |
| 155208 | #define TK_WINDOW 161 | 157268 | #define TK_ALTER 161 |
| 155209 | #define TK_OVER 162 | 157269 | #define TK_ADD 162 |
| 155210 | #define TK_FILTER 163 | 157270 | #define TK_WINDOW 163 |
| 155211 | #define TK_COLUMN 164 | 157271 | #define TK_OVER 164 |
| 155212 | #define TK_AGG_FUNCTION 165 | 157272 | #define TK_FILTER 165 |
| 155213 | #define TK_AGG_COLUMN 166 | 157273 | #define TK_COLUMN 166 |
| 155214 | #define TK_TRUEFALSE 167 | 157274 | #define TK_AGG_FUNCTION 167 |
| 155215 | #define TK_ISNOT 168 | 157275 | #define TK_AGG_COLUMN 168 |
| 155216 | #define TK_FUNCTION 169 | 157276 | #define TK_TRUEFALSE 169 |
| 155217 | #define TK_UMINUS 170 | 157277 | #define TK_ISNOT 170 |
| 155218 | #define TK_UPLUS 171 | 157278 | #define TK_FUNCTION 171 |
| 155219 | #define TK_TRUTH 172 | 157279 | #define TK_UMINUS 172 |
| 155220 | #define TK_REGISTER 173 | 157280 | #define TK_UPLUS 173 |
| 155221 | #define TK_VECTOR 174 | 157281 | #define TK_TRUTH 174 |
| 155222 | #define TK_SELECT_COLUMN 175 | 157282 | #define TK_REGISTER 175 |
| 155223 | #define TK_IF_NULL_ROW 176 | 157283 | #define TK_VECTOR 176 |
| 155224 | #define TK_ASTERISK 177 | 157284 | #define TK_SELECT_COLUMN 177 |
| 155225 | #define TK_SPAN 178 | 157285 | #define TK_IF_NULL_ROW 178 |
| 155226 | #define TK_SPACE 179 | 157286 | #define TK_ASTERISK 179 |
| 155227 | #define TK_ILLEGAL 180 | 157287 | #define TK_SPAN 180 |
| 157288 | #define TK_SPACE 181 | ||
| 157289 | #define TK_ILLEGAL 182 | ||
| 155228 | #endif | 157290 | #endif |
| 155229 | /**************** End token definitions ***************************************/ | 157291 | /**************** End token definitions ***************************************/ |
| 155230 | 157292 | ||
| @@ -155284,28 +157346,29 @@ static void updateDeleteLimitError( | |||
| 155284 | #endif | 157346 | #endif |
| 155285 | /************* Begin control #defines *****************************************/ | 157347 | /************* Begin control #defines *****************************************/ |
| 155286 | #define YYCODETYPE unsigned short int | 157348 | #define YYCODETYPE unsigned short int |
| 155287 | #define YYNOCODE 310 | 157349 | #define YYNOCODE 316 |
| 155288 | #define YYACTIONTYPE unsigned short int | 157350 | #define YYACTIONTYPE unsigned short int |
| 155289 | #define YYWILDCARD 100 | 157351 | #define YYWILDCARD 101 |
| 155290 | #define sqlite3ParserTOKENTYPE Token | 157352 | #define sqlite3ParserTOKENTYPE Token |
| 155291 | typedef union { | 157353 | typedef union { |
| 155292 | int yyinit; | 157354 | int yyinit; |
| 155293 | sqlite3ParserTOKENTYPE yy0; | 157355 | sqlite3ParserTOKENTYPE yy0; |
| 155294 | SrcList* yy47; | 157356 | Window* yy19; |
| 155295 | u8 yy58; | 157357 | struct TrigEvent yy50; |
| 155296 | struct FrameBound yy77; | 157358 | int yy60; |
| 155297 | With* yy131; | 157359 | struct FrameBound yy113; |
| 155298 | int yy192; | 157360 | Upsert* yy178; |
| 155299 | Expr* yy202; | 157361 | With* yy195; |
| 155300 | struct {int value; int mask;} yy207; | 157362 | IdList* yy288; |
| 155301 | struct TrigEvent yy230; | 157363 | SrcList* yy291; |
| 155302 | ExprList* yy242; | 157364 | Select* yy307; |
| 155303 | Window* yy303; | 157365 | ExprList* yy338; |
| 155304 | Upsert* yy318; | 157366 | TriggerStep* yy483; |
| 155305 | const char* yy436; | 157367 | const char* yy528; |
| 155306 | TriggerStep* yy447; | 157368 | u8 yy570; |
| 155307 | Select* yy539; | 157369 | Expr* yy602; |
| 155308 | IdList* yy600; | 157370 | Cte* yy607; |
| 157371 | struct {int value; int mask;} yy615; | ||
| 155309 | } YYMINORTYPE; | 157372 | } YYMINORTYPE; |
| 155310 | #ifndef YYSTACKDEPTH | 157373 | #ifndef YYSTACKDEPTH |
| 155311 | #define YYSTACKDEPTH 100 | 157374 | #define YYSTACKDEPTH 100 |
| @@ -155321,18 +157384,18 @@ typedef union { | |||
| 155321 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; | 157384 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 155322 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; | 157385 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 155323 | #define YYFALLBACK 1 | 157386 | #define YYFALLBACK 1 |
| 155324 | #define YYNSTATE 553 | 157387 | #define YYNSTATE 570 |
| 155325 | #define YYNRULE 385 | 157388 | #define YYNRULE 398 |
| 155326 | #define YYNRULE_WITH_ACTION 325 | 157389 | #define YYNRULE_WITH_ACTION 337 |
| 155327 | #define YYNTOKEN 181 | 157390 | #define YYNTOKEN 183 |
| 155328 | #define YY_MAX_SHIFT 552 | 157391 | #define YY_MAX_SHIFT 569 |
| 155329 | #define YY_MIN_SHIFTREDUCE 803 | 157392 | #define YY_MIN_SHIFTREDUCE 825 |
| 155330 | #define YY_MAX_SHIFTREDUCE 1187 | 157393 | #define YY_MAX_SHIFTREDUCE 1222 |
| 155331 | #define YY_ERROR_ACTION 1188 | 157394 | #define YY_ERROR_ACTION 1223 |
| 155332 | #define YY_ACCEPT_ACTION 1189 | 157395 | #define YY_ACCEPT_ACTION 1224 |
| 155333 | #define YY_NO_ACTION 1190 | 157396 | #define YY_NO_ACTION 1225 |
| 155334 | #define YY_MIN_REDUCE 1191 | 157397 | #define YY_MIN_REDUCE 1226 |
| 155335 | #define YY_MAX_REDUCE 1575 | 157398 | #define YY_MAX_REDUCE 1623 |
| 155336 | /************* End control #defines *******************************************/ | 157399 | /************* End control #defines *******************************************/ |
| 155337 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) | 157400 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 155338 | 157401 | ||
| @@ -155399,586 +157462,600 @@ typedef union { | |||
| 155399 | ** yy_default[] Default action for each state. | 157462 | ** yy_default[] Default action for each state. |
| 155400 | ** | 157463 | ** |
| 155401 | *********** Begin parsing tables **********************************************/ | 157464 | *********** Begin parsing tables **********************************************/ |
| 155402 | #define YY_ACTTAB_COUNT (1962) | 157465 | #define YY_ACTTAB_COUNT (2020) |
| 155403 | static const YYACTIONTYPE yy_action[] = { | 157466 | static const YYACTIONTYPE yy_action[] = { |
| 155404 | /* 0 */ 546, 1222, 546, 451, 1260, 546, 1239, 546, 114, 111, | 157467 | /* 0 */ 563, 1295, 563, 1274, 168, 361, 115, 112, 218, 373, |
| 155405 | /* 10 */ 211, 546, 1537, 546, 1260, 523, 114, 111, 211, 392, | 157468 | /* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406, |
| 155406 | /* 20 */ 1232, 344, 42, 42, 42, 42, 1225, 42, 42, 71, | 157469 | /* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298, |
| 155407 | /* 30 */ 71, 937, 1224, 71, 71, 71, 71, 1462, 1493, 938, | 157470 | /* 30 */ 1298, 959, 41, 41, 1257, 71, 71, 51, 51, 960, |
| 155408 | /* 40 */ 820, 453, 6, 121, 122, 112, 1165, 1165, 1006, 1009, | 157471 | /* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 155409 | /* 50 */ 999, 999, 119, 119, 120, 120, 120, 120, 1543, 392, | 157472 | /* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406, |
| 155410 | /* 60 */ 1358, 1517, 552, 2, 1193, 194, 528, 436, 143, 291, | 157473 | /* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218, |
| 155411 | /* 70 */ 528, 136, 528, 371, 261, 504, 272, 385, 1273, 527, | 157474 | /* 70 */ 197, 268, 545, 560, 515, 560, 1260, 563, 385, 248, |
| 155412 | /* 80 */ 503, 493, 164, 121, 122, 112, 1165, 1165, 1006, 1009, | 157475 | /* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 155413 | /* 90 */ 999, 999, 119, 119, 120, 120, 120, 120, 1358, 442, | 157476 | /* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13, |
| 155414 | /* 100 */ 1514, 118, 118, 118, 118, 117, 117, 116, 116, 116, | 157477 | /* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117, |
| 155415 | /* 110 */ 115, 424, 266, 266, 266, 266, 1498, 358, 1500, 435, | 157478 | /* 110 */ 117, 116, 441, 1176, 419, 1531, 446, 137, 512, 1539, |
| 155416 | /* 120 */ 357, 1498, 517, 524, 1485, 543, 1114, 543, 1114, 392, | 157479 | /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 1584, 1148, 406, |
| 155417 | /* 130 */ 405, 241, 208, 114, 111, 211, 98, 290, 537, 221, | 157480 | /* 130 */ 1545, 534, 115, 112, 218, 1267, 99, 441, 121, 121, |
| 155418 | /* 140 */ 1029, 118, 118, 118, 118, 117, 117, 116, 116, 116, | 157481 | /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117, |
| 155419 | /* 150 */ 115, 424, 1142, 121, 122, 112, 1165, 1165, 1006, 1009, | 157482 | /* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 155420 | /* 160 */ 999, 999, 119, 119, 120, 120, 120, 120, 406, 428, | 157483 | /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 197, 1176, |
| 155421 | /* 170 */ 117, 117, 116, 116, 116, 115, 424, 1418, 468, 123, | 157484 | /* 170 */ 1177, 1178, 241, 304, 554, 501, 498, 497, 473, 124, |
| 155422 | /* 180 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, | 157485 | /* 180 */ 394, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119, |
| 155423 | /* 190 */ 424, 116, 116, 116, 115, 424, 540, 540, 540, 392, | 157486 | /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 540, 406, |
| 155424 | /* 200 */ 505, 120, 120, 120, 120, 113, 1051, 1142, 1143, 1144, | 157487 | /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441, |
| 155425 | /* 210 */ 1051, 118, 118, 118, 118, 117, 117, 116, 116, 116, | 157488 | /* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117, |
| 155426 | /* 220 */ 115, 424, 1461, 121, 122, 112, 1165, 1165, 1006, 1009, | 157489 | /* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, |
| 155427 | /* 230 */ 999, 999, 119, 119, 120, 120, 120, 120, 392, 444, | 157490 | /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 320, |
| 155428 | /* 240 */ 316, 83, 463, 81, 359, 382, 1142, 80, 118, 118, | 157491 | /* 240 */ 1176, 1177, 1178, 81, 342, 1590, 396, 80, 119, 119, |
| 155429 | /* 250 */ 118, 118, 117, 117, 116, 116, 116, 115, 424, 179, | 157492 | /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 1176, |
| 155430 | /* 260 */ 434, 424, 121, 122, 112, 1165, 1165, 1006, 1009, 999, | 157493 | /* 260 */ 211, 450, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 155431 | /* 270 */ 999, 119, 119, 120, 120, 120, 120, 434, 433, 266, | 157494 | /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 251, 450, 449, |
| 155432 | /* 280 */ 266, 118, 118, 118, 118, 117, 117, 116, 116, 116, | 157495 | /* 280 */ 273, 273, 119, 119, 119, 119, 118, 118, 117, 117, |
| 155433 | /* 290 */ 115, 424, 543, 1109, 903, 506, 1142, 114, 111, 211, | 157496 | /* 290 */ 117, 116, 441, 560, 1224, 1, 1, 569, 2, 1228, |
| 155434 | /* 300 */ 1431, 1142, 1143, 1144, 206, 491, 1109, 392, 449, 1109, | 157497 | /* 300 */ 317, 1176, 319, 1561, 305, 337, 140, 340, 406, 430, |
| 155435 | /* 310 */ 545, 330, 120, 120, 120, 120, 298, 1431, 1433, 17, | 157498 | /* 310 */ 469, 1533, 1197, 1308, 348, 1176, 1177, 1178, 168, 462, |
| 155436 | /* 320 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, | 157499 | /* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 155437 | /* 330 */ 424, 121, 122, 112, 1165, 1165, 1006, 1009, 999, 999, | 157500 | /* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 155438 | /* 340 */ 119, 119, 120, 120, 120, 120, 392, 1358, 434, 1142, | 157501 | /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 273, 273, 563, |
| 155439 | /* 350 */ 482, 1142, 1143, 1144, 996, 996, 1007, 1010, 445, 118, | 157502 | /* 350 */ 83, 450, 416, 1564, 569, 2, 1228, 1176, 1177, 1178, |
| 155440 | /* 360 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 424, | 157503 | /* 360 */ 560, 305, 471, 140, 944, 995, 860, 563, 467, 1197, |
| 155441 | /* 370 */ 121, 122, 112, 1165, 1165, 1006, 1009, 999, 999, 119, | 157504 | /* 370 */ 1308, 13, 13, 137, 229, 118, 118, 117, 117, 117, |
| 155442 | /* 380 */ 119, 120, 120, 120, 120, 1054, 1054, 465, 1431, 118, | 157505 | /* 380 */ 116, 441, 96, 318, 946, 504, 424, 361, 562, 71, |
| 155443 | /* 390 */ 118, 118, 118, 117, 117, 116, 116, 116, 115, 424, | 157506 | /* 390 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 155444 | /* 400 */ 1142, 451, 546, 1426, 1142, 1143, 1144, 233, 966, 1142, | 157507 | /* 400 */ 116, 441, 427, 205, 273, 273, 445, 1015, 259, 276, |
| 155445 | /* 410 */ 481, 478, 477, 171, 360, 392, 164, 407, 414, 842, | 157508 | /* 410 */ 356, 507, 351, 506, 246, 406, 959, 560, 328, 344, |
| 155446 | /* 420 */ 476, 164, 185, 334, 71, 71, 1243, 1000, 118, 118, | 157509 | /* 420 */ 347, 315, 860, 1006, 960, 126, 545, 1005, 313, 304, |
| 155447 | /* 430 */ 118, 118, 117, 117, 116, 116, 116, 115, 424, 121, | 157510 | /* 430 */ 554, 229, 538, 1539, 148, 544, 281, 6, 203, 122, |
| 155448 | /* 440 */ 122, 112, 1165, 1165, 1006, 1009, 999, 999, 119, 119, | 157511 | /* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 155449 | /* 450 */ 120, 120, 120, 120, 392, 1142, 1143, 1144, 835, 12, | 157512 | /* 450 */ 121, 121, 121, 121, 563, 217, 563, 12, 406, 1005, |
| 155450 | /* 460 */ 314, 509, 163, 356, 1142, 1143, 1144, 114, 111, 211, | 157513 | /* 460 */ 1005, 1007, 502, 445, 119, 119, 119, 119, 118, 118, |
| 155451 | /* 470 */ 508, 290, 537, 546, 276, 180, 290, 537, 121, 122, | 157514 | /* 470 */ 117, 117, 117, 116, 441, 452, 71, 71, 70, 70, |
| 155452 | /* 480 */ 112, 1165, 1165, 1006, 1009, 999, 999, 119, 119, 120, | 157515 | /* 480 */ 944, 137, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 155453 | /* 490 */ 120, 120, 120, 345, 484, 71, 71, 118, 118, 118, | 157516 | /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 1530, 119, 119, |
| 155454 | /* 500 */ 118, 117, 117, 116, 116, 116, 115, 424, 1142, 209, | 157517 | /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 403, |
| 155455 | /* 510 */ 411, 523, 1142, 1109, 1571, 378, 252, 269, 342, 487, | 157518 | /* 510 */ 402, 241, 1176, 545, 501, 498, 497, 1468, 1143, 451, |
| 155456 | /* 520 */ 337, 486, 238, 392, 513, 364, 1109, 1127, 333, 1109, | 157519 | /* 520 */ 267, 267, 513, 1540, 496, 142, 1176, 6, 406, 530, |
| 155457 | /* 530 */ 191, 409, 286, 32, 457, 443, 118, 118, 118, 118, | 157520 | /* 530 */ 194, 1143, 864, 560, 1143, 461, 182, 304, 554, 32, |
| 155458 | /* 540 */ 117, 117, 116, 116, 116, 115, 424, 121, 122, 112, | 157521 | /* 540 */ 379, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 155459 | /* 550 */ 1165, 1165, 1006, 1009, 999, 999, 119, 119, 120, 120, | 157522 | /* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, |
| 155460 | /* 560 */ 120, 120, 392, 1142, 1143, 1144, 987, 1142, 1143, 1144, | 157523 | /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 1176, 1177, |
| 155461 | /* 570 */ 1142, 233, 492, 1492, 481, 478, 477, 6, 163, 546, | 157524 | /* 570 */ 1178, 857, 568, 1176, 1228, 925, 1176, 454, 361, 305, |
| 155462 | /* 580 */ 512, 546, 115, 424, 476, 5, 121, 122, 112, 1165, | 157525 | /* 580 */ 189, 140, 1176, 1177, 1178, 519, 529, 404, 1308, 183, |
| 155463 | /* 590 */ 1165, 1006, 1009, 999, 999, 119, 119, 120, 120, 120, | 157526 | /* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 155464 | /* 600 */ 120, 13, 13, 13, 13, 118, 118, 118, 118, 117, | 157527 | /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 16, 16, 370, |
| 155465 | /* 610 */ 117, 116, 116, 116, 115, 424, 403, 502, 408, 546, | 157528 | /* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 155466 | /* 620 */ 1486, 544, 1142, 892, 892, 1142, 1143, 1144, 1473, 1142, | 157529 | /* 620 */ 116, 441, 273, 273, 1537, 150, 1176, 98, 6, 1176, |
| 155467 | /* 630 */ 275, 392, 808, 809, 810, 971, 422, 422, 422, 16, | 157530 | /* 630 */ 1177, 1178, 1176, 1177, 1178, 560, 380, 406, 376, 438, |
| 155468 | /* 640 */ 16, 55, 55, 1242, 118, 118, 118, 118, 117, 117, | 157531 | /* 640 */ 437, 1161, 1005, 1005, 1007, 1025, 1025, 1036, 1039, 229, |
| 155469 | /* 650 */ 116, 116, 116, 115, 424, 121, 122, 112, 1165, 1165, | 157532 | /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 155470 | /* 660 */ 1006, 1009, 999, 999, 119, 119, 120, 120, 120, 120, | 157533 | /* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 155471 | /* 670 */ 392, 1189, 1, 1, 552, 2, 1193, 1142, 1143, 1144, | 157534 | /* 670 */ 120, 120, 121, 121, 121, 121, 406, 1143, 1619, 392, |
| 155472 | /* 680 */ 194, 291, 898, 136, 1142, 1143, 1144, 897, 521, 1492, | 157535 | /* 680 */ 1016, 445, 1176, 1177, 1178, 1207, 525, 1207, 1530, 995, |
| 155473 | /* 690 */ 1273, 3, 380, 6, 121, 122, 112, 1165, 1165, 1006, | 157536 | /* 690 */ 1143, 304, 554, 1143, 5, 563, 543, 3, 361, 216, |
| 155474 | /* 700 */ 1009, 999, 999, 119, 119, 120, 120, 120, 120, 858, | 157537 | /* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, |
| 155475 | /* 710 */ 546, 924, 546, 118, 118, 118, 118, 117, 117, 116, | 157538 | /* 710 */ 120, 121, 121, 121, 121, 143, 563, 13, 13, 1029, |
| 155476 | /* 720 */ 116, 116, 115, 424, 266, 266, 1092, 1569, 1142, 551, | 157539 | /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 155477 | /* 730 */ 1569, 1193, 13, 13, 13, 13, 291, 543, 136, 392, | 157540 | /* 730 */ 441, 1176, 426, 563, 1176, 563, 274, 274, 13, 13, |
| 155478 | /* 740 */ 485, 421, 420, 966, 344, 1273, 468, 410, 859, 279, | 157541 | /* 740 */ 1078, 1176, 328, 457, 316, 147, 406, 211, 361, 560, |
| 155479 | /* 750 */ 140, 221, 118, 118, 118, 118, 117, 117, 116, 116, | 157542 | /* 750 */ 1000, 213, 511, 293, 477, 55, 55, 71, 71, 119, |
| 155480 | /* 760 */ 116, 115, 424, 121, 122, 112, 1165, 1165, 1006, 1009, | 157543 | /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, |
| 155481 | /* 770 */ 999, 999, 119, 119, 120, 120, 120, 120, 546, 266, | 157544 | /* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, |
| 155482 | /* 780 */ 266, 428, 392, 1142, 1143, 1144, 1172, 830, 1172, 468, | 157545 | /* 780 */ 120, 121, 121, 121, 121, 406, 455, 1176, 1177, 1178, |
| 155483 | /* 790 */ 431, 145, 543, 1146, 401, 314, 439, 302, 838, 1490, | 157546 | /* 790 */ 1176, 1177, 1178, 471, 526, 149, 404, 1176, 1177, 1178, |
| 155484 | /* 800 */ 71, 71, 412, 6, 1090, 473, 221, 100, 112, 1165, | 157547 | /* 800 */ 105, 270, 103, 563, 944, 563, 116, 441, 1530, 122, |
| 155485 | /* 810 */ 1165, 1006, 1009, 999, 999, 119, 119, 120, 120, 120, | 157548 | /* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 155486 | /* 820 */ 120, 118, 118, 118, 118, 117, 117, 116, 116, 116, | 157549 | /* 820 */ 121, 121, 121, 121, 945, 13, 13, 13, 13, 119, |
| 155487 | /* 830 */ 115, 424, 237, 1425, 546, 451, 428, 287, 986, 546, | 157550 | /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, |
| 155488 | /* 840 */ 236, 235, 234, 830, 97, 529, 429, 1265, 1265, 1146, | 157551 | /* 840 */ 191, 563, 192, 563, 416, 439, 439, 439, 1083, 1083, |
| 155489 | /* 850 */ 494, 307, 430, 838, 977, 546, 71, 71, 976, 1241, | 157552 | /* 850 */ 485, 561, 285, 914, 914, 406, 462, 330, 1530, 830, |
| 155490 | /* 860 */ 546, 51, 51, 300, 118, 118, 118, 118, 117, 117, | 157553 | /* 860 */ 831, 832, 206, 71, 71, 71, 71, 286, 119, 119, |
| 155491 | /* 870 */ 116, 116, 116, 115, 424, 194, 103, 70, 70, 266, | 157554 | /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122, |
| 155492 | /* 880 */ 266, 546, 71, 71, 266, 266, 30, 391, 344, 976, | 157555 | /* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, |
| 155493 | /* 890 */ 976, 978, 543, 528, 1109, 328, 392, 543, 495, 397, | 157556 | /* 890 */ 121, 121, 121, 121, 563, 217, 563, 1122, 1617, 406, |
| 155494 | /* 900 */ 1470, 195, 530, 13, 13, 1358, 240, 1109, 277, 280, | 157557 | /* 900 */ 300, 1617, 301, 416, 1278, 1473, 244, 243, 242, 1249, |
| 155495 | /* 910 */ 1109, 280, 304, 457, 306, 333, 392, 31, 188, 419, | 157558 | /* 910 */ 412, 556, 412, 282, 842, 279, 71, 71, 71, 71, |
| 155496 | /* 920 */ 121, 122, 112, 1165, 1165, 1006, 1009, 999, 999, 119, | 157559 | /* 920 */ 944, 1415, 1473, 1475, 101, 113, 1200, 1200, 1035, 1038, |
| 155497 | /* 930 */ 119, 120, 120, 120, 120, 142, 392, 365, 457, 986, | 157560 | /* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119, |
| 155498 | /* 940 */ 121, 122, 112, 1165, 1165, 1006, 1009, 999, 999, 119, | 157561 | /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273, |
| 155499 | /* 950 */ 119, 120, 120, 120, 120, 977, 323, 1142, 326, 976, | 157562 | /* 950 */ 273, 1099, 563, 436, 1143, 440, 563, 1122, 1618, 357, |
| 155500 | /* 960 */ 121, 110, 112, 1165, 1165, 1006, 1009, 999, 999, 119, | 157563 | /* 960 */ 1558, 1618, 560, 546, 488, 197, 1100, 1143, 378, 290, |
| 155501 | /* 970 */ 119, 120, 120, 120, 120, 464, 377, 1185, 118, 118, | 157564 | /* 970 */ 1143, 1306, 284, 460, 71, 71, 1120, 405, 13, 13, |
| 155502 | /* 980 */ 118, 118, 117, 117, 116, 116, 116, 115, 424, 1142, | 157565 | /* 980 */ 145, 1101, 119, 119, 119, 119, 118, 118, 117, 117, |
| 155503 | /* 990 */ 976, 976, 978, 305, 9, 366, 244, 362, 118, 118, | 157566 | /* 990 */ 117, 116, 441, 542, 104, 1473, 509, 273, 273, 294, |
| 155504 | /* 1000 */ 118, 118, 117, 117, 116, 116, 116, 115, 424, 313, | 157567 | /* 1000 */ 1514, 294, 900, 273, 273, 273, 273, 563, 1503, 563, |
| 155505 | /* 1010 */ 546, 344, 1142, 1143, 1144, 299, 290, 537, 118, 118, | 157568 | /* 1010 */ 560, 545, 901, 464, 406, 1058, 560, 852, 560, 198, |
| 155506 | /* 1020 */ 118, 118, 117, 117, 116, 116, 116, 115, 424, 1263, | 157569 | /* 1020 */ 547, 1080, 920, 404, 1400, 1080, 146, 919, 38, 56, |
| 155507 | /* 1030 */ 1263, 1163, 13, 13, 278, 421, 420, 468, 392, 923, | 157570 | /* 1030 */ 56, 15, 15, 563, 406, 12, 1120, 471, 122, 123, |
| 155508 | /* 1040 */ 260, 260, 289, 1169, 1142, 1143, 1144, 189, 1171, 266, | 157571 | /* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 155509 | /* 1050 */ 266, 468, 390, 543, 1186, 546, 1170, 263, 144, 489, | 157572 | /* 1050 */ 121, 121, 121, 1460, 406, 43, 43, 483, 122, 123, |
| 155510 | /* 1060 */ 922, 546, 543, 122, 112, 1165, 1165, 1006, 1009, 999, | 157573 | /* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 155511 | /* 1070 */ 999, 119, 119, 120, 120, 120, 120, 71, 71, 1142, | 157574 | /* 1070 */ 121, 121, 121, 563, 852, 9, 471, 251, 122, 111, |
| 155512 | /* 1080 */ 1172, 1272, 1172, 13, 13, 898, 1070, 1163, 546, 468, | 157575 | /* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, |
| 155513 | /* 1090 */ 897, 107, 538, 1491, 4, 1268, 1109, 6, 525, 1049, | 157576 | /* 1090 */ 121, 121, 121, 563, 421, 57, 57, 119, 119, 119, |
| 155514 | /* 1100 */ 12, 1071, 1092, 1570, 312, 455, 1570, 520, 541, 1109, | 157577 | /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 493, |
| 155515 | /* 1110 */ 56, 56, 1109, 1489, 423, 1358, 1072, 6, 345, 285, | 157578 | /* 1110 */ 563, 289, 1197, 478, 1516, 44, 44, 119, 119, 119, |
| 155516 | /* 1120 */ 118, 118, 118, 118, 117, 117, 116, 116, 116, 115, | 157579 | /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 880, 563, |
| 155517 | /* 1130 */ 424, 425, 1271, 321, 1142, 1143, 1144, 878, 266, 266, | 157580 | /* 1130 */ 536, 563, 58, 58, 488, 1414, 245, 119, 119, 119, |
| 155518 | /* 1140 */ 1277, 107, 538, 535, 4, 1488, 293, 879, 1211, 6, | 157581 | /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 563, 535, |
| 155519 | /* 1150 */ 210, 543, 543, 164, 294, 496, 416, 204, 541, 267, | 157582 | /* 1150 */ 291, 59, 59, 60, 60, 438, 437, 406, 1154, 505, |
| 155520 | /* 1160 */ 267, 1214, 398, 511, 499, 204, 266, 266, 396, 531, | 157583 | /* 1160 */ 304, 554, 477, 1204, 1176, 1177, 1178, 881, 1206, 1197, |
| 155521 | /* 1170 */ 8, 986, 543, 519, 546, 922, 458, 105, 105, 543, | 157584 | /* 1170 */ 61, 61, 1246, 357, 1558, 1538, 1205, 563, 1467, 6, |
| 155522 | /* 1180 */ 1090, 425, 266, 266, 106, 417, 425, 548, 547, 266, | 157585 | /* 1180 */ 1176, 488, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, |
| 155523 | /* 1190 */ 266, 976, 518, 535, 1373, 543, 15, 15, 266, 266, | 157586 | /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 410, 62, |
| 155524 | /* 1200 */ 456, 1120, 543, 266, 266, 1070, 1372, 515, 290, 537, | 157587 | /* 1200 */ 62, 1207, 1099, 1207, 411, 447, 273, 273, 537, 1154, |
| 155525 | /* 1210 */ 546, 543, 514, 97, 444, 316, 543, 546, 922, 125, | 157588 | /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1220, 1100, 1512, 560, |
| 155526 | /* 1220 */ 1071, 986, 976, 976, 978, 979, 27, 105, 105, 401, | 157589 | /* 1220 */ 347, 516, 428, 548, 308, 1307, 1536, 1077, 558, 1077, |
| 155527 | /* 1230 */ 343, 1511, 44, 44, 106, 1072, 425, 548, 547, 57, | 157590 | /* 1230 */ 6, 488, 1101, 1400, 488, 309, 1176, 1177, 1178, 563, |
| 155528 | /* 1240 */ 57, 976, 343, 1511, 107, 538, 546, 4, 462, 401, | 157591 | /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 155529 | /* 1250 */ 214, 1120, 459, 297, 377, 1091, 534, 1309, 546, 539, | 157592 | /* 1250 */ 441, 442, 278, 551, 563, 273, 273, 273, 273, 563, |
| 155530 | /* 1260 */ 398, 541, 290, 537, 104, 244, 102, 526, 58, 58, | 157593 | /* 1260 */ 327, 45, 45, 552, 563, 528, 422, 563, 560, 1400, |
| 155531 | /* 1270 */ 546, 199, 976, 976, 978, 979, 27, 1516, 1131, 427, | 157594 | /* 1270 */ 560, 108, 555, 137, 4, 1303, 46, 46, 335, 563, |
| 155532 | /* 1280 */ 59, 59, 270, 237, 425, 138, 95, 375, 375, 374, | 157595 | /* 1280 */ 482, 47, 47, 477, 479, 307, 49, 49, 558, 50, |
| 155533 | /* 1290 */ 255, 372, 60, 60, 817, 1180, 535, 546, 273, 546, | 157596 | /* 1290 */ 50, 563, 1015, 563, 1221, 563, 1400, 563, 106, 106, |
| 155534 | /* 1300 */ 1163, 1308, 389, 388, 546, 438, 546, 215, 210, 296, | 157597 | /* 1300 */ 8, 63, 63, 423, 563, 107, 312, 442, 565, 564, |
| 155535 | /* 1310 */ 515, 849, 546, 265, 208, 516, 1476, 295, 274, 61, | 157598 | /* 1310 */ 563, 442, 1005, 64, 64, 65, 65, 14, 14, 66, |
| 155536 | /* 1320 */ 61, 62, 62, 308, 986, 109, 45, 45, 46, 46, | 157599 | /* 1320 */ 66, 391, 1121, 552, 1312, 1180, 128, 128, 563, 304, |
| 155537 | /* 1330 */ 105, 105, 1186, 922, 47, 47, 341, 106, 546, 425, | 157600 | /* 1330 */ 554, 563, 67, 67, 563, 359, 560, 532, 563, 484, |
| 155538 | /* 1340 */ 548, 547, 1542, 546, 976, 867, 340, 217, 546, 937, | 157601 | /* 1340 */ 563, 1196, 531, 222, 1005, 1005, 1007, 1008, 27, 522, |
| 155539 | /* 1350 */ 397, 107, 538, 218, 4, 156, 1163, 938, 158, 546, | 157602 | /* 1350 */ 52, 52, 1015, 68, 68, 563, 69, 69, 106, 106, |
| 155540 | /* 1360 */ 49, 49, 1162, 546, 268, 50, 50, 546, 541, 1450, | 157603 | /* 1360 */ 53, 53, 156, 156, 563, 107, 434, 442, 565, 564, |
| 155541 | /* 1370 */ 63, 63, 546, 1449, 216, 976, 976, 978, 979, 27, | 157604 | /* 1370 */ 272, 215, 1005, 425, 563, 359, 563, 157, 157, 563, |
| 155542 | /* 1380 */ 446, 64, 64, 546, 460, 65, 65, 546, 318, 14, | 157605 | /* 1380 */ 1535, 292, 1180, 98, 6, 1344, 76, 76, 1215, 475, |
| 155543 | /* 1390 */ 14, 425, 1305, 546, 66, 66, 1087, 546, 141, 379, | 157606 | /* 1390 */ 413, 169, 226, 563, 245, 563, 54, 54, 72, 72, |
| 155544 | /* 1400 */ 38, 546, 963, 535, 322, 127, 127, 546, 393, 67, | 157607 | /* 1400 */ 1221, 129, 129, 1343, 1005, 1005, 1007, 1008, 27, 1563, |
| 155545 | /* 1410 */ 67, 546, 325, 290, 537, 52, 52, 515, 546, 68, | 157608 | /* 1410 */ 1165, 444, 456, 433, 277, 73, 73, 130, 130, 389, |
| 155546 | /* 1420 */ 68, 845, 514, 69, 69, 399, 165, 857, 856, 53, | 157609 | /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 1519, 277, 108, |
| 155547 | /* 1430 */ 53, 986, 311, 151, 151, 97, 432, 105, 105, 327, | 157610 | /* 1430 */ 555, 321, 4, 389, 389, 388, 262, 386, 563, 223, |
| 155548 | /* 1440 */ 152, 152, 526, 1048, 106, 1048, 425, 548, 547, 1131, | 157611 | /* 1440 */ 839, 311, 468, 84, 202, 523, 558, 1492, 303, 310, |
| 155549 | /* 1450 */ 427, 976, 1032, 270, 968, 239, 329, 243, 375, 375, | 157612 | /* 1450 */ 563, 110, 404, 223, 563, 311, 206, 30, 404, 277, |
| 155550 | /* 1460 */ 374, 255, 372, 940, 941, 817, 1296, 546, 220, 546, | 157613 | /* 1460 */ 131, 131, 411, 310, 389, 389, 388, 262, 386, 442, |
| 155551 | /* 1470 */ 107, 538, 546, 4, 546, 1256, 199, 845, 215, 1036, | 157614 | /* 1470 */ 920, 839, 127, 127, 563, 919, 155, 155, 1491, 225, |
| 155552 | /* 1480 */ 296, 1530, 976, 976, 978, 979, 27, 541, 295, 76, | 157615 | /* 1480 */ 563, 552, 871, 563, 223, 476, 311, 161, 31, 563, |
| 155553 | /* 1490 */ 76, 54, 54, 980, 72, 72, 128, 128, 864, 865, | 157616 | /* 1490 */ 135, 563, 480, 225, 310, 532, 154, 154, 332, 17, |
| 155554 | /* 1500 */ 107, 538, 546, 4, 1047, 546, 1047, 533, 469, 546, | 157617 | /* 1500 */ 533, 161, 136, 136, 135, 134, 134, 224, 228, 355, |
| 155555 | /* 1510 */ 425, 546, 450, 1240, 546, 243, 546, 541, 217, 546, | 157618 | /* 1510 */ 1015, 132, 132, 133, 133, 1589, 106, 106, 889, 354, |
| 155556 | /* 1520 */ 452, 197, 535, 243, 73, 73, 156, 129, 129, 158, | 157619 | /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 1117, 275, |
| 155557 | /* 1530 */ 336, 130, 130, 126, 126, 1036, 150, 150, 149, 149, | 157620 | /* 1530 */ 1005, 393, 161, 518, 563, 135, 108, 555, 417, 4, |
| 155558 | /* 1540 */ 425, 134, 134, 317, 474, 216, 97, 239, 331, 980, | 157621 | /* 1540 */ 1340, 407, 75, 75, 77, 77, 304, 554, 867, 563, |
| 155559 | /* 1550 */ 986, 97, 535, 346, 347, 546, 105, 105, 902, 931, | 157622 | /* 1550 */ 336, 563, 224, 558, 463, 407, 74, 74, 465, 1065, |
| 155560 | /* 1560 */ 546, 895, 243, 106, 109, 425, 548, 547, 546, 1505, | 157623 | /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 962, 963, 543, |
| 155561 | /* 1570 */ 976, 828, 99, 538, 139, 4, 546, 133, 133, 393, | 157624 | /* 1570 */ 448, 42, 42, 48, 48, 326, 442, 325, 98, 997, |
| 155562 | /* 1580 */ 986, 1317, 131, 131, 290, 537, 105, 105, 1357, 541, | 157625 | /* 1580 */ 470, 287, 250, 250, 448, 1009, 407, 472, 552, 339, |
| 155563 | /* 1590 */ 132, 132, 1292, 106, 1303, 425, 548, 547, 75, 75, | 157626 | /* 1590 */ 250, 304, 554, 879, 878, 331, 108, 555, 98, 4, |
| 155564 | /* 1600 */ 976, 976, 976, 978, 979, 27, 546, 432, 896, 1289, | 157627 | /* 1600 */ 1277, 494, 532, 345, 247, 867, 98, 531, 341, 886, |
| 155565 | /* 1610 */ 532, 109, 425, 1363, 546, 1221, 1213, 1202, 258, 546, | 157628 | /* 1610 */ 887, 1126, 1076, 558, 1076, 448, 1065, 1015, 1061, 953, |
| 155566 | /* 1620 */ 349, 546, 1201, 11, 535, 1203, 1524, 351, 77, 77, | 157629 | /* 1620 */ 343, 247, 250, 106, 106, 1291, 917, 1276, 850, 110, |
| 155567 | /* 1630 */ 376, 976, 976, 978, 979, 27, 74, 74, 353, 213, | 157630 | /* 1630 */ 107, 144, 442, 565, 564, 918, 442, 1005, 110, 1275, |
| 155568 | /* 1640 */ 301, 43, 43, 48, 48, 437, 310, 201, 303, 1350, | 157631 | /* 1640 */ 350, 360, 1009, 1331, 1352, 299, 1399, 1577, 552, 1327, |
| 155569 | /* 1650 */ 315, 355, 986, 454, 479, 1239, 339, 192, 105, 105, | 157632 | /* 1650 */ 1552, 550, 1338, 549, 1405, 1256, 1248, 1237, 1236, 1238, |
| 155570 | /* 1660 */ 1422, 1421, 193, 536, 205, 106, 1527, 425, 548, 547, | 157633 | /* 1660 */ 1571, 489, 265, 200, 1324, 363, 365, 367, 11, 1005, |
| 155571 | /* 1670 */ 1180, 167, 976, 270, 247, 1469, 1467, 1177, 375, 375, | 157634 | /* 1670 */ 1005, 1007, 1008, 27, 390, 221, 1386, 1015, 280, 1391, |
| 155572 | /* 1680 */ 374, 255, 372, 200, 369, 817, 400, 83, 79, 82, | 157635 | /* 1680 */ 1381, 208, 323, 106, 106, 924, 1374, 453, 283, 324, |
| 155573 | /* 1690 */ 1427, 448, 177, 95, 1342, 161, 169, 1339, 215, 440, | 157636 | /* 1690 */ 107, 474, 442, 565, 564, 1390, 499, 1005, 212, 288, |
| 155574 | /* 1700 */ 296, 172, 173, 976, 976, 978, 979, 27, 295, 174, | 157637 | /* 1700 */ 1274, 397, 353, 108, 555, 195, 4, 1464, 369, 1463, |
| 155575 | /* 1710 */ 175, 441, 472, 223, 1347, 383, 35, 381, 36, 461, | 157638 | /* 1710 */ 1574, 1215, 1212, 329, 553, 171, 207, 383, 1511, 196, |
| 155576 | /* 1720 */ 88, 1353, 181, 447, 384, 1416, 227, 467, 259, 229, | 157639 | /* 1720 */ 558, 254, 1509, 415, 100, 555, 83, 4, 204, 1005, |
| 155577 | /* 1730 */ 186, 488, 470, 324, 1250, 230, 231, 320, 217, 1204, | 157640 | /* 1730 */ 1005, 1007, 1008, 27, 219, 79, 82, 1469, 180, 166, |
| 155578 | /* 1740 */ 1438, 1259, 386, 1258, 413, 90, 156, 849, 1541, 158, | 157641 | /* 1740 */ 173, 558, 458, 442, 175, 176, 177, 178, 35, 1387, |
| 155579 | /* 1750 */ 206, 415, 1540, 507, 1300, 1257, 94, 348, 1229, 1301, | 157642 | /* 1750 */ 492, 459, 231, 1395, 96, 552, 1393, 1392, 395, 184, |
| 155580 | /* 1760 */ 387, 1510, 1228, 338, 1227, 216, 350, 1539, 498, 283, | 157643 | /* 1760 */ 481, 466, 36, 235, 442, 89, 398, 266, 487, 1480, |
| 155581 | /* 1770 */ 284, 1249, 501, 1299, 352, 245, 246, 418, 1298, 354, | 157644 | /* 1770 */ 1458, 237, 188, 338, 508, 429, 552, 490, 400, 238, |
| 155582 | /* 1780 */ 1496, 1495, 124, 10, 526, 363, 101, 1324, 253, 96, | 157645 | /* 1780 */ 334, 1239, 239, 1294, 1015, 1293, 1292, 1285, 91, 871, |
| 155583 | /* 1790 */ 510, 1210, 34, 549, 1137, 254, 256, 257, 166, 393, | 157646 | /* 1790 */ 106, 106, 213, 431, 1588, 432, 524, 107, 517, 442, |
| 155584 | /* 1800 */ 550, 1199, 1282, 361, 290, 537, 1281, 196, 367, 368, | 157647 | /* 1800 */ 565, 564, 401, 1264, 1005, 1015, 1263, 1587, 352, 1262, |
| 155585 | /* 1810 */ 1194, 153, 1454, 137, 281, 1323, 1455, 804, 154, 426, | 157648 | /* 1810 */ 1557, 106, 106, 1586, 1284, 297, 298, 358, 107, 1335, |
| 155586 | /* 1820 */ 198, 155, 1453, 1452, 292, 212, 202, 432, 1402, 203, | 157649 | /* 1820 */ 442, 565, 564, 95, 362, 1005, 253, 252, 435, 125, |
| 155587 | /* 1830 */ 271, 135, 288, 78, 1046, 1044, 960, 168, 157, 881, | 157650 | /* 1830 */ 543, 10, 1444, 1543, 377, 1542, 1005, 1005, 1007, 1008, |
| 155588 | /* 1840 */ 170, 219, 309, 222, 1060, 176, 964, 159, 402, 84, | 157651 | /* 1840 */ 27, 302, 102, 97, 527, 1336, 260, 1317, 364, 1245, |
| 155589 | /* 1850 */ 178, 404, 85, 86, 87, 160, 1063, 224, 394, 395, | 157652 | /* 1850 */ 1334, 34, 566, 1171, 366, 381, 375, 1005, 1005, 1007, |
| 155590 | /* 1860 */ 225, 1059, 146, 18, 226, 319, 243, 1174, 466, 228, | 157653 | /* 1860 */ 1008, 27, 1333, 1359, 368, 1316, 199, 382, 261, 263, |
| 155591 | /* 1870 */ 1052, 182, 183, 37, 819, 471, 340, 232, 332, 483, | 157654 | /* 1870 */ 264, 1358, 158, 1496, 141, 1497, 1495, 567, 1234, 1229, |
| 155592 | /* 1880 */ 184, 89, 162, 19, 20, 475, 91, 480, 847, 335, | 157655 | /* 1880 */ 1494, 295, 159, 209, 210, 78, 826, 443, 201, 306, |
| 155593 | /* 1890 */ 147, 860, 282, 92, 490, 93, 1125, 148, 1012, 1095, | 157656 | /* 1890 */ 220, 1075, 138, 1073, 160, 314, 162, 172, 1196, 174, |
| 155594 | /* 1900 */ 39, 497, 1096, 40, 500, 262, 207, 264, 930, 187, | 157657 | /* 1900 */ 903, 227, 230, 322, 1089, 179, 163, 164, 418, 85, |
| 155595 | /* 1910 */ 925, 109, 1111, 1115, 1113, 7, 1099, 242, 33, 1119, | 157658 | /* 1910 */ 420, 181, 170, 408, 409, 86, 87, 165, 88, 1092, |
| 155596 | /* 1920 */ 21, 522, 22, 23, 24, 1118, 25, 190, 97, 26, | 157659 | /* 1920 */ 232, 233, 1088, 151, 18, 234, 1081, 250, 333, 185, |
| 155597 | /* 1930 */ 1027, 1013, 1011, 1015, 1069, 1016, 1068, 249, 248, 28, | 157660 | /* 1930 */ 1209, 486, 236, 186, 37, 841, 491, 354, 240, 346, |
| 155598 | /* 1940 */ 41, 891, 981, 829, 108, 29, 250, 542, 251, 370, | 157661 | /* 1940 */ 503, 187, 90, 167, 19, 495, 20, 869, 500, 349, |
| 155599 | /* 1950 */ 373, 1133, 1132, 1190, 1190, 1190, 1190, 1190, 1190, 1190, | 157662 | /* 1950 */ 92, 882, 296, 152, 93, 510, 1127, 1159, 153, 1041, |
| 155600 | /* 1960 */ 1532, 1531, | 157663 | /* 1960 */ 214, 1128, 39, 94, 269, 271, 952, 190, 947, 110, |
| 157664 | /* 1970 */ 1149, 1145, 1153, 249, 1133, 1147, 7, 33, 21, 193, | ||
| 157665 | /* 1980 */ 22, 23, 24, 25, 1152, 539, 98, 1056, 26, 1042, | ||
| 157666 | /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 387, | ||
| 157667 | /* 2000 */ 1010, 851, 109, 29, 1167, 559, 384, 257, 913, 258, | ||
| 157668 | /* 2010 */ 1166, 1579, 1225, 1225, 1225, 1225, 1225, 1225, 1225, 1578, | ||
| 155601 | }; | 157669 | }; |
| 155602 | static const YYCODETYPE yy_lookahead[] = { | 157670 | static const YYCODETYPE yy_lookahead[] = { |
| 155603 | /* 0 */ 189, 211, 189, 189, 218, 189, 220, 189, 267, 268, | 157671 | /* 0 */ 191, 220, 191, 222, 191, 191, 271, 272, 273, 216, |
| 155604 | /* 10 */ 269, 189, 210, 189, 228, 189, 267, 268, 269, 19, | 157672 | /* 10 */ 191, 230, 216, 191, 191, 191, 271, 272, 273, 19, |
| 155605 | /* 20 */ 218, 189, 211, 212, 211, 212, 211, 211, 212, 211, | 157673 | /* 20 */ 232, 233, 213, 214, 213, 214, 202, 292, 202, 232, |
| 155606 | /* 30 */ 212, 31, 211, 211, 212, 211, 212, 288, 300, 39, | 157674 | /* 30 */ 233, 31, 213, 214, 213, 213, 214, 213, 214, 39, |
| 155607 | /* 40 */ 21, 189, 304, 43, 44, 45, 46, 47, 48, 49, | 157675 | /* 40 */ 207, 208, 209, 43, 44, 45, 46, 47, 48, 49, |
| 155608 | /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 225, 19, | 157676 | /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 235, 19, |
| 155609 | /* 60 */ 189, 183, 184, 185, 186, 189, 248, 263, 236, 191, | 157677 | /* 60 */ 236, 237, 236, 237, 271, 272, 273, 271, 272, 273, |
| 155610 | /* 70 */ 248, 193, 248, 197, 208, 257, 262, 201, 200, 257, | 157678 | /* 70 */ 191, 210, 250, 249, 250, 249, 213, 191, 199, 253, |
| 155611 | /* 80 */ 200, 257, 81, 43, 44, 45, 46, 47, 48, 49, | 157679 | /* 80 */ 254, 259, 203, 43, 44, 45, 46, 47, 48, 49, |
| 155612 | /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 80, | 157680 | /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 213, |
| 155613 | /* 100 */ 189, 101, 102, 103, 104, 105, 106, 107, 108, 109, | 157681 | /* 100 */ 214, 213, 102, 103, 104, 105, 106, 107, 108, 109, |
| 155614 | /* 110 */ 110, 111, 234, 235, 234, 235, 305, 306, 305, 118, | 157682 | /* 110 */ 110, 111, 112, 59, 228, 301, 293, 81, 305, 306, |
| 155615 | /* 120 */ 307, 305, 306, 297, 298, 247, 86, 247, 88, 19, | 157683 | /* 120 */ 311, 312, 311, 310, 313, 59, 86, 212, 88, 19, |
| 155616 | /* 130 */ 259, 251, 252, 267, 268, 269, 26, 136, 137, 261, | 157684 | /* 130 */ 311, 312, 271, 272, 273, 220, 26, 112, 54, 55, |
| 155617 | /* 140 */ 121, 101, 102, 103, 104, 105, 106, 107, 108, 109, | 157685 | /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109, |
| 155618 | /* 150 */ 110, 111, 59, 43, 44, 45, 46, 47, 48, 49, | 157686 | /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 155619 | /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 259, 291, | 157687 | /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 191, 115, |
| 155620 | /* 170 */ 105, 106, 107, 108, 109, 110, 111, 158, 189, 69, | 157688 | /* 170 */ 116, 117, 118, 137, 138, 121, 122, 123, 191, 69, |
| 155621 | /* 180 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 157689 | /* 180 */ 203, 115, 116, 117, 59, 131, 102, 103, 104, 105, |
| 155622 | /* 190 */ 111, 107, 108, 109, 110, 111, 205, 206, 207, 19, | 157690 | /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 191, 19, |
| 155623 | /* 200 */ 19, 54, 55, 56, 57, 58, 29, 114, 115, 116, | 157691 | /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112, |
| 155624 | /* 210 */ 33, 101, 102, 103, 104, 105, 106, 107, 108, 109, | 157692 | /* 210 */ 303, 304, 102, 103, 104, 105, 106, 107, 108, 109, |
| 155625 | /* 220 */ 110, 111, 233, 43, 44, 45, 46, 47, 48, 49, | 157693 | /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 155626 | /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 126, | 157694 | /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 16, |
| 155627 | /* 240 */ 127, 148, 65, 24, 214, 200, 59, 67, 101, 102, | 157695 | /* 240 */ 115, 116, 117, 24, 16, 227, 202, 67, 102, 103, |
| 155628 | /* 250 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 22, | 157696 | /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 59, |
| 155629 | /* 260 */ 189, 111, 43, 44, 45, 46, 47, 48, 49, 50, | 157697 | /* 260 */ 26, 191, 43, 44, 45, 46, 47, 48, 49, 50, |
| 155630 | /* 270 */ 51, 52, 53, 54, 55, 56, 57, 206, 207, 234, | 157698 | /* 270 */ 51, 52, 53, 54, 55, 56, 57, 24, 208, 209, |
| 155631 | /* 280 */ 235, 101, 102, 103, 104, 105, 106, 107, 108, 109, | 157699 | /* 280 */ 236, 237, 102, 103, 104, 105, 106, 107, 108, 109, |
| 155632 | /* 290 */ 110, 111, 247, 76, 107, 114, 59, 267, 268, 269, | 157700 | /* 290 */ 110, 111, 112, 249, 183, 184, 185, 186, 187, 188, |
| 155633 | /* 300 */ 189, 114, 115, 116, 162, 163, 89, 19, 263, 92, | 157701 | /* 300 */ 77, 59, 79, 191, 193, 77, 195, 79, 19, 19, |
| 155634 | /* 310 */ 189, 23, 54, 55, 56, 57, 189, 206, 207, 22, | 157702 | /* 310 */ 266, 304, 59, 202, 24, 115, 116, 117, 191, 127, |
| 155635 | /* 320 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 157703 | /* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 155636 | /* 330 */ 111, 43, 44, 45, 46, 47, 48, 49, 50, 51, | 157704 | /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 155637 | /* 340 */ 52, 53, 54, 55, 56, 57, 19, 189, 277, 59, | 157705 | /* 340 */ 51, 52, 53, 54, 55, 56, 57, 236, 237, 191, |
| 155638 | /* 350 */ 23, 114, 115, 116, 46, 47, 48, 49, 61, 101, | 157706 | /* 350 */ 150, 281, 191, 185, 186, 187, 188, 115, 116, 117, |
| 155639 | /* 360 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 157707 | /* 360 */ 249, 193, 191, 195, 26, 73, 59, 191, 114, 116, |
| 155640 | /* 370 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 157708 | /* 370 */ 202, 213, 214, 81, 263, 106, 107, 108, 109, 110, |
| 155641 | /* 380 */ 53, 54, 55, 56, 57, 125, 126, 127, 277, 101, | 157709 | /* 380 */ 111, 112, 148, 160, 142, 95, 228, 191, 191, 213, |
| 155642 | /* 390 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 157710 | /* 390 */ 214, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 155643 | /* 400 */ 59, 189, 189, 276, 114, 115, 116, 117, 73, 59, | 157711 | /* 400 */ 111, 112, 112, 149, 236, 237, 295, 100, 118, 119, |
| 155644 | /* 410 */ 120, 121, 122, 72, 214, 19, 81, 259, 19, 23, | 157712 | /* 410 */ 120, 121, 122, 123, 124, 19, 31, 249, 126, 23, |
| 155645 | /* 420 */ 130, 81, 72, 24, 211, 212, 221, 119, 101, 102, | 157713 | /* 420 */ 130, 260, 115, 116, 39, 22, 250, 120, 191, 137, |
| 155646 | /* 430 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 43, | 157714 | /* 430 */ 138, 263, 305, 306, 238, 259, 265, 310, 149, 43, |
| 155647 | /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 157715 | /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 155648 | /* 450 */ 54, 55, 56, 57, 19, 114, 115, 116, 23, 208, | 157716 | /* 450 */ 54, 55, 56, 57, 191, 117, 191, 210, 19, 152, |
| 155649 | /* 460 */ 125, 248, 189, 189, 114, 115, 116, 267, 268, 269, | 157717 | /* 460 */ 153, 154, 23, 295, 102, 103, 104, 105, 106, 107, |
| 155650 | /* 470 */ 189, 136, 137, 189, 262, 22, 136, 137, 43, 44, | 157718 | /* 470 */ 108, 109, 110, 111, 112, 266, 213, 214, 213, 214, |
| 155651 | /* 480 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | 157719 | /* 480 */ 142, 81, 43, 44, 45, 46, 47, 48, 49, 50, |
| 155652 | /* 490 */ 55, 56, 57, 189, 95, 211, 212, 101, 102, 103, | 157720 | /* 490 */ 51, 52, 53, 54, 55, 56, 57, 301, 102, 103, |
| 155653 | /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 59, 189, | 157721 | /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 106, |
| 155654 | /* 510 */ 111, 189, 59, 76, 294, 295, 117, 118, 119, 120, | 157722 | /* 510 */ 107, 118, 59, 250, 121, 122, 123, 280, 76, 119, |
| 155655 | /* 520 */ 121, 122, 123, 19, 87, 189, 89, 23, 129, 92, | 157723 | /* 520 */ 236, 237, 259, 306, 131, 72, 59, 310, 19, 87, |
| 155656 | /* 530 */ 279, 227, 248, 22, 189, 284, 101, 102, 103, 104, | 157724 | /* 530 */ 283, 89, 23, 249, 92, 288, 22, 137, 138, 22, |
| 155657 | /* 540 */ 105, 106, 107, 108, 109, 110, 111, 43, 44, 45, | 157725 | /* 540 */ 275, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 155658 | /* 550 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, | 157726 | /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 155659 | /* 560 */ 56, 57, 19, 114, 115, 116, 23, 114, 115, 116, | 157727 | /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 115, 116, |
| 155660 | /* 570 */ 59, 117, 299, 300, 120, 121, 122, 304, 189, 189, | 157728 | /* 570 */ 117, 23, 186, 59, 188, 108, 59, 241, 191, 193, |
| 155661 | /* 580 */ 143, 189, 110, 111, 130, 22, 43, 44, 45, 46, | 157729 | /* 580 */ 26, 195, 115, 116, 117, 191, 144, 251, 202, 22, |
| 155662 | /* 590 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 157730 | /* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 155663 | /* 600 */ 57, 211, 212, 211, 212, 101, 102, 103, 104, 105, | 157731 | /* 600 */ 52, 53, 54, 55, 56, 57, 116, 213, 214, 191, |
| 155664 | /* 610 */ 106, 107, 108, 109, 110, 111, 226, 189, 226, 189, | 157732 | /* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 155665 | /* 620 */ 298, 132, 59, 134, 135, 114, 115, 116, 189, 59, | 157733 | /* 620 */ 111, 112, 236, 237, 306, 238, 59, 26, 310, 115, |
| 155666 | /* 630 */ 285, 19, 7, 8, 9, 23, 205, 206, 207, 211, | 157734 | /* 630 */ 116, 117, 115, 116, 117, 249, 246, 19, 248, 106, |
| 155667 | /* 640 */ 212, 211, 212, 221, 101, 102, 103, 104, 105, 106, | 157735 | /* 640 */ 107, 23, 152, 153, 154, 46, 47, 48, 49, 263, |
| 155668 | /* 650 */ 107, 108, 109, 110, 111, 43, 44, 45, 46, 47, | 157736 | /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 155669 | /* 660 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, | 157737 | /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 155670 | /* 670 */ 19, 181, 182, 183, 184, 185, 186, 114, 115, 116, | 157738 | /* 670 */ 52, 53, 54, 55, 56, 57, 19, 76, 298, 299, |
| 155671 | /* 680 */ 189, 191, 133, 193, 114, 115, 116, 138, 299, 300, | 157739 | /* 680 */ 23, 295, 115, 116, 117, 152, 191, 154, 301, 73, |
| 155672 | /* 690 */ 200, 22, 201, 304, 43, 44, 45, 46, 47, 48, | 157740 | /* 690 */ 89, 137, 138, 92, 22, 191, 144, 22, 191, 191, |
| 155673 | /* 700 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 35, | 157741 | /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 155674 | /* 710 */ 189, 141, 189, 101, 102, 103, 104, 105, 106, 107, | 157742 | /* 710 */ 53, 54, 55, 56, 57, 163, 191, 213, 214, 120, |
| 155675 | /* 720 */ 108, 109, 110, 111, 234, 235, 22, 23, 59, 184, | 157743 | /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 155676 | /* 730 */ 26, 186, 211, 212, 211, 212, 191, 247, 193, 19, | 157744 | /* 730 */ 112, 59, 228, 191, 59, 191, 236, 237, 213, 214, |
| 155677 | /* 740 */ 66, 105, 106, 73, 189, 200, 189, 226, 74, 226, | 157745 | /* 740 */ 11, 59, 126, 127, 128, 238, 19, 26, 191, 249, |
| 155678 | /* 750 */ 22, 261, 101, 102, 103, 104, 105, 106, 107, 108, | 157746 | /* 750 */ 23, 164, 165, 228, 191, 213, 214, 213, 214, 102, |
| 155679 | /* 760 */ 109, 110, 111, 43, 44, 45, 46, 47, 48, 49, | 157747 | /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 155680 | /* 770 */ 50, 51, 52, 53, 54, 55, 56, 57, 189, 234, | 157748 | /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 155681 | /* 780 */ 235, 291, 19, 114, 115, 116, 150, 59, 152, 189, | 157749 | /* 780 */ 53, 54, 55, 56, 57, 19, 241, 115, 116, 117, |
| 155682 | /* 790 */ 233, 236, 247, 59, 189, 125, 126, 127, 59, 300, | 157750 | /* 790 */ 115, 116, 117, 191, 250, 238, 251, 115, 116, 117, |
| 155683 | /* 800 */ 211, 212, 128, 304, 100, 19, 261, 156, 45, 46, | 157751 | /* 800 */ 157, 23, 159, 191, 26, 191, 111, 112, 301, 43, |
| 155684 | /* 810 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | 157752 | /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 155685 | /* 820 */ 57, 101, 102, 103, 104, 105, 106, 107, 108, 109, | 157753 | /* 820 */ 54, 55, 56, 57, 142, 213, 214, 213, 214, 102, |
| 155686 | /* 830 */ 110, 111, 46, 233, 189, 189, 291, 248, 99, 189, | 157754 | /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 155687 | /* 840 */ 125, 126, 127, 115, 26, 200, 289, 230, 231, 115, | 157755 | /* 840 */ 228, 191, 228, 191, 191, 207, 208, 209, 126, 127, |
| 155688 | /* 850 */ 200, 16, 189, 114, 115, 189, 211, 212, 119, 221, | 157756 | /* 850 */ 128, 133, 289, 135, 136, 19, 127, 128, 301, 7, |
| 155689 | /* 860 */ 189, 211, 212, 258, 101, 102, 103, 104, 105, 106, | 157757 | /* 860 */ 8, 9, 141, 213, 214, 213, 214, 265, 102, 103, |
| 155690 | /* 870 */ 107, 108, 109, 110, 111, 189, 156, 211, 212, 234, | 157758 | /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43, |
| 155691 | /* 880 */ 235, 189, 211, 212, 234, 235, 22, 201, 189, 150, | 157759 | /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 155692 | /* 890 */ 151, 152, 247, 248, 76, 16, 19, 247, 248, 113, | 157760 | /* 890 */ 54, 55, 56, 57, 191, 117, 191, 22, 23, 19, |
| 155693 | /* 900 */ 189, 24, 257, 211, 212, 189, 26, 89, 262, 223, | 157761 | /* 900 */ 250, 26, 250, 191, 223, 191, 126, 127, 128, 205, |
| 155694 | /* 910 */ 92, 225, 77, 189, 79, 129, 19, 53, 226, 248, | 157762 | /* 910 */ 206, 205, 206, 260, 21, 202, 213, 214, 213, 214, |
| 155695 | /* 920 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 157763 | /* 920 */ 142, 270, 208, 209, 158, 45, 46, 47, 48, 49, |
| 155696 | /* 930 */ 53, 54, 55, 56, 57, 236, 19, 271, 189, 99, | 157764 | /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103, |
| 155697 | /* 940 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 157765 | /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 236, |
| 155698 | /* 950 */ 53, 54, 55, 56, 57, 115, 77, 59, 79, 119, | 157766 | /* 950 */ 237, 12, 191, 250, 76, 250, 191, 22, 23, 308, |
| 155699 | /* 960 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 157767 | /* 960 */ 309, 26, 249, 202, 191, 191, 27, 89, 191, 202, |
| 155700 | /* 970 */ 53, 54, 55, 56, 57, 259, 22, 23, 101, 102, | 157768 | /* 970 */ 92, 202, 260, 80, 213, 214, 101, 203, 213, 214, |
| 155701 | /* 980 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 59, | 157769 | /* 980 */ 22, 42, 102, 103, 104, 105, 106, 107, 108, 109, |
| 155702 | /* 990 */ 150, 151, 152, 158, 22, 244, 24, 246, 101, 102, | 157770 | /* 990 */ 110, 111, 112, 228, 158, 281, 108, 236, 237, 225, |
| 155703 | /* 1000 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 285, | 157771 | /* 1000 */ 191, 227, 63, 236, 237, 236, 237, 191, 235, 191, |
| 155704 | /* 1010 */ 189, 189, 114, 115, 116, 200, 136, 137, 101, 102, | 157772 | /* 1010 */ 249, 250, 73, 241, 19, 122, 249, 59, 249, 24, |
| 155705 | /* 1020 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 230, | 157773 | /* 1020 */ 259, 29, 134, 251, 191, 33, 22, 139, 24, 213, |
| 155706 | /* 1030 */ 231, 59, 211, 212, 285, 105, 106, 189, 19, 141, | 157774 | /* 1030 */ 214, 213, 214, 191, 19, 210, 101, 191, 43, 44, |
| 155707 | /* 1040 */ 234, 235, 239, 113, 114, 115, 116, 226, 118, 234, | 157775 | /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 155708 | /* 1050 */ 235, 189, 249, 247, 100, 189, 126, 23, 236, 107, | 157776 | /* 1050 */ 55, 56, 57, 160, 19, 213, 214, 65, 43, 44, |
| 155709 | /* 1060 */ 26, 189, 247, 44, 45, 46, 47, 48, 49, 50, | 157777 | /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 155710 | /* 1070 */ 51, 52, 53, 54, 55, 56, 57, 211, 212, 59, | 157778 | /* 1070 */ 55, 56, 57, 191, 116, 22, 191, 24, 43, 44, |
| 155711 | /* 1080 */ 150, 233, 152, 211, 212, 133, 12, 115, 189, 189, | 157779 | /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 155712 | /* 1090 */ 138, 19, 20, 300, 22, 233, 76, 304, 226, 11, | 157780 | /* 1090 */ 55, 56, 57, 191, 261, 213, 214, 102, 103, 104, |
| 155713 | /* 1100 */ 208, 27, 22, 23, 200, 19, 26, 87, 36, 89, | 157781 | /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 19, |
| 155714 | /* 1110 */ 211, 212, 92, 300, 248, 189, 42, 304, 189, 250, | 157782 | /* 1110 */ 191, 265, 59, 288, 191, 213, 214, 102, 103, 104, |
| 155715 | /* 1120 */ 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 157783 | /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 35, 191, |
| 155716 | /* 1130 */ 111, 59, 200, 233, 114, 115, 116, 63, 234, 235, | 157784 | /* 1130 */ 66, 191, 213, 214, 191, 270, 46, 102, 103, 104, |
| 155717 | /* 1140 */ 235, 19, 20, 71, 22, 300, 189, 73, 200, 304, | 157785 | /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 191, 85, |
| 155718 | /* 1150 */ 116, 247, 247, 81, 189, 200, 227, 26, 36, 234, | 157786 | /* 1150 */ 265, 213, 214, 213, 214, 106, 107, 19, 94, 66, |
| 155719 | /* 1160 */ 235, 203, 204, 143, 200, 26, 234, 235, 194, 200, | 157787 | /* 1160 */ 137, 138, 191, 114, 115, 116, 117, 74, 119, 116, |
| 155720 | /* 1170 */ 48, 99, 247, 66, 189, 141, 284, 105, 106, 247, | 157788 | /* 1170 */ 213, 214, 202, 308, 309, 306, 127, 191, 235, 310, |
| 155721 | /* 1180 */ 100, 59, 234, 235, 112, 259, 114, 115, 116, 234, | 157789 | /* 1180 */ 59, 191, 44, 45, 46, 47, 48, 49, 50, 51, |
| 155722 | /* 1190 */ 235, 119, 85, 71, 266, 247, 211, 212, 234, 235, | 157790 | /* 1190 */ 52, 53, 54, 55, 56, 57, 191, 76, 196, 213, |
| 155723 | /* 1200 */ 114, 94, 247, 234, 235, 12, 266, 85, 136, 137, | 157791 | /* 1200 */ 214, 152, 12, 154, 114, 191, 236, 237, 87, 145, |
| 155724 | /* 1210 */ 189, 247, 90, 26, 126, 127, 247, 189, 26, 22, | 157792 | /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 27, 191, 249, |
| 155725 | /* 1220 */ 27, 99, 150, 151, 152, 153, 154, 105, 106, 189, | 157793 | /* 1220 */ 130, 202, 129, 202, 191, 235, 306, 152, 36, 154, |
| 155726 | /* 1230 */ 302, 303, 211, 212, 112, 42, 114, 115, 116, 211, | 157794 | /* 1230 */ 310, 191, 42, 191, 191, 191, 115, 116, 117, 191, |
| 155727 | /* 1240 */ 212, 119, 302, 303, 19, 20, 189, 22, 274, 189, | 157795 | /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 155728 | /* 1250 */ 15, 144, 278, 189, 22, 23, 63, 189, 189, 203, | 157796 | /* 1250 */ 112, 59, 99, 63, 191, 236, 237, 236, 237, 191, |
| 155729 | /* 1260 */ 204, 36, 136, 137, 155, 24, 157, 143, 211, 212, | 157797 | /* 1260 */ 289, 213, 214, 71, 191, 144, 261, 191, 249, 191, |
| 155730 | /* 1270 */ 189, 140, 150, 151, 152, 153, 154, 0, 1, 2, | 157798 | /* 1270 */ 249, 19, 20, 81, 22, 235, 213, 214, 235, 191, |
| 155731 | /* 1280 */ 211, 212, 5, 46, 59, 161, 147, 10, 11, 12, | 157799 | /* 1280 */ 278, 213, 214, 191, 282, 132, 213, 214, 36, 213, |
| 155732 | /* 1290 */ 13, 14, 211, 212, 17, 60, 71, 189, 258, 189, | 157800 | /* 1290 */ 214, 191, 100, 191, 101, 191, 191, 191, 106, 107, |
| 155733 | /* 1300 */ 59, 189, 105, 106, 189, 189, 189, 30, 116, 32, | 157801 | /* 1300 */ 48, 213, 214, 261, 191, 113, 191, 115, 116, 117, |
| 155734 | /* 1310 */ 85, 124, 189, 251, 252, 90, 189, 40, 258, 211, | 157802 | /* 1310 */ 191, 59, 120, 213, 214, 213, 214, 213, 214, 213, |
| 155735 | /* 1320 */ 212, 211, 212, 189, 99, 26, 211, 212, 211, 212, | 157803 | /* 1320 */ 214, 22, 23, 71, 237, 59, 213, 214, 191, 137, |
| 155736 | /* 1330 */ 105, 106, 100, 141, 211, 212, 119, 112, 189, 114, | 157804 | /* 1330 */ 138, 191, 213, 214, 191, 191, 249, 85, 191, 261, |
| 155737 | /* 1340 */ 115, 116, 23, 189, 119, 26, 129, 70, 189, 31, | 157805 | /* 1340 */ 191, 26, 90, 15, 152, 153, 154, 155, 156, 19, |
| 155738 | /* 1350 */ 113, 19, 20, 24, 22, 78, 115, 39, 81, 189, | 157806 | /* 1350 */ 213, 214, 100, 213, 214, 191, 213, 214, 106, 107, |
| 155739 | /* 1360 */ 211, 212, 26, 189, 22, 211, 212, 189, 36, 189, | 157807 | /* 1360 */ 213, 214, 213, 214, 191, 113, 261, 115, 116, 117, |
| 155740 | /* 1370 */ 211, 212, 189, 189, 97, 150, 151, 152, 153, 154, | 157808 | /* 1370 */ 253, 254, 120, 229, 191, 191, 191, 213, 214, 191, |
| 155741 | /* 1380 */ 127, 211, 212, 189, 189, 211, 212, 189, 189, 211, | 157809 | /* 1380 */ 306, 289, 116, 26, 310, 191, 213, 214, 60, 19, |
| 155742 | /* 1390 */ 212, 59, 189, 189, 211, 212, 23, 189, 22, 26, | 157810 | /* 1390 */ 296, 297, 24, 191, 46, 191, 213, 214, 213, 214, |
| 155743 | /* 1400 */ 24, 189, 149, 71, 189, 211, 212, 189, 131, 211, | 157811 | /* 1400 */ 101, 213, 214, 191, 152, 153, 154, 155, 156, 0, |
| 155744 | /* 1410 */ 212, 189, 189, 136, 137, 211, 212, 85, 189, 211, | 157812 | /* 1410 */ 1, 2, 191, 229, 5, 213, 214, 213, 214, 10, |
| 155745 | /* 1420 */ 212, 59, 90, 211, 212, 292, 293, 118, 119, 211, | 157813 | /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 191, 5, 19, |
| 155746 | /* 1430 */ 212, 99, 23, 211, 212, 26, 159, 105, 106, 189, | 157814 | /* 1430 */ 20, 191, 22, 10, 11, 12, 13, 14, 191, 30, |
| 155747 | /* 1440 */ 211, 212, 143, 150, 112, 152, 114, 115, 116, 1, | 157815 | /* 1440 */ 17, 32, 241, 148, 149, 115, 36, 191, 241, 40, |
| 155748 | /* 1450 */ 2, 119, 23, 5, 23, 26, 189, 26, 10, 11, | 157816 | /* 1450 */ 191, 26, 251, 30, 191, 32, 141, 22, 251, 5, |
| 155749 | /* 1460 */ 12, 13, 14, 83, 84, 17, 253, 189, 139, 189, | 157817 | /* 1460 */ 213, 214, 114, 40, 10, 11, 12, 13, 14, 59, |
| 155750 | /* 1470 */ 19, 20, 189, 22, 189, 189, 140, 115, 30, 59, | 157818 | /* 1470 */ 134, 17, 213, 214, 191, 139, 213, 214, 191, 70, |
| 155751 | /* 1480 */ 32, 139, 150, 151, 152, 153, 154, 36, 40, 211, | 157819 | /* 1480 */ 191, 71, 125, 191, 30, 115, 32, 78, 53, 191, |
| 155752 | /* 1490 */ 212, 211, 212, 59, 211, 212, 211, 212, 7, 8, | 157820 | /* 1490 */ 81, 191, 191, 70, 40, 85, 213, 214, 191, 22, |
| 155753 | /* 1500 */ 19, 20, 189, 22, 150, 189, 152, 231, 281, 189, | 157821 | /* 1500 */ 90, 78, 213, 214, 81, 213, 214, 98, 140, 120, |
| 155754 | /* 1510 */ 59, 189, 23, 189, 189, 26, 189, 36, 70, 189, | 157822 | /* 1510 */ 100, 213, 214, 213, 214, 23, 106, 107, 26, 130, |
| 155755 | /* 1520 */ 23, 237, 71, 26, 211, 212, 78, 211, 212, 81, | 157823 | /* 1520 */ 191, 98, 191, 113, 70, 115, 116, 117, 23, 22, |
| 155756 | /* 1530 */ 189, 211, 212, 211, 212, 115, 211, 212, 211, 212, | 157824 | /* 1530 */ 120, 26, 78, 19, 191, 81, 19, 20, 61, 22, |
| 155757 | /* 1540 */ 59, 211, 212, 23, 23, 97, 26, 26, 23, 115, | 157825 | /* 1540 */ 191, 132, 213, 214, 213, 214, 137, 138, 59, 191, |
| 155758 | /* 1550 */ 99, 26, 71, 189, 189, 189, 105, 106, 107, 23, | 157826 | /* 1550 */ 191, 191, 98, 36, 128, 132, 213, 214, 128, 59, |
| 155759 | /* 1560 */ 189, 23, 26, 112, 26, 114, 115, 116, 189, 309, | 157827 | /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 83, 84, 144, |
| 155760 | /* 1570 */ 119, 23, 19, 20, 26, 22, 189, 211, 212, 131, | 157828 | /* 1570 */ 161, 213, 214, 213, 214, 23, 59, 151, 26, 23, |
| 155761 | /* 1580 */ 99, 189, 211, 212, 136, 137, 105, 106, 189, 36, | 157829 | /* 1580 */ 23, 151, 26, 26, 161, 59, 132, 23, 71, 191, |
| 155762 | /* 1590 */ 211, 212, 189, 112, 189, 114, 115, 116, 211, 212, | 157830 | /* 1590 */ 26, 137, 138, 119, 120, 23, 19, 20, 26, 22, |
| 155763 | /* 1600 */ 119, 150, 151, 152, 153, 154, 189, 159, 23, 250, | 157831 | /* 1600 */ 223, 23, 85, 23, 26, 116, 26, 90, 191, 7, |
| 155764 | /* 1610 */ 189, 26, 59, 189, 189, 189, 189, 189, 280, 189, | 157832 | /* 1610 */ 8, 97, 152, 36, 154, 161, 116, 100, 23, 23, |
| 155765 | /* 1620 */ 250, 189, 189, 238, 71, 189, 189, 250, 211, 212, | 157833 | /* 1620 */ 191, 26, 26, 106, 107, 191, 23, 223, 23, 26, |
| 155766 | /* 1630 */ 187, 150, 151, 152, 153, 154, 211, 212, 250, 290, | 157834 | /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 191, |
| 155767 | /* 1640 */ 240, 211, 212, 211, 212, 254, 286, 209, 254, 241, | 157835 | /* 1640 */ 191, 191, 116, 255, 191, 252, 191, 140, 71, 191, |
| 155768 | /* 1650 */ 240, 254, 99, 286, 215, 220, 214, 244, 105, 106, | 157836 | /* 1650 */ 315, 233, 191, 191, 191, 191, 191, 191, 191, 191, |
| 155769 | /* 1660 */ 214, 214, 244, 273, 224, 112, 192, 114, 115, 116, | 157837 | /* 1660 */ 191, 285, 284, 239, 252, 252, 252, 252, 240, 152, |
| 155770 | /* 1670 */ 60, 290, 119, 5, 139, 196, 196, 38, 10, 11, | 157838 | /* 1670 */ 153, 154, 155, 156, 189, 294, 268, 100, 242, 268, |
| 155771 | /* 1680 */ 12, 13, 14, 238, 240, 17, 196, 148, 287, 287, | 157839 | /* 1680 */ 264, 211, 290, 106, 107, 108, 264, 256, 256, 243, |
| 155772 | /* 1690 */ 276, 113, 22, 147, 241, 43, 229, 241, 30, 18, | 157840 | /* 1690 */ 113, 290, 115, 116, 117, 268, 217, 120, 226, 243, |
| 155773 | /* 1700 */ 32, 232, 232, 150, 151, 152, 153, 154, 40, 232, | 157841 | /* 1700 */ 222, 268, 216, 19, 20, 246, 22, 216, 256, 216, |
| 155774 | /* 1710 */ 232, 196, 18, 195, 265, 265, 264, 241, 264, 196, | 157842 | /* 1710 */ 194, 60, 38, 242, 277, 294, 240, 242, 198, 246, |
| 155775 | /* 1720 */ 155, 229, 229, 241, 241, 241, 195, 62, 196, 195, | 157843 | /* 1720 */ 36, 140, 198, 198, 19, 20, 150, 22, 149, 152, |
| 155776 | /* 1730 */ 22, 113, 216, 196, 222, 195, 195, 282, 70, 196, | 157844 | /* 1730 */ 153, 154, 155, 156, 294, 291, 291, 280, 22, 43, |
| 155777 | /* 1740 */ 283, 213, 216, 213, 64, 22, 78, 124, 219, 81, | 157845 | /* 1740 */ 231, 36, 18, 59, 234, 234, 234, 234, 267, 269, |
| 155778 | /* 1750 */ 162, 111, 219, 142, 256, 213, 113, 255, 213, 256, | 157846 | /* 1750 */ 18, 198, 197, 231, 148, 71, 269, 269, 243, 231, |
| 155779 | /* 1760 */ 216, 303, 215, 213, 213, 97, 255, 213, 216, 275, | 157847 | /* 1760 */ 198, 243, 267, 197, 59, 157, 243, 198, 62, 287, |
| 155780 | /* 1770 */ 275, 222, 216, 256, 255, 196, 91, 82, 256, 255, | 157848 | /* 1770 */ 243, 197, 22, 198, 114, 64, 71, 218, 218, 197, |
| 155781 | /* 1780 */ 308, 308, 146, 22, 143, 196, 155, 260, 25, 145, | 157849 | /* 1780 */ 286, 198, 197, 215, 100, 215, 215, 224, 22, 125, |
| 155782 | /* 1790 */ 144, 199, 26, 198, 13, 190, 190, 6, 293, 131, | 157850 | /* 1790 */ 106, 107, 164, 24, 221, 112, 143, 113, 302, 115, |
| 155783 | /* 1800 */ 188, 188, 245, 244, 136, 137, 245, 243, 242, 241, | 157851 | /* 1800 */ 116, 117, 218, 215, 120, 100, 217, 221, 215, 215, |
| 155784 | /* 1810 */ 188, 202, 208, 217, 217, 260, 208, 4, 202, 3, | 157852 | /* 1810 */ 309, 106, 107, 215, 224, 279, 279, 218, 113, 258, |
| 155785 | /* 1820 */ 22, 202, 208, 208, 160, 15, 209, 159, 270, 209, | 157853 | /* 1820 */ 115, 116, 117, 114, 257, 120, 91, 198, 82, 147, |
| 155786 | /* 1830 */ 98, 16, 272, 208, 23, 23, 137, 148, 128, 20, | 157854 | /* 1830 */ 144, 22, 274, 314, 198, 314, 152, 153, 154, 155, |
| 155787 | /* 1840 */ 140, 24, 16, 142, 1, 140, 149, 128, 61, 53, | 157855 | /* 1840 */ 156, 276, 157, 146, 145, 258, 25, 247, 257, 201, |
| 155788 | /* 1850 */ 148, 37, 53, 53, 53, 128, 114, 34, 296, 296, | 157856 | /* 1850 */ 258, 26, 200, 13, 257, 244, 246, 152, 153, 154, |
| 155789 | /* 1860 */ 139, 1, 5, 22, 113, 158, 26, 75, 41, 139, | 157857 | /* 1860 */ 155, 156, 258, 262, 257, 247, 245, 243, 192, 192, |
| 155790 | /* 1870 */ 68, 68, 113, 24, 20, 19, 129, 123, 23, 96, | 157858 | /* 1870 */ 6, 262, 204, 210, 219, 210, 210, 190, 190, 190, |
| 155791 | /* 1880 */ 22, 22, 37, 22, 22, 67, 22, 67, 59, 24, | 157859 | /* 1880 */ 210, 219, 204, 211, 211, 210, 4, 3, 22, 162, |
| 155792 | /* 1890 */ 23, 28, 67, 147, 22, 26, 23, 23, 23, 23, | 157860 | /* 1890 */ 15, 23, 16, 23, 204, 138, 129, 150, 26, 141, |
| 155793 | /* 1900 */ 22, 24, 23, 22, 24, 23, 139, 23, 114, 22, | 157861 | /* 1900 */ 20, 24, 143, 16, 1, 141, 129, 129, 61, 53, |
| 155794 | /* 1910 */ 141, 26, 88, 75, 86, 44, 23, 34, 22, 75, | 157862 | /* 1910 */ 37, 150, 297, 300, 300, 53, 53, 129, 53, 115, |
| 155795 | /* 1920 */ 34, 24, 34, 34, 34, 93, 34, 26, 26, 34, | 157863 | /* 1920 */ 34, 140, 1, 5, 22, 114, 68, 26, 160, 68, |
| 155796 | /* 1930 */ 23, 23, 23, 23, 23, 11, 23, 22, 26, 22, | 157864 | /* 1930 */ 75, 41, 140, 114, 24, 20, 19, 130, 124, 23, |
| 155797 | /* 1940 */ 22, 133, 23, 23, 22, 22, 139, 26, 139, 23, | 157865 | /* 1940 */ 96, 22, 22, 37, 22, 67, 22, 59, 67, 24, |
| 155798 | /* 1950 */ 15, 1, 1, 310, 310, 310, 310, 310, 310, 310, | 157866 | /* 1950 */ 22, 28, 67, 23, 148, 22, 97, 23, 23, 23, |
| 155799 | /* 1960 */ 139, 139, 310, 310, 310, 310, 310, 310, 310, 310, | 157867 | /* 1960 */ 140, 23, 22, 26, 23, 23, 115, 22, 142, 26, |
| 155800 | /* 1970 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157868 | /* 1970 */ 75, 88, 75, 34, 23, 86, 44, 22, 34, 26, |
| 155801 | /* 1980 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157869 | /* 1980 */ 34, 34, 34, 34, 93, 24, 26, 23, 34, 23, |
| 155802 | /* 1990 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157870 | /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 15, |
| 155803 | /* 2000 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157871 | /* 2000 */ 23, 23, 22, 22, 1, 26, 23, 140, 134, 140, |
| 155804 | /* 2010 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157872 | /* 2010 */ 1, 140, 316, 316, 316, 316, 316, 316, 316, 140, |
| 155805 | /* 2020 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157873 | /* 2020 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155806 | /* 2030 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157874 | /* 2030 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155807 | /* 2040 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157875 | /* 2040 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155808 | /* 2050 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157876 | /* 2050 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155809 | /* 2060 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157877 | /* 2060 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155810 | /* 2070 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157878 | /* 2070 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155811 | /* 2080 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157879 | /* 2080 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155812 | /* 2090 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157880 | /* 2090 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155813 | /* 2100 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157881 | /* 2100 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155814 | /* 2110 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157882 | /* 2110 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155815 | /* 2120 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157883 | /* 2120 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155816 | /* 2130 */ 310, 310, 310, 310, 310, 310, 310, 310, 310, 310, | 157884 | /* 2130 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 155817 | /* 2140 */ 310, 310, 310, | 157885 | /* 2140 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, |
| 157886 | /* 2150 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | ||
| 157887 | /* 2160 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | ||
| 157888 | /* 2170 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | ||
| 157889 | /* 2180 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | ||
| 157890 | /* 2190 */ 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, | ||
| 157891 | /* 2200 */ 316, 316, 316, | ||
| 155818 | }; | 157892 | }; |
| 155819 | #define YY_SHIFT_COUNT (552) | 157893 | #define YY_SHIFT_COUNT (569) |
| 155820 | #define YY_SHIFT_MIN (0) | 157894 | #define YY_SHIFT_MIN (0) |
| 155821 | #define YY_SHIFT_MAX (1951) | 157895 | #define YY_SHIFT_MAX (2009) |
| 155822 | static const unsigned short int yy_shift_ofst[] = { | 157896 | static const unsigned short int yy_shift_ofst[] = { |
| 155823 | /* 0 */ 1448, 1277, 1668, 1072, 1072, 340, 1122, 1225, 1332, 1481, | 157897 | /* 0 */ 1423, 1409, 1454, 1192, 1192, 36, 1252, 1410, 1517, 1684, |
| 155824 | /* 10 */ 1481, 1481, 335, 0, 0, 180, 897, 1481, 1481, 1481, | 157898 | /* 10 */ 1684, 1684, 292, 0, 0, 180, 1015, 1684, 1684, 1684, |
| 155825 | /* 20 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, | 157899 | /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 155826 | /* 30 */ 930, 930, 1020, 1020, 290, 1, 340, 340, 340, 340, | 157900 | /* 30 */ 1049, 1049, 1121, 1121, 54, 400, 36, 36, 36, 36, |
| 155827 | /* 40 */ 340, 340, 40, 110, 219, 288, 327, 396, 435, 504, | 157901 | /* 40 */ 36, 40, 110, 219, 289, 396, 439, 509, 548, 618, |
| 155828 | /* 50 */ 543, 612, 651, 720, 877, 897, 897, 897, 897, 897, | 157902 | /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015, |
| 155829 | /* 60 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, | 157903 | /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, |
| 155830 | /* 70 */ 897, 897, 897, 917, 897, 1019, 763, 763, 1451, 1481, | 157904 | /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684, |
| 155831 | /* 80 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, | 157905 | /* 80 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 155832 | /* 90 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, | 157906 | /* 90 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 155833 | /* 100 */ 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, 1481, | 157907 | /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 155834 | /* 110 */ 1481, 1481, 1553, 1481, 1481, 1481, 1481, 1481, 1481, 1481, | 157908 | /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684, |
| 155835 | /* 120 */ 1481, 1481, 1481, 1481, 1481, 1481, 147, 258, 258, 258, | 157909 | /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84, |
| 155836 | /* 130 */ 258, 258, 79, 65, 84, 449, 19, 786, 449, 636, | 157910 | /* 130 */ 84, 84, 84, 362, 269, 125, 97, 453, 66, 66, |
| 155837 | /* 140 */ 636, 449, 880, 880, 880, 880, 113, 142, 142, 472, | 157911 | /* 140 */ 893, 1090, 66, 66, 533, 533, 66, 554, 554, 554, |
| 155838 | /* 150 */ 150, 1962, 1962, 399, 399, 399, 93, 237, 341, 237, | 157912 | /* 150 */ 554, 192, 587, 587, 695, 25, 2020, 2020, 290, 290, |
| 155839 | /* 160 */ 237, 1074, 1074, 437, 350, 704, 1080, 449, 449, 449, | 157913 | /* 160 */ 290, 200, 514, 514, 514, 514, 939, 939, 442, 875, |
| 155840 | /* 170 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, | 157914 | /* 170 */ 935, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 155841 | /* 180 */ 449, 449, 449, 449, 449, 449, 449, 449, 818, 818, | 157915 | /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 155842 | /* 190 */ 449, 1088, 217, 217, 734, 734, 1124, 1126, 1962, 1962, | 157916 | /* 190 */ 66, 601, 601, 66, 729, 878, 878, 1266, 1266, 552, |
| 155843 | /* 200 */ 1962, 739, 840, 840, 453, 454, 511, 187, 563, 570, | 157917 | /* 200 */ 1023, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 307, 490, |
| 155844 | /* 210 */ 898, 669, 449, 449, 449, 449, 449, 449, 449, 449, | 157918 | /* 210 */ 490, 567, 393, 517, 467, 672, 242, 682, 675, 66, |
| 155845 | /* 220 */ 449, 670, 449, 449, 449, 449, 449, 449, 449, 449, | 157919 | /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 616, |
| 155846 | /* 230 */ 449, 449, 449, 449, 674, 674, 674, 449, 449, 449, | 157920 | /* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 155847 | /* 240 */ 449, 1034, 449, 449, 449, 972, 1107, 449, 449, 1193, | 157921 | /* 240 */ 66, 66, 1093, 1093, 1093, 66, 66, 66, 778, 66, |
| 155848 | /* 250 */ 449, 449, 449, 449, 449, 449, 449, 449, 260, 177, | 157922 | /* 250 */ 66, 66, 1053, 1064, 66, 66, 1190, 66, 66, 66, |
| 155849 | /* 260 */ 489, 1241, 1241, 1241, 1241, 1192, 489, 489, 952, 1197, | 157923 | /* 260 */ 66, 66, 66, 66, 66, 722, 992, 718, 253, 253, |
| 155850 | /* 270 */ 625, 1235, 1131, 181, 181, 1086, 1139, 1131, 1086, 1187, | 157924 | /* 270 */ 253, 253, 338, 718, 718, 888, 403, 852, 1328, 254, |
| 155851 | /* 280 */ 1319, 1237, 1318, 1318, 1318, 181, 1299, 1299, 1109, 1336, | 157925 | /* 280 */ 1295, 721, 1330, 1295, 1330, 1370, 234, 254, 254, 234, |
| 155852 | /* 290 */ 549, 1376, 1610, 1535, 1535, 1639, 1639, 1535, 1539, 1578, | 157926 | /* 290 */ 254, 721, 1370, 1357, 1492, 1348, 385, 385, 385, 1330, |
| 155853 | /* 300 */ 1670, 1546, 1652, 1546, 1681, 1681, 1681, 1681, 1535, 1694, | 157927 | /* 300 */ 1425, 1425, 643, 1315, 1336, 1004, 1651, 1651, 1581, 1581, |
| 155854 | /* 310 */ 1546, 1546, 1578, 1670, 1652, 1546, 1652, 1546, 1535, 1694, | 157928 | /* 310 */ 1674, 1674, 1581, 1576, 1579, 1716, 1696, 1724, 1724, 1724, |
| 155855 | /* 320 */ 1565, 1665, 1535, 1694, 1708, 1535, 1694, 1535, 1694, 1708, | 157929 | /* 320 */ 1724, 1581, 1732, 1606, 1579, 1579, 1606, 1716, 1696, 1606, |
| 155856 | /* 330 */ 1618, 1618, 1618, 1680, 1723, 1723, 1708, 1618, 1623, 1618, | 157930 | /* 330 */ 1696, 1606, 1581, 1732, 1608, 1706, 1581, 1732, 1750, 1581, |
| 155857 | /* 340 */ 1680, 1618, 1618, 1588, 1708, 1640, 1640, 1708, 1611, 1643, | 157931 | /* 340 */ 1732, 1581, 1732, 1750, 1660, 1660, 1660, 1711, 1766, 1766, |
| 155858 | /* 350 */ 1611, 1643, 1611, 1643, 1611, 1643, 1535, 1685, 1685, 1695, | 157932 | /* 350 */ 1750, 1660, 1664, 1660, 1711, 1660, 1660, 1628, 1769, 1683, |
| 155859 | /* 360 */ 1695, 1636, 1641, 1761, 1535, 1631, 1636, 1644, 1646, 1546, | 157933 | /* 360 */ 1683, 1750, 1653, 1709, 1653, 1709, 1653, 1709, 1653, 1709, |
| 155860 | /* 370 */ 1763, 1766, 1781, 1781, 1791, 1791, 1791, 1962, 1962, 1962, | 157934 | /* 370 */ 1581, 1735, 1735, 1746, 1746, 1682, 1686, 1809, 1581, 1685, |
| 155861 | /* 380 */ 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, 1962, | 157935 | /* 380 */ 1682, 1697, 1699, 1606, 1821, 1825, 1840, 1840, 1864, 1864, |
| 155862 | /* 390 */ 1962, 1962, 308, 835, 954, 1232, 879, 715, 728, 1373, | 157936 | /* 390 */ 1864, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, |
| 155863 | /* 400 */ 864, 1329, 1253, 1409, 297, 1431, 1489, 1497, 1520, 1521, | 157937 | /* 400 */ 2020, 2020, 2020, 2020, 2020, 2020, 599, 223, 1193, 1299, |
| 155864 | /* 410 */ 1525, 1362, 1309, 1491, 1217, 1420, 1429, 1536, 1380, 1538, | 157938 | /* 410 */ 228, 780, 958, 1505, 1153, 1435, 1368, 1426, 1430, 1552, |
| 155865 | /* 420 */ 1293, 1354, 1548, 1585, 1434, 1342, 1813, 1816, 1798, 1664, | 157939 | /* 420 */ 1477, 1556, 1557, 1564, 1572, 1578, 1580, 1489, 1474, 1602, |
| 155866 | /* 430 */ 1810, 1732, 1815, 1811, 1812, 1699, 1689, 1710, 1817, 1700, | 157940 | /* 430 */ 1389, 1514, 1500, 1595, 1596, 1484, 1603, 1075, 1460, 1605, |
| 155867 | /* 440 */ 1819, 1701, 1826, 1843, 1705, 1697, 1719, 1787, 1814, 1702, | 157941 | /* 440 */ 1612, 1526, 1507, 1882, 1884, 1866, 1727, 1875, 1876, 1868, |
| 155868 | /* 450 */ 1796, 1799, 1800, 1801, 1727, 1742, 1823, 1721, 1860, 1857, | 157942 | /* 450 */ 1870, 1757, 1747, 1767, 1872, 1872, 1877, 1758, 1880, 1759, |
| 155869 | /* 460 */ 1841, 1751, 1707, 1802, 1840, 1803, 1792, 1827, 1730, 1759, | 157943 | /* 460 */ 1887, 1903, 1764, 1777, 1872, 1778, 1847, 1873, 1872, 1761, |
| 155870 | /* 470 */ 1849, 1854, 1856, 1747, 1754, 1858, 1818, 1859, 1861, 1855, | 157944 | /* 470 */ 1856, 1862, 1863, 1865, 1788, 1804, 1886, 1781, 1921, 1918, |
| 155871 | /* 480 */ 1862, 1820, 1829, 1865, 1783, 1863, 1864, 1825, 1845, 1867, | 157945 | /* 480 */ 1902, 1811, 1768, 1858, 1901, 1861, 1855, 1890, 1792, 1819, |
| 155872 | /* 490 */ 1746, 1872, 1873, 1874, 1875, 1869, 1876, 1878, 1877, 1879, | 157946 | /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1878, 1920, 1922, 1916, |
| 155873 | /* 500 */ 1881, 1880, 1767, 1882, 1884, 1794, 1883, 1887, 1769, 1885, | 157947 | /* 500 */ 1924, 1881, 1888, 1925, 1844, 1923, 1928, 1885, 1906, 1930, |
| 155874 | /* 510 */ 1886, 1888, 1889, 1890, 1824, 1838, 1828, 1871, 1844, 1832, | 157948 | /* 510 */ 1806, 1933, 1934, 1935, 1936, 1937, 1938, 1940, 1859, 1820, |
| 155875 | /* 520 */ 1892, 1893, 1896, 1897, 1901, 1902, 1895, 1907, 1885, 1908, | 157949 | /* 520 */ 1941, 1942, 1851, 1939, 1945, 1826, 1943, 1944, 1946, 1947, |
| 155876 | /* 530 */ 1909, 1910, 1911, 1912, 1913, 1915, 1924, 1917, 1918, 1919, | 157950 | /* 530 */ 1948, 1883, 1895, 1889, 1932, 1897, 1891, 1949, 1951, 1955, |
| 155877 | /* 540 */ 1920, 1922, 1923, 1921, 1808, 1807, 1809, 1821, 1822, 1926, | 157951 | /* 540 */ 1961, 1953, 1960, 1954, 1964, 1943, 1966, 1967, 1968, 1969, |
| 155878 | /* 550 */ 1935, 1950, 1951, | 157952 | /* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981, |
| 157953 | /* 560 */ 1979, 1874, 1867, 1869, 1871, 1879, 1983, 1984, 2003, 2009, | ||
| 155879 | }; | 157954 | }; |
| 155880 | #define YY_REDUCE_COUNT (391) | 157955 | #define YY_REDUCE_COUNT (405) |
| 155881 | #define YY_REDUCE_MIN (-262) | 157956 | #define YY_REDUCE_MIN (-265) |
| 155882 | #define YY_REDUCE_MAX (1625) | 157957 | #define YY_REDUCE_MAX (1690) |
| 155883 | static const short yy_reduce_ofst[] = { | 157958 | static const short yy_reduce_ofst[] = { |
| 155884 | /* 0 */ 490, -122, 545, 645, 650, -120, -189, -187, -184, -182, | 157959 | /* 0 */ 111, 168, 386, 761, -176, -174, -191, -189, -181, -178, |
| 155885 | /* 10 */ -178, -176, 45, 30, 200, -251, -134, 390, 392, 521, | 157960 | /* 10 */ 176, 263, 44, -207, -204, -265, -139, -114, 158, 504, |
| 155886 | /* 20 */ 523, 213, 692, 821, 284, 589, 872, 666, 671, 866, | 157961 | /* 20 */ 525, 544, 612, 614, 650, 652, 765, 265, 703, 705, |
| 155887 | /* 30 */ 71, 111, 273, 389, 686, 815, 904, 932, 948, 955, | 157962 | /* 30 */ 70, 714, -187, 127, 774, 713, 767, 769, 970, 1019, |
| 155888 | /* 40 */ 964, 969, -259, -259, -259, -259, -259, -259, -259, -259, | 157963 | /* 40 */ 1021, -255, -255, -255, -255, -255, -255, -255, -255, -255, |
| 155889 | /* 50 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259, | 157964 | /* 50 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, |
| 155890 | /* 60 */ -259, -259, -259, -259, -259, -259, -259, -259, -259, -259, | 157965 | /* 60 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255, |
| 155891 | /* 70 */ -259, -259, -259, -259, -259, -259, -259, -259, 428, 430, | 157966 | /* 70 */ -255, -255, -255, -255, -255, -255, -255, -255, 394, 542, |
| 155892 | /* 80 */ 899, 985, 1021, 1028, 1057, 1069, 1081, 1108, 1110, 1115, | 157967 | /* 80 */ 816, 818, 842, 882, 902, 919, 938, 940, 957, 986, |
| 155893 | /* 90 */ 1117, 1123, 1149, 1154, 1159, 1170, 1174, 1178, 1183, 1194, | 157968 | /* 90 */ 1048, 1063, 1068, 1073, 1076, 1088, 1100, 1102, 1104, 1106, |
| 155894 | /* 100 */ 1198, 1204, 1208, 1212, 1218, 1222, 1229, 1278, 1280, 1283, | 157969 | /* 100 */ 1113, 1119, 1137, 1140, 1143, 1147, 1149, 1164, 1173, 1183, |
| 155895 | /* 110 */ 1285, 1313, 1316, 1320, 1322, 1325, 1327, 1330, 1366, 1371, | 157970 | /* 110 */ 1185, 1188, 1202, 1204, 1247, 1259, 1263, 1283, 1289, 1292, |
| 155896 | /* 120 */ 1379, 1387, 1417, 1425, 1430, 1432, -259, -259, -259, -259, | 157971 | /* 120 */ 1298, 1300, 1329, 1331, 1343, 1358, 1360, -255, -255, -255, |
| 155897 | /* 130 */ -259, -259, -259, -259, -259, 557, 974, -214, -174, -9, | 157972 | /* 130 */ -255, -255, -255, -255, -255, 196, -255, 387, -177, 507, |
| 155898 | /* 140 */ 431, -124, 806, 925, 806, 925, 251, 928, 940, -259, | 157973 | /* 140 */ 1002, -219, 557, -93, -167, 638, -121, 284, 500, 284, |
| 155899 | /* 150 */ -259, -259, -259, -198, -198, -198, 127, -186, -168, 212, | 157974 | /* 150 */ 500, 247, 651, 865, -255, -255, -255, -255, -85, -85, |
| 155900 | /* 160 */ 646, 617, 799, -262, 555, 220, 220, 491, 605, 1040, | 157975 | /* 160 */ -85, 237, 171, 602, 846, 885, -212, -203, 217, 380, |
| 155901 | /* 170 */ 1060, 699, -11, 600, 848, 862, 345, -129, 724, -91, | 157976 | /* 170 */ 380, -23, 161, 653, 712, 773, 943, 990, 1040, 563, |
| 155902 | /* 180 */ 158, 749, 716, 900, 304, 822, 929, 926, 499, 793, | 157977 | /* 180 */ 833, 971, 1005, 1042, 1092, 1078, 1043, 1144, 1184, -186, |
| 155903 | /* 190 */ 322, 892, 813, 845, 958, 1056, 751, 905, 1133, 1062, | 157978 | /* 190 */ 1105, 318, 869, 7, 825, 920, 1074, 704, 706, 390, |
| 155904 | /* 200 */ 803, -210, -185, -179, -148, -167, -89, 121, 274, 281, | 157979 | /* 200 */ 1087, 1094, 336, 545, 772, 1201, 1117, 1207, -179, -137, |
| 155905 | /* 210 */ 320, 336, 439, 663, 711, 957, 965, 1064, 1068, 1112, | 157980 | /* 210 */ -112, -13, 18, 112, 197, 418, 495, 508, 777, 809, |
| 155906 | /* 220 */ 1116, -196, 1127, 1134, 1180, 1184, 1195, 1199, 1203, 1215, | 157981 | /* 220 */ 923, 1014, 1027, 1033, 1044, 1115, 1194, 1212, 1221, 209, |
| 155907 | /* 230 */ 1223, 1250, 1267, 1286, 205, 422, 638, 1324, 1341, 1364, | 157982 | /* 230 */ 1236, 1240, 1256, 1287, 1301, 1307, 1349, 1359, 1398, 1417, |
| 155908 | /* 240 */ 1365, 1213, 1392, 1399, 1403, 869, 1260, 1405, 1421, 1276, | 157983 | /* 240 */ 1429, 1434, 681, 1377, 1404, 1448, 1449, 1450, 1388, 1453, |
| 155909 | /* 250 */ 1424, 121, 1426, 1427, 1428, 1433, 1436, 1437, 1227, 1338, | 157984 | /* 250 */ 1455, 1458, 1393, 1335, 1461, 1462, 1418, 1463, 197, 1464, |
| 155910 | /* 260 */ 1284, 1359, 1370, 1377, 1388, 1213, 1284, 1284, 1385, 1438, | 157985 | /* 260 */ 1465, 1466, 1467, 1468, 1469, 1376, 1378, 1424, 1412, 1413, |
| 155911 | /* 270 */ 1443, 1349, 1400, 1391, 1394, 1360, 1408, 1410, 1367, 1439, | 157986 | /* 270 */ 1414, 1415, 1388, 1424, 1424, 1428, 1470, 1485, 1381, 1408, |
| 155912 | /* 280 */ 1440, 1435, 1442, 1446, 1447, 1397, 1413, 1418, 1390, 1444, | 157987 | /* 280 */ 1416, 1436, 1431, 1422, 1432, 1392, 1446, 1411, 1427, 1456, |
| 155913 | /* 290 */ 1445, 1474, 1381, 1479, 1480, 1401, 1402, 1490, 1414, 1449, | 157988 | /* 290 */ 1433, 1471, 1401, 1479, 1472, 1478, 1486, 1491, 1493, 1452, |
| 155914 | /* 300 */ 1452, 1453, 1467, 1456, 1469, 1470, 1477, 1478, 1515, 1518, | 157989 | /* 300 */ 1459, 1473, 1437, 1475, 1476, 1516, 1421, 1440, 1520, 1524, |
| 155915 | /* 310 */ 1476, 1482, 1450, 1454, 1492, 1483, 1493, 1484, 1523, 1531, | 157990 | /* 310 */ 1444, 1445, 1525, 1457, 1480, 1481, 1509, 1510, 1511, 1512, |
| 155916 | /* 320 */ 1457, 1455, 1532, 1534, 1516, 1537, 1540, 1543, 1541, 1526, | 157991 | /* 320 */ 1513, 1553, 1555, 1515, 1487, 1488, 1518, 1495, 1522, 1523, |
| 155917 | /* 330 */ 1528, 1530, 1542, 1512, 1529, 1533, 1544, 1545, 1547, 1550, | 157992 | /* 330 */ 1528, 1527, 1562, 1566, 1482, 1494, 1569, 1574, 1559, 1575, |
| 155918 | /* 340 */ 1549, 1551, 1554, 1458, 1552, 1494, 1495, 1556, 1498, 1502, | 157993 | /* 340 */ 1582, 1583, 1585, 1560, 1568, 1570, 1571, 1563, 1573, 1586, |
| 155919 | /* 350 */ 1503, 1511, 1517, 1519, 1522, 1524, 1579, 1472, 1473, 1527, | 157994 | /* 350 */ 1584, 1588, 1589, 1593, 1590, 1594, 1598, 1501, 1496, 1536, |
| 155920 | /* 360 */ 1555, 1557, 1559, 1558, 1589, 1560, 1561, 1564, 1566, 1568, | 157995 | /* 360 */ 1537, 1599, 1561, 1567, 1587, 1591, 1592, 1597, 1604, 1607, |
| 155921 | /* 370 */ 1592, 1595, 1605, 1606, 1612, 1613, 1622, 1562, 1563, 1505, | 157996 | /* 370 */ 1629, 1519, 1521, 1601, 1609, 1600, 1610, 1558, 1636, 1565, |
| 155922 | /* 380 */ 1609, 1604, 1608, 1614, 1615, 1616, 1596, 1597, 1617, 1620, | 157997 | /* 380 */ 1618, 1621, 1611, 1624, 1648, 1652, 1676, 1677, 1687, 1688, |
| 155923 | /* 390 */ 1625, 1619, | 157998 | /* 390 */ 1689, 1613, 1614, 1615, 1668, 1663, 1665, 1666, 1670, 1678, |
| 157999 | /* 400 */ 1655, 1662, 1672, 1673, 1675, 1690, | ||
| 155924 | }; | 158000 | }; |
| 155925 | static const YYACTIONTYPE yy_default[] = { | 158001 | static const YYACTIONTYPE yy_default[] = { |
| 155926 | /* 0 */ 1575, 1575, 1575, 1411, 1188, 1297, 1188, 1188, 1188, 1411, | 158002 | /* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453, |
| 155927 | /* 10 */ 1411, 1411, 1188, 1327, 1327, 1464, 1219, 1188, 1188, 1188, | 158003 | /* 10 */ 1453, 1453, 1223, 1362, 1362, 1506, 1254, 1223, 1223, 1223, |
| 155928 | /* 20 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1410, 1188, 1188, | 158004 | /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1452, 1223, 1223, |
| 155929 | /* 30 */ 1188, 1188, 1494, 1494, 1188, 1188, 1188, 1188, 1188, 1188, | 158005 | /* 30 */ 1223, 1223, 1541, 1541, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155930 | /* 40 */ 1188, 1188, 1188, 1336, 1188, 1188, 1188, 1188, 1188, 1188, | 158006 | /* 40 */ 1223, 1223, 1371, 1223, 1378, 1223, 1223, 1223, 1223, 1223, |
| 155931 | /* 50 */ 1412, 1413, 1188, 1188, 1188, 1463, 1465, 1428, 1346, 1345, | 158007 | /* 50 */ 1454, 1455, 1223, 1223, 1223, 1505, 1507, 1470, 1385, 1384, |
| 155932 | /* 60 */ 1344, 1343, 1446, 1314, 1341, 1334, 1338, 1406, 1407, 1405, | 158008 | /* 60 */ 1383, 1382, 1488, 1349, 1376, 1369, 1373, 1448, 1449, 1447, |
| 155933 | /* 70 */ 1409, 1413, 1412, 1188, 1337, 1377, 1391, 1376, 1188, 1188, | 158009 | /* 70 */ 1451, 1455, 1454, 1223, 1372, 1419, 1433, 1418, 1223, 1223, |
| 155934 | /* 80 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158010 | /* 80 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155935 | /* 90 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158011 | /* 90 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155936 | /* 100 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158012 | /* 100 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155937 | /* 110 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158013 | /* 110 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155938 | /* 120 */ 1188, 1188, 1188, 1188, 1188, 1188, 1385, 1390, 1396, 1389, | 158014 | /* 120 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1427, 1432, 1438, |
| 155939 | /* 130 */ 1386, 1379, 1378, 1380, 1381, 1188, 1209, 1261, 1188, 1188, | 158015 | /* 130 */ 1431, 1428, 1421, 1420, 1422, 1223, 1423, 1223, 1223, 1223, |
| 155940 | /* 140 */ 1188, 1188, 1482, 1481, 1188, 1188, 1219, 1371, 1370, 1382, | 158016 | /* 140 */ 1244, 1296, 1223, 1223, 1223, 1223, 1223, 1525, 1524, 1223, |
| 155941 | /* 150 */ 1383, 1393, 1392, 1471, 1529, 1528, 1429, 1188, 1188, 1188, | 158017 | /* 150 */ 1223, 1254, 1413, 1412, 1424, 1425, 1435, 1434, 1513, 1576, |
| 155942 | /* 160 */ 1188, 1188, 1188, 1494, 1188, 1188, 1188, 1188, 1188, 1188, | 158018 | /* 160 */ 1575, 1471, 1223, 1223, 1223, 1223, 1223, 1223, 1541, 1223, |
| 155943 | /* 170 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158019 | /* 170 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155944 | /* 180 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1494, 1494, | 158020 | /* 180 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155945 | /* 190 */ 1188, 1219, 1494, 1494, 1215, 1215, 1321, 1188, 1477, 1297, | 158021 | /* 190 */ 1223, 1541, 1541, 1223, 1254, 1541, 1541, 1250, 1250, 1356, |
| 155946 | /* 200 */ 1288, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158022 | /* 200 */ 1223, 1520, 1323, 1323, 1323, 1323, 1332, 1323, 1223, 1223, |
| 155947 | /* 210 */ 1188, 1188, 1188, 1188, 1188, 1468, 1466, 1188, 1188, 1188, | 158023 | /* 210 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155948 | /* 220 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158024 | /* 220 */ 1223, 1223, 1223, 1510, 1508, 1223, 1223, 1223, 1223, 1223, |
| 155949 | /* 230 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158025 | /* 230 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155950 | /* 240 */ 1188, 1188, 1188, 1188, 1188, 1293, 1188, 1188, 1188, 1188, | 158026 | /* 240 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155951 | /* 250 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1523, 1188, 1441, | 158027 | /* 250 */ 1223, 1223, 1328, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155952 | /* 260 */ 1275, 1293, 1293, 1293, 1293, 1295, 1276, 1274, 1287, 1220, | 158028 | /* 260 */ 1223, 1223, 1223, 1223, 1570, 1223, 1483, 1310, 1328, 1328, |
| 155953 | /* 270 */ 1195, 1567, 1294, 1316, 1316, 1564, 1340, 1294, 1564, 1236, | 158029 | /* 270 */ 1328, 1328, 1330, 1311, 1309, 1322, 1255, 1230, 1615, 1388, |
| 155954 | /* 280 */ 1545, 1231, 1327, 1327, 1327, 1316, 1321, 1321, 1408, 1294, | 158030 | /* 280 */ 1377, 1329, 1351, 1377, 1351, 1612, 1375, 1388, 1388, 1375, |
| 155955 | /* 290 */ 1287, 1188, 1567, 1302, 1302, 1566, 1566, 1302, 1429, 1349, | 158031 | /* 290 */ 1388, 1329, 1612, 1271, 1592, 1266, 1362, 1362, 1362, 1351, |
| 155956 | /* 300 */ 1355, 1340, 1264, 1340, 1270, 1270, 1270, 1270, 1302, 1206, | 158032 | /* 300 */ 1356, 1356, 1450, 1329, 1322, 1223, 1615, 1615, 1337, 1337, |
| 155957 | /* 310 */ 1340, 1340, 1349, 1355, 1264, 1340, 1264, 1340, 1302, 1206, | 158033 | /* 310 */ 1614, 1614, 1337, 1471, 1599, 1397, 1299, 1305, 1305, 1305, |
| 155958 | /* 320 */ 1445, 1561, 1302, 1206, 1419, 1302, 1206, 1302, 1206, 1419, | 158034 | /* 320 */ 1305, 1337, 1241, 1375, 1599, 1599, 1375, 1397, 1299, 1375, |
| 155959 | /* 330 */ 1262, 1262, 1262, 1251, 1188, 1188, 1419, 1262, 1236, 1262, | 158035 | /* 330 */ 1299, 1375, 1337, 1241, 1487, 1609, 1337, 1241, 1461, 1337, |
| 155960 | /* 340 */ 1251, 1262, 1262, 1512, 1419, 1423, 1423, 1419, 1320, 1315, | 158036 | /* 340 */ 1241, 1337, 1241, 1461, 1297, 1297, 1297, 1286, 1223, 1223, |
| 155961 | /* 350 */ 1320, 1315, 1320, 1315, 1320, 1315, 1302, 1504, 1504, 1330, | 158037 | /* 350 */ 1461, 1297, 1271, 1297, 1286, 1297, 1297, 1559, 1223, 1465, |
| 155962 | /* 360 */ 1330, 1335, 1321, 1414, 1302, 1188, 1335, 1333, 1331, 1340, | 158038 | /* 360 */ 1465, 1461, 1355, 1350, 1355, 1350, 1355, 1350, 1355, 1350, |
| 155963 | /* 370 */ 1212, 1254, 1526, 1526, 1522, 1522, 1522, 1572, 1572, 1477, | 158039 | /* 370 */ 1337, 1551, 1551, 1365, 1365, 1370, 1356, 1456, 1337, 1223, |
| 155964 | /* 380 */ 1538, 1219, 1219, 1219, 1219, 1538, 1238, 1238, 1220, 1220, | 158040 | /* 380 */ 1370, 1368, 1366, 1375, 1247, 1289, 1573, 1573, 1569, 1569, |
| 155965 | /* 390 */ 1219, 1538, 1188, 1188, 1188, 1188, 1188, 1188, 1533, 1188, | 158041 | /* 390 */ 1569, 1620, 1620, 1520, 1585, 1254, 1254, 1254, 1254, 1585, |
| 155966 | /* 400 */ 1430, 1306, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158042 | /* 400 */ 1273, 1273, 1255, 1255, 1254, 1585, 1223, 1223, 1223, 1223, |
| 155967 | /* 410 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158043 | /* 410 */ 1223, 1223, 1580, 1223, 1515, 1472, 1341, 1223, 1223, 1223, |
| 155968 | /* 420 */ 1188, 1188, 1188, 1188, 1188, 1360, 1188, 1191, 1474, 1188, | 158044 | /* 420 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155969 | /* 430 */ 1188, 1472, 1188, 1188, 1188, 1188, 1188, 1188, 1307, 1188, | 158045 | /* 430 */ 1223, 1526, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155970 | /* 440 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158046 | /* 440 */ 1223, 1223, 1402, 1223, 1226, 1517, 1223, 1223, 1223, 1223, |
| 155971 | /* 450 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1563, 1188, 1188, | 158047 | /* 450 */ 1223, 1223, 1223, 1223, 1379, 1380, 1342, 1223, 1223, 1223, |
| 155972 | /* 460 */ 1188, 1188, 1188, 1188, 1444, 1443, 1188, 1188, 1304, 1188, | 158048 | /* 460 */ 1223, 1223, 1223, 1223, 1394, 1223, 1223, 1223, 1389, 1223, |
| 155973 | /* 470 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158049 | /* 470 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1611, 1223, 1223, |
| 155974 | /* 480 */ 1188, 1188, 1234, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158050 | /* 480 */ 1223, 1223, 1223, 1223, 1486, 1485, 1223, 1223, 1339, 1223, |
| 155975 | /* 490 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158051 | /* 490 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155976 | /* 500 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1332, | 158052 | /* 500 */ 1223, 1223, 1269, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155977 | /* 510 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158053 | /* 510 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155978 | /* 520 */ 1188, 1188, 1188, 1188, 1509, 1322, 1188, 1188, 1554, 1188, | 158054 | /* 520 */ 1223, 1223, 1223, 1223, 1223, 1223, 1367, 1223, 1223, 1223, |
| 155979 | /* 530 */ 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, 1188, | 158055 | /* 530 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 155980 | /* 540 */ 1188, 1188, 1188, 1549, 1278, 1362, 1188, 1361, 1365, 1188, | 158056 | /* 540 */ 1223, 1556, 1357, 1223, 1223, 1602, 1223, 1223, 1223, 1223, |
| 155981 | /* 550 */ 1200, 1188, 1188, | 158057 | /* 550 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, |
| 158058 | /* 560 */ 1596, 1313, 1404, 1223, 1403, 1407, 1223, 1235, 1223, 1223, | ||
| 155982 | }; | 158059 | }; |
| 155983 | /********** End of lemon-generated parsing tables *****************************/ | 158060 | /********** End of lemon-generated parsing tables *****************************/ |
| 155984 | 158061 | ||
| @@ -156095,6 +158172,7 @@ static const YYCODETYPE yyFallback[] = { | |||
| 156095 | 59, /* TIES => ID */ | 158172 | 59, /* TIES => ID */ |
| 156096 | 59, /* GENERATED => ID */ | 158173 | 59, /* GENERATED => ID */ |
| 156097 | 59, /* ALWAYS => ID */ | 158174 | 59, /* ALWAYS => ID */ |
| 158175 | 59, /* MATERIALIZED => ID */ | ||
| 156098 | 59, /* REINDEX => ID */ | 158176 | 59, /* REINDEX => ID */ |
| 156099 | 59, /* RENAME => ID */ | 158177 | 59, /* RENAME => ID */ |
| 156100 | 59, /* CTIME_KW => ID */ | 158178 | 59, /* CTIME_KW => ID */ |
| @@ -156146,6 +158224,7 @@ static const YYCODETYPE yyFallback[] = { | |||
| 156146 | 0, /* HAVING => nothing */ | 158224 | 0, /* HAVING => nothing */ |
| 156147 | 0, /* LIMIT => nothing */ | 158225 | 0, /* LIMIT => nothing */ |
| 156148 | 0, /* WHERE => nothing */ | 158226 | 0, /* WHERE => nothing */ |
| 158227 | 0, /* RETURNING => nothing */ | ||
| 156149 | 0, /* INTO => nothing */ | 158228 | 0, /* INTO => nothing */ |
| 156150 | 0, /* NOTHING => nothing */ | 158229 | 0, /* NOTHING => nothing */ |
| 156151 | 0, /* FLOAT => nothing */ | 158230 | 0, /* FLOAT => nothing */ |
| @@ -156364,219 +158443,225 @@ static const char *const yyTokenName[] = { | |||
| 156364 | /* 94 */ "TIES", | 158443 | /* 94 */ "TIES", |
| 156365 | /* 95 */ "GENERATED", | 158444 | /* 95 */ "GENERATED", |
| 156366 | /* 96 */ "ALWAYS", | 158445 | /* 96 */ "ALWAYS", |
| 156367 | /* 97 */ "REINDEX", | 158446 | /* 97 */ "MATERIALIZED", |
| 156368 | /* 98 */ "RENAME", | 158447 | /* 98 */ "REINDEX", |
| 156369 | /* 99 */ "CTIME_KW", | 158448 | /* 99 */ "RENAME", |
| 156370 | /* 100 */ "ANY", | 158449 | /* 100 */ "CTIME_KW", |
| 156371 | /* 101 */ "BITAND", | 158450 | /* 101 */ "ANY", |
| 156372 | /* 102 */ "BITOR", | 158451 | /* 102 */ "BITAND", |
| 156373 | /* 103 */ "LSHIFT", | 158452 | /* 103 */ "BITOR", |
| 156374 | /* 104 */ "RSHIFT", | 158453 | /* 104 */ "LSHIFT", |
| 156375 | /* 105 */ "PLUS", | 158454 | /* 105 */ "RSHIFT", |
| 156376 | /* 106 */ "MINUS", | 158455 | /* 106 */ "PLUS", |
| 156377 | /* 107 */ "STAR", | 158456 | /* 107 */ "MINUS", |
| 156378 | /* 108 */ "SLASH", | 158457 | /* 108 */ "STAR", |
| 156379 | /* 109 */ "REM", | 158458 | /* 109 */ "SLASH", |
| 156380 | /* 110 */ "CONCAT", | 158459 | /* 110 */ "REM", |
| 156381 | /* 111 */ "COLLATE", | 158460 | /* 111 */ "CONCAT", |
| 156382 | /* 112 */ "BITNOT", | 158461 | /* 112 */ "COLLATE", |
| 156383 | /* 113 */ "ON", | 158462 | /* 113 */ "BITNOT", |
| 156384 | /* 114 */ "INDEXED", | 158463 | /* 114 */ "ON", |
| 156385 | /* 115 */ "STRING", | 158464 | /* 115 */ "INDEXED", |
| 156386 | /* 116 */ "JOIN_KW", | 158465 | /* 116 */ "STRING", |
| 156387 | /* 117 */ "CONSTRAINT", | 158466 | /* 117 */ "JOIN_KW", |
| 156388 | /* 118 */ "DEFAULT", | 158467 | /* 118 */ "CONSTRAINT", |
| 156389 | /* 119 */ "NULL", | 158468 | /* 119 */ "DEFAULT", |
| 156390 | /* 120 */ "PRIMARY", | 158469 | /* 120 */ "NULL", |
| 156391 | /* 121 */ "UNIQUE", | 158470 | /* 121 */ "PRIMARY", |
| 156392 | /* 122 */ "CHECK", | 158471 | /* 122 */ "UNIQUE", |
| 156393 | /* 123 */ "REFERENCES", | 158472 | /* 123 */ "CHECK", |
| 156394 | /* 124 */ "AUTOINCR", | 158473 | /* 124 */ "REFERENCES", |
| 156395 | /* 125 */ "INSERT", | 158474 | /* 125 */ "AUTOINCR", |
| 156396 | /* 126 */ "DELETE", | 158475 | /* 126 */ "INSERT", |
| 156397 | /* 127 */ "UPDATE", | 158476 | /* 127 */ "DELETE", |
| 156398 | /* 128 */ "SET", | 158477 | /* 128 */ "UPDATE", |
| 156399 | /* 129 */ "DEFERRABLE", | 158478 | /* 129 */ "SET", |
| 156400 | /* 130 */ "FOREIGN", | 158479 | /* 130 */ "DEFERRABLE", |
| 156401 | /* 131 */ "DROP", | 158480 | /* 131 */ "FOREIGN", |
| 156402 | /* 132 */ "UNION", | 158481 | /* 132 */ "DROP", |
| 156403 | /* 133 */ "ALL", | 158482 | /* 133 */ "UNION", |
| 156404 | /* 134 */ "EXCEPT", | 158483 | /* 134 */ "ALL", |
| 156405 | /* 135 */ "INTERSECT", | 158484 | /* 135 */ "EXCEPT", |
| 156406 | /* 136 */ "SELECT", | 158485 | /* 136 */ "INTERSECT", |
| 156407 | /* 137 */ "VALUES", | 158486 | /* 137 */ "SELECT", |
| 156408 | /* 138 */ "DISTINCT", | 158487 | /* 138 */ "VALUES", |
| 156409 | /* 139 */ "DOT", | 158488 | /* 139 */ "DISTINCT", |
| 156410 | /* 140 */ "FROM", | 158489 | /* 140 */ "DOT", |
| 156411 | /* 141 */ "JOIN", | 158490 | /* 141 */ "FROM", |
| 156412 | /* 142 */ "USING", | 158491 | /* 142 */ "JOIN", |
| 156413 | /* 143 */ "ORDER", | 158492 | /* 143 */ "USING", |
| 156414 | /* 144 */ "GROUP", | 158493 | /* 144 */ "ORDER", |
| 156415 | /* 145 */ "HAVING", | 158494 | /* 145 */ "GROUP", |
| 156416 | /* 146 */ "LIMIT", | 158495 | /* 146 */ "HAVING", |
| 156417 | /* 147 */ "WHERE", | 158496 | /* 147 */ "LIMIT", |
| 156418 | /* 148 */ "INTO", | 158497 | /* 148 */ "WHERE", |
| 156419 | /* 149 */ "NOTHING", | 158498 | /* 149 */ "RETURNING", |
| 156420 | /* 150 */ "FLOAT", | 158499 | /* 150 */ "INTO", |
| 156421 | /* 151 */ "BLOB", | 158500 | /* 151 */ "NOTHING", |
| 156422 | /* 152 */ "INTEGER", | 158501 | /* 152 */ "FLOAT", |
| 156423 | /* 153 */ "VARIABLE", | 158502 | /* 153 */ "BLOB", |
| 156424 | /* 154 */ "CASE", | 158503 | /* 154 */ "INTEGER", |
| 156425 | /* 155 */ "WHEN", | 158504 | /* 155 */ "VARIABLE", |
| 156426 | /* 156 */ "THEN", | 158505 | /* 156 */ "CASE", |
| 156427 | /* 157 */ "ELSE", | 158506 | /* 157 */ "WHEN", |
| 156428 | /* 158 */ "INDEX", | 158507 | /* 158 */ "THEN", |
| 156429 | /* 159 */ "ALTER", | 158508 | /* 159 */ "ELSE", |
| 156430 | /* 160 */ "ADD", | 158509 | /* 160 */ "INDEX", |
| 156431 | /* 161 */ "WINDOW", | 158510 | /* 161 */ "ALTER", |
| 156432 | /* 162 */ "OVER", | 158511 | /* 162 */ "ADD", |
| 156433 | /* 163 */ "FILTER", | 158512 | /* 163 */ "WINDOW", |
| 156434 | /* 164 */ "COLUMN", | 158513 | /* 164 */ "OVER", |
| 156435 | /* 165 */ "AGG_FUNCTION", | 158514 | /* 165 */ "FILTER", |
| 156436 | /* 166 */ "AGG_COLUMN", | 158515 | /* 166 */ "COLUMN", |
| 156437 | /* 167 */ "TRUEFALSE", | 158516 | /* 167 */ "AGG_FUNCTION", |
| 156438 | /* 168 */ "ISNOT", | 158517 | /* 168 */ "AGG_COLUMN", |
| 156439 | /* 169 */ "FUNCTION", | 158518 | /* 169 */ "TRUEFALSE", |
| 156440 | /* 170 */ "UMINUS", | 158519 | /* 170 */ "ISNOT", |
| 156441 | /* 171 */ "UPLUS", | 158520 | /* 171 */ "FUNCTION", |
| 156442 | /* 172 */ "TRUTH", | 158521 | /* 172 */ "UMINUS", |
| 156443 | /* 173 */ "REGISTER", | 158522 | /* 173 */ "UPLUS", |
| 156444 | /* 174 */ "VECTOR", | 158523 | /* 174 */ "TRUTH", |
| 156445 | /* 175 */ "SELECT_COLUMN", | 158524 | /* 175 */ "REGISTER", |
| 156446 | /* 176 */ "IF_NULL_ROW", | 158525 | /* 176 */ "VECTOR", |
| 156447 | /* 177 */ "ASTERISK", | 158526 | /* 177 */ "SELECT_COLUMN", |
| 156448 | /* 178 */ "SPAN", | 158527 | /* 178 */ "IF_NULL_ROW", |
| 156449 | /* 179 */ "SPACE", | 158528 | /* 179 */ "ASTERISK", |
| 156450 | /* 180 */ "ILLEGAL", | 158529 | /* 180 */ "SPAN", |
| 156451 | /* 181 */ "input", | 158530 | /* 181 */ "SPACE", |
| 156452 | /* 182 */ "cmdlist", | 158531 | /* 182 */ "ILLEGAL", |
| 156453 | /* 183 */ "ecmd", | 158532 | /* 183 */ "input", |
| 156454 | /* 184 */ "cmdx", | 158533 | /* 184 */ "cmdlist", |
| 156455 | /* 185 */ "explain", | 158534 | /* 185 */ "ecmd", |
| 156456 | /* 186 */ "cmd", | 158535 | /* 186 */ "cmdx", |
| 156457 | /* 187 */ "transtype", | 158536 | /* 187 */ "explain", |
| 156458 | /* 188 */ "trans_opt", | 158537 | /* 188 */ "cmd", |
| 156459 | /* 189 */ "nm", | 158538 | /* 189 */ "transtype", |
| 156460 | /* 190 */ "savepoint_opt", | 158539 | /* 190 */ "trans_opt", |
| 156461 | /* 191 */ "create_table", | 158540 | /* 191 */ "nm", |
| 156462 | /* 192 */ "create_table_args", | 158541 | /* 192 */ "savepoint_opt", |
| 156463 | /* 193 */ "createkw", | 158542 | /* 193 */ "create_table", |
| 156464 | /* 194 */ "temp", | 158543 | /* 194 */ "create_table_args", |
| 156465 | /* 195 */ "ifnotexists", | 158544 | /* 195 */ "createkw", |
| 156466 | /* 196 */ "dbnm", | 158545 | /* 196 */ "temp", |
| 156467 | /* 197 */ "columnlist", | 158546 | /* 197 */ "ifnotexists", |
| 156468 | /* 198 */ "conslist_opt", | 158547 | /* 198 */ "dbnm", |
| 156469 | /* 199 */ "table_options", | 158548 | /* 199 */ "columnlist", |
| 156470 | /* 200 */ "select", | 158549 | /* 200 */ "conslist_opt", |
| 156471 | /* 201 */ "columnname", | 158550 | /* 201 */ "table_options", |
| 156472 | /* 202 */ "carglist", | 158551 | /* 202 */ "select", |
| 156473 | /* 203 */ "typetoken", | 158552 | /* 203 */ "columnname", |
| 156474 | /* 204 */ "typename", | 158553 | /* 204 */ "carglist", |
| 156475 | /* 205 */ "signed", | 158554 | /* 205 */ "typetoken", |
| 156476 | /* 206 */ "plus_num", | 158555 | /* 206 */ "typename", |
| 156477 | /* 207 */ "minus_num", | 158556 | /* 207 */ "signed", |
| 156478 | /* 208 */ "scanpt", | 158557 | /* 208 */ "plus_num", |
| 156479 | /* 209 */ "scantok", | 158558 | /* 209 */ "minus_num", |
| 156480 | /* 210 */ "ccons", | 158559 | /* 210 */ "scanpt", |
| 156481 | /* 211 */ "term", | 158560 | /* 211 */ "scantok", |
| 156482 | /* 212 */ "expr", | 158561 | /* 212 */ "ccons", |
| 156483 | /* 213 */ "onconf", | 158562 | /* 213 */ "term", |
| 156484 | /* 214 */ "sortorder", | 158563 | /* 214 */ "expr", |
| 156485 | /* 215 */ "autoinc", | 158564 | /* 215 */ "onconf", |
| 156486 | /* 216 */ "eidlist_opt", | 158565 | /* 216 */ "sortorder", |
| 156487 | /* 217 */ "refargs", | 158566 | /* 217 */ "autoinc", |
| 156488 | /* 218 */ "defer_subclause", | 158567 | /* 218 */ "eidlist_opt", |
| 156489 | /* 219 */ "generated", | 158568 | /* 219 */ "refargs", |
| 156490 | /* 220 */ "refarg", | 158569 | /* 220 */ "defer_subclause", |
| 156491 | /* 221 */ "refact", | 158570 | /* 221 */ "generated", |
| 156492 | /* 222 */ "init_deferred_pred_opt", | 158571 | /* 222 */ "refarg", |
| 156493 | /* 223 */ "conslist", | 158572 | /* 223 */ "refact", |
| 156494 | /* 224 */ "tconscomma", | 158573 | /* 224 */ "init_deferred_pred_opt", |
| 156495 | /* 225 */ "tcons", | 158574 | /* 225 */ "conslist", |
| 156496 | /* 226 */ "sortlist", | 158575 | /* 226 */ "tconscomma", |
| 156497 | /* 227 */ "eidlist", | 158576 | /* 227 */ "tcons", |
| 156498 | /* 228 */ "defer_subclause_opt", | 158577 | /* 228 */ "sortlist", |
| 156499 | /* 229 */ "orconf", | 158578 | /* 229 */ "eidlist", |
| 156500 | /* 230 */ "resolvetype", | 158579 | /* 230 */ "defer_subclause_opt", |
| 156501 | /* 231 */ "raisetype", | 158580 | /* 231 */ "orconf", |
| 156502 | /* 232 */ "ifexists", | 158581 | /* 232 */ "resolvetype", |
| 156503 | /* 233 */ "fullname", | 158582 | /* 233 */ "raisetype", |
| 156504 | /* 234 */ "selectnowith", | 158583 | /* 234 */ "ifexists", |
| 156505 | /* 235 */ "oneselect", | 158584 | /* 235 */ "fullname", |
| 156506 | /* 236 */ "wqlist", | 158585 | /* 236 */ "selectnowith", |
| 156507 | /* 237 */ "multiselect_op", | 158586 | /* 237 */ "oneselect", |
| 156508 | /* 238 */ "distinct", | 158587 | /* 238 */ "wqlist", |
| 156509 | /* 239 */ "selcollist", | 158588 | /* 239 */ "multiselect_op", |
| 156510 | /* 240 */ "from", | 158589 | /* 240 */ "distinct", |
| 156511 | /* 241 */ "where_opt", | 158590 | /* 241 */ "selcollist", |
| 156512 | /* 242 */ "groupby_opt", | 158591 | /* 242 */ "from", |
| 156513 | /* 243 */ "having_opt", | 158592 | /* 243 */ "where_opt", |
| 156514 | /* 244 */ "orderby_opt", | 158593 | /* 244 */ "groupby_opt", |
| 156515 | /* 245 */ "limit_opt", | 158594 | /* 245 */ "having_opt", |
| 156516 | /* 246 */ "window_clause", | 158595 | /* 246 */ "orderby_opt", |
| 156517 | /* 247 */ "values", | 158596 | /* 247 */ "limit_opt", |
| 156518 | /* 248 */ "nexprlist", | 158597 | /* 248 */ "window_clause", |
| 156519 | /* 249 */ "sclp", | 158598 | /* 249 */ "values", |
| 156520 | /* 250 */ "as", | 158599 | /* 250 */ "nexprlist", |
| 156521 | /* 251 */ "seltablist", | 158600 | /* 251 */ "sclp", |
| 156522 | /* 252 */ "stl_prefix", | 158601 | /* 252 */ "as", |
| 156523 | /* 253 */ "joinop", | 158602 | /* 253 */ "seltablist", |
| 156524 | /* 254 */ "indexed_opt", | 158603 | /* 254 */ "stl_prefix", |
| 156525 | /* 255 */ "on_opt", | 158604 | /* 255 */ "joinop", |
| 156526 | /* 256 */ "using_opt", | 158605 | /* 256 */ "indexed_opt", |
| 156527 | /* 257 */ "exprlist", | 158606 | /* 257 */ "on_opt", |
| 156528 | /* 258 */ "xfullname", | 158607 | /* 258 */ "using_opt", |
| 156529 | /* 259 */ "idlist", | 158608 | /* 259 */ "exprlist", |
| 156530 | /* 260 */ "nulls", | 158609 | /* 260 */ "xfullname", |
| 156531 | /* 261 */ "with", | 158610 | /* 261 */ "idlist", |
| 156532 | /* 262 */ "setlist", | 158611 | /* 262 */ "nulls", |
| 156533 | /* 263 */ "insert_cmd", | 158612 | /* 263 */ "with", |
| 156534 | /* 264 */ "idlist_opt", | 158613 | /* 264 */ "where_opt_ret", |
| 156535 | /* 265 */ "upsert", | 158614 | /* 265 */ "setlist", |
| 156536 | /* 266 */ "filter_over", | 158615 | /* 266 */ "insert_cmd", |
| 156537 | /* 267 */ "likeop", | 158616 | /* 267 */ "idlist_opt", |
| 156538 | /* 268 */ "between_op", | 158617 | /* 268 */ "upsert", |
| 156539 | /* 269 */ "in_op", | 158618 | /* 269 */ "returning", |
| 156540 | /* 270 */ "paren_exprlist", | 158619 | /* 270 */ "filter_over", |
| 156541 | /* 271 */ "case_operand", | 158620 | /* 271 */ "likeop", |
| 156542 | /* 272 */ "case_exprlist", | 158621 | /* 272 */ "between_op", |
| 156543 | /* 273 */ "case_else", | 158622 | /* 273 */ "in_op", |
| 156544 | /* 274 */ "uniqueflag", | 158623 | /* 274 */ "paren_exprlist", |
| 156545 | /* 275 */ "collate", | 158624 | /* 275 */ "case_operand", |
| 156546 | /* 276 */ "vinto", | 158625 | /* 276 */ "case_exprlist", |
| 156547 | /* 277 */ "nmnum", | 158626 | /* 277 */ "case_else", |
| 156548 | /* 278 */ "trigger_decl", | 158627 | /* 278 */ "uniqueflag", |
| 156549 | /* 279 */ "trigger_cmd_list", | 158628 | /* 279 */ "collate", |
| 156550 | /* 280 */ "trigger_time", | 158629 | /* 280 */ "vinto", |
| 156551 | /* 281 */ "trigger_event", | 158630 | /* 281 */ "nmnum", |
| 156552 | /* 282 */ "foreach_clause", | 158631 | /* 282 */ "trigger_decl", |
| 156553 | /* 283 */ "when_clause", | 158632 | /* 283 */ "trigger_cmd_list", |
| 156554 | /* 284 */ "trigger_cmd", | 158633 | /* 284 */ "trigger_time", |
| 156555 | /* 285 */ "trnm", | 158634 | /* 285 */ "trigger_event", |
| 156556 | /* 286 */ "tridxby", | 158635 | /* 286 */ "foreach_clause", |
| 156557 | /* 287 */ "database_kw_opt", | 158636 | /* 287 */ "when_clause", |
| 156558 | /* 288 */ "key_opt", | 158637 | /* 288 */ "trigger_cmd", |
| 156559 | /* 289 */ "add_column_fullname", | 158638 | /* 289 */ "trnm", |
| 156560 | /* 290 */ "kwcolumn_opt", | 158639 | /* 290 */ "tridxby", |
| 156561 | /* 291 */ "create_vtab", | 158640 | /* 291 */ "database_kw_opt", |
| 156562 | /* 292 */ "vtabarglist", | 158641 | /* 292 */ "key_opt", |
| 156563 | /* 293 */ "vtabarg", | 158642 | /* 293 */ "add_column_fullname", |
| 156564 | /* 294 */ "vtabargtoken", | 158643 | /* 294 */ "kwcolumn_opt", |
| 156565 | /* 295 */ "lp", | 158644 | /* 295 */ "create_vtab", |
| 156566 | /* 296 */ "anylist", | 158645 | /* 296 */ "vtabarglist", |
| 156567 | /* 297 */ "windowdefn_list", | 158646 | /* 297 */ "vtabarg", |
| 156568 | /* 298 */ "windowdefn", | 158647 | /* 298 */ "vtabargtoken", |
| 156569 | /* 299 */ "window", | 158648 | /* 299 */ "lp", |
| 156570 | /* 300 */ "frame_opt", | 158649 | /* 300 */ "anylist", |
| 156571 | /* 301 */ "part_opt", | 158650 | /* 301 */ "wqitem", |
| 156572 | /* 302 */ "filter_clause", | 158651 | /* 302 */ "wqas", |
| 156573 | /* 303 */ "over_clause", | 158652 | /* 303 */ "windowdefn_list", |
| 156574 | /* 304 */ "range_or_rows", | 158653 | /* 304 */ "windowdefn", |
| 156575 | /* 305 */ "frame_bound", | 158654 | /* 305 */ "window", |
| 156576 | /* 306 */ "frame_bound_s", | 158655 | /* 306 */ "frame_opt", |
| 156577 | /* 307 */ "frame_bound_e", | 158656 | /* 307 */ "part_opt", |
| 156578 | /* 308 */ "frame_exclude_opt", | 158657 | /* 308 */ "filter_clause", |
| 156579 | /* 309 */ "frame_exclude", | 158658 | /* 309 */ "over_clause", |
| 158659 | /* 310 */ "range_or_rows", | ||
| 158660 | /* 311 */ "frame_bound", | ||
| 158661 | /* 312 */ "frame_bound_s", | ||
| 158662 | /* 313 */ "frame_bound_e", | ||
| 158663 | /* 314 */ "frame_exclude_opt", | ||
| 158664 | /* 315 */ "frame_exclude", | ||
| 156580 | }; | 158665 | }; |
| 156581 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ | 158666 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ |
| 156582 | 158667 | ||
| @@ -156732,243 +158817,256 @@ static const char *const yyRuleName[] = { | |||
| 156732 | /* 145 */ "limit_opt ::= LIMIT expr", | 158817 | /* 145 */ "limit_opt ::= LIMIT expr", |
| 156733 | /* 146 */ "limit_opt ::= LIMIT expr OFFSET expr", | 158818 | /* 146 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 156734 | /* 147 */ "limit_opt ::= LIMIT expr COMMA expr", | 158819 | /* 147 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 156735 | /* 148 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt", | 158820 | /* 148 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret", |
| 156736 | /* 149 */ "where_opt ::=", | 158821 | /* 149 */ "where_opt ::=", |
| 156737 | /* 150 */ "where_opt ::= WHERE expr", | 158822 | /* 150 */ "where_opt ::= WHERE expr", |
| 156738 | /* 151 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt", | 158823 | /* 151 */ "where_opt_ret ::=", |
| 156739 | /* 152 */ "setlist ::= setlist COMMA nm EQ expr", | 158824 | /* 152 */ "where_opt_ret ::= WHERE expr", |
| 156740 | /* 153 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", | 158825 | /* 153 */ "where_opt_ret ::= RETURNING selcollist", |
| 156741 | /* 154 */ "setlist ::= nm EQ expr", | 158826 | /* 154 */ "where_opt_ret ::= WHERE expr RETURNING selcollist", |
| 156742 | /* 155 */ "setlist ::= LP idlist RP EQ expr", | 158827 | /* 155 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret", |
| 156743 | /* 156 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert", | 158828 | /* 156 */ "setlist ::= setlist COMMA nm EQ expr", |
| 156744 | /* 157 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES", | 158829 | /* 157 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", |
| 156745 | /* 158 */ "upsert ::=", | 158830 | /* 158 */ "setlist ::= nm EQ expr", |
| 156746 | /* 159 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt", | 158831 | /* 159 */ "setlist ::= LP idlist RP EQ expr", |
| 156747 | /* 160 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING", | 158832 | /* 160 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert", |
| 156748 | /* 161 */ "upsert ::= ON CONFLICT DO NOTHING", | 158833 | /* 161 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning", |
| 156749 | /* 162 */ "insert_cmd ::= INSERT orconf", | 158834 | /* 162 */ "upsert ::=", |
| 156750 | /* 163 */ "insert_cmd ::= REPLACE", | 158835 | /* 163 */ "upsert ::= RETURNING selcollist", |
| 156751 | /* 164 */ "idlist_opt ::=", | 158836 | /* 164 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert", |
| 156752 | /* 165 */ "idlist_opt ::= LP idlist RP", | 158837 | /* 165 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert", |
| 156753 | /* 166 */ "idlist ::= idlist COMMA nm", | 158838 | /* 166 */ "upsert ::= ON CONFLICT DO NOTHING returning", |
| 156754 | /* 167 */ "idlist ::= nm", | 158839 | /* 167 */ "upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning", |
| 156755 | /* 168 */ "expr ::= LP expr RP", | 158840 | /* 168 */ "returning ::= RETURNING selcollist", |
| 156756 | /* 169 */ "expr ::= ID|INDEXED", | 158841 | /* 169 */ "insert_cmd ::= INSERT orconf", |
| 156757 | /* 170 */ "expr ::= JOIN_KW", | 158842 | /* 170 */ "insert_cmd ::= REPLACE", |
| 156758 | /* 171 */ "expr ::= nm DOT nm", | 158843 | /* 171 */ "idlist_opt ::=", |
| 156759 | /* 172 */ "expr ::= nm DOT nm DOT nm", | 158844 | /* 172 */ "idlist_opt ::= LP idlist RP", |
| 156760 | /* 173 */ "term ::= NULL|FLOAT|BLOB", | 158845 | /* 173 */ "idlist ::= idlist COMMA nm", |
| 156761 | /* 174 */ "term ::= STRING", | 158846 | /* 174 */ "idlist ::= nm", |
| 156762 | /* 175 */ "term ::= INTEGER", | 158847 | /* 175 */ "expr ::= LP expr RP", |
| 156763 | /* 176 */ "expr ::= VARIABLE", | 158848 | /* 176 */ "expr ::= ID|INDEXED", |
| 156764 | /* 177 */ "expr ::= expr COLLATE ID|STRING", | 158849 | /* 177 */ "expr ::= JOIN_KW", |
| 156765 | /* 178 */ "expr ::= CAST LP expr AS typetoken RP", | 158850 | /* 178 */ "expr ::= nm DOT nm", |
| 156766 | /* 179 */ "expr ::= ID|INDEXED LP distinct exprlist RP", | 158851 | /* 179 */ "expr ::= nm DOT nm DOT nm", |
| 156767 | /* 180 */ "expr ::= ID|INDEXED LP STAR RP", | 158852 | /* 180 */ "term ::= NULL|FLOAT|BLOB", |
| 156768 | /* 181 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over", | 158853 | /* 181 */ "term ::= STRING", |
| 156769 | /* 182 */ "expr ::= ID|INDEXED LP STAR RP filter_over", | 158854 | /* 182 */ "term ::= INTEGER", |
| 156770 | /* 183 */ "term ::= CTIME_KW", | 158855 | /* 183 */ "expr ::= VARIABLE", |
| 156771 | /* 184 */ "expr ::= LP nexprlist COMMA expr RP", | 158856 | /* 184 */ "expr ::= expr COLLATE ID|STRING", |
| 156772 | /* 185 */ "expr ::= expr AND expr", | 158857 | /* 185 */ "expr ::= CAST LP expr AS typetoken RP", |
| 156773 | /* 186 */ "expr ::= expr OR expr", | 158858 | /* 186 */ "expr ::= ID|INDEXED LP distinct exprlist RP", |
| 156774 | /* 187 */ "expr ::= expr LT|GT|GE|LE expr", | 158859 | /* 187 */ "expr ::= ID|INDEXED LP STAR RP", |
| 156775 | /* 188 */ "expr ::= expr EQ|NE expr", | 158860 | /* 188 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over", |
| 156776 | /* 189 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", | 158861 | /* 189 */ "expr ::= ID|INDEXED LP STAR RP filter_over", |
| 156777 | /* 190 */ "expr ::= expr PLUS|MINUS expr", | 158862 | /* 190 */ "term ::= CTIME_KW", |
| 156778 | /* 191 */ "expr ::= expr STAR|SLASH|REM expr", | 158863 | /* 191 */ "expr ::= LP nexprlist COMMA expr RP", |
| 156779 | /* 192 */ "expr ::= expr CONCAT expr", | 158864 | /* 192 */ "expr ::= expr AND expr", |
| 156780 | /* 193 */ "likeop ::= NOT LIKE_KW|MATCH", | 158865 | /* 193 */ "expr ::= expr OR expr", |
| 156781 | /* 194 */ "expr ::= expr likeop expr", | 158866 | /* 194 */ "expr ::= expr LT|GT|GE|LE expr", |
| 156782 | /* 195 */ "expr ::= expr likeop expr ESCAPE expr", | 158867 | /* 195 */ "expr ::= expr EQ|NE expr", |
| 156783 | /* 196 */ "expr ::= expr ISNULL|NOTNULL", | 158868 | /* 196 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 156784 | /* 197 */ "expr ::= expr NOT NULL", | 158869 | /* 197 */ "expr ::= expr PLUS|MINUS expr", |
| 156785 | /* 198 */ "expr ::= expr IS expr", | 158870 | /* 198 */ "expr ::= expr STAR|SLASH|REM expr", |
| 156786 | /* 199 */ "expr ::= expr IS NOT expr", | 158871 | /* 199 */ "expr ::= expr CONCAT expr", |
| 156787 | /* 200 */ "expr ::= NOT expr", | 158872 | /* 200 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 156788 | /* 201 */ "expr ::= BITNOT expr", | 158873 | /* 201 */ "expr ::= expr likeop expr", |
| 156789 | /* 202 */ "expr ::= PLUS|MINUS expr", | 158874 | /* 202 */ "expr ::= expr likeop expr ESCAPE expr", |
| 156790 | /* 203 */ "between_op ::= BETWEEN", | 158875 | /* 203 */ "expr ::= expr ISNULL|NOTNULL", |
| 156791 | /* 204 */ "between_op ::= NOT BETWEEN", | 158876 | /* 204 */ "expr ::= expr NOT NULL", |
| 156792 | /* 205 */ "expr ::= expr between_op expr AND expr", | 158877 | /* 205 */ "expr ::= expr IS expr", |
| 156793 | /* 206 */ "in_op ::= IN", | 158878 | /* 206 */ "expr ::= expr IS NOT expr", |
| 156794 | /* 207 */ "in_op ::= NOT IN", | 158879 | /* 207 */ "expr ::= NOT expr", |
| 156795 | /* 208 */ "expr ::= expr in_op LP exprlist RP", | 158880 | /* 208 */ "expr ::= BITNOT expr", |
| 156796 | /* 209 */ "expr ::= LP select RP", | 158881 | /* 209 */ "expr ::= PLUS|MINUS expr", |
| 156797 | /* 210 */ "expr ::= expr in_op LP select RP", | 158882 | /* 210 */ "between_op ::= BETWEEN", |
| 156798 | /* 211 */ "expr ::= expr in_op nm dbnm paren_exprlist", | 158883 | /* 211 */ "between_op ::= NOT BETWEEN", |
| 156799 | /* 212 */ "expr ::= EXISTS LP select RP", | 158884 | /* 212 */ "expr ::= expr between_op expr AND expr", |
| 156800 | /* 213 */ "expr ::= CASE case_operand case_exprlist case_else END", | 158885 | /* 213 */ "in_op ::= IN", |
| 156801 | /* 214 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", | 158886 | /* 214 */ "in_op ::= NOT IN", |
| 156802 | /* 215 */ "case_exprlist ::= WHEN expr THEN expr", | 158887 | /* 215 */ "expr ::= expr in_op LP exprlist RP", |
| 156803 | /* 216 */ "case_else ::= ELSE expr", | 158888 | /* 216 */ "expr ::= LP select RP", |
| 156804 | /* 217 */ "case_else ::=", | 158889 | /* 217 */ "expr ::= expr in_op LP select RP", |
| 156805 | /* 218 */ "case_operand ::= expr", | 158890 | /* 218 */ "expr ::= expr in_op nm dbnm paren_exprlist", |
| 156806 | /* 219 */ "case_operand ::=", | 158891 | /* 219 */ "expr ::= EXISTS LP select RP", |
| 156807 | /* 220 */ "exprlist ::=", | 158892 | /* 220 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 156808 | /* 221 */ "nexprlist ::= nexprlist COMMA expr", | 158893 | /* 221 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 156809 | /* 222 */ "nexprlist ::= expr", | 158894 | /* 222 */ "case_exprlist ::= WHEN expr THEN expr", |
| 156810 | /* 223 */ "paren_exprlist ::=", | 158895 | /* 223 */ "case_else ::= ELSE expr", |
| 156811 | /* 224 */ "paren_exprlist ::= LP exprlist RP", | 158896 | /* 224 */ "case_else ::=", |
| 156812 | /* 225 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", | 158897 | /* 225 */ "case_operand ::= expr", |
| 156813 | /* 226 */ "uniqueflag ::= UNIQUE", | 158898 | /* 226 */ "case_operand ::=", |
| 156814 | /* 227 */ "uniqueflag ::=", | 158899 | /* 227 */ "exprlist ::=", |
| 156815 | /* 228 */ "eidlist_opt ::=", | 158900 | /* 228 */ "nexprlist ::= nexprlist COMMA expr", |
| 156816 | /* 229 */ "eidlist_opt ::= LP eidlist RP", | 158901 | /* 229 */ "nexprlist ::= expr", |
| 156817 | /* 230 */ "eidlist ::= eidlist COMMA nm collate sortorder", | 158902 | /* 230 */ "paren_exprlist ::=", |
| 156818 | /* 231 */ "eidlist ::= nm collate sortorder", | 158903 | /* 231 */ "paren_exprlist ::= LP exprlist RP", |
| 156819 | /* 232 */ "collate ::=", | 158904 | /* 232 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 156820 | /* 233 */ "collate ::= COLLATE ID|STRING", | 158905 | /* 233 */ "uniqueflag ::= UNIQUE", |
| 156821 | /* 234 */ "cmd ::= DROP INDEX ifexists fullname", | 158906 | /* 234 */ "uniqueflag ::=", |
| 156822 | /* 235 */ "cmd ::= VACUUM vinto", | 158907 | /* 235 */ "eidlist_opt ::=", |
| 156823 | /* 236 */ "cmd ::= VACUUM nm vinto", | 158908 | /* 236 */ "eidlist_opt ::= LP eidlist RP", |
| 156824 | /* 237 */ "vinto ::= INTO expr", | 158909 | /* 237 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 156825 | /* 238 */ "vinto ::=", | 158910 | /* 238 */ "eidlist ::= nm collate sortorder", |
| 156826 | /* 239 */ "cmd ::= PRAGMA nm dbnm", | 158911 | /* 239 */ "collate ::=", |
| 156827 | /* 240 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", | 158912 | /* 240 */ "collate ::= COLLATE ID|STRING", |
| 156828 | /* 241 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", | 158913 | /* 241 */ "cmd ::= DROP INDEX ifexists fullname", |
| 156829 | /* 242 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", | 158914 | /* 242 */ "cmd ::= VACUUM vinto", |
| 156830 | /* 243 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", | 158915 | /* 243 */ "cmd ::= VACUUM nm vinto", |
| 156831 | /* 244 */ "plus_num ::= PLUS INTEGER|FLOAT", | 158916 | /* 244 */ "vinto ::= INTO expr", |
| 156832 | /* 245 */ "minus_num ::= MINUS INTEGER|FLOAT", | 158917 | /* 245 */ "vinto ::=", |
| 156833 | /* 246 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", | 158918 | /* 246 */ "cmd ::= PRAGMA nm dbnm", |
| 156834 | /* 247 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", | 158919 | /* 247 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 156835 | /* 248 */ "trigger_time ::= BEFORE|AFTER", | 158920 | /* 248 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 156836 | /* 249 */ "trigger_time ::= INSTEAD OF", | 158921 | /* 249 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 156837 | /* 250 */ "trigger_time ::=", | 158922 | /* 250 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 156838 | /* 251 */ "trigger_event ::= DELETE|INSERT", | 158923 | /* 251 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 156839 | /* 252 */ "trigger_event ::= UPDATE", | 158924 | /* 252 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 156840 | /* 253 */ "trigger_event ::= UPDATE OF idlist", | 158925 | /* 253 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 156841 | /* 254 */ "when_clause ::=", | 158926 | /* 254 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 156842 | /* 255 */ "when_clause ::= WHEN expr", | 158927 | /* 255 */ "trigger_time ::= BEFORE|AFTER", |
| 156843 | /* 256 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", | 158928 | /* 256 */ "trigger_time ::= INSTEAD OF", |
| 156844 | /* 257 */ "trigger_cmd_list ::= trigger_cmd SEMI", | 158929 | /* 257 */ "trigger_time ::=", |
| 156845 | /* 258 */ "trnm ::= nm DOT nm", | 158930 | /* 258 */ "trigger_event ::= DELETE|INSERT", |
| 156846 | /* 259 */ "tridxby ::= INDEXED BY nm", | 158931 | /* 259 */ "trigger_event ::= UPDATE", |
| 156847 | /* 260 */ "tridxby ::= NOT INDEXED", | 158932 | /* 260 */ "trigger_event ::= UPDATE OF idlist", |
| 156848 | /* 261 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", | 158933 | /* 261 */ "when_clause ::=", |
| 156849 | /* 262 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", | 158934 | /* 262 */ "when_clause ::= WHEN expr", |
| 156850 | /* 263 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", | 158935 | /* 263 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 156851 | /* 264 */ "trigger_cmd ::= scanpt select scanpt", | 158936 | /* 264 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 156852 | /* 265 */ "expr ::= RAISE LP IGNORE RP", | 158937 | /* 265 */ "trnm ::= nm DOT nm", |
| 156853 | /* 266 */ "expr ::= RAISE LP raisetype COMMA nm RP", | 158938 | /* 266 */ "tridxby ::= INDEXED BY nm", |
| 156854 | /* 267 */ "raisetype ::= ROLLBACK", | 158939 | /* 267 */ "tridxby ::= NOT INDEXED", |
| 156855 | /* 268 */ "raisetype ::= ABORT", | 158940 | /* 268 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 156856 | /* 269 */ "raisetype ::= FAIL", | 158941 | /* 269 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 156857 | /* 270 */ "cmd ::= DROP TRIGGER ifexists fullname", | 158942 | /* 270 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 156858 | /* 271 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", | 158943 | /* 271 */ "trigger_cmd ::= scanpt select scanpt", |
| 156859 | /* 272 */ "cmd ::= DETACH database_kw_opt expr", | 158944 | /* 272 */ "expr ::= RAISE LP IGNORE RP", |
| 156860 | /* 273 */ "key_opt ::=", | 158945 | /* 273 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 156861 | /* 274 */ "key_opt ::= KEY expr", | 158946 | /* 274 */ "raisetype ::= ROLLBACK", |
| 156862 | /* 275 */ "cmd ::= REINDEX", | 158947 | /* 275 */ "raisetype ::= ABORT", |
| 156863 | /* 276 */ "cmd ::= REINDEX nm dbnm", | 158948 | /* 276 */ "raisetype ::= FAIL", |
| 156864 | /* 277 */ "cmd ::= ANALYZE", | 158949 | /* 277 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 156865 | /* 278 */ "cmd ::= ANALYZE nm dbnm", | 158950 | /* 278 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 156866 | /* 279 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", | 158951 | /* 279 */ "cmd ::= DETACH database_kw_opt expr", |
| 156867 | /* 280 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", | 158952 | /* 280 */ "key_opt ::=", |
| 156868 | /* 281 */ "add_column_fullname ::= fullname", | 158953 | /* 281 */ "key_opt ::= KEY expr", |
| 156869 | /* 282 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", | 158954 | /* 282 */ "cmd ::= REINDEX", |
| 156870 | /* 283 */ "cmd ::= create_vtab", | 158955 | /* 283 */ "cmd ::= REINDEX nm dbnm", |
| 156871 | /* 284 */ "cmd ::= create_vtab LP vtabarglist RP", | 158956 | /* 284 */ "cmd ::= ANALYZE", |
| 156872 | /* 285 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", | 158957 | /* 285 */ "cmd ::= ANALYZE nm dbnm", |
| 156873 | /* 286 */ "vtabarg ::=", | 158958 | /* 286 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 156874 | /* 287 */ "vtabargtoken ::= ANY", | 158959 | /* 287 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 156875 | /* 288 */ "vtabargtoken ::= lp anylist RP", | 158960 | /* 288 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", |
| 156876 | /* 289 */ "lp ::= LP", | 158961 | /* 289 */ "add_column_fullname ::= fullname", |
| 156877 | /* 290 */ "with ::= WITH wqlist", | 158962 | /* 290 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", |
| 156878 | /* 291 */ "with ::= WITH RECURSIVE wqlist", | 158963 | /* 291 */ "cmd ::= create_vtab", |
| 156879 | /* 292 */ "wqlist ::= nm eidlist_opt AS LP select RP", | 158964 | /* 292 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 156880 | /* 293 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", | 158965 | /* 293 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 156881 | /* 294 */ "windowdefn_list ::= windowdefn", | 158966 | /* 294 */ "vtabarg ::=", |
| 156882 | /* 295 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", | 158967 | /* 295 */ "vtabargtoken ::= ANY", |
| 156883 | /* 296 */ "windowdefn ::= nm AS LP window RP", | 158968 | /* 296 */ "vtabargtoken ::= lp anylist RP", |
| 156884 | /* 297 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", | 158969 | /* 297 */ "lp ::= LP", |
| 156885 | /* 298 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", | 158970 | /* 298 */ "with ::= WITH wqlist", |
| 156886 | /* 299 */ "window ::= ORDER BY sortlist frame_opt", | 158971 | /* 299 */ "with ::= WITH RECURSIVE wqlist", |
| 156887 | /* 300 */ "window ::= nm ORDER BY sortlist frame_opt", | 158972 | /* 300 */ "wqas ::= AS", |
| 156888 | /* 301 */ "window ::= frame_opt", | 158973 | /* 301 */ "wqas ::= AS MATERIALIZED", |
| 156889 | /* 302 */ "window ::= nm frame_opt", | 158974 | /* 302 */ "wqas ::= AS NOT MATERIALIZED", |
| 156890 | /* 303 */ "frame_opt ::=", | 158975 | /* 303 */ "wqitem ::= nm eidlist_opt wqas LP select RP", |
| 156891 | /* 304 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", | 158976 | /* 304 */ "wqlist ::= wqitem", |
| 156892 | /* 305 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", | 158977 | /* 305 */ "wqlist ::= wqlist COMMA wqitem", |
| 156893 | /* 306 */ "range_or_rows ::= RANGE|ROWS|GROUPS", | 158978 | /* 306 */ "windowdefn_list ::= windowdefn", |
| 156894 | /* 307 */ "frame_bound_s ::= frame_bound", | 158979 | /* 307 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", |
| 156895 | /* 308 */ "frame_bound_s ::= UNBOUNDED PRECEDING", | 158980 | /* 308 */ "windowdefn ::= nm AS LP window RP", |
| 156896 | /* 309 */ "frame_bound_e ::= frame_bound", | 158981 | /* 309 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", |
| 156897 | /* 310 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", | 158982 | /* 310 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", |
| 156898 | /* 311 */ "frame_bound ::= expr PRECEDING|FOLLOWING", | 158983 | /* 311 */ "window ::= ORDER BY sortlist frame_opt", |
| 156899 | /* 312 */ "frame_bound ::= CURRENT ROW", | 158984 | /* 312 */ "window ::= nm ORDER BY sortlist frame_opt", |
| 156900 | /* 313 */ "frame_exclude_opt ::=", | 158985 | /* 313 */ "window ::= frame_opt", |
| 156901 | /* 314 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", | 158986 | /* 314 */ "window ::= nm frame_opt", |
| 156902 | /* 315 */ "frame_exclude ::= NO OTHERS", | 158987 | /* 315 */ "frame_opt ::=", |
| 156903 | /* 316 */ "frame_exclude ::= CURRENT ROW", | 158988 | /* 316 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", |
| 156904 | /* 317 */ "frame_exclude ::= GROUP|TIES", | 158989 | /* 317 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", |
| 156905 | /* 318 */ "window_clause ::= WINDOW windowdefn_list", | 158990 | /* 318 */ "range_or_rows ::= RANGE|ROWS|GROUPS", |
| 156906 | /* 319 */ "filter_over ::= filter_clause over_clause", | 158991 | /* 319 */ "frame_bound_s ::= frame_bound", |
| 156907 | /* 320 */ "filter_over ::= over_clause", | 158992 | /* 320 */ "frame_bound_s ::= UNBOUNDED PRECEDING", |
| 156908 | /* 321 */ "filter_over ::= filter_clause", | 158993 | /* 321 */ "frame_bound_e ::= frame_bound", |
| 156909 | /* 322 */ "over_clause ::= OVER LP window RP", | 158994 | /* 322 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", |
| 156910 | /* 323 */ "over_clause ::= OVER nm", | 158995 | /* 323 */ "frame_bound ::= expr PRECEDING|FOLLOWING", |
| 156911 | /* 324 */ "filter_clause ::= FILTER LP WHERE expr RP", | 158996 | /* 324 */ "frame_bound ::= CURRENT ROW", |
| 156912 | /* 325 */ "input ::= cmdlist", | 158997 | /* 325 */ "frame_exclude_opt ::=", |
| 156913 | /* 326 */ "cmdlist ::= cmdlist ecmd", | 158998 | /* 326 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", |
| 156914 | /* 327 */ "cmdlist ::= ecmd", | 158999 | /* 327 */ "frame_exclude ::= NO OTHERS", |
| 156915 | /* 328 */ "ecmd ::= SEMI", | 159000 | /* 328 */ "frame_exclude ::= CURRENT ROW", |
| 156916 | /* 329 */ "ecmd ::= cmdx SEMI", | 159001 | /* 329 */ "frame_exclude ::= GROUP|TIES", |
| 156917 | /* 330 */ "ecmd ::= explain cmdx SEMI", | 159002 | /* 330 */ "window_clause ::= WINDOW windowdefn_list", |
| 156918 | /* 331 */ "trans_opt ::=", | 159003 | /* 331 */ "filter_over ::= filter_clause over_clause", |
| 156919 | /* 332 */ "trans_opt ::= TRANSACTION", | 159004 | /* 332 */ "filter_over ::= over_clause", |
| 156920 | /* 333 */ "trans_opt ::= TRANSACTION nm", | 159005 | /* 333 */ "filter_over ::= filter_clause", |
| 156921 | /* 334 */ "savepoint_opt ::= SAVEPOINT", | 159006 | /* 334 */ "over_clause ::= OVER LP window RP", |
| 156922 | /* 335 */ "savepoint_opt ::=", | 159007 | /* 335 */ "over_clause ::= OVER nm", |
| 156923 | /* 336 */ "cmd ::= create_table create_table_args", | 159008 | /* 336 */ "filter_clause ::= FILTER LP WHERE expr RP", |
| 156924 | /* 337 */ "columnlist ::= columnlist COMMA columnname carglist", | 159009 | /* 337 */ "input ::= cmdlist", |
| 156925 | /* 338 */ "columnlist ::= columnname carglist", | 159010 | /* 338 */ "cmdlist ::= cmdlist ecmd", |
| 156926 | /* 339 */ "nm ::= ID|INDEXED", | 159011 | /* 339 */ "cmdlist ::= ecmd", |
| 156927 | /* 340 */ "nm ::= STRING", | 159012 | /* 340 */ "ecmd ::= SEMI", |
| 156928 | /* 341 */ "nm ::= JOIN_KW", | 159013 | /* 341 */ "ecmd ::= cmdx SEMI", |
| 156929 | /* 342 */ "typetoken ::= typename", | 159014 | /* 342 */ "ecmd ::= explain cmdx SEMI", |
| 156930 | /* 343 */ "typename ::= ID|STRING", | 159015 | /* 343 */ "trans_opt ::=", |
| 156931 | /* 344 */ "signed ::= plus_num", | 159016 | /* 344 */ "trans_opt ::= TRANSACTION", |
| 156932 | /* 345 */ "signed ::= minus_num", | 159017 | /* 345 */ "trans_opt ::= TRANSACTION nm", |
| 156933 | /* 346 */ "carglist ::= carglist ccons", | 159018 | /* 346 */ "savepoint_opt ::= SAVEPOINT", |
| 156934 | /* 347 */ "carglist ::=", | 159019 | /* 347 */ "savepoint_opt ::=", |
| 156935 | /* 348 */ "ccons ::= NULL onconf", | 159020 | /* 348 */ "cmd ::= create_table create_table_args", |
| 156936 | /* 349 */ "ccons ::= GENERATED ALWAYS AS generated", | 159021 | /* 349 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 156937 | /* 350 */ "ccons ::= AS generated", | 159022 | /* 350 */ "columnlist ::= columnname carglist", |
| 156938 | /* 351 */ "conslist_opt ::= COMMA conslist", | 159023 | /* 351 */ "nm ::= ID|INDEXED", |
| 156939 | /* 352 */ "conslist ::= conslist tconscomma tcons", | 159024 | /* 352 */ "nm ::= STRING", |
| 156940 | /* 353 */ "conslist ::= tcons", | 159025 | /* 353 */ "nm ::= JOIN_KW", |
| 156941 | /* 354 */ "tconscomma ::=", | 159026 | /* 354 */ "typetoken ::= typename", |
| 156942 | /* 355 */ "defer_subclause_opt ::= defer_subclause", | 159027 | /* 355 */ "typename ::= ID|STRING", |
| 156943 | /* 356 */ "resolvetype ::= raisetype", | 159028 | /* 356 */ "signed ::= plus_num", |
| 156944 | /* 357 */ "selectnowith ::= oneselect", | 159029 | /* 357 */ "signed ::= minus_num", |
| 156945 | /* 358 */ "oneselect ::= values", | 159030 | /* 358 */ "carglist ::= carglist ccons", |
| 156946 | /* 359 */ "sclp ::= selcollist COMMA", | 159031 | /* 359 */ "carglist ::=", |
| 156947 | /* 360 */ "as ::= ID|STRING", | 159032 | /* 360 */ "ccons ::= NULL onconf", |
| 156948 | /* 361 */ "expr ::= term", | 159033 | /* 361 */ "ccons ::= GENERATED ALWAYS AS generated", |
| 156949 | /* 362 */ "likeop ::= LIKE_KW|MATCH", | 159034 | /* 362 */ "ccons ::= AS generated", |
| 156950 | /* 363 */ "exprlist ::= nexprlist", | 159035 | /* 363 */ "conslist_opt ::= COMMA conslist", |
| 156951 | /* 364 */ "nmnum ::= plus_num", | 159036 | /* 364 */ "conslist ::= conslist tconscomma tcons", |
| 156952 | /* 365 */ "nmnum ::= nm", | 159037 | /* 365 */ "conslist ::= tcons", |
| 156953 | /* 366 */ "nmnum ::= ON", | 159038 | /* 366 */ "tconscomma ::=", |
| 156954 | /* 367 */ "nmnum ::= DELETE", | 159039 | /* 367 */ "defer_subclause_opt ::= defer_subclause", |
| 156955 | /* 368 */ "nmnum ::= DEFAULT", | 159040 | /* 368 */ "resolvetype ::= raisetype", |
| 156956 | /* 369 */ "plus_num ::= INTEGER|FLOAT", | 159041 | /* 369 */ "selectnowith ::= oneselect", |
| 156957 | /* 370 */ "foreach_clause ::=", | 159042 | /* 370 */ "oneselect ::= values", |
| 156958 | /* 371 */ "foreach_clause ::= FOR EACH ROW", | 159043 | /* 371 */ "sclp ::= selcollist COMMA", |
| 156959 | /* 372 */ "trnm ::= nm", | 159044 | /* 372 */ "as ::= ID|STRING", |
| 156960 | /* 373 */ "tridxby ::=", | 159045 | /* 373 */ "returning ::=", |
| 156961 | /* 374 */ "database_kw_opt ::= DATABASE", | 159046 | /* 374 */ "expr ::= term", |
| 156962 | /* 375 */ "database_kw_opt ::=", | 159047 | /* 375 */ "likeop ::= LIKE_KW|MATCH", |
| 156963 | /* 376 */ "kwcolumn_opt ::=", | 159048 | /* 376 */ "exprlist ::= nexprlist", |
| 156964 | /* 377 */ "kwcolumn_opt ::= COLUMNKW", | 159049 | /* 377 */ "nmnum ::= plus_num", |
| 156965 | /* 378 */ "vtabarglist ::= vtabarg", | 159050 | /* 378 */ "nmnum ::= nm", |
| 156966 | /* 379 */ "vtabarglist ::= vtabarglist COMMA vtabarg", | 159051 | /* 379 */ "nmnum ::= ON", |
| 156967 | /* 380 */ "vtabarg ::= vtabarg vtabargtoken", | 159052 | /* 380 */ "nmnum ::= DELETE", |
| 156968 | /* 381 */ "anylist ::=", | 159053 | /* 381 */ "nmnum ::= DEFAULT", |
| 156969 | /* 382 */ "anylist ::= anylist LP anylist RP", | 159054 | /* 382 */ "plus_num ::= INTEGER|FLOAT", |
| 156970 | /* 383 */ "anylist ::= anylist ANY", | 159055 | /* 383 */ "foreach_clause ::=", |
| 156971 | /* 384 */ "with ::=", | 159056 | /* 384 */ "foreach_clause ::= FOR EACH ROW", |
| 159057 | /* 385 */ "trnm ::= nm", | ||
| 159058 | /* 386 */ "tridxby ::=", | ||
| 159059 | /* 387 */ "database_kw_opt ::= DATABASE", | ||
| 159060 | /* 388 */ "database_kw_opt ::=", | ||
| 159061 | /* 389 */ "kwcolumn_opt ::=", | ||
| 159062 | /* 390 */ "kwcolumn_opt ::= COLUMNKW", | ||
| 159063 | /* 391 */ "vtabarglist ::= vtabarg", | ||
| 159064 | /* 392 */ "vtabarglist ::= vtabarglist COMMA vtabarg", | ||
| 159065 | /* 393 */ "vtabarg ::= vtabarg vtabargtoken", | ||
| 159066 | /* 394 */ "anylist ::=", | ||
| 159067 | /* 395 */ "anylist ::= anylist LP anylist RP", | ||
| 159068 | /* 396 */ "anylist ::= anylist ANY", | ||
| 159069 | /* 397 */ "with ::=", | ||
| 156972 | }; | 159070 | }; |
| 156973 | #endif /* NDEBUG */ | 159071 | #endif /* NDEBUG */ |
| 156974 | 159072 | ||
| @@ -157094,98 +159192,99 @@ static void yy_destructor( | |||
| 157094 | ** inside the C code. | 159192 | ** inside the C code. |
| 157095 | */ | 159193 | */ |
| 157096 | /********* Begin destructor definitions ***************************************/ | 159194 | /********* Begin destructor definitions ***************************************/ |
| 157097 | case 200: /* select */ | 159195 | case 202: /* select */ |
| 157098 | case 234: /* selectnowith */ | 159196 | case 236: /* selectnowith */ |
| 157099 | case 235: /* oneselect */ | 159197 | case 237: /* oneselect */ |
| 157100 | case 247: /* values */ | 159198 | case 249: /* values */ |
| 157101 | { | 159199 | { |
| 157102 | sqlite3SelectDelete(pParse->db, (yypminor->yy539)); | 159200 | sqlite3SelectDelete(pParse->db, (yypminor->yy307)); |
| 157103 | } | 159201 | } |
| 157104 | break; | 159202 | break; |
| 157105 | case 211: /* term */ | 159203 | case 213: /* term */ |
| 157106 | case 212: /* expr */ | 159204 | case 214: /* expr */ |
| 157107 | case 241: /* where_opt */ | 159205 | case 243: /* where_opt */ |
| 157108 | case 243: /* having_opt */ | 159206 | case 245: /* having_opt */ |
| 157109 | case 255: /* on_opt */ | 159207 | case 257: /* on_opt */ |
| 157110 | case 271: /* case_operand */ | 159208 | case 264: /* where_opt_ret */ |
| 157111 | case 273: /* case_else */ | 159209 | case 275: /* case_operand */ |
| 157112 | case 276: /* vinto */ | 159210 | case 277: /* case_else */ |
| 157113 | case 283: /* when_clause */ | 159211 | case 280: /* vinto */ |
| 157114 | case 288: /* key_opt */ | 159212 | case 287: /* when_clause */ |
| 157115 | case 302: /* filter_clause */ | 159213 | case 292: /* key_opt */ |
| 159214 | case 308: /* filter_clause */ | ||
| 157116 | { | 159215 | { |
| 157117 | sqlite3ExprDelete(pParse->db, (yypminor->yy202)); | 159216 | sqlite3ExprDelete(pParse->db, (yypminor->yy602)); |
| 157118 | } | 159217 | } |
| 157119 | break; | 159218 | break; |
| 157120 | case 216: /* eidlist_opt */ | 159219 | case 218: /* eidlist_opt */ |
| 157121 | case 226: /* sortlist */ | 159220 | case 228: /* sortlist */ |
| 157122 | case 227: /* eidlist */ | 159221 | case 229: /* eidlist */ |
| 157123 | case 239: /* selcollist */ | 159222 | case 241: /* selcollist */ |
| 157124 | case 242: /* groupby_opt */ | 159223 | case 244: /* groupby_opt */ |
| 157125 | case 244: /* orderby_opt */ | 159224 | case 246: /* orderby_opt */ |
| 157126 | case 248: /* nexprlist */ | 159225 | case 250: /* nexprlist */ |
| 157127 | case 249: /* sclp */ | 159226 | case 251: /* sclp */ |
| 157128 | case 257: /* exprlist */ | 159227 | case 259: /* exprlist */ |
| 157129 | case 262: /* setlist */ | 159228 | case 265: /* setlist */ |
| 157130 | case 270: /* paren_exprlist */ | 159229 | case 274: /* paren_exprlist */ |
| 157131 | case 272: /* case_exprlist */ | 159230 | case 276: /* case_exprlist */ |
| 157132 | case 301: /* part_opt */ | 159231 | case 307: /* part_opt */ |
| 157133 | { | 159232 | { |
| 157134 | sqlite3ExprListDelete(pParse->db, (yypminor->yy242)); | 159233 | sqlite3ExprListDelete(pParse->db, (yypminor->yy338)); |
| 157135 | } | 159234 | } |
| 157136 | break; | 159235 | break; |
| 157137 | case 233: /* fullname */ | 159236 | case 235: /* fullname */ |
| 157138 | case 240: /* from */ | 159237 | case 242: /* from */ |
| 157139 | case 251: /* seltablist */ | 159238 | case 253: /* seltablist */ |
| 157140 | case 252: /* stl_prefix */ | 159239 | case 254: /* stl_prefix */ |
| 157141 | case 258: /* xfullname */ | 159240 | case 260: /* xfullname */ |
| 157142 | { | 159241 | { |
| 157143 | sqlite3SrcListDelete(pParse->db, (yypminor->yy47)); | 159242 | sqlite3SrcListDelete(pParse->db, (yypminor->yy291)); |
| 157144 | } | 159243 | } |
| 157145 | break; | 159244 | break; |
| 157146 | case 236: /* wqlist */ | 159245 | case 238: /* wqlist */ |
| 157147 | { | 159246 | { |
| 157148 | sqlite3WithDelete(pParse->db, (yypminor->yy131)); | 159247 | sqlite3WithDelete(pParse->db, (yypminor->yy195)); |
| 157149 | } | 159248 | } |
| 157150 | break; | 159249 | break; |
| 157151 | case 246: /* window_clause */ | 159250 | case 248: /* window_clause */ |
| 157152 | case 297: /* windowdefn_list */ | 159251 | case 303: /* windowdefn_list */ |
| 157153 | { | 159252 | { |
| 157154 | sqlite3WindowListDelete(pParse->db, (yypminor->yy303)); | 159253 | sqlite3WindowListDelete(pParse->db, (yypminor->yy19)); |
| 157155 | } | 159254 | } |
| 157156 | break; | 159255 | break; |
| 157157 | case 256: /* using_opt */ | 159256 | case 258: /* using_opt */ |
| 157158 | case 259: /* idlist */ | 159257 | case 261: /* idlist */ |
| 157159 | case 264: /* idlist_opt */ | 159258 | case 267: /* idlist_opt */ |
| 157160 | { | 159259 | { |
| 157161 | sqlite3IdListDelete(pParse->db, (yypminor->yy600)); | 159260 | sqlite3IdListDelete(pParse->db, (yypminor->yy288)); |
| 157162 | } | 159261 | } |
| 157163 | break; | 159262 | break; |
| 157164 | case 266: /* filter_over */ | 159263 | case 270: /* filter_over */ |
| 157165 | case 298: /* windowdefn */ | 159264 | case 304: /* windowdefn */ |
| 157166 | case 299: /* window */ | 159265 | case 305: /* window */ |
| 157167 | case 300: /* frame_opt */ | 159266 | case 306: /* frame_opt */ |
| 157168 | case 303: /* over_clause */ | 159267 | case 309: /* over_clause */ |
| 157169 | { | 159268 | { |
| 157170 | sqlite3WindowDelete(pParse->db, (yypminor->yy303)); | 159269 | sqlite3WindowDelete(pParse->db, (yypminor->yy19)); |
| 157171 | } | 159270 | } |
| 157172 | break; | 159271 | break; |
| 157173 | case 279: /* trigger_cmd_list */ | 159272 | case 283: /* trigger_cmd_list */ |
| 157174 | case 284: /* trigger_cmd */ | 159273 | case 288: /* trigger_cmd */ |
| 157175 | { | 159274 | { |
| 157176 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy447)); | 159275 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy483)); |
| 157177 | } | 159276 | } |
| 157178 | break; | 159277 | break; |
| 157179 | case 281: /* trigger_event */ | 159278 | case 285: /* trigger_event */ |
| 157180 | { | 159279 | { |
| 157181 | sqlite3IdListDelete(pParse->db, (yypminor->yy230).b); | 159280 | sqlite3IdListDelete(pParse->db, (yypminor->yy50).b); |
| 157182 | } | 159281 | } |
| 157183 | break; | 159282 | break; |
| 157184 | case 305: /* frame_bound */ | 159283 | case 311: /* frame_bound */ |
| 157185 | case 306: /* frame_bound_s */ | 159284 | case 312: /* frame_bound_s */ |
| 157186 | case 307: /* frame_bound_e */ | 159285 | case 313: /* frame_bound_e */ |
| 157187 | { | 159286 | { |
| 157188 | sqlite3ExprDelete(pParse->db, (yypminor->yy77).pExpr); | 159287 | sqlite3ExprDelete(pParse->db, (yypminor->yy113).pExpr); |
| 157189 | } | 159288 | } |
| 157190 | break; | 159289 | break; |
| 157191 | /********* End destructor definitions *****************************************/ | 159290 | /********* End destructor definitions *****************************************/ |
| @@ -157476,391 +159575,404 @@ static void yy_shift( | |||
| 157476 | /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side | 159575 | /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side |
| 157477 | ** of that rule */ | 159576 | ** of that rule */ |
| 157478 | static const YYCODETYPE yyRuleInfoLhs[] = { | 159577 | static const YYCODETYPE yyRuleInfoLhs[] = { |
| 157479 | 185, /* (0) explain ::= EXPLAIN */ | 159578 | 187, /* (0) explain ::= EXPLAIN */ |
| 157480 | 185, /* (1) explain ::= EXPLAIN QUERY PLAN */ | 159579 | 187, /* (1) explain ::= EXPLAIN QUERY PLAN */ |
| 157481 | 184, /* (2) cmdx ::= cmd */ | 159580 | 186, /* (2) cmdx ::= cmd */ |
| 157482 | 186, /* (3) cmd ::= BEGIN transtype trans_opt */ | 159581 | 188, /* (3) cmd ::= BEGIN transtype trans_opt */ |
| 157483 | 187, /* (4) transtype ::= */ | 159582 | 189, /* (4) transtype ::= */ |
| 157484 | 187, /* (5) transtype ::= DEFERRED */ | 159583 | 189, /* (5) transtype ::= DEFERRED */ |
| 157485 | 187, /* (6) transtype ::= IMMEDIATE */ | 159584 | 189, /* (6) transtype ::= IMMEDIATE */ |
| 157486 | 187, /* (7) transtype ::= EXCLUSIVE */ | 159585 | 189, /* (7) transtype ::= EXCLUSIVE */ |
| 157487 | 186, /* (8) cmd ::= COMMIT|END trans_opt */ | 159586 | 188, /* (8) cmd ::= COMMIT|END trans_opt */ |
| 157488 | 186, /* (9) cmd ::= ROLLBACK trans_opt */ | 159587 | 188, /* (9) cmd ::= ROLLBACK trans_opt */ |
| 157489 | 186, /* (10) cmd ::= SAVEPOINT nm */ | 159588 | 188, /* (10) cmd ::= SAVEPOINT nm */ |
| 157490 | 186, /* (11) cmd ::= RELEASE savepoint_opt nm */ | 159589 | 188, /* (11) cmd ::= RELEASE savepoint_opt nm */ |
| 157491 | 186, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ | 159590 | 188, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 157492 | 191, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ | 159591 | 193, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 157493 | 193, /* (14) createkw ::= CREATE */ | 159592 | 195, /* (14) createkw ::= CREATE */ |
| 157494 | 195, /* (15) ifnotexists ::= */ | 159593 | 197, /* (15) ifnotexists ::= */ |
| 157495 | 195, /* (16) ifnotexists ::= IF NOT EXISTS */ | 159594 | 197, /* (16) ifnotexists ::= IF NOT EXISTS */ |
| 157496 | 194, /* (17) temp ::= TEMP */ | 159595 | 196, /* (17) temp ::= TEMP */ |
| 157497 | 194, /* (18) temp ::= */ | 159596 | 196, /* (18) temp ::= */ |
| 157498 | 192, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ | 159597 | 194, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 157499 | 192, /* (20) create_table_args ::= AS select */ | 159598 | 194, /* (20) create_table_args ::= AS select */ |
| 157500 | 199, /* (21) table_options ::= */ | 159599 | 201, /* (21) table_options ::= */ |
| 157501 | 199, /* (22) table_options ::= WITHOUT nm */ | 159600 | 201, /* (22) table_options ::= WITHOUT nm */ |
| 157502 | 201, /* (23) columnname ::= nm typetoken */ | 159601 | 203, /* (23) columnname ::= nm typetoken */ |
| 157503 | 203, /* (24) typetoken ::= */ | 159602 | 205, /* (24) typetoken ::= */ |
| 157504 | 203, /* (25) typetoken ::= typename LP signed RP */ | 159603 | 205, /* (25) typetoken ::= typename LP signed RP */ |
| 157505 | 203, /* (26) typetoken ::= typename LP signed COMMA signed RP */ | 159604 | 205, /* (26) typetoken ::= typename LP signed COMMA signed RP */ |
| 157506 | 204, /* (27) typename ::= typename ID|STRING */ | 159605 | 206, /* (27) typename ::= typename ID|STRING */ |
| 157507 | 208, /* (28) scanpt ::= */ | 159606 | 210, /* (28) scanpt ::= */ |
| 157508 | 209, /* (29) scantok ::= */ | 159607 | 211, /* (29) scantok ::= */ |
| 157509 | 210, /* (30) ccons ::= CONSTRAINT nm */ | 159608 | 212, /* (30) ccons ::= CONSTRAINT nm */ |
| 157510 | 210, /* (31) ccons ::= DEFAULT scantok term */ | 159609 | 212, /* (31) ccons ::= DEFAULT scantok term */ |
| 157511 | 210, /* (32) ccons ::= DEFAULT LP expr RP */ | 159610 | 212, /* (32) ccons ::= DEFAULT LP expr RP */ |
| 157512 | 210, /* (33) ccons ::= DEFAULT PLUS scantok term */ | 159611 | 212, /* (33) ccons ::= DEFAULT PLUS scantok term */ |
| 157513 | 210, /* (34) ccons ::= DEFAULT MINUS scantok term */ | 159612 | 212, /* (34) ccons ::= DEFAULT MINUS scantok term */ |
| 157514 | 210, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ | 159613 | 212, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ |
| 157515 | 210, /* (36) ccons ::= NOT NULL onconf */ | 159614 | 212, /* (36) ccons ::= NOT NULL onconf */ |
| 157516 | 210, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ | 159615 | 212, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 157517 | 210, /* (38) ccons ::= UNIQUE onconf */ | 159616 | 212, /* (38) ccons ::= UNIQUE onconf */ |
| 157518 | 210, /* (39) ccons ::= CHECK LP expr RP */ | 159617 | 212, /* (39) ccons ::= CHECK LP expr RP */ |
| 157519 | 210, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ | 159618 | 212, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 157520 | 210, /* (41) ccons ::= defer_subclause */ | 159619 | 212, /* (41) ccons ::= defer_subclause */ |
| 157521 | 210, /* (42) ccons ::= COLLATE ID|STRING */ | 159620 | 212, /* (42) ccons ::= COLLATE ID|STRING */ |
| 157522 | 219, /* (43) generated ::= LP expr RP */ | 159621 | 221, /* (43) generated ::= LP expr RP */ |
| 157523 | 219, /* (44) generated ::= LP expr RP ID */ | 159622 | 221, /* (44) generated ::= LP expr RP ID */ |
| 157524 | 215, /* (45) autoinc ::= */ | 159623 | 217, /* (45) autoinc ::= */ |
| 157525 | 215, /* (46) autoinc ::= AUTOINCR */ | 159624 | 217, /* (46) autoinc ::= AUTOINCR */ |
| 157526 | 217, /* (47) refargs ::= */ | 159625 | 219, /* (47) refargs ::= */ |
| 157527 | 217, /* (48) refargs ::= refargs refarg */ | 159626 | 219, /* (48) refargs ::= refargs refarg */ |
| 157528 | 220, /* (49) refarg ::= MATCH nm */ | 159627 | 222, /* (49) refarg ::= MATCH nm */ |
| 157529 | 220, /* (50) refarg ::= ON INSERT refact */ | 159628 | 222, /* (50) refarg ::= ON INSERT refact */ |
| 157530 | 220, /* (51) refarg ::= ON DELETE refact */ | 159629 | 222, /* (51) refarg ::= ON DELETE refact */ |
| 157531 | 220, /* (52) refarg ::= ON UPDATE refact */ | 159630 | 222, /* (52) refarg ::= ON UPDATE refact */ |
| 157532 | 221, /* (53) refact ::= SET NULL */ | 159631 | 223, /* (53) refact ::= SET NULL */ |
| 157533 | 221, /* (54) refact ::= SET DEFAULT */ | 159632 | 223, /* (54) refact ::= SET DEFAULT */ |
| 157534 | 221, /* (55) refact ::= CASCADE */ | 159633 | 223, /* (55) refact ::= CASCADE */ |
| 157535 | 221, /* (56) refact ::= RESTRICT */ | 159634 | 223, /* (56) refact ::= RESTRICT */ |
| 157536 | 221, /* (57) refact ::= NO ACTION */ | 159635 | 223, /* (57) refact ::= NO ACTION */ |
| 157537 | 218, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ | 159636 | 220, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 157538 | 218, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ | 159637 | 220, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 157539 | 222, /* (60) init_deferred_pred_opt ::= */ | 159638 | 224, /* (60) init_deferred_pred_opt ::= */ |
| 157540 | 222, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 159639 | 224, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 157541 | 222, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 159640 | 224, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 157542 | 198, /* (63) conslist_opt ::= */ | 159641 | 200, /* (63) conslist_opt ::= */ |
| 157543 | 224, /* (64) tconscomma ::= COMMA */ | 159642 | 226, /* (64) tconscomma ::= COMMA */ |
| 157544 | 225, /* (65) tcons ::= CONSTRAINT nm */ | 159643 | 227, /* (65) tcons ::= CONSTRAINT nm */ |
| 157545 | 225, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ | 159644 | 227, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 157546 | 225, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ | 159645 | 227, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ |
| 157547 | 225, /* (68) tcons ::= CHECK LP expr RP onconf */ | 159646 | 227, /* (68) tcons ::= CHECK LP expr RP onconf */ |
| 157548 | 225, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ | 159647 | 227, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 157549 | 228, /* (70) defer_subclause_opt ::= */ | 159648 | 230, /* (70) defer_subclause_opt ::= */ |
| 157550 | 213, /* (71) onconf ::= */ | 159649 | 215, /* (71) onconf ::= */ |
| 157551 | 213, /* (72) onconf ::= ON CONFLICT resolvetype */ | 159650 | 215, /* (72) onconf ::= ON CONFLICT resolvetype */ |
| 157552 | 229, /* (73) orconf ::= */ | 159651 | 231, /* (73) orconf ::= */ |
| 157553 | 229, /* (74) orconf ::= OR resolvetype */ | 159652 | 231, /* (74) orconf ::= OR resolvetype */ |
| 157554 | 230, /* (75) resolvetype ::= IGNORE */ | 159653 | 232, /* (75) resolvetype ::= IGNORE */ |
| 157555 | 230, /* (76) resolvetype ::= REPLACE */ | 159654 | 232, /* (76) resolvetype ::= REPLACE */ |
| 157556 | 186, /* (77) cmd ::= DROP TABLE ifexists fullname */ | 159655 | 188, /* (77) cmd ::= DROP TABLE ifexists fullname */ |
| 157557 | 232, /* (78) ifexists ::= IF EXISTS */ | 159656 | 234, /* (78) ifexists ::= IF EXISTS */ |
| 157558 | 232, /* (79) ifexists ::= */ | 159657 | 234, /* (79) ifexists ::= */ |
| 157559 | 186, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ | 159658 | 188, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 157560 | 186, /* (81) cmd ::= DROP VIEW ifexists fullname */ | 159659 | 188, /* (81) cmd ::= DROP VIEW ifexists fullname */ |
| 157561 | 186, /* (82) cmd ::= select */ | 159660 | 188, /* (82) cmd ::= select */ |
| 157562 | 200, /* (83) select ::= WITH wqlist selectnowith */ | 159661 | 202, /* (83) select ::= WITH wqlist selectnowith */ |
| 157563 | 200, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ | 159662 | 202, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ |
| 157564 | 200, /* (85) select ::= selectnowith */ | 159663 | 202, /* (85) select ::= selectnowith */ |
| 157565 | 234, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ | 159664 | 236, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ |
| 157566 | 237, /* (87) multiselect_op ::= UNION */ | 159665 | 239, /* (87) multiselect_op ::= UNION */ |
| 157567 | 237, /* (88) multiselect_op ::= UNION ALL */ | 159666 | 239, /* (88) multiselect_op ::= UNION ALL */ |
| 157568 | 237, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ | 159667 | 239, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ |
| 157569 | 235, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ | 159668 | 237, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 157570 | 235, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ | 159669 | 237, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 157571 | 247, /* (92) values ::= VALUES LP nexprlist RP */ | 159670 | 249, /* (92) values ::= VALUES LP nexprlist RP */ |
| 157572 | 247, /* (93) values ::= values COMMA LP nexprlist RP */ | 159671 | 249, /* (93) values ::= values COMMA LP nexprlist RP */ |
| 157573 | 238, /* (94) distinct ::= DISTINCT */ | 159672 | 240, /* (94) distinct ::= DISTINCT */ |
| 157574 | 238, /* (95) distinct ::= ALL */ | 159673 | 240, /* (95) distinct ::= ALL */ |
| 157575 | 238, /* (96) distinct ::= */ | 159674 | 240, /* (96) distinct ::= */ |
| 157576 | 249, /* (97) sclp ::= */ | 159675 | 251, /* (97) sclp ::= */ |
| 157577 | 239, /* (98) selcollist ::= sclp scanpt expr scanpt as */ | 159676 | 241, /* (98) selcollist ::= sclp scanpt expr scanpt as */ |
| 157578 | 239, /* (99) selcollist ::= sclp scanpt STAR */ | 159677 | 241, /* (99) selcollist ::= sclp scanpt STAR */ |
| 157579 | 239, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ | 159678 | 241, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ |
| 157580 | 250, /* (101) as ::= AS nm */ | 159679 | 252, /* (101) as ::= AS nm */ |
| 157581 | 250, /* (102) as ::= */ | 159680 | 252, /* (102) as ::= */ |
| 157582 | 240, /* (103) from ::= */ | 159681 | 242, /* (103) from ::= */ |
| 157583 | 240, /* (104) from ::= FROM seltablist */ | 159682 | 242, /* (104) from ::= FROM seltablist */ |
| 157584 | 252, /* (105) stl_prefix ::= seltablist joinop */ | 159683 | 254, /* (105) stl_prefix ::= seltablist joinop */ |
| 157585 | 252, /* (106) stl_prefix ::= */ | 159684 | 254, /* (106) stl_prefix ::= */ |
| 157586 | 251, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ | 159685 | 253, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 157587 | 251, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ | 159686 | 253, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 157588 | 251, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ | 159687 | 253, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 157589 | 251, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ | 159688 | 253, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 157590 | 196, /* (111) dbnm ::= */ | 159689 | 198, /* (111) dbnm ::= */ |
| 157591 | 196, /* (112) dbnm ::= DOT nm */ | 159690 | 198, /* (112) dbnm ::= DOT nm */ |
| 157592 | 233, /* (113) fullname ::= nm */ | 159691 | 235, /* (113) fullname ::= nm */ |
| 157593 | 233, /* (114) fullname ::= nm DOT nm */ | 159692 | 235, /* (114) fullname ::= nm DOT nm */ |
| 157594 | 258, /* (115) xfullname ::= nm */ | 159693 | 260, /* (115) xfullname ::= nm */ |
| 157595 | 258, /* (116) xfullname ::= nm DOT nm */ | 159694 | 260, /* (116) xfullname ::= nm DOT nm */ |
| 157596 | 258, /* (117) xfullname ::= nm DOT nm AS nm */ | 159695 | 260, /* (117) xfullname ::= nm DOT nm AS nm */ |
| 157597 | 258, /* (118) xfullname ::= nm AS nm */ | 159696 | 260, /* (118) xfullname ::= nm AS nm */ |
| 157598 | 253, /* (119) joinop ::= COMMA|JOIN */ | 159697 | 255, /* (119) joinop ::= COMMA|JOIN */ |
| 157599 | 253, /* (120) joinop ::= JOIN_KW JOIN */ | 159698 | 255, /* (120) joinop ::= JOIN_KW JOIN */ |
| 157600 | 253, /* (121) joinop ::= JOIN_KW nm JOIN */ | 159699 | 255, /* (121) joinop ::= JOIN_KW nm JOIN */ |
| 157601 | 253, /* (122) joinop ::= JOIN_KW nm nm JOIN */ | 159700 | 255, /* (122) joinop ::= JOIN_KW nm nm JOIN */ |
| 157602 | 255, /* (123) on_opt ::= ON expr */ | 159701 | 257, /* (123) on_opt ::= ON expr */ |
| 157603 | 255, /* (124) on_opt ::= */ | 159702 | 257, /* (124) on_opt ::= */ |
| 157604 | 254, /* (125) indexed_opt ::= */ | 159703 | 256, /* (125) indexed_opt ::= */ |
| 157605 | 254, /* (126) indexed_opt ::= INDEXED BY nm */ | 159704 | 256, /* (126) indexed_opt ::= INDEXED BY nm */ |
| 157606 | 254, /* (127) indexed_opt ::= NOT INDEXED */ | 159705 | 256, /* (127) indexed_opt ::= NOT INDEXED */ |
| 157607 | 256, /* (128) using_opt ::= USING LP idlist RP */ | 159706 | 258, /* (128) using_opt ::= USING LP idlist RP */ |
| 157608 | 256, /* (129) using_opt ::= */ | 159707 | 258, /* (129) using_opt ::= */ |
| 157609 | 244, /* (130) orderby_opt ::= */ | 159708 | 246, /* (130) orderby_opt ::= */ |
| 157610 | 244, /* (131) orderby_opt ::= ORDER BY sortlist */ | 159709 | 246, /* (131) orderby_opt ::= ORDER BY sortlist */ |
| 157611 | 226, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ | 159710 | 228, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 157612 | 226, /* (133) sortlist ::= expr sortorder nulls */ | 159711 | 228, /* (133) sortlist ::= expr sortorder nulls */ |
| 157613 | 214, /* (134) sortorder ::= ASC */ | 159712 | 216, /* (134) sortorder ::= ASC */ |
| 157614 | 214, /* (135) sortorder ::= DESC */ | 159713 | 216, /* (135) sortorder ::= DESC */ |
| 157615 | 214, /* (136) sortorder ::= */ | 159714 | 216, /* (136) sortorder ::= */ |
| 157616 | 260, /* (137) nulls ::= NULLS FIRST */ | 159715 | 262, /* (137) nulls ::= NULLS FIRST */ |
| 157617 | 260, /* (138) nulls ::= NULLS LAST */ | 159716 | 262, /* (138) nulls ::= NULLS LAST */ |
| 157618 | 260, /* (139) nulls ::= */ | 159717 | 262, /* (139) nulls ::= */ |
| 157619 | 242, /* (140) groupby_opt ::= */ | 159718 | 244, /* (140) groupby_opt ::= */ |
| 157620 | 242, /* (141) groupby_opt ::= GROUP BY nexprlist */ | 159719 | 244, /* (141) groupby_opt ::= GROUP BY nexprlist */ |
| 157621 | 243, /* (142) having_opt ::= */ | 159720 | 245, /* (142) having_opt ::= */ |
| 157622 | 243, /* (143) having_opt ::= HAVING expr */ | 159721 | 245, /* (143) having_opt ::= HAVING expr */ |
| 157623 | 245, /* (144) limit_opt ::= */ | 159722 | 247, /* (144) limit_opt ::= */ |
| 157624 | 245, /* (145) limit_opt ::= LIMIT expr */ | 159723 | 247, /* (145) limit_opt ::= LIMIT expr */ |
| 157625 | 245, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ | 159724 | 247, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ |
| 157626 | 245, /* (147) limit_opt ::= LIMIT expr COMMA expr */ | 159725 | 247, /* (147) limit_opt ::= LIMIT expr COMMA expr */ |
| 157627 | 186, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ | 159726 | 188, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 157628 | 241, /* (149) where_opt ::= */ | 159727 | 243, /* (149) where_opt ::= */ |
| 157629 | 241, /* (150) where_opt ::= WHERE expr */ | 159728 | 243, /* (150) where_opt ::= WHERE expr */ |
| 157630 | 186, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt */ | 159729 | 264, /* (151) where_opt_ret ::= */ |
| 157631 | 262, /* (152) setlist ::= setlist COMMA nm EQ expr */ | 159730 | 264, /* (152) where_opt_ret ::= WHERE expr */ |
| 157632 | 262, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */ | 159731 | 264, /* (153) where_opt_ret ::= RETURNING selcollist */ |
| 157633 | 262, /* (154) setlist ::= nm EQ expr */ | 159732 | 264, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 157634 | 262, /* (155) setlist ::= LP idlist RP EQ expr */ | 159733 | 188, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 157635 | 186, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 159734 | 265, /* (156) setlist ::= setlist COMMA nm EQ expr */ |
| 157636 | 186, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ | 159735 | 265, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 157637 | 265, /* (158) upsert ::= */ | 159736 | 265, /* (158) setlist ::= nm EQ expr */ |
| 157638 | 265, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ | 159737 | 265, /* (159) setlist ::= LP idlist RP EQ expr */ |
| 157639 | 265, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ | 159738 | 188, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 157640 | 265, /* (161) upsert ::= ON CONFLICT DO NOTHING */ | 159739 | 188, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 157641 | 263, /* (162) insert_cmd ::= INSERT orconf */ | 159740 | 268, /* (162) upsert ::= */ |
| 157642 | 263, /* (163) insert_cmd ::= REPLACE */ | 159741 | 268, /* (163) upsert ::= RETURNING selcollist */ |
| 157643 | 264, /* (164) idlist_opt ::= */ | 159742 | 268, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 157644 | 264, /* (165) idlist_opt ::= LP idlist RP */ | 159743 | 268, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 157645 | 259, /* (166) idlist ::= idlist COMMA nm */ | 159744 | 268, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ |
| 157646 | 259, /* (167) idlist ::= nm */ | 159745 | 268, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 157647 | 212, /* (168) expr ::= LP expr RP */ | 159746 | 269, /* (168) returning ::= RETURNING selcollist */ |
| 157648 | 212, /* (169) expr ::= ID|INDEXED */ | 159747 | 266, /* (169) insert_cmd ::= INSERT orconf */ |
| 157649 | 212, /* (170) expr ::= JOIN_KW */ | 159748 | 266, /* (170) insert_cmd ::= REPLACE */ |
| 157650 | 212, /* (171) expr ::= nm DOT nm */ | 159749 | 267, /* (171) idlist_opt ::= */ |
| 157651 | 212, /* (172) expr ::= nm DOT nm DOT nm */ | 159750 | 267, /* (172) idlist_opt ::= LP idlist RP */ |
| 157652 | 211, /* (173) term ::= NULL|FLOAT|BLOB */ | 159751 | 261, /* (173) idlist ::= idlist COMMA nm */ |
| 157653 | 211, /* (174) term ::= STRING */ | 159752 | 261, /* (174) idlist ::= nm */ |
| 157654 | 211, /* (175) term ::= INTEGER */ | 159753 | 214, /* (175) expr ::= LP expr RP */ |
| 157655 | 212, /* (176) expr ::= VARIABLE */ | 159754 | 214, /* (176) expr ::= ID|INDEXED */ |
| 157656 | 212, /* (177) expr ::= expr COLLATE ID|STRING */ | 159755 | 214, /* (177) expr ::= JOIN_KW */ |
| 157657 | 212, /* (178) expr ::= CAST LP expr AS typetoken RP */ | 159756 | 214, /* (178) expr ::= nm DOT nm */ |
| 157658 | 212, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */ | 159757 | 214, /* (179) expr ::= nm DOT nm DOT nm */ |
| 157659 | 212, /* (180) expr ::= ID|INDEXED LP STAR RP */ | 159758 | 213, /* (180) term ::= NULL|FLOAT|BLOB */ |
| 157660 | 212, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 159759 | 213, /* (181) term ::= STRING */ |
| 157661 | 212, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */ | 159760 | 213, /* (182) term ::= INTEGER */ |
| 157662 | 211, /* (183) term ::= CTIME_KW */ | 159761 | 214, /* (183) expr ::= VARIABLE */ |
| 157663 | 212, /* (184) expr ::= LP nexprlist COMMA expr RP */ | 159762 | 214, /* (184) expr ::= expr COLLATE ID|STRING */ |
| 157664 | 212, /* (185) expr ::= expr AND expr */ | 159763 | 214, /* (185) expr ::= CAST LP expr AS typetoken RP */ |
| 157665 | 212, /* (186) expr ::= expr OR expr */ | 159764 | 214, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 157666 | 212, /* (187) expr ::= expr LT|GT|GE|LE expr */ | 159765 | 214, /* (187) expr ::= ID|INDEXED LP STAR RP */ |
| 157667 | 212, /* (188) expr ::= expr EQ|NE expr */ | 159766 | 214, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 157668 | 212, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | 159767 | 214, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 157669 | 212, /* (190) expr ::= expr PLUS|MINUS expr */ | 159768 | 213, /* (190) term ::= CTIME_KW */ |
| 157670 | 212, /* (191) expr ::= expr STAR|SLASH|REM expr */ | 159769 | 214, /* (191) expr ::= LP nexprlist COMMA expr RP */ |
| 157671 | 212, /* (192) expr ::= expr CONCAT expr */ | 159770 | 214, /* (192) expr ::= expr AND expr */ |
| 157672 | 267, /* (193) likeop ::= NOT LIKE_KW|MATCH */ | 159771 | 214, /* (193) expr ::= expr OR expr */ |
| 157673 | 212, /* (194) expr ::= expr likeop expr */ | 159772 | 214, /* (194) expr ::= expr LT|GT|GE|LE expr */ |
| 157674 | 212, /* (195) expr ::= expr likeop expr ESCAPE expr */ | 159773 | 214, /* (195) expr ::= expr EQ|NE expr */ |
| 157675 | 212, /* (196) expr ::= expr ISNULL|NOTNULL */ | 159774 | 214, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 157676 | 212, /* (197) expr ::= expr NOT NULL */ | 159775 | 214, /* (197) expr ::= expr PLUS|MINUS expr */ |
| 157677 | 212, /* (198) expr ::= expr IS expr */ | 159776 | 214, /* (198) expr ::= expr STAR|SLASH|REM expr */ |
| 157678 | 212, /* (199) expr ::= expr IS NOT expr */ | 159777 | 214, /* (199) expr ::= expr CONCAT expr */ |
| 157679 | 212, /* (200) expr ::= NOT expr */ | 159778 | 271, /* (200) likeop ::= NOT LIKE_KW|MATCH */ |
| 157680 | 212, /* (201) expr ::= BITNOT expr */ | 159779 | 214, /* (201) expr ::= expr likeop expr */ |
| 157681 | 212, /* (202) expr ::= PLUS|MINUS expr */ | 159780 | 214, /* (202) expr ::= expr likeop expr ESCAPE expr */ |
| 157682 | 268, /* (203) between_op ::= BETWEEN */ | 159781 | 214, /* (203) expr ::= expr ISNULL|NOTNULL */ |
| 157683 | 268, /* (204) between_op ::= NOT BETWEEN */ | 159782 | 214, /* (204) expr ::= expr NOT NULL */ |
| 157684 | 212, /* (205) expr ::= expr between_op expr AND expr */ | 159783 | 214, /* (205) expr ::= expr IS expr */ |
| 157685 | 269, /* (206) in_op ::= IN */ | 159784 | 214, /* (206) expr ::= expr IS NOT expr */ |
| 157686 | 269, /* (207) in_op ::= NOT IN */ | 159785 | 214, /* (207) expr ::= NOT expr */ |
| 157687 | 212, /* (208) expr ::= expr in_op LP exprlist RP */ | 159786 | 214, /* (208) expr ::= BITNOT expr */ |
| 157688 | 212, /* (209) expr ::= LP select RP */ | 159787 | 214, /* (209) expr ::= PLUS|MINUS expr */ |
| 157689 | 212, /* (210) expr ::= expr in_op LP select RP */ | 159788 | 272, /* (210) between_op ::= BETWEEN */ |
| 157690 | 212, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */ | 159789 | 272, /* (211) between_op ::= NOT BETWEEN */ |
| 157691 | 212, /* (212) expr ::= EXISTS LP select RP */ | 159790 | 214, /* (212) expr ::= expr between_op expr AND expr */ |
| 157692 | 212, /* (213) expr ::= CASE case_operand case_exprlist case_else END */ | 159791 | 273, /* (213) in_op ::= IN */ |
| 157693 | 272, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 159792 | 273, /* (214) in_op ::= NOT IN */ |
| 157694 | 272, /* (215) case_exprlist ::= WHEN expr THEN expr */ | 159793 | 214, /* (215) expr ::= expr in_op LP exprlist RP */ |
| 157695 | 273, /* (216) case_else ::= ELSE expr */ | 159794 | 214, /* (216) expr ::= LP select RP */ |
| 157696 | 273, /* (217) case_else ::= */ | 159795 | 214, /* (217) expr ::= expr in_op LP select RP */ |
| 157697 | 271, /* (218) case_operand ::= expr */ | 159796 | 214, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 157698 | 271, /* (219) case_operand ::= */ | 159797 | 214, /* (219) expr ::= EXISTS LP select RP */ |
| 157699 | 257, /* (220) exprlist ::= */ | 159798 | 214, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ |
| 157700 | 248, /* (221) nexprlist ::= nexprlist COMMA expr */ | 159799 | 276, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 157701 | 248, /* (222) nexprlist ::= expr */ | 159800 | 276, /* (222) case_exprlist ::= WHEN expr THEN expr */ |
| 157702 | 270, /* (223) paren_exprlist ::= */ | 159801 | 277, /* (223) case_else ::= ELSE expr */ |
| 157703 | 270, /* (224) paren_exprlist ::= LP exprlist RP */ | 159802 | 277, /* (224) case_else ::= */ |
| 157704 | 186, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 159803 | 275, /* (225) case_operand ::= expr */ |
| 157705 | 274, /* (226) uniqueflag ::= UNIQUE */ | 159804 | 275, /* (226) case_operand ::= */ |
| 157706 | 274, /* (227) uniqueflag ::= */ | 159805 | 259, /* (227) exprlist ::= */ |
| 157707 | 216, /* (228) eidlist_opt ::= */ | 159806 | 250, /* (228) nexprlist ::= nexprlist COMMA expr */ |
| 157708 | 216, /* (229) eidlist_opt ::= LP eidlist RP */ | 159807 | 250, /* (229) nexprlist ::= expr */ |
| 157709 | 227, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */ | 159808 | 274, /* (230) paren_exprlist ::= */ |
| 157710 | 227, /* (231) eidlist ::= nm collate sortorder */ | 159809 | 274, /* (231) paren_exprlist ::= LP exprlist RP */ |
| 157711 | 275, /* (232) collate ::= */ | 159810 | 188, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 157712 | 275, /* (233) collate ::= COLLATE ID|STRING */ | 159811 | 278, /* (233) uniqueflag ::= UNIQUE */ |
| 157713 | 186, /* (234) cmd ::= DROP INDEX ifexists fullname */ | 159812 | 278, /* (234) uniqueflag ::= */ |
| 157714 | 186, /* (235) cmd ::= VACUUM vinto */ | 159813 | 218, /* (235) eidlist_opt ::= */ |
| 157715 | 186, /* (236) cmd ::= VACUUM nm vinto */ | 159814 | 218, /* (236) eidlist_opt ::= LP eidlist RP */ |
| 157716 | 276, /* (237) vinto ::= INTO expr */ | 159815 | 229, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 157717 | 276, /* (238) vinto ::= */ | 159816 | 229, /* (238) eidlist ::= nm collate sortorder */ |
| 157718 | 186, /* (239) cmd ::= PRAGMA nm dbnm */ | 159817 | 279, /* (239) collate ::= */ |
| 157719 | 186, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */ | 159818 | 279, /* (240) collate ::= COLLATE ID|STRING */ |
| 157720 | 186, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 159819 | 188, /* (241) cmd ::= DROP INDEX ifexists fullname */ |
| 157721 | 186, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */ | 159820 | 188, /* (242) cmd ::= VACUUM vinto */ |
| 157722 | 186, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 159821 | 188, /* (243) cmd ::= VACUUM nm vinto */ |
| 157723 | 206, /* (244) plus_num ::= PLUS INTEGER|FLOAT */ | 159822 | 280, /* (244) vinto ::= INTO expr */ |
| 157724 | 207, /* (245) minus_num ::= MINUS INTEGER|FLOAT */ | 159823 | 280, /* (245) vinto ::= */ |
| 157725 | 186, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 159824 | 188, /* (246) cmd ::= PRAGMA nm dbnm */ |
| 157726 | 278, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 159825 | 188, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 157727 | 280, /* (248) trigger_time ::= BEFORE|AFTER */ | 159826 | 188, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 157728 | 280, /* (249) trigger_time ::= INSTEAD OF */ | 159827 | 188, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 157729 | 280, /* (250) trigger_time ::= */ | 159828 | 188, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 157730 | 281, /* (251) trigger_event ::= DELETE|INSERT */ | 159829 | 208, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ |
| 157731 | 281, /* (252) trigger_event ::= UPDATE */ | 159830 | 209, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ |
| 157732 | 281, /* (253) trigger_event ::= UPDATE OF idlist */ | 159831 | 188, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 157733 | 283, /* (254) when_clause ::= */ | 159832 | 282, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 157734 | 283, /* (255) when_clause ::= WHEN expr */ | 159833 | 284, /* (255) trigger_time ::= BEFORE|AFTER */ |
| 157735 | 279, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 159834 | 284, /* (256) trigger_time ::= INSTEAD OF */ |
| 157736 | 279, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */ | 159835 | 284, /* (257) trigger_time ::= */ |
| 157737 | 285, /* (258) trnm ::= nm DOT nm */ | 159836 | 285, /* (258) trigger_event ::= DELETE|INSERT */ |
| 157738 | 286, /* (259) tridxby ::= INDEXED BY nm */ | 159837 | 285, /* (259) trigger_event ::= UPDATE */ |
| 157739 | 286, /* (260) tridxby ::= NOT INDEXED */ | 159838 | 285, /* (260) trigger_event ::= UPDATE OF idlist */ |
| 157740 | 284, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 159839 | 287, /* (261) when_clause ::= */ |
| 157741 | 284, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 159840 | 287, /* (262) when_clause ::= WHEN expr */ |
| 157742 | 284, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 159841 | 283, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 157743 | 284, /* (264) trigger_cmd ::= scanpt select scanpt */ | 159842 | 283, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 157744 | 212, /* (265) expr ::= RAISE LP IGNORE RP */ | 159843 | 289, /* (265) trnm ::= nm DOT nm */ |
| 157745 | 212, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */ | 159844 | 290, /* (266) tridxby ::= INDEXED BY nm */ |
| 157746 | 231, /* (267) raisetype ::= ROLLBACK */ | 159845 | 290, /* (267) tridxby ::= NOT INDEXED */ |
| 157747 | 231, /* (268) raisetype ::= ABORT */ | 159846 | 288, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 157748 | 231, /* (269) raisetype ::= FAIL */ | 159847 | 288, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 157749 | 186, /* (270) cmd ::= DROP TRIGGER ifexists fullname */ | 159848 | 288, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 157750 | 186, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 159849 | 288, /* (271) trigger_cmd ::= scanpt select scanpt */ |
| 157751 | 186, /* (272) cmd ::= DETACH database_kw_opt expr */ | 159850 | 214, /* (272) expr ::= RAISE LP IGNORE RP */ |
| 157752 | 288, /* (273) key_opt ::= */ | 159851 | 214, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 157753 | 288, /* (274) key_opt ::= KEY expr */ | 159852 | 233, /* (274) raisetype ::= ROLLBACK */ |
| 157754 | 186, /* (275) cmd ::= REINDEX */ | 159853 | 233, /* (275) raisetype ::= ABORT */ |
| 157755 | 186, /* (276) cmd ::= REINDEX nm dbnm */ | 159854 | 233, /* (276) raisetype ::= FAIL */ |
| 157756 | 186, /* (277) cmd ::= ANALYZE */ | 159855 | 188, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ |
| 157757 | 186, /* (278) cmd ::= ANALYZE nm dbnm */ | 159856 | 188, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 157758 | 186, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */ | 159857 | 188, /* (279) cmd ::= DETACH database_kw_opt expr */ |
| 157759 | 186, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 159858 | 292, /* (280) key_opt ::= */ |
| 157760 | 289, /* (281) add_column_fullname ::= fullname */ | 159859 | 292, /* (281) key_opt ::= KEY expr */ |
| 157761 | 186, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 159860 | 188, /* (282) cmd ::= REINDEX */ |
| 157762 | 186, /* (283) cmd ::= create_vtab */ | 159861 | 188, /* (283) cmd ::= REINDEX nm dbnm */ |
| 157763 | 186, /* (284) cmd ::= create_vtab LP vtabarglist RP */ | 159862 | 188, /* (284) cmd ::= ANALYZE */ |
| 157764 | 291, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 159863 | 188, /* (285) cmd ::= ANALYZE nm dbnm */ |
| 157765 | 293, /* (286) vtabarg ::= */ | 159864 | 188, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 157766 | 294, /* (287) vtabargtoken ::= ANY */ | 159865 | 188, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 157767 | 294, /* (288) vtabargtoken ::= lp anylist RP */ | 159866 | 188, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 157768 | 295, /* (289) lp ::= LP */ | 159867 | 293, /* (289) add_column_fullname ::= fullname */ |
| 157769 | 261, /* (290) with ::= WITH wqlist */ | 159868 | 188, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 157770 | 261, /* (291) with ::= WITH RECURSIVE wqlist */ | 159869 | 188, /* (291) cmd ::= create_vtab */ |
| 157771 | 236, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */ | 159870 | 188, /* (292) cmd ::= create_vtab LP vtabarglist RP */ |
| 157772 | 236, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ | 159871 | 295, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 157773 | 297, /* (294) windowdefn_list ::= windowdefn */ | 159872 | 297, /* (294) vtabarg ::= */ |
| 157774 | 297, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 159873 | 298, /* (295) vtabargtoken ::= ANY */ |
| 157775 | 298, /* (296) windowdefn ::= nm AS LP window RP */ | 159874 | 298, /* (296) vtabargtoken ::= lp anylist RP */ |
| 157776 | 299, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 159875 | 299, /* (297) lp ::= LP */ |
| 157777 | 299, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 159876 | 263, /* (298) with ::= WITH wqlist */ |
| 157778 | 299, /* (299) window ::= ORDER BY sortlist frame_opt */ | 159877 | 263, /* (299) with ::= WITH RECURSIVE wqlist */ |
| 157779 | 299, /* (300) window ::= nm ORDER BY sortlist frame_opt */ | 159878 | 302, /* (300) wqas ::= AS */ |
| 157780 | 299, /* (301) window ::= frame_opt */ | 159879 | 302, /* (301) wqas ::= AS MATERIALIZED */ |
| 157781 | 299, /* (302) window ::= nm frame_opt */ | 159880 | 302, /* (302) wqas ::= AS NOT MATERIALIZED */ |
| 157782 | 300, /* (303) frame_opt ::= */ | 159881 | 301, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 157783 | 300, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 159882 | 238, /* (304) wqlist ::= wqitem */ |
| 157784 | 300, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 159883 | 238, /* (305) wqlist ::= wqlist COMMA wqitem */ |
| 157785 | 304, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */ | 159884 | 303, /* (306) windowdefn_list ::= windowdefn */ |
| 157786 | 306, /* (307) frame_bound_s ::= frame_bound */ | 159885 | 303, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 157787 | 306, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */ | 159886 | 304, /* (308) windowdefn ::= nm AS LP window RP */ |
| 157788 | 307, /* (309) frame_bound_e ::= frame_bound */ | 159887 | 305, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 157789 | 307, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */ | 159888 | 305, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 157790 | 305, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */ | 159889 | 305, /* (311) window ::= ORDER BY sortlist frame_opt */ |
| 157791 | 305, /* (312) frame_bound ::= CURRENT ROW */ | 159890 | 305, /* (312) window ::= nm ORDER BY sortlist frame_opt */ |
| 157792 | 308, /* (313) frame_exclude_opt ::= */ | 159891 | 305, /* (313) window ::= frame_opt */ |
| 157793 | 308, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */ | 159892 | 305, /* (314) window ::= nm frame_opt */ |
| 157794 | 309, /* (315) frame_exclude ::= NO OTHERS */ | 159893 | 306, /* (315) frame_opt ::= */ |
| 157795 | 309, /* (316) frame_exclude ::= CURRENT ROW */ | 159894 | 306, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 157796 | 309, /* (317) frame_exclude ::= GROUP|TIES */ | 159895 | 306, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 157797 | 246, /* (318) window_clause ::= WINDOW windowdefn_list */ | 159896 | 310, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 157798 | 266, /* (319) filter_over ::= filter_clause over_clause */ | 159897 | 312, /* (319) frame_bound_s ::= frame_bound */ |
| 157799 | 266, /* (320) filter_over ::= over_clause */ | 159898 | 312, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 157800 | 266, /* (321) filter_over ::= filter_clause */ | 159899 | 313, /* (321) frame_bound_e ::= frame_bound */ |
| 157801 | 303, /* (322) over_clause ::= OVER LP window RP */ | 159900 | 313, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 157802 | 303, /* (323) over_clause ::= OVER nm */ | 159901 | 311, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 157803 | 302, /* (324) filter_clause ::= FILTER LP WHERE expr RP */ | 159902 | 311, /* (324) frame_bound ::= CURRENT ROW */ |
| 157804 | 181, /* (325) input ::= cmdlist */ | 159903 | 314, /* (325) frame_exclude_opt ::= */ |
| 157805 | 182, /* (326) cmdlist ::= cmdlist ecmd */ | 159904 | 314, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 157806 | 182, /* (327) cmdlist ::= ecmd */ | 159905 | 315, /* (327) frame_exclude ::= NO OTHERS */ |
| 157807 | 183, /* (328) ecmd ::= SEMI */ | 159906 | 315, /* (328) frame_exclude ::= CURRENT ROW */ |
| 157808 | 183, /* (329) ecmd ::= cmdx SEMI */ | 159907 | 315, /* (329) frame_exclude ::= GROUP|TIES */ |
| 157809 | 183, /* (330) ecmd ::= explain cmdx SEMI */ | 159908 | 248, /* (330) window_clause ::= WINDOW windowdefn_list */ |
| 157810 | 188, /* (331) trans_opt ::= */ | 159909 | 270, /* (331) filter_over ::= filter_clause over_clause */ |
| 157811 | 188, /* (332) trans_opt ::= TRANSACTION */ | 159910 | 270, /* (332) filter_over ::= over_clause */ |
| 157812 | 188, /* (333) trans_opt ::= TRANSACTION nm */ | 159911 | 270, /* (333) filter_over ::= filter_clause */ |
| 157813 | 190, /* (334) savepoint_opt ::= SAVEPOINT */ | 159912 | 309, /* (334) over_clause ::= OVER LP window RP */ |
| 157814 | 190, /* (335) savepoint_opt ::= */ | 159913 | 309, /* (335) over_clause ::= OVER nm */ |
| 157815 | 186, /* (336) cmd ::= create_table create_table_args */ | 159914 | 308, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ |
| 157816 | 197, /* (337) columnlist ::= columnlist COMMA columnname carglist */ | 159915 | 183, /* (337) input ::= cmdlist */ |
| 157817 | 197, /* (338) columnlist ::= columnname carglist */ | 159916 | 184, /* (338) cmdlist ::= cmdlist ecmd */ |
| 157818 | 189, /* (339) nm ::= ID|INDEXED */ | 159917 | 184, /* (339) cmdlist ::= ecmd */ |
| 157819 | 189, /* (340) nm ::= STRING */ | 159918 | 185, /* (340) ecmd ::= SEMI */ |
| 157820 | 189, /* (341) nm ::= JOIN_KW */ | 159919 | 185, /* (341) ecmd ::= cmdx SEMI */ |
| 157821 | 203, /* (342) typetoken ::= typename */ | 159920 | 185, /* (342) ecmd ::= explain cmdx SEMI */ |
| 157822 | 204, /* (343) typename ::= ID|STRING */ | 159921 | 190, /* (343) trans_opt ::= */ |
| 157823 | 205, /* (344) signed ::= plus_num */ | 159922 | 190, /* (344) trans_opt ::= TRANSACTION */ |
| 157824 | 205, /* (345) signed ::= minus_num */ | 159923 | 190, /* (345) trans_opt ::= TRANSACTION nm */ |
| 157825 | 202, /* (346) carglist ::= carglist ccons */ | 159924 | 192, /* (346) savepoint_opt ::= SAVEPOINT */ |
| 157826 | 202, /* (347) carglist ::= */ | 159925 | 192, /* (347) savepoint_opt ::= */ |
| 157827 | 210, /* (348) ccons ::= NULL onconf */ | 159926 | 188, /* (348) cmd ::= create_table create_table_args */ |
| 157828 | 210, /* (349) ccons ::= GENERATED ALWAYS AS generated */ | 159927 | 199, /* (349) columnlist ::= columnlist COMMA columnname carglist */ |
| 157829 | 210, /* (350) ccons ::= AS generated */ | 159928 | 199, /* (350) columnlist ::= columnname carglist */ |
| 157830 | 198, /* (351) conslist_opt ::= COMMA conslist */ | 159929 | 191, /* (351) nm ::= ID|INDEXED */ |
| 157831 | 223, /* (352) conslist ::= conslist tconscomma tcons */ | 159930 | 191, /* (352) nm ::= STRING */ |
| 157832 | 223, /* (353) conslist ::= tcons */ | 159931 | 191, /* (353) nm ::= JOIN_KW */ |
| 157833 | 224, /* (354) tconscomma ::= */ | 159932 | 205, /* (354) typetoken ::= typename */ |
| 157834 | 228, /* (355) defer_subclause_opt ::= defer_subclause */ | 159933 | 206, /* (355) typename ::= ID|STRING */ |
| 157835 | 230, /* (356) resolvetype ::= raisetype */ | 159934 | 207, /* (356) signed ::= plus_num */ |
| 157836 | 234, /* (357) selectnowith ::= oneselect */ | 159935 | 207, /* (357) signed ::= minus_num */ |
| 157837 | 235, /* (358) oneselect ::= values */ | 159936 | 204, /* (358) carglist ::= carglist ccons */ |
| 157838 | 249, /* (359) sclp ::= selcollist COMMA */ | 159937 | 204, /* (359) carglist ::= */ |
| 157839 | 250, /* (360) as ::= ID|STRING */ | 159938 | 212, /* (360) ccons ::= NULL onconf */ |
| 157840 | 212, /* (361) expr ::= term */ | 159939 | 212, /* (361) ccons ::= GENERATED ALWAYS AS generated */ |
| 157841 | 267, /* (362) likeop ::= LIKE_KW|MATCH */ | 159940 | 212, /* (362) ccons ::= AS generated */ |
| 157842 | 257, /* (363) exprlist ::= nexprlist */ | 159941 | 200, /* (363) conslist_opt ::= COMMA conslist */ |
| 157843 | 277, /* (364) nmnum ::= plus_num */ | 159942 | 225, /* (364) conslist ::= conslist tconscomma tcons */ |
| 157844 | 277, /* (365) nmnum ::= nm */ | 159943 | 225, /* (365) conslist ::= tcons */ |
| 157845 | 277, /* (366) nmnum ::= ON */ | 159944 | 226, /* (366) tconscomma ::= */ |
| 157846 | 277, /* (367) nmnum ::= DELETE */ | 159945 | 230, /* (367) defer_subclause_opt ::= defer_subclause */ |
| 157847 | 277, /* (368) nmnum ::= DEFAULT */ | 159946 | 232, /* (368) resolvetype ::= raisetype */ |
| 157848 | 206, /* (369) plus_num ::= INTEGER|FLOAT */ | 159947 | 236, /* (369) selectnowith ::= oneselect */ |
| 157849 | 282, /* (370) foreach_clause ::= */ | 159948 | 237, /* (370) oneselect ::= values */ |
| 157850 | 282, /* (371) foreach_clause ::= FOR EACH ROW */ | 159949 | 251, /* (371) sclp ::= selcollist COMMA */ |
| 157851 | 285, /* (372) trnm ::= nm */ | 159950 | 252, /* (372) as ::= ID|STRING */ |
| 157852 | 286, /* (373) tridxby ::= */ | 159951 | 269, /* (373) returning ::= */ |
| 157853 | 287, /* (374) database_kw_opt ::= DATABASE */ | 159952 | 214, /* (374) expr ::= term */ |
| 157854 | 287, /* (375) database_kw_opt ::= */ | 159953 | 271, /* (375) likeop ::= LIKE_KW|MATCH */ |
| 157855 | 290, /* (376) kwcolumn_opt ::= */ | 159954 | 259, /* (376) exprlist ::= nexprlist */ |
| 157856 | 290, /* (377) kwcolumn_opt ::= COLUMNKW */ | 159955 | 281, /* (377) nmnum ::= plus_num */ |
| 157857 | 292, /* (378) vtabarglist ::= vtabarg */ | 159956 | 281, /* (378) nmnum ::= nm */ |
| 157858 | 292, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ | 159957 | 281, /* (379) nmnum ::= ON */ |
| 157859 | 293, /* (380) vtabarg ::= vtabarg vtabargtoken */ | 159958 | 281, /* (380) nmnum ::= DELETE */ |
| 157860 | 296, /* (381) anylist ::= */ | 159959 | 281, /* (381) nmnum ::= DEFAULT */ |
| 157861 | 296, /* (382) anylist ::= anylist LP anylist RP */ | 159960 | 208, /* (382) plus_num ::= INTEGER|FLOAT */ |
| 157862 | 296, /* (383) anylist ::= anylist ANY */ | 159961 | 286, /* (383) foreach_clause ::= */ |
| 157863 | 261, /* (384) with ::= */ | 159962 | 286, /* (384) foreach_clause ::= FOR EACH ROW */ |
| 159963 | 289, /* (385) trnm ::= nm */ | ||
| 159964 | 290, /* (386) tridxby ::= */ | ||
| 159965 | 291, /* (387) database_kw_opt ::= DATABASE */ | ||
| 159966 | 291, /* (388) database_kw_opt ::= */ | ||
| 159967 | 294, /* (389) kwcolumn_opt ::= */ | ||
| 159968 | 294, /* (390) kwcolumn_opt ::= COLUMNKW */ | ||
| 159969 | 296, /* (391) vtabarglist ::= vtabarg */ | ||
| 159970 | 296, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ | ||
| 159971 | 297, /* (393) vtabarg ::= vtabarg vtabargtoken */ | ||
| 159972 | 300, /* (394) anylist ::= */ | ||
| 159973 | 300, /* (395) anylist ::= anylist LP anylist RP */ | ||
| 159974 | 300, /* (396) anylist ::= anylist ANY */ | ||
| 159975 | 263, /* (397) with ::= */ | ||
| 157864 | }; | 159976 | }; |
| 157865 | 159977 | ||
| 157866 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number | 159978 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| @@ -158014,243 +160126,256 @@ static const signed char yyRuleInfoNRhs[] = { | |||
| 158014 | -2, /* (145) limit_opt ::= LIMIT expr */ | 160126 | -2, /* (145) limit_opt ::= LIMIT expr */ |
| 158015 | -4, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ | 160127 | -4, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ |
| 158016 | -4, /* (147) limit_opt ::= LIMIT expr COMMA expr */ | 160128 | -4, /* (147) limit_opt ::= LIMIT expr COMMA expr */ |
| 158017 | -6, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ | 160129 | -6, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 158018 | 0, /* (149) where_opt ::= */ | 160130 | 0, /* (149) where_opt ::= */ |
| 158019 | -2, /* (150) where_opt ::= WHERE expr */ | 160131 | -2, /* (150) where_opt ::= WHERE expr */ |
| 158020 | -9, /* (151) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt */ | 160132 | 0, /* (151) where_opt_ret ::= */ |
| 158021 | -5, /* (152) setlist ::= setlist COMMA nm EQ expr */ | 160133 | -2, /* (152) where_opt_ret ::= WHERE expr */ |
| 158022 | -7, /* (153) setlist ::= setlist COMMA LP idlist RP EQ expr */ | 160134 | -2, /* (153) where_opt_ret ::= RETURNING selcollist */ |
| 158023 | -3, /* (154) setlist ::= nm EQ expr */ | 160135 | -4, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 158024 | -5, /* (155) setlist ::= LP idlist RP EQ expr */ | 160136 | -9, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 158025 | -7, /* (156) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 160137 | -5, /* (156) setlist ::= setlist COMMA nm EQ expr */ |
| 158026 | -7, /* (157) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ | 160138 | -7, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 158027 | 0, /* (158) upsert ::= */ | 160139 | -3, /* (158) setlist ::= nm EQ expr */ |
| 158028 | -11, /* (159) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ | 160140 | -5, /* (159) setlist ::= LP idlist RP EQ expr */ |
| 158029 | -8, /* (160) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ | 160141 | -7, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 158030 | -4, /* (161) upsert ::= ON CONFLICT DO NOTHING */ | 160142 | -8, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 158031 | -2, /* (162) insert_cmd ::= INSERT orconf */ | 160143 | 0, /* (162) upsert ::= */ |
| 158032 | -1, /* (163) insert_cmd ::= REPLACE */ | 160144 | -2, /* (163) upsert ::= RETURNING selcollist */ |
| 158033 | 0, /* (164) idlist_opt ::= */ | 160145 | -12, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 158034 | -3, /* (165) idlist_opt ::= LP idlist RP */ | 160146 | -9, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 158035 | -3, /* (166) idlist ::= idlist COMMA nm */ | 160147 | -5, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ |
| 158036 | -1, /* (167) idlist ::= nm */ | 160148 | -8, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 158037 | -3, /* (168) expr ::= LP expr RP */ | 160149 | -2, /* (168) returning ::= RETURNING selcollist */ |
| 158038 | -1, /* (169) expr ::= ID|INDEXED */ | 160150 | -2, /* (169) insert_cmd ::= INSERT orconf */ |
| 158039 | -1, /* (170) expr ::= JOIN_KW */ | 160151 | -1, /* (170) insert_cmd ::= REPLACE */ |
| 158040 | -3, /* (171) expr ::= nm DOT nm */ | 160152 | 0, /* (171) idlist_opt ::= */ |
| 158041 | -5, /* (172) expr ::= nm DOT nm DOT nm */ | 160153 | -3, /* (172) idlist_opt ::= LP idlist RP */ |
| 158042 | -1, /* (173) term ::= NULL|FLOAT|BLOB */ | 160154 | -3, /* (173) idlist ::= idlist COMMA nm */ |
| 158043 | -1, /* (174) term ::= STRING */ | 160155 | -1, /* (174) idlist ::= nm */ |
| 158044 | -1, /* (175) term ::= INTEGER */ | 160156 | -3, /* (175) expr ::= LP expr RP */ |
| 158045 | -1, /* (176) expr ::= VARIABLE */ | 160157 | -1, /* (176) expr ::= ID|INDEXED */ |
| 158046 | -3, /* (177) expr ::= expr COLLATE ID|STRING */ | 160158 | -1, /* (177) expr ::= JOIN_KW */ |
| 158047 | -6, /* (178) expr ::= CAST LP expr AS typetoken RP */ | 160159 | -3, /* (178) expr ::= nm DOT nm */ |
| 158048 | -5, /* (179) expr ::= ID|INDEXED LP distinct exprlist RP */ | 160160 | -5, /* (179) expr ::= nm DOT nm DOT nm */ |
| 158049 | -4, /* (180) expr ::= ID|INDEXED LP STAR RP */ | 160161 | -1, /* (180) term ::= NULL|FLOAT|BLOB */ |
| 158050 | -6, /* (181) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 160162 | -1, /* (181) term ::= STRING */ |
| 158051 | -5, /* (182) expr ::= ID|INDEXED LP STAR RP filter_over */ | 160163 | -1, /* (182) term ::= INTEGER */ |
| 158052 | -1, /* (183) term ::= CTIME_KW */ | 160164 | -1, /* (183) expr ::= VARIABLE */ |
| 158053 | -5, /* (184) expr ::= LP nexprlist COMMA expr RP */ | 160165 | -3, /* (184) expr ::= expr COLLATE ID|STRING */ |
| 158054 | -3, /* (185) expr ::= expr AND expr */ | 160166 | -6, /* (185) expr ::= CAST LP expr AS typetoken RP */ |
| 158055 | -3, /* (186) expr ::= expr OR expr */ | 160167 | -5, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 158056 | -3, /* (187) expr ::= expr LT|GT|GE|LE expr */ | 160168 | -4, /* (187) expr ::= ID|INDEXED LP STAR RP */ |
| 158057 | -3, /* (188) expr ::= expr EQ|NE expr */ | 160169 | -6, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 158058 | -3, /* (189) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | 160170 | -5, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 158059 | -3, /* (190) expr ::= expr PLUS|MINUS expr */ | 160171 | -1, /* (190) term ::= CTIME_KW */ |
| 158060 | -3, /* (191) expr ::= expr STAR|SLASH|REM expr */ | 160172 | -5, /* (191) expr ::= LP nexprlist COMMA expr RP */ |
| 158061 | -3, /* (192) expr ::= expr CONCAT expr */ | 160173 | -3, /* (192) expr ::= expr AND expr */ |
| 158062 | -2, /* (193) likeop ::= NOT LIKE_KW|MATCH */ | 160174 | -3, /* (193) expr ::= expr OR expr */ |
| 158063 | -3, /* (194) expr ::= expr likeop expr */ | 160175 | -3, /* (194) expr ::= expr LT|GT|GE|LE expr */ |
| 158064 | -5, /* (195) expr ::= expr likeop expr ESCAPE expr */ | 160176 | -3, /* (195) expr ::= expr EQ|NE expr */ |
| 158065 | -2, /* (196) expr ::= expr ISNULL|NOTNULL */ | 160177 | -3, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 158066 | -3, /* (197) expr ::= expr NOT NULL */ | 160178 | -3, /* (197) expr ::= expr PLUS|MINUS expr */ |
| 158067 | -3, /* (198) expr ::= expr IS expr */ | 160179 | -3, /* (198) expr ::= expr STAR|SLASH|REM expr */ |
| 158068 | -4, /* (199) expr ::= expr IS NOT expr */ | 160180 | -3, /* (199) expr ::= expr CONCAT expr */ |
| 158069 | -2, /* (200) expr ::= NOT expr */ | 160181 | -2, /* (200) likeop ::= NOT LIKE_KW|MATCH */ |
| 158070 | -2, /* (201) expr ::= BITNOT expr */ | 160182 | -3, /* (201) expr ::= expr likeop expr */ |
| 158071 | -2, /* (202) expr ::= PLUS|MINUS expr */ | 160183 | -5, /* (202) expr ::= expr likeop expr ESCAPE expr */ |
| 158072 | -1, /* (203) between_op ::= BETWEEN */ | 160184 | -2, /* (203) expr ::= expr ISNULL|NOTNULL */ |
| 158073 | -2, /* (204) between_op ::= NOT BETWEEN */ | 160185 | -3, /* (204) expr ::= expr NOT NULL */ |
| 158074 | -5, /* (205) expr ::= expr between_op expr AND expr */ | 160186 | -3, /* (205) expr ::= expr IS expr */ |
| 158075 | -1, /* (206) in_op ::= IN */ | 160187 | -4, /* (206) expr ::= expr IS NOT expr */ |
| 158076 | -2, /* (207) in_op ::= NOT IN */ | 160188 | -2, /* (207) expr ::= NOT expr */ |
| 158077 | -5, /* (208) expr ::= expr in_op LP exprlist RP */ | 160189 | -2, /* (208) expr ::= BITNOT expr */ |
| 158078 | -3, /* (209) expr ::= LP select RP */ | 160190 | -2, /* (209) expr ::= PLUS|MINUS expr */ |
| 158079 | -5, /* (210) expr ::= expr in_op LP select RP */ | 160191 | -1, /* (210) between_op ::= BETWEEN */ |
| 158080 | -5, /* (211) expr ::= expr in_op nm dbnm paren_exprlist */ | 160192 | -2, /* (211) between_op ::= NOT BETWEEN */ |
| 158081 | -4, /* (212) expr ::= EXISTS LP select RP */ | 160193 | -5, /* (212) expr ::= expr between_op expr AND expr */ |
| 158082 | -5, /* (213) expr ::= CASE case_operand case_exprlist case_else END */ | 160194 | -1, /* (213) in_op ::= IN */ |
| 158083 | -5, /* (214) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 160195 | -2, /* (214) in_op ::= NOT IN */ |
| 158084 | -4, /* (215) case_exprlist ::= WHEN expr THEN expr */ | 160196 | -5, /* (215) expr ::= expr in_op LP exprlist RP */ |
| 158085 | -2, /* (216) case_else ::= ELSE expr */ | 160197 | -3, /* (216) expr ::= LP select RP */ |
| 158086 | 0, /* (217) case_else ::= */ | 160198 | -5, /* (217) expr ::= expr in_op LP select RP */ |
| 158087 | -1, /* (218) case_operand ::= expr */ | 160199 | -5, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 158088 | 0, /* (219) case_operand ::= */ | 160200 | -4, /* (219) expr ::= EXISTS LP select RP */ |
| 158089 | 0, /* (220) exprlist ::= */ | 160201 | -5, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ |
| 158090 | -3, /* (221) nexprlist ::= nexprlist COMMA expr */ | 160202 | -5, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 158091 | -1, /* (222) nexprlist ::= expr */ | 160203 | -4, /* (222) case_exprlist ::= WHEN expr THEN expr */ |
| 158092 | 0, /* (223) paren_exprlist ::= */ | 160204 | -2, /* (223) case_else ::= ELSE expr */ |
| 158093 | -3, /* (224) paren_exprlist ::= LP exprlist RP */ | 160205 | 0, /* (224) case_else ::= */ |
| 158094 | -12, /* (225) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 160206 | -1, /* (225) case_operand ::= expr */ |
| 158095 | -1, /* (226) uniqueflag ::= UNIQUE */ | 160207 | 0, /* (226) case_operand ::= */ |
| 158096 | 0, /* (227) uniqueflag ::= */ | 160208 | 0, /* (227) exprlist ::= */ |
| 158097 | 0, /* (228) eidlist_opt ::= */ | 160209 | -3, /* (228) nexprlist ::= nexprlist COMMA expr */ |
| 158098 | -3, /* (229) eidlist_opt ::= LP eidlist RP */ | 160210 | -1, /* (229) nexprlist ::= expr */ |
| 158099 | -5, /* (230) eidlist ::= eidlist COMMA nm collate sortorder */ | 160211 | 0, /* (230) paren_exprlist ::= */ |
| 158100 | -3, /* (231) eidlist ::= nm collate sortorder */ | 160212 | -3, /* (231) paren_exprlist ::= LP exprlist RP */ |
| 158101 | 0, /* (232) collate ::= */ | 160213 | -12, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 158102 | -2, /* (233) collate ::= COLLATE ID|STRING */ | 160214 | -1, /* (233) uniqueflag ::= UNIQUE */ |
| 158103 | -4, /* (234) cmd ::= DROP INDEX ifexists fullname */ | 160215 | 0, /* (234) uniqueflag ::= */ |
| 158104 | -2, /* (235) cmd ::= VACUUM vinto */ | 160216 | 0, /* (235) eidlist_opt ::= */ |
| 158105 | -3, /* (236) cmd ::= VACUUM nm vinto */ | 160217 | -3, /* (236) eidlist_opt ::= LP eidlist RP */ |
| 158106 | -2, /* (237) vinto ::= INTO expr */ | 160218 | -5, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 158107 | 0, /* (238) vinto ::= */ | 160219 | -3, /* (238) eidlist ::= nm collate sortorder */ |
| 158108 | -3, /* (239) cmd ::= PRAGMA nm dbnm */ | 160220 | 0, /* (239) collate ::= */ |
| 158109 | -5, /* (240) cmd ::= PRAGMA nm dbnm EQ nmnum */ | 160221 | -2, /* (240) collate ::= COLLATE ID|STRING */ |
| 158110 | -6, /* (241) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 160222 | -4, /* (241) cmd ::= DROP INDEX ifexists fullname */ |
| 158111 | -5, /* (242) cmd ::= PRAGMA nm dbnm EQ minus_num */ | 160223 | -2, /* (242) cmd ::= VACUUM vinto */ |
| 158112 | -6, /* (243) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 160224 | -3, /* (243) cmd ::= VACUUM nm vinto */ |
| 158113 | -2, /* (244) plus_num ::= PLUS INTEGER|FLOAT */ | 160225 | -2, /* (244) vinto ::= INTO expr */ |
| 158114 | -2, /* (245) minus_num ::= MINUS INTEGER|FLOAT */ | 160226 | 0, /* (245) vinto ::= */ |
| 158115 | -5, /* (246) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 160227 | -3, /* (246) cmd ::= PRAGMA nm dbnm */ |
| 158116 | -11, /* (247) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 160228 | -5, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 158117 | -1, /* (248) trigger_time ::= BEFORE|AFTER */ | 160229 | -6, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 158118 | -2, /* (249) trigger_time ::= INSTEAD OF */ | 160230 | -5, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 158119 | 0, /* (250) trigger_time ::= */ | 160231 | -6, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 158120 | -1, /* (251) trigger_event ::= DELETE|INSERT */ | 160232 | -2, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ |
| 158121 | -1, /* (252) trigger_event ::= UPDATE */ | 160233 | -2, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ |
| 158122 | -3, /* (253) trigger_event ::= UPDATE OF idlist */ | 160234 | -5, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 158123 | 0, /* (254) when_clause ::= */ | 160235 | -11, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 158124 | -2, /* (255) when_clause ::= WHEN expr */ | 160236 | -1, /* (255) trigger_time ::= BEFORE|AFTER */ |
| 158125 | -3, /* (256) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 160237 | -2, /* (256) trigger_time ::= INSTEAD OF */ |
| 158126 | -2, /* (257) trigger_cmd_list ::= trigger_cmd SEMI */ | 160238 | 0, /* (257) trigger_time ::= */ |
| 158127 | -3, /* (258) trnm ::= nm DOT nm */ | 160239 | -1, /* (258) trigger_event ::= DELETE|INSERT */ |
| 158128 | -3, /* (259) tridxby ::= INDEXED BY nm */ | 160240 | -1, /* (259) trigger_event ::= UPDATE */ |
| 158129 | -2, /* (260) tridxby ::= NOT INDEXED */ | 160241 | -3, /* (260) trigger_event ::= UPDATE OF idlist */ |
| 158130 | -9, /* (261) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 160242 | 0, /* (261) when_clause ::= */ |
| 158131 | -8, /* (262) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 160243 | -2, /* (262) when_clause ::= WHEN expr */ |
| 158132 | -6, /* (263) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 160244 | -3, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 158133 | -3, /* (264) trigger_cmd ::= scanpt select scanpt */ | 160245 | -2, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 158134 | -4, /* (265) expr ::= RAISE LP IGNORE RP */ | 160246 | -3, /* (265) trnm ::= nm DOT nm */ |
| 158135 | -6, /* (266) expr ::= RAISE LP raisetype COMMA nm RP */ | 160247 | -3, /* (266) tridxby ::= INDEXED BY nm */ |
| 158136 | -1, /* (267) raisetype ::= ROLLBACK */ | 160248 | -2, /* (267) tridxby ::= NOT INDEXED */ |
| 158137 | -1, /* (268) raisetype ::= ABORT */ | 160249 | -9, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 158138 | -1, /* (269) raisetype ::= FAIL */ | 160250 | -8, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 158139 | -4, /* (270) cmd ::= DROP TRIGGER ifexists fullname */ | 160251 | -6, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 158140 | -6, /* (271) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 160252 | -3, /* (271) trigger_cmd ::= scanpt select scanpt */ |
| 158141 | -3, /* (272) cmd ::= DETACH database_kw_opt expr */ | 160253 | -4, /* (272) expr ::= RAISE LP IGNORE RP */ |
| 158142 | 0, /* (273) key_opt ::= */ | 160254 | -6, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 158143 | -2, /* (274) key_opt ::= KEY expr */ | 160255 | -1, /* (274) raisetype ::= ROLLBACK */ |
| 158144 | -1, /* (275) cmd ::= REINDEX */ | 160256 | -1, /* (275) raisetype ::= ABORT */ |
| 158145 | -3, /* (276) cmd ::= REINDEX nm dbnm */ | 160257 | -1, /* (276) raisetype ::= FAIL */ |
| 158146 | -1, /* (277) cmd ::= ANALYZE */ | 160258 | -4, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ |
| 158147 | -3, /* (278) cmd ::= ANALYZE nm dbnm */ | 160259 | -6, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 158148 | -6, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */ | 160260 | -3, /* (279) cmd ::= DETACH database_kw_opt expr */ |
| 158149 | -7, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 160261 | 0, /* (280) key_opt ::= */ |
| 158150 | -1, /* (281) add_column_fullname ::= fullname */ | 160262 | -2, /* (281) key_opt ::= KEY expr */ |
| 158151 | -8, /* (282) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 160263 | -1, /* (282) cmd ::= REINDEX */ |
| 158152 | -1, /* (283) cmd ::= create_vtab */ | 160264 | -3, /* (283) cmd ::= REINDEX nm dbnm */ |
| 158153 | -4, /* (284) cmd ::= create_vtab LP vtabarglist RP */ | 160265 | -1, /* (284) cmd ::= ANALYZE */ |
| 158154 | -8, /* (285) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 160266 | -3, /* (285) cmd ::= ANALYZE nm dbnm */ |
| 158155 | 0, /* (286) vtabarg ::= */ | 160267 | -6, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 158156 | -1, /* (287) vtabargtoken ::= ANY */ | 160268 | -7, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 158157 | -3, /* (288) vtabargtoken ::= lp anylist RP */ | 160269 | -6, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 158158 | -1, /* (289) lp ::= LP */ | 160270 | -1, /* (289) add_column_fullname ::= fullname */ |
| 158159 | -2, /* (290) with ::= WITH wqlist */ | 160271 | -8, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 158160 | -3, /* (291) with ::= WITH RECURSIVE wqlist */ | 160272 | -1, /* (291) cmd ::= create_vtab */ |
| 158161 | -6, /* (292) wqlist ::= nm eidlist_opt AS LP select RP */ | 160273 | -4, /* (292) cmd ::= create_vtab LP vtabarglist RP */ |
| 158162 | -8, /* (293) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ | 160274 | -8, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 158163 | -1, /* (294) windowdefn_list ::= windowdefn */ | 160275 | 0, /* (294) vtabarg ::= */ |
| 158164 | -3, /* (295) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 160276 | -1, /* (295) vtabargtoken ::= ANY */ |
| 158165 | -5, /* (296) windowdefn ::= nm AS LP window RP */ | 160277 | -3, /* (296) vtabargtoken ::= lp anylist RP */ |
| 158166 | -5, /* (297) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 160278 | -1, /* (297) lp ::= LP */ |
| 158167 | -6, /* (298) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 160279 | -2, /* (298) with ::= WITH wqlist */ |
| 158168 | -4, /* (299) window ::= ORDER BY sortlist frame_opt */ | 160280 | -3, /* (299) with ::= WITH RECURSIVE wqlist */ |
| 158169 | -5, /* (300) window ::= nm ORDER BY sortlist frame_opt */ | 160281 | -1, /* (300) wqas ::= AS */ |
| 158170 | -1, /* (301) window ::= frame_opt */ | 160282 | -2, /* (301) wqas ::= AS MATERIALIZED */ |
| 158171 | -2, /* (302) window ::= nm frame_opt */ | 160283 | -3, /* (302) wqas ::= AS NOT MATERIALIZED */ |
| 158172 | 0, /* (303) frame_opt ::= */ | 160284 | -6, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 158173 | -3, /* (304) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 160285 | -1, /* (304) wqlist ::= wqitem */ |
| 158174 | -6, /* (305) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 160286 | -3, /* (305) wqlist ::= wqlist COMMA wqitem */ |
| 158175 | -1, /* (306) range_or_rows ::= RANGE|ROWS|GROUPS */ | 160287 | -1, /* (306) windowdefn_list ::= windowdefn */ |
| 158176 | -1, /* (307) frame_bound_s ::= frame_bound */ | 160288 | -3, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 158177 | -2, /* (308) frame_bound_s ::= UNBOUNDED PRECEDING */ | 160289 | -5, /* (308) windowdefn ::= nm AS LP window RP */ |
| 158178 | -1, /* (309) frame_bound_e ::= frame_bound */ | 160290 | -5, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 158179 | -2, /* (310) frame_bound_e ::= UNBOUNDED FOLLOWING */ | 160291 | -6, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 158180 | -2, /* (311) frame_bound ::= expr PRECEDING|FOLLOWING */ | 160292 | -4, /* (311) window ::= ORDER BY sortlist frame_opt */ |
| 158181 | -2, /* (312) frame_bound ::= CURRENT ROW */ | 160293 | -5, /* (312) window ::= nm ORDER BY sortlist frame_opt */ |
| 158182 | 0, /* (313) frame_exclude_opt ::= */ | 160294 | -1, /* (313) window ::= frame_opt */ |
| 158183 | -2, /* (314) frame_exclude_opt ::= EXCLUDE frame_exclude */ | 160295 | -2, /* (314) window ::= nm frame_opt */ |
| 158184 | -2, /* (315) frame_exclude ::= NO OTHERS */ | 160296 | 0, /* (315) frame_opt ::= */ |
| 158185 | -2, /* (316) frame_exclude ::= CURRENT ROW */ | 160297 | -3, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 158186 | -1, /* (317) frame_exclude ::= GROUP|TIES */ | 160298 | -6, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 158187 | -2, /* (318) window_clause ::= WINDOW windowdefn_list */ | 160299 | -1, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 158188 | -2, /* (319) filter_over ::= filter_clause over_clause */ | 160300 | -1, /* (319) frame_bound_s ::= frame_bound */ |
| 158189 | -1, /* (320) filter_over ::= over_clause */ | 160301 | -2, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 158190 | -1, /* (321) filter_over ::= filter_clause */ | 160302 | -1, /* (321) frame_bound_e ::= frame_bound */ |
| 158191 | -4, /* (322) over_clause ::= OVER LP window RP */ | 160303 | -2, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 158192 | -2, /* (323) over_clause ::= OVER nm */ | 160304 | -2, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 158193 | -5, /* (324) filter_clause ::= FILTER LP WHERE expr RP */ | 160305 | -2, /* (324) frame_bound ::= CURRENT ROW */ |
| 158194 | -1, /* (325) input ::= cmdlist */ | 160306 | 0, /* (325) frame_exclude_opt ::= */ |
| 158195 | -2, /* (326) cmdlist ::= cmdlist ecmd */ | 160307 | -2, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 158196 | -1, /* (327) cmdlist ::= ecmd */ | 160308 | -2, /* (327) frame_exclude ::= NO OTHERS */ |
| 158197 | -1, /* (328) ecmd ::= SEMI */ | 160309 | -2, /* (328) frame_exclude ::= CURRENT ROW */ |
| 158198 | -2, /* (329) ecmd ::= cmdx SEMI */ | 160310 | -1, /* (329) frame_exclude ::= GROUP|TIES */ |
| 158199 | -3, /* (330) ecmd ::= explain cmdx SEMI */ | 160311 | -2, /* (330) window_clause ::= WINDOW windowdefn_list */ |
| 158200 | 0, /* (331) trans_opt ::= */ | 160312 | -2, /* (331) filter_over ::= filter_clause over_clause */ |
| 158201 | -1, /* (332) trans_opt ::= TRANSACTION */ | 160313 | -1, /* (332) filter_over ::= over_clause */ |
| 158202 | -2, /* (333) trans_opt ::= TRANSACTION nm */ | 160314 | -1, /* (333) filter_over ::= filter_clause */ |
| 158203 | -1, /* (334) savepoint_opt ::= SAVEPOINT */ | 160315 | -4, /* (334) over_clause ::= OVER LP window RP */ |
| 158204 | 0, /* (335) savepoint_opt ::= */ | 160316 | -2, /* (335) over_clause ::= OVER nm */ |
| 158205 | -2, /* (336) cmd ::= create_table create_table_args */ | 160317 | -5, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ |
| 158206 | -4, /* (337) columnlist ::= columnlist COMMA columnname carglist */ | 160318 | -1, /* (337) input ::= cmdlist */ |
| 158207 | -2, /* (338) columnlist ::= columnname carglist */ | 160319 | -2, /* (338) cmdlist ::= cmdlist ecmd */ |
| 158208 | -1, /* (339) nm ::= ID|INDEXED */ | 160320 | -1, /* (339) cmdlist ::= ecmd */ |
| 158209 | -1, /* (340) nm ::= STRING */ | 160321 | -1, /* (340) ecmd ::= SEMI */ |
| 158210 | -1, /* (341) nm ::= JOIN_KW */ | 160322 | -2, /* (341) ecmd ::= cmdx SEMI */ |
| 158211 | -1, /* (342) typetoken ::= typename */ | 160323 | -3, /* (342) ecmd ::= explain cmdx SEMI */ |
| 158212 | -1, /* (343) typename ::= ID|STRING */ | 160324 | 0, /* (343) trans_opt ::= */ |
| 158213 | -1, /* (344) signed ::= plus_num */ | 160325 | -1, /* (344) trans_opt ::= TRANSACTION */ |
| 158214 | -1, /* (345) signed ::= minus_num */ | 160326 | -2, /* (345) trans_opt ::= TRANSACTION nm */ |
| 158215 | -2, /* (346) carglist ::= carglist ccons */ | 160327 | -1, /* (346) savepoint_opt ::= SAVEPOINT */ |
| 158216 | 0, /* (347) carglist ::= */ | 160328 | 0, /* (347) savepoint_opt ::= */ |
| 158217 | -2, /* (348) ccons ::= NULL onconf */ | 160329 | -2, /* (348) cmd ::= create_table create_table_args */ |
| 158218 | -4, /* (349) ccons ::= GENERATED ALWAYS AS generated */ | 160330 | -4, /* (349) columnlist ::= columnlist COMMA columnname carglist */ |
| 158219 | -2, /* (350) ccons ::= AS generated */ | 160331 | -2, /* (350) columnlist ::= columnname carglist */ |
| 158220 | -2, /* (351) conslist_opt ::= COMMA conslist */ | 160332 | -1, /* (351) nm ::= ID|INDEXED */ |
| 158221 | -3, /* (352) conslist ::= conslist tconscomma tcons */ | 160333 | -1, /* (352) nm ::= STRING */ |
| 158222 | -1, /* (353) conslist ::= tcons */ | 160334 | -1, /* (353) nm ::= JOIN_KW */ |
| 158223 | 0, /* (354) tconscomma ::= */ | 160335 | -1, /* (354) typetoken ::= typename */ |
| 158224 | -1, /* (355) defer_subclause_opt ::= defer_subclause */ | 160336 | -1, /* (355) typename ::= ID|STRING */ |
| 158225 | -1, /* (356) resolvetype ::= raisetype */ | 160337 | -1, /* (356) signed ::= plus_num */ |
| 158226 | -1, /* (357) selectnowith ::= oneselect */ | 160338 | -1, /* (357) signed ::= minus_num */ |
| 158227 | -1, /* (358) oneselect ::= values */ | 160339 | -2, /* (358) carglist ::= carglist ccons */ |
| 158228 | -2, /* (359) sclp ::= selcollist COMMA */ | 160340 | 0, /* (359) carglist ::= */ |
| 158229 | -1, /* (360) as ::= ID|STRING */ | 160341 | -2, /* (360) ccons ::= NULL onconf */ |
| 158230 | -1, /* (361) expr ::= term */ | 160342 | -4, /* (361) ccons ::= GENERATED ALWAYS AS generated */ |
| 158231 | -1, /* (362) likeop ::= LIKE_KW|MATCH */ | 160343 | -2, /* (362) ccons ::= AS generated */ |
| 158232 | -1, /* (363) exprlist ::= nexprlist */ | 160344 | -2, /* (363) conslist_opt ::= COMMA conslist */ |
| 158233 | -1, /* (364) nmnum ::= plus_num */ | 160345 | -3, /* (364) conslist ::= conslist tconscomma tcons */ |
| 158234 | -1, /* (365) nmnum ::= nm */ | 160346 | -1, /* (365) conslist ::= tcons */ |
| 158235 | -1, /* (366) nmnum ::= ON */ | 160347 | 0, /* (366) tconscomma ::= */ |
| 158236 | -1, /* (367) nmnum ::= DELETE */ | 160348 | -1, /* (367) defer_subclause_opt ::= defer_subclause */ |
| 158237 | -1, /* (368) nmnum ::= DEFAULT */ | 160349 | -1, /* (368) resolvetype ::= raisetype */ |
| 158238 | -1, /* (369) plus_num ::= INTEGER|FLOAT */ | 160350 | -1, /* (369) selectnowith ::= oneselect */ |
| 158239 | 0, /* (370) foreach_clause ::= */ | 160351 | -1, /* (370) oneselect ::= values */ |
| 158240 | -3, /* (371) foreach_clause ::= FOR EACH ROW */ | 160352 | -2, /* (371) sclp ::= selcollist COMMA */ |
| 158241 | -1, /* (372) trnm ::= nm */ | 160353 | -1, /* (372) as ::= ID|STRING */ |
| 158242 | 0, /* (373) tridxby ::= */ | 160354 | 0, /* (373) returning ::= */ |
| 158243 | -1, /* (374) database_kw_opt ::= DATABASE */ | 160355 | -1, /* (374) expr ::= term */ |
| 158244 | 0, /* (375) database_kw_opt ::= */ | 160356 | -1, /* (375) likeop ::= LIKE_KW|MATCH */ |
| 158245 | 0, /* (376) kwcolumn_opt ::= */ | 160357 | -1, /* (376) exprlist ::= nexprlist */ |
| 158246 | -1, /* (377) kwcolumn_opt ::= COLUMNKW */ | 160358 | -1, /* (377) nmnum ::= plus_num */ |
| 158247 | -1, /* (378) vtabarglist ::= vtabarg */ | 160359 | -1, /* (378) nmnum ::= nm */ |
| 158248 | -3, /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ | 160360 | -1, /* (379) nmnum ::= ON */ |
| 158249 | -2, /* (380) vtabarg ::= vtabarg vtabargtoken */ | 160361 | -1, /* (380) nmnum ::= DELETE */ |
| 158250 | 0, /* (381) anylist ::= */ | 160362 | -1, /* (381) nmnum ::= DEFAULT */ |
| 158251 | -4, /* (382) anylist ::= anylist LP anylist RP */ | 160363 | -1, /* (382) plus_num ::= INTEGER|FLOAT */ |
| 158252 | -2, /* (383) anylist ::= anylist ANY */ | 160364 | 0, /* (383) foreach_clause ::= */ |
| 158253 | 0, /* (384) with ::= */ | 160365 | -3, /* (384) foreach_clause ::= FOR EACH ROW */ |
| 160366 | -1, /* (385) trnm ::= nm */ | ||
| 160367 | 0, /* (386) tridxby ::= */ | ||
| 160368 | -1, /* (387) database_kw_opt ::= DATABASE */ | ||
| 160369 | 0, /* (388) database_kw_opt ::= */ | ||
| 160370 | 0, /* (389) kwcolumn_opt ::= */ | ||
| 160371 | -1, /* (390) kwcolumn_opt ::= COLUMNKW */ | ||
| 160372 | -1, /* (391) vtabarglist ::= vtabarg */ | ||
| 160373 | -3, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ | ||
| 160374 | -2, /* (393) vtabarg ::= vtabarg vtabargtoken */ | ||
| 160375 | 0, /* (394) anylist ::= */ | ||
| 160376 | -4, /* (395) anylist ::= anylist LP anylist RP */ | ||
| 160377 | -2, /* (396) anylist ::= anylist ANY */ | ||
| 160378 | 0, /* (397) with ::= */ | ||
| 158254 | }; | 160379 | }; |
| 158255 | 160380 | ||
| 158256 | static void yy_accept(yyParser*); /* Forward Declaration */ | 160381 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| @@ -158280,55 +160405,6 @@ static YYACTIONTYPE yy_reduce( | |||
| 158280 | (void)yyLookahead; | 160405 | (void)yyLookahead; |
| 158281 | (void)yyLookaheadToken; | 160406 | (void)yyLookaheadToken; |
| 158282 | yymsp = yypParser->yytos; | 160407 | yymsp = yypParser->yytos; |
| 158283 | assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); | ||
| 158284 | #ifndef NDEBUG | ||
| 158285 | if( yyTraceFILE ){ | ||
| 158286 | yysize = yyRuleInfoNRhs[yyruleno]; | ||
| 158287 | if( yysize ){ | ||
| 158288 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", | ||
| 158289 | yyTracePrompt, | ||
| 158290 | yyruleno, yyRuleName[yyruleno], | ||
| 158291 | yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action", | ||
| 158292 | yymsp[yysize].stateno); | ||
| 158293 | }else{ | ||
| 158294 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", | ||
| 158295 | yyTracePrompt, yyruleno, yyRuleName[yyruleno], | ||
| 158296 | yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action"); | ||
| 158297 | } | ||
| 158298 | } | ||
| 158299 | #endif /* NDEBUG */ | ||
| 158300 | |||
| 158301 | /* Check that the stack is large enough to grow by a single entry | ||
| 158302 | ** if the RHS of the rule is empty. This ensures that there is room | ||
| 158303 | ** enough on the stack to push the LHS value */ | ||
| 158304 | if( yyRuleInfoNRhs[yyruleno]==0 ){ | ||
| 158305 | #ifdef YYTRACKMAXSTACKDEPTH | ||
| 158306 | if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ | ||
| 158307 | yypParser->yyhwm++; | ||
| 158308 | assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); | ||
| 158309 | } | ||
| 158310 | #endif | ||
| 158311 | #if YYSTACKDEPTH>0 | ||
| 158312 | if( yypParser->yytos>=yypParser->yystackEnd ){ | ||
| 158313 | yyStackOverflow(yypParser); | ||
| 158314 | /* The call to yyStackOverflow() above pops the stack until it is | ||
| 158315 | ** empty, causing the main parser loop to exit. So the return value | ||
| 158316 | ** is never used and does not matter. */ | ||
| 158317 | return 0; | ||
| 158318 | } | ||
| 158319 | #else | ||
| 158320 | if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ | ||
| 158321 | if( yyGrowStack(yypParser) ){ | ||
| 158322 | yyStackOverflow(yypParser); | ||
| 158323 | /* The call to yyStackOverflow() above pops the stack until it is | ||
| 158324 | ** empty, causing the main parser loop to exit. So the return value | ||
| 158325 | ** is never used and does not matter. */ | ||
| 158326 | return 0; | ||
| 158327 | } | ||
| 158328 | yymsp = yypParser->yytos; | ||
| 158329 | } | ||
| 158330 | #endif | ||
| 158331 | } | ||
| 158332 | 160408 | ||
| 158333 | switch( yyruleno ){ | 160409 | switch( yyruleno ){ |
| 158334 | /* Beginning here are the reduction cases. A typical example | 160410 | /* Beginning here are the reduction cases. A typical example |
| @@ -158351,16 +160427,16 @@ static YYACTIONTYPE yy_reduce( | |||
| 158351 | { sqlite3FinishCoding(pParse); } | 160427 | { sqlite3FinishCoding(pParse); } |
| 158352 | break; | 160428 | break; |
| 158353 | case 3: /* cmd ::= BEGIN transtype trans_opt */ | 160429 | case 3: /* cmd ::= BEGIN transtype trans_opt */ |
| 158354 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy192);} | 160430 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy60);} |
| 158355 | break; | 160431 | break; |
| 158356 | case 4: /* transtype ::= */ | 160432 | case 4: /* transtype ::= */ |
| 158357 | {yymsp[1].minor.yy192 = TK_DEFERRED;} | 160433 | {yymsp[1].minor.yy60 = TK_DEFERRED;} |
| 158358 | break; | 160434 | break; |
| 158359 | case 5: /* transtype ::= DEFERRED */ | 160435 | case 5: /* transtype ::= DEFERRED */ |
| 158360 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); | 160436 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 158361 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); | 160437 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 158362 | case 306: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==306); | 160438 | case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318); |
| 158363 | {yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-X*/} | 160439 | {yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/} |
| 158364 | break; | 160440 | break; |
| 158365 | case 8: /* cmd ::= COMMIT|END trans_opt */ | 160441 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 158366 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); | 160442 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| @@ -158383,7 +160459,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 158383 | break; | 160459 | break; |
| 158384 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ | 160460 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 158385 | { | 160461 | { |
| 158386 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy192,0,0,yymsp[-2].minor.yy192); | 160462 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy60,0,0,yymsp[-2].minor.yy60); |
| 158387 | } | 160463 | } |
| 158388 | break; | 160464 | break; |
| 158389 | case 14: /* createkw ::= CREATE */ | 160465 | case 14: /* createkw ::= CREATE */ |
| @@ -158397,33 +160473,33 @@ static YYACTIONTYPE yy_reduce( | |||
| 158397 | case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70); | 160473 | case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70); |
| 158398 | case 79: /* ifexists ::= */ yytestcase(yyruleno==79); | 160474 | case 79: /* ifexists ::= */ yytestcase(yyruleno==79); |
| 158399 | case 96: /* distinct ::= */ yytestcase(yyruleno==96); | 160475 | case 96: /* distinct ::= */ yytestcase(yyruleno==96); |
| 158400 | case 232: /* collate ::= */ yytestcase(yyruleno==232); | 160476 | case 239: /* collate ::= */ yytestcase(yyruleno==239); |
| 158401 | {yymsp[1].minor.yy192 = 0;} | 160477 | {yymsp[1].minor.yy60 = 0;} |
| 158402 | break; | 160478 | break; |
| 158403 | case 16: /* ifnotexists ::= IF NOT EXISTS */ | 160479 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 158404 | {yymsp[-2].minor.yy192 = 1;} | 160480 | {yymsp[-2].minor.yy60 = 1;} |
| 158405 | break; | 160481 | break; |
| 158406 | case 17: /* temp ::= TEMP */ | 160482 | case 17: /* temp ::= TEMP */ |
| 158407 | case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46); | 160483 | case 46: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==46); |
| 158408 | {yymsp[0].minor.yy192 = 1;} | 160484 | {yymsp[0].minor.yy60 = 1;} |
| 158409 | break; | 160485 | break; |
| 158410 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ | 160486 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 158411 | { | 160487 | { |
| 158412 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy192,0); | 160488 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy60,0); |
| 158413 | } | 160489 | } |
| 158414 | break; | 160490 | break; |
| 158415 | case 20: /* create_table_args ::= AS select */ | 160491 | case 20: /* create_table_args ::= AS select */ |
| 158416 | { | 160492 | { |
| 158417 | sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy539); | 160493 | sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy307); |
| 158418 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy539); | 160494 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307); |
| 158419 | } | 160495 | } |
| 158420 | break; | 160496 | break; |
| 158421 | case 22: /* table_options ::= WITHOUT nm */ | 160497 | case 22: /* table_options ::= WITHOUT nm */ |
| 158422 | { | 160498 | { |
| 158423 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ | 160499 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ |
| 158424 | yymsp[-1].minor.yy192 = TF_WithoutRowid | TF_NoVisibleRowid; | 160500 | yymsp[-1].minor.yy60 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 158425 | }else{ | 160501 | }else{ |
| 158426 | yymsp[-1].minor.yy192 = 0; | 160502 | yymsp[-1].minor.yy60 = 0; |
| 158427 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); | 160503 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 158428 | } | 160504 | } |
| 158429 | } | 160505 | } |
| @@ -158452,7 +160528,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 158452 | case 28: /* scanpt ::= */ | 160528 | case 28: /* scanpt ::= */ |
| 158453 | { | 160529 | { |
| 158454 | assert( yyLookahead!=YYNOCODE ); | 160530 | assert( yyLookahead!=YYNOCODE ); |
| 158455 | yymsp[1].minor.yy436 = yyLookaheadToken.z; | 160531 | yymsp[1].minor.yy528 = yyLookaheadToken.z; |
| 158456 | } | 160532 | } |
| 158457 | break; | 160533 | break; |
| 158458 | case 29: /* scantok ::= */ | 160534 | case 29: /* scantok ::= */ |
| @@ -158466,17 +160542,17 @@ static YYACTIONTYPE yy_reduce( | |||
| 158466 | {pParse->constraintName = yymsp[0].minor.yy0;} | 160542 | {pParse->constraintName = yymsp[0].minor.yy0;} |
| 158467 | break; | 160543 | break; |
| 158468 | case 31: /* ccons ::= DEFAULT scantok term */ | 160544 | case 31: /* ccons ::= DEFAULT scantok term */ |
| 158469 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} | 160545 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 158470 | break; | 160546 | break; |
| 158471 | case 32: /* ccons ::= DEFAULT LP expr RP */ | 160547 | case 32: /* ccons ::= DEFAULT LP expr RP */ |
| 158472 | {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy202,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} | 160548 | {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} |
| 158473 | break; | 160549 | break; |
| 158474 | case 33: /* ccons ::= DEFAULT PLUS scantok term */ | 160550 | case 33: /* ccons ::= DEFAULT PLUS scantok term */ |
| 158475 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy202,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} | 160551 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy602,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 158476 | break; | 160552 | break; |
| 158477 | case 34: /* ccons ::= DEFAULT MINUS scantok term */ | 160553 | case 34: /* ccons ::= DEFAULT MINUS scantok term */ |
| 158478 | { | 160554 | { |
| 158479 | Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy202, 0); | 160555 | Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy602, 0); |
| 158480 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); | 160556 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); |
| 158481 | } | 160557 | } |
| 158482 | break; | 160558 | break; |
| @@ -158491,176 +160567,158 @@ static YYACTIONTYPE yy_reduce( | |||
| 158491 | } | 160567 | } |
| 158492 | break; | 160568 | break; |
| 158493 | case 36: /* ccons ::= NOT NULL onconf */ | 160569 | case 36: /* ccons ::= NOT NULL onconf */ |
| 158494 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy192);} | 160570 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy60);} |
| 158495 | break; | 160571 | break; |
| 158496 | case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ | 160572 | case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 158497 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy192,yymsp[0].minor.yy192,yymsp[-2].minor.yy192);} | 160573 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy60,yymsp[0].minor.yy60,yymsp[-2].minor.yy60);} |
| 158498 | break; | 160574 | break; |
| 158499 | case 38: /* ccons ::= UNIQUE onconf */ | 160575 | case 38: /* ccons ::= UNIQUE onconf */ |
| 158500 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy192,0,0,0,0, | 160576 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy60,0,0,0,0, |
| 158501 | SQLITE_IDXTYPE_UNIQUE);} | 160577 | SQLITE_IDXTYPE_UNIQUE);} |
| 158502 | break; | 160578 | break; |
| 158503 | case 39: /* ccons ::= CHECK LP expr RP */ | 160579 | case 39: /* ccons ::= CHECK LP expr RP */ |
| 158504 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy202,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} | 160580 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy602,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} |
| 158505 | break; | 160581 | break; |
| 158506 | case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */ | 160582 | case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 158507 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy242,yymsp[0].minor.yy192);} | 160583 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy338,yymsp[0].minor.yy60);} |
| 158508 | break; | 160584 | break; |
| 158509 | case 41: /* ccons ::= defer_subclause */ | 160585 | case 41: /* ccons ::= defer_subclause */ |
| 158510 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy192);} | 160586 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy60);} |
| 158511 | break; | 160587 | break; |
| 158512 | case 42: /* ccons ::= COLLATE ID|STRING */ | 160588 | case 42: /* ccons ::= COLLATE ID|STRING */ |
| 158513 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} | 160589 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 158514 | break; | 160590 | break; |
| 158515 | case 43: /* generated ::= LP expr RP */ | 160591 | case 43: /* generated ::= LP expr RP */ |
| 158516 | {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy202,0);} | 160592 | {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy602,0);} |
| 158517 | break; | 160593 | break; |
| 158518 | case 44: /* generated ::= LP expr RP ID */ | 160594 | case 44: /* generated ::= LP expr RP ID */ |
| 158519 | {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy202,&yymsp[0].minor.yy0);} | 160595 | {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy602,&yymsp[0].minor.yy0);} |
| 158520 | break; | 160596 | break; |
| 158521 | case 47: /* refargs ::= */ | 160597 | case 47: /* refargs ::= */ |
| 158522 | { yymsp[1].minor.yy192 = OE_None*0x0101; /* EV: R-19803-45884 */} | 160598 | { yymsp[1].minor.yy60 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 158523 | break; | 160599 | break; |
| 158524 | case 48: /* refargs ::= refargs refarg */ | 160600 | case 48: /* refargs ::= refargs refarg */ |
| 158525 | { yymsp[-1].minor.yy192 = (yymsp[-1].minor.yy192 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; } | 160601 | { yymsp[-1].minor.yy60 = (yymsp[-1].minor.yy60 & ~yymsp[0].minor.yy615.mask) | yymsp[0].minor.yy615.value; } |
| 158526 | break; | 160602 | break; |
| 158527 | case 49: /* refarg ::= MATCH nm */ | 160603 | case 49: /* refarg ::= MATCH nm */ |
| 158528 | { yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; } | 160604 | { yymsp[-1].minor.yy615.value = 0; yymsp[-1].minor.yy615.mask = 0x000000; } |
| 158529 | break; | 160605 | break; |
| 158530 | case 50: /* refarg ::= ON INSERT refact */ | 160606 | case 50: /* refarg ::= ON INSERT refact */ |
| 158531 | { yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; } | 160607 | { yymsp[-2].minor.yy615.value = 0; yymsp[-2].minor.yy615.mask = 0x000000; } |
| 158532 | break; | 160608 | break; |
| 158533 | case 51: /* refarg ::= ON DELETE refact */ | 160609 | case 51: /* refarg ::= ON DELETE refact */ |
| 158534 | { yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192; yymsp[-2].minor.yy207.mask = 0x0000ff; } | 160610 | { yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60; yymsp[-2].minor.yy615.mask = 0x0000ff; } |
| 158535 | break; | 160611 | break; |
| 158536 | case 52: /* refarg ::= ON UPDATE refact */ | 160612 | case 52: /* refarg ::= ON UPDATE refact */ |
| 158537 | { yymsp[-2].minor.yy207.value = yymsp[0].minor.yy192<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; } | 160613 | { yymsp[-2].minor.yy615.value = yymsp[0].minor.yy60<<8; yymsp[-2].minor.yy615.mask = 0x00ff00; } |
| 158538 | break; | 160614 | break; |
| 158539 | case 53: /* refact ::= SET NULL */ | 160615 | case 53: /* refact ::= SET NULL */ |
| 158540 | { yymsp[-1].minor.yy192 = OE_SetNull; /* EV: R-33326-45252 */} | 160616 | { yymsp[-1].minor.yy60 = OE_SetNull; /* EV: R-33326-45252 */} |
| 158541 | break; | 160617 | break; |
| 158542 | case 54: /* refact ::= SET DEFAULT */ | 160618 | case 54: /* refact ::= SET DEFAULT */ |
| 158543 | { yymsp[-1].minor.yy192 = OE_SetDflt; /* EV: R-33326-45252 */} | 160619 | { yymsp[-1].minor.yy60 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 158544 | break; | 160620 | break; |
| 158545 | case 55: /* refact ::= CASCADE */ | 160621 | case 55: /* refact ::= CASCADE */ |
| 158546 | { yymsp[0].minor.yy192 = OE_Cascade; /* EV: R-33326-45252 */} | 160622 | { yymsp[0].minor.yy60 = OE_Cascade; /* EV: R-33326-45252 */} |
| 158547 | break; | 160623 | break; |
| 158548 | case 56: /* refact ::= RESTRICT */ | 160624 | case 56: /* refact ::= RESTRICT */ |
| 158549 | { yymsp[0].minor.yy192 = OE_Restrict; /* EV: R-33326-45252 */} | 160625 | { yymsp[0].minor.yy60 = OE_Restrict; /* EV: R-33326-45252 */} |
| 158550 | break; | 160626 | break; |
| 158551 | case 57: /* refact ::= NO ACTION */ | 160627 | case 57: /* refact ::= NO ACTION */ |
| 158552 | { yymsp[-1].minor.yy192 = OE_None; /* EV: R-33326-45252 */} | 160628 | { yymsp[-1].minor.yy60 = OE_None; /* EV: R-33326-45252 */} |
| 158553 | break; | 160629 | break; |
| 158554 | case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ | 160630 | case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 158555 | {yymsp[-2].minor.yy192 = 0;} | 160631 | {yymsp[-2].minor.yy60 = 0;} |
| 158556 | break; | 160632 | break; |
| 158557 | case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ | 160633 | case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 158558 | case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74); | 160634 | case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74); |
| 158559 | case 162: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==162); | 160635 | case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169); |
| 158560 | {yymsp[-1].minor.yy192 = yymsp[0].minor.yy192;} | 160636 | {yymsp[-1].minor.yy60 = yymsp[0].minor.yy60;} |
| 158561 | break; | 160637 | break; |
| 158562 | case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 160638 | case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 158563 | case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78); | 160639 | case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78); |
| 158564 | case 204: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==204); | 160640 | case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211); |
| 158565 | case 207: /* in_op ::= NOT IN */ yytestcase(yyruleno==207); | 160641 | case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214); |
| 158566 | case 233: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==233); | 160642 | case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240); |
| 158567 | {yymsp[-1].minor.yy192 = 1;} | 160643 | {yymsp[-1].minor.yy60 = 1;} |
| 158568 | break; | 160644 | break; |
| 158569 | case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 160645 | case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 158570 | {yymsp[-1].minor.yy192 = 0;} | 160646 | {yymsp[-1].minor.yy60 = 0;} |
| 158571 | break; | 160647 | break; |
| 158572 | case 64: /* tconscomma ::= COMMA */ | 160648 | case 64: /* tconscomma ::= COMMA */ |
| 158573 | {pParse->constraintName.n = 0;} | 160649 | {pParse->constraintName.n = 0;} |
| 158574 | break; | 160650 | break; |
| 158575 | case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ | 160651 | case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 158576 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy242,yymsp[0].minor.yy192,yymsp[-2].minor.yy192,0);} | 160652 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy338,yymsp[0].minor.yy60,yymsp[-2].minor.yy60,0);} |
| 158577 | break; | 160653 | break; |
| 158578 | case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */ | 160654 | case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */ |
| 158579 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy242,yymsp[0].minor.yy192,0,0,0,0, | 160655 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy338,yymsp[0].minor.yy60,0,0,0,0, |
| 158580 | SQLITE_IDXTYPE_UNIQUE);} | 160656 | SQLITE_IDXTYPE_UNIQUE);} |
| 158581 | break; | 160657 | break; |
| 158582 | case 68: /* tcons ::= CHECK LP expr RP onconf */ | 160658 | case 68: /* tcons ::= CHECK LP expr RP onconf */ |
| 158583 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy202,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} | 160659 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy602,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} |
| 158584 | break; | 160660 | break; |
| 158585 | case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ | 160661 | case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 158586 | { | 160662 | { |
| 158587 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy242, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[-1].minor.yy192); | 160663 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy338, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[-1].minor.yy60); |
| 158588 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy192); | 160664 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy60); |
| 158589 | } | 160665 | } |
| 158590 | break; | 160666 | break; |
| 158591 | case 71: /* onconf ::= */ | 160667 | case 71: /* onconf ::= */ |
| 158592 | case 73: /* orconf ::= */ yytestcase(yyruleno==73); | 160668 | case 73: /* orconf ::= */ yytestcase(yyruleno==73); |
| 158593 | {yymsp[1].minor.yy192 = OE_Default;} | 160669 | {yymsp[1].minor.yy60 = OE_Default;} |
| 158594 | break; | 160670 | break; |
| 158595 | case 72: /* onconf ::= ON CONFLICT resolvetype */ | 160671 | case 72: /* onconf ::= ON CONFLICT resolvetype */ |
| 158596 | {yymsp[-2].minor.yy192 = yymsp[0].minor.yy192;} | 160672 | {yymsp[-2].minor.yy60 = yymsp[0].minor.yy60;} |
| 158597 | break; | 160673 | break; |
| 158598 | case 75: /* resolvetype ::= IGNORE */ | 160674 | case 75: /* resolvetype ::= IGNORE */ |
| 158599 | {yymsp[0].minor.yy192 = OE_Ignore;} | 160675 | {yymsp[0].minor.yy60 = OE_Ignore;} |
| 158600 | break; | 160676 | break; |
| 158601 | case 76: /* resolvetype ::= REPLACE */ | 160677 | case 76: /* resolvetype ::= REPLACE */ |
| 158602 | case 163: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==163); | 160678 | case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170); |
| 158603 | {yymsp[0].minor.yy192 = OE_Replace;} | 160679 | {yymsp[0].minor.yy60 = OE_Replace;} |
| 158604 | break; | 160680 | break; |
| 158605 | case 77: /* cmd ::= DROP TABLE ifexists fullname */ | 160681 | case 77: /* cmd ::= DROP TABLE ifexists fullname */ |
| 158606 | { | 160682 | { |
| 158607 | sqlite3DropTable(pParse, yymsp[0].minor.yy47, 0, yymsp[-1].minor.yy192); | 160683 | sqlite3DropTable(pParse, yymsp[0].minor.yy291, 0, yymsp[-1].minor.yy60); |
| 158608 | } | 160684 | } |
| 158609 | break; | 160685 | break; |
| 158610 | case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ | 160686 | case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 158611 | { | 160687 | { |
| 158612 | sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy242, yymsp[0].minor.yy539, yymsp[-7].minor.yy192, yymsp[-5].minor.yy192); | 160688 | sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy338, yymsp[0].minor.yy307, yymsp[-7].minor.yy60, yymsp[-5].minor.yy60); |
| 158613 | } | 160689 | } |
| 158614 | break; | 160690 | break; |
| 158615 | case 81: /* cmd ::= DROP VIEW ifexists fullname */ | 160691 | case 81: /* cmd ::= DROP VIEW ifexists fullname */ |
| 158616 | { | 160692 | { |
| 158617 | sqlite3DropTable(pParse, yymsp[0].minor.yy47, 1, yymsp[-1].minor.yy192); | 160693 | sqlite3DropTable(pParse, yymsp[0].minor.yy291, 1, yymsp[-1].minor.yy60); |
| 158618 | } | 160694 | } |
| 158619 | break; | 160695 | break; |
| 158620 | case 82: /* cmd ::= select */ | 160696 | case 82: /* cmd ::= select */ |
| 158621 | { | 160697 | { |
| 158622 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; | 160698 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; |
| 158623 | sqlite3Select(pParse, yymsp[0].minor.yy539, &dest); | 160699 | sqlite3Select(pParse, yymsp[0].minor.yy307, &dest); |
| 158624 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy539); | 160700 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy307); |
| 158625 | } | 160701 | } |
| 158626 | break; | 160702 | break; |
| 158627 | case 83: /* select ::= WITH wqlist selectnowith */ | 160703 | case 83: /* select ::= WITH wqlist selectnowith */ |
| 158628 | { | 160704 | {yymsp[-2].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);} |
| 158629 | Select *p = yymsp[0].minor.yy539; | ||
| 158630 | if( p ){ | ||
| 158631 | p->pWith = yymsp[-1].minor.yy131; | ||
| 158632 | parserDoubleLinkSelect(pParse, p); | ||
| 158633 | }else{ | ||
| 158634 | sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131); | ||
| 158635 | } | ||
| 158636 | yymsp[-2].minor.yy539 = p; | ||
| 158637 | } | ||
| 158638 | break; | 160705 | break; |
| 158639 | case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */ | 160706 | case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */ |
| 158640 | { | 160707 | {yymsp[-3].minor.yy307 = attachWithToSelect(pParse,yymsp[0].minor.yy307,yymsp[-1].minor.yy195);} |
| 158641 | Select *p = yymsp[0].minor.yy539; | ||
| 158642 | if( p ){ | ||
| 158643 | p->pWith = yymsp[-1].minor.yy131; | ||
| 158644 | parserDoubleLinkSelect(pParse, p); | ||
| 158645 | }else{ | ||
| 158646 | sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy131); | ||
| 158647 | } | ||
| 158648 | yymsp[-3].minor.yy539 = p; | ||
| 158649 | } | ||
| 158650 | break; | 160708 | break; |
| 158651 | case 85: /* select ::= selectnowith */ | 160709 | case 85: /* select ::= selectnowith */ |
| 158652 | { | 160710 | { |
| 158653 | Select *p = yymsp[0].minor.yy539; | 160711 | Select *p = yymsp[0].minor.yy307; |
| 158654 | if( p ){ | 160712 | if( p ){ |
| 158655 | parserDoubleLinkSelect(pParse, p); | 160713 | parserDoubleLinkSelect(pParse, p); |
| 158656 | } | 160714 | } |
| 158657 | yymsp[0].minor.yy539 = p; /*A-overwrites-X*/ | 160715 | yymsp[0].minor.yy307 = p; /*A-overwrites-X*/ |
| 158658 | } | 160716 | } |
| 158659 | break; | 160717 | break; |
| 158660 | case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */ | 160718 | case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */ |
| 158661 | { | 160719 | { |
| 158662 | Select *pRhs = yymsp[0].minor.yy539; | 160720 | Select *pRhs = yymsp[0].minor.yy307; |
| 158663 | Select *pLhs = yymsp[-2].minor.yy539; | 160721 | Select *pLhs = yymsp[-2].minor.yy307; |
| 158664 | if( pRhs && pRhs->pPrior ){ | 160722 | if( pRhs && pRhs->pPrior ){ |
| 158665 | SrcList *pFrom; | 160723 | SrcList *pFrom; |
| 158666 | Token x; | 160724 | Token x; |
| @@ -158670,83 +160728,83 @@ static YYACTIONTYPE yy_reduce( | |||
| 158670 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); | 160728 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); |
| 158671 | } | 160729 | } |
| 158672 | if( pRhs ){ | 160730 | if( pRhs ){ |
| 158673 | pRhs->op = (u8)yymsp[-1].minor.yy192; | 160731 | pRhs->op = (u8)yymsp[-1].minor.yy60; |
| 158674 | pRhs->pPrior = pLhs; | 160732 | pRhs->pPrior = pLhs; |
| 158675 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; | 160733 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; |
| 158676 | pRhs->selFlags &= ~SF_MultiValue; | 160734 | pRhs->selFlags &= ~SF_MultiValue; |
| 158677 | if( yymsp[-1].minor.yy192!=TK_ALL ) pParse->hasCompound = 1; | 160735 | if( yymsp[-1].minor.yy60!=TK_ALL ) pParse->hasCompound = 1; |
| 158678 | }else{ | 160736 | }else{ |
| 158679 | sqlite3SelectDelete(pParse->db, pLhs); | 160737 | sqlite3SelectDelete(pParse->db, pLhs); |
| 158680 | } | 160738 | } |
| 158681 | yymsp[-2].minor.yy539 = pRhs; | 160739 | yymsp[-2].minor.yy307 = pRhs; |
| 158682 | } | 160740 | } |
| 158683 | break; | 160741 | break; |
| 158684 | case 87: /* multiselect_op ::= UNION */ | 160742 | case 87: /* multiselect_op ::= UNION */ |
| 158685 | case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89); | 160743 | case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89); |
| 158686 | {yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-OP*/} | 160744 | {yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-OP*/} |
| 158687 | break; | 160745 | break; |
| 158688 | case 88: /* multiselect_op ::= UNION ALL */ | 160746 | case 88: /* multiselect_op ::= UNION ALL */ |
| 158689 | {yymsp[-1].minor.yy192 = TK_ALL;} | 160747 | {yymsp[-1].minor.yy60 = TK_ALL;} |
| 158690 | break; | 160748 | break; |
| 158691 | case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ | 160749 | case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 158692 | { | 160750 | { |
| 158693 | yymsp[-8].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy242,yymsp[-5].minor.yy47,yymsp[-4].minor.yy202,yymsp[-3].minor.yy242,yymsp[-2].minor.yy202,yymsp[-1].minor.yy242,yymsp[-7].minor.yy192,yymsp[0].minor.yy202); | 160751 | yymsp[-8].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy338,yymsp[-5].minor.yy291,yymsp[-4].minor.yy602,yymsp[-3].minor.yy338,yymsp[-2].minor.yy602,yymsp[-1].minor.yy338,yymsp[-7].minor.yy60,yymsp[0].minor.yy602); |
| 158694 | } | 160752 | } |
| 158695 | break; | 160753 | break; |
| 158696 | case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ | 160754 | case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 158697 | { | 160755 | { |
| 158698 | yymsp[-9].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy242,yymsp[-6].minor.yy47,yymsp[-5].minor.yy202,yymsp[-4].minor.yy242,yymsp[-3].minor.yy202,yymsp[-1].minor.yy242,yymsp[-8].minor.yy192,yymsp[0].minor.yy202); | 160756 | yymsp[-9].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy338,yymsp[-6].minor.yy291,yymsp[-5].minor.yy602,yymsp[-4].minor.yy338,yymsp[-3].minor.yy602,yymsp[-1].minor.yy338,yymsp[-8].minor.yy60,yymsp[0].minor.yy602); |
| 158699 | if( yymsp[-9].minor.yy539 ){ | 160757 | if( yymsp[-9].minor.yy307 ){ |
| 158700 | yymsp[-9].minor.yy539->pWinDefn = yymsp[-2].minor.yy303; | 160758 | yymsp[-9].minor.yy307->pWinDefn = yymsp[-2].minor.yy19; |
| 158701 | }else{ | 160759 | }else{ |
| 158702 | sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy303); | 160760 | sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy19); |
| 158703 | } | 160761 | } |
| 158704 | } | 160762 | } |
| 158705 | break; | 160763 | break; |
| 158706 | case 92: /* values ::= VALUES LP nexprlist RP */ | 160764 | case 92: /* values ::= VALUES LP nexprlist RP */ |
| 158707 | { | 160765 | { |
| 158708 | yymsp[-3].minor.yy539 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values,0); | 160766 | yymsp[-3].minor.yy307 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values,0); |
| 158709 | } | 160767 | } |
| 158710 | break; | 160768 | break; |
| 158711 | case 93: /* values ::= values COMMA LP nexprlist RP */ | 160769 | case 93: /* values ::= values COMMA LP nexprlist RP */ |
| 158712 | { | 160770 | { |
| 158713 | Select *pRight, *pLeft = yymsp[-4].minor.yy539; | 160771 | Select *pRight, *pLeft = yymsp[-4].minor.yy307; |
| 158714 | pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy242,0,0,0,0,0,SF_Values|SF_MultiValue,0); | 160772 | pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy338,0,0,0,0,0,SF_Values|SF_MultiValue,0); |
| 158715 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; | 160773 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; |
| 158716 | if( pRight ){ | 160774 | if( pRight ){ |
| 158717 | pRight->op = TK_ALL; | 160775 | pRight->op = TK_ALL; |
| 158718 | pRight->pPrior = pLeft; | 160776 | pRight->pPrior = pLeft; |
| 158719 | yymsp[-4].minor.yy539 = pRight; | 160777 | yymsp[-4].minor.yy307 = pRight; |
| 158720 | }else{ | 160778 | }else{ |
| 158721 | yymsp[-4].minor.yy539 = pLeft; | 160779 | yymsp[-4].minor.yy307 = pLeft; |
| 158722 | } | 160780 | } |
| 158723 | } | 160781 | } |
| 158724 | break; | 160782 | break; |
| 158725 | case 94: /* distinct ::= DISTINCT */ | 160783 | case 94: /* distinct ::= DISTINCT */ |
| 158726 | {yymsp[0].minor.yy192 = SF_Distinct;} | 160784 | {yymsp[0].minor.yy60 = SF_Distinct;} |
| 158727 | break; | 160785 | break; |
| 158728 | case 95: /* distinct ::= ALL */ | 160786 | case 95: /* distinct ::= ALL */ |
| 158729 | {yymsp[0].minor.yy192 = SF_All;} | 160787 | {yymsp[0].minor.yy60 = SF_All;} |
| 158730 | break; | 160788 | break; |
| 158731 | case 97: /* sclp ::= */ | 160789 | case 97: /* sclp ::= */ |
| 158732 | case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130); | 160790 | case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130); |
| 158733 | case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140); | 160791 | case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140); |
| 158734 | case 220: /* exprlist ::= */ yytestcase(yyruleno==220); | 160792 | case 227: /* exprlist ::= */ yytestcase(yyruleno==227); |
| 158735 | case 223: /* paren_exprlist ::= */ yytestcase(yyruleno==223); | 160793 | case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230); |
| 158736 | case 228: /* eidlist_opt ::= */ yytestcase(yyruleno==228); | 160794 | case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235); |
| 158737 | {yymsp[1].minor.yy242 = 0;} | 160795 | {yymsp[1].minor.yy338 = 0;} |
| 158738 | break; | 160796 | break; |
| 158739 | case 98: /* selcollist ::= sclp scanpt expr scanpt as */ | 160797 | case 98: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 158740 | { | 160798 | { |
| 158741 | yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[-2].minor.yy202); | 160799 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[-2].minor.yy602); |
| 158742 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[0].minor.yy0, 1); | 160800 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[0].minor.yy0, 1); |
| 158743 | sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy242,yymsp[-3].minor.yy436,yymsp[-1].minor.yy436); | 160801 | sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy338,yymsp[-3].minor.yy528,yymsp[-1].minor.yy528); |
| 158744 | } | 160802 | } |
| 158745 | break; | 160803 | break; |
| 158746 | case 99: /* selcollist ::= sclp scanpt STAR */ | 160804 | case 99: /* selcollist ::= sclp scanpt STAR */ |
| 158747 | { | 160805 | { |
| 158748 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); | 160806 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); |
| 158749 | yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy242, p); | 160807 | yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy338, p); |
| 158750 | } | 160808 | } |
| 158751 | break; | 160809 | break; |
| 158752 | case 100: /* selcollist ::= sclp scanpt nm DOT STAR */ | 160810 | case 100: /* selcollist ::= sclp scanpt nm DOT STAR */ |
| @@ -158754,56 +160812,56 @@ static YYACTIONTYPE yy_reduce( | |||
| 158754 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); | 160812 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); |
| 158755 | Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); | 160813 | Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| 158756 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); | 160814 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); |
| 158757 | yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, pDot); | 160815 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, pDot); |
| 158758 | } | 160816 | } |
| 158759 | break; | 160817 | break; |
| 158760 | case 101: /* as ::= AS nm */ | 160818 | case 101: /* as ::= AS nm */ |
| 158761 | case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112); | 160819 | case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112); |
| 158762 | case 244: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==244); | 160820 | case 251: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==251); |
| 158763 | case 245: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==245); | 160821 | case 252: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==252); |
| 158764 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} | 160822 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 158765 | break; | 160823 | break; |
| 158766 | case 103: /* from ::= */ | 160824 | case 103: /* from ::= */ |
| 158767 | case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106); | 160825 | case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106); |
| 158768 | {yymsp[1].minor.yy47 = 0;} | 160826 | {yymsp[1].minor.yy291 = 0;} |
| 158769 | break; | 160827 | break; |
| 158770 | case 104: /* from ::= FROM seltablist */ | 160828 | case 104: /* from ::= FROM seltablist */ |
| 158771 | { | 160829 | { |
| 158772 | yymsp[-1].minor.yy47 = yymsp[0].minor.yy47; | 160830 | yymsp[-1].minor.yy291 = yymsp[0].minor.yy291; |
| 158773 | sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy47); | 160831 | sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy291); |
| 158774 | } | 160832 | } |
| 158775 | break; | 160833 | break; |
| 158776 | case 105: /* stl_prefix ::= seltablist joinop */ | 160834 | case 105: /* stl_prefix ::= seltablist joinop */ |
| 158777 | { | 160835 | { |
| 158778 | if( ALWAYS(yymsp[-1].minor.yy47 && yymsp[-1].minor.yy47->nSrc>0) ) yymsp[-1].minor.yy47->a[yymsp[-1].minor.yy47->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy192; | 160836 | if( ALWAYS(yymsp[-1].minor.yy291 && yymsp[-1].minor.yy291->nSrc>0) ) yymsp[-1].minor.yy291->a[yymsp[-1].minor.yy291->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy60; |
| 158779 | } | 160837 | } |
| 158780 | break; | 160838 | break; |
| 158781 | case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ | 160839 | case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 158782 | { | 160840 | { |
| 158783 | yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); | 160841 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); |
| 158784 | sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy47, &yymsp[-2].minor.yy0); | 160842 | sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy291, &yymsp[-2].minor.yy0); |
| 158785 | } | 160843 | } |
| 158786 | break; | 160844 | break; |
| 158787 | case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ | 160845 | case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 158788 | { | 160846 | { |
| 158789 | yymsp[-8].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy47,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); | 160847 | yymsp[-8].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy291,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); |
| 158790 | sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy47, yymsp[-4].minor.yy242); | 160848 | sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy291, yymsp[-4].minor.yy338); |
| 158791 | } | 160849 | } |
| 158792 | break; | 160850 | break; |
| 158793 | case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ | 160851 | case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 158794 | { | 160852 | { |
| 158795 | yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy539,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); | 160853 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy307,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); |
| 158796 | } | 160854 | } |
| 158797 | break; | 160855 | break; |
| 158798 | case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ | 160856 | case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 158799 | { | 160857 | { |
| 158800 | if( yymsp[-6].minor.yy47==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy202==0 && yymsp[0].minor.yy600==0 ){ | 160858 | if( yymsp[-6].minor.yy291==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy602==0 && yymsp[0].minor.yy288==0 ){ |
| 158801 | yymsp[-6].minor.yy47 = yymsp[-4].minor.yy47; | 160859 | yymsp[-6].minor.yy291 = yymsp[-4].minor.yy291; |
| 158802 | }else if( yymsp[-4].minor.yy47->nSrc==1 ){ | 160860 | }else if( yymsp[-4].minor.yy291->nSrc==1 ){ |
| 158803 | yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); | 160861 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); |
| 158804 | if( yymsp[-6].minor.yy47 ){ | 160862 | if( yymsp[-6].minor.yy291 ){ |
| 158805 | struct SrcList_item *pNew = &yymsp[-6].minor.yy47->a[yymsp[-6].minor.yy47->nSrc-1]; | 160863 | SrcItem *pNew = &yymsp[-6].minor.yy291->a[yymsp[-6].minor.yy291->nSrc-1]; |
| 158806 | struct SrcList_item *pOld = yymsp[-4].minor.yy47->a; | 160864 | SrcItem *pOld = yymsp[-4].minor.yy291->a; |
| 158807 | pNew->zName = pOld->zName; | 160865 | pNew->zName = pOld->zName; |
| 158808 | pNew->zDatabase = pOld->zDatabase; | 160866 | pNew->zDatabase = pOld->zDatabase; |
| 158809 | pNew->pSelect = pOld->pSelect; | 160867 | pNew->pSelect = pOld->pSelect; |
| @@ -158816,12 +160874,12 @@ static YYACTIONTYPE yy_reduce( | |||
| 158816 | pOld->zName = pOld->zDatabase = 0; | 160874 | pOld->zName = pOld->zDatabase = 0; |
| 158817 | pOld->pSelect = 0; | 160875 | pOld->pSelect = 0; |
| 158818 | } | 160876 | } |
| 158819 | sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy47); | 160877 | sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy291); |
| 158820 | }else{ | 160878 | }else{ |
| 158821 | Select *pSubquery; | 160879 | Select *pSubquery; |
| 158822 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy47); | 160880 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy291); |
| 158823 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy47,0,0,0,0,SF_NestedFrom,0); | 160881 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy291,0,0,0,0,SF_NestedFrom,0); |
| 158824 | yymsp[-6].minor.yy47 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy47,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy202,yymsp[0].minor.yy600); | 160882 | yymsp[-6].minor.yy291 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy291,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy602,yymsp[0].minor.yy288); |
| 158825 | } | 160883 | } |
| 158826 | } | 160884 | } |
| 158827 | break; | 160885 | break; |
| @@ -158831,63 +160889,65 @@ static YYACTIONTYPE yy_reduce( | |||
| 158831 | break; | 160889 | break; |
| 158832 | case 113: /* fullname ::= nm */ | 160890 | case 113: /* fullname ::= nm */ |
| 158833 | { | 160891 | { |
| 158834 | yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); | 160892 | yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); |
| 158835 | if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0); | 160893 | if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0); |
| 158836 | } | 160894 | } |
| 158837 | yymsp[0].minor.yy47 = yylhsminor.yy47; | 160895 | yymsp[0].minor.yy291 = yylhsminor.yy291; |
| 158838 | break; | 160896 | break; |
| 158839 | case 114: /* fullname ::= nm DOT nm */ | 160897 | case 114: /* fullname ::= nm DOT nm */ |
| 158840 | { | 160898 | { |
| 158841 | yylhsminor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); | 160899 | yylhsminor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 158842 | if( IN_RENAME_OBJECT && yylhsminor.yy47 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy47->a[0].zName, &yymsp[0].minor.yy0); | 160900 | if( IN_RENAME_OBJECT && yylhsminor.yy291 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy291->a[0].zName, &yymsp[0].minor.yy0); |
| 158843 | } | 160901 | } |
| 158844 | yymsp[-2].minor.yy47 = yylhsminor.yy47; | 160902 | yymsp[-2].minor.yy291 = yylhsminor.yy291; |
| 158845 | break; | 160903 | break; |
| 158846 | case 115: /* xfullname ::= nm */ | 160904 | case 115: /* xfullname ::= nm */ |
| 158847 | {yymsp[0].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} | 160905 | {yymsp[0].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} |
| 158848 | break; | 160906 | break; |
| 158849 | case 116: /* xfullname ::= nm DOT nm */ | 160907 | case 116: /* xfullname ::= nm DOT nm */ |
| 158850 | {yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} | 160908 | {yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 158851 | break; | 160909 | break; |
| 158852 | case 117: /* xfullname ::= nm DOT nm AS nm */ | 160910 | case 117: /* xfullname ::= nm DOT nm AS nm */ |
| 158853 | { | 160911 | { |
| 158854 | yymsp[-4].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ | 160912 | yymsp[-4].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ |
| 158855 | if( yymsp[-4].minor.yy47 ) yymsp[-4].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); | 160913 | if( yymsp[-4].minor.yy291 ) yymsp[-4].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 158856 | } | 160914 | } |
| 158857 | break; | 160915 | break; |
| 158858 | case 118: /* xfullname ::= nm AS nm */ | 160916 | case 118: /* xfullname ::= nm AS nm */ |
| 158859 | { | 160917 | { |
| 158860 | yymsp[-2].minor.yy47 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ | 160918 | yymsp[-2].minor.yy291 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ |
| 158861 | if( yymsp[-2].minor.yy47 ) yymsp[-2].minor.yy47->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); | 160919 | if( yymsp[-2].minor.yy291 ) yymsp[-2].minor.yy291->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 158862 | } | 160920 | } |
| 158863 | break; | 160921 | break; |
| 158864 | case 119: /* joinop ::= COMMA|JOIN */ | 160922 | case 119: /* joinop ::= COMMA|JOIN */ |
| 158865 | { yymsp[0].minor.yy192 = JT_INNER; } | 160923 | { yymsp[0].minor.yy60 = JT_INNER; } |
| 158866 | break; | 160924 | break; |
| 158867 | case 120: /* joinop ::= JOIN_KW JOIN */ | 160925 | case 120: /* joinop ::= JOIN_KW JOIN */ |
| 158868 | {yymsp[-1].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} | 160926 | {yymsp[-1].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 158869 | break; | 160927 | break; |
| 158870 | case 121: /* joinop ::= JOIN_KW nm JOIN */ | 160928 | case 121: /* joinop ::= JOIN_KW nm JOIN */ |
| 158871 | {yymsp[-2].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} | 160929 | {yymsp[-2].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 158872 | break; | 160930 | break; |
| 158873 | case 122: /* joinop ::= JOIN_KW nm nm JOIN */ | 160931 | case 122: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 158874 | {yymsp[-3].minor.yy192 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} | 160932 | {yymsp[-3].minor.yy60 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 158875 | break; | 160933 | break; |
| 158876 | case 123: /* on_opt ::= ON expr */ | 160934 | case 123: /* on_opt ::= ON expr */ |
| 158877 | case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143); | 160935 | case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143); |
| 158878 | case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150); | 160936 | case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150); |
| 158879 | case 216: /* case_else ::= ELSE expr */ yytestcase(yyruleno==216); | 160937 | case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152); |
| 158880 | case 237: /* vinto ::= INTO expr */ yytestcase(yyruleno==237); | 160938 | case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223); |
| 158881 | {yymsp[-1].minor.yy202 = yymsp[0].minor.yy202;} | 160939 | case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244); |
| 160940 | {yymsp[-1].minor.yy602 = yymsp[0].minor.yy602;} | ||
| 158882 | break; | 160941 | break; |
| 158883 | case 124: /* on_opt ::= */ | 160942 | case 124: /* on_opt ::= */ |
| 158884 | case 142: /* having_opt ::= */ yytestcase(yyruleno==142); | 160943 | case 142: /* having_opt ::= */ yytestcase(yyruleno==142); |
| 158885 | case 144: /* limit_opt ::= */ yytestcase(yyruleno==144); | 160944 | case 144: /* limit_opt ::= */ yytestcase(yyruleno==144); |
| 158886 | case 149: /* where_opt ::= */ yytestcase(yyruleno==149); | 160945 | case 149: /* where_opt ::= */ yytestcase(yyruleno==149); |
| 158887 | case 217: /* case_else ::= */ yytestcase(yyruleno==217); | 160946 | case 151: /* where_opt_ret ::= */ yytestcase(yyruleno==151); |
| 158888 | case 219: /* case_operand ::= */ yytestcase(yyruleno==219); | 160947 | case 224: /* case_else ::= */ yytestcase(yyruleno==224); |
| 158889 | case 238: /* vinto ::= */ yytestcase(yyruleno==238); | 160948 | case 226: /* case_operand ::= */ yytestcase(yyruleno==226); |
| 158890 | {yymsp[1].minor.yy202 = 0;} | 160949 | case 245: /* vinto ::= */ yytestcase(yyruleno==245); |
| 160950 | {yymsp[1].minor.yy602 = 0;} | ||
| 158891 | break; | 160951 | break; |
| 158892 | case 126: /* indexed_opt ::= INDEXED BY nm */ | 160952 | case 126: /* indexed_opt ::= INDEXED BY nm */ |
| 158893 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} | 160953 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| @@ -158896,129 +160956,144 @@ static YYACTIONTYPE yy_reduce( | |||
| 158896 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} | 160956 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} |
| 158897 | break; | 160957 | break; |
| 158898 | case 128: /* using_opt ::= USING LP idlist RP */ | 160958 | case 128: /* using_opt ::= USING LP idlist RP */ |
| 158899 | {yymsp[-3].minor.yy600 = yymsp[-1].minor.yy600;} | 160959 | {yymsp[-3].minor.yy288 = yymsp[-1].minor.yy288;} |
| 158900 | break; | 160960 | break; |
| 158901 | case 129: /* using_opt ::= */ | 160961 | case 129: /* using_opt ::= */ |
| 158902 | case 164: /* idlist_opt ::= */ yytestcase(yyruleno==164); | 160962 | case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171); |
| 158903 | {yymsp[1].minor.yy600 = 0;} | 160963 | {yymsp[1].minor.yy288 = 0;} |
| 158904 | break; | 160964 | break; |
| 158905 | case 131: /* orderby_opt ::= ORDER BY sortlist */ | 160965 | case 131: /* orderby_opt ::= ORDER BY sortlist */ |
| 158906 | case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141); | 160966 | case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141); |
| 158907 | {yymsp[-2].minor.yy242 = yymsp[0].minor.yy242;} | 160967 | {yymsp[-2].minor.yy338 = yymsp[0].minor.yy338;} |
| 158908 | break; | 160968 | break; |
| 158909 | case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */ | 160969 | case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 158910 | { | 160970 | { |
| 158911 | yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202); | 160971 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338,yymsp[-2].minor.yy602); |
| 158912 | sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192); | 160972 | sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60); |
| 158913 | } | 160973 | } |
| 158914 | break; | 160974 | break; |
| 158915 | case 133: /* sortlist ::= expr sortorder nulls */ | 160975 | case 133: /* sortlist ::= expr sortorder nulls */ |
| 158916 | { | 160976 | { |
| 158917 | yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy202); /*A-overwrites-Y*/ | 160977 | yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy602); /*A-overwrites-Y*/ |
| 158918 | sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy242,yymsp[-1].minor.yy192,yymsp[0].minor.yy192); | 160978 | sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy338,yymsp[-1].minor.yy60,yymsp[0].minor.yy60); |
| 158919 | } | 160979 | } |
| 158920 | break; | 160980 | break; |
| 158921 | case 134: /* sortorder ::= ASC */ | 160981 | case 134: /* sortorder ::= ASC */ |
| 158922 | {yymsp[0].minor.yy192 = SQLITE_SO_ASC;} | 160982 | {yymsp[0].minor.yy60 = SQLITE_SO_ASC;} |
| 158923 | break; | 160983 | break; |
| 158924 | case 135: /* sortorder ::= DESC */ | 160984 | case 135: /* sortorder ::= DESC */ |
| 158925 | {yymsp[0].minor.yy192 = SQLITE_SO_DESC;} | 160985 | {yymsp[0].minor.yy60 = SQLITE_SO_DESC;} |
| 158926 | break; | 160986 | break; |
| 158927 | case 136: /* sortorder ::= */ | 160987 | case 136: /* sortorder ::= */ |
| 158928 | case 139: /* nulls ::= */ yytestcase(yyruleno==139); | 160988 | case 139: /* nulls ::= */ yytestcase(yyruleno==139); |
| 158929 | {yymsp[1].minor.yy192 = SQLITE_SO_UNDEFINED;} | 160989 | {yymsp[1].minor.yy60 = SQLITE_SO_UNDEFINED;} |
| 158930 | break; | 160990 | break; |
| 158931 | case 137: /* nulls ::= NULLS FIRST */ | 160991 | case 137: /* nulls ::= NULLS FIRST */ |
| 158932 | {yymsp[-1].minor.yy192 = SQLITE_SO_ASC;} | 160992 | {yymsp[-1].minor.yy60 = SQLITE_SO_ASC;} |
| 158933 | break; | 160993 | break; |
| 158934 | case 138: /* nulls ::= NULLS LAST */ | 160994 | case 138: /* nulls ::= NULLS LAST */ |
| 158935 | {yymsp[-1].minor.yy192 = SQLITE_SO_DESC;} | 160995 | {yymsp[-1].minor.yy60 = SQLITE_SO_DESC;} |
| 158936 | break; | 160996 | break; |
| 158937 | case 145: /* limit_opt ::= LIMIT expr */ | 160997 | case 145: /* limit_opt ::= LIMIT expr */ |
| 158938 | {yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,0);} | 160998 | {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,0);} |
| 158939 | break; | 160999 | break; |
| 158940 | case 146: /* limit_opt ::= LIMIT expr OFFSET expr */ | 161000 | case 146: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 158941 | {yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);} | 161001 | {yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} |
| 158942 | break; | 161002 | break; |
| 158943 | case 147: /* limit_opt ::= LIMIT expr COMMA expr */ | 161003 | case 147: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 158944 | {yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy202,yymsp[-2].minor.yy202);} | 161004 | {yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy602,yymsp[-2].minor.yy602);} |
| 158945 | break; | 161005 | break; |
| 158946 | case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ | 161006 | case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 158947 | { | 161007 | { |
| 158948 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy47, &yymsp[-1].minor.yy0); | 161008 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy291, &yymsp[-1].minor.yy0); |
| 158949 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy47,yymsp[0].minor.yy202,0,0); | 161009 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy291,yymsp[0].minor.yy602,0,0); |
| 158950 | } | 161010 | } |
| 158951 | break; | 161011 | break; |
| 158952 | case 151: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt */ | 161012 | case 153: /* where_opt_ret ::= RETURNING selcollist */ |
| 161013 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-1].minor.yy602 = 0;} | ||
| 161014 | break; | ||
| 161015 | case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */ | ||
| 161016 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy338); yymsp[-3].minor.yy602 = yymsp[-2].minor.yy602;} | ||
| 161017 | break; | ||
| 161018 | case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ | ||
| 158953 | { | 161019 | { |
| 158954 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy47, &yymsp[-4].minor.yy0); | 161020 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy291, &yymsp[-4].minor.yy0); |
| 158955 | sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy242,"set list"); | 161021 | sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy338,"set list"); |
| 158956 | yymsp[-5].minor.yy47 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy47, yymsp[-1].minor.yy47); | 161022 | yymsp[-5].minor.yy291 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy291, yymsp[-1].minor.yy291); |
| 158957 | sqlite3Update(pParse,yymsp[-5].minor.yy47,yymsp[-2].minor.yy242,yymsp[0].minor.yy202,yymsp[-6].minor.yy192,0,0,0); | 161023 | sqlite3Update(pParse,yymsp[-5].minor.yy291,yymsp[-2].minor.yy338,yymsp[0].minor.yy602,yymsp[-6].minor.yy60,0,0,0); |
| 158958 | } | 161024 | } |
| 158959 | break; | 161025 | break; |
| 158960 | case 152: /* setlist ::= setlist COMMA nm EQ expr */ | 161026 | case 156: /* setlist ::= setlist COMMA nm EQ expr */ |
| 158961 | { | 161027 | { |
| 158962 | yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy242, yymsp[0].minor.yy202); | 161028 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy338, yymsp[0].minor.yy602); |
| 158963 | sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, 1); | 161029 | sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, 1); |
| 158964 | } | 161030 | } |
| 158965 | break; | 161031 | break; |
| 158966 | case 153: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ | 161032 | case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 158967 | { | 161033 | { |
| 158968 | yymsp[-6].minor.yy242 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy242, yymsp[-3].minor.yy600, yymsp[0].minor.yy202); | 161034 | yymsp[-6].minor.yy338 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy338, yymsp[-3].minor.yy288, yymsp[0].minor.yy602); |
| 158969 | } | 161035 | } |
| 158970 | break; | 161036 | break; |
| 158971 | case 154: /* setlist ::= nm EQ expr */ | 161037 | case 158: /* setlist ::= nm EQ expr */ |
| 158972 | { | 161038 | { |
| 158973 | yylhsminor.yy242 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy202); | 161039 | yylhsminor.yy338 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy602); |
| 158974 | sqlite3ExprListSetName(pParse, yylhsminor.yy242, &yymsp[-2].minor.yy0, 1); | 161040 | sqlite3ExprListSetName(pParse, yylhsminor.yy338, &yymsp[-2].minor.yy0, 1); |
| 158975 | } | 161041 | } |
| 158976 | yymsp[-2].minor.yy242 = yylhsminor.yy242; | 161042 | yymsp[-2].minor.yy338 = yylhsminor.yy338; |
| 158977 | break; | 161043 | break; |
| 158978 | case 155: /* setlist ::= LP idlist RP EQ expr */ | 161044 | case 159: /* setlist ::= LP idlist RP EQ expr */ |
| 158979 | { | 161045 | { |
| 158980 | yymsp[-4].minor.yy242 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy600, yymsp[0].minor.yy202); | 161046 | yymsp[-4].minor.yy338 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy288, yymsp[0].minor.yy602); |
| 158981 | } | 161047 | } |
| 158982 | break; | 161048 | break; |
| 158983 | case 156: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 161049 | case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 158984 | { | 161050 | { |
| 158985 | sqlite3Insert(pParse, yymsp[-3].minor.yy47, yymsp[-1].minor.yy539, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, yymsp[0].minor.yy318); | 161051 | sqlite3Insert(pParse, yymsp[-3].minor.yy291, yymsp[-1].minor.yy307, yymsp[-2].minor.yy288, yymsp[-5].minor.yy60, yymsp[0].minor.yy178); |
| 158986 | } | 161052 | } |
| 158987 | break; | 161053 | break; |
| 158988 | case 157: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ | 161054 | case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 158989 | { | 161055 | { |
| 158990 | sqlite3Insert(pParse, yymsp[-3].minor.yy47, 0, yymsp[-2].minor.yy600, yymsp[-5].minor.yy192, 0); | 161056 | sqlite3Insert(pParse, yymsp[-4].minor.yy291, 0, yymsp[-3].minor.yy288, yymsp[-6].minor.yy60, 0); |
| 158991 | } | 161057 | } |
| 158992 | break; | 161058 | break; |
| 158993 | case 158: /* upsert ::= */ | 161059 | case 162: /* upsert ::= */ |
| 158994 | { yymsp[1].minor.yy318 = 0; } | 161060 | { yymsp[1].minor.yy178 = 0; } |
| 161061 | break; | ||
| 161062 | case 163: /* upsert ::= RETURNING selcollist */ | ||
| 161063 | { yymsp[-1].minor.yy178 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy338); } | ||
| 161064 | break; | ||
| 161065 | case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ | ||
| 161066 | { yymsp[-11].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy338,yymsp[-6].minor.yy602,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,yymsp[0].minor.yy178);} | ||
| 158995 | break; | 161067 | break; |
| 158996 | case 159: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ | 161068 | case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 158997 | { yymsp[-10].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy242,yymsp[-5].minor.yy202,yymsp[-1].minor.yy242,yymsp[0].minor.yy202);} | 161069 | { yymsp[-8].minor.yy178 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy338,yymsp[-3].minor.yy602,0,0,yymsp[0].minor.yy178); } |
| 158998 | break; | 161070 | break; |
| 158999 | case 160: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ | 161071 | case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */ |
| 159000 | { yymsp[-7].minor.yy318 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy242,yymsp[-2].minor.yy202,0,0); } | 161072 | { yymsp[-4].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } |
| 159001 | break; | 161073 | break; |
| 159002 | case 161: /* upsert ::= ON CONFLICT DO NOTHING */ | 161074 | case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 159003 | { yymsp[-3].minor.yy318 = sqlite3UpsertNew(pParse->db,0,0,0,0); } | 161075 | { yymsp[-7].minor.yy178 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602,0);} |
| 159004 | break; | 161076 | break; |
| 159005 | case 165: /* idlist_opt ::= LP idlist RP */ | 161077 | case 168: /* returning ::= RETURNING selcollist */ |
| 159006 | {yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600;} | 161078 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy338);} |
| 159007 | break; | 161079 | break; |
| 159008 | case 166: /* idlist ::= idlist COMMA nm */ | 161080 | case 172: /* idlist_opt ::= LP idlist RP */ |
| 159009 | {yymsp[-2].minor.yy600 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy600,&yymsp[0].minor.yy0);} | 161081 | {yymsp[-2].minor.yy288 = yymsp[-1].minor.yy288;} |
| 159010 | break; | 161082 | break; |
| 159011 | case 167: /* idlist ::= nm */ | 161083 | case 173: /* idlist ::= idlist COMMA nm */ |
| 159012 | {yymsp[0].minor.yy600 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} | 161084 | {yymsp[-2].minor.yy288 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy288,&yymsp[0].minor.yy0);} |
| 159013 | break; | 161085 | break; |
| 159014 | case 168: /* expr ::= LP expr RP */ | 161086 | case 174: /* idlist ::= nm */ |
| 159015 | {yymsp[-2].minor.yy202 = yymsp[-1].minor.yy202;} | 161087 | {yymsp[0].minor.yy288 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 159016 | break; | 161088 | break; |
| 159017 | case 169: /* expr ::= ID|INDEXED */ | 161089 | case 175: /* expr ::= LP expr RP */ |
| 159018 | case 170: /* expr ::= JOIN_KW */ yytestcase(yyruleno==170); | 161090 | {yymsp[-2].minor.yy602 = yymsp[-1].minor.yy602;} |
| 159019 | {yymsp[0].minor.yy202=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} | ||
| 159020 | break; | 161091 | break; |
| 159021 | case 171: /* expr ::= nm DOT nm */ | 161092 | case 176: /* expr ::= ID|INDEXED */ |
| 161093 | case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177); | ||
| 161094 | {yymsp[0].minor.yy602=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} | ||
| 161095 | break; | ||
| 161096 | case 178: /* expr ::= nm DOT nm */ | ||
| 159022 | { | 161097 | { |
| 159023 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); | 161098 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| 159024 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); | 161099 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); |
| @@ -159026,11 +161101,11 @@ static YYACTIONTYPE yy_reduce( | |||
| 159026 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); | 161101 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); |
| 159027 | sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); | 161102 | sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); |
| 159028 | } | 161103 | } |
| 159029 | yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); | 161104 | yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); |
| 159030 | } | 161105 | } |
| 159031 | yymsp[-2].minor.yy202 = yylhsminor.yy202; | 161106 | yymsp[-2].minor.yy602 = yylhsminor.yy602; |
| 159032 | break; | 161107 | break; |
| 159033 | case 172: /* expr ::= nm DOT nm DOT nm */ | 161108 | case 179: /* expr ::= nm DOT nm DOT nm */ |
| 159034 | { | 161109 | { |
| 159035 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); | 161110 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); |
| 159036 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); | 161111 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| @@ -159040,26 +161115,26 @@ static YYACTIONTYPE yy_reduce( | |||
| 159040 | sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); | 161115 | sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); |
| 159041 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); | 161116 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); |
| 159042 | } | 161117 | } |
| 159043 | yylhsminor.yy202 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); | 161118 | yylhsminor.yy602 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); |
| 159044 | } | 161119 | } |
| 159045 | yymsp[-4].minor.yy202 = yylhsminor.yy202; | 161120 | yymsp[-4].minor.yy602 = yylhsminor.yy602; |
| 159046 | break; | 161121 | break; |
| 159047 | case 173: /* term ::= NULL|FLOAT|BLOB */ | 161122 | case 180: /* term ::= NULL|FLOAT|BLOB */ |
| 159048 | case 174: /* term ::= STRING */ yytestcase(yyruleno==174); | 161123 | case 181: /* term ::= STRING */ yytestcase(yyruleno==181); |
| 159049 | {yymsp[0].minor.yy202=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} | 161124 | {yymsp[0].minor.yy602=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 159050 | break; | 161125 | break; |
| 159051 | case 175: /* term ::= INTEGER */ | 161126 | case 182: /* term ::= INTEGER */ |
| 159052 | { | 161127 | { |
| 159053 | yylhsminor.yy202 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); | 161128 | yylhsminor.yy602 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); |
| 159054 | } | 161129 | } |
| 159055 | yymsp[0].minor.yy202 = yylhsminor.yy202; | 161130 | yymsp[0].minor.yy602 = yylhsminor.yy602; |
| 159056 | break; | 161131 | break; |
| 159057 | case 176: /* expr ::= VARIABLE */ | 161132 | case 183: /* expr ::= VARIABLE */ |
| 159058 | { | 161133 | { |
| 159059 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ | 161134 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 159060 | u32 n = yymsp[0].minor.yy0.n; | 161135 | u32 n = yymsp[0].minor.yy0.n; |
| 159061 | yymsp[0].minor.yy202 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); | 161136 | yymsp[0].minor.yy602 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 159062 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy202, n); | 161137 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy602, n); |
| 159063 | }else{ | 161138 | }else{ |
| 159064 | /* When doing a nested parse, one can include terms in an expression | 161139 | /* When doing a nested parse, one can include terms in an expression |
| 159065 | ** that look like this: #1 #2 ... These terms refer to registers | 161140 | ** that look like this: #1 #2 ... These terms refer to registers |
| @@ -159068,159 +161143,159 @@ static YYACTIONTYPE yy_reduce( | |||
| 159068 | assert( t.n>=2 ); | 161143 | assert( t.n>=2 ); |
| 159069 | if( pParse->nested==0 ){ | 161144 | if( pParse->nested==0 ){ |
| 159070 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); | 161145 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); |
| 159071 | yymsp[0].minor.yy202 = 0; | 161146 | yymsp[0].minor.yy602 = 0; |
| 159072 | }else{ | 161147 | }else{ |
| 159073 | yymsp[0].minor.yy202 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); | 161148 | yymsp[0].minor.yy602 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); |
| 159074 | if( yymsp[0].minor.yy202 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy202->iTable); | 161149 | if( yymsp[0].minor.yy602 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy602->iTable); |
| 159075 | } | 161150 | } |
| 159076 | } | 161151 | } |
| 159077 | } | 161152 | } |
| 159078 | break; | 161153 | break; |
| 159079 | case 177: /* expr ::= expr COLLATE ID|STRING */ | 161154 | case 184: /* expr ::= expr COLLATE ID|STRING */ |
| 159080 | { | 161155 | { |
| 159081 | yymsp[-2].minor.yy202 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy202, &yymsp[0].minor.yy0, 1); | 161156 | yymsp[-2].minor.yy602 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy602, &yymsp[0].minor.yy0, 1); |
| 159082 | } | 161157 | } |
| 159083 | break; | 161158 | break; |
| 159084 | case 178: /* expr ::= CAST LP expr AS typetoken RP */ | 161159 | case 185: /* expr ::= CAST LP expr AS typetoken RP */ |
| 159085 | { | 161160 | { |
| 159086 | yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); | 161161 | yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); |
| 159087 | sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy202, yymsp[-3].minor.yy202, 0); | 161162 | sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy602, yymsp[-3].minor.yy602, 0); |
| 159088 | } | 161163 | } |
| 159089 | break; | 161164 | break; |
| 159090 | case 179: /* expr ::= ID|INDEXED LP distinct exprlist RP */ | 161165 | case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 159091 | { | 161166 | { |
| 159092 | yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy192); | 161167 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy60); |
| 159093 | } | 161168 | } |
| 159094 | yymsp[-4].minor.yy202 = yylhsminor.yy202; | 161169 | yymsp[-4].minor.yy602 = yylhsminor.yy602; |
| 159095 | break; | 161170 | break; |
| 159096 | case 180: /* expr ::= ID|INDEXED LP STAR RP */ | 161171 | case 187: /* expr ::= ID|INDEXED LP STAR RP */ |
| 159097 | { | 161172 | { |
| 159098 | yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); | 161173 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 159099 | } | 161174 | } |
| 159100 | yymsp[-3].minor.yy202 = yylhsminor.yy202; | 161175 | yymsp[-3].minor.yy602 = yylhsminor.yy602; |
| 159101 | break; | 161176 | break; |
| 159102 | case 181: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 161177 | case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 159103 | { | 161178 | { |
| 159104 | yylhsminor.yy202 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy242, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy192); | 161179 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy338, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy60); |
| 159105 | sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303); | 161180 | sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19); |
| 159106 | } | 161181 | } |
| 159107 | yymsp[-5].minor.yy202 = yylhsminor.yy202; | 161182 | yymsp[-5].minor.yy602 = yylhsminor.yy602; |
| 159108 | break; | 161183 | break; |
| 159109 | case 182: /* expr ::= ID|INDEXED LP STAR RP filter_over */ | 161184 | case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 159110 | { | 161185 | { |
| 159111 | yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); | 161186 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 159112 | sqlite3WindowAttach(pParse, yylhsminor.yy202, yymsp[0].minor.yy303); | 161187 | sqlite3WindowAttach(pParse, yylhsminor.yy602, yymsp[0].minor.yy19); |
| 159113 | } | 161188 | } |
| 159114 | yymsp[-4].minor.yy202 = yylhsminor.yy202; | 161189 | yymsp[-4].minor.yy602 = yylhsminor.yy602; |
| 159115 | break; | 161190 | break; |
| 159116 | case 183: /* term ::= CTIME_KW */ | 161191 | case 190: /* term ::= CTIME_KW */ |
| 159117 | { | 161192 | { |
| 159118 | yylhsminor.yy202 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); | 161193 | yylhsminor.yy602 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 159119 | } | 161194 | } |
| 159120 | yymsp[0].minor.yy202 = yylhsminor.yy202; | 161195 | yymsp[0].minor.yy602 = yylhsminor.yy602; |
| 159121 | break; | 161196 | break; |
| 159122 | case 184: /* expr ::= LP nexprlist COMMA expr RP */ | 161197 | case 191: /* expr ::= LP nexprlist COMMA expr RP */ |
| 159123 | { | 161198 | { |
| 159124 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy242, yymsp[-1].minor.yy202); | 161199 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602); |
| 159125 | yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); | 161200 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 159126 | if( yymsp[-4].minor.yy202 ){ | 161201 | if( yymsp[-4].minor.yy602 ){ |
| 159127 | yymsp[-4].minor.yy202->x.pList = pList; | 161202 | yymsp[-4].minor.yy602->x.pList = pList; |
| 159128 | if( ALWAYS(pList->nExpr) ){ | 161203 | if( ALWAYS(pList->nExpr) ){ |
| 159129 | yymsp[-4].minor.yy202->flags |= pList->a[0].pExpr->flags & EP_Propagate; | 161204 | yymsp[-4].minor.yy602->flags |= pList->a[0].pExpr->flags & EP_Propagate; |
| 159130 | } | 161205 | } |
| 159131 | }else{ | 161206 | }else{ |
| 159132 | sqlite3ExprListDelete(pParse->db, pList); | 161207 | sqlite3ExprListDelete(pParse->db, pList); |
| 159133 | } | 161208 | } |
| 159134 | } | 161209 | } |
| 159135 | break; | 161210 | break; |
| 159136 | case 185: /* expr ::= expr AND expr */ | 161211 | case 192: /* expr ::= expr AND expr */ |
| 159137 | {yymsp[-2].minor.yy202=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);} | 161212 | {yymsp[-2].minor.yy602=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} |
| 159138 | break; | 161213 | break; |
| 159139 | case 186: /* expr ::= expr OR expr */ | 161214 | case 193: /* expr ::= expr OR expr */ |
| 159140 | case 187: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==187); | 161215 | case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194); |
| 159141 | case 188: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==188); | 161216 | case 195: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==195); |
| 159142 | case 189: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==189); | 161217 | case 196: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==196); |
| 159143 | case 190: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==190); | 161218 | case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197); |
| 159144 | case 191: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==191); | 161219 | case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198); |
| 159145 | case 192: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==192); | 161220 | case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199); |
| 159146 | {yymsp[-2].minor.yy202=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy202,yymsp[0].minor.yy202);} | 161221 | {yymsp[-2].minor.yy602=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy602,yymsp[0].minor.yy602);} |
| 159147 | break; | 161222 | break; |
| 159148 | case 193: /* likeop ::= NOT LIKE_KW|MATCH */ | 161223 | case 200: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 159149 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} | 161224 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 159150 | break; | 161225 | break; |
| 159151 | case 194: /* expr ::= expr likeop expr */ | 161226 | case 201: /* expr ::= expr likeop expr */ |
| 159152 | { | 161227 | { |
| 159153 | ExprList *pList; | 161228 | ExprList *pList; |
| 159154 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; | 161229 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 159155 | yymsp[-1].minor.yy0.n &= 0x7fffffff; | 161230 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 159156 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy202); | 161231 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy602); |
| 159157 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy202); | 161232 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy602); |
| 159158 | yymsp[-2].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); | 161233 | yymsp[-2].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 159159 | if( bNot ) yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy202, 0); | 161234 | if( bNot ) yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy602, 0); |
| 159160 | if( yymsp[-2].minor.yy202 ) yymsp[-2].minor.yy202->flags |= EP_InfixFunc; | 161235 | if( yymsp[-2].minor.yy602 ) yymsp[-2].minor.yy602->flags |= EP_InfixFunc; |
| 159161 | } | 161236 | } |
| 159162 | break; | 161237 | break; |
| 159163 | case 195: /* expr ::= expr likeop expr ESCAPE expr */ | 161238 | case 202: /* expr ::= expr likeop expr ESCAPE expr */ |
| 159164 | { | 161239 | { |
| 159165 | ExprList *pList; | 161240 | ExprList *pList; |
| 159166 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; | 161241 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 159167 | yymsp[-3].minor.yy0.n &= 0x7fffffff; | 161242 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 159168 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202); | 161243 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); |
| 159169 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy202); | 161244 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy602); |
| 159170 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202); | 161245 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602); |
| 159171 | yymsp[-4].minor.yy202 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); | 161246 | yymsp[-4].minor.yy602 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 159172 | if( bNot ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); | 161247 | if( bNot ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 159173 | if( yymsp[-4].minor.yy202 ) yymsp[-4].minor.yy202->flags |= EP_InfixFunc; | 161248 | if( yymsp[-4].minor.yy602 ) yymsp[-4].minor.yy602->flags |= EP_InfixFunc; |
| 159174 | } | 161249 | } |
| 159175 | break; | 161250 | break; |
| 159176 | case 196: /* expr ::= expr ISNULL|NOTNULL */ | 161251 | case 203: /* expr ::= expr ISNULL|NOTNULL */ |
| 159177 | {yymsp[-1].minor.yy202 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy202,0);} | 161252 | {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy602,0);} |
| 159178 | break; | 161253 | break; |
| 159179 | case 197: /* expr ::= expr NOT NULL */ | 161254 | case 204: /* expr ::= expr NOT NULL */ |
| 159180 | {yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy202,0);} | 161255 | {yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy602,0);} |
| 159181 | break; | 161256 | break; |
| 159182 | case 198: /* expr ::= expr IS expr */ | 161257 | case 205: /* expr ::= expr IS expr */ |
| 159183 | { | 161258 | { |
| 159184 | yymsp[-2].minor.yy202 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy202,yymsp[0].minor.yy202); | 161259 | yymsp[-2].minor.yy602 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy602,yymsp[0].minor.yy602); |
| 159185 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-2].minor.yy202, TK_ISNULL); | 161260 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-2].minor.yy602, TK_ISNULL); |
| 159186 | } | 161261 | } |
| 159187 | break; | 161262 | break; |
| 159188 | case 199: /* expr ::= expr IS NOT expr */ | 161263 | case 206: /* expr ::= expr IS NOT expr */ |
| 159189 | { | 161264 | { |
| 159190 | yymsp[-3].minor.yy202 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy202,yymsp[0].minor.yy202); | 161265 | yymsp[-3].minor.yy602 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy602,yymsp[0].minor.yy602); |
| 159191 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy202, yymsp[-3].minor.yy202, TK_NOTNULL); | 161266 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy602, yymsp[-3].minor.yy602, TK_NOTNULL); |
| 159192 | } | 161267 | } |
| 159193 | break; | 161268 | break; |
| 159194 | case 200: /* expr ::= NOT expr */ | 161269 | case 207: /* expr ::= NOT expr */ |
| 159195 | case 201: /* expr ::= BITNOT expr */ yytestcase(yyruleno==201); | 161270 | case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208); |
| 159196 | {yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy202, 0);/*A-overwrites-B*/} | 161271 | {yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy602, 0);/*A-overwrites-B*/} |
| 159197 | break; | 161272 | break; |
| 159198 | case 202: /* expr ::= PLUS|MINUS expr */ | 161273 | case 209: /* expr ::= PLUS|MINUS expr */ |
| 159199 | { | 161274 | { |
| 159200 | yymsp[-1].minor.yy202 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy202, 0); | 161275 | yymsp[-1].minor.yy602 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy602, 0); |
| 159201 | /*A-overwrites-B*/ | 161276 | /*A-overwrites-B*/ |
| 159202 | } | 161277 | } |
| 159203 | break; | 161278 | break; |
| 159204 | case 203: /* between_op ::= BETWEEN */ | 161279 | case 210: /* between_op ::= BETWEEN */ |
| 159205 | case 206: /* in_op ::= IN */ yytestcase(yyruleno==206); | 161280 | case 213: /* in_op ::= IN */ yytestcase(yyruleno==213); |
| 159206 | {yymsp[0].minor.yy192 = 0;} | 161281 | {yymsp[0].minor.yy60 = 0;} |
| 159207 | break; | 161282 | break; |
| 159208 | case 205: /* expr ::= expr between_op expr AND expr */ | 161283 | case 212: /* expr ::= expr between_op expr AND expr */ |
| 159209 | { | 161284 | { |
| 159210 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202); | 161285 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); |
| 159211 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy202); | 161286 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy602); |
| 159212 | yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy202, 0); | 161287 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy602, 0); |
| 159213 | if( yymsp[-4].minor.yy202 ){ | 161288 | if( yymsp[-4].minor.yy602 ){ |
| 159214 | yymsp[-4].minor.yy202->x.pList = pList; | 161289 | yymsp[-4].minor.yy602->x.pList = pList; |
| 159215 | }else{ | 161290 | }else{ |
| 159216 | sqlite3ExprListDelete(pParse->db, pList); | 161291 | sqlite3ExprListDelete(pParse->db, pList); |
| 159217 | } | 161292 | } |
| 159218 | if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); | 161293 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 159219 | } | 161294 | } |
| 159220 | break; | 161295 | break; |
| 159221 | case 208: /* expr ::= expr in_op LP exprlist RP */ | 161296 | case 215: /* expr ::= expr in_op LP exprlist RP */ |
| 159222 | { | 161297 | { |
| 159223 | if( yymsp[-1].minor.yy242==0 ){ | 161298 | if( yymsp[-1].minor.yy338==0 ){ |
| 159224 | /* Expressions of the form | 161299 | /* Expressions of the form |
| 159225 | ** | 161300 | ** |
| 159226 | ** expr1 IN () | 161301 | ** expr1 IN () |
| @@ -159229,197 +161304,197 @@ static YYACTIONTYPE yy_reduce( | |||
| 159229 | ** simplify to constants 0 (false) and 1 (true), respectively, | 161304 | ** simplify to constants 0 (false) and 1 (true), respectively, |
| 159230 | ** regardless of the value of expr1. | 161305 | ** regardless of the value of expr1. |
| 159231 | */ | 161306 | */ |
| 159232 | sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy202); | 161307 | sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy602); |
| 159233 | yymsp[-4].minor.yy202 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy192 ? "1" : "0"); | 161308 | yymsp[-4].minor.yy602 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy60 ? "1" : "0"); |
| 159234 | }else if( yymsp[-1].minor.yy242->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy242->a[0].pExpr) ){ | 161309 | }else if( yymsp[-1].minor.yy338->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy338->a[0].pExpr) ){ |
| 159235 | Expr *pRHS = yymsp[-1].minor.yy242->a[0].pExpr; | 161310 | Expr *pRHS = yymsp[-1].minor.yy338->a[0].pExpr; |
| 159236 | yymsp[-1].minor.yy242->a[0].pExpr = 0; | 161311 | yymsp[-1].minor.yy338->a[0].pExpr = 0; |
| 159237 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy242); | 161312 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338); |
| 159238 | pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); | 161313 | pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); |
| 159239 | yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy202, pRHS); | 161314 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy602, pRHS); |
| 159240 | if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); | 161315 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 159241 | }else{ | 161316 | }else{ |
| 159242 | yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0); | 161317 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); |
| 159243 | if( yymsp[-4].minor.yy202 ){ | 161318 | if( yymsp[-4].minor.yy602 ){ |
| 159244 | yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy242; | 161319 | yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy338; |
| 159245 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202); | 161320 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602); |
| 159246 | }else{ | 161321 | }else{ |
| 159247 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy242); | 161322 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy338); |
| 159248 | } | 161323 | } |
| 159249 | if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); | 161324 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 159250 | } | 161325 | } |
| 159251 | } | 161326 | } |
| 159252 | break; | 161327 | break; |
| 159253 | case 209: /* expr ::= LP select RP */ | 161328 | case 216: /* expr ::= LP select RP */ |
| 159254 | { | 161329 | { |
| 159255 | yymsp[-2].minor.yy202 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); | 161330 | yymsp[-2].minor.yy602 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 159256 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy202, yymsp[-1].minor.yy539); | 161331 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy602, yymsp[-1].minor.yy307); |
| 159257 | } | 161332 | } |
| 159258 | break; | 161333 | break; |
| 159259 | case 210: /* expr ::= expr in_op LP select RP */ | 161334 | case 217: /* expr ::= expr in_op LP select RP */ |
| 159260 | { | 161335 | { |
| 159261 | yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0); | 161336 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); |
| 159262 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, yymsp[-1].minor.yy539); | 161337 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, yymsp[-1].minor.yy307); |
| 159263 | if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); | 161338 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 159264 | } | 161339 | } |
| 159265 | break; | 161340 | break; |
| 159266 | case 211: /* expr ::= expr in_op nm dbnm paren_exprlist */ | 161341 | case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 159267 | { | 161342 | { |
| 159268 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); | 161343 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 159269 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); | 161344 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| 159270 | if( yymsp[0].minor.yy242 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy242); | 161345 | if( yymsp[0].minor.yy338 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy338); |
| 159271 | yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy202, 0); | 161346 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy602, 0); |
| 159272 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy202, pSelect); | 161347 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy602, pSelect); |
| 159273 | if( yymsp[-3].minor.yy192 ) yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy202, 0); | 161348 | if( yymsp[-3].minor.yy60 ) yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy602, 0); |
| 159274 | } | 161349 | } |
| 159275 | break; | 161350 | break; |
| 159276 | case 212: /* expr ::= EXISTS LP select RP */ | 161351 | case 219: /* expr ::= EXISTS LP select RP */ |
| 159277 | { | 161352 | { |
| 159278 | Expr *p; | 161353 | Expr *p; |
| 159279 | p = yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); | 161354 | p = yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 159280 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy539); | 161355 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy307); |
| 159281 | } | 161356 | } |
| 159282 | break; | 161357 | break; |
| 159283 | case 213: /* expr ::= CASE case_operand case_exprlist case_else END */ | 161358 | case 220: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 159284 | { | 161359 | { |
| 159285 | yymsp[-4].minor.yy202 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy202, 0); | 161360 | yymsp[-4].minor.yy602 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy602, 0); |
| 159286 | if( yymsp[-4].minor.yy202 ){ | 161361 | if( yymsp[-4].minor.yy602 ){ |
| 159287 | yymsp[-4].minor.yy202->x.pList = yymsp[-1].minor.yy202 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[-1].minor.yy202) : yymsp[-2].minor.yy242; | 161362 | yymsp[-4].minor.yy602->x.pList = yymsp[-1].minor.yy602 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[-1].minor.yy602) : yymsp[-2].minor.yy338; |
| 159288 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy202); | 161363 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy602); |
| 159289 | }else{ | 161364 | }else{ |
| 159290 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy242); | 161365 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy338); |
| 159291 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy202); | 161366 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy602); |
| 159292 | } | 161367 | } |
| 159293 | } | 161368 | } |
| 159294 | break; | 161369 | break; |
| 159295 | case 214: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 161370 | case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 159296 | { | 161371 | { |
| 159297 | yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[-2].minor.yy202); | 161372 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[-2].minor.yy602); |
| 159298 | yymsp[-4].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy242, yymsp[0].minor.yy202); | 161373 | yymsp[-4].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy338, yymsp[0].minor.yy602); |
| 159299 | } | 161374 | } |
| 159300 | break; | 161375 | break; |
| 159301 | case 215: /* case_exprlist ::= WHEN expr THEN expr */ | 161376 | case 222: /* case_exprlist ::= WHEN expr THEN expr */ |
| 159302 | { | 161377 | { |
| 159303 | yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy202); | 161378 | yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy602); |
| 159304 | yymsp[-3].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy242, yymsp[0].minor.yy202); | 161379 | yymsp[-3].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy338, yymsp[0].minor.yy602); |
| 159305 | } | 161380 | } |
| 159306 | break; | 161381 | break; |
| 159307 | case 218: /* case_operand ::= expr */ | 161382 | case 225: /* case_operand ::= expr */ |
| 159308 | {yymsp[0].minor.yy202 = yymsp[0].minor.yy202; /*A-overwrites-X*/} | 161383 | {yymsp[0].minor.yy602 = yymsp[0].minor.yy602; /*A-overwrites-X*/} |
| 159309 | break; | 161384 | break; |
| 159310 | case 221: /* nexprlist ::= nexprlist COMMA expr */ | 161385 | case 228: /* nexprlist ::= nexprlist COMMA expr */ |
| 159311 | {yymsp[-2].minor.yy242 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy242,yymsp[0].minor.yy202);} | 161386 | {yymsp[-2].minor.yy338 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy338,yymsp[0].minor.yy602);} |
| 159312 | break; | 161387 | break; |
| 159313 | case 222: /* nexprlist ::= expr */ | 161388 | case 229: /* nexprlist ::= expr */ |
| 159314 | {yymsp[0].minor.yy242 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy202); /*A-overwrites-Y*/} | 161389 | {yymsp[0].minor.yy338 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy602); /*A-overwrites-Y*/} |
| 159315 | break; | 161390 | break; |
| 159316 | case 224: /* paren_exprlist ::= LP exprlist RP */ | 161391 | case 231: /* paren_exprlist ::= LP exprlist RP */ |
| 159317 | case 229: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==229); | 161392 | case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236); |
| 159318 | {yymsp[-2].minor.yy242 = yymsp[-1].minor.yy242;} | 161393 | {yymsp[-2].minor.yy338 = yymsp[-1].minor.yy338;} |
| 159319 | break; | 161394 | break; |
| 159320 | case 225: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 161395 | case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 159321 | { | 161396 | { |
| 159322 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, | 161397 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 159323 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy242, yymsp[-10].minor.yy192, | 161398 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy338, yymsp[-10].minor.yy60, |
| 159324 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy202, SQLITE_SO_ASC, yymsp[-8].minor.yy192, SQLITE_IDXTYPE_APPDEF); | 161399 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy602, SQLITE_SO_ASC, yymsp[-8].minor.yy60, SQLITE_IDXTYPE_APPDEF); |
| 159325 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ | 161400 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 159326 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); | 161401 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 159327 | } | 161402 | } |
| 159328 | } | 161403 | } |
| 159329 | break; | 161404 | break; |
| 159330 | case 226: /* uniqueflag ::= UNIQUE */ | 161405 | case 233: /* uniqueflag ::= UNIQUE */ |
| 159331 | case 268: /* raisetype ::= ABORT */ yytestcase(yyruleno==268); | 161406 | case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275); |
| 159332 | {yymsp[0].minor.yy192 = OE_Abort;} | 161407 | {yymsp[0].minor.yy60 = OE_Abort;} |
| 159333 | break; | 161408 | break; |
| 159334 | case 227: /* uniqueflag ::= */ | 161409 | case 234: /* uniqueflag ::= */ |
| 159335 | {yymsp[1].minor.yy192 = OE_None;} | 161410 | {yymsp[1].minor.yy60 = OE_None;} |
| 159336 | break; | 161411 | break; |
| 159337 | case 230: /* eidlist ::= eidlist COMMA nm collate sortorder */ | 161412 | case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 159338 | { | 161413 | { |
| 159339 | yymsp[-4].minor.yy242 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy242, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192); | 161414 | yymsp[-4].minor.yy338 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy338, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); |
| 159340 | } | 161415 | } |
| 159341 | break; | 161416 | break; |
| 159342 | case 231: /* eidlist ::= nm collate sortorder */ | 161417 | case 238: /* eidlist ::= nm collate sortorder */ |
| 159343 | { | 161418 | { |
| 159344 | yymsp[-2].minor.yy242 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy192, yymsp[0].minor.yy192); /*A-overwrites-Y*/ | 161419 | yymsp[-2].minor.yy338 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy60, yymsp[0].minor.yy60); /*A-overwrites-Y*/ |
| 159345 | } | 161420 | } |
| 159346 | break; | 161421 | break; |
| 159347 | case 234: /* cmd ::= DROP INDEX ifexists fullname */ | 161422 | case 241: /* cmd ::= DROP INDEX ifexists fullname */ |
| 159348 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy47, yymsp[-1].minor.yy192);} | 161423 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy291, yymsp[-1].minor.yy60);} |
| 159349 | break; | 161424 | break; |
| 159350 | case 235: /* cmd ::= VACUUM vinto */ | 161425 | case 242: /* cmd ::= VACUUM vinto */ |
| 159351 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy202);} | 161426 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy602);} |
| 159352 | break; | 161427 | break; |
| 159353 | case 236: /* cmd ::= VACUUM nm vinto */ | 161428 | case 243: /* cmd ::= VACUUM nm vinto */ |
| 159354 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy202);} | 161429 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy602);} |
| 159355 | break; | 161430 | break; |
| 159356 | case 239: /* cmd ::= PRAGMA nm dbnm */ | 161431 | case 246: /* cmd ::= PRAGMA nm dbnm */ |
| 159357 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} | 161432 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 159358 | break; | 161433 | break; |
| 159359 | case 240: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ | 161434 | case 247: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 159360 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} | 161435 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 159361 | break; | 161436 | break; |
| 159362 | case 241: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 161437 | case 248: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 159363 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} | 161438 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 159364 | break; | 161439 | break; |
| 159365 | case 242: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ | 161440 | case 249: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 159366 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} | 161441 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 159367 | break; | 161442 | break; |
| 159368 | case 243: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 161443 | case 250: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 159369 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} | 161444 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 159370 | break; | 161445 | break; |
| 159371 | case 246: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 161446 | case 253: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 159372 | { | 161447 | { |
| 159373 | Token all; | 161448 | Token all; |
| 159374 | all.z = yymsp[-3].minor.yy0.z; | 161449 | all.z = yymsp[-3].minor.yy0.z; |
| 159375 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; | 161450 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 159376 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy447, &all); | 161451 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy483, &all); |
| 159377 | } | 161452 | } |
| 159378 | break; | 161453 | break; |
| 159379 | case 247: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 161454 | case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 159380 | { | 161455 | { |
| 159381 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy192, yymsp[-4].minor.yy230.a, yymsp[-4].minor.yy230.b, yymsp[-2].minor.yy47, yymsp[0].minor.yy202, yymsp[-10].minor.yy192, yymsp[-8].minor.yy192); | 161456 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy60, yymsp[-4].minor.yy50.a, yymsp[-4].minor.yy50.b, yymsp[-2].minor.yy291, yymsp[0].minor.yy602, yymsp[-10].minor.yy60, yymsp[-8].minor.yy60); |
| 159382 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ | 161457 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 159383 | } | 161458 | } |
| 159384 | break; | 161459 | break; |
| 159385 | case 248: /* trigger_time ::= BEFORE|AFTER */ | 161460 | case 255: /* trigger_time ::= BEFORE|AFTER */ |
| 159386 | { yymsp[0].minor.yy192 = yymsp[0].major; /*A-overwrites-X*/ } | 161461 | { yymsp[0].minor.yy60 = yymsp[0].major; /*A-overwrites-X*/ } |
| 159387 | break; | 161462 | break; |
| 159388 | case 249: /* trigger_time ::= INSTEAD OF */ | 161463 | case 256: /* trigger_time ::= INSTEAD OF */ |
| 159389 | { yymsp[-1].minor.yy192 = TK_INSTEAD;} | 161464 | { yymsp[-1].minor.yy60 = TK_INSTEAD;} |
| 159390 | break; | 161465 | break; |
| 159391 | case 250: /* trigger_time ::= */ | 161466 | case 257: /* trigger_time ::= */ |
| 159392 | { yymsp[1].minor.yy192 = TK_BEFORE; } | 161467 | { yymsp[1].minor.yy60 = TK_BEFORE; } |
| 159393 | break; | 161468 | break; |
| 159394 | case 251: /* trigger_event ::= DELETE|INSERT */ | 161469 | case 258: /* trigger_event ::= DELETE|INSERT */ |
| 159395 | case 252: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==252); | 161470 | case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259); |
| 159396 | {yymsp[0].minor.yy230.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy230.b = 0;} | 161471 | {yymsp[0].minor.yy50.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy50.b = 0;} |
| 159397 | break; | 161472 | break; |
| 159398 | case 253: /* trigger_event ::= UPDATE OF idlist */ | 161473 | case 260: /* trigger_event ::= UPDATE OF idlist */ |
| 159399 | {yymsp[-2].minor.yy230.a = TK_UPDATE; yymsp[-2].minor.yy230.b = yymsp[0].minor.yy600;} | 161474 | {yymsp[-2].minor.yy50.a = TK_UPDATE; yymsp[-2].minor.yy50.b = yymsp[0].minor.yy288;} |
| 159400 | break; | 161475 | break; |
| 159401 | case 254: /* when_clause ::= */ | 161476 | case 261: /* when_clause ::= */ |
| 159402 | case 273: /* key_opt ::= */ yytestcase(yyruleno==273); | 161477 | case 280: /* key_opt ::= */ yytestcase(yyruleno==280); |
| 159403 | { yymsp[1].minor.yy202 = 0; } | 161478 | { yymsp[1].minor.yy602 = 0; } |
| 159404 | break; | 161479 | break; |
| 159405 | case 255: /* when_clause ::= WHEN expr */ | 161480 | case 262: /* when_clause ::= WHEN expr */ |
| 159406 | case 274: /* key_opt ::= KEY expr */ yytestcase(yyruleno==274); | 161481 | case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281); |
| 159407 | { yymsp[-1].minor.yy202 = yymsp[0].minor.yy202; } | 161482 | { yymsp[-1].minor.yy602 = yymsp[0].minor.yy602; } |
| 159408 | break; | 161483 | break; |
| 159409 | case 256: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 161484 | case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 159410 | { | 161485 | { |
| 159411 | assert( yymsp[-2].minor.yy447!=0 ); | 161486 | assert( yymsp[-2].minor.yy483!=0 ); |
| 159412 | yymsp[-2].minor.yy447->pLast->pNext = yymsp[-1].minor.yy447; | 161487 | yymsp[-2].minor.yy483->pLast->pNext = yymsp[-1].minor.yy483; |
| 159413 | yymsp[-2].minor.yy447->pLast = yymsp[-1].minor.yy447; | 161488 | yymsp[-2].minor.yy483->pLast = yymsp[-1].minor.yy483; |
| 159414 | } | 161489 | } |
| 159415 | break; | 161490 | break; |
| 159416 | case 257: /* trigger_cmd_list ::= trigger_cmd SEMI */ | 161491 | case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 159417 | { | 161492 | { |
| 159418 | assert( yymsp[-1].minor.yy447!=0 ); | 161493 | assert( yymsp[-1].minor.yy483!=0 ); |
| 159419 | yymsp[-1].minor.yy447->pLast = yymsp[-1].minor.yy447; | 161494 | yymsp[-1].minor.yy483->pLast = yymsp[-1].minor.yy483; |
| 159420 | } | 161495 | } |
| 159421 | break; | 161496 | break; |
| 159422 | case 258: /* trnm ::= nm DOT nm */ | 161497 | case 265: /* trnm ::= nm DOT nm */ |
| 159423 | { | 161498 | { |
| 159424 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; | 161499 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 159425 | sqlite3ErrorMsg(pParse, | 161500 | sqlite3ErrorMsg(pParse, |
| @@ -159427,344 +161502,364 @@ static YYACTIONTYPE yy_reduce( | |||
| 159427 | "statements within triggers"); | 161502 | "statements within triggers"); |
| 159428 | } | 161503 | } |
| 159429 | break; | 161504 | break; |
| 159430 | case 259: /* tridxby ::= INDEXED BY nm */ | 161505 | case 266: /* tridxby ::= INDEXED BY nm */ |
| 159431 | { | 161506 | { |
| 159432 | sqlite3ErrorMsg(pParse, | 161507 | sqlite3ErrorMsg(pParse, |
| 159433 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " | 161508 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 159434 | "within triggers"); | 161509 | "within triggers"); |
| 159435 | } | 161510 | } |
| 159436 | break; | 161511 | break; |
| 159437 | case 260: /* tridxby ::= NOT INDEXED */ | 161512 | case 267: /* tridxby ::= NOT INDEXED */ |
| 159438 | { | 161513 | { |
| 159439 | sqlite3ErrorMsg(pParse, | 161514 | sqlite3ErrorMsg(pParse, |
| 159440 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " | 161515 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 159441 | "within triggers"); | 161516 | "within triggers"); |
| 159442 | } | 161517 | } |
| 159443 | break; | 161518 | break; |
| 159444 | case 261: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 161519 | case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 159445 | {yylhsminor.yy447 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy47, yymsp[-3].minor.yy242, yymsp[-1].minor.yy202, yymsp[-7].minor.yy192, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy436);} | 161520 | {yylhsminor.yy483 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy291, yymsp[-3].minor.yy338, yymsp[-1].minor.yy602, yymsp[-7].minor.yy60, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy528);} |
| 159446 | yymsp[-8].minor.yy447 = yylhsminor.yy447; | 161521 | yymsp[-8].minor.yy483 = yylhsminor.yy483; |
| 159447 | break; | 161522 | break; |
| 159448 | case 262: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 161523 | case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 159449 | { | 161524 | { |
| 159450 | yylhsminor.yy447 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy600,yymsp[-2].minor.yy539,yymsp[-6].minor.yy192,yymsp[-1].minor.yy318,yymsp[-7].minor.yy436,yymsp[0].minor.yy436);/*yylhsminor.yy447-overwrites-yymsp[-6].minor.yy192*/ | 161525 | yylhsminor.yy483 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy288,yymsp[-2].minor.yy307,yymsp[-6].minor.yy60,yymsp[-1].minor.yy178,yymsp[-7].minor.yy528,yymsp[0].minor.yy528);/*yylhsminor.yy483-overwrites-yymsp[-6].minor.yy60*/ |
| 159451 | } | 161526 | } |
| 159452 | yymsp[-7].minor.yy447 = yylhsminor.yy447; | 161527 | yymsp[-7].minor.yy483 = yylhsminor.yy483; |
| 159453 | break; | 161528 | break; |
| 159454 | case 263: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 161529 | case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 159455 | {yylhsminor.yy447 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy202, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy436);} | 161530 | {yylhsminor.yy483 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy602, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy528);} |
| 159456 | yymsp[-5].minor.yy447 = yylhsminor.yy447; | 161531 | yymsp[-5].minor.yy483 = yylhsminor.yy483; |
| 159457 | break; | 161532 | break; |
| 159458 | case 264: /* trigger_cmd ::= scanpt select scanpt */ | 161533 | case 271: /* trigger_cmd ::= scanpt select scanpt */ |
| 159459 | {yylhsminor.yy447 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy539, yymsp[-2].minor.yy436, yymsp[0].minor.yy436); /*yylhsminor.yy447-overwrites-yymsp[-1].minor.yy539*/} | 161534 | {yylhsminor.yy483 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy307, yymsp[-2].minor.yy528, yymsp[0].minor.yy528); /*yylhsminor.yy483-overwrites-yymsp[-1].minor.yy307*/} |
| 159460 | yymsp[-2].minor.yy447 = yylhsminor.yy447; | 161535 | yymsp[-2].minor.yy483 = yylhsminor.yy483; |
| 159461 | break; | 161536 | break; |
| 159462 | case 265: /* expr ::= RAISE LP IGNORE RP */ | 161537 | case 272: /* expr ::= RAISE LP IGNORE RP */ |
| 159463 | { | 161538 | { |
| 159464 | yymsp[-3].minor.yy202 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); | 161539 | yymsp[-3].minor.yy602 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 159465 | if( yymsp[-3].minor.yy202 ){ | 161540 | if( yymsp[-3].minor.yy602 ){ |
| 159466 | yymsp[-3].minor.yy202->affExpr = OE_Ignore; | 161541 | yymsp[-3].minor.yy602->affExpr = OE_Ignore; |
| 159467 | } | 161542 | } |
| 159468 | } | 161543 | } |
| 159469 | break; | 161544 | break; |
| 159470 | case 266: /* expr ::= RAISE LP raisetype COMMA nm RP */ | 161545 | case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 159471 | { | 161546 | { |
| 159472 | yymsp[-5].minor.yy202 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); | 161547 | yymsp[-5].minor.yy602 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 159473 | if( yymsp[-5].minor.yy202 ) { | 161548 | if( yymsp[-5].minor.yy602 ) { |
| 159474 | yymsp[-5].minor.yy202->affExpr = (char)yymsp[-3].minor.yy192; | 161549 | yymsp[-5].minor.yy602->affExpr = (char)yymsp[-3].minor.yy60; |
| 159475 | } | 161550 | } |
| 159476 | } | 161551 | } |
| 159477 | break; | 161552 | break; |
| 159478 | case 267: /* raisetype ::= ROLLBACK */ | 161553 | case 274: /* raisetype ::= ROLLBACK */ |
| 159479 | {yymsp[0].minor.yy192 = OE_Rollback;} | 161554 | {yymsp[0].minor.yy60 = OE_Rollback;} |
| 159480 | break; | 161555 | break; |
| 159481 | case 269: /* raisetype ::= FAIL */ | 161556 | case 276: /* raisetype ::= FAIL */ |
| 159482 | {yymsp[0].minor.yy192 = OE_Fail;} | 161557 | {yymsp[0].minor.yy60 = OE_Fail;} |
| 159483 | break; | 161558 | break; |
| 159484 | case 270: /* cmd ::= DROP TRIGGER ifexists fullname */ | 161559 | case 277: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 159485 | { | 161560 | { |
| 159486 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy192); | 161561 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy291,yymsp[-1].minor.yy60); |
| 159487 | } | 161562 | } |
| 159488 | break; | 161563 | break; |
| 159489 | case 271: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 161564 | case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 159490 | { | 161565 | { |
| 159491 | sqlite3Attach(pParse, yymsp[-3].minor.yy202, yymsp[-1].minor.yy202, yymsp[0].minor.yy202); | 161566 | sqlite3Attach(pParse, yymsp[-3].minor.yy602, yymsp[-1].minor.yy602, yymsp[0].minor.yy602); |
| 159492 | } | 161567 | } |
| 159493 | break; | 161568 | break; |
| 159494 | case 272: /* cmd ::= DETACH database_kw_opt expr */ | 161569 | case 279: /* cmd ::= DETACH database_kw_opt expr */ |
| 159495 | { | 161570 | { |
| 159496 | sqlite3Detach(pParse, yymsp[0].minor.yy202); | 161571 | sqlite3Detach(pParse, yymsp[0].minor.yy602); |
| 159497 | } | 161572 | } |
| 159498 | break; | 161573 | break; |
| 159499 | case 275: /* cmd ::= REINDEX */ | 161574 | case 282: /* cmd ::= REINDEX */ |
| 159500 | {sqlite3Reindex(pParse, 0, 0);} | 161575 | {sqlite3Reindex(pParse, 0, 0);} |
| 159501 | break; | 161576 | break; |
| 159502 | case 276: /* cmd ::= REINDEX nm dbnm */ | 161577 | case 283: /* cmd ::= REINDEX nm dbnm */ |
| 159503 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} | 161578 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 159504 | break; | 161579 | break; |
| 159505 | case 277: /* cmd ::= ANALYZE */ | 161580 | case 284: /* cmd ::= ANALYZE */ |
| 159506 | {sqlite3Analyze(pParse, 0, 0);} | 161581 | {sqlite3Analyze(pParse, 0, 0);} |
| 159507 | break; | 161582 | break; |
| 159508 | case 278: /* cmd ::= ANALYZE nm dbnm */ | 161583 | case 285: /* cmd ::= ANALYZE nm dbnm */ |
| 159509 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} | 161584 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 159510 | break; | 161585 | break; |
| 159511 | case 279: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | 161586 | case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 159512 | { | 161587 | { |
| 159513 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy47,&yymsp[0].minor.yy0); | 161588 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy291,&yymsp[0].minor.yy0); |
| 159514 | } | 161589 | } |
| 159515 | break; | 161590 | break; |
| 159516 | case 280: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 161591 | case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 159517 | { | 161592 | { |
| 159518 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; | 161593 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 159519 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); | 161594 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 159520 | } | 161595 | } |
| 159521 | break; | 161596 | break; |
| 159522 | case 281: /* add_column_fullname ::= fullname */ | 161597 | case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 161598 | { | ||
| 161599 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy291, &yymsp[0].minor.yy0); | ||
| 161600 | } | ||
| 161601 | break; | ||
| 161602 | case 289: /* add_column_fullname ::= fullname */ | ||
| 159523 | { | 161603 | { |
| 159524 | disableLookaside(pParse); | 161604 | disableLookaside(pParse); |
| 159525 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy47); | 161605 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy291); |
| 159526 | } | 161606 | } |
| 159527 | break; | 161607 | break; |
| 159528 | case 282: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 161608 | case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 159529 | { | 161609 | { |
| 159530 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy47, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); | 161610 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy291, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 159531 | } | 161611 | } |
| 159532 | break; | 161612 | break; |
| 159533 | case 283: /* cmd ::= create_vtab */ | 161613 | case 291: /* cmd ::= create_vtab */ |
| 159534 | {sqlite3VtabFinishParse(pParse,0);} | 161614 | {sqlite3VtabFinishParse(pParse,0);} |
| 159535 | break; | 161615 | break; |
| 159536 | case 284: /* cmd ::= create_vtab LP vtabarglist RP */ | 161616 | case 292: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 159537 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} | 161617 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 159538 | break; | 161618 | break; |
| 159539 | case 285: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 161619 | case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 159540 | { | 161620 | { |
| 159541 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy192); | 161621 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy60); |
| 159542 | } | 161622 | } |
| 159543 | break; | 161623 | break; |
| 159544 | case 286: /* vtabarg ::= */ | 161624 | case 294: /* vtabarg ::= */ |
| 159545 | {sqlite3VtabArgInit(pParse);} | 161625 | {sqlite3VtabArgInit(pParse);} |
| 159546 | break; | 161626 | break; |
| 159547 | case 287: /* vtabargtoken ::= ANY */ | 161627 | case 295: /* vtabargtoken ::= ANY */ |
| 159548 | case 288: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==288); | 161628 | case 296: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==296); |
| 159549 | case 289: /* lp ::= LP */ yytestcase(yyruleno==289); | 161629 | case 297: /* lp ::= LP */ yytestcase(yyruleno==297); |
| 159550 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} | 161630 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 159551 | break; | 161631 | break; |
| 159552 | case 290: /* with ::= WITH wqlist */ | 161632 | case 298: /* with ::= WITH wqlist */ |
| 159553 | case 291: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==291); | 161633 | case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299); |
| 159554 | { sqlite3WithPush(pParse, yymsp[0].minor.yy131, 1); } | 161634 | { sqlite3WithPush(pParse, yymsp[0].minor.yy195, 1); } |
| 161635 | break; | ||
| 161636 | case 300: /* wqas ::= AS */ | ||
| 161637 | {yymsp[0].minor.yy570 = M10d_Any;} | ||
| 161638 | break; | ||
| 161639 | case 301: /* wqas ::= AS MATERIALIZED */ | ||
| 161640 | {yymsp[-1].minor.yy570 = M10d_Yes;} | ||
| 161641 | break; | ||
| 161642 | case 302: /* wqas ::= AS NOT MATERIALIZED */ | ||
| 161643 | {yymsp[-2].minor.yy570 = M10d_No;} | ||
| 159555 | break; | 161644 | break; |
| 159556 | case 292: /* wqlist ::= nm eidlist_opt AS LP select RP */ | 161645 | case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 159557 | { | 161646 | { |
| 159558 | yymsp[-5].minor.yy131 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539); /*A-overwrites-X*/ | 161647 | yymsp[-5].minor.yy607 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy338, yymsp[-1].minor.yy307, yymsp[-3].minor.yy570); /*A-overwrites-X*/ |
| 159559 | } | 161648 | } |
| 159560 | break; | 161649 | break; |
| 159561 | case 293: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ | 161650 | case 304: /* wqlist ::= wqitem */ |
| 159562 | { | 161651 | { |
| 159563 | yymsp[-7].minor.yy131 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy131, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy242, yymsp[-1].minor.yy539); | 161652 | yymsp[0].minor.yy195 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy607); /*A-overwrites-X*/ |
| 159564 | } | 161653 | } |
| 159565 | break; | 161654 | break; |
| 159566 | case 294: /* windowdefn_list ::= windowdefn */ | 161655 | case 305: /* wqlist ::= wqlist COMMA wqitem */ |
| 159567 | { yylhsminor.yy303 = yymsp[0].minor.yy303; } | 161656 | { |
| 159568 | yymsp[0].minor.yy303 = yylhsminor.yy303; | 161657 | yymsp[-2].minor.yy195 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy195, yymsp[0].minor.yy607); |
| 161658 | } | ||
| 159569 | break; | 161659 | break; |
| 159570 | case 295: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 161660 | case 306: /* windowdefn_list ::= windowdefn */ |
| 161661 | { yylhsminor.yy19 = yymsp[0].minor.yy19; } | ||
| 161662 | yymsp[0].minor.yy19 = yylhsminor.yy19; | ||
| 161663 | break; | ||
| 161664 | case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ | ||
| 159571 | { | 161665 | { |
| 159572 | assert( yymsp[0].minor.yy303!=0 ); | 161666 | assert( yymsp[0].minor.yy19!=0 ); |
| 159573 | sqlite3WindowChain(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy303); | 161667 | sqlite3WindowChain(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy19); |
| 159574 | yymsp[0].minor.yy303->pNextWin = yymsp[-2].minor.yy303; | 161668 | yymsp[0].minor.yy19->pNextWin = yymsp[-2].minor.yy19; |
| 159575 | yylhsminor.yy303 = yymsp[0].minor.yy303; | 161669 | yylhsminor.yy19 = yymsp[0].minor.yy19; |
| 159576 | } | 161670 | } |
| 159577 | yymsp[-2].minor.yy303 = yylhsminor.yy303; | 161671 | yymsp[-2].minor.yy19 = yylhsminor.yy19; |
| 159578 | break; | 161672 | break; |
| 159579 | case 296: /* windowdefn ::= nm AS LP window RP */ | 161673 | case 308: /* windowdefn ::= nm AS LP window RP */ |
| 159580 | { | 161674 | { |
| 159581 | if( ALWAYS(yymsp[-1].minor.yy303) ){ | 161675 | if( ALWAYS(yymsp[-1].minor.yy19) ){ |
| 159582 | yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); | 161676 | yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 159583 | } | 161677 | } |
| 159584 | yylhsminor.yy303 = yymsp[-1].minor.yy303; | 161678 | yylhsminor.yy19 = yymsp[-1].minor.yy19; |
| 159585 | } | 161679 | } |
| 159586 | yymsp[-4].minor.yy303 = yylhsminor.yy303; | 161680 | yymsp[-4].minor.yy19 = yylhsminor.yy19; |
| 159587 | break; | 161681 | break; |
| 159588 | case 297: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 161682 | case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 159589 | { | 161683 | { |
| 159590 | yymsp[-4].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, 0); | 161684 | yymsp[-4].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, 0); |
| 159591 | } | 161685 | } |
| 159592 | break; | 161686 | break; |
| 159593 | case 298: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 161687 | case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 159594 | { | 161688 | { |
| 159595 | yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, yymsp[-2].minor.yy242, yymsp[-1].minor.yy242, &yymsp[-5].minor.yy0); | 161689 | yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, yymsp[-2].minor.yy338, yymsp[-1].minor.yy338, &yymsp[-5].minor.yy0); |
| 159596 | } | 161690 | } |
| 159597 | yymsp[-5].minor.yy303 = yylhsminor.yy303; | 161691 | yymsp[-5].minor.yy19 = yylhsminor.yy19; |
| 159598 | break; | 161692 | break; |
| 159599 | case 299: /* window ::= ORDER BY sortlist frame_opt */ | 161693 | case 311: /* window ::= ORDER BY sortlist frame_opt */ |
| 159600 | { | 161694 | { |
| 159601 | yymsp[-3].minor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, 0); | 161695 | yymsp[-3].minor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, 0); |
| 159602 | } | 161696 | } |
| 159603 | break; | 161697 | break; |
| 159604 | case 300: /* window ::= nm ORDER BY sortlist frame_opt */ | 161698 | case 312: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 159605 | { | 161699 | { |
| 159606 | yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, yymsp[-1].minor.yy242, &yymsp[-4].minor.yy0); | 161700 | yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, yymsp[-1].minor.yy338, &yymsp[-4].minor.yy0); |
| 159607 | } | 161701 | } |
| 159608 | yymsp[-4].minor.yy303 = yylhsminor.yy303; | 161702 | yymsp[-4].minor.yy19 = yylhsminor.yy19; |
| 159609 | break; | 161703 | break; |
| 159610 | case 301: /* window ::= frame_opt */ | 161704 | case 313: /* window ::= frame_opt */ |
| 159611 | case 320: /* filter_over ::= over_clause */ yytestcase(yyruleno==320); | 161705 | case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332); |
| 159612 | { | 161706 | { |
| 159613 | yylhsminor.yy303 = yymsp[0].minor.yy303; | 161707 | yylhsminor.yy19 = yymsp[0].minor.yy19; |
| 159614 | } | 161708 | } |
| 159615 | yymsp[0].minor.yy303 = yylhsminor.yy303; | 161709 | yymsp[0].minor.yy19 = yylhsminor.yy19; |
| 159616 | break; | 161710 | break; |
| 159617 | case 302: /* window ::= nm frame_opt */ | 161711 | case 314: /* window ::= nm frame_opt */ |
| 159618 | { | 161712 | { |
| 159619 | yylhsminor.yy303 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy303, 0, 0, &yymsp[-1].minor.yy0); | 161713 | yylhsminor.yy19 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy19, 0, 0, &yymsp[-1].minor.yy0); |
| 159620 | } | 161714 | } |
| 159621 | yymsp[-1].minor.yy303 = yylhsminor.yy303; | 161715 | yymsp[-1].minor.yy19 = yylhsminor.yy19; |
| 159622 | break; | 161716 | break; |
| 159623 | case 303: /* frame_opt ::= */ | 161717 | case 315: /* frame_opt ::= */ |
| 159624 | { | 161718 | { |
| 159625 | yymsp[1].minor.yy303 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); | 161719 | yymsp[1].minor.yy19 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 159626 | } | 161720 | } |
| 159627 | break; | 161721 | break; |
| 159628 | case 304: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 161722 | case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 159629 | { | 161723 | { |
| 159630 | yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy192, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy58); | 161724 | yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy60, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy570); |
| 159631 | } | 161725 | } |
| 159632 | yymsp[-2].minor.yy303 = yylhsminor.yy303; | 161726 | yymsp[-2].minor.yy19 = yylhsminor.yy19; |
| 159633 | break; | 161727 | break; |
| 159634 | case 305: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 161728 | case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 159635 | { | 161729 | { |
| 159636 | yylhsminor.yy303 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy192, yymsp[-3].minor.yy77.eType, yymsp[-3].minor.yy77.pExpr, yymsp[-1].minor.yy77.eType, yymsp[-1].minor.yy77.pExpr, yymsp[0].minor.yy58); | 161730 | yylhsminor.yy19 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy60, yymsp[-3].minor.yy113.eType, yymsp[-3].minor.yy113.pExpr, yymsp[-1].minor.yy113.eType, yymsp[-1].minor.yy113.pExpr, yymsp[0].minor.yy570); |
| 159637 | } | 161731 | } |
| 159638 | yymsp[-5].minor.yy303 = yylhsminor.yy303; | 161732 | yymsp[-5].minor.yy19 = yylhsminor.yy19; |
| 159639 | break; | 161733 | break; |
| 159640 | case 307: /* frame_bound_s ::= frame_bound */ | 161734 | case 319: /* frame_bound_s ::= frame_bound */ |
| 159641 | case 309: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==309); | 161735 | case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321); |
| 159642 | {yylhsminor.yy77 = yymsp[0].minor.yy77;} | 161736 | {yylhsminor.yy113 = yymsp[0].minor.yy113;} |
| 159643 | yymsp[0].minor.yy77 = yylhsminor.yy77; | 161737 | yymsp[0].minor.yy113 = yylhsminor.yy113; |
| 159644 | break; | 161738 | break; |
| 159645 | case 308: /* frame_bound_s ::= UNBOUNDED PRECEDING */ | 161739 | case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 159646 | case 310: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==310); | 161740 | case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322); |
| 159647 | case 312: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==312); | 161741 | case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324); |
| 159648 | {yylhsminor.yy77.eType = yymsp[-1].major; yylhsminor.yy77.pExpr = 0;} | 161742 | {yylhsminor.yy113.eType = yymsp[-1].major; yylhsminor.yy113.pExpr = 0;} |
| 159649 | yymsp[-1].minor.yy77 = yylhsminor.yy77; | 161743 | yymsp[-1].minor.yy113 = yylhsminor.yy113; |
| 159650 | break; | 161744 | break; |
| 159651 | case 311: /* frame_bound ::= expr PRECEDING|FOLLOWING */ | 161745 | case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 159652 | {yylhsminor.yy77.eType = yymsp[0].major; yylhsminor.yy77.pExpr = yymsp[-1].minor.yy202;} | 161746 | {yylhsminor.yy113.eType = yymsp[0].major; yylhsminor.yy113.pExpr = yymsp[-1].minor.yy602;} |
| 159653 | yymsp[-1].minor.yy77 = yylhsminor.yy77; | 161747 | yymsp[-1].minor.yy113 = yylhsminor.yy113; |
| 159654 | break; | 161748 | break; |
| 159655 | case 313: /* frame_exclude_opt ::= */ | 161749 | case 325: /* frame_exclude_opt ::= */ |
| 159656 | {yymsp[1].minor.yy58 = 0;} | 161750 | {yymsp[1].minor.yy570 = 0;} |
| 159657 | break; | 161751 | break; |
| 159658 | case 314: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ | 161752 | case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 159659 | {yymsp[-1].minor.yy58 = yymsp[0].minor.yy58;} | 161753 | {yymsp[-1].minor.yy570 = yymsp[0].minor.yy570;} |
| 159660 | break; | 161754 | break; |
| 159661 | case 315: /* frame_exclude ::= NO OTHERS */ | 161755 | case 327: /* frame_exclude ::= NO OTHERS */ |
| 159662 | case 316: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==316); | 161756 | case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328); |
| 159663 | {yymsp[-1].minor.yy58 = yymsp[-1].major; /*A-overwrites-X*/} | 161757 | {yymsp[-1].minor.yy570 = yymsp[-1].major; /*A-overwrites-X*/} |
| 159664 | break; | 161758 | break; |
| 159665 | case 317: /* frame_exclude ::= GROUP|TIES */ | 161759 | case 329: /* frame_exclude ::= GROUP|TIES */ |
| 159666 | {yymsp[0].minor.yy58 = yymsp[0].major; /*A-overwrites-X*/} | 161760 | {yymsp[0].minor.yy570 = yymsp[0].major; /*A-overwrites-X*/} |
| 159667 | break; | 161761 | break; |
| 159668 | case 318: /* window_clause ::= WINDOW windowdefn_list */ | 161762 | case 330: /* window_clause ::= WINDOW windowdefn_list */ |
| 159669 | { yymsp[-1].minor.yy303 = yymsp[0].minor.yy303; } | 161763 | { yymsp[-1].minor.yy19 = yymsp[0].minor.yy19; } |
| 159670 | break; | 161764 | break; |
| 159671 | case 319: /* filter_over ::= filter_clause over_clause */ | 161765 | case 331: /* filter_over ::= filter_clause over_clause */ |
| 159672 | { | 161766 | { |
| 159673 | yymsp[0].minor.yy303->pFilter = yymsp[-1].minor.yy202; | 161767 | yymsp[0].minor.yy19->pFilter = yymsp[-1].minor.yy602; |
| 159674 | yylhsminor.yy303 = yymsp[0].minor.yy303; | 161768 | yylhsminor.yy19 = yymsp[0].minor.yy19; |
| 159675 | } | 161769 | } |
| 159676 | yymsp[-1].minor.yy303 = yylhsminor.yy303; | 161770 | yymsp[-1].minor.yy19 = yylhsminor.yy19; |
| 159677 | break; | 161771 | break; |
| 159678 | case 321: /* filter_over ::= filter_clause */ | 161772 | case 333: /* filter_over ::= filter_clause */ |
| 159679 | { | 161773 | { |
| 159680 | yylhsminor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 161774 | yylhsminor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 159681 | if( yylhsminor.yy303 ){ | 161775 | if( yylhsminor.yy19 ){ |
| 159682 | yylhsminor.yy303->eFrmType = TK_FILTER; | 161776 | yylhsminor.yy19->eFrmType = TK_FILTER; |
| 159683 | yylhsminor.yy303->pFilter = yymsp[0].minor.yy202; | 161777 | yylhsminor.yy19->pFilter = yymsp[0].minor.yy602; |
| 159684 | }else{ | 161778 | }else{ |
| 159685 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy202); | 161779 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy602); |
| 159686 | } | 161780 | } |
| 159687 | } | 161781 | } |
| 159688 | yymsp[0].minor.yy303 = yylhsminor.yy303; | 161782 | yymsp[0].minor.yy19 = yylhsminor.yy19; |
| 159689 | break; | 161783 | break; |
| 159690 | case 322: /* over_clause ::= OVER LP window RP */ | 161784 | case 334: /* over_clause ::= OVER LP window RP */ |
| 159691 | { | 161785 | { |
| 159692 | yymsp[-3].minor.yy303 = yymsp[-1].minor.yy303; | 161786 | yymsp[-3].minor.yy19 = yymsp[-1].minor.yy19; |
| 159693 | assert( yymsp[-3].minor.yy303!=0 ); | 161787 | assert( yymsp[-3].minor.yy19!=0 ); |
| 159694 | } | 161788 | } |
| 159695 | break; | 161789 | break; |
| 159696 | case 323: /* over_clause ::= OVER nm */ | 161790 | case 335: /* over_clause ::= OVER nm */ |
| 159697 | { | 161791 | { |
| 159698 | yymsp[-1].minor.yy303 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 161792 | yymsp[-1].minor.yy19 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 159699 | if( yymsp[-1].minor.yy303 ){ | 161793 | if( yymsp[-1].minor.yy19 ){ |
| 159700 | yymsp[-1].minor.yy303->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); | 161794 | yymsp[-1].minor.yy19->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 159701 | } | 161795 | } |
| 159702 | } | 161796 | } |
| 159703 | break; | 161797 | break; |
| 159704 | case 324: /* filter_clause ::= FILTER LP WHERE expr RP */ | 161798 | case 336: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 159705 | { yymsp[-4].minor.yy202 = yymsp[-1].minor.yy202; } | 161799 | { yymsp[-4].minor.yy602 = yymsp[-1].minor.yy602; } |
| 159706 | break; | 161800 | break; |
| 159707 | default: | 161801 | default: |
| 159708 | /* (325) input ::= cmdlist */ yytestcase(yyruleno==325); | 161802 | /* (337) input ::= cmdlist */ yytestcase(yyruleno==337); |
| 159709 | /* (326) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==326); | 161803 | /* (338) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==338); |
| 159710 | /* (327) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=327); | 161804 | /* (339) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=339); |
| 159711 | /* (328) ecmd ::= SEMI */ yytestcase(yyruleno==328); | 161805 | /* (340) ecmd ::= SEMI */ yytestcase(yyruleno==340); |
| 159712 | /* (329) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==329); | 161806 | /* (341) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==341); |
| 159713 | /* (330) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=330); | 161807 | /* (342) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=342); |
| 159714 | /* (331) trans_opt ::= */ yytestcase(yyruleno==331); | 161808 | /* (343) trans_opt ::= */ yytestcase(yyruleno==343); |
| 159715 | /* (332) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==332); | 161809 | /* (344) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==344); |
| 159716 | /* (333) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==333); | 161810 | /* (345) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==345); |
| 159717 | /* (334) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==334); | 161811 | /* (346) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==346); |
| 159718 | /* (335) savepoint_opt ::= */ yytestcase(yyruleno==335); | 161812 | /* (347) savepoint_opt ::= */ yytestcase(yyruleno==347); |
| 159719 | /* (336) cmd ::= create_table create_table_args */ yytestcase(yyruleno==336); | 161813 | /* (348) cmd ::= create_table create_table_args */ yytestcase(yyruleno==348); |
| 159720 | /* (337) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==337); | 161814 | /* (349) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==349); |
| 159721 | /* (338) columnlist ::= columnname carglist */ yytestcase(yyruleno==338); | 161815 | /* (350) columnlist ::= columnname carglist */ yytestcase(yyruleno==350); |
| 159722 | /* (339) nm ::= ID|INDEXED */ yytestcase(yyruleno==339); | 161816 | /* (351) nm ::= ID|INDEXED */ yytestcase(yyruleno==351); |
| 159723 | /* (340) nm ::= STRING */ yytestcase(yyruleno==340); | 161817 | /* (352) nm ::= STRING */ yytestcase(yyruleno==352); |
| 159724 | /* (341) nm ::= JOIN_KW */ yytestcase(yyruleno==341); | 161818 | /* (353) nm ::= JOIN_KW */ yytestcase(yyruleno==353); |
| 159725 | /* (342) typetoken ::= typename */ yytestcase(yyruleno==342); | 161819 | /* (354) typetoken ::= typename */ yytestcase(yyruleno==354); |
| 159726 | /* (343) typename ::= ID|STRING */ yytestcase(yyruleno==343); | 161820 | /* (355) typename ::= ID|STRING */ yytestcase(yyruleno==355); |
| 159727 | /* (344) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=344); | 161821 | /* (356) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=356); |
| 159728 | /* (345) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=345); | 161822 | /* (357) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); |
| 159729 | /* (346) carglist ::= carglist ccons */ yytestcase(yyruleno==346); | 161823 | /* (358) carglist ::= carglist ccons */ yytestcase(yyruleno==358); |
| 159730 | /* (347) carglist ::= */ yytestcase(yyruleno==347); | 161824 | /* (359) carglist ::= */ yytestcase(yyruleno==359); |
| 159731 | /* (348) ccons ::= NULL onconf */ yytestcase(yyruleno==348); | 161825 | /* (360) ccons ::= NULL onconf */ yytestcase(yyruleno==360); |
| 159732 | /* (349) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==349); | 161826 | /* (361) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==361); |
| 159733 | /* (350) ccons ::= AS generated */ yytestcase(yyruleno==350); | 161827 | /* (362) ccons ::= AS generated */ yytestcase(yyruleno==362); |
| 159734 | /* (351) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==351); | 161828 | /* (363) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==363); |
| 159735 | /* (352) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==352); | 161829 | /* (364) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==364); |
| 159736 | /* (353) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=353); | 161830 | /* (365) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=365); |
| 159737 | /* (354) tconscomma ::= */ yytestcase(yyruleno==354); | 161831 | /* (366) tconscomma ::= */ yytestcase(yyruleno==366); |
| 159738 | /* (355) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=355); | 161832 | /* (367) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=367); |
| 159739 | /* (356) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=356); | 161833 | /* (368) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=368); |
| 159740 | /* (357) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=357); | 161834 | /* (369) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=369); |
| 159741 | /* (358) oneselect ::= values */ yytestcase(yyruleno==358); | 161835 | /* (370) oneselect ::= values */ yytestcase(yyruleno==370); |
| 159742 | /* (359) sclp ::= selcollist COMMA */ yytestcase(yyruleno==359); | 161836 | /* (371) sclp ::= selcollist COMMA */ yytestcase(yyruleno==371); |
| 159743 | /* (360) as ::= ID|STRING */ yytestcase(yyruleno==360); | 161837 | /* (372) as ::= ID|STRING */ yytestcase(yyruleno==372); |
| 159744 | /* (361) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=361); | 161838 | /* (373) returning ::= */ yytestcase(yyruleno==373); |
| 159745 | /* (362) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==362); | 161839 | /* (374) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=374); |
| 159746 | /* (363) exprlist ::= nexprlist */ yytestcase(yyruleno==363); | 161840 | /* (375) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==375); |
| 159747 | /* (364) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=364); | 161841 | /* (376) exprlist ::= nexprlist */ yytestcase(yyruleno==376); |
| 159748 | /* (365) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=365); | 161842 | /* (377) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=377); |
| 159749 | /* (366) nmnum ::= ON */ yytestcase(yyruleno==366); | 161843 | /* (378) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=378); |
| 159750 | /* (367) nmnum ::= DELETE */ yytestcase(yyruleno==367); | 161844 | /* (379) nmnum ::= ON */ yytestcase(yyruleno==379); |
| 159751 | /* (368) nmnum ::= DEFAULT */ yytestcase(yyruleno==368); | 161845 | /* (380) nmnum ::= DELETE */ yytestcase(yyruleno==380); |
| 159752 | /* (369) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==369); | 161846 | /* (381) nmnum ::= DEFAULT */ yytestcase(yyruleno==381); |
| 159753 | /* (370) foreach_clause ::= */ yytestcase(yyruleno==370); | 161847 | /* (382) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==382); |
| 159754 | /* (371) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==371); | 161848 | /* (383) foreach_clause ::= */ yytestcase(yyruleno==383); |
| 159755 | /* (372) trnm ::= nm */ yytestcase(yyruleno==372); | 161849 | /* (384) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==384); |
| 159756 | /* (373) tridxby ::= */ yytestcase(yyruleno==373); | 161850 | /* (385) trnm ::= nm */ yytestcase(yyruleno==385); |
| 159757 | /* (374) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==374); | 161851 | /* (386) tridxby ::= */ yytestcase(yyruleno==386); |
| 159758 | /* (375) database_kw_opt ::= */ yytestcase(yyruleno==375); | 161852 | /* (387) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==387); |
| 159759 | /* (376) kwcolumn_opt ::= */ yytestcase(yyruleno==376); | 161853 | /* (388) database_kw_opt ::= */ yytestcase(yyruleno==388); |
| 159760 | /* (377) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==377); | 161854 | /* (389) kwcolumn_opt ::= */ yytestcase(yyruleno==389); |
| 159761 | /* (378) vtabarglist ::= vtabarg */ yytestcase(yyruleno==378); | 161855 | /* (390) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==390); |
| 159762 | /* (379) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==379); | 161856 | /* (391) vtabarglist ::= vtabarg */ yytestcase(yyruleno==391); |
| 159763 | /* (380) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==380); | 161857 | /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==392); |
| 159764 | /* (381) anylist ::= */ yytestcase(yyruleno==381); | 161858 | /* (393) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==393); |
| 159765 | /* (382) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==382); | 161859 | /* (394) anylist ::= */ yytestcase(yyruleno==394); |
| 159766 | /* (383) anylist ::= anylist ANY */ yytestcase(yyruleno==383); | 161860 | /* (395) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==395); |
| 159767 | /* (384) with ::= */ yytestcase(yyruleno==384); | 161861 | /* (396) anylist ::= anylist ANY */ yytestcase(yyruleno==396); |
| 161862 | /* (397) with ::= */ yytestcase(yyruleno==397); | ||
| 159768 | break; | 161863 | break; |
| 159769 | /********** End reduce actions ************************************************/ | 161864 | /********** End reduce actions ************************************************/ |
| 159770 | }; | 161865 | }; |
| @@ -159916,12 +162011,56 @@ SQLITE_PRIVATE void sqlite3Parser( | |||
| 159916 | } | 162011 | } |
| 159917 | #endif | 162012 | #endif |
| 159918 | 162013 | ||
| 159919 | do{ | 162014 | while(1){ /* Exit by "break" */ |
| 162015 | assert( yypParser->yytos>=yypParser->yystack ); | ||
| 159920 | assert( yyact==yypParser->yytos->stateno ); | 162016 | assert( yyact==yypParser->yytos->stateno ); |
| 159921 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); | 162017 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); |
| 159922 | if( yyact >= YY_MIN_REDUCE ){ | 162018 | if( yyact >= YY_MIN_REDUCE ){ |
| 159923 | yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, | 162019 | unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ |
| 159924 | yyminor sqlite3ParserCTX_PARAM); | 162020 | assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); |
| 162021 | #ifndef NDEBUG | ||
| 162022 | if( yyTraceFILE ){ | ||
| 162023 | int yysize = yyRuleInfoNRhs[yyruleno]; | ||
| 162024 | if( yysize ){ | ||
| 162025 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", | ||
| 162026 | yyTracePrompt, | ||
| 162027 | yyruleno, yyRuleName[yyruleno], | ||
| 162028 | yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action", | ||
| 162029 | yypParser->yytos[yysize].stateno); | ||
| 162030 | }else{ | ||
| 162031 | fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", | ||
| 162032 | yyTracePrompt, yyruleno, yyRuleName[yyruleno], | ||
| 162033 | yyruleno<YYNRULE_WITH_ACTION ? "" : " without external action"); | ||
| 162034 | } | ||
| 162035 | } | ||
| 162036 | #endif /* NDEBUG */ | ||
| 162037 | |||
| 162038 | /* Check that the stack is large enough to grow by a single entry | ||
| 162039 | ** if the RHS of the rule is empty. This ensures that there is room | ||
| 162040 | ** enough on the stack to push the LHS value */ | ||
| 162041 | if( yyRuleInfoNRhs[yyruleno]==0 ){ | ||
| 162042 | #ifdef YYTRACKMAXSTACKDEPTH | ||
| 162043 | if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ | ||
| 162044 | yypParser->yyhwm++; | ||
| 162045 | assert( yypParser->yyhwm == | ||
| 162046 | (int)(yypParser->yytos - yypParser->yystack)); | ||
| 162047 | } | ||
| 162048 | #endif | ||
| 162049 | #if YYSTACKDEPTH>0 | ||
| 162050 | if( yypParser->yytos>=yypParser->yystackEnd ){ | ||
| 162051 | yyStackOverflow(yypParser); | ||
| 162052 | break; | ||
| 162053 | } | ||
| 162054 | #else | ||
| 162055 | if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ | ||
| 162056 | if( yyGrowStack(yypParser) ){ | ||
| 162057 | yyStackOverflow(yypParser); | ||
| 162058 | break; | ||
| 162059 | } | ||
| 162060 | } | ||
| 162061 | #endif | ||
| 162062 | } | ||
| 162063 | yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor sqlite3ParserCTX_PARAM); | ||
| 159925 | }else if( yyact <= YY_MAX_SHIFTREDUCE ){ | 162064 | }else if( yyact <= YY_MAX_SHIFTREDUCE ){ |
| 159926 | yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); | 162065 | yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); |
| 159927 | #ifndef YYNOERRORRECOVERY | 162066 | #ifndef YYNOERRORRECOVERY |
| @@ -160034,7 +162173,7 @@ SQLITE_PRIVATE void sqlite3Parser( | |||
| 160034 | break; | 162173 | break; |
| 160035 | #endif | 162174 | #endif |
| 160036 | } | 162175 | } |
| 160037 | }while( yypParser->yytos>yypParser->yystack ); | 162176 | } |
| 160038 | #ifndef NDEBUG | 162177 | #ifndef NDEBUG |
| 160039 | if( yyTraceFILE ){ | 162178 | if( yyTraceFILE ){ |
| 160040 | yyStackEntry *i; | 162179 | yyStackEntry *i; |
| @@ -160095,8 +162234,8 @@ SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){ | |||
| 160095 | ** all of them need to be used within the switch. | 162234 | ** all of them need to be used within the switch. |
| 160096 | */ | 162235 | */ |
| 160097 | #define CC_X 0 /* The letter 'x', or start of BLOB literal */ | 162236 | #define CC_X 0 /* The letter 'x', or start of BLOB literal */ |
| 160098 | #define CC_KYWD 1 /* Alphabetics or '_'. Usable in a keyword */ | 162237 | #define CC_KYWD0 1 /* First letter of a keyword */ |
| 160099 | #define CC_ID 2 /* unicode characters usable in IDs */ | 162238 | #define CC_KYWD 2 /* Alphabetics or '_'. Usable in a keyword */ |
| 160100 | #define CC_DIGIT 3 /* Digits */ | 162239 | #define CC_DIGIT 3 /* Digits */ |
| 160101 | #define CC_DOLLAR 4 /* '$' */ | 162240 | #define CC_DOLLAR 4 /* '$' */ |
| 160102 | #define CC_VARALPHA 5 /* '@', '#', ':'. Alphabetic SQL variables */ | 162241 | #define CC_VARALPHA 5 /* '@', '#', ':'. Alphabetic SQL variables */ |
| @@ -160121,20 +162260,21 @@ SQLITE_PRIVATE int sqlite3ParserFallback(int iToken){ | |||
| 160121 | #define CC_AND 24 /* '&' */ | 162260 | #define CC_AND 24 /* '&' */ |
| 160122 | #define CC_TILDA 25 /* '~' */ | 162261 | #define CC_TILDA 25 /* '~' */ |
| 160123 | #define CC_DOT 26 /* '.' */ | 162262 | #define CC_DOT 26 /* '.' */ |
| 160124 | #define CC_ILLEGAL 27 /* Illegal character */ | 162263 | #define CC_ID 27 /* unicode characters usable in IDs */ |
| 160125 | #define CC_NUL 28 /* 0x00 */ | 162264 | #define CC_ILLEGAL 28 /* Illegal character */ |
| 162265 | #define CC_NUL 29 /* 0x00 */ | ||
| 160126 | 162266 | ||
| 160127 | static const unsigned char aiClass[] = { | 162267 | static const unsigned char aiClass[] = { |
| 160128 | #ifdef SQLITE_ASCII | 162268 | #ifdef SQLITE_ASCII |
| 160129 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ | 162269 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ |
| 160130 | /* 0x */ 28, 27, 27, 27, 27, 27, 27, 27, 27, 7, 7, 27, 7, 7, 27, 27, | 162270 | /* 0x */ 29, 28, 28, 28, 28, 28, 28, 28, 28, 7, 7, 28, 7, 7, 28, 28, |
| 160131 | /* 1x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | 162271 | /* 1x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| 160132 | /* 2x */ 7, 15, 8, 5, 4, 22, 24, 8, 17, 18, 21, 20, 23, 11, 26, 16, | 162272 | /* 2x */ 7, 15, 8, 5, 4, 22, 24, 8, 17, 18, 21, 20, 23, 11, 26, 16, |
| 160133 | /* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6, | 162273 | /* 3x */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 19, 12, 14, 13, 6, |
| 160134 | /* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 162274 | /* 4x */ 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 160135 | /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 9, 27, 27, 27, 1, | 162275 | /* 5x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 9, 28, 28, 28, 2, |
| 160136 | /* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 162276 | /* 6x */ 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 160137 | /* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 27, 10, 27, 25, 27, | 162277 | /* 7x */ 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 28, 10, 28, 25, 28, |
| 160138 | /* 8x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 162278 | /* 8x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 160139 | /* 9x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 162279 | /* 9x */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| 160140 | /* Ax */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | 162280 | /* Ax */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, |
| @@ -160146,22 +162286,22 @@ static const unsigned char aiClass[] = { | |||
| 160146 | #endif | 162286 | #endif |
| 160147 | #ifdef SQLITE_EBCDIC | 162287 | #ifdef SQLITE_EBCDIC |
| 160148 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ | 162288 | /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ |
| 160149 | /* 0x */ 27, 27, 27, 27, 27, 7, 27, 27, 27, 27, 27, 27, 7, 7, 27, 27, | 162289 | /* 0x */ 29, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 7, 7, 28, 28, |
| 160150 | /* 1x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | 162290 | /* 1x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| 160151 | /* 2x */ 27, 27, 27, 27, 27, 7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | 162291 | /* 2x */ 28, 28, 28, 28, 28, 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| 160152 | /* 3x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, | 162292 | /* 3x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, |
| 160153 | /* 4x */ 7, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 26, 12, 17, 20, 10, | 162293 | /* 4x */ 7, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 26, 12, 17, 20, 10, |
| 160154 | /* 5x */ 24, 27, 27, 27, 27, 27, 27, 27, 27, 27, 15, 4, 21, 18, 19, 27, | 162294 | /* 5x */ 24, 28, 28, 28, 28, 28, 28, 28, 28, 28, 15, 4, 21, 18, 19, 28, |
| 160155 | /* 6x */ 11, 16, 27, 27, 27, 27, 27, 27, 27, 27, 27, 23, 22, 1, 13, 6, | 162295 | /* 6x */ 11, 16, 28, 28, 28, 28, 28, 28, 28, 28, 28, 23, 22, 2, 13, 6, |
| 160156 | /* 7x */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 8, 5, 5, 5, 8, 14, 8, | 162296 | /* 7x */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 8, 5, 5, 5, 8, 14, 8, |
| 160157 | /* 8x */ 27, 1, 1, 1, 1, 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, 27, | 162297 | /* 8x */ 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28, 28, 28, 28, 28, 28, |
| 160158 | /* 9x */ 27, 1, 1, 1, 1, 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, 27, | 162298 | /* 9x */ 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28, 28, 28, 28, 28, 28, |
| 160159 | /* Ax */ 27, 25, 1, 1, 1, 1, 1, 0, 1, 1, 27, 27, 27, 27, 27, 27, | 162299 | /* Ax */ 28, 25, 1, 1, 1, 1, 1, 0, 2, 2, 28, 28, 28, 28, 28, 28, |
| 160160 | /* Bx */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 9, 27, 27, 27, 27, 27, | 162300 | /* Bx */ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 9, 28, 28, 28, 28, 28, |
| 160161 | /* Cx */ 27, 1, 1, 1, 1, 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, 27, | 162301 | /* Cx */ 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28, 28, 28, 28, 28, 28, |
| 160162 | /* Dx */ 27, 1, 1, 1, 1, 1, 1, 1, 1, 1, 27, 27, 27, 27, 27, 27, | 162302 | /* Dx */ 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 28, 28, 28, 28, 28, 28, |
| 160163 | /* Ex */ 27, 27, 1, 1, 1, 1, 1, 0, 1, 1, 27, 27, 27, 27, 27, 27, | 162303 | /* Ex */ 28, 28, 1, 1, 1, 1, 1, 0, 2, 2, 28, 28, 28, 28, 28, 28, |
| 160164 | /* Fx */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 27, 27, 27, 27, 27, 27, | 162304 | /* Fx */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 28, 28, 28, 28, 28, 28, |
| 160165 | #endif | 162305 | #endif |
| 160166 | }; | 162306 | }; |
| 160167 | 162307 | ||
| @@ -160226,20 +162366,21 @@ const unsigned char ebcdicToAscii[] = { | |||
| 160226 | ** is substantially reduced. This is important for embedded applications | 162366 | ** is substantially reduced. This is important for embedded applications |
| 160227 | ** on platforms with limited memory. | 162367 | ** on platforms with limited memory. |
| 160228 | */ | 162368 | */ |
| 160229 | /* Hash score: 227 */ | 162369 | /* Hash score: 231 */ |
| 160230 | /* zKWText[] encodes 984 bytes of keyword text in 648 bytes */ | 162370 | /* zKWText[] encodes 1007 bytes of keyword text in 667 bytes */ |
| 160231 | /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ | 162371 | /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ |
| 160232 | /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */ | 162372 | /* ABLEFTHENDEFERRABLELSEXCLUDELETEMPORARYISNULLSAVEPOINTERSECT */ |
| 160233 | /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */ | 162373 | /* IESNOTNULLIKEXCEPTRANSACTIONATURALTERAISEXCLUSIVEXISTS */ |
| 160234 | /* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */ | 162374 | /* CONSTRAINTOFFSETRIGGERANGENERATEDETACHAVINGLOBEGINNEREFERENCES */ |
| 160235 | /* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */ | 162375 | /* UNIQUERYWITHOUTERELEASEATTACHBETWEENOTHINGROUPSCASCADEFAULT */ |
| 160236 | /* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */ | 162376 | /* CASECOLLATECREATECURRENT_DATEIMMEDIATEJOINSERTMATCHPLANALYZE */ |
| 160237 | /* PRAGMABORTUPDATEVALUESVIRTUALWAYSWHENWHERECURSIVEAFTERENAMEAND */ | 162377 | /* PRAGMATERIALIZEDEFERREDISTINCTUPDATEVALUESVIRTUALWAYSWHENWHERE */ |
| 160238 | /* EFERREDISTINCTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */ | 162378 | /* CURSIVEABORTAFTERENAMEANDROPARTITIONAUTOINCREMENTCASTCOLUMN */ |
| 160239 | /* CURRENT_TIMESTAMPARTITIONDROPRECEDINGFAILASTFILTEREPLACEFIRST */ | 162379 | /* COMMITCONFLICTCROSSCURRENT_TIMESTAMPRECEDINGFAILASTFILTER */ |
| 160240 | /* FOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVERIGHTROLLBACKROWS */ | 162380 | /* EPLACEFIRSTFOLLOWINGFROMFULLIMITIFORDERESTRICTOTHERSOVER */ |
| 160241 | /* UNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBYINITIALLYPRIMARY */ | 162381 | /* ETURNINGRIGHTROLLBACKROWSUNBOUNDEDUNIONUSINGVACUUMVIEWINDOWBY */ |
| 160242 | static const char zKWText[647] = { | 162382 | /* INITIALLYPRIMARY */ |
| 162383 | static const char zKWText[666] = { | ||
| 160243 | 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H', | 162384 | 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H', |
| 160244 | 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G', | 162385 | 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G', |
| 160245 | 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A', | 162386 | 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A', |
| @@ -160260,86 +162401,87 @@ static const char zKWText[647] = { | |||
| 160260 | 'C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E', | 162401 | 'C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A','T','E', |
| 160261 | 'I','M','M','E','D','I','A','T','E','J','O','I','N','S','E','R','T','M', | 162402 | 'I','M','M','E','D','I','A','T','E','J','O','I','N','S','E','R','T','M', |
| 160262 | 'A','T','C','H','P','L','A','N','A','L','Y','Z','E','P','R','A','G','M', | 162403 | 'A','T','C','H','P','L','A','N','A','L','Y','Z','E','P','R','A','G','M', |
| 160263 | 'A','B','O','R','T','U','P','D','A','T','E','V','A','L','U','E','S','V', | 162404 | 'A','T','E','R','I','A','L','I','Z','E','D','E','F','E','R','R','E','D', |
| 160264 | 'I','R','T','U','A','L','W','A','Y','S','W','H','E','N','W','H','E','R', | 162405 | 'I','S','T','I','N','C','T','U','P','D','A','T','E','V','A','L','U','E', |
| 160265 | 'E','C','U','R','S','I','V','E','A','F','T','E','R','E','N','A','M','E', | 162406 | 'S','V','I','R','T','U','A','L','W','A','Y','S','W','H','E','N','W','H', |
| 160266 | 'A','N','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','A', | 162407 | 'E','R','E','C','U','R','S','I','V','E','A','B','O','R','T','A','F','T', |
| 160267 | 'U','T','O','I','N','C','R','E','M','E','N','T','C','A','S','T','C','O', | 162408 | 'E','R','E','N','A','M','E','A','N','D','R','O','P','A','R','T','I','T', |
| 160268 | 'L','U','M','N','C','O','M','M','I','T','C','O','N','F','L','I','C','T', | 162409 | 'I','O','N','A','U','T','O','I','N','C','R','E','M','E','N','T','C','A', |
| 160269 | 'C','R','O','S','S','C','U','R','R','E','N','T','_','T','I','M','E','S', | 162410 | 'S','T','C','O','L','U','M','N','C','O','M','M','I','T','C','O','N','F', |
| 160270 | 'T','A','M','P','A','R','T','I','T','I','O','N','D','R','O','P','R','E', | 162411 | 'L','I','C','T','C','R','O','S','S','C','U','R','R','E','N','T','_','T', |
| 160271 | 'C','E','D','I','N','G','F','A','I','L','A','S','T','F','I','L','T','E', | 162412 | 'I','M','E','S','T','A','M','P','R','E','C','E','D','I','N','G','F','A', |
| 160272 | 'R','E','P','L','A','C','E','F','I','R','S','T','F','O','L','L','O','W', | 162413 | 'I','L','A','S','T','F','I','L','T','E','R','E','P','L','A','C','E','F', |
| 160273 | 'I','N','G','F','R','O','M','F','U','L','L','I','M','I','T','I','F','O', | 162414 | 'I','R','S','T','F','O','L','L','O','W','I','N','G','F','R','O','M','F', |
| 160274 | 'R','D','E','R','E','S','T','R','I','C','T','O','T','H','E','R','S','O', | 162415 | 'U','L','L','I','M','I','T','I','F','O','R','D','E','R','E','S','T','R', |
| 160275 | 'V','E','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W', | 162416 | 'I','C','T','O','T','H','E','R','S','O','V','E','R','E','T','U','R','N', |
| 160276 | 'S','U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S','I', | 162417 | 'I','N','G','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O', |
| 160277 | 'N','G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W','B', | 162418 | 'W','S','U','N','B','O','U','N','D','E','D','U','N','I','O','N','U','S', |
| 160278 | 'Y','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y', | 162419 | 'I','N','G','V','A','C','U','U','M','V','I','E','W','I','N','D','O','W', |
| 162420 | 'B','Y','I','N','I','T','I','A','L','L','Y','P','R','I','M','A','R','Y', | ||
| 160279 | }; | 162421 | }; |
| 160280 | /* aKWHash[i] is the hash value for the i-th keyword */ | 162422 | /* aKWHash[i] is the hash value for the i-th keyword */ |
| 160281 | static const unsigned char aKWHash[127] = { | 162423 | static const unsigned char aKWHash[127] = { |
| 160282 | 84, 102, 132, 82, 114, 29, 0, 0, 91, 0, 85, 72, 0, | 162424 | 84, 92, 134, 82, 105, 29, 0, 0, 94, 0, 85, 72, 0, |
| 160283 | 53, 35, 86, 15, 0, 42, 94, 54, 126, 133, 19, 0, 0, | 162425 | 53, 35, 86, 15, 0, 42, 97, 54, 89, 135, 19, 0, 0, |
| 160284 | 138, 0, 40, 128, 0, 22, 104, 0, 9, 0, 0, 122, 80, | 162426 | 140, 0, 40, 129, 0, 22, 107, 0, 9, 0, 0, 123, 80, |
| 160285 | 0, 78, 6, 0, 65, 99, 145, 0, 134, 112, 0, 0, 48, | 162427 | 0, 78, 6, 0, 65, 103, 147, 0, 136, 115, 0, 0, 48, |
| 160286 | 0, 100, 24, 0, 17, 0, 27, 70, 23, 26, 5, 60, 140, | 162428 | 0, 90, 24, 0, 17, 0, 27, 70, 23, 26, 5, 60, 142, |
| 160287 | 107, 121, 0, 73, 101, 71, 143, 61, 119, 74, 0, 49, 0, | 162429 | 110, 122, 0, 73, 91, 71, 145, 61, 120, 74, 0, 49, 0, |
| 160288 | 11, 41, 0, 110, 0, 0, 0, 106, 10, 108, 113, 124, 14, | 162430 | 11, 41, 0, 113, 0, 0, 0, 109, 10, 111, 116, 125, 14, |
| 160289 | 50, 123, 0, 89, 0, 18, 120, 142, 56, 129, 137, 88, 83, | 162431 | 50, 124, 0, 100, 0, 18, 121, 144, 56, 130, 139, 88, 83, |
| 160290 | 37, 30, 125, 0, 0, 105, 51, 130, 127, 0, 34, 0, 0, | 162432 | 37, 30, 126, 0, 0, 108, 51, 131, 128, 0, 34, 0, 0, |
| 160291 | 44, 0, 95, 38, 39, 0, 20, 45, 116, 90, | 162433 | 132, 0, 98, 38, 39, 0, 20, 45, 117, 93, |
| 160292 | }; | 162434 | }; |
| 160293 | /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0 | 162435 | /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0 |
| 160294 | ** then the i-th keyword has no more hash collisions. Otherwise, | 162436 | ** then the i-th keyword has no more hash collisions. Otherwise, |
| 160295 | ** the next keyword with the same hash is aKWHash[i]-1. */ | 162437 | ** the next keyword with the same hash is aKWHash[i]-1. */ |
| 160296 | static const unsigned char aKWNext[145] = { | 162438 | static const unsigned char aKWNext[147] = { |
| 160297 | 0, 0, 0, 0, 4, 0, 43, 0, 0, 103, 111, 0, 0, | 162439 | 0, 0, 0, 0, 4, 0, 43, 0, 0, 106, 114, 0, 0, |
| 160298 | 0, 2, 0, 0, 141, 0, 0, 0, 13, 0, 0, 0, 0, | 162440 | 0, 2, 0, 0, 143, 0, 0, 0, 13, 0, 0, 0, 0, |
| 160299 | 139, 0, 0, 118, 52, 0, 0, 135, 12, 0, 0, 62, 0, | 162441 | 141, 0, 0, 119, 52, 0, 0, 137, 12, 0, 0, 62, 0, |
| 160300 | 136, 0, 131, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0, | 162442 | 138, 0, 133, 0, 0, 36, 0, 0, 28, 77, 0, 0, 0, |
| 160301 | 0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 162443 | 0, 59, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 160302 | 0, 69, 0, 0, 0, 0, 0, 144, 3, 0, 58, 0, 1, | 162444 | 0, 69, 0, 0, 0, 0, 0, 146, 3, 0, 58, 0, 1, |
| 160303 | 75, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 64, 66, | 162445 | 75, 0, 0, 0, 31, 0, 0, 0, 0, 0, 127, 0, 104, |
| 160304 | 63, 0, 0, 0, 0, 46, 0, 16, 0, 115, 0, 0, 0, | 162446 | 0, 64, 66, 63, 0, 0, 0, 0, 0, 46, 0, 16, 8, |
| 160305 | 0, 0, 0, 0, 0, 0, 0, 81, 97, 0, 8, 0, 109, | 162447 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 81, 101, 0, |
| 160306 | 21, 7, 67, 0, 79, 93, 117, 0, 0, 68, 0, 0, 96, | 162448 | 112, 21, 7, 67, 0, 79, 96, 118, 0, 0, 68, 0, 0, |
| 160307 | 0, 55, 0, 76, 0, 92, 32, 33, 57, 25, 0, 98, 0, | 162449 | 99, 44, 0, 55, 0, 76, 0, 95, 32, 33, 57, 25, 0, |
| 160308 | 0, 87, | 162450 | 102, 0, 0, 87, |
| 160309 | }; | 162451 | }; |
| 160310 | /* aKWLen[i] is the length (in bytes) of the i-th keyword */ | 162452 | /* aKWLen[i] is the length (in bytes) of the i-th keyword */ |
| 160311 | static const unsigned char aKWLen[145] = { | 162453 | static const unsigned char aKWLen[147] = { |
| 160312 | 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, | 162454 | 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, |
| 160313 | 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7, | 162455 | 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 7, |
| 160314 | 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4, | 162456 | 6, 9, 4, 2, 6, 5, 9, 9, 4, 7, 3, 2, 4, |
| 160315 | 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6, | 162457 | 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 10, 4, 6, |
| 160316 | 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5, | 162458 | 2, 3, 7, 5, 9, 6, 6, 4, 5, 5, 10, 6, 5, |
| 160317 | 7, 4, 5, 7, 6, 7, 7, 6, 5, 7, 3, 7, 4, | 162459 | 7, 4, 5, 7, 6, 7, 7, 6, 5, 7, 3, 7, 4, |
| 160318 | 7, 6, 12, 9, 4, 6, 5, 4, 7, 6, 5, 6, 6, | 162460 | 7, 6, 12, 9, 4, 6, 5, 4, 7, 6, 12, 8, 8, |
| 160319 | 7, 6, 4, 5, 9, 5, 6, 3, 8, 8, 2, 13, 2, | 162461 | 2, 6, 6, 7, 6, 4, 5, 9, 5, 5, 6, 3, 4, |
| 160320 | 2, 4, 6, 6, 8, 5, 17, 12, 7, 9, 4, 9, 4, | 162462 | 9, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 9, |
| 160321 | 4, 6, 7, 5, 9, 4, 4, 5, 2, 5, 8, 6, 4, | 162463 | 4, 4, 6, 7, 5, 9, 4, 4, 5, 2, 5, 8, 6, |
| 160322 | 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2, 2, 9, | 162464 | 4, 9, 5, 8, 4, 3, 9, 5, 5, 6, 4, 6, 2, |
| 160323 | 3, 7, | 162465 | 2, 9, 3, 7, |
| 160324 | }; | 162466 | }; |
| 160325 | /* aKWOffset[i] is the index into zKWText[] of the start of | 162467 | /* aKWOffset[i] is the index into zKWText[] of the start of |
| 160326 | ** the text for the i-th keyword. */ | 162468 | ** the text for the i-th keyword. */ |
| 160327 | static const unsigned short int aKWOffset[145] = { | 162469 | static const unsigned short int aKWOffset[147] = { |
| 160328 | 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, | 162470 | 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, |
| 160329 | 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, | 162471 | 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, |
| 160330 | 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126, | 162472 | 86, 90, 90, 94, 99, 101, 105, 111, 119, 123, 123, 123, 126, |
| 160331 | 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184, | 162473 | 129, 132, 137, 142, 146, 147, 152, 156, 160, 168, 174, 181, 184, |
| 160332 | 184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239, | 162474 | 184, 187, 189, 195, 198, 206, 211, 216, 219, 222, 226, 236, 239, |
| 160333 | 244, 244, 248, 252, 259, 265, 271, 277, 277, 283, 284, 288, 295, | 162475 | 244, 244, 248, 252, 259, 265, 271, 277, 277, 283, 284, 288, 295, |
| 160334 | 299, 306, 312, 324, 333, 335, 341, 346, 348, 355, 360, 365, 371, | 162476 | 299, 306, 312, 324, 333, 335, 341, 346, 348, 355, 359, 370, 377, |
| 160335 | 377, 382, 388, 392, 395, 404, 408, 414, 416, 423, 424, 431, 433, | 162477 | 378, 385, 391, 397, 402, 408, 412, 415, 424, 429, 433, 439, 441, |
| 160336 | 435, 444, 448, 454, 460, 468, 473, 473, 473, 489, 498, 501, 510, | 162478 | 444, 453, 455, 457, 466, 470, 476, 482, 490, 495, 495, 495, 511, |
| 160337 | 513, 517, 522, 529, 534, 543, 547, 550, 555, 557, 561, 569, 575, | 162479 | 520, 523, 527, 532, 539, 544, 553, 557, 560, 565, 567, 571, 579, |
| 160338 | 578, 583, 591, 591, 595, 604, 609, 614, 620, 623, 626, 629, 631, | 162480 | 585, 588, 597, 602, 610, 610, 614, 623, 628, 633, 639, 642, 645, |
| 160339 | 636, 640, | 162481 | 648, 650, 655, 659, |
| 160340 | }; | 162482 | }; |
| 160341 | /* aKWCode[i] is the parser symbol code for the i-th keyword */ | 162483 | /* aKWCode[i] is the parser symbol code for the i-th keyword */ |
| 160342 | static const unsigned char aKWCode[145] = { | 162484 | static const unsigned char aKWCode[147] = { |
| 160343 | TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, | 162485 | TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, |
| 160344 | TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, | 162486 | TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, |
| 160345 | TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, | 162487 | TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, |
| @@ -160357,18 +162499,19 @@ static const unsigned char aKWCode[145] = { | |||
| 160357 | TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE, | 162499 | TK_BETWEEN, TK_NOTHING, TK_GROUPS, TK_GROUP, TK_CASCADE, |
| 160358 | TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE, | 162500 | TK_ASC, TK_DEFAULT, TK_CASE, TK_COLLATE, TK_CREATE, |
| 160359 | TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH, | 162501 | TK_CTIME_KW, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_MATCH, |
| 160360 | TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_UPDATE, | 162502 | TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_MATERIALIZED, TK_DEFERRED, |
| 160361 | TK_VALUES, TK_VIRTUAL, TK_ALWAYS, TK_WHEN, TK_WHERE, | 162503 | TK_DISTINCT, TK_IS, TK_UPDATE, TK_VALUES, TK_VIRTUAL, |
| 160362 | TK_RECURSIVE, TK_AFTER, TK_RENAME, TK_AND, TK_DEFERRED, | 162504 | TK_ALWAYS, TK_WHEN, TK_WHERE, TK_RECURSIVE, TK_ABORT, |
| 160363 | TK_DISTINCT, TK_IS, TK_AUTOINCR, TK_TO, TK_IN, | 162505 | TK_AFTER, TK_RENAME, TK_AND, TK_DROP, TK_PARTITION, |
| 160364 | TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, | 162506 | TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, |
| 160365 | TK_CTIME_KW, TK_CTIME_KW, TK_CURRENT, TK_PARTITION, TK_DROP, | 162507 | TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, |
| 160366 | TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER, TK_REPLACE, | 162508 | TK_CURRENT, TK_PRECEDING, TK_FAIL, TK_LAST, TK_FILTER, |
| 160367 | TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, TK_LIMIT, | 162509 | TK_REPLACE, TK_FIRST, TK_FOLLOWING, TK_FROM, TK_JOIN_KW, |
| 160368 | TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS, TK_OVER, | 162510 | TK_LIMIT, TK_IF, TK_ORDER, TK_RESTRICT, TK_OTHERS, |
| 160369 | TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNBOUNDED, | 162511 | TK_OVER, TK_RETURNING, TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, |
| 160370 | TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_WINDOW, | 162512 | TK_ROW, TK_UNBOUNDED, TK_UNION, TK_USING, TK_VACUUM, |
| 160371 | TK_DO, TK_BY, TK_INITIALLY, TK_ALL, TK_PRIMARY, | 162513 | TK_VIEW, TK_WINDOW, TK_DO, TK_BY, TK_INITIALLY, |
| 162514 | TK_ALL, TK_PRIMARY, | ||
| 160372 | }; | 162515 | }; |
| 160373 | /* Hash table decoded: | 162516 | /* Hash table decoded: |
| 160374 | ** 0: INSERT | 162517 | ** 0: INSERT |
| @@ -160392,7 +162535,7 @@ static const unsigned char aKWCode[145] = { | |||
| 160392 | ** 18: TRANSACTION RIGHT | 162535 | ** 18: TRANSACTION RIGHT |
| 160393 | ** 19: WHEN | 162536 | ** 19: WHEN |
| 160394 | ** 20: SET HAVING | 162537 | ** 20: SET HAVING |
| 160395 | ** 21: IF | 162538 | ** 21: MATERIALIZED IF |
| 160396 | ** 22: ROWS | 162539 | ** 22: ROWS |
| 160397 | ** 23: SELECT | 162540 | ** 23: SELECT |
| 160398 | ** 24: | 162541 | ** 24: |
| @@ -160488,7 +162631,7 @@ static const unsigned char aKWCode[145] = { | |||
| 160488 | ** 114: INTERSECT UNBOUNDED | 162631 | ** 114: INTERSECT UNBOUNDED |
| 160489 | ** 115: | 162632 | ** 115: |
| 160490 | ** 116: | 162633 | ** 116: |
| 160491 | ** 117: ON | 162634 | ** 117: RETURNING ON |
| 160492 | ** 118: | 162635 | ** 118: |
| 160493 | ** 119: WHERE | 162636 | ** 119: WHERE |
| 160494 | ** 120: NO INNER | 162637 | ** 120: NO INNER |
| @@ -160506,7 +162649,7 @@ static int keywordCode(const char *z, int n, int *pType){ | |||
| 160506 | int i, j; | 162649 | int i, j; |
| 160507 | const char *zKW; | 162650 | const char *zKW; |
| 160508 | if( n>=2 ){ | 162651 | if( n>=2 ){ |
| 160509 | i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n) % 127; | 162652 | i = ((charMap(z[0])*4) ^ (charMap(z[n-1])*3) ^ n*1) % 127; |
| 160510 | for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){ | 162653 | for(i=((int)aKWHash[i])-1; i>=0; i=((int)aKWNext[i])-1){ |
| 160511 | if( aKWLen[i]!=n ) continue; | 162654 | if( aKWLen[i]!=n ) continue; |
| 160512 | zKW = &zKWText[aKWOffset[i]]; | 162655 | zKW = &zKWText[aKWOffset[i]]; |
| @@ -160611,63 +162754,65 @@ static int keywordCode(const char *z, int n, int *pType){ | |||
| 160611 | testcase( i==85 ); /* PLAN */ | 162754 | testcase( i==85 ); /* PLAN */ |
| 160612 | testcase( i==86 ); /* ANALYZE */ | 162755 | testcase( i==86 ); /* ANALYZE */ |
| 160613 | testcase( i==87 ); /* PRAGMA */ | 162756 | testcase( i==87 ); /* PRAGMA */ |
| 160614 | testcase( i==88 ); /* ABORT */ | 162757 | testcase( i==88 ); /* MATERIALIZED */ |
| 160615 | testcase( i==89 ); /* UPDATE */ | 162758 | testcase( i==89 ); /* DEFERRED */ |
| 160616 | testcase( i==90 ); /* VALUES */ | 162759 | testcase( i==90 ); /* DISTINCT */ |
| 160617 | testcase( i==91 ); /* VIRTUAL */ | 162760 | testcase( i==91 ); /* IS */ |
| 160618 | testcase( i==92 ); /* ALWAYS */ | 162761 | testcase( i==92 ); /* UPDATE */ |
| 160619 | testcase( i==93 ); /* WHEN */ | 162762 | testcase( i==93 ); /* VALUES */ |
| 160620 | testcase( i==94 ); /* WHERE */ | 162763 | testcase( i==94 ); /* VIRTUAL */ |
| 160621 | testcase( i==95 ); /* RECURSIVE */ | 162764 | testcase( i==95 ); /* ALWAYS */ |
| 160622 | testcase( i==96 ); /* AFTER */ | 162765 | testcase( i==96 ); /* WHEN */ |
| 160623 | testcase( i==97 ); /* RENAME */ | 162766 | testcase( i==97 ); /* WHERE */ |
| 160624 | testcase( i==98 ); /* AND */ | 162767 | testcase( i==98 ); /* RECURSIVE */ |
| 160625 | testcase( i==99 ); /* DEFERRED */ | 162768 | testcase( i==99 ); /* ABORT */ |
| 160626 | testcase( i==100 ); /* DISTINCT */ | 162769 | testcase( i==100 ); /* AFTER */ |
| 160627 | testcase( i==101 ); /* IS */ | 162770 | testcase( i==101 ); /* RENAME */ |
| 160628 | testcase( i==102 ); /* AUTOINCREMENT */ | 162771 | testcase( i==102 ); /* AND */ |
| 160629 | testcase( i==103 ); /* TO */ | 162772 | testcase( i==103 ); /* DROP */ |
| 160630 | testcase( i==104 ); /* IN */ | 162773 | testcase( i==104 ); /* PARTITION */ |
| 160631 | testcase( i==105 ); /* CAST */ | 162774 | testcase( i==105 ); /* AUTOINCREMENT */ |
| 160632 | testcase( i==106 ); /* COLUMN */ | 162775 | testcase( i==106 ); /* TO */ |
| 160633 | testcase( i==107 ); /* COMMIT */ | 162776 | testcase( i==107 ); /* IN */ |
| 160634 | testcase( i==108 ); /* CONFLICT */ | 162777 | testcase( i==108 ); /* CAST */ |
| 160635 | testcase( i==109 ); /* CROSS */ | 162778 | testcase( i==109 ); /* COLUMN */ |
| 160636 | testcase( i==110 ); /* CURRENT_TIMESTAMP */ | 162779 | testcase( i==110 ); /* COMMIT */ |
| 160637 | testcase( i==111 ); /* CURRENT_TIME */ | 162780 | testcase( i==111 ); /* CONFLICT */ |
| 160638 | testcase( i==112 ); /* CURRENT */ | 162781 | testcase( i==112 ); /* CROSS */ |
| 160639 | testcase( i==113 ); /* PARTITION */ | 162782 | testcase( i==113 ); /* CURRENT_TIMESTAMP */ |
| 160640 | testcase( i==114 ); /* DROP */ | 162783 | testcase( i==114 ); /* CURRENT_TIME */ |
| 160641 | testcase( i==115 ); /* PRECEDING */ | 162784 | testcase( i==115 ); /* CURRENT */ |
| 160642 | testcase( i==116 ); /* FAIL */ | 162785 | testcase( i==116 ); /* PRECEDING */ |
| 160643 | testcase( i==117 ); /* LAST */ | 162786 | testcase( i==117 ); /* FAIL */ |
| 160644 | testcase( i==118 ); /* FILTER */ | 162787 | testcase( i==118 ); /* LAST */ |
| 160645 | testcase( i==119 ); /* REPLACE */ | 162788 | testcase( i==119 ); /* FILTER */ |
| 160646 | testcase( i==120 ); /* FIRST */ | 162789 | testcase( i==120 ); /* REPLACE */ |
| 160647 | testcase( i==121 ); /* FOLLOWING */ | 162790 | testcase( i==121 ); /* FIRST */ |
| 160648 | testcase( i==122 ); /* FROM */ | 162791 | testcase( i==122 ); /* FOLLOWING */ |
| 160649 | testcase( i==123 ); /* FULL */ | 162792 | testcase( i==123 ); /* FROM */ |
| 160650 | testcase( i==124 ); /* LIMIT */ | 162793 | testcase( i==124 ); /* FULL */ |
| 160651 | testcase( i==125 ); /* IF */ | 162794 | testcase( i==125 ); /* LIMIT */ |
| 160652 | testcase( i==126 ); /* ORDER */ | 162795 | testcase( i==126 ); /* IF */ |
| 160653 | testcase( i==127 ); /* RESTRICT */ | 162796 | testcase( i==127 ); /* ORDER */ |
| 160654 | testcase( i==128 ); /* OTHERS */ | 162797 | testcase( i==128 ); /* RESTRICT */ |
| 160655 | testcase( i==129 ); /* OVER */ | 162798 | testcase( i==129 ); /* OTHERS */ |
| 160656 | testcase( i==130 ); /* RIGHT */ | 162799 | testcase( i==130 ); /* OVER */ |
| 160657 | testcase( i==131 ); /* ROLLBACK */ | 162800 | testcase( i==131 ); /* RETURNING */ |
| 160658 | testcase( i==132 ); /* ROWS */ | 162801 | testcase( i==132 ); /* RIGHT */ |
| 160659 | testcase( i==133 ); /* ROW */ | 162802 | testcase( i==133 ); /* ROLLBACK */ |
| 160660 | testcase( i==134 ); /* UNBOUNDED */ | 162803 | testcase( i==134 ); /* ROWS */ |
| 160661 | testcase( i==135 ); /* UNION */ | 162804 | testcase( i==135 ); /* ROW */ |
| 160662 | testcase( i==136 ); /* USING */ | 162805 | testcase( i==136 ); /* UNBOUNDED */ |
| 160663 | testcase( i==137 ); /* VACUUM */ | 162806 | testcase( i==137 ); /* UNION */ |
| 160664 | testcase( i==138 ); /* VIEW */ | 162807 | testcase( i==138 ); /* USING */ |
| 160665 | testcase( i==139 ); /* WINDOW */ | 162808 | testcase( i==139 ); /* VACUUM */ |
| 160666 | testcase( i==140 ); /* DO */ | 162809 | testcase( i==140 ); /* VIEW */ |
| 160667 | testcase( i==141 ); /* BY */ | 162810 | testcase( i==141 ); /* WINDOW */ |
| 160668 | testcase( i==142 ); /* INITIALLY */ | 162811 | testcase( i==142 ); /* DO */ |
| 160669 | testcase( i==143 ); /* ALL */ | 162812 | testcase( i==143 ); /* BY */ |
| 160670 | testcase( i==144 ); /* PRIMARY */ | 162813 | testcase( i==144 ); /* INITIALLY */ |
| 162814 | testcase( i==145 ); /* ALL */ | ||
| 162815 | testcase( i==146 ); /* PRIMARY */ | ||
| 160671 | *pType = aKWCode[i]; | 162816 | *pType = aKWCode[i]; |
| 160672 | break; | 162817 | break; |
| 160673 | } | 162818 | } |
| @@ -160679,7 +162824,7 @@ SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){ | |||
| 160679 | keywordCode((char*)z, n, &id); | 162824 | keywordCode((char*)z, n, &id); |
| 160680 | return id; | 162825 | return id; |
| 160681 | } | 162826 | } |
| 160682 | #define SQLITE_N_KEYWORD 145 | 162827 | #define SQLITE_N_KEYWORD 147 |
| 160683 | SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){ | 162828 | SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){ |
| 160684 | if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR; | 162829 | if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR; |
| 160685 | *pzName = zKWText + aKWOffset[i]; | 162830 | *pzName = zKWText + aKWOffset[i]; |
| @@ -161048,7 +163193,7 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ | |||
| 161048 | if( n==0 ) *tokenType = TK_ILLEGAL; | 163193 | if( n==0 ) *tokenType = TK_ILLEGAL; |
| 161049 | return i; | 163194 | return i; |
| 161050 | } | 163195 | } |
| 161051 | case CC_KYWD: { | 163196 | case CC_KYWD0: { |
| 161052 | for(i=1; aiClass[z[i]]<=CC_KYWD; i++){} | 163197 | for(i=1; aiClass[z[i]]<=CC_KYWD; i++){} |
| 161053 | if( IdChar(z[i]) ){ | 163198 | if( IdChar(z[i]) ){ |
| 161054 | /* This token started out using characters that can appear in keywords, | 163199 | /* This token started out using characters that can appear in keywords, |
| @@ -161078,6 +163223,7 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ | |||
| 161078 | ** SQL keywords start with the letter 'x'. Fall through */ | 163223 | ** SQL keywords start with the letter 'x'. Fall through */ |
| 161079 | /* no break */ deliberate_fall_through | 163224 | /* no break */ deliberate_fall_through |
| 161080 | } | 163225 | } |
| 163226 | case CC_KYWD: | ||
| 161081 | case CC_ID: { | 163227 | case CC_ID: { |
| 161082 | i = 1; | 163228 | i = 1; |
| 161083 | break; | 163229 | break; |
| @@ -161260,19 +163406,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr | |||
| 161260 | if( !IN_RENAME_OBJECT ){ | 163406 | if( !IN_RENAME_OBJECT ){ |
| 161261 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); | 163407 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
| 161262 | } | 163408 | } |
| 161263 | |||
| 161264 | if( pParse->pWithToFree ) sqlite3WithDelete(db, pParse->pWithToFree); | ||
| 161265 | sqlite3DbFree(db, pParse->pVList); | 163409 | sqlite3DbFree(db, pParse->pVList); |
| 161266 | while( pParse->pAinc ){ | ||
| 161267 | AutoincInfo *p = pParse->pAinc; | ||
| 161268 | pParse->pAinc = p->pNext; | ||
| 161269 | sqlite3DbFreeNN(db, p); | ||
| 161270 | } | ||
| 161271 | while( pParse->pZombieTab ){ | ||
| 161272 | Table *p = pParse->pZombieTab; | ||
| 161273 | pParse->pZombieTab = p->pNextZombie; | ||
| 161274 | sqlite3DeleteTable(db, p); | ||
| 161275 | } | ||
| 161276 | db->pParse = pParse->pParentParse; | 163410 | db->pParse = pParse->pParentParse; |
| 161277 | pParse->pParentParse = 0; | 163411 | pParse->pParentParse = 0; |
| 161278 | assert( nErr==0 || pParse->rc!=SQLITE_OK ); | 163412 | assert( nErr==0 || pParse->rc!=SQLITE_OK ); |
| @@ -164179,7 +166313,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2( | |||
| 164179 | return SQLITE_OK; | 166313 | return SQLITE_OK; |
| 164180 | #else | 166314 | #else |
| 164181 | int rc; /* Return code */ | 166315 | int rc; /* Return code */ |
| 164182 | int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */ | 166316 | int iDb; /* Schema to checkpoint */ |
| 164183 | 166317 | ||
| 164184 | #ifdef SQLITE_ENABLE_API_ARMOR | 166318 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 164185 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; | 166319 | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; |
| @@ -164202,6 +166336,8 @@ SQLITE_API int sqlite3_wal_checkpoint_v2( | |||
| 164202 | sqlite3_mutex_enter(db->mutex); | 166336 | sqlite3_mutex_enter(db->mutex); |
| 164203 | if( zDb && zDb[0] ){ | 166337 | if( zDb && zDb[0] ){ |
| 164204 | iDb = sqlite3FindDbName(db, zDb); | 166338 | iDb = sqlite3FindDbName(db, zDb); |
| 166339 | }else{ | ||
| 166340 | iDb = SQLITE_MAX_DB; /* This means process all schemas */ | ||
| 164205 | } | 166341 | } |
| 164206 | if( iDb<0 ){ | 166342 | if( iDb<0 ){ |
| 164207 | rc = SQLITE_ERROR; | 166343 | rc = SQLITE_ERROR; |
| @@ -164250,7 +166386,7 @@ SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){ | |||
| 164250 | ** associated with the specific b-tree being checkpointed is taken by | 166386 | ** associated with the specific b-tree being checkpointed is taken by |
| 164251 | ** this function while the checkpoint is running. | 166387 | ** this function while the checkpoint is running. |
| 164252 | ** | 166388 | ** |
| 164253 | ** If iDb is passed SQLITE_MAX_ATTACHED, then all attached databases are | 166389 | ** If iDb is passed SQLITE_MAX_DB then all attached databases are |
| 164254 | ** checkpointed. If an error is encountered it is returned immediately - | 166390 | ** checkpointed. If an error is encountered it is returned immediately - |
| 164255 | ** no attempt is made to checkpoint any remaining databases. | 166391 | ** no attempt is made to checkpoint any remaining databases. |
| 164256 | ** | 166392 | ** |
| @@ -164265,9 +166401,11 @@ SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3 *db, int iDb, int eMode, int *pnLog | |||
| 164265 | assert( sqlite3_mutex_held(db->mutex) ); | 166401 | assert( sqlite3_mutex_held(db->mutex) ); |
| 164266 | assert( !pnLog || *pnLog==-1 ); | 166402 | assert( !pnLog || *pnLog==-1 ); |
| 164267 | assert( !pnCkpt || *pnCkpt==-1 ); | 166403 | assert( !pnCkpt || *pnCkpt==-1 ); |
| 166404 | testcase( iDb==SQLITE_MAX_ATTACHED ); /* See forum post a006d86f72 */ | ||
| 166405 | testcase( iDb==SQLITE_MAX_DB ); | ||
| 164268 | 166406 | ||
| 164269 | for(i=0; i<db->nDb && rc==SQLITE_OK; i++){ | 166407 | for(i=0; i<db->nDb && rc==SQLITE_OK; i++){ |
| 164270 | if( i==iDb || iDb==SQLITE_MAX_ATTACHED ){ | 166408 | if( i==iDb || iDb==SQLITE_MAX_DB ){ |
| 164271 | rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt); | 166409 | rc = sqlite3BtreeCheckpoint(db->aDb[i].pBt, eMode, pnLog, pnCkpt); |
| 164272 | pnLog = 0; | 166410 | pnLog = 0; |
| 164273 | pnCkpt = 0; | 166411 | pnCkpt = 0; |
| @@ -165885,7 +168023,7 @@ SQLITE_API int sqlite3_test_control(int op, ...){ | |||
| 165885 | */ | 168023 | */ |
| 165886 | case SQLITE_TESTCTRL_OPTIMIZATIONS: { | 168024 | case SQLITE_TESTCTRL_OPTIMIZATIONS: { |
| 165887 | sqlite3 *db = va_arg(ap, sqlite3*); | 168025 | sqlite3 *db = va_arg(ap, sqlite3*); |
| 165888 | db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff); | 168026 | db->dbOptFlags = va_arg(ap, u32); |
| 165889 | break; | 168027 | break; |
| 165890 | } | 168028 | } |
| 165891 | 168029 | ||
| @@ -166060,7 +168198,26 @@ SQLITE_API int sqlite3_test_control(int op, ...){ | |||
| 166060 | break; | 168198 | break; |
| 166061 | } | 168199 | } |
| 166062 | 168200 | ||
| 166063 | 168201 | /* sqlite3_test_control(SQLITE_TESTCTRL_TRACEFLAGS, op, ptr) | |
| 168202 | ** | ||
| 168203 | ** "ptr" is a pointer to a u32. | ||
| 168204 | ** | ||
| 168205 | ** op==0 Store the current sqlite3SelectTrace in *ptr | ||
| 168206 | ** op==1 Set sqlite3SelectTrace to the value *ptr | ||
| 168207 | ** op==3 Store the current sqlite3WhereTrace in *ptr | ||
| 168208 | ** op==3 Set sqlite3WhereTrace to the value *ptr | ||
| 168209 | */ | ||
| 168210 | case SQLITE_TESTCTRL_TRACEFLAGS: { | ||
| 168211 | int opTrace = va_arg(ap, int); | ||
| 168212 | u32 *ptr = va_arg(ap, u32*); | ||
| 168213 | switch( opTrace ){ | ||
| 168214 | case 0: *ptr = sqlite3SelectTrace; break; | ||
| 168215 | case 1: sqlite3SelectTrace = *ptr; break; | ||
| 168216 | case 2: *ptr = sqlite3WhereTrace; break; | ||
| 168217 | case 3: sqlite3WhereTrace = *ptr; break; | ||
| 168218 | } | ||
| 168219 | break; | ||
| 168220 | } | ||
| 166064 | } | 168221 | } |
| 166065 | va_end(ap); | 168222 | va_end(ap); |
| 166066 | #endif /* SQLITE_UNTESTABLE */ | 168223 | #endif /* SQLITE_UNTESTABLE */ |
| @@ -172945,9 +175102,9 @@ static int fts3EvalNearTrim( | |||
| 172945 | ); | 175102 | ); |
| 172946 | if( res ){ | 175103 | if( res ){ |
| 172947 | nNew = (int)(pOut - pPhrase->doclist.pList) - 1; | 175104 | nNew = (int)(pOut - pPhrase->doclist.pList) - 1; |
| 172948 | if( nNew>=0 ){ | 175105 | assert_fts3_nc( nNew<=pPhrase->doclist.nList && nNew>0 ); |
| 175106 | if( nNew>=0 && nNew<=pPhrase->doclist.nList ){ | ||
| 172949 | assert( pPhrase->doclist.pList[nNew]=='\0' ); | 175107 | assert( pPhrase->doclist.pList[nNew]=='\0' ); |
| 172950 | assert( nNew<=pPhrase->doclist.nList && nNew>0 ); | ||
| 172951 | memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew); | 175108 | memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew); |
| 172952 | pPhrase->doclist.nList = nNew; | 175109 | pPhrase->doclist.nList = nNew; |
| 172953 | } | 175110 | } |
| @@ -174881,6 +177038,11 @@ static int getNextNode( | |||
| 174881 | if( *zInput=='(' ){ | 177038 | if( *zInput=='(' ){ |
| 174882 | int nConsumed = 0; | 177039 | int nConsumed = 0; |
| 174883 | pParse->nNest++; | 177040 | pParse->nNest++; |
| 177041 | #if !defined(SQLITE_MAX_EXPR_DEPTH) | ||
| 177042 | if( pParse->nNest>1000 ) return SQLITE_ERROR; | ||
| 177043 | #elif SQLITE_MAX_EXPR_DEPTH>0 | ||
| 177044 | if( pParse->nNest>SQLITE_MAX_EXPR_DEPTH ) return SQLITE_ERROR; | ||
| 177045 | #endif | ||
| 174884 | rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed); | 177046 | rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed); |
| 174885 | *pnConsumed = (int)(zInput - z) + 1 + nConsumed; | 177047 | *pnConsumed = (int)(zInput - z) + 1 + nConsumed; |
| 174886 | return rc; | 177048 | return rc; |
| @@ -182284,17 +184446,20 @@ static int fts3IncrmergeLoad( | |||
| 182284 | while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader); | 184446 | while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader); |
| 182285 | blobGrowBuffer(&pNode->key, reader.term.n, &rc); | 184447 | blobGrowBuffer(&pNode->key, reader.term.n, &rc); |
| 182286 | if( rc==SQLITE_OK ){ | 184448 | if( rc==SQLITE_OK ){ |
| 182287 | memcpy(pNode->key.a, reader.term.a, reader.term.n); | 184449 | assert_fts3_nc( reader.term.n>0 || reader.aNode==0 ); |
| 184450 | if( reader.term.n>0 ){ | ||
| 184451 | memcpy(pNode->key.a, reader.term.a, reader.term.n); | ||
| 184452 | } | ||
| 182288 | pNode->key.n = reader.term.n; | 184453 | pNode->key.n = reader.term.n; |
| 182289 | if( i>0 ){ | 184454 | if( i>0 ){ |
| 182290 | char *aBlock = 0; | 184455 | char *aBlock = 0; |
| 182291 | int nBlock = 0; | 184456 | int nBlock = 0; |
| 182292 | pNode = &pWriter->aNodeWriter[i-1]; | 184457 | pNode = &pWriter->aNodeWriter[i-1]; |
| 182293 | pNode->iBlock = reader.iChild; | 184458 | pNode->iBlock = reader.iChild; |
| 182294 | rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0); | 184459 | rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock,0); |
| 182295 | blobGrowBuffer(&pNode->block, | 184460 | blobGrowBuffer(&pNode->block, |
| 182296 | MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc | 184461 | MAX(nBlock, p->nNodeSize)+FTS3_NODE_PADDING, &rc |
| 182297 | ); | 184462 | ); |
| 182298 | if( rc==SQLITE_OK ){ | 184463 | if( rc==SQLITE_OK ){ |
| 182299 | memcpy(pNode->block.a, aBlock, nBlock); | 184464 | memcpy(pNode->block.a, aBlock, nBlock); |
| 182300 | pNode->block.n = nBlock; | 184465 | pNode->block.n = nBlock; |
| @@ -185782,6 +187947,7 @@ static int unicodeOpen( | |||
| 185782 | pCsr->aInput = (const unsigned char *)aInput; | 187947 | pCsr->aInput = (const unsigned char *)aInput; |
| 185783 | if( aInput==0 ){ | 187948 | if( aInput==0 ){ |
| 185784 | pCsr->nInput = 0; | 187949 | pCsr->nInput = 0; |
| 187950 | pCsr->aInput = (const unsigned char*)""; | ||
| 185785 | }else if( nInput<0 ){ | 187951 | }else if( nInput<0 ){ |
| 185786 | pCsr->nInput = (int)strlen(aInput); | 187952 | pCsr->nInput = (int)strlen(aInput); |
| 185787 | }else{ | 187953 | }else{ |
| @@ -201537,22 +203703,24 @@ static int rbuVfsShmLock(sqlite3_file *pFile, int ofst, int n, int flags){ | |||
| 201537 | #endif | 203703 | #endif |
| 201538 | 203704 | ||
| 201539 | assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) ); | 203705 | assert( p->openFlags & (SQLITE_OPEN_MAIN_DB|SQLITE_OPEN_TEMP_DB) ); |
| 201540 | if( pRbu && (pRbu->eStage==RBU_STAGE_OAL || pRbu->eStage==RBU_STAGE_MOVE) ){ | 203706 | if( pRbu && ( |
| 201541 | /* Magic number 1 is the WAL_CKPT_LOCK lock. Preventing SQLite from | 203707 | pRbu->eStage==RBU_STAGE_OAL |
| 201542 | ** taking this lock also prevents any checkpoints from occurring. | 203708 | || pRbu->eStage==RBU_STAGE_MOVE |
| 201543 | ** todo: really, it's not clear why this might occur, as | 203709 | || pRbu->eStage==RBU_STAGE_DONE |
| 201544 | ** wal_autocheckpoint ought to be turned off. */ | 203710 | )){ |
| 203711 | /* Prevent SQLite from taking a shm-lock on the target file when it | ||
| 203712 | ** is supplying heap memory to the upper layer in place of *-shm | ||
| 203713 | ** segments. */ | ||
| 201545 | if( ofst==WAL_LOCK_CKPT && n==1 ) rc = SQLITE_BUSY; | 203714 | if( ofst==WAL_LOCK_CKPT && n==1 ) rc = SQLITE_BUSY; |
| 201546 | }else{ | 203715 | }else{ |
| 201547 | int bCapture = 0; | 203716 | int bCapture = 0; |
| 201548 | if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){ | 203717 | if( pRbu && pRbu->eStage==RBU_STAGE_CAPTURE ){ |
| 201549 | bCapture = 1; | 203718 | bCapture = 1; |
| 201550 | } | 203719 | } |
| 201551 | |||
| 201552 | if( bCapture==0 || 0==(flags & SQLITE_SHM_UNLOCK) ){ | 203720 | if( bCapture==0 || 0==(flags & SQLITE_SHM_UNLOCK) ){ |
| 201553 | rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags); | 203721 | rc = p->pReal->pMethods->xShmLock(p->pReal, ofst, n, flags); |
| 201554 | if( bCapture && rc==SQLITE_OK ){ | 203722 | if( bCapture && rc==SQLITE_OK ){ |
| 201555 | pRbu->mLock |= (1 << ofst); | 203723 | pRbu->mLock |= ((1<<n) - 1) << ofst; |
| 201556 | } | 203724 | } |
| 201557 | } | 203725 | } |
| 201558 | } | 203726 | } |
| @@ -203339,6 +205507,7 @@ struct sqlite3_session { | |||
| 203339 | int rc; /* Non-zero if an error has occurred */ | 205507 | int rc; /* Non-zero if an error has occurred */ |
| 203340 | void *pFilterCtx; /* First argument to pass to xTableFilter */ | 205508 | void *pFilterCtx; /* First argument to pass to xTableFilter */ |
| 203341 | int (*xTableFilter)(void *pCtx, const char *zTab); | 205509 | int (*xTableFilter)(void *pCtx, const char *zTab); |
| 205510 | i64 nMalloc; /* Number of bytes of data allocated */ | ||
| 203342 | sqlite3_value *pZeroBlob; /* Value containing X'' */ | 205511 | sqlite3_value *pZeroBlob; /* Value containing X'' */ |
| 203343 | sqlite3_session *pNext; /* Next session object on same db. */ | 205512 | sqlite3_session *pNext; /* Next session object on same db. */ |
| 203344 | SessionTable *pTable; /* List of attached tables */ | 205513 | SessionTable *pTable; /* List of attached tables */ |
| @@ -203381,6 +205550,7 @@ struct sqlite3_changeset_iter { | |||
| 203381 | SessionBuffer tblhdr; /* Buffer to hold apValue/zTab/abPK/ */ | 205550 | SessionBuffer tblhdr; /* Buffer to hold apValue/zTab/abPK/ */ |
| 203382 | int bPatchset; /* True if this is a patchset */ | 205551 | int bPatchset; /* True if this is a patchset */ |
| 203383 | int bInvert; /* True to invert changeset */ | 205552 | int bInvert; /* True to invert changeset */ |
| 205553 | int bSkipEmpty; /* Skip noop UPDATE changes */ | ||
| 203384 | int rc; /* Iterator error code */ | 205554 | int rc; /* Iterator error code */ |
| 203385 | sqlite3_stmt *pConflict; /* Points to conflicting row, if any */ | 205555 | sqlite3_stmt *pConflict; /* Points to conflicting row, if any */ |
| 203386 | char *zTab; /* Current table */ | 205556 | char *zTab; /* Current table */ |
| @@ -203722,6 +205892,26 @@ static int sessionSerializeValue( | |||
| 203722 | return SQLITE_OK; | 205892 | return SQLITE_OK; |
| 203723 | } | 205893 | } |
| 203724 | 205894 | ||
| 205895 | /* | ||
| 205896 | ** Allocate and return a pointer to a buffer nByte bytes in size. If | ||
| 205897 | ** pSession is not NULL, increase the sqlite3_session.nMalloc variable | ||
| 205898 | ** by the number of bytes allocated. | ||
| 205899 | */ | ||
| 205900 | static void *sessionMalloc64(sqlite3_session *pSession, i64 nByte){ | ||
| 205901 | void *pRet = sqlite3_malloc64(nByte); | ||
| 205902 | if( pSession ) pSession->nMalloc += sqlite3_msize(pRet); | ||
| 205903 | return pRet; | ||
| 205904 | } | ||
| 205905 | |||
| 205906 | /* | ||
| 205907 | ** Free buffer pFree, which must have been allocated by an earlier | ||
| 205908 | ** call to sessionMalloc64(). If pSession is not NULL, decrease the | ||
| 205909 | ** sqlite3_session.nMalloc counter by the number of bytes freed. | ||
| 205910 | */ | ||
| 205911 | static void sessionFree(sqlite3_session *pSession, void *pFree){ | ||
| 205912 | if( pSession ) pSession->nMalloc -= sqlite3_msize(pFree); | ||
| 205913 | sqlite3_free(pFree); | ||
| 205914 | } | ||
| 203725 | 205915 | ||
| 203726 | /* | 205916 | /* |
| 203727 | ** This macro is used to calculate hash key values for data structures. In | 205917 | ** This macro is used to calculate hash key values for data structures. In |
| @@ -204189,13 +206379,19 @@ static int sessionPreupdateEqual( | |||
| 204189 | ** Growing the hash table in this case is a performance optimization only, | 206379 | ** Growing the hash table in this case is a performance optimization only, |
| 204190 | ** it is not required for correct operation. | 206380 | ** it is not required for correct operation. |
| 204191 | */ | 206381 | */ |
| 204192 | static int sessionGrowHash(int bPatchset, SessionTable *pTab){ | 206382 | static int sessionGrowHash( |
| 206383 | sqlite3_session *pSession, /* For memory accounting. May be NULL */ | ||
| 206384 | int bPatchset, | ||
| 206385 | SessionTable *pTab | ||
| 206386 | ){ | ||
| 204193 | if( pTab->nChange==0 || pTab->nEntry>=(pTab->nChange/2) ){ | 206387 | if( pTab->nChange==0 || pTab->nEntry>=(pTab->nChange/2) ){ |
| 204194 | int i; | 206388 | int i; |
| 204195 | SessionChange **apNew; | 206389 | SessionChange **apNew; |
| 204196 | sqlite3_int64 nNew = 2*(sqlite3_int64)(pTab->nChange ? pTab->nChange : 128); | 206390 | sqlite3_int64 nNew = 2*(sqlite3_int64)(pTab->nChange ? pTab->nChange : 128); |
| 204197 | 206391 | ||
| 204198 | apNew = (SessionChange **)sqlite3_malloc64(sizeof(SessionChange *) * nNew); | 206392 | apNew = (SessionChange**)sessionMalloc64( |
| 206393 | pSession, sizeof(SessionChange*) * nNew | ||
| 206394 | ); | ||
| 204199 | if( apNew==0 ){ | 206395 | if( apNew==0 ){ |
| 204200 | if( pTab->nChange==0 ){ | 206396 | if( pTab->nChange==0 ){ |
| 204201 | return SQLITE_ERROR; | 206397 | return SQLITE_ERROR; |
| @@ -204216,7 +206412,7 @@ static int sessionGrowHash(int bPatchset, SessionTable *pTab){ | |||
| 204216 | } | 206412 | } |
| 204217 | } | 206413 | } |
| 204218 | 206414 | ||
| 204219 | sqlite3_free(pTab->apChange); | 206415 | sessionFree(pSession, pTab->apChange); |
| 204220 | pTab->nChange = nNew; | 206416 | pTab->nChange = nNew; |
| 204221 | pTab->apChange = apNew; | 206417 | pTab->apChange = apNew; |
| 204222 | } | 206418 | } |
| @@ -204250,6 +206446,7 @@ static int sessionGrowHash(int bPatchset, SessionTable *pTab){ | |||
| 204250 | ** be freed using sqlite3_free() by the caller | 206446 | ** be freed using sqlite3_free() by the caller |
| 204251 | */ | 206447 | */ |
| 204252 | static int sessionTableInfo( | 206448 | static int sessionTableInfo( |
| 206449 | sqlite3_session *pSession, /* For memory accounting. May be NULL */ | ||
| 204253 | sqlite3 *db, /* Database connection */ | 206450 | sqlite3 *db, /* Database connection */ |
| 204254 | const char *zDb, /* Name of attached database (e.g. "main") */ | 206451 | const char *zDb, /* Name of attached database (e.g. "main") */ |
| 204255 | const char *zThis, /* Table name */ | 206452 | const char *zThis, /* Table name */ |
| @@ -204304,7 +206501,7 @@ static int sessionTableInfo( | |||
| 204304 | 206501 | ||
| 204305 | if( rc==SQLITE_OK ){ | 206502 | if( rc==SQLITE_OK ){ |
| 204306 | nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); | 206503 | nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); |
| 204307 | pAlloc = sqlite3_malloc64(nByte); | 206504 | pAlloc = sessionMalloc64(pSession, nByte); |
| 204308 | if( pAlloc==0 ){ | 206505 | if( pAlloc==0 ){ |
| 204309 | rc = SQLITE_NOMEM; | 206506 | rc = SQLITE_NOMEM; |
| 204310 | } | 206507 | } |
| @@ -204347,7 +206544,7 @@ static int sessionTableInfo( | |||
| 204347 | *pabPK = 0; | 206544 | *pabPK = 0; |
| 204348 | *pnCol = 0; | 206545 | *pnCol = 0; |
| 204349 | if( pzTab ) *pzTab = 0; | 206546 | if( pzTab ) *pzTab = 0; |
| 204350 | sqlite3_free(azCol); | 206547 | sessionFree(pSession, azCol); |
| 204351 | } | 206548 | } |
| 204352 | sqlite3_finalize(pStmt); | 206549 | sqlite3_finalize(pStmt); |
| 204353 | return rc; | 206550 | return rc; |
| @@ -204369,7 +206566,7 @@ static int sessionInitTable(sqlite3_session *pSession, SessionTable *pTab){ | |||
| 204369 | if( pTab->nCol==0 ){ | 206566 | if( pTab->nCol==0 ){ |
| 204370 | u8 *abPK; | 206567 | u8 *abPK; |
| 204371 | assert( pTab->azCol==0 || pTab->abPK==0 ); | 206568 | assert( pTab->azCol==0 || pTab->abPK==0 ); |
| 204372 | pSession->rc = sessionTableInfo(pSession->db, pSession->zDb, | 206569 | pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb, |
| 204373 | pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK | 206570 | pTab->zName, &pTab->nCol, 0, &pTab->azCol, &abPK |
| 204374 | ); | 206571 | ); |
| 204375 | if( pSession->rc==SQLITE_OK ){ | 206572 | if( pSession->rc==SQLITE_OK ){ |
| @@ -204460,7 +206657,7 @@ static void sessionPreupdateOneChange( | |||
| 204460 | } | 206657 | } |
| 204461 | 206658 | ||
| 204462 | /* Grow the hash table if required */ | 206659 | /* Grow the hash table if required */ |
| 204463 | if( sessionGrowHash(0, pTab) ){ | 206660 | if( sessionGrowHash(pSession, 0, pTab) ){ |
| 204464 | pSession->rc = SQLITE_NOMEM; | 206661 | pSession->rc = SQLITE_NOMEM; |
| 204465 | return; | 206662 | return; |
| 204466 | } | 206663 | } |
| @@ -204527,7 +206724,7 @@ static void sessionPreupdateOneChange( | |||
| 204527 | } | 206724 | } |
| 204528 | 206725 | ||
| 204529 | /* Allocate the change object */ | 206726 | /* Allocate the change object */ |
| 204530 | pChange = (SessionChange *)sqlite3_malloc64(nByte); | 206727 | pChange = (SessionChange *)sessionMalloc64(pSession, nByte); |
| 204531 | if( !pChange ){ | 206728 | if( !pChange ){ |
| 204532 | rc = SQLITE_NOMEM; | 206729 | rc = SQLITE_NOMEM; |
| 204533 | goto error_out; | 206730 | goto error_out; |
| @@ -204900,7 +207097,7 @@ SQLITE_API int sqlite3session_diff( | |||
| 204900 | int nCol; /* Columns in zFrom.zTbl */ | 207097 | int nCol; /* Columns in zFrom.zTbl */ |
| 204901 | u8 *abPK; | 207098 | u8 *abPK; |
| 204902 | const char **azCol = 0; | 207099 | const char **azCol = 0; |
| 204903 | rc = sessionTableInfo(db, zFrom, zTbl, &nCol, 0, &azCol, &abPK); | 207100 | rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, &abPK); |
| 204904 | if( rc==SQLITE_OK ){ | 207101 | if( rc==SQLITE_OK ){ |
| 204905 | if( pTo->nCol!=nCol ){ | 207102 | if( pTo->nCol!=nCol ){ |
| 204906 | bMismatch = 1; | 207103 | bMismatch = 1; |
| @@ -204998,7 +207195,7 @@ SQLITE_API int sqlite3session_create( | |||
| 204998 | ** Free the list of table objects passed as the first argument. The contents | 207195 | ** Free the list of table objects passed as the first argument. The contents |
| 204999 | ** of the changed-rows hash tables are also deleted. | 207196 | ** of the changed-rows hash tables are also deleted. |
| 205000 | */ | 207197 | */ |
| 205001 | static void sessionDeleteTable(SessionTable *pList){ | 207198 | static void sessionDeleteTable(sqlite3_session *pSession, SessionTable *pList){ |
| 205002 | SessionTable *pNext; | 207199 | SessionTable *pNext; |
| 205003 | SessionTable *pTab; | 207200 | SessionTable *pTab; |
| 205004 | 207201 | ||
| @@ -205010,12 +207207,12 @@ static void sessionDeleteTable(SessionTable *pList){ | |||
| 205010 | SessionChange *pNextChange; | 207207 | SessionChange *pNextChange; |
| 205011 | for(p=pTab->apChange[i]; p; p=pNextChange){ | 207208 | for(p=pTab->apChange[i]; p; p=pNextChange){ |
| 205012 | pNextChange = p->pNext; | 207209 | pNextChange = p->pNext; |
| 205013 | sqlite3_free(p); | 207210 | sessionFree(pSession, p); |
| 205014 | } | 207211 | } |
| 205015 | } | 207212 | } |
| 205016 | sqlite3_free((char*)pTab->azCol); /* cast works around VC++ bug */ | 207213 | sessionFree(pSession, (char*)pTab->azCol); /* cast works around VC++ bug */ |
| 205017 | sqlite3_free(pTab->apChange); | 207214 | sessionFree(pSession, pTab->apChange); |
| 205018 | sqlite3_free(pTab); | 207215 | sessionFree(pSession, pTab); |
| 205019 | } | 207216 | } |
| 205020 | } | 207217 | } |
| 205021 | 207218 | ||
| @@ -205043,9 +207240,11 @@ SQLITE_API void sqlite3session_delete(sqlite3_session *pSession){ | |||
| 205043 | 207240 | ||
| 205044 | /* Delete all attached table objects. And the contents of their | 207241 | /* Delete all attached table objects. And the contents of their |
| 205045 | ** associated hash-tables. */ | 207242 | ** associated hash-tables. */ |
| 205046 | sessionDeleteTable(pSession->pTable); | 207243 | sessionDeleteTable(pSession, pSession->pTable); |
| 205047 | 207244 | ||
| 205048 | /* Free the session object itself. */ | 207245 | /* Assert that all allocations have been freed and then free the |
| 207246 | ** session object itself. */ | ||
| 207247 | assert( pSession->nMalloc==0 ); | ||
| 205049 | sqlite3_free(pSession); | 207248 | sqlite3_free(pSession); |
| 205050 | } | 207249 | } |
| 205051 | 207250 | ||
| @@ -205092,7 +207291,8 @@ SQLITE_API int sqlite3session_attach( | |||
| 205092 | 207291 | ||
| 205093 | if( !pTab ){ | 207292 | if( !pTab ){ |
| 205094 | /* Allocate new SessionTable object. */ | 207293 | /* Allocate new SessionTable object. */ |
| 205095 | pTab = (SessionTable *)sqlite3_malloc64(sizeof(SessionTable) + nName + 1); | 207294 | int nByte = sizeof(SessionTable) + nName + 1; |
| 207295 | pTab = (SessionTable*)sessionMalloc64(pSession, nByte); | ||
| 205096 | if( !pTab ){ | 207296 | if( !pTab ){ |
| 205097 | rc = SQLITE_NOMEM; | 207297 | rc = SQLITE_NOMEM; |
| 205098 | }else{ | 207298 | }else{ |
| @@ -205689,7 +207889,7 @@ static int sessionGenerateChangeset( | |||
| 205689 | int nNoop; /* Size of buffer after writing tbl header */ | 207889 | int nNoop; /* Size of buffer after writing tbl header */ |
| 205690 | 207890 | ||
| 205691 | /* Check the table schema is still Ok. */ | 207891 | /* Check the table schema is still Ok. */ |
| 205692 | rc = sessionTableInfo(db, pSession->zDb, zName, &nCol, 0, &azCol, &abPK); | 207892 | rc = sessionTableInfo(0, db, pSession->zDb, zName, &nCol, 0,&azCol,&abPK); |
| 205693 | if( !rc && (pTab->nCol!=nCol || memcmp(abPK, pTab->abPK, nCol)) ){ | 207893 | if( !rc && (pTab->nCol!=nCol || memcmp(abPK, pTab->abPK, nCol)) ){ |
| 205694 | rc = SQLITE_SCHEMA; | 207894 | rc = SQLITE_SCHEMA; |
| 205695 | } | 207895 | } |
| @@ -205865,6 +208065,13 @@ SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession){ | |||
| 205865 | } | 208065 | } |
| 205866 | 208066 | ||
| 205867 | /* | 208067 | /* |
| 208068 | ** Return the amount of heap memory in use. | ||
| 208069 | */ | ||
| 208070 | SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession){ | ||
| 208071 | return pSession->nMalloc; | ||
| 208072 | } | ||
| 208073 | |||
| 208074 | /* | ||
| 205868 | ** Do the work for either sqlite3changeset_start() or start_strm(). | 208075 | ** Do the work for either sqlite3changeset_start() or start_strm(). |
| 205869 | */ | 208076 | */ |
| 205870 | static int sessionChangesetStart( | 208077 | static int sessionChangesetStart( |
| @@ -205873,7 +208080,8 @@ static int sessionChangesetStart( | |||
| 205873 | void *pIn, | 208080 | void *pIn, |
| 205874 | int nChangeset, /* Size of buffer pChangeset in bytes */ | 208081 | int nChangeset, /* Size of buffer pChangeset in bytes */ |
| 205875 | void *pChangeset, /* Pointer to buffer containing changeset */ | 208082 | void *pChangeset, /* Pointer to buffer containing changeset */ |
| 205876 | int bInvert /* True to invert changeset */ | 208083 | int bInvert, /* True to invert changeset */ |
| 208084 | int bSkipEmpty /* True to skip empty UPDATE changes */ | ||
| 205877 | ){ | 208085 | ){ |
| 205878 | sqlite3_changeset_iter *pRet; /* Iterator to return */ | 208086 | sqlite3_changeset_iter *pRet; /* Iterator to return */ |
| 205879 | int nByte; /* Number of bytes to allocate for iterator */ | 208087 | int nByte; /* Number of bytes to allocate for iterator */ |
| @@ -205894,6 +208102,7 @@ static int sessionChangesetStart( | |||
| 205894 | pRet->in.pIn = pIn; | 208102 | pRet->in.pIn = pIn; |
| 205895 | pRet->in.bEof = (xInput ? 0 : 1); | 208103 | pRet->in.bEof = (xInput ? 0 : 1); |
| 205896 | pRet->bInvert = bInvert; | 208104 | pRet->bInvert = bInvert; |
| 208105 | pRet->bSkipEmpty = bSkipEmpty; | ||
| 205897 | 208106 | ||
| 205898 | /* Populate the output variable and return success. */ | 208107 | /* Populate the output variable and return success. */ |
| 205899 | *pp = pRet; | 208108 | *pp = pRet; |
| @@ -205908,7 +208117,7 @@ SQLITE_API int sqlite3changeset_start( | |||
| 205908 | int nChangeset, /* Size of buffer pChangeset in bytes */ | 208117 | int nChangeset, /* Size of buffer pChangeset in bytes */ |
| 205909 | void *pChangeset /* Pointer to buffer containing changeset */ | 208118 | void *pChangeset /* Pointer to buffer containing changeset */ |
| 205910 | ){ | 208119 | ){ |
| 205911 | return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, 0); | 208120 | return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, 0, 0); |
| 205912 | } | 208121 | } |
| 205913 | SQLITE_API int sqlite3changeset_start_v2( | 208122 | SQLITE_API int sqlite3changeset_start_v2( |
| 205914 | sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */ | 208123 | sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */ |
| @@ -205917,7 +208126,7 @@ SQLITE_API int sqlite3changeset_start_v2( | |||
| 205917 | int flags | 208126 | int flags |
| 205918 | ){ | 208127 | ){ |
| 205919 | int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT); | 208128 | int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT); |
| 205920 | return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, bInvert); | 208129 | return sessionChangesetStart(pp, 0, 0, nChangeset, pChangeset, bInvert, 0); |
| 205921 | } | 208130 | } |
| 205922 | 208131 | ||
| 205923 | /* | 208132 | /* |
| @@ -205928,7 +208137,7 @@ SQLITE_API int sqlite3changeset_start_strm( | |||
| 205928 | int (*xInput)(void *pIn, void *pData, int *pnData), | 208137 | int (*xInput)(void *pIn, void *pData, int *pnData), |
| 205929 | void *pIn | 208138 | void *pIn |
| 205930 | ){ | 208139 | ){ |
| 205931 | return sessionChangesetStart(pp, xInput, pIn, 0, 0, 0); | 208140 | return sessionChangesetStart(pp, xInput, pIn, 0, 0, 0, 0); |
| 205932 | } | 208141 | } |
| 205933 | SQLITE_API int sqlite3changeset_start_v2_strm( | 208142 | SQLITE_API int sqlite3changeset_start_v2_strm( |
| 205934 | sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */ | 208143 | sqlite3_changeset_iter **pp, /* OUT: Changeset iterator handle */ |
| @@ -205937,7 +208146,7 @@ SQLITE_API int sqlite3changeset_start_v2_strm( | |||
| 205937 | int flags | 208146 | int flags |
| 205938 | ){ | 208147 | ){ |
| 205939 | int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT); | 208148 | int bInvert = !!(flags & SQLITE_CHANGESETSTART_INVERT); |
| 205940 | return sessionChangesetStart(pp, xInput, pIn, 0, 0, bInvert); | 208149 | return sessionChangesetStart(pp, xInput, pIn, 0, 0, bInvert, 0); |
| 205941 | } | 208150 | } |
| 205942 | 208151 | ||
| 205943 | /* | 208152 | /* |
| @@ -206063,11 +208272,14 @@ static int sessionReadRecord( | |||
| 206063 | SessionInput *pIn, /* Input data */ | 208272 | SessionInput *pIn, /* Input data */ |
| 206064 | int nCol, /* Number of values in record */ | 208273 | int nCol, /* Number of values in record */ |
| 206065 | u8 *abPK, /* Array of primary key flags, or NULL */ | 208274 | u8 *abPK, /* Array of primary key flags, or NULL */ |
| 206066 | sqlite3_value **apOut /* Write values to this array */ | 208275 | sqlite3_value **apOut, /* Write values to this array */ |
| 208276 | int *pbEmpty | ||
| 206067 | ){ | 208277 | ){ |
| 206068 | int i; /* Used to iterate through columns */ | 208278 | int i; /* Used to iterate through columns */ |
| 206069 | int rc = SQLITE_OK; | 208279 | int rc = SQLITE_OK; |
| 206070 | 208280 | ||
| 208281 | assert( pbEmpty==0 || *pbEmpty==0 ); | ||
| 208282 | if( pbEmpty ) *pbEmpty = 1; | ||
| 206071 | for(i=0; i<nCol && rc==SQLITE_OK; i++){ | 208283 | for(i=0; i<nCol && rc==SQLITE_OK; i++){ |
| 206072 | int eType = 0; /* Type of value (SQLITE_NULL, TEXT etc.) */ | 208284 | int eType = 0; /* Type of value (SQLITE_NULL, TEXT etc.) */ |
| 206073 | if( abPK && abPK[i]==0 ) continue; | 208285 | if( abPK && abPK[i]==0 ) continue; |
| @@ -206079,6 +208291,7 @@ static int sessionReadRecord( | |||
| 206079 | eType = pIn->aData[pIn->iNext++]; | 208291 | eType = pIn->aData[pIn->iNext++]; |
| 206080 | assert( apOut[i]==0 ); | 208292 | assert( apOut[i]==0 ); |
| 206081 | if( eType ){ | 208293 | if( eType ){ |
| 208294 | if( pbEmpty ) *pbEmpty = 0; | ||
| 206082 | apOut[i] = sqlite3ValueNew(0); | 208295 | apOut[i] = sqlite3ValueNew(0); |
| 206083 | if( !apOut[i] ) rc = SQLITE_NOMEM; | 208296 | if( !apOut[i] ) rc = SQLITE_NOMEM; |
| 206084 | } | 208297 | } |
| @@ -206258,31 +208471,27 @@ static int sessionChangesetReadTblhdr(sqlite3_changeset_iter *p){ | |||
| 206258 | } | 208471 | } |
| 206259 | 208472 | ||
| 206260 | /* | 208473 | /* |
| 206261 | ** Advance the changeset iterator to the next change. | 208474 | ** Advance the changeset iterator to the next change. The differences between |
| 206262 | ** | 208475 | ** this function and sessionChangesetNext() are that |
| 206263 | ** If both paRec and pnRec are NULL, then this function works like the public | ||
| 206264 | ** API sqlite3changeset_next(). If SQLITE_ROW is returned, then the | ||
| 206265 | ** sqlite3changeset_new() and old() APIs may be used to query for values. | ||
| 206266 | ** | 208476 | ** |
| 206267 | ** Otherwise, if paRec and pnRec are not NULL, then a pointer to the change | 208477 | ** * If pbEmpty is not NULL and the change is a no-op UPDATE (an UPDATE |
| 206268 | ** record is written to *paRec before returning and the number of bytes in | 208478 | ** that modifies no columns), this function sets (*pbEmpty) to 1. |
| 206269 | ** the record to *pnRec. | ||
| 206270 | ** | 208479 | ** |
| 206271 | ** Either way, this function returns SQLITE_ROW if the iterator is | 208480 | ** * If the iterator is configured to skip no-op UPDATEs, |
| 206272 | ** successfully advanced to the next change in the changeset, an SQLite | 208481 | ** sessionChangesetNext() does that. This function does not. |
| 206273 | ** error code if an error occurs, or SQLITE_DONE if there are no further | ||
| 206274 | ** changes in the changeset. | ||
| 206275 | */ | 208482 | */ |
| 206276 | static int sessionChangesetNext( | 208483 | static int sessionChangesetNextOne( |
| 206277 | sqlite3_changeset_iter *p, /* Changeset iterator */ | 208484 | sqlite3_changeset_iter *p, /* Changeset iterator */ |
| 206278 | u8 **paRec, /* If non-NULL, store record pointer here */ | 208485 | u8 **paRec, /* If non-NULL, store record pointer here */ |
| 206279 | int *pnRec, /* If non-NULL, store size of record here */ | 208486 | int *pnRec, /* If non-NULL, store size of record here */ |
| 206280 | int *pbNew /* If non-NULL, true if new table */ | 208487 | int *pbNew, /* If non-NULL, true if new table */ |
| 208488 | int *pbEmpty | ||
| 206281 | ){ | 208489 | ){ |
| 206282 | int i; | 208490 | int i; |
| 206283 | u8 op; | 208491 | u8 op; |
| 206284 | 208492 | ||
| 206285 | assert( (paRec==0 && pnRec==0) || (paRec && pnRec) ); | 208493 | assert( (paRec==0 && pnRec==0) || (paRec && pnRec) ); |
| 208494 | assert( pbEmpty==0 || *pbEmpty==0 ); | ||
| 206286 | 208495 | ||
| 206287 | /* If the iterator is in the error-state, return immediately. */ | 208496 | /* If the iterator is in the error-state, return immediately. */ |
| 206288 | if( p->rc!=SQLITE_OK ) return p->rc; | 208497 | if( p->rc!=SQLITE_OK ) return p->rc; |
| @@ -206355,13 +208564,13 @@ static int sessionChangesetNext( | |||
| 206355 | /* If this is an UPDATE or DELETE, read the old.* record. */ | 208564 | /* If this is an UPDATE or DELETE, read the old.* record. */ |
| 206356 | if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){ | 208565 | if( p->op!=SQLITE_INSERT && (p->bPatchset==0 || p->op==SQLITE_DELETE) ){ |
| 206357 | u8 *abPK = p->bPatchset ? p->abPK : 0; | 208566 | u8 *abPK = p->bPatchset ? p->abPK : 0; |
| 206358 | p->rc = sessionReadRecord(&p->in, p->nCol, abPK, apOld); | 208567 | p->rc = sessionReadRecord(&p->in, p->nCol, abPK, apOld, 0); |
| 206359 | if( p->rc!=SQLITE_OK ) return p->rc; | 208568 | if( p->rc!=SQLITE_OK ) return p->rc; |
| 206360 | } | 208569 | } |
| 206361 | 208570 | ||
| 206362 | /* If this is an INSERT or UPDATE, read the new.* record. */ | 208571 | /* If this is an INSERT or UPDATE, read the new.* record. */ |
| 206363 | if( p->op!=SQLITE_DELETE ){ | 208572 | if( p->op!=SQLITE_DELETE ){ |
| 206364 | p->rc = sessionReadRecord(&p->in, p->nCol, 0, apNew); | 208573 | p->rc = sessionReadRecord(&p->in, p->nCol, 0, apNew, pbEmpty); |
| 206365 | if( p->rc!=SQLITE_OK ) return p->rc; | 208574 | if( p->rc!=SQLITE_OK ) return p->rc; |
| 206366 | } | 208575 | } |
| 206367 | 208576 | ||
| @@ -206389,6 +208598,37 @@ static int sessionChangesetNext( | |||
| 206389 | } | 208598 | } |
| 206390 | 208599 | ||
| 206391 | /* | 208600 | /* |
| 208601 | ** Advance the changeset iterator to the next change. | ||
| 208602 | ** | ||
| 208603 | ** If both paRec and pnRec are NULL, then this function works like the public | ||
| 208604 | ** API sqlite3changeset_next(). If SQLITE_ROW is returned, then the | ||
| 208605 | ** sqlite3changeset_new() and old() APIs may be used to query for values. | ||
| 208606 | ** | ||
| 208607 | ** Otherwise, if paRec and pnRec are not NULL, then a pointer to the change | ||
| 208608 | ** record is written to *paRec before returning and the number of bytes in | ||
| 208609 | ** the record to *pnRec. | ||
| 208610 | ** | ||
| 208611 | ** Either way, this function returns SQLITE_ROW if the iterator is | ||
| 208612 | ** successfully advanced to the next change in the changeset, an SQLite | ||
| 208613 | ** error code if an error occurs, or SQLITE_DONE if there are no further | ||
| 208614 | ** changes in the changeset. | ||
| 208615 | */ | ||
| 208616 | static int sessionChangesetNext( | ||
| 208617 | sqlite3_changeset_iter *p, /* Changeset iterator */ | ||
| 208618 | u8 **paRec, /* If non-NULL, store record pointer here */ | ||
| 208619 | int *pnRec, /* If non-NULL, store size of record here */ | ||
| 208620 | int *pbNew /* If non-NULL, true if new table */ | ||
| 208621 | ){ | ||
| 208622 | int bEmpty; | ||
| 208623 | int rc; | ||
| 208624 | do { | ||
| 208625 | bEmpty = 0; | ||
| 208626 | rc = sessionChangesetNextOne(p, paRec, pnRec, pbNew, &bEmpty); | ||
| 208627 | }while( rc==SQLITE_ROW && p->bSkipEmpty && bEmpty); | ||
| 208628 | return rc; | ||
| 208629 | } | ||
| 208630 | |||
| 208631 | /* | ||
| 206392 | ** Advance an iterator created by sqlite3changeset_start() to the next | 208632 | ** Advance an iterator created by sqlite3changeset_start() to the next |
| 206393 | ** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE | 208633 | ** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE |
| 206394 | ** or SQLITE_CORRUPT. | 208634 | ** or SQLITE_CORRUPT. |
| @@ -206660,9 +208900,9 @@ static int sessionChangesetInvert( | |||
| 206660 | 208900 | ||
| 206661 | /* Read the old.* and new.* records for the update change. */ | 208901 | /* Read the old.* and new.* records for the update change. */ |
| 206662 | pInput->iNext += 2; | 208902 | pInput->iNext += 2; |
| 206663 | rc = sessionReadRecord(pInput, nCol, 0, &apVal[0]); | 208903 | rc = sessionReadRecord(pInput, nCol, 0, &apVal[0], 0); |
| 206664 | if( rc==SQLITE_OK ){ | 208904 | if( rc==SQLITE_OK ){ |
| 206665 | rc = sessionReadRecord(pInput, nCol, 0, &apVal[nCol]); | 208905 | rc = sessionReadRecord(pInput, nCol, 0, &apVal[nCol], 0); |
| 206666 | } | 208906 | } |
| 206667 | 208907 | ||
| 206668 | /* Write the new old.* record. Consists of the PK columns from the | 208908 | /* Write the new old.* record. Consists of the PK columns from the |
| @@ -206763,16 +209003,25 @@ SQLITE_API int sqlite3changeset_invert_strm( | |||
| 206763 | return rc; | 209003 | return rc; |
| 206764 | } | 209004 | } |
| 206765 | 209005 | ||
| 209006 | |||
| 209007 | typedef struct SessionUpdate SessionUpdate; | ||
| 209008 | struct SessionUpdate { | ||
| 209009 | sqlite3_stmt *pStmt; | ||
| 209010 | u32 *aMask; | ||
| 209011 | SessionUpdate *pNext; | ||
| 209012 | }; | ||
| 209013 | |||
| 206766 | typedef struct SessionApplyCtx SessionApplyCtx; | 209014 | typedef struct SessionApplyCtx SessionApplyCtx; |
| 206767 | struct SessionApplyCtx { | 209015 | struct SessionApplyCtx { |
| 206768 | sqlite3 *db; | 209016 | sqlite3 *db; |
| 206769 | sqlite3_stmt *pDelete; /* DELETE statement */ | 209017 | sqlite3_stmt *pDelete; /* DELETE statement */ |
| 206770 | sqlite3_stmt *pUpdate; /* UPDATE statement */ | ||
| 206771 | sqlite3_stmt *pInsert; /* INSERT statement */ | 209018 | sqlite3_stmt *pInsert; /* INSERT statement */ |
| 206772 | sqlite3_stmt *pSelect; /* SELECT statement */ | 209019 | sqlite3_stmt *pSelect; /* SELECT statement */ |
| 206773 | int nCol; /* Size of azCol[] and abPK[] arrays */ | 209020 | int nCol; /* Size of azCol[] and abPK[] arrays */ |
| 206774 | const char **azCol; /* Array of column names */ | 209021 | const char **azCol; /* Array of column names */ |
| 206775 | u8 *abPK; /* Boolean array - true if column is in PK */ | 209022 | u8 *abPK; /* Boolean array - true if column is in PK */ |
| 209023 | u32 *aUpdateMask; /* Used by sessionUpdateFind */ | ||
| 209024 | SessionUpdate *pUp; | ||
| 206776 | int bStat1; /* True if table is sqlite_stat1 */ | 209025 | int bStat1; /* True if table is sqlite_stat1 */ |
| 206777 | int bDeferConstraints; /* True to defer constraints */ | 209026 | int bDeferConstraints; /* True to defer constraints */ |
| 206778 | int bInvertConstraints; /* Invert when iterating constraints buffer */ | 209027 | int bInvertConstraints; /* Invert when iterating constraints buffer */ |
| @@ -206782,6 +209031,167 @@ struct SessionApplyCtx { | |||
| 206782 | u8 bRebase; /* True to collect rebase information */ | 209031 | u8 bRebase; /* True to collect rebase information */ |
| 206783 | }; | 209032 | }; |
| 206784 | 209033 | ||
| 209034 | /* Number of prepared UPDATE statements to cache. */ | ||
| 209035 | #define SESSION_UPDATE_CACHE_SZ 12 | ||
| 209036 | |||
| 209037 | /* | ||
| 209038 | ** Find a prepared UPDATE statement suitable for the UPDATE step currently | ||
| 209039 | ** being visited by the iterator. The UPDATE is of the form: | ||
| 209040 | ** | ||
| 209041 | ** UPDATE tbl SET col = ?, col2 = ? WHERE pk1 IS ? AND pk2 IS ? | ||
| 209042 | */ | ||
| 209043 | static int sessionUpdateFind( | ||
| 209044 | sqlite3_changeset_iter *pIter, | ||
| 209045 | SessionApplyCtx *p, | ||
| 209046 | int bPatchset, | ||
| 209047 | sqlite3_stmt **ppStmt | ||
| 209048 | ){ | ||
| 209049 | int rc = SQLITE_OK; | ||
| 209050 | SessionUpdate *pUp = 0; | ||
| 209051 | int nCol = pIter->nCol; | ||
| 209052 | int nU32 = (pIter->nCol+33)/32; | ||
| 209053 | int ii; | ||
| 209054 | |||
| 209055 | if( p->aUpdateMask==0 ){ | ||
| 209056 | p->aUpdateMask = sqlite3_malloc(nU32*sizeof(u32)); | ||
| 209057 | if( p->aUpdateMask==0 ){ | ||
| 209058 | rc = SQLITE_NOMEM; | ||
| 209059 | } | ||
| 209060 | } | ||
| 209061 | |||
| 209062 | if( rc==SQLITE_OK ){ | ||
| 209063 | memset(p->aUpdateMask, 0, nU32*sizeof(u32)); | ||
| 209064 | rc = SQLITE_CORRUPT; | ||
| 209065 | for(ii=0; ii<pIter->nCol; ii++){ | ||
| 209066 | if( sessionChangesetNew(pIter, ii) ){ | ||
| 209067 | p->aUpdateMask[ii/32] |= (1<<(ii%32)); | ||
| 209068 | rc = SQLITE_OK; | ||
| 209069 | } | ||
| 209070 | } | ||
| 209071 | } | ||
| 209072 | |||
| 209073 | if( rc==SQLITE_OK ){ | ||
| 209074 | if( bPatchset ) p->aUpdateMask[nCol/32] |= (1<<(nCol%32)); | ||
| 209075 | |||
| 209076 | if( p->pUp ){ | ||
| 209077 | int nUp = 0; | ||
| 209078 | SessionUpdate **pp = &p->pUp; | ||
| 209079 | while( 1 ){ | ||
| 209080 | nUp++; | ||
| 209081 | if( 0==memcmp(p->aUpdateMask, (*pp)->aMask, nU32*sizeof(u32)) ){ | ||
| 209082 | pUp = *pp; | ||
| 209083 | *pp = pUp->pNext; | ||
| 209084 | pUp->pNext = p->pUp; | ||
| 209085 | p->pUp = pUp; | ||
| 209086 | break; | ||
| 209087 | } | ||
| 209088 | |||
| 209089 | if( (*pp)->pNext ){ | ||
| 209090 | pp = &(*pp)->pNext; | ||
| 209091 | }else{ | ||
| 209092 | if( nUp>=SESSION_UPDATE_CACHE_SZ ){ | ||
| 209093 | sqlite3_finalize((*pp)->pStmt); | ||
| 209094 | sqlite3_free(*pp); | ||
| 209095 | *pp = 0; | ||
| 209096 | } | ||
| 209097 | break; | ||
| 209098 | } | ||
| 209099 | } | ||
| 209100 | } | ||
| 209101 | |||
| 209102 | if( pUp==0 ){ | ||
| 209103 | int nByte = sizeof(SessionUpdate) * nU32*sizeof(u32); | ||
| 209104 | int bStat1 = (sqlite3_stricmp(pIter->zTab, "sqlite_stat1")==0); | ||
| 209105 | pUp = (SessionUpdate*)sqlite3_malloc(nByte); | ||
| 209106 | if( pUp==0 ){ | ||
| 209107 | rc = SQLITE_NOMEM; | ||
| 209108 | }else{ | ||
| 209109 | const char *zSep = ""; | ||
| 209110 | SessionBuffer buf; | ||
| 209111 | |||
| 209112 | memset(&buf, 0, sizeof(buf)); | ||
| 209113 | pUp->aMask = (u32*)&pUp[1]; | ||
| 209114 | memcpy(pUp->aMask, p->aUpdateMask, nU32*sizeof(u32)); | ||
| 209115 | |||
| 209116 | sessionAppendStr(&buf, "UPDATE main.", &rc); | ||
| 209117 | sessionAppendIdent(&buf, pIter->zTab, &rc); | ||
| 209118 | sessionAppendStr(&buf, " SET ", &rc); | ||
| 209119 | |||
| 209120 | /* Create the assignments part of the UPDATE */ | ||
| 209121 | for(ii=0; ii<pIter->nCol; ii++){ | ||
| 209122 | if( p->abPK[ii]==0 && sessionChangesetNew(pIter, ii) ){ | ||
| 209123 | sessionAppendStr(&buf, zSep, &rc); | ||
| 209124 | sessionAppendIdent(&buf, p->azCol[ii], &rc); | ||
| 209125 | sessionAppendStr(&buf, " = ?", &rc); | ||
| 209126 | sessionAppendInteger(&buf, ii*2+1, &rc); | ||
| 209127 | zSep = ", "; | ||
| 209128 | } | ||
| 209129 | } | ||
| 209130 | |||
| 209131 | /* Create the WHERE clause part of the UPDATE */ | ||
| 209132 | zSep = ""; | ||
| 209133 | sessionAppendStr(&buf, " WHERE ", &rc); | ||
| 209134 | for(ii=0; ii<pIter->nCol; ii++){ | ||
| 209135 | if( p->abPK[ii] || (bPatchset==0 && sessionChangesetOld(pIter, ii)) ){ | ||
| 209136 | sessionAppendStr(&buf, zSep, &rc); | ||
| 209137 | if( bStat1 && ii==1 ){ | ||
| 209138 | assert( sqlite3_stricmp(p->azCol[ii], "idx")==0 ); | ||
| 209139 | sessionAppendStr(&buf, | ||
| 209140 | "idx IS CASE " | ||
| 209141 | "WHEN length(?4)=0 AND typeof(?4)='blob' THEN NULL " | ||
| 209142 | "ELSE ?4 END ", &rc | ||
| 209143 | ); | ||
| 209144 | }else{ | ||
| 209145 | sessionAppendIdent(&buf, p->azCol[ii], &rc); | ||
| 209146 | sessionAppendStr(&buf, " IS ?", &rc); | ||
| 209147 | sessionAppendInteger(&buf, ii*2+2, &rc); | ||
| 209148 | } | ||
| 209149 | zSep = " AND "; | ||
| 209150 | } | ||
| 209151 | } | ||
| 209152 | |||
| 209153 | if( rc==SQLITE_OK ){ | ||
| 209154 | char *zSql = (char*)buf.aBuf; | ||
| 209155 | rc = sqlite3_prepare_v2(p->db, zSql, buf.nBuf, &pUp->pStmt, 0); | ||
| 209156 | } | ||
| 209157 | |||
| 209158 | if( rc!=SQLITE_OK ){ | ||
| 209159 | sqlite3_free(pUp); | ||
| 209160 | pUp = 0; | ||
| 209161 | }else{ | ||
| 209162 | pUp->pNext = p->pUp; | ||
| 209163 | p->pUp = pUp; | ||
| 209164 | } | ||
| 209165 | sqlite3_free(buf.aBuf); | ||
| 209166 | } | ||
| 209167 | } | ||
| 209168 | } | ||
| 209169 | |||
| 209170 | assert( (rc==SQLITE_OK)==(pUp!=0) ); | ||
| 209171 | if( pUp ){ | ||
| 209172 | *ppStmt = pUp->pStmt; | ||
| 209173 | }else{ | ||
| 209174 | *ppStmt = 0; | ||
| 209175 | } | ||
| 209176 | return rc; | ||
| 209177 | } | ||
| 209178 | |||
| 209179 | /* | ||
| 209180 | ** Free all cached UPDATE statements. | ||
| 209181 | */ | ||
| 209182 | static void sessionUpdateFree(SessionApplyCtx *p){ | ||
| 209183 | SessionUpdate *pUp; | ||
| 209184 | SessionUpdate *pNext; | ||
| 209185 | for(pUp=p->pUp; pUp; pUp=pNext){ | ||
| 209186 | pNext = pUp->pNext; | ||
| 209187 | sqlite3_finalize(pUp->pStmt); | ||
| 209188 | sqlite3_free(pUp); | ||
| 209189 | } | ||
| 209190 | p->pUp = 0; | ||
| 209191 | sqlite3_free(p->aUpdateMask); | ||
| 209192 | p->aUpdateMask = 0; | ||
| 209193 | } | ||
| 209194 | |||
| 206785 | /* | 209195 | /* |
| 206786 | ** Formulate a statement to DELETE a row from database db. Assuming a table | 209196 | ** Formulate a statement to DELETE a row from database db. Assuming a table |
| 206787 | ** structure like this: | 209197 | ** structure like this: |
| @@ -206852,103 +209262,6 @@ static int sessionDeleteRow( | |||
| 206852 | } | 209262 | } |
| 206853 | 209263 | ||
| 206854 | /* | 209264 | /* |
| 206855 | ** Formulate and prepare a statement to UPDATE a row from database db. | ||
| 206856 | ** Assuming a table structure like this: | ||
| 206857 | ** | ||
| 206858 | ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c)); | ||
| 206859 | ** | ||
| 206860 | ** The UPDATE statement looks like this: | ||
| 206861 | ** | ||
| 206862 | ** UPDATE x SET | ||
| 206863 | ** a = CASE WHEN ?2 THEN ?3 ELSE a END, | ||
| 206864 | ** b = CASE WHEN ?5 THEN ?6 ELSE b END, | ||
| 206865 | ** c = CASE WHEN ?8 THEN ?9 ELSE c END, | ||
| 206866 | ** d = CASE WHEN ?11 THEN ?12 ELSE d END | ||
| 206867 | ** WHERE a = ?1 AND c = ?7 AND (?13 OR | ||
| 206868 | ** (?5==0 OR b IS ?4) AND (?11==0 OR d IS ?10) AND | ||
| 206869 | ** ) | ||
| 206870 | ** | ||
| 206871 | ** For each column in the table, there are three variables to bind: | ||
| 206872 | ** | ||
| 206873 | ** ?(i*3+1) The old.* value of the column, if any. | ||
| 206874 | ** ?(i*3+2) A boolean flag indicating that the value is being modified. | ||
| 206875 | ** ?(i*3+3) The new.* value of the column, if any. | ||
| 206876 | ** | ||
| 206877 | ** Also, a boolean flag that, if set to true, causes the statement to update | ||
| 206878 | ** a row even if the non-PK values do not match. This is required if the | ||
| 206879 | ** conflict-handler is invoked with CHANGESET_DATA and returns | ||
| 206880 | ** CHANGESET_REPLACE. This is variable "?(nCol*3+1)". | ||
| 206881 | ** | ||
| 206882 | ** If successful, SQLITE_OK is returned and SessionApplyCtx.pUpdate is left | ||
| 206883 | ** pointing to the prepared version of the SQL statement. | ||
| 206884 | */ | ||
| 206885 | static int sessionUpdateRow( | ||
| 206886 | sqlite3 *db, /* Database handle */ | ||
| 206887 | const char *zTab, /* Table name */ | ||
| 206888 | SessionApplyCtx *p /* Session changeset-apply context */ | ||
| 206889 | ){ | ||
| 206890 | int rc = SQLITE_OK; | ||
| 206891 | int i; | ||
| 206892 | const char *zSep = ""; | ||
| 206893 | SessionBuffer buf = {0, 0, 0}; | ||
| 206894 | |||
| 206895 | /* Append "UPDATE tbl SET " */ | ||
| 206896 | sessionAppendStr(&buf, "UPDATE main.", &rc); | ||
| 206897 | sessionAppendIdent(&buf, zTab, &rc); | ||
| 206898 | sessionAppendStr(&buf, " SET ", &rc); | ||
| 206899 | |||
| 206900 | /* Append the assignments */ | ||
| 206901 | for(i=0; i<p->nCol; i++){ | ||
| 206902 | sessionAppendStr(&buf, zSep, &rc); | ||
| 206903 | sessionAppendIdent(&buf, p->azCol[i], &rc); | ||
| 206904 | sessionAppendStr(&buf, " = CASE WHEN ?", &rc); | ||
| 206905 | sessionAppendInteger(&buf, i*3+2, &rc); | ||
| 206906 | sessionAppendStr(&buf, " THEN ?", &rc); | ||
| 206907 | sessionAppendInteger(&buf, i*3+3, &rc); | ||
| 206908 | sessionAppendStr(&buf, " ELSE ", &rc); | ||
| 206909 | sessionAppendIdent(&buf, p->azCol[i], &rc); | ||
| 206910 | sessionAppendStr(&buf, " END", &rc); | ||
| 206911 | zSep = ", "; | ||
| 206912 | } | ||
| 206913 | |||
| 206914 | /* Append the PK part of the WHERE clause */ | ||
| 206915 | sessionAppendStr(&buf, " WHERE ", &rc); | ||
| 206916 | for(i=0; i<p->nCol; i++){ | ||
| 206917 | if( p->abPK[i] ){ | ||
| 206918 | sessionAppendIdent(&buf, p->azCol[i], &rc); | ||
| 206919 | sessionAppendStr(&buf, " = ?", &rc); | ||
| 206920 | sessionAppendInteger(&buf, i*3+1, &rc); | ||
| 206921 | sessionAppendStr(&buf, " AND ", &rc); | ||
| 206922 | } | ||
| 206923 | } | ||
| 206924 | |||
| 206925 | /* Append the non-PK part of the WHERE clause */ | ||
| 206926 | sessionAppendStr(&buf, " (?", &rc); | ||
| 206927 | sessionAppendInteger(&buf, p->nCol*3+1, &rc); | ||
| 206928 | sessionAppendStr(&buf, " OR 1", &rc); | ||
| 206929 | for(i=0; i<p->nCol; i++){ | ||
| 206930 | if( !p->abPK[i] ){ | ||
| 206931 | sessionAppendStr(&buf, " AND (?", &rc); | ||
| 206932 | sessionAppendInteger(&buf, i*3+2, &rc); | ||
| 206933 | sessionAppendStr(&buf, "=0 OR ", &rc); | ||
| 206934 | sessionAppendIdent(&buf, p->azCol[i], &rc); | ||
| 206935 | sessionAppendStr(&buf, " IS ?", &rc); | ||
| 206936 | sessionAppendInteger(&buf, i*3+1, &rc); | ||
| 206937 | sessionAppendStr(&buf, ")", &rc); | ||
| 206938 | } | ||
| 206939 | } | ||
| 206940 | sessionAppendStr(&buf, ")", &rc); | ||
| 206941 | |||
| 206942 | if( rc==SQLITE_OK ){ | ||
| 206943 | rc = sqlite3_prepare_v2(db, (char *)buf.aBuf, buf.nBuf, &p->pUpdate, 0); | ||
| 206944 | } | ||
| 206945 | sqlite3_free(buf.aBuf); | ||
| 206946 | |||
| 206947 | return rc; | ||
| 206948 | } | ||
| 206949 | |||
| 206950 | |||
| 206951 | /* | ||
| 206952 | ** Formulate and prepare an SQL statement to query table zTab by primary | 209265 | ** Formulate and prepare an SQL statement to query table zTab by primary |
| 206953 | ** key. Assuming the following table structure: | 209266 | ** key. Assuming the following table structure: |
| 206954 | ** | 209267 | ** |
| @@ -207029,17 +209342,6 @@ static int sessionStat1Sql(sqlite3 *db, SessionApplyCtx *p){ | |||
| 207029 | ); | 209342 | ); |
| 207030 | } | 209343 | } |
| 207031 | if( rc==SQLITE_OK ){ | 209344 | if( rc==SQLITE_OK ){ |
| 207032 | rc = sessionPrepare(db, &p->pUpdate, | ||
| 207033 | "UPDATE main.sqlite_stat1 SET " | ||
| 207034 | "tbl = CASE WHEN ?2 THEN ?3 ELSE tbl END, " | ||
| 207035 | "idx = CASE WHEN ?5 THEN ?6 ELSE idx END, " | ||
| 207036 | "stat = CASE WHEN ?8 THEN ?9 ELSE stat END " | ||
| 207037 | "WHERE tbl=?1 AND idx IS " | ||
| 207038 | "CASE WHEN length(?4)=0 AND typeof(?4)='blob' THEN NULL ELSE ?4 END " | ||
| 207039 | "AND (?10 OR ?8=0 OR stat IS ?7)" | ||
| 207040 | ); | ||
| 207041 | } | ||
| 207042 | if( rc==SQLITE_OK ){ | ||
| 207043 | rc = sessionPrepare(db, &p->pDelete, | 209345 | rc = sessionPrepare(db, &p->pDelete, |
| 207044 | "DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS " | 209346 | "DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS " |
| 207045 | "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END " | 209347 | "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END " |
| @@ -207355,7 +209657,7 @@ static int sessionApplyOneOp( | |||
| 207355 | int nCol; | 209657 | int nCol; |
| 207356 | int rc = SQLITE_OK; | 209658 | int rc = SQLITE_OK; |
| 207357 | 209659 | ||
| 207358 | assert( p->pDelete && p->pUpdate && p->pInsert && p->pSelect ); | 209660 | assert( p->pDelete && p->pInsert && p->pSelect ); |
| 207359 | assert( p->azCol && p->abPK ); | 209661 | assert( p->azCol && p->abPK ); |
| 207360 | assert( !pbReplace || *pbReplace==0 ); | 209662 | assert( !pbReplace || *pbReplace==0 ); |
| 207361 | 209663 | ||
| @@ -207395,29 +209697,28 @@ static int sessionApplyOneOp( | |||
| 207395 | 209697 | ||
| 207396 | }else if( op==SQLITE_UPDATE ){ | 209698 | }else if( op==SQLITE_UPDATE ){ |
| 207397 | int i; | 209699 | int i; |
| 209700 | sqlite3_stmt *pUp = 0; | ||
| 209701 | int bPatchset = (pbRetry==0 || pIter->bPatchset); | ||
| 209702 | |||
| 209703 | rc = sessionUpdateFind(pIter, p, bPatchset, &pUp); | ||
| 207398 | 209704 | ||
| 207399 | /* Bind values to the UPDATE statement. */ | 209705 | /* Bind values to the UPDATE statement. */ |
| 207400 | for(i=0; rc==SQLITE_OK && i<nCol; i++){ | 209706 | for(i=0; rc==SQLITE_OK && i<nCol; i++){ |
| 207401 | sqlite3_value *pOld = sessionChangesetOld(pIter, i); | 209707 | sqlite3_value *pOld = sessionChangesetOld(pIter, i); |
| 207402 | sqlite3_value *pNew = sessionChangesetNew(pIter, i); | 209708 | sqlite3_value *pNew = sessionChangesetNew(pIter, i); |
| 207403 | 209709 | if( p->abPK[i] || (bPatchset==0 && pOld) ){ | |
| 207404 | sqlite3_bind_int(p->pUpdate, i*3+2, !!pNew); | 209710 | rc = sessionBindValue(pUp, i*2+2, pOld); |
| 207405 | if( pOld ){ | ||
| 207406 | rc = sessionBindValue(p->pUpdate, i*3+1, pOld); | ||
| 207407 | } | 209711 | } |
| 207408 | if( rc==SQLITE_OK && pNew ){ | 209712 | if( rc==SQLITE_OK && pNew ){ |
| 207409 | rc = sessionBindValue(p->pUpdate, i*3+3, pNew); | 209713 | rc = sessionBindValue(pUp, i*2+1, pNew); |
| 207410 | } | 209714 | } |
| 207411 | } | 209715 | } |
| 207412 | if( rc==SQLITE_OK ){ | ||
| 207413 | sqlite3_bind_int(p->pUpdate, nCol*3+1, pbRetry==0 || pIter->bPatchset); | ||
| 207414 | } | ||
| 207415 | if( rc!=SQLITE_OK ) return rc; | 209716 | if( rc!=SQLITE_OK ) return rc; |
| 207416 | 209717 | ||
| 207417 | /* Attempt the UPDATE. In the case of a NOTFOUND or DATA conflict, | 209718 | /* Attempt the UPDATE. In the case of a NOTFOUND or DATA conflict, |
| 207418 | ** the result will be SQLITE_OK with 0 rows modified. */ | 209719 | ** the result will be SQLITE_OK with 0 rows modified. */ |
| 207419 | sqlite3_step(p->pUpdate); | 209720 | sqlite3_step(pUp); |
| 207420 | rc = sqlite3_reset(p->pUpdate); | 209721 | rc = sqlite3_reset(pUp); |
| 207421 | 209722 | ||
| 207422 | if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){ | 209723 | if( rc==SQLITE_OK && sqlite3_changes(p->db)==0 ){ |
| 207423 | /* A NOTFOUND or DATA error. Search the table to see if it contains | 209724 | /* A NOTFOUND or DATA error. Search the table to see if it contains |
| @@ -207549,7 +209850,7 @@ static int sessionRetryConstraints( | |||
| 207549 | memset(&pApply->constraints, 0, sizeof(SessionBuffer)); | 209850 | memset(&pApply->constraints, 0, sizeof(SessionBuffer)); |
| 207550 | 209851 | ||
| 207551 | rc = sessionChangesetStart( | 209852 | rc = sessionChangesetStart( |
| 207552 | &pIter2, 0, 0, cons.nBuf, cons.aBuf, pApply->bInvertConstraints | 209853 | &pIter2, 0, 0, cons.nBuf, cons.aBuf, pApply->bInvertConstraints, 1 |
| 207553 | ); | 209854 | ); |
| 207554 | if( rc==SQLITE_OK ){ | 209855 | if( rc==SQLITE_OK ){ |
| 207555 | size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*); | 209856 | size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*); |
| @@ -207640,14 +209941,13 @@ static int sessionChangesetApply( | |||
| 207640 | ); | 209941 | ); |
| 207641 | if( rc!=SQLITE_OK ) break; | 209942 | if( rc!=SQLITE_OK ) break; |
| 207642 | 209943 | ||
| 209944 | sessionUpdateFree(&sApply); | ||
| 207643 | sqlite3_free((char*)sApply.azCol); /* cast works around VC++ bug */ | 209945 | sqlite3_free((char*)sApply.azCol); /* cast works around VC++ bug */ |
| 207644 | sqlite3_finalize(sApply.pDelete); | 209946 | sqlite3_finalize(sApply.pDelete); |
| 207645 | sqlite3_finalize(sApply.pUpdate); | ||
| 207646 | sqlite3_finalize(sApply.pInsert); | 209947 | sqlite3_finalize(sApply.pInsert); |
| 207647 | sqlite3_finalize(sApply.pSelect); | 209948 | sqlite3_finalize(sApply.pSelect); |
| 207648 | sApply.db = db; | 209949 | sApply.db = db; |
| 207649 | sApply.pDelete = 0; | 209950 | sApply.pDelete = 0; |
| 207650 | sApply.pUpdate = 0; | ||
| 207651 | sApply.pInsert = 0; | 209951 | sApply.pInsert = 0; |
| 207652 | sApply.pSelect = 0; | 209952 | sApply.pSelect = 0; |
| 207653 | sApply.nCol = 0; | 209953 | sApply.nCol = 0; |
| @@ -207675,7 +209975,7 @@ static int sessionChangesetApply( | |||
| 207675 | int i; | 209975 | int i; |
| 207676 | 209976 | ||
| 207677 | sqlite3changeset_pk(pIter, &abPK, 0); | 209977 | sqlite3changeset_pk(pIter, &abPK, 0); |
| 207678 | rc = sessionTableInfo( | 209978 | rc = sessionTableInfo(0, |
| 207679 | db, "main", zNew, &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK | 209979 | db, "main", zNew, &sApply.nCol, &zTab, &sApply.azCol, &sApply.abPK |
| 207680 | ); | 209980 | ); |
| 207681 | if( rc!=SQLITE_OK ) break; | 209981 | if( rc!=SQLITE_OK ) break; |
| @@ -207711,11 +210011,10 @@ static int sessionChangesetApply( | |||
| 207711 | } | 210011 | } |
| 207712 | sApply.bStat1 = 1; | 210012 | sApply.bStat1 = 1; |
| 207713 | }else{ | 210013 | }else{ |
| 207714 | if((rc = sessionSelectRow(db, zTab, &sApply)) | 210014 | if( (rc = sessionSelectRow(db, zTab, &sApply)) |
| 207715 | || (rc = sessionUpdateRow(db, zTab, &sApply)) | 210015 | || (rc = sessionDeleteRow(db, zTab, &sApply)) |
| 207716 | || (rc = sessionDeleteRow(db, zTab, &sApply)) | 210016 | || (rc = sessionInsertRow(db, zTab, &sApply)) |
| 207717 | || (rc = sessionInsertRow(db, zTab, &sApply)) | 210017 | ){ |
| 207718 | ){ | ||
| 207719 | break; | 210018 | break; |
| 207720 | } | 210019 | } |
| 207721 | sApply.bStat1 = 0; | 210020 | sApply.bStat1 = 0; |
| @@ -207774,9 +210073,9 @@ static int sessionChangesetApply( | |||
| 207774 | *pnRebase = sApply.rebase.nBuf; | 210073 | *pnRebase = sApply.rebase.nBuf; |
| 207775 | sApply.rebase.aBuf = 0; | 210074 | sApply.rebase.aBuf = 0; |
| 207776 | } | 210075 | } |
| 210076 | sessionUpdateFree(&sApply); | ||
| 207777 | sqlite3_finalize(sApply.pInsert); | 210077 | sqlite3_finalize(sApply.pInsert); |
| 207778 | sqlite3_finalize(sApply.pDelete); | 210078 | sqlite3_finalize(sApply.pDelete); |
| 207779 | sqlite3_finalize(sApply.pUpdate); | ||
| 207780 | sqlite3_finalize(sApply.pSelect); | 210079 | sqlite3_finalize(sApply.pSelect); |
| 207781 | sqlite3_free((char*)sApply.azCol); /* cast works around VC++ bug */ | 210080 | sqlite3_free((char*)sApply.azCol); /* cast works around VC++ bug */ |
| 207782 | sqlite3_free((char*)sApply.constraints.aBuf); | 210081 | sqlite3_free((char*)sApply.constraints.aBuf); |
| @@ -207807,8 +210106,8 @@ SQLITE_API int sqlite3changeset_apply_v2( | |||
| 207807 | int flags | 210106 | int flags |
| 207808 | ){ | 210107 | ){ |
| 207809 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ | 210108 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ |
| 207810 | int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); | 210109 | int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); |
| 207811 | int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset,bInverse); | 210110 | int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1); |
| 207812 | if( rc==SQLITE_OK ){ | 210111 | if( rc==SQLITE_OK ){ |
| 207813 | rc = sessionChangesetApply( | 210112 | rc = sessionChangesetApply( |
| 207814 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags | 210113 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags |
| @@ -207866,7 +210165,7 @@ SQLITE_API int sqlite3changeset_apply_v2_strm( | |||
| 207866 | ){ | 210165 | ){ |
| 207867 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ | 210166 | sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ |
| 207868 | int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); | 210167 | int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT); |
| 207869 | int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse); | 210168 | int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse, 1); |
| 207870 | if( rc==SQLITE_OK ){ | 210169 | if( rc==SQLITE_OK ){ |
| 207871 | rc = sessionChangesetApply( | 210170 | rc = sessionChangesetApply( |
| 207872 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags | 210171 | db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags |
| @@ -208154,7 +210453,7 @@ static int sessionChangesetToHash( | |||
| 208154 | } | 210453 | } |
| 208155 | } | 210454 | } |
| 208156 | 210455 | ||
| 208157 | if( sessionGrowHash(pIter->bPatchset, pTab) ){ | 210456 | if( sessionGrowHash(0, pIter->bPatchset, pTab) ){ |
| 208158 | rc = SQLITE_NOMEM; | 210457 | rc = SQLITE_NOMEM; |
| 208159 | break; | 210458 | break; |
| 208160 | } | 210459 | } |
| @@ -208340,7 +210639,7 @@ SQLITE_API int sqlite3changegroup_output_strm( | |||
| 208340 | */ | 210639 | */ |
| 208341 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ | 210640 | SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup *pGrp){ |
| 208342 | if( pGrp ){ | 210641 | if( pGrp ){ |
| 208343 | sessionDeleteTable(pGrp->pList); | 210642 | sessionDeleteTable(0, pGrp->pList); |
| 208344 | sqlite3_free(pGrp); | 210643 | sqlite3_free(pGrp); |
| 208345 | } | 210644 | } |
| 208346 | } | 210645 | } |
| @@ -208486,7 +210785,7 @@ static void sessionAppendPartialUpdate( | |||
| 208486 | int n1 = sessionSerialLen(a1); | 210785 | int n1 = sessionSerialLen(a1); |
| 208487 | int n2 = sessionSerialLen(a2); | 210786 | int n2 = sessionSerialLen(a2); |
| 208488 | if( pIter->abPK[i] || a2[0]==0 ){ | 210787 | if( pIter->abPK[i] || a2[0]==0 ){ |
| 208489 | if( !pIter->abPK[i] ) bData = 1; | 210788 | if( !pIter->abPK[i] && a1[0] ) bData = 1; |
| 208490 | memcpy(pOut, a1, n1); | 210789 | memcpy(pOut, a1, n1); |
| 208491 | pOut += n1; | 210790 | pOut += n1; |
| 208492 | }else if( a2[0]!=0xFF ){ | 210791 | }else if( a2[0]!=0xFF ){ |
| @@ -208741,7 +211040,7 @@ SQLITE_API int sqlite3rebaser_rebase_strm( | |||
| 208741 | */ | 211040 | */ |
| 208742 | SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p){ | 211041 | SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p){ |
| 208743 | if( p ){ | 211042 | if( p ){ |
| 208744 | sessionDeleteTable(p->grp.pList); | 211043 | sessionDeleteTable(0, p->grp.pList); |
| 208745 | sqlite3_free(p); | 211044 | sqlite3_free(p); |
| 208746 | } | 211045 | } |
| 208747 | } | 211046 | } |
| @@ -211203,55 +213502,6 @@ static fts5YYACTIONTYPE fts5yy_reduce( | |||
| 211203 | (void)fts5yyLookahead; | 213502 | (void)fts5yyLookahead; |
| 211204 | (void)fts5yyLookaheadToken; | 213503 | (void)fts5yyLookaheadToken; |
| 211205 | fts5yymsp = fts5yypParser->fts5yytos; | 213504 | fts5yymsp = fts5yypParser->fts5yytos; |
| 211206 | assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); | ||
| 211207 | #ifndef NDEBUG | ||
| 211208 | if( fts5yyTraceFILE ){ | ||
| 211209 | fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; | ||
| 211210 | if( fts5yysize ){ | ||
| 211211 | fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", | ||
| 211212 | fts5yyTracePrompt, | ||
| 211213 | fts5yyruleno, fts5yyRuleName[fts5yyruleno], | ||
| 211214 | fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action", | ||
| 211215 | fts5yymsp[fts5yysize].stateno); | ||
| 211216 | }else{ | ||
| 211217 | fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s.\n", | ||
| 211218 | fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno], | ||
| 211219 | fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action"); | ||
| 211220 | } | ||
| 211221 | } | ||
| 211222 | #endif /* NDEBUG */ | ||
| 211223 | |||
| 211224 | /* Check that the stack is large enough to grow by a single entry | ||
| 211225 | ** if the RHS of the rule is empty. This ensures that there is room | ||
| 211226 | ** enough on the stack to push the LHS value */ | ||
| 211227 | if( fts5yyRuleInfoNRhs[fts5yyruleno]==0 ){ | ||
| 211228 | #ifdef fts5YYTRACKMAXSTACKDEPTH | ||
| 211229 | if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){ | ||
| 211230 | fts5yypParser->fts5yyhwm++; | ||
| 211231 | assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)); | ||
| 211232 | } | ||
| 211233 | #endif | ||
| 211234 | #if fts5YYSTACKDEPTH>0 | ||
| 211235 | if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){ | ||
| 211236 | fts5yyStackOverflow(fts5yypParser); | ||
| 211237 | /* The call to fts5yyStackOverflow() above pops the stack until it is | ||
| 211238 | ** empty, causing the main parser loop to exit. So the return value | ||
| 211239 | ** is never used and does not matter. */ | ||
| 211240 | return 0; | ||
| 211241 | } | ||
| 211242 | #else | ||
| 211243 | if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){ | ||
| 211244 | if( fts5yyGrowStack(fts5yypParser) ){ | ||
| 211245 | fts5yyStackOverflow(fts5yypParser); | ||
| 211246 | /* The call to fts5yyStackOverflow() above pops the stack until it is | ||
| 211247 | ** empty, causing the main parser loop to exit. So the return value | ||
| 211248 | ** is never used and does not matter. */ | ||
| 211249 | return 0; | ||
| 211250 | } | ||
| 211251 | fts5yymsp = fts5yypParser->fts5yytos; | ||
| 211252 | } | ||
| 211253 | #endif | ||
| 211254 | } | ||
| 211255 | 213505 | ||
| 211256 | switch( fts5yyruleno ){ | 213506 | switch( fts5yyruleno ){ |
| 211257 | /* Beginning here are the reduction cases. A typical example | 213507 | /* Beginning here are the reduction cases. A typical example |
| @@ -211554,12 +213804,56 @@ static void sqlite3Fts5Parser( | |||
| 211554 | } | 213804 | } |
| 211555 | #endif | 213805 | #endif |
| 211556 | 213806 | ||
| 211557 | do{ | 213807 | while(1){ /* Exit by "break" */ |
| 213808 | assert( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystack ); | ||
| 211558 | assert( fts5yyact==fts5yypParser->fts5yytos->stateno ); | 213809 | assert( fts5yyact==fts5yypParser->fts5yytos->stateno ); |
| 211559 | fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact); | 213810 | fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact); |
| 211560 | if( fts5yyact >= fts5YY_MIN_REDUCE ){ | 213811 | if( fts5yyact >= fts5YY_MIN_REDUCE ){ |
| 211561 | fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor, | 213812 | unsigned int fts5yyruleno = fts5yyact - fts5YY_MIN_REDUCE; /* Reduce by this rule */ |
| 211562 | fts5yyminor sqlite3Fts5ParserCTX_PARAM); | 213813 | assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); |
| 213814 | #ifndef NDEBUG | ||
| 213815 | if( fts5yyTraceFILE ){ | ||
| 213816 | int fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; | ||
| 213817 | if( fts5yysize ){ | ||
| 213818 | fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", | ||
| 213819 | fts5yyTracePrompt, | ||
| 213820 | fts5yyruleno, fts5yyRuleName[fts5yyruleno], | ||
| 213821 | fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action", | ||
| 213822 | fts5yypParser->fts5yytos[fts5yysize].stateno); | ||
| 213823 | }else{ | ||
| 213824 | fprintf(fts5yyTraceFILE, "%sReduce %d [%s]%s.\n", | ||
| 213825 | fts5yyTracePrompt, fts5yyruleno, fts5yyRuleName[fts5yyruleno], | ||
| 213826 | fts5yyruleno<fts5YYNRULE_WITH_ACTION ? "" : " without external action"); | ||
| 213827 | } | ||
| 213828 | } | ||
| 213829 | #endif /* NDEBUG */ | ||
| 213830 | |||
| 213831 | /* Check that the stack is large enough to grow by a single entry | ||
| 213832 | ** if the RHS of the rule is empty. This ensures that there is room | ||
| 213833 | ** enough on the stack to push the LHS value */ | ||
| 213834 | if( fts5yyRuleInfoNRhs[fts5yyruleno]==0 ){ | ||
| 213835 | #ifdef fts5YYTRACKMAXSTACKDEPTH | ||
| 213836 | if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){ | ||
| 213837 | fts5yypParser->fts5yyhwm++; | ||
| 213838 | assert( fts5yypParser->fts5yyhwm == | ||
| 213839 | (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)); | ||
| 213840 | } | ||
| 213841 | #endif | ||
| 213842 | #if fts5YYSTACKDEPTH>0 | ||
| 213843 | if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){ | ||
| 213844 | fts5yyStackOverflow(fts5yypParser); | ||
| 213845 | break; | ||
| 213846 | } | ||
| 213847 | #else | ||
| 213848 | if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){ | ||
| 213849 | if( fts5yyGrowStack(fts5yypParser) ){ | ||
| 213850 | fts5yyStackOverflow(fts5yypParser); | ||
| 213851 | break; | ||
| 213852 | } | ||
| 213853 | } | ||
| 213854 | #endif | ||
| 213855 | } | ||
| 213856 | fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyruleno,fts5yymajor,fts5yyminor sqlite3Fts5ParserCTX_PARAM); | ||
| 211563 | }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){ | 213857 | }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){ |
| 211564 | fts5yy_shift(fts5yypParser,fts5yyact,(fts5YYCODETYPE)fts5yymajor,fts5yyminor); | 213858 | fts5yy_shift(fts5yypParser,fts5yyact,(fts5YYCODETYPE)fts5yymajor,fts5yyminor); |
| 211565 | #ifndef fts5YYNOERRORRECOVERY | 213859 | #ifndef fts5YYNOERRORRECOVERY |
| @@ -211672,7 +213966,7 @@ static void sqlite3Fts5Parser( | |||
| 211672 | break; | 213966 | break; |
| 211673 | #endif | 213967 | #endif |
| 211674 | } | 213968 | } |
| 211675 | }while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ); | 213969 | } |
| 211676 | #ifndef NDEBUG | 213970 | #ifndef NDEBUG |
| 211677 | if( fts5yyTraceFILE ){ | 213971 | if( fts5yyTraceFILE ){ |
| 211678 | fts5yyStackEntry *i; | 213972 | fts5yyStackEntry *i; |
| @@ -215284,8 +217578,8 @@ static int sqlite3Fts5ExprFirst(Fts5Expr *p, Fts5Index *pIdx, i64 iFirst, int bD | |||
| 215284 | } | 217578 | } |
| 215285 | 217579 | ||
| 215286 | /* If the iterator is not at a real match, skip forward until it is. */ | 217580 | /* If the iterator is not at a real match, skip forward until it is. */ |
| 215287 | while( pRoot->bNomatch ){ | 217581 | while( pRoot->bNomatch && rc==SQLITE_OK ){ |
| 215288 | assert( pRoot->bEof==0 && rc==SQLITE_OK ); | 217582 | assert( pRoot->bEof==0 ); |
| 215289 | rc = fts5ExprNodeNext(p, pRoot, 0, 0); | 217583 | rc = fts5ExprNodeNext(p, pRoot, 0, 0); |
| 215290 | } | 217584 | } |
| 215291 | return rc; | 217585 | return rc; |
| @@ -219470,14 +221764,10 @@ static void fts5SegIterNext( | |||
| 219470 | }else{ | 221764 | }else{ |
| 219471 | /* The following could be done by calling fts5SegIterLoadNPos(). But | 221765 | /* The following could be done by calling fts5SegIterLoadNPos(). But |
| 219472 | ** this block is particularly performance critical, so equivalent | 221766 | ** this block is particularly performance critical, so equivalent |
| 219473 | ** code is inlined. | 221767 | ** code is inlined. */ |
| 219474 | ** | ||
| 219475 | ** Later: Switched back to fts5SegIterLoadNPos() because it supports | ||
| 219476 | ** detail=none mode. Not ideal. | ||
| 219477 | */ | ||
| 219478 | int nSz; | 221768 | int nSz; |
| 219479 | assert( p->rc==SQLITE_OK ); | 221769 | assert( p->rc==SQLITE_OK ); |
| 219480 | assert( pIter->iLeafOffset<=pIter->pLeaf->nn ); | 221770 | assert_nc( pIter->iLeafOffset<=pIter->pLeaf->nn ); |
| 219481 | fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); | 221771 | fts5FastGetVarint32(pIter->pLeaf->p, pIter->iLeafOffset, nSz); |
| 219482 | pIter->bDel = (nSz & 0x0001); | 221772 | pIter->bDel = (nSz & 0x0001); |
| 219483 | pIter->nPos = nSz>>1; | 221773 | pIter->nPos = nSz>>1; |
| @@ -220469,7 +222759,7 @@ static void fts5ChunkIterate( | |||
| 220469 | int pgno = pSeg->iLeafPgno; | 222759 | int pgno = pSeg->iLeafPgno; |
| 220470 | int pgnoSave = 0; | 222760 | int pgnoSave = 0; |
| 220471 | 222761 | ||
| 220472 | /* This function does notmwork with detail=none databases. */ | 222762 | /* This function does not work with detail=none databases. */ |
| 220473 | assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE ); | 222763 | assert( p->pConfig->eDetail!=FTS5_DETAIL_NONE ); |
| 220474 | 222764 | ||
| 220475 | if( (pSeg->flags & FTS5_SEGITER_REVERSE)==0 ){ | 222765 | if( (pSeg->flags & FTS5_SEGITER_REVERSE)==0 ){ |
| @@ -220482,6 +222772,9 @@ static void fts5ChunkIterate( | |||
| 220482 | fts5DataRelease(pData); | 222772 | fts5DataRelease(pData); |
| 220483 | if( nRem<=0 ){ | 222773 | if( nRem<=0 ){ |
| 220484 | break; | 222774 | break; |
| 222775 | }else if( pSeg->pSeg==0 ){ | ||
| 222776 | p->rc = FTS5_CORRUPT; | ||
| 222777 | return; | ||
| 220485 | }else{ | 222778 | }else{ |
| 220486 | pgno++; | 222779 | pgno++; |
| 220487 | pData = fts5LeafRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno)); | 222780 | pData = fts5LeafRead(p, FTS5_SEGMENT_ROWID(pSeg->pSeg->iSegid, pgno)); |
| @@ -220533,66 +222826,72 @@ static void fts5SegiterPoslist( | |||
| 220533 | } | 222826 | } |
| 220534 | 222827 | ||
| 220535 | /* | 222828 | /* |
| 220536 | ** IN/OUT parameter (*pa) points to a position list n bytes in size. If | 222829 | ** Parameter pPos points to a buffer containing a position list, size nPos. |
| 220537 | ** the position list contains entries for column iCol, then (*pa) is set | 222830 | ** This function filters it according to pColset (which must be non-NULL) |
| 220538 | ** to point to the sub-position-list for that column and the number of | 222831 | ** and sets pIter->base.pData/nData to point to the new position list. |
| 220539 | ** bytes in it returned. Or, if the argument position list does not | 222832 | ** If memory is required for the new position list, use buffer pIter->poslist. |
| 220540 | ** contain any entries for column iCol, return 0. | 222833 | ** Or, if the new position list is a contiguous subset of the input, set |
| 222834 | ** pIter->base.pData/nData to point directly to it. | ||
| 222835 | ** | ||
| 222836 | ** This function is a no-op if *pRc is other than SQLITE_OK when it is | ||
| 222837 | ** called. If an OOM error is encountered, *pRc is set to SQLITE_NOMEM | ||
| 222838 | ** before returning. | ||
| 220541 | */ | 222839 | */ |
| 220542 | static int fts5IndexExtractCol( | ||
| 220543 | const u8 **pa, /* IN/OUT: Pointer to poslist */ | ||
| 220544 | int n, /* IN: Size of poslist in bytes */ | ||
| 220545 | int iCol /* Column to extract from poslist */ | ||
| 220546 | ){ | ||
| 220547 | int iCurrent = 0; /* Anything before the first 0x01 is col 0 */ | ||
| 220548 | const u8 *p = *pa; | ||
| 220549 | const u8 *pEnd = &p[n]; /* One byte past end of position list */ | ||
| 220550 | |||
| 220551 | while( iCol>iCurrent ){ | ||
| 220552 | /* Advance pointer p until it points to pEnd or an 0x01 byte that is | ||
| 220553 | ** not part of a varint. Note that it is not possible for a negative | ||
| 220554 | ** or extremely large varint to occur within an uncorrupted position | ||
| 220555 | ** list. So the last byte of each varint may be assumed to have a clear | ||
| 220556 | ** 0x80 bit. */ | ||
| 220557 | while( *p!=0x01 ){ | ||
| 220558 | while( *p++ & 0x80 ); | ||
| 220559 | if( p>=pEnd ) return 0; | ||
| 220560 | } | ||
| 220561 | *pa = p++; | ||
| 220562 | iCurrent = *p++; | ||
| 220563 | if( iCurrent & 0x80 ){ | ||
| 220564 | p--; | ||
| 220565 | p += fts5GetVarint32(p, iCurrent); | ||
| 220566 | } | ||
| 220567 | } | ||
| 220568 | if( iCol!=iCurrent ) return 0; | ||
| 220569 | |||
| 220570 | /* Advance pointer p until it points to pEnd or an 0x01 byte that is | ||
| 220571 | ** not part of a varint */ | ||
| 220572 | while( p<pEnd && *p!=0x01 ){ | ||
| 220573 | while( *p++ & 0x80 ); | ||
| 220574 | } | ||
| 220575 | |||
| 220576 | return p - (*pa); | ||
| 220577 | } | ||
| 220578 | |||
| 220579 | static void fts5IndexExtractColset( | 222840 | static void fts5IndexExtractColset( |
| 220580 | int *pRc, | 222841 | int *pRc, |
| 220581 | Fts5Colset *pColset, /* Colset to filter on */ | 222842 | Fts5Colset *pColset, /* Colset to filter on */ |
| 220582 | const u8 *pPos, int nPos, /* Position list */ | 222843 | const u8 *pPos, int nPos, /* Position list */ |
| 220583 | Fts5Buffer *pBuf /* Output buffer */ | 222844 | Fts5Iter *pIter |
| 220584 | ){ | 222845 | ){ |
| 220585 | if( *pRc==SQLITE_OK ){ | 222846 | if( *pRc==SQLITE_OK ){ |
| 220586 | int i; | 222847 | const u8 *p = pPos; |
| 220587 | fts5BufferZero(pBuf); | 222848 | const u8 *aCopy = p; |
| 220588 | for(i=0; i<pColset->nCol; i++){ | 222849 | const u8 *pEnd = &p[nPos]; /* One byte past end of position list */ |
| 220589 | const u8 *pSub = pPos; | 222850 | int i = 0; |
| 220590 | int nSub = fts5IndexExtractCol(&pSub, nPos, pColset->aiCol[i]); | 222851 | int iCurrent = 0; |
| 220591 | if( nSub ){ | 222852 | |
| 220592 | fts5BufferAppendBlob(pRc, pBuf, nSub, pSub); | 222853 | if( pColset->nCol>1 && sqlite3Fts5BufferSize(pRc, &pIter->poslist, nPos) ){ |
| 222854 | return; | ||
| 222855 | } | ||
| 222856 | |||
| 222857 | while( 1 ){ | ||
| 222858 | while( pColset->aiCol[i]<iCurrent ){ | ||
| 222859 | i++; | ||
| 222860 | if( i==pColset->nCol ){ | ||
| 222861 | pIter->base.pData = pIter->poslist.p; | ||
| 222862 | pIter->base.nData = pIter->poslist.n; | ||
| 222863 | return; | ||
| 222864 | } | ||
| 222865 | } | ||
| 222866 | |||
| 222867 | /* Advance pointer p until it points to pEnd or an 0x01 byte that is | ||
| 222868 | ** not part of a varint */ | ||
| 222869 | while( p<pEnd && *p!=0x01 ){ | ||
| 222870 | while( *p++ & 0x80 ); | ||
| 222871 | } | ||
| 222872 | |||
| 222873 | if( pColset->aiCol[i]==iCurrent ){ | ||
| 222874 | if( pColset->nCol==1 ){ | ||
| 222875 | pIter->base.pData = aCopy; | ||
| 222876 | pIter->base.nData = p-aCopy; | ||
| 222877 | return; | ||
| 222878 | } | ||
| 222879 | fts5BufferSafeAppendBlob(&pIter->poslist, aCopy, p-aCopy); | ||
| 222880 | } | ||
| 222881 | if( p==pEnd ){ | ||
| 222882 | pIter->base.pData = pIter->poslist.p; | ||
| 222883 | pIter->base.nData = pIter->poslist.n; | ||
| 222884 | return; | ||
| 222885 | } | ||
| 222886 | aCopy = p++; | ||
| 222887 | iCurrent = *p++; | ||
| 222888 | if( iCurrent & 0x80 ){ | ||
| 222889 | p--; | ||
| 222890 | p += fts5GetVarint32(p, iCurrent); | ||
| 220593 | } | 222891 | } |
| 220594 | } | 222892 | } |
| 220595 | } | 222893 | } |
| 222894 | |||
| 220596 | } | 222895 | } |
| 220597 | 222896 | ||
| 220598 | /* | 222897 | /* |
| @@ -220712,16 +223011,9 @@ static void fts5IterSetOutputs_Full(Fts5Iter *pIter, Fts5SegIter *pSeg){ | |||
| 220712 | /* All data is stored on the current page. Populate the output | 223011 | /* All data is stored on the current page. Populate the output |
| 220713 | ** variables to point into the body of the page object. */ | 223012 | ** variables to point into the body of the page object. */ |
| 220714 | const u8 *a = &pSeg->pLeaf->p[pSeg->iLeafOffset]; | 223013 | const u8 *a = &pSeg->pLeaf->p[pSeg->iLeafOffset]; |
| 220715 | if( pColset->nCol==1 ){ | 223014 | int *pRc = &pIter->pIndex->rc; |
| 220716 | pIter->base.nData = fts5IndexExtractCol(&a, pSeg->nPos,pColset->aiCol[0]); | 223015 | fts5BufferZero(&pIter->poslist); |
| 220717 | pIter->base.pData = a; | 223016 | fts5IndexExtractColset(pRc, pColset, a, pSeg->nPos, pIter); |
| 220718 | }else{ | ||
| 220719 | int *pRc = &pIter->pIndex->rc; | ||
| 220720 | fts5BufferZero(&pIter->poslist); | ||
| 220721 | fts5IndexExtractColset(pRc, pColset, a, pSeg->nPos, &pIter->poslist); | ||
| 220722 | pIter->base.pData = pIter->poslist.p; | ||
| 220723 | pIter->base.nData = pIter->poslist.n; | ||
| 220724 | } | ||
| 220725 | }else{ | 223017 | }else{ |
| 220726 | /* The data is distributed over two or more pages. Copy it into the | 223018 | /* The data is distributed over two or more pages. Copy it into the |
| 220727 | ** Fts5Iter.poslist buffer and then set the output pointer to point | 223019 | ** Fts5Iter.poslist buffer and then set the output pointer to point |
| @@ -222204,7 +224496,7 @@ static void fts5AppendPoslist( | |||
| 222204 | static void fts5DoclistIterNext(Fts5DoclistIter *pIter){ | 224496 | static void fts5DoclistIterNext(Fts5DoclistIter *pIter){ |
| 222205 | u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist; | 224497 | u8 *p = pIter->aPoslist + pIter->nSize + pIter->nPoslist; |
| 222206 | 224498 | ||
| 222207 | assert( pIter->aPoslist ); | 224499 | assert( pIter->aPoslist || (p==0 && pIter->aPoslist==0) ); |
| 222208 | if( p>=pIter->aEof ){ | 224500 | if( p>=pIter->aEof ){ |
| 222209 | pIter->aPoslist = 0; | 224501 | pIter->aPoslist = 0; |
| 222210 | }else{ | 224502 | }else{ |
| @@ -222224,6 +224516,9 @@ static void fts5DoclistIterNext(Fts5DoclistIter *pIter){ | |||
| 222224 | } | 224516 | } |
| 222225 | 224517 | ||
| 222226 | pIter->aPoslist = p; | 224518 | pIter->aPoslist = p; |
| 224519 | if( &pIter->aPoslist[pIter->nPoslist]>pIter->aEof ){ | ||
| 224520 | pIter->aPoslist = 0; | ||
| 224521 | } | ||
| 222227 | } | 224522 | } |
| 222228 | } | 224523 | } |
| 222229 | 224524 | ||
| @@ -222232,9 +224527,11 @@ static void fts5DoclistIterInit( | |||
| 222232 | Fts5DoclistIter *pIter | 224527 | Fts5DoclistIter *pIter |
| 222233 | ){ | 224528 | ){ |
| 222234 | memset(pIter, 0, sizeof(*pIter)); | 224529 | memset(pIter, 0, sizeof(*pIter)); |
| 222235 | pIter->aPoslist = pBuf->p; | 224530 | if( pBuf->n>0 ){ |
| 222236 | pIter->aEof = &pBuf->p[pBuf->n]; | 224531 | pIter->aPoslist = pBuf->p; |
| 222237 | fts5DoclistIterNext(pIter); | 224532 | pIter->aEof = &pBuf->p[pBuf->n]; |
| 224533 | fts5DoclistIterNext(pIter); | ||
| 224534 | } | ||
| 222238 | } | 224535 | } |
| 222239 | 224536 | ||
| 222240 | #if 0 | 224537 | #if 0 |
| @@ -222288,16 +224585,20 @@ static void fts5NextRowid(Fts5Buffer *pBuf, int *piOff, i64 *piRowid){ | |||
| 222288 | static void fts5MergeRowidLists( | 224585 | static void fts5MergeRowidLists( |
| 222289 | Fts5Index *p, /* FTS5 backend object */ | 224586 | Fts5Index *p, /* FTS5 backend object */ |
| 222290 | Fts5Buffer *p1, /* First list to merge */ | 224587 | Fts5Buffer *p1, /* First list to merge */ |
| 222291 | Fts5Buffer *p2 /* Second list to merge */ | 224588 | int nBuf, /* Number of entries in apBuf[] */ |
| 224589 | Fts5Buffer *aBuf /* Array of other lists to merge into p1 */ | ||
| 222292 | ){ | 224590 | ){ |
| 222293 | int i1 = 0; | 224591 | int i1 = 0; |
| 222294 | int i2 = 0; | 224592 | int i2 = 0; |
| 222295 | i64 iRowid1 = 0; | 224593 | i64 iRowid1 = 0; |
| 222296 | i64 iRowid2 = 0; | 224594 | i64 iRowid2 = 0; |
| 222297 | i64 iOut = 0; | 224595 | i64 iOut = 0; |
| 222298 | 224596 | Fts5Buffer *p2 = &aBuf[0]; | |
| 222299 | Fts5Buffer out; | 224597 | Fts5Buffer out; |
| 224598 | |||
| 224599 | (void)nBuf; | ||
| 222300 | memset(&out, 0, sizeof(out)); | 224600 | memset(&out, 0, sizeof(out)); |
| 224601 | assert( nBuf==1 ); | ||
| 222301 | sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n); | 224602 | sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n); |
| 222302 | if( p->rc ) return; | 224603 | if( p->rc ) return; |
| 222303 | 224604 | ||
| @@ -222324,180 +224625,213 @@ static void fts5MergeRowidLists( | |||
| 222324 | fts5BufferFree(&out); | 224625 | fts5BufferFree(&out); |
| 222325 | } | 224626 | } |
| 222326 | 224627 | ||
| 224628 | typedef struct PrefixMerger PrefixMerger; | ||
| 224629 | struct PrefixMerger { | ||
| 224630 | Fts5DoclistIter iter; /* Doclist iterator */ | ||
| 224631 | i64 iPos; /* For iterating through a position list */ | ||
| 224632 | int iOff; | ||
| 224633 | u8 *aPos; | ||
| 224634 | PrefixMerger *pNext; /* Next in docid/poslist order */ | ||
| 224635 | }; | ||
| 224636 | |||
| 224637 | static void fts5PrefixMergerInsertByRowid( | ||
| 224638 | PrefixMerger **ppHead, | ||
| 224639 | PrefixMerger *p | ||
| 224640 | ){ | ||
| 224641 | if( p->iter.aPoslist ){ | ||
| 224642 | PrefixMerger **pp = ppHead; | ||
| 224643 | while( *pp && p->iter.iRowid>(*pp)->iter.iRowid ){ | ||
| 224644 | pp = &(*pp)->pNext; | ||
| 224645 | } | ||
| 224646 | p->pNext = *pp; | ||
| 224647 | *pp = p; | ||
| 224648 | } | ||
| 224649 | } | ||
| 224650 | |||
| 224651 | static void fts5PrefixMergerInsertByPosition( | ||
| 224652 | PrefixMerger **ppHead, | ||
| 224653 | PrefixMerger *p | ||
| 224654 | ){ | ||
| 224655 | if( p->iPos>=0 ){ | ||
| 224656 | PrefixMerger **pp = ppHead; | ||
| 224657 | while( *pp && p->iPos>(*pp)->iPos ){ | ||
| 224658 | pp = &(*pp)->pNext; | ||
| 224659 | } | ||
| 224660 | p->pNext = *pp; | ||
| 224661 | *pp = p; | ||
| 224662 | } | ||
| 224663 | } | ||
| 224664 | |||
| 224665 | |||
| 222327 | /* | 224666 | /* |
| 222328 | ** Buffers p1 and p2 contain doclists. This function merges the content | 224667 | ** Array aBuf[] contains nBuf doclists. These are all merged in with the |
| 222329 | ** of the two doclists together and sets buffer p1 to the result before | 224668 | ** doclist in buffer p1. |
| 222330 | ** returning. | ||
| 222331 | ** | ||
| 222332 | ** If an error occurs, an error code is left in p->rc. If an error has | ||
| 222333 | ** already occurred, this function is a no-op. | ||
| 222334 | */ | 224669 | */ |
| 222335 | static void fts5MergePrefixLists( | 224670 | static void fts5MergePrefixLists( |
| 222336 | Fts5Index *p, /* FTS5 backend object */ | 224671 | Fts5Index *p, /* FTS5 backend object */ |
| 222337 | Fts5Buffer *p1, /* First list to merge */ | 224672 | Fts5Buffer *p1, /* First list to merge */ |
| 222338 | Fts5Buffer *p2 /* Second list to merge */ | 224673 | int nBuf, /* Number of buffers in array aBuf[] */ |
| 222339 | ){ | 224674 | Fts5Buffer *aBuf /* Other lists to merge in */ |
| 222340 | if( p2->n ){ | 224675 | ){ |
| 222341 | i64 iLastRowid = 0; | 224676 | #define fts5PrefixMergerNextPosition(p) \ |
| 222342 | Fts5DoclistIter i1; | 224677 | sqlite3Fts5PoslistNext64((p)->aPos,(p)->iter.nPoslist,&(p)->iOff,&(p)->iPos); |
| 222343 | Fts5DoclistIter i2; | 224678 | #define FTS5_MERGE_NLIST 16 |
| 222344 | Fts5Buffer out = {0, 0, 0}; | 224679 | PrefixMerger aMerger[FTS5_MERGE_NLIST]; |
| 222345 | Fts5Buffer tmp = {0, 0, 0}; | 224680 | PrefixMerger *pHead = 0; |
| 222346 | 224681 | int i; | |
| 222347 | /* The maximum size of the output is equal to the sum of the two | 224682 | int nOut = 0; |
| 222348 | ** input sizes + 1 varint (9 bytes). The extra varint is because if the | 224683 | Fts5Buffer out = {0, 0, 0}; |
| 222349 | ** first rowid in one input is a large negative number, and the first in | 224684 | Fts5Buffer tmp = {0, 0, 0}; |
| 222350 | ** the other a non-negative number, the delta for the non-negative | 224685 | i64 iLastRowid = 0; |
| 222351 | ** number will be larger on disk than the literal integer value | 224686 | |
| 222352 | ** was. | 224687 | /* Initialize a doclist-iterator for each input buffer. Arrange them in |
| 222353 | ** | 224688 | ** a linked-list starting at pHead in ascending order of rowid. Avoid |
| 222354 | ** Or, if the input position-lists are corrupt, then the output might | 224689 | ** linking any iterators already at EOF into the linked list at all. */ |
| 222355 | ** include up to 2 extra 10-byte positions created by interpreting -1 | 224690 | assert( nBuf+1<=sizeof(aMerger)/sizeof(aMerger[0]) ); |
| 222356 | ** (the value PoslistNext64() uses for EOF) as a position and appending | 224691 | memset(aMerger, 0, sizeof(PrefixMerger)*(nBuf+1)); |
| 222357 | ** it to the output. This can happen at most once for each input | 224692 | pHead = &aMerger[nBuf]; |
| 222358 | ** position-list, hence two 10 byte paddings. */ | 224693 | fts5DoclistIterInit(p1, &pHead->iter); |
| 222359 | if( sqlite3Fts5BufferSize(&p->rc, &out, p1->n + p2->n + 9+10+10) ) return; | 224694 | for(i=0; i<nBuf; i++){ |
| 222360 | fts5DoclistIterInit(p1, &i1); | 224695 | fts5DoclistIterInit(&aBuf[i], &aMerger[i].iter); |
| 222361 | fts5DoclistIterInit(p2, &i2); | 224696 | fts5PrefixMergerInsertByRowid(&pHead, &aMerger[i]); |
| 224697 | nOut += aBuf[i].n; | ||
| 224698 | } | ||
| 224699 | if( nOut==0 ) return; | ||
| 224700 | nOut += p1->n + 9 + 10*nBuf; | ||
| 224701 | |||
| 224702 | /* The maximum size of the output is equal to the sum of the | ||
| 224703 | ** input sizes + 1 varint (9 bytes). The extra varint is because if the | ||
| 224704 | ** first rowid in one input is a large negative number, and the first in | ||
| 224705 | ** the other a non-negative number, the delta for the non-negative | ||
| 224706 | ** number will be larger on disk than the literal integer value | ||
| 224707 | ** was. | ||
| 224708 | ** | ||
| 224709 | ** Or, if the input position-lists are corrupt, then the output might | ||
| 224710 | ** include up to (nBuf+1) extra 10-byte positions created by interpreting -1 | ||
| 224711 | ** (the value PoslistNext64() uses for EOF) as a position and appending | ||
| 224712 | ** it to the output. This can happen at most once for each input | ||
| 224713 | ** position-list, hence (nBuf+1) 10 byte paddings. */ | ||
| 224714 | if( sqlite3Fts5BufferSize(&p->rc, &out, nOut) ) return; | ||
| 224715 | |||
| 224716 | while( pHead ){ | ||
| 224717 | fts5MergeAppendDocid(&out, iLastRowid, pHead->iter.iRowid); | ||
| 224718 | |||
| 224719 | if( pHead->pNext && iLastRowid==pHead->pNext->iter.iRowid ){ | ||
| 224720 | /* Merge data from two or more poslists */ | ||
| 224721 | i64 iPrev = 0; | ||
| 224722 | int nTmp = FTS5_DATA_ZERO_PADDING; | ||
| 224723 | int nMerge = 0; | ||
| 224724 | PrefixMerger *pSave = pHead; | ||
| 224725 | PrefixMerger *pThis = 0; | ||
| 224726 | int nTail = 0; | ||
| 224727 | |||
| 224728 | pHead = 0; | ||
| 224729 | while( pSave && pSave->iter.iRowid==iLastRowid ){ | ||
| 224730 | PrefixMerger *pNext = pSave->pNext; | ||
| 224731 | pSave->iOff = 0; | ||
| 224732 | pSave->iPos = 0; | ||
| 224733 | pSave->aPos = &pSave->iter.aPoslist[pSave->iter.nSize]; | ||
| 224734 | fts5PrefixMergerNextPosition(pSave); | ||
| 224735 | nTmp += pSave->iter.nPoslist + 10; | ||
| 224736 | nMerge++; | ||
| 224737 | fts5PrefixMergerInsertByPosition(&pHead, pSave); | ||
| 224738 | pSave = pNext; | ||
| 224739 | } | ||
| 224740 | |||
| 224741 | if( pHead==0 || pHead->pNext==0 ){ | ||
| 224742 | p->rc = FTS5_CORRUPT; | ||
| 224743 | break; | ||
| 224744 | } | ||
| 222362 | 224745 | ||
| 222363 | while( 1 ){ | 224746 | /* See the earlier comment in this function for an explanation of why |
| 222364 | if( i1.iRowid<i2.iRowid ){ | 224747 | ** corrupt input position lists might cause the output to consume |
| 222365 | /* Copy entry from i1 */ | 224748 | ** at most nMerge*10 bytes of unexpected space. */ |
| 222366 | fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid); | 224749 | if( sqlite3Fts5BufferSize(&p->rc, &tmp, nTmp+nMerge*10) ){ |
| 222367 | fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.nPoslist+i1.nSize); | 224750 | break; |
| 222368 | fts5DoclistIterNext(&i1); | ||
| 222369 | if( i1.aPoslist==0 ) break; | ||
| 222370 | assert( out.n<=((i1.aPoslist-p1->p) + (i2.aPoslist-p2->p)+9+10+10) ); | ||
| 222371 | } | ||
| 222372 | else if( i2.iRowid!=i1.iRowid ){ | ||
| 222373 | /* Copy entry from i2 */ | ||
| 222374 | fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid); | ||
| 222375 | fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.nPoslist+i2.nSize); | ||
| 222376 | fts5DoclistIterNext(&i2); | ||
| 222377 | if( i2.aPoslist==0 ) break; | ||
| 222378 | assert( out.n<=((i1.aPoslist-p1->p) + (i2.aPoslist-p2->p)+9+10+10) ); | ||
| 222379 | } | 224751 | } |
| 222380 | else{ | 224752 | fts5BufferZero(&tmp); |
| 222381 | /* Merge the two position lists. */ | ||
| 222382 | i64 iPos1 = 0; | ||
| 222383 | i64 iPos2 = 0; | ||
| 222384 | int iOff1 = 0; | ||
| 222385 | int iOff2 = 0; | ||
| 222386 | u8 *a1 = &i1.aPoslist[i1.nSize]; | ||
| 222387 | u8 *a2 = &i2.aPoslist[i2.nSize]; | ||
| 222388 | int nCopy; | ||
| 222389 | u8 *aCopy; | ||
| 222390 | |||
| 222391 | i64 iPrev = 0; | ||
| 222392 | Fts5PoslistWriter writer; | ||
| 222393 | memset(&writer, 0, sizeof(writer)); | ||
| 222394 | |||
| 222395 | /* See the earlier comment in this function for an explanation of why | ||
| 222396 | ** corrupt input position lists might cause the output to consume | ||
| 222397 | ** at most 20 bytes of unexpected space. */ | ||
| 222398 | fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid); | ||
| 222399 | fts5BufferZero(&tmp); | ||
| 222400 | sqlite3Fts5BufferSize(&p->rc, &tmp, | ||
| 222401 | i1.nPoslist + i2.nPoslist + 10 + 10 + FTS5_DATA_ZERO_PADDING | ||
| 222402 | ); | ||
| 222403 | if( p->rc ) break; | ||
| 222404 | 224753 | ||
| 222405 | sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1); | 224754 | pThis = pHead; |
| 222406 | sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2); | 224755 | pHead = pThis->pNext; |
| 222407 | assert_nc( iPos1>=0 && iPos2>=0 ); | 224756 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, pThis->iPos); |
| 224757 | fts5PrefixMergerNextPosition(pThis); | ||
| 224758 | fts5PrefixMergerInsertByPosition(&pHead, pThis); | ||
| 222408 | 224759 | ||
| 222409 | if( iPos1<iPos2 ){ | 224760 | while( pHead->pNext ){ |
| 222410 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1); | 224761 | pThis = pHead; |
| 222411 | sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1); | 224762 | if( pThis->iPos!=iPrev ){ |
| 222412 | }else{ | 224763 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, pThis->iPos); |
| 222413 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2); | ||
| 222414 | sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2); | ||
| 222415 | } | ||
| 222416 | if( iPos1>=0 && iPos2>=0 ){ | ||
| 222417 | while( 1 ){ | ||
| 222418 | if( iPos1<iPos2 ){ | ||
| 222419 | if( iPos1!=iPrev ){ | ||
| 222420 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1); | ||
| 222421 | } | ||
| 222422 | sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1); | ||
| 222423 | if( iPos1<0 ) break; | ||
| 222424 | }else{ | ||
| 222425 | assert_nc( iPos2!=iPrev ); | ||
| 222426 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2); | ||
| 222427 | sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2); | ||
| 222428 | if( iPos2<0 ) break; | ||
| 222429 | } | ||
| 222430 | } | ||
| 222431 | } | 224764 | } |
| 224765 | fts5PrefixMergerNextPosition(pThis); | ||
| 224766 | pHead = pThis->pNext; | ||
| 224767 | fts5PrefixMergerInsertByPosition(&pHead, pThis); | ||
| 224768 | } | ||
| 222432 | 224769 | ||
| 222433 | if( iPos1>=0 ){ | 224770 | if( pHead->iPos!=iPrev ){ |
| 222434 | if( iPos1!=iPrev ){ | 224771 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, pHead->iPos); |
| 222435 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1); | 224772 | } |
| 222436 | } | 224773 | nTail = pHead->iter.nPoslist - pHead->iOff; |
| 222437 | aCopy = &a1[iOff1]; | ||
| 222438 | nCopy = i1.nPoslist - iOff1; | ||
| 222439 | }else{ | ||
| 222440 | assert_nc( iPos2>=0 && iPos2!=iPrev ); | ||
| 222441 | sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2); | ||
| 222442 | aCopy = &a2[iOff2]; | ||
| 222443 | nCopy = i2.nPoslist - iOff2; | ||
| 222444 | } | ||
| 222445 | if( nCopy>0 ){ | ||
| 222446 | fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy); | ||
| 222447 | } | ||
| 222448 | 224774 | ||
| 222449 | /* WRITEPOSLISTSIZE */ | 224775 | /* WRITEPOSLISTSIZE */ |
| 222450 | assert_nc( tmp.n<=i1.nPoslist+i2.nPoslist ); | 224776 | assert( tmp.n+nTail<=nTmp ); |
| 222451 | assert( tmp.n<=i1.nPoslist+i2.nPoslist+10+10 ); | 224777 | if( tmp.n+nTail>nTmp-FTS5_DATA_ZERO_PADDING ){ |
| 222452 | if( tmp.n>i1.nPoslist+i2.nPoslist ){ | 224778 | if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT; |
| 222453 | if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT; | 224779 | break; |
| 222454 | break; | 224780 | } |
| 224781 | fts5BufferSafeAppendVarint(&out, (tmp.n+nTail) * 2); | ||
| 224782 | fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n); | ||
| 224783 | if( nTail>0 ){ | ||
| 224784 | fts5BufferSafeAppendBlob(&out, &pHead->aPos[pHead->iOff], nTail); | ||
| 224785 | } | ||
| 224786 | |||
| 224787 | pHead = pSave; | ||
| 224788 | for(i=0; i<nBuf+1; i++){ | ||
| 224789 | PrefixMerger *pX = &aMerger[i]; | ||
| 224790 | if( pX->iter.aPoslist && pX->iter.iRowid==iLastRowid ){ | ||
| 224791 | fts5DoclistIterNext(&pX->iter); | ||
| 224792 | fts5PrefixMergerInsertByRowid(&pHead, pX); | ||
| 222455 | } | 224793 | } |
| 222456 | fts5BufferSafeAppendVarint(&out, tmp.n * 2); | ||
| 222457 | fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n); | ||
| 222458 | fts5DoclistIterNext(&i1); | ||
| 222459 | fts5DoclistIterNext(&i2); | ||
| 222460 | assert_nc( out.n<=(p1->n+p2->n+9) ); | ||
| 222461 | if( i1.aPoslist==0 || i2.aPoslist==0 ) break; | ||
| 222462 | assert( out.n<=((i1.aPoslist-p1->p) + (i2.aPoslist-p2->p)+9+10+10) ); | ||
| 222463 | } | 224794 | } |
| 222464 | } | ||
| 222465 | 224795 | ||
| 222466 | if( i1.aPoslist ){ | 224796 | }else{ |
| 222467 | fts5MergeAppendDocid(&out, iLastRowid, i1.iRowid); | 224797 | /* Copy poslist from pHead to output */ |
| 222468 | fts5BufferSafeAppendBlob(&out, i1.aPoslist, i1.aEof - i1.aPoslist); | 224798 | PrefixMerger *pThis = pHead; |
| 222469 | } | 224799 | Fts5DoclistIter *pI = &pThis->iter; |
| 222470 | else if( i2.aPoslist ){ | 224800 | fts5BufferSafeAppendBlob(&out, pI->aPoslist, pI->nPoslist+pI->nSize); |
| 222471 | fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid); | 224801 | fts5DoclistIterNext(pI); |
| 222472 | fts5BufferSafeAppendBlob(&out, i2.aPoslist, i2.aEof - i2.aPoslist); | 224802 | pHead = pThis->pNext; |
| 224803 | fts5PrefixMergerInsertByRowid(&pHead, pThis); | ||
| 222473 | } | 224804 | } |
| 222474 | assert_nc( out.n<=(p1->n+p2->n+9) ); | ||
| 222475 | |||
| 222476 | fts5BufferFree(p1); | ||
| 222477 | fts5BufferFree(&tmp); | ||
| 222478 | memset(&out.p[out.n], 0, FTS5_DATA_ZERO_PADDING); | ||
| 222479 | *p1 = out; | ||
| 222480 | } | 224805 | } |
| 224806 | |||
| 224807 | fts5BufferFree(p1); | ||
| 224808 | fts5BufferFree(&tmp); | ||
| 224809 | memset(&out.p[out.n], 0, FTS5_DATA_ZERO_PADDING); | ||
| 224810 | *p1 = out; | ||
| 222481 | } | 224811 | } |
| 222482 | 224812 | ||
| 222483 | static void fts5SetupPrefixIter( | 224813 | static void fts5SetupPrefixIter( |
| 222484 | Fts5Index *p, /* Index to read from */ | 224814 | Fts5Index *p, /* Index to read from */ |
| 222485 | int bDesc, /* True for "ORDER BY rowid DESC" */ | 224815 | int bDesc, /* True for "ORDER BY rowid DESC" */ |
| 222486 | const u8 *pToken, /* Buffer containing prefix to match */ | 224816 | int iIdx, /* Index to scan for data */ |
| 224817 | u8 *pToken, /* Buffer containing prefix to match */ | ||
| 222487 | int nToken, /* Size of buffer pToken in bytes */ | 224818 | int nToken, /* Size of buffer pToken in bytes */ |
| 222488 | Fts5Colset *pColset, /* Restrict matches to these columns */ | 224819 | Fts5Colset *pColset, /* Restrict matches to these columns */ |
| 222489 | Fts5Iter **ppIter /* OUT: New iterator */ | 224820 | Fts5Iter **ppIter /* OUT: New iterator */ |
| 222490 | ){ | 224821 | ){ |
| 222491 | Fts5Structure *pStruct; | 224822 | Fts5Structure *pStruct; |
| 222492 | Fts5Buffer *aBuf; | 224823 | Fts5Buffer *aBuf; |
| 222493 | const int nBuf = 32; | 224824 | int nBuf = 32; |
| 224825 | int nMerge = 1; | ||
| 222494 | 224826 | ||
| 222495 | void (*xMerge)(Fts5Index*, Fts5Buffer*, Fts5Buffer*); | 224827 | void (*xMerge)(Fts5Index*, Fts5Buffer*, int, Fts5Buffer*); |
| 222496 | void (*xAppend)(Fts5Index*, i64, Fts5Iter*, Fts5Buffer*); | 224828 | void (*xAppend)(Fts5Index*, i64, Fts5Iter*, Fts5Buffer*); |
| 222497 | if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ | 224829 | if( p->pConfig->eDetail==FTS5_DETAIL_NONE ){ |
| 222498 | xMerge = fts5MergeRowidLists; | 224830 | xMerge = fts5MergeRowidLists; |
| 222499 | xAppend = fts5AppendRowid; | 224831 | xAppend = fts5AppendRowid; |
| 222500 | }else{ | 224832 | }else{ |
| 224833 | nMerge = FTS5_MERGE_NLIST-1; | ||
| 224834 | nBuf = nMerge*8; /* Sufficient to merge (16^8)==(2^32) lists */ | ||
| 222501 | xMerge = fts5MergePrefixLists; | 224835 | xMerge = fts5MergePrefixLists; |
| 222502 | xAppend = fts5AppendPoslist; | 224836 | xAppend = fts5AppendPoslist; |
| 222503 | } | 224837 | } |
| @@ -222517,6 +224851,27 @@ static void fts5SetupPrefixIter( | |||
| 222517 | int bNewTerm = 1; | 224851 | int bNewTerm = 1; |
| 222518 | 224852 | ||
| 222519 | memset(&doclist, 0, sizeof(doclist)); | 224853 | memset(&doclist, 0, sizeof(doclist)); |
| 224854 | if( iIdx!=0 ){ | ||
| 224855 | int dummy = 0; | ||
| 224856 | const int f2 = FTS5INDEX_QUERY_SKIPEMPTY|FTS5INDEX_QUERY_NOOUTPUT; | ||
| 224857 | pToken[0] = FTS5_MAIN_PREFIX; | ||
| 224858 | fts5MultiIterNew(p, pStruct, f2, pColset, pToken, nToken, -1, 0, &p1); | ||
| 224859 | fts5IterSetOutputCb(&p->rc, p1); | ||
| 224860 | for(; | ||
| 224861 | fts5MultiIterEof(p, p1)==0; | ||
| 224862 | fts5MultiIterNext2(p, p1, &dummy) | ||
| 224863 | ){ | ||
| 224864 | Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ]; | ||
| 224865 | p1->xSetOutputs(p1, pSeg); | ||
| 224866 | if( p1->base.nData ){ | ||
| 224867 | xAppend(p, p1->base.iRowid-iLastRowid, p1, &doclist); | ||
| 224868 | iLastRowid = p1->base.iRowid; | ||
| 224869 | } | ||
| 224870 | } | ||
| 224871 | fts5MultiIterFree(p1); | ||
| 224872 | } | ||
| 224873 | |||
| 224874 | pToken[0] = FTS5_MAIN_PREFIX + iIdx; | ||
| 222520 | fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1); | 224875 | fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1); |
| 222521 | fts5IterSetOutputCb(&p->rc, p1); | 224876 | fts5IterSetOutputCb(&p->rc, p1); |
| 222522 | for( /* no-op */ ; | 224877 | for( /* no-op */ ; |
| @@ -222537,13 +224892,21 @@ static void fts5SetupPrefixIter( | |||
| 222537 | 224892 | ||
| 222538 | if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){ | 224893 | if( p1->base.iRowid<=iLastRowid && doclist.n>0 ){ |
| 222539 | for(i=0; p->rc==SQLITE_OK && doclist.n; i++){ | 224894 | for(i=0; p->rc==SQLITE_OK && doclist.n; i++){ |
| 222540 | assert( i<nBuf ); | 224895 | int i1 = i*nMerge; |
| 222541 | if( aBuf[i].n==0 ){ | 224896 | int iStore; |
| 222542 | fts5BufferSwap(&doclist, &aBuf[i]); | 224897 | assert( i1+nMerge<=nBuf ); |
| 222543 | fts5BufferZero(&doclist); | 224898 | for(iStore=i1; iStore<i1+nMerge; iStore++){ |
| 222544 | }else{ | 224899 | if( aBuf[iStore].n==0 ){ |
| 222545 | xMerge(p, &doclist, &aBuf[i]); | 224900 | fts5BufferSwap(&doclist, &aBuf[iStore]); |
| 222546 | fts5BufferZero(&aBuf[i]); | 224901 | fts5BufferZero(&doclist); |
| 224902 | break; | ||
| 224903 | } | ||
| 224904 | } | ||
| 224905 | if( iStore==i1+nMerge ){ | ||
| 224906 | xMerge(p, &doclist, nMerge, &aBuf[i1]); | ||
| 224907 | for(iStore=i1; iStore<i1+nMerge; iStore++){ | ||
| 224908 | fts5BufferZero(&aBuf[iStore]); | ||
| 224909 | } | ||
| 222547 | } | 224910 | } |
| 222548 | } | 224911 | } |
| 222549 | iLastRowid = 0; | 224912 | iLastRowid = 0; |
| @@ -222553,11 +224916,15 @@ static void fts5SetupPrefixIter( | |||
| 222553 | iLastRowid = p1->base.iRowid; | 224916 | iLastRowid = p1->base.iRowid; |
| 222554 | } | 224917 | } |
| 222555 | 224918 | ||
| 222556 | for(i=0; i<nBuf; i++){ | 224919 | assert( (nBuf%nMerge)==0 ); |
| 224920 | for(i=0; i<nBuf; i+=nMerge){ | ||
| 224921 | int iFree; | ||
| 222557 | if( p->rc==SQLITE_OK ){ | 224922 | if( p->rc==SQLITE_OK ){ |
| 222558 | xMerge(p, &doclist, &aBuf[i]); | 224923 | xMerge(p, &doclist, nMerge, &aBuf[i]); |
| 224924 | } | ||
| 224925 | for(iFree=i; iFree<i+nMerge; iFree++){ | ||
| 224926 | fts5BufferFree(&aBuf[iFree]); | ||
| 222559 | } | 224927 | } |
| 222560 | fts5BufferFree(&aBuf[i]); | ||
| 222561 | } | 224928 | } |
| 222562 | fts5MultiIterFree(p1); | 224929 | fts5MultiIterFree(p1); |
| 222563 | 224930 | ||
| @@ -222812,6 +225179,7 @@ static int sqlite3Fts5IndexQuery( | |||
| 222812 | 225179 | ||
| 222813 | if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){ | 225180 | if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){ |
| 222814 | int iIdx = 0; /* Index to search */ | 225181 | int iIdx = 0; /* Index to search */ |
| 225182 | int iPrefixIdx = 0; /* +1 prefix index */ | ||
| 222815 | if( nToken ) memcpy(&buf.p[1], pToken, nToken); | 225183 | if( nToken ) memcpy(&buf.p[1], pToken, nToken); |
| 222816 | 225184 | ||
| 222817 | /* Figure out which index to search and set iIdx accordingly. If this | 225185 | /* Figure out which index to search and set iIdx accordingly. If this |
| @@ -222833,7 +225201,9 @@ static int sqlite3Fts5IndexQuery( | |||
| 222833 | if( flags & FTS5INDEX_QUERY_PREFIX ){ | 225201 | if( flags & FTS5INDEX_QUERY_PREFIX ){ |
| 222834 | int nChar = fts5IndexCharlen(pToken, nToken); | 225202 | int nChar = fts5IndexCharlen(pToken, nToken); |
| 222835 | for(iIdx=1; iIdx<=pConfig->nPrefix; iIdx++){ | 225203 | for(iIdx=1; iIdx<=pConfig->nPrefix; iIdx++){ |
| 222836 | if( pConfig->aPrefix[iIdx-1]==nChar ) break; | 225204 | int nIdxChar = pConfig->aPrefix[iIdx-1]; |
| 225205 | if( nIdxChar==nChar ) break; | ||
| 225206 | if( nIdxChar==nChar+1 ) iPrefixIdx = iIdx; | ||
| 222837 | } | 225207 | } |
| 222838 | } | 225208 | } |
| 222839 | 225209 | ||
| @@ -222850,8 +225220,7 @@ static int sqlite3Fts5IndexQuery( | |||
| 222850 | }else{ | 225220 | }else{ |
| 222851 | /* Scan multiple terms in the main index */ | 225221 | /* Scan multiple terms in the main index */ |
| 222852 | int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0; | 225222 | int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0; |
| 222853 | buf.p[0] = FTS5_MAIN_PREFIX; | 225223 | fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet); |
| 222854 | fts5SetupPrefixIter(p, bDesc, buf.p, nToken+1, pColset, &pRet); | ||
| 222855 | assert( p->rc!=SQLITE_OK || pRet->pColset==0 ); | 225224 | assert( p->rc!=SQLITE_OK || pRet->pColset==0 ); |
| 222856 | fts5IterSetOutputCb(&p->rc, pRet); | 225225 | fts5IterSetOutputCb(&p->rc, pRet); |
| 222857 | if( p->rc==SQLITE_OK ){ | 225226 | if( p->rc==SQLITE_OK ){ |
| @@ -222924,8 +225293,9 @@ static int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){ | |||
| 222924 | static const char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){ | 225293 | static const char *sqlite3Fts5IterTerm(Fts5IndexIter *pIndexIter, int *pn){ |
| 222925 | int n; | 225294 | int n; |
| 222926 | const char *z = (const char*)fts5MultiIterTerm((Fts5Iter*)pIndexIter, &n); | 225295 | const char *z = (const char*)fts5MultiIterTerm((Fts5Iter*)pIndexIter, &n); |
| 225296 | assert_nc( z || n<=1 ); | ||
| 222927 | *pn = n-1; | 225297 | *pn = n-1; |
| 222928 | return &z[1]; | 225298 | return (z ? &z[1] : 0); |
| 222929 | } | 225299 | } |
| 222930 | 225300 | ||
| 222931 | /* | 225301 | /* |
| @@ -226211,7 +228581,8 @@ static int fts5ApiPhraseFirst( | |||
| 226211 | int n; | 228581 | int n; |
| 226212 | int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); | 228582 | int rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); |
| 226213 | if( rc==SQLITE_OK ){ | 228583 | if( rc==SQLITE_OK ){ |
| 226214 | pIter->b = &pIter->a[n]; | 228584 | assert( pIter->a || n==0 ); |
| 228585 | pIter->b = (pIter->a ? &pIter->a[n] : 0); | ||
| 226215 | *piCol = 0; | 228586 | *piCol = 0; |
| 226216 | *piOff = 0; | 228587 | *piOff = 0; |
| 226217 | fts5ApiPhraseNext(pCtx, pIter, piCol, piOff); | 228588 | fts5ApiPhraseNext(pCtx, pIter, piCol, piOff); |
| @@ -226270,7 +228641,8 @@ static int fts5ApiPhraseFirstColumn( | |||
| 226270 | rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n); | 228641 | rc = sqlite3Fts5ExprPhraseCollist(pCsr->pExpr, iPhrase, &pIter->a, &n); |
| 226271 | } | 228642 | } |
| 226272 | if( rc==SQLITE_OK ){ | 228643 | if( rc==SQLITE_OK ){ |
| 226273 | pIter->b = &pIter->a[n]; | 228644 | assert( pIter->a || n==0 ); |
| 228645 | pIter->b = (pIter->a ? &pIter->a[n] : 0); | ||
| 226274 | *piCol = 0; | 228646 | *piCol = 0; |
| 226275 | fts5ApiPhraseNextColumn(pCtx, pIter, piCol); | 228647 | fts5ApiPhraseNextColumn(pCtx, pIter, piCol); |
| 226276 | } | 228648 | } |
| @@ -226278,7 +228650,8 @@ static int fts5ApiPhraseFirstColumn( | |||
| 226278 | int n; | 228650 | int n; |
| 226279 | rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); | 228651 | rc = fts5CsrPoslist(pCsr, iPhrase, &pIter->a, &n); |
| 226280 | if( rc==SQLITE_OK ){ | 228652 | if( rc==SQLITE_OK ){ |
| 226281 | pIter->b = &pIter->a[n]; | 228653 | assert( pIter->a || n==0 ); |
| 228654 | pIter->b = (pIter->a ? &pIter->a[n] : 0); | ||
| 226282 | if( n<=0 ){ | 228655 | if( n<=0 ){ |
| 226283 | *piCol = -1; | 228656 | *piCol = -1; |
| 226284 | }else if( pIter->a[0]==0x01 ){ | 228657 | }else if( pIter->a[0]==0x01 ){ |
| @@ -226756,7 +229129,7 @@ static int sqlite3Fts5GetTokenizer( | |||
| 226756 | *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); | 229129 | *pzErr = sqlite3_mprintf("no such tokenizer: %s", azArg[0]); |
| 226757 | }else{ | 229130 | }else{ |
| 226758 | rc = pMod->x.xCreate( | 229131 | rc = pMod->x.xCreate( |
| 226759 | pMod->pUserData, &azArg[1], (nArg?nArg-1:0), &pConfig->pTok | 229132 | pMod->pUserData, (azArg?&azArg[1]:0), (nArg?nArg-1:0), &pConfig->pTok |
| 226760 | ); | 229133 | ); |
| 226761 | pConfig->pTokApi = &pMod->x; | 229134 | pConfig->pTokApi = &pMod->x; |
| 226762 | if( rc!=SQLITE_OK ){ | 229135 | if( rc!=SQLITE_OK ){ |
| @@ -226819,7 +229192,7 @@ static void fts5SourceIdFunc( | |||
| 226819 | ){ | 229192 | ){ |
| 226820 | assert( nArg==0 ); | 229193 | assert( nArg==0 ); |
| 226821 | UNUSED_PARAM2(nArg, apUnused); | 229194 | UNUSED_PARAM2(nArg, apUnused); |
| 226822 | sqlite3_result_text(pCtx, "fts5: 2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b", -1, SQLITE_TRANSIENT); | 229195 | sqlite3_result_text(pCtx, "fts5: 2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115500b", -1, SQLITE_TRANSIENT); |
| 226823 | } | 229196 | } |
| 226824 | 229197 | ||
| 226825 | /* | 229198 | /* |
| @@ -231745,9 +234118,9 @@ SQLITE_API int sqlite3_stmt_init( | |||
| 231745 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ | 234118 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 231746 | 234119 | ||
| 231747 | /************** End of stmt.c ************************************************/ | 234120 | /************** End of stmt.c ************************************************/ |
| 231748 | #if __LINE__!=231748 | 234121 | #if __LINE__!=234121 |
| 231749 | #undef SQLITE_SOURCE_ID | 234122 | #undef SQLITE_SOURCE_ID |
| 231750 | #define SQLITE_SOURCE_ID "2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089falt2" | 234123 | #define SQLITE_SOURCE_ID "2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115alt2" |
| 231751 | #endif | 234124 | #endif |
| 231752 | /* Return the source-id for this library */ | 234125 | /* Return the source-id for this library */ |
| 231753 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } | 234126 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| @@ -123,9 +123,9 @@ extern "C" { | |||
| 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 123 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 124 | ** [sqlite_version()] and [sqlite_source_id()]. | 124 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 125 | */ | 125 | */ |
| 126 | #define SQLITE_VERSION "3.34.0" | 126 | #define SQLITE_VERSION "3.35.0" |
| 127 | #define SQLITE_VERSION_NUMBER 3034000 | 127 | #define SQLITE_VERSION_NUMBER 3035000 |
| 128 | #define SQLITE_SOURCE_ID "2020-12-01 16:14:00 a26b6597e3ae272231b96f9982c3bcc17ddec2f2b6eb4df06a224b91089fed5b" | 128 | #define SQLITE_SOURCE_ID "2021-03-12 15:10:09 acd63062eb06748bfe9e4886639e4f2b54ea6a496a83f10716abbaba4115500b" |
| 129 | 129 | ||
| 130 | /* | 130 | /* |
| 131 | ** CAPI3REF: Run-Time Library Version Numbers | 131 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -2115,7 +2115,13 @@ struct sqlite3_mem_methods { | |||
| 2115 | ** The second parameter is a pointer to an integer into which | 2115 | ** The second parameter is a pointer to an integer into which |
| 2116 | ** is written 0 or 1 to indicate whether triggers are disabled or enabled | 2116 | ** is written 0 or 1 to indicate whether triggers are disabled or enabled |
| 2117 | ** following this call. The second parameter may be a NULL pointer, in | 2117 | ** following this call. The second parameter may be a NULL pointer, in |
| 2118 | ** which case the trigger setting is not reported back. </dd> | 2118 | ** which case the trigger setting is not reported back. |
| 2119 | ** | ||
| 2120 | ** <p>Originally this option disabled all triggers. ^(However, since | ||
| 2121 | ** SQLite version 3.35.0, TEMP triggers are still allowed even if | ||
| 2122 | ** this option is off. So, in other words, this option now only disables | ||
| 2123 | ** triggers in the main database schema or in the schemas of ATTACH-ed | ||
| 2124 | ** databases.)^ </dd> | ||
| 2119 | ** | 2125 | ** |
| 2120 | ** [[SQLITE_DBCONFIG_ENABLE_VIEW]] | 2126 | ** [[SQLITE_DBCONFIG_ENABLE_VIEW]] |
| 2121 | ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt> | 2127 | ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt> |
| @@ -2126,7 +2132,13 @@ struct sqlite3_mem_methods { | |||
| 2126 | ** The second parameter is a pointer to an integer into which | 2132 | ** The second parameter is a pointer to an integer into which |
| 2127 | ** is written 0 or 1 to indicate whether views are disabled or enabled | 2133 | ** is written 0 or 1 to indicate whether views are disabled or enabled |
| 2128 | ** following this call. The second parameter may be a NULL pointer, in | 2134 | ** following this call. The second parameter may be a NULL pointer, in |
| 2129 | ** which case the view setting is not reported back. </dd> | 2135 | ** which case the view setting is not reported back. |
| 2136 | ** | ||
| 2137 | ** <p>Originally this option disabled all views. ^(However, since | ||
| 2138 | ** SQLite version 3.35.0, TEMP views are still allowed even if | ||
| 2139 | ** this option is off. So, in other words, this option now only disables | ||
| 2140 | ** views in the main database schema or in the schemas of ATTACH-ed | ||
| 2141 | ** databases.)^ </dd> | ||
| 2130 | ** | 2142 | ** |
| 2131 | ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]] | 2143 | ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]] |
| 2132 | ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt> | 2144 | ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt> |
| @@ -3499,6 +3511,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); | |||
| 3499 | ** that uses dot-files in place of posix advisory locking. | 3511 | ** that uses dot-files in place of posix advisory locking. |
| 3500 | ** <tr><td> file:data.db?mode=readonly <td> | 3512 | ** <tr><td> file:data.db?mode=readonly <td> |
| 3501 | ** An error. "readonly" is not a valid option for the "mode" parameter. | 3513 | ** An error. "readonly" is not a valid option for the "mode" parameter. |
| 3514 | ** Use "ro" instead: "file:data.db?mode=ro". | ||
| 3502 | ** </table> | 3515 | ** </table> |
| 3503 | ** | 3516 | ** |
| 3504 | ** ^URI hexadecimal escape sequences (%HH) are supported within the path and | 3517 | ** ^URI hexadecimal escape sequences (%HH) are supported within the path and |
| @@ -3697,7 +3710,7 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*); | |||
| 3697 | ** If the Y parameter to sqlite3_free_filename(Y) is anything other | 3710 | ** If the Y parameter to sqlite3_free_filename(Y) is anything other |
| 3698 | ** than a NULL pointer or a pointer previously acquired from | 3711 | ** than a NULL pointer or a pointer previously acquired from |
| 3699 | ** sqlite3_create_filename(), then bad things such as heap | 3712 | ** sqlite3_create_filename(), then bad things such as heap |
| 3700 | ** corruption or segfaults may occur. The value Y should be | 3713 | ** corruption or segfaults may occur. The value Y should not be |
| 3701 | ** used again after sqlite3_free_filename(Y) has been called. This means | 3714 | ** used again after sqlite3_free_filename(Y) has been called. This means |
| 3702 | ** that if the [sqlite3_vfs.xOpen()] method of a VFS has been called using Y, | 3715 | ** that if the [sqlite3_vfs.xOpen()] method of a VFS has been called using Y, |
| 3703 | ** then the corresponding [sqlite3_module.xClose() method should also be | 3716 | ** then the corresponding [sqlite3_module.xClose() method should also be |
| @@ -7765,7 +7778,8 @@ SQLITE_API int sqlite3_test_control(int op, ...); | |||
| 7765 | #define SQLITE_TESTCTRL_PRNG_SEED 28 | 7778 | #define SQLITE_TESTCTRL_PRNG_SEED 28 |
| 7766 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 | 7779 | #define SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS 29 |
| 7767 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 | 7780 | #define SQLITE_TESTCTRL_SEEK_COUNT 30 |
| 7768 | #define SQLITE_TESTCTRL_LAST 30 /* Largest TESTCTRL */ | 7781 | #define SQLITE_TESTCTRL_TRACEFLAGS 31 |
| 7782 | #define SQLITE_TESTCTRL_LAST 31 /* Largest TESTCTRL */ | ||
| 7769 | 7783 | ||
| 7770 | /* | 7784 | /* |
| 7771 | ** CAPI3REF: SQL Keyword Checking | 7785 | ** CAPI3REF: SQL Keyword Checking |
| @@ -10439,6 +10453,14 @@ SQLITE_API int sqlite3session_patchset( | |||
| 10439 | SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); | 10453 | SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); |
| 10440 | 10454 | ||
| 10441 | /* | 10455 | /* |
| 10456 | ** CAPI3REF: Query for the amount of heap memory used by a session object. | ||
| 10457 | ** | ||
| 10458 | ** This API returns the total amount of heap memory in bytes currently | ||
| 10459 | ** used by the session object passed as the only argument. | ||
| 10460 | */ | ||
| 10461 | SQLITE_API sqlite3_int64 sqlite3session_memory_used(sqlite3_session *pSession); | ||
| 10462 | |||
| 10463 | /* | ||
| 10442 | ** CAPI3REF: Create An Iterator To Traverse A Changeset | 10464 | ** CAPI3REF: Create An Iterator To Traverse A Changeset |
| 10443 | ** CONSTRUCTOR: sqlite3_changeset_iter | 10465 | ** CONSTRUCTOR: sqlite3_changeset_iter |
| 10444 | ** | 10466 | ** |
| @@ -10540,18 +10562,23 @@ SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter); | |||
| 10540 | ** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this | 10562 | ** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this |
| 10541 | ** is not the case, this function returns [SQLITE_MISUSE]. | 10563 | ** is not the case, this function returns [SQLITE_MISUSE]. |
| 10542 | ** | 10564 | ** |
| 10543 | ** If argument pzTab is not NULL, then *pzTab is set to point to a | 10565 | ** Arguments pOp, pnCol and pzTab may not be NULL. Upon return, three |
| 10544 | ** nul-terminated utf-8 encoded string containing the name of the table | 10566 | ** outputs are set through these pointers: |
| 10545 | ** affected by the current change. The buffer remains valid until either | 10567 | ** |
| 10546 | ** sqlite3changeset_next() is called on the iterator or until the | 10568 | ** *pOp is set to one of [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], |
| 10547 | ** conflict-handler function returns. If pnCol is not NULL, then *pnCol is | 10569 | ** depending on the type of change that the iterator currently points to; |
| 10548 | ** set to the number of columns in the table affected by the change. If | 10570 | ** |
| 10549 | ** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change | 10571 | ** *pnCol is set to the number of columns in the table affected by the change; and |
| 10572 | ** | ||
| 10573 | ** *pzTab is set to point to a nul-terminated utf-8 encoded string containing | ||
| 10574 | ** the name of the table affected by the current change. The buffer remains | ||
| 10575 | ** valid until either sqlite3changeset_next() is called on the iterator | ||
| 10576 | ** or until the conflict-handler function returns. | ||
| 10577 | ** | ||
| 10578 | ** If pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change | ||
| 10550 | ** is an indirect change, or false (0) otherwise. See the documentation for | 10579 | ** is an indirect change, or false (0) otherwise. See the documentation for |
| 10551 | ** [sqlite3session_indirect()] for a description of direct and indirect | 10580 | ** [sqlite3session_indirect()] for a description of direct and indirect |
| 10552 | ** changes. Finally, if pOp is not NULL, then *pOp is set to one of | 10581 | ** changes. |
| 10553 | ** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the | ||
| 10554 | ** type of change that the iterator currently points to. | ||
| 10555 | ** | 10582 | ** |
| 10556 | ** If no error occurs, SQLITE_OK is returned. If an error does occur, an | 10583 | ** If no error occurs, SQLITE_OK is returned. If an error does occur, an |
| 10557 | ** SQLite error code is returned. The values of the output variables may not | 10584 | ** SQLite error code is returned. The values of the output variables may not |