Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add test case for fuzzing upsert. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
043843ec0a5d6c3c8303ce711aaad288 |
User & Date: | drh 2018-04-23 12:24:50.437 |
Context
2018-04-23
| ||
13:50 | Update SQLite. Add the enhanced SQL dictionary. check-in: 3b6d8668ed user: drh tags: trunk | |
12:24 | Add test case for fuzzing upsert. check-in: 043843ec0a user: drh tags: trunk | |
2018-03-22
| ||
11:28 | Add support for optfuzz. check-in: 876389a99e user: drh tags: trunk | |
Changes
Added run-upsert.sh.
> > > | 1 2 3 | export set AFL_SKIP_CPUFREQ=1 ../afl-fuzz -i upsert-cases -o upsert-out -T upsert \ -x ../dictionaries/sql.dict -- ./fuzzershell |
Changes to sqlite3.c.
1 2 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite | | | 1 2 3 4 5 6 7 8 9 10 | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite ** version 3.24.0. By combining all the individual C code files into this ** single large file, the entire code can be compiled as a single translation ** unit. This allows many compilers to do optimizations that would not be ** possible if the files were compiled separately. Performance improvements ** of 5% or more are commonly seen when SQLite is compiled as a single ** translation unit. ** ** This file is all you need to compile SQLite. To use SQLite in other |
︙ | ︙ | |||
306 307 308 309 310 311 312 313 314 315 316 317 318 319 | "ENABLE_SELECTTRACE", #endif #if SQLITE_ENABLE_SESSION "ENABLE_SESSION", #endif #if SQLITE_ENABLE_SNAPSHOT "ENABLE_SNAPSHOT", #endif #if SQLITE_ENABLE_SQLLOG "ENABLE_SQLLOG", #endif #if defined(SQLITE_ENABLE_STAT4) "ENABLE_STAT4", #elif defined(SQLITE_ENABLE_STAT3) | > > > | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | "ENABLE_SELECTTRACE", #endif #if SQLITE_ENABLE_SESSION "ENABLE_SESSION", #endif #if SQLITE_ENABLE_SNAPSHOT "ENABLE_SNAPSHOT", #endif #if SQLITE_ENABLE_SORTER_REFERENCES "ENABLE_SORTER_REFERENCES", #endif #if SQLITE_ENABLE_SQLLOG "ENABLE_SQLLOG", #endif #if defined(SQLITE_ENABLE_STAT4) "ENABLE_STAT4", #elif defined(SQLITE_ENABLE_STAT3) |
︙ | ︙ | |||
1143 1144 1145 1146 1147 1148 1149 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | | 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.24.0" #define SQLITE_VERSION_NUMBER 3024000 #define SQLITE_SOURCE_ID "2018-04-23 00:25:31 e3064ba3b68ca2a1c54561756e8c898866a19ef6e785d315171cd47827a50c85" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
︙ | ︙ | |||
2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 | ** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. ** ^This file control takes the file descriptor out of batch write mode ** so that all subsequent write operations are independent. ** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 | > > > > > > | 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 | ** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. ** ^This file control takes the file descriptor out of batch write mode ** so that all subsequent write operations are independent. ** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** ** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]] ** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain ** a file lock using the xLock or xShmLock methods of the VFS to wait ** for up to M milliseconds before failing, where M is the single ** unsigned integer parameter. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 |
︙ | ︙ | |||
2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 | #define SQLITE_FCNTL_VFS_POINTER 27 #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO | > | 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 | #define SQLITE_FCNTL_VFS_POINTER 27 #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 #define SQLITE_FCNTL_LOCK_TIMEOUT 34 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
︙ | ︙ | |||
2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 | ** Or if the threshold is -1, statement journals are always held ** exclusively in memory. ** Since many statement journals never become large, setting the spill ** threshold to a value such as 64KiB can greatly reduce the amount of ** I/O required to support statement rollback. ** The default value for this setting is controlled by the ** [SQLITE_STMTJRNL_SPILL] compile-time option. ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ | > > > > > > > > > > > > > > > > | 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 | ** Or if the threshold is -1, statement journals are always held ** exclusively in memory. ** Since many statement journals never become large, setting the spill ** threshold to a value such as 64KiB can greatly reduce the amount of ** I/O required to support statement rollback. ** The default value for this setting is controlled by the ** [SQLITE_STMTJRNL_SPILL] compile-time option. ** ** [[SQLITE_CONFIG_SORTERREF_SIZE]] ** <dt>SQLITE_CONFIG_SORTERREF_SIZE ** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter ** of type (int) - the new value of the sorter-reference size threshold. ** Usually, when SQLite uses an external sort to order records according ** to an ORDER BY clause, all fields required by the caller are present in the ** sorted records. However, if SQLite determines based on the declared type ** of a table column that its values are likely to be very large - larger ** than the configured sorter-reference size threshold - then a reference ** is stored in each sorted record and the required column values loaded ** from the database as records are returned in sorted order. The default ** value for this option is to never use this optimization. Specifying a ** negative value for this option restores the default behaviour. ** This option is only available if SQLite is compiled with the ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ |
︙ | ︙ | |||
2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 | #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** | > | 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 | #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** |
︙ | ︙ | |||
9831 9832 9833 9834 9835 9836 9837 | */ #define SQLITE_SERIALIZE_NOCOPY 0x001 /* Do no memory allocations */ /* ** CAPI3REF: Deserialize a database ** ** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the | | | 9858 9859 9860 9861 9862 9863 9864 9865 9866 9867 9868 9869 9870 9871 9872 | */ #define SQLITE_SERIALIZE_NOCOPY 0x001 /* Do no memory allocations */ /* ** CAPI3REF: Deserialize a database ** ** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the ** [database connection] D to disconnect from database S and then ** reopen S as an in-memory database based on the serialization contained ** in P. The serialized database P is N bytes in size. M is the size of ** the buffer P, which might be larger than N. If M is larger than N, and ** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is ** permitted to add content to the in-memory database as long as the total ** size does not exceed M bytes. ** |
︙ | ︙ | |||
10972 10973 10974 10975 10976 10977 10978 | ** DESTRUCTOR: sqlite3_changegroup */ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); /* ** CAPI3REF: Apply A Changeset To A Database ** | | | | | | | | | < | 10999 11000 11001 11002 11003 11004 11005 11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 | ** DESTRUCTOR: sqlite3_changegroup */ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); /* ** CAPI3REF: Apply A Changeset To A Database ** ** Apply a changeset or patchset to a database. These functions attempt to ** update the "main" database attached to handle db with the changes found in ** the changeset passed via the second and third arguments. ** ** The fourth argument (xFilter) passed to these functions is the "filter ** callback". If it is not NULL, then for each table affected by at least one ** change in the changeset, the filter callback is invoked with ** the table name as the second argument, and a copy of the context pointer ** passed as the sixth argument as the first. If the "filter callback" ** returns zero, then no attempt is made to apply any changes to the table. ** Otherwise, if the return value is non-zero or the xFilter argument to ** is NULL, all changes related to the table are attempted. ** ** For each table that is not excluded by the filter callback, this function ** tests that the target database contains a compatible table. A table is ** considered compatible if all of the following are true: ** ** <ul> ** <li> The table has the same name as the name recorded in the |
︙ | ︙ | |||
11029 11030 11031 11032 11033 11034 11035 | ** actions are taken by sqlite3changeset_apply() depending on the value ** returned by each invocation of the conflict-handler function. Refer to ** the documentation for the three ** [SQLITE_CHANGESET_OMIT|available return values] for details. ** ** <dl> ** <dt>DELETE Changes<dd> | | | 11055 11056 11057 11058 11059 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 | ** actions are taken by sqlite3changeset_apply() depending on the value ** returned by each invocation of the conflict-handler function. Refer to ** the documentation for the three ** [SQLITE_CHANGESET_OMIT|available return values] for details. ** ** <dl> ** <dt>DELETE Changes<dd> ** For each DELETE change, the function checks if the target database ** contains a row with the same primary key value (or values) as the ** original row values stored in the changeset. If it does, and the values ** stored in all non-primary key columns also match the values stored in ** the changeset the row is deleted from the target database. ** ** If a row with matching primary key values is found, but one or more of ** the non-primary key fields contains a value different from the original |
︙ | ︙ | |||
11074 11075 11076 11077 11078 11079 11080 | ** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is ** invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT]. ** This includes the case where the INSERT operation is re-attempted because ** an earlier call to the conflict handler function returned ** [SQLITE_CHANGESET_REPLACE]. ** ** <dt>UPDATE Changes<dd> | | | 11100 11101 11102 11103 11104 11105 11106 11107 11108 11109 11110 11111 11112 11113 11114 | ** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is ** invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT]. ** This includes the case where the INSERT operation is re-attempted because ** an earlier call to the conflict handler function returned ** [SQLITE_CHANGESET_REPLACE]. ** ** <dt>UPDATE Changes<dd> ** For each UPDATE change, the function checks if the target database ** contains a row with the same primary key value (or values) as the ** original row values stored in the changeset. If it does, and the values ** stored in all modified non-primary key columns also match the values ** stored in the changeset the row is updated within the target database. ** ** If a row with matching primary key values is found, but one or more of ** the modified non-primary key fields contains a value different from an |
︙ | ︙ | |||
11105 11106 11107 11108 11109 11110 11111 | ** </dl> ** ** It is safe to execute SQL statements, including those that write to the ** table that the callback related to, from within the xConflict callback. ** This can be used to further customize the applications conflict ** resolution strategy. ** | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 11131 11132 11133 11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 11153 11154 11155 11156 11157 11158 11159 11160 11161 11162 11163 11164 11165 11166 11167 11168 11169 11170 11171 11172 11173 11174 11175 11176 11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 11217 | ** </dl> ** ** It is safe to execute SQL statements, including those that write to the ** table that the callback related to, from within the xConflict callback. ** This can be used to further customize the applications conflict ** resolution strategy. ** ** All changes made by these functions are enclosed in a savepoint transaction. ** If any other error (aside from a constraint failure when attempting to ** write to the target database) occurs, then the savepoint transaction is ** rolled back, restoring the target database to its original state, and an ** SQLite error code returned. ** ** If the output parameters (ppRebase) and (pnRebase) are non-NULL and ** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2() ** may set (*ppRebase) to point to a "rebase" that may be used with the ** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase) ** is set to the size of the buffer in bytes. It is the responsibility of the ** caller to eventually free any such buffer using sqlite3_free(). The buffer ** is only allocated and populated if one or more conflicts were encountered ** while applying the patchset. See comments surrounding the sqlite3_rebaser ** APIs for further details. ** ** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent ** may be modified by passing a combination of ** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter. ** ** Note that the sqlite3changeset_apply_v2() API is still <b>experimental</b> ** and therefore subject to change. */ SQLITE_API int sqlite3changeset_apply( sqlite3 *db, /* Apply change to "main" db of this handle */ int nChangeset, /* Size of changeset in bytes */ void *pChangeset, /* Changeset blob */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ); SQLITE_API int sqlite3changeset_apply_v2( sqlite3 *db, /* Apply change to "main" db of this handle */ int nChangeset, /* Size of changeset in bytes */ void *pChangeset, /* Changeset blob */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx, /* First argument passed to xConflict */ void **ppRebase, int *pnRebase, /* OUT: Rebase data */ int flags /* Combination of SESSION_APPLY_* flags */ ); /* ** CAPI3REF: Flags for sqlite3changeset_apply_v2 ** ** The following flags may passed via the 9th parameter to ** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]: ** ** <dl> ** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd> ** Usually, the sessions module encloses all operations performed by ** a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The ** SAVEPOINT is committed if the changeset or patchset is successfully ** applied, or rolled back if an error occurs. Specifying this flag ** causes the sessions module to omit this savepoint. In this case, if the ** caller has an open transaction or savepoint when apply_v2() is called, ** it may revert the partially applied changeset by rolling it back. */ #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 /* ** CAPI3REF: Constants Passed To The Conflict Handler ** ** Values that may be passed as the second argument to a conflict-handler. ** ** <dl> |
︙ | ︙ | |||
11223 11224 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 | ** and the call to sqlite3changeset_apply() returns SQLITE_ABORT. ** </dl> */ #define SQLITE_CHANGESET_OMIT 0 #define SQLITE_CHANGESET_REPLACE 1 #define SQLITE_CHANGESET_ABORT 2 /* ** CAPI3REF: Streaming Versions of API functions. ** ** The six streaming API xxx_strm() functions serve similar purposes to the ** corresponding non-streaming API functions: ** ** <table border=1 style="margin-left:8ex;margin-right:8ex"> ** <tr><th>Streaming function<th>Non-streaming equivalent</th> ** <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] ** <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] ** <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] ** <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] ** <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] ** <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] ** </table> ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 11301 11302 11303 11304 11305 11306 11307 11308 11309 11310 11311 11312 11313 11314 11315 11316 11317 11318 11319 11320 11321 11322 11323 11324 11325 11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 11359 11360 11361 11362 11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 11377 11378 11379 11380 11381 11382 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 11414 11415 11416 11417 11418 11419 11420 11421 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 | ** and the call to sqlite3changeset_apply() returns SQLITE_ABORT. ** </dl> */ #define SQLITE_CHANGESET_OMIT 0 #define SQLITE_CHANGESET_REPLACE 1 #define SQLITE_CHANGESET_ABORT 2 /* ** CAPI3REF: Rebasing changesets ** EXPERIMENTAL ** ** Suppose there is a site hosting a database in state S0. And that ** modifications are made that move that database to state S1 and a ** changeset recorded (the "local" changeset). Then, a changeset based ** on S0 is received from another site (the "remote" changeset) and ** applied to the database. The database is then in state ** (S1+"remote"), where the exact state depends on any conflict ** resolution decisions (OMIT or REPLACE) made while applying "remote". ** Rebasing a changeset is to update it to take those conflict ** resolution decisions into account, so that the same conflicts ** do not have to be resolved elsewhere in the network. ** ** For example, if both the local and remote changesets contain an ** INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)": ** ** local: INSERT INTO t1 VALUES(1, 'v1'); ** remote: INSERT INTO t1 VALUES(1, 'v2'); ** ** and the conflict resolution is REPLACE, then the INSERT change is ** removed from the local changeset (it was overridden). Or, if the ** conflict resolution was "OMIT", then the local changeset is modified ** to instead contain: ** ** UPDATE t1 SET b = 'v2' WHERE a=1; ** ** Changes within the local changeset are rebased as follows: ** ** <dl> ** <dt>Local INSERT<dd> ** This may only conflict with a remote INSERT. If the conflict ** resolution was OMIT, then add an UPDATE change to the rebased ** changeset. Or, if the conflict resolution was REPLACE, add ** nothing to the rebased changeset. ** ** <dt>Local DELETE<dd> ** This may conflict with a remote UPDATE or DELETE. In both cases the ** only possible resolution is OMIT. If the remote operation was a ** DELETE, then add no change to the rebased changeset. If the remote ** operation was an UPDATE, then the old.* fields of change are updated ** to reflect the new.* values in the UPDATE. ** ** <dt>Local UPDATE<dd> ** This may conflict with a remote UPDATE or DELETE. If it conflicts ** with a DELETE, and the conflict resolution was OMIT, then the update ** is changed into an INSERT. Any undefined values in the new.* record ** from the update change are filled in using the old.* values from ** the conflicting DELETE. Or, if the conflict resolution was REPLACE, ** the UPDATE change is simply omitted from the rebased changeset. ** ** If conflict is with a remote UPDATE and the resolution is OMIT, then ** the old.* values are rebased using the new.* values in the remote ** change. Or, if the resolution is REPLACE, then the change is copied ** into the rebased changeset with updates to columns also updated by ** the conflicting remote UPDATE removed. If this means no columns would ** be updated, the change is omitted. ** </dl> ** ** A local change may be rebased against multiple remote changes ** simultaneously. If a single key is modified by multiple remote ** changesets, they are combined as follows before the local changeset ** is rebased: ** ** <ul> ** <li> If there has been one or more REPLACE resolutions on a ** key, it is rebased according to a REPLACE. ** ** <li> If there have been no REPLACE resolutions on a key, then ** the local changeset is rebased according to the most recent ** of the OMIT resolutions. ** </ul> ** ** Note that conflict resolutions from multiple remote changesets are ** combined on a per-field basis, not per-row. This means that in the ** case of multiple remote UPDATE operations, some fields of a single ** local change may be rebased for REPLACE while others are rebased for ** OMIT. ** ** In order to rebase a local changeset, the remote changeset must first ** be applied to the local database using sqlite3changeset_apply_v2() and ** the buffer of rebase information captured. Then: ** ** <ol> ** <li> An sqlite3_rebaser object is created by calling ** sqlite3rebaser_create(). ** <li> The new object is configured with the rebase buffer obtained from ** sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure(). ** If the local changeset is to be rebased against multiple remote ** changesets, then sqlite3rebaser_configure() should be called ** multiple times, in the same order that the multiple ** sqlite3changeset_apply_v2() calls were made. ** <li> Each local changeset is rebased by calling sqlite3rebaser_rebase(). ** <li> The sqlite3_rebaser object is deleted by calling ** sqlite3rebaser_delete(). ** </ol> */ typedef struct sqlite3_rebaser sqlite3_rebaser; /* ** CAPI3REF: Create a changeset rebaser object. ** EXPERIMENTAL ** ** Allocate a new changeset rebaser object. If successful, set (*ppNew) to ** point to the new object and return SQLITE_OK. Otherwise, if an error ** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) ** to NULL. */ SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew); /* ** CAPI3REF: Configure a changeset rebaser object. ** EXPERIMENTAL ** ** Configure the changeset rebaser object to rebase changesets according ** to the conflict resolutions described by buffer pRebase (size nRebase ** bytes), which must have been obtained from a previous call to ** sqlite3changeset_apply_v2(). */ SQLITE_API int sqlite3rebaser_configure( sqlite3_rebaser*, int nRebase, const void *pRebase ); /* ** CAPI3REF: Rebase a changeset ** EXPERIMENTAL ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy ** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) ** is set to point to the new buffer containing the rebased changset and ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the ** responsibility of the caller to eventually free the new buffer using ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut) ** are set to zero and an SQLite error code returned. */ SQLITE_API int sqlite3rebaser_rebase( sqlite3_rebaser*, int nIn, const void *pIn, int *pnOut, void **ppOut ); /* ** CAPI3REF: Delete a changeset rebaser object. ** EXPERIMENTAL ** ** Delete the changeset rebaser object and all associated resources. There ** should be one call to this function for each successful invocation ** of sqlite3rebaser_create(). */ SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); /* ** CAPI3REF: Streaming Versions of API functions. ** ** The six streaming API xxx_strm() functions serve similar purposes to the ** corresponding non-streaming API functions: ** ** <table border=1 style="margin-left:8ex;margin-right:8ex"> ** <tr><th>Streaming function<th>Non-streaming equivalent</th> ** <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] ** <tr><td>sqlite3changeset_apply_strm_v2<td>[sqlite3changeset_apply_v2] ** <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] ** <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] ** <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] ** <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] ** <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] ** </table> ** |
︙ | ︙ | |||
11326 11327 11328 11329 11330 11331 11332 11333 11334 11335 11336 11337 11338 11339 | ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ); SQLITE_API int sqlite3changeset_concat_strm( int (*xInputA)(void *pIn, void *pData, int *pnData), void *pInA, int (*xInputB)(void *pIn, void *pData, int *pnData), void *pInB, int (*xOutput)(void *pOut, const void *pData, int nData), | > > > > > > > > > > > > > > > > > | 11560 11561 11562 11563 11564 11565 11566 11567 11568 11569 11570 11571 11572 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 11588 11589 11590 | ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ); SQLITE_API int sqlite3changeset_apply_v2_strm( sqlite3 *db, /* Apply change to "main" db of this handle */ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ void *pIn, /* First arg for xInput */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx, /* First argument passed to xConflict */ void **ppRebase, int *pnRebase, int flags ); SQLITE_API int sqlite3changeset_concat_strm( int (*xInputA)(void *pIn, void *pData, int *pnData), void *pInA, int (*xInputB)(void *pIn, void *pData, int *pnData), void *pInB, int (*xOutput)(void *pOut, const void *pData, int nData), |
︙ | ︙ | |||
11363 11364 11365 11366 11367 11368 11369 11370 11371 11372 11373 11374 11375 11376 | SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, int (*xInput)(void *pIn, void *pData, int *pnData), void *pIn ); SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ); /* ** Make sure we can call this stuff from C++. */ #if 0 | > > > > > > > | 11614 11615 11616 11617 11618 11619 11620 11621 11622 11623 11624 11625 11626 11627 11628 11629 11630 11631 11632 11633 11634 | SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, int (*xInput)(void *pIn, void *pData, int *pnData), void *pIn ); SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ); SQLITE_API int sqlite3rebaser_rebase_strm( sqlite3_rebaser *pRebaser, int (*xInput)(void *pIn, void *pData, int *pnData), void *pIn, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ); /* ** Make sure we can call this stuff from C++. */ #if 0 |
︙ | ︙ | |||
12699 12700 12701 12702 12703 12704 12705 | #define TK_GT 54 #define TK_LE 55 #define TK_LT 56 #define TK_GE 57 #define TK_ESCAPE 58 #define TK_ID 59 #define TK_COLUMNKW 60 | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 12957 12958 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 12974 12975 12976 12977 12978 12979 12980 12981 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 12997 12998 12999 13000 13001 13002 13003 13004 13005 13006 13007 13008 13009 13010 13011 13012 13013 13014 13015 13016 13017 13018 13019 13020 13021 13022 13023 13024 13025 13026 13027 13028 13029 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 | #define TK_GT 54 #define TK_LE 55 #define TK_LT 56 #define TK_GE 57 #define TK_ESCAPE 58 #define TK_ID 59 #define TK_COLUMNKW 60 #define TK_DO 61 #define TK_FOR 62 #define TK_IGNORE 63 #define TK_INITIALLY 64 #define TK_INSTEAD 65 #define TK_NO 66 #define TK_KEY 67 #define TK_OF 68 #define TK_OFFSET 69 #define TK_PRAGMA 70 #define TK_RAISE 71 #define TK_RECURSIVE 72 #define TK_REPLACE 73 #define TK_RESTRICT 74 #define TK_ROW 75 #define TK_TRIGGER 76 #define TK_VACUUM 77 #define TK_VIEW 78 #define TK_VIRTUAL 79 #define TK_WITH 80 #define TK_REINDEX 81 #define TK_RENAME 82 #define TK_CTIME_KW 83 #define TK_ANY 84 #define TK_BITAND 85 #define TK_BITOR 86 #define TK_LSHIFT 87 #define TK_RSHIFT 88 #define TK_PLUS 89 #define TK_MINUS 90 #define TK_STAR 91 #define TK_SLASH 92 #define TK_REM 93 #define TK_CONCAT 94 #define TK_COLLATE 95 #define TK_BITNOT 96 #define TK_ON 97 #define TK_INDEXED 98 #define TK_STRING 99 #define TK_JOIN_KW 100 #define TK_CONSTRAINT 101 #define TK_DEFAULT 102 #define TK_NULL 103 #define TK_PRIMARY 104 #define TK_UNIQUE 105 #define TK_CHECK 106 #define TK_REFERENCES 107 #define TK_AUTOINCR 108 #define TK_INSERT 109 #define TK_DELETE 110 #define TK_UPDATE 111 #define TK_SET 112 #define TK_DEFERRABLE 113 #define TK_FOREIGN 114 #define TK_DROP 115 #define TK_UNION 116 #define TK_ALL 117 #define TK_EXCEPT 118 #define TK_INTERSECT 119 #define TK_SELECT 120 #define TK_VALUES 121 #define TK_DISTINCT 122 #define TK_DOT 123 #define TK_FROM 124 #define TK_JOIN 125 #define TK_USING 126 #define TK_ORDER 127 #define TK_GROUP 128 #define TK_HAVING 129 #define TK_LIMIT 130 #define TK_WHERE 131 #define TK_INTO 132 #define TK_NOTHING 133 #define TK_FLOAT 134 #define TK_BLOB 135 #define TK_INTEGER 136 #define TK_VARIABLE 137 #define TK_CASE 138 #define TK_WHEN 139 #define TK_THEN 140 #define TK_ELSE 141 #define TK_INDEX 142 #define TK_ALTER 143 #define TK_ADD 144 #define TK_TRUEFALSE 145 #define TK_ISNOT 146 #define TK_FUNCTION 147 #define TK_COLUMN 148 #define TK_AGG_FUNCTION 149 #define TK_AGG_COLUMN 150 #define TK_UMINUS 151 #define TK_UPLUS 152 #define TK_TRUTH 153 #define TK_REGISTER 154 #define TK_VECTOR 155 #define TK_SELECT_COLUMN 156 #define TK_IF_NULL_ROW 157 #define TK_ASTERISK 158 #define TK_SPAN 159 #define TK_END_OF_FILE 160 #define TK_UNCLOSED_STRING 161 #define TK_SPACE 162 #define TK_ILLEGAL 163 /* The token codes above must all fit in 8 bits */ #define TKFLG_MASK 0xff /* Flags that can be added to a token code when it is not ** being stored in a u8: */ #define TKFLG_DONTFOLD 0x100 /* Omit constant folding optimizations */ |
︙ | ︙ | |||
12919 12920 12921 12922 12923 12924 12925 12926 12927 12928 12929 12930 12931 12932 | ** The default value of "20" was choosen to minimize the run-time of the ** speedtest1 test program with options: --shrink-memory --reprepare */ #ifndef SQLITE_DEFAULT_PCACHE_INITSZ # define SQLITE_DEFAULT_PCACHE_INITSZ 20 #endif /* ** The compile-time options SQLITE_MMAP_READWRITE and ** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another. ** You must choose one or the other (or neither) but not both. */ #if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) #error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE | > > > > > > > | 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 13193 13194 13195 13196 13197 13198 13199 | ** The default value of "20" was choosen to minimize the run-time of the ** speedtest1 test program with options: --shrink-memory --reprepare */ #ifndef SQLITE_DEFAULT_PCACHE_INITSZ # define SQLITE_DEFAULT_PCACHE_INITSZ 20 #endif /* ** Default value for the SQLITE_CONFIG_SORTERREF_SIZE option. */ #ifndef SQLITE_DEFAULT_SORTERREF_SIZE # define SQLITE_DEFAULT_SORTERREF_SIZE 0x7fffffff #endif /* ** The compile-time options SQLITE_MMAP_READWRITE and ** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another. ** You must choose one or the other (or neither) but not both. */ #if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) #error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE |
︙ | ︙ | |||
13243 13244 13245 13246 13247 13248 13249 | ** The sqlite.busyHandler member of the sqlite struct contains the busy ** callback for the database handle. Each pager opened via the sqlite ** handle is passed a pointer to sqlite.busyHandler. The busy-handler ** callback is currently invoked only from within pager.c. */ typedef struct BusyHandler BusyHandler; struct BusyHandler { | | | | > | 13510 13511 13512 13513 13514 13515 13516 13517 13518 13519 13520 13521 13522 13523 13524 13525 13526 13527 | ** The sqlite.busyHandler member of the sqlite struct contains the busy ** callback for the database handle. Each pager opened via the sqlite ** handle is passed a pointer to sqlite.busyHandler. The busy-handler ** callback is currently invoked only from within pager.c. */ typedef struct BusyHandler BusyHandler; struct BusyHandler { int (*xBusyHandler)(void *,int); /* The busy callback */ void *pBusyArg; /* First arg to busy callback */ int nBusy; /* Incremented with each busy call */ u8 bExtraFileArg; /* Include sqlite3_file as callback arg */ }; /* ** Name of the master database table. The master database table ** is a special table that holds the names and attributes of all ** user tables and indices. */ |
︙ | ︙ | |||
13376 13377 13378 13379 13380 13381 13382 13383 13384 13385 13386 13387 13388 13389 | typedef struct TableLock TableLock; typedef struct Token Token; typedef struct TreeView TreeView; typedef struct Trigger Trigger; typedef struct TriggerPrg TriggerPrg; typedef struct TriggerStep TriggerStep; typedef struct UnpackedRecord UnpackedRecord; typedef struct VTable VTable; typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WhereInfo WhereInfo; typedef struct With With; /* A VList object records a mapping between parameters/variables/wildcards | > | 13644 13645 13646 13647 13648 13649 13650 13651 13652 13653 13654 13655 13656 13657 13658 | typedef struct TableLock TableLock; typedef struct Token Token; typedef struct TreeView TreeView; typedef struct Trigger Trigger; typedef struct TriggerPrg TriggerPrg; typedef struct TriggerStep TriggerStep; typedef struct UnpackedRecord UnpackedRecord; typedef struct Upsert Upsert; typedef struct VTable VTable; typedef struct VtabCtx VtabCtx; typedef struct Walker Walker; typedef struct WhereInfo WhereInfo; typedef struct With With; /* A VList object records a mapping between parameters/variables/wildcards |
︙ | ︙ | |||
14033 14034 14035 14036 14037 14038 14039 | #define OP_IntCopy 77 /* synopsis: r[P2]=r[P1] */ #define OP_ResultRow 78 /* synopsis: output=r[P1@P2] */ #define OP_CollSeq 79 #define OP_AddImm 80 /* synopsis: r[P1]=r[P1]+P2 */ #define OP_RealAffinity 81 #define OP_Cast 82 /* synopsis: affinity(r[P1]) */ #define OP_Permutation 83 | > | | | | | | | | | | < < | | | | > | 14302 14303 14304 14305 14306 14307 14308 14309 14310 14311 14312 14313 14314 14315 14316 14317 14318 14319 14320 14321 14322 14323 14324 14325 14326 14327 14328 14329 14330 14331 | #define OP_IntCopy 77 /* synopsis: r[P2]=r[P1] */ #define OP_ResultRow 78 /* synopsis: output=r[P1@P2] */ #define OP_CollSeq 79 #define OP_AddImm 80 /* synopsis: r[P1]=r[P1]+P2 */ #define OP_RealAffinity 81 #define OP_Cast 82 /* synopsis: affinity(r[P1]) */ #define OP_Permutation 83 #define OP_Compare 84 /* synopsis: r[P1@P3] <-> r[P2@P3] */ #define OP_BitAnd 85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ #define OP_BitOr 86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ #define OP_ShiftLeft 87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ #define OP_ShiftRight 88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ #define OP_Add 89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ #define OP_Subtract 90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ #define OP_Multiply 91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ #define OP_Divide 92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ #define OP_Remainder 93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ #define OP_Concat 94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ #define OP_IsTrue 95 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ #define OP_BitNot 96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ #define OP_Offset 97 /* synopsis: r[P3] = sqlite_offset(P1) */ #define OP_Column 98 /* synopsis: r[P3]=PX */ #define OP_String8 99 /* same as TK_STRING, synopsis: r[P2]='P4' */ #define OP_Affinity 100 /* synopsis: affinity(r[P1@P2]) */ #define OP_MakeRecord 101 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ #define OP_Count 102 /* synopsis: r[P2]=count() */ #define OP_ReadCookie 103 #define OP_SetCookie 104 #define OP_ReopenIdx 105 /* synopsis: root=P2 iDb=P3 */ #define OP_OpenRead 106 /* synopsis: root=P2 iDb=P3 */ |
︙ | ︙ | |||
14081 14082 14083 14084 14085 14086 14087 | #define OP_Rowid 125 /* synopsis: r[P2]=rowid */ #define OP_NullRow 126 #define OP_SeekEnd 127 #define OP_SorterInsert 128 /* synopsis: key=r[P2] */ #define OP_IdxInsert 129 /* synopsis: key=r[P2] */ #define OP_IdxDelete 130 /* synopsis: key=r[P2@P3] */ #define OP_DeferredSeek 131 /* synopsis: Move P3 to P1.rowid if needed */ | < | | > | 14350 14351 14352 14353 14354 14355 14356 14357 14358 14359 14360 14361 14362 14363 14364 14365 14366 | #define OP_Rowid 125 /* synopsis: r[P2]=rowid */ #define OP_NullRow 126 #define OP_SeekEnd 127 #define OP_SorterInsert 128 /* synopsis: key=r[P2] */ #define OP_IdxInsert 129 /* synopsis: key=r[P2] */ #define OP_IdxDelete 130 /* synopsis: key=r[P2@P3] */ #define OP_DeferredSeek 131 /* synopsis: Move P3 to P1.rowid if needed */ #define OP_IdxRowid 132 /* synopsis: r[P2]=rowid */ #define OP_Destroy 133 #define OP_Real 134 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ #define OP_Clear 135 #define OP_ResetSorter 136 #define OP_CreateBtree 137 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ #define OP_SqlExec 138 #define OP_ParseSchema 139 #define OP_LoadAnalysis 140 #define OP_DropTable 141 |
︙ | ︙ | |||
14142 14143 14144 14145 14146 14147 14148 | /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\ /* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ /* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\ /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\ /* 64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\ /* 72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ | | | | | 14411 14412 14413 14414 14415 14416 14417 14418 14419 14420 14421 14422 14423 14424 14425 14426 14427 | /* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\ /* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ /* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\ /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x02,\ /* 64 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\ /* 72 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ /* 80 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x26, 0x26, 0x26,\ /* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x12,\ /* 96 */ 0x12, 0x20, 0x00, 0x10, 0x00, 0x00, 0x10, 0x10,\ /* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 112 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\ /* 128 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\ /* 136 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ /* 144 */ 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00,\ /* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
︙ | ︙ | |||
14218 14219 14220 14221 14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 | SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*); SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*); SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int); SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*); #ifdef SQLITE_DEBUG SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int); #endif SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*); | > > > | 14487 14488 14489 14490 14491 14492 14493 14494 14495 14496 14497 14498 14499 14500 14501 14502 14503 | SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*); SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*); SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int); #ifdef SQLITE_COVERAGE_TEST SQLITE_PRIVATE int sqlite3VdbeLabelHasBeenResolved(Vdbe*,int); #endif SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*); #ifdef SQLITE_DEBUG SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int); #endif SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*); SQLITE_PRIVATE void sqlite3VdbeRewind(Vdbe*); SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*); |
︙ | ︙ | |||
14454 14455 14456 14457 14458 14459 14460 | int, void(*)(DbPage*) ); SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*); SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); /* Functions used to configure a Pager object. */ | | | 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 | int, void(*)(DbPage*) ); SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3*); SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); /* Functions used to configure a Pager object. */ SQLITE_PRIVATE void sqlite3PagerSetBusyHandler(Pager*, int(*)(void *), void *); SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u32*, int); #ifdef SQLITE_HAS_CODEC SQLITE_PRIVATE void sqlite3PagerAlignReserve(Pager*,Pager*); #endif SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int); SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int); SQLITE_PRIVATE int sqlite3PagerSetSpillsize(Pager*, int); |
︙ | ︙ | |||
14540 14541 14542 14543 14544 14545 14546 14547 14548 14549 14550 14551 14552 14553 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*); SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *); SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*); SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *); /* Functions used to truncate the database file. */ SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); SQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16); #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) | > > > > > | 14812 14813 14814 14815 14816 14817 14818 14819 14820 14821 14822 14823 14824 14825 14826 14827 14828 14829 14830 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*); SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *); SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*); SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *); #ifdef SQLITE_ENABLE_SETLK_TIMEOUT SQLITE_PRIVATE void sqlite3PagerResetLockTimeout(Pager *pPager); #else # define sqlite3PagerResetLockTimeout(X) #endif /* Functions used to truncate the database file. */ SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); SQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16); #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
︙ | ︙ | |||
15752 15753 15754 15755 15756 15757 15758 15759 15760 15761 15762 15763 15764 15765 | /* Allowed values for Column.colFlags: */ #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ #define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ #define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */ /* ** A "Collating Sequence" is defined by an instance of the following ** structure. Conceptually, a collating sequence consists of a name and ** a comparison routine that defines the order of that sequence. ** ** If CollSeq.xCmp is NULL, it means that the | > | 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 | /* Allowed values for Column.colFlags: */ #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ #define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ #define COLFLAG_UNIQUE 0x0008 /* Column def contains "UNIQUE" or "PK" */ #define COLFLAG_SORTERREF 0x0010 /* Use sorter-refs with this column */ /* ** A "Collating Sequence" is defined by an instance of the following ** structure. Conceptually, a collating sequence consists of a name and ** a comparison routine that defines the order of that sequence. ** ** If CollSeq.xCmp is NULL, it means that the |
︙ | ︙ | |||
16039 16040 16041 16042 16043 16044 16045 | */ #define OE_None 0 /* There is no constraint to check */ #define OE_Rollback 1 /* Fail the operation and rollback the transaction */ #define OE_Abort 2 /* Back out changes but do no rollback transaction */ #define OE_Fail 3 /* Stop the operation but leave all prior changes */ #define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ #define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ | | | | | | < | | 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 | */ #define OE_None 0 /* There is no constraint to check */ #define OE_Rollback 1 /* Fail the operation and rollback the transaction */ #define OE_Abort 2 /* Back out changes but do no rollback transaction */ #define OE_Fail 3 /* Stop the operation but leave all prior changes */ #define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ #define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ #define OE_Update 6 /* Process as a DO UPDATE in an upsert */ #define OE_Restrict 7 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ #define OE_SetNull 8 /* Set the foreign key value to NULL */ #define OE_SetDflt 9 /* Set the foreign key value to its default */ #define OE_Cascade 10 /* Cascade the changes */ #define OE_Default 11 /* Do whatever the default action is */ /* ** An instance of the following structure is passed as the first ** argument to sqlite3VdbeKeyCompare and is used to control the ** comparison of the two index keys. ** |
︙ | ︙ | |||
16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 | Expr *pExpr; /* The parse tree for this expression */ char *zName; /* Token associated with this expression */ char *zSpan; /* Original text of the expression */ u8 sortOrder; /* 1 for DESC or 0 for ASC */ unsigned done :1; /* A flag to indicate when processing is finished */ unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */ unsigned reusable :1; /* Constant expression is reusable */ union { struct { u16 iOrderByCol; /* For ORDER BY, column number in result set */ u16 iAlias; /* Index into Parse.aAlias[] for zName */ } x; int iConstExprReg; /* Register in which Expr value is cached */ } u; | > | 16769 16770 16771 16772 16773 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 | Expr *pExpr; /* The parse tree for this expression */ char *zName; /* Token associated with this expression */ char *zSpan; /* Original text of the expression */ u8 sortOrder; /* 1 for DESC or 0 for ASC */ unsigned done :1; /* A flag to indicate when processing is finished */ unsigned bSpanIsTab :1; /* zSpan holds DB.TABLE.COLUMN */ unsigned reusable :1; /* Constant expression is reusable */ unsigned bSorterRef :1; /* Defer evaluation until after sorting */ union { struct { u16 iOrderByCol; /* For ORDER BY, column number in result set */ u16 iAlias; /* Index into Parse.aAlias[] for zName */ } x; int iConstExprReg; /* Register in which Expr value is cached */ } u; |
︙ | ︙ | |||
16675 16676 16677 16678 16679 16680 16681 | ** NameContext in the parent query. Thus the process of scanning the ** NameContext list corresponds to searching through successively outer ** subqueries looking for a match. */ struct NameContext { Parse *pParse; /* The parser */ SrcList *pSrcList; /* One or more tables used to resolve names */ | > | | > > | 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 | ** NameContext in the parent query. Thus the process of scanning the ** NameContext list corresponds to searching through successively outer ** subqueries looking for a match. */ struct NameContext { Parse *pParse; /* The parser */ SrcList *pSrcList; /* One or more tables used to resolve names */ union { ExprList *pEList; /* Optional list of result-set columns */ AggInfo *pAggInfo; /* Information about aggregates at this level */ Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */ } uNC; NameContext *pNext; /* Next outer name context. NULL for outermost */ int nRef; /* Number of names resolved by this context */ int nErr; /* Number of errors encountered while resolving names */ u16 ncFlags; /* Zero or more NC_* flags defined below */ }; /* |
︙ | ︙ | |||
16698 16699 16700 16701 16702 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 | #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ #define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */ #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ #define NC_HasAgg 0x0010 /* One or more aggregate functions seen */ #define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ #define NC_VarSelect 0x0040 /* A correlated subquery has been seen */ #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ #define NC_Complex 0x2000 /* True if a function or subquery seen */ /* ** An instance of the following structure contains all information ** needed to generate code for a single SELECT statement. ** ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. ** If there is a LIMIT clause, the parser sets nLimit to the value of the | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 16989 16990 16991 16992 16993 16994 16995 16996 16997 16998 16999 17000 17001 17002 17003 17004 17005 17006 17007 17008 17009 17010 17011 17012 17013 17014 17015 17016 17017 17018 17019 17020 17021 17022 17023 17024 17025 17026 17027 | #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ #define NC_PartIdx 0x0002 /* True if resolving a partial index WHERE */ #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ #define NC_HasAgg 0x0010 /* One or more aggregate functions seen */ #define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ #define NC_VarSelect 0x0040 /* A correlated subquery has been seen */ #define NC_UEList 0x0080 /* True if uNC.pEList is used */ #define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */ #define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */ #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ #define NC_Complex 0x2000 /* True if a function or subquery seen */ /* ** An instance of the following object describes a single ON CONFLICT ** clause in an upsert. ** ** The pUpsertTarget field is only set if the ON CONFLICT clause includes ** conflict-target clause. (In "ON CONFLICT(a,b)" the "(a,b)" is the ** conflict-target clause.) The pUpsertTargetWhere is the optional ** WHERE clause used to identify partial unique indexes. ** ** pUpsertSet is the list of column=expr terms of the UPDATE statement. ** The pUpsertSet field is NULL for a ON CONFLICT DO NOTHING. The ** pUpsertWhere is the WHERE clause for the UPDATE and is NULL if the ** WHERE clause is omitted. */ struct Upsert { ExprList *pUpsertTarget; /* Optional description of conflicting index */ Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */ Index *pUpsertIdx; /* Constraint that pUpsertTarget identifies */ ExprList *pUpsertSet; /* The SET clause from an ON CONFLICT UPDATE */ Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */ /* The fields above comprise the parse tree for the upsert clause. ** The fields below are used to transfer information from the INSERT ** processing down into the UPDATE processing while generating code. ** Upsert owns the memory allocated above, but not the memory below. */ SrcList *pUpsertSrc; /* Table to be updated */ int regData; /* First register holding array of VALUES */ int iDataCur; /* Index of the data cursor */ int iIdxCur; /* Index of the first index cursor */ }; /* ** An instance of the following structure contains all information ** needed to generate code for a single SELECT statement. ** ** nLimit is set to -1 if there is no LIMIT clause. nOffset is set to 0. ** If there is a LIMIT clause, the parser sets nLimit to the value of the |
︙ | ︙ | |||
17200 17201 17202 17203 17204 17205 17206 | struct TriggerStep { u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ u8 orconf; /* OE_Rollback etc. */ Trigger *pTrig; /* The trigger that this step is a part of */ Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */ char *zTarget; /* Target table for DELETE, UPDATE, INSERT */ Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */ | | > | 17514 17515 17516 17517 17518 17519 17520 17521 17522 17523 17524 17525 17526 17527 17528 17529 17530 | struct TriggerStep { u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */ u8 orconf; /* OE_Rollback etc. */ Trigger *pTrig; /* The trigger that this step is a part of */ Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */ char *zTarget; /* Target table for DELETE, UPDATE, INSERT */ Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */ ExprList *pExprList; /* SET clause for UPDATE */ IdList *pIdList; /* Column names for INSERT */ Upsert *pUpsert; /* Upsert clauses on an INSERT */ char *zSpan; /* Original SQL text of this command */ TriggerStep *pNext; /* Next in the link-list */ TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */ }; /* ** The following structure contains information used by the sqliteFix... |
︙ | ︙ | |||
17313 17314 17315 17316 17317 17318 17319 17320 17321 17322 17323 17324 17325 17326 | void *pVdbeBranchArg; /* 1st argument */ #endif #ifndef SQLITE_UNTESTABLE int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ #endif int bLocaltimeFault; /* True to fail localtime() calls */ int iOnceResetThreshold; /* When to reset OP_Once counters */ }; /* ** This macro is used inside of assert() statements to indicate that ** the assert is only valid on a well-formed database. Instead of: ** ** assert( X ); | > | 17628 17629 17630 17631 17632 17633 17634 17635 17636 17637 17638 17639 17640 17641 17642 | void *pVdbeBranchArg; /* 1st argument */ #endif #ifndef SQLITE_UNTESTABLE int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ #endif int bLocaltimeFault; /* True to fail localtime() calls */ int iOnceResetThreshold; /* When to reset OP_Once counters */ u32 szSorterRef; /* Min size in bytes to use sorter-refs */ }; /* ** This macro is used inside of assert() statements to indicate that ** the assert is only valid on a well-formed database. Instead of: ** ** assert( X ); |
︙ | ︙ | |||
17733 17734 17735 17736 17737 17738 17739 | #ifndef SQLITE_OMIT_AUTOINCREMENT SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse); #else # define sqlite3AutoincrementBegin(X) # define sqlite3AutoincrementEnd(X) #endif | | | 18049 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 | #ifndef SQLITE_OMIT_AUTOINCREMENT SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse); #else # define sqlite3AutoincrementBegin(X) # define sqlite3AutoincrementEnd(X) #endif SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*); SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*); SQLITE_PRIVATE IdList *sqlite3IdListAppend(sqlite3*, IdList*, Token*); SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*); SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*); SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, Token*, Select*, Expr*, IdList*); |
︙ | ︙ | |||
17763 17764 17765 17766 17767 17768 17769 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*); #endif SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*); | | > | 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 18090 18091 18092 18093 18094 | SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse*, SrcList*); SQLITE_PRIVATE int sqlite3IsReadOnly(Parse*, Table*, int); SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int); #if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*); #endif SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*); SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*, Upsert*); SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int); SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*); SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*); SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*); SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*); SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*); SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*); |
︙ | ︙ | |||
17856 17857 17858 17859 17860 17861 17862 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); SQLITE_PRIVATE void sqlite3GenerateRowDelete( Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int); SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int, | | | 18173 18174 18175 18176 18177 18178 18179 18180 18181 18182 18183 18184 18185 18186 18187 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); SQLITE_PRIVATE void sqlite3GenerateRowDelete( Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int); SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int, u8,u8,int,int*,int*,Upsert*); #ifdef SQLITE_ENABLE_NULL_TRIM SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe*,Table*); #else # define sqlite3SetMakeRecordP5(A,B) #endif SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int); SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*); |
︙ | ︙ | |||
17909 17910 17911 17912 17913 17914 17915 | int, int, int); SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int); void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*); SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*, const char*,const char*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, | > | | 18226 18227 18228 18229 18230 18231 18232 18233 18234 18235 18236 18237 18238 18239 18240 18241 | int, int, int); SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(Parse *, Trigger *, Table *, int, int, int); void sqliteViewTriggers(Parse*, Table*, Expr*, int, ExprList*); SQLITE_PRIVATE void sqlite3DeleteTriggerStep(sqlite3*, TriggerStep*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*, const char*,const char*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep(sqlite3*,Token*, IdList*, Select*,u8,Upsert*, const char*,const char*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerUpdateStep(sqlite3*,Token*,ExprList*, Expr*, u8, const char*,const char*); SQLITE_PRIVATE TriggerStep *sqlite3TriggerDeleteStep(sqlite3*,Token*, Expr*, const char*,const char*); SQLITE_PRIVATE void sqlite3DeleteTrigger(sqlite3*, Trigger*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTrigger(sqlite3*,int,const char*); SQLITE_PRIVATE u32 sqlite3TriggerColmask(Parse*,Trigger*,ExprList*,int,int,Table*,int); |
︙ | ︙ | |||
18095 18096 18097 18098 18099 18100 18101 | SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); | | | | 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 | SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); SQLITE_PRIVATE char sqlite3AffinityType(const char*, Column*); SQLITE_PRIVATE void sqlite3Analyze(Parse*, Token*, Token*); SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler*, sqlite3_file*); SQLITE_PRIVATE int sqlite3FindDb(sqlite3*, Token*); SQLITE_PRIVATE int sqlite3FindDbName(sqlite3 *, const char *); SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3*,int iDB); SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3*,Index*); SQLITE_PRIVATE void sqlite3DefaultRowEst(Index*); SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3*, int); SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*); |
︙ | ︙ | |||
18157 18158 18159 18160 18161 18162 18163 | SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int); #endif /* ** The interface to the LEMON-generated parser */ #ifndef SQLITE_AMALGAMATION | | | | 18475 18476 18477 18478 18479 18480 18481 18482 18483 18484 18485 18486 18487 18488 18489 18490 18491 18492 | SQLITE_PRIVATE char sqlite3IndexColumnAffinity(sqlite3*, Index*, int); #endif /* ** The interface to the LEMON-generated parser */ #ifndef SQLITE_AMALGAMATION SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64), Parse*); SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*)); #endif SQLITE_PRIVATE void sqlite3Parser(void*, int, Token); #ifdef YYTRACKMAXSTACKDEPTH SQLITE_PRIVATE int sqlite3ParserStackPeak(void*); #endif SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3*); #ifndef SQLITE_OMIT_LOAD_EXTENSION SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3*); |
︙ | ︙ | |||
18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 18259 18260 18261 | SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*); SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8); #else #define sqlite3WithPush(x,y,z) #define sqlite3WithDelete(x,y) #endif /* Declarations for functions in fkey.c. All of these are replaced by ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign ** key functionality is available. If OMIT_TRIGGER is defined but ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In ** this case foreign keys are parsed, but no other functionality is ** provided (enforcement of FK constraints requires the triggers sub-system). | > > > > > > > > > > > > | 18566 18567 18568 18569 18570 18571 18572 18573 18574 18575 18576 18577 18578 18579 18580 18581 18582 18583 18584 18585 18586 18587 18588 18589 18590 18591 | SQLITE_PRIVATE With *sqlite3WithAdd(Parse*,With*,Token*,ExprList*,Select*); SQLITE_PRIVATE void sqlite3WithDelete(sqlite3*,With*); SQLITE_PRIVATE void sqlite3WithPush(Parse*, With*, u8); #else #define sqlite3WithPush(x,y,z) #define sqlite3WithDelete(x,y) #endif #ifndef SQLITE_OMIT_UPSERT SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*); SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3*,Upsert*); SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3*,Upsert*); SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget(Parse*,SrcList*,Upsert*); SQLITE_PRIVATE void sqlite3UpsertDoUpdate(Parse*,Upsert*,Table*,Index*,int); #else #define sqlite3UpsertNew(v,w,x,y,z) ((Upsert*)0) #define sqlite3UpsertDelete(x,y) #define sqlite3UpsertDup(x,y) ((Upsert*)0) #endif /* Declarations for functions in fkey.c. All of these are replaced by ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign ** key functionality is available. If OMIT_TRIGGER is defined but ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In ** this case foreign keys are parsed, but no other functionality is ** provided (enforcement of FK constraints requires the triggers sub-system). |
︙ | ︙ | |||
18680 18681 18682 18683 18684 18685 18686 | 0, /* xVdbeBranch */ 0, /* pVbeBranchArg */ #endif #ifndef SQLITE_UNTESTABLE 0, /* xTestCallback */ #endif 0, /* bLocaltimeFault */ | | > | 19010 19011 19012 19013 19014 19015 19016 19017 19018 19019 19020 19021 19022 19023 19024 19025 | 0, /* xVdbeBranch */ 0, /* pVbeBranchArg */ #endif #ifndef SQLITE_UNTESTABLE 0, /* xTestCallback */ #endif 0, /* bLocaltimeFault */ 0x7ffffffe, /* iOnceResetThreshold */ SQLITE_DEFAULT_SORTERREF_SIZE /* szSorterRef */ }; /* ** Hash table for global functions - functions common to all ** database connections. After initialization, this table is ** read-only. */ |
︙ | ︙ | |||
21067 21068 21069 21070 21071 21072 21073 21074 | ** and we need to know about the failures. Use sqlite3OsFileControlHint() ** when simply tossing information over the wall to the VFS and we do not ** really care if the VFS receives and understands the information since it ** is only a hint and can be safely ignored. The sqlite3OsFileControlHint() ** routine has no return value since the return value would be meaningless. */ SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){ #ifdef SQLITE_TEST | > | > > | | 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 21412 21413 21414 21415 21416 21417 21418 21419 21420 21421 21422 21423 21424 21425 21426 21427 21428 21429 21430 21431 21432 21433 | ** and we need to know about the failures. Use sqlite3OsFileControlHint() ** when simply tossing information over the wall to the VFS and we do not ** really care if the VFS receives and understands the information since it ** is only a hint and can be safely ignored. The sqlite3OsFileControlHint() ** routine has no return value since the return value would be meaningless. */ SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file *id, int op, void *pArg){ if( id->pMethods==0 ) return SQLITE_NOTFOUND; #ifdef SQLITE_TEST if( op!=SQLITE_FCNTL_COMMIT_PHASETWO && op!=SQLITE_FCNTL_LOCK_TIMEOUT ){ /* Faults are not injected into COMMIT_PHASETWO because, assuming SQLite ** is using a regular VFS, it is called after the corresponding ** transaction has been committed. Injecting a fault at this point ** confuses the test scripts - the COMMIT comand returns SQLITE_NOMEM ** but the transaction is committed anyway. ** ** The core must call OsFileControl() though, not OsFileControlHint(), ** as if a custom VFS (e.g. zipvfs) returns an error here, it probably ** means the commit really has failed and an error should be returned ** to the user. */ DO_OS_MALLOC_TEST(id); } #endif return id->pMethods->xFileControl(id, op, pArg); } SQLITE_PRIVATE void sqlite3OsFileControlHint(sqlite3_file *id, int op, void *pArg){ if( id->pMethods ) (void)id->pMethods->xFileControl(id, op, pArg); } SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){ int (*xSectorSize)(sqlite3_file*) = id->pMethods->xSectorSize; return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE); } SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){ |
︙ | ︙ | |||
30699 30700 30701 30702 30703 30704 30705 | /* 77 */ "IntCopy" OpHelp("r[P2]=r[P1]"), /* 78 */ "ResultRow" OpHelp("output=r[P1@P2]"), /* 79 */ "CollSeq" OpHelp(""), /* 80 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), /* 81 */ "RealAffinity" OpHelp(""), /* 82 */ "Cast" OpHelp("affinity(r[P1])"), /* 83 */ "Permutation" OpHelp(""), | > | | | | | | | | | | < < | | | | > | 31033 31034 31035 31036 31037 31038 31039 31040 31041 31042 31043 31044 31045 31046 31047 31048 31049 31050 31051 31052 31053 31054 31055 31056 31057 31058 31059 31060 31061 31062 | /* 77 */ "IntCopy" OpHelp("r[P2]=r[P1]"), /* 78 */ "ResultRow" OpHelp("output=r[P1@P2]"), /* 79 */ "CollSeq" OpHelp(""), /* 80 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), /* 81 */ "RealAffinity" OpHelp(""), /* 82 */ "Cast" OpHelp("affinity(r[P1])"), /* 83 */ "Permutation" OpHelp(""), /* 84 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), /* 85 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), /* 86 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), /* 87 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), /* 88 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), /* 89 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), /* 90 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), /* 91 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), /* 92 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), /* 93 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), /* 94 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), /* 95 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), /* 96 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), /* 97 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), /* 98 */ "Column" OpHelp("r[P3]=PX"), /* 99 */ "String8" OpHelp("r[P2]='P4'"), /* 100 */ "Affinity" OpHelp("affinity(r[P1@P2])"), /* 101 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), /* 102 */ "Count" OpHelp("r[P2]=count()"), /* 103 */ "ReadCookie" OpHelp(""), /* 104 */ "SetCookie" OpHelp(""), /* 105 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), /* 106 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
︙ | ︙ | |||
30747 30748 30749 30750 30751 30752 30753 | /* 125 */ "Rowid" OpHelp("r[P2]=rowid"), /* 126 */ "NullRow" OpHelp(""), /* 127 */ "SeekEnd" OpHelp(""), /* 128 */ "SorterInsert" OpHelp("key=r[P2]"), /* 129 */ "IdxInsert" OpHelp("key=r[P2]"), /* 130 */ "IdxDelete" OpHelp("key=r[P2@P3]"), /* 131 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), | < | | > | 31081 31082 31083 31084 31085 31086 31087 31088 31089 31090 31091 31092 31093 31094 31095 31096 31097 | /* 125 */ "Rowid" OpHelp("r[P2]=rowid"), /* 126 */ "NullRow" OpHelp(""), /* 127 */ "SeekEnd" OpHelp(""), /* 128 */ "SorterInsert" OpHelp("key=r[P2]"), /* 129 */ "IdxInsert" OpHelp("key=r[P2]"), /* 130 */ "IdxDelete" OpHelp("key=r[P2@P3]"), /* 131 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), /* 132 */ "IdxRowid" OpHelp("r[P2]=rowid"), /* 133 */ "Destroy" OpHelp(""), /* 134 */ "Real" OpHelp("r[P2]=P4"), /* 135 */ "Clear" OpHelp(""), /* 136 */ "ResetSorter" OpHelp(""), /* 137 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), /* 138 */ "SqlExec" OpHelp(""), /* 139 */ "ParseSchema" OpHelp(""), /* 140 */ "LoadAnalysis" OpHelp(""), /* 141 */ "DropTable" OpHelp(""), |
︙ | ︙ | |||
31024 31025 31026 31027 31028 31029 31030 31031 31032 31033 31034 31035 31036 31037 | int deviceCharacteristics; /* Precomputed device characteristics */ #if SQLITE_ENABLE_LOCKING_STYLE int openFlags; /* The flags specified at open() */ #endif #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__) unsigned fsFlags; /* cached details from statfs() */ #endif #if OS_VXWORKS struct vxworksFileId *pId; /* Unique file ID */ #endif #ifdef SQLITE_DEBUG /* The next group of variables are used to track whether or not the ** transaction counter in bytes 24-27 of database files are updated ** whenever any part of the database changes. An assertion fault will | > > > | 31358 31359 31360 31361 31362 31363 31364 31365 31366 31367 31368 31369 31370 31371 31372 31373 31374 | int deviceCharacteristics; /* Precomputed device characteristics */ #if SQLITE_ENABLE_LOCKING_STYLE int openFlags; /* The flags specified at open() */ #endif #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__) unsigned fsFlags; /* cached details from statfs() */ #endif #ifdef SQLITE_ENABLE_SETLK_TIMEOUT unsigned iBusyTimeout; /* Wait this many millisec on locks */ #endif #if OS_VXWORKS struct vxworksFileId *pId; /* Unique file ID */ #endif #ifdef SQLITE_DEBUG /* The next group of variables are used to track whether or not the ** transaction counter in bytes 24-27 of database files are updated ** whenever any part of the database changes. An assertion fault will |
︙ | ︙ | |||
32457 32458 32459 32460 32461 32462 32463 32464 32465 32466 32467 32468 32469 32470 | unixLeaveMutex(); OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved)); *pResOut = reserved; return rc; } /* ** Attempt to set a system-lock on the file pFile. The lock is ** described by pLock. ** ** If the pFile was opened read/write from unix-excl, then the only lock ** ever obtained is an exclusive lock, and it is obtained exactly once | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 32794 32795 32796 32797 32798 32799 32800 32801 32802 32803 32804 32805 32806 32807 32808 32809 32810 32811 32812 32813 32814 32815 32816 32817 32818 32819 32820 32821 32822 32823 32824 32825 32826 32827 32828 32829 32830 32831 32832 32833 32834 32835 32836 32837 32838 32839 32840 32841 32842 32843 32844 | unixLeaveMutex(); OSTRACE(("TEST WR-LOCK %d %d %d (unix)\n", pFile->h, rc, reserved)); *pResOut = reserved; return rc; } /* ** Set a posix-advisory-lock. ** ** There are two versions of this routine. If compiled with ** SQLITE_ENABLE_SETLK_TIMEOUT then the routine has an extra parameter ** which is a pointer to a unixFile. If the unixFile->iBusyTimeout ** value is set, then it is the number of milliseconds to wait before ** failing the lock. The iBusyTimeout value is always reset back to ** zero on each call. ** ** If SQLITE_ENABLE_SETLK_TIMEOUT is not defined, then do a non-blocking ** attempt to set the lock. */ #ifndef SQLITE_ENABLE_SETLK_TIMEOUT # define osSetPosixAdvisoryLock(h,x,t) osFcntl(h,F_SETLK,x) #else static int osSetPosixAdvisoryLock( int h, /* The file descriptor on which to take the lock */ struct flock *pLock, /* The description of the lock */ unixFile *pFile /* Structure holding timeout value */ ){ int rc = osFcntl(h,F_SETLK,pLock); while( rc<0 && pFile->iBusyTimeout>0 ){ /* On systems that support some kind of blocking file lock with a timeout, ** make appropriate changes here to invoke that blocking file lock. On ** generic posix, however, there is no such API. So we simply try the ** lock once every millisecond until either the timeout expires, or until ** the lock is obtained. */ usleep(1000); rc = osFcntl(h,F_SETLK,pLock); pFile->iBusyTimeout--; } return rc; } #endif /* SQLITE_ENABLE_SETLK_TIMEOUT */ /* ** Attempt to set a system-lock on the file pFile. The lock is ** described by pLock. ** ** If the pFile was opened read/write from unix-excl, then the only lock ** ever obtained is an exclusive lock, and it is obtained exactly once |
︙ | ︙ | |||
32490 32491 32492 32493 32494 32495 32496 | if( pInode->bProcessLock==0 ){ struct flock lock; assert( pInode->nLock==0 ); lock.l_whence = SEEK_SET; lock.l_start = SHARED_FIRST; lock.l_len = SHARED_SIZE; lock.l_type = F_WRLCK; | | | | 32864 32865 32866 32867 32868 32869 32870 32871 32872 32873 32874 32875 32876 32877 32878 32879 32880 32881 32882 32883 32884 32885 32886 | if( pInode->bProcessLock==0 ){ struct flock lock; assert( pInode->nLock==0 ); lock.l_whence = SEEK_SET; lock.l_start = SHARED_FIRST; lock.l_len = SHARED_SIZE; lock.l_type = F_WRLCK; rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile); if( rc<0 ) return rc; pInode->bProcessLock = 1; pInode->nLock++; }else{ rc = 0; } }else{ rc = osSetPosixAdvisoryLock(pFile->h, pLock, pFile); } return rc; } /* ** Lock the file with the lock specified by parameter eFileLock - one ** of the following: |
︙ | ︙ | |||
34858 34859 34860 34861 34862 34863 34864 34865 34866 34867 34868 34869 34870 34871 | } return SQLITE_OK; } case SQLITE_FCNTL_HAS_MOVED: { *(int*)pArg = fileHasMoved(pFile); return SQLITE_OK; } #if SQLITE_MAX_MMAP_SIZE>0 case SQLITE_FCNTL_MMAP_SIZE: { i64 newLimit = *(i64*)pArg; int rc = SQLITE_OK; if( newLimit>sqlite3GlobalConfig.mxMmap ){ newLimit = sqlite3GlobalConfig.mxMmap; } | > > > > > > | 35232 35233 35234 35235 35236 35237 35238 35239 35240 35241 35242 35243 35244 35245 35246 35247 35248 35249 35250 35251 | } return SQLITE_OK; } case SQLITE_FCNTL_HAS_MOVED: { *(int*)pArg = fileHasMoved(pFile); return SQLITE_OK; } #ifdef SQLITE_ENABLE_SETLK_TIMEOUT case SQLITE_FCNTL_LOCK_TIMEOUT: { pFile->iBusyTimeout = *(int*)pArg; return SQLITE_OK; } #endif #if SQLITE_MAX_MMAP_SIZE>0 case SQLITE_FCNTL_MMAP_SIZE: { i64 newLimit = *(i64*)pArg; int rc = SQLITE_OK; if( newLimit>sqlite3GlobalConfig.mxMmap ){ newLimit = sqlite3GlobalConfig.mxMmap; } |
︙ | ︙ | |||
35177 35178 35179 35180 35181 35182 35183 | if( pShmNode->h>=0 ){ /* Initialize the locking parameters */ f.l_type = lockType; f.l_whence = SEEK_SET; f.l_start = ofst; f.l_len = n; | | | 35557 35558 35559 35560 35561 35562 35563 35564 35565 35566 35567 35568 35569 35570 35571 | if( pShmNode->h>=0 ){ /* Initialize the locking parameters */ f.l_type = lockType; f.l_whence = SEEK_SET; f.l_start = ofst; f.l_len = n; rc = osSetPosixAdvisoryLock(pShmNode->h, &f, pFile); rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY; } /* Update the global lock state and do debug tracing */ #ifdef SQLITE_DEBUG { u16 mask; OSTRACE(("SHM-LOCK ")); |
︙ | ︙ | |||
45037 45038 45039 45040 45041 45042 45043 | ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** | | | 45417 45418 45419 45420 45421 45422 45423 45424 45425 45426 45427 45428 45429 45430 45431 | ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file implements an in-memory VFS. A database is held as a contiguous ** block of memory. ** ** This file also implements interface sqlite3_serialize() and ** sqlite3_deserialize(). */ #ifdef SQLITE_ENABLE_DESERIALIZE /* #include "sqliteInt.h" */ |
︙ | ︙ | |||
50951 50952 50953 50954 50955 50956 50957 | ** successfully committed, but the EXCLUSIVE lock is still held on the ** file. So it is safe to truncate the database file to its minimum ** required size. */ assert( pPager->eLock==EXCLUSIVE_LOCK ); rc = pager_truncate(pPager, pPager->dbSize); } | | | 51331 51332 51333 51334 51335 51336 51337 51338 51339 51340 51341 51342 51343 51344 51345 | ** successfully committed, but the EXCLUSIVE lock is still held on the ** file. So it is safe to truncate the database file to its minimum ** required size. */ assert( pPager->eLock==EXCLUSIVE_LOCK ); rc = pager_truncate(pPager, pPager->dbSize); } if( rc==SQLITE_OK && bCommit ){ rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_COMMIT_PHASETWO, 0); if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK; } if( !pPager->exclusiveMode && (!pagerUseWal(pPager) || sqlite3WalExclusiveMode(pPager->pWal, 0)) ){ |
︙ | ︙ | |||
51770 51771 51772 51773 51774 51775 51776 | } /* Following a rollback, the database file should be back in its original ** state prior to the start of the transaction, so invoke the ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the ** assertion that the transaction counter was modified. */ #ifdef SQLITE_DEBUG | < | < | 52150 52151 52152 52153 52154 52155 52156 52157 52158 52159 52160 52161 52162 52163 52164 | } /* Following a rollback, the database file should be back in its original ** state prior to the start of the transaction, so invoke the ** SQLITE_FCNTL_DB_UNCHANGED file-control method to disable the ** assertion that the transaction counter was modified. */ #ifdef SQLITE_DEBUG sqlite3OsFileControlHint(pPager->fd,SQLITE_FCNTL_DB_UNCHANGED,0); #endif /* If this playback is happening automatically as a result of an IO or ** malloc error that occurred after the change-counter was updated but ** before the transaction was committed, then the change-counter ** modification may just have been reverted. If this happens in exclusive ** mode, then subsequent transactions performed by the connection will not |
︙ | ︙ | |||
52525 52526 52527 52528 52529 52530 52531 | ** SHARED_LOCK -> EXCLUSIVE_LOCK | No ** RESERVED_LOCK -> EXCLUSIVE_LOCK | Yes ** ** If the busy-handler callback returns non-zero, the lock is ** retried. If it returns zero, then the SQLITE_BUSY error is ** returned to the caller of the pager API function. */ | | > < < | | | | < | 52903 52904 52905 52906 52907 52908 52909 52910 52911 52912 52913 52914 52915 52916 52917 52918 52919 52920 52921 52922 52923 52924 52925 52926 52927 52928 | ** SHARED_LOCK -> EXCLUSIVE_LOCK | No ** RESERVED_LOCK -> EXCLUSIVE_LOCK | Yes ** ** If the busy-handler callback returns non-zero, the lock is ** retried. If it returns zero, then the SQLITE_BUSY error is ** returned to the caller of the pager API function. */ SQLITE_PRIVATE void sqlite3PagerSetBusyHandler( Pager *pPager, /* Pager object */ int (*xBusyHandler)(void *), /* Pointer to busy-handler function */ void *pBusyHandlerArg /* Argument to pass to xBusyHandler */ ){ void **ap; pPager->xBusyHandler = xBusyHandler; pPager->pBusyHandlerArg = pBusyHandlerArg; ap = (void **)&pPager->xBusyHandler; assert( ((int(*)(void *))(ap[0]))==xBusyHandler ); assert( ap[1]==pBusyHandlerArg ); sqlite3OsFileControlHint(pPager->fd, SQLITE_FCNTL_BUSYHANDLER, (void *)ap); } /* ** Change the page size used by the Pager object. The new page size ** is passed in *pPageSize. ** ** If the pager is in the error state when this function is called, it |
︙ | ︙ | |||
54514 54515 54516 54517 54518 54519 54520 54521 54522 54523 54524 54525 54526 54527 | } SQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage *pPg){ Pager *pPager; assert( pPg!=0 ); assert( pPg->pgno==1 ); assert( (pPg->flags & PGHDR_MMAP)==0 ); /* Page1 is never memory mapped */ pPager = pPg->pPager; sqlite3PcacheRelease(pPg); pagerUnlockIfUnused(pPager); } /* ** This function is called at the start of every write transaction. ** There must already be a RESERVED or EXCLUSIVE lock on the database | > | 54890 54891 54892 54893 54894 54895 54896 54897 54898 54899 54900 54901 54902 54903 54904 | } SQLITE_PRIVATE void sqlite3PagerUnrefPageOne(DbPage *pPg){ Pager *pPager; assert( pPg!=0 ); assert( pPg->pgno==1 ); assert( (pPg->flags & PGHDR_MMAP)==0 ); /* Page1 is never memory mapped */ pPager = pPg->pPager; sqlite3PagerResetLockTimeout(pPager); sqlite3PcacheRelease(pPg); pagerUnlockIfUnused(pPager); } /* ** This function is called at the start of every write transaction. ** There must already be a RESERVED or EXCLUSIVE lock on the database |
︙ | ︙ | |||
55109 55110 55111 55112 55113 55114 55115 | ** or pages with the Pager.noSync flag set. ** ** If successful, or if called on a pager for which it is a no-op, this ** function returns SQLITE_OK. Otherwise, an IO error code is returned. */ SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){ int rc = SQLITE_OK; | < < | | | < | 55486 55487 55488 55489 55490 55491 55492 55493 55494 55495 55496 55497 55498 55499 55500 55501 55502 | ** or pages with the Pager.noSync flag set. ** ** If successful, or if called on a pager for which it is a no-op, this ** function returns SQLITE_OK. Otherwise, an IO error code is returned. */ SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager, const char *zMaster){ int rc = SQLITE_OK; void *pArg = (void*)zMaster; rc = sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_SYNC, pArg); if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK; if( rc==SQLITE_OK && !pPager->noSync ){ assert( !MEMDB ); rc = sqlite3OsSync(pPager->fd, pPager->syncFlags); } return rc; } |
︙ | ︙ | |||
55791 55792 55793 55794 55795 55796 55797 55798 55799 55800 55801 55802 55803 55804 | ** with the pager. This might return NULL if the file has ** not yet been opened. */ SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){ return pPager->fd; } /* ** Return the file handle for the journal file (if it exists). ** This will be either the rollback journal or the WAL file. */ SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ #if SQLITE_OMIT_WAL return pPager->jfd; | > > > > > > > > > > | 56165 56166 56167 56168 56169 56170 56171 56172 56173 56174 56175 56176 56177 56178 56179 56180 56181 56182 56183 56184 56185 56186 56187 56188 | ** with the pager. This might return NULL if the file has ** not yet been opened. */ SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager *pPager){ return pPager->fd; } #ifdef SQLITE_ENABLE_SETLK_TIMEOUT /* ** Reset the lock timeout for pager. */ SQLITE_PRIVATE void sqlite3PagerResetLockTimeout(Pager *pPager){ int x = 0; sqlite3OsFileControl(pPager->fd, SQLITE_FCNTL_LOCK_TIMEOUT, &x); } #endif /* ** Return the file handle for the journal file (if it exists). ** This will be either the rollback journal or the WAL file. */ SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager *pPager){ #if SQLITE_OMIT_WAL return pPager->jfd; |
︙ | ︙ | |||
56251 56252 56253 56254 56255 56256 56257 56258 56259 56260 56261 56262 56263 56264 | if( pPager->pWal ){ rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode, (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler), pPager->pBusyHandlerArg, pPager->walSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace, pnLog, pnCkpt ); } return rc; } SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){ return sqlite3WalCallback(pPager->pWal); } | > | 56635 56636 56637 56638 56639 56640 56641 56642 56643 56644 56645 56646 56647 56648 56649 | if( pPager->pWal ){ rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode, (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler), pPager->pBusyHandlerArg, pPager->walSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace, pnLog, pnCkpt ); sqlite3PagerResetLockTimeout(pPager); } return rc; } SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager){ return sqlite3WalCallback(pPager->pWal); } |
︙ | ︙ | |||
63527 63528 63529 63530 63531 63532 63533 | /* ** Invoke the busy handler for a btree. */ static int btreeInvokeBusyHandler(void *pArg){ BtShared *pBt = (BtShared*)pArg; assert( pBt->db ); assert( sqlite3_mutex_held(pBt->db->mutex) ); | | > | 63912 63913 63914 63915 63916 63917 63918 63919 63920 63921 63922 63923 63924 63925 63926 63927 | /* ** Invoke the busy handler for a btree. */ static int btreeInvokeBusyHandler(void *pArg){ BtShared *pBt = (BtShared*)pArg; assert( pBt->db ); assert( sqlite3_mutex_held(pBt->db->mutex) ); return sqlite3InvokeBusyHandler(&pBt->db->busyHandler, sqlite3PagerFile(pBt->pPager)); } /* ** Open a database file. ** ** zFilename is the name of the database file. If zFilename is NULL ** then an ephemeral database is created. The ephemeral database might |
︙ | ︙ | |||
63705 63706 63707 63708 63709 63710 63711 | rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader); } if( rc!=SQLITE_OK ){ goto btree_open_out; } pBt->openFlags = (u8)flags; pBt->db = db; | | | 64091 64092 64093 64094 64095 64096 64097 64098 64099 64100 64101 64102 64103 64104 64105 | rc = sqlite3PagerReadFileheader(pBt->pPager,sizeof(zDbHeader),zDbHeader); } if( rc!=SQLITE_OK ){ goto btree_open_out; } pBt->openFlags = (u8)flags; pBt->db = db; sqlite3PagerSetBusyHandler(pBt->pPager, btreeInvokeBusyHandler, pBt); p->pBt = pBt; pBt->pCursor = 0; pBt->pPage1 = 0; if( sqlite3PagerIsreadonly(pBt->pPager) ) pBt->btsFlags |= BTS_READ_ONLY; #if defined(SQLITE_SECURE_DELETE) pBt->btsFlags |= BTS_SECURE_DELETE; |
︙ | ︙ | |||
64668 64669 64670 64671 64672 64673 64674 64675 64676 64677 64678 64679 64680 64681 | } if( rc!=SQLITE_OK ){ unlockBtreeIfUnused(pBt); } }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE && btreeInvokeBusyHandler(pBt) ); if( rc==SQLITE_OK ){ if( p->inTrans==TRANS_NONE ){ pBt->nTransaction++; #ifndef SQLITE_OMIT_SHARED_CACHE if( p->sharable ){ assert( p->lock.pBtree==p && p->lock.iTable==1 ); | > | 65054 65055 65056 65057 65058 65059 65060 65061 65062 65063 65064 65065 65066 65067 65068 | } if( rc!=SQLITE_OK ){ unlockBtreeIfUnused(pBt); } }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE && btreeInvokeBusyHandler(pBt) ); sqlite3PagerResetLockTimeout(pBt->pPager); if( rc==SQLITE_OK ){ if( p->inTrans==TRANS_NONE ){ pBt->nTransaction++; #ifndef SQLITE_OMIT_SHARED_CACHE if( p->sharable ){ assert( p->lock.pBtree==p && p->lock.iTable==1 ); |
︙ | ︙ | |||
73569 73570 73571 73572 73573 73574 73575 | zVal = &pExpr->u.zToken[2]; nVal = sqlite3Strlen30(zVal)-1; assert( zVal[nVal]=='\'' ); sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2, 0, SQLITE_DYNAMIC); } #endif | < > > > > > | 73956 73957 73958 73959 73960 73961 73962 73963 73964 73965 73966 73967 73968 73969 73970 73971 73972 73973 73974 73975 73976 73977 73978 73979 | zVal = &pExpr->u.zToken[2]; nVal = sqlite3Strlen30(zVal)-1; assert( zVal[nVal]=='\'' ); sqlite3VdbeMemSetStr(pVal, sqlite3HexToBlob(db, zVal, nVal), nVal/2, 0, SQLITE_DYNAMIC); } #endif #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 else if( op==TK_FUNCTION && pCtx!=0 ){ rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx); } #endif else if( op==TK_TRUEFALSE ){ pVal = valueNew(db, pCtx); pVal->flags = MEM_Int; pVal->u.i = pExpr->u.zToken[4]==0; } *ppVal = pVal; return rc; no_mem: #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 if( pCtx==0 || pCtx->pParse->nErr==0 ) |
︙ | ︙ | |||
74322 74323 74324 74325 74326 74327 74328 74329 74330 74331 74332 74333 74334 74335 74336 74337 74338 74339 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){ Parse *p = v->pParse; int j = ADDR(x); assert( v->magic==VDBE_MAGIC_INIT ); assert( j<p->nLabel ); assert( j>=0 ); if( p->aLabel ){ p->aLabel[j] = v->nOp; } } /* ** Mark the VDBE as one that can only be run one time. */ SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){ p->runOnlyOnce = 1; } | > > > > > > > > > > > > > > > > > > > | 74713 74714 74715 74716 74717 74718 74719 74720 74721 74722 74723 74724 74725 74726 74727 74728 74729 74730 74731 74732 74733 74734 74735 74736 74737 74738 74739 74740 74741 74742 74743 74744 74745 74746 74747 74748 74749 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){ Parse *p = v->pParse; int j = ADDR(x); assert( v->magic==VDBE_MAGIC_INIT ); assert( j<p->nLabel ); assert( j>=0 ); if( p->aLabel ){ #ifdef SQLITE_DEBUG if( p->db->flags & SQLITE_VdbeAddopTrace ){ printf("RESOLVE LABEL %d to %d\n", x, v->nOp); } #endif assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */ p->aLabel[j] = v->nOp; } } #ifdef SQLITE_COVERAGE_TEST /* ** Return TRUE if and only if the label x has already been resolved. ** Return FALSE (zero) if label x is still unresolved. ** ** This routine is only used inside of testcase() macros, and so it ** only exists when measuring test coverage. */ SQLITE_PRIVATE int sqlite3VdbeLabelHasBeenResolved(Vdbe *v, int x){ return v->pParse->aLabel && v->pParse->aLabel[ADDR(x)]>=0; } #endif /* SQLITE_COVERAGE_TEST */ /* ** Mark the VDBE as one that can only be run one time. */ SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe *p){ p->runOnlyOnce = 1; } |
︙ | ︙ | |||
92342 92343 92344 92345 92346 92347 92348 | int cntTab = 0; /* Number of matching table names */ int nSubquery = 0; /* How many levels of subquery */ sqlite3 *db = pParse->db; /* The database connection */ struct SrcList_item *pItem; /* Use for looping over pSrcList items */ struct SrcList_item *pMatch = 0; /* The matching pSrcList item */ NameContext *pTopNC = pNC; /* First namecontext in the list */ Schema *pSchema = 0; /* Schema of the expression */ | | | 92752 92753 92754 92755 92756 92757 92758 92759 92760 92761 92762 92763 92764 92765 92766 | int cntTab = 0; /* Number of matching table names */ int nSubquery = 0; /* How many levels of subquery */ sqlite3 *db = pParse->db; /* The database connection */ struct SrcList_item *pItem; /* Use for looping over pSrcList items */ struct SrcList_item *pMatch = 0; /* The matching pSrcList item */ NameContext *pTopNC = pNC; /* First namecontext in the list */ Schema *pSchema = 0; /* Schema of the expression */ int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */ Table *pTab = 0; /* Table hold the row */ Column *pCol; /* A column of pTab */ assert( pNC ); /* the name context cannot be NULL. */ assert( zCol ); /* The Z in X.Y.Z cannot be NULL */ assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); |
︙ | ︙ | |||
92447 92448 92449 92450 92451 92452 92453 | if( (pMatch->fg.jointype & JT_LEFT)!=0 ){ ExprSetProperty(pExpr, EP_CanBeNull); } pSchema = pExpr->pTab->pSchema; } } /* if( pSrcList ) */ | | | > | > > > | | | | | | | | > > > > | > > | > | > > > > > > > > > > > | | | | | | | | | | | > | | < > | | | > | | 92857 92858 92859 92860 92861 92862 92863 92864 92865 92866 92867 92868 92869 92870 92871 92872 92873 92874 92875 92876 92877 92878 92879 92880 92881 92882 92883 92884 92885 92886 92887 92888 92889 92890 92891 92892 92893 92894 92895 92896 92897 92898 92899 92900 92901 92902 92903 92904 92905 92906 92907 92908 92909 92910 92911 92912 92913 92914 92915 92916 92917 92918 92919 92920 92921 92922 92923 92924 92925 92926 92927 92928 92929 92930 92931 92932 92933 92934 92935 92936 92937 92938 92939 92940 92941 92942 92943 92944 92945 92946 92947 | if( (pMatch->fg.jointype & JT_LEFT)!=0 ){ ExprSetProperty(pExpr, EP_CanBeNull); } pSchema = pExpr->pTab->pSchema; } } /* if( pSrcList ) */ #if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) /* If we have not already resolved the name, then maybe ** it is a new.* or old.* trigger argument reference. Or ** maybe it is an excluded.* from an upsert. */ if( zDb==0 && zTab!=0 && cntTab==0 ){ pTab = 0; #ifndef SQLITE_OMIT_TRIGGER if( pParse->pTriggerTab!=0 ){ int op = pParse->eTriggerOp; assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT ); if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){ pExpr->iTable = 1; pTab = pParse->pTriggerTab; }else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){ pExpr->iTable = 0; pTab = pParse->pTriggerTab; } } #endif /* SQLITE_OMIT_TRIGGER */ #ifndef SQLITE_OMIT_UPSERT if( (pNC->ncFlags & NC_UUpsert)!=0 ){ Upsert *pUpsert = pNC->uNC.pUpsert; if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){ pTab = pUpsert->pUpsertSrc->a[0].pTab; pExpr->iTable = 2; } } #endif /* SQLITE_OMIT_UPSERT */ if( pTab ){ int iCol; pSchema = pTab->pSchema; cntTab++; for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){ if( sqlite3StrICmp(pCol->zName, zCol)==0 ){ if( iCol==pTab->iPKey ){ iCol = -1; } break; } } if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){ /* IMP: R-51414-32910 */ iCol = -1; } if( iCol<pTab->nCol ){ cnt++; #ifndef SQLITE_OMIT_UPSERT if( pExpr->iTable==2 ){ testcase( iCol==(-1) ); pExpr->iTable = pNC->uNC.pUpsert->regData + iCol; eNewExprOp = TK_REGISTER; }else #endif /* SQLITE_OMIT_UPSERT */ { #ifndef SQLITE_OMIT_TRIGGER if( iCol<0 ){ pExpr->affinity = SQLITE_AFF_INTEGER; }else if( pExpr->iTable==0 ){ testcase( iCol==31 ); testcase( iCol==32 ); pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol)); }else{ testcase( iCol==31 ); testcase( iCol==32 ); pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol)); } pExpr->pTab = pTab; pExpr->iColumn = (i16)iCol; eNewExprOp = TK_TRIGGER; #endif /* SQLITE_OMIT_TRIGGER */ } } } } #endif /* !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) */ /* ** Perhaps the name is a reference to the ROWID */ if( cnt==0 && cntTab==1 && pMatch |
︙ | ︙ | |||
92534 92535 92536 92537 92538 92539 92540 | ** ** The ability to use an output result-set column in the WHERE, GROUP BY, ** or HAVING clauses, or as part of a larger expression in the ORDER BY ** clause is not standard SQL. This is a (goofy) SQLite extension, that ** is supported for backwards compatibility only. Hence, we issue a warning ** on sqlite3_log() whenever the capability is used. */ | | < > > > | 92968 92969 92970 92971 92972 92973 92974 92975 92976 92977 92978 92979 92980 92981 92982 92983 92984 92985 92986 92987 | ** ** The ability to use an output result-set column in the WHERE, GROUP BY, ** or HAVING clauses, or as part of a larger expression in the ORDER BY ** clause is not standard SQL. This is a (goofy) SQLite extension, that ** is supported for backwards compatibility only. Hence, we issue a warning ** on sqlite3_log() whenever the capability is used. */ if( (pNC->ncFlags & NC_UEList)!=0 && cnt==0 && zTab==0 ){ pEList = pNC->uNC.pEList; assert( pEList!=0 ); for(j=0; j<pEList->nExpr; j++){ char *zAs = pEList->a[j].zName; if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ Expr *pOrig; assert( pExpr->pLeft==0 && pExpr->pRight==0 ); assert( pExpr->x.pList==0 ); assert( pExpr->x.pSelect==0 ); |
︙ | ︙ | |||
92634 92635 92636 92637 92638 92639 92640 | /* Clean up and return */ sqlite3ExprDelete(db, pExpr->pLeft); pExpr->pLeft = 0; sqlite3ExprDelete(db, pExpr->pRight); pExpr->pRight = 0; | | | 93070 93071 93072 93073 93074 93075 93076 93077 93078 93079 93080 93081 93082 93083 93084 | /* Clean up and return */ sqlite3ExprDelete(db, pExpr->pLeft); pExpr->pLeft = 0; sqlite3ExprDelete(db, pExpr->pRight); pExpr->pRight = 0; pExpr->op = eNewExprOp; ExprSetProperty(pExpr, EP_Leaf); lookupname_end: if( cnt==1 ){ assert( pNC!=0 ); if( !ExprHasProperty(pExpr, EP_Alias) ){ sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList); } |
︙ | ︙ | |||
93066 93067 93068 93069 93070 93071 93072 | pEList = pSelect->pEList; /* Resolve all names in the ORDER BY term expression */ memset(&nc, 0, sizeof(nc)); nc.pParse = pParse; nc.pSrcList = pSelect->pSrc; | | | | 93502 93503 93504 93505 93506 93507 93508 93509 93510 93511 93512 93513 93514 93515 93516 93517 | pEList = pSelect->pEList; /* Resolve all names in the ORDER BY term expression */ memset(&nc, 0, sizeof(nc)); nc.pParse = pParse; nc.pSrcList = pSelect->pSrc; nc.uNC.pEList = pEList; nc.ncFlags = NC_AllowAgg|NC_UEList; nc.nErr = 0; db = pParse->db; savedSuppErr = db->suppressErr; db->suppressErr = 1; rc = sqlite3ResolveExprNames(&nc, pE); db->suppressErr = savedSuppErr; if( rc ) return 0; |
︙ | ︙ | |||
93450 93451 93452 93453 93454 93455 93456 | ** other expressions in the SELECT statement. This is so that ** expressions in the WHERE clause (etc.) can refer to expressions by ** aliases in the result set. ** ** Minor point: If this is the case, then the expression will be ** re-evaluated for each reference to it. */ | > | > | 93886 93887 93888 93889 93890 93891 93892 93893 93894 93895 93896 93897 93898 93899 93900 93901 93902 | ** other expressions in the SELECT statement. This is so that ** expressions in the WHERE clause (etc.) can refer to expressions by ** aliases in the result set. ** ** Minor point: If this is the case, then the expression will be ** re-evaluated for each reference to it. */ assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert))==0 ); sNC.uNC.pEList = p->pEList; sNC.ncFlags |= NC_UEList; if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; /* Resolve names in table-valued-function arguments */ for(i=0; i<p->pSrc->nSrc; i++){ struct SrcList_item *pItem = &p->pSrc->a[i]; if( pItem->fg.isTabFunc |
︙ | ︙ | |||
93683 93684 93685 93686 93687 93688 93689 | ** Any errors cause an error message to be set in pParse. */ SQLITE_PRIVATE void sqlite3ResolveSelfReference( Parse *pParse, /* Parsing context */ Table *pTab, /* The table being referenced */ int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */ Expr *pExpr, /* Expression to resolve. May be NULL. */ | | | 94121 94122 94123 94124 94125 94126 94127 94128 94129 94130 94131 94132 94133 94134 94135 | ** Any errors cause an error message to be set in pParse. */ SQLITE_PRIVATE void sqlite3ResolveSelfReference( Parse *pParse, /* Parsing context */ Table *pTab, /* The table being referenced */ int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */ Expr *pExpr, /* Expression to resolve. May be NULL. */ ExprList *pList /* Expression list to resolve. May be NULL. */ ){ SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ NameContext sNC; /* Name context for pParse->pNewTable */ assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr ); memset(&sNC, 0, sizeof(sNC)); memset(&sSrc, 0, sizeof(sSrc)); |
︙ | ︙ | |||
95069 95070 95071 95072 95073 95074 95075 95076 95077 95078 95079 95080 95081 95082 | } } pItem->zName = sqlite3DbStrDup(db, pOldItem->zName); pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan); pItem->sortOrder = pOldItem->sortOrder; pItem->done = 0; pItem->bSpanIsTab = pOldItem->bSpanIsTab; pItem->u = pOldItem->u; } return pNew; } /* ** If cursors, triggers, views and subqueries are all omitted from | > | 95507 95508 95509 95510 95511 95512 95513 95514 95515 95516 95517 95518 95519 95520 95521 | } } pItem->zName = sqlite3DbStrDup(db, pOldItem->zName); pItem->zSpan = sqlite3DbStrDup(db, pOldItem->zSpan); pItem->sortOrder = pOldItem->sortOrder; pItem->done = 0; pItem->bSpanIsTab = pOldItem->bSpanIsTab; pItem->bSorterRef = pOldItem->bSorterRef; pItem->u = pOldItem->u; } return pNew; } /* ** If cursors, triggers, views and subqueries are all omitted from |
︙ | ︙ | |||
95531 95532 95533 95534 95535 95536 95537 95538 95539 95540 95541 95542 95543 95544 95545 95546 95547 95548 95549 95550 95551 95552 95553 95554 | testcase( pExpr->op==TK_AGG_FUNCTION ); testcase( pExpr->op==TK_AGG_COLUMN ); if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){ return WRC_Continue; } /* Fall through */ case TK_IF_NULL_ROW: testcase( pExpr->op==TK_IF_NULL_ROW ); pWalker->eCode = 0; return WRC_Abort; case TK_VARIABLE: if( pWalker->eCode==5 ){ /* Silently convert bound parameters that appear inside of CREATE ** statements into a NULL when parsing the CREATE statement text out ** of the sqlite_master table */ pExpr->op = TK_NULL; }else if( pWalker->eCode==4 ){ /* A bound parameter in a CREATE statement that originates from ** sqlite3_prepare() causes an error */ pWalker->eCode = 0; return WRC_Abort; } /* Fall through */ default: | > > | | | 95970 95971 95972 95973 95974 95975 95976 95977 95978 95979 95980 95981 95982 95983 95984 95985 95986 95987 95988 95989 95990 95991 95992 95993 95994 95995 95996 95997 95998 95999 96000 96001 96002 96003 96004 | testcase( pExpr->op==TK_AGG_FUNCTION ); testcase( pExpr->op==TK_AGG_COLUMN ); if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){ return WRC_Continue; } /* Fall through */ case TK_IF_NULL_ROW: case TK_REGISTER: testcase( pExpr->op==TK_REGISTER ); testcase( pExpr->op==TK_IF_NULL_ROW ); pWalker->eCode = 0; return WRC_Abort; case TK_VARIABLE: if( pWalker->eCode==5 ){ /* Silently convert bound parameters that appear inside of CREATE ** statements into a NULL when parsing the CREATE statement text out ** of the sqlite_master table */ pExpr->op = TK_NULL; }else if( pWalker->eCode==4 ){ /* A bound parameter in a CREATE statement that originates from ** sqlite3_prepare() causes an error */ pWalker->eCode = 0; return WRC_Abort; } /* Fall through */ default: testcase( pExpr->op==TK_SELECT ); /* sqlite3SelectWalkFail() disallows */ testcase( pExpr->op==TK_EXISTS ); /* sqlite3SelectWalkFail() disallows */ return WRC_Continue; } } static int exprIsConst(Expr *p, int initFlag, int iCur){ Walker w; w.eCode = initFlag; w.xExprCallback = exprNodeIsConstant; |
︙ | ︙ | |||
98077 98078 98079 98080 98081 98082 98083 98084 98085 98086 98087 98088 98089 98090 | assert( pList!=0 ); assert( target>0 ); assert( pParse->pVdbe!=0 ); /* Never gets this far otherwise */ n = pList->nExpr; if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR; for(pItem=pList->a, i=0; i<n; i++, pItem++){ Expr *pExpr = pItem->pExpr; if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){ if( flags & SQLITE_ECEL_OMITREF ){ i--; n--; }else{ sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i); } | > > > > > > | 98518 98519 98520 98521 98522 98523 98524 98525 98526 98527 98528 98529 98530 98531 98532 98533 98534 98535 98536 98537 | assert( pList!=0 ); assert( target>0 ); assert( pParse->pVdbe!=0 ); /* Never gets this far otherwise */ n = pList->nExpr; if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR; for(pItem=pList->a, i=0; i<n; i++, pItem++){ Expr *pExpr = pItem->pExpr; #ifdef SQLITE_ENABLE_SORTER_REFERENCES if( pItem->bSorterRef ){ i--; n--; }else #endif if( (flags & SQLITE_ECEL_REF)!=0 && (j = pItem->u.x.iOrderByCol)>0 ){ if( flags & SQLITE_ECEL_OMITREF ){ i--; n--; }else{ sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i); } |
︙ | ︙ | |||
98605 98606 98607 98608 98609 98610 98611 98612 | return 1; } return 2; } if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){ if( pA->op==TK_FUNCTION ){ if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ | > > | | 99052 99053 99054 99055 99056 99057 99058 99059 99060 99061 99062 99063 99064 99065 99066 99067 99068 99069 | return 1; } return 2; } if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){ if( pA->op==TK_FUNCTION ){ if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; }else if( pA->op==TK_COLLATE ){ if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ return 2; } } if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2; if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){ if( combinedFlags & EP_xIsSelect ) return 2; if( sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2; if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2; |
︙ | ︙ | |||
98713 98714 98715 98716 98717 98718 98719 98720 98721 98722 98723 98724 | /* ** This is the Expr node callback for sqlite3ExprImpliesNotNullRow(). ** If the expression node requires that the table at pWalker->iCur ** have a non-NULL column, then set pWalker->eCode to 1 and abort. */ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune; switch( pExpr->op ){ case TK_ISNULL: case TK_IS: case TK_OR: | > > > > > > > > > > > | | > > > > > > > > > < > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 99162 99163 99164 99165 99166 99167 99168 99169 99170 99171 99172 99173 99174 99175 99176 99177 99178 99179 99180 99181 99182 99183 99184 99185 99186 99187 99188 99189 99190 99191 99192 99193 99194 99195 99196 99197 99198 99199 99200 99201 99202 99203 99204 99205 99206 99207 99208 99209 99210 99211 99212 99213 99214 99215 99216 99217 99218 99219 99220 99221 99222 99223 99224 99225 99226 99227 99228 99229 99230 99231 99232 99233 99234 99235 99236 99237 99238 99239 99240 99241 99242 99243 99244 99245 99246 99247 | /* ** This is the Expr node callback for sqlite3ExprImpliesNotNullRow(). ** If the expression node requires that the table at pWalker->iCur ** have a non-NULL column, then set pWalker->eCode to 1 and abort. */ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ /* This routine is only called for WHERE clause expressions and so it ** cannot have any TK_AGG_COLUMN entries because those are only found ** in HAVING clauses. We can get a TK_AGG_FUNCTION in a WHERE clause, ** but that is an illegal construct and the query will be rejected at ** a later stage of processing, so the TK_AGG_FUNCTION case does not ** need to be considered here. */ assert( pExpr->op!=TK_AGG_COLUMN ); testcase( pExpr->op==TK_AGG_FUNCTION ); if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune; switch( pExpr->op ){ case TK_ISNOT: case TK_NOT: case TK_ISNULL: case TK_IS: case TK_OR: case TK_CASE: case TK_IN: case TK_FUNCTION: testcase( pExpr->op==TK_ISNOT ); testcase( pExpr->op==TK_NOT ); testcase( pExpr->op==TK_ISNULL ); testcase( pExpr->op==TK_IS ); testcase( pExpr->op==TK_OR ); testcase( pExpr->op==TK_CASE ); testcase( pExpr->op==TK_IN ); testcase( pExpr->op==TK_FUNCTION ); return WRC_Prune; case TK_COLUMN: if( pWalker->u.iCur==pExpr->iTable ){ pWalker->eCode = 1; return WRC_Abort; } return WRC_Prune; /* Virtual tables are allowed to use constraints like x=NULL. So ** a term of the form x=y does not prove that y is not null if x ** is the column of a virtual table */ case TK_EQ: case TK_NE: case TK_LT: case TK_LE: case TK_GT: case TK_GE: testcase( pExpr->op==TK_EQ ); testcase( pExpr->op==TK_NE ); testcase( pExpr->op==TK_LT ); testcase( pExpr->op==TK_LE ); testcase( pExpr->op==TK_GT ); testcase( pExpr->op==TK_GE ); if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab)) || (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab)) ){ return WRC_Prune; } default: return WRC_Continue; } } /* ** Return true (non-zero) if expression p can only be true if at least ** one column of table iTab is non-null. In other words, return true ** if expression p will always be NULL or false if every column of iTab ** is NULL. ** ** False negatives are acceptable. In other words, it is ok to return ** zero even if expression p will never be true of every column of iTab ** is NULL. A false negative is merely a missed optimization opportunity. ** ** False positives are not allowed, however. A false positive may result ** in an incorrect answer. ** ** Terms of p that are marked with EP_FromJoin (and hence that come from ** the ON or USING clauses of LEFT JOINS) are excluded from the analysis. ** ** This routine is used to check if a LEFT JOIN can be converted into ** an ordinary JOIN. The p argument is the WHERE clause. If the WHERE ** clause requires that some column of the right table of the LEFT JOIN |
︙ | ︙ | |||
98914 98915 98916 98917 98918 98919 98920 | ** for additional information. */ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ int i; NameContext *pNC = pWalker->u.pNC; Parse *pParse = pNC->pParse; SrcList *pSrcList = pNC->pSrcList; | | > | 99410 99411 99412 99413 99414 99415 99416 99417 99418 99419 99420 99421 99422 99423 99424 99425 99426 | ** for additional information. */ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ int i; NameContext *pNC = pWalker->u.pNC; Parse *pParse = pNC->pParse; SrcList *pSrcList = pNC->pSrcList; AggInfo *pAggInfo = pNC->uNC.pAggInfo; assert( pNC->ncFlags & NC_UAggInfo ); switch( pExpr->op ){ case TK_AGG_COLUMN: case TK_COLUMN: { testcase( pExpr->op==TK_AGG_COLUMN ); testcase( pExpr->op==TK_COLUMN ); /* Check to see if the column is in one of the tables in the FROM ** clause of the aggregate query */ |
︙ | ︙ | |||
101003 101004 101005 101006 101007 101008 101009 | if( v==0 || NEVER(pTab==0) ){ return; } if( pTab->tnum==0 ){ /* Do not gather statistics on views or virtual tables */ return; } | | | 101500 101501 101502 101503 101504 101505 101506 101507 101508 101509 101510 101511 101512 101513 101514 | if( v==0 || NEVER(pTab==0) ){ return; } if( pTab->tnum==0 ){ /* Do not gather statistics on views or virtual tables */ return; } if( sqlite3_strlike("sqlite\\_%", pTab->zName, '\\')==0 ){ /* Do not gather statistics on system tables */ return; } assert( sqlite3BtreeHoldsAllMutexes(db) ); iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( iDb>=0 ); assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
︙ | ︙ | |||
102429 102430 102431 102432 102433 102434 102435 102436 102437 102438 102439 102440 102441 102442 | pItem->zDatabase = 0; pItem->pSchema = pFix->pSchema; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1; if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1; #endif } return 0; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) SQLITE_PRIVATE int sqlite3FixSelect( DbFixer *pFix, /* Context of the fixation */ Select *pSelect /* The SELECT statement to be fixed to one database */ | > > > | 102926 102927 102928 102929 102930 102931 102932 102933 102934 102935 102936 102937 102938 102939 102940 102941 102942 | pItem->zDatabase = 0; pItem->pSchema = pFix->pSchema; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) if( sqlite3FixSelect(pFix, pItem->pSelect) ) return 1; if( sqlite3FixExpr(pFix, pItem->pOn) ) return 1; #endif if( pItem->fg.isTabFunc && sqlite3FixExprList(pFix, pItem->u1.pFuncArg) ){ return 1; } } return 0; } #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) SQLITE_PRIVATE int sqlite3FixSelect( DbFixer *pFix, /* Context of the fixation */ Select *pSelect /* The SELECT statement to be fixed to one database */ |
︙ | ︙ | |||
103907 103908 103909 103910 103911 103912 103913 | pCol = &p->aCol[p->nCol]; memset(pCol, 0, sizeof(p->aCol[0])); pCol->zName = z; sqlite3ColumnPropertiesFromName(p, pCol); if( pType->n==0 ){ /* If there is no type specified, columns have the default affinity | | > > > > > | | 104407 104408 104409 104410 104411 104412 104413 104414 104415 104416 104417 104418 104419 104420 104421 104422 104423 104424 104425 104426 104427 104428 104429 104430 104431 104432 104433 104434 | pCol = &p->aCol[p->nCol]; memset(pCol, 0, sizeof(p->aCol[0])); pCol->zName = z; sqlite3ColumnPropertiesFromName(p, pCol); if( pType->n==0 ){ /* If there is no type specified, columns have the default affinity ** 'BLOB' with a default size of 4 bytes. */ pCol->affinity = SQLITE_AFF_BLOB; pCol->szEst = 1; #ifdef SQLITE_ENABLE_SORTER_REFERENCES if( 4>=sqlite3GlobalConfig.szSorterRef ){ pCol->colFlags |= COLFLAG_SORTERREF; } #endif }else{ zType = z + sqlite3Strlen30(z) + 1; memcpy(zType, pType->z, pType->n); zType[pType->n] = 0; sqlite3Dequote(zType); pCol->affinity = sqlite3AffinityType(zType, pCol); pCol->colFlags |= COLFLAG_HASTYPE; } p->nCol++; pParse->constraintName.n = 0; } /* |
︙ | ︙ | |||
103975 103976 103977 103978 103979 103980 103981 | ** 'REAL' | SQLITE_AFF_REAL ** 'FLOA' | SQLITE_AFF_REAL ** 'DOUB' | SQLITE_AFF_REAL ** ** If none of the substrings in the above table are found, ** SQLITE_AFF_NUMERIC is returned. */ | | | 104480 104481 104482 104483 104484 104485 104486 104487 104488 104489 104490 104491 104492 104493 104494 | ** 'REAL' | SQLITE_AFF_REAL ** 'FLOA' | SQLITE_AFF_REAL ** 'DOUB' | SQLITE_AFF_REAL ** ** If none of the substrings in the above table are found, ** SQLITE_AFF_NUMERIC is returned. */ SQLITE_PRIVATE char sqlite3AffinityType(const char *zIn, Column *pCol){ u32 h = 0; char aff = SQLITE_AFF_NUMERIC; const char *zChar = 0; assert( zIn!=0 ); while( zIn[0] ){ h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff]; |
︙ | ︙ | |||
104012 104013 104014 104015 104016 104017 104018 | #endif }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){ /* INT */ aff = SQLITE_AFF_INTEGER; break; } } | | | | | < < < | > > > > > > > > | 104517 104518 104519 104520 104521 104522 104523 104524 104525 104526 104527 104528 104529 104530 104531 104532 104533 104534 104535 104536 104537 104538 104539 104540 104541 104542 104543 104544 104545 104546 104547 104548 104549 104550 104551 104552 104553 104554 104555 104556 | #endif }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){ /* INT */ aff = SQLITE_AFF_INTEGER; break; } } /* If pCol is not NULL, store an estimate of the field size. The ** estimate is scaled so that the size of an integer is 1. */ if( pCol ){ int v = 0; /* default size is approx 4 bytes */ if( aff<SQLITE_AFF_NUMERIC ){ if( zChar ){ while( zChar[0] ){ if( sqlite3Isdigit(zChar[0]) ){ /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */ sqlite3GetInt32(zChar, &v); break; } zChar++; } }else{ v = 16; /* BLOB, TEXT, CLOB -> r=5 (approx 20 bytes)*/ } } #ifdef SQLITE_ENABLE_SORTER_REFERENCES if( v>=sqlite3GlobalConfig.szSorterRef ){ pCol->colFlags |= COLFLAG_SORTERREF; } #endif v = v/4 + 1; if( v>255 ) v = 255; pCol->szEst = v; } return aff; } /* ** The expression is the default value for the most recently added column ** of the table currently under construction. |
︙ | ︙ | |||
104064 104065 104066 104067 104068 104069 104070 | if( p!=0 ){ pCol = &(p->aCol[p->nCol-1]); if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){ sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", pCol->zName); }else{ /* A copy of pExpr is used instead of the original, as pExpr contains | | | 104574 104575 104576 104577 104578 104579 104580 104581 104582 104583 104584 104585 104586 104587 104588 | if( p!=0 ){ pCol = &(p->aCol[p->nCol-1]); if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){ sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", pCol->zName); }else{ /* A copy of pExpr is used instead of the original, as pExpr contains ** tokens that point to volatile memory. */ Expr x; sqlite3ExprDelete(db, pCol->pDflt); memset(&x, 0, sizeof(x)); x.op = TK_SPAN; x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd); x.pLeft = pExpr; |
︙ | ︙ | |||
104308 104309 104310 104311 104312 104313 104314 | ** the schema-version whenever the schema changes. */ SQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){ sqlite3 *db = pParse->db; Vdbe *v = pParse->pVdbe; assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, | | | 104818 104819 104820 104821 104822 104823 104824 104825 104826 104827 104828 104829 104830 104831 104832 | ** the schema-version whenever the schema changes. */ SQLITE_PRIVATE void sqlite3ChangeCookie(Parse *pParse, int iDb){ sqlite3 *db = pParse->db; Vdbe *v = pParse->pVdbe; assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, (int)(1+(unsigned)db->aDb[iDb].pSchema->schema_cookie)); } /* ** Measure the number of characters needed to output the given ** identifier. The number returned includes any quotes used ** but does not include the null terminator. ** |
︙ | ︙ | |||
104986 104987 104988 104989 104990 104991 104992 | */ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ Table *pSelTab; /* A fake table from which we get the result set */ Select *pSel; /* Copy of the SELECT that implements the view */ int nErr = 0; /* Number of errors encountered */ int n; /* Temporarily holds the number of cursors assigned */ sqlite3 *db = pParse->db; /* Database connection for malloc errors */ | | | 105496 105497 105498 105499 105500 105501 105502 105503 105504 105505 105506 105507 105508 105509 105510 | */ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ Table *pSelTab; /* A fake table from which we get the result set */ Select *pSel; /* Copy of the SELECT that implements the view */ int nErr = 0; /* Number of errors encountered */ int n; /* Temporarily holds the number of cursors assigned */ sqlite3 *db = pParse->db; /* Database connection for malloc errors */ #ifndef SQLITE_OMIT_VIRTUALTABLE int rc; #endif #ifndef SQLITE_OMIT_AUTHORIZATION sqlite3_xauth xAuth; /* Saved xAuth pointer */ #endif assert( pTable ); |
︙ | ︙ | |||
108017 108018 108019 108020 108021 108022 108023 | int iDataCur = 0; /* VDBE cursor for the canonical data source */ int iIdxCur = 0; /* Cursor number of the first index */ int nIdx; /* Number of indices */ sqlite3 *db; /* Main database structure */ AuthContext sContext; /* Authorization context */ NameContext sNC; /* Name context to resolve expressions in */ int iDb; /* Database number */ | | | 108527 108528 108529 108530 108531 108532 108533 108534 108535 108536 108537 108538 108539 108540 108541 | int iDataCur = 0; /* VDBE cursor for the canonical data source */ int iIdxCur = 0; /* Cursor number of the first index */ int nIdx; /* Number of indices */ sqlite3 *db; /* Main database structure */ AuthContext sContext; /* Authorization context */ NameContext sNC; /* Name context to resolve expressions in */ int iDb; /* Database number */ int memCnt = 0; /* Memory cell used for change counting */ int rcauth; /* Value returned by authorization callback */ int eOnePass; /* ONEPASS_OFF or _SINGLE or _MULTI */ int aiCurOnePass[2]; /* The write cursors opened by WHERE_ONEPASS */ u8 *aToOpen = 0; /* Open cursor iTabCur+j if aToOpen[j] is true */ Index *pPk; /* The PRIMARY KEY index on the table */ int iPk = 0; /* First of nPk registers holding PRIMARY KEY value */ i16 nPk = 1; /* Number of columns in the PRIMARY KEY */ |
︙ | ︙ | |||
108122 108123 108124 108125 108126 108127 108128 | /* Begin generating code. */ v = sqlite3GetVdbe(pParse); if( v==0 ){ goto delete_from_cleanup; } if( pParse->nested==0 ) sqlite3VdbeCountChanges(v); | | | 108632 108633 108634 108635 108636 108637 108638 108639 108640 108641 108642 108643 108644 108645 108646 | /* Begin generating code. */ v = sqlite3GetVdbe(pParse); if( v==0 ){ goto delete_from_cleanup; } if( pParse->nested==0 ) sqlite3VdbeCountChanges(v); sqlite3BeginWriteOperation(pParse, bComplex, iDb); /* If we are trying to delete from a view, realize that view into ** an ephemeral table. */ #if !defined(SQLITE_OMIT_VIEW) && !defined(SQLITE_OMIT_TRIGGER) if( isView ){ sqlite3MaterializeView(pParse, pTab, |
︙ | ︙ | |||
108150 108151 108152 108153 108154 108155 108156 | if( sqlite3ResolveExprNames(&sNC, pWhere) ){ goto delete_from_cleanup; } /* Initialize the counter of the number of rows deleted, if ** we are counting rows. */ | | > > > | 108660 108661 108662 108663 108664 108665 108666 108667 108668 108669 108670 108671 108672 108673 108674 108675 108676 108677 | if( sqlite3ResolveExprNames(&sNC, pWhere) ){ goto delete_from_cleanup; } /* Initialize the counter of the number of rows deleted, if ** we are counting rows. */ if( (db->flags & SQLITE_CountRows)!=0 && !pParse->nested && !pParse->pTriggerTab ){ memCnt = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt); } #ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION /* Special case: A DELETE without a WHERE clause deletes everything. ** It is easier just to erase the whole table. Prior to version 3.6.5, |
︙ | ︙ | |||
108178 108179 108180 108181 108182 108183 108184 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK && db->xPreUpdateCallback==0 #endif ){ assert( !isView ); sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName); if( HasRowid(pTab) ){ | | | 108691 108692 108693 108694 108695 108696 108697 108698 108699 108700 108701 108702 108703 108704 108705 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK && db->xPreUpdateCallback==0 #endif ){ assert( !isView ); sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName); if( HasRowid(pTab) ){ sqlite3VdbeAddOp4(v, OP_Clear, pTab->tnum, iDb, memCnt ? memCnt : -1, pTab->zName, P4_STATIC); } for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ assert( pIdx->pSchema==pTab->pSchema ); sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb); } }else |
︙ | ︙ | |||
108223 108224 108225 108226 108227 108228 108229 108230 108231 | ** ONEPASS_MULTI: One-pass approach - any number of rows may be deleted. */ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1); if( pWInfo==0 ) goto delete_from_cleanup; eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI ); assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF ); /* Keep track of the number of rows to be deleted */ | > | | 108736 108737 108738 108739 108740 108741 108742 108743 108744 108745 108746 108747 108748 108749 108750 108751 108752 108753 | ** ONEPASS_MULTI: One-pass approach - any number of rows may be deleted. */ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1); if( pWInfo==0 ) goto delete_from_cleanup; eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI ); assert( IsVirtual(pTab) || bComplex || eOnePass!=ONEPASS_OFF ); if( eOnePass!=ONEPASS_SINGLE ) sqlite3MultiWrite(pParse); /* Keep track of the number of rows to be deleted */ if( memCnt ){ sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1); } /* Extract the rowid or primary key for the current row */ if( pPk ){ for(i=0; i<nPk; i++){ assert( pPk->aiColumn[i]>=0 ); |
︙ | ︙ | |||
108368 108369 108370 108371 108372 108373 108374 | sqlite3AutoincrementEnd(pParse); } /* Return the number of rows that were deleted. If this routine is ** generating code because of a call to sqlite3NestedParse(), do not ** invoke the callback function. */ | | | 108882 108883 108884 108885 108886 108887 108888 108889 108890 108891 108892 108893 108894 108895 108896 | sqlite3AutoincrementEnd(pParse); } /* Return the number of rows that were deleted. If this routine is ** generating code because of a call to sqlite3NestedParse(), do not ** invoke the callback function. */ if( memCnt ){ sqlite3VdbeAddOp2(v, OP_ResultRow, memCnt, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC); } delete_from_cleanup: sqlite3AuthContextPop(&sContext); |
︙ | ︙ | |||
112550 112551 112552 112553 112554 112555 112556 | ** D: cleanup */ SQLITE_PRIVATE void sqlite3Insert( Parse *pParse, /* Parser context */ SrcList *pTabList, /* Name of table into which we are inserting */ Select *pSelect, /* A SELECT statement to use as the data source */ IdList *pColumn, /* Column names corresponding to IDLIST. */ | | > | 113064 113065 113066 113067 113068 113069 113070 113071 113072 113073 113074 113075 113076 113077 113078 113079 | ** D: cleanup */ SQLITE_PRIVATE void sqlite3Insert( Parse *pParse, /* Parser context */ SrcList *pTabList, /* Name of table into which we are inserting */ Select *pSelect, /* A SELECT statement to use as the data source */ IdList *pColumn, /* Column names corresponding to IDLIST. */ int onError, /* How to handle constraint errors */ Upsert *pUpsert /* ON CONFLICT clauses for upsert, or NULL */ ){ sqlite3 *db; /* The main database structure */ Table *pTab; /* The table to insert into. aka TABLE */ int i, j; /* Loop counters */ Vdbe *v; /* Generate code into this virtual machine */ Index *pIdx; /* For looping over indices of the table */ int nColumn; /* Number of columns in the data */ |
︙ | ︙ | |||
112845 112846 112847 112848 112849 112850 112851 | if( pColumn!=0 && nColumn!=pColumn->nId ){ sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId); goto insert_cleanup; } /* Initialize the count of rows to be inserted */ | | > > > > > > > > > > > > > > > > | 113360 113361 113362 113363 113364 113365 113366 113367 113368 113369 113370 113371 113372 113373 113374 113375 113376 113377 113378 113379 113380 113381 113382 113383 113384 113385 113386 113387 113388 113389 113390 113391 113392 113393 113394 113395 113396 113397 113398 113399 113400 113401 113402 113403 113404 113405 113406 113407 113408 113409 | if( pColumn!=0 && nColumn!=pColumn->nId ){ sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId); goto insert_cleanup; } /* Initialize the count of rows to be inserted */ if( (db->flags & SQLITE_CountRows)!=0 && !pParse->nested && !pParse->pTriggerTab ){ regRowCount = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); } /* If this is not a view, open the table and and all indices */ if( !isView ){ int nIdx; nIdx = sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, -1, 0, &iDataCur, &iIdxCur); aRegIdx = sqlite3DbMallocRawNN(db, sizeof(int)*(nIdx+1)); if( aRegIdx==0 ){ goto insert_cleanup; } for(i=0, pIdx=pTab->pIndex; i<nIdx; pIdx=pIdx->pNext, i++){ assert( pIdx ); aRegIdx[i] = ++pParse->nMem; pParse->nMem += pIdx->nColumn; } } #ifndef SQLITE_OMIT_UPSERT if( pUpsert ){ pTabList->a[0].iCursor = iDataCur; pUpsert->pUpsertSrc = pTabList; pUpsert->regData = regData; pUpsert->iDataCur = iDataCur; pUpsert->iIdxCur = iIdxCur; if( pUpsert->pUpsertTarget ){ sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert); } } #endif /* This is the top of the main insertion loop */ if( useTempTable ){ /* This block codes the top of loop only. The complete loop is the ** following pseudocode (template 4): ** ** rewind temp table, if empty goto D |
︙ | ︙ | |||
113067 113068 113069 113070 113071 113072 113073 | sqlite3MayAbort(pParse); }else #endif { int isReplace; /* Set to true if constraints may cause a replace */ int bUseSeek; /* True to use OPFLAG_SEEKRESULT */ sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, | | | 113598 113599 113600 113601 113602 113603 113604 113605 113606 113607 113608 113609 113610 113611 113612 | sqlite3MayAbort(pParse); }else #endif { int isReplace; /* Set to true if constraints may cause a replace */ int bUseSeek; /* True to use OPFLAG_SEEKRESULT */ sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, regIns, 0, ipkColumn>=0, onError, endOfLoop, &isReplace, 0, pUpsert ); sqlite3FkCheck(pParse, pTab, 0, regIns, 0, 0); /* Set the OPFLAG_USESEEKRESULT flag if either (a) there are no REPLACE ** constraints or (b) there are no triggers and this table is not a ** parent table in a foreign key constraint. It is safe to set the ** flag in the second case as if any REPLACE constraint is hit, an |
︙ | ︙ | |||
113090 113091 113092 113093 113094 113095 113096 | regIns, aRegIdx, 0, appendFlag, bUseSeek ); } } /* Update the count of rows that are inserted */ | | | 113621 113622 113623 113624 113625 113626 113627 113628 113629 113630 113631 113632 113633 113634 113635 | regIns, aRegIdx, 0, appendFlag, bUseSeek ); } } /* Update the count of rows that are inserted */ if( regRowCount ){ sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); } if( pTrigger ){ /* Code AFTER triggers */ sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER, pTab, regData-2-pTab->nCol, onError, endOfLoop); |
︙ | ︙ | |||
113127 113128 113129 113130 113131 113132 113133 | } /* ** Return the number of rows inserted. If this routine is ** generating code because of a call to sqlite3NestedParse(), do not ** invoke the callback function. */ | | > | 113658 113659 113660 113661 113662 113663 113664 113665 113666 113667 113668 113669 113670 113671 113672 113673 113674 113675 113676 113677 113678 113679 113680 113681 | } /* ** Return the number of rows inserted. If this routine is ** generating code because of a call to sqlite3NestedParse(), do not ** invoke the callback function. */ if( regRowCount ){ sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC); } insert_cleanup: sqlite3SrcListDelete(db, pTabList); sqlite3ExprListDelete(db, pList); sqlite3UpsertDelete(db, pUpsert); sqlite3SelectDelete(db, pSelect); sqlite3IdListDelete(db, pColumn); sqlite3DbFree(db, aRegIdx); } /* Make sure "isView" and other macros defined above are undefined. Otherwise ** they may interfere with compilation of other functions in this file |
︙ | ︙ | |||
113206 113207 113208 113209 113210 113211 113212 113213 113214 113215 113216 113217 113218 113219 | } testcase( w.eCode==0 ); testcase( w.eCode==CKCNSTRNT_COLUMN ); testcase( w.eCode==CKCNSTRNT_ROWID ); testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) ); return !w.eCode; } /* ** Generate code to do constraint checks prior to an INSERT or an UPDATE ** on table pTab. ** ** The regNewData parameter is the first register in a range that contains ** the data to be inserted or the data after the update. There will be | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 113738 113739 113740 113741 113742 113743 113744 113745 113746 113747 113748 113749 113750 113751 113752 113753 113754 113755 113756 113757 113758 113759 113760 113761 113762 113763 113764 113765 113766 113767 113768 113769 113770 113771 113772 113773 113774 113775 113776 113777 113778 113779 113780 113781 113782 113783 113784 113785 113786 113787 113788 113789 | } testcase( w.eCode==0 ); testcase( w.eCode==CKCNSTRNT_COLUMN ); testcase( w.eCode==CKCNSTRNT_ROWID ); testcase( w.eCode==(CKCNSTRNT_ROWID|CKCNSTRNT_COLUMN) ); return !w.eCode; } /* ** An instance of the ConstraintAddr object remembers the byte-code addresses ** for sections of the constraint checks that deal with uniqueness constraints ** on the rowid and on the upsert constraint. ** ** This information is passed into checkReorderConstraintChecks() to insert ** some OP_Goto operations so that the rowid and upsert constraints occur ** in the correct order relative to other constraints. */ typedef struct ConstraintAddr ConstraintAddr; struct ConstraintAddr { int ipkTop; /* Subroutine for rowid constraint check */ int upsertTop; /* Label for upsert constraint check subroutine */ int upsertTop2; /* Copy of upsertTop not cleared by the call */ int upsertBtm; /* upsert constraint returns to this label */ int ipkBtm; /* Return opcode rowid constraint check */ }; /* ** Generate any OP_Goto operations needed to cause constraints to be ** run that haven't already been run. */ static void reorderConstraintChecks(Vdbe *v, ConstraintAddr *p){ if( p->upsertTop ){ testcase( sqlite3VdbeLabelHasBeenResolved(v, p->upsertTop) ); sqlite3VdbeGoto(v, p->upsertTop); VdbeComment((v, "call upsert subroutine")); sqlite3VdbeResolveLabel(v, p->upsertBtm); p->upsertTop = 0; } if( p->ipkTop ){ sqlite3VdbeGoto(v, p->ipkTop); VdbeComment((v, "call rowid unique-check subroutine")); sqlite3VdbeJumpHere(v, p->ipkBtm); p->ipkTop = 0; } } /* ** Generate code to do constraint checks prior to an INSERT or an UPDATE ** on table pTab. ** ** The regNewData parameter is the first register in a range that contains ** the data to be inserted or the data after the update. There will be |
︙ | ︙ | |||
113302 113303 113304 113305 113306 113307 113308 | int iIdxCur, /* First index cursor */ int regNewData, /* First register in a range holding values to insert */ int regOldData, /* Previous content. 0 for INSERTs */ u8 pkChng, /* Non-zero if the rowid or PRIMARY KEY changed */ u8 overrideError, /* Override onError to this if not OE_Default */ int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ int *pbMayReplace, /* OUT: Set to true if constraint may cause a replace */ | | > | | > > | 113872 113873 113874 113875 113876 113877 113878 113879 113880 113881 113882 113883 113884 113885 113886 113887 113888 113889 113890 113891 113892 113893 113894 113895 113896 113897 113898 113899 113900 113901 113902 113903 113904 113905 113906 113907 113908 113909 113910 113911 113912 | int iIdxCur, /* First index cursor */ int regNewData, /* First register in a range holding values to insert */ int regOldData, /* Previous content. 0 for INSERTs */ u8 pkChng, /* Non-zero if the rowid or PRIMARY KEY changed */ u8 overrideError, /* Override onError to this if not OE_Default */ int ignoreDest, /* Jump to this label on an OE_Ignore resolution */ int *pbMayReplace, /* OUT: Set to true if constraint may cause a replace */ int *aiChng, /* column i is unchanged if aiChng[i]<0 */ Upsert *pUpsert /* ON CONFLICT clauses, if any. NULL otherwise */ ){ Vdbe *v; /* VDBE under constrution */ Index *pIdx; /* Pointer to one of the indices */ Index *pPk = 0; /* The PRIMARY KEY index */ sqlite3 *db; /* Database connection */ int i; /* loop counter */ int ix; /* Index loop counter */ int nCol; /* Number of columns */ int onError; /* Conflict resolution strategy */ int addr1; /* Address of jump instruction */ int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */ int nPkField; /* Number of fields in PRIMARY KEY. 1 for ROWID tables */ ConstraintAddr sAddr;/* Address information for constraint reordering */ Index *pUpIdx = 0; /* Index to which to apply the upsert */ u8 isUpdate; /* True if this is an UPDATE operation */ u8 bAffinityDone = 0; /* True if the OP_Affinity operation has been run */ int upsertBypass = 0; /* Address of Goto to bypass upsert subroutine */ isUpdate = regOldData!=0; db = pParse->db; v = sqlite3GetVdbe(pParse); assert( v!=0 ); assert( pTab->pSelect==0 ); /* This table is not a VIEW */ nCol = pTab->nCol; memset(&sAddr, 0, sizeof(sAddr)); /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for ** normal rowid tables. nPkField is the number of key fields in the ** pPk index or 1 for a rowid table. In other words, nPkField is the ** number of fields in the true primary key of the table. */ if( HasRowid(pTab) ){ pPk = 0; |
︙ | ︙ | |||
113424 113425 113426 113427 113428 113429 113430 113431 113432 113433 113434 113435 113436 113437 113438 113439 113440 113441 113442 113443 113444 113445 113446 113447 113448 113449 113450 113451 113452 113453 113454 | P5_ConstraintCheck); } sqlite3VdbeResolveLabel(v, allOk); } pParse->iSelfTab = 0; } #endif /* !defined(SQLITE_OMIT_CHECK) */ /* If rowid is changing, make sure the new rowid does not previously ** exist in the table. */ if( pkChng && pPk==0 ){ int addrRowidOk = sqlite3VdbeMakeLabel(v); /* Figure out what action to take in case of a rowid collision */ onError = pTab->keyConf; if( overrideError!=OE_Default ){ onError = overrideError; }else if( onError==OE_Default ){ onError = OE_Abort; } if( isUpdate ){ /* pkChng!=0 does not mean that the rowid has changed, only that ** it might have changed. Skip the conflict logic below if the rowid ** is unchanged. */ sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData); sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); VdbeCoverage(v); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < < < < < < < < < < < < < < > < > > > | 113997 113998 113999 114000 114001 114002 114003 114004 114005 114006 114007 114008 114009 114010 114011 114012 114013 114014 114015 114016 114017 114018 114019 114020 114021 114022 114023 114024 114025 114026 114027 114028 114029 114030 114031 114032 114033 114034 114035 114036 114037 114038 114039 114040 114041 114042 114043 114044 114045 114046 114047 114048 114049 114050 114051 114052 114053 114054 114055 114056 114057 114058 114059 114060 114061 114062 114063 114064 114065 114066 114067 114068 114069 114070 114071 114072 114073 114074 114075 114076 114077 114078 114079 114080 114081 114082 114083 114084 114085 114086 114087 114088 114089 114090 114091 114092 114093 114094 114095 114096 114097 114098 114099 114100 114101 114102 114103 114104 114105 114106 114107 114108 114109 114110 114111 114112 114113 114114 114115 114116 114117 | P5_ConstraintCheck); } sqlite3VdbeResolveLabel(v, allOk); } pParse->iSelfTab = 0; } #endif /* !defined(SQLITE_OMIT_CHECK) */ /* UNIQUE and PRIMARY KEY constraints should be handled in the following ** order: ** ** (1) OE_Abort, OE_Fail, OE_Rollback, OE_Ignore ** (2) OE_Update ** (3) OE_Replace ** ** OE_Fail and OE_Ignore must happen before any changes are made. ** OE_Update guarantees that only a single row will change, so it ** must happen before OE_Replace. Technically, OE_Abort and OE_Rollback ** could happen in any order, but they are grouped up front for ** convenience. ** ** Constraint checking code is generated in this order: ** (A) The rowid constraint ** (B) Unique index constraints that do not have OE_Replace as their ** default conflict resolution strategy ** (C) Unique index that do use OE_Replace by default. ** ** The ordering of (2) and (3) is accomplished by making sure the linked ** list of indexes attached to a table puts all OE_Replace indexes last ** in the list. See sqlite3CreateIndex() for where that happens. */ if( pUpsert ){ if( pUpsert->pUpsertTarget==0 ){ /* An ON CONFLICT DO NOTHING clause, without a constraint-target. ** Make all unique constraint resolution be OE_Ignore */ assert( pUpsert->pUpsertSet==0 ); overrideError = OE_Ignore; pUpsert = 0; }else if( (pUpIdx = pUpsert->pUpsertIdx)!=0 ){ /* If the constraint-target is on some column other than ** then ROWID, then we might need to move the UPSERT around ** so that it occurs in the correct order. */ sAddr.upsertTop = sAddr.upsertTop2 = sqlite3VdbeMakeLabel(v); sAddr.upsertBtm = sqlite3VdbeMakeLabel(v); } } /* If rowid is changing, make sure the new rowid does not previously ** exist in the table. */ if( pkChng && pPk==0 ){ int addrRowidOk = sqlite3VdbeMakeLabel(v); /* Figure out what action to take in case of a rowid collision */ onError = pTab->keyConf; if( overrideError!=OE_Default ){ onError = overrideError; }else if( onError==OE_Default ){ onError = OE_Abort; } /* figure out whether or not upsert applies in this case */ if( pUpsert && pUpsert->pUpsertIdx==0 ){ if( pUpsert->pUpsertSet==0 ){ onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */ }else{ onError = OE_Update; /* DO UPDATE */ } } /* If the response to a rowid conflict is REPLACE but the response ** to some other UNIQUE constraint is FAIL or IGNORE, then we need ** to defer the running of the rowid conflict checking until after ** the UNIQUE constraints have run. */ assert( OE_Update>OE_Replace ); assert( OE_Ignore<OE_Replace ); assert( OE_Fail<OE_Replace ); assert( OE_Abort<OE_Replace ); assert( OE_Rollback<OE_Replace ); if( onError>=OE_Replace && (pUpsert || onError!=overrideError) && pTab->pIndex ){ sAddr.ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1; } if( isUpdate ){ /* pkChng!=0 does not mean that the rowid has changed, only that ** it might have changed. Skip the conflict logic below if the rowid ** is unchanged. */ sqlite3VdbeAddOp3(v, OP_Eq, regNewData, addrRowidOk, regOldData); sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); VdbeCoverage(v); } /* Check to see if the new rowid already exists in the table. Skip ** the following conflict logic if it does not. */ VdbeNoopComment((v, "uniqueness check for ROWID")); sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, addrRowidOk, regNewData); VdbeCoverage(v); switch( onError ){ default: { onError = OE_Abort; /* Fall thru into the next case */ } case OE_Rollback: case OE_Abort: case OE_Fail: { testcase( onError==OE_Rollback ); testcase( onError==OE_Abort ); testcase( onError==OE_Fail ); sqlite3RowidConstraint(pParse, onError, pTab); break; } case OE_Replace: { /* If there are DELETE triggers on this table and the ** recursive-triggers flag is set, call GenerateRowDelete() to ** remove the conflicting row from the table. This will fire |
︙ | ︙ | |||
113512 113513 113514 113515 113516 113517 113518 | } if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ sqlite3MultiWrite(pParse); sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, regNewData, 1, 0, OE_Replace, 1, -1); }else{ #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | | | | | | | | < > > > > > > < > | | | > > > > > > > > > | | 114140 114141 114142 114143 114144 114145 114146 114147 114148 114149 114150 114151 114152 114153 114154 114155 114156 114157 114158 114159 114160 114161 114162 114163 114164 114165 114166 114167 114168 114169 114170 114171 114172 114173 114174 114175 114176 114177 114178 114179 114180 114181 114182 114183 114184 114185 114186 114187 114188 114189 114190 114191 114192 114193 114194 114195 114196 114197 114198 114199 114200 114201 114202 114203 114204 114205 114206 114207 114208 114209 114210 114211 114212 114213 114214 114215 114216 114217 | } if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ sqlite3MultiWrite(pParse); sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, regNewData, 1, 0, OE_Replace, 1, -1); }else{ #ifdef SQLITE_ENABLE_PREUPDATE_HOOK assert( HasRowid(pTab) ); /* This OP_Delete opcode fires the pre-update-hook only. It does ** not modify the b-tree. It is more efficient to let the coming ** OP_Insert replace the existing entry than it is to delete the ** existing entry and then insert a new one. */ sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, OPFLAG_ISNOOP); sqlite3VdbeAppendP4(v, pTab, P4_TABLE); #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ if( pTab->pIndex ){ sqlite3MultiWrite(pParse); sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,-1); } } seenReplace = 1; break; } #ifndef SQLITE_OMIT_UPSERT case OE_Update: { sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, 0, iDataCur); /* Fall through */ } #endif case OE_Ignore: { testcase( onError==OE_Ignore ); sqlite3VdbeGoto(v, ignoreDest); break; } } sqlite3VdbeResolveLabel(v, addrRowidOk); if( sAddr.ipkTop ){ sAddr.ipkBtm = sqlite3VdbeAddOp0(v, OP_Goto); sqlite3VdbeJumpHere(v, sAddr.ipkTop-1); } } /* Test all UNIQUE constraints by creating entries for each UNIQUE ** index and making sure that duplicate entries do not already exist. ** Compute the revised record entries for indices as we go. ** ** This loop also handles the case of the PRIMARY KEY index for a ** WITHOUT ROWID table. */ for(ix=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, ix++){ int regIdx; /* Range of registers hold conent for pIdx */ int regR; /* Range of registers holding conflicting PK */ int iThisCur; /* Cursor for this UNIQUE index */ int addrUniqueOk; /* Jump here if the UNIQUE constraint is satisfied */ if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */ if( pUpIdx==pIdx ){ addrUniqueOk = sAddr.upsertBtm; upsertBypass = sqlite3VdbeGoto(v, 0); VdbeComment((v, "Skip upsert subroutine")); sqlite3VdbeResolveLabel(v, sAddr.upsertTop2); }else{ addrUniqueOk = sqlite3VdbeMakeLabel(v); } VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName)); if( bAffinityDone==0 ){ sqlite3TableAffinity(v, pTab, regNewData+1); bAffinityDone = 1; } iThisCur = iIdxCur+ix; /* Skip partial indices for which the WHERE clause is not true */ if( pIdx->pPartIdxWhere ){ sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[ix]); pParse->iSelfTab = -(regNewData+1); sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, addrUniqueOk, SQLITE_JUMPIFNULL); |
︙ | ︙ | |||
113620 113621 113622 113623 113624 113625 113626 113627 113628 113629 113630 113631 113632 113633 | continue; /* pIdx is not a UNIQUE index */ } if( overrideError!=OE_Default ){ onError = overrideError; }else if( onError==OE_Default ){ onError = OE_Abort; } /* Collision detection may be omitted if all of the following are true: ** (1) The conflict resolution algorithm is REPLACE ** (2) The table is a WITHOUT ROWID table ** (3) There are no secondary indexes on the table ** (4) No delete triggers need to be fired if there is a conflict ** (5) No FK constraint counters need to be updated if a conflict occurs. | > > > > > > > > > > > > > > > > > > | 114262 114263 114264 114265 114266 114267 114268 114269 114270 114271 114272 114273 114274 114275 114276 114277 114278 114279 114280 114281 114282 114283 114284 114285 114286 114287 114288 114289 114290 114291 114292 114293 | continue; /* pIdx is not a UNIQUE index */ } if( overrideError!=OE_Default ){ onError = overrideError; }else if( onError==OE_Default ){ onError = OE_Abort; } /* Figure out if the upsert clause applies to this index */ if( pUpIdx==pIdx ){ if( pUpsert->pUpsertSet==0 ){ onError = OE_Ignore; /* DO NOTHING is the same as INSERT OR IGNORE */ }else{ onError = OE_Update; /* DO UPDATE */ } } /* Invoke subroutines to handle IPK replace and upsert prior to running ** the first REPLACE constraint check. */ if( onError==OE_Replace ){ testcase( sAddr.ipkTop ); testcase( sAddr.upsertTop && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) ); reorderConstraintChecks(v, &sAddr); } /* Collision detection may be omitted if all of the following are true: ** (1) The conflict resolution algorithm is REPLACE ** (2) The table is a WITHOUT ROWID table ** (3) There are no secondary indexes on the table ** (4) No delete triggers need to be fired if there is a conflict ** (5) No FK constraint counters need to be updated if a conflict occurs. |
︙ | ︙ | |||
113703 113704 113705 113706 113707 113708 113709 | } } } } /* Generate code that executes if the new index entry is not unique */ assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail | | > > > > > > > > > > > > > | > | < < < > > > > | 114363 114364 114365 114366 114367 114368 114369 114370 114371 114372 114373 114374 114375 114376 114377 114378 114379 114380 114381 114382 114383 114384 114385 114386 114387 114388 114389 114390 114391 114392 114393 114394 114395 114396 114397 114398 114399 114400 114401 114402 114403 114404 114405 114406 114407 114408 114409 114410 114411 114412 114413 114414 114415 114416 114417 114418 114419 114420 114421 114422 114423 114424 114425 | } } } } /* Generate code that executes if the new index entry is not unique */ assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail || onError==OE_Ignore || onError==OE_Replace || onError==OE_Update ); switch( onError ){ case OE_Rollback: case OE_Abort: case OE_Fail: { testcase( onError==OE_Rollback ); testcase( onError==OE_Abort ); testcase( onError==OE_Fail ); sqlite3UniqueConstraint(pParse, onError, pIdx); break; } #ifndef SQLITE_OMIT_UPSERT case OE_Update: { sqlite3UpsertDoUpdate(pParse, pUpsert, pTab, pIdx, iIdxCur+ix); /* Fall through */ } #endif case OE_Ignore: { testcase( onError==OE_Ignore ); sqlite3VdbeGoto(v, ignoreDest); break; } default: { Trigger *pTrigger = 0; assert( onError==OE_Replace ); sqlite3MultiWrite(pParse); if( db->flags&SQLITE_RecTriggers ){ pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); } sqlite3GenerateRowDelete(pParse, pTab, pTrigger, iDataCur, iIdxCur, regR, nPkField, 0, OE_Replace, (pIdx==pPk ? ONEPASS_SINGLE : ONEPASS_OFF), iThisCur); seenReplace = 1; break; } } if( pUpIdx==pIdx ){ sqlite3VdbeJumpHere(v, upsertBypass); }else{ sqlite3VdbeResolveLabel(v, addrUniqueOk); } sqlite3ExprCachePop(pParse); if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField); } testcase( sAddr.ipkTop!=0 ); testcase( sAddr.upsertTop && sqlite3VdbeLabelHasBeenResolved(v,sAddr.upsertTop) ); reorderConstraintChecks(v, &sAddr); *pbMayReplace = seenReplace; VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace)); } #ifdef SQLITE_ENABLE_NULL_TRIM /* |
︙ | ︙ | |||
119963 119964 119965 119966 119967 119968 119969 119970 119971 119972 119973 119974 119975 119976 119977 119978 119979 119980 119981 119982 119983 119984 119985 119986 119987 119988 | int tabTnct; /* Ephemeral table used for DISTINCT processing */ int addrTnct; /* Address of OP_OpenEphemeral opcode for tabTnct */ }; /* ** An instance of the following object is used to record information about ** the ORDER BY (or GROUP BY) clause of query is being coded. */ typedef struct SortCtx SortCtx; struct SortCtx { ExprList *pOrderBy; /* The ORDER BY (or GROUP BY clause) */ int nOBSat; /* Number of ORDER BY terms satisfied by indices */ int iECursor; /* Cursor number for the sorter */ int regReturn; /* Register holding block-output return address */ int labelBkOut; /* Start label for the block-output subroutine */ int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */ int labelDone; /* Jump here when done, ex: LIMIT reached */ u8 sortFlags; /* Zero or more SORTFLAG_* bits */ u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */ }; #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */ /* ** Delete all the content of a Select structure. Deallocate the structure ** itself only if bFree is true. */ | > > > > > > > > > > > > > > > > > > > > > > | 120638 120639 120640 120641 120642 120643 120644 120645 120646 120647 120648 120649 120650 120651 120652 120653 120654 120655 120656 120657 120658 120659 120660 120661 120662 120663 120664 120665 120666 120667 120668 120669 120670 120671 120672 120673 120674 120675 120676 120677 120678 120679 120680 120681 120682 120683 120684 120685 | int tabTnct; /* Ephemeral table used for DISTINCT processing */ int addrTnct; /* Address of OP_OpenEphemeral opcode for tabTnct */ }; /* ** An instance of the following object is used to record information about ** the ORDER BY (or GROUP BY) clause of query is being coded. ** ** The aDefer[] array is used by the sorter-references optimization. For ** example, assuming there is no index that can be used for the ORDER BY, ** for the query: ** ** SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10; ** ** it may be more efficient to add just the "a" values to the sorter, and ** retrieve the associated "bigblob" values directly from table t1 as the ** 10 smallest "a" values are extracted from the sorter. ** ** When the sorter-reference optimization is used, there is one entry in the ** aDefer[] array for each database table that may be read as values are ** extracted from the sorter. */ typedef struct SortCtx SortCtx; struct SortCtx { ExprList *pOrderBy; /* The ORDER BY (or GROUP BY clause) */ int nOBSat; /* Number of ORDER BY terms satisfied by indices */ int iECursor; /* Cursor number for the sorter */ int regReturn; /* Register holding block-output return address */ int labelBkOut; /* Start label for the block-output subroutine */ int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */ int labelDone; /* Jump here when done, ex: LIMIT reached */ u8 sortFlags; /* Zero or more SORTFLAG_* bits */ u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */ #ifdef SQLITE_ENABLE_SORTER_REFERENCES u8 nDefer; /* Number of valid entries in aDefer[] */ struct DeferredCsr { Table *pTab; /* Table definition */ int iCsr; /* Cursor number for table */ int nKey; /* Number of PK columns for table pTab (>=1) */ } aDefer[4]; #endif }; #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */ /* ** Delete all the content of a Select structure. Deallocate the structure ** itself only if bFree is true. */ |
︙ | ︙ | |||
120597 120598 120599 120600 120601 120602 120603 120604 120605 120606 120607 120608 120609 120610 | sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1); sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N); sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); sqlite3ReleaseTempReg(pParse, r1); } /* ** This routine generates the code for the inside of the inner loop ** of a SELECT. ** ** If srcTab is negative, then the p->pEList expressions ** are evaluated in order to get the data for this row. If srcTab is ** zero or more, then data is pulled from srcTab and p->pEList is used only | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 121294 121295 121296 121297 121298 121299 121300 121301 121302 121303 121304 121305 121306 121307 121308 121309 121310 121311 121312 121313 121314 121315 121316 121317 121318 121319 121320 121321 121322 121323 121324 121325 121326 121327 121328 121329 121330 121331 121332 121333 121334 121335 121336 121337 121338 121339 121340 121341 121342 121343 121344 121345 121346 121347 121348 121349 121350 121351 121352 121353 121354 121355 121356 121357 121358 121359 121360 121361 121362 121363 121364 121365 121366 121367 121368 121369 121370 121371 121372 121373 121374 121375 121376 121377 121378 121379 121380 121381 121382 121383 121384 121385 121386 121387 121388 121389 121390 121391 | sqlite3VdbeAddOp4Int(v, OP_Found, iTab, addrRepeat, iMem, N); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_MakeRecord, iMem, N, r1); sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r1, iMem, N); sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); sqlite3ReleaseTempReg(pParse, r1); } #ifdef SQLITE_ENABLE_SORTER_REFERENCES /* ** This function is called as part of inner-loop generation for a SELECT ** statement with an ORDER BY that is not optimized by an index. It ** determines the expressions, if any, that the sorter-reference ** optimization should be used for. The sorter-reference optimization ** is used for SELECT queries like: ** ** SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10 ** ** If the optimization is used for expression "bigblob", then instead of ** storing values read from that column in the sorter records, the PK of ** the row from table t1 is stored instead. Then, as records are extracted from ** the sorter to return to the user, the required value of bigblob is ** retrieved directly from table t1. If the values are very large, this ** can be more efficient than storing them directly in the sorter records. ** ** The ExprList_item.bSorterRef flag is set for each expression in pEList ** for which the sorter-reference optimization should be enabled. ** Additionally, the pSort->aDefer[] array is populated with entries ** for all cursors required to evaluate all selected expressions. Finally. ** output variable (*ppExtra) is set to an expression list containing ** expressions for all extra PK values that should be stored in the ** sorter records. */ static void selectExprDefer( Parse *pParse, /* Leave any error here */ SortCtx *pSort, /* Sorter context */ ExprList *pEList, /* Expressions destined for sorter */ ExprList **ppExtra /* Expressions to append to sorter record */ ){ int i; int nDefer = 0; ExprList *pExtra = 0; for(i=0; i<pEList->nExpr; i++){ struct ExprList_item *pItem = &pEList->a[i]; if( pItem->u.x.iOrderByCol==0 ){ Expr *pExpr = pItem->pExpr; Table *pTab = pExpr->pTab; if( pExpr->op==TK_COLUMN && pTab && !IsVirtual(pTab) && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF) #if 0 && pTab->pSchema && pTab->pSelect==0 && !IsVirtual(pTab) #endif ){ int j; for(j=0; j<nDefer; j++){ if( pSort->aDefer[j].iCsr==pExpr->iTable ) break; } if( j==nDefer ){ if( nDefer==ArraySize(pSort->aDefer) ){ continue; }else{ int nKey = 1; int k; Index *pPk = 0; if( !HasRowid(pTab) ){ pPk = sqlite3PrimaryKeyIndex(pTab); nKey = pPk->nKeyCol; } for(k=0; k<nKey; k++){ Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0); if( pNew ){ pNew->iTable = pExpr->iTable; pNew->pTab = pExpr->pTab; pNew->iColumn = pPk ? pPk->aiColumn[k] : -1; pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew); } } pSort->aDefer[nDefer].pTab = pExpr->pTab; pSort->aDefer[nDefer].iCsr = pExpr->iTable; pSort->aDefer[nDefer].nKey = nKey; nDefer++; } } pItem->bSorterRef = 1; } } } pSort->nDefer = (u8)nDefer; *ppExtra = pExtra; } #endif /* ** This routine generates the code for the inside of the inner loop ** of a SELECT. ** ** If srcTab is negative, then the p->pEList expressions ** are evaluated in order to get the data for this row. If srcTab is ** zero or more, then data is pulled from srcTab and p->pEList is used only |
︙ | ︙ | |||
120669 120670 120671 120672 120673 120674 120675 120676 120677 120678 120679 120680 120681 120682 | regOrig = regResult = pDest->iSdst; if( srcTab>=0 ){ for(i=0; i<nResultCol; i++){ sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i); VdbeComment((v, "%s", p->pEList->a[i].zName)); } }else if( eDest!=SRT_Exists ){ /* If the destination is an EXISTS(...) expression, the actual ** values returned by the SELECT are not required. */ u8 ecelFlags; if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){ ecelFlags = SQLITE_ECEL_DUP; }else{ | > > > | 121450 121451 121452 121453 121454 121455 121456 121457 121458 121459 121460 121461 121462 121463 121464 121465 121466 | regOrig = regResult = pDest->iSdst; if( srcTab>=0 ){ for(i=0; i<nResultCol; i++){ sqlite3VdbeAddOp3(v, OP_Column, srcTab, i, regResult+i); VdbeComment((v, "%s", p->pEList->a[i].zName)); } }else if( eDest!=SRT_Exists ){ #ifdef SQLITE_ENABLE_SORTER_REFERENCES ExprList *pExtra = 0; #endif /* If the destination is an EXISTS(...) expression, the actual ** values returned by the SELECT are not required. */ u8 ecelFlags; if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){ ecelFlags = SQLITE_ECEL_DUP; }else{ |
︙ | ︙ | |||
120692 120693 120694 120695 120696 120697 120698 120699 120700 120701 120702 120703 120704 120705 120706 120707 120708 120709 120710 120711 | ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF); for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){ int j; if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){ p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat; } } regOrig = 0; assert( eDest==SRT_Set || eDest==SRT_Mem || eDest==SRT_Coroutine || eDest==SRT_Output ); } nResultCol = sqlite3ExprCodeExprList(pParse,p->pEList,regResult, 0,ecelFlags); } /* If the DISTINCT keyword was present on the SELECT statement ** and this row has been seen before, then do not make this row ** part of the result. */ if( hasDistinct ){ | > > > > > > > > > > > > > > > > > > > > > > | 121476 121477 121478 121479 121480 121481 121482 121483 121484 121485 121486 121487 121488 121489 121490 121491 121492 121493 121494 121495 121496 121497 121498 121499 121500 121501 121502 121503 121504 121505 121506 121507 121508 121509 121510 121511 121512 121513 121514 121515 121516 121517 | ecelFlags |= (SQLITE_ECEL_OMITREF|SQLITE_ECEL_REF); for(i=pSort->nOBSat; i<pSort->pOrderBy->nExpr; i++){ int j; if( (j = pSort->pOrderBy->a[i].u.x.iOrderByCol)>0 ){ p->pEList->a[j-1].u.x.iOrderByCol = i+1-pSort->nOBSat; } } #ifdef SQLITE_ENABLE_SORTER_REFERENCES selectExprDefer(pParse, pSort, p->pEList, &pExtra); if( pExtra && pParse->db->mallocFailed==0 ){ /* If there are any extra PK columns to add to the sorter records, ** allocate extra memory cells and adjust the OpenEphemeral ** instruction to account for the larger records. This is only ** required if there are one or more WITHOUT ROWID tables with ** composite primary keys in the SortCtx.aDefer[] array. */ VdbeOp *pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex); pOp->p2 += (pExtra->nExpr - pSort->nDefer); pOp->p4.pKeyInfo->nAllField += (pExtra->nExpr - pSort->nDefer); pParse->nMem += pExtra->nExpr; } #endif regOrig = 0; assert( eDest==SRT_Set || eDest==SRT_Mem || eDest==SRT_Coroutine || eDest==SRT_Output ); } nResultCol = sqlite3ExprCodeExprList(pParse,p->pEList,regResult, 0,ecelFlags); #ifdef SQLITE_ENABLE_SORTER_REFERENCES if( pExtra ){ nResultCol += sqlite3ExprCodeExprList( pParse, pExtra, regResult + nResultCol, 0, 0 ); sqlite3ExprListDelete(pParse->db, pExtra); } #endif } /* If the DISTINCT keyword was present on the SELECT statement ** and this row has been seen before, then do not make this row ** part of the result. */ if( hasDistinct ){ |
︙ | ︙ | |||
121155 121156 121157 121158 121159 121160 121161 | SortCtx *pSort, /* Information on the ORDER BY clause */ int nColumn, /* Number of columns of data */ SelectDest *pDest /* Write the sorted results here */ ){ Vdbe *v = pParse->pVdbe; /* The prepared statement */ int addrBreak = pSort->labelDone; /* Jump here to exit loop */ int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */ | | | < > > > > > > > > > > > > < < | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > | | | | | | | | > | 121961 121962 121963 121964 121965 121966 121967 121968 121969 121970 121971 121972 121973 121974 121975 121976 121977 121978 121979 121980 121981 121982 121983 121984 121985 121986 121987 121988 121989 121990 121991 121992 121993 121994 121995 121996 121997 121998 121999 122000 122001 122002 122003 122004 122005 122006 122007 122008 122009 122010 122011 122012 122013 122014 122015 122016 122017 122018 122019 122020 122021 122022 122023 122024 122025 122026 122027 122028 122029 122030 122031 122032 122033 122034 122035 122036 122037 122038 122039 122040 122041 122042 122043 122044 122045 122046 122047 122048 122049 122050 122051 122052 122053 122054 122055 122056 122057 122058 122059 122060 122061 122062 122063 122064 122065 122066 122067 122068 122069 122070 122071 122072 122073 122074 122075 122076 122077 122078 122079 122080 122081 122082 122083 122084 122085 122086 122087 122088 122089 | SortCtx *pSort, /* Information on the ORDER BY clause */ int nColumn, /* Number of columns of data */ SelectDest *pDest /* Write the sorted results here */ ){ Vdbe *v = pParse->pVdbe; /* The prepared statement */ int addrBreak = pSort->labelDone; /* Jump here to exit loop */ int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */ int addr; /* Top of output loop. Jump for Next. */ int addrOnce = 0; int iTab; ExprList *pOrderBy = pSort->pOrderBy; int eDest = pDest->eDest; int iParm = pDest->iSDParm; int regRow; int regRowid; int iCol; int nKey; /* Number of key columns in sorter record */ int iSortTab; /* Sorter cursor to read from */ int i; int bSeq; /* True if sorter record includes seq. no. */ int nRefKey = 0; struct ExprList_item *aOutEx = p->pEList->a; assert( addrBreak<0 ); if( pSort->labelBkOut ){ sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut); sqlite3VdbeGoto(v, addrBreak); sqlite3VdbeResolveLabel(v, pSort->labelBkOut); } #ifdef SQLITE_ENABLE_SORTER_REFERENCES /* Open any cursors needed for sorter-reference expressions */ for(i=0; i<pSort->nDefer; i++){ Table *pTab = pSort->aDefer[i].pTab; int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); sqlite3OpenTable(pParse, pSort->aDefer[i].iCsr, iDb, pTab, OP_OpenRead); nRefKey = MAX(nRefKey, pSort->aDefer[i].nKey); } #endif iTab = pSort->iECursor; if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){ regRowid = 0; regRow = pDest->iSdst; }else{ regRowid = sqlite3GetTempReg(pParse); regRow = sqlite3GetTempRange(pParse, nColumn); } nKey = pOrderBy->nExpr - pSort->nOBSat; if( pSort->sortFlags & SORTFLAG_UseSorter ){ int regSortOut = ++pParse->nMem; iSortTab = pParse->nTab++; if( pSort->labelBkOut ){ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); } sqlite3VdbeAddOp3(v, OP_OpenPseudo, iSortTab, regSortOut, nKey+1+nColumn+nRefKey); if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce); addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak); VdbeCoverage(v); codeOffset(v, p->iOffset, addrContinue); sqlite3VdbeAddOp3(v, OP_SorterData, iTab, regSortOut, iSortTab); bSeq = 0; }else{ addr = 1 + sqlite3VdbeAddOp2(v, OP_Sort, iTab, addrBreak); VdbeCoverage(v); codeOffset(v, p->iOffset, addrContinue); iSortTab = iTab; bSeq = 1; } for(i=0, iCol=nKey+bSeq-1; i<nColumn; i++){ #ifdef SQLITE_ENABLE_SORTER_REFERENCES if( aOutEx[i].bSorterRef ) continue; #endif if( aOutEx[i].u.x.iOrderByCol==0 ) iCol++; } #ifdef SQLITE_ENABLE_SORTER_REFERENCES if( pSort->nDefer ){ int iKey = iCol+1; int regKey = sqlite3GetTempRange(pParse, nRefKey); for(i=0; i<pSort->nDefer; i++){ int iCsr = pSort->aDefer[i].iCsr; Table *pTab = pSort->aDefer[i].pTab; int nKey = pSort->aDefer[i].nKey; sqlite3VdbeAddOp1(v, OP_NullRow, iCsr); if( HasRowid(pTab) ){ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey); sqlite3VdbeAddOp3(v, OP_SeekRowid, iCsr, sqlite3VdbeCurrentAddr(v)+1, regKey); }else{ int k; int iJmp; assert( sqlite3PrimaryKeyIndex(pTab)->nKeyCol==nKey ); for(k=0; k<nKey; k++){ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iKey++, regKey+k); } iJmp = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp4Int(v, OP_SeekGE, iCsr, iJmp+2, regKey, nKey); sqlite3VdbeAddOp4Int(v, OP_IdxLE, iCsr, iJmp+3, regKey, nKey); sqlite3VdbeAddOp1(v, OP_NullRow, iCsr); } } sqlite3ReleaseTempRange(pParse, regKey, nRefKey); } #endif for(i=nColumn-1; i>=0; i--){ #ifdef SQLITE_ENABLE_SORTER_REFERENCES if( aOutEx[i].bSorterRef ){ sqlite3ExprCode(pParse, aOutEx[i].pExpr, regRow+i); }else #endif { int iRead; if( aOutEx[i].u.x.iOrderByCol ){ iRead = aOutEx[i].u.x.iOrderByCol-1; }else{ iRead = iCol--; } sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i); VdbeComment((v, "%s", aOutEx[i].zName?aOutEx[i].zName : aOutEx[i].zSpan)); } } switch( eDest ){ case SRT_Table: case SRT_EphemTab: { sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid); sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid); sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
︙ | ︙ | |||
123692 123693 123694 123695 123696 123697 123698 | ** (the only way this can happen is if the compound sub-query is ** currently part of pSub->pSrc). See ticket [d11a6e908f]. */ ExprList *pOrderBy = pSub->pOrderBy; for(i=0; i<pOrderBy->nExpr; i++){ pOrderBy->a[i].u.x.iOrderByCol = 0; } assert( pParent->pOrderBy==0 ); | < | 124549 124550 124551 124552 124553 124554 124555 124556 124557 124558 124559 124560 124561 124562 | ** (the only way this can happen is if the compound sub-query is ** currently part of pSub->pSrc). See ticket [d11a6e908f]. */ ExprList *pOrderBy = pSub->pOrderBy; for(i=0; i<pOrderBy->nExpr; i++){ pOrderBy->a[i].u.x.iOrderByCol = 0; } assert( pParent->pOrderBy==0 ); pParent->pOrderBy = pOrderBy; pSub->pOrderBy = 0; } pWhere = sqlite3ExprDup(db, pSub->pWhere, 0); if( isLeftJoin>0 ){ setJoinExpr(pWhere, iNewParent); } |
︙ | ︙ | |||
123776 123777 123778 123779 123780 123781 123782 | ** to suppress it. **) ** ** (2) The inner query is the recursive part of a common table expression. ** ** (3) The inner query has a LIMIT clause (since the changes to the WHERE ** close would change the meaning of the LIMIT). ** | < | > > | 124632 124633 124634 124635 124636 124637 124638 124639 124640 124641 124642 124643 124644 124645 124646 124647 124648 | ** to suppress it. **) ** ** (2) The inner query is the recursive part of a common table expression. ** ** (3) The inner query has a LIMIT clause (since the changes to the WHERE ** close would change the meaning of the LIMIT). ** ** (4) The inner query is the right operand of a LEFT JOIN and the ** expression to be pushed down does not come from the ON clause ** on that LEFT JOIN. ** ** (5) The WHERE clause expression originates in the ON or USING clause ** of a LEFT JOIN where iCursor is not the right-hand table of that ** left join. An example: ** ** SELECT * ** FROM (SELECT 1 AS a1 UNION ALL SELECT 2) AS aa |
︙ | ︙ | |||
123799 123800 123801 123802 123803 123804 123805 | ** Return 0 if no changes are made and non-zero if one or more WHERE clause ** terms are duplicated into the subquery. */ static int pushDownWhereTerms( Parse *pParse, /* Parse context (for malloc() and error reporting) */ Select *pSubq, /* The subquery whose WHERE clause is to be augmented */ Expr *pWhere, /* The WHERE clause of the outer query */ | | > | 124656 124657 124658 124659 124660 124661 124662 124663 124664 124665 124666 124667 124668 124669 124670 124671 | ** Return 0 if no changes are made and non-zero if one or more WHERE clause ** terms are duplicated into the subquery. */ static int pushDownWhereTerms( Parse *pParse, /* Parse context (for malloc() and error reporting) */ Select *pSubq, /* The subquery whose WHERE clause is to be augmented */ Expr *pWhere, /* The WHERE clause of the outer query */ int iCursor, /* Cursor number of the subquery */ int isLeftJoin /* True if pSubq is the right term of a LEFT JOIN */ ){ Expr *pNew; int nChng = 0; if( pWhere==0 ) return 0; if( pSubq->selFlags & SF_Recursive ) return 0; /* restriction (2) */ #ifdef SQLITE_DEBUG |
︙ | ︙ | |||
123823 123824 123825 123826 123827 123828 123829 | } #endif if( pSubq->pLimit!=0 ){ return 0; /* restriction (3) */ } while( pWhere->op==TK_AND ){ | | > > > > > > > | 124681 124682 124683 124684 124685 124686 124687 124688 124689 124690 124691 124692 124693 124694 124695 124696 124697 124698 124699 124700 124701 124702 124703 124704 | } #endif if( pSubq->pLimit!=0 ){ return 0; /* restriction (3) */ } while( pWhere->op==TK_AND ){ nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight, iCursor, isLeftJoin); pWhere = pWhere->pLeft; } if( isLeftJoin && (ExprHasProperty(pWhere,EP_FromJoin)==0 || pWhere->iRightJoinTable!=iCursor) ){ return 0; /* restriction (4) */ } if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){ return 0; /* restriction (5) */ } if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ nChng++; while( pSubq ){ SubstContext x; |
︙ | ︙ | |||
124289 124290 124291 124292 124293 124294 124295 | } assert( p->pSrc!=0 ); if( (selFlags & SF_Expanded)!=0 ){ return WRC_Prune; } pTabList = p->pSrc; pEList = p->pEList; | < | < | 125154 125155 125156 125157 125158 125159 125160 125161 125162 125163 125164 125165 125166 125167 125168 | } assert( p->pSrc!=0 ); if( (selFlags & SF_Expanded)!=0 ){ return WRC_Prune; } pTabList = p->pSrc; pEList = p->pEList; sqlite3WithPush(pParse, p->pWith, 0); /* Make sure cursor numbers have been assigned to all entries in ** the FROM clause of the SELECT statement. */ sqlite3SrcListAssignCursors(pParse, pTabList); /* Look up every table named in the FROM clause of the select. If |
︙ | ︙ | |||
125293 125294 125295 125296 125297 125298 125299 | */ pParse->nHeight += sqlite3SelectExprHeight(p); /* Make copies of constant WHERE-clause terms in the outer query down ** inside the subquery. This can help the subquery to run more efficiently. */ if( OptimizationEnabled(db, SQLITE_PushDown) | | > | 126156 126157 126158 126159 126160 126161 126162 126163 126164 126165 126166 126167 126168 126169 126170 126171 | */ pParse->nHeight += sqlite3SelectExprHeight(p); /* Make copies of constant WHERE-clause terms in the outer query down ** inside the subquery. This can help the subquery to run more efficiently. */ if( OptimizationEnabled(db, SQLITE_PushDown) && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, (pItem->fg.jointype & JT_OUTER)!=0) ){ #if SELECTTRACE_ENABLED if( sqlite3SelectTrace & 0x100 ){ SELECTTRACE(0x100,pParse,p,("After WHERE-clause push-down:\n")); sqlite3TreeViewSelect(0, p, 0); } #endif |
︙ | ︙ | |||
125598 125599 125600 125601 125602 125603 125604 | /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the ** SELECT statement. */ memset(&sNC, 0, sizeof(sNC)); sNC.pParse = pParse; sNC.pSrcList = pTabList; | | > | 126462 126463 126464 126465 126466 126467 126468 126469 126470 126471 126472 126473 126474 126475 126476 126477 | /* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in ** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the ** SELECT statement. */ memset(&sNC, 0, sizeof(sNC)); sNC.pParse = pParse; sNC.pSrcList = pTabList; sNC.uNC.pAggInfo = &sAggInfo; VVA_ONLY( sNC.ncFlags = NC_UAggInfo; ) sAggInfo.mnReg = pParse->nMem+1; sAggInfo.nSortingColumn = pGroupBy ? pGroupBy->nExpr : 0; sAggInfo.pGroupBy = pGroupBy; sqlite3ExprAnalyzeAggList(&sNC, pEList); sqlite3ExprAnalyzeAggList(&sNC, sSort.pOrderBy); if( pHaving ){ if( pGroupBy ){ |
︙ | ︙ | |||
125987 125988 125989 125990 125991 125992 125993 125994 125995 125996 125997 125998 125999 126000 | /* If there is an ORDER BY clause, then we need to sort the results ** and send them to the callback one by one. */ if( sSort.pOrderBy ){ explainTempTable(pParse, sSort.nOBSat>0 ? "RIGHT PART OF ORDER BY":"ORDER BY"); generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest); } /* Jump here to skip this query */ sqlite3VdbeResolveLabel(v, iEnd); | > | 126852 126853 126854 126855 126856 126857 126858 126859 126860 126861 126862 126863 126864 126865 126866 | /* If there is an ORDER BY clause, then we need to sort the results ** and send them to the callback one by one. */ if( sSort.pOrderBy ){ explainTempTable(pParse, sSort.nOBSat>0 ? "RIGHT PART OF ORDER BY":"ORDER BY"); assert( p->pEList==pEList ); generateSortTail(pParse, p, &sSort, pEList->nExpr, pDest); } /* Jump here to skip this query */ sqlite3VdbeResolveLabel(v, iEnd); |
︙ | ︙ | |||
126242 126243 126244 126245 126246 126247 126248 126249 126250 126251 126252 126253 126254 126255 | TriggerStep * pTmp = pTriggerStep; pTriggerStep = pTriggerStep->pNext; sqlite3ExprDelete(db, pTmp->pWhere); sqlite3ExprListDelete(db, pTmp->pExprList); sqlite3SelectDelete(db, pTmp->pSelect); sqlite3IdListDelete(db, pTmp->pIdList); sqlite3DbFree(db, pTmp->zSpan); sqlite3DbFree(db, pTmp); } } /* | > | 127108 127109 127110 127111 127112 127113 127114 127115 127116 127117 127118 127119 127120 127121 127122 | TriggerStep * pTmp = pTriggerStep; pTriggerStep = pTriggerStep->pNext; sqlite3ExprDelete(db, pTmp->pWhere); sqlite3ExprListDelete(db, pTmp->pExprList); sqlite3SelectDelete(db, pTmp->pSelect); sqlite3IdListDelete(db, pTmp->pIdList); sqlite3UpsertDelete(db, pTmp->pUpsert); sqlite3DbFree(db, pTmp->zSpan); sqlite3DbFree(db, pTmp); } } /* |
︙ | ︙ | |||
126633 126634 126635 126636 126637 126638 126639 126640 126641 126642 126643 126644 126645 126646 126647 126648 126649 126650 126651 126652 126653 126654 126655 126656 126657 126658 126659 126660 | */ SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep( sqlite3 *db, /* The database connection */ Token *pTableName, /* Name of the table into which we insert */ IdList *pColumn, /* List of columns in pTableName to insert into */ Select *pSelect, /* A SELECT statement that supplies values */ u8 orconf, /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */ const char *zStart, /* Start of SQL text */ const char *zEnd /* End of SQL text */ ){ TriggerStep *pTriggerStep; assert(pSelect != 0 || db->mallocFailed); pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName, zStart, zEnd); if( pTriggerStep ){ pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); pTriggerStep->pIdList = pColumn; pTriggerStep->orconf = orconf; }else{ sqlite3IdListDelete(db, pColumn); } sqlite3SelectDelete(db, pSelect); return pTriggerStep; } /* | > > > > > | 127500 127501 127502 127503 127504 127505 127506 127507 127508 127509 127510 127511 127512 127513 127514 127515 127516 127517 127518 127519 127520 127521 127522 127523 127524 127525 127526 127527 127528 127529 127530 127531 127532 | */ SQLITE_PRIVATE TriggerStep *sqlite3TriggerInsertStep( sqlite3 *db, /* The database connection */ Token *pTableName, /* Name of the table into which we insert */ IdList *pColumn, /* List of columns in pTableName to insert into */ Select *pSelect, /* A SELECT statement that supplies values */ u8 orconf, /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */ Upsert *pUpsert, /* ON CONFLICT clauses for upsert */ const char *zStart, /* Start of SQL text */ const char *zEnd /* End of SQL text */ ){ TriggerStep *pTriggerStep; assert(pSelect != 0 || db->mallocFailed); pTriggerStep = triggerStepAllocate(db, TK_INSERT, pTableName, zStart, zEnd); if( pTriggerStep ){ pTriggerStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); pTriggerStep->pIdList = pColumn; pTriggerStep->pUpsert = pUpsert; pTriggerStep->orconf = orconf; }else{ testcase( pColumn ); sqlite3IdListDelete(db, pColumn); testcase( pUpsert ); sqlite3UpsertDelete(db, pUpsert); } sqlite3SelectDelete(db, pSelect); return pTriggerStep; } /* |
︙ | ︙ | |||
126963 126964 126965 126966 126967 126968 126969 | switch( pStep->op ){ case TK_UPDATE: { sqlite3Update(pParse, targetSrcList(pParse, pStep), sqlite3ExprListDup(db, pStep->pExprList, 0), sqlite3ExprDup(db, pStep->pWhere, 0), | | | > | 127835 127836 127837 127838 127839 127840 127841 127842 127843 127844 127845 127846 127847 127848 127849 127850 127851 127852 127853 127854 127855 127856 127857 127858 127859 | switch( pStep->op ){ case TK_UPDATE: { sqlite3Update(pParse, targetSrcList(pParse, pStep), sqlite3ExprListDup(db, pStep->pExprList, 0), sqlite3ExprDup(db, pStep->pWhere, 0), pParse->eOrconf, 0, 0, 0 ); break; } case TK_INSERT: { sqlite3Insert(pParse, targetSrcList(pParse, pStep), sqlite3SelectDup(db, pStep->pSelect, 0), sqlite3IdListDup(db, pStep->pIdList), pParse->eOrconf, sqlite3UpsertDup(db, pStep->pUpsert) ); break; } case TK_DELETE: { sqlite3DeleteFrom(pParse, targetSrcList(pParse, pStep), sqlite3ExprDup(db, pStep->pWhere, 0), 0, 0 |
︙ | ︙ | |||
127450 127451 127452 127453 127454 127455 127456 | SQLITE_PRIVATE void sqlite3Update( Parse *pParse, /* The parser context */ SrcList *pTabList, /* The table in which we should change things */ ExprList *pChanges, /* Things to be changed */ Expr *pWhere, /* The WHERE clause. May be null */ int onError, /* How to handle constraint errors */ ExprList *pOrderBy, /* ORDER BY clause. May be null */ | | > | 128323 128324 128325 128326 128327 128328 128329 128330 128331 128332 128333 128334 128335 128336 128337 128338 | SQLITE_PRIVATE void sqlite3Update( Parse *pParse, /* The parser context */ SrcList *pTabList, /* The table in which we should change things */ ExprList *pChanges, /* Things to be changed */ Expr *pWhere, /* The WHERE clause. May be null */ int onError, /* How to handle constraint errors */ ExprList *pOrderBy, /* ORDER BY clause. May be null */ Expr *pLimit, /* LIMIT clause. May be null */ Upsert *pUpsert /* ON CONFLICT clause, or null */ ){ int i, j; /* Loop counters */ Table *pTab; /* The table to be updated */ int addrTop = 0; /* VDBE instruction address of the start of the loop */ WhereInfo *pWInfo; /* Information about the WHERE clause */ Vdbe *v; /* The virtual database engine */ Index *pIdx; /* For looping over indices */ |
︙ | ︙ | |||
127557 127558 127559 127560 127561 127562 127563 | } /* Allocate a cursors for the main database table and for all indices. ** The index cursors might not be used, but if they are used they ** need to occur right after the database cursor. So go ahead and ** allocate enough space, just in case. */ | | > | < > > > > > > > > > | 128431 128432 128433 128434 128435 128436 128437 128438 128439 128440 128441 128442 128443 128444 128445 128446 128447 128448 128449 128450 128451 128452 128453 128454 128455 128456 128457 128458 128459 128460 128461 128462 128463 128464 128465 128466 128467 128468 128469 128470 128471 128472 128473 128474 128475 128476 128477 128478 128479 | } /* Allocate a cursors for the main database table and for all indices. ** The index cursors might not be used, but if they are used they ** need to occur right after the database cursor. So go ahead and ** allocate enough space, just in case. */ iBaseCur = iDataCur = pParse->nTab++; iIdxCur = iDataCur+1; pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab); testcase( pPk!=0 && pPk!=pTab->pIndex ); for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){ if( pPk==pIdx ){ iDataCur = pParse->nTab; } pParse->nTab++; } if( pUpsert ){ /* On an UPSERT, reuse the same cursors already opened by INSERT */ iDataCur = pUpsert->iDataCur; iIdxCur = pUpsert->iIdxCur; pParse->nTab = iBaseCur; } pTabList->a[0].iCursor = iDataCur; /* Allocate space for aXRef[], aRegIdx[], and aToOpen[]. ** Initialize aXRef[] and aToOpen[] to their default values. */ aXRef = sqlite3DbMallocRawNN(db, sizeof(int) * (pTab->nCol+nIdx) + nIdx+2 ); if( aXRef==0 ) goto update_cleanup; aRegIdx = aXRef+pTab->nCol; aToOpen = (u8*)(aRegIdx+nIdx); memset(aToOpen, 1, nIdx+1); aToOpen[nIdx+1] = 0; for(i=0; i<pTab->nCol; i++) aXRef[i] = -1; /* Initialize the name-context */ memset(&sNC, 0, sizeof(sNC)); sNC.pParse = pParse; sNC.pSrcList = pTabList; sNC.uNC.pUpsert = pUpsert; sNC.ncFlags = NC_UUpsert; /* Resolve the column names in all the expressions of the ** of the UPDATE statement. Also find the column index ** for each column to be updated in the pChanges array. For each ** column to be updated, make sure we have authorization to change ** that column. */ |
︙ | ︙ | |||
127686 127687 127688 127689 127690 127691 127692 | memset(aToOpen, 1, nIdx+1); } /* Begin generating code. */ v = sqlite3GetVdbe(pParse); if( v==0 ) goto update_cleanup; if( pParse->nested==0 ) sqlite3VdbeCountChanges(v); | | | 128569 128570 128571 128572 128573 128574 128575 128576 128577 128578 128579 128580 128581 128582 128583 | memset(aToOpen, 1, nIdx+1); } /* Begin generating code. */ v = sqlite3GetVdbe(pParse); if( v==0 ) goto update_cleanup; if( pParse->nested==0 ) sqlite3VdbeCountChanges(v); sqlite3BeginWriteOperation(pParse, pTrigger || hasFK, iDb); /* Allocate required registers. */ if( !IsVirtual(pTab) ){ regRowSet = ++pParse->nMem; regOldRowid = regNewRowid = ++pParse->nMem; if( chngPk || pTrigger || hasFK ){ regOld = pParse->nMem + 1; |
︙ | ︙ | |||
127737 127738 127739 127740 127741 127742 127743 | if( IsVirtual(pTab) ){ updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, pWhere, onError); goto update_cleanup; } #endif | > > > > | > | > > > > | < | | | | | > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | > > | > | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | < < | | | | | | | | | | | | | | | | | | | > | | | 128620 128621 128622 128623 128624 128625 128626 128627 128628 128629 128630 128631 128632 128633 128634 128635 128636 128637 128638 128639 128640 128641 128642 128643 128644 128645 128646 128647 128648 128649 128650 128651 128652 128653 128654 128655 128656 128657 128658 128659 128660 128661 128662 128663 128664 128665 128666 128667 128668 128669 128670 128671 128672 128673 128674 128675 128676 128677 128678 128679 128680 128681 128682 128683 128684 128685 128686 128687 128688 128689 128690 128691 128692 128693 128694 128695 128696 128697 128698 128699 128700 128701 128702 128703 128704 128705 128706 128707 128708 128709 128710 128711 128712 128713 128714 128715 128716 128717 128718 128719 128720 128721 128722 128723 128724 128725 128726 128727 128728 128729 128730 128731 128732 128733 128734 128735 128736 128737 128738 128739 128740 128741 128742 128743 128744 128745 128746 128747 128748 128749 128750 128751 128752 128753 128754 128755 128756 128757 128758 128759 128760 128761 128762 128763 128764 128765 128766 128767 128768 128769 128770 128771 128772 128773 128774 128775 128776 128777 128778 128779 128780 128781 128782 128783 128784 128785 128786 128787 128788 128789 128790 128791 | if( IsVirtual(pTab) ){ updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, pWhere, onError); goto update_cleanup; } #endif /* Jump to labelBreak to abandon further processing of this UPDATE */ labelContinue = labelBreak = sqlite3VdbeMakeLabel(v); /* Not an UPSERT. Normal processing. Begin by ** initialize the count of updated rows */ if( (db->flags&SQLITE_CountRows)!=0 && !pParse->pTriggerTab && !pParse->nested && pUpsert==0 ){ regRowCount = ++pParse->nMem; sqlite3VdbeAddOp2(v, OP_Integer, 0, regRowCount); } if( HasRowid(pTab) ){ sqlite3VdbeAddOp3(v, OP_Null, 0, regRowSet, regOldRowid); }else{ assert( pPk!=0 ); nPk = pPk->nKeyCol; iPk = pParse->nMem+1; pParse->nMem += nPk; regKey = ++pParse->nMem; if( pUpsert==0 ){ iEph = pParse->nTab++; sqlite3VdbeAddOp3(v, OP_Null, 0, iPk, iPk+nPk-1); addrOpen = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, iEph, nPk); sqlite3VdbeSetP4KeyInfo(pParse, pPk); } } if( pUpsert ){ /* If this is an UPSERT, then all cursors have already been opened by ** the outer INSERT and the data cursor should be pointing at the row ** that is to be updated. So bypass the code that searches for the ** row(s) to be updated. */ pWInfo = 0; eOnePass = ONEPASS_SINGLE; sqlite3ExprIfFalse(pParse, pWhere, labelBreak, SQLITE_JUMPIFNULL); }else{ /* Begin the database scan. ** ** Do not consider a single-pass strategy for a multi-row update if ** there are any triggers or foreign keys to process, or rows may ** be deleted as a result of REPLACE conflict handling. Any of these ** things might disturb a cursor being used to scan through the table ** or index, causing a single-pass approach to malfunction. */ flags = WHERE_ONEPASS_DESIRED|WHERE_SEEK_UNIQ_TABLE; if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){ flags |= WHERE_ONEPASS_MULTIROW; } pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags, iIdxCur); if( pWInfo==0 ) goto update_cleanup; /* A one-pass strategy that might update more than one row may not ** be used if any column of the index used for the scan is being ** updated. Otherwise, if there is an index on "b", statements like ** the following could create an infinite loop: ** ** UPDATE t1 SET b=b+1 WHERE b>? ** ** Fall back to ONEPASS_OFF if where.c has selected a ONEPASS_MULTI ** strategy that uses an index for which one or more columns are being ** updated. */ eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); if( eOnePass!=ONEPASS_SINGLE ){ sqlite3MultiWrite(pParse); if( eOnePass==ONEPASS_MULTI ){ int iCur = aiCurOnePass[1]; if( iCur>=0 && iCur!=iDataCur && aToOpen[iCur-iBaseCur] ){ eOnePass = ONEPASS_OFF; } assert( iCur!=iDataCur || !HasRowid(pTab) ); } } } if( HasRowid(pTab) ){ /* Read the rowid of the current row of the WHERE scan. In ONEPASS_OFF ** mode, write the rowid into the FIFO. In either of the one-pass modes, ** leave it in register regOldRowid. */ sqlite3VdbeAddOp2(v, OP_Rowid, iDataCur, regOldRowid); if( eOnePass==ONEPASS_OFF ){ sqlite3VdbeAddOp2(v, OP_RowSetAdd, regRowSet, regOldRowid); } }else{ /* Read the PK of the current row into an array of registers. In ** ONEPASS_OFF mode, serialize the array into a record and store it in ** the ephemeral table. Or, in ONEPASS_SINGLE or MULTI mode, change ** the OP_OpenEphemeral instruction to a Noop (the ephemeral table ** is not required) and leave the PK fields in the array of registers. */ for(i=0; i<nPk; i++){ assert( pPk->aiColumn[i]>=0 ); sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur,pPk->aiColumn[i],iPk+i); } if( eOnePass ){ if( addrOpen ) sqlite3VdbeChangeToNoop(v, addrOpen); nKey = nPk; regKey = iPk; }else{ sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey, sqlite3IndexAffinityStr(db, pPk), nPk); sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iEph, regKey, iPk, nPk); } } if( pUpsert==0 ){ if( eOnePass!=ONEPASS_MULTI ){ sqlite3WhereEnd(pWInfo); } if( !isView ){ int addrOnce = 0; /* Open every index that needs updating. */ if( eOnePass!=ONEPASS_OFF ){ if( aiCurOnePass[0]>=0 ) aToOpen[aiCurOnePass[0]-iBaseCur] = 0; if( aiCurOnePass[1]>=0 ) aToOpen[aiCurOnePass[1]-iBaseCur] = 0; } if( eOnePass==ONEPASS_MULTI && (nIdx-(aiCurOnePass[1]>=0))>0 ){ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); } sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenWrite, 0, iBaseCur, aToOpen, 0, 0); if( addrOnce ) sqlite3VdbeJumpHere(v, addrOnce); } /* Top of the update loop */ if( eOnePass!=ONEPASS_OFF ){ if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){ assert( pPk ); sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey); VdbeCoverageNeverTaken(v); } if( eOnePass!=ONEPASS_SINGLE ){ labelContinue = sqlite3VdbeMakeLabel(v); } sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak); VdbeCoverageIf(v, pPk==0); VdbeCoverageIf(v, pPk!=0); }else if( pPk ){ labelContinue = sqlite3VdbeMakeLabel(v); sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v); addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey); sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0); VdbeCoverage(v); }else{ labelContinue = sqlite3VdbeAddOp3(v, OP_RowSetRead, regRowSet,labelBreak, regOldRowid); VdbeCoverage(v); sqlite3VdbeAddOp3(v, OP_NotExists, iDataCur, labelContinue, regOldRowid); VdbeCoverage(v); } } /* If the rowid value will change, set register regNewRowid to ** contain the new value. If the rowid is not being modified, ** then regNewRowid is the same register as regOldRowid, which is ** already populated. */ assert( chngKey || pTrigger || hasFK || regOldRowid==regNewRowid ); if( chngRowid ){ sqlite3ExprCode(pParse, pRowidExpr, regNewRowid); sqlite3VdbeAddOp1(v, OP_MustBeInt, regNewRowid); VdbeCoverage(v); } |
︙ | ︙ | |||
127983 127984 127985 127986 127987 127988 127989 | if( !isView ){ int addr1 = 0; /* Address of jump instruction */ /* Do constraint checks. */ assert( regOldRowid>0 ); sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace, | | | 128888 128889 128890 128891 128892 128893 128894 128895 128896 128897 128898 128899 128900 128901 128902 | if( !isView ){ int addr1 = 0; /* Address of jump instruction */ /* Do constraint checks. */ assert( regOldRowid>0 ); sqlite3GenerateConstraintChecks(pParse, pTab, aRegIdx, iDataCur, iIdxCur, regNewRowid, regOldRowid, chngKey, onError, labelContinue, &bReplace, aXRef, 0); /* Do FK constraint checks. */ if( hasFK ){ sqlite3FkCheck(pParse, pTab, regOldRowid, 0, aXRef, chngKey); } /* Delete the index entries associated with the current record. */ |
︙ | ︙ | |||
128053 128054 128055 128056 128057 128058 128059 | if( hasFK ){ sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey); } } /* Increment the row counter */ | | | 128958 128959 128960 128961 128962 128963 128964 128965 128966 128967 128968 128969 128970 128971 128972 | if( hasFK ){ sqlite3FkActions(pParse, pTab, pChanges, regOldRowid, aXRef, chngKey); } } /* Increment the row counter */ if( regRowCount ){ sqlite3VdbeAddOp2(v, OP_AddImm, regRowCount, 1); } sqlite3CodeRowTrigger(pParse, pTrigger, TK_UPDATE, pChanges, TRIGGER_AFTER, pTab, regOldRowid, onError, labelContinue); /* Repeat the above with the next record to be updated, until |
︙ | ︙ | |||
128080 128081 128082 128083 128084 128085 128086 | } sqlite3VdbeResolveLabel(v, labelBreak); /* Update the sqlite_sequence table by storing the content of the ** maximum rowid counter values recorded while inserting into ** autoincrement tables. */ | | | < | | | 128985 128986 128987 128988 128989 128990 128991 128992 128993 128994 128995 128996 128997 128998 128999 129000 129001 129002 129003 129004 129005 129006 129007 | } sqlite3VdbeResolveLabel(v, labelBreak); /* Update the sqlite_sequence table by storing the content of the ** maximum rowid counter values recorded while inserting into ** autoincrement tables. */ if( pParse->nested==0 && pParse->pTriggerTab==0 && pUpsert==0 ){ sqlite3AutoincrementEnd(pParse); } /* ** Return the number of rows that were changed, if we are tracking ** that information. */ if( regRowCount ){ sqlite3VdbeAddOp2(v, OP_ResultRow, regRowCount, 1); sqlite3VdbeSetNumCols(v, 1); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC); } update_cleanup: sqlite3AuthContextPop(&sContext); |
︙ | ︙ | |||
128210 128211 128212 128213 128214 128215 128216 | sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1); } bOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy); if( bOnePass ){ /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded | | < < < < > | 129114 129115 129116 129117 129118 129119 129120 129121 129122 129123 129124 129125 129126 129127 129128 129129 129130 129131 129132 129133 | sqlite3VdbeAddOp2(v, OP_SCopy, regArg+2+iPk, regArg+1); } bOnePass = sqlite3WhereOkOnePass(pWInfo, aDummy); if( bOnePass ){ /* If using the onepass strategy, no-op out the OP_OpenEphemeral coded ** above. */ sqlite3VdbeChangeToNoop(v, addr); }else{ /* Create a record from the argument register contents and insert it into ** the ephemeral table. */ sqlite3MultiWrite(pParse); sqlite3VdbeAddOp3(v, OP_MakeRecord, regArg, nArg, regRec); #ifdef SQLITE_DEBUG /* Signal an assert() within OP_MakeRecord that it is allowed to ** accept no-change records with serial_type 10 */ sqlite3VdbeChangeP5(v, OPFLAG_NOCHNG_MAGIC); #endif sqlite3VdbeAddOp2(v, OP_NewRowid, ephemTab, regRowid); |
︙ | ︙ | |||
128261 128262 128263 128264 128265 128266 128267 128268 128269 128270 128271 128272 128273 128274 | }else{ sqlite3WhereEnd(pWInfo); } } #endif /* SQLITE_OMIT_VIRTUALTABLE */ /************** End of update.c **********************************************/ /************** Begin file vacuum.c ******************************************/ /* ** 2003 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 129162 129163 129164 129165 129166 129167 129168 129169 129170 129171 129172 129173 129174 129175 129176 129177 129178 129179 129180 129181 129182 129183 129184 129185 129186 129187 129188 129189 129190 129191 129192 129193 129194 129195 129196 129197 129198 129199 129200 129201 129202 129203 129204 129205 129206 129207 129208 129209 129210 129211 129212 129213 129214 129215 129216 129217 129218 129219 129220 129221 129222 129223 129224 129225 129226 129227 129228 129229 129230 129231 129232 129233 129234 129235 129236 129237 129238 129239 129240 129241 129242 129243 129244 129245 129246 129247 129248 129249 129250 129251 129252 129253 129254 129255 129256 129257 129258 129259 129260 129261 129262 129263 129264 129265 129266 129267 129268 129269 129270 129271 129272 129273 129274 129275 129276 129277 129278 129279 129280 129281 129282 129283 129284 129285 129286 129287 129288 129289 129290 129291 129292 129293 129294 129295 129296 129297 129298 129299 129300 129301 129302 129303 129304 129305 129306 129307 129308 129309 129310 129311 129312 129313 129314 129315 129316 129317 129318 129319 129320 129321 129322 129323 129324 129325 129326 129327 129328 129329 129330 129331 129332 129333 129334 129335 129336 129337 129338 129339 129340 129341 129342 129343 129344 129345 129346 129347 129348 129349 129350 129351 129352 129353 129354 129355 129356 129357 129358 129359 129360 129361 129362 129363 129364 129365 129366 129367 129368 129369 129370 129371 129372 129373 129374 129375 129376 129377 129378 129379 129380 129381 129382 129383 129384 129385 129386 129387 129388 129389 129390 129391 129392 129393 129394 129395 129396 129397 129398 129399 129400 129401 129402 129403 129404 129405 129406 129407 129408 129409 129410 129411 129412 129413 129414 129415 129416 129417 129418 129419 129420 129421 129422 129423 129424 129425 129426 129427 | }else{ sqlite3WhereEnd(pWInfo); } } #endif /* SQLITE_OMIT_VIRTUALTABLE */ /************** End of update.c **********************************************/ /************** Begin file upsert.c ******************************************/ /* ** 2018-04-12 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement various aspects of UPSERT ** processing and handling of the Upsert object. */ /* #include "sqliteInt.h" */ #ifndef SQLITE_OMIT_UPSERT /* ** Free a list of Upsert objects */ SQLITE_PRIVATE void sqlite3UpsertDelete(sqlite3 *db, Upsert *p){ if( p ){ sqlite3ExprListDelete(db, p->pUpsertTarget); sqlite3ExprDelete(db, p->pUpsertTargetWhere); sqlite3ExprListDelete(db, p->pUpsertSet); sqlite3ExprDelete(db, p->pUpsertWhere); sqlite3DbFree(db, p); } } /* ** Duplicate an Upsert object. */ SQLITE_PRIVATE Upsert *sqlite3UpsertDup(sqlite3 *db, Upsert *p){ if( p==0 ) return 0; return sqlite3UpsertNew(db, sqlite3ExprListDup(db, p->pUpsertTarget, 0), sqlite3ExprDup(db, p->pUpsertTargetWhere, 0), sqlite3ExprListDup(db, p->pUpsertSet, 0), sqlite3ExprDup(db, p->pUpsertWhere, 0) ); } /* ** Create a new Upsert object. */ SQLITE_PRIVATE Upsert *sqlite3UpsertNew( sqlite3 *db, /* Determines which memory allocator to use */ ExprList *pTarget, /* Target argument to ON CONFLICT, or NULL */ Expr *pTargetWhere, /* Optional WHERE clause on the target */ ExprList *pSet, /* UPDATE columns, or NULL for a DO NOTHING */ Expr *pWhere /* WHERE clause for the ON CONFLICT UPDATE */ ){ Upsert *pNew; pNew = sqlite3DbMallocRaw(db, sizeof(Upsert)); if( pNew==0 ){ sqlite3ExprListDelete(db, pTarget); sqlite3ExprDelete(db, pTargetWhere); sqlite3ExprListDelete(db, pSet); sqlite3ExprDelete(db, pWhere); return 0; }else{ pNew->pUpsertTarget = pTarget; pNew->pUpsertTargetWhere = pTargetWhere; pNew->pUpsertSet = pSet; pNew->pUpsertWhere = pWhere; pNew->pUpsertIdx = 0; } return pNew; } /* ** Analyze the ON CONFLICT clause described by pUpsert. Resolve all ** symbols in the conflict-target. ** ** Return SQLITE_OK if everything works, or an error code is something ** is wrong. */ SQLITE_PRIVATE int sqlite3UpsertAnalyzeTarget( Parse *pParse, /* The parsing context */ SrcList *pTabList, /* Table into which we are inserting */ Upsert *pUpsert /* The ON CONFLICT clauses */ ){ Table *pTab; /* That table into which we are inserting */ int rc; /* Result code */ int iCursor; /* Cursor used by pTab */ Index *pIdx; /* One of the indexes of pTab */ ExprList *pTarget; /* The conflict-target clause */ Expr *pTerm; /* One term of the conflict-target clause */ NameContext sNC; /* Context for resolving symbolic names */ Expr sCol[2]; /* Index column converted into an Expr */ assert( pTabList->nSrc==1 ); assert( pTabList->a[0].pTab!=0 ); assert( pUpsert!=0 ); assert( pUpsert->pUpsertTarget!=0 ); /* Resolve all symbolic names in the conflict-target clause, which ** includes both the list of columns and the optional partial-index ** WHERE clause. */ memset(&sNC, 0, sizeof(sNC)); sNC.pParse = pParse; sNC.pSrcList = pTabList; rc = sqlite3ResolveExprListNames(&sNC, pUpsert->pUpsertTarget); if( rc ) return rc; rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere); if( rc ) return rc; /* Check to see if the conflict target matches the rowid. */ pTab = pTabList->a[0].pTab; pTarget = pUpsert->pUpsertTarget; iCursor = pTabList->a[0].iCursor; if( HasRowid(pTab) && pTarget->nExpr==1 && (pTerm = pTarget->a[0].pExpr)->op==TK_COLUMN && pTerm->iColumn==XN_ROWID ){ /* The conflict-target is the rowid of the primary table */ assert( pUpsert->pUpsertIdx==0 ); return SQLITE_OK; } /* Initialize sCol[0..1] to be an expression parse tree for a ** single column of an index. The sCol[0] node will be the TK_COLLATE ** operator and sCol[1] will be the TK_COLUMN operator. Code below ** will populate the specific collation and column number values ** prior to comparing against the conflict-target expression. */ memset(sCol, 0, sizeof(sCol)); sCol[0].op = TK_COLLATE; sCol[0].pLeft = &sCol[1]; sCol[1].op = TK_COLUMN; sCol[1].iTable = pTabList->a[0].iCursor; /* Check for matches against other indexes */ for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ int ii, jj, nn; if( !IsUniqueIndex(pIdx) ) continue; if( pTarget->nExpr!=pIdx->nKeyCol ) continue; if( pIdx->pPartIdxWhere ){ if( pUpsert->pUpsertTargetWhere==0 ) continue; if( sqlite3ExprCompare(pParse, pUpsert->pUpsertTargetWhere, pIdx->pPartIdxWhere, iCursor)!=0 ){ continue; } } nn = pIdx->nKeyCol; for(ii=0; ii<nn; ii++){ Expr *pExpr; sCol[0].u.zToken = (char*)pIdx->azColl[ii]; if( pIdx->aiColumn[ii]==XN_EXPR ){ assert( pIdx->aColExpr!=0 ); assert( pIdx->aColExpr->nExpr>ii ); pExpr = pIdx->aColExpr->a[ii].pExpr; if( pExpr->op!=TK_COLLATE ){ sCol[0].pLeft = pExpr; pExpr = &sCol[0]; } }else{ sCol[0].pLeft = &sCol[1]; sCol[1].iColumn = pIdx->aiColumn[ii]; pExpr = &sCol[0]; } for(jj=0; jj<nn; jj++){ if( sqlite3ExprCompare(pParse, pTarget->a[jj].pExpr, pExpr,iCursor)<2 ){ break; /* Column ii of the index matches column jj of target */ } } if( jj>=nn ){ /* The target contains no match for column jj of the index */ break; } } if( ii<nn ){ /* Column ii of the index did not match any term of the conflict target. ** Continue the search with the next index. */ continue; } pUpsert->pUpsertIdx = pIdx; return SQLITE_OK; } sqlite3ErrorMsg(pParse, "ON CONFLICT clause does not match any " "PRIMARY KEY or UNIQUE constraint"); return SQLITE_ERROR; } /* ** Generate bytecode that does an UPDATE as part of an upsert. ** ** If pIdx is NULL, then the UNIQUE constraint that failed was the IPK. ** In this case parameter iCur is a cursor open on the table b-tree that ** currently points to the conflicting table row. Otherwise, if pIdx ** is not NULL, then pIdx is the constraint that failed and iCur is a ** cursor points to the conflicting row. */ SQLITE_PRIVATE void sqlite3UpsertDoUpdate( Parse *pParse, /* The parsing and code-generating context */ Upsert *pUpsert, /* The ON CONFLICT clause for the upsert */ Table *pTab, /* The table being updated */ Index *pIdx, /* The UNIQUE constraint that failed */ int iCur /* Cursor for pIdx (or pTab if pIdx==NULL) */ ){ Vdbe *v = pParse->pVdbe; sqlite3 *db = pParse->db; SrcList *pSrc; /* FROM clause for the UPDATE */ int iDataCur = pUpsert->iDataCur; assert( v!=0 ); VdbeNoopComment((v, "Begin DO UPDATE of UPSERT")); if( pIdx && iCur!=iDataCur ){ if( HasRowid(pTab) ){ int regRowid = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp2(v, OP_IdxRowid, iCur, regRowid); sqlite3VdbeAddOp3(v, OP_SeekRowid, iDataCur, 0, regRowid); VdbeCoverage(v); sqlite3ReleaseTempReg(pParse, regRowid); }else{ Index *pPk = sqlite3PrimaryKeyIndex(pTab); int nPk = pPk->nKeyCol; int iPk = pParse->nMem+1; int i; pParse->nMem += nPk; for(i=0; i<nPk; i++){ int k; assert( pPk->aiColumn[i]>=0 ); k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[i]); sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i); VdbeComment((v, "%s.%s", pIdx->zName, pTab->aCol[pPk->aiColumn[i]].zName)); } i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk); VdbeCoverage(v); sqlite3VdbeAddOp4(v, OP_Halt, SQLITE_CORRUPT, OE_Abort, 0, "corrupt database", P4_STATIC); sqlite3VdbeJumpHere(v, i); } } /* pUpsert does not own pUpsertSrc - the outer INSERT statement does. So ** we have to make a copy before passing it down into sqlite3Update() */ pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0); sqlite3Update(pParse, pSrc, pUpsert->pUpsertSet, pUpsert->pUpsertWhere, OE_Abort, 0, 0, pUpsert); pUpsert->pUpsertSet = 0; /* Will have been deleted by sqlite3Update() */ pUpsert->pUpsertWhere = 0; /* Will have been deleted by sqlite3Update() */ VdbeNoopComment((v, "End DO UPDATE of UPSERT")); } #endif /* SQLITE_OMIT_UPSERT */ /************** End of upsert.c **********************************************/ /************** Begin file vacuum.c ******************************************/ /* ** 2003 April 6 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** |
︙ | ︙ | |||
129925 129926 129927 129928 129929 129930 129931 | ** a separate source file for easier editing. */ /* ** Trace output macros */ #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) | | | 131078 131079 131080 131081 131082 131083 131084 131085 131086 131087 131088 131089 131090 131091 131092 | ** a separate source file for easier editing. */ /* ** Trace output macros */ #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG) /***/ extern int sqlite3WhereTrace; #endif #if defined(SQLITE_DEBUG) \ && (defined(SQLITE_TEST) || defined(SQLITE_ENABLE_WHERETRACE)) # define WHERETRACE(K,X) if(sqlite3WhereTrace&(K)) sqlite3DebugPrintf X # define WHERETRACE_ENABLED 1 #else # define WHERETRACE(K,X) |
︙ | ︙ | |||
132574 132575 132576 132577 132578 132579 132580 | continue; } if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){ if( iNext==0 ) iNext = 3; continue; } | | | | > | 133727 133728 133729 133730 133731 133732 133733 133734 133735 133736 133737 133738 133739 133740 133741 133742 133743 133744 133745 133746 133747 133748 133749 133750 133751 133752 133753 | continue; } if( iLoop<3 && (pTerm->wtFlags & TERM_VARSELECT) ){ if( iNext==0 ) iNext = 3; continue; } if( (pTerm->wtFlags & TERM_LIKECOND)!=0 ){ /* If the TERM_LIKECOND flag is set, that means that the range search ** is sufficient to guarantee that the LIKE operator is true, so we ** can skip the call to the like(A,B) function. But this only works ** for strings. So do not skip the call to the function on the pass ** that compares BLOBs. */ #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS continue; #else u32 x = pLevel->iLikeRepCntr; if( x>0 ){ skipLikeAddr = sqlite3VdbeAddOp1(v, (x&1)?OP_IfNot:OP_If,(int)(x>>1)); } VdbeCoverage(v); #endif } #ifdef WHERETRACE_ENABLED /* 0xffff */ if( sqlite3WhereTrace ){ VdbeNoopComment((v, "WhereTerm[%d] (%p) priority=%d", pWC->nTerm-j, pTerm, iLoop)); |
︙ | ︙ | |||
136577 136578 136579 136580 136581 136582 136583 | int rc = SQLITE_OK; /* Return code */ LogEst rSize; /* Number of rows in the table */ LogEst rLogSize; /* Logarithm of table size */ WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */ pNew = pBuilder->pNew; if( db->mallocFailed ) return SQLITE_NOMEM_BKPT; | | | | 137731 137732 137733 137734 137735 137736 137737 137738 137739 137740 137741 137742 137743 137744 137745 137746 | int rc = SQLITE_OK; /* Return code */ LogEst rSize; /* Number of rows in the table */ LogEst rLogSize; /* Logarithm of table size */ WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */ pNew = pBuilder->pNew; if( db->mallocFailed ) return SQLITE_NOMEM_BKPT; WHERETRACE(0x800, ("BEGIN %s.addBtreeIdx(%s), nEq=%d\n", pProbe->pTable->zName,pProbe->zName, pNew->u.btree.nEq)); assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 ); if( pNew->wsFlags & WHERE_BTM_LIMIT ){ opMask = WO_LT|WO_LE; }else{ assert( pNew->u.btree.nBtm==0 ); |
︙ | ︙ | |||
136864 136865 136866 136867 136868 136869 136870 | whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul); pNew->nOut = saved_nOut; pNew->u.btree.nEq = saved_nEq; pNew->nSkip = saved_nSkip; pNew->wsFlags = saved_wsFlags; } | | | | 138018 138019 138020 138021 138022 138023 138024 138025 138026 138027 138028 138029 138030 138031 138032 138033 | whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul); pNew->nOut = saved_nOut; pNew->u.btree.nEq = saved_nEq; pNew->nSkip = saved_nSkip; pNew->wsFlags = saved_wsFlags; } WHERETRACE(0x800, ("END %s.addBtreeIdx(%s), nEq=%d, rc=%d\n", pProbe->pTable->zName, pProbe->zName, saved_nEq, rc)); return rc; } /* ** Return True if it is possible that pIndex might be useful in ** implementing the ORDER BY clause in pBuilder. ** |
︙ | ︙ | |||
137303 137304 137305 137306 137307 137308 137309 | int j = pIdxCons->iTermOffset; if( iTerm>=nConstraint || j<0 || j>=pWC->nTerm || pNew->aLTerm[iTerm]!=0 || pIdxCons->usable==0 ){ | < > | | 138457 138458 138459 138460 138461 138462 138463 138464 138465 138466 138467 138468 138469 138470 138471 138472 138473 | int j = pIdxCons->iTermOffset; if( iTerm>=nConstraint || j<0 || j>=pWC->nTerm || pNew->aLTerm[iTerm]!=0 || pIdxCons->usable==0 ){ sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); testcase( pIdxInfo->needToFreeIdxStr ); return SQLITE_ERROR; } testcase( iTerm==nConstraint-1 ); testcase( j==0 ); testcase( j==pWC->nTerm-1 ); pTerm = &pWC->a[j]; pNew->prereq |= pTerm->prereqRight; assert( iTerm<pNew->nLSlot ); |
︙ | ︙ | |||
137333 137334 137335 137336 137337 137338 137339 137340 137341 137342 137343 137344 137345 137346 | *pbIn = 1; assert( (mExclude & WO_IN)==0 ); } } } pNew->u.vtab.omitMask &= ~mNoOmit; pNew->nLTerm = mxTerm+1; assert( pNew->nLTerm<=pNew->nLSlot ); pNew->u.vtab.idxNum = pIdxInfo->idxNum; pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr; pIdxInfo->needToFreeIdxStr = 0; pNew->u.vtab.idxStr = pIdxInfo->idxStr; pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ? pIdxInfo->nOrderBy : 0); | > > > > > > > > > | 138487 138488 138489 138490 138491 138492 138493 138494 138495 138496 138497 138498 138499 138500 138501 138502 138503 138504 138505 138506 138507 138508 138509 | *pbIn = 1; assert( (mExclude & WO_IN)==0 ); } } } pNew->u.vtab.omitMask &= ~mNoOmit; pNew->nLTerm = mxTerm+1; for(i=0; i<=mxTerm; i++){ if( pNew->aLTerm[i]==0 ){ /* The non-zero argvIdx values must be contiguous. Raise an ** error if they are not */ sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName); testcase( pIdxInfo->needToFreeIdxStr ); return SQLITE_ERROR; } } assert( pNew->nLTerm<=pNew->nLSlot ); pNew->u.vtab.idxNum = pIdxInfo->idxNum; pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr; pIdxInfo->needToFreeIdxStr = 0; pNew->u.vtab.idxStr = pIdxInfo->idxStr; pNew->u.vtab.isOrdered = (i8)(pIdxInfo->orderByConsumed ? pIdxInfo->nOrderBy : 0); |
︙ | ︙ | |||
137448 137449 137450 137451 137452 137453 137454 137455 137456 137457 137458 137459 137460 137461 | nConstraint = p->nConstraint; if( whereLoopResize(pParse->db, pNew, nConstraint) ){ sqlite3DbFree(pParse->db, p); return SQLITE_NOMEM_BKPT; } /* First call xBestIndex() with all constraints usable. */ WHERETRACE(0x40, (" VirtualOne: all usable\n")); rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn); /* If the call to xBestIndex() with all terms enabled produced a plan ** that does not require any source tables (IOW: a plan with mBest==0), ** then there is no point in making any further calls to xBestIndex() ** since they will all return the same result (if the xBestIndex() | > | 138611 138612 138613 138614 138615 138616 138617 138618 138619 138620 138621 138622 138623 138624 138625 | nConstraint = p->nConstraint; if( whereLoopResize(pParse->db, pNew, nConstraint) ){ sqlite3DbFree(pParse->db, p); return SQLITE_NOMEM_BKPT; } /* First call xBestIndex() with all constraints usable. */ WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName)); WHERETRACE(0x40, (" VirtualOne: all usable\n")); rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn); /* If the call to xBestIndex() with all terms enabled produced a plan ** that does not require any source tables (IOW: a plan with mBest==0), ** then there is no point in making any further calls to xBestIndex() ** since they will all return the same result (if the xBestIndex() |
︙ | ︙ | |||
137523 137524 137525 137526 137527 137528 137529 137530 137531 137532 137533 137534 137535 137536 | rc = whereLoopAddVirtualOne( pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn); } } if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); sqlite3DbFreeNN(pParse->db, p); return rc; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ /* ** Add WhereLoop entries to handle OR terms. This works for either ** btrees or virtual tables. | > | 138687 138688 138689 138690 138691 138692 138693 138694 138695 138696 138697 138698 138699 138700 138701 | rc = whereLoopAddVirtualOne( pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn); } } if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr); sqlite3DbFreeNN(pParse->db, p); WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc)); return rc; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ /* ** Add WhereLoop entries to handle OR terms. This works for either ** btrees or virtual tables. |
︙ | ︙ | |||
139615 139616 139617 139618 139619 139620 139621 139622 139623 139624 139625 139626 139627 139628 139629 139630 139631 139632 139633 139634 139635 139636 139637 139638 139639 139640 139641 139642 | ** This is typically a union of many types, one of ** which is sqlite3ParserTOKENTYPE. The entry in the union ** for terminal symbols is called "yy0". ** YYSTACKDEPTH is the maximum depth of the parser's stack. If ** zero the stack is dynamically sized using realloc() ** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument ** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument ** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser ** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. ** YYNRULE the number of rules in the grammar ** YYNTOKEN Number of terminal symbols ** YY_MAX_SHIFT Maximum value for shift actions ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions ** YY_ERROR_ACTION The yy_action[] code for syntax error ** YY_ACCEPT_ACTION The yy_action[] code for accept ** YY_NO_ACTION The yy_action[] code for no-op ** YY_MIN_REDUCE Minimum value for reduce actions ** YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char | > > | | | < | > | < | > | > | | | | | | > | | > > > > > | | | | | | | | | | | | 140780 140781 140782 140783 140784 140785 140786 140787 140788 140789 140790 140791 140792 140793 140794 140795 140796 140797 140798 140799 140800 140801 140802 140803 140804 140805 140806 140807 140808 140809 140810 140811 140812 140813 140814 140815 140816 140817 140818 140819 140820 140821 140822 140823 140824 140825 140826 140827 140828 140829 140830 140831 140832 140833 140834 140835 140836 140837 140838 140839 140840 140841 140842 140843 140844 140845 140846 140847 140848 140849 140850 140851 140852 140853 140854 140855 140856 140857 140858 140859 140860 140861 | ** This is typically a union of many types, one of ** which is sqlite3ParserTOKENTYPE. The entry in the union ** for terminal symbols is called "yy0". ** YYSTACKDEPTH is the maximum depth of the parser's stack. If ** zero the stack is dynamically sized using realloc() ** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument ** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument ** sqlite3ParserARG_PARAM Code to pass %extra_argument as a subroutine parameter ** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser ** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser ** sqlite3ParserCTX_* As sqlite3ParserARG_ except for %extra_context ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. ** YYNRULE the number of rules in the grammar ** YYNTOKEN Number of terminal symbols ** YY_MAX_SHIFT Maximum value for shift actions ** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions ** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions ** YY_ERROR_ACTION The yy_action[] code for syntax error ** YY_ACCEPT_ACTION The yy_action[] code for accept ** YY_NO_ACTION The yy_action[] code for no-op ** YY_MIN_REDUCE Minimum value for reduce actions ** YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char #define YYNOCODE 255 #define YYACTIONTYPE unsigned short int #define YYWILDCARD 84 #define sqlite3ParserTOKENTYPE Token typedef union { int yyinit; sqlite3ParserTOKENTYPE yy0; const char* yy36; TriggerStep* yy47; With* yy91; struct {int value; int mask;} yy107; Expr* yy182; Upsert* yy198; ExprList* yy232; struct TrigEvent yy300; Select* yy399; SrcList* yy427; int yy502; IdList* yy510; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define sqlite3ParserARG_SDECL #define sqlite3ParserARG_PDECL #define sqlite3ParserARG_PARAM #define sqlite3ParserARG_FETCH #define sqlite3ParserARG_STORE #define sqlite3ParserCTX_SDECL Parse *pParse; #define sqlite3ParserCTX_PDECL ,Parse *pParse #define sqlite3ParserCTX_PARAM ,pParse #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; #define YYFALLBACK 1 #define YYNSTATE 490 #define YYNRULE 341 #define YYNTOKEN 145 #define YY_MAX_SHIFT 489 #define YY_MIN_SHIFTREDUCE 705 #define YY_MAX_SHIFTREDUCE 1045 #define YY_ERROR_ACTION 1046 #define YY_ACCEPT_ACTION 1047 #define YY_NO_ACTION 1048 #define YY_MIN_REDUCE 1049 #define YY_MAX_REDUCE 1389 /************* End control #defines *******************************************/ /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. ** ** Applications can choose to define yytestcase() in the %include section ** to a macro that can assist in verifying code coverage. For production |
︙ | ︙ | |||
139739 139740 139741 139742 139743 139744 139745 | ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > < < < < < < | | | | | | | | | | | | | > > > > > > > < < < < < < < | | | | | | | | | | | | | > > > > > > > > < < < < < < < < | | | | | | | | | | | > > > > > > > > > > | | | | | | | | | | | | | | | | | | | > | | | | | | | | | | | | | | | < < < < < | | | | | | | | < < | < < < | | | | | | | | | | | | | | | > | > > > | > > > > > > > | | | | | | | | < | | > | > > > > > | | > | | | | | | | | | | | | < | | | | | | | > | | > | > | | < | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | < | | < < | > > | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | 140913 140914 140915 140916 140917 140918 140919 140920 140921 140922 140923 140924 140925 140926 140927 140928 140929 140930 140931 140932 140933 140934 140935 140936 140937 140938 140939 140940 140941 140942 140943 140944 140945 140946 140947 140948 140949 140950 140951 140952 140953 140954 140955 140956 140957 140958 140959 140960 140961 140962 140963 140964 140965 140966 140967 140968 140969 140970 140971 140972 140973 140974 140975 140976 140977 140978 140979 140980 140981 140982 140983 140984 140985 140986 140987 140988 140989 140990 140991 140992 140993 140994 140995 140996 140997 140998 140999 141000 141001 141002 141003 141004 141005 141006 141007 141008 141009 141010 141011 141012 141013 141014 141015 141016 141017 141018 141019 141020 141021 141022 141023 141024 141025 141026 141027 141028 141029 141030 141031 141032 141033 141034 141035 141036 141037 141038 141039 141040 141041 141042 141043 141044 141045 141046 141047 141048 141049 141050 141051 141052 141053 141054 141055 141056 141057 141058 141059 141060 141061 141062 141063 141064 141065 141066 141067 141068 141069 141070 141071 141072 141073 141074 141075 141076 141077 141078 141079 141080 141081 141082 141083 141084 141085 141086 141087 141088 141089 141090 141091 141092 141093 141094 141095 141096 141097 141098 141099 141100 141101 141102 141103 141104 141105 141106 141107 141108 141109 141110 141111 141112 141113 141114 141115 141116 141117 141118 141119 141120 141121 141122 141123 141124 141125 141126 141127 141128 141129 141130 141131 141132 141133 141134 141135 141136 141137 141138 141139 141140 141141 141142 141143 141144 141145 141146 141147 141148 141149 141150 141151 141152 141153 141154 141155 141156 141157 141158 141159 141160 141161 141162 141163 141164 141165 141166 141167 141168 141169 141170 141171 141172 141173 141174 141175 141176 141177 141178 141179 141180 141181 141182 141183 141184 141185 141186 141187 141188 141189 141190 141191 141192 141193 141194 141195 141196 141197 141198 141199 141200 141201 141202 141203 141204 141205 141206 141207 141208 141209 141210 141211 141212 141213 141214 141215 141216 141217 141218 141219 141220 141221 141222 141223 141224 141225 141226 141227 141228 141229 141230 141231 141232 141233 141234 141235 141236 141237 141238 141239 141240 141241 141242 141243 141244 141245 141246 141247 141248 141249 141250 141251 141252 141253 141254 141255 141256 141257 141258 141259 141260 141261 141262 141263 141264 141265 141266 141267 141268 141269 141270 141271 141272 141273 141274 141275 141276 141277 141278 141279 141280 141281 141282 141283 141284 141285 141286 141287 141288 141289 141290 141291 141292 141293 141294 141295 141296 141297 141298 141299 141300 141301 141302 141303 141304 141305 141306 141307 141308 141309 141310 141311 141312 141313 141314 141315 141316 141317 141318 141319 141320 141321 141322 141323 141324 141325 141326 141327 141328 141329 141330 141331 141332 141333 141334 141335 141336 141337 141338 141339 141340 141341 141342 141343 141344 141345 141346 141347 141348 141349 141350 141351 141352 141353 141354 141355 141356 141357 141358 141359 141360 141361 141362 141363 141364 141365 141366 141367 141368 141369 141370 141371 141372 141373 141374 141375 141376 141377 141378 141379 141380 141381 141382 141383 141384 141385 141386 141387 141388 141389 141390 141391 141392 141393 141394 141395 141396 141397 141398 141399 141400 141401 141402 141403 141404 141405 141406 141407 141408 141409 141410 141411 141412 141413 141414 141415 141416 141417 141418 141419 141420 141421 141422 141423 | ** yy_shift_ofst[] For each state, the offset into yy_action for ** shifting terminals. ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (1657) static const YYACTIONTYPE yy_action[] = { /* 0 */ 349, 99, 96, 185, 99, 96, 185, 233, 1047, 1, /* 10 */ 1, 489, 2, 1051, 484, 477, 477, 477, 260, 351, /* 20 */ 121, 1310, 1120, 1120, 1178, 1115, 1094, 1128, 380, 380, /* 30 */ 380, 835, 454, 410, 1115, 59, 59, 1357, 425, 836, /* 40 */ 710, 711, 712, 106, 107, 97, 1023, 1023, 900, 903, /* 50 */ 892, 892, 104, 104, 105, 105, 105, 105, 346, 238, /* 60 */ 238, 99, 96, 185, 238, 238, 889, 889, 901, 904, /* 70 */ 460, 481, 351, 99, 96, 185, 481, 347, 1177, 82, /* 80 */ 388, 214, 182, 23, 194, 103, 103, 103, 103, 102, /* 90 */ 102, 101, 101, 101, 100, 381, 106, 107, 97, 1023, /* 100 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105, /* 110 */ 105, 10, 385, 484, 24, 484, 1333, 489, 2, 1051, /* 120 */ 335, 1043, 108, 893, 260, 351, 121, 99, 96, 185, /* 130 */ 100, 381, 386, 1128, 59, 59, 59, 59, 103, 103, /* 140 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 106, /* 150 */ 107, 97, 1023, 1023, 900, 903, 892, 892, 104, 104, /* 160 */ 105, 105, 105, 105, 360, 238, 238, 170, 170, 467, /* 170 */ 455, 467, 464, 67, 381, 329, 169, 481, 351, 343, /* 180 */ 338, 400, 1044, 68, 101, 101, 101, 100, 381, 393, /* 190 */ 194, 103, 103, 103, 103, 102, 102, 101, 101, 101, /* 200 */ 100, 381, 106, 107, 97, 1023, 1023, 900, 903, 892, /* 210 */ 892, 104, 104, 105, 105, 105, 105, 483, 385, 103, /* 220 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381, /* 230 */ 268, 351, 946, 946, 422, 296, 102, 102, 101, 101, /* 240 */ 101, 100, 381, 861, 103, 103, 103, 103, 102, 102, /* 250 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023, /* 260 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105, /* 270 */ 484, 983, 1383, 206, 1353, 1383, 438, 435, 434, 281, /* 280 */ 396, 269, 1089, 941, 351, 1002, 433, 861, 743, 401, /* 290 */ 282, 57, 57, 482, 145, 791, 791, 103, 103, 103, /* 300 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 107, /* 310 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105, /* 320 */ 105, 105, 105, 281, 1002, 1003, 1004, 206, 879, 319, /* 330 */ 438, 435, 434, 981, 259, 474, 360, 351, 1118, 1118, /* 340 */ 433, 736, 379, 378, 872, 1002, 1356, 322, 871, 766, /* 350 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100, /* 360 */ 381, 106, 107, 97, 1023, 1023, 900, 903, 892, 892, /* 370 */ 104, 104, 105, 105, 105, 105, 484, 801, 484, 871, /* 380 */ 871, 873, 401, 282, 1002, 1003, 1004, 1030, 360, 1030, /* 390 */ 351, 983, 1384, 213, 880, 1384, 145, 59, 59, 59, /* 400 */ 59, 1002, 244, 103, 103, 103, 103, 102, 102, 101, /* 410 */ 101, 101, 100, 381, 106, 107, 97, 1023, 1023, 900, /* 420 */ 903, 892, 892, 104, 104, 105, 105, 105, 105, 274, /* 430 */ 484, 110, 467, 479, 467, 444, 259, 474, 232, 232, /* 440 */ 1002, 1003, 1004, 351, 210, 335, 982, 866, 1385, 336, /* 450 */ 481, 59, 59, 981, 245, 307, 103, 103, 103, 103, /* 460 */ 102, 102, 101, 101, 101, 100, 381, 106, 107, 97, /* 470 */ 1023, 1023, 900, 903, 892, 892, 104, 104, 105, 105, /* 480 */ 105, 105, 453, 459, 484, 408, 377, 259, 474, 271, /* 490 */ 183, 273, 209, 208, 207, 356, 351, 307, 178, 177, /* 500 */ 127, 1006, 1098, 14, 14, 43, 43, 1044, 425, 103, /* 510 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381, /* 520 */ 106, 107, 97, 1023, 1023, 900, 903, 892, 892, 104, /* 530 */ 104, 105, 105, 105, 105, 294, 1132, 408, 160, 484, /* 540 */ 408, 1006, 129, 962, 1209, 239, 239, 481, 307, 425, /* 550 */ 1309, 1097, 351, 235, 243, 272, 820, 481, 963, 425, /* 560 */ 11, 11, 103, 103, 103, 103, 102, 102, 101, 101, /* 570 */ 101, 100, 381, 964, 362, 1002, 106, 107, 97, 1023, /* 580 */ 1023, 900, 903, 892, 892, 104, 104, 105, 105, 105, /* 590 */ 105, 1275, 161, 126, 777, 289, 1209, 292, 1072, 357, /* 600 */ 1209, 1127, 476, 357, 778, 425, 247, 425, 351, 248, /* 610 */ 414, 364, 414, 171, 1002, 1003, 1004, 84, 103, 103, /* 620 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 1002, /* 630 */ 184, 484, 106, 107, 97, 1023, 1023, 900, 903, 892, /* 640 */ 892, 104, 104, 105, 105, 105, 105, 1123, 1209, 287, /* 650 */ 484, 1209, 11, 11, 179, 820, 259, 474, 307, 237, /* 660 */ 182, 351, 321, 365, 414, 308, 367, 366, 1002, 1003, /* 670 */ 1004, 44, 44, 87, 103, 103, 103, 103, 102, 102, /* 680 */ 101, 101, 101, 100, 381, 106, 107, 97, 1023, 1023, /* 690 */ 900, 903, 892, 892, 104, 104, 105, 105, 105, 105, /* 700 */ 246, 368, 280, 128, 10, 358, 146, 796, 835, 258, /* 710 */ 1020, 88, 795, 86, 351, 421, 836, 943, 376, 348, /* 720 */ 191, 943, 1318, 267, 308, 279, 456, 103, 103, 103, /* 730 */ 103, 102, 102, 101, 101, 101, 100, 381, 106, 95, /* 740 */ 97, 1023, 1023, 900, 903, 892, 892, 104, 104, 105, /* 750 */ 105, 105, 105, 420, 249, 238, 238, 238, 238, 79, /* 760 */ 375, 125, 305, 29, 262, 978, 351, 481, 337, 481, /* 770 */ 756, 755, 304, 278, 415, 15, 81, 940, 1126, 940, /* 780 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100, /* 790 */ 381, 107, 97, 1023, 1023, 900, 903, 892, 892, 104, /* 800 */ 104, 105, 105, 105, 105, 457, 263, 484, 174, 484, /* 810 */ 238, 238, 863, 407, 402, 216, 216, 351, 409, 193, /* 820 */ 283, 216, 481, 81, 763, 764, 266, 5, 13, 13, /* 830 */ 34, 34, 103, 103, 103, 103, 102, 102, 101, 101, /* 840 */ 101, 100, 381, 97, 1023, 1023, 900, 903, 892, 892, /* 850 */ 104, 104, 105, 105, 105, 105, 93, 475, 1002, 4, /* 860 */ 403, 1002, 340, 431, 1002, 297, 212, 1277, 81, 746, /* 870 */ 1163, 152, 926, 478, 166, 212, 757, 829, 930, 939, /* 880 */ 216, 939, 858, 103, 103, 103, 103, 102, 102, 101, /* 890 */ 101, 101, 100, 381, 238, 238, 382, 1002, 1003, 1004, /* 900 */ 1002, 1003, 1004, 1002, 1003, 1004, 481, 439, 472, 746, /* 910 */ 105, 105, 105, 105, 98, 758, 1162, 145, 930, 412, /* 920 */ 879, 406, 793, 81, 395, 89, 90, 91, 105, 105, /* 930 */ 105, 105, 1323, 92, 484, 382, 486, 485, 240, 275, /* 940 */ 871, 103, 103, 103, 103, 102, 102, 101, 101, 101, /* 950 */ 100, 381, 1096, 371, 355, 45, 45, 259, 474, 103, /* 960 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381, /* 970 */ 1150, 871, 871, 873, 874, 21, 1332, 991, 384, 730, /* 980 */ 722, 242, 123, 1298, 124, 875, 333, 333, 332, 227, /* 990 */ 330, 991, 384, 719, 256, 242, 484, 391, 413, 1297, /* 1000 */ 333, 333, 332, 227, 330, 748, 187, 719, 265, 470, /* 1010 */ 1279, 1002, 484, 417, 391, 390, 264, 11, 11, 284, /* 1020 */ 187, 732, 265, 93, 475, 875, 4, 1279, 1281, 419, /* 1030 */ 264, 369, 416, 11, 11, 1159, 288, 484, 399, 1346, /* 1040 */ 478, 379, 378, 291, 484, 293, 189, 250, 295, 1027, /* 1050 */ 1002, 1003, 1004, 190, 1029, 1111, 140, 188, 11, 11, /* 1060 */ 189, 732, 1028, 382, 923, 46, 46, 190, 1095, 230, /* 1070 */ 140, 188, 462, 93, 475, 472, 4, 300, 309, 391, /* 1080 */ 373, 6, 1069, 217, 739, 310, 1030, 879, 1030, 1171, /* 1090 */ 478, 352, 1279, 90, 91, 800, 259, 474, 1208, 484, /* 1100 */ 92, 1268, 382, 486, 485, 352, 1002, 871, 879, 426, /* 1110 */ 259, 474, 172, 382, 238, 238, 1146, 170, 1021, 389, /* 1120 */ 47, 47, 1157, 739, 872, 472, 481, 469, 871, 350, /* 1130 */ 1214, 83, 475, 389, 4, 1078, 1071, 879, 871, 871, /* 1140 */ 873, 874, 21, 90, 91, 1002, 1003, 1004, 478, 251, /* 1150 */ 92, 251, 382, 486, 485, 443, 370, 871, 1021, 871, /* 1160 */ 871, 873, 224, 241, 306, 441, 301, 440, 211, 1060, /* 1170 */ 820, 382, 822, 447, 299, 1059, 484, 1061, 1143, 962, /* 1180 */ 430, 796, 484, 472, 1340, 312, 795, 465, 871, 871, /* 1190 */ 873, 874, 21, 314, 963, 879, 316, 59, 59, 1002, /* 1200 */ 9, 90, 91, 48, 48, 238, 238, 210, 92, 964, /* 1210 */ 382, 486, 485, 176, 334, 871, 242, 481, 1193, 238, /* 1220 */ 238, 333, 333, 332, 227, 330, 394, 270, 719, 277, /* 1230 */ 471, 481, 467, 466, 484, 145, 217, 1201, 1002, 1003, /* 1240 */ 1004, 187, 3, 265, 184, 445, 871, 871, 873, 874, /* 1250 */ 21, 264, 1337, 450, 1051, 39, 39, 392, 356, 260, /* 1260 */ 342, 121, 468, 411, 436, 821, 180, 1094, 1128, 820, /* 1270 */ 303, 1021, 1272, 1271, 299, 259, 474, 238, 238, 1002, /* 1280 */ 473, 189, 484, 318, 327, 238, 238, 484, 190, 481, /* 1290 */ 446, 140, 188, 1343, 238, 238, 1038, 481, 148, 175, /* 1300 */ 238, 238, 484, 49, 49, 219, 481, 484, 35, 35, /* 1310 */ 1317, 1021, 481, 484, 1035, 484, 1315, 484, 1002, 1003, /* 1320 */ 1004, 484, 66, 36, 36, 194, 352, 484, 38, 38, /* 1330 */ 484, 259, 474, 69, 50, 50, 51, 51, 52, 52, /* 1340 */ 359, 484, 12, 12, 484, 1198, 484, 158, 53, 53, /* 1350 */ 405, 112, 112, 385, 389, 484, 26, 484, 143, 484, /* 1360 */ 150, 484, 54, 54, 397, 40, 40, 55, 55, 484, /* 1370 */ 79, 484, 153, 1190, 484, 154, 56, 56, 41, 41, /* 1380 */ 58, 58, 133, 133, 484, 398, 484, 429, 484, 155, /* 1390 */ 134, 134, 135, 135, 484, 63, 63, 484, 341, 484, /* 1400 */ 339, 484, 196, 484, 156, 42, 42, 113, 113, 60, /* 1410 */ 60, 484, 404, 484, 27, 114, 114, 1204, 115, 115, /* 1420 */ 111, 111, 132, 132, 131, 131, 1266, 418, 484, 162, /* 1430 */ 484, 200, 119, 119, 118, 118, 484, 74, 424, 484, /* 1440 */ 1286, 484, 231, 484, 202, 484, 167, 286, 427, 116, /* 1450 */ 116, 117, 117, 290, 203, 442, 1062, 62, 62, 204, /* 1460 */ 64, 64, 61, 61, 33, 33, 37, 37, 344, 372, /* 1470 */ 1114, 1105, 748, 1113, 374, 1112, 254, 458, 1086, 255, /* 1480 */ 345, 1085, 302, 1084, 1355, 78, 1154, 311, 1104, 449, /* 1490 */ 452, 1155, 1153, 218, 7, 313, 315, 320, 1152, 85, /* 1500 */ 1252, 317, 109, 80, 463, 225, 461, 1068, 25, 487, /* 1510 */ 997, 323, 257, 226, 229, 228, 1136, 324, 325, 326, /* 1520 */ 488, 136, 1057, 1052, 1302, 1303, 1301, 706, 1300, 137, /* 1530 */ 122, 138, 383, 173, 1082, 261, 186, 252, 1081, 65, /* 1540 */ 387, 120, 938, 936, 855, 353, 149, 1079, 139, 151, /* 1550 */ 192, 780, 195, 276, 952, 157, 141, 361, 70, 363, /* 1560 */ 859, 159, 71, 72, 142, 73, 955, 354, 147, 197, /* 1570 */ 198, 951, 130, 16, 199, 285, 216, 1032, 201, 423, /* 1580 */ 164, 944, 163, 28, 721, 428, 304, 165, 205, 759, /* 1590 */ 75, 432, 298, 17, 18, 437, 76, 253, 878, 144, /* 1600 */ 877, 906, 77, 986, 30, 448, 987, 31, 451, 181, /* 1610 */ 234, 236, 168, 828, 823, 89, 910, 921, 81, 907, /* 1620 */ 215, 905, 909, 961, 960, 19, 221, 20, 220, 22, /* 1630 */ 32, 331, 876, 731, 94, 790, 794, 8, 992, 222, /* 1640 */ 480, 328, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, /* 1650 */ 223, 1048, 1048, 1048, 1048, 1348, 1347, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 174, 226, 227, 228, 226, 227, 228, 172, 145, 146, /* 10 */ 147, 148, 149, 150, 153, 169, 170, 171, 155, 19, /* 20 */ 157, 246, 192, 193, 177, 181, 182, 164, 169, 170, /* 30 */ 171, 31, 164, 153, 190, 174, 175, 187, 153, 39, /* 40 */ 7, 8, 9, 43, 44, 45, 46, 47, 48, 49, /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 174, 196, /* 60 */ 197, 226, 227, 228, 196, 197, 46, 47, 48, 49, /* 70 */ 209, 208, 19, 226, 227, 228, 208, 174, 177, 26, /* 80 */ 195, 213, 214, 22, 221, 85, 86, 87, 88, 89, /* 90 */ 90, 91, 92, 93, 94, 95, 43, 44, 45, 46, /* 100 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, /* 110 */ 57, 172, 249, 153, 53, 153, 147, 148, 149, 150, /* 120 */ 22, 23, 69, 103, 155, 19, 157, 226, 227, 228, /* 130 */ 94, 95, 247, 164, 174, 175, 174, 175, 85, 86, /* 140 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 43, /* 150 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, /* 160 */ 54, 55, 56, 57, 153, 196, 197, 153, 153, 209, /* 170 */ 210, 209, 210, 67, 95, 161, 237, 208, 19, 165, /* 180 */ 165, 242, 84, 24, 91, 92, 93, 94, 95, 223, /* 190 */ 221, 85, 86, 87, 88, 89, 90, 91, 92, 93, /* 200 */ 94, 95, 43, 44, 45, 46, 47, 48, 49, 50, /* 210 */ 51, 52, 53, 54, 55, 56, 57, 153, 249, 85, /* 220 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 230 */ 219, 19, 109, 110, 111, 23, 89, 90, 91, 92, /* 240 */ 93, 94, 95, 73, 85, 86, 87, 88, 89, 90, /* 250 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47, /* 260 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, /* 270 */ 153, 22, 23, 101, 173, 26, 104, 105, 106, 109, /* 280 */ 110, 111, 181, 11, 19, 59, 114, 73, 23, 110, /* 290 */ 111, 174, 175, 116, 80, 118, 119, 85, 86, 87, /* 300 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44, /* 310 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, /* 320 */ 55, 56, 57, 109, 98, 99, 100, 101, 83, 153, /* 330 */ 104, 105, 106, 84, 120, 121, 153, 19, 192, 193, /* 340 */ 114, 23, 89, 90, 99, 59, 23, 230, 103, 26, /* 350 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, /* 360 */ 95, 43, 44, 45, 46, 47, 48, 49, 50, 51, /* 370 */ 52, 53, 54, 55, 56, 57, 153, 91, 153, 134, /* 380 */ 135, 136, 110, 111, 98, 99, 100, 134, 153, 136, /* 390 */ 19, 22, 23, 26, 23, 26, 80, 174, 175, 174, /* 400 */ 175, 59, 219, 85, 86, 87, 88, 89, 90, 91, /* 410 */ 92, 93, 94, 95, 43, 44, 45, 46, 47, 48, /* 420 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 16, /* 430 */ 153, 22, 209, 210, 209, 210, 120, 121, 196, 197, /* 440 */ 98, 99, 100, 19, 46, 22, 23, 23, 252, 253, /* 450 */ 208, 174, 175, 84, 219, 153, 85, 86, 87, 88, /* 460 */ 89, 90, 91, 92, 93, 94, 95, 43, 44, 45, /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, /* 480 */ 56, 57, 153, 153, 153, 153, 209, 120, 121, 76, /* 490 */ 153, 78, 109, 110, 111, 97, 19, 153, 89, 90, /* 500 */ 198, 59, 183, 174, 175, 174, 175, 84, 153, 85, /* 510 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 520 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, /* 530 */ 53, 54, 55, 56, 57, 16, 197, 153, 22, 153, /* 540 */ 153, 99, 198, 12, 153, 196, 197, 208, 153, 153, /* 550 */ 195, 183, 19, 23, 222, 142, 26, 208, 27, 153, /* 560 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92, /* 570 */ 93, 94, 95, 42, 188, 59, 43, 44, 45, 46, /* 580 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, /* 590 */ 57, 195, 22, 198, 63, 76, 153, 78, 167, 168, /* 600 */ 153, 195, 167, 168, 73, 153, 222, 153, 19, 222, /* 610 */ 153, 220, 153, 24, 98, 99, 100, 140, 85, 86, /* 620 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 59, /* 630 */ 100, 153, 43, 44, 45, 46, 47, 48, 49, 50, /* 640 */ 51, 52, 53, 54, 55, 56, 57, 195, 153, 195, /* 650 */ 153, 153, 174, 175, 26, 125, 120, 121, 153, 213, /* 660 */ 214, 19, 153, 220, 153, 153, 188, 220, 98, 99, /* 670 */ 100, 174, 175, 140, 85, 86, 87, 88, 89, 90, /* 680 */ 91, 92, 93, 94, 95, 43, 44, 45, 46, 47, /* 690 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, /* 700 */ 243, 189, 243, 198, 172, 250, 251, 117, 31, 201, /* 710 */ 26, 139, 122, 141, 19, 220, 39, 29, 220, 211, /* 720 */ 24, 33, 153, 164, 153, 164, 19, 85, 86, 87, /* 730 */ 88, 89, 90, 91, 92, 93, 94, 95, 43, 44, /* 740 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, /* 750 */ 55, 56, 57, 65, 243, 196, 197, 196, 197, 131, /* 760 */ 189, 22, 103, 24, 153, 23, 19, 208, 26, 208, /* 770 */ 102, 103, 113, 23, 242, 22, 26, 134, 164, 136, /* 780 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, /* 790 */ 95, 44, 45, 46, 47, 48, 49, 50, 51, 52, /* 800 */ 53, 54, 55, 56, 57, 98, 153, 153, 124, 153, /* 810 */ 196, 197, 23, 23, 61, 26, 26, 19, 23, 123, /* 820 */ 23, 26, 208, 26, 7, 8, 153, 22, 174, 175, /* 830 */ 174, 175, 85, 86, 87, 88, 89, 90, 91, 92, /* 840 */ 93, 94, 95, 45, 46, 47, 48, 49, 50, 51, /* 850 */ 52, 53, 54, 55, 56, 57, 19, 20, 59, 22, /* 860 */ 111, 59, 164, 23, 59, 23, 26, 153, 26, 59, /* 870 */ 153, 72, 23, 36, 72, 26, 35, 23, 59, 134, /* 880 */ 26, 136, 133, 85, 86, 87, 88, 89, 90, 91, /* 890 */ 92, 93, 94, 95, 196, 197, 59, 98, 99, 100, /* 900 */ 98, 99, 100, 98, 99, 100, 208, 66, 71, 99, /* 910 */ 54, 55, 56, 57, 58, 74, 153, 80, 99, 19, /* 920 */ 83, 223, 23, 26, 153, 26, 89, 90, 54, 55, /* 930 */ 56, 57, 153, 96, 153, 98, 99, 100, 22, 153, /* 940 */ 103, 85, 86, 87, 88, 89, 90, 91, 92, 93, /* 950 */ 94, 95, 183, 112, 158, 174, 175, 120, 121, 85, /* 960 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 970 */ 215, 134, 135, 136, 137, 138, 0, 1, 2, 23, /* 980 */ 21, 5, 26, 153, 22, 59, 10, 11, 12, 13, /* 990 */ 14, 1, 2, 17, 212, 5, 153, 153, 98, 153, /* 1000 */ 10, 11, 12, 13, 14, 108, 30, 17, 32, 193, /* 1010 */ 153, 59, 153, 153, 170, 171, 40, 174, 175, 153, /* 1020 */ 30, 59, 32, 19, 20, 99, 22, 170, 171, 233, /* 1030 */ 40, 188, 236, 174, 175, 153, 153, 153, 79, 123, /* 1040 */ 36, 89, 90, 153, 153, 153, 70, 188, 153, 97, /* 1050 */ 98, 99, 100, 77, 102, 153, 80, 81, 174, 175, /* 1060 */ 70, 99, 110, 59, 105, 174, 175, 77, 153, 238, /* 1070 */ 80, 81, 188, 19, 20, 71, 22, 153, 153, 235, /* 1080 */ 19, 22, 164, 24, 59, 153, 134, 83, 136, 153, /* 1090 */ 36, 115, 235, 89, 90, 91, 120, 121, 153, 153, /* 1100 */ 96, 142, 98, 99, 100, 115, 59, 103, 83, 239, /* 1110 */ 120, 121, 199, 59, 196, 197, 153, 153, 59, 143, /* 1120 */ 174, 175, 153, 98, 99, 71, 208, 153, 103, 165, /* 1130 */ 153, 19, 20, 143, 22, 153, 153, 83, 134, 135, /* 1140 */ 136, 137, 138, 89, 90, 98, 99, 100, 36, 185, /* 1150 */ 96, 187, 98, 99, 100, 91, 95, 103, 99, 134, /* 1160 */ 135, 136, 101, 102, 103, 104, 105, 106, 107, 153, /* 1170 */ 26, 59, 125, 164, 113, 153, 153, 153, 212, 12, /* 1180 */ 19, 117, 153, 71, 153, 212, 122, 164, 134, 135, /* 1190 */ 136, 137, 138, 212, 27, 83, 212, 174, 175, 59, /* 1200 */ 200, 89, 90, 174, 175, 196, 197, 46, 96, 42, /* 1210 */ 98, 99, 100, 172, 151, 103, 5, 208, 203, 196, /* 1220 */ 197, 10, 11, 12, 13, 14, 216, 216, 17, 244, /* 1230 */ 63, 208, 209, 210, 153, 80, 24, 203, 98, 99, /* 1240 */ 100, 30, 22, 32, 100, 164, 134, 135, 136, 137, /* 1250 */ 138, 40, 148, 164, 150, 174, 175, 102, 97, 155, /* 1260 */ 203, 157, 164, 244, 178, 125, 186, 182, 164, 125, /* 1270 */ 177, 59, 177, 177, 113, 120, 121, 196, 197, 59, /* 1280 */ 232, 70, 153, 216, 202, 196, 197, 153, 77, 208, /* 1290 */ 209, 80, 81, 156, 196, 197, 60, 208, 248, 200, /* 1300 */ 196, 197, 153, 174, 175, 123, 208, 153, 174, 175, /* 1310 */ 160, 99, 208, 153, 38, 153, 160, 153, 98, 99, /* 1320 */ 100, 153, 245, 174, 175, 221, 115, 153, 174, 175, /* 1330 */ 153, 120, 121, 245, 174, 175, 174, 175, 174, 175, /* 1340 */ 160, 153, 174, 175, 153, 225, 153, 22, 174, 175, /* 1350 */ 97, 174, 175, 249, 143, 153, 224, 153, 43, 153, /* 1360 */ 191, 153, 174, 175, 18, 174, 175, 174, 175, 153, /* 1370 */ 131, 153, 194, 203, 153, 194, 174, 175, 174, 175, /* 1380 */ 174, 175, 174, 175, 153, 160, 153, 18, 153, 194, /* 1390 */ 174, 175, 174, 175, 153, 174, 175, 153, 225, 153, /* 1400 */ 203, 153, 159, 153, 194, 174, 175, 174, 175, 174, /* 1410 */ 175, 153, 203, 153, 224, 174, 175, 191, 174, 175, /* 1420 */ 174, 175, 174, 175, 174, 175, 203, 160, 153, 191, /* 1430 */ 153, 159, 174, 175, 174, 175, 153, 139, 62, 153, /* 1440 */ 241, 153, 160, 153, 159, 153, 22, 240, 179, 174, /* 1450 */ 175, 174, 175, 160, 159, 97, 160, 174, 175, 159, /* 1460 */ 174, 175, 174, 175, 174, 175, 174, 175, 179, 64, /* 1470 */ 176, 184, 108, 176, 95, 176, 234, 126, 176, 234, /* 1480 */ 179, 178, 176, 176, 176, 97, 218, 217, 184, 179, /* 1490 */ 179, 218, 218, 160, 22, 217, 217, 160, 218, 139, /* 1500 */ 229, 217, 130, 129, 127, 25, 128, 163, 26, 162, /* 1510 */ 13, 206, 231, 154, 6, 154, 207, 205, 204, 203, /* 1520 */ 152, 166, 152, 152, 172, 172, 172, 4, 172, 166, /* 1530 */ 180, 166, 3, 22, 172, 144, 15, 180, 172, 172, /* 1540 */ 82, 16, 23, 23, 121, 254, 132, 172, 112, 124, /* 1550 */ 24, 20, 126, 16, 1, 124, 112, 61, 53, 37, /* 1560 */ 133, 132, 53, 53, 112, 53, 98, 254, 251, 34, /* 1570 */ 123, 1, 5, 22, 97, 142, 26, 75, 123, 41, /* 1580 */ 97, 68, 68, 24, 20, 19, 113, 22, 107, 28, /* 1590 */ 22, 67, 23, 22, 22, 67, 22, 67, 23, 37, /* 1600 */ 23, 23, 26, 23, 22, 24, 23, 22, 24, 123, /* 1610 */ 23, 23, 22, 98, 125, 26, 11, 23, 26, 23, /* 1620 */ 34, 23, 23, 23, 23, 34, 22, 34, 26, 22, /* 1630 */ 22, 15, 23, 23, 22, 117, 23, 22, 1, 123, /* 1640 */ 26, 23, 255, 255, 255, 255, 255, 255, 255, 255, /* 1650 */ 123, 255, 255, 255, 255, 123, 123, 255, 255, 255, /* 1660 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1670 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1680 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1690 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1700 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1710 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1720 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1730 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1740 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1750 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1760 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1770 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1780 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1790 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, /* 1800 */ 255, 255, }; #define YY_SHIFT_COUNT (489) #define YY_SHIFT_MIN (0) #define YY_SHIFT_MAX (1637) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 990, 976, 1211, 837, 837, 316, 1054, 1054, 1054, 1054, /* 10 */ 214, 0, 0, 106, 642, 1054, 1054, 1054, 1054, 1054, /* 20 */ 1054, 1054, 1054, 952, 952, 226, 1155, 316, 316, 316, /* 30 */ 316, 316, 316, 53, 159, 212, 265, 318, 371, 424, /* 40 */ 477, 533, 589, 642, 642, 642, 642, 642, 642, 642, /* 50 */ 642, 642, 642, 642, 642, 642, 642, 642, 642, 642, /* 60 */ 695, 642, 747, 798, 798, 1004, 1054, 1054, 1054, 1054, /* 70 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, /* 80 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, /* 90 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1112, 1054, 1054, /* 100 */ 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, 1054, /* 110 */ 1054, 856, 874, 874, 874, 874, 874, 134, 147, 93, /* 120 */ 342, 959, 1161, 253, 253, 342, 367, 367, 367, 367, /* 130 */ 179, 36, 79, 1657, 1657, 1657, 1061, 1061, 1061, 516, /* 140 */ 799, 516, 516, 531, 531, 802, 249, 369, 342, 342, /* 150 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 342, /* 160 */ 342, 342, 342, 342, 342, 342, 342, 342, 342, 272, /* 170 */ 442, 442, 536, 1657, 1657, 1657, 1025, 245, 245, 570, /* 180 */ 172, 286, 805, 1047, 1140, 1220, 342, 342, 342, 342, /* 190 */ 342, 342, 342, 342, 170, 342, 342, 342, 342, 342, /* 200 */ 342, 342, 342, 342, 342, 342, 342, 841, 841, 841, /* 210 */ 342, 342, 342, 342, 530, 342, 342, 342, 1059, 342, /* 220 */ 342, 1167, 342, 342, 342, 342, 342, 342, 342, 342, /* 230 */ 123, 688, 177, 1212, 1212, 1212, 1212, 1144, 177, 177, /* 240 */ 1064, 409, 33, 628, 707, 707, 900, 628, 628, 900, /* 250 */ 897, 323, 398, 677, 677, 677, 707, 572, 684, 590, /* 260 */ 739, 1236, 1182, 1182, 1276, 1276, 1182, 1253, 1325, 1315, /* 270 */ 1239, 1346, 1346, 1346, 1346, 1182, 1369, 1239, 1239, 1253, /* 280 */ 1325, 1315, 1315, 1239, 1182, 1369, 1298, 1376, 1182, 1369, /* 290 */ 1424, 1182, 1369, 1182, 1369, 1424, 1358, 1358, 1358, 1405, /* 300 */ 1424, 1358, 1364, 1358, 1405, 1358, 1358, 1424, 1379, 1379, /* 310 */ 1424, 1351, 1388, 1351, 1388, 1351, 1388, 1351, 1388, 1182, /* 320 */ 1472, 1182, 1360, 1372, 1377, 1374, 1378, 1239, 1480, 1482, /* 330 */ 1497, 1497, 1508, 1508, 1508, 1657, 1657, 1657, 1657, 1657, /* 340 */ 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, /* 350 */ 1657, 20, 413, 98, 423, 519, 383, 962, 742, 61, /* 360 */ 696, 749, 750, 753, 789, 790, 795, 797, 840, 842, /* 370 */ 810, 668, 817, 659, 819, 849, 854, 899, 643, 745, /* 380 */ 956, 926, 916, 1523, 1529, 1511, 1391, 1521, 1458, 1525, /* 390 */ 1519, 1520, 1423, 1414, 1436, 1526, 1425, 1531, 1426, 1537, /* 400 */ 1553, 1431, 1427, 1444, 1496, 1522, 1429, 1505, 1509, 1510, /* 410 */ 1512, 1452, 1468, 1535, 1447, 1570, 1567, 1551, 1477, 1433, /* 420 */ 1513, 1550, 1514, 1502, 1538, 1455, 1483, 1559, 1564, 1566, /* 430 */ 1473, 1481, 1565, 1524, 1568, 1571, 1569, 1572, 1528, 1561, /* 440 */ 1574, 1530, 1562, 1575, 1577, 1578, 1576, 1580, 1582, 1581, /* 450 */ 1583, 1585, 1584, 1486, 1587, 1588, 1515, 1586, 1590, 1489, /* 460 */ 1589, 1591, 1592, 1593, 1594, 1596, 1598, 1589, 1599, 1600, /* 470 */ 1602, 1601, 1604, 1605, 1607, 1608, 1609, 1610, 1612, 1613, /* 480 */ 1615, 1614, 1518, 1516, 1527, 1532, 1533, 1618, 1616, 1637, }; #define YY_REDUCE_COUNT (350) #define YY_REDUCE_MIN (-225) #define YY_REDUCE_MAX (1375) static const short yy_reduce_ofst[] = { /* 0 */ -137, -31, 1104, 1023, 1081, -132, -40, -38, 223, 225, /* 10 */ 698, -153, -99, -225, -165, 386, 478, 843, 859, -139, /* 20 */ 884, 117, 277, 844, 857, 964, 559, 561, 614, 918, /* 30 */ 1009, 1089, 1098, -222, -222, -222, -222, -222, -222, -222, /* 40 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222, /* 50 */ -222, -222, -222, -222, -222, -222, -222, -222, -222, -222, /* 60 */ -222, -222, -222, -222, -222, 329, 331, 497, 654, 656, /* 70 */ 781, 891, 946, 1029, 1129, 1134, 1149, 1154, 1160, 1162, /* 80 */ 1164, 1168, 1174, 1177, 1188, 1191, 1193, 1202, 1204, 1206, /* 90 */ 1208, 1216, 1218, 1221, 1231, 1233, 1235, 1241, 1244, 1246, /* 100 */ 1248, 1250, 1258, 1260, 1275, 1277, 1283, 1286, 1288, 1290, /* 110 */ 1292, -222, -222, -222, -222, -222, -222, -222, -222, -222, /* 120 */ -115, 796, -156, -154, -141, 14, 242, 349, 242, 349, /* 130 */ -61, -222, -222, -222, -222, -222, 101, 101, 101, 332, /* 140 */ 302, 384, 387, -170, 146, 344, 196, 196, 15, 11, /* 150 */ 183, 235, 395, 355, 396, 406, 452, 457, 391, 459, /* 160 */ 443, 447, 511, 495, 454, 512, 505, 571, 498, 532, /* 170 */ 431, 435, 339, 455, 446, 508, -174, -116, -97, -120, /* 180 */ -150, 64, 176, 330, 337, 509, 569, 611, 653, 673, /* 190 */ 714, 717, 763, 771, -34, 779, 786, 830, 846, 860, /* 200 */ 866, 882, 883, 890, 892, 895, 902, 319, 368, 769, /* 210 */ 915, 924, 925, 932, 755, 936, 945, 963, 782, 969, /* 220 */ 974, 816, 977, 64, 982, 983, 1016, 1022, 1024, 1031, /* 230 */ 870, 831, 913, 966, 973, 981, 984, 755, 913, 913, /* 240 */ 1000, 1041, 1063, 1015, 1010, 1011, 985, 1034, 1057, 1019, /* 250 */ 1086, 1080, 1085, 1093, 1095, 1096, 1067, 1048, 1082, 1099, /* 260 */ 1137, 1050, 1150, 1156, 1077, 1088, 1180, 1120, 1132, 1169, /* 270 */ 1170, 1178, 1181, 1195, 1210, 1225, 1243, 1197, 1209, 1173, /* 280 */ 1190, 1226, 1238, 1223, 1267, 1272, 1199, 1207, 1282, 1285, /* 290 */ 1269, 1293, 1295, 1296, 1300, 1289, 1294, 1297, 1299, 1287, /* 300 */ 1301, 1302, 1303, 1306, 1304, 1307, 1308, 1310, 1242, 1245, /* 310 */ 1311, 1268, 1270, 1273, 1278, 1274, 1279, 1280, 1284, 1333, /* 320 */ 1271, 1337, 1281, 1309, 1305, 1312, 1314, 1316, 1344, 1347, /* 330 */ 1359, 1361, 1368, 1370, 1371, 1291, 1313, 1317, 1355, 1352, /* 340 */ 1353, 1354, 1356, 1363, 1350, 1357, 1362, 1366, 1367, 1375, /* 350 */ 1365, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 1389, 1389, 1389, 1261, 1046, 1151, 1261, 1261, 1261, 1261, /* 10 */ 1046, 1181, 1181, 1312, 1077, 1046, 1046, 1046, 1046, 1046, /* 20 */ 1046, 1260, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 30 */ 1046, 1046, 1046, 1187, 1046, 1046, 1046, 1046, 1262, 1263, /* 40 */ 1046, 1046, 1046, 1311, 1313, 1197, 1196, 1195, 1194, 1294, /* 50 */ 1168, 1192, 1185, 1189, 1256, 1257, 1255, 1259, 1262, 1263, /* 60 */ 1046, 1188, 1226, 1240, 1225, 1046, 1046, 1046, 1046, 1046, /* 70 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 80 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 90 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 100 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 110 */ 1046, 1234, 1239, 1246, 1238, 1235, 1228, 1227, 1229, 1230, /* 120 */ 1046, 1067, 1116, 1046, 1046, 1046, 1329, 1328, 1046, 1046, /* 130 */ 1077, 1231, 1232, 1243, 1242, 1241, 1319, 1345, 1344, 1046, /* 140 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 150 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 160 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1077, /* 170 */ 1073, 1073, 1046, 1324, 1151, 1142, 1046, 1046, 1046, 1046, /* 180 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1316, 1314, 1046, /* 190 */ 1276, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 200 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 210 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1147, 1046, /* 220 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1339, /* 230 */ 1046, 1289, 1130, 1147, 1147, 1147, 1147, 1149, 1131, 1129, /* 240 */ 1141, 1077, 1053, 1191, 1170, 1170, 1378, 1191, 1191, 1378, /* 250 */ 1091, 1359, 1088, 1181, 1181, 1181, 1170, 1258, 1148, 1141, /* 260 */ 1046, 1381, 1156, 1156, 1380, 1380, 1156, 1200, 1206, 1119, /* 270 */ 1191, 1125, 1125, 1125, 1125, 1156, 1064, 1191, 1191, 1200, /* 280 */ 1206, 1119, 1119, 1191, 1156, 1064, 1293, 1375, 1156, 1064, /* 290 */ 1269, 1156, 1064, 1156, 1064, 1269, 1117, 1117, 1117, 1106, /* 300 */ 1269, 1117, 1091, 1117, 1106, 1117, 1117, 1269, 1273, 1273, /* 310 */ 1269, 1174, 1169, 1174, 1169, 1174, 1169, 1174, 1169, 1156, /* 320 */ 1264, 1156, 1046, 1186, 1175, 1184, 1182, 1191, 1070, 1109, /* 330 */ 1342, 1342, 1338, 1338, 1338, 1386, 1386, 1324, 1354, 1077, /* 340 */ 1077, 1077, 1077, 1354, 1093, 1093, 1077, 1077, 1077, 1077, /* 350 */ 1354, 1046, 1046, 1046, 1046, 1046, 1046, 1349, 1046, 1278, /* 360 */ 1160, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 370 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 380 */ 1046, 1046, 1211, 1046, 1049, 1321, 1046, 1046, 1320, 1046, /* 390 */ 1046, 1046, 1046, 1046, 1046, 1161, 1046, 1046, 1046, 1046, /* 400 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 410 */ 1046, 1046, 1046, 1046, 1377, 1046, 1046, 1046, 1046, 1046, /* 420 */ 1046, 1292, 1291, 1046, 1046, 1158, 1046, 1046, 1046, 1046, /* 430 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 440 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 450 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 460 */ 1183, 1046, 1176, 1046, 1046, 1046, 1046, 1368, 1046, 1046, /* 470 */ 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, 1046, /* 480 */ 1046, 1363, 1133, 1213, 1046, 1212, 1216, 1046, 1058, 1046, }; /********** End of lemon-generated parsing tables *****************************/ /* The next table maps tokens (terminal symbols) into fallback tokens. ** If a construct like the following: ** ** %fallback ID X Y Z. |
︙ | ︙ | |||
140287 140288 140289 140290 140291 140292 140293 140294 140295 140296 140297 140298 140299 140300 | 0, /* GT => nothing */ 0, /* LE => nothing */ 0, /* LT => nothing */ 0, /* GE => nothing */ 0, /* ESCAPE => nothing */ 0, /* ID => nothing */ 59, /* COLUMNKW => ID */ 59, /* FOR => ID */ 59, /* IGNORE => ID */ 59, /* INITIALLY => ID */ 59, /* INSTEAD => ID */ 59, /* NO => ID */ 59, /* KEY => ID */ 59, /* OF => ID */ | > | 141490 141491 141492 141493 141494 141495 141496 141497 141498 141499 141500 141501 141502 141503 141504 | 0, /* GT => nothing */ 0, /* LE => nothing */ 0, /* LT => nothing */ 0, /* GE => nothing */ 0, /* ESCAPE => nothing */ 0, /* ID => nothing */ 59, /* COLUMNKW => ID */ 59, /* DO => ID */ 59, /* FOR => ID */ 59, /* IGNORE => ID */ 59, /* INITIALLY => ID */ 59, /* INSTEAD => ID */ 59, /* NO => ID */ 59, /* KEY => ID */ 59, /* OF => ID */ |
︙ | ︙ | |||
140348 140349 140350 140351 140352 140353 140354 140355 140356 140357 140358 140359 140360 140361 | #ifdef YYTRACKMAXSTACKDEPTH int yyhwm; /* High-water mark of the stack */ #endif #ifndef YYNOERRORRECOVERY int yyerrcnt; /* Shifts left before out of the error */ #endif sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ yyStackEntry yystk0; /* First stack entry */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ yyStackEntry *yystackEnd; /* Last entry in the stack */ | > | 141552 141553 141554 141555 141556 141557 141558 141559 141560 141561 141562 141563 141564 141565 141566 | #ifdef YYTRACKMAXSTACKDEPTH int yyhwm; /* High-water mark of the stack */ #endif #ifndef YYNOERRORRECOVERY int yyerrcnt; /* Shifts left before out of the error */ #endif sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ sqlite3ParserCTX_SDECL /* A place to hold %extra_context */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ yyStackEntry yystk0; /* First stack entry */ #else yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ yyStackEntry *yystackEnd; /* Last entry in the stack */ |
︙ | ︙ | |||
140456 140457 140458 140459 140460 140461 140462 | /* 54 */ "GT", /* 55 */ "LE", /* 56 */ "LT", /* 57 */ "GE", /* 58 */ "ESCAPE", /* 59 */ "ID", /* 60 */ "COLUMNKW", | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | 141661 141662 141663 141664 141665 141666 141667 141668 141669 141670 141671 141672 141673 141674 141675 141676 141677 141678 141679 141680 141681 141682 141683 141684 141685 141686 141687 141688 141689 141690 141691 141692 141693 141694 141695 141696 141697 141698 141699 141700 141701 141702 141703 141704 141705 141706 141707 141708 141709 141710 141711 141712 141713 141714 141715 141716 141717 141718 141719 141720 141721 141722 141723 141724 141725 141726 141727 141728 141729 141730 141731 141732 141733 141734 141735 141736 141737 141738 141739 141740 141741 141742 141743 141744 141745 141746 141747 141748 141749 141750 141751 141752 141753 141754 141755 141756 141757 141758 141759 141760 141761 141762 141763 141764 141765 141766 141767 141768 141769 141770 141771 141772 141773 141774 141775 141776 141777 141778 141779 141780 141781 141782 141783 141784 141785 141786 141787 141788 141789 141790 141791 141792 141793 141794 141795 141796 141797 141798 141799 141800 141801 141802 141803 141804 141805 141806 141807 141808 141809 141810 141811 141812 141813 141814 141815 141816 141817 141818 141819 141820 141821 141822 141823 141824 141825 141826 141827 141828 141829 141830 141831 141832 141833 141834 141835 141836 141837 141838 141839 141840 141841 141842 141843 141844 141845 141846 141847 141848 141849 141850 141851 141852 141853 141854 141855 141856 141857 141858 141859 141860 141861 141862 141863 141864 141865 141866 141867 141868 | /* 54 */ "GT", /* 55 */ "LE", /* 56 */ "LT", /* 57 */ "GE", /* 58 */ "ESCAPE", /* 59 */ "ID", /* 60 */ "COLUMNKW", /* 61 */ "DO", /* 62 */ "FOR", /* 63 */ "IGNORE", /* 64 */ "INITIALLY", /* 65 */ "INSTEAD", /* 66 */ "NO", /* 67 */ "KEY", /* 68 */ "OF", /* 69 */ "OFFSET", /* 70 */ "PRAGMA", /* 71 */ "RAISE", /* 72 */ "RECURSIVE", /* 73 */ "REPLACE", /* 74 */ "RESTRICT", /* 75 */ "ROW", /* 76 */ "TRIGGER", /* 77 */ "VACUUM", /* 78 */ "VIEW", /* 79 */ "VIRTUAL", /* 80 */ "WITH", /* 81 */ "REINDEX", /* 82 */ "RENAME", /* 83 */ "CTIME_KW", /* 84 */ "ANY", /* 85 */ "BITAND", /* 86 */ "BITOR", /* 87 */ "LSHIFT", /* 88 */ "RSHIFT", /* 89 */ "PLUS", /* 90 */ "MINUS", /* 91 */ "STAR", /* 92 */ "SLASH", /* 93 */ "REM", /* 94 */ "CONCAT", /* 95 */ "COLLATE", /* 96 */ "BITNOT", /* 97 */ "ON", /* 98 */ "INDEXED", /* 99 */ "STRING", /* 100 */ "JOIN_KW", /* 101 */ "CONSTRAINT", /* 102 */ "DEFAULT", /* 103 */ "NULL", /* 104 */ "PRIMARY", /* 105 */ "UNIQUE", /* 106 */ "CHECK", /* 107 */ "REFERENCES", /* 108 */ "AUTOINCR", /* 109 */ "INSERT", /* 110 */ "DELETE", /* 111 */ "UPDATE", /* 112 */ "SET", /* 113 */ "DEFERRABLE", /* 114 */ "FOREIGN", /* 115 */ "DROP", /* 116 */ "UNION", /* 117 */ "ALL", /* 118 */ "EXCEPT", /* 119 */ "INTERSECT", /* 120 */ "SELECT", /* 121 */ "VALUES", /* 122 */ "DISTINCT", /* 123 */ "DOT", /* 124 */ "FROM", /* 125 */ "JOIN", /* 126 */ "USING", /* 127 */ "ORDER", /* 128 */ "GROUP", /* 129 */ "HAVING", /* 130 */ "LIMIT", /* 131 */ "WHERE", /* 132 */ "INTO", /* 133 */ "NOTHING", /* 134 */ "FLOAT", /* 135 */ "BLOB", /* 136 */ "INTEGER", /* 137 */ "VARIABLE", /* 138 */ "CASE", /* 139 */ "WHEN", /* 140 */ "THEN", /* 141 */ "ELSE", /* 142 */ "INDEX", /* 143 */ "ALTER", /* 144 */ "ADD", /* 145 */ "input", /* 146 */ "cmdlist", /* 147 */ "ecmd", /* 148 */ "cmdx", /* 149 */ "explain", /* 150 */ "cmd", /* 151 */ "transtype", /* 152 */ "trans_opt", /* 153 */ "nm", /* 154 */ "savepoint_opt", /* 155 */ "create_table", /* 156 */ "create_table_args", /* 157 */ "createkw", /* 158 */ "temp", /* 159 */ "ifnotexists", /* 160 */ "dbnm", /* 161 */ "columnlist", /* 162 */ "conslist_opt", /* 163 */ "table_options", /* 164 */ "select", /* 165 */ "columnname", /* 166 */ "carglist", /* 167 */ "typetoken", /* 168 */ "typename", /* 169 */ "signed", /* 170 */ "plus_num", /* 171 */ "minus_num", /* 172 */ "scanpt", /* 173 */ "ccons", /* 174 */ "term", /* 175 */ "expr", /* 176 */ "onconf", /* 177 */ "sortorder", /* 178 */ "autoinc", /* 179 */ "eidlist_opt", /* 180 */ "refargs", /* 181 */ "defer_subclause", /* 182 */ "refarg", /* 183 */ "refact", /* 184 */ "init_deferred_pred_opt", /* 185 */ "conslist", /* 186 */ "tconscomma", /* 187 */ "tcons", /* 188 */ "sortlist", /* 189 */ "eidlist", /* 190 */ "defer_subclause_opt", /* 191 */ "orconf", /* 192 */ "resolvetype", /* 193 */ "raisetype", /* 194 */ "ifexists", /* 195 */ "fullname", /* 196 */ "selectnowith", /* 197 */ "oneselect", /* 198 */ "wqlist", /* 199 */ "multiselect_op", /* 200 */ "distinct", /* 201 */ "selcollist", /* 202 */ "from", /* 203 */ "where_opt", /* 204 */ "groupby_opt", /* 205 */ "having_opt", /* 206 */ "orderby_opt", /* 207 */ "limit_opt", /* 208 */ "values", /* 209 */ "nexprlist", /* 210 */ "exprlist", /* 211 */ "sclp", /* 212 */ "as", /* 213 */ "seltablist", /* 214 */ "stl_prefix", /* 215 */ "joinop", /* 216 */ "indexed_opt", /* 217 */ "on_opt", /* 218 */ "using_opt", /* 219 */ "xfullname", /* 220 */ "idlist", /* 221 */ "with", /* 222 */ "setlist", /* 223 */ "insert_cmd", /* 224 */ "idlist_opt", /* 225 */ "upsert", /* 226 */ "likeop", /* 227 */ "between_op", /* 228 */ "in_op", /* 229 */ "paren_exprlist", /* 230 */ "case_operand", /* 231 */ "case_exprlist", /* 232 */ "case_else", /* 233 */ "uniqueflag", /* 234 */ "collate", /* 235 */ "nmnum", /* 236 */ "trigger_decl", /* 237 */ "trigger_cmd_list", /* 238 */ "trigger_time", /* 239 */ "trigger_event", /* 240 */ "foreach_clause", /* 241 */ "when_clause", /* 242 */ "trigger_cmd", /* 243 */ "trnm", /* 244 */ "tridxby", /* 245 */ "database_kw_opt", /* 246 */ "key_opt", /* 247 */ "add_column_fullname", /* 248 */ "kwcolumn_opt", /* 249 */ "create_vtab", /* 250 */ "vtabarglist", /* 251 */ "vtabarg", /* 252 */ "vtabargtoken", /* 253 */ "lp", /* 254 */ "anylist", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const yyRuleName[] = { |
︙ | ︙ | |||
140734 140735 140736 140737 140738 140739 140740 | /* 73 */ "resolvetype ::= REPLACE", /* 74 */ "cmd ::= DROP TABLE ifexists fullname", /* 75 */ "ifexists ::= IF EXISTS", /* 76 */ "ifexists ::=", /* 77 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select", /* 78 */ "cmd ::= DROP VIEW ifexists fullname", /* 79 */ "cmd ::= select", | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | < < < < < < < < < < < | | | | | | | | > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 141942 141943 141944 141945 141946 141947 141948 141949 141950 141951 141952 141953 141954 141955 141956 141957 141958 141959 141960 141961 141962 141963 141964 141965 141966 141967 141968 141969 141970 141971 141972 141973 141974 141975 141976 141977 141978 141979 141980 141981 141982 141983 141984 141985 141986 141987 141988 141989 141990 141991 141992 141993 141994 141995 141996 141997 141998 141999 142000 142001 142002 142003 142004 142005 142006 142007 142008 142009 142010 142011 142012 142013 142014 142015 142016 142017 142018 142019 142020 142021 142022 142023 142024 142025 142026 142027 142028 142029 142030 142031 142032 142033 142034 142035 142036 142037 142038 142039 142040 142041 142042 142043 142044 142045 142046 142047 142048 142049 142050 142051 142052 142053 142054 142055 142056 142057 142058 142059 142060 142061 142062 142063 142064 142065 142066 142067 142068 142069 142070 142071 142072 142073 142074 142075 142076 142077 142078 142079 142080 142081 142082 142083 142084 142085 142086 142087 142088 142089 142090 142091 142092 142093 142094 142095 142096 142097 142098 142099 142100 142101 142102 142103 142104 142105 142106 142107 142108 142109 142110 142111 142112 142113 142114 142115 142116 142117 142118 142119 142120 142121 142122 142123 142124 142125 142126 142127 142128 142129 142130 142131 142132 142133 142134 142135 142136 142137 142138 142139 142140 142141 142142 142143 142144 142145 142146 142147 142148 142149 142150 142151 142152 142153 142154 142155 142156 142157 142158 142159 142160 142161 142162 142163 142164 142165 142166 142167 142168 142169 142170 142171 142172 142173 142174 142175 142176 142177 142178 142179 142180 142181 142182 142183 142184 142185 142186 142187 142188 142189 142190 142191 142192 142193 142194 142195 142196 142197 142198 142199 142200 142201 142202 142203 142204 142205 142206 142207 142208 142209 142210 142211 142212 142213 142214 142215 142216 | /* 73 */ "resolvetype ::= REPLACE", /* 74 */ "cmd ::= DROP TABLE ifexists fullname", /* 75 */ "ifexists ::= IF EXISTS", /* 76 */ "ifexists ::=", /* 77 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select", /* 78 */ "cmd ::= DROP VIEW ifexists fullname", /* 79 */ "cmd ::= select", /* 80 */ "select ::= WITH wqlist selectnowith", /* 81 */ "select ::= WITH RECURSIVE wqlist selectnowith", /* 82 */ "select ::= selectnowith", /* 83 */ "selectnowith ::= selectnowith multiselect_op oneselect", /* 84 */ "multiselect_op ::= UNION", /* 85 */ "multiselect_op ::= UNION ALL", /* 86 */ "multiselect_op ::= EXCEPT|INTERSECT", /* 87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", /* 88 */ "values ::= VALUES LP nexprlist RP", /* 89 */ "values ::= values COMMA LP exprlist RP", /* 90 */ "distinct ::= DISTINCT", /* 91 */ "distinct ::= ALL", /* 92 */ "distinct ::=", /* 93 */ "sclp ::=", /* 94 */ "selcollist ::= sclp scanpt expr scanpt as", /* 95 */ "selcollist ::= sclp scanpt STAR", /* 96 */ "selcollist ::= sclp scanpt nm DOT STAR", /* 97 */ "as ::= AS nm", /* 98 */ "as ::=", /* 99 */ "from ::=", /* 100 */ "from ::= FROM seltablist", /* 101 */ "stl_prefix ::= seltablist joinop", /* 102 */ "stl_prefix ::=", /* 103 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", /* 104 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt", /* 105 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", /* 106 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", /* 107 */ "dbnm ::=", /* 108 */ "dbnm ::= DOT nm", /* 109 */ "fullname ::= nm", /* 110 */ "fullname ::= nm DOT nm", /* 111 */ "xfullname ::= nm", /* 112 */ "xfullname ::= nm DOT nm", /* 113 */ "xfullname ::= nm DOT nm AS nm", /* 114 */ "xfullname ::= nm AS nm", /* 115 */ "joinop ::= COMMA|JOIN", /* 116 */ "joinop ::= JOIN_KW JOIN", /* 117 */ "joinop ::= JOIN_KW nm JOIN", /* 118 */ "joinop ::= JOIN_KW nm nm JOIN", /* 119 */ "on_opt ::= ON expr", /* 120 */ "on_opt ::=", /* 121 */ "indexed_opt ::=", /* 122 */ "indexed_opt ::= INDEXED BY nm", /* 123 */ "indexed_opt ::= NOT INDEXED", /* 124 */ "using_opt ::= USING LP idlist RP", /* 125 */ "using_opt ::=", /* 126 */ "orderby_opt ::=", /* 127 */ "orderby_opt ::= ORDER BY sortlist", /* 128 */ "sortlist ::= sortlist COMMA expr sortorder", /* 129 */ "sortlist ::= expr sortorder", /* 130 */ "sortorder ::= ASC", /* 131 */ "sortorder ::= DESC", /* 132 */ "sortorder ::=", /* 133 */ "groupby_opt ::=", /* 134 */ "groupby_opt ::= GROUP BY nexprlist", /* 135 */ "having_opt ::=", /* 136 */ "having_opt ::= HAVING expr", /* 137 */ "limit_opt ::=", /* 138 */ "limit_opt ::= LIMIT expr", /* 139 */ "limit_opt ::= LIMIT expr OFFSET expr", /* 140 */ "limit_opt ::= LIMIT expr COMMA expr", /* 141 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt", /* 142 */ "where_opt ::=", /* 143 */ "where_opt ::= WHERE expr", /* 144 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt", /* 145 */ "setlist ::= setlist COMMA nm EQ expr", /* 146 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", /* 147 */ "setlist ::= nm EQ expr", /* 148 */ "setlist ::= LP idlist RP EQ expr", /* 149 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert", /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES", /* 151 */ "upsert ::=", /* 152 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt", /* 153 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING", /* 154 */ "upsert ::= ON CONFLICT DO NOTHING", /* 155 */ "insert_cmd ::= INSERT orconf", /* 156 */ "insert_cmd ::= REPLACE", /* 157 */ "idlist_opt ::=", /* 158 */ "idlist_opt ::= LP idlist RP", /* 159 */ "idlist ::= idlist COMMA nm", /* 160 */ "idlist ::= nm", /* 161 */ "expr ::= LP expr RP", /* 162 */ "expr ::= ID|INDEXED", /* 163 */ "expr ::= JOIN_KW", /* 164 */ "expr ::= nm DOT nm", /* 165 */ "expr ::= nm DOT nm DOT nm", /* 166 */ "term ::= NULL|FLOAT|BLOB", /* 167 */ "term ::= STRING", /* 168 */ "term ::= INTEGER", /* 169 */ "expr ::= VARIABLE", /* 170 */ "expr ::= expr COLLATE ID|STRING", /* 171 */ "expr ::= CAST LP expr AS typetoken RP", /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP", /* 173 */ "expr ::= ID|INDEXED LP STAR RP", /* 174 */ "term ::= CTIME_KW", /* 175 */ "expr ::= LP nexprlist COMMA expr RP", /* 176 */ "expr ::= expr AND expr", /* 177 */ "expr ::= expr OR expr", /* 178 */ "expr ::= expr LT|GT|GE|LE expr", /* 179 */ "expr ::= expr EQ|NE expr", /* 180 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", /* 181 */ "expr ::= expr PLUS|MINUS expr", /* 182 */ "expr ::= expr STAR|SLASH|REM expr", /* 183 */ "expr ::= expr CONCAT expr", /* 184 */ "likeop ::= NOT LIKE_KW|MATCH", /* 185 */ "expr ::= expr likeop expr", /* 186 */ "expr ::= expr likeop expr ESCAPE expr", /* 187 */ "expr ::= expr ISNULL|NOTNULL", /* 188 */ "expr ::= expr NOT NULL", /* 189 */ "expr ::= expr IS expr", /* 190 */ "expr ::= expr IS NOT expr", /* 191 */ "expr ::= NOT expr", /* 192 */ "expr ::= BITNOT expr", /* 193 */ "expr ::= MINUS expr", /* 194 */ "expr ::= PLUS expr", /* 195 */ "between_op ::= BETWEEN", /* 196 */ "between_op ::= NOT BETWEEN", /* 197 */ "expr ::= expr between_op expr AND expr", /* 198 */ "in_op ::= IN", /* 199 */ "in_op ::= NOT IN", /* 200 */ "expr ::= expr in_op LP exprlist RP", /* 201 */ "expr ::= LP select RP", /* 202 */ "expr ::= expr in_op LP select RP", /* 203 */ "expr ::= expr in_op nm dbnm paren_exprlist", /* 204 */ "expr ::= EXISTS LP select RP", /* 205 */ "expr ::= CASE case_operand case_exprlist case_else END", /* 206 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", /* 207 */ "case_exprlist ::= WHEN expr THEN expr", /* 208 */ "case_else ::= ELSE expr", /* 209 */ "case_else ::=", /* 210 */ "case_operand ::= expr", /* 211 */ "case_operand ::=", /* 212 */ "exprlist ::=", /* 213 */ "nexprlist ::= nexprlist COMMA expr", /* 214 */ "nexprlist ::= expr", /* 215 */ "paren_exprlist ::=", /* 216 */ "paren_exprlist ::= LP exprlist RP", /* 217 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", /* 218 */ "uniqueflag ::= UNIQUE", /* 219 */ "uniqueflag ::=", /* 220 */ "eidlist_opt ::=", /* 221 */ "eidlist_opt ::= LP eidlist RP", /* 222 */ "eidlist ::= eidlist COMMA nm collate sortorder", /* 223 */ "eidlist ::= nm collate sortorder", /* 224 */ "collate ::=", /* 225 */ "collate ::= COLLATE ID|STRING", /* 226 */ "cmd ::= DROP INDEX ifexists fullname", /* 227 */ "cmd ::= VACUUM", /* 228 */ "cmd ::= VACUUM nm", /* 229 */ "cmd ::= PRAGMA nm dbnm", /* 230 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", /* 231 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", /* 232 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", /* 233 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", /* 234 */ "plus_num ::= PLUS INTEGER|FLOAT", /* 235 */ "minus_num ::= MINUS INTEGER|FLOAT", /* 236 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", /* 237 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", /* 238 */ "trigger_time ::= BEFORE|AFTER", /* 239 */ "trigger_time ::= INSTEAD OF", /* 240 */ "trigger_time ::=", /* 241 */ "trigger_event ::= DELETE|INSERT", /* 242 */ "trigger_event ::= UPDATE", /* 243 */ "trigger_event ::= UPDATE OF idlist", /* 244 */ "when_clause ::=", /* 245 */ "when_clause ::= WHEN expr", /* 246 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", /* 247 */ "trigger_cmd_list ::= trigger_cmd SEMI", /* 248 */ "trnm ::= nm DOT nm", /* 249 */ "tridxby ::= INDEXED BY nm", /* 250 */ "tridxby ::= NOT INDEXED", /* 251 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt", /* 252 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", /* 253 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", /* 254 */ "trigger_cmd ::= scanpt select scanpt", /* 255 */ "expr ::= RAISE LP IGNORE RP", /* 256 */ "expr ::= RAISE LP raisetype COMMA nm RP", /* 257 */ "raisetype ::= ROLLBACK", /* 258 */ "raisetype ::= ABORT", /* 259 */ "raisetype ::= FAIL", /* 260 */ "cmd ::= DROP TRIGGER ifexists fullname", /* 261 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", /* 262 */ "cmd ::= DETACH database_kw_opt expr", /* 263 */ "key_opt ::=", /* 264 */ "key_opt ::= KEY expr", /* 265 */ "cmd ::= REINDEX", /* 266 */ "cmd ::= REINDEX nm dbnm", /* 267 */ "cmd ::= ANALYZE", /* 268 */ "cmd ::= ANALYZE nm dbnm", /* 269 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", /* 270 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", /* 271 */ "add_column_fullname ::= fullname", /* 272 */ "cmd ::= create_vtab", /* 273 */ "cmd ::= create_vtab LP vtabarglist RP", /* 274 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", /* 275 */ "vtabarg ::=", /* 276 */ "vtabargtoken ::= ANY", /* 277 */ "vtabargtoken ::= lp anylist RP", /* 278 */ "lp ::= LP", /* 279 */ "with ::= WITH wqlist", /* 280 */ "with ::= WITH RECURSIVE wqlist", /* 281 */ "wqlist ::= nm eidlist_opt AS LP select RP", /* 282 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", /* 283 */ "input ::= cmdlist", /* 284 */ "cmdlist ::= cmdlist ecmd", /* 285 */ "cmdlist ::= ecmd", /* 286 */ "ecmd ::= SEMI", /* 287 */ "ecmd ::= cmdx SEMI", /* 288 */ "ecmd ::= explain cmdx", /* 289 */ "trans_opt ::=", /* 290 */ "trans_opt ::= TRANSACTION", /* 291 */ "trans_opt ::= TRANSACTION nm", /* 292 */ "savepoint_opt ::= SAVEPOINT", /* 293 */ "savepoint_opt ::=", /* 294 */ "cmd ::= create_table create_table_args", /* 295 */ "columnlist ::= columnlist COMMA columnname carglist", /* 296 */ "columnlist ::= columnname carglist", /* 297 */ "nm ::= ID|INDEXED", /* 298 */ "nm ::= STRING", /* 299 */ "nm ::= JOIN_KW", /* 300 */ "typetoken ::= typename", /* 301 */ "typename ::= ID|STRING", /* 302 */ "signed ::= plus_num", /* 303 */ "signed ::= minus_num", /* 304 */ "carglist ::= carglist ccons", /* 305 */ "carglist ::=", /* 306 */ "ccons ::= NULL onconf", /* 307 */ "conslist_opt ::= COMMA conslist", /* 308 */ "conslist ::= conslist tconscomma tcons", /* 309 */ "conslist ::= tcons", /* 310 */ "tconscomma ::=", /* 311 */ "defer_subclause_opt ::= defer_subclause", /* 312 */ "resolvetype ::= raisetype", /* 313 */ "selectnowith ::= oneselect", /* 314 */ "oneselect ::= values", /* 315 */ "sclp ::= selcollist COMMA", /* 316 */ "as ::= ID|STRING", /* 317 */ "expr ::= term", /* 318 */ "likeop ::= LIKE_KW|MATCH", /* 319 */ "exprlist ::= nexprlist", /* 320 */ "nmnum ::= plus_num", /* 321 */ "nmnum ::= nm", /* 322 */ "nmnum ::= ON", /* 323 */ "nmnum ::= DELETE", /* 324 */ "nmnum ::= DEFAULT", /* 325 */ "plus_num ::= INTEGER|FLOAT", /* 326 */ "foreach_clause ::=", /* 327 */ "foreach_clause ::= FOR EACH ROW", /* 328 */ "trnm ::= nm", /* 329 */ "tridxby ::=", /* 330 */ "database_kw_opt ::= DATABASE", /* 331 */ "database_kw_opt ::=", /* 332 */ "kwcolumn_opt ::=", /* 333 */ "kwcolumn_opt ::= COLUMNKW", /* 334 */ "vtabarglist ::= vtabarg", /* 335 */ "vtabarglist ::= vtabarglist COMMA vtabarg", /* 336 */ "vtabarg ::= vtabarg vtabargtoken", /* 337 */ "anylist ::=", /* 338 */ "anylist ::= anylist LP anylist RP", /* 339 */ "anylist ::= anylist ANY", /* 340 */ "with ::=", }; #endif /* NDEBUG */ #if YYSTACKDEPTH<=0 /* ** Try to increase the size of the parser stack. Return the number |
︙ | ︙ | |||
141032 141033 141034 141035 141036 141037 141038 | */ #ifndef YYMALLOCARGTYPE # define YYMALLOCARGTYPE size_t #endif /* Initialize a new parser that has already been allocated. */ | | | > | | | | | | | | | | | | | | | > | > > | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | < | | | | | | | | | | | | 142251 142252 142253 142254 142255 142256 142257 142258 142259 142260 142261 142262 142263 142264 142265 142266 142267 142268 142269 142270 142271 142272 142273 142274 142275 142276 142277 142278 142279 142280 142281 142282 142283 142284 142285 142286 142287 142288 142289 142290 142291 142292 142293 142294 142295 142296 142297 142298 142299 142300 142301 142302 142303 142304 142305 142306 142307 142308 142309 142310 142311 142312 142313 142314 142315 142316 142317 142318 142319 142320 142321 142322 142323 142324 142325 142326 142327 142328 142329 142330 142331 142332 142333 142334 142335 142336 142337 142338 142339 142340 142341 142342 142343 142344 142345 142346 142347 142348 142349 142350 142351 142352 142353 142354 142355 142356 142357 142358 142359 142360 142361 142362 142363 142364 142365 142366 142367 142368 142369 142370 142371 142372 142373 142374 142375 142376 142377 142378 142379 142380 142381 142382 142383 142384 142385 142386 142387 142388 142389 142390 142391 142392 142393 142394 142395 142396 142397 142398 142399 142400 142401 142402 142403 142404 142405 142406 142407 142408 | */ #ifndef YYMALLOCARGTYPE # define YYMALLOCARGTYPE size_t #endif /* Initialize a new parser that has already been allocated. */ SQLITE_PRIVATE void sqlite3ParserInit(void *yypRawParser sqlite3ParserCTX_PDECL){ yyParser *yypParser = (yyParser*)yypRawParser; sqlite3ParserCTX_STORE #ifdef YYTRACKMAXSTACKDEPTH yypParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 yypParser->yytos = NULL; yypParser->yystack = NULL; yypParser->yystksz = 0; if( yyGrowStack(yypParser) ){ yypParser->yystack = &yypParser->yystk0; yypParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif yypParser->yytos = yypParser->yystack; yypParser->yystack[0].stateno = 0; yypParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; #endif } #ifndef sqlite3Parser_ENGINEALWAYSONSTACK /* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like ** malloc. ** ** Inputs: ** A pointer to the function used to allocate memory. ** ** Outputs: ** A pointer to a parser. This pointer is used in subsequent calls ** to sqlite3Parser and sqlite3ParserFree. */ SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) sqlite3ParserCTX_PDECL){ yyParser *yypParser; yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); if( yypParser ){ sqlite3ParserCTX_STORE sqlite3ParserInit(yypParser sqlite3ParserCTX_PARAM); } return (void*)yypParser; } #endif /* sqlite3Parser_ENGINEALWAYSONSTACK */ /* The following function deletes the "minor type" or semantic value ** associated with a symbol. The symbol can be either a terminal ** or nonterminal. "yymajor" is the symbol code, and "yypminor" is ** a pointer to the value to be deleted. The code used to do the ** deletions is derived from the %destructor and/or %token_destructor ** directives of the input grammar. */ static void yy_destructor( yyParser *yypParser, /* The parser */ YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ sqlite3ParserARG_FETCH sqlite3ParserCTX_FETCH switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are *not* used ** inside the C code. */ /********* Begin destructor definitions ***************************************/ case 164: /* select */ case 196: /* selectnowith */ case 197: /* oneselect */ case 208: /* values */ { sqlite3SelectDelete(pParse->db, (yypminor->yy399)); } break; case 174: /* term */ case 175: /* expr */ case 203: /* where_opt */ case 205: /* having_opt */ case 217: /* on_opt */ case 230: /* case_operand */ case 232: /* case_else */ case 241: /* when_clause */ case 246: /* key_opt */ { sqlite3ExprDelete(pParse->db, (yypminor->yy182)); } break; case 179: /* eidlist_opt */ case 188: /* sortlist */ case 189: /* eidlist */ case 201: /* selcollist */ case 204: /* groupby_opt */ case 206: /* orderby_opt */ case 209: /* nexprlist */ case 210: /* exprlist */ case 211: /* sclp */ case 222: /* setlist */ case 229: /* paren_exprlist */ case 231: /* case_exprlist */ { sqlite3ExprListDelete(pParse->db, (yypminor->yy232)); } break; case 195: /* fullname */ case 202: /* from */ case 213: /* seltablist */ case 214: /* stl_prefix */ case 219: /* xfullname */ { sqlite3SrcListDelete(pParse->db, (yypminor->yy427)); } break; case 198: /* wqlist */ { sqlite3WithDelete(pParse->db, (yypminor->yy91)); } break; case 218: /* using_opt */ case 220: /* idlist */ case 224: /* idlist_opt */ { sqlite3IdListDelete(pParse->db, (yypminor->yy510)); } break; case 237: /* trigger_cmd_list */ case 242: /* trigger_cmd */ { sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47)); } break; case 239: /* trigger_event */ { sqlite3IdListDelete(pParse->db, (yypminor->yy300).b); } break; /********* End destructor definitions *****************************************/ default: break; /* If no destructor action specified: do nothing */ } } |
︙ | ︙ | |||
141282 141283 141284 141285 141286 141287 141288 | } #endif /* ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ | | < | > < | | 142506 142507 142508 142509 142510 142511 142512 142513 142514 142515 142516 142517 142518 142519 142520 142521 142522 142523 142524 142525 | } #endif /* ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ static YYACTIONTYPE yy_find_shift_action( YYCODETYPE iLookAhead, /* The look-ahead token */ YYACTIONTYPE stateno /* Current state number */ ){ int i; if( stateno>YY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) yycoverage[stateno][iLookAhead] = 1; #endif do{ i = yy_shift_ofst[stateno]; |
︙ | ︙ | |||
141352 141353 141354 141355 141356 141357 141358 | } /* ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ static int yy_find_reduce_action( | | | 142575 142576 142577 142578 142579 142580 142581 142582 142583 142584 142585 142586 142587 142588 142589 | } /* ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ static int yy_find_reduce_action( YYACTIONTYPE stateno, /* Current state number */ YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; #ifdef YYERRORSYMBOL if( stateno>YY_REDUCE_COUNT ){ return yy_default[stateno]; } |
︙ | ︙ | |||
141381 141382 141383 141384 141385 141386 141387 | return yy_action[i]; } /* ** The following routine is called if the stack overflows. */ static void yyStackOverflow(yyParser *yypParser){ | | > | > | 142604 142605 142606 142607 142608 142609 142610 142611 142612 142613 142614 142615 142616 142617 142618 142619 142620 142621 142622 142623 142624 142625 142626 142627 142628 142629 142630 142631 142632 142633 | return yy_action[i]; } /* ** The following routine is called if the stack overflows. */ static void yyStackOverflow(yyParser *yypParser){ sqlite3ParserARG_FETCH sqlite3ParserCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ sqlite3ErrorMsg(pParse, "parser stack overflow"); /******** End %stack_overflow code ********************************************/ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument var */ sqlite3ParserCTX_STORE } /* ** Print tracing information for a SHIFT action */ #ifndef NDEBUG static void yyTraceShift(yyParser *yypParser, int yyNewState, const char *zTag){ |
︙ | ︙ | |||
141423 141424 141425 141426 141427 141428 141429 | #endif /* ** Perform a shift action. */ static void yy_shift( yyParser *yypParser, /* The parser to be shifted */ | | | | 142648 142649 142650 142651 142652 142653 142654 142655 142656 142657 142658 142659 142660 142661 142662 142663 | #endif /* ** Perform a shift action. */ static void yy_shift( yyParser *yypParser, /* The parser to be shifted */ YYACTIONTYPE yyNewState, /* The new state to shift in */ YYCODETYPE yyMajor, /* The major token to shift in */ sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */ ){ yyStackEntry *yytos; yypParser->yytos++; #ifdef YYTRACKMAXSTACKDEPTH if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; |
︙ | ︙ | |||
141454 141455 141456 141457 141458 141459 141460 | } } #endif if( yyNewState > YY_MAX_SHIFT ){ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; } yytos = yypParser->yytos; | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | | > | < | | | > > > > > > | < < < < < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | > | | 142679 142680 142681 142682 142683 142684 142685 142686 142687 142688 142689 142690 142691 142692 142693 142694 142695 142696 142697 142698 142699 142700 142701 142702 142703 142704 142705 142706 142707 142708 142709 142710 142711 142712 142713 142714 142715 142716 142717 142718 142719 142720 142721 142722 142723 142724 142725 142726 142727 142728 142729 142730 142731 142732 142733 142734 142735 142736 142737 142738 142739 142740 142741 142742 142743 142744 142745 142746 142747 142748 142749 142750 142751 142752 142753 142754 142755 142756 142757 142758 142759 142760 142761 142762 142763 142764 142765 142766 142767 142768 142769 142770 142771 142772 142773 142774 142775 142776 142777 142778 142779 142780 142781 142782 142783 142784 142785 142786 142787 142788 142789 142790 142791 142792 142793 142794 142795 142796 142797 142798 142799 142800 142801 142802 142803 142804 142805 142806 142807 142808 142809 142810 142811 142812 142813 142814 142815 142816 142817 142818 142819 142820 142821 142822 142823 142824 142825 142826 142827 142828 142829 142830 142831 142832 142833 142834 142835 142836 142837 142838 142839 142840 142841 142842 142843 142844 142845 142846 142847 142848 142849 142850 142851 142852 142853 142854 142855 142856 142857 142858 142859 142860 142861 142862 142863 142864 142865 142866 142867 142868 142869 142870 142871 142872 142873 142874 142875 142876 142877 142878 142879 142880 142881 142882 142883 142884 142885 142886 142887 142888 142889 142890 142891 142892 142893 142894 142895 142896 142897 142898 142899 142900 142901 142902 142903 142904 142905 142906 142907 142908 142909 142910 142911 142912 142913 142914 142915 142916 142917 142918 142919 142920 142921 142922 142923 142924 142925 142926 142927 142928 142929 142930 142931 142932 142933 142934 142935 142936 142937 142938 142939 142940 142941 142942 142943 142944 142945 142946 142947 142948 142949 142950 142951 142952 142953 142954 142955 142956 142957 142958 142959 142960 142961 142962 142963 142964 142965 142966 142967 142968 142969 142970 142971 142972 142973 142974 142975 142976 142977 142978 142979 142980 142981 142982 142983 142984 142985 142986 142987 142988 142989 142990 142991 142992 142993 142994 142995 142996 142997 142998 142999 143000 143001 143002 143003 143004 143005 143006 143007 143008 143009 143010 143011 143012 143013 143014 143015 143016 143017 143018 143019 143020 143021 143022 143023 143024 143025 143026 143027 143028 143029 143030 143031 143032 143033 143034 143035 143036 143037 143038 143039 143040 143041 143042 143043 143044 143045 143046 143047 143048 143049 143050 143051 143052 143053 143054 143055 143056 143057 143058 143059 143060 143061 143062 143063 143064 143065 143066 143067 143068 143069 143070 143071 143072 | } } #endif if( yyNewState > YY_MAX_SHIFT ){ yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; } yytos = yypParser->yytos; yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } /* The following table contains information about every rule that ** is used during the reduce. */ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { { 149, -1 }, /* (0) explain ::= EXPLAIN */ { 149, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */ { 148, -1 }, /* (2) cmdx ::= cmd */ { 150, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */ { 151, 0 }, /* (4) transtype ::= */ { 151, -1 }, /* (5) transtype ::= DEFERRED */ { 151, -1 }, /* (6) transtype ::= IMMEDIATE */ { 151, -1 }, /* (7) transtype ::= EXCLUSIVE */ { 150, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */ { 150, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */ { 150, -2 }, /* (10) cmd ::= SAVEPOINT nm */ { 150, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */ { 150, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { 155, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { 157, -1 }, /* (14) createkw ::= CREATE */ { 159, 0 }, /* (15) ifnotexists ::= */ { 159, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */ { 158, -1 }, /* (17) temp ::= TEMP */ { 158, 0 }, /* (18) temp ::= */ { 156, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ { 156, -2 }, /* (20) create_table_args ::= AS select */ { 163, 0 }, /* (21) table_options ::= */ { 163, -2 }, /* (22) table_options ::= WITHOUT nm */ { 165, -2 }, /* (23) columnname ::= nm typetoken */ { 167, 0 }, /* (24) typetoken ::= */ { 167, -4 }, /* (25) typetoken ::= typename LP signed RP */ { 167, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */ { 168, -2 }, /* (27) typename ::= typename ID|STRING */ { 172, 0 }, /* (28) scanpt ::= */ { 173, -2 }, /* (29) ccons ::= CONSTRAINT nm */ { 173, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */ { 173, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */ { 173, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */ { 173, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */ { 173, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */ { 173, -3 }, /* (35) ccons ::= NOT NULL onconf */ { 173, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */ { 173, -2 }, /* (37) ccons ::= UNIQUE onconf */ { 173, -4 }, /* (38) ccons ::= CHECK LP expr RP */ { 173, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */ { 173, -1 }, /* (40) ccons ::= defer_subclause */ { 173, -2 }, /* (41) ccons ::= COLLATE ID|STRING */ { 178, 0 }, /* (42) autoinc ::= */ { 178, -1 }, /* (43) autoinc ::= AUTOINCR */ { 180, 0 }, /* (44) refargs ::= */ { 180, -2 }, /* (45) refargs ::= refargs refarg */ { 182, -2 }, /* (46) refarg ::= MATCH nm */ { 182, -3 }, /* (47) refarg ::= ON INSERT refact */ { 182, -3 }, /* (48) refarg ::= ON DELETE refact */ { 182, -3 }, /* (49) refarg ::= ON UPDATE refact */ { 183, -2 }, /* (50) refact ::= SET NULL */ { 183, -2 }, /* (51) refact ::= SET DEFAULT */ { 183, -1 }, /* (52) refact ::= CASCADE */ { 183, -1 }, /* (53) refact ::= RESTRICT */ { 183, -2 }, /* (54) refact ::= NO ACTION */ { 181, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ { 181, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ { 184, 0 }, /* (57) init_deferred_pred_opt ::= */ { 184, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */ { 184, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ { 162, 0 }, /* (60) conslist_opt ::= */ { 186, -1 }, /* (61) tconscomma ::= COMMA */ { 187, -2 }, /* (62) tcons ::= CONSTRAINT nm */ { 187, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ { 187, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */ { 187, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */ { 187, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ { 190, 0 }, /* (67) defer_subclause_opt ::= */ { 176, 0 }, /* (68) onconf ::= */ { 176, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */ { 191, 0 }, /* (70) orconf ::= */ { 191, -2 }, /* (71) orconf ::= OR resolvetype */ { 192, -1 }, /* (72) resolvetype ::= IGNORE */ { 192, -1 }, /* (73) resolvetype ::= REPLACE */ { 150, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */ { 194, -2 }, /* (75) ifexists ::= IF EXISTS */ { 194, 0 }, /* (76) ifexists ::= */ { 150, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ { 150, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */ { 150, -1 }, /* (79) cmd ::= select */ { 164, -3 }, /* (80) select ::= WITH wqlist selectnowith */ { 164, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */ { 164, -1 }, /* (82) select ::= selectnowith */ { 196, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */ { 199, -1 }, /* (84) multiselect_op ::= UNION */ { 199, -2 }, /* (85) multiselect_op ::= UNION ALL */ { 199, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */ { 197, -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ { 208, -4 }, /* (88) values ::= VALUES LP nexprlist RP */ { 208, -5 }, /* (89) values ::= values COMMA LP exprlist RP */ { 200, -1 }, /* (90) distinct ::= DISTINCT */ { 200, -1 }, /* (91) distinct ::= ALL */ { 200, 0 }, /* (92) distinct ::= */ { 211, 0 }, /* (93) sclp ::= */ { 201, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */ { 201, -3 }, /* (95) selcollist ::= sclp scanpt STAR */ { 201, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */ { 212, -2 }, /* (97) as ::= AS nm */ { 212, 0 }, /* (98) as ::= */ { 202, 0 }, /* (99) from ::= */ { 202, -2 }, /* (100) from ::= FROM seltablist */ { 214, -2 }, /* (101) stl_prefix ::= seltablist joinop */ { 214, 0 }, /* (102) stl_prefix ::= */ { 213, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ { 213, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ { 213, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ { 213, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ { 160, 0 }, /* (107) dbnm ::= */ { 160, -2 }, /* (108) dbnm ::= DOT nm */ { 195, -1 }, /* (109) fullname ::= nm */ { 195, -3 }, /* (110) fullname ::= nm DOT nm */ { 219, -1 }, /* (111) xfullname ::= nm */ { 219, -3 }, /* (112) xfullname ::= nm DOT nm */ { 219, -5 }, /* (113) xfullname ::= nm DOT nm AS nm */ { 219, -3 }, /* (114) xfullname ::= nm AS nm */ { 215, -1 }, /* (115) joinop ::= COMMA|JOIN */ { 215, -2 }, /* (116) joinop ::= JOIN_KW JOIN */ { 215, -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */ { 215, -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */ { 217, -2 }, /* (119) on_opt ::= ON expr */ { 217, 0 }, /* (120) on_opt ::= */ { 216, 0 }, /* (121) indexed_opt ::= */ { 216, -3 }, /* (122) indexed_opt ::= INDEXED BY nm */ { 216, -2 }, /* (123) indexed_opt ::= NOT INDEXED */ { 218, -4 }, /* (124) using_opt ::= USING LP idlist RP */ { 218, 0 }, /* (125) using_opt ::= */ { 206, 0 }, /* (126) orderby_opt ::= */ { 206, -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */ { 188, -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */ { 188, -2 }, /* (129) sortlist ::= expr sortorder */ { 177, -1 }, /* (130) sortorder ::= ASC */ { 177, -1 }, /* (131) sortorder ::= DESC */ { 177, 0 }, /* (132) sortorder ::= */ { 204, 0 }, /* (133) groupby_opt ::= */ { 204, -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */ { 205, 0 }, /* (135) having_opt ::= */ { 205, -2 }, /* (136) having_opt ::= HAVING expr */ { 207, 0 }, /* (137) limit_opt ::= */ { 207, -2 }, /* (138) limit_opt ::= LIMIT expr */ { 207, -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */ { 207, -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */ { 150, -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ { 203, 0 }, /* (142) where_opt ::= */ { 203, -2 }, /* (143) where_opt ::= WHERE expr */ { 150, -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ { 222, -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */ { 222, -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */ { 222, -3 }, /* (147) setlist ::= nm EQ expr */ { 222, -5 }, /* (148) setlist ::= LP idlist RP EQ expr */ { 150, -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ { 150, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ { 225, 0 }, /* (151) upsert ::= */ { 225, -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ { 225, -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ { 225, -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */ { 223, -2 }, /* (155) insert_cmd ::= INSERT orconf */ { 223, -1 }, /* (156) insert_cmd ::= REPLACE */ { 224, 0 }, /* (157) idlist_opt ::= */ { 224, -3 }, /* (158) idlist_opt ::= LP idlist RP */ { 220, -3 }, /* (159) idlist ::= idlist COMMA nm */ { 220, -1 }, /* (160) idlist ::= nm */ { 175, -3 }, /* (161) expr ::= LP expr RP */ { 175, -1 }, /* (162) expr ::= ID|INDEXED */ { 175, -1 }, /* (163) expr ::= JOIN_KW */ { 175, -3 }, /* (164) expr ::= nm DOT nm */ { 175, -5 }, /* (165) expr ::= nm DOT nm DOT nm */ { 174, -1 }, /* (166) term ::= NULL|FLOAT|BLOB */ { 174, -1 }, /* (167) term ::= STRING */ { 174, -1 }, /* (168) term ::= INTEGER */ { 175, -1 }, /* (169) expr ::= VARIABLE */ { 175, -3 }, /* (170) expr ::= expr COLLATE ID|STRING */ { 175, -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */ { 175, -5 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP */ { 175, -4 }, /* (173) expr ::= ID|INDEXED LP STAR RP */ { 174, -1 }, /* (174) term ::= CTIME_KW */ { 175, -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */ { 175, -3 }, /* (176) expr ::= expr AND expr */ { 175, -3 }, /* (177) expr ::= expr OR expr */ { 175, -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */ { 175, -3 }, /* (179) expr ::= expr EQ|NE expr */ { 175, -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ { 175, -3 }, /* (181) expr ::= expr PLUS|MINUS expr */ { 175, -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */ { 175, -3 }, /* (183) expr ::= expr CONCAT expr */ { 226, -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */ { 175, -3 }, /* (185) expr ::= expr likeop expr */ { 175, -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */ { 175, -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */ { 175, -3 }, /* (188) expr ::= expr NOT NULL */ { 175, -3 }, /* (189) expr ::= expr IS expr */ { 175, -4 }, /* (190) expr ::= expr IS NOT expr */ { 175, -2 }, /* (191) expr ::= NOT expr */ { 175, -2 }, /* (192) expr ::= BITNOT expr */ { 175, -2 }, /* (193) expr ::= MINUS expr */ { 175, -2 }, /* (194) expr ::= PLUS expr */ { 227, -1 }, /* (195) between_op ::= BETWEEN */ { 227, -2 }, /* (196) between_op ::= NOT BETWEEN */ { 175, -5 }, /* (197) expr ::= expr between_op expr AND expr */ { 228, -1 }, /* (198) in_op ::= IN */ { 228, -2 }, /* (199) in_op ::= NOT IN */ { 175, -5 }, /* (200) expr ::= expr in_op LP exprlist RP */ { 175, -3 }, /* (201) expr ::= LP select RP */ { 175, -5 }, /* (202) expr ::= expr in_op LP select RP */ { 175, -5 }, /* (203) expr ::= expr in_op nm dbnm paren_exprlist */ { 175, -4 }, /* (204) expr ::= EXISTS LP select RP */ { 175, -5 }, /* (205) expr ::= CASE case_operand case_exprlist case_else END */ { 231, -5 }, /* (206) case_exprlist ::= case_exprlist WHEN expr THEN expr */ { 231, -4 }, /* (207) case_exprlist ::= WHEN expr THEN expr */ { 232, -2 }, /* (208) case_else ::= ELSE expr */ { 232, 0 }, /* (209) case_else ::= */ { 230, -1 }, /* (210) case_operand ::= expr */ { 230, 0 }, /* (211) case_operand ::= */ { 210, 0 }, /* (212) exprlist ::= */ { 209, -3 }, /* (213) nexprlist ::= nexprlist COMMA expr */ { 209, -1 }, /* (214) nexprlist ::= expr */ { 229, 0 }, /* (215) paren_exprlist ::= */ { 229, -3 }, /* (216) paren_exprlist ::= LP exprlist RP */ { 150, -12 }, /* (217) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ { 233, -1 }, /* (218) uniqueflag ::= UNIQUE */ { 233, 0 }, /* (219) uniqueflag ::= */ { 179, 0 }, /* (220) eidlist_opt ::= */ { 179, -3 }, /* (221) eidlist_opt ::= LP eidlist RP */ { 189, -5 }, /* (222) eidlist ::= eidlist COMMA nm collate sortorder */ { 189, -3 }, /* (223) eidlist ::= nm collate sortorder */ { 234, 0 }, /* (224) collate ::= */ { 234, -2 }, /* (225) collate ::= COLLATE ID|STRING */ { 150, -4 }, /* (226) cmd ::= DROP INDEX ifexists fullname */ { 150, -1 }, /* (227) cmd ::= VACUUM */ { 150, -2 }, /* (228) cmd ::= VACUUM nm */ { 150, -3 }, /* (229) cmd ::= PRAGMA nm dbnm */ { 150, -5 }, /* (230) cmd ::= PRAGMA nm dbnm EQ nmnum */ { 150, -6 }, /* (231) cmd ::= PRAGMA nm dbnm LP nmnum RP */ { 150, -5 }, /* (232) cmd ::= PRAGMA nm dbnm EQ minus_num */ { 150, -6 }, /* (233) cmd ::= PRAGMA nm dbnm LP minus_num RP */ { 170, -2 }, /* (234) plus_num ::= PLUS INTEGER|FLOAT */ { 171, -2 }, /* (235) minus_num ::= MINUS INTEGER|FLOAT */ { 150, -5 }, /* (236) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ { 236, -11 }, /* (237) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ { 238, -1 }, /* (238) trigger_time ::= BEFORE|AFTER */ { 238, -2 }, /* (239) trigger_time ::= INSTEAD OF */ { 238, 0 }, /* (240) trigger_time ::= */ { 239, -1 }, /* (241) trigger_event ::= DELETE|INSERT */ { 239, -1 }, /* (242) trigger_event ::= UPDATE */ { 239, -3 }, /* (243) trigger_event ::= UPDATE OF idlist */ { 241, 0 }, /* (244) when_clause ::= */ { 241, -2 }, /* (245) when_clause ::= WHEN expr */ { 237, -3 }, /* (246) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ { 237, -2 }, /* (247) trigger_cmd_list ::= trigger_cmd SEMI */ { 243, -3 }, /* (248) trnm ::= nm DOT nm */ { 244, -3 }, /* (249) tridxby ::= INDEXED BY nm */ { 244, -2 }, /* (250) tridxby ::= NOT INDEXED */ { 242, -8 }, /* (251) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ { 242, -8 }, /* (252) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ { 242, -6 }, /* (253) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ { 242, -3 }, /* (254) trigger_cmd ::= scanpt select scanpt */ { 175, -4 }, /* (255) expr ::= RAISE LP IGNORE RP */ { 175, -6 }, /* (256) expr ::= RAISE LP raisetype COMMA nm RP */ { 193, -1 }, /* (257) raisetype ::= ROLLBACK */ { 193, -1 }, /* (258) raisetype ::= ABORT */ { 193, -1 }, /* (259) raisetype ::= FAIL */ { 150, -4 }, /* (260) cmd ::= DROP TRIGGER ifexists fullname */ { 150, -6 }, /* (261) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ { 150, -3 }, /* (262) cmd ::= DETACH database_kw_opt expr */ { 246, 0 }, /* (263) key_opt ::= */ { 246, -2 }, /* (264) key_opt ::= KEY expr */ { 150, -1 }, /* (265) cmd ::= REINDEX */ { 150, -3 }, /* (266) cmd ::= REINDEX nm dbnm */ { 150, -1 }, /* (267) cmd ::= ANALYZE */ { 150, -3 }, /* (268) cmd ::= ANALYZE nm dbnm */ { 150, -6 }, /* (269) cmd ::= ALTER TABLE fullname RENAME TO nm */ { 150, -7 }, /* (270) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ { 247, -1 }, /* (271) add_column_fullname ::= fullname */ { 150, -1 }, /* (272) cmd ::= create_vtab */ { 150, -4 }, /* (273) cmd ::= create_vtab LP vtabarglist RP */ { 249, -8 }, /* (274) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ { 251, 0 }, /* (275) vtabarg ::= */ { 252, -1 }, /* (276) vtabargtoken ::= ANY */ { 252, -3 }, /* (277) vtabargtoken ::= lp anylist RP */ { 253, -1 }, /* (278) lp ::= LP */ { 221, -2 }, /* (279) with ::= WITH wqlist */ { 221, -3 }, /* (280) with ::= WITH RECURSIVE wqlist */ { 198, -6 }, /* (281) wqlist ::= nm eidlist_opt AS LP select RP */ { 198, -8 }, /* (282) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ { 145, -1 }, /* (283) input ::= cmdlist */ { 146, -2 }, /* (284) cmdlist ::= cmdlist ecmd */ { 146, -1 }, /* (285) cmdlist ::= ecmd */ { 147, -1 }, /* (286) ecmd ::= SEMI */ { 147, -2 }, /* (287) ecmd ::= cmdx SEMI */ { 147, -2 }, /* (288) ecmd ::= explain cmdx */ { 152, 0 }, /* (289) trans_opt ::= */ { 152, -1 }, /* (290) trans_opt ::= TRANSACTION */ { 152, -2 }, /* (291) trans_opt ::= TRANSACTION nm */ { 154, -1 }, /* (292) savepoint_opt ::= SAVEPOINT */ { 154, 0 }, /* (293) savepoint_opt ::= */ { 150, -2 }, /* (294) cmd ::= create_table create_table_args */ { 161, -4 }, /* (295) columnlist ::= columnlist COMMA columnname carglist */ { 161, -2 }, /* (296) columnlist ::= columnname carglist */ { 153, -1 }, /* (297) nm ::= ID|INDEXED */ { 153, -1 }, /* (298) nm ::= STRING */ { 153, -1 }, /* (299) nm ::= JOIN_KW */ { 167, -1 }, /* (300) typetoken ::= typename */ { 168, -1 }, /* (301) typename ::= ID|STRING */ { 169, -1 }, /* (302) signed ::= plus_num */ { 169, -1 }, /* (303) signed ::= minus_num */ { 166, -2 }, /* (304) carglist ::= carglist ccons */ { 166, 0 }, /* (305) carglist ::= */ { 173, -2 }, /* (306) ccons ::= NULL onconf */ { 162, -2 }, /* (307) conslist_opt ::= COMMA conslist */ { 185, -3 }, /* (308) conslist ::= conslist tconscomma tcons */ { 185, -1 }, /* (309) conslist ::= tcons */ { 186, 0 }, /* (310) tconscomma ::= */ { 190, -1 }, /* (311) defer_subclause_opt ::= defer_subclause */ { 192, -1 }, /* (312) resolvetype ::= raisetype */ { 196, -1 }, /* (313) selectnowith ::= oneselect */ { 197, -1 }, /* (314) oneselect ::= values */ { 211, -2 }, /* (315) sclp ::= selcollist COMMA */ { 212, -1 }, /* (316) as ::= ID|STRING */ { 175, -1 }, /* (317) expr ::= term */ { 226, -1 }, /* (318) likeop ::= LIKE_KW|MATCH */ { 210, -1 }, /* (319) exprlist ::= nexprlist */ { 235, -1 }, /* (320) nmnum ::= plus_num */ { 235, -1 }, /* (321) nmnum ::= nm */ { 235, -1 }, /* (322) nmnum ::= ON */ { 235, -1 }, /* (323) nmnum ::= DELETE */ { 235, -1 }, /* (324) nmnum ::= DEFAULT */ { 170, -1 }, /* (325) plus_num ::= INTEGER|FLOAT */ { 240, 0 }, /* (326) foreach_clause ::= */ { 240, -3 }, /* (327) foreach_clause ::= FOR EACH ROW */ { 243, -1 }, /* (328) trnm ::= nm */ { 244, 0 }, /* (329) tridxby ::= */ { 245, -1 }, /* (330) database_kw_opt ::= DATABASE */ { 245, 0 }, /* (331) database_kw_opt ::= */ { 248, 0 }, /* (332) kwcolumn_opt ::= */ { 248, -1 }, /* (333) kwcolumn_opt ::= COLUMNKW */ { 250, -1 }, /* (334) vtabarglist ::= vtabarg */ { 250, -3 }, /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */ { 251, -2 }, /* (336) vtabarg ::= vtabarg vtabargtoken */ { 254, 0 }, /* (337) anylist ::= */ { 254, -4 }, /* (338) anylist ::= anylist LP anylist RP */ { 254, -2 }, /* (339) anylist ::= anylist ANY */ { 221, 0 }, /* (340) with ::= */ }; static void yy_accept(yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. ** ** The yyLookahead and yyLookaheadToken parameters provide reduce actions ** access to the lookahead token (if any). The yyLookahead will be YYNOCODE ** if the lookahead token has already been consumed. As this procedure is ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ static YYACTIONTYPE yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ sqlite3ParserTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ sqlite3ParserCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ sqlite3ParserARG_FETCH (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ yysize = yyRuleInfo[yyruleno].nrhs; if( yysize ){ |
︙ | ︙ | |||
141852 141853 141854 141855 141856 141857 141858 | yypParser->yyhwm++; assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); } #endif #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); | > > > | > > > | | 143089 143090 143091 143092 143093 143094 143095 143096 143097 143098 143099 143100 143101 143102 143103 143104 143105 143106 143107 143108 143109 143110 143111 143112 143113 143114 143115 | yypParser->yyhwm++; assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); } #endif #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); /* The call to yyStackOverflow() above pops the stack until it is ** empty, causing the main parser loop to exit. So the return value ** is never used and does not matter. */ return 0; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); /* The call to yyStackOverflow() above pops the stack until it is ** empty, causing the main parser loop to exit. So the return value ** is never used and does not matter. */ return 0; } yymsp = yypParser->yytos; } #endif } switch( yyruleno ){ |
︙ | ︙ | |||
141886 141887 141888 141889 141890 141891 141892 | case 1: /* explain ::= EXPLAIN QUERY PLAN */ { pParse->explain = 2; } break; case 2: /* cmdx ::= cmd */ { sqlite3FinishCoding(pParse); } break; case 3: /* cmd ::= BEGIN transtype trans_opt */ | | | | | 143129 143130 143131 143132 143133 143134 143135 143136 143137 143138 143139 143140 143141 143142 143143 143144 143145 143146 143147 143148 143149 143150 143151 | case 1: /* explain ::= EXPLAIN QUERY PLAN */ { pParse->explain = 2; } break; case 2: /* cmdx ::= cmd */ { sqlite3FinishCoding(pParse); } break; case 3: /* cmd ::= BEGIN transtype trans_opt */ {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);} break; case 4: /* transtype ::= */ {yymsp[1].minor.yy502 = TK_DEFERRED;} break; case 5: /* transtype ::= DEFERRED */ case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); {yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/} break; case 8: /* cmd ::= COMMIT|END trans_opt */ case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); {sqlite3EndTransaction(pParse,yymsp[-1].major);} break; case 10: /* cmd ::= SAVEPOINT nm */ { |
︙ | ︙ | |||
141917 141918 141919 141920 141921 141922 141923 | case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); } break; case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > | > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | < | | | > > > > > > | > > > > > | | > | | | | < < < > | | < | > | < > | < | > > | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < < | < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | > | > | > | > | > | > | 143160 143161 143162 143163 143164 143165 143166 143167 143168 143169 143170 143171 143172 143173 143174 143175 143176 143177 143178 143179 143180 143181 143182 143183 143184 143185 143186 143187 143188 143189 143190 143191 143192 143193 143194 143195 143196 143197 143198 143199 143200 143201 143202 143203 143204 143205 143206 143207 143208 143209 143210 143211 143212 143213 143214 143215 143216 143217 143218 143219 143220 143221 143222 143223 143224 143225 143226 143227 143228 143229 143230 143231 143232 143233 143234 143235 143236 143237 143238 143239 143240 143241 143242 143243 143244 143245 143246 143247 143248 143249 143250 143251 143252 143253 143254 143255 143256 143257 143258 143259 143260 143261 143262 143263 143264 143265 143266 143267 143268 143269 143270 143271 143272 143273 143274 143275 143276 143277 143278 143279 143280 143281 143282 143283 143284 143285 143286 143287 143288 143289 143290 143291 143292 143293 143294 143295 143296 143297 143298 143299 143300 143301 143302 143303 143304 143305 143306 143307 143308 143309 143310 143311 143312 143313 143314 143315 143316 143317 143318 143319 143320 143321 143322 143323 143324 143325 143326 143327 143328 143329 143330 143331 143332 143333 143334 143335 143336 143337 143338 143339 143340 143341 143342 143343 143344 143345 143346 143347 143348 143349 143350 143351 143352 143353 143354 143355 143356 143357 143358 143359 143360 143361 143362 143363 143364 143365 143366 143367 143368 143369 143370 143371 143372 143373 143374 143375 143376 143377 143378 143379 143380 143381 143382 143383 143384 143385 143386 143387 143388 143389 143390 143391 143392 143393 143394 143395 143396 143397 143398 143399 143400 143401 143402 143403 143404 143405 143406 143407 143408 143409 143410 143411 143412 143413 143414 143415 143416 143417 143418 143419 143420 143421 143422 143423 143424 143425 143426 143427 143428 143429 143430 143431 143432 143433 143434 143435 143436 143437 143438 143439 143440 143441 143442 143443 143444 143445 143446 143447 143448 143449 143450 143451 143452 143453 143454 143455 143456 143457 143458 143459 143460 143461 143462 143463 143464 143465 143466 143467 143468 143469 143470 143471 143472 143473 143474 143475 143476 143477 143478 143479 143480 143481 143482 143483 143484 143485 143486 143487 143488 143489 143490 143491 143492 143493 143494 143495 143496 143497 143498 143499 143500 143501 143502 143503 143504 143505 143506 143507 143508 143509 143510 143511 143512 143513 143514 143515 143516 143517 143518 143519 143520 143521 143522 143523 143524 143525 143526 143527 143528 143529 143530 143531 143532 143533 143534 143535 143536 143537 143538 143539 143540 143541 143542 143543 143544 143545 143546 143547 143548 143549 143550 143551 143552 143553 143554 143555 143556 143557 143558 143559 143560 143561 143562 143563 143564 143565 143566 143567 143568 143569 143570 143571 143572 143573 143574 143575 143576 143577 143578 143579 143580 143581 143582 143583 143584 143585 143586 143587 143588 143589 143590 143591 143592 143593 143594 143595 143596 143597 143598 143599 143600 143601 143602 143603 143604 143605 143606 143607 143608 143609 143610 143611 143612 143613 143614 143615 143616 143617 143618 143619 143620 143621 143622 143623 143624 143625 143626 143627 143628 143629 143630 143631 143632 143633 143634 143635 143636 143637 143638 143639 143640 143641 143642 143643 143644 143645 143646 143647 143648 143649 143650 143651 143652 143653 143654 143655 143656 143657 143658 143659 143660 143661 143662 143663 143664 143665 143666 143667 143668 143669 143670 143671 143672 143673 143674 143675 143676 143677 143678 143679 143680 143681 143682 143683 143684 143685 143686 143687 143688 143689 143690 143691 143692 143693 143694 143695 143696 143697 143698 143699 143700 143701 143702 143703 143704 143705 143706 143707 143708 143709 143710 143711 143712 143713 143714 143715 143716 143717 143718 143719 143720 143721 143722 143723 143724 143725 143726 143727 143728 143729 143730 143731 143732 143733 143734 143735 143736 143737 143738 143739 143740 143741 143742 143743 143744 143745 143746 143747 143748 143749 143750 143751 143752 143753 143754 143755 143756 143757 143758 143759 143760 143761 143762 143763 143764 143765 143766 143767 143768 143769 143770 143771 143772 143773 143774 143775 143776 143777 143778 143779 143780 143781 143782 143783 143784 143785 143786 143787 143788 143789 143790 143791 143792 143793 143794 143795 143796 143797 143798 143799 143800 143801 143802 143803 143804 143805 143806 143807 143808 143809 143810 143811 143812 143813 143814 143815 143816 143817 143818 143819 143820 143821 143822 143823 143824 143825 143826 143827 143828 143829 143830 143831 143832 143833 143834 143835 143836 143837 143838 143839 143840 143841 143842 143843 143844 143845 143846 143847 143848 143849 143850 143851 143852 143853 143854 143855 143856 143857 143858 143859 143860 143861 143862 143863 143864 143865 143866 143867 143868 143869 143870 143871 143872 143873 143874 143875 143876 143877 143878 143879 143880 143881 143882 143883 143884 143885 143886 143887 143888 143889 143890 143891 143892 143893 143894 143895 143896 143897 143898 143899 143900 143901 143902 143903 143904 143905 143906 143907 143908 143909 143910 143911 143912 143913 143914 143915 143916 143917 143918 143919 143920 143921 143922 143923 143924 143925 143926 143927 143928 143929 143930 143931 143932 143933 143934 143935 143936 143937 143938 143939 143940 143941 143942 143943 143944 143945 143946 143947 143948 143949 143950 143951 143952 143953 143954 143955 143956 143957 143958 143959 143960 143961 143962 143963 143964 143965 143966 143967 143968 143969 143970 143971 143972 143973 143974 143975 143976 143977 143978 143979 143980 143981 143982 143983 143984 143985 143986 143987 143988 143989 143990 143991 143992 143993 143994 143995 143996 143997 143998 143999 144000 144001 144002 144003 144004 144005 144006 144007 144008 144009 144010 144011 144012 144013 144014 144015 144016 144017 144018 144019 144020 144021 144022 144023 144024 144025 144026 144027 144028 144029 144030 144031 144032 144033 144034 144035 144036 144037 144038 144039 144040 144041 144042 144043 144044 144045 144046 144047 144048 144049 144050 144051 144052 144053 144054 144055 144056 144057 144058 144059 144060 144061 144062 144063 144064 144065 144066 144067 144068 144069 144070 144071 144072 144073 144074 144075 144076 144077 144078 144079 144080 144081 144082 144083 144084 144085 144086 144087 144088 144089 144090 144091 144092 144093 144094 144095 144096 144097 144098 144099 144100 144101 144102 144103 144104 144105 144106 144107 144108 144109 144110 144111 144112 144113 144114 144115 144116 144117 144118 144119 144120 144121 144122 144123 144124 144125 144126 144127 144128 144129 144130 144131 144132 144133 144134 144135 144136 144137 144138 144139 144140 144141 144142 144143 144144 144145 144146 144147 144148 144149 144150 144151 144152 144153 144154 144155 144156 144157 144158 144159 144160 144161 144162 144163 144164 144165 144166 144167 144168 144169 144170 144171 144172 144173 144174 144175 144176 144177 144178 144179 144180 144181 144182 144183 144184 144185 144186 144187 144188 144189 144190 144191 144192 144193 144194 144195 144196 144197 144198 144199 144200 144201 144202 144203 144204 144205 144206 144207 144208 144209 144210 144211 144212 144213 144214 144215 144216 144217 144218 144219 144220 144221 144222 144223 144224 144225 144226 144227 144228 144229 144230 144231 144232 144233 144234 144235 144236 144237 144238 144239 144240 144241 144242 144243 144244 144245 144246 144247 144248 144249 144250 144251 144252 144253 144254 144255 144256 144257 144258 144259 144260 144261 144262 144263 144264 144265 144266 144267 144268 144269 144270 144271 144272 144273 144274 144275 144276 144277 144278 144279 144280 144281 144282 144283 144284 144285 144286 144287 144288 144289 144290 144291 144292 144293 144294 144295 144296 144297 144298 144299 144300 144301 144302 144303 144304 144305 144306 144307 144308 144309 144310 144311 144312 144313 144314 144315 144316 144317 144318 144319 144320 144321 144322 144323 144324 144325 144326 144327 144328 144329 144330 144331 144332 144333 144334 144335 144336 144337 144338 144339 144340 144341 144342 144343 144344 144345 144346 144347 144348 144349 144350 144351 144352 144353 144354 144355 144356 144357 144358 144359 144360 144361 144362 144363 144364 144365 144366 144367 144368 144369 144370 144371 144372 144373 144374 144375 144376 144377 144378 144379 144380 144381 144382 144383 144384 144385 144386 144387 144388 144389 144390 144391 144392 144393 144394 144395 144396 144397 144398 144399 144400 144401 144402 144403 144404 144405 144406 144407 144408 144409 144410 144411 144412 144413 144414 144415 144416 144417 144418 144419 144420 144421 144422 144423 144424 144425 144426 144427 144428 144429 144430 144431 144432 144433 144434 144435 144436 144437 144438 144439 144440 144441 144442 144443 144444 144445 144446 144447 144448 144449 144450 144451 144452 144453 144454 144455 144456 144457 144458 144459 144460 144461 144462 144463 144464 144465 144466 144467 144468 144469 144470 144471 144472 144473 144474 144475 | case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); } break; case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502); } break; case 14: /* createkw ::= CREATE */ {disableLookaside(pParse);} break; case 15: /* ifnotexists ::= */ case 18: /* temp ::= */ yytestcase(yyruleno==18); case 21: /* table_options ::= */ yytestcase(yyruleno==21); case 42: /* autoinc ::= */ yytestcase(yyruleno==42); case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57); case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67); case 76: /* ifexists ::= */ yytestcase(yyruleno==76); case 92: /* distinct ::= */ yytestcase(yyruleno==92); case 224: /* collate ::= */ yytestcase(yyruleno==224); {yymsp[1].minor.yy502 = 0;} break; case 16: /* ifnotexists ::= IF NOT EXISTS */ {yymsp[-2].minor.yy502 = 1;} break; case 17: /* temp ::= TEMP */ case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43); {yymsp[0].minor.yy502 = 1;} break; case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ { sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy502,0); } break; case 20: /* create_table_args ::= AS select */ { sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399); sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399); } break; case 22: /* table_options ::= WITHOUT nm */ { if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ yymsp[-1].minor.yy502 = TF_WithoutRowid | TF_NoVisibleRowid; }else{ yymsp[-1].minor.yy502 = 0; sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); } } break; case 23: /* columnname ::= nm typetoken */ {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} break; case 24: /* typetoken ::= */ case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60); case 98: /* as ::= */ yytestcase(yyruleno==98); {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;} break; case 25: /* typetoken ::= typename LP signed RP */ { yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); } break; case 26: /* typetoken ::= typename LP signed COMMA signed RP */ { yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); } break; case 27: /* typename ::= typename ID|STRING */ {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} break; case 28: /* scanpt ::= */ { assert( yyLookahead!=YYNOCODE ); yymsp[1].minor.yy36 = yyLookaheadToken.z; } break; case 29: /* ccons ::= CONSTRAINT nm */ case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62); {pParse->constraintName = yymsp[0].minor.yy0;} break; case 30: /* ccons ::= DEFAULT scanpt term scanpt */ {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);} break; case 31: /* ccons ::= DEFAULT LP expr RP */ {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} break; case 32: /* ccons ::= DEFAULT PLUS term scanpt */ {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);} break; case 33: /* ccons ::= DEFAULT MINUS term scanpt */ { Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0); sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36); } break; case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */ { Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0); if( p ){ sqlite3ExprIdToTrueFalse(p); testcase( p->op==TK_TRUEFALSE && sqlite3ExprTruthValue(p) ); } sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n); } break; case 35: /* ccons ::= NOT NULL onconf */ {sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);} break; case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);} break; case 37: /* ccons ::= UNIQUE onconf */ {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} break; case 38: /* ccons ::= CHECK LP expr RP */ {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);} break; case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */ {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);} break; case 40: /* ccons ::= defer_subclause */ {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);} break; case 41: /* ccons ::= COLLATE ID|STRING */ {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} break; case 44: /* refargs ::= */ { yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */} break; case 45: /* refargs ::= refargs refarg */ { yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; } break; case 46: /* refarg ::= MATCH nm */ { yymsp[-1].minor.yy107.value = 0; yymsp[-1].minor.yy107.mask = 0x000000; } break; case 47: /* refarg ::= ON INSERT refact */ { yymsp[-2].minor.yy107.value = 0; yymsp[-2].minor.yy107.mask = 0x000000; } break; case 48: /* refarg ::= ON DELETE refact */ { yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy107.mask = 0x0000ff; } break; case 49: /* refarg ::= ON UPDATE refact */ { yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy107.mask = 0x00ff00; } break; case 50: /* refact ::= SET NULL */ { yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */} break; case 51: /* refact ::= SET DEFAULT */ { yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */} break; case 52: /* refact ::= CASCADE */ { yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */} break; case 53: /* refact ::= RESTRICT */ { yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */} break; case 54: /* refact ::= NO ACTION */ { yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */} break; case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ {yymsp[-2].minor.yy502 = 0;} break; case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71); case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155); {yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;} break; case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75); case 196: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==196); case 199: /* in_op ::= NOT IN */ yytestcase(yyruleno==199); case 225: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==225); {yymsp[-1].minor.yy502 = 1;} break; case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ {yymsp[-1].minor.yy502 = 0;} break; case 61: /* tconscomma ::= COMMA */ {pParse->constraintName.n = 0;} break; case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy232,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);} break; case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */ {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy232,yymsp[0].minor.yy502,0,0,0,0, SQLITE_IDXTYPE_UNIQUE);} break; case 65: /* tcons ::= CHECK LP expr RP onconf */ {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);} break; case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ { sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502); sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502); } break; case 68: /* onconf ::= */ case 70: /* orconf ::= */ yytestcase(yyruleno==70); {yymsp[1].minor.yy502 = OE_Default;} break; case 69: /* onconf ::= ON CONFLICT resolvetype */ {yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;} break; case 72: /* resolvetype ::= IGNORE */ {yymsp[0].minor.yy502 = OE_Ignore;} break; case 73: /* resolvetype ::= REPLACE */ case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156); {yymsp[0].minor.yy502 = OE_Replace;} break; case 74: /* cmd ::= DROP TABLE ifexists fullname */ { sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502); } break; case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ { sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502); } break; case 78: /* cmd ::= DROP VIEW ifexists fullname */ { sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502); } break; case 79: /* cmd ::= select */ { SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0}; sqlite3Select(pParse, yymsp[0].minor.yy399, &dest); sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399); } break; case 80: /* select ::= WITH wqlist selectnowith */ { Select *p = yymsp[0].minor.yy399; if( p ){ p->pWith = yymsp[-1].minor.yy91; parserDoubleLinkSelect(pParse, p); }else{ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91); } yymsp[-2].minor.yy399 = p; } break; case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */ { Select *p = yymsp[0].minor.yy399; if( p ){ p->pWith = yymsp[-1].minor.yy91; parserDoubleLinkSelect(pParse, p); }else{ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91); } yymsp[-3].minor.yy399 = p; } break; case 82: /* select ::= selectnowith */ { Select *p = yymsp[0].minor.yy399; if( p ){ parserDoubleLinkSelect(pParse, p); } yymsp[0].minor.yy399 = p; /*A-overwrites-X*/ } break; case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */ { Select *pRhs = yymsp[0].minor.yy399; Select *pLhs = yymsp[-2].minor.yy399; if( pRhs && pRhs->pPrior ){ SrcList *pFrom; Token x; x.n = 0; parserDoubleLinkSelect(pParse, pRhs); pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0); pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); } if( pRhs ){ pRhs->op = (u8)yymsp[-1].minor.yy502; pRhs->pPrior = pLhs; if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; pRhs->selFlags &= ~SF_MultiValue; if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1; }else{ sqlite3SelectDelete(pParse->db, pLhs); } yymsp[-2].minor.yy399 = pRhs; } break; case 84: /* multiselect_op ::= UNION */ case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86); {yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/} break; case 85: /* multiselect_op ::= UNION ALL */ {yymsp[-1].minor.yy502 = TK_ALL;} break; case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ { #if SELECTTRACE_ENABLED Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/ #endif yymsp[-8].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy232,yymsp[-5].minor.yy427,yymsp[-4].minor.yy182,yymsp[-3].minor.yy232,yymsp[-2].minor.yy182,yymsp[-1].minor.yy232,yymsp[-7].minor.yy502,yymsp[0].minor.yy182); #if SELECTTRACE_ENABLED /* Populate the Select.zSelName[] string that is used to help with ** query planner debugging, to differentiate between multiple Select ** objects in a complex query. ** ** If the SELECT keyword is immediately followed by a C-style comment ** then extract the first few alphanumeric characters from within that ** comment to be the zSelName value. Otherwise, the label is #N where ** is an integer that is incremented with each SELECT statement seen. */ if( yymsp[-8].minor.yy399!=0 ){ const char *z = s.z+6; int i; sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName,"#%d",++pParse->nSelect); while( z[0]==' ' ) z++; if( z[0]=='/' && z[1]=='*' ){ z += 2; while( z[0]==' ' ) z++; for(i=0; sqlite3Isalnum(z[i]); i++){} sqlite3_snprintf(sizeof(yymsp[-8].minor.yy399->zSelName), yymsp[-8].minor.yy399->zSelName, "%.*s", i, z); } } #endif /* SELECTRACE_ENABLED */ } break; case 88: /* values ::= VALUES LP nexprlist RP */ { yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values,0); } break; case 89: /* values ::= values COMMA LP exprlist RP */ { Select *pRight, *pLeft = yymsp[-4].minor.yy399; pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values|SF_MultiValue,0); if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; if( pRight ){ pRight->op = TK_ALL; pRight->pPrior = pLeft; yymsp[-4].minor.yy399 = pRight; }else{ yymsp[-4].minor.yy399 = pLeft; } } break; case 90: /* distinct ::= DISTINCT */ {yymsp[0].minor.yy502 = SF_Distinct;} break; case 91: /* distinct ::= ALL */ {yymsp[0].minor.yy502 = SF_All;} break; case 93: /* sclp ::= */ case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126); case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133); case 212: /* exprlist ::= */ yytestcase(yyruleno==212); case 215: /* paren_exprlist ::= */ yytestcase(yyruleno==215); case 220: /* eidlist_opt ::= */ yytestcase(yyruleno==220); {yymsp[1].minor.yy232 = 0;} break; case 94: /* selcollist ::= sclp scanpt expr scanpt as */ { yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[-2].minor.yy182); if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[0].minor.yy0, 1); sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy232,yymsp[-3].minor.yy36,yymsp[-1].minor.yy36); } break; case 95: /* selcollist ::= sclp scanpt STAR */ { Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, p); } break; case 96: /* selcollist ::= sclp scanpt nm DOT STAR */ { Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, pDot); } break; case 97: /* as ::= AS nm */ case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108); case 234: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==234); case 235: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==235); {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} break; case 99: /* from ::= */ {yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));} break; case 100: /* from ::= FROM seltablist */ { yymsp[-1].minor.yy427 = yymsp[0].minor.yy427; sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427); } break; case 101: /* stl_prefix ::= seltablist joinop */ { if( ALWAYS(yymsp[-1].minor.yy427 && yymsp[-1].minor.yy427->nSrc>0) ) yymsp[-1].minor.yy427->a[yymsp[-1].minor.yy427->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502; } break; case 102: /* stl_prefix ::= */ {yymsp[1].minor.yy427 = 0;} break; case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ { yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510); sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy427, &yymsp[-2].minor.yy0); } break; case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ { yymsp[-8].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy427,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510); sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy427, yymsp[-4].minor.yy232); } break; case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ { yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy399,yymsp[-1].minor.yy182,yymsp[0].minor.yy510); } break; case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ { if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy182==0 && yymsp[0].minor.yy510==0 ){ yymsp[-6].minor.yy427 = yymsp[-4].minor.yy427; }else if( yymsp[-4].minor.yy427->nSrc==1 ){ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510); if( yymsp[-6].minor.yy427 ){ struct SrcList_item *pNew = &yymsp[-6].minor.yy427->a[yymsp[-6].minor.yy427->nSrc-1]; struct SrcList_item *pOld = yymsp[-4].minor.yy427->a; pNew->zName = pOld->zName; pNew->zDatabase = pOld->zDatabase; pNew->pSelect = pOld->pSelect; pOld->zName = pOld->zDatabase = 0; pOld->pSelect = 0; } sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427); }else{ Select *pSubquery; sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427); pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,SF_NestedFrom,0); yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy182,yymsp[0].minor.yy510); } } break; case 107: /* dbnm ::= */ case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121); {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} break; case 109: /* fullname ::= nm */ case 111: /* xfullname ::= nm */ yytestcase(yyruleno==111); {yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} break; case 110: /* fullname ::= nm DOT nm */ case 112: /* xfullname ::= nm DOT nm */ yytestcase(yyruleno==112); {yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} break; case 113: /* xfullname ::= nm DOT nm AS nm */ { yymsp[-4].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ if( yymsp[-4].minor.yy427 ) yymsp[-4].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); } break; case 114: /* xfullname ::= nm AS nm */ { yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ if( yymsp[-2].minor.yy427 ) yymsp[-2].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); } break; case 115: /* joinop ::= COMMA|JOIN */ { yymsp[0].minor.yy502 = JT_INNER; } break; case 116: /* joinop ::= JOIN_KW JOIN */ {yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} break; case 117: /* joinop ::= JOIN_KW nm JOIN */ {yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} break; case 118: /* joinop ::= JOIN_KW nm nm JOIN */ {yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} break; case 119: /* on_opt ::= ON expr */ case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136); case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143); case 208: /* case_else ::= ELSE expr */ yytestcase(yyruleno==208); {yymsp[-1].minor.yy182 = yymsp[0].minor.yy182;} break; case 120: /* on_opt ::= */ case 135: /* having_opt ::= */ yytestcase(yyruleno==135); case 137: /* limit_opt ::= */ yytestcase(yyruleno==137); case 142: /* where_opt ::= */ yytestcase(yyruleno==142); case 209: /* case_else ::= */ yytestcase(yyruleno==209); case 211: /* case_operand ::= */ yytestcase(yyruleno==211); {yymsp[1].minor.yy182 = 0;} break; case 122: /* indexed_opt ::= INDEXED BY nm */ {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} break; case 123: /* indexed_opt ::= NOT INDEXED */ {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} break; case 124: /* using_opt ::= USING LP idlist RP */ {yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;} break; case 125: /* using_opt ::= */ case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157); {yymsp[1].minor.yy510 = 0;} break; case 127: /* orderby_opt ::= ORDER BY sortlist */ case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134); {yymsp[-2].minor.yy232 = yymsp[0].minor.yy232;} break; case 128: /* sortlist ::= sortlist COMMA expr sortorder */ { yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182); sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502); } break; case 129: /* sortlist ::= expr sortorder */ { yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502); } break; case 130: /* sortorder ::= ASC */ {yymsp[0].minor.yy502 = SQLITE_SO_ASC;} break; case 131: /* sortorder ::= DESC */ {yymsp[0].minor.yy502 = SQLITE_SO_DESC;} break; case 132: /* sortorder ::= */ {yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;} break; case 138: /* limit_opt ::= LIMIT expr */ {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,0);} break; case 139: /* limit_opt ::= LIMIT expr OFFSET expr */ {yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);} break; case 140: /* limit_opt ::= LIMIT expr COMMA expr */ {yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);} break; case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */ { sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0); sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0); } break; case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */ { sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0); sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy232,"set list"); sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy232,yymsp[0].minor.yy182,yymsp[-5].minor.yy502,0,0,0); } break; case 145: /* setlist ::= setlist COMMA nm EQ expr */ { yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[0].minor.yy182); sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, 1); } break; case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ { yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182); } break; case 147: /* setlist ::= nm EQ expr */ { yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182); sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1); } yymsp[-2].minor.yy232 = yylhsminor.yy232; break; case 148: /* setlist ::= LP idlist RP EQ expr */ { yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182); } break; case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ { sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198); } break; case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */ { sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0); } break; case 151: /* upsert ::= */ { yymsp[1].minor.yy198 = 0; } break; case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */ { yymsp[-10].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy232,yymsp[-5].minor.yy182,yymsp[-1].minor.yy232,yymsp[0].minor.yy182);} break; case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */ { yymsp[-7].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy232,yymsp[-2].minor.yy182,0,0); } break; case 154: /* upsert ::= ON CONFLICT DO NOTHING */ { yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); } break; case 158: /* idlist_opt ::= LP idlist RP */ {yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;} break; case 159: /* idlist ::= idlist COMMA nm */ {yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);} break; case 160: /* idlist ::= nm */ {yymsp[0].minor.yy510 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} break; case 161: /* expr ::= LP expr RP */ {yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;} break; case 162: /* expr ::= ID|INDEXED */ case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163); {yymsp[0].minor.yy182=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} break; case 164: /* expr ::= nm DOT nm */ { Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); } yymsp[-2].minor.yy182 = yylhsminor.yy182; break; case 165: /* expr ::= nm DOT nm DOT nm */ { Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3); yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); } yymsp[-4].minor.yy182 = yylhsminor.yy182; break; case 166: /* term ::= NULL|FLOAT|BLOB */ case 167: /* term ::= STRING */ yytestcase(yyruleno==167); {yymsp[0].minor.yy182=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} break; case 168: /* term ::= INTEGER */ { yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); } yymsp[0].minor.yy182 = yylhsminor.yy182; break; case 169: /* expr ::= VARIABLE */ { if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ u32 n = yymsp[0].minor.yy0.n; yymsp[0].minor.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n); }else{ /* When doing a nested parse, one can include terms in an expression ** that look like this: #1 #2 ... These terms refer to registers ** in the virtual machine. #N is the N-th register. */ Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ assert( t.n>=2 ); if( pParse->nested==0 ){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); yymsp[0].minor.yy182 = 0; }else{ yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable); } } } break; case 170: /* expr ::= expr COLLATE ID|STRING */ { yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1); } break; case 171: /* expr ::= CAST LP expr AS typetoken RP */ { yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy182, yymsp[-3].minor.yy182, 0); } break; case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP */ { if( yymsp[-1].minor.yy232 && yymsp[-1].minor.yy232->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); } yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0); if( yymsp[-2].minor.yy502==SF_Distinct && yylhsminor.yy182 ){ yylhsminor.yy182->flags |= EP_Distinct; } } yymsp[-4].minor.yy182 = yylhsminor.yy182; break; case 173: /* expr ::= ID|INDEXED LP STAR RP */ { yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); } yymsp[-3].minor.yy182 = yylhsminor.yy182; break; case 174: /* term ::= CTIME_KW */ { yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0); } yymsp[0].minor.yy182 = yylhsminor.yy182; break; case 175: /* expr ::= LP nexprlist COMMA expr RP */ { ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy232, yymsp[-1].minor.yy182); yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); if( yymsp[-4].minor.yy182 ){ yymsp[-4].minor.yy182->x.pList = pList; }else{ sqlite3ExprListDelete(pParse->db, pList); } } break; case 176: /* expr ::= expr AND expr */ case 177: /* expr ::= expr OR expr */ yytestcase(yyruleno==177); case 178: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==178); case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179); case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180); case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181); case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182); case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183); {yymsp[-2].minor.yy182=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);} break; case 184: /* likeop ::= NOT LIKE_KW|MATCH */ {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} break; case 185: /* expr ::= expr likeop expr */ { ExprList *pList; int bNot = yymsp[-1].minor.yy0.n & 0x80000000; yymsp[-1].minor.yy0.n &= 0x7fffffff; pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy182); pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy182); yymsp[-2].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0); if( bNot ) yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy182, 0); if( yymsp[-2].minor.yy182 ) yymsp[-2].minor.yy182->flags |= EP_InfixFunc; } break; case 186: /* expr ::= expr likeop expr ESCAPE expr */ { ExprList *pList; int bNot = yymsp[-3].minor.yy0.n & 0x80000000; yymsp[-3].minor.yy0.n &= 0x7fffffff; pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182); pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy182); pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182); yymsp[-4].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0); if( bNot ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0); if( yymsp[-4].minor.yy182 ) yymsp[-4].minor.yy182->flags |= EP_InfixFunc; } break; case 187: /* expr ::= expr ISNULL|NOTNULL */ {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);} break; case 188: /* expr ::= expr NOT NULL */ {yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);} break; case 189: /* expr ::= expr IS expr */ { yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy182,yymsp[0].minor.yy182); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-2].minor.yy182, TK_ISNULL); } break; case 190: /* expr ::= expr IS NOT expr */ { yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy182,yymsp[0].minor.yy182); binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-3].minor.yy182, TK_NOTNULL); } break; case 191: /* expr ::= NOT expr */ case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192); {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy182, 0);/*A-overwrites-B*/} break; case 193: /* expr ::= MINUS expr */ {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy182, 0);} break; case 194: /* expr ::= PLUS expr */ {yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, TK_UPLUS, yymsp[0].minor.yy182, 0);} break; case 195: /* between_op ::= BETWEEN */ case 198: /* in_op ::= IN */ yytestcase(yyruleno==198); {yymsp[0].minor.yy502 = 0;} break; case 197: /* expr ::= expr between_op expr AND expr */ { ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182); pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182); yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy182, 0); if( yymsp[-4].minor.yy182 ){ yymsp[-4].minor.yy182->x.pList = pList; }else{ sqlite3ExprListDelete(pParse->db, pList); } if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0); } break; case 200: /* expr ::= expr in_op LP exprlist RP */ { if( yymsp[-1].minor.yy232==0 ){ /* Expressions of the form ** ** expr1 IN () ** expr1 NOT IN () ** ** simplify to constants 0 (false) and 1 (true), respectively, ** regardless of the value of expr1. */ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy182); yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1); }else if( yymsp[-1].minor.yy232->nExpr==1 ){ /* Expressions of the form: ** ** expr1 IN (?1) ** expr1 NOT IN (?2) ** ** with exactly one value on the RHS can be simplified to something ** like this: ** ** expr1 == ?1 ** expr1 <> ?2 ** ** But, the RHS of the == or <> is marked with the EP_Generic flag ** so that it may not contribute to the computation of comparison ** affinity or the collating sequence to use for comparison. Otherwise, ** the semantics would be subtly different from IN or NOT IN. */ Expr *pRHS = yymsp[-1].minor.yy232->a[0].pExpr; yymsp[-1].minor.yy232->a[0].pExpr = 0; sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232); /* pRHS cannot be NULL because a malloc error would have been detected ** before now and control would have never reached this point */ if( ALWAYS(pRHS) ){ pRHS->flags &= ~EP_Collate; pRHS->flags |= EP_Generic; } yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS); }else{ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0); if( yymsp[-4].minor.yy182 ){ yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy232; sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182); }else{ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232); } if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0); } } break; case 201: /* expr ::= LP select RP */ { yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399); } break; case 202: /* expr ::= expr in_op LP select RP */ { yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0); sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, yymsp[-1].minor.yy399); if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0); } break; case 203: /* expr ::= expr in_op nm dbnm paren_exprlist */ { SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); if( yymsp[0].minor.yy232 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy232); yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0); sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, pSelect); if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0); } break; case 204: /* expr ::= EXISTS LP select RP */ { Expr *p; p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399); } break; case 205: /* expr ::= CASE case_operand case_exprlist case_else END */ { yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy182, 0); if( yymsp[-4].minor.yy182 ){ yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy182 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[-1].minor.yy182) : yymsp[-2].minor.yy232; sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182); }else{ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232); sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182); } } break; case 206: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ { yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[-2].minor.yy182); yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[0].minor.yy182); } break; case 207: /* case_exprlist ::= WHEN expr THEN expr */ { yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182); yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232, yymsp[0].minor.yy182); } break; case 210: /* case_operand ::= expr */ {yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/} break; case 213: /* nexprlist ::= nexprlist COMMA expr */ {yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);} break; case 214: /* nexprlist ::= expr */ {yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*A-overwrites-Y*/} break; case 216: /* paren_exprlist ::= LP exprlist RP */ case 221: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==221); {yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232;} break; case 217: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ { sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy232, yymsp[-10].minor.yy502, &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF); } break; case 218: /* uniqueflag ::= UNIQUE */ case 258: /* raisetype ::= ABORT */ yytestcase(yyruleno==258); {yymsp[0].minor.yy502 = OE_Abort;} break; case 219: /* uniqueflag ::= */ {yymsp[1].minor.yy502 = OE_None;} break; case 222: /* eidlist ::= eidlist COMMA nm collate sortorder */ { yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); } break; case 223: /* eidlist ::= nm collate sortorder */ { yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/ } break; case 226: /* cmd ::= DROP INDEX ifexists fullname */ {sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);} break; case 227: /* cmd ::= VACUUM */ {sqlite3Vacuum(pParse,0);} break; case 228: /* cmd ::= VACUUM nm */ {sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);} break; case 229: /* cmd ::= PRAGMA nm dbnm */ {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} break; case 230: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} break; case 231: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} break; case 232: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} break; case 233: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} break; case 236: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ { Token all; all.z = yymsp[-3].minor.yy0.z; all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy47, &all); } break; case 237: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ { sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy300.a, yymsp[-4].minor.yy300.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy182, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502); yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ } break; case 238: /* trigger_time ::= BEFORE|AFTER */ { yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ } break; case 239: /* trigger_time ::= INSTEAD OF */ { yymsp[-1].minor.yy502 = TK_INSTEAD;} break; case 240: /* trigger_time ::= */ { yymsp[1].minor.yy502 = TK_BEFORE; } break; case 241: /* trigger_event ::= DELETE|INSERT */ case 242: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==242); {yymsp[0].minor.yy300.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy300.b = 0;} break; case 243: /* trigger_event ::= UPDATE OF idlist */ {yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;} break; case 244: /* when_clause ::= */ case 263: /* key_opt ::= */ yytestcase(yyruleno==263); { yymsp[1].minor.yy182 = 0; } break; case 245: /* when_clause ::= WHEN expr */ case 264: /* key_opt ::= KEY expr */ yytestcase(yyruleno==264); { yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; } break; case 246: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ { assert( yymsp[-2].minor.yy47!=0 ); yymsp[-2].minor.yy47->pLast->pNext = yymsp[-1].minor.yy47; yymsp[-2].minor.yy47->pLast = yymsp[-1].minor.yy47; } break; case 247: /* trigger_cmd_list ::= trigger_cmd SEMI */ { assert( yymsp[-1].minor.yy47!=0 ); yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47; } break; case 248: /* trnm ::= nm DOT nm */ { yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; sqlite3ErrorMsg(pParse, "qualified table names are not allowed on INSERT, UPDATE, and DELETE " "statements within triggers"); } break; case 249: /* tridxby ::= INDEXED BY nm */ { sqlite3ErrorMsg(pParse, "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; case 250: /* tridxby ::= NOT INDEXED */ { sqlite3ErrorMsg(pParse, "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " "within triggers"); } break; case 251: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */ {yylhsminor.yy47 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy182, yymsp[-6].minor.yy502, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy36);} yymsp[-7].minor.yy47 = yylhsminor.yy47; break; case 252: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ { yylhsminor.yy47 = sqlite3TriggerInsertStep(pParse->db,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy510,yymsp[-2].minor.yy399,yymsp[-6].minor.yy502,yymsp[-1].minor.yy198,yymsp[-7].minor.yy36,yymsp[0].minor.yy36);/*yylhsminor.yy47-overwrites-yymsp[-6].minor.yy502*/ } yymsp[-7].minor.yy47 = yylhsminor.yy47; break; case 253: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ {yylhsminor.yy47 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy182, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy36);} yymsp[-5].minor.yy47 = yylhsminor.yy47; break; case 254: /* trigger_cmd ::= scanpt select scanpt */ {yylhsminor.yy47 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy399, yymsp[-2].minor.yy36, yymsp[0].minor.yy36); /*yylhsminor.yy47-overwrites-yymsp[-1].minor.yy399*/} yymsp[-2].minor.yy47 = yylhsminor.yy47; break; case 255: /* expr ::= RAISE LP IGNORE RP */ { yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); if( yymsp[-3].minor.yy182 ){ yymsp[-3].minor.yy182->affinity = OE_Ignore; } } break; case 256: /* expr ::= RAISE LP raisetype COMMA nm RP */ { yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); if( yymsp[-5].minor.yy182 ) { yymsp[-5].minor.yy182->affinity = (char)yymsp[-3].minor.yy502; } } break; case 257: /* raisetype ::= ROLLBACK */ {yymsp[0].minor.yy502 = OE_Rollback;} break; case 259: /* raisetype ::= FAIL */ {yymsp[0].minor.yy502 = OE_Fail;} break; case 260: /* cmd ::= DROP TRIGGER ifexists fullname */ { sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy502); } break; case 261: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ { sqlite3Attach(pParse, yymsp[-3].minor.yy182, yymsp[-1].minor.yy182, yymsp[0].minor.yy182); } break; case 262: /* cmd ::= DETACH database_kw_opt expr */ { sqlite3Detach(pParse, yymsp[0].minor.yy182); } break; case 265: /* cmd ::= REINDEX */ {sqlite3Reindex(pParse, 0, 0);} break; case 266: /* cmd ::= REINDEX nm dbnm */ {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; case 267: /* cmd ::= ANALYZE */ {sqlite3Analyze(pParse, 0, 0);} break; case 268: /* cmd ::= ANALYZE nm dbnm */ {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} break; case 269: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ { sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy427,&yymsp[0].minor.yy0); } break; case 270: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ { yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); } break; case 271: /* add_column_fullname ::= fullname */ { disableLookaside(pParse); sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy427); } break; case 272: /* cmd ::= create_vtab */ {sqlite3VtabFinishParse(pParse,0);} break; case 273: /* cmd ::= create_vtab LP vtabarglist RP */ {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} break; case 274: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ { sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502); } break; case 275: /* vtabarg ::= */ {sqlite3VtabArgInit(pParse);} break; case 276: /* vtabargtoken ::= ANY */ case 277: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==277); case 278: /* lp ::= LP */ yytestcase(yyruleno==278); {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} break; case 279: /* with ::= WITH wqlist */ case 280: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==280); { sqlite3WithPush(pParse, yymsp[0].minor.yy91, 1); } break; case 281: /* wqlist ::= nm eidlist_opt AS LP select RP */ { yymsp[-5].minor.yy91 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); /*A-overwrites-X*/ } break; case 282: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ { yymsp[-7].minor.yy91 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy91, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); } break; default: /* (283) input ::= cmdlist */ yytestcase(yyruleno==283); /* (284) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==284); /* (285) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=285); /* (286) ecmd ::= SEMI */ yytestcase(yyruleno==286); /* (287) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==287); /* (288) ecmd ::= explain cmdx */ yytestcase(yyruleno==288); /* (289) trans_opt ::= */ yytestcase(yyruleno==289); /* (290) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==290); /* (291) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==291); /* (292) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==292); /* (293) savepoint_opt ::= */ yytestcase(yyruleno==293); /* (294) cmd ::= create_table create_table_args */ yytestcase(yyruleno==294); /* (295) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==295); /* (296) columnlist ::= columnname carglist */ yytestcase(yyruleno==296); /* (297) nm ::= ID|INDEXED */ yytestcase(yyruleno==297); /* (298) nm ::= STRING */ yytestcase(yyruleno==298); /* (299) nm ::= JOIN_KW */ yytestcase(yyruleno==299); /* (300) typetoken ::= typename */ yytestcase(yyruleno==300); /* (301) typename ::= ID|STRING */ yytestcase(yyruleno==301); /* (302) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=302); /* (303) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=303); /* (304) carglist ::= carglist ccons */ yytestcase(yyruleno==304); /* (305) carglist ::= */ yytestcase(yyruleno==305); /* (306) ccons ::= NULL onconf */ yytestcase(yyruleno==306); /* (307) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==307); /* (308) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==308); /* (309) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=309); /* (310) tconscomma ::= */ yytestcase(yyruleno==310); /* (311) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=311); /* (312) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=312); /* (313) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=313); /* (314) oneselect ::= values */ yytestcase(yyruleno==314); /* (315) sclp ::= selcollist COMMA */ yytestcase(yyruleno==315); /* (316) as ::= ID|STRING */ yytestcase(yyruleno==316); /* (317) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=317); /* (318) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==318); /* (319) exprlist ::= nexprlist */ yytestcase(yyruleno==319); /* (320) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=320); /* (321) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=321); /* (322) nmnum ::= ON */ yytestcase(yyruleno==322); /* (323) nmnum ::= DELETE */ yytestcase(yyruleno==323); /* (324) nmnum ::= DEFAULT */ yytestcase(yyruleno==324); /* (325) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==325); /* (326) foreach_clause ::= */ yytestcase(yyruleno==326); /* (327) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==327); /* (328) trnm ::= nm */ yytestcase(yyruleno==328); /* (329) tridxby ::= */ yytestcase(yyruleno==329); /* (330) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==330); /* (331) database_kw_opt ::= */ yytestcase(yyruleno==331); /* (332) kwcolumn_opt ::= */ yytestcase(yyruleno==332); /* (333) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==333); /* (334) vtabarglist ::= vtabarg */ yytestcase(yyruleno==334); /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==335); /* (336) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==336); /* (337) anylist ::= */ yytestcase(yyruleno==337); /* (338) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==338); /* (339) anylist ::= anylist ANY */ yytestcase(yyruleno==339); /* (340) with ::= */ yytestcase(yyruleno==340); break; /********** End reduce actions ************************************************/ }; assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); yygoto = yyRuleInfo[yyruleno].lhs; yysize = yyRuleInfo[yyruleno].nrhs; yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto); /* There are no SHIFTREDUCE actions on nonterminals because the table ** generator has simplified them to pure REDUCE actions. */ assert( !(yyact>YY_MAX_SHIFT && yyact<=YY_MAX_SHIFTREDUCE) ); /* It is not possible for a REDUCE to be followed by an error */ assert( yyact!=YY_ERROR_ACTION ); yymsp += yysize+1; yypParser->yytos = yymsp; yymsp->stateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); return yyact; } /* ** The following code executes when the parse fails */ #ifndef YYNOERRORRECOVERY static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ sqlite3ParserARG_FETCH sqlite3ParserCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); } #endif while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will be executed whenever the ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ sqlite3ParserCTX_STORE } #endif /* YYNOERRORRECOVERY */ /* ** The following code executes when a syntax error first occurs. */ static void yy_syntax_error( yyParser *yypParser, /* The parser */ int yymajor, /* The major type of the error token */ sqlite3ParserTOKENTYPE yyminor /* The minor type of the error token */ ){ sqlite3ParserARG_FETCH sqlite3ParserCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ if( TOKEN.z[0] ){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); }else{ sqlite3ErrorMsg(pParse, "incomplete input"); } /************ End %syntax_error code ******************************************/ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ sqlite3ParserCTX_STORE } /* ** The following is executed when the parser accepts */ static void yy_accept( yyParser *yypParser /* The parser */ ){ sqlite3ParserARG_FETCH sqlite3ParserCTX_FETCH #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); } #endif #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif assert( yypParser->yytos==yypParser->yystack ); /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ sqlite3ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ sqlite3ParserCTX_STORE } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "sqlite3ParserAlloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the |
︙ | ︙ | |||
143196 143197 143198 143199 143200 143201 143202 | SQLITE_PRIVATE void sqlite3Parser( void *yyp, /* The parser */ int yymajor, /* The major token code number */ sqlite3ParserTOKENTYPE yyminor /* The value for the token */ sqlite3ParserARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; | | | > > < < > < | | | > | | > | | 144490 144491 144492 144493 144494 144495 144496 144497 144498 144499 144500 144501 144502 144503 144504 144505 144506 144507 144508 144509 144510 144511 144512 144513 144514 144515 144516 144517 144518 144519 144520 144521 144522 144523 144524 144525 144526 144527 144528 144529 144530 144531 144532 144533 144534 144535 144536 144537 144538 144539 144540 144541 144542 144543 144544 | SQLITE_PRIVATE void sqlite3Parser( void *yyp, /* The parser */ int yymajor, /* The major token code number */ sqlite3ParserTOKENTYPE yyminor /* The value for the token */ sqlite3ParserARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; YYACTIONTYPE yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif yyParser *yypParser = (yyParser*)yyp; /* The parser */ sqlite3ParserCTX_FETCH sqlite3ParserARG_STORE assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ if( yyact < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", yyTracePrompt,yyTokenName[yymajor],yyact); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); } } #endif do{ assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action(yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, yyminor sqlite3ParserCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif break; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); return; }else{ assert( yyact == YY_ERROR_ACTION ); yyminorunion.yy0 = yyminor; |
︙ | ︙ | |||
143305 143306 143307 143308 143309 143310 143311 143312 143313 143314 143315 143316 143317 143318 143319 143320 143321 | yymajor = YYNOCODE; }else if( yymx!=YYERRORSYMBOL ){ yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor); } } yypParser->yyerrcnt = 3; yyerrorhit = 1; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax ** error routine and continue going as if nothing had happened. ** ** Applications can set this macro (for example inside %include) if ** they intend to abandon the parse upon the first syntax error seen. */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); | > > < | | 144601 144602 144603 144604 144605 144606 144607 144608 144609 144610 144611 144612 144613 144614 144615 144616 144617 144618 144619 144620 144621 144622 144623 144624 144625 144626 144627 | yymajor = YYNOCODE; }else if( yymx!=YYERRORSYMBOL ){ yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor); } } yypParser->yyerrcnt = 3; yyerrorhit = 1; if( yymajor==YYNOCODE ) break; yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax ** error routine and continue going as if nothing had happened. ** ** Applications can set this macro (for example inside %include) if ** they intend to abandon the parse upon the first syntax error seen. */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); break; #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** |
︙ | ︙ | |||
143338 143339 143340 143341 143342 143343 143344 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif } | | | | 144635 144636 144637 144638 144639 144640 144641 144642 144643 144644 144645 144646 144647 144648 144649 144650 144651 144652 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); if( yyendofinput ){ yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt = -1; #endif } break; #endif } }while( yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; char cDiv = '['; fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt); for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){ fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]); |
︙ | ︙ | |||
143518 143519 143520 143521 143522 143523 143524 | ** The code in this file implements a function that determines whether ** or not a given identifier is really an SQL keyword. The same thing ** might be implemented more directly using a hand-written hash table. ** But by using this automatically generated code, the size of the code ** is substantially reduced. This is important for embedded applications ** on platforms with limited memory. */ | | | | | | | | | | | | | | | | | > | | | | | | | | < | | > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | | | | < | | > | 144815 144816 144817 144818 144819 144820 144821 144822 144823 144824 144825 144826 144827 144828 144829 144830 144831 144832 144833 144834 144835 144836 144837 144838 144839 144840 144841 144842 144843 144844 144845 144846 144847 144848 144849 144850 144851 144852 144853 144854 144855 144856 144857 144858 144859 144860 144861 144862 144863 144864 144865 144866 144867 144868 144869 144870 144871 144872 144873 144874 144875 144876 144877 144878 144879 144880 144881 144882 144883 144884 144885 144886 144887 144888 144889 144890 144891 144892 144893 144894 144895 144896 144897 144898 144899 144900 144901 144902 144903 144904 144905 144906 144907 144908 144909 144910 144911 144912 144913 144914 144915 144916 144917 144918 144919 144920 144921 144922 144923 144924 144925 144926 144927 144928 144929 144930 144931 144932 144933 144934 144935 144936 144937 144938 144939 144940 144941 144942 144943 144944 144945 144946 144947 144948 144949 144950 144951 144952 144953 144954 144955 144956 144957 | ** The code in this file implements a function that determines whether ** or not a given identifier is really an SQL keyword. The same thing ** might be implemented more directly using a hand-written hash table. ** But by using this automatically generated code, the size of the code ** is substantially reduced. This is important for embedded applications ** on platforms with limited memory. */ /* Hash score: 185 */ /* zKWText[] encodes 845 bytes of keyword text in 561 bytes */ /* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */ /* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */ /* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */ /* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */ /* BETWEENOTHINGLOBYCASCADELETECASECOLLATECREATECURRENT_DATE */ /* DETACHIMMEDIATEJOINSERTLIKEMATCHPLANALYZEPRAGMABORTVALUES */ /* VIRTUALIMITWHENOTNULLWHERENAMEAFTEREPLACEANDEFAULT */ /* AUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSSCURRENT_TIMESTAMP */ /* RIMARYDEFERREDISTINCTDORDERESTRICTDROPFAILFROMFULLIFISNULL */ /* RIGHTROLLBACKROWUNIONUSINGVACUUMVIEWINITIALLY */ static const char zKWText[560] = { 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H', 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G', 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A', 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F', 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N', 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I', 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E', 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E', 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T', 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q', 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S', 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A', 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E', 'B','E','T','W','E','E','N','O','T','H','I','N','G','L','O','B','Y','C', 'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L', 'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D', 'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E', 'J','O','I','N','S','E','R','T','L','I','K','E','M','A','T','C','H','P', 'L','A','N','A','L','Y','Z','E','P','R','A','G','M','A','B','O','R','T', 'V','A','L','U','E','S','V','I','R','T','U','A','L','I','M','I','T','W', 'H','E','N','O','T','N','U','L','L','W','H','E','R','E','N','A','M','E', 'A','F','T','E','R','E','P','L','A','C','E','A','N','D','E','F','A','U', 'L','T','A','U','T','O','I','N','C','R','E','M','E','N','T','C','A','S', 'T','C','O','L','U','M','N','C','O','M','M','I','T','C','O','N','F','L', 'I','C','T','C','R','O','S','S','C','U','R','R','E','N','T','_','T','I', 'M','E','S','T','A','M','P','R','I','M','A','R','Y','D','E','F','E','R', 'R','E','D','I','S','T','I','N','C','T','D','O','R','D','E','R','E','S', 'T','R','I','C','T','D','R','O','P','F','A','I','L','F','R','O','M','F', 'U','L','L','I','F','I','S','N','U','L','L','R','I','G','H','T','R','O', 'L','L','B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N', 'G','V','A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L', 'L','Y', }; /* aKWHash[i] is the hash value for the i-th keyword */ static const unsigned char aKWHash[127] = { 74, 108, 119, 72, 0, 45, 0, 0, 81, 0, 76, 61, 0, 42, 12, 77, 15, 0, 118, 84, 54, 116, 0, 19, 0, 0, 123, 0, 121, 111, 0, 22, 96, 0, 9, 0, 0, 68, 69, 0, 67, 6, 0, 48, 93, 105, 0, 120, 104, 0, 0, 44, 0, 106, 24, 0, 17, 0, 124, 53, 23, 0, 5, 62, 25, 99, 0, 0, 126, 112, 60, 125, 57, 28, 55, 0, 94, 0, 103, 26, 0, 102, 0, 0, 0, 98, 95, 100, 91, 115, 14, 39, 114, 0, 80, 0, 109, 92, 90, 32, 0, 122, 79, 117, 86, 46, 83, 0, 0, 97, 40, 59, 110, 0, 36, 0, 0, 29, 0, 89, 87, 88, 0, 20, 85, 0, 56, }; /* aKWNext[] forms the hash collision chain. If aKWHash[i]==0 ** then the i-th keyword has no more hash collisions. Otherwise, ** the next keyword with the same hash is aKWHash[i]-1. */ static const unsigned char aKWNext[126] = { 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50, 0, 43, 3, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 64, 0, 0, 65, 0, 41, 0, 38, 0, 0, 0, 0, 0, 49, 75, 0, 0, 30, 0, 58, 0, 0, 63, 31, 52, 16, 34, 10, 0, 0, 0, 0, 0, 0, 0, 11, 70, 78, 0, 8, 0, 18, 51, 0, 107, 101, 0, 113, 0, 73, 27, 37, 71, 82, 0, 35, 66, 0, 0, }; /* aKWLen[i] is the length (in bytes) of the i-th keyword */ static const unsigned char aKWLen[126] = { 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6, 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6, 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7, 6, 6, 5, 6, 5, 5, 9, 7, 7, 4, 2, 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 4, 5, 4, 7, 6, 5, 6, 7, 5, 4, 7, 3, 2, 4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8, 2, 2, 5, 8, 4, 4, 4, 4, 2, 6, 5, 8, 3, 5, 5, 6, 4, 9, 3, }; /* aKWOffset[i] is the index into zKWText[] of the start of ** the text for the i-th keyword. */ static const unsigned short int aKWOffset[126] = { 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33, 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81, 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192, 199, 204, 209, 212, 218, 221, 225, 234, 240, 246, 249, 251, 252, 256, 262, 266, 273, 279, 291, 297, 306, 308, 314, 318, 323, 325, 332, 337, 342, 348, 354, 359, 362, 362, 362, 365, 369, 372, 378, 382, 389, 391, 398, 400, 402, 411, 415, 421, 427, 435, 440, 440, 456, 463, 470, 471, 478, 479, 483, 491, 495, 499, 503, 507, 509, 515, 520, 528, 531, 536, 541, 547, 551, 556, }; /* aKWCode[i] is the parser symbol code for the i-th keyword */ static const unsigned char aKWCode[126] = { TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE, TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN, TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD, TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE, TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE, TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW, TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP, TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP, TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN, TK_NOTHING, TK_LIKE_KW, TK_BY, TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT, TK_LIKE_KW, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DO, TK_ORDER, TK_RESTRICT, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_IF, TK_ISNULL, TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL, }; /* Check to see if z[0..n-1] is a keyword. If it is, write the ** parser symbol code for that keyword into *pType. Always ** return the integer n (the length of the token). */ static int keywordCode(const char *z, int n, int *pType){ int i, j; const char *zKW; |
︙ | ︙ | |||
143725 143726 143727 143728 143729 143730 143731 | testcase( i==53 ); /* HAVING */ testcase( i==54 ); /* GROUP */ testcase( i==55 ); /* UPDATE */ testcase( i==56 ); /* BEGIN */ testcase( i==57 ); /* INNER */ testcase( i==58 ); /* RECURSIVE */ testcase( i==59 ); /* BETWEEN */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | 145024 145025 145026 145027 145028 145029 145030 145031 145032 145033 145034 145035 145036 145037 145038 145039 145040 145041 145042 145043 145044 145045 145046 145047 145048 145049 145050 145051 145052 145053 145054 145055 145056 145057 145058 145059 145060 145061 145062 145063 145064 145065 145066 145067 145068 145069 145070 145071 145072 145073 145074 145075 145076 145077 145078 145079 145080 145081 145082 145083 145084 145085 145086 145087 145088 145089 145090 145091 145092 145093 145094 145095 145096 145097 145098 145099 145100 145101 145102 145103 145104 145105 145106 145107 145108 145109 145110 145111 145112 145113 145114 145115 | testcase( i==53 ); /* HAVING */ testcase( i==54 ); /* GROUP */ testcase( i==55 ); /* UPDATE */ testcase( i==56 ); /* BEGIN */ testcase( i==57 ); /* INNER */ testcase( i==58 ); /* RECURSIVE */ testcase( i==59 ); /* BETWEEN */ testcase( i==60 ); /* NOTHING */ testcase( i==61 ); /* GLOB */ testcase( i==62 ); /* BY */ testcase( i==63 ); /* CASCADE */ testcase( i==64 ); /* ASC */ testcase( i==65 ); /* DELETE */ testcase( i==66 ); /* CASE */ testcase( i==67 ); /* COLLATE */ testcase( i==68 ); /* CREATE */ testcase( i==69 ); /* CURRENT_DATE */ testcase( i==70 ); /* DETACH */ testcase( i==71 ); /* IMMEDIATE */ testcase( i==72 ); /* JOIN */ testcase( i==73 ); /* INSERT */ testcase( i==74 ); /* LIKE */ testcase( i==75 ); /* MATCH */ testcase( i==76 ); /* PLAN */ testcase( i==77 ); /* ANALYZE */ testcase( i==78 ); /* PRAGMA */ testcase( i==79 ); /* ABORT */ testcase( i==80 ); /* VALUES */ testcase( i==81 ); /* VIRTUAL */ testcase( i==82 ); /* LIMIT */ testcase( i==83 ); /* WHEN */ testcase( i==84 ); /* NOTNULL */ testcase( i==85 ); /* NOT */ testcase( i==86 ); /* NO */ testcase( i==87 ); /* NULL */ testcase( i==88 ); /* WHERE */ testcase( i==89 ); /* RENAME */ testcase( i==90 ); /* AFTER */ testcase( i==91 ); /* REPLACE */ testcase( i==92 ); /* AND */ testcase( i==93 ); /* DEFAULT */ testcase( i==94 ); /* AUTOINCREMENT */ testcase( i==95 ); /* TO */ testcase( i==96 ); /* IN */ testcase( i==97 ); /* CAST */ testcase( i==98 ); /* COLUMN */ testcase( i==99 ); /* COMMIT */ testcase( i==100 ); /* CONFLICT */ testcase( i==101 ); /* CROSS */ testcase( i==102 ); /* CURRENT_TIMESTAMP */ testcase( i==103 ); /* CURRENT_TIME */ testcase( i==104 ); /* PRIMARY */ testcase( i==105 ); /* DEFERRED */ testcase( i==106 ); /* DISTINCT */ testcase( i==107 ); /* IS */ testcase( i==108 ); /* DO */ testcase( i==109 ); /* ORDER */ testcase( i==110 ); /* RESTRICT */ testcase( i==111 ); /* DROP */ testcase( i==112 ); /* FAIL */ testcase( i==113 ); /* FROM */ testcase( i==114 ); /* FULL */ testcase( i==115 ); /* IF */ testcase( i==116 ); /* ISNULL */ testcase( i==117 ); /* RIGHT */ testcase( i==118 ); /* ROLLBACK */ testcase( i==119 ); /* ROW */ testcase( i==120 ); /* UNION */ testcase( i==121 ); /* USING */ testcase( i==122 ); /* VACUUM */ testcase( i==123 ); /* VIEW */ testcase( i==124 ); /* INITIALLY */ testcase( i==125 ); /* ALL */ *pType = aKWCode[i]; break; } } return n; } SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){ int id = TK_ID; keywordCode((char*)z, n, &id); return id; } #define SQLITE_N_KEYWORD 126 /************** End of keywordhash.h *****************************************/ /************** Continuing where we left off in tokenize.c *******************/ /* ** If X is a character that can be used in an identifier then |
︙ | ︙ | |||
144157 144158 144159 144160 144161 144162 144163 | } pParse->rc = SQLITE_OK; pParse->zTail = zSql; assert( pzErrMsg!=0 ); /* sqlite3ParserTrace(stdout, "parser: "); */ #ifdef sqlite3Parser_ENGINEALWAYSONSTACK pEngine = &sEngine; | | | | 145458 145459 145460 145461 145462 145463 145464 145465 145466 145467 145468 145469 145470 145471 145472 145473 145474 | } pParse->rc = SQLITE_OK; pParse->zTail = zSql; assert( pzErrMsg!=0 ); /* sqlite3ParserTrace(stdout, "parser: "); */ #ifdef sqlite3Parser_ENGINEALWAYSONSTACK pEngine = &sEngine; sqlite3ParserInit(pEngine, pParse); #else pEngine = sqlite3ParserAlloc(sqlite3Malloc, pParse); if( pEngine==0 ){ sqlite3OomFault(db); return SQLITE_NOMEM_BKPT; } #endif assert( pParse->pNewTable==0 ); assert( pParse->pNewTrigger==0 ); |
︙ | ︙ | |||
144203 144204 144205 144206 144207 144208 144209 | sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql); break; } zSql += n; }else{ pParse->sLastToken.z = zSql; pParse->sLastToken.n = n; | | | 145504 145505 145506 145507 145508 145509 145510 145511 145512 145513 145514 145515 145516 145517 145518 | sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql); break; } zSql += n; }else{ pParse->sLastToken.z = zSql; pParse->sLastToken.n = n; sqlite3Parser(pEngine, tokenType, pParse->sLastToken); lastTokenParsed = tokenType; zSql += n; if( pParse->rc!=SQLITE_OK || db->mallocFailed ) break; } } assert( nErr==0 ); pParse->zTail = zSql; |
︙ | ︙ | |||
145310 145311 145312 145313 145314 145315 145316 145317 145318 145319 145320 145321 145322 145323 | } case SQLITE_CONFIG_STMTJRNL_SPILL: { sqlite3GlobalConfig.nStmtSpill = va_arg(ap, int); break; } default: { rc = SQLITE_ERROR; break; } } va_end(ap); return rc; | > > > > > > > > > > > | 146611 146612 146613 146614 146615 146616 146617 146618 146619 146620 146621 146622 146623 146624 146625 146626 146627 146628 146629 146630 146631 146632 146633 146634 146635 | } case SQLITE_CONFIG_STMTJRNL_SPILL: { sqlite3GlobalConfig.nStmtSpill = va_arg(ap, int); break; } #ifdef SQLITE_ENABLE_SORTER_REFERENCES case SQLITE_CONFIG_SORTERREF_SIZE: { int iVal = va_arg(ap, int); if( iVal<0 ){ iVal = SQLITE_DEFAULT_SORTERREF_SIZE; } sqlite3GlobalConfig.szSorterRef = (u32)iVal; break; } #endif /* SQLITE_ENABLE_SORTER_REFERENCES */ default: { rc = SQLITE_ERROR; break; } } va_end(ap); return rc; |
︙ | ︙ | |||
146144 146145 146146 146147 146148 146149 146150 146151 146152 | } /* ** This routine implements a busy callback that sleeps and tries ** again until a timeout value is reached. The timeout value is ** an integer number of milliseconds passed in as the first ** argument. */ static int sqliteDefaultBusyCallback( | > > > | | > > > | > > > > > > > > > > > > > | | > > | > | | > > | | > > > > > > > > | > | 147456 147457 147458 147459 147460 147461 147462 147463 147464 147465 147466 147467 147468 147469 147470 147471 147472 147473 147474 147475 147476 147477 147478 147479 147480 147481 147482 147483 147484 147485 147486 147487 147488 147489 147490 147491 147492 147493 147494 147495 147496 147497 147498 147499 147500 147501 147502 147503 147504 147505 147506 147507 147508 147509 147510 147511 147512 147513 147514 147515 147516 147517 147518 147519 147520 147521 147522 147523 147524 147525 147526 147527 147528 147529 147530 147531 147532 147533 147534 147535 147536 147537 147538 147539 147540 147541 147542 147543 147544 147545 147546 147547 147548 147549 147550 147551 147552 147553 | } /* ** This routine implements a busy callback that sleeps and tries ** again until a timeout value is reached. The timeout value is ** an integer number of milliseconds passed in as the first ** argument. ** ** Return non-zero to retry the lock. Return zero to stop trying ** and cause SQLite to return SQLITE_BUSY. */ static int sqliteDefaultBusyCallback( void *ptr, /* Database connection */ int count, /* Number of times table has been busy */ sqlite3_file *pFile /* The file on which the lock occurred */ ){ #if SQLITE_OS_WIN || HAVE_USLEEP /* This case is for systems that have support for sleeping for fractions of ** a second. Examples: All windows systems, unix systems with usleep() */ static const u8 delays[] = { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; static const u8 totals[] = { 0, 1, 3, 8, 18, 33, 53, 78, 103, 128, 178, 228 }; # define NDELAY ArraySize(delays) sqlite3 *db = (sqlite3 *)ptr; int tmout = db->busyTimeout; int delay, prior; #ifdef SQLITE_ENABLE_SETLK_TIMEOUT if( sqlite3OsFileControl(pFile,SQLITE_FCNTL_LOCK_TIMEOUT,&tmout)==SQLITE_OK ){ if( count ){ tmout = 0; sqlite3OsFileControl(pFile, SQLITE_FCNTL_LOCK_TIMEOUT, &tmout); return 0; }else{ return 1; } } #else UNUSED_PARAMETER(pFile); #endif assert( count>=0 ); if( count < NDELAY ){ delay = delays[count]; prior = totals[count]; }else{ delay = delays[NDELAY-1]; prior = totals[NDELAY-1] + delay*(count-(NDELAY-1)); } if( prior + delay > tmout ){ delay = tmout - prior; if( delay<=0 ) return 0; } sqlite3OsSleep(db->pVfs, delay*1000); return 1; #else /* This case for unix systems that lack usleep() support. Sleeping ** must be done in increments of whole seconds */ sqlite3 *db = (sqlite3 *)ptr; int tmout = ((sqlite3 *)ptr)->busyTimeout; UNUSED_PARAMETER(pFile); if( (count+1)*1000 > tmout ){ return 0; } sqlite3OsSleep(db->pVfs, 1000000); return 1; #endif } /* ** Invoke the given busy handler. ** ** This routine is called when an operation failed to acquire a ** lock on VFS file pFile. ** ** If this routine returns non-zero, the lock is retried. If it ** returns 0, the operation aborts with an SQLITE_BUSY error. */ SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler *p, sqlite3_file *pFile){ int rc; if( p->xBusyHandler==0 || p->nBusy<0 ) return 0; if( p->bExtraFileArg ){ /* Add an extra parameter with the pFile pointer to the end of the ** callback argument list */ int (*xTra)(void*,int,sqlite3_file*); xTra = (int(*)(void*,int,sqlite3_file*))p->xBusyHandler; rc = xTra(p->pBusyArg, p->nBusy, pFile); }else{ /* Legacy style busy handler callback */ rc = p->xBusyHandler(p->pBusyArg, p->nBusy); } if( rc==0 ){ p->nBusy = -1; }else{ p->nBusy++; } return rc; } |
︙ | ︙ | |||
146216 146217 146218 146219 146220 146221 146222 | int (*xBusy)(void*,int), void *pArg ){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; #endif sqlite3_mutex_enter(db->mutex); | | | > | 147561 147562 147563 147564 147565 147566 147567 147568 147569 147570 147571 147572 147573 147574 147575 147576 147577 147578 | int (*xBusy)(void*,int), void *pArg ){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; #endif sqlite3_mutex_enter(db->mutex); db->busyHandler.xBusyHandler = xBusy; db->busyHandler.pBusyArg = pArg; db->busyHandler.nBusy = 0; db->busyHandler.bExtraFileArg = 0; db->busyTimeout = 0; sqlite3_mutex_leave(db->mutex); return SQLITE_OK; } #ifndef SQLITE_OMIT_PROGRESS_CALLBACK /* |
︙ | ︙ | |||
146266 146267 146268 146269 146270 146271 146272 | ** specified number of milliseconds before returning 0. */ SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; #endif if( ms>0 ){ | | > > | 147612 147613 147614 147615 147616 147617 147618 147619 147620 147621 147622 147623 147624 147625 147626 147627 147628 147629 | ** specified number of milliseconds before returning 0. */ SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){ #ifdef SQLITE_ENABLE_API_ARMOR if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; #endif if( ms>0 ){ sqlite3_busy_handler(db, (int(*)(void*,int))sqliteDefaultBusyCallback, (void*)db); db->busyTimeout = ms; db->busyHandler.bExtraFileArg = 1; }else{ sqlite3_busy_handler(db, 0, 0); } return SQLITE_OK; } /* |
︙ | ︙ | |||
148260 148261 148262 148263 148264 148265 148266 | rc = SQLITE_OK; }else if( op==SQLITE_FCNTL_VFS_POINTER ){ *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager); rc = SQLITE_OK; }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){ *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager); rc = SQLITE_OK; | | < < | 149608 149609 149610 149611 149612 149613 149614 149615 149616 149617 149618 149619 149620 149621 149622 149623 | rc = SQLITE_OK; }else if( op==SQLITE_FCNTL_VFS_POINTER ){ *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager); rc = SQLITE_OK; }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){ *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager); rc = SQLITE_OK; }else{ rc = sqlite3OsFileControl(fd, op, pArg); } sqlite3BtreeLeave(pBtree); } sqlite3_mutex_leave(db->mutex); return rc; } |
︙ | ︙ | |||
175839 175840 175841 175842 175843 175844 175845 | while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){ int bKey = sqlite3_column_int(pXInfo, 5); if( bKey ){ int iCid = sqlite3_column_int(pXInfo, 1); int bDesc = sqlite3_column_int(pXInfo, 3); const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4); | | | 177185 177186 177187 177188 177189 177190 177191 177192 177193 177194 177195 177196 177197 177198 177199 | while( p->rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pXInfo) ){ int bKey = sqlite3_column_int(pXInfo, 5); if( bKey ){ int iCid = sqlite3_column_int(pXInfo, 1); int bDesc = sqlite3_column_int(pXInfo, 3); const char *zCollate = (const char*)sqlite3_column_text(pXInfo, 4); zCols = rbuMPrintf(p, "%z%sc%d %s COLLATE %Q", zCols, zComma, iCid, pIter->azTblType[iCid], zCollate ); zPk = rbuMPrintf(p, "%z%sc%d%s", zPk, zComma, iCid, bDesc?" DESC":""); zComma = ", "; } } zCols = rbuMPrintf(p, "%z, id INTEGER", zCols); |
︙ | ︙ | |||
175900 175901 175902 175903 175904 175905 175906 | ); if( pIter->eType==RBU_PK_IPK && pIter->abTblPk[iCol] ){ /* If the target table column is an "INTEGER PRIMARY KEY", add ** "PRIMARY KEY" to the imposter table column declaration. */ zPk = "PRIMARY KEY "; } | | | 177246 177247 177248 177249 177250 177251 177252 177253 177254 177255 177256 177257 177258 177259 177260 | ); if( pIter->eType==RBU_PK_IPK && pIter->abTblPk[iCol] ){ /* If the target table column is an "INTEGER PRIMARY KEY", add ** "PRIMARY KEY" to the imposter table column declaration. */ zPk = "PRIMARY KEY "; } zSql = rbuMPrintf(p, "%z%s\"%w\" %s %sCOLLATE %Q%s", zSql, zComma, zCol, pIter->azTblType[iCol], zPk, zColl, (pIter->abNotNull[iCol] ? " NOT NULL" : "") ); zComma = ", "; } if( pIter->eType==RBU_PK_WITHOUT_ROWID ){ |
︙ | ︙ | |||
179334 179335 179336 179337 179338 179339 179340 | pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1); /* If connected to a ZIPVFS backend, override the page size and ** offset with actual values obtained from ZIPVFS. */ fd = sqlite3PagerFile(pPager); x[0] = pCsr->iPageno; | | | 180680 180681 180682 180683 180684 180685 180686 180687 180688 180689 180690 180691 180692 180693 180694 | pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1); /* If connected to a ZIPVFS backend, override the page size and ** offset with actual values obtained from ZIPVFS. */ fd = sqlite3PagerFile(pPager); x[0] = pCsr->iPageno; if( sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){ pCsr->iOffset = x[0]; pCsr->szPage = (int)x[1]; } } /* ** Move a statvfs cursor to the next entry in the file. |
︙ | ︙ | |||
180100 180101 180102 180103 180104 180105 180106 | /* ** An object of this type is used internally as an abstraction for ** input data. Input data may be supplied either as a single large buffer ** (e.g. sqlite3changeset_start()) or using a stream function (e.g. ** sqlite3changeset_start_strm()). */ struct SessionInput { | | | 181446 181447 181448 181449 181450 181451 181452 181453 181454 181455 181456 181457 181458 181459 181460 | /* ** An object of this type is used internally as an abstraction for ** input data. Input data may be supplied either as a single large buffer ** (e.g. sqlite3changeset_start()) or using a stream function (e.g. ** sqlite3changeset_start_strm()). */ struct SessionInput { int bNoDiscard; /* If true, do not discard in InputBuffer() */ int iCurrent; /* Offset in aData[] of current change */ int iNext; /* Offset in aData[] of next change */ u8 *aData; /* Pointer to buffer containing changeset */ int nData; /* Number of bytes in aData */ SessionBuffer buf; /* Current read buffer */ int (*xInput)(void*, void*, int*); /* Input stream call (or NULL) */ |
︙ | ︙ | |||
180264 180265 180266 180267 180268 180269 180270 | ** ** As in the changeset format, each field of the single record that is part ** of a patchset change is associated with the correspondingly positioned ** table column, counting from left to right within the CREATE TABLE ** statement. ** ** For a DELETE change, all fields within the record except those associated | | | | 181610 181611 181612 181613 181614 181615 181616 181617 181618 181619 181620 181621 181622 181623 181624 181625 | ** ** As in the changeset format, each field of the single record that is part ** of a patchset change is associated with the correspondingly positioned ** table column, counting from left to right within the CREATE TABLE ** statement. ** ** For a DELETE change, all fields within the record except those associated ** with PRIMARY KEY columns are omitted. The PRIMARY KEY fields contain the ** values identifying the row to delete. ** ** For an UPDATE change, all fields except those associated with PRIMARY KEY ** columns and columns that are modified by the UPDATE are set to "undefined". ** PRIMARY KEY fields contain the values identifying the table row to update, ** and fields associated with modified columns contain the new column values. ** ** The records associated with INSERT changes are in the same format as for |
︙ | ︙ | |||
180548 180549 180550 180551 180552 180553 180554 | ** The buffer that the argument points to contains a serialized SQL value. ** Return the number of bytes of space occupied by the value (including ** the type byte). */ static int sessionSerialLen(u8 *a){ int e = *a; int n; | | | 181894 181895 181896 181897 181898 181899 181900 181901 181902 181903 181904 181905 181906 181907 181908 | ** The buffer that the argument points to contains a serialized SQL value. ** Return the number of bytes of space occupied by the value (including ** the type byte). */ static int sessionSerialLen(u8 *a){ int e = *a; int n; if( e==0 || e==0xFF ) return 1; if( e==SQLITE_NULL ) return 1; if( e==SQLITE_INTEGER || e==SQLITE_FLOAT ) return 9; return sessionVarintGet(&a[1], &n) + 1 + n; } /* ** Based on the primary key values stored in change aRecord, calculate a |
︙ | ︙ | |||
180628 180629 180630 180631 180632 180633 180634 | int iCol; /* Used to iterate through table columns */ for(iCol=0; iCol<pTab->nCol; iCol++){ if( pTab->abPK[iCol] ){ int n1 = sessionSerialLen(a1); int n2 = sessionSerialLen(a2); | | | 181974 181975 181976 181977 181978 181979 181980 181981 181982 181983 181984 181985 181986 181987 181988 | int iCol; /* Used to iterate through table columns */ for(iCol=0; iCol<pTab->nCol; iCol++){ if( pTab->abPK[iCol] ){ int n1 = sessionSerialLen(a1); int n2 = sessionSerialLen(a2); if( n1!=n2 || memcmp(a1, a2, n1) ){ return 0; } a1 += n1; a2 += n2; }else{ if( bLeftPkOnly==0 ) a1 += sessionSerialLen(a1); if( bRightPkOnly==0 ) a2 += sessionSerialLen(a2); |
︙ | ︙ | |||
180871 180872 180873 180874 180875 180876 180877 | a += sessionVarintGet(a, &n); if( sqlite3_value_bytes(pVal)!=n ) return 0; if( eType==SQLITE_TEXT ){ z = sqlite3_value_text(pVal); }else{ z = sqlite3_value_blob(pVal); } | | | 182217 182218 182219 182220 182221 182222 182223 182224 182225 182226 182227 182228 182229 182230 182231 | a += sessionVarintGet(a, &n); if( sqlite3_value_bytes(pVal)!=n ) return 0; if( eType==SQLITE_TEXT ){ z = sqlite3_value_text(pVal); }else{ z = sqlite3_value_blob(pVal); } if( n>0 && memcmp(a, z, n) ) return 0; a += n; } } } return 1; } |
︙ | ︙ | |||
182215 182216 182217 182218 182219 182220 182221 182222 182223 182224 182225 182226 182227 182228 | int nSql = -1; if( 0==sqlite3_stricmp("sqlite_stat1", zTab) ){ zSql = sqlite3_mprintf( "SELECT tbl, ?2, stat FROM %Q.sqlite_stat1 WHERE tbl IS ?1 AND " "idx IS (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", zDb ); }else{ int i; const char *zSep = ""; SessionBuffer buf = {0, 0, 0}; sessionAppendStr(&buf, "SELECT * FROM ", &rc); sessionAppendIdent(&buf, zDb, &rc); | > | 183561 183562 183563 183564 183565 183566 183567 183568 183569 183570 183571 183572 183573 183574 183575 | int nSql = -1; if( 0==sqlite3_stricmp("sqlite_stat1", zTab) ){ zSql = sqlite3_mprintf( "SELECT tbl, ?2, stat FROM %Q.sqlite_stat1 WHERE tbl IS ?1 AND " "idx IS (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", zDb ); if( zSql==0 ) rc = SQLITE_NOMEM; }else{ int i; const char *zSep = ""; SessionBuffer buf = {0, 0, 0}; sessionAppendStr(&buf, "SELECT * FROM ", &rc); sessionAppendIdent(&buf, zDb, &rc); |
︙ | ︙ | |||
182624 182625 182626 182627 182628 182629 182630 | } /* ** If the SessionInput object passed as the only argument is a streaming ** object and the buffer is full, discard some data to free up space. */ static void sessionDiscardData(SessionInput *pIn){ | | | 183971 183972 183973 183974 183975 183976 183977 183978 183979 183980 183981 183982 183983 183984 183985 | } /* ** If the SessionInput object passed as the only argument is a streaming ** object and the buffer is full, discard some data to free up space. */ static void sessionDiscardData(SessionInput *pIn){ if( pIn->xInput && pIn->iNext>=SESSIONS_STRM_CHUNK_SIZE ){ int nMove = pIn->buf.nBuf - pIn->iNext; assert( nMove>=0 ); if( nMove>0 ){ memmove(pIn->buf.aBuf, &pIn->buf.aBuf[pIn->iNext], nMove); } pIn->buf.nBuf -= pIn->iNext; pIn->iNext = 0; |
︙ | ︙ | |||
182950 182951 182952 182953 182954 182955 182956 | ** successfully advanced to the next change in the changeset, an SQLite ** error code if an error occurs, or SQLITE_DONE if there are no further ** changes in the changeset. */ static int sessionChangesetNext( sqlite3_changeset_iter *p, /* Changeset iterator */ u8 **paRec, /* If non-NULL, store record pointer here */ | | > | 184297 184298 184299 184300 184301 184302 184303 184304 184305 184306 184307 184308 184309 184310 184311 184312 | ** successfully advanced to the next change in the changeset, an SQLite ** error code if an error occurs, or SQLITE_DONE if there are no further ** changes in the changeset. */ static int sessionChangesetNext( sqlite3_changeset_iter *p, /* Changeset iterator */ u8 **paRec, /* If non-NULL, store record pointer here */ int *pnRec, /* If non-NULL, store size of record here */ int *pbNew /* If non-NULL, true if new table */ ){ int i; u8 op; assert( (paRec==0 && pnRec==0) || (paRec && pnRec) ); /* If the iterator is in the error-state, return immediately. */ |
︙ | ︙ | |||
182985 182986 182987 182988 182989 182990 182991 182992 182993 182994 182995 182996 182997 182998 | } sessionDiscardData(&p->in); p->in.iCurrent = p->in.iNext; op = p->in.aData[p->in.iNext++]; while( op=='T' || op=='P' ){ p->bPatchset = (op=='P'); if( sessionChangesetReadTblhdr(p) ) return p->rc; if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc; p->in.iCurrent = p->in.iNext; if( p->in.iNext>=p->in.nData ) return SQLITE_DONE; op = p->in.aData[p->in.iNext++]; } | > | 184333 184334 184335 184336 184337 184338 184339 184340 184341 184342 184343 184344 184345 184346 184347 | } sessionDiscardData(&p->in); p->in.iCurrent = p->in.iNext; op = p->in.aData[p->in.iNext++]; while( op=='T' || op=='P' ){ if( pbNew ) *pbNew = 1; p->bPatchset = (op=='P'); if( sessionChangesetReadTblhdr(p) ) return p->rc; if( (p->rc = sessionInputBuffer(&p->in, 2)) ) return p->rc; p->in.iCurrent = p->in.iNext; if( p->in.iNext>=p->in.nData ) return SQLITE_DONE; op = p->in.aData[p->in.iNext++]; } |
︙ | ︙ | |||
183063 183064 183065 183066 183067 183068 183069 | ** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE ** or SQLITE_CORRUPT. ** ** This function may not be called on iterators passed to a conflict handler ** callback by changeset_apply(). */ SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *p){ | | | 184412 184413 184414 184415 184416 184417 184418 184419 184420 184421 184422 184423 184424 184425 184426 | ** change in the changeset. This function may return SQLITE_ROW, SQLITE_DONE ** or SQLITE_CORRUPT. ** ** This function may not be called on iterators passed to a conflict handler ** callback by changeset_apply(). */ SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *p){ return sessionChangesetNext(p, 0, 0, 0); } /* ** The following function extracts information on the current change ** from a changeset iterator. It may only be called after changeset_next() ** has returned SQLITE_ROW. */ |
︙ | ︙ | |||
183442 183443 183444 183445 183446 183447 183448 183449 183450 183451 183452 183453 183454 183455 | sqlite3_stmt *pSelect; /* SELECT statement */ int nCol; /* Size of azCol[] and abPK[] arrays */ const char **azCol; /* Array of column names */ u8 *abPK; /* Boolean array - true if column is in PK */ int bStat1; /* True if table is sqlite_stat1 */ int bDeferConstraints; /* True to defer constraints */ SessionBuffer constraints; /* Deferred constraints are stored here */ }; /* ** Formulate a statement to DELETE a row from database db. Assuming a table ** structure like this: ** ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c)); | > > | 184791 184792 184793 184794 184795 184796 184797 184798 184799 184800 184801 184802 184803 184804 184805 184806 | sqlite3_stmt *pSelect; /* SELECT statement */ int nCol; /* Size of azCol[] and abPK[] arrays */ const char **azCol; /* Array of column names */ u8 *abPK; /* Boolean array - true if column is in PK */ int bStat1; /* True if table is sqlite_stat1 */ int bDeferConstraints; /* True to defer constraints */ SessionBuffer constraints; /* Deferred constraints are stored here */ SessionBuffer rebase; /* Rebase information (if any) here */ int bRebaseStarted; /* If table header is already in rebase */ }; /* ** Formulate a statement to DELETE a row from database db. Assuming a table ** structure like this: ** ** CREATE TABLE x(a, b, c, d, PRIMARY KEY(a, c)); |
︙ | ︙ | |||
183708 183709 183710 183711 183712 183713 183714 | if( rc==SQLITE_OK ){ rc = sessionPrepare(db, &p->pDelete, "DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS " "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END " "AND (?4 OR stat IS ?3)" ); } | < | 185059 185060 185061 185062 185063 185064 185065 185066 185067 185068 185069 185070 185071 185072 | if( rc==SQLITE_OK ){ rc = sessionPrepare(db, &p->pDelete, "DELETE FROM main.sqlite_stat1 WHERE tbl=?1 AND idx IS " "CASE WHEN length(?2)=0 AND typeof(?2)='blob' THEN NULL ELSE ?2 END " "AND (?4 OR stat IS ?3)" ); } return rc; } /* ** A wrapper around sqlite3_bind_value() that detects an extra problem. ** See comments in the body of this function for details. */ |
︙ | ︙ | |||
183822 183823 183824 183825 183826 183827 183828 183829 183830 183831 183832 183833 183834 183835 | if( rc==SQLITE_OK ){ rc = sqlite3_step(pSelect); if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect); } return rc; } /* ** Invoke the conflict handler for the change that the changeset iterator ** currently points to. ** ** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT. ** If argument pbReplace is NULL, then the type of conflict handler invoked | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 185172 185173 185174 185175 185176 185177 185178 185179 185180 185181 185182 185183 185184 185185 185186 185187 185188 185189 185190 185191 185192 185193 185194 185195 185196 185197 185198 185199 185200 185201 185202 185203 185204 185205 185206 185207 185208 185209 185210 185211 185212 185213 185214 185215 185216 185217 185218 185219 185220 185221 185222 185223 185224 185225 185226 185227 185228 185229 185230 185231 185232 185233 | if( rc==SQLITE_OK ){ rc = sqlite3_step(pSelect); if( rc!=SQLITE_ROW ) rc = sqlite3_reset(pSelect); } return rc; } /* ** This function is called from within sqlite3changset_apply_v2() when ** a conflict is encountered and resolved using conflict resolution ** mode eType (either SQLITE_CHANGESET_OMIT or SQLITE_CHANGESET_REPLACE).. ** It adds a conflict resolution record to the buffer in ** SessionApplyCtx.rebase, which will eventually be returned to the caller ** of apply_v2() as the "rebase" buffer. ** ** Return SQLITE_OK if successful, or an SQLite error code otherwise. */ static int sessionRebaseAdd( SessionApplyCtx *p, /* Apply context */ int eType, /* Conflict resolution (OMIT or REPLACE) */ sqlite3_changeset_iter *pIter /* Iterator pointing at current change */ ){ int rc = SQLITE_OK; int i; int eOp = pIter->op; if( p->bRebaseStarted==0 ){ /* Append a table-header to the rebase buffer */ const char *zTab = pIter->zTab; sessionAppendByte(&p->rebase, 'T', &rc); sessionAppendVarint(&p->rebase, p->nCol, &rc); sessionAppendBlob(&p->rebase, p->abPK, p->nCol, &rc); sessionAppendBlob(&p->rebase, (u8*)zTab, (int)strlen(zTab)+1, &rc); p->bRebaseStarted = 1; } assert( eType==SQLITE_CHANGESET_REPLACE||eType==SQLITE_CHANGESET_OMIT ); assert( eOp==SQLITE_DELETE || eOp==SQLITE_INSERT || eOp==SQLITE_UPDATE ); sessionAppendByte(&p->rebase, (eOp==SQLITE_DELETE ? SQLITE_DELETE : SQLITE_INSERT), &rc ); sessionAppendByte(&p->rebase, (eType==SQLITE_CHANGESET_REPLACE), &rc); for(i=0; i<p->nCol; i++){ sqlite3_value *pVal = 0; if( eOp==SQLITE_DELETE || (eOp==SQLITE_UPDATE && p->abPK[i]) ){ sqlite3changeset_old(pIter, i, &pVal); }else{ sqlite3changeset_new(pIter, i, &pVal); } sessionAppendValue(&p->rebase, pVal, &rc); } return rc; } /* ** Invoke the conflict handler for the change that the changeset iterator ** currently points to. ** ** Argument eType must be either CHANGESET_DATA or CHANGESET_CONFLICT. ** If argument pbReplace is NULL, then the type of conflict handler invoked |
︙ | ︙ | |||
183898 183899 183900 183901 183902 183903 183904 | }else if( rc==SQLITE_OK ){ if( p->bDeferConstraints && eType==SQLITE_CHANGESET_CONFLICT ){ /* Instead of invoking the conflict handler, append the change blob ** to the SessionApplyCtx.constraints buffer. */ u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent]; int nBlob = pIter->in.iNext - pIter->in.iCurrent; sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc); | | | 185296 185297 185298 185299 185300 185301 185302 185303 185304 185305 185306 185307 185308 185309 185310 | }else if( rc==SQLITE_OK ){ if( p->bDeferConstraints && eType==SQLITE_CHANGESET_CONFLICT ){ /* Instead of invoking the conflict handler, append the change blob ** to the SessionApplyCtx.constraints buffer. */ u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent]; int nBlob = pIter->in.iNext - pIter->in.iCurrent; sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc); return SQLITE_OK; }else{ /* No other row with the new.* primary key. */ res = xConflict(pCtx, eType+1, pIter); if( res==SQLITE_CHANGESET_REPLACE ) rc = SQLITE_MISUSE; } } |
︙ | ︙ | |||
183924 183925 183926 183927 183928 183929 183930 183931 183932 183933 183934 183935 183936 183937 | rc = SQLITE_ABORT; break; default: rc = SQLITE_MISUSE; break; } } return rc; } /* ** Attempt to apply the change that the iterator passed as the first argument | > > > | 185322 185323 185324 185325 185326 185327 185328 185329 185330 185331 185332 185333 185334 185335 185336 185337 185338 | rc = SQLITE_ABORT; break; default: rc = SQLITE_MISUSE; break; } if( rc==SQLITE_OK ){ rc = sessionRebaseAdd(p, res, pIter); } } return rc; } /* ** Attempt to apply the change that the iterator passed as the first argument |
︙ | ︙ | |||
184099 184100 184101 184102 184103 184104 184105 | void *pCtx /* First argument passed to xConflict */ ){ int bReplace = 0; int bRetry = 0; int rc; rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry); | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 185500 185501 185502 185503 185504 185505 185506 185507 185508 185509 185510 185511 185512 185513 185514 185515 185516 185517 185518 185519 185520 185521 185522 185523 185524 185525 185526 185527 185528 185529 185530 185531 185532 185533 185534 185535 185536 185537 185538 185539 185540 185541 185542 185543 185544 185545 185546 185547 185548 185549 | void *pCtx /* First argument passed to xConflict */ ){ int bReplace = 0; int bRetry = 0; int rc; rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, &bReplace, &bRetry); if( rc==SQLITE_OK ){ /* If the bRetry flag is set, the change has not been applied due to an ** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and ** a row with the correct PK is present in the db, but one or more other ** fields do not contain the expected values) and the conflict handler ** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation, ** but pass NULL as the final argument so that sessionApplyOneOp() ignores ** the SQLITE_CHANGESET_DATA problem. */ if( bRetry ){ assert( pIter->op==SQLITE_UPDATE || pIter->op==SQLITE_DELETE ); rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0); } /* If the bReplace flag is set, the change is an INSERT that has not ** been performed because the database already contains a row with the ** specified primary key and the conflict handler returned ** SQLITE_CHANGESET_REPLACE. In this case remove the conflicting row ** before reattempting the INSERT. */ else if( bReplace ){ assert( pIter->op==SQLITE_INSERT ); rc = sqlite3_exec(db, "SAVEPOINT replace_op", 0, 0, 0); if( rc==SQLITE_OK ){ rc = sessionBindRow(pIter, sqlite3changeset_new, pApply->nCol, pApply->abPK, pApply->pDelete); sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1); } if( rc==SQLITE_OK ){ sqlite3_step(pApply->pDelete); rc = sqlite3_reset(pApply->pDelete); } if( rc==SQLITE_OK ){ rc = sessionApplyOneOp(pIter, pApply, xConflict, pCtx, 0, 0); } if( rc==SQLITE_OK ){ rc = sqlite3_exec(db, "RELEASE replace_op", 0, 0, 0); } } } return rc; } /* |
︙ | ︙ | |||
184210 184211 184212 184213 184214 184215 184216 | const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of fifth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), | | > > | > | > | 185611 185612 185613 185614 185615 185616 185617 185618 185619 185620 185621 185622 185623 185624 185625 185626 185627 185628 185629 185630 185631 185632 185633 185634 185635 185636 185637 185638 185639 185640 185641 185642 185643 | const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of fifth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx, /* First argument passed to xConflict */ void **ppRebase, int *pnRebase, /* OUT: Rebase information */ int flags /* SESSION_APPLY_XXX flags */ ){ int schemaMismatch = 0; int rc = SQLITE_OK; /* Return code */ const char *zTab = 0; /* Name of current table */ int nTab = 0; /* Result of sqlite3Strlen30(zTab) */ SessionApplyCtx sApply; /* changeset_apply() context object */ int bPatchset; assert( xConflict!=0 ); pIter->in.bNoDiscard = 1; memset(&sApply, 0, sizeof(sApply)); sqlite3_mutex_enter(sqlite3_db_mutex(db)); if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){ rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0); } if( rc==SQLITE_OK ){ rc = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 1", 0, 0, 0); } while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter) ){ int nCol; int op; const char *zNew; |
︙ | ︙ | |||
184248 184249 184250 184251 184252 184253 184254 | if( rc!=SQLITE_OK ) break; sqlite3_free((char*)sApply.azCol); /* cast works around VC++ bug */ sqlite3_finalize(sApply.pDelete); sqlite3_finalize(sApply.pUpdate); sqlite3_finalize(sApply.pInsert); sqlite3_finalize(sApply.pSelect); | < > > > > > > > > > > | 185653 185654 185655 185656 185657 185658 185659 185660 185661 185662 185663 185664 185665 185666 185667 185668 185669 185670 185671 185672 185673 185674 185675 185676 185677 185678 | if( rc!=SQLITE_OK ) break; sqlite3_free((char*)sApply.azCol); /* cast works around VC++ bug */ sqlite3_finalize(sApply.pDelete); sqlite3_finalize(sApply.pUpdate); sqlite3_finalize(sApply.pInsert); sqlite3_finalize(sApply.pSelect); sApply.db = db; sApply.pDelete = 0; sApply.pUpdate = 0; sApply.pInsert = 0; sApply.pSelect = 0; sApply.nCol = 0; sApply.azCol = 0; sApply.abPK = 0; sApply.bStat1 = 0; sApply.bDeferConstraints = 1; sApply.bRebaseStarted = 0; memset(&sApply.constraints, 0, sizeof(SessionBuffer)); /* If an xFilter() callback was specified, invoke it now. If the ** xFilter callback returns zero, skip this table. If it returns ** non-zero, proceed. */ schemaMismatch = (xFilter && (0==xFilter(pCtx, zNew))); if( schemaMismatch ){ zTab = sqlite3_mprintf("%s", zNew); |
︙ | ︙ | |||
184353 184354 184355 184356 184357 184358 184359 | if( res!=SQLITE_CHANGESET_OMIT ){ rc = SQLITE_CONSTRAINT; } } } sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0); | > | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 185767 185768 185769 185770 185771 185772 185773 185774 185775 185776 185777 185778 185779 185780 185781 185782 185783 185784 185785 185786 185787 185788 185789 185790 185791 185792 185793 185794 185795 185796 185797 185798 185799 185800 185801 185802 185803 185804 185805 185806 185807 185808 185809 185810 185811 185812 185813 185814 185815 185816 185817 185818 185819 185820 185821 185822 185823 185824 185825 185826 185827 185828 185829 185830 185831 185832 185833 185834 185835 | if( res!=SQLITE_CHANGESET_OMIT ){ rc = SQLITE_CONSTRAINT; } } } sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0); if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){ if( rc==SQLITE_OK ){ rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0); }else{ sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0); sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0); } } if( rc==SQLITE_OK && bPatchset==0 && ppRebase && pnRebase ){ *ppRebase = (void*)sApply.rebase.aBuf; *pnRebase = sApply.rebase.nBuf; sApply.rebase.aBuf = 0; } sqlite3_finalize(sApply.pInsert); sqlite3_finalize(sApply.pDelete); sqlite3_finalize(sApply.pUpdate); sqlite3_finalize(sApply.pSelect); sqlite3_free((char*)sApply.azCol); /* cast works around VC++ bug */ sqlite3_free((char*)sApply.constraints.aBuf); sqlite3_free((char*)sApply.rebase.aBuf); sqlite3_mutex_leave(sqlite3_db_mutex(db)); return rc; } /* ** Apply the changeset passed via pChangeset/nChangeset to the main ** database attached to handle "db". */ SQLITE_API int sqlite3changeset_apply_v2( sqlite3 *db, /* Apply change to "main" db of this handle */ int nChangeset, /* Size of changeset in bytes */ void *pChangeset, /* Changeset blob */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx, /* First argument passed to xConflict */ void **ppRebase, int *pnRebase, int flags ){ sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ int rc = sqlite3changeset_start(&pIter, nChangeset, pChangeset); if( rc==SQLITE_OK ){ rc = sessionChangesetApply( db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags ); } return rc; } /* ** Apply the changeset passed via pChangeset/nChangeset to the main database ** attached to handle "db". Invoke the supplied conflict handler callback ** to resolve any conflicts encountered while applying the change. */ SQLITE_API int sqlite3changeset_apply( |
︙ | ︙ | |||
184390 184391 184392 184393 184394 184395 184396 | int(*xConflict)( void *pCtx, /* Copy of fifth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ){ | < | < | < < > > > > > > > > > > > > > > > > > > > > > > > > > > > < | < | < < > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > | 185843 185844 185845 185846 185847 185848 185849 185850 185851 185852 185853 185854 185855 185856 185857 185858 185859 185860 185861 185862 185863 185864 185865 185866 185867 185868 185869 185870 185871 185872 185873 185874 185875 185876 185877 185878 185879 185880 185881 185882 185883 185884 185885 185886 185887 185888 185889 185890 185891 185892 185893 185894 185895 185896 185897 185898 185899 185900 185901 185902 185903 185904 185905 185906 185907 185908 185909 185910 185911 185912 185913 185914 185915 185916 185917 185918 185919 185920 185921 185922 185923 185924 185925 185926 185927 185928 185929 185930 185931 185932 185933 185934 185935 185936 185937 185938 185939 185940 185941 185942 185943 185944 185945 185946 185947 185948 185949 185950 185951 185952 185953 185954 185955 185956 185957 185958 185959 185960 185961 185962 185963 185964 185965 185966 185967 185968 185969 185970 185971 185972 185973 185974 185975 185976 185977 185978 185979 185980 185981 185982 185983 185984 185985 185986 185987 185988 185989 185990 185991 185992 185993 185994 185995 185996 185997 185998 185999 186000 186001 186002 186003 186004 186005 186006 186007 186008 | int(*xConflict)( void *pCtx, /* Copy of fifth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ){ return sqlite3changeset_apply_v2( db, nChangeset, pChangeset, xFilter, xConflict, pCtx, 0, 0, 0 ); } /* ** Apply the changeset passed via xInput/pIn to the main database ** attached to handle "db". Invoke the supplied conflict handler callback ** to resolve any conflicts encountered while applying the change. */ SQLITE_API int sqlite3changeset_apply_v2_strm( sqlite3 *db, /* Apply change to "main" db of this handle */ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ void *pIn, /* First arg for xInput */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx, /* First argument passed to xConflict */ void **ppRebase, int *pnRebase, int flags ){ sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */ int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn); if( rc==SQLITE_OK ){ rc = sessionChangesetApply( db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags ); } return rc; } SQLITE_API int sqlite3changeset_apply_strm( sqlite3 *db, /* Apply change to "main" db of this handle */ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ void *pIn, /* First arg for xInput */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ){ return sqlite3changeset_apply_v2_strm( db, xInput, pIn, xFilter, xConflict, pCtx, 0, 0, 0 ); } /* ** sqlite3_changegroup handle. */ struct sqlite3_changegroup { int rc; /* Error code */ int bPatch; /* True to accumulate patchsets */ SessionTable *pList; /* List of tables in current patch */ }; /* ** This function is called to merge two changes to the same row together as ** part of an sqlite3changeset_concat() operation. A new change object is ** allocated and a pointer to it stored in *ppNew. */ static int sessionChangeMerge( SessionTable *pTab, /* Table structure */ int bRebase, /* True for a rebase hash-table */ int bPatchset, /* True for patchsets */ SessionChange *pExist, /* Existing change */ int op2, /* Second change operation */ int bIndirect, /* True if second change is indirect */ u8 *aRec, /* Second change record */ int nRec, /* Number of bytes in aRec */ SessionChange **ppNew /* OUT: Merged change */ ){ SessionChange *pNew = 0; int rc = SQLITE_OK; if( !pExist ){ pNew = (SessionChange *)sqlite3_malloc(sizeof(SessionChange) + nRec); if( !pNew ){ return SQLITE_NOMEM; } memset(pNew, 0, sizeof(SessionChange)); pNew->op = op2; pNew->bIndirect = bIndirect; pNew->aRecord = (u8*)&pNew[1]; if( bIndirect==0 || bRebase==0 ){ pNew->nRecord = nRec; memcpy(pNew->aRecord, aRec, nRec); }else{ int i; u8 *pIn = aRec; u8 *pOut = pNew->aRecord; for(i=0; i<pTab->nCol; i++){ int nIn = sessionSerialLen(pIn); if( *pIn==0 ){ *pOut++ = 0; }else if( pTab->abPK[i]==0 ){ *pOut++ = 0xFF; }else{ memcpy(pOut, pIn, nIn); pOut += nIn; } pIn += nIn; } pNew->nRecord = pOut - pNew->aRecord; } }else if( bRebase ){ if( pExist->op==SQLITE_DELETE && pExist->bIndirect ){ *ppNew = pExist; }else{ int nByte = nRec + pExist->nRecord + sizeof(SessionChange); pNew = (SessionChange*)sqlite3_malloc(nByte); if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ int i; u8 *a1 = pExist->aRecord; u8 *a2 = aRec; u8 *pOut; memset(pNew, 0, nByte); pNew->bIndirect = bIndirect || pExist->bIndirect; pNew->op = op2; pOut = pNew->aRecord = (u8*)&pNew[1]; for(i=0; i<pTab->nCol; i++){ int n1 = sessionSerialLen(a1); int n2 = sessionSerialLen(a2); if( *a1==0xFF || (pTab->abPK[i]==0 && bIndirect) ){ *pOut++ = 0xFF; }else if( *a2==0 ){ memcpy(pOut, a1, n1); pOut += n1; }else{ memcpy(pOut, a2, n2); pOut += n2; } a1 += n1; a2 += n2; } pNew->nRecord = pOut - pNew->aRecord; } sqlite3_free(pExist); } }else{ int op1 = pExist->op; /* ** op1=INSERT, op2=INSERT -> Unsupported. Discard op2. ** op1=INSERT, op2=UPDATE -> INSERT. ** op1=INSERT, op2=DELETE -> (none) |
︙ | ︙ | |||
184556 184557 184558 184559 184560 184561 184562 | pNew->nRecord = (int)(aCsr - pNew->aRecord); } sqlite3_free(pExist); } } *ppNew = pNew; | | | > < | | 186088 186089 186090 186091 186092 186093 186094 186095 186096 186097 186098 186099 186100 186101 186102 186103 186104 186105 186106 186107 186108 186109 186110 186111 186112 186113 186114 186115 186116 186117 186118 186119 | pNew->nRecord = (int)(aCsr - pNew->aRecord); } sqlite3_free(pExist); } } *ppNew = pNew; return rc; } /* ** Add all changes in the changeset traversed by the iterator passed as ** the first argument to the changegroup hash tables. */ static int sessionChangesetToHash( sqlite3_changeset_iter *pIter, /* Iterator to read from */ sqlite3_changegroup *pGrp, /* Changegroup object to add changeset to */ int bRebase /* True if hash table is for rebasing */ ){ u8 *aRec; int nRec; int rc = SQLITE_OK; SessionTable *pTab = 0; while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, 0) ){ const char *zNew; int nCol; int op; int iHash; int bIndirect; SessionChange *pChange; SessionChange *pExist = 0; |
︙ | ︙ | |||
184653 184654 184655 184656 184657 184658 184659 | pExist = *pp; *pp = (*pp)->pNext; pTab->nEntry--; break; } } | | | 186185 186186 186187 186188 186189 186190 186191 186192 186193 186194 186195 186196 186197 186198 186199 | pExist = *pp; *pp = (*pp)->pNext; pTab->nEntry--; break; } } rc = sessionChangeMerge(pTab, bRebase, pIter->bPatchset, pExist, op, bIndirect, aRec, nRec, &pChange ); if( rc ) break; if( pChange ){ pChange->pNext = pTab->apChange[iHash]; pTab->apChange[iHash] = pChange; pTab->nEntry++; |
︙ | ︙ | |||
184761 184762 184763 184764 184765 184766 184767 | */ SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){ sqlite3_changeset_iter *pIter; /* Iterator opened on pData/nData */ int rc; /* Return code */ rc = sqlite3changeset_start(&pIter, nData, pData); if( rc==SQLITE_OK ){ | | | 186293 186294 186295 186296 186297 186298 186299 186300 186301 186302 186303 186304 186305 186306 186307 | */ SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup *pGrp, int nData, void *pData){ sqlite3_changeset_iter *pIter; /* Iterator opened on pData/nData */ int rc; /* Return code */ rc = sqlite3changeset_start(&pIter, nData, pData); if( rc==SQLITE_OK ){ rc = sessionChangesetToHash(pIter, pGrp, 0); } sqlite3changeset_finalize(pIter); return rc; } /* ** Obtain a buffer containing a changeset representing the concatenation |
︙ | ︙ | |||
184792 184793 184794 184795 184796 184797 184798 | void *pIn ){ sqlite3_changeset_iter *pIter; /* Iterator opened on pData/nData */ int rc; /* Return code */ rc = sqlite3changeset_start_strm(&pIter, xInput, pIn); if( rc==SQLITE_OK ){ | | | 186324 186325 186326 186327 186328 186329 186330 186331 186332 186333 186334 186335 186336 186337 186338 | void *pIn ){ sqlite3_changeset_iter *pIter; /* Iterator opened on pData/nData */ int rc; /* Return code */ rc = sqlite3changeset_start_strm(&pIter, xInput, pIn); if( rc==SQLITE_OK ){ rc = sessionChangesetToHash(pIter, pGrp, 0); } sqlite3changeset_finalize(pIter); return rc; } /* ** Streaming versions of changegroup_output(). |
︙ | ︙ | |||
184876 184877 184878 184879 184880 184881 184882 184883 184884 184885 184886 184887 184888 184889 | if( rc==SQLITE_OK ){ rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut); } sqlite3changegroup_delete(pGrp); return rc; } #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */ /************** End of sqlite3session.c **************************************/ /************** Begin file json1.c *******************************************/ /* ** 2015-08-12 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 186408 186409 186410 186411 186412 186413 186414 186415 186416 186417 186418 186419 186420 186421 186422 186423 186424 186425 186426 186427 186428 186429 186430 186431 186432 186433 186434 186435 186436 186437 186438 186439 186440 186441 186442 186443 186444 186445 186446 186447 186448 186449 186450 186451 186452 186453 186454 186455 186456 186457 186458 186459 186460 186461 186462 186463 186464 186465 186466 186467 186468 186469 186470 186471 186472 186473 186474 186475 186476 186477 186478 186479 186480 186481 186482 186483 186484 186485 186486 186487 186488 186489 186490 186491 186492 186493 186494 186495 186496 186497 186498 186499 186500 186501 186502 186503 186504 186505 186506 186507 186508 186509 186510 186511 186512 186513 186514 186515 186516 186517 186518 186519 186520 186521 186522 186523 186524 186525 186526 186527 186528 186529 186530 186531 186532 186533 186534 186535 186536 186537 186538 186539 186540 186541 186542 186543 186544 186545 186546 186547 186548 186549 186550 186551 186552 186553 186554 186555 186556 186557 186558 186559 186560 186561 186562 186563 186564 186565 186566 186567 186568 186569 186570 186571 186572 186573 186574 186575 186576 186577 186578 186579 186580 186581 186582 186583 186584 186585 186586 186587 186588 186589 186590 186591 186592 186593 186594 186595 186596 186597 186598 186599 186600 186601 186602 186603 186604 186605 186606 186607 186608 186609 186610 186611 186612 186613 186614 186615 186616 186617 186618 186619 186620 186621 186622 186623 186624 186625 186626 186627 186628 186629 186630 186631 186632 186633 186634 186635 186636 186637 186638 186639 186640 186641 186642 186643 186644 186645 186646 186647 186648 186649 186650 186651 186652 186653 186654 186655 186656 186657 186658 186659 186660 186661 186662 186663 186664 186665 186666 186667 186668 186669 186670 186671 186672 186673 186674 186675 186676 186677 186678 186679 186680 186681 186682 186683 186684 186685 186686 186687 186688 186689 186690 186691 186692 186693 186694 186695 186696 186697 186698 186699 186700 186701 186702 186703 186704 186705 186706 186707 186708 186709 186710 186711 186712 186713 186714 186715 186716 186717 186718 186719 186720 186721 186722 186723 186724 186725 186726 186727 186728 186729 186730 186731 186732 186733 186734 186735 186736 186737 186738 186739 186740 186741 186742 186743 186744 186745 186746 186747 186748 186749 186750 186751 186752 186753 186754 186755 186756 186757 186758 186759 186760 186761 186762 186763 186764 | if( rc==SQLITE_OK ){ rc = sqlite3changegroup_output_strm(pGrp, xOutput, pOut); } sqlite3changegroup_delete(pGrp); return rc; } /* ** Changeset rebaser handle. */ struct sqlite3_rebaser { sqlite3_changegroup grp; /* Hash table */ }; /* ** Buffers a1 and a2 must both contain a sessions module record nCol ** fields in size. This function appends an nCol sessions module ** record to buffer pBuf that is a copy of a1, except that for ** each field that is undefined in a1[], swap in the field from a2[]. */ static void sessionAppendRecordMerge( SessionBuffer *pBuf, /* Buffer to append to */ int nCol, /* Number of columns in each record */ u8 *a1, int n1, /* Record 1 */ u8 *a2, int n2, /* Record 2 */ int *pRc /* IN/OUT: error code */ ){ sessionBufferGrow(pBuf, n1+n2, pRc); if( *pRc==SQLITE_OK ){ int i; u8 *pOut = &pBuf->aBuf[pBuf->nBuf]; for(i=0; i<nCol; i++){ int nn1 = sessionSerialLen(a1); int nn2 = sessionSerialLen(a2); if( *a1==0 || *a1==0xFF ){ memcpy(pOut, a2, nn2); pOut += nn2; }else{ memcpy(pOut, a1, nn1); pOut += nn1; } a1 += nn1; a2 += nn2; } pBuf->nBuf = pOut-pBuf->aBuf; assert( pBuf->nBuf<=pBuf->nAlloc ); } } /* ** This function is called when rebasing a local UPDATE change against one ** or more remote UPDATE changes. The aRec/nRec buffer contains the current ** old.* and new.* records for the change. The rebase buffer (a single ** record) is in aChange/nChange. The rebased change is appended to buffer ** pBuf. ** ** Rebasing the UPDATE involves: ** ** * Removing any changes to fields for which the corresponding field ** in the rebase buffer is set to "replaced" (type 0xFF). If this ** means the UPDATE change updates no fields, nothing is appended ** to the output buffer. ** ** * For each field modified by the local change for which the ** corresponding field in the rebase buffer is not "undefined" (0x00) ** or "replaced" (0xFF), the old.* value is replaced by the value ** in the rebase buffer. */ static void sessionAppendPartialUpdate( SessionBuffer *pBuf, /* Append record here */ sqlite3_changeset_iter *pIter, /* Iterator pointed at local change */ u8 *aRec, int nRec, /* Local change */ u8 *aChange, int nChange, /* Record to rebase against */ int *pRc /* IN/OUT: Return Code */ ){ sessionBufferGrow(pBuf, 2+nRec+nChange, pRc); if( *pRc==SQLITE_OK ){ int bData = 0; u8 *pOut = &pBuf->aBuf[pBuf->nBuf]; int i; u8 *a1 = aRec; u8 *a2 = aChange; *pOut++ = SQLITE_UPDATE; *pOut++ = pIter->bIndirect; for(i=0; i<pIter->nCol; i++){ int n1 = sessionSerialLen(a1); int n2 = sessionSerialLen(a2); if( pIter->abPK[i] || a2[0]==0 ){ if( !pIter->abPK[i] ) bData = 1; memcpy(pOut, a1, n1); pOut += n1; }else if( a2[0]!=0xFF ){ bData = 1; memcpy(pOut, a2, n2); pOut += n2; }else{ *pOut++ = '\0'; } a1 += n1; a2 += n2; } if( bData ){ a2 = aChange; for(i=0; i<pIter->nCol; i++){ int n1 = sessionSerialLen(a1); int n2 = sessionSerialLen(a2); if( pIter->abPK[i] || a2[0]!=0xFF ){ memcpy(pOut, a1, n1); pOut += n1; }else{ *pOut++ = '\0'; } a1 += n1; a2 += n2; } pBuf->nBuf = (pOut - pBuf->aBuf); } } } /* ** pIter is configured to iterate through a changeset. This function rebases ** that changeset according to the current configuration of the rebaser ** object passed as the first argument. If no error occurs and argument xOutput ** is not NULL, then the changeset is returned to the caller by invoking ** xOutput zero or more times and SQLITE_OK returned. Or, if xOutput is NULL, ** then (*ppOut) is set to point to a buffer containing the rebased changeset ** before this function returns. In this case (*pnOut) is set to the size of ** the buffer in bytes. It is the responsibility of the caller to eventually ** free the (*ppOut) buffer using sqlite3_free(). ** ** If an error occurs, an SQLite error code is returned. If ppOut and ** pnOut are not NULL, then the two output parameters are set to 0 before ** returning. */ static int sessionRebase( sqlite3_rebaser *p, /* Rebaser hash table */ sqlite3_changeset_iter *pIter, /* Input data */ int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut, /* Context for xOutput callback */ int *pnOut, /* OUT: Number of bytes in output changeset */ void **ppOut /* OUT: Inverse of pChangeset */ ){ int rc = SQLITE_OK; u8 *aRec = 0; int nRec = 0; int bNew = 0; SessionTable *pTab = 0; SessionBuffer sOut = {0,0,0}; while( SQLITE_ROW==sessionChangesetNext(pIter, &aRec, &nRec, &bNew) ){ SessionChange *pChange = 0; int bDone = 0; if( bNew ){ const char *zTab = pIter->zTab; for(pTab=p->grp.pList; pTab; pTab=pTab->pNext){ if( 0==sqlite3_stricmp(pTab->zName, zTab) ) break; } bNew = 0; /* A patchset may not be rebased */ if( pIter->bPatchset ){ rc = SQLITE_ERROR; } /* Append a table header to the output for this new table */ sessionAppendByte(&sOut, pIter->bPatchset ? 'P' : 'T', &rc); sessionAppendVarint(&sOut, pIter->nCol, &rc); sessionAppendBlob(&sOut, pIter->abPK, pIter->nCol, &rc); sessionAppendBlob(&sOut,(u8*)pIter->zTab,(int)strlen(pIter->zTab)+1,&rc); } if( pTab && rc==SQLITE_OK ){ int iHash = sessionChangeHash(pTab, 0, aRec, pTab->nChange); for(pChange=pTab->apChange[iHash]; pChange; pChange=pChange->pNext){ if( sessionChangeEqual(pTab, 0, aRec, 0, pChange->aRecord) ){ break; } } } if( pChange ){ assert( pChange->op==SQLITE_DELETE || pChange->op==SQLITE_INSERT ); switch( pIter->op ){ case SQLITE_INSERT: if( pChange->op==SQLITE_INSERT ){ bDone = 1; if( pChange->bIndirect==0 ){ sessionAppendByte(&sOut, SQLITE_UPDATE, &rc); sessionAppendByte(&sOut, pIter->bIndirect, &rc); sessionAppendBlob(&sOut, pChange->aRecord, pChange->nRecord, &rc); sessionAppendBlob(&sOut, aRec, nRec, &rc); } } break; case SQLITE_UPDATE: bDone = 1; if( pChange->op==SQLITE_DELETE ){ if( pChange->bIndirect==0 ){ u8 *pCsr = aRec; sessionSkipRecord(&pCsr, pIter->nCol); sessionAppendByte(&sOut, SQLITE_INSERT, &rc); sessionAppendByte(&sOut, pIter->bIndirect, &rc); sessionAppendRecordMerge(&sOut, pIter->nCol, pCsr, nRec-(pCsr-aRec), pChange->aRecord, pChange->nRecord, &rc ); } }else{ sessionAppendPartialUpdate(&sOut, pIter, aRec, nRec, pChange->aRecord, pChange->nRecord, &rc ); } break; default: assert( pIter->op==SQLITE_DELETE ); bDone = 1; if( pChange->op==SQLITE_INSERT ){ sessionAppendByte(&sOut, SQLITE_DELETE, &rc); sessionAppendByte(&sOut, pIter->bIndirect, &rc); sessionAppendRecordMerge(&sOut, pIter->nCol, pChange->aRecord, pChange->nRecord, aRec, nRec, &rc ); } break; } } if( bDone==0 ){ sessionAppendByte(&sOut, pIter->op, &rc); sessionAppendByte(&sOut, pIter->bIndirect, &rc); sessionAppendBlob(&sOut, aRec, nRec, &rc); } if( rc==SQLITE_OK && xOutput && sOut.nBuf>SESSIONS_STRM_CHUNK_SIZE ){ rc = xOutput(pOut, sOut.aBuf, sOut.nBuf); sOut.nBuf = 0; } if( rc ) break; } if( rc!=SQLITE_OK ){ sqlite3_free(sOut.aBuf); memset(&sOut, 0, sizeof(sOut)); } if( rc==SQLITE_OK ){ if( xOutput ){ if( sOut.nBuf>0 ){ rc = xOutput(pOut, sOut.aBuf, sOut.nBuf); } }else{ *ppOut = (void*)sOut.aBuf; *pnOut = sOut.nBuf; sOut.aBuf = 0; } } sqlite3_free(sOut.aBuf); return rc; } /* ** Create a new rebaser object. */ SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew){ int rc = SQLITE_OK; sqlite3_rebaser *pNew; pNew = sqlite3_malloc(sizeof(sqlite3_rebaser)); if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ memset(pNew, 0, sizeof(sqlite3_rebaser)); } *ppNew = pNew; return rc; } /* ** Call this one or more times to configure a rebaser. */ SQLITE_API int sqlite3rebaser_configure( sqlite3_rebaser *p, int nRebase, const void *pRebase ){ sqlite3_changeset_iter *pIter = 0; /* Iterator opened on pData/nData */ int rc; /* Return code */ rc = sqlite3changeset_start(&pIter, nRebase, (void*)pRebase); if( rc==SQLITE_OK ){ rc = sessionChangesetToHash(pIter, &p->grp, 1); } sqlite3changeset_finalize(pIter); return rc; } /* ** Rebase a changeset according to current rebaser configuration */ SQLITE_API int sqlite3rebaser_rebase( sqlite3_rebaser *p, int nIn, const void *pIn, int *pnOut, void **ppOut ){ sqlite3_changeset_iter *pIter = 0; /* Iterator to skip through input */ int rc = sqlite3changeset_start(&pIter, nIn, (void*)pIn); if( rc==SQLITE_OK ){ rc = sessionRebase(p, pIter, 0, 0, pnOut, ppOut); sqlite3changeset_finalize(pIter); } return rc; } /* ** Rebase a changeset according to current rebaser configuration */ SQLITE_API int sqlite3rebaser_rebase_strm( sqlite3_rebaser *p, int (*xInput)(void *pIn, void *pData, int *pnData), void *pIn, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ){ sqlite3_changeset_iter *pIter = 0; /* Iterator to skip through input */ int rc = sqlite3changeset_start_strm(&pIter, xInput, pIn); if( rc==SQLITE_OK ){ rc = sessionRebase(p, pIter, xOutput, pOut, 0, 0); sqlite3changeset_finalize(pIter); } return rc; } /* ** Destroy a rebaser object */ SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p){ if( p ){ sessionDeleteTable(p->grp.pList); sqlite3_free(p); } } #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */ /************** End of sqlite3session.c **************************************/ /************** Begin file json1.c *******************************************/ /* ** 2015-08-12 |
︙ | ︙ | |||
188806 188807 188808 188809 188810 188811 188812 188813 188814 188815 188816 188817 188818 188819 188820 188821 188822 188823 188824 188825 188826 188827 188828 188829 188830 188831 188832 188833 | ** This is typically a union of many types, one of ** which is sqlite3Fts5ParserFTS5TOKENTYPE. The entry in the union ** for terminal symbols is called "fts5yy0". ** fts5YYSTACKDEPTH is the maximum depth of the parser's stack. If ** zero the stack is dynamically sized using realloc() ** sqlite3Fts5ParserARG_SDECL A static variable declaration for the %extra_argument ** sqlite3Fts5ParserARG_PDECL A parameter declaration for the %extra_argument ** sqlite3Fts5ParserARG_STORE Code to store %extra_argument into fts5yypParser ** sqlite3Fts5ParserARG_FETCH Code to extract %extra_argument from fts5yypParser ** fts5YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** fts5YYNSTATE the combined number of states. ** fts5YYNRULE the number of rules in the grammar ** fts5YYNFTS5TOKEN Number of terminal symbols ** fts5YY_MAX_SHIFT Maximum value for shift actions ** fts5YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions ** fts5YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions ** fts5YY_ERROR_ACTION The fts5yy_action[] code for syntax error ** fts5YY_ACCEPT_ACTION The fts5yy_action[] code for accept ** fts5YY_NO_ACTION The fts5yy_action[] code for no-op ** fts5YY_MIN_REDUCE Minimum value for reduce actions ** fts5YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define fts5YYCODETYPE unsigned char | > > | | > | < | > | | > > > > > | 190681 190682 190683 190684 190685 190686 190687 190688 190689 190690 190691 190692 190693 190694 190695 190696 190697 190698 190699 190700 190701 190702 190703 190704 190705 190706 190707 190708 190709 190710 190711 190712 190713 190714 190715 190716 190717 190718 190719 190720 190721 190722 190723 190724 190725 190726 190727 190728 190729 190730 190731 190732 190733 190734 190735 190736 190737 190738 190739 190740 190741 190742 | ** This is typically a union of many types, one of ** which is sqlite3Fts5ParserFTS5TOKENTYPE. The entry in the union ** for terminal symbols is called "fts5yy0". ** fts5YYSTACKDEPTH is the maximum depth of the parser's stack. If ** zero the stack is dynamically sized using realloc() ** sqlite3Fts5ParserARG_SDECL A static variable declaration for the %extra_argument ** sqlite3Fts5ParserARG_PDECL A parameter declaration for the %extra_argument ** sqlite3Fts5ParserARG_PARAM Code to pass %extra_argument as a subroutine parameter ** sqlite3Fts5ParserARG_STORE Code to store %extra_argument into fts5yypParser ** sqlite3Fts5ParserARG_FETCH Code to extract %extra_argument from fts5yypParser ** sqlite3Fts5ParserCTX_* As sqlite3Fts5ParserARG_ except for %extra_context ** fts5YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** fts5YYNSTATE the combined number of states. ** fts5YYNRULE the number of rules in the grammar ** fts5YYNFTS5TOKEN Number of terminal symbols ** fts5YY_MAX_SHIFT Maximum value for shift actions ** fts5YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions ** fts5YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions ** fts5YY_ERROR_ACTION The fts5yy_action[] code for syntax error ** fts5YY_ACCEPT_ACTION The fts5yy_action[] code for accept ** fts5YY_NO_ACTION The fts5yy_action[] code for no-op ** fts5YY_MIN_REDUCE Minimum value for reduce actions ** fts5YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define fts5YYCODETYPE unsigned char #define fts5YYNOCODE 27 #define fts5YYACTIONTYPE unsigned char #define sqlite3Fts5ParserFTS5TOKENTYPE Fts5Token typedef union { int fts5yyinit; sqlite3Fts5ParserFTS5TOKENTYPE fts5yy0; int fts5yy4; Fts5Colset* fts5yy11; Fts5ExprNode* fts5yy24; Fts5ExprNearset* fts5yy46; Fts5ExprPhrase* fts5yy53; } fts5YYMINORTYPE; #ifndef fts5YYSTACKDEPTH #define fts5YYSTACKDEPTH 100 #endif #define sqlite3Fts5ParserARG_SDECL Fts5Parse *pParse; #define sqlite3Fts5ParserARG_PDECL ,Fts5Parse *pParse #define sqlite3Fts5ParserARG_PARAM ,pParse #define sqlite3Fts5ParserARG_FETCH Fts5Parse *pParse=fts5yypParser->pParse; #define sqlite3Fts5ParserARG_STORE fts5yypParser->pParse=pParse; #define sqlite3Fts5ParserCTX_SDECL #define sqlite3Fts5ParserCTX_PDECL #define sqlite3Fts5ParserCTX_PARAM #define sqlite3Fts5ParserCTX_FETCH #define sqlite3Fts5ParserCTX_STORE #define fts5YYNSTATE 35 #define fts5YYNRULE 28 #define fts5YYNFTS5TOKEN 16 #define fts5YY_MAX_SHIFT 34 #define fts5YY_MIN_SHIFTREDUCE 52 #define fts5YY_MAX_SHIFTREDUCE 79 #define fts5YY_ERROR_ACTION 80 |
︙ | ︙ | |||
188926 188927 188928 188929 188930 188931 188932 | ** fts5yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ #define fts5YY_ACTTAB_COUNT (105) static const fts5YYACTIONTYPE fts5yy_action[] = { /* 0 */ 81, 20, 96, 6, 28, 99, 98, 26, 26, 18, /* 10 */ 96, 6, 28, 17, 98, 56, 26, 19, 96, 6, | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 190809 190810 190811 190812 190813 190814 190815 190816 190817 190818 190819 190820 190821 190822 190823 190824 190825 190826 190827 190828 190829 190830 190831 190832 190833 190834 190835 190836 190837 190838 190839 190840 190841 190842 190843 190844 190845 190846 190847 190848 190849 190850 190851 190852 190853 190854 190855 190856 190857 190858 190859 190860 190861 190862 | ** fts5yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ #define fts5YY_ACTTAB_COUNT (105) static const fts5YYACTIONTYPE fts5yy_action[] = { /* 0 */ 81, 20, 96, 6, 28, 99, 98, 26, 26, 18, /* 10 */ 96, 6, 28, 17, 98, 56, 26, 19, 96, 6, /* 20 */ 28, 14, 98, 14, 26, 31, 92, 96, 6, 28, /* 30 */ 108, 98, 25, 26, 21, 96, 6, 28, 78, 98, /* 40 */ 58, 26, 29, 96, 6, 28, 107, 98, 22, 26, /* 50 */ 24, 16, 12, 11, 1, 13, 13, 24, 16, 23, /* 60 */ 11, 33, 34, 13, 97, 8, 27, 32, 98, 7, /* 70 */ 26, 3, 4, 5, 3, 4, 5, 3, 83, 4, /* 80 */ 5, 3, 63, 5, 3, 62, 12, 2, 86, 13, /* 90 */ 9, 30, 10, 10, 54, 57, 75, 78, 78, 53, /* 100 */ 57, 15, 82, 82, 71, }; static const fts5YYCODETYPE fts5yy_lookahead[] = { /* 0 */ 16, 17, 18, 19, 20, 22, 22, 24, 24, 17, /* 10 */ 18, 19, 20, 7, 22, 9, 24, 17, 18, 19, /* 20 */ 20, 9, 22, 9, 24, 13, 17, 18, 19, 20, /* 30 */ 26, 22, 24, 24, 17, 18, 19, 20, 15, 22, /* 40 */ 9, 24, 17, 18, 19, 20, 26, 22, 21, 24, /* 50 */ 6, 7, 9, 9, 10, 12, 12, 6, 7, 21, /* 60 */ 9, 24, 25, 12, 18, 5, 20, 14, 22, 5, /* 70 */ 24, 3, 1, 2, 3, 1, 2, 3, 0, 1, /* 80 */ 2, 3, 11, 2, 3, 11, 9, 10, 5, 12, /* 90 */ 23, 24, 10, 10, 8, 9, 9, 15, 15, 8, /* 100 */ 9, 9, 27, 27, 11, 27, 27, 27, 27, 27, /* 110 */ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, /* 120 */ 27, }; #define fts5YY_SHIFT_COUNT (34) #define fts5YY_SHIFT_MIN (0) #define fts5YY_SHIFT_MAX (93) static const unsigned char fts5yy_shift_ofst[] = { /* 0 */ 44, 44, 44, 44, 44, 44, 51, 77, 43, 12, /* 10 */ 14, 83, 82, 14, 23, 23, 31, 31, 71, 74, /* 20 */ 78, 81, 86, 91, 6, 53, 53, 60, 64, 68, /* 30 */ 53, 87, 92, 53, 93, }; #define fts5YY_REDUCE_COUNT (17) #define fts5YY_REDUCE_MIN (-17) #define fts5YY_REDUCE_MAX (67) static const signed char fts5yy_reduce_ofst[] = { /* 0 */ -16, -8, 0, 9, 17, 25, 46, -17, -17, 37, /* 10 */ 67, 4, 4, 8, 4, 20, 27, 38, }; static const fts5YYACTIONTYPE fts5yy_default[] = { /* 0 */ 80, 80, 80, 80, 80, 80, 95, 80, 80, 105, /* 10 */ 80, 110, 110, 80, 110, 110, 80, 80, 80, 80, /* 20 */ 80, 91, 80, 80, 80, 101, 100, 80, 80, 90, /* 30 */ 103, 80, 80, 104, 80, }; |
︙ | ︙ | |||
189030 189031 189032 189033 189034 189035 189036 189037 189038 189039 189040 189041 189042 189043 | #ifdef fts5YYTRACKMAXSTACKDEPTH int fts5yyhwm; /* High-water mark of the stack */ #endif #ifndef fts5YYNOERRORRECOVERY int fts5yyerrcnt; /* Shifts left before out of the error */ #endif sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */ #if fts5YYSTACKDEPTH<=0 int fts5yystksz; /* Current side of the stack */ fts5yyStackEntry *fts5yystack; /* The parser's stack */ fts5yyStackEntry fts5yystk0; /* First stack entry */ #else fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */ fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */ | > | 190913 190914 190915 190916 190917 190918 190919 190920 190921 190922 190923 190924 190925 190926 190927 | #ifdef fts5YYTRACKMAXSTACKDEPTH int fts5yyhwm; /* High-water mark of the stack */ #endif #ifndef fts5YYNOERRORRECOVERY int fts5yyerrcnt; /* Shifts left before out of the error */ #endif sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */ sqlite3Fts5ParserCTX_SDECL /* A place to hold %extra_context */ #if fts5YYSTACKDEPTH<=0 int fts5yystksz; /* Current side of the stack */ fts5yyStackEntry *fts5yystack; /* The parser's stack */ fts5yyStackEntry fts5yystk0; /* First stack entry */ #else fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */ fts5yyStackEntry *fts5yystackEnd; /* Last entry in the stack */ |
︙ | ︙ | |||
189093 189094 189095 189096 189097 189098 189099 | /* 9 */ "STRING", /* 10 */ "LP", /* 11 */ "RP", /* 12 */ "CARET", /* 13 */ "COMMA", /* 14 */ "PLUS", /* 15 */ "STAR", | | | | | | | | | | | | < | 190977 190978 190979 190980 190981 190982 190983 190984 190985 190986 190987 190988 190989 190990 190991 190992 190993 190994 190995 190996 190997 190998 190999 191000 191001 | /* 9 */ "STRING", /* 10 */ "LP", /* 11 */ "RP", /* 12 */ "CARET", /* 13 */ "COMMA", /* 14 */ "PLUS", /* 15 */ "STAR", /* 16 */ "input", /* 17 */ "expr", /* 18 */ "cnearset", /* 19 */ "exprlist", /* 20 */ "colset", /* 21 */ "colsetlist", /* 22 */ "nearset", /* 23 */ "nearphrases", /* 24 */ "phrase", /* 25 */ "neardist_opt", /* 26 */ "star_opt", }; #endif /* defined(fts5YYCOVERAGE) || !defined(NDEBUG) */ #ifndef NDEBUG /* For tracing reduce actions, the names of all rules are required. */ static const char *const fts5yyRuleName[] = { |
︙ | ︙ | |||
189188 189189 189190 189191 189192 189193 189194 | */ #ifndef fts5YYMALLOCARGTYPE # define fts5YYMALLOCARGTYPE size_t #endif /* Initialize a new parser that has already been allocated. */ | | | > | | | | | | | | | | | | | | | > | > > | | > | | | | | | | | | | | | | | 191071 191072 191073 191074 191075 191076 191077 191078 191079 191080 191081 191082 191083 191084 191085 191086 191087 191088 191089 191090 191091 191092 191093 191094 191095 191096 191097 191098 191099 191100 191101 191102 191103 191104 191105 191106 191107 191108 191109 191110 191111 191112 191113 191114 191115 191116 191117 191118 191119 191120 191121 191122 191123 191124 191125 191126 191127 191128 191129 191130 191131 191132 191133 191134 191135 191136 191137 191138 191139 191140 191141 191142 191143 191144 191145 191146 191147 191148 191149 191150 191151 191152 191153 191154 191155 191156 191157 191158 191159 191160 191161 191162 191163 191164 191165 191166 191167 191168 191169 191170 191171 191172 191173 191174 191175 191176 191177 191178 191179 191180 191181 191182 191183 191184 191185 191186 191187 191188 | */ #ifndef fts5YYMALLOCARGTYPE # define fts5YYMALLOCARGTYPE size_t #endif /* Initialize a new parser that has already been allocated. */ static void sqlite3Fts5ParserInit(void *fts5yypRawParser sqlite3Fts5ParserCTX_PDECL){ fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yypRawParser; sqlite3Fts5ParserCTX_STORE #ifdef fts5YYTRACKMAXSTACKDEPTH fts5yypParser->fts5yyhwm = 0; #endif #if fts5YYSTACKDEPTH<=0 fts5yypParser->fts5yytos = NULL; fts5yypParser->fts5yystack = NULL; fts5yypParser->fts5yystksz = 0; if( fts5yyGrowStack(fts5yypParser) ){ fts5yypParser->fts5yystack = &fts5yypParser->fts5yystk0; fts5yypParser->fts5yystksz = 1; } #endif #ifndef fts5YYNOERRORRECOVERY fts5yypParser->fts5yyerrcnt = -1; #endif fts5yypParser->fts5yytos = fts5yypParser->fts5yystack; fts5yypParser->fts5yystack[0].stateno = 0; fts5yypParser->fts5yystack[0].major = 0; #if fts5YYSTACKDEPTH>0 fts5yypParser->fts5yystackEnd = &fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1]; #endif } #ifndef sqlite3Fts5Parser_ENGINEALWAYSONSTACK /* ** This function allocates a new parser. ** The only argument is a pointer to a function which works like ** malloc. ** ** Inputs: ** A pointer to the function used to allocate memory. ** ** Outputs: ** A pointer to a parser. This pointer is used in subsequent calls ** to sqlite3Fts5Parser and sqlite3Fts5ParserFree. */ static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE) sqlite3Fts5ParserCTX_PDECL){ fts5yyParser *fts5yypParser; fts5yypParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) ); if( fts5yypParser ){ sqlite3Fts5ParserCTX_STORE sqlite3Fts5ParserInit(fts5yypParser sqlite3Fts5ParserCTX_PARAM); } return (void*)fts5yypParser; } #endif /* sqlite3Fts5Parser_ENGINEALWAYSONSTACK */ /* The following function deletes the "minor type" or semantic value ** associated with a symbol. The symbol can be either a terminal ** or nonterminal. "fts5yymajor" is the symbol code, and "fts5yypminor" is ** a pointer to the value to be deleted. The code used to do the ** deletions is derived from the %destructor and/or %token_destructor ** directives of the input grammar. */ static void fts5yy_destructor( fts5yyParser *fts5yypParser, /* The parser */ fts5YYCODETYPE fts5yymajor, /* Type code for object to destroy */ fts5YYMINORTYPE *fts5yypminor /* The object to be destroyed */ ){ sqlite3Fts5ParserARG_FETCH sqlite3Fts5ParserCTX_FETCH switch( fts5yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen ** when the symbol is popped from the stack during a ** reduce or during error processing or when a parser is ** being destroyed before it is finished parsing. ** ** Note: during a reduce, the only symbols destroyed are those ** which appear on the RHS of the rule, but which are *not* used ** inside the C code. */ /********* Begin destructor definitions ***************************************/ case 16: /* input */ { (void)pParse; } break; case 17: /* expr */ case 18: /* cnearset */ case 19: /* exprlist */ { sqlite3Fts5ParseNodeFree((fts5yypminor->fts5yy24)); } break; case 20: /* colset */ case 21: /* colsetlist */ { sqlite3_free((fts5yypminor->fts5yy11)); } break; case 22: /* nearset */ case 23: /* nearphrases */ { sqlite3Fts5ParseNearsetFree((fts5yypminor->fts5yy46)); } break; case 24: /* phrase */ { sqlite3Fts5ParsePhraseFree((fts5yypminor->fts5yy53)); } break; /********* End destructor definitions *****************************************/ default: break; /* If no destructor action specified: do nothing */ } } |
︙ | ︙ | |||
189398 189399 189400 189401 189402 189403 189404 | } #endif /* ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ | | < | > < | | 191286 191287 191288 191289 191290 191291 191292 191293 191294 191295 191296 191297 191298 191299 191300 191301 191302 191303 191304 191305 | } #endif /* ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ static fts5YYACTIONTYPE fts5yy_find_shift_action( fts5YYCODETYPE iLookAhead, /* The look-ahead token */ fts5YYACTIONTYPE stateno /* Current state number */ ){ int i; if( stateno>fts5YY_MAX_SHIFT ) return stateno; assert( stateno <= fts5YY_SHIFT_COUNT ); #if defined(fts5YYCOVERAGE) fts5yycoverage[stateno][iLookAhead] = 1; #endif do{ i = fts5yy_shift_ofst[stateno]; |
︙ | ︙ | |||
189468 189469 189470 189471 189472 189473 189474 | } /* ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ static int fts5yy_find_reduce_action( | | | 191355 191356 191357 191358 191359 191360 191361 191362 191363 191364 191365 191366 191367 191368 191369 | } /* ** Find the appropriate action for a parser given the non-terminal ** look-ahead token iLookAhead. */ static int fts5yy_find_reduce_action( fts5YYACTIONTYPE stateno, /* Current state number */ fts5YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; #ifdef fts5YYERRORSYMBOL if( stateno>fts5YY_REDUCE_COUNT ){ return fts5yy_default[stateno]; } |
︙ | ︙ | |||
189497 189498 189499 189500 189501 189502 189503 | return fts5yy_action[i]; } /* ** The following routine is called if the stack overflows. */ static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){ | | > | > | 191384 191385 191386 191387 191388 191389 191390 191391 191392 191393 191394 191395 191396 191397 191398 191399 191400 191401 191402 191403 191404 191405 191406 191407 191408 191409 191410 191411 191412 191413 | return fts5yy_action[i]; } /* ** The following routine is called if the stack overflows. */ static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){ sqlite3Fts5ParserARG_FETCH sqlite3Fts5ParserCTX_FETCH #ifndef NDEBUG if( fts5yyTraceFILE ){ fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt); } #endif while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ /******** Begin %stack_overflow code ******************************************/ sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow"); /******** End %stack_overflow code ********************************************/ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument var */ sqlite3Fts5ParserCTX_STORE } /* ** Print tracing information for a SHIFT action */ #ifndef NDEBUG static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState, const char *zTag){ |
︙ | ︙ | |||
189539 189540 189541 189542 189543 189544 189545 | #endif /* ** Perform a shift action. */ static void fts5yy_shift( fts5yyParser *fts5yypParser, /* The parser to be shifted */ | | | | 191428 191429 191430 191431 191432 191433 191434 191435 191436 191437 191438 191439 191440 191441 191442 191443 | #endif /* ** Perform a shift action. */ static void fts5yy_shift( fts5yyParser *fts5yypParser, /* The parser to be shifted */ fts5YYACTIONTYPE fts5yyNewState, /* The new state to shift in */ fts5YYCODETYPE fts5yyMajor, /* The major token to shift in */ sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */ ){ fts5yyStackEntry *fts5yytos; fts5yypParser->fts5yytos++; #ifdef fts5YYTRACKMAXSTACKDEPTH if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){ fts5yypParser->fts5yyhwm++; |
︙ | ︙ | |||
189570 189571 189572 189573 189574 189575 189576 | } } #endif if( fts5yyNewState > fts5YY_MAX_SHIFT ){ fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE; } fts5yytos = fts5yypParser->fts5yytos; | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | | 191459 191460 191461 191462 191463 191464 191465 191466 191467 191468 191469 191470 191471 191472 191473 191474 191475 191476 191477 191478 191479 191480 191481 191482 191483 191484 191485 191486 191487 191488 191489 191490 191491 191492 191493 191494 191495 191496 191497 191498 191499 191500 191501 191502 191503 191504 191505 191506 191507 191508 191509 191510 191511 191512 191513 191514 191515 191516 191517 191518 191519 191520 191521 191522 191523 191524 191525 191526 191527 191528 191529 191530 191531 191532 191533 191534 191535 191536 191537 191538 191539 | } } #endif if( fts5yyNewState > fts5YY_MAX_SHIFT ){ fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE; } fts5yytos = fts5yypParser->fts5yytos; fts5yytos->stateno = fts5yyNewState; fts5yytos->major = fts5yyMajor; fts5yytos->minor.fts5yy0 = fts5yyMinor; fts5yyTraceShift(fts5yypParser, fts5yyNewState, "Shift"); } /* The following table contains information about every rule that ** is used during the reduce. */ static const struct { fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } fts5yyRuleInfo[] = { { 16, -1 }, /* (0) input ::= expr */ { 20, -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */ { 20, -3 }, /* (2) colset ::= LCP colsetlist RCP */ { 20, -1 }, /* (3) colset ::= STRING */ { 20, -2 }, /* (4) colset ::= MINUS STRING */ { 21, -2 }, /* (5) colsetlist ::= colsetlist STRING */ { 21, -1 }, /* (6) colsetlist ::= STRING */ { 17, -3 }, /* (7) expr ::= expr AND expr */ { 17, -3 }, /* (8) expr ::= expr OR expr */ { 17, -3 }, /* (9) expr ::= expr NOT expr */ { 17, -5 }, /* (10) expr ::= colset COLON LP expr RP */ { 17, -3 }, /* (11) expr ::= LP expr RP */ { 17, -1 }, /* (12) expr ::= exprlist */ { 19, -1 }, /* (13) exprlist ::= cnearset */ { 19, -2 }, /* (14) exprlist ::= exprlist cnearset */ { 18, -1 }, /* (15) cnearset ::= nearset */ { 18, -3 }, /* (16) cnearset ::= colset COLON nearset */ { 22, -1 }, /* (17) nearset ::= phrase */ { 22, -2 }, /* (18) nearset ::= CARET phrase */ { 22, -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */ { 23, -1 }, /* (20) nearphrases ::= phrase */ { 23, -2 }, /* (21) nearphrases ::= nearphrases phrase */ { 25, 0 }, /* (22) neardist_opt ::= */ { 25, -2 }, /* (23) neardist_opt ::= COMMA STRING */ { 24, -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */ { 24, -2 }, /* (25) phrase ::= STRING star_opt */ { 26, -1 }, /* (26) star_opt ::= STAR */ { 26, 0 }, /* (27) star_opt ::= */ }; static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */ /* ** Perform a reduce action and the shift that must immediately ** follow the reduce. ** ** The fts5yyLookahead and fts5yyLookaheadToken parameters provide reduce actions ** access to the lookahead token (if any). The fts5yyLookahead will be fts5YYNOCODE ** if the lookahead token has already been consumed. As this procedure is ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ static fts5YYACTIONTYPE fts5yy_reduce( fts5yyParser *fts5yypParser, /* The parser */ unsigned int fts5yyruleno, /* Number of the rule by which to reduce */ int fts5yyLookahead, /* Lookahead token, or fts5YYNOCODE if none */ sqlite3Fts5ParserFTS5TOKENTYPE fts5yyLookaheadToken /* Value of the lookahead token */ sqlite3Fts5ParserCTX_PDECL /* %extra_context */ ){ int fts5yygoto; /* The next state */ int fts5yyact; /* The next action */ fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */ int fts5yysize; /* Amount to pop the stack */ sqlite3Fts5ParserARG_FETCH (void)fts5yyLookahead; (void)fts5yyLookaheadToken; fts5yymsp = fts5yypParser->fts5yytos; #ifndef NDEBUG if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){ fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs; if( fts5yysize ){ |
︙ | ︙ | |||
189666 189667 189668 189669 189670 189671 189672 | fts5yypParser->fts5yyhwm++; assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)); } #endif #if fts5YYSTACKDEPTH>0 if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){ fts5yyStackOverflow(fts5yypParser); | > > > | > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 191556 191557 191558 191559 191560 191561 191562 191563 191564 191565 191566 191567 191568 191569 191570 191571 191572 191573 191574 191575 191576 191577 191578 191579 191580 191581 191582 191583 191584 191585 191586 191587 191588 191589 191590 191591 191592 191593 191594 191595 191596 191597 191598 191599 191600 191601 191602 191603 191604 191605 191606 191607 191608 191609 191610 191611 191612 191613 191614 191615 191616 191617 191618 191619 191620 191621 191622 191623 191624 191625 191626 191627 191628 191629 191630 191631 191632 191633 191634 191635 191636 191637 191638 191639 191640 191641 191642 191643 191644 191645 191646 191647 191648 191649 191650 191651 191652 191653 191654 191655 191656 191657 191658 191659 191660 191661 191662 191663 191664 191665 191666 191667 191668 191669 191670 191671 191672 191673 191674 191675 191676 191677 191678 191679 191680 191681 191682 191683 191684 191685 191686 191687 191688 191689 191690 191691 191692 191693 191694 191695 191696 191697 191698 191699 191700 191701 191702 191703 191704 191705 191706 191707 191708 191709 191710 191711 191712 191713 191714 191715 191716 191717 191718 191719 191720 191721 191722 191723 191724 191725 191726 191727 191728 191729 191730 191731 191732 | fts5yypParser->fts5yyhwm++; assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)); } #endif #if fts5YYSTACKDEPTH>0 if( fts5yypParser->fts5yytos>=fts5yypParser->fts5yystackEnd ){ fts5yyStackOverflow(fts5yypParser); /* The call to fts5yyStackOverflow() above pops the stack until it is ** empty, causing the main parser loop to exit. So the return value ** is never used and does not matter. */ return 0; } #else if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){ if( fts5yyGrowStack(fts5yypParser) ){ fts5yyStackOverflow(fts5yypParser); /* The call to fts5yyStackOverflow() above pops the stack until it is ** empty, causing the main parser loop to exit. So the return value ** is never used and does not matter. */ return 0; } fts5yymsp = fts5yypParser->fts5yytos; } #endif } switch( fts5yyruleno ){ /* Beginning here are the reduction cases. A typical example ** follows: ** case 0: ** #line <lineno> <grammarfile> ** { ... } // User supplied code ** #line <lineno> <thisfile> ** break; */ /********** Begin reduce actions **********************************************/ fts5YYMINORTYPE fts5yylhsminor; case 0: /* input ::= expr */ { sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); } break; case 1: /* colset ::= MINUS LCP colsetlist RCP */ { fts5yymsp[-3].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); } break; case 2: /* colset ::= LCP colsetlist RCP */ { fts5yymsp[-2].minor.fts5yy11 = fts5yymsp[-1].minor.fts5yy11; } break; case 3: /* colset ::= STRING */ { fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); } fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; break; case 4: /* colset ::= MINUS STRING */ { fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); fts5yymsp[-1].minor.fts5yy11 = sqlite3Fts5ParseColsetInvert(pParse, fts5yymsp[-1].minor.fts5yy11); } break; case 5: /* colsetlist ::= colsetlist STRING */ { fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, fts5yymsp[-1].minor.fts5yy11, &fts5yymsp[0].minor.fts5yy0); } fts5yymsp[-1].minor.fts5yy11 = fts5yylhsminor.fts5yy11; break; case 6: /* colsetlist ::= STRING */ { fts5yylhsminor.fts5yy11 = sqlite3Fts5ParseColset(pParse, 0, &fts5yymsp[0].minor.fts5yy0); } fts5yymsp[0].minor.fts5yy11 = fts5yylhsminor.fts5yy11; break; case 7: /* expr ::= expr AND expr */ { fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_AND, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); } fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 8: /* expr ::= expr OR expr */ { fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_OR, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); } fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 9: /* expr ::= expr NOT expr */ { fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_NOT, fts5yymsp[-2].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24, 0); } fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 10: /* expr ::= colset COLON LP expr RP */ { sqlite3Fts5ParseSetColset(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[-4].minor.fts5yy11); fts5yylhsminor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24; } fts5yymsp[-4].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 11: /* expr ::= LP expr RP */ {fts5yymsp[-2].minor.fts5yy24 = fts5yymsp[-1].minor.fts5yy24;} break; case 12: /* expr ::= exprlist */ case 13: /* exprlist ::= cnearset */ fts5yytestcase(fts5yyruleno==13); {fts5yylhsminor.fts5yy24 = fts5yymsp[0].minor.fts5yy24;} fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 14: /* exprlist ::= exprlist cnearset */ { fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseImplicitAnd(pParse, fts5yymsp[-1].minor.fts5yy24, fts5yymsp[0].minor.fts5yy24); } fts5yymsp[-1].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 15: /* cnearset ::= nearset */ { fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); } fts5yymsp[0].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 16: /* cnearset ::= colset COLON nearset */ { fts5yylhsminor.fts5yy24 = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, fts5yymsp[0].minor.fts5yy46); sqlite3Fts5ParseSetColset(pParse, fts5yylhsminor.fts5yy24, fts5yymsp[-2].minor.fts5yy11); } fts5yymsp[-2].minor.fts5yy24 = fts5yylhsminor.fts5yy24; break; case 17: /* nearset ::= phrase */ { fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; break; case 18: /* nearset ::= CARET phrase */ { sqlite3Fts5ParseSetCaret(fts5yymsp[0].minor.fts5yy53); fts5yymsp[-1].minor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } break; case 19: /* nearset ::= STRING LP nearphrases neardist_opt RP */ { sqlite3Fts5ParseNear(pParse, &fts5yymsp[-4].minor.fts5yy0); sqlite3Fts5ParseSetDistance(pParse, fts5yymsp[-2].minor.fts5yy46, &fts5yymsp[-1].minor.fts5yy0); fts5yylhsminor.fts5yy46 = fts5yymsp[-2].minor.fts5yy46; } fts5yymsp[-4].minor.fts5yy46 = fts5yylhsminor.fts5yy46; break; case 20: /* nearphrases ::= phrase */ { fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, 0, fts5yymsp[0].minor.fts5yy53); } fts5yymsp[0].minor.fts5yy46 = fts5yylhsminor.fts5yy46; break; case 21: /* nearphrases ::= nearphrases phrase */ { fts5yylhsminor.fts5yy46 = sqlite3Fts5ParseNearset(pParse, fts5yymsp[-1].minor.fts5yy46, fts5yymsp[0].minor.fts5yy53); } fts5yymsp[-1].minor.fts5yy46 = fts5yylhsminor.fts5yy46; break; case 22: /* neardist_opt ::= */ { fts5yymsp[1].minor.fts5yy0.p = 0; fts5yymsp[1].minor.fts5yy0.n = 0; } break; case 23: /* neardist_opt ::= COMMA STRING */ { fts5yymsp[-1].minor.fts5yy0 = fts5yymsp[0].minor.fts5yy0; } break; case 24: /* phrase ::= phrase PLUS STRING star_opt */ { fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, fts5yymsp[-3].minor.fts5yy53, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); } fts5yymsp[-3].minor.fts5yy53 = fts5yylhsminor.fts5yy53; break; case 25: /* phrase ::= STRING star_opt */ { fts5yylhsminor.fts5yy53 = sqlite3Fts5ParseTerm(pParse, 0, &fts5yymsp[-1].minor.fts5yy0, fts5yymsp[0].minor.fts5yy4); } fts5yymsp[-1].minor.fts5yy53 = fts5yylhsminor.fts5yy53; break; case 26: /* star_opt ::= STAR */ { fts5yymsp[0].minor.fts5yy4 = 1; } break; case 27: /* star_opt ::= */ { fts5yymsp[1].minor.fts5yy4 = 0; } break; |
︙ | ︙ | |||
189851 189852 189853 189854 189855 189856 189857 189858 189859 189860 189861 189862 189863 189864 189865 189866 | assert( fts5yyact!=fts5YY_ERROR_ACTION ); fts5yymsp += fts5yysize+1; fts5yypParser->fts5yytos = fts5yymsp; fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact; fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto; fts5yyTraceShift(fts5yypParser, fts5yyact, "... then shift"); } /* ** The following code executes when the parse fails */ #ifndef fts5YYNOERRORRECOVERY static void fts5yy_parse_failed( fts5yyParser *fts5yypParser /* The parser */ ){ | > | > | > | > | > | > | > | 191747 191748 191749 191750 191751 191752 191753 191754 191755 191756 191757 191758 191759 191760 191761 191762 191763 191764 191765 191766 191767 191768 191769 191770 191771 191772 191773 191774 191775 191776 191777 191778 191779 191780 191781 191782 191783 191784 191785 191786 191787 191788 191789 191790 191791 191792 191793 191794 191795 191796 191797 191798 191799 191800 191801 191802 191803 191804 191805 191806 191807 191808 191809 191810 191811 191812 191813 191814 191815 191816 191817 191818 191819 191820 191821 191822 191823 191824 191825 191826 191827 191828 191829 191830 191831 191832 | assert( fts5yyact!=fts5YY_ERROR_ACTION ); fts5yymsp += fts5yysize+1; fts5yypParser->fts5yytos = fts5yymsp; fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact; fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto; fts5yyTraceShift(fts5yypParser, fts5yyact, "... then shift"); return fts5yyact; } /* ** The following code executes when the parse fails */ #ifndef fts5YYNOERRORRECOVERY static void fts5yy_parse_failed( fts5yyParser *fts5yypParser /* The parser */ ){ sqlite3Fts5ParserARG_FETCH sqlite3Fts5ParserCTX_FETCH #ifndef NDEBUG if( fts5yyTraceFILE ){ fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt); } #endif while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser); /* Here code is inserted which will be executed whenever the ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ sqlite3Fts5ParserCTX_STORE } #endif /* fts5YYNOERRORRECOVERY */ /* ** The following code executes when a syntax error first occurs. */ static void fts5yy_syntax_error( fts5yyParser *fts5yypParser, /* The parser */ int fts5yymajor, /* The major type of the error token */ sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor /* The minor type of the error token */ ){ sqlite3Fts5ParserARG_FETCH sqlite3Fts5ParserCTX_FETCH #define FTS5TOKEN fts5yyminor /************ Begin %syntax_error code ****************************************/ UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */ sqlite3Fts5ParseError( pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p ); /************ End %syntax_error code ******************************************/ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ sqlite3Fts5ParserCTX_STORE } /* ** The following is executed when the parser accepts */ static void fts5yy_accept( fts5yyParser *fts5yypParser /* The parser */ ){ sqlite3Fts5ParserARG_FETCH sqlite3Fts5ParserCTX_FETCH #ifndef NDEBUG if( fts5yyTraceFILE ){ fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt); } #endif #ifndef fts5YYNOERRORRECOVERY fts5yypParser->fts5yyerrcnt = -1; #endif assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack ); /* Here code is inserted which will be executed whenever the ** parser accepts */ /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ sqlite3Fts5ParserARG_STORE /* Suppress warning about unused %extra_argument variable */ sqlite3Fts5ParserCTX_STORE } /* The main parser program. ** The first argument is a pointer to a structure obtained from ** "sqlite3Fts5ParserAlloc" which describes the current state of the parser. ** The second argument is the major token number. The third is ** the minor token. The fourth optional argument is whatever the |
︙ | ︙ | |||
189944 189945 189946 189947 189948 189949 189950 | static void sqlite3Fts5Parser( void *fts5yyp, /* The parser */ int fts5yymajor, /* The major token code number */ sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor /* The value for the token */ sqlite3Fts5ParserARG_PDECL /* Optional %extra_argument parameter */ ){ fts5YYMINORTYPE fts5yyminorunion; | | | > > < < > < | | | > | | > | | 191847 191848 191849 191850 191851 191852 191853 191854 191855 191856 191857 191858 191859 191860 191861 191862 191863 191864 191865 191866 191867 191868 191869 191870 191871 191872 191873 191874 191875 191876 191877 191878 191879 191880 191881 191882 191883 191884 191885 191886 191887 191888 191889 191890 191891 191892 191893 191894 191895 191896 191897 191898 191899 191900 191901 | static void sqlite3Fts5Parser( void *fts5yyp, /* The parser */ int fts5yymajor, /* The major token code number */ sqlite3Fts5ParserFTS5TOKENTYPE fts5yyminor /* The value for the token */ sqlite3Fts5ParserARG_PDECL /* Optional %extra_argument parameter */ ){ fts5YYMINORTYPE fts5yyminorunion; fts5YYACTIONTYPE fts5yyact; /* The parser action. */ #if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY) int fts5yyendofinput; /* True if we are at the end of input */ #endif #ifdef fts5YYERRORSYMBOL int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */ #endif fts5yyParser *fts5yypParser = (fts5yyParser*)fts5yyp; /* The parser */ sqlite3Fts5ParserCTX_FETCH sqlite3Fts5ParserARG_STORE assert( fts5yypParser->fts5yytos!=0 ); #if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY) fts5yyendofinput = (fts5yymajor==0); #endif fts5yyact = fts5yypParser->fts5yytos->stateno; #ifndef NDEBUG if( fts5yyTraceFILE ){ if( fts5yyact < fts5YY_MIN_REDUCE ){ fprintf(fts5yyTraceFILE,"%sInput '%s' in state %d\n", fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact); }else{ fprintf(fts5yyTraceFILE,"%sInput '%s' with pending reduce %d\n", fts5yyTracePrompt,fts5yyTokenName[fts5yymajor],fts5yyact-fts5YY_MIN_REDUCE); } } #endif do{ assert( fts5yyact==fts5yypParser->fts5yytos->stateno ); fts5yyact = fts5yy_find_shift_action(fts5yymajor,fts5yyact); if( fts5yyact >= fts5YY_MIN_REDUCE ){ fts5yyact = fts5yy_reduce(fts5yypParser,fts5yyact-fts5YY_MIN_REDUCE,fts5yymajor, fts5yyminor sqlite3Fts5ParserCTX_PARAM); }else if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){ fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor); #ifndef fts5YYNOERRORRECOVERY fts5yypParser->fts5yyerrcnt--; #endif break; }else if( fts5yyact==fts5YY_ACCEPT_ACTION ){ fts5yypParser->fts5yytos--; fts5yy_accept(fts5yypParser); return; }else{ assert( fts5yyact == fts5YY_ERROR_ACTION ); fts5yyminorunion.fts5yy0 = fts5yyminor; |
︙ | ︙ | |||
190053 190054 190055 190056 190057 190058 190059 190060 190061 190062 190063 190064 190065 190066 190067 190068 190069 | fts5yymajor = fts5YYNOCODE; }else if( fts5yymx!=fts5YYERRORSYMBOL ){ fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor); } } fts5yypParser->fts5yyerrcnt = 3; fts5yyerrorhit = 1; #elif defined(fts5YYNOERRORRECOVERY) /* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax ** error routine and continue going as if nothing had happened. ** ** Applications can set this macro (for example inside %include) if ** they intend to abandon the parse upon the first syntax error seen. */ fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor); fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); | > > < | | 191958 191959 191960 191961 191962 191963 191964 191965 191966 191967 191968 191969 191970 191971 191972 191973 191974 191975 191976 191977 191978 191979 191980 191981 191982 191983 191984 | fts5yymajor = fts5YYNOCODE; }else if( fts5yymx!=fts5YYERRORSYMBOL ){ fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor); } } fts5yypParser->fts5yyerrcnt = 3; fts5yyerrorhit = 1; if( fts5yymajor==fts5YYNOCODE ) break; fts5yyact = fts5yypParser->fts5yytos->stateno; #elif defined(fts5YYNOERRORRECOVERY) /* If the fts5YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax ** error routine and continue going as if nothing had happened. ** ** Applications can set this macro (for example inside %include) if ** they intend to abandon the parse upon the first syntax error seen. */ fts5yy_syntax_error(fts5yypParser,fts5yymajor, fts5yyminor); fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); break; #else /* fts5YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** ** * Report an error message, and throw away the input token. ** ** * If the input token is $, then fail the parse. ** |
︙ | ︙ | |||
190086 190087 190088 190089 190090 190091 190092 | fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); if( fts5yyendofinput ){ fts5yy_parse_failed(fts5yypParser); #ifndef fts5YYNOERRORRECOVERY fts5yypParser->fts5yyerrcnt = -1; #endif } | | | | 191992 191993 191994 191995 191996 191997 191998 191999 192000 192001 192002 192003 192004 192005 192006 192007 192008 192009 | fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); if( fts5yyendofinput ){ fts5yy_parse_failed(fts5yypParser); #ifndef fts5YYNOERRORRECOVERY fts5yypParser->fts5yyerrcnt = -1; #endif } break; #endif } }while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ); #ifndef NDEBUG if( fts5yyTraceFILE ){ fts5yyStackEntry *i; char cDiv = '['; fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt); for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){ fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]); |
︙ | ︙ | |||
202600 202601 202602 202603 202604 202605 202606 202607 202608 202609 202610 202611 202612 202613 202614 202615 202616 202617 202618 202619 202620 202621 202622 202623 202624 202625 | FTS5_BI_ROWID_GE, 0, 0, -1}, }; int aColMap[3]; aColMap[0] = -1; aColMap[1] = nCol; aColMap[2] = nCol+1; /* Set idxFlags flags for all WHERE clause terms that will be used. */ for(i=0; i<pInfo->nConstraint; i++){ struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; int iCol = p->iColumn; if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol) || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol) ){ /* A MATCH operator or equivalent */ if( p->usable ){ idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16); aConstraint[0].iConsIndex = i; }else{ /* As there exists an unusable MATCH constraint this is an ** unusable plan. Set a prohibitively high cost. */ pInfo->estimatedCost = 1e50; return SQLITE_OK; } | > > > > > > | | | 204506 204507 204508 204509 204510 204511 204512 204513 204514 204515 204516 204517 204518 204519 204520 204521 204522 204523 204524 204525 204526 204527 204528 204529 204530 204531 204532 204533 204534 204535 204536 204537 204538 204539 204540 204541 204542 204543 204544 204545 204546 204547 204548 204549 | FTS5_BI_ROWID_GE, 0, 0, -1}, }; int aColMap[3]; aColMap[0] = -1; aColMap[1] = nCol; aColMap[2] = nCol+1; assert( SQLITE_INDEX_CONSTRAINT_EQ<SQLITE_INDEX_CONSTRAINT_MATCH ); assert( SQLITE_INDEX_CONSTRAINT_GT<SQLITE_INDEX_CONSTRAINT_MATCH ); assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH ); assert( SQLITE_INDEX_CONSTRAINT_GE<SQLITE_INDEX_CONSTRAINT_MATCH ); assert( SQLITE_INDEX_CONSTRAINT_LE<SQLITE_INDEX_CONSTRAINT_MATCH ); /* Set idxFlags flags for all WHERE clause terms that will be used. */ for(i=0; i<pInfo->nConstraint; i++){ struct sqlite3_index_constraint *p = &pInfo->aConstraint[i]; int iCol = p->iColumn; if( (p->op==SQLITE_INDEX_CONSTRAINT_MATCH && iCol>=0 && iCol<=nCol) || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol==nCol) ){ /* A MATCH operator or equivalent */ if( p->usable ){ idxFlags = (idxFlags & 0xFFFF) | FTS5_BI_MATCH | (iCol << 16); aConstraint[0].iConsIndex = i; }else{ /* As there exists an unusable MATCH constraint this is an ** unusable plan. Set a prohibitively high cost. */ pInfo->estimatedCost = 1e50; return SQLITE_OK; } }else if( p->op<=SQLITE_INDEX_CONSTRAINT_MATCH ){ int j; for(j=1; j<ArraySize(aConstraint); j++){ struct Constraint *pC = &aConstraint[j]; if( iCol==aColMap[pC->iCol] && (p->op & pC->op) && p->usable ){ pC->iConsIndex = i; idxFlags |= pC->fts5op; } } } } |
︙ | ︙ | |||
204695 204696 204697 204698 204699 204700 204701 | static void fts5SourceIdFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apUnused /* Function arguments */ ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); | | | 206607 206608 206609 206610 206611 206612 206613 206614 206615 206616 206617 206618 206619 206620 206621 | static void fts5SourceIdFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apUnused /* Function arguments */ ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); sqlite3_result_text(pCtx, "fts5: 2018-04-23 00:25:31 e3064ba3b68ca2a1c54561756e8c898866a19ef6e785d315171cd47827a50c85", -1, SQLITE_TRANSIENT); } static int fts5Init(sqlite3 *db){ static const sqlite3_module fts5Mod = { /* iVersion */ 2, /* xCreate */ fts5CreateMethod, /* xConnect */ fts5ConnectMethod, |
︙ | ︙ | |||
208965 208966 208967 208968 208969 208970 208971 | #endif return rc; } #endif /* SQLITE_CORE */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ /************** End of stmt.c ************************************************/ | | | | 210877 210878 210879 210880 210881 210882 210883 210884 210885 210886 210887 210888 210889 210890 | #endif return rc; } #endif /* SQLITE_CORE */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ /************** End of stmt.c ************************************************/ #if __LINE__!=210884 #undef SQLITE_SOURCE_ID #define SQLITE_SOURCE_ID "2018-04-23 00:25:31 e3064ba3b68ca2a1c54561756e8c898866a19ef6e785d315171cd47827a5alt2" #endif /* Return the source-id for this library */ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } /************************** End of sqlite3.c ******************************/ |
Changes to sqlite3.h.
︙ | ︙ | |||
119 120 121 122 123 124 125 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.24.0" #define SQLITE_VERSION_NUMBER 3024000 #define SQLITE_SOURCE_ID "2018-04-23 00:25:31 e3064ba3b68ca2a1c54561756e8c898866a19ef6e785d315171cd47827a50c85" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
︙ | ︙ | |||
1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 | ** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. ** ^This file control takes the file descriptor out of batch write mode ** so that all subsequent write operations are independent. ** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 | > > > > > > | 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 | ** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. ** ^This file control takes the file descriptor out of batch write mode ** so that all subsequent write operations are independent. ** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** ** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]] ** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain ** a file lock using the xLock or xShmLock methods of the VFS to wait ** for up to M milliseconds before failing, where M is the single ** unsigned integer parameter. ** </ul> */ #define SQLITE_FCNTL_LOCKSTATE 1 #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 #define SQLITE_FCNTL_LAST_ERRNO 4 #define SQLITE_FCNTL_SIZE_HINT 5 |
︙ | ︙ | |||
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 | #define SQLITE_FCNTL_VFS_POINTER 27 #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO | > | 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | #define SQLITE_FCNTL_VFS_POINTER 27 #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 #define SQLITE_FCNTL_LOCK_TIMEOUT 34 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
︙ | ︙ | |||
1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 | ** Or if the threshold is -1, statement journals are always held ** exclusively in memory. ** Since many statement journals never become large, setting the spill ** threshold to a value such as 64KiB can greatly reduce the amount of ** I/O required to support statement rollback. ** The default value for this setting is controlled by the ** [SQLITE_STMTJRNL_SPILL] compile-time option. ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ | > > > > > > > > > > > > > > > > | 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 | ** Or if the threshold is -1, statement journals are always held ** exclusively in memory. ** Since many statement journals never become large, setting the spill ** threshold to a value such as 64KiB can greatly reduce the amount of ** I/O required to support statement rollback. ** The default value for this setting is controlled by the ** [SQLITE_STMTJRNL_SPILL] compile-time option. ** ** [[SQLITE_CONFIG_SORTERREF_SIZE]] ** <dt>SQLITE_CONFIG_SORTERREF_SIZE ** <dd>The SQLITE_CONFIG_SORTERREF_SIZE option accepts a single parameter ** of type (int) - the new value of the sorter-reference size threshold. ** Usually, when SQLite uses an external sort to order records according ** to an ORDER BY clause, all fields required by the caller are present in the ** sorted records. However, if SQLite determines based on the declared type ** of a table column that its values are likely to be very large - larger ** than the configured sorter-reference size threshold - then a reference ** is stored in each sorted record and the required column values loaded ** from the database as records are returned in sorted order. The default ** value for this option is to never use this optimization. Specifying a ** negative value for this option restores the default behaviour. ** This option is only available if SQLite is compiled with the ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ |
︙ | ︙ | |||
1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 | #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** | > | 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 | #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** |
︙ | ︙ | |||
8807 8808 8809 8810 8811 8812 8813 | */ #define SQLITE_SERIALIZE_NOCOPY 0x001 /* Do no memory allocations */ /* ** CAPI3REF: Deserialize a database ** ** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the | | | 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 | */ #define SQLITE_SERIALIZE_NOCOPY 0x001 /* Do no memory allocations */ /* ** CAPI3REF: Deserialize a database ** ** The sqlite3_deserialize(D,S,P,N,M,F) interface causes the ** [database connection] D to disconnect from database S and then ** reopen S as an in-memory database based on the serialization contained ** in P. The serialized database P is N bytes in size. M is the size of ** the buffer P, which might be larger than N. If M is larger than N, and ** the SQLITE_DESERIALIZE_READONLY bit is not set in F, then SQLite is ** permitted to add content to the in-memory database as long as the total ** size does not exceed M bytes. ** |
︙ | ︙ | |||
9948 9949 9950 9951 9952 9953 9954 | ** DESTRUCTOR: sqlite3_changegroup */ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); /* ** CAPI3REF: Apply A Changeset To A Database ** | | | | | | | | | < | 9972 9973 9974 9975 9976 9977 9978 9979 9980 9981 9982 9983 9984 9985 9986 9987 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 | ** DESTRUCTOR: sqlite3_changegroup */ SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*); /* ** CAPI3REF: Apply A Changeset To A Database ** ** Apply a changeset or patchset to a database. These functions attempt to ** update the "main" database attached to handle db with the changes found in ** the changeset passed via the second and third arguments. ** ** The fourth argument (xFilter) passed to these functions is the "filter ** callback". If it is not NULL, then for each table affected by at least one ** change in the changeset, the filter callback is invoked with ** the table name as the second argument, and a copy of the context pointer ** passed as the sixth argument as the first. If the "filter callback" ** returns zero, then no attempt is made to apply any changes to the table. ** Otherwise, if the return value is non-zero or the xFilter argument to ** is NULL, all changes related to the table are attempted. ** ** For each table that is not excluded by the filter callback, this function ** tests that the target database contains a compatible table. A table is ** considered compatible if all of the following are true: ** ** <ul> ** <li> The table has the same name as the name recorded in the |
︙ | ︙ | |||
10005 10006 10007 10008 10009 10010 10011 | ** actions are taken by sqlite3changeset_apply() depending on the value ** returned by each invocation of the conflict-handler function. Refer to ** the documentation for the three ** [SQLITE_CHANGESET_OMIT|available return values] for details. ** ** <dl> ** <dt>DELETE Changes<dd> | | | 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 | ** actions are taken by sqlite3changeset_apply() depending on the value ** returned by each invocation of the conflict-handler function. Refer to ** the documentation for the three ** [SQLITE_CHANGESET_OMIT|available return values] for details. ** ** <dl> ** <dt>DELETE Changes<dd> ** For each DELETE change, the function checks if the target database ** contains a row with the same primary key value (or values) as the ** original row values stored in the changeset. If it does, and the values ** stored in all non-primary key columns also match the values stored in ** the changeset the row is deleted from the target database. ** ** If a row with matching primary key values is found, but one or more of ** the non-primary key fields contains a value different from the original |
︙ | ︙ | |||
10050 10051 10052 10053 10054 10055 10056 | ** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is ** invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT]. ** This includes the case where the INSERT operation is re-attempted because ** an earlier call to the conflict handler function returned ** [SQLITE_CHANGESET_REPLACE]. ** ** <dt>UPDATE Changes<dd> | | | 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 | ** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is ** invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT]. ** This includes the case where the INSERT operation is re-attempted because ** an earlier call to the conflict handler function returned ** [SQLITE_CHANGESET_REPLACE]. ** ** <dt>UPDATE Changes<dd> ** For each UPDATE change, the function checks if the target database ** contains a row with the same primary key value (or values) as the ** original row values stored in the changeset. If it does, and the values ** stored in all modified non-primary key columns also match the values ** stored in the changeset the row is updated within the target database. ** ** If a row with matching primary key values is found, but one or more of ** the modified non-primary key fields contains a value different from an |
︙ | ︙ | |||
10081 10082 10083 10084 10085 10086 10087 | ** </dl> ** ** It is safe to execute SQL statements, including those that write to the ** table that the callback related to, from within the xConflict callback. ** This can be used to further customize the applications conflict ** resolution strategy. ** | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 10104 10105 10106 10107 10108 10109 10110 10111 10112 10113 10114 10115 10116 10117 10118 10119 10120 10121 10122 10123 10124 10125 10126 10127 10128 10129 10130 10131 10132 10133 10134 10135 10136 10137 10138 10139 10140 10141 10142 10143 10144 10145 10146 10147 10148 10149 10150 10151 10152 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 10168 10169 10170 10171 10172 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 | ** </dl> ** ** It is safe to execute SQL statements, including those that write to the ** table that the callback related to, from within the xConflict callback. ** This can be used to further customize the applications conflict ** resolution strategy. ** ** All changes made by these functions are enclosed in a savepoint transaction. ** If any other error (aside from a constraint failure when attempting to ** write to the target database) occurs, then the savepoint transaction is ** rolled back, restoring the target database to its original state, and an ** SQLite error code returned. ** ** If the output parameters (ppRebase) and (pnRebase) are non-NULL and ** the input is a changeset (not a patchset), then sqlite3changeset_apply_v2() ** may set (*ppRebase) to point to a "rebase" that may be used with the ** sqlite3_rebaser APIs buffer before returning. In this case (*pnRebase) ** is set to the size of the buffer in bytes. It is the responsibility of the ** caller to eventually free any such buffer using sqlite3_free(). The buffer ** is only allocated and populated if one or more conflicts were encountered ** while applying the patchset. See comments surrounding the sqlite3_rebaser ** APIs for further details. ** ** The behavior of sqlite3changeset_apply_v2() and its streaming equivalent ** may be modified by passing a combination of ** [SQLITE_CHANGESETAPPLY_NOSAVEPOINT | supported flags] as the 9th parameter. ** ** Note that the sqlite3changeset_apply_v2() API is still <b>experimental</b> ** and therefore subject to change. */ SQLITE_API int sqlite3changeset_apply( sqlite3 *db, /* Apply change to "main" db of this handle */ int nChangeset, /* Size of changeset in bytes */ void *pChangeset, /* Changeset blob */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ); SQLITE_API int sqlite3changeset_apply_v2( sqlite3 *db, /* Apply change to "main" db of this handle */ int nChangeset, /* Size of changeset in bytes */ void *pChangeset, /* Changeset blob */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx, /* First argument passed to xConflict */ void **ppRebase, int *pnRebase, /* OUT: Rebase data */ int flags /* Combination of SESSION_APPLY_* flags */ ); /* ** CAPI3REF: Flags for sqlite3changeset_apply_v2 ** ** The following flags may passed via the 9th parameter to ** [sqlite3changeset_apply_v2] and [sqlite3changeset_apply_v2_strm]: ** ** <dl> ** <dt>SQLITE_CHANGESETAPPLY_NOSAVEPOINT <dd> ** Usually, the sessions module encloses all operations performed by ** a single call to apply_v2() or apply_v2_strm() in a [SAVEPOINT]. The ** SAVEPOINT is committed if the changeset or patchset is successfully ** applied, or rolled back if an error occurs. Specifying this flag ** causes the sessions module to omit this savepoint. In this case, if the ** caller has an open transaction or savepoint when apply_v2() is called, ** it may revert the partially applied changeset by rolling it back. */ #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001 /* ** CAPI3REF: Constants Passed To The Conflict Handler ** ** Values that may be passed as the second argument to a conflict-handler. ** ** <dl> |
︙ | ︙ | |||
10199 10200 10201 10202 10203 10204 10205 10206 10207 10208 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 | ** and the call to sqlite3changeset_apply() returns SQLITE_ABORT. ** </dl> */ #define SQLITE_CHANGESET_OMIT 0 #define SQLITE_CHANGESET_REPLACE 1 #define SQLITE_CHANGESET_ABORT 2 /* ** CAPI3REF: Streaming Versions of API functions. ** ** The six streaming API xxx_strm() functions serve similar purposes to the ** corresponding non-streaming API functions: ** ** <table border=1 style="margin-left:8ex;margin-right:8ex"> ** <tr><th>Streaming function<th>Non-streaming equivalent</th> ** <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] ** <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] ** <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] ** <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] ** <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] ** <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] ** </table> ** | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 10274 10275 10276 10277 10278 10279 10280 10281 10282 10283 10284 10285 10286 10287 10288 10289 10290 10291 10292 10293 10294 10295 10296 10297 10298 10299 10300 10301 10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 10316 10317 10318 10319 10320 10321 10322 10323 10324 10325 10326 10327 10328 10329 10330 10331 10332 10333 10334 10335 10336 10337 10338 10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 10353 10354 10355 10356 10357 10358 10359 10360 10361 10362 10363 10364 10365 10366 10367 10368 10369 10370 10371 10372 10373 10374 10375 10376 10377 10378 10379 10380 10381 10382 10383 10384 10385 10386 10387 10388 10389 10390 10391 10392 10393 10394 10395 10396 10397 10398 10399 10400 10401 10402 10403 10404 10405 10406 10407 10408 10409 10410 10411 10412 10413 10414 10415 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 | ** and the call to sqlite3changeset_apply() returns SQLITE_ABORT. ** </dl> */ #define SQLITE_CHANGESET_OMIT 0 #define SQLITE_CHANGESET_REPLACE 1 #define SQLITE_CHANGESET_ABORT 2 /* ** CAPI3REF: Rebasing changesets ** EXPERIMENTAL ** ** Suppose there is a site hosting a database in state S0. And that ** modifications are made that move that database to state S1 and a ** changeset recorded (the "local" changeset). Then, a changeset based ** on S0 is received from another site (the "remote" changeset) and ** applied to the database. The database is then in state ** (S1+"remote"), where the exact state depends on any conflict ** resolution decisions (OMIT or REPLACE) made while applying "remote". ** Rebasing a changeset is to update it to take those conflict ** resolution decisions into account, so that the same conflicts ** do not have to be resolved elsewhere in the network. ** ** For example, if both the local and remote changesets contain an ** INSERT of the same key on "CREATE TABLE t1(a PRIMARY KEY, b)": ** ** local: INSERT INTO t1 VALUES(1, 'v1'); ** remote: INSERT INTO t1 VALUES(1, 'v2'); ** ** and the conflict resolution is REPLACE, then the INSERT change is ** removed from the local changeset (it was overridden). Or, if the ** conflict resolution was "OMIT", then the local changeset is modified ** to instead contain: ** ** UPDATE t1 SET b = 'v2' WHERE a=1; ** ** Changes within the local changeset are rebased as follows: ** ** <dl> ** <dt>Local INSERT<dd> ** This may only conflict with a remote INSERT. If the conflict ** resolution was OMIT, then add an UPDATE change to the rebased ** changeset. Or, if the conflict resolution was REPLACE, add ** nothing to the rebased changeset. ** ** <dt>Local DELETE<dd> ** This may conflict with a remote UPDATE or DELETE. In both cases the ** only possible resolution is OMIT. If the remote operation was a ** DELETE, then add no change to the rebased changeset. If the remote ** operation was an UPDATE, then the old.* fields of change are updated ** to reflect the new.* values in the UPDATE. ** ** <dt>Local UPDATE<dd> ** This may conflict with a remote UPDATE or DELETE. If it conflicts ** with a DELETE, and the conflict resolution was OMIT, then the update ** is changed into an INSERT. Any undefined values in the new.* record ** from the update change are filled in using the old.* values from ** the conflicting DELETE. Or, if the conflict resolution was REPLACE, ** the UPDATE change is simply omitted from the rebased changeset. ** ** If conflict is with a remote UPDATE and the resolution is OMIT, then ** the old.* values are rebased using the new.* values in the remote ** change. Or, if the resolution is REPLACE, then the change is copied ** into the rebased changeset with updates to columns also updated by ** the conflicting remote UPDATE removed. If this means no columns would ** be updated, the change is omitted. ** </dl> ** ** A local change may be rebased against multiple remote changes ** simultaneously. If a single key is modified by multiple remote ** changesets, they are combined as follows before the local changeset ** is rebased: ** ** <ul> ** <li> If there has been one or more REPLACE resolutions on a ** key, it is rebased according to a REPLACE. ** ** <li> If there have been no REPLACE resolutions on a key, then ** the local changeset is rebased according to the most recent ** of the OMIT resolutions. ** </ul> ** ** Note that conflict resolutions from multiple remote changesets are ** combined on a per-field basis, not per-row. This means that in the ** case of multiple remote UPDATE operations, some fields of a single ** local change may be rebased for REPLACE while others are rebased for ** OMIT. ** ** In order to rebase a local changeset, the remote changeset must first ** be applied to the local database using sqlite3changeset_apply_v2() and ** the buffer of rebase information captured. Then: ** ** <ol> ** <li> An sqlite3_rebaser object is created by calling ** sqlite3rebaser_create(). ** <li> The new object is configured with the rebase buffer obtained from ** sqlite3changeset_apply_v2() by calling sqlite3rebaser_configure(). ** If the local changeset is to be rebased against multiple remote ** changesets, then sqlite3rebaser_configure() should be called ** multiple times, in the same order that the multiple ** sqlite3changeset_apply_v2() calls were made. ** <li> Each local changeset is rebased by calling sqlite3rebaser_rebase(). ** <li> The sqlite3_rebaser object is deleted by calling ** sqlite3rebaser_delete(). ** </ol> */ typedef struct sqlite3_rebaser sqlite3_rebaser; /* ** CAPI3REF: Create a changeset rebaser object. ** EXPERIMENTAL ** ** Allocate a new changeset rebaser object. If successful, set (*ppNew) to ** point to the new object and return SQLITE_OK. Otherwise, if an error ** occurs, return an SQLite error code (e.g. SQLITE_NOMEM) and set (*ppNew) ** to NULL. */ SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew); /* ** CAPI3REF: Configure a changeset rebaser object. ** EXPERIMENTAL ** ** Configure the changeset rebaser object to rebase changesets according ** to the conflict resolutions described by buffer pRebase (size nRebase ** bytes), which must have been obtained from a previous call to ** sqlite3changeset_apply_v2(). */ SQLITE_API int sqlite3rebaser_configure( sqlite3_rebaser*, int nRebase, const void *pRebase ); /* ** CAPI3REF: Rebase a changeset ** EXPERIMENTAL ** ** Argument pIn must point to a buffer containing a changeset nIn bytes ** in size. This function allocates and populates a buffer with a copy ** of the changeset rebased rebased according to the configuration of the ** rebaser object passed as the first argument. If successful, (*ppOut) ** is set to point to the new buffer containing the rebased changset and ** (*pnOut) to its size in bytes and SQLITE_OK returned. It is the ** responsibility of the caller to eventually free the new buffer using ** sqlite3_free(). Otherwise, if an error occurs, (*ppOut) and (*pnOut) ** are set to zero and an SQLite error code returned. */ SQLITE_API int sqlite3rebaser_rebase( sqlite3_rebaser*, int nIn, const void *pIn, int *pnOut, void **ppOut ); /* ** CAPI3REF: Delete a changeset rebaser object. ** EXPERIMENTAL ** ** Delete the changeset rebaser object and all associated resources. There ** should be one call to this function for each successful invocation ** of sqlite3rebaser_create(). */ SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p); /* ** CAPI3REF: Streaming Versions of API functions. ** ** The six streaming API xxx_strm() functions serve similar purposes to the ** corresponding non-streaming API functions: ** ** <table border=1 style="margin-left:8ex;margin-right:8ex"> ** <tr><th>Streaming function<th>Non-streaming equivalent</th> ** <tr><td>sqlite3changeset_apply_strm<td>[sqlite3changeset_apply] ** <tr><td>sqlite3changeset_apply_strm_v2<td>[sqlite3changeset_apply_v2] ** <tr><td>sqlite3changeset_concat_strm<td>[sqlite3changeset_concat] ** <tr><td>sqlite3changeset_invert_strm<td>[sqlite3changeset_invert] ** <tr><td>sqlite3changeset_start_strm<td>[sqlite3changeset_start] ** <tr><td>sqlite3session_changeset_strm<td>[sqlite3session_changeset] ** <tr><td>sqlite3session_patchset_strm<td>[sqlite3session_patchset] ** </table> ** |
︙ | ︙ | |||
10302 10303 10304 10305 10306 10307 10308 10309 10310 10311 10312 10313 10314 10315 | ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ); SQLITE_API int sqlite3changeset_concat_strm( int (*xInputA)(void *pIn, void *pData, int *pnData), void *pInA, int (*xInputB)(void *pIn, void *pData, int *pnData), void *pInB, int (*xOutput)(void *pOut, const void *pData, int nData), | > > > > > > > > > > > > > > > > > | 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 | ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx /* First argument passed to xConflict */ ); SQLITE_API int sqlite3changeset_apply_v2_strm( sqlite3 *db, /* Apply change to "main" db of this handle */ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ void *pIn, /* First arg for xInput */ int(*xFilter)( void *pCtx, /* Copy of sixth arg to _apply() */ const char *zTab /* Table name */ ), int(*xConflict)( void *pCtx, /* Copy of sixth arg to _apply() */ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ sqlite3_changeset_iter *p /* Handle describing change and conflict */ ), void *pCtx, /* First argument passed to xConflict */ void **ppRebase, int *pnRebase, int flags ); SQLITE_API int sqlite3changeset_concat_strm( int (*xInputA)(void *pIn, void *pData, int *pnData), void *pInA, int (*xInputB)(void *pIn, void *pData, int *pnData), void *pInB, int (*xOutput)(void *pOut, const void *pData, int nData), |
︙ | ︙ | |||
10339 10340 10341 10342 10343 10344 10345 10346 10347 10348 10349 10350 10351 10352 | SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, int (*xInput)(void *pIn, void *pData, int *pnData), void *pIn ); SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ); /* ** Make sure we can call this stuff from C++. */ #ifdef __cplusplus | > > > > > > > | 10587 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 10606 10607 | SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup*, int (*xInput)(void *pIn, void *pData, int *pnData), void *pIn ); SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup*, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ); SQLITE_API int sqlite3rebaser_rebase_strm( sqlite3_rebaser *pRebaser, int (*xInput)(void *pIn, void *pData, int *pnData), void *pIn, int (*xOutput)(void *pOut, const void *pData, int nData), void *pOut ); /* ** Make sure we can call this stuff from C++. */ #ifdef __cplusplus |
︙ | ︙ |
Added upsert-cases/c01.txt.
> > > > > > > > | 1 2 3 4 5 6 7 8 | CREATE TABLE t1( a INT, b INT, c INT DEFAULT 0, PRIMARY KEY(a,b) ); INSERT INTO t1(a,b) VALUES(1,2),(3,4),(1,2) ON CONFLICT(a,b) DO NOTHING; |
Added upsert-cases/c02.txt.
> > > > > > > > | 1 2 3 4 5 6 7 8 | CREATE TABLE t1( a INT, b INT, c INT DEFAULT 0, PRIMARY KEY(a,b) ) WITHOUT ROWID; INSERT INTO t1(a,b) VALUES(1,2),(3,4),(1,2) ON CONFLICT(a,b) DO NOTHING; |
Added upsert-cases/c03.txt.
> > > > > > > > | 1 2 3 4 5 6 7 8 | CREATE TABLE t1( a INT, b INT UNIQUE, c INT DEFAULT 0, PRIMARY KEY(a,b) ) WITHOUT ROWID; INSERT INTO t1(a,b) VALUES(1,2),(3,4),(1,2) ON CONFLICT(a,b) DO NOTHING; |
Added upsert-cases/c04.txt.
> > > > > > > > | 1 2 3 4 5 6 7 8 | CREATE TABLE t1( a INT, b INT, c INT DEFAULT 0, PRIMARY KEY(a,b) ) WITHOUT ROWID; INSERT INTO t1(a,b) VALUES(1,2),(3,4),(1,2) ON CONFLICT(a,b) DO UPDATE SET c=c+1; |
Added upsert-cases/c05.txt.
> > > > | 1 2 3 4 | CREATE TABLE t1(a,b,c,d,PRIMARY KEY(b,d)); WITH data(a,b,c,d) AS (VALUES(1,2,3,4),(5,6,7,8),(9,10,11,12)) INSERT INTO t1(a,b,c,d) SELECT * FROM data ON CONFLICT(b,d) UPDATE SET a=a+excluded.a WHERE b+exluded.b<10 |
Added upsert-cases/c06.txt.
> > > > | 1 2 3 4 | CREATE TABLE t1(a,b,c DEFAULT 0,PRIMARY KEY(a,b)); INSERT INTO t1 AS nx(a,b) VALUES(1,2),(3,4),(7,8) ON CONFLICT(a,b) DO UPDATE SET c=(SELECT c FROM t2 WHERE (a,b)=(excluded.a,excluded.b)); |
Added upsert-cases/c07.txt.
> > | 1 2 | CREATE TABLE t7(a UNIQUE, b UNIQUE); INSERT INTO t7(a,b) VALUES(1,1),(1,2) ON CONFLICT(b COLLATE binary) DO NOTHING; |
Added upsert-cases/c08.txt.
> > > > | 1 2 3 4 | CREATE TABLE t4(a INT, b INT); CREATE UNIQUE INDEX t4a1 ON t4(a) WHERE b<1000; CREATE UNIQUE INDEX t4a2 ON t4(a) WHERE b>=2000; INSERT INTO t4(a,b) VALUES(50,60) ON CONFLICT(a) DO NOTHING; |
Added upsert-cases/c09.txt.
> > > > > > > | 1 2 3 4 5 6 7 | CREATE TABLE t2(x INTEGER PRIMARY KEY, y INT UNIQUE)/*WITHOUT ROWID*/; CREATE TABLE t3(a,b); INSERT INTO t3 VALUES(1,2),(3,4),(1,5),(6,7),(3,1),(8,9),(6,11),(1,1); INSERT INTO t2(x,y) SELECT a,b FROM t3 WHERE true ON CONFLICT(x) DO UPDATE SET y=max(t2.y,excluded.y); INSERT INTO t2(x,y) SELECT a,b FROM t3 WHERE true ON CONFLICT(x) DO UPDATE SET y=excluded.y WHERE y<excluded.y; |
Added upsert-cases/c10.txt.
> > > > > > > > | 1 2 3 4 5 6 7 8 | CREATE TABLE t6( a INT UNIQUE ON CONFLICT fail, b INT UNIQUE ON CONFLICT replace, c INT UNIQUE ON CONFLICT fail, d INT UNIQUE ON CONFLICT replace ); INSERT INTO t6(a,b,c,d) VALUES(1,2,3,4),(5,6,7,8),(1,100,110,120) ON CONFLICT(a) DO UPDATE SET a=1000; |
Added upsert-cases/c11.txt.
> > > > | 1 2 3 4 | CREATE TABLE t8(a INT PRIMARY KEY, b, c); CREATE UNIQUE INDEX t8x ON t8((b||'x')); INSERT INTO t8(a,b,c) VALUES(1,'one',2),(2,'one',3) ON CONFLICT((b||'x')) DO NOTHING; |
Added upsert-cases/c12.txt.
> > > > > | 1 2 3 4 5 | CREATE TABLE t9(a TEXT PRIMARY KEY, b INT DEFAULT 1); PRAGMA count_changes=ON; INSERT INTO t9(a) VALUES('abc'),('def'),('ghi'),('abc'),('jkl'),('abc'),('ghi') ON CONFLICT(a) DO UPDATE SET b=b+1; PRAGMA count_changes=OFF; |
Added upsert-cases/c13.txt.
> > > > > > | 1 2 3 4 5 6 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b) -- WITHOUT ROWID ; INSERT INTO t1(a,b) VALUES(1,2),(1,7),(1,3) ON CONFLICT(rowid) DO UPDATE set b=max(b,excluded.b); INSERT INTO t1(a,b) VALUES(1,2),(1,7),(1,3) ON CONFLICT(A) DO UPDATE set b=max(b,excluded.b); |
Added upsert-cases/c14.txt.
> > > > > > > > | 1 2 3 4 5 6 7 8 | CREATE TABLE t1(a INT,b INTEGER, c TEXT, d BLOB, e ANY, UNIQUE(a) ON CONFLICT ignore, PRIMARY KEY(b), UNIQUE(c) ON CONFLICT fail ) /*WITHOUT ROWID*/; CREATE INDEX t1d ON t1(d); CREATE UNIQUE INDEX t1e ON t1(e); INSERT INTO t1(a,b,c,d,e) VALUES(1,2,'abc','b1b2b3',3.5); |
Added upsert-cases/c15.txt.
> > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 | CREATE TABLE t1(a INT,b INTEGER, c TEXT, d BLOB, e ANY, UNIQUE(a) ON CONFLICT ignore, PRIMARY KEY(b), UNIQUE(c) ON CONFLICT fail ) WITHOUT ROWID; CREATE INDEX t1d ON t1(d); CREATE UNIQUE INDEX t1e ON t1(e); INSERT INTO t1(a,b,c,d,e) VALUES(1,2,'abc','b1b2b3',3.5); INSERT INTO t1 VALUES(2,2,'xyz',NULL,4.25) ON CONFLICT(b) DO UPDATE SET e=max(e,excluded.e); |
Added upsert-cases/c16.txt.
> > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | CREATE TABLE t1(a INT); CREATE TABLE counts(v INTEGER PRIMARY KEY, n INT)/*WITHOUT ROWID*/; CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN INSERT INTO counts(v,n) VALUES(new.a,1) ON CONFLICT(v) DO UPDATE SET n=n+1; END; CREATE TRIGGER r2 AFTER UPDATE ON t1 BEGIN DELETE FROM counts WHERE v=old.a AND n==1; UPDATE counts SET n=n-1 WHERE v=old.a; INSERT INTO counts(v,n) VALUES(new.a,1) ON CONFLICT(v) DO UPDATE SET n=n+1; END; CREATE TRIGGER r3 AFTER DELETE ON t1 BEGIN DELETE FROM counts WHERE v=old.a AND n==1; UPDATE counts SET n=n-1 WHERE v=old.a; END; INSERT INTO t1(a) VALUES(1),(2),(1),(3),(1),(3),(2),(4),(7); UPDATE t1 SET a=5 WHERE a=4; DELETE FROM t1 WHERE a=7; |
Added upsert-cases/c17.txt.
> > > > > | 1 2 3 4 5 | CREATE TABLE t2(a,b,c,d,PRIMARY KEY(d))WITHOUT ROWID; CREATE UNIQUE INDEX t2bc ON t2(b,c); INSERT INTO t2(a,b,c,d) VALUES(1,2,3,4),(5,6,7,8),(9,2,3,10),(11,12,13,14) ON CONFLICT(c,b) DO UPDATE SET a=a+1000; SELECT *, 'x' FROM t2 ORDER BY +a; |
Added upsert-cases/c18.txt.
> > > > > | 1 2 3 4 5 | CREATE TABLE t1(a,b,c,d,PRIMARY KEY(d,c))WITHOUT ROWID; CREATE UNIQUE INDEX t1bc ON t1(b,c); INSERT INTO t1(a,b,c,d) VALUES(1,2,3,4),(5,6,7,8),(9,2,3,10),(11,12,13,14) ON CONFLICT(c,b) DO UPDATE SET a=a+1000; SELECT *, 'x' FROM t1 ORDER BY +a; |
Added upsert-cases/c19.txt.
> > > > > | 1 2 3 4 5 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c DEFAULT 0); CREATE UNIQUE INDEX t1x1 ON t1(a+b); INSERT INTO t1(a,b) VALUES(7,8) ON CONFLICT(a+b) DO NOTHING; INSERT INTO t1(a,b) VALUES(8,7),(9,6) ON CONFLICT(a+b) DO NOTHING; SELECT * FROM t1; |
Added upsert-cases/c20.txt.
> > > > > | 1 2 3 4 5 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c DEFAULT 0); CREATE UNIQUE INDEX t1x1 ON t1(a+b) WHERE b>10; INSERT INTO t1(a,b) VALUES(7,8) ON CONFLICT(a+b) DO NOTHING; INSERT INTO t1(a,b) VALUES(8,7),(9,6) ON CONFLICT(a+b) DO NOTHING; SELECT * FROM t1; |
Added upsert-cases/c21.txt.
> > > > > | 1 2 3 4 5 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0); INSERT INTO t1(a,b) VALUES(1,2),(3,4); INSERT INTO t1(a,b) VALUES(1,8),(2,11),(3,1) ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b; SELECT *, 'x' FROM t1 ORDER BY a; |
Added upsert-cases/c22.txt.
> > > > > | 1 2 3 4 5 | CREATE TABLE t1(a INT PRIMARY KEY, b int, c DEFAULT 0) WITHOUT ROWID; INSERT INTO t1(a,b) VALUES(1,2),(3,4); INSERT INTO t1(a,b) VALUES(1,8),(2,11),(3,1) ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b; SELECT *, 'x' FROM t1 ORDER BY a; |
Added upsert-cases/c23.txt.
> > > > > > | 1 2 3 4 5 6 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0); INSERT INTO t1(a,b) VALUES(1,2),(3,4); WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99)) INSERT INTO t1(a,b) SELECT a, b FROM nx WHERE true ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b; SELECT *, 'x' FROM t1 ORDER BY a; |
Added upsert-cases/c24.txt.
> > > > > > | 1 2 3 4 5 6 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0); INSERT INTO t1(a,b) VALUES(1,2),(3,4); WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99)) INSERT INTO main.t1 AS t2(a,b) SELECT a, b FROM nx WHERE true ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=t2.c+1 WHERE t2.b<excluded.b; SELECT *, 'x' FROM t1 ORDER BY a; |
Added upsert-cases/c25.txt.
> > > > > > | 1 2 3 4 5 6 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0); INSERT INTO t1(a,b) VALUES(1,2),(3,4); WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99)) INSERT INTO t1 AS t2(a,b) SELECT a, b FROM nx WHERE true ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=t1.c+1 WHERE t1.b<excluded.b; SELECT *, 'x' FROM t1 ORDER BY a; |
Added upsert-cases/c26.txt.
> > > > > > | 1 2 3 4 5 6 | CREATE TABLE t1(a INT PRIMARY KEY, b int, c DEFAULT 0) WITHOUT ROWID; INSERT INTO t1(a,b) VALUES(1,2),(3,4); WITH nx(a,b) AS (VALUES(1,8),(2,11),(3,1),(2,15),(1,4),(1,99)) INSERT INTO t1(a,b) SELECT a, b FROM nx WHERE true ON CONFLICT(a) DO UPDATE SET b=excluded.b, c=c+1 WHERE t1.b<excluded.b; SELECT *, 'x' FROM t1 ORDER BY a; |
Added upsert-cases/c27.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b int, c DEFAULT 0); CREATE TABLE record(x TEXT, y TEXT); CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN INSERT INTO record(x,y) VALUES('before-insert',printf('%d,%d,%d',new.a,new.b,new.c)); END; CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN INSERT INTO record(x,y) VALUES('after-insert',printf('%d,%d,%d',new.a,new.b,new.c)); END; CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN INSERT INTO record(x,y) VALUES('before-update',printf('%d,%d,%d/%d,%d,%d', old.a,old.b,old.c,new.a,new.b,new.c)); END; CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN INSERT INTO record(x,y) VALUES('after-update',printf('%d,%d,%d/%d,%d,%d', old.a,old.b,old.c,new.a,new.b,new.c)); END; INSERT INTO t1(a,b) VALUES(1,2); DELETE FROM record; INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT(a) DO UPDATE SET c=t1.c+1; SELECT * FROM record; DELETE FROM record; INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT(a) DO UPDATE SET c=c+1 WHERE c<0; SELECT * FROM record; |
Added upsert-cases/c28.txt.
> > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | CREATE TABLE t1(a INT PRIMARY KEY, b int, c DEFAULT 0) WITHOUT ROWID; CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN INSERT INTO record(x,y) VALUES('before-insert',printf('%d,%d,%d',new.a,new.b,new.c)); END; CREATE TRIGGER r2 AFTER INSERT ON t1 BEGIN INSERT INTO record(x,y) VALUES('after-insert',printf('%d,%d,%d',new.a,new.b,new.c)); END; CREATE TRIGGER r3 BEFORE UPDATE ON t1 BEGIN INSERT INTO record(x,y) VALUES('before-update',printf('%d,%d,%d/%d,%d,%d', old.a,old.b,old.c,new.a,new.b,new.c)); END; CREATE TRIGGER r4 AFTER UPDATE ON t1 BEGIN INSERT INTO record(x,y) VALUES('after-update',printf('%d,%d,%d/%d,%d,%d', old.a,old.b,old.c,new.a,new.b,new.c)); END; INSERT INTO t1(a,b) VALUES(1,2); DELETE FROM record; INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT(a) DO UPDATE SET c=t1.c+1; DELETE FROM record; INSERT INTO t1(a,b) VALUES(1,2) ON CONFLICT DO NOTHING; SELECT * FROM record; |
Added upsert-cases/c29.txt.
> > > > > > > | 1 2 3 4 5 6 7 | CREATE TABLE excluded(a INT, b INT, c INT DEFAULT 0); CREATE UNIQUE INDEX excludedab ON excluded(a,b); INSERT INTO excluded(a,b) VALUES(1,2),(1,2),(3,4),(1,2),(5,6),(3,4) ON CONFLICT(b,a) DO UPDATE SET c=excluded.c+1; INSERT INTO excluded AS base(a,b,c) VALUES(1,2,8),(1,2,3) ON CONFLICT(b,a) DO UPDATE SET c=excluded.c+1 WHERE base.c<excluded.c; SELECT *, 'x' FROM excluded ORDER BY a; |