Fossil SCM
Update the built-in SQLite to the latest 3.7.9 alpha.
Commit
f678a7b9487476fccad560ee91b667ef87230ca1
Parent
4b0f813b8c59ac8…
2 files changed
+1699
-794
+31
-7
+1699
-794
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | -** version 3.7.8. By combining all the individual C code files into this | |
| 3 | +** version 3.7.9. By combining all the individual C code files into this | |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -24,10 +24,11 @@ | ||
| 24 | 24 | #endif |
| 25 | 25 | #ifndef SQLITE_API |
| 26 | 26 | # define SQLITE_API |
| 27 | 27 | #endif |
| 28 | 28 | /************** Begin file sqliteInt.h ***************************************/ |
| 29 | +#line 1 "tsrc/sqliteInt.h" | |
| 29 | 30 | /* |
| 30 | 31 | ** 2001 September 15 |
| 31 | 32 | ** |
| 32 | 33 | ** The author disclaims copyright to this source code. In place of |
| 33 | 34 | ** a legal notice, here is a blessing: |
| @@ -78,10 +79,11 @@ | ||
| 78 | 79 | #include "config.h" |
| 79 | 80 | #endif |
| 80 | 81 | |
| 81 | 82 | /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ |
| 82 | 83 | /************** Begin file sqliteLimit.h *************************************/ |
| 84 | +#line 1 "tsrc/sqliteLimit.h" | |
| 83 | 85 | /* |
| 84 | 86 | ** 2007 May 7 |
| 85 | 87 | ** |
| 86 | 88 | ** The author disclaims copyright to this source code. In place of |
| 87 | 89 | ** a legal notice, here is a blessing: |
| @@ -289,10 +291,11 @@ | ||
| 289 | 291 | # define SQLITE_MAX_TRIGGER_DEPTH 1000 |
| 290 | 292 | #endif |
| 291 | 293 | |
| 292 | 294 | /************** End of sqliteLimit.h *****************************************/ |
| 293 | 295 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 296 | +#line 54 "tsrc/sqliteInt.h" | |
| 294 | 297 | |
| 295 | 298 | /* Disable nuisance warnings on Borland compilers */ |
| 296 | 299 | #if defined(__BORLANDC__) |
| 297 | 300 | #pragma warn -rch /* unreachable code */ |
| 298 | 301 | #pragma warn -ccc /* Condition is always true or false */ |
| @@ -394,11 +397,11 @@ | ||
| 394 | 397 | ** assert() macro is enabled, each call into the Win32 native heap subsystem |
| 395 | 398 | ** will cause HeapValidate to be called. If heap validation should fail, an |
| 396 | 399 | ** assertion will be triggered. |
| 397 | 400 | ** |
| 398 | 401 | ** (Historical note: There used to be several other options, but we've |
| 399 | -** pared it down to just these two.) | |
| 402 | +** pared it down to just these three.) | |
| 400 | 403 | ** |
| 401 | 404 | ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as |
| 402 | 405 | ** the default. |
| 403 | 406 | */ |
| 404 | 407 | #if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)>1 |
| @@ -545,10 +548,11 @@ | ||
| 545 | 548 | # define unlikely(X) !!(X) |
| 546 | 549 | #endif |
| 547 | 550 | |
| 548 | 551 | /************** Include sqlite3.h in the middle of sqliteInt.h ***************/ |
| 549 | 552 | /************** Begin file sqlite3.h *****************************************/ |
| 553 | +#line 1 "tsrc/sqlite3.h" | |
| 550 | 554 | /* |
| 551 | 555 | ** 2001 September 15 |
| 552 | 556 | ** |
| 553 | 557 | ** The author disclaims copyright to this source code. In place of |
| 554 | 558 | ** a legal notice, here is a blessing: |
| @@ -654,13 +658,13 @@ | ||
| 654 | 658 | ** |
| 655 | 659 | ** See also: [sqlite3_libversion()], |
| 656 | 660 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | 661 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | 662 | */ |
| 659 | -#define SQLITE_VERSION "3.7.8" | |
| 660 | -#define SQLITE_VERSION_NUMBER 3007008 | |
| 661 | -#define SQLITE_SOURCE_ID "2011-09-19 14:49:19 3e0da808d2f5b4d12046e05980ca04578f581177" | |
| 663 | +#define SQLITE_VERSION "3.7.9" | |
| 664 | +#define SQLITE_VERSION_NUMBER 3007009 | |
| 665 | +#define SQLITE_SOURCE_ID "2011-10-07 18:24:25 d4f95b3b6e9f4a4072606af5daa17ea7c645382e" | |
| 662 | 666 | |
| 663 | 667 | /* |
| 664 | 668 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | 669 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | 670 | ** |
| @@ -1318,11 +1322,15 @@ | ||
| 1318 | 1322 | ** in order for the database to be readable. The fourth parameter to |
| 1319 | 1323 | ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
| 1320 | 1324 | ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent |
| 1321 | 1325 | ** WAL mode. If the integer is -1, then it is overwritten with the current |
| 1322 | 1326 | ** WAL persistence setting. |
| 1323 | -** | |
| 1327 | +** | |
| 1328 | +** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening | |
| 1329 | +** a write transaction to indicate that, unless it is rolled back for some | |
| 1330 | +** reason, the entire database file will be overwritten by the current | |
| 1331 | +** transaction. This is used by VACUUM operations. | |
| 1324 | 1332 | */ |
| 1325 | 1333 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1326 | 1334 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1327 | 1335 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1328 | 1336 | #define SQLITE_LAST_ERRNO 4 |
| @@ -1330,10 +1338,11 @@ | ||
| 1330 | 1338 | #define SQLITE_FCNTL_CHUNK_SIZE 6 |
| 1331 | 1339 | #define SQLITE_FCNTL_FILE_POINTER 7 |
| 1332 | 1340 | #define SQLITE_FCNTL_SYNC_OMITTED 8 |
| 1333 | 1341 | #define SQLITE_FCNTL_WIN32_AV_RETRY 9 |
| 1334 | 1342 | #define SQLITE_FCNTL_PERSIST_WAL 10 |
| 1343 | +#define SQLITE_FCNTL_OVERWRITE 11 | |
| 1335 | 1344 | |
| 1336 | 1345 | /* |
| 1337 | 1346 | ** CAPI3REF: Mutex Handle |
| 1338 | 1347 | ** |
| 1339 | 1348 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| @@ -3397,11 +3406,11 @@ | ||
| 3397 | 3406 | ** a schema change, on the first [sqlite3_step()] call following any change |
| 3398 | 3407 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 3399 | 3408 | ** ^The specific value of WHERE-clause [parameter] might influence the |
| 3400 | 3409 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 3401 | 3410 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 3402 | -** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. | |
| 3411 | +** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. | |
| 3403 | 3412 | ** the |
| 3404 | 3413 | ** </li> |
| 3405 | 3414 | ** </ol> |
| 3406 | 3415 | */ |
| 3407 | 3416 | SQLITE_API int sqlite3_prepare( |
| @@ -3900,10 +3909,16 @@ | ||
| 3900 | 3909 | ** current row of the result set of [prepared statement] P. |
| 3901 | 3910 | ** ^If prepared statement P does not have results ready to return |
| 3902 | 3911 | ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 3903 | 3912 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 3904 | 3913 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 3914 | +** ^The sqlite3_data_count(P) routine returns 0 if the previous call to | |
| 3915 | +** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) | |
| 3916 | +** will return non-zero if previous call to [sqlite3_step](P) returned | |
| 3917 | +** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum] | |
| 3918 | +** where it always returns zero since each step of that multi-step | |
| 3919 | +** pragma returns 0 columns of data. | |
| 3905 | 3920 | ** |
| 3906 | 3921 | ** See also: [sqlite3_column_count()] |
| 3907 | 3922 | */ |
| 3908 | 3923 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 3909 | 3924 | |
| @@ -6362,20 +6377,34 @@ | ||
| 6362 | 6377 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6363 | 6378 | ** and lookaside memory used by all prepared statements associated with |
| 6364 | 6379 | ** the database connection.)^ |
| 6365 | 6380 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6366 | 6381 | ** </dd> |
| 6382 | +** | |
| 6383 | +** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt> | |
| 6384 | +** <dd>This parameter returns the number of pager cache hits that have | |
| 6385 | +** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT | |
| 6386 | +** is always 0. | |
| 6387 | +** </dd> | |
| 6388 | +** | |
| 6389 | +** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt> | |
| 6390 | +** <dd>This parameter returns the number of pager cache misses that have | |
| 6391 | +** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS | |
| 6392 | +** is always 0. | |
| 6393 | +** </dd> | |
| 6367 | 6394 | ** </dl> |
| 6368 | 6395 | */ |
| 6369 | 6396 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6370 | 6397 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6371 | 6398 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 6372 | 6399 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 6373 | 6400 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 6374 | 6401 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 6375 | 6402 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 6376 | -#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ | |
| 6403 | +#define SQLITE_DBSTATUS_CACHE_HIT 7 | |
| 6404 | +#define SQLITE_DBSTATUS_CACHE_MISS 8 | |
| 6405 | +#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */ | |
| 6377 | 6406 | |
| 6378 | 6407 | |
| 6379 | 6408 | /* |
| 6380 | 6409 | ** CAPI3REF: Prepared Statement Status |
| 6381 | 6410 | ** |
| @@ -6425,11 +6454,10 @@ | ||
| 6425 | 6454 | ** <dd>^This is the number of rows inserted into transient indices that |
| 6426 | 6455 | ** were created automatically in order to help joins run faster. |
| 6427 | 6456 | ** A non-zero value in this counter may indicate an opportunity to |
| 6428 | 6457 | ** improvement performance by adding permanent indices that do not |
| 6429 | 6458 | ** need to be reinitialized each time the statement is run.</dd> |
| 6430 | -** | |
| 6431 | 6459 | ** </dl> |
| 6432 | 6460 | */ |
| 6433 | 6461 | #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
| 6434 | 6462 | #define SQLITE_STMTSTATUS_SORT 2 |
| 6435 | 6463 | #define SQLITE_STMTSTATUS_AUTOINDEX 3 |
| @@ -7305,12 +7333,14 @@ | ||
| 7305 | 7333 | #endif /* ifndef _SQLITE3RTREE_H_ */ |
| 7306 | 7334 | |
| 7307 | 7335 | |
| 7308 | 7336 | /************** End of sqlite3.h *********************************************/ |
| 7309 | 7337 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7338 | +#line 309 "tsrc/sqliteInt.h" | |
| 7310 | 7339 | /************** Include hash.h in the middle of sqliteInt.h ******************/ |
| 7311 | 7340 | /************** Begin file hash.h ********************************************/ |
| 7341 | +#line 1 "tsrc/hash.h" | |
| 7312 | 7342 | /* |
| 7313 | 7343 | ** 2001 September 22 |
| 7314 | 7344 | ** |
| 7315 | 7345 | ** The author disclaims copyright to this source code. In place of |
| 7316 | 7346 | ** a legal notice, here is a blessing: |
| @@ -7406,12 +7436,14 @@ | ||
| 7406 | 7436 | |
| 7407 | 7437 | #endif /* _SQLITE_HASH_H_ */ |
| 7408 | 7438 | |
| 7409 | 7439 | /************** End of hash.h ************************************************/ |
| 7410 | 7440 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7441 | +#line 310 "tsrc/sqliteInt.h" | |
| 7411 | 7442 | /************** Include parse.h in the middle of sqliteInt.h *****************/ |
| 7412 | 7443 | /************** Begin file parse.h *******************************************/ |
| 7444 | +#line 1 "tsrc/parse.h" | |
| 7413 | 7445 | #define TK_SEMI 1 |
| 7414 | 7446 | #define TK_EXPLAIN 2 |
| 7415 | 7447 | #define TK_QUERY 3 |
| 7416 | 7448 | #define TK_PLAN 4 |
| 7417 | 7449 | #define TK_BEGIN 5 |
| @@ -7568,10 +7600,11 @@ | ||
| 7568 | 7600 | #define TK_UMINUS 156 |
| 7569 | 7601 | #define TK_UPLUS 157 |
| 7570 | 7602 | |
| 7571 | 7603 | /************** End of parse.h ***********************************************/ |
| 7572 | 7604 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7605 | +#line 311 "tsrc/sqliteInt.h" | |
| 7573 | 7606 | #include <stdio.h> |
| 7574 | 7607 | #include <stdlib.h> |
| 7575 | 7608 | #include <string.h> |
| 7576 | 7609 | #include <assert.h> |
| 7577 | 7610 | #include <stddef.h> |
| @@ -7711,10 +7744,22 @@ | ||
| 7711 | 7744 | ** is 0x00000000ffffffff. But because of quirks of some compilers, we |
| 7712 | 7745 | ** have to specify the value in the less intuitive manner shown: |
| 7713 | 7746 | */ |
| 7714 | 7747 | #define SQLITE_MAX_U32 ((((u64)1)<<32)-1) |
| 7715 | 7748 | |
| 7749 | +/* | |
| 7750 | +** The datatype used to store estimates of the number of rows in a | |
| 7751 | +** table or index. This is an unsigned integer type. For 99.9% of | |
| 7752 | +** the world, a 32-bit integer is sufficient. But a 64-bit integer | |
| 7753 | +** can be used at compile-time if desired. | |
| 7754 | +*/ | |
| 7755 | +#ifdef SQLITE_64BIT_STATS | |
| 7756 | + typedef u64 tRowcnt; /* 64-bit only if requested at compile-time */ | |
| 7757 | +#else | |
| 7758 | + typedef u32 tRowcnt; /* 32-bit is the default */ | |
| 7759 | +#endif | |
| 7760 | + | |
| 7716 | 7761 | /* |
| 7717 | 7762 | ** Macros to determine whether the machine is big or little endian, |
| 7718 | 7763 | ** evaluated at runtime. |
| 7719 | 7764 | */ |
| 7720 | 7765 | #ifdef SQLITE_AMALGAMATION |
| @@ -7911,10 +7956,11 @@ | ||
| 7911 | 7956 | ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque |
| 7912 | 7957 | ** pointer types (i.e. FuncDef) defined above. |
| 7913 | 7958 | */ |
| 7914 | 7959 | /************** Include btree.h in the middle of sqliteInt.h *****************/ |
| 7915 | 7960 | /************** Begin file btree.h *******************************************/ |
| 7961 | +#line 1 "tsrc/btree.h" | |
| 7916 | 7962 | /* |
| 7917 | 7963 | ** 2001 September 15 |
| 7918 | 7964 | ** |
| 7919 | 7965 | ** The author disclaims copyright to this source code. In place of |
| 7920 | 7966 | ** a legal notice, here is a blessing: |
| @@ -8155,12 +8201,14 @@ | ||
| 8155 | 8201 | |
| 8156 | 8202 | #endif /* _BTREE_H_ */ |
| 8157 | 8203 | |
| 8158 | 8204 | /************** End of btree.h ***********************************************/ |
| 8159 | 8205 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8206 | +#line 665 "tsrc/sqliteInt.h" | |
| 8160 | 8207 | /************** Include vdbe.h in the middle of sqliteInt.h ******************/ |
| 8161 | 8208 | /************** Begin file vdbe.h ********************************************/ |
| 8209 | +#line 1 "tsrc/vdbe.h" | |
| 8162 | 8210 | /* |
| 8163 | 8211 | ** 2001 September 15 |
| 8164 | 8212 | ** |
| 8165 | 8213 | ** The author disclaims copyright to this source code. In place of |
| 8166 | 8214 | ** a legal notice, here is a blessing: |
| @@ -8321,10 +8369,11 @@ | ||
| 8321 | 8369 | ** The makefile scans the vdbe.c source file and creates the "opcodes.h" |
| 8322 | 8370 | ** header file that defines a number for each opcode used by the VDBE. |
| 8323 | 8371 | */ |
| 8324 | 8372 | /************** Include opcodes.h in the middle of vdbe.h ********************/ |
| 8325 | 8373 | /************** Begin file opcodes.h *****************************************/ |
| 8374 | +#line 1 "tsrc/opcodes.h" | |
| 8326 | 8375 | /* Automatically generated. Do not edit */ |
| 8327 | 8376 | /* See the mkopcodeh.awk script for details */ |
| 8328 | 8377 | #define OP_Goto 1 |
| 8329 | 8378 | #define OP_Gosub 2 |
| 8330 | 8379 | #define OP_Return 3 |
| @@ -8509,10 +8558,11 @@ | ||
| 8509 | 8558 | /* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\ |
| 8510 | 8559 | /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,} |
| 8511 | 8560 | |
| 8512 | 8561 | /************** End of opcodes.h *********************************************/ |
| 8513 | 8562 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 8563 | +#line 164 "tsrc/vdbe.h" | |
| 8514 | 8564 | |
| 8515 | 8565 | /* |
| 8516 | 8566 | ** Prototypes for the VDBE interface. See comments on the implementation |
| 8517 | 8567 | ** for a description of what each of these routines does. |
| 8518 | 8568 | */ |
| @@ -8583,12 +8633,14 @@ | ||
| 8583 | 8633 | |
| 8584 | 8634 | #endif |
| 8585 | 8635 | |
| 8586 | 8636 | /************** End of vdbe.h ************************************************/ |
| 8587 | 8637 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8638 | +#line 666 "tsrc/sqliteInt.h" | |
| 8588 | 8639 | /************** Include pager.h in the middle of sqliteInt.h *****************/ |
| 8589 | 8640 | /************** Begin file pager.h *******************************************/ |
| 8641 | +#line 1 "tsrc/pager.h" | |
| 8590 | 8642 | /* |
| 8591 | 8643 | ** 2001 September 15 |
| 8592 | 8644 | ** |
| 8593 | 8645 | ** The author disclaims copyright to this source code. In place of |
| 8594 | 8646 | ** a legal notice, here is a blessing: |
| @@ -8742,10 +8794,11 @@ | ||
| 8742 | 8794 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); |
| 8743 | 8795 | SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); |
| 8744 | 8796 | SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); |
| 8745 | 8797 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| 8746 | 8798 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); |
| 8799 | +SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *); | |
| 8747 | 8800 | |
| 8748 | 8801 | /* Functions used to truncate the database file. */ |
| 8749 | 8802 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 8750 | 8803 | |
| 8751 | 8804 | #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
| @@ -8769,12 +8822,14 @@ | ||
| 8769 | 8822 | |
| 8770 | 8823 | #endif /* _PAGER_H_ */ |
| 8771 | 8824 | |
| 8772 | 8825 | /************** End of pager.h ***********************************************/ |
| 8773 | 8826 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8827 | +#line 667 "tsrc/sqliteInt.h" | |
| 8774 | 8828 | /************** Include pcache.h in the middle of sqliteInt.h ****************/ |
| 8775 | 8829 | /************** Begin file pcache.h ******************************************/ |
| 8830 | +#line 1 "tsrc/pcache.h" | |
| 8776 | 8831 | /* |
| 8777 | 8832 | ** 2008 August 05 |
| 8778 | 8833 | ** |
| 8779 | 8834 | ** The author disclaims copyright to this source code. In place of |
| 8780 | 8835 | ** a legal notice, here is a blessing: |
| @@ -8929,13 +8984,15 @@ | ||
| 8929 | 8984 | |
| 8930 | 8985 | #endif /* _PCACHE_H_ */ |
| 8931 | 8986 | |
| 8932 | 8987 | /************** End of pcache.h **********************************************/ |
| 8933 | 8988 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8989 | +#line 668 "tsrc/sqliteInt.h" | |
| 8934 | 8990 | |
| 8935 | 8991 | /************** Include os.h in the middle of sqliteInt.h ********************/ |
| 8936 | 8992 | /************** Begin file os.h **********************************************/ |
| 8993 | +#line 1 "tsrc/os.h" | |
| 8937 | 8994 | /* |
| 8938 | 8995 | ** 2001 September 16 |
| 8939 | 8996 | ** |
| 8940 | 8997 | ** The author disclaims copyright to this source code. In place of |
| 8941 | 8998 | ** a legal notice, here is a blessing: |
| @@ -9214,12 +9271,14 @@ | ||
| 9214 | 9271 | |
| 9215 | 9272 | #endif /* _SQLITE_OS_H_ */ |
| 9216 | 9273 | |
| 9217 | 9274 | /************** End of os.h **************************************************/ |
| 9218 | 9275 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 9276 | +#line 670 "tsrc/sqliteInt.h" | |
| 9219 | 9277 | /************** Include mutex.h in the middle of sqliteInt.h *****************/ |
| 9220 | 9278 | /************** Begin file mutex.h *******************************************/ |
| 9279 | +#line 1 "tsrc/mutex.h" | |
| 9221 | 9280 | /* |
| 9222 | 9281 | ** 2007 August 28 |
| 9223 | 9282 | ** |
| 9224 | 9283 | ** The author disclaims copyright to this source code. In place of |
| 9225 | 9284 | ** a legal notice, here is a blessing: |
| @@ -9290,10 +9349,11 @@ | ||
| 9290 | 9349 | #define sqlite3MutexEnd() |
| 9291 | 9350 | #endif /* defined(SQLITE_MUTEX_OMIT) */ |
| 9292 | 9351 | |
| 9293 | 9352 | /************** End of mutex.h ***********************************************/ |
| 9294 | 9353 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 9354 | +#line 671 "tsrc/sqliteInt.h" | |
| 9295 | 9355 | |
| 9296 | 9356 | |
| 9297 | 9357 | /* |
| 9298 | 9358 | ** Each database file to be accessed by the system is an instance |
| 9299 | 9359 | ** of the following structure. There are normally two of these structures |
| @@ -9918,11 +9978,11 @@ | ||
| 9918 | 9978 | int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ |
| 9919 | 9979 | int nCol; /* Number of columns in this table */ |
| 9920 | 9980 | Column *aCol; /* Information about each column */ |
| 9921 | 9981 | Index *pIndex; /* List of SQL indexes on this table. */ |
| 9922 | 9982 | int tnum; /* Root BTree node for this table (see note above) */ |
| 9923 | - unsigned nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ | |
| 9983 | + tRowcnt nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ | |
| 9924 | 9984 | Select *pSelect; /* NULL for tables. Points to definition if a view. */ |
| 9925 | 9985 | u16 nRef; /* Number of pointers to this Table */ |
| 9926 | 9986 | u8 tabFlags; /* Mask of TF_* values */ |
| 9927 | 9987 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
| 9928 | 9988 | FKey *pFKey; /* Linked list of all foreign keys in this table */ |
| @@ -10117,11 +10177,11 @@ | ||
| 10117 | 10177 | */ |
| 10118 | 10178 | struct Index { |
| 10119 | 10179 | char *zName; /* Name of this index */ |
| 10120 | 10180 | int nColumn; /* Number of columns in the table used by this index */ |
| 10121 | 10181 | int *aiColumn; /* Which columns are used by this index. 1st is 0 */ |
| 10122 | - unsigned *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ | |
| 10182 | + tRowcnt *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ | |
| 10123 | 10183 | Table *pTable; /* The SQL table being indexed */ |
| 10124 | 10184 | int tnum; /* Page containing root of this index in database file */ |
| 10125 | 10185 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 10126 | 10186 | u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ |
| 10127 | 10187 | u8 bUnordered; /* Use this index for == or IN queries only */ |
| @@ -10128,24 +10188,32 @@ | ||
| 10128 | 10188 | char *zColAff; /* String defining the affinity of each column */ |
| 10129 | 10189 | Index *pNext; /* The next index associated with the same table */ |
| 10130 | 10190 | Schema *pSchema; /* Schema containing this index */ |
| 10131 | 10191 | u8 *aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ |
| 10132 | 10192 | char **azColl; /* Array of collation sequence names for index */ |
| 10133 | - IndexSample *aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ | |
| 10193 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 10194 | + int nSample; /* Number of elements in aSample[] */ | |
| 10195 | + tRowcnt avgEq; /* Average nEq value for key values not in aSample */ | |
| 10196 | + IndexSample *aSample; /* Samples of the left-most key */ | |
| 10197 | +#endif | |
| 10134 | 10198 | }; |
| 10135 | 10199 | |
| 10136 | 10200 | /* |
| 10137 | 10201 | ** Each sample stored in the sqlite_stat2 table is represented in memory |
| 10138 | 10202 | ** using a structure of this type. |
| 10139 | 10203 | */ |
| 10140 | 10204 | struct IndexSample { |
| 10141 | 10205 | union { |
| 10142 | 10206 | char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */ |
| 10143 | - double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ | |
| 10207 | + double r; /* Value if eType is SQLITE_FLOAT */ | |
| 10208 | + i64 i; /* Value if eType is SQLITE_INTEGER */ | |
| 10144 | 10209 | } u; |
| 10145 | 10210 | u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ |
| 10146 | - u8 nByte; /* Size in byte of text or blob. */ | |
| 10211 | + int nByte; /* Size in byte of text or blob. */ | |
| 10212 | + tRowcnt nEq; /* Est. number of rows where the key equals this sample */ | |
| 10213 | + tRowcnt nLt; /* Est. number of rows where key is less than this sample */ | |
| 10214 | + tRowcnt nDLt; /* Est. number of distinct keys less than this sample */ | |
| 10147 | 10215 | }; |
| 10148 | 10216 | |
| 10149 | 10217 | /* |
| 10150 | 10218 | ** Each token coming out of the lexer is an instance of |
| 10151 | 10219 | ** this structure. Tokens are also used as part of an expression. |
| @@ -10593,14 +10661,14 @@ | ||
| 10593 | 10661 | #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ |
| 10594 | 10662 | #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ |
| 10595 | 10663 | #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ |
| 10596 | 10664 | #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
| 10597 | 10665 | #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
| 10598 | -#define WHERE_OMIT_OPEN 0x0010 /* Table cursors are already open */ | |
| 10599 | -#define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ | |
| 10600 | -#define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ | |
| 10601 | -#define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ | |
| 10666 | +#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */ | |
| 10667 | +#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */ | |
| 10668 | +#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */ | |
| 10669 | +#define WHERE_AND_ONLY 0x0080 /* Don't use indices for OR terms */ | |
| 10602 | 10670 | |
| 10603 | 10671 | /* |
| 10604 | 10672 | ** The WHERE clause processing routine has two halves. The |
| 10605 | 10673 | ** first part does the start of the WHERE loop and the second |
| 10606 | 10674 | ** half does the tail of the WHERE loop. An instance of |
| @@ -11350,10 +11418,11 @@ | ||
| 11350 | 11418 | #else |
| 11351 | 11419 | # define sqlite3ViewGetColumnNames(A,B) 0 |
| 11352 | 11420 | #endif |
| 11353 | 11421 | |
| 11354 | 11422 | SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int); |
| 11423 | +SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int); | |
| 11355 | 11424 | SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*); |
| 11356 | 11425 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 11357 | 11426 | SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); |
| 11358 | 11427 | SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse); |
| 11359 | 11428 | #else |
| @@ -11606,11 +11675,11 @@ | ||
| 11606 | 11675 | SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, |
| 11607 | 11676 | void(*)(void*)); |
| 11608 | 11677 | SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*); |
| 11609 | 11678 | SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *); |
| 11610 | 11679 | SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); |
| 11611 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 11680 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 11612 | 11681 | SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *); |
| 11613 | 11682 | #endif |
| 11614 | 11683 | SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); |
| 11615 | 11684 | SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); |
| 11616 | 11685 | #ifndef SQLITE_AMALGAMATION |
| @@ -11893,10 +11962,11 @@ | ||
| 11893 | 11962 | |
| 11894 | 11963 | #endif /* _SQLITEINT_H_ */ |
| 11895 | 11964 | |
| 11896 | 11965 | /************** End of sqliteInt.h *******************************************/ |
| 11897 | 11966 | /************** Begin file global.c ******************************************/ |
| 11967 | +#line 1 "tsrc/global.c" | |
| 11898 | 11968 | /* |
| 11899 | 11969 | ** 2008 June 13 |
| 11900 | 11970 | ** |
| 11901 | 11971 | ** The author disclaims copyright to this source code. In place of |
| 11902 | 11972 | ** a legal notice, here is a blessing: |
| @@ -12115,10 +12185,11 @@ | ||
| 12115 | 12185 | */ |
| 12116 | 12186 | SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER; |
| 12117 | 12187 | |
| 12118 | 12188 | /************** End of global.c **********************************************/ |
| 12119 | 12189 | /************** Begin file ctime.c *******************************************/ |
| 12190 | +#line 1 "tsrc/ctime.c" | |
| 12120 | 12191 | /* |
| 12121 | 12192 | ** 2010 February 23 |
| 12122 | 12193 | ** |
| 12123 | 12194 | ** The author disclaims copyright to this source code. In place of |
| 12124 | 12195 | ** a legal notice, here is a blessing: |
| @@ -12232,10 +12303,13 @@ | ||
| 12232 | 12303 | #ifdef SQLITE_ENABLE_RTREE |
| 12233 | 12304 | "ENABLE_RTREE", |
| 12234 | 12305 | #endif |
| 12235 | 12306 | #ifdef SQLITE_ENABLE_STAT2 |
| 12236 | 12307 | "ENABLE_STAT2", |
| 12308 | +#endif | |
| 12309 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 12310 | + "ENABLE_STAT3", | |
| 12237 | 12311 | #endif |
| 12238 | 12312 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 12239 | 12313 | "ENABLE_UNLOCK_NOTIFY", |
| 12240 | 12314 | #endif |
| 12241 | 12315 | #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT |
| @@ -12445,13 +12519,10 @@ | ||
| 12445 | 12519 | "OMIT_WSD", |
| 12446 | 12520 | #endif |
| 12447 | 12521 | #ifdef SQLITE_OMIT_XFER_OPT |
| 12448 | 12522 | "OMIT_XFER_OPT", |
| 12449 | 12523 | #endif |
| 12450 | -#ifdef SQLITE_PAGECACHE_BLOCKALLOC | |
| 12451 | - "PAGECACHE_BLOCKALLOC", | |
| 12452 | -#endif | |
| 12453 | 12524 | #ifdef SQLITE_PERFORMANCE_TRACE |
| 12454 | 12525 | "PERFORMANCE_TRACE", |
| 12455 | 12526 | #endif |
| 12456 | 12527 | #ifdef SQLITE_PROXY_DEBUG |
| 12457 | 12528 | "PROXY_DEBUG", |
| @@ -12519,10 +12590,11 @@ | ||
| 12519 | 12590 | |
| 12520 | 12591 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| 12521 | 12592 | |
| 12522 | 12593 | /************** End of ctime.c ***********************************************/ |
| 12523 | 12594 | /************** Begin file status.c ******************************************/ |
| 12595 | +#line 1 "tsrc/status.c" | |
| 12524 | 12596 | /* |
| 12525 | 12597 | ** 2008 June 18 |
| 12526 | 12598 | ** |
| 12527 | 12599 | ** The author disclaims copyright to this source code. In place of |
| 12528 | 12600 | ** a legal notice, here is a blessing: |
| @@ -12536,10 +12608,11 @@ | ||
| 12536 | 12608 | ** This module implements the sqlite3_status() interface and related |
| 12537 | 12609 | ** functionality. |
| 12538 | 12610 | */ |
| 12539 | 12611 | /************** Include vdbeInt.h in the middle of status.c ******************/ |
| 12540 | 12612 | /************** Begin file vdbeInt.h *****************************************/ |
| 12613 | +#line 1 "tsrc/vdbeInt.h" | |
| 12541 | 12614 | /* |
| 12542 | 12615 | ** 2003 September 6 |
| 12543 | 12616 | ** |
| 12544 | 12617 | ** The author disclaims copyright to this source code. In place of |
| 12545 | 12618 | ** a legal notice, here is a blessing: |
| @@ -12987,10 +13060,11 @@ | ||
| 12987 | 13060 | |
| 12988 | 13061 | #endif /* !defined(_VDBEINT_H_) */ |
| 12989 | 13062 | |
| 12990 | 13063 | /************** End of vdbeInt.h *********************************************/ |
| 12991 | 13064 | /************** Continuing where we left off in status.c *********************/ |
| 13065 | +#line 18 "tsrc/status.c" | |
| 12992 | 13066 | |
| 12993 | 13067 | /* |
| 12994 | 13068 | ** Variables in which to record status information. |
| 12995 | 13069 | */ |
| 12996 | 13070 | typedef struct sqlite3StatType sqlite3StatType; |
| @@ -13189,10 +13263,32 @@ | ||
| 13189 | 13263 | *pHighwater = 0; |
| 13190 | 13264 | *pCurrent = nByte; |
| 13191 | 13265 | |
| 13192 | 13266 | break; |
| 13193 | 13267 | } |
| 13268 | + | |
| 13269 | + /* | |
| 13270 | + ** Set *pCurrent to the total cache hits or misses encountered by all | |
| 13271 | + ** pagers the database handle is connected to. *pHighwater is always set | |
| 13272 | + ** to zero. | |
| 13273 | + */ | |
| 13274 | + case SQLITE_DBSTATUS_CACHE_HIT: | |
| 13275 | + case SQLITE_DBSTATUS_CACHE_MISS: { | |
| 13276 | + int i; | |
| 13277 | + int nRet = 0; | |
| 13278 | + assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 ); | |
| 13279 | + | |
| 13280 | + for(i=0; i<db->nDb; i++){ | |
| 13281 | + if( db->aDb[i].pBt ){ | |
| 13282 | + Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt); | |
| 13283 | + sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet); | |
| 13284 | + } | |
| 13285 | + } | |
| 13286 | + *pHighwater = 0; | |
| 13287 | + *pCurrent = nRet; | |
| 13288 | + break; | |
| 13289 | + } | |
| 13194 | 13290 | |
| 13195 | 13291 | default: { |
| 13196 | 13292 | rc = SQLITE_ERROR; |
| 13197 | 13293 | } |
| 13198 | 13294 | } |
| @@ -13200,10 +13296,11 @@ | ||
| 13200 | 13296 | return rc; |
| 13201 | 13297 | } |
| 13202 | 13298 | |
| 13203 | 13299 | /************** End of status.c **********************************************/ |
| 13204 | 13300 | /************** Begin file date.c ********************************************/ |
| 13301 | +#line 1 "tsrc/date.c" | |
| 13205 | 13302 | /* |
| 13206 | 13303 | ** 2003 October 31 |
| 13207 | 13304 | ** |
| 13208 | 13305 | ** The author disclaims copyright to this source code. In place of |
| 13209 | 13306 | ** a legal notice, here is a blessing: |
| @@ -14327,10 +14424,11 @@ | ||
| 14327 | 14424 | } |
| 14328 | 14425 | } |
| 14329 | 14426 | |
| 14330 | 14427 | /************** End of date.c ************************************************/ |
| 14331 | 14428 | /************** Begin file os.c **********************************************/ |
| 14429 | +#line 1 "tsrc/os.c" | |
| 14332 | 14430 | /* |
| 14333 | 14431 | ** 2005 November 29 |
| 14334 | 14432 | ** |
| 14335 | 14433 | ** The author disclaims copyright to this source code. In place of |
| 14336 | 14434 | ** a legal notice, here is a blessing: |
| @@ -14660,10 +14758,11 @@ | ||
| 14660 | 14758 | return SQLITE_OK; |
| 14661 | 14759 | } |
| 14662 | 14760 | |
| 14663 | 14761 | /************** End of os.c **************************************************/ |
| 14664 | 14762 | /************** Begin file fault.c *******************************************/ |
| 14763 | +#line 1 "tsrc/fault.c" | |
| 14665 | 14764 | /* |
| 14666 | 14765 | ** 2008 Jan 22 |
| 14667 | 14766 | ** |
| 14668 | 14767 | ** The author disclaims copyright to this source code. In place of |
| 14669 | 14768 | ** a legal notice, here is a blessing: |
| @@ -14749,10 +14848,11 @@ | ||
| 14749 | 14848 | |
| 14750 | 14849 | #endif /* #ifndef SQLITE_OMIT_BUILTIN_TEST */ |
| 14751 | 14850 | |
| 14752 | 14851 | /************** End of fault.c ***********************************************/ |
| 14753 | 14852 | /************** Begin file mem0.c ********************************************/ |
| 14853 | +#line 1 "tsrc/mem0.c" | |
| 14754 | 14854 | /* |
| 14755 | 14855 | ** 2008 October 28 |
| 14756 | 14856 | ** |
| 14757 | 14857 | ** The author disclaims copyright to this source code. In place of |
| 14758 | 14858 | ** a legal notice, here is a blessing: |
| @@ -14810,10 +14910,11 @@ | ||
| 14810 | 14910 | |
| 14811 | 14911 | #endif /* SQLITE_ZERO_MALLOC */ |
| 14812 | 14912 | |
| 14813 | 14913 | /************** End of mem0.c ************************************************/ |
| 14814 | 14914 | /************** Begin file mem1.c ********************************************/ |
| 14915 | +#line 1 "tsrc/mem1.c" | |
| 14815 | 14916 | /* |
| 14816 | 14917 | ** 2007 August 14 |
| 14817 | 14918 | ** |
| 14818 | 14919 | ** The author disclaims copyright to this source code. In place of |
| 14819 | 14920 | ** a legal notice, here is a blessing: |
| @@ -14962,10 +15063,11 @@ | ||
| 14962 | 15063 | |
| 14963 | 15064 | #endif /* SQLITE_SYSTEM_MALLOC */ |
| 14964 | 15065 | |
| 14965 | 15066 | /************** End of mem1.c ************************************************/ |
| 14966 | 15067 | /************** Begin file mem2.c ********************************************/ |
| 15068 | +#line 1 "tsrc/mem2.c" | |
| 14967 | 15069 | /* |
| 14968 | 15070 | ** 2007 August 15 |
| 14969 | 15071 | ** |
| 14970 | 15072 | ** The author disclaims copyright to this source code. In place of |
| 14971 | 15073 | ** a legal notice, here is a blessing: |
| @@ -15492,10 +15594,11 @@ | ||
| 15492 | 15594 | |
| 15493 | 15595 | #endif /* SQLITE_MEMDEBUG */ |
| 15494 | 15596 | |
| 15495 | 15597 | /************** End of mem2.c ************************************************/ |
| 15496 | 15598 | /************** Begin file mem3.c ********************************************/ |
| 15599 | +#line 1 "tsrc/mem3.c" | |
| 15497 | 15600 | /* |
| 15498 | 15601 | ** 2007 October 14 |
| 15499 | 15602 | ** |
| 15500 | 15603 | ** The author disclaims copyright to this source code. In place of |
| 15501 | 15604 | ** a legal notice, here is a blessing: |
| @@ -16181,10 +16284,11 @@ | ||
| 16181 | 16284 | |
| 16182 | 16285 | #endif /* SQLITE_ENABLE_MEMSYS3 */ |
| 16183 | 16286 | |
| 16184 | 16287 | /************** End of mem3.c ************************************************/ |
| 16185 | 16288 | /************** Begin file mem5.c ********************************************/ |
| 16289 | +#line 1 "tsrc/mem5.c" | |
| 16186 | 16290 | /* |
| 16187 | 16291 | ** 2007 October 14 |
| 16188 | 16292 | ** |
| 16189 | 16293 | ** The author disclaims copyright to this source code. In place of |
| 16190 | 16294 | ** a legal notice, here is a blessing: |
| @@ -16764,10 +16868,11 @@ | ||
| 16764 | 16868 | |
| 16765 | 16869 | #endif /* SQLITE_ENABLE_MEMSYS5 */ |
| 16766 | 16870 | |
| 16767 | 16871 | /************** End of mem5.c ************************************************/ |
| 16768 | 16872 | /************** Begin file mutex.c *******************************************/ |
| 16873 | +#line 1 "tsrc/mutex.c" | |
| 16769 | 16874 | /* |
| 16770 | 16875 | ** 2007 August 14 |
| 16771 | 16876 | ** |
| 16772 | 16877 | ** The author disclaims copyright to this source code. In place of |
| 16773 | 16878 | ** a legal notice, here is a blessing: |
| @@ -16919,10 +17024,11 @@ | ||
| 16919 | 17024 | |
| 16920 | 17025 | #endif /* SQLITE_MUTEX_OMIT */ |
| 16921 | 17026 | |
| 16922 | 17027 | /************** End of mutex.c ***********************************************/ |
| 16923 | 17028 | /************** Begin file mutex_noop.c **************************************/ |
| 17029 | +#line 1 "tsrc/mutex_noop.c" | |
| 16924 | 17030 | /* |
| 16925 | 17031 | ** 2008 October 07 |
| 16926 | 17032 | ** |
| 16927 | 17033 | ** The author disclaims copyright to this source code. In place of |
| 16928 | 17034 | ** a legal notice, here is a blessing: |
| @@ -17127,10 +17233,11 @@ | ||
| 17127 | 17233 | #endif /* SQLITE_MUTEX_NOOP */ |
| 17128 | 17234 | #endif /* SQLITE_MUTEX_OMIT */ |
| 17129 | 17235 | |
| 17130 | 17236 | /************** End of mutex_noop.c ******************************************/ |
| 17131 | 17237 | /************** Begin file mutex_os2.c ***************************************/ |
| 17238 | +#line 1 "tsrc/mutex_os2.c" | |
| 17132 | 17239 | /* |
| 17133 | 17240 | ** 2007 August 28 |
| 17134 | 17241 | ** |
| 17135 | 17242 | ** The author disclaims copyright to this source code. In place of |
| 17136 | 17243 | ** a legal notice, here is a blessing: |
| @@ -17403,10 +17510,11 @@ | ||
| 17403 | 17510 | } |
| 17404 | 17511 | #endif /* SQLITE_MUTEX_OS2 */ |
| 17405 | 17512 | |
| 17406 | 17513 | /************** End of mutex_os2.c *******************************************/ |
| 17407 | 17514 | /************** Begin file mutex_unix.c **************************************/ |
| 17515 | +#line 1 "tsrc/mutex_unix.c" | |
| 17408 | 17516 | /* |
| 17409 | 17517 | ** 2007 August 28 |
| 17410 | 17518 | ** |
| 17411 | 17519 | ** The author disclaims copyright to this source code. In place of |
| 17412 | 17520 | ** a legal notice, here is a blessing: |
| @@ -17756,10 +17864,11 @@ | ||
| 17756 | 17864 | |
| 17757 | 17865 | #endif /* SQLITE_MUTEX_PTHREAD */ |
| 17758 | 17866 | |
| 17759 | 17867 | /************** End of mutex_unix.c ******************************************/ |
| 17760 | 17868 | /************** Begin file mutex_w32.c ***************************************/ |
| 17869 | +#line 1 "tsrc/mutex_w32.c" | |
| 17761 | 17870 | /* |
| 17762 | 17871 | ** 2007 August 14 |
| 17763 | 17872 | ** |
| 17764 | 17873 | ** The author disclaims copyright to this source code. In place of |
| 17765 | 17874 | ** a legal notice, here is a blessing: |
| @@ -18090,10 +18199,11 @@ | ||
| 18090 | 18199 | } |
| 18091 | 18200 | #endif /* SQLITE_MUTEX_W32 */ |
| 18092 | 18201 | |
| 18093 | 18202 | /************** End of mutex_w32.c *******************************************/ |
| 18094 | 18203 | /************** Begin file malloc.c ******************************************/ |
| 18204 | +#line 1 "tsrc/malloc.c" | |
| 18095 | 18205 | /* |
| 18096 | 18206 | ** 2001 September 15 |
| 18097 | 18207 | ** |
| 18098 | 18208 | ** The author disclaims copyright to this source code. In place of |
| 18099 | 18209 | ** a legal notice, here is a blessing: |
| @@ -18869,10 +18979,11 @@ | ||
| 18869 | 18979 | return rc & (db ? db->errMask : 0xff); |
| 18870 | 18980 | } |
| 18871 | 18981 | |
| 18872 | 18982 | /************** End of malloc.c **********************************************/ |
| 18873 | 18983 | /************** Begin file printf.c ******************************************/ |
| 18984 | +#line 1 "tsrc/printf.c" | |
| 18874 | 18985 | /* |
| 18875 | 18986 | ** The "printf" code that follows dates from the 1980's. It is in |
| 18876 | 18987 | ** the public domain. The original comments are included here for |
| 18877 | 18988 | ** completeness. They are very out-of-date but might be useful as |
| 18878 | 18989 | ** an historical reference. Most of the "enhancements" have been backed |
| @@ -19900,10 +20011,11 @@ | ||
| 19900 | 20011 | } |
| 19901 | 20012 | #endif |
| 19902 | 20013 | |
| 19903 | 20014 | /************** End of printf.c **********************************************/ |
| 19904 | 20015 | /************** Begin file random.c ******************************************/ |
| 20016 | +#line 1 "tsrc/random.c" | |
| 19905 | 20017 | /* |
| 19906 | 20018 | ** 2001 September 15 |
| 19907 | 20019 | ** |
| 19908 | 20020 | ** The author disclaims copyright to this source code. In place of |
| 19909 | 20021 | ** a legal notice, here is a blessing: |
| @@ -20047,10 +20159,11 @@ | ||
| 20047 | 20159 | } |
| 20048 | 20160 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 20049 | 20161 | |
| 20050 | 20162 | /************** End of random.c **********************************************/ |
| 20051 | 20163 | /************** Begin file utf.c *********************************************/ |
| 20164 | +#line 1 "tsrc/utf.c" | |
| 20052 | 20165 | /* |
| 20053 | 20166 | ** 2004 April 13 |
| 20054 | 20167 | ** |
| 20055 | 20168 | ** The author disclaims copyright to this source code. In place of |
| 20056 | 20169 | ** a legal notice, here is a blessing: |
| @@ -20511,11 +20624,11 @@ | ||
| 20511 | 20624 | ** no longer required. |
| 20512 | 20625 | ** |
| 20513 | 20626 | ** If a malloc failure occurs, NULL is returned and the db.mallocFailed |
| 20514 | 20627 | ** flag set. |
| 20515 | 20628 | */ |
| 20516 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 20629 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 20517 | 20630 | SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *db, u8 enc, char *z, int n, int *pnOut){ |
| 20518 | 20631 | Mem m; |
| 20519 | 20632 | memset(&m, 0, sizeof(m)); |
| 20520 | 20633 | m.db = db; |
| 20521 | 20634 | sqlite3VdbeMemSetStr(&m, z, n, SQLITE_UTF8, SQLITE_STATIC); |
| @@ -20608,10 +20721,11 @@ | ||
| 20608 | 20721 | #endif /* SQLITE_TEST */ |
| 20609 | 20722 | #endif /* SQLITE_OMIT_UTF16 */ |
| 20610 | 20723 | |
| 20611 | 20724 | /************** End of utf.c *************************************************/ |
| 20612 | 20725 | /************** Begin file util.c ********************************************/ |
| 20726 | +#line 1 "tsrc/util.c" | |
| 20613 | 20727 | /* |
| 20614 | 20728 | ** 2001 September 15 |
| 20615 | 20729 | ** |
| 20616 | 20730 | ** The author disclaims copyright to this source code. In place of |
| 20617 | 20731 | ** a legal notice, here is a blessing: |
| @@ -21790,10 +21904,11 @@ | ||
| 21790 | 21904 | } |
| 21791 | 21905 | #endif |
| 21792 | 21906 | |
| 21793 | 21907 | /************** End of util.c ************************************************/ |
| 21794 | 21908 | /************** Begin file hash.c ********************************************/ |
| 21909 | +#line 1 "tsrc/hash.c" | |
| 21795 | 21910 | /* |
| 21796 | 21911 | ** 2001 September 22 |
| 21797 | 21912 | ** |
| 21798 | 21913 | ** The author disclaims copyright to this source code. In place of |
| 21799 | 21914 | ** a legal notice, here is a blessing: |
| @@ -22069,10 +22184,11 @@ | ||
| 22069 | 22184 | return 0; |
| 22070 | 22185 | } |
| 22071 | 22186 | |
| 22072 | 22187 | /************** End of hash.c ************************************************/ |
| 22073 | 22188 | /************** Begin file opcodes.c *****************************************/ |
| 22189 | +#line 1 "tsrc/opcodes.c" | |
| 22074 | 22190 | /* Automatically generated. Do not edit */ |
| 22075 | 22191 | /* See the mkopcodec.awk script for details. */ |
| 22076 | 22192 | #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) |
| 22077 | 22193 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ |
| 22078 | 22194 | static const char *const azName[] = { "?", |
| @@ -22231,10 +22347,11 @@ | ||
| 22231 | 22347 | } |
| 22232 | 22348 | #endif |
| 22233 | 22349 | |
| 22234 | 22350 | /************** End of opcodes.c *********************************************/ |
| 22235 | 22351 | /************** Begin file os_os2.c ******************************************/ |
| 22352 | +#line 1 "tsrc/os_os2.c" | |
| 22236 | 22353 | /* |
| 22237 | 22354 | ** 2006 Feb 14 |
| 22238 | 22355 | ** |
| 22239 | 22356 | ** The author disclaims copyright to this source code. In place of |
| 22240 | 22357 | ** a legal notice, here is a blessing: |
| @@ -22287,10 +22404,11 @@ | ||
| 22287 | 22404 | /* |
| 22288 | 22405 | ** Include code that is common to all os_*.c files |
| 22289 | 22406 | */ |
| 22290 | 22407 | /************** Include os_common.h in the middle of os_os2.c ****************/ |
| 22291 | 22408 | /************** Begin file os_common.h ***************************************/ |
| 22409 | +#line 1 "tsrc/os_common.h" | |
| 22292 | 22410 | /* |
| 22293 | 22411 | ** 2004 May 22 |
| 22294 | 22412 | ** |
| 22295 | 22413 | ** The author disclaims copyright to this source code. In place of |
| 22296 | 22414 | ** a legal notice, here is a blessing: |
| @@ -22340,10 +22458,11 @@ | ||
| 22340 | 22458 | ** hwtime.h contains inline assembler code for implementing |
| 22341 | 22459 | ** high-performance timing routines. |
| 22342 | 22460 | */ |
| 22343 | 22461 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 22344 | 22462 | /************** Begin file hwtime.h ******************************************/ |
| 22463 | +#line 1 "tsrc/hwtime.h" | |
| 22345 | 22464 | /* |
| 22346 | 22465 | ** 2008 May 27 |
| 22347 | 22466 | ** |
| 22348 | 22467 | ** The author disclaims copyright to this source code. In place of |
| 22349 | 22468 | ** a legal notice, here is a blessing: |
| @@ -22428,10 +22547,11 @@ | ||
| 22428 | 22547 | |
| 22429 | 22548 | #endif /* !defined(_HWTIME_H_) */ |
| 22430 | 22549 | |
| 22431 | 22550 | /************** End of hwtime.h **********************************************/ |
| 22432 | 22551 | /************** Continuing where we left off in os_common.h ******************/ |
| 22552 | +#line 53 "tsrc/os_common.h" | |
| 22433 | 22553 | |
| 22434 | 22554 | static sqlite_uint64 g_start; |
| 22435 | 22555 | static sqlite_uint64 g_elapsed; |
| 22436 | 22556 | #define TIMER_START g_start=sqlite3Hwtime() |
| 22437 | 22557 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -22494,10 +22614,11 @@ | ||
| 22494 | 22614 | |
| 22495 | 22615 | #endif /* !defined(_OS_COMMON_H_) */ |
| 22496 | 22616 | |
| 22497 | 22617 | /************** End of os_common.h *******************************************/ |
| 22498 | 22618 | /************** Continuing where we left off in os_os2.c *********************/ |
| 22619 | +#line 57 "tsrc/os_os2.c" | |
| 22499 | 22620 | |
| 22500 | 22621 | /* Forward references */ |
| 22501 | 22622 | typedef struct os2File os2File; /* The file structure */ |
| 22502 | 22623 | typedef struct os2ShmNode os2ShmNode; /* A shared descritive memory node */ |
| 22503 | 22624 | typedef struct os2ShmLink os2ShmLink; /* A connection to shared-memory */ |
| @@ -24365,10 +24486,11 @@ | ||
| 24365 | 24486 | |
| 24366 | 24487 | #endif /* SQLITE_OS_OS2 */ |
| 24367 | 24488 | |
| 24368 | 24489 | /************** End of os_os2.c **********************************************/ |
| 24369 | 24490 | /************** Begin file os_unix.c *****************************************/ |
| 24491 | +#line 1 "tsrc/os_unix.c" | |
| 24370 | 24492 | /* |
| 24371 | 24493 | ** 2004 May 22 |
| 24372 | 24494 | ** |
| 24373 | 24495 | ** The author disclaims copyright to this source code. In place of |
| 24374 | 24496 | ** a legal notice, here is a blessing: |
| @@ -24629,10 +24751,11 @@ | ||
| 24629 | 24751 | /* |
| 24630 | 24752 | ** Include code that is common to all os_*.c files |
| 24631 | 24753 | */ |
| 24632 | 24754 | /************** Include os_common.h in the middle of os_unix.c ***************/ |
| 24633 | 24755 | /************** Begin file os_common.h ***************************************/ |
| 24756 | +#line 1 "tsrc/os_common.h" | |
| 24634 | 24757 | /* |
| 24635 | 24758 | ** 2004 May 22 |
| 24636 | 24759 | ** |
| 24637 | 24760 | ** The author disclaims copyright to this source code. In place of |
| 24638 | 24761 | ** a legal notice, here is a blessing: |
| @@ -24682,10 +24805,11 @@ | ||
| 24682 | 24805 | ** hwtime.h contains inline assembler code for implementing |
| 24683 | 24806 | ** high-performance timing routines. |
| 24684 | 24807 | */ |
| 24685 | 24808 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 24686 | 24809 | /************** Begin file hwtime.h ******************************************/ |
| 24810 | +#line 1 "tsrc/hwtime.h" | |
| 24687 | 24811 | /* |
| 24688 | 24812 | ** 2008 May 27 |
| 24689 | 24813 | ** |
| 24690 | 24814 | ** The author disclaims copyright to this source code. In place of |
| 24691 | 24815 | ** a legal notice, here is a blessing: |
| @@ -24770,10 +24894,11 @@ | ||
| 24770 | 24894 | |
| 24771 | 24895 | #endif /* !defined(_HWTIME_H_) */ |
| 24772 | 24896 | |
| 24773 | 24897 | /************** End of hwtime.h **********************************************/ |
| 24774 | 24898 | /************** Continuing where we left off in os_common.h ******************/ |
| 24899 | +#line 53 "tsrc/os_common.h" | |
| 24775 | 24900 | |
| 24776 | 24901 | static sqlite_uint64 g_start; |
| 24777 | 24902 | static sqlite_uint64 g_elapsed; |
| 24778 | 24903 | #define TIMER_START g_start=sqlite3Hwtime() |
| 24779 | 24904 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -24836,10 +24961,11 @@ | ||
| 24836 | 24961 | |
| 24837 | 24962 | #endif /* !defined(_OS_COMMON_H_) */ |
| 24838 | 24963 | |
| 24839 | 24964 | /************** End of os_common.h *******************************************/ |
| 24840 | 24965 | /************** Continuing where we left off in os_unix.c ********************/ |
| 24966 | +#line 265 "tsrc/os_unix.c" | |
| 24841 | 24967 | |
| 24842 | 24968 | /* |
| 24843 | 24969 | ** Define various macros that are missing from some systems. |
| 24844 | 24970 | */ |
| 24845 | 24971 | #ifndef O_LARGEFILE |
| @@ -29462,12 +29588,20 @@ | ||
| 29462 | 29588 | ** |
| 29463 | 29589 | ** where NN is a 4 digit decimal number. The NN naming schemes are |
| 29464 | 29590 | ** used by the test_multiplex.c module. |
| 29465 | 29591 | */ |
| 29466 | 29592 | nDb = sqlite3Strlen30(zPath) - 1; |
| 29467 | - while( nDb>0 && zPath[nDb]!='-' ) nDb--; | |
| 29468 | - if( nDb==0 ) return SQLITE_OK; | |
| 29593 | +#ifdef SQLITE_ENABLE_8_3_NAMES | |
| 29594 | + while( nDb>0 && zPath[nDb]!='-' && zPath[nDb]!='/' ) nDb--; | |
| 29595 | + if( nDb==0 || zPath[nDb]=='/' ) return SQLITE_OK; | |
| 29596 | +#else | |
| 29597 | + while( zPath[nDb]!='-' ){ | |
| 29598 | + assert( nDb>0 ); | |
| 29599 | + assert( zPath[nDb]!='\n' ); | |
| 29600 | + nDb--; | |
| 29601 | + } | |
| 29602 | +#endif | |
| 29469 | 29603 | memcpy(zDb, zPath, nDb); |
| 29470 | 29604 | zDb[nDb] = '\0'; |
| 29471 | 29605 | |
| 29472 | 29606 | if( 0==osStat(zDb, &sStat) ){ |
| 29473 | 29607 | *pMode = sStat.st_mode & 0777; |
| @@ -31345,10 +31479,11 @@ | ||
| 31345 | 31479 | |
| 31346 | 31480 | #endif /* SQLITE_OS_UNIX */ |
| 31347 | 31481 | |
| 31348 | 31482 | /************** End of os_unix.c *********************************************/ |
| 31349 | 31483 | /************** Begin file os_win.c ******************************************/ |
| 31484 | +#line 1 "tsrc/os_win.c" | |
| 31350 | 31485 | /* |
| 31351 | 31486 | ** 2004 May 22 |
| 31352 | 31487 | ** |
| 31353 | 31488 | ** The author disclaims copyright to this source code. In place of |
| 31354 | 31489 | ** a legal notice, here is a blessing: |
| @@ -31406,10 +31541,11 @@ | ||
| 31406 | 31541 | /* |
| 31407 | 31542 | ** Include code that is common to all os_*.c files |
| 31408 | 31543 | */ |
| 31409 | 31544 | /************** Include os_common.h in the middle of os_win.c ****************/ |
| 31410 | 31545 | /************** Begin file os_common.h ***************************************/ |
| 31546 | +#line 1 "tsrc/os_common.h" | |
| 31411 | 31547 | /* |
| 31412 | 31548 | ** 2004 May 22 |
| 31413 | 31549 | ** |
| 31414 | 31550 | ** The author disclaims copyright to this source code. In place of |
| 31415 | 31551 | ** a legal notice, here is a blessing: |
| @@ -31459,10 +31595,11 @@ | ||
| 31459 | 31595 | ** hwtime.h contains inline assembler code for implementing |
| 31460 | 31596 | ** high-performance timing routines. |
| 31461 | 31597 | */ |
| 31462 | 31598 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 31463 | 31599 | /************** Begin file hwtime.h ******************************************/ |
| 31600 | +#line 1 "tsrc/hwtime.h" | |
| 31464 | 31601 | /* |
| 31465 | 31602 | ** 2008 May 27 |
| 31466 | 31603 | ** |
| 31467 | 31604 | ** The author disclaims copyright to this source code. In place of |
| 31468 | 31605 | ** a legal notice, here is a blessing: |
| @@ -31547,10 +31684,11 @@ | ||
| 31547 | 31684 | |
| 31548 | 31685 | #endif /* !defined(_HWTIME_H_) */ |
| 31549 | 31686 | |
| 31550 | 31687 | /************** End of hwtime.h **********************************************/ |
| 31551 | 31688 | /************** Continuing where we left off in os_common.h ******************/ |
| 31689 | +#line 53 "tsrc/os_common.h" | |
| 31552 | 31690 | |
| 31553 | 31691 | static sqlite_uint64 g_start; |
| 31554 | 31692 | static sqlite_uint64 g_elapsed; |
| 31555 | 31693 | #define TIMER_START g_start=sqlite3Hwtime() |
| 31556 | 31694 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -31613,10 +31751,11 @@ | ||
| 31613 | 31751 | |
| 31614 | 31752 | #endif /* !defined(_OS_COMMON_H_) */ |
| 31615 | 31753 | |
| 31616 | 31754 | /************** End of os_common.h *******************************************/ |
| 31617 | 31755 | /************** Continuing where we left off in os_win.c *********************/ |
| 31756 | +#line 62 "tsrc/os_win.c" | |
| 31618 | 31757 | |
| 31619 | 31758 | /* |
| 31620 | 31759 | ** Some microsoft compilers lack this definition. |
| 31621 | 31760 | */ |
| 31622 | 31761 | #ifndef INVALID_FILE_ATTRIBUTES |
| @@ -34169,11 +34308,11 @@ | ||
| 34169 | 34308 | |
| 34170 | 34309 | if( h==INVALID_HANDLE_VALUE ){ |
| 34171 | 34310 | pFile->lastErrno = GetLastError(); |
| 34172 | 34311 | winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); |
| 34173 | 34312 | free(zConverted); |
| 34174 | - if( isReadWrite ){ | |
| 34313 | + if( isReadWrite && !isExclusive ){ | |
| 34175 | 34314 | return winOpen(pVfs, zName, id, |
| 34176 | 34315 | ((flags|SQLITE_OPEN_READONLY)&~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), pOutFlags); |
| 34177 | 34316 | }else{ |
| 34178 | 34317 | return SQLITE_CANTOPEN_BKPT; |
| 34179 | 34318 | } |
| @@ -34758,10 +34897,11 @@ | ||
| 34758 | 34897 | |
| 34759 | 34898 | #endif /* SQLITE_OS_WIN */ |
| 34760 | 34899 | |
| 34761 | 34900 | /************** End of os_win.c **********************************************/ |
| 34762 | 34901 | /************** Begin file bitvec.c ******************************************/ |
| 34902 | +#line 1 "tsrc/bitvec.c" | |
| 34763 | 34903 | /* |
| 34764 | 34904 | ** 2008 February 16 |
| 34765 | 34905 | ** |
| 34766 | 34906 | ** The author disclaims copyright to this source code. In place of |
| 34767 | 34907 | ** a legal notice, here is a blessing: |
| @@ -35168,10 +35308,11 @@ | ||
| 35168 | 35308 | } |
| 35169 | 35309 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 35170 | 35310 | |
| 35171 | 35311 | /************** End of bitvec.c **********************************************/ |
| 35172 | 35312 | /************** Begin file pcache.c ******************************************/ |
| 35313 | +#line 1 "tsrc/pcache.c" | |
| 35173 | 35314 | /* |
| 35174 | 35315 | ** 2008 August 05 |
| 35175 | 35316 | ** |
| 35176 | 35317 | ** The author disclaims copyright to this source code. In place of |
| 35177 | 35318 | ** a legal notice, here is a blessing: |
| @@ -35764,10 +35905,11 @@ | ||
| 35764 | 35905 | } |
| 35765 | 35906 | #endif |
| 35766 | 35907 | |
| 35767 | 35908 | /************** End of pcache.c **********************************************/ |
| 35768 | 35909 | /************** Begin file pcache1.c *****************************************/ |
| 35910 | +#line 1 "tsrc/pcache1.c" | |
| 35769 | 35911 | /* |
| 35770 | 35912 | ** 2008 November 05 |
| 35771 | 35913 | ** |
| 35772 | 35914 | ** The author disclaims copyright to this source code. In place of |
| 35773 | 35915 | ** a legal notice, here is a blessing: |
| @@ -35789,12 +35931,10 @@ | ||
| 35789 | 35931 | typedef struct PCache1 PCache1; |
| 35790 | 35932 | typedef struct PgHdr1 PgHdr1; |
| 35791 | 35933 | typedef struct PgFreeslot PgFreeslot; |
| 35792 | 35934 | typedef struct PGroup PGroup; |
| 35793 | 35935 | |
| 35794 | -typedef struct PGroupBlock PGroupBlock; | |
| 35795 | -typedef struct PGroupBlockList PGroupBlockList; | |
| 35796 | 35936 | |
| 35797 | 35937 | /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set |
| 35798 | 35938 | ** of one or more PCaches that are able to recycle each others unpinned |
| 35799 | 35939 | ** pages when they are under memory pressure. A PGroup is an instance of |
| 35800 | 35940 | ** the following object. |
| @@ -35821,69 +35961,11 @@ | ||
| 35821 | 35961 | int nMaxPage; /* Sum of nMax for purgeable caches */ |
| 35822 | 35962 | int nMinPage; /* Sum of nMin for purgeable caches */ |
| 35823 | 35963 | int mxPinned; /* nMaxpage + 10 - nMinPage */ |
| 35824 | 35964 | int nCurrentPage; /* Number of purgeable pages allocated */ |
| 35825 | 35965 | PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ |
| 35826 | -#ifdef SQLITE_PAGECACHE_BLOCKALLOC | |
| 35827 | - int isBusy; /* Do not run ReleaseMemory() if true */ | |
| 35828 | - PGroupBlockList *pBlockList; /* List of block-lists for this group */ | |
| 35829 | -#endif | |
| 35830 | -}; | |
| 35831 | - | |
| 35832 | -/* | |
| 35833 | -** If SQLITE_PAGECACHE_BLOCKALLOC is defined when the library is built, | |
| 35834 | -** each PGroup structure has a linked list of the the following starting | |
| 35835 | -** at PGroup.pBlockList. There is one entry for each distinct page-size | |
| 35836 | -** currently used by members of the PGroup (i.e. 1024 bytes, 4096 bytes | |
| 35837 | -** etc.). Variable PGroupBlockList.nByte is set to the actual allocation | |
| 35838 | -** size requested by each pcache, which is the database page-size plus | |
| 35839 | -** the various header structures used by the pcache, pager and btree layers. | |
| 35840 | -** Usually around (pgsz+200) bytes. | |
| 35841 | -** | |
| 35842 | -** This size (pgsz+200) bytes is not allocated efficiently by some | |
| 35843 | -** implementations of malloc. In particular, some implementations are only | |
| 35844 | -** able to allocate blocks of memory chunks of 2^N bytes, where N is some | |
| 35845 | -** integer value. Since the page-size is a power of 2, this means we | |
| 35846 | -** end up wasting (pgsz-200) bytes in each allocation. | |
| 35847 | -** | |
| 35848 | -** If SQLITE_PAGECACHE_BLOCKALLOC is defined, the (pgsz+200) byte blocks | |
| 35849 | -** are not allocated directly. Instead, blocks of roughly M*(pgsz+200) bytes | |
| 35850 | -** are requested from malloc allocator. After a block is returned, | |
| 35851 | -** sqlite3MallocSize() is used to determine how many (pgsz+200) byte | |
| 35852 | -** allocations can fit in the space returned by malloc(). This value may | |
| 35853 | -** be more than M. | |
| 35854 | -** | |
| 35855 | -** The blocks are stored in a doubly-linked list. Variable PGroupBlock.nEntry | |
| 35856 | -** contains the number of allocations that will fit in the aData[] space. | |
| 35857 | -** nEntry is limited to the number of bits in bitmask mUsed. If a slot | |
| 35858 | -** within aData is in use, the corresponding bit in mUsed is set. Thus | |
| 35859 | -** when (mUsed+1==(1 << nEntry)) the block is completely full. | |
| 35860 | -** | |
| 35861 | -** Each time a slot within a block is freed, the block is moved to the start | |
| 35862 | -** of the linked-list. And if a block becomes completely full, then it is | |
| 35863 | -** moved to the end of the list. As a result, when searching for a free | |
| 35864 | -** slot, only the first block in the list need be examined. If it is full, | |
| 35865 | -** then it is guaranteed that all blocks are full. | |
| 35866 | -*/ | |
| 35867 | -struct PGroupBlockList { | |
| 35868 | - int nByte; /* Size of each allocation in bytes */ | |
| 35869 | - PGroupBlock *pFirst; /* First PGroupBlock in list */ | |
| 35870 | - PGroupBlock *pLast; /* Last PGroupBlock in list */ | |
| 35871 | - PGroupBlockList *pNext; /* Next block-list attached to group */ | |
| 35872 | -}; | |
| 35873 | - | |
| 35874 | -struct PGroupBlock { | |
| 35875 | - Bitmask mUsed; /* Mask of used slots */ | |
| 35876 | - int nEntry; /* Maximum number of allocations in aData[] */ | |
| 35877 | - u8 *aData; /* Pointer to data block */ | |
| 35878 | - PGroupBlock *pNext; /* Next PGroupBlock in list */ | |
| 35879 | - PGroupBlock *pPrev; /* Previous PGroupBlock in list */ | |
| 35880 | - PGroupBlockList *pList; /* Owner list */ | |
| 35881 | -}; | |
| 35882 | - | |
| 35883 | -/* Minimum value for PGroupBlock.nEntry */ | |
| 35884 | -#define PAGECACHE_BLOCKALLOC_MINENTRY 15 | |
| 35966 | +}; | |
| 35885 | 35967 | |
| 35886 | 35968 | /* Each page cache is an instance of the following object. Every |
| 35887 | 35969 | ** open database file (including each in-memory database and each |
| 35888 | 35970 | ** temporary or transient database) has a single page cache which |
| 35889 | 35971 | ** is an instance of this object. |
| @@ -35983,21 +36065,10 @@ | ||
| 35983 | 36065 | ** |
| 35984 | 36066 | ** assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X ); |
| 35985 | 36067 | */ |
| 35986 | 36068 | #define PGHDR1_TO_PAGE(p) (void*)(((char*)p) - p->pCache->szPage) |
| 35987 | 36069 | #define PAGE_TO_PGHDR1(c, p) (PgHdr1*)(((char*)p) + c->szPage) |
| 35988 | - | |
| 35989 | -/* | |
| 35990 | -** Blocks used by the SQLITE_PAGECACHE_BLOCKALLOC blocks to store/retrieve | |
| 35991 | -** a PGroupBlock pointer based on a pointer to a page buffer. | |
| 35992 | -*/ | |
| 35993 | -#define PAGE_SET_BLOCKPTR(pCache, pPg, pBlock) \ | |
| 35994 | - ( *(PGroupBlock **)&(((u8*)pPg)[sizeof(PgHdr1) + pCache->szPage]) = pBlock ) | |
| 35995 | - | |
| 35996 | -#define PAGE_GET_BLOCKPTR(pCache, pPg) \ | |
| 35997 | - ( *(PGroupBlock **)&(((u8*)pPg)[sizeof(PgHdr1) + pCache->szPage]) ) | |
| 35998 | - | |
| 35999 | 36070 | |
| 36000 | 36071 | /* |
| 36001 | 36072 | ** Macros to enter and leave the PCache LRU mutex. |
| 36002 | 36073 | */ |
| 36003 | 36074 | #define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex) |
| @@ -36120,159 +36191,32 @@ | ||
| 36120 | 36191 | return iSize; |
| 36121 | 36192 | } |
| 36122 | 36193 | } |
| 36123 | 36194 | #endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */ |
| 36124 | 36195 | |
| 36125 | -#ifdef SQLITE_PAGECACHE_BLOCKALLOC | |
| 36126 | -/* | |
| 36127 | -** The block pBlock belongs to list pList but is not currently linked in. | |
| 36128 | -** Insert it into the start of the list. | |
| 36129 | -*/ | |
| 36130 | -static void addBlockToList(PGroupBlockList *pList, PGroupBlock *pBlock){ | |
| 36131 | - pBlock->pPrev = 0; | |
| 36132 | - pBlock->pNext = pList->pFirst; | |
| 36133 | - pList->pFirst = pBlock; | |
| 36134 | - if( pBlock->pNext ){ | |
| 36135 | - pBlock->pNext->pPrev = pBlock; | |
| 36136 | - }else{ | |
| 36137 | - assert( pList->pLast==0 ); | |
| 36138 | - pList->pLast = pBlock; | |
| 36139 | - } | |
| 36140 | -} | |
| 36141 | - | |
| 36142 | -/* | |
| 36143 | -** If there are no blocks in the list headed by pList, remove pList | |
| 36144 | -** from the pGroup->pBlockList list and free it with sqlite3_free(). | |
| 36145 | -*/ | |
| 36146 | -static void freeListIfEmpty(PGroup *pGroup, PGroupBlockList *pList){ | |
| 36147 | - assert( sqlite3_mutex_held(pGroup->mutex) ); | |
| 36148 | - if( pList->pFirst==0 ){ | |
| 36149 | - PGroupBlockList **pp; | |
| 36150 | - for(pp=&pGroup->pBlockList; *pp!=pList; pp=&(*pp)->pNext); | |
| 36151 | - *pp = (*pp)->pNext; | |
| 36152 | - sqlite3_free(pList); | |
| 36153 | - } | |
| 36154 | -} | |
| 36155 | -#endif /* SQLITE_PAGECACHE_BLOCKALLOC */ | |
| 36156 | - | |
| 36157 | 36196 | /* |
| 36158 | 36197 | ** Allocate a new page object initially associated with cache pCache. |
| 36159 | 36198 | */ |
| 36160 | 36199 | static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ |
| 36161 | 36200 | int nByte = sizeof(PgHdr1) + pCache->szPage; |
| 36162 | - void *pPg = 0; | |
| 36163 | - PgHdr1 *p; | |
| 36164 | - | |
| 36165 | -#ifdef SQLITE_PAGECACHE_BLOCKALLOC | |
| 36166 | - PGroup *pGroup = pCache->pGroup; | |
| 36167 | - PGroupBlockList *pList; | |
| 36168 | - PGroupBlock *pBlock; | |
| 36169 | - int i; | |
| 36170 | - | |
| 36171 | - nByte += sizeof(PGroupBlockList *); | |
| 36172 | - nByte = ROUND8(nByte); | |
| 36173 | - | |
| 36174 | - for(pList=pGroup->pBlockList; pList; pList=pList->pNext){ | |
| 36175 | - if( pList->nByte==nByte ) break; | |
| 36176 | - } | |
| 36177 | - if( pList==0 ){ | |
| 36178 | - PGroupBlockList *pNew; | |
| 36179 | - assert( pGroup->isBusy==0 ); | |
| 36180 | - assert( sqlite3_mutex_held(pGroup->mutex) ); | |
| 36181 | - pGroup->isBusy = 1; /* Disable sqlite3PcacheReleaseMemory() */ | |
| 36182 | - pNew = (PGroupBlockList *)sqlite3MallocZero(sizeof(PGroupBlockList)); | |
| 36183 | - pGroup->isBusy = 0; /* Reenable sqlite3PcacheReleaseMemory() */ | |
| 36184 | - if( pNew==0 ){ | |
| 36185 | - /* malloc() failure. Return early. */ | |
| 36186 | - return 0; | |
| 36187 | - } | |
| 36188 | -#ifdef SQLITE_DEBUG | |
| 36189 | - for(pList=pGroup->pBlockList; pList; pList=pList->pNext){ | |
| 36190 | - assert( pList->nByte!=nByte ); | |
| 36191 | - } | |
| 36192 | -#endif | |
| 36193 | - pNew->nByte = nByte; | |
| 36194 | - pNew->pNext = pGroup->pBlockList; | |
| 36195 | - pGroup->pBlockList = pNew; | |
| 36196 | - pList = pNew; | |
| 36197 | - } | |
| 36198 | - | |
| 36199 | - pBlock = pList->pFirst; | |
| 36200 | - if( pBlock==0 || pBlock->mUsed==(((Bitmask)1<<pBlock->nEntry)-1) ){ | |
| 36201 | - int sz; | |
| 36202 | - | |
| 36203 | - /* Allocate a new block. Try to allocate enough space for the PGroupBlock | |
| 36204 | - ** structure and MINENTRY allocations of nByte bytes each. If the | |
| 36205 | - ** allocator returns more memory than requested, then more than MINENTRY | |
| 36206 | - ** allocations may fit in it. */ | |
| 36207 | - assert( sqlite3_mutex_held(pGroup->mutex) ); | |
| 36208 | - pcache1LeaveMutex(pCache->pGroup); | |
| 36209 | - sz = sizeof(PGroupBlock) + PAGECACHE_BLOCKALLOC_MINENTRY * nByte; | |
| 36210 | - pBlock = (PGroupBlock *)sqlite3Malloc(sz); | |
| 36211 | - pcache1EnterMutex(pCache->pGroup); | |
| 36212 | - | |
| 36213 | - if( !pBlock ){ | |
| 36214 | - freeListIfEmpty(pGroup, pList); | |
| 36215 | - return 0; | |
| 36216 | - } | |
| 36217 | - pBlock->nEntry = (sqlite3MallocSize(pBlock) - sizeof(PGroupBlock)) / nByte; | |
| 36218 | - if( pBlock->nEntry>=BMS ){ | |
| 36219 | - pBlock->nEntry = BMS-1; | |
| 36220 | - } | |
| 36221 | - pBlock->pList = pList; | |
| 36222 | - pBlock->mUsed = 0; | |
| 36223 | - pBlock->aData = (u8 *)&pBlock[1]; | |
| 36224 | - addBlockToList(pList, pBlock); | |
| 36225 | - | |
| 36226 | - sz = sqlite3MallocSize(pBlock); | |
| 36227 | - sqlite3_mutex_enter(pcache1.mutex); | |
| 36228 | - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); | |
| 36229 | - sqlite3_mutex_leave(pcache1.mutex); | |
| 36230 | - } | |
| 36231 | - | |
| 36232 | - for(i=0; pPg==0 && ALWAYS(i<pBlock->nEntry); i++){ | |
| 36233 | - if( 0==(pBlock->mUsed & ((Bitmask)1<<i)) ){ | |
| 36234 | - pBlock->mUsed |= ((Bitmask)1<<i); | |
| 36235 | - pPg = (void *)&pBlock->aData[pList->nByte * i]; | |
| 36236 | - } | |
| 36237 | - } | |
| 36238 | - assert( pPg ); | |
| 36239 | - PAGE_SET_BLOCKPTR(pCache, pPg, pBlock); | |
| 36240 | - | |
| 36241 | - /* If the block is now full, shift it to the end of the list */ | |
| 36242 | - if( pBlock->mUsed==(((Bitmask)1<<pBlock->nEntry)-1) && pList->pLast!=pBlock ){ | |
| 36243 | - assert( pList->pFirst==pBlock ); | |
| 36244 | - assert( pBlock->pPrev==0 ); | |
| 36245 | - assert( pList->pLast->pNext==0 ); | |
| 36246 | - pList->pFirst = pBlock->pNext; | |
| 36247 | - pList->pFirst->pPrev = 0; | |
| 36248 | - pBlock->pPrev = pList->pLast; | |
| 36249 | - pBlock->pNext = 0; | |
| 36250 | - pList->pLast->pNext = pBlock; | |
| 36251 | - pList->pLast = pBlock; | |
| 36252 | - } | |
| 36253 | - p = PAGE_TO_PGHDR1(pCache, pPg); | |
| 36254 | - if( pCache->bPurgeable ){ | |
| 36255 | - pCache->pGroup->nCurrentPage++; | |
| 36256 | - } | |
| 36257 | -#else | |
| 36201 | + PgHdr1 *p = 0; | |
| 36202 | + void *pPg; | |
| 36203 | + | |
| 36258 | 36204 | /* The group mutex must be released before pcache1Alloc() is called. This |
| 36259 | 36205 | ** is because it may call sqlite3_release_memory(), which assumes that |
| 36260 | 36206 | ** this mutex is not held. */ |
| 36261 | 36207 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 36262 | 36208 | pcache1LeaveMutex(pCache->pGroup); |
| 36263 | 36209 | pPg = pcache1Alloc(nByte); |
| 36264 | 36210 | pcache1EnterMutex(pCache->pGroup); |
| 36211 | + | |
| 36265 | 36212 | if( pPg ){ |
| 36266 | 36213 | p = PAGE_TO_PGHDR1(pCache, pPg); |
| 36267 | 36214 | if( pCache->bPurgeable ){ |
| 36268 | 36215 | pCache->pGroup->nCurrentPage++; |
| 36269 | 36216 | } |
| 36270 | - }else{ | |
| 36271 | - p = 0; | |
| 36272 | 36217 | } |
| 36273 | -#endif | |
| 36274 | 36218 | return p; |
| 36275 | 36219 | } |
| 36276 | 36220 | |
| 36277 | 36221 | /* |
| 36278 | 36222 | ** Free a page object allocated by pcache1AllocPage(). |
| @@ -36282,53 +36226,12 @@ | ||
| 36282 | 36226 | ** with a NULL pointer, so we mark the NULL test with ALWAYS(). |
| 36283 | 36227 | */ |
| 36284 | 36228 | static void pcache1FreePage(PgHdr1 *p){ |
| 36285 | 36229 | if( ALWAYS(p) ){ |
| 36286 | 36230 | PCache1 *pCache = p->pCache; |
| 36287 | - void *pPg = PGHDR1_TO_PAGE(p); | |
| 36288 | - | |
| 36289 | -#ifdef SQLITE_PAGECACHE_BLOCKALLOC | |
| 36290 | - PGroupBlock *pBlock = PAGE_GET_BLOCKPTR(pCache, pPg); | |
| 36291 | - PGroupBlockList *pList = pBlock->pList; | |
| 36292 | - int i = ((u8 *)pPg - pBlock->aData) / pList->nByte; | |
| 36293 | - | |
| 36294 | - assert( pPg==(void *)&pBlock->aData[i*pList->nByte] ); | |
| 36295 | - assert( pBlock->mUsed & ((Bitmask)1<<i) ); | |
| 36296 | - pBlock->mUsed &= ~((Bitmask)1<<i); | |
| 36297 | - | |
| 36298 | - /* Remove the block from the list. If it is completely empty, free it. | |
| 36299 | - ** Or if it is not completely empty, re-insert it at the start of the | |
| 36300 | - ** list. */ | |
| 36301 | - if( pList->pFirst==pBlock ){ | |
| 36302 | - pList->pFirst = pBlock->pNext; | |
| 36303 | - if( pList->pFirst ) pList->pFirst->pPrev = 0; | |
| 36304 | - }else{ | |
| 36305 | - pBlock->pPrev->pNext = pBlock->pNext; | |
| 36306 | - } | |
| 36307 | - if( pList->pLast==pBlock ){ | |
| 36308 | - pList->pLast = pBlock->pPrev; | |
| 36309 | - if( pList->pLast ) pList->pLast->pNext = 0; | |
| 36310 | - }else{ | |
| 36311 | - pBlock->pNext->pPrev = pBlock->pPrev; | |
| 36312 | - } | |
| 36313 | - | |
| 36314 | - if( pBlock->mUsed==0 ){ | |
| 36315 | - PGroup *pGroup = p->pCache->pGroup; | |
| 36316 | - | |
| 36317 | - int sz = sqlite3MallocSize(pBlock); | |
| 36318 | - sqlite3_mutex_enter(pcache1.mutex); | |
| 36319 | - sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -sz); | |
| 36320 | - sqlite3_mutex_leave(pcache1.mutex); | |
| 36321 | - freeListIfEmpty(pGroup, pList); | |
| 36322 | - sqlite3_free(pBlock); | |
| 36323 | - }else{ | |
| 36324 | - addBlockToList(pList, pBlock); | |
| 36325 | - } | |
| 36326 | -#else | |
| 36327 | 36231 | assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) ); |
| 36328 | - pcache1Free(pPg); | |
| 36329 | -#endif | |
| 36232 | + pcache1Free(PGHDR1_TO_PAGE(p)); | |
| 36330 | 36233 | if( pCache->bPurgeable ){ |
| 36331 | 36234 | pCache->pGroup->nCurrentPage--; |
| 36332 | 36235 | } |
| 36333 | 36236 | } |
| 36334 | 36237 | } |
| @@ -36935,13 +36838,10 @@ | ||
| 36935 | 36838 | ** been released, the function returns. The return value is the total number |
| 36936 | 36839 | ** of bytes of memory released. |
| 36937 | 36840 | */ |
| 36938 | 36841 | SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){ |
| 36939 | 36842 | int nFree = 0; |
| 36940 | -#ifdef SQLITE_PAGECACHE_BLOCKALLOC | |
| 36941 | - if( pcache1.grp.isBusy ) return 0; | |
| 36942 | -#endif | |
| 36943 | 36843 | assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); |
| 36944 | 36844 | assert( sqlite3_mutex_notheld(pcache1.mutex) ); |
| 36945 | 36845 | if( pcache1.pStart==0 ){ |
| 36946 | 36846 | PgHdr1 *p; |
| 36947 | 36847 | pcache1EnterMutex(&pcache1.grp); |
| @@ -36980,10 +36880,11 @@ | ||
| 36980 | 36880 | } |
| 36981 | 36881 | #endif |
| 36982 | 36882 | |
| 36983 | 36883 | /************** End of pcache1.c *********************************************/ |
| 36984 | 36884 | /************** Begin file rowset.c ******************************************/ |
| 36885 | +#line 1 "tsrc/rowset.c" | |
| 36985 | 36886 | /* |
| 36986 | 36887 | ** 2008 December 3 |
| 36987 | 36888 | ** |
| 36988 | 36889 | ** The author disclaims copyright to this source code. In place of |
| 36989 | 36890 | ** a legal notice, here is a blessing: |
| @@ -37404,10 +37305,11 @@ | ||
| 37404 | 37305 | return 0; |
| 37405 | 37306 | } |
| 37406 | 37307 | |
| 37407 | 37308 | /************** End of rowset.c **********************************************/ |
| 37408 | 37309 | /************** Begin file pager.c *******************************************/ |
| 37310 | +#line 1 "tsrc/pager.c" | |
| 37409 | 37311 | /* |
| 37410 | 37312 | ** 2001 September 15 |
| 37411 | 37313 | ** |
| 37412 | 37314 | ** The author disclaims copyright to this source code. In place of |
| 37413 | 37315 | ** a legal notice, here is a blessing: |
| @@ -37427,10 +37329,11 @@ | ||
| 37427 | 37329 | ** another is writing. |
| 37428 | 37330 | */ |
| 37429 | 37331 | #ifndef SQLITE_OMIT_DISKIO |
| 37430 | 37332 | /************** Include wal.h in the middle of pager.c ***********************/ |
| 37431 | 37333 | /************** Begin file wal.h *********************************************/ |
| 37334 | +#line 1 "tsrc/wal.h" | |
| 37432 | 37335 | /* |
| 37433 | 37336 | ** 2010 February 1 |
| 37434 | 37337 | ** |
| 37435 | 37338 | ** The author disclaims copyright to this source code. In place of |
| 37436 | 37339 | ** a legal notice, here is a blessing: |
| @@ -37551,10 +37454,11 @@ | ||
| 37551 | 37454 | #endif /* ifndef SQLITE_OMIT_WAL */ |
| 37552 | 37455 | #endif /* _WAL_H_ */ |
| 37553 | 37456 | |
| 37554 | 37457 | /************** End of wal.h *************************************************/ |
| 37555 | 37458 | /************** Continuing where we left off in pager.c **********************/ |
| 37459 | +#line 24 "tsrc/pager.c" | |
| 37556 | 37460 | |
| 37557 | 37461 | |
| 37558 | 37462 | /******************* NOTES ON THE DESIGN OF THE PAGER ************************ |
| 37559 | 37463 | ** |
| 37560 | 37464 | ** This comment block describes invariants that hold when using a rollback |
| @@ -38200,12 +38104,12 @@ | ||
| 38200 | 38104 | i64 journalSizeLimit; /* Size limit for persistent journal files */ |
| 38201 | 38105 | char *zFilename; /* Name of the database file */ |
| 38202 | 38106 | char *zJournal; /* Name of the journal file */ |
| 38203 | 38107 | int (*xBusyHandler)(void*); /* Function to call when busy */ |
| 38204 | 38108 | void *pBusyHandlerArg; /* Context argument for xBusyHandler */ |
| 38109 | + int nHit, nMiss; /* Total cache hits and misses */ | |
| 38205 | 38110 | #ifdef SQLITE_TEST |
| 38206 | - int nHit, nMiss; /* Cache hits and missing */ | |
| 38207 | 38111 | int nRead, nWrite; /* Database pages read/written */ |
| 38208 | 38112 | #endif |
| 38209 | 38113 | void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */ |
| 38210 | 38114 | #ifdef SQLITE_HAS_CODEC |
| 38211 | 38115 | void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ |
| @@ -41699,11 +41603,11 @@ | ||
| 41699 | 41603 | ** The doNotSpill flag inhibits all cache spilling regardless of whether |
| 41700 | 41604 | ** or not a sync is required. This is set during a rollback. |
| 41701 | 41605 | ** |
| 41702 | 41606 | ** Spilling is also prohibited when in an error state since that could |
| 41703 | 41607 | ** lead to database corruption. In the current implementaton it |
| 41704 | - ** is impossible for sqlite3PCacheFetch() to be called with createFlag==1 | |
| 41608 | + ** is impossible for sqlite3PcacheFetch() to be called with createFlag==1 | |
| 41705 | 41609 | ** while in the error state, hence it is impossible for this routine to |
| 41706 | 41610 | ** be called in the error state. Nevertheless, we include a NEVER() |
| 41707 | 41611 | ** test for the error state as a safeguard against future changes. |
| 41708 | 41612 | */ |
| 41709 | 41613 | if( NEVER(pPager->errCode) ) return SQLITE_OK; |
| @@ -42535,18 +42439,17 @@ | ||
| 42535 | 42439 | |
| 42536 | 42440 | if( (*ppPage)->pPager && !noContent ){ |
| 42537 | 42441 | /* In this case the pcache already contains an initialized copy of |
| 42538 | 42442 | ** the page. Return without further ado. */ |
| 42539 | 42443 | assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) ); |
| 42540 | - PAGER_INCR(pPager->nHit); | |
| 42444 | + pPager->nHit++; | |
| 42541 | 42445 | return SQLITE_OK; |
| 42542 | 42446 | |
| 42543 | 42447 | }else{ |
| 42544 | 42448 | /* The pager cache has created a new page. Its content needs to |
| 42545 | 42449 | ** be initialized. */ |
| 42546 | 42450 | |
| 42547 | - PAGER_INCR(pPager->nMiss); | |
| 42548 | 42451 | pPg = *ppPage; |
| 42549 | 42452 | pPg->pPager = pPager; |
| 42550 | 42453 | |
| 42551 | 42454 | /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page |
| 42552 | 42455 | ** number greater than this, or the unused locking-page, is requested. */ |
| @@ -42578,10 +42481,11 @@ | ||
| 42578 | 42481 | } |
| 42579 | 42482 | memset(pPg->pData, 0, pPager->pageSize); |
| 42580 | 42483 | IOTRACE(("ZERO %p %d\n", pPager, pgno)); |
| 42581 | 42484 | }else{ |
| 42582 | 42485 | assert( pPg->pPager==pPager ); |
| 42486 | + pPager->nMiss++; | |
| 42583 | 42487 | rc = readDbPage(pPg); |
| 42584 | 42488 | if( rc!=SQLITE_OK ){ |
| 42585 | 42489 | goto pager_acquire_err; |
| 42586 | 42490 | } |
| 42587 | 42491 | } |
| @@ -43611,10 +43515,35 @@ | ||
| 43611 | 43515 | a[9] = pPager->nRead; |
| 43612 | 43516 | a[10] = pPager->nWrite; |
| 43613 | 43517 | return a; |
| 43614 | 43518 | } |
| 43615 | 43519 | #endif |
| 43520 | + | |
| 43521 | +/* | |
| 43522 | +** Parameter eStat must be either SQLITE_DBSTATUS_CACHE_HIT or | |
| 43523 | +** SQLITE_DBSTATUS_CACHE_MISS. Before returning, *pnVal is incremented by the | |
| 43524 | +** current cache hit or miss count, according to the value of eStat. If the | |
| 43525 | +** reset parameter is non-zero, the cache hit or miss count is zeroed before | |
| 43526 | +** returning. | |
| 43527 | +*/ | |
| 43528 | +SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){ | |
| 43529 | + int *piStat; | |
| 43530 | + | |
| 43531 | + assert( eStat==SQLITE_DBSTATUS_CACHE_HIT | |
| 43532 | + || eStat==SQLITE_DBSTATUS_CACHE_MISS | |
| 43533 | + ); | |
| 43534 | + if( eStat==SQLITE_DBSTATUS_CACHE_HIT ){ | |
| 43535 | + piStat = &pPager->nHit; | |
| 43536 | + }else{ | |
| 43537 | + piStat = &pPager->nMiss; | |
| 43538 | + } | |
| 43539 | + | |
| 43540 | + *pnVal += *piStat; | |
| 43541 | + if( reset ){ | |
| 43542 | + *piStat = 0; | |
| 43543 | + } | |
| 43544 | +} | |
| 43616 | 43545 | |
| 43617 | 43546 | /* |
| 43618 | 43547 | ** Return true if this is an in-memory pager. |
| 43619 | 43548 | */ |
| 43620 | 43549 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){ |
| @@ -44362,10 +44291,11 @@ | ||
| 44362 | 44291 | |
| 44363 | 44292 | #endif /* SQLITE_OMIT_DISKIO */ |
| 44364 | 44293 | |
| 44365 | 44294 | /************** End of pager.c ***********************************************/ |
| 44366 | 44295 | /************** Begin file wal.c *********************************************/ |
| 44296 | +#line 1 "tsrc/wal.c" | |
| 44367 | 44297 | /* |
| 44368 | 44298 | ** 2010 February 1 |
| 44369 | 44299 | ** |
| 44370 | 44300 | ** The author disclaims copyright to this source code. In place of |
| 44371 | 44301 | ** a legal notice, here is a blessing: |
| @@ -47316,10 +47246,11 @@ | ||
| 47316 | 47246 | |
| 47317 | 47247 | #endif /* #ifndef SQLITE_OMIT_WAL */ |
| 47318 | 47248 | |
| 47319 | 47249 | /************** End of wal.c *************************************************/ |
| 47320 | 47250 | /************** Begin file btmutex.c *****************************************/ |
| 47251 | +#line 1 "tsrc/btmutex.c" | |
| 47321 | 47252 | /* |
| 47322 | 47253 | ** 2007 August 27 |
| 47323 | 47254 | ** |
| 47324 | 47255 | ** The author disclaims copyright to this source code. In place of |
| 47325 | 47256 | ** a legal notice, here is a blessing: |
| @@ -47335,10 +47266,11 @@ | ||
| 47335 | 47266 | ** big and we want to break it down some. This packaged seemed like |
| 47336 | 47267 | ** a good breakout. |
| 47337 | 47268 | */ |
| 47338 | 47269 | /************** Include btreeInt.h in the middle of btmutex.c ****************/ |
| 47339 | 47270 | /************** Begin file btreeInt.h ****************************************/ |
| 47271 | +#line 1 "tsrc/btreeInt.h" | |
| 47340 | 47272 | /* |
| 47341 | 47273 | ** 2004 April 6 |
| 47342 | 47274 | ** |
| 47343 | 47275 | ** The author disclaims copyright to this source code. In place of |
| 47344 | 47276 | ** a legal notice, here is a blessing: |
| @@ -47980,10 +47912,11 @@ | ||
| 47980 | 47912 | #define get4byte sqlite3Get4byte |
| 47981 | 47913 | #define put4byte sqlite3Put4byte |
| 47982 | 47914 | |
| 47983 | 47915 | /************** End of btreeInt.h ********************************************/ |
| 47984 | 47916 | /************** Continuing where we left off in btmutex.c ********************/ |
| 47917 | +#line 19 "tsrc/btmutex.c" | |
| 47985 | 47918 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 47986 | 47919 | #if SQLITE_THREADSAFE |
| 47987 | 47920 | |
| 47988 | 47921 | /* |
| 47989 | 47922 | ** Obtain the BtShared mutex associated with B-Tree handle p. Also, |
| @@ -48252,10 +48185,11 @@ | ||
| 48252 | 48185 | #endif /* if SQLITE_THREADSAFE */ |
| 48253 | 48186 | #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ |
| 48254 | 48187 | |
| 48255 | 48188 | /************** End of btmutex.c *********************************************/ |
| 48256 | 48189 | /************** Begin file btree.c *******************************************/ |
| 48190 | +#line 1 "tsrc/btree.c" | |
| 48257 | 48191 | /* |
| 48258 | 48192 | ** 2004 April 6 |
| 48259 | 48193 | ** |
| 48260 | 48194 | ** The author disclaims copyright to this source code. In place of |
| 48261 | 48195 | ** a legal notice, here is a blessing: |
| @@ -56439,10 +56373,11 @@ | ||
| 56439 | 56373 | return rc; |
| 56440 | 56374 | } |
| 56441 | 56375 | |
| 56442 | 56376 | /************** End of btree.c ***********************************************/ |
| 56443 | 56377 | /************** Begin file backup.c ******************************************/ |
| 56378 | +#line 1 "tsrc/backup.c" | |
| 56444 | 56379 | /* |
| 56445 | 56380 | ** 2009 January 28 |
| 56446 | 56381 | ** |
| 56447 | 56382 | ** The author disclaims copyright to this source code. In place of |
| 56448 | 56383 | ** a legal notice, here is a blessing: |
| @@ -57108,13 +57043,21 @@ | ||
| 57108 | 57043 | ** goes wrong, the transaction on pTo is rolled back. If successful, the |
| 57109 | 57044 | ** transaction is committed before returning. |
| 57110 | 57045 | */ |
| 57111 | 57046 | SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ |
| 57112 | 57047 | int rc; |
| 57048 | + sqlite3_file *pFd; /* File descriptor for database pTo */ | |
| 57113 | 57049 | sqlite3_backup b; |
| 57114 | 57050 | sqlite3BtreeEnter(pTo); |
| 57115 | 57051 | sqlite3BtreeEnter(pFrom); |
| 57052 | + | |
| 57053 | + assert( sqlite3BtreeIsInTrans(pTo) ); | |
| 57054 | + pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); | |
| 57055 | + if( pFd->pMethods ){ | |
| 57056 | + i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); | |
| 57057 | + sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte); | |
| 57058 | + } | |
| 57116 | 57059 | |
| 57117 | 57060 | /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set |
| 57118 | 57061 | ** to 0. This is used by the implementations of sqlite3_backup_step() |
| 57119 | 57062 | ** and sqlite3_backup_finish() to detect that they are being called |
| 57120 | 57063 | ** from this function, not directly by the user. |
| @@ -57137,18 +57080,20 @@ | ||
| 57137 | 57080 | rc = sqlite3_backup_finish(&b); |
| 57138 | 57081 | if( rc==SQLITE_OK ){ |
| 57139 | 57082 | pTo->pBt->pageSizeFixed = 0; |
| 57140 | 57083 | } |
| 57141 | 57084 | |
| 57085 | + assert( sqlite3BtreeIsInTrans(pTo)==0 ); | |
| 57142 | 57086 | sqlite3BtreeLeave(pFrom); |
| 57143 | 57087 | sqlite3BtreeLeave(pTo); |
| 57144 | 57088 | return rc; |
| 57145 | 57089 | } |
| 57146 | 57090 | #endif /* SQLITE_OMIT_VACUUM */ |
| 57147 | 57091 | |
| 57148 | 57092 | /************** End of backup.c **********************************************/ |
| 57149 | 57093 | /************** Begin file vdbemem.c *****************************************/ |
| 57094 | +#line 1 "tsrc/vdbemem.c" | |
| 57150 | 57095 | /* |
| 57151 | 57096 | ** 2004 May 26 |
| 57152 | 57097 | ** |
| 57153 | 57098 | ** The author disclaims copyright to this source code. In place of |
| 57154 | 57099 | ** a legal notice, here is a blessing: |
| @@ -58171,15 +58116,15 @@ | ||
| 58171 | 58116 | *ppVal = 0; |
| 58172 | 58117 | return SQLITE_OK; |
| 58173 | 58118 | } |
| 58174 | 58119 | op = pExpr->op; |
| 58175 | 58120 | |
| 58176 | - /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT2. | |
| 58121 | + /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT3. | |
| 58177 | 58122 | ** The ifdef here is to enable us to achieve 100% branch test coverage even |
| 58178 | - ** when SQLITE_ENABLE_STAT2 is omitted. | |
| 58123 | + ** when SQLITE_ENABLE_STAT3 is omitted. | |
| 58179 | 58124 | */ |
| 58180 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 58125 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 58181 | 58126 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 58182 | 58127 | #else |
| 58183 | 58128 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 58184 | 58129 | #endif |
| 58185 | 58130 | |
| @@ -58299,10 +58244,11 @@ | ||
| 58299 | 58244 | return 0; |
| 58300 | 58245 | } |
| 58301 | 58246 | |
| 58302 | 58247 | /************** End of vdbemem.c *********************************************/ |
| 58303 | 58248 | /************** Begin file vdbeaux.c *****************************************/ |
| 58249 | +#line 1 "tsrc/vdbeaux.c" | |
| 58304 | 58250 | /* |
| 58305 | 58251 | ** 2003 September 6 |
| 58306 | 58252 | ** |
| 58307 | 58253 | ** The author disclaims copyright to this source code. In place of |
| 58308 | 58254 | ** a legal notice, here is a blessing: |
| @@ -58874,12 +58820,12 @@ | ||
| 58874 | 58820 | /* |
| 58875 | 58821 | ** Change the P2 operand of instruction addr so that it points to |
| 58876 | 58822 | ** the address of the next instruction to be coded. |
| 58877 | 58823 | */ |
| 58878 | 58824 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){ |
| 58879 | - assert( addr>=0 ); | |
| 58880 | - sqlite3VdbeChangeP2(p, addr, p->nOp); | |
| 58825 | + assert( addr>=0 || p->db->mallocFailed ); | |
| 58826 | + if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp); | |
| 58881 | 58827 | } |
| 58882 | 58828 | |
| 58883 | 58829 | |
| 58884 | 58830 | /* |
| 58885 | 58831 | ** If the input FuncDef structure is ephemeral, then free it. If |
| @@ -59441,11 +59387,11 @@ | ||
| 59441 | 59387 | SubProgram **apSub = 0; /* Array of sub-vdbes */ |
| 59442 | 59388 | Mem *pSub = 0; /* Memory cell hold array of subprogs */ |
| 59443 | 59389 | sqlite3 *db = p->db; /* The database connection */ |
| 59444 | 59390 | int i; /* Loop counter */ |
| 59445 | 59391 | int rc = SQLITE_OK; /* Return code */ |
| 59446 | - Mem *pMem = p->pResultSet = &p->aMem[1]; /* First Mem of result set */ | |
| 59392 | + Mem *pMem = &p->aMem[1]; /* First Mem of result set */ | |
| 59447 | 59393 | |
| 59448 | 59394 | assert( p->explain ); |
| 59449 | 59395 | assert( p->magic==VDBE_MAGIC_RUN ); |
| 59450 | 59396 | assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM ); |
| 59451 | 59397 | |
| @@ -59452,10 +59398,11 @@ | ||
| 59452 | 59398 | /* Even though this opcode does not use dynamic strings for |
| 59453 | 59399 | ** the result, result columns may become dynamic if the user calls |
| 59454 | 59400 | ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. |
| 59455 | 59401 | */ |
| 59456 | 59402 | releaseMemArray(pMem, 8); |
| 59403 | + p->pResultSet = 0; | |
| 59457 | 59404 | |
| 59458 | 59405 | if( p->rc==SQLITE_NOMEM ){ |
| 59459 | 59406 | /* This happens if a malloc() inside a call to sqlite3_column_text() or |
| 59460 | 59407 | ** sqlite3_column_text16() failed. */ |
| 59461 | 59408 | db->mallocFailed = 1; |
| @@ -59606,10 +59553,11 @@ | ||
| 59606 | 59553 | pMem->type = SQLITE_NULL; |
| 59607 | 59554 | } |
| 59608 | 59555 | } |
| 59609 | 59556 | |
| 59610 | 59557 | p->nResColumn = 8 - 4*(p->explain-1); |
| 59558 | + p->pResultSet = &p->aMem[1]; | |
| 59611 | 59559 | p->rc = SQLITE_OK; |
| 59612 | 59560 | rc = SQLITE_ROW; |
| 59613 | 59561 | } |
| 59614 | 59562 | return rc; |
| 59615 | 59563 | } |
| @@ -61538,10 +61486,11 @@ | ||
| 61538 | 61486 | } |
| 61539 | 61487 | } |
| 61540 | 61488 | |
| 61541 | 61489 | /************** End of vdbeaux.c *********************************************/ |
| 61542 | 61490 | /************** Begin file vdbeapi.c *****************************************/ |
| 61491 | +#line 1 "tsrc/vdbeapi.c" | |
| 61543 | 61492 | /* |
| 61544 | 61493 | ** 2004 May 26 |
| 61545 | 61494 | ** |
| 61546 | 61495 | ** The author disclaims copyright to this source code. In place of |
| 61547 | 61496 | ** a legal notice, here is a blessing: |
| @@ -62845,10 +62794,11 @@ | ||
| 62845 | 62794 | return v; |
| 62846 | 62795 | } |
| 62847 | 62796 | |
| 62848 | 62797 | /************** End of vdbeapi.c *********************************************/ |
| 62849 | 62798 | /************** Begin file vdbetrace.c ***************************************/ |
| 62799 | +#line 1 "tsrc/vdbetrace.c" | |
| 62850 | 62800 | /* |
| 62851 | 62801 | ** 2009 November 25 |
| 62852 | 62802 | ** |
| 62853 | 62803 | ** The author disclaims copyright to this source code. In place of |
| 62854 | 62804 | ** a legal notice, here is a blessing: |
| @@ -63000,10 +62950,11 @@ | ||
| 63000 | 62950 | |
| 63001 | 62951 | #endif /* #ifndef SQLITE_OMIT_TRACE */ |
| 63002 | 62952 | |
| 63003 | 62953 | /************** End of vdbetrace.c *******************************************/ |
| 63004 | 62954 | /************** Begin file vdbe.c ********************************************/ |
| 62955 | +#line 1 "tsrc/vdbe.c" | |
| 63005 | 62956 | /* |
| 63006 | 62957 | ** 2001 September 15 |
| 63007 | 62958 | ** |
| 63008 | 62959 | ** The author disclaims copyright to this source code. In place of |
| 63009 | 62960 | ** a legal notice, here is a blessing: |
| @@ -63469,10 +63420,11 @@ | ||
| 63469 | 63420 | ** hwtime.h contains inline assembler code for implementing |
| 63470 | 63421 | ** high-performance timing routines. |
| 63471 | 63422 | */ |
| 63472 | 63423 | /************** Include hwtime.h in the middle of vdbe.c *********************/ |
| 63473 | 63424 | /************** Begin file hwtime.h ******************************************/ |
| 63425 | +#line 1 "tsrc/hwtime.h" | |
| 63474 | 63426 | /* |
| 63475 | 63427 | ** 2008 May 27 |
| 63476 | 63428 | ** |
| 63477 | 63429 | ** The author disclaims copyright to this source code. In place of |
| 63478 | 63430 | ** a legal notice, here is a blessing: |
| @@ -63557,10 +63509,11 @@ | ||
| 63557 | 63509 | |
| 63558 | 63510 | #endif /* !defined(_HWTIME_H_) */ |
| 63559 | 63511 | |
| 63560 | 63512 | /************** End of hwtime.h **********************************************/ |
| 63561 | 63513 | /************** Continuing where we left off in vdbe.c ***********************/ |
| 63514 | +#line 471 "tsrc/vdbe.c" | |
| 63562 | 63515 | |
| 63563 | 63516 | #endif |
| 63564 | 63517 | |
| 63565 | 63518 | /* |
| 63566 | 63519 | ** The CHECK_FOR_INTERRUPT macro defined here looks to see if the |
| @@ -69801,10 +69754,11 @@ | ||
| 69801 | 69754 | goto vdbe_error_halt; |
| 69802 | 69755 | } |
| 69803 | 69756 | |
| 69804 | 69757 | /************** End of vdbe.c ************************************************/ |
| 69805 | 69758 | /************** Begin file vdbeblob.c ****************************************/ |
| 69759 | +#line 1 "tsrc/vdbeblob.c" | |
| 69806 | 69760 | /* |
| 69807 | 69761 | ** 2007 May 1 |
| 69808 | 69762 | ** |
| 69809 | 69763 | ** The author disclaims copyright to this source code. In place of |
| 69810 | 69764 | ** a legal notice, here is a blessing: |
| @@ -70271,10 +70225,11 @@ | ||
| 70271 | 70225 | |
| 70272 | 70226 | #endif /* #ifndef SQLITE_OMIT_INCRBLOB */ |
| 70273 | 70227 | |
| 70274 | 70228 | /************** End of vdbeblob.c ********************************************/ |
| 70275 | 70229 | /************** Begin file vdbesort.c ****************************************/ |
| 70230 | +#line 1 "tsrc/vdbesort.c" | |
| 70276 | 70231 | /* |
| 70277 | 70232 | ** 2011 July 9 |
| 70278 | 70233 | ** |
| 70279 | 70234 | ** The author disclaims copyright to this source code. In place of |
| 70280 | 70235 | ** a legal notice, here is a blessing: |
| @@ -71154,10 +71109,11 @@ | ||
| 71154 | 71109 | |
| 71155 | 71110 | #endif /* #ifndef SQLITE_OMIT_MERGE_SORT */ |
| 71156 | 71111 | |
| 71157 | 71112 | /************** End of vdbesort.c ********************************************/ |
| 71158 | 71113 | /************** Begin file journal.c *****************************************/ |
| 71114 | +#line 1 "tsrc/journal.c" | |
| 71159 | 71115 | /* |
| 71160 | 71116 | ** 2007 August 22 |
| 71161 | 71117 | ** |
| 71162 | 71118 | ** The author disclaims copyright to this source code. In place of |
| 71163 | 71119 | ** a legal notice, here is a blessing: |
| @@ -71394,10 +71350,11 @@ | ||
| 71394 | 71350 | } |
| 71395 | 71351 | #endif |
| 71396 | 71352 | |
| 71397 | 71353 | /************** End of journal.c *********************************************/ |
| 71398 | 71354 | /************** Begin file memjournal.c **************************************/ |
| 71355 | +#line 1 "tsrc/memjournal.c" | |
| 71399 | 71356 | /* |
| 71400 | 71357 | ** 2008 October 7 |
| 71401 | 71358 | ** |
| 71402 | 71359 | ** The author disclaims copyright to this source code. In place of |
| 71403 | 71360 | ** a legal notice, here is a blessing: |
| @@ -71655,10 +71612,11 @@ | ||
| 71655 | 71612 | return sizeof(MemJournal); |
| 71656 | 71613 | } |
| 71657 | 71614 | |
| 71658 | 71615 | /************** End of memjournal.c ******************************************/ |
| 71659 | 71616 | /************** Begin file walker.c ******************************************/ |
| 71617 | +#line 1 "tsrc/walker.c" | |
| 71660 | 71618 | /* |
| 71661 | 71619 | ** 2008 August 16 |
| 71662 | 71620 | ** |
| 71663 | 71621 | ** The author disclaims copyright to this source code. In place of |
| 71664 | 71622 | ** a legal notice, here is a blessing: |
| @@ -71793,10 +71751,11 @@ | ||
| 71793 | 71751 | return rc & WRC_Abort; |
| 71794 | 71752 | } |
| 71795 | 71753 | |
| 71796 | 71754 | /************** End of walker.c **********************************************/ |
| 71797 | 71755 | /************** Begin file resolve.c *****************************************/ |
| 71756 | +#line 1 "tsrc/resolve.c" | |
| 71798 | 71757 | /* |
| 71799 | 71758 | ** 2008 August 18 |
| 71800 | 71759 | ** |
| 71801 | 71760 | ** The author disclaims copyright to this source code. In place of |
| 71802 | 71761 | ** a legal notice, here is a blessing: |
| @@ -73013,10 +72972,11 @@ | ||
| 73013 | 72972 | sqlite3WalkSelect(&w, p); |
| 73014 | 72973 | } |
| 73015 | 72974 | |
| 73016 | 72975 | /************** End of resolve.c *********************************************/ |
| 73017 | 72976 | /************** Begin file expr.c ********************************************/ |
| 72977 | +#line 1 "tsrc/expr.c" | |
| 73018 | 72978 | /* |
| 73019 | 72979 | ** 2001 September 15 |
| 73020 | 72980 | ** |
| 73021 | 72981 | ** The author disclaims copyright to this source code. In place of |
| 73022 | 72982 | ** a legal notice, here is a blessing: |
| @@ -76770,10 +76730,11 @@ | ||
| 76770 | 76730 | } |
| 76771 | 76731 | } |
| 76772 | 76732 | |
| 76773 | 76733 | /************** End of expr.c ************************************************/ |
| 76774 | 76734 | /************** Begin file alter.c *******************************************/ |
| 76735 | +#line 1 "tsrc/alter.c" | |
| 76775 | 76736 | /* |
| 76776 | 76737 | ** 2005 February 15 |
| 76777 | 76738 | ** |
| 76778 | 76739 | ** The author disclaims copyright to this source code. In place of |
| 76779 | 76740 | ** a legal notice, here is a blessing: |
| @@ -77598,10 +77559,11 @@ | ||
| 77598 | 77559 | } |
| 77599 | 77560 | #endif /* SQLITE_ALTER_TABLE */ |
| 77600 | 77561 | |
| 77601 | 77562 | /************** End of alter.c ***********************************************/ |
| 77602 | 77563 | /************** Begin file analyze.c *****************************************/ |
| 77564 | +#line 1 "tsrc/analyze.c" | |
| 77603 | 77565 | /* |
| 77604 | 77566 | ** 2005 July 8 |
| 77605 | 77567 | ** |
| 77606 | 77568 | ** The author disclaims copyright to this source code. In place of |
| 77607 | 77569 | ** a legal notice, here is a blessing: |
| @@ -77610,10 +77572,112 @@ | ||
| 77610 | 77572 | ** May you find forgiveness for yourself and forgive others. |
| 77611 | 77573 | ** May you share freely, never taking more than you give. |
| 77612 | 77574 | ** |
| 77613 | 77575 | ************************************************************************* |
| 77614 | 77576 | ** This file contains code associated with the ANALYZE command. |
| 77577 | +** | |
| 77578 | +** The ANALYZE command gather statistics about the content of tables | |
| 77579 | +** and indices. These statistics are made available to the query planner | |
| 77580 | +** to help it make better decisions about how to perform queries. | |
| 77581 | +** | |
| 77582 | +** The following system tables are or have been supported: | |
| 77583 | +** | |
| 77584 | +** CREATE TABLE sqlite_stat1(tbl, idx, stat); | |
| 77585 | +** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample); | |
| 77586 | +** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample); | |
| 77587 | +** | |
| 77588 | +** Additional tables might be added in future releases of SQLite. | |
| 77589 | +** The sqlite_stat2 table is not created or used unless the SQLite version | |
| 77590 | +** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled | |
| 77591 | +** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated. | |
| 77592 | +** The sqlite_stat2 table is superceded by sqlite_stat3, which is only | |
| 77593 | +** created and used by SQLite versions 3.7.9 and later and with | |
| 77594 | +** SQLITE_ENABLE_STAT3 defined. The fucntionality of sqlite_stat3 | |
| 77595 | +** is a superset of sqlite_stat2. | |
| 77596 | +** | |
| 77597 | +** Format of sqlite_stat1: | |
| 77598 | +** | |
| 77599 | +** There is normally one row per index, with the index identified by the | |
| 77600 | +** name in the idx column. The tbl column is the name of the table to | |
| 77601 | +** which the index belongs. In each such row, the stat column will be | |
| 77602 | +** a string consisting of a list of integers. The first integer in this | |
| 77603 | +** list is the number of rows in the index and in the table. The second | |
| 77604 | +** integer is the average number of rows in the index that have the same | |
| 77605 | +** value in the first column of the index. The third integer is the average | |
| 77606 | +** number of rows in the index that have the same value for the first two | |
| 77607 | +** columns. The N-th integer (for N>1) is the average number of rows in | |
| 77608 | +** the index which have the same value for the first N-1 columns. For | |
| 77609 | +** a K-column index, there will be K+1 integers in the stat column. If | |
| 77610 | +** the index is unique, then the last integer will be 1. | |
| 77611 | +** | |
| 77612 | +** The list of integers in the stat column can optionally be followed | |
| 77613 | +** by the keyword "unordered". The "unordered" keyword, if it is present, | |
| 77614 | +** must be separated from the last integer by a single space. If the | |
| 77615 | +** "unordered" keyword is present, then the query planner assumes that | |
| 77616 | +** the index is unordered and will not use the index for a range query. | |
| 77617 | +** | |
| 77618 | +** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat | |
| 77619 | +** column contains a single integer which is the (estimated) number of | |
| 77620 | +** rows in the table identified by sqlite_stat1.tbl. | |
| 77621 | +** | |
| 77622 | +** Format of sqlite_stat2: | |
| 77623 | +** | |
| 77624 | +** The sqlite_stat2 is only created and is only used if SQLite is compiled | |
| 77625 | +** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between | |
| 77626 | +** 3.6.18 and 3.7.8. The "stat2" table contains additional information | |
| 77627 | +** about the distribution of keys within an index. The index is identified by | |
| 77628 | +** the "idx" column and the "tbl" column is the name of the table to which | |
| 77629 | +** the index belongs. There are usually 10 rows in the sqlite_stat2 | |
| 77630 | +** table for each index. | |
| 77631 | +** | |
| 77632 | +** The sqlite_stat2 entries for an index that have sampleno between 0 and 9 | |
| 77633 | +** inclusive are samples of the left-most key value in the index taken at | |
| 77634 | +** evenly spaced points along the index. Let the number of samples be S | |
| 77635 | +** (10 in the standard build) and let C be the number of rows in the index. | |
| 77636 | +** Then the sampled rows are given by: | |
| 77637 | +** | |
| 77638 | +** rownumber = (i*C*2 + C)/(S*2) | |
| 77639 | +** | |
| 77640 | +** For i between 0 and S-1. Conceptually, the index space is divided into | |
| 77641 | +** S uniform buckets and the samples are the middle row from each bucket. | |
| 77642 | +** | |
| 77643 | +** The format for sqlite_stat2 is recorded here for legacy reference. This | |
| 77644 | +** version of SQLite does not support sqlite_stat2. It neither reads nor | |
| 77645 | +** writes the sqlite_stat2 table. This version of SQLite only supports | |
| 77646 | +** sqlite_stat3. | |
| 77647 | +** | |
| 77648 | +** Format for sqlite_stat3: | |
| 77649 | +** | |
| 77650 | +** The sqlite_stat3 is an enhancement to sqlite_stat2. A new name is | |
| 77651 | +** used to avoid compatibility problems. | |
| 77652 | +** | |
| 77653 | +** The format of the sqlite_stat3 table is similar to the format of | |
| 77654 | +** the sqlite_stat2 table. There are multiple entries for each index. | |
| 77655 | +** The idx column names the index and the tbl column is the table of the | |
| 77656 | +** index. If the idx and tbl columns are the same, then the sample is | |
| 77657 | +** of the INTEGER PRIMARY KEY. The sample column is a value taken from | |
| 77658 | +** the left-most column of the index. The nEq column is the approximate | |
| 77659 | +** number of entires in the index whose left-most column exactly matches | |
| 77660 | +** the sample. nLt is the approximate number of entires whose left-most | |
| 77661 | +** column is less than the sample. The nDLt column is the approximate | |
| 77662 | +** number of distinct left-most entries in the index that are less than | |
| 77663 | +** the sample. | |
| 77664 | +** | |
| 77665 | +** Future versions of SQLite might change to store a string containing | |
| 77666 | +** multiple integers values in the nDLt column of sqlite_stat3. The first | |
| 77667 | +** integer will be the number of prior index entires that are distinct in | |
| 77668 | +** the left-most column. The second integer will be the number of prior index | |
| 77669 | +** entries that are distinct in the first two columns. The third integer | |
| 77670 | +** will be the number of prior index entries that are distinct in the first | |
| 77671 | +** three columns. And so forth. With that extension, the nDLt field is | |
| 77672 | +** similar in function to the sqlite_stat1.stat field. | |
| 77673 | +** | |
| 77674 | +** There can be an arbitrary number of sqlite_stat3 entries per index. | |
| 77675 | +** The ANALYZE command will typically generate sqlite_stat3 tables | |
| 77676 | +** that contain between 10 and 40 samples which are distributed across | |
| 77677 | +** the key space, though not uniformly, and which include samples with | |
| 77678 | +** largest possible nEq values. | |
| 77615 | 77679 | */ |
| 77616 | 77680 | #ifndef SQLITE_OMIT_ANALYZE |
| 77617 | 77681 | |
| 77618 | 77682 | /* |
| 77619 | 77683 | ** This routine generates code that opens the sqlite_stat1 table for |
| @@ -77641,12 +77705,18 @@ | ||
| 77641 | 77705 | static const struct { |
| 77642 | 77706 | const char *zName; |
| 77643 | 77707 | const char *zCols; |
| 77644 | 77708 | } aTable[] = { |
| 77645 | 77709 | { "sqlite_stat1", "tbl,idx,stat" }, |
| 77646 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 77647 | - { "sqlite_stat2", "tbl,idx,sampleno,sample" }, | |
| 77710 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 77711 | + { "sqlite_stat3", "tbl,idx,neq,nlt,ndlt,sample" }, | |
| 77712 | +#endif | |
| 77713 | + }; | |
| 77714 | + static const char *azToDrop[] = { | |
| 77715 | + "sqlite_stat2", | |
| 77716 | +#ifndef SQLITE_ENABLE_STAT3 | |
| 77717 | + "sqlite_stat3", | |
| 77648 | 77718 | #endif |
| 77649 | 77719 | }; |
| 77650 | 77720 | |
| 77651 | 77721 | int aRoot[] = {0, 0}; |
| 77652 | 77722 | u8 aCreateTbl[] = {0, 0}; |
| @@ -77658,10 +77728,24 @@ | ||
| 77658 | 77728 | if( v==0 ) return; |
| 77659 | 77729 | assert( sqlite3BtreeHoldsAllMutexes(db) ); |
| 77660 | 77730 | assert( sqlite3VdbeDb(v)==db ); |
| 77661 | 77731 | pDb = &db->aDb[iDb]; |
| 77662 | 77732 | |
| 77733 | + /* Drop all statistics tables that this version of SQLite does not | |
| 77734 | + ** understand. | |
| 77735 | + */ | |
| 77736 | + for(i=0; i<ArraySize(azToDrop); i++){ | |
| 77737 | + Table *pTab = sqlite3FindTable(db, azToDrop[i], pDb->zName); | |
| 77738 | + if( pTab ){ | |
| 77739 | + sqlite3CodeDropTable(pParse, pTab, iDb, 0); | |
| 77740 | + break; | |
| 77741 | + } | |
| 77742 | + } | |
| 77743 | + | |
| 77744 | + /* Create new statistic tables if they do not exist, or clear them | |
| 77745 | + ** if they do already exist. | |
| 77746 | + */ | |
| 77663 | 77747 | for(i=0; i<ArraySize(aTable); i++){ |
| 77664 | 77748 | const char *zTab = aTable[i].zName; |
| 77665 | 77749 | Table *pStat; |
| 77666 | 77750 | if( (pStat = sqlite3FindTable(db, zTab, pDb->zName))==0 ){ |
| 77667 | 77751 | /* The sqlite_stat[12] table does not exist. Create it. Note that a |
| @@ -77688,17 +77772,237 @@ | ||
| 77688 | 77772 | sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb); |
| 77689 | 77773 | } |
| 77690 | 77774 | } |
| 77691 | 77775 | } |
| 77692 | 77776 | |
| 77693 | - /* Open the sqlite_stat[12] tables for writing. */ | |
| 77777 | + /* Open the sqlite_stat[13] tables for writing. */ | |
| 77694 | 77778 | for(i=0; i<ArraySize(aTable); i++){ |
| 77695 | 77779 | sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb); |
| 77696 | 77780 | sqlite3VdbeChangeP4(v, -1, (char *)3, P4_INT32); |
| 77697 | 77781 | sqlite3VdbeChangeP5(v, aCreateTbl[i]); |
| 77698 | 77782 | } |
| 77699 | 77783 | } |
| 77784 | + | |
| 77785 | +/* | |
| 77786 | +** Recommended number of samples for sqlite_stat3 | |
| 77787 | +*/ | |
| 77788 | +#ifndef SQLITE_STAT3_SAMPLES | |
| 77789 | +# define SQLITE_STAT3_SAMPLES 24 | |
| 77790 | +#endif | |
| 77791 | + | |
| 77792 | +/* | |
| 77793 | +** Three SQL functions - stat3_init(), stat3_push(), and stat3_pop() - | |
| 77794 | +** share an instance of the following structure to hold their state | |
| 77795 | +** information. | |
| 77796 | +*/ | |
| 77797 | +typedef struct Stat3Accum Stat3Accum; | |
| 77798 | +struct Stat3Accum { | |
| 77799 | + tRowcnt nRow; /* Number of rows in the entire table */ | |
| 77800 | + tRowcnt nPSample; /* How often to do a periodic sample */ | |
| 77801 | + int iMin; /* Index of entry with minimum nEq and hash */ | |
| 77802 | + int mxSample; /* Maximum number of samples to accumulate */ | |
| 77803 | + int nSample; /* Current number of samples */ | |
| 77804 | + u32 iPrn; /* Pseudo-random number used for sampling */ | |
| 77805 | + struct Stat3Sample { | |
| 77806 | + i64 iRowid; /* Rowid in main table of the key */ | |
| 77807 | + tRowcnt nEq; /* sqlite_stat3.nEq */ | |
| 77808 | + tRowcnt nLt; /* sqlite_stat3.nLt */ | |
| 77809 | + tRowcnt nDLt; /* sqlite_stat3.nDLt */ | |
| 77810 | + u8 isPSample; /* True if a periodic sample */ | |
| 77811 | + u32 iHash; /* Tiebreaker hash */ | |
| 77812 | + } *a; /* An array of samples */ | |
| 77813 | +}; | |
| 77814 | + | |
| 77815 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 77816 | +/* | |
| 77817 | +** Implementation of the stat3_init(C,S) SQL function. The two parameters | |
| 77818 | +** are the number of rows in the table or index (C) and the number of samples | |
| 77819 | +** to accumulate (S). | |
| 77820 | +** | |
| 77821 | +** This routine allocates the Stat3Accum object. | |
| 77822 | +** | |
| 77823 | +** The return value is the Stat3Accum object (P). | |
| 77824 | +*/ | |
| 77825 | +static void stat3Init( | |
| 77826 | + sqlite3_context *context, | |
| 77827 | + int argc, | |
| 77828 | + sqlite3_value **argv | |
| 77829 | +){ | |
| 77830 | + Stat3Accum *p; | |
| 77831 | + tRowcnt nRow; | |
| 77832 | + int mxSample; | |
| 77833 | + int n; | |
| 77834 | + | |
| 77835 | + UNUSED_PARAMETER(argc); | |
| 77836 | + nRow = (tRowcnt)sqlite3_value_int64(argv[0]); | |
| 77837 | + mxSample = sqlite3_value_int(argv[1]); | |
| 77838 | + n = sizeof(*p) + sizeof(p->a[0])*mxSample; | |
| 77839 | + p = sqlite3_malloc( n ); | |
| 77840 | + if( p==0 ){ | |
| 77841 | + sqlite3_result_error_nomem(context); | |
| 77842 | + return; | |
| 77843 | + } | |
| 77844 | + memset(p, 0, n); | |
| 77845 | + p->a = (struct Stat3Sample*)&p[1]; | |
| 77846 | + p->nRow = nRow; | |
| 77847 | + p->mxSample = mxSample; | |
| 77848 | + p->nPSample = p->nRow/(mxSample/3+1) + 1; | |
| 77849 | + sqlite3_randomness(sizeof(p->iPrn), &p->iPrn); | |
| 77850 | + sqlite3_result_blob(context, p, sizeof(p), sqlite3_free); | |
| 77851 | +} | |
| 77852 | +static const FuncDef stat3InitFuncdef = { | |
| 77853 | + 2, /* nArg */ | |
| 77854 | + SQLITE_UTF8, /* iPrefEnc */ | |
| 77855 | + 0, /* flags */ | |
| 77856 | + 0, /* pUserData */ | |
| 77857 | + 0, /* pNext */ | |
| 77858 | + stat3Init, /* xFunc */ | |
| 77859 | + 0, /* xStep */ | |
| 77860 | + 0, /* xFinalize */ | |
| 77861 | + "stat3_init", /* zName */ | |
| 77862 | + 0, /* pHash */ | |
| 77863 | + 0 /* pDestructor */ | |
| 77864 | +}; | |
| 77865 | + | |
| 77866 | + | |
| 77867 | +/* | |
| 77868 | +** Implementation of the stat3_push(nEq,nLt,nDLt,rowid,P) SQL function. The | |
| 77869 | +** arguments describe a single key instance. This routine makes the | |
| 77870 | +** decision about whether or not to retain this key for the sqlite_stat3 | |
| 77871 | +** table. | |
| 77872 | +** | |
| 77873 | +** The return value is NULL. | |
| 77874 | +*/ | |
| 77875 | +static void stat3Push( | |
| 77876 | + sqlite3_context *context, | |
| 77877 | + int argc, | |
| 77878 | + sqlite3_value **argv | |
| 77879 | +){ | |
| 77880 | + Stat3Accum *p = (Stat3Accum*)sqlite3_value_blob(argv[4]); | |
| 77881 | + tRowcnt nEq = sqlite3_value_int64(argv[0]); | |
| 77882 | + tRowcnt nLt = sqlite3_value_int64(argv[1]); | |
| 77883 | + tRowcnt nDLt = sqlite3_value_int64(argv[2]); | |
| 77884 | + i64 rowid = sqlite3_value_int64(argv[3]); | |
| 77885 | + u8 isPSample = 0; | |
| 77886 | + u8 doInsert = 0; | |
| 77887 | + int iMin = p->iMin; | |
| 77888 | + struct Stat3Sample *pSample; | |
| 77889 | + int i; | |
| 77890 | + u32 h; | |
| 77891 | + | |
| 77892 | + UNUSED_PARAMETER(context); | |
| 77893 | + UNUSED_PARAMETER(argc); | |
| 77894 | + if( nEq==0 ) return; | |
| 77895 | + h = p->iPrn = p->iPrn*1103515245 + 12345; | |
| 77896 | + if( (nLt/p->nPSample)!=((nEq+nLt)/p->nPSample) ){ | |
| 77897 | + doInsert = isPSample = 1; | |
| 77898 | + }else if( p->nSample<p->mxSample ){ | |
| 77899 | + doInsert = 1; | |
| 77900 | + }else{ | |
| 77901 | + if( nEq>p->a[iMin].nEq || (nEq==p->a[iMin].nEq && h>p->a[iMin].iHash) ){ | |
| 77902 | + doInsert = 1; | |
| 77903 | + } | |
| 77904 | + } | |
| 77905 | + if( !doInsert ) return; | |
| 77906 | + if( p->nSample==p->mxSample ){ | |
| 77907 | + assert( p->nSample - iMin - 1 >= 0 ); | |
| 77908 | + memmove(&p->a[iMin], &p->a[iMin+1], sizeof(p->a[0])*(p->nSample-iMin-1)); | |
| 77909 | + pSample = &p->a[p->nSample-1]; | |
| 77910 | + }else{ | |
| 77911 | + pSample = &p->a[p->nSample++]; | |
| 77912 | + } | |
| 77913 | + pSample->iRowid = rowid; | |
| 77914 | + pSample->nEq = nEq; | |
| 77915 | + pSample->nLt = nLt; | |
| 77916 | + pSample->nDLt = nDLt; | |
| 77917 | + pSample->iHash = h; | |
| 77918 | + pSample->isPSample = isPSample; | |
| 77919 | + | |
| 77920 | + /* Find the new minimum */ | |
| 77921 | + if( p->nSample==p->mxSample ){ | |
| 77922 | + pSample = p->a; | |
| 77923 | + i = 0; | |
| 77924 | + while( pSample->isPSample ){ | |
| 77925 | + i++; | |
| 77926 | + pSample++; | |
| 77927 | + assert( i<p->nSample ); | |
| 77928 | + } | |
| 77929 | + nEq = pSample->nEq; | |
| 77930 | + h = pSample->iHash; | |
| 77931 | + iMin = i; | |
| 77932 | + for(i++, pSample++; i<p->nSample; i++, pSample++){ | |
| 77933 | + if( pSample->isPSample ) continue; | |
| 77934 | + if( pSample->nEq<nEq | |
| 77935 | + || (pSample->nEq==nEq && pSample->iHash<h) | |
| 77936 | + ){ | |
| 77937 | + iMin = i; | |
| 77938 | + nEq = pSample->nEq; | |
| 77939 | + h = pSample->iHash; | |
| 77940 | + } | |
| 77941 | + } | |
| 77942 | + p->iMin = iMin; | |
| 77943 | + } | |
| 77944 | +} | |
| 77945 | +static const FuncDef stat3PushFuncdef = { | |
| 77946 | + 5, /* nArg */ | |
| 77947 | + SQLITE_UTF8, /* iPrefEnc */ | |
| 77948 | + 0, /* flags */ | |
| 77949 | + 0, /* pUserData */ | |
| 77950 | + 0, /* pNext */ | |
| 77951 | + stat3Push, /* xFunc */ | |
| 77952 | + 0, /* xStep */ | |
| 77953 | + 0, /* xFinalize */ | |
| 77954 | + "stat3_push", /* zName */ | |
| 77955 | + 0, /* pHash */ | |
| 77956 | + 0 /* pDestructor */ | |
| 77957 | +}; | |
| 77958 | + | |
| 77959 | +/* | |
| 77960 | +** Implementation of the stat3_get(P,N,...) SQL function. This routine is | |
| 77961 | +** used to query the results. Content is returned for the Nth sqlite_stat3 | |
| 77962 | +** row where N is between 0 and S-1 and S is the number of samples. The | |
| 77963 | +** value returned depends on the number of arguments. | |
| 77964 | +** | |
| 77965 | +** argc==2 result: rowid | |
| 77966 | +** argc==3 result: nEq | |
| 77967 | +** argc==4 result: nLt | |
| 77968 | +** argc==5 result: nDLt | |
| 77969 | +*/ | |
| 77970 | +static void stat3Get( | |
| 77971 | + sqlite3_context *context, | |
| 77972 | + int argc, | |
| 77973 | + sqlite3_value **argv | |
| 77974 | +){ | |
| 77975 | + int n = sqlite3_value_int(argv[1]); | |
| 77976 | + Stat3Accum *p = (Stat3Accum*)sqlite3_value_blob(argv[0]); | |
| 77977 | + | |
| 77978 | + assert( p!=0 ); | |
| 77979 | + if( p->nSample<=n ) return; | |
| 77980 | + switch( argc ){ | |
| 77981 | + case 2: sqlite3_result_int64(context, p->a[n].iRowid); break; | |
| 77982 | + case 3: sqlite3_result_int64(context, p->a[n].nEq); break; | |
| 77983 | + case 4: sqlite3_result_int64(context, p->a[n].nLt); break; | |
| 77984 | + default: sqlite3_result_int64(context, p->a[n].nDLt); break; | |
| 77985 | + } | |
| 77986 | +} | |
| 77987 | +static const FuncDef stat3GetFuncdef = { | |
| 77988 | + -1, /* nArg */ | |
| 77989 | + SQLITE_UTF8, /* iPrefEnc */ | |
| 77990 | + 0, /* flags */ | |
| 77991 | + 0, /* pUserData */ | |
| 77992 | + 0, /* pNext */ | |
| 77993 | + stat3Get, /* xFunc */ | |
| 77994 | + 0, /* xStep */ | |
| 77995 | + 0, /* xFinalize */ | |
| 77996 | + "stat3_get", /* zName */ | |
| 77997 | + 0, /* pHash */ | |
| 77998 | + 0 /* pDestructor */ | |
| 77999 | +}; | |
| 78000 | +#endif /* SQLITE_ENABLE_STAT3 */ | |
| 78001 | + | |
| 78002 | + | |
| 78003 | + | |
| 77700 | 78004 | |
| 77701 | 78005 | /* |
| 77702 | 78006 | ** Generate code to do an analysis of all indices associated with |
| 77703 | 78007 | ** a single table. |
| 77704 | 78008 | */ |
| @@ -77718,24 +78022,31 @@ | ||
| 77718 | 78022 | int endOfLoop; /* The end of the loop */ |
| 77719 | 78023 | int jZeroRows = -1; /* Jump from here if number of rows is zero */ |
| 77720 | 78024 | int iDb; /* Index of database containing pTab */ |
| 77721 | 78025 | int regTabname = iMem++; /* Register containing table name */ |
| 77722 | 78026 | int regIdxname = iMem++; /* Register containing index name */ |
| 77723 | - int regSampleno = iMem++; /* Register containing next sample number */ | |
| 77724 | - int regCol = iMem++; /* Content of a column analyzed table */ | |
| 78027 | + int regStat1 = iMem++; /* The stat column of sqlite_stat1 */ | |
| 78028 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78029 | + int regNumEq = regStat1; /* Number of instances. Same as regStat1 */ | |
| 78030 | + int regNumLt = iMem++; /* Number of keys less than regSample */ | |
| 78031 | + int regNumDLt = iMem++; /* Number of distinct keys less than regSample */ | |
| 78032 | + int regSample = iMem++; /* The next sample value */ | |
| 78033 | + int regRowid = regSample; /* Rowid of a sample */ | |
| 78034 | + int regAccum = iMem++; /* Register to hold Stat3Accum object */ | |
| 78035 | + int regLoop = iMem++; /* Loop counter */ | |
| 78036 | + int regCount = iMem++; /* Number of rows in the table or index */ | |
| 78037 | + int regTemp1 = iMem++; /* Intermediate register */ | |
| 78038 | + int regTemp2 = iMem++; /* Intermediate register */ | |
| 78039 | + int once = 1; /* One-time initialization */ | |
| 78040 | + int shortJump = 0; /* Instruction address */ | |
| 78041 | + int iTabCur = pParse->nTab++; /* Table cursor */ | |
| 78042 | +#endif | |
| 78043 | + int regCol = iMem++; /* Content of a column in analyzed table */ | |
| 77725 | 78044 | int regRec = iMem++; /* Register holding completed record */ |
| 77726 | 78045 | int regTemp = iMem++; /* Temporary use register */ |
| 77727 | - int regRowid = iMem++; /* Rowid for the inserted record */ | |
| 77728 | - | |
| 77729 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 77730 | - int addr = 0; /* Instruction address */ | |
| 77731 | - int regTemp2 = iMem++; /* Temporary use register */ | |
| 77732 | - int regSamplerecno = iMem++; /* Index of next sample to record */ | |
| 77733 | - int regRecno = iMem++; /* Current sample index */ | |
| 77734 | - int regLast = iMem++; /* Index of last sample to record */ | |
| 77735 | - int regFirst = iMem++; /* Index of first sample to record */ | |
| 77736 | -#endif | |
| 78046 | + int regNewRowid = iMem++; /* Rowid for the inserted record */ | |
| 78047 | + | |
| 77737 | 78048 | |
| 77738 | 78049 | v = sqlite3GetVdbe(pParse); |
| 77739 | 78050 | if( v==0 || NEVER(pTab==0) ){ |
| 77740 | 78051 | return; |
| 77741 | 78052 | } |
| @@ -77764,13 +78075,18 @@ | ||
| 77764 | 78075 | iIdxCur = pParse->nTab++; |
| 77765 | 78076 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0); |
| 77766 | 78077 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 77767 | 78078 | int nCol; |
| 77768 | 78079 | KeyInfo *pKey; |
| 78080 | + int addrIfNot = 0; /* address of OP_IfNot */ | |
| 78081 | + int *aChngAddr; /* Array of jump instruction addresses */ | |
| 77769 | 78082 | |
| 77770 | 78083 | if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; |
| 78084 | + VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName)); | |
| 77771 | 78085 | nCol = pIdx->nColumn; |
| 78086 | + aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol); | |
| 78087 | + if( aChngAddr==0 ) continue; | |
| 77772 | 78088 | pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 77773 | 78089 | if( iMem+1+(nCol*2)>pParse->nMem ){ |
| 77774 | 78090 | pParse->nMem = iMem+1+(nCol*2); |
| 77775 | 78091 | } |
| 77776 | 78092 | |
| @@ -77781,35 +78097,24 @@ | ||
| 77781 | 78097 | VdbeComment((v, "%s", pIdx->zName)); |
| 77782 | 78098 | |
| 77783 | 78099 | /* Populate the register containing the index name. */ |
| 77784 | 78100 | sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0); |
| 77785 | 78101 | |
| 77786 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 77787 | - | |
| 77788 | - /* If this iteration of the loop is generating code to analyze the | |
| 77789 | - ** first index in the pTab->pIndex list, then register regLast has | |
| 77790 | - ** not been populated. In this case populate it now. */ | |
| 77791 | - if( pTab->pIndex==pIdx ){ | |
| 77792 | - sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regSamplerecno); | |
| 77793 | - sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2-1, regTemp); | |
| 77794 | - sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2, regTemp2); | |
| 77795 | - | |
| 77796 | - sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regLast); | |
| 77797 | - sqlite3VdbeAddOp2(v, OP_Null, 0, regFirst); | |
| 77798 | - addr = sqlite3VdbeAddOp3(v, OP_Lt, regSamplerecno, 0, regLast); | |
| 77799 | - sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regLast, regFirst); | |
| 77800 | - sqlite3VdbeAddOp3(v, OP_Multiply, regLast, regTemp, regLast); | |
| 77801 | - sqlite3VdbeAddOp2(v, OP_AddImm, regLast, SQLITE_INDEX_SAMPLES*2-2); | |
| 77802 | - sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regLast, regLast); | |
| 77803 | - sqlite3VdbeJumpHere(v, addr); | |
| 77804 | - } | |
| 77805 | - | |
| 77806 | - /* Zero the regSampleno and regRecno registers. */ | |
| 77807 | - sqlite3VdbeAddOp2(v, OP_Integer, 0, regSampleno); | |
| 77808 | - sqlite3VdbeAddOp2(v, OP_Integer, 0, regRecno); | |
| 77809 | - sqlite3VdbeAddOp2(v, OP_Copy, regFirst, regSamplerecno); | |
| 77810 | -#endif | |
| 78102 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78103 | + if( once ){ | |
| 78104 | + once = 0; | |
| 78105 | + sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); | |
| 78106 | + } | |
| 78107 | + sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regCount); | |
| 78108 | + sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_STAT3_SAMPLES, regTemp1); | |
| 78109 | + sqlite3VdbeAddOp2(v, OP_Integer, 0, regNumEq); | |
| 78110 | + sqlite3VdbeAddOp2(v, OP_Integer, 0, regNumLt); | |
| 78111 | + sqlite3VdbeAddOp2(v, OP_Integer, -1, regNumDLt); | |
| 78112 | + sqlite3VdbeAddOp4(v, OP_Function, 1, regCount, regAccum, | |
| 78113 | + (char*)&stat3InitFuncdef, P4_FUNCDEF); | |
| 78114 | + sqlite3VdbeChangeP5(v, 2); | |
| 78115 | +#endif /* SQLITE_ENABLE_STAT3 */ | |
| 77811 | 78116 | |
| 77812 | 78117 | /* The block of memory cells initialized here is used as follows. |
| 77813 | 78118 | ** |
| 77814 | 78119 | ** iMem: |
| 77815 | 78120 | ** The total number of rows in the table. |
| @@ -77835,79 +78140,87 @@ | ||
| 77835 | 78140 | /* Start the analysis loop. This loop runs through all the entries in |
| 77836 | 78141 | ** the index b-tree. */ |
| 77837 | 78142 | endOfLoop = sqlite3VdbeMakeLabel(v); |
| 77838 | 78143 | sqlite3VdbeAddOp2(v, OP_Rewind, iIdxCur, endOfLoop); |
| 77839 | 78144 | topOfLoop = sqlite3VdbeCurrentAddr(v); |
| 77840 | - sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1); | |
| 78145 | + sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1); /* Increment row counter */ | |
| 77841 | 78146 | |
| 77842 | 78147 | for(i=0; i<nCol; i++){ |
| 77843 | 78148 | CollSeq *pColl; |
| 77844 | 78149 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol); |
| 77845 | 78150 | if( i==0 ){ |
| 77846 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 77847 | - /* Check if the record that cursor iIdxCur points to contains a | |
| 77848 | - ** value that should be stored in the sqlite_stat2 table. If so, | |
| 77849 | - ** store it. */ | |
| 77850 | - int ne = sqlite3VdbeAddOp3(v, OP_Ne, regRecno, 0, regSamplerecno); | |
| 77851 | - assert( regTabname+1==regIdxname | |
| 77852 | - && regTabname+2==regSampleno | |
| 77853 | - && regTabname+3==regCol | |
| 77854 | - ); | |
| 77855 | - sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); | |
| 77856 | - sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 4, regRec, "aaab", 0); | |
| 77857 | - sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regRowid); | |
| 77858 | - sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regRec, regRowid); | |
| 77859 | - | |
| 77860 | - /* Calculate new values for regSamplerecno and regSampleno. | |
| 77861 | - ** | |
| 77862 | - ** sampleno = sampleno + 1 | |
| 77863 | - ** samplerecno = samplerecno+(remaining records)/(remaining samples) | |
| 77864 | - */ | |
| 77865 | - sqlite3VdbeAddOp2(v, OP_AddImm, regSampleno, 1); | |
| 77866 | - sqlite3VdbeAddOp3(v, OP_Subtract, regRecno, regLast, regTemp); | |
| 77867 | - sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); | |
| 77868 | - sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regTemp2); | |
| 77869 | - sqlite3VdbeAddOp3(v, OP_Subtract, regSampleno, regTemp2, regTemp2); | |
| 77870 | - sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regTemp, regTemp); | |
| 77871 | - sqlite3VdbeAddOp3(v, OP_Add, regSamplerecno, regTemp, regSamplerecno); | |
| 77872 | - | |
| 77873 | - sqlite3VdbeJumpHere(v, ne); | |
| 77874 | - sqlite3VdbeAddOp2(v, OP_AddImm, regRecno, 1); | |
| 77875 | -#endif | |
| 77876 | - | |
| 77877 | 78151 | /* Always record the very first row */ |
| 77878 | - sqlite3VdbeAddOp1(v, OP_IfNot, iMem+1); | |
| 78152 | + addrIfNot = sqlite3VdbeAddOp1(v, OP_IfNot, iMem+1); | |
| 77879 | 78153 | } |
| 77880 | 78154 | assert( pIdx->azColl!=0 ); |
| 77881 | 78155 | assert( pIdx->azColl[i]!=0 ); |
| 77882 | 78156 | pColl = sqlite3LocateCollSeq(pParse, pIdx->azColl[i]); |
| 77883 | - sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem+nCol+i+1, | |
| 77884 | - (char*)pColl, P4_COLLSEQ); | |
| 78157 | + aChngAddr[i] = sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem+nCol+i+1, | |
| 78158 | + (char*)pColl, P4_COLLSEQ); | |
| 77885 | 78159 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 77886 | - } | |
| 77887 | - if( db->mallocFailed ){ | |
| 77888 | - /* If a malloc failure has occurred, then the result of the expression | |
| 77889 | - ** passed as the second argument to the call to sqlite3VdbeJumpHere() | |
| 77890 | - ** below may be negative. Which causes an assert() to fail (or an | |
| 77891 | - ** out-of-bounds write if SQLITE_DEBUG is not defined). */ | |
| 77892 | - return; | |
| 78160 | + VdbeComment((v, "jump if column %d changed", i)); | |
| 78161 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78162 | + if( i==0 ){ | |
| 78163 | + sqlite3VdbeAddOp2(v, OP_AddImm, regNumEq, 1); | |
| 78164 | + VdbeComment((v, "incr repeat count")); | |
| 78165 | + } | |
| 78166 | +#endif | |
| 77893 | 78167 | } |
| 77894 | 78168 | sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop); |
| 77895 | 78169 | for(i=0; i<nCol; i++){ |
| 77896 | - int addr2 = sqlite3VdbeCurrentAddr(v) - (nCol*2); | |
| 78170 | + sqlite3VdbeJumpHere(v, aChngAddr[i]); /* Set jump dest for the OP_Ne */ | |
| 77897 | 78171 | if( i==0 ){ |
| 77898 | - sqlite3VdbeJumpHere(v, addr2-1); /* Set jump dest for the OP_IfNot */ | |
| 78172 | + sqlite3VdbeJumpHere(v, addrIfNot); /* Jump dest for OP_IfNot */ | |
| 78173 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78174 | + sqlite3VdbeAddOp4(v, OP_Function, 1, regNumEq, regTemp2, | |
| 78175 | + (char*)&stat3PushFuncdef, P4_FUNCDEF); | |
| 78176 | + sqlite3VdbeChangeP5(v, 5); | |
| 78177 | + sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, pIdx->nColumn, regRowid); | |
| 78178 | + sqlite3VdbeAddOp3(v, OP_Add, regNumEq, regNumLt, regNumLt); | |
| 78179 | + sqlite3VdbeAddOp2(v, OP_AddImm, regNumDLt, 1); | |
| 78180 | + sqlite3VdbeAddOp2(v, OP_Integer, 1, regNumEq); | |
| 78181 | +#endif | |
| 77899 | 78182 | } |
| 77900 | - sqlite3VdbeJumpHere(v, addr2); /* Set jump dest for the OP_Ne */ | |
| 77901 | 78183 | sqlite3VdbeAddOp2(v, OP_AddImm, iMem+i+1, 1); |
| 77902 | 78184 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, iMem+nCol+i+1); |
| 77903 | 78185 | } |
| 78186 | + sqlite3DbFree(db, aChngAddr); | |
| 77904 | 78187 | |
| 77905 | - /* End of the analysis loop. */ | |
| 78188 | + /* Always jump here after updating the iMem+1...iMem+1+nCol counters */ | |
| 77906 | 78189 | sqlite3VdbeResolveLabel(v, endOfLoop); |
| 78190 | + | |
| 77907 | 78191 | sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, topOfLoop); |
| 77908 | 78192 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 78193 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78194 | + sqlite3VdbeAddOp4(v, OP_Function, 1, regNumEq, regTemp2, | |
| 78195 | + (char*)&stat3PushFuncdef, P4_FUNCDEF); | |
| 78196 | + sqlite3VdbeChangeP5(v, 5); | |
| 78197 | + sqlite3VdbeAddOp2(v, OP_Integer, -1, regLoop); | |
| 78198 | + shortJump = | |
| 78199 | + sqlite3VdbeAddOp2(v, OP_AddImm, regLoop, 1); | |
| 78200 | + sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regTemp1, | |
| 78201 | + (char*)&stat3GetFuncdef, P4_FUNCDEF); | |
| 78202 | + sqlite3VdbeChangeP5(v, 2); | |
| 78203 | + sqlite3VdbeAddOp1(v, OP_IsNull, regTemp1); | |
| 78204 | + sqlite3VdbeAddOp3(v, OP_NotExists, iTabCur, shortJump, regTemp1); | |
| 78205 | + sqlite3VdbeAddOp3(v, OP_Column, iTabCur, pIdx->aiColumn[0], regSample); | |
| 78206 | + sqlite3ColumnDefault(v, pTab, pIdx->aiColumn[0], regSample); | |
| 78207 | + sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumEq, | |
| 78208 | + (char*)&stat3GetFuncdef, P4_FUNCDEF); | |
| 78209 | + sqlite3VdbeChangeP5(v, 3); | |
| 78210 | + sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumLt, | |
| 78211 | + (char*)&stat3GetFuncdef, P4_FUNCDEF); | |
| 78212 | + sqlite3VdbeChangeP5(v, 4); | |
| 78213 | + sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumDLt, | |
| 78214 | + (char*)&stat3GetFuncdef, P4_FUNCDEF); | |
| 78215 | + sqlite3VdbeChangeP5(v, 5); | |
| 78216 | + sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 6, regRec, "bbbbbb", 0); | |
| 78217 | + sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid); | |
| 78218 | + sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regRec, regNewRowid); | |
| 78219 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, shortJump); | |
| 78220 | + sqlite3VdbeJumpHere(v, shortJump+2); | |
| 78221 | +#endif | |
| 77909 | 78222 | |
| 77910 | 78223 | /* Store the results in sqlite_stat1. |
| 77911 | 78224 | ** |
| 77912 | 78225 | ** The result is a single row of the sqlite_stat1 table. The first |
| 77913 | 78226 | ** two columns are the names of the table and index. The third column |
| @@ -77923,50 +78236,51 @@ | ||
| 77923 | 78236 | ** |
| 77924 | 78237 | ** If K==0 then no entry is made into the sqlite_stat1 table. |
| 77925 | 78238 | ** If K>0 then it is always the case the D>0 so division by zero |
| 77926 | 78239 | ** is never possible. |
| 77927 | 78240 | */ |
| 77928 | - sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regSampleno); | |
| 78241 | + sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1); | |
| 77929 | 78242 | if( jZeroRows<0 ){ |
| 77930 | 78243 | jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); |
| 77931 | 78244 | } |
| 77932 | 78245 | for(i=0; i<nCol; i++){ |
| 77933 | 78246 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0); |
| 77934 | - sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); | |
| 78247 | + sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); | |
| 77935 | 78248 | sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp); |
| 77936 | 78249 | sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); |
| 77937 | 78250 | sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp); |
| 77938 | 78251 | sqlite3VdbeAddOp1(v, OP_ToInt, regTemp); |
| 77939 | - sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); | |
| 78252 | + sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); | |
| 77940 | 78253 | } |
| 77941 | 78254 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 77942 | - sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); | |
| 77943 | - sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); | |
| 78255 | + sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); | |
| 78256 | + sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); | |
| 77944 | 78257 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 77945 | 78258 | } |
| 77946 | 78259 | |
| 77947 | 78260 | /* If the table has no indices, create a single sqlite_stat1 entry |
| 77948 | 78261 | ** containing NULL as the index name and the row count as the content. |
| 77949 | 78262 | */ |
| 77950 | 78263 | if( pTab->pIndex==0 ){ |
| 77951 | 78264 | sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb); |
| 77952 | 78265 | VdbeComment((v, "%s", pTab->zName)); |
| 77953 | - sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regSampleno); | |
| 78266 | + sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1); | |
| 77954 | 78267 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 77955 | - jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regSampleno); | |
| 78268 | + jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); | |
| 77956 | 78269 | }else{ |
| 77957 | 78270 | sqlite3VdbeJumpHere(v, jZeroRows); |
| 77958 | 78271 | jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto); |
| 77959 | 78272 | } |
| 77960 | 78273 | sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); |
| 77961 | 78274 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 77962 | - sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); | |
| 77963 | - sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); | |
| 78275 | + sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); | |
| 78276 | + sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); | |
| 77964 | 78277 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 77965 | 78278 | if( pParse->nMem<regRec ) pParse->nMem = regRec; |
| 77966 | 78279 | sqlite3VdbeJumpHere(v, jZeroRows); |
| 77967 | 78280 | } |
| 78281 | + | |
| 77968 | 78282 | |
| 77969 | 78283 | /* |
| 77970 | 78284 | ** Generate code that will cause the most recent index analysis to |
| 77971 | 78285 | ** be loaded into internal hash tables where is can be used. |
| 77972 | 78286 | */ |
| @@ -77987,11 +78301,11 @@ | ||
| 77987 | 78301 | int iStatCur; |
| 77988 | 78302 | int iMem; |
| 77989 | 78303 | |
| 77990 | 78304 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| 77991 | 78305 | iStatCur = pParse->nTab; |
| 77992 | - pParse->nTab += 2; | |
| 78306 | + pParse->nTab += 3; | |
| 77993 | 78307 | openStatTable(pParse, iDb, iStatCur, 0, 0); |
| 77994 | 78308 | iMem = pParse->nMem+1; |
| 77995 | 78309 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 77996 | 78310 | for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 77997 | 78311 | Table *pTab = (Table*)sqliteHashData(k); |
| @@ -78012,11 +78326,11 @@ | ||
| 78012 | 78326 | assert( pTab!=0 ); |
| 78013 | 78327 | assert( sqlite3BtreeHoldsAllMutexes(pParse->db) ); |
| 78014 | 78328 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
| 78015 | 78329 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| 78016 | 78330 | iStatCur = pParse->nTab; |
| 78017 | - pParse->nTab += 2; | |
| 78331 | + pParse->nTab += 3; | |
| 78018 | 78332 | if( pOnlyIdx ){ |
| 78019 | 78333 | openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, "idx"); |
| 78020 | 78334 | }else{ |
| 78021 | 78335 | openStatTable(pParse, iDb, iStatCur, pTab->zName, "tbl"); |
| 78022 | 78336 | } |
| @@ -78117,11 +78431,11 @@ | ||
| 78117 | 78431 | static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){ |
| 78118 | 78432 | analysisInfo *pInfo = (analysisInfo*)pData; |
| 78119 | 78433 | Index *pIndex; |
| 78120 | 78434 | Table *pTable; |
| 78121 | 78435 | int i, c, n; |
| 78122 | - unsigned int v; | |
| 78436 | + tRowcnt v; | |
| 78123 | 78437 | const char *z; |
| 78124 | 78438 | |
| 78125 | 78439 | assert( argc==3 ); |
| 78126 | 78440 | UNUSED_PARAMETER2(NotUsed, argc); |
| 78127 | 78441 | |
| @@ -78160,40 +78474,172 @@ | ||
| 78160 | 78474 | /* |
| 78161 | 78475 | ** If the Index.aSample variable is not NULL, delete the aSample[] array |
| 78162 | 78476 | ** and its contents. |
| 78163 | 78477 | */ |
| 78164 | 78478 | SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){ |
| 78165 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 78479 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78166 | 78480 | if( pIdx->aSample ){ |
| 78167 | 78481 | int j; |
| 78168 | - for(j=0; j<SQLITE_INDEX_SAMPLES; j++){ | |
| 78482 | + for(j=0; j<pIdx->nSample; j++){ | |
| 78169 | 78483 | IndexSample *p = &pIdx->aSample[j]; |
| 78170 | 78484 | if( p->eType==SQLITE_TEXT || p->eType==SQLITE_BLOB ){ |
| 78171 | 78485 | sqlite3DbFree(db, p->u.z); |
| 78172 | 78486 | } |
| 78173 | 78487 | } |
| 78174 | 78488 | sqlite3DbFree(db, pIdx->aSample); |
| 78489 | + } | |
| 78490 | + if( db && db->pnBytesFreed==0 ){ | |
| 78491 | + pIdx->nSample = 0; | |
| 78492 | + pIdx->aSample = 0; | |
| 78175 | 78493 | } |
| 78176 | 78494 | #else |
| 78177 | 78495 | UNUSED_PARAMETER(db); |
| 78178 | 78496 | UNUSED_PARAMETER(pIdx); |
| 78179 | 78497 | #endif |
| 78180 | 78498 | } |
| 78181 | 78499 | |
| 78500 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78182 | 78501 | /* |
| 78183 | -** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The | |
| 78502 | +** Load content from the sqlite_stat3 table into the Index.aSample[] | |
| 78503 | +** arrays of all indices. | |
| 78504 | +*/ | |
| 78505 | +static int loadStat3(sqlite3 *db, const char *zDb){ | |
| 78506 | + int rc; /* Result codes from subroutines */ | |
| 78507 | + sqlite3_stmt *pStmt = 0; /* An SQL statement being run */ | |
| 78508 | + char *zSql; /* Text of the SQL statement */ | |
| 78509 | + Index *pPrevIdx = 0; /* Previous index in the loop */ | |
| 78510 | + int idx = 0; /* slot in pIdx->aSample[] for next sample */ | |
| 78511 | + int eType; /* Datatype of a sample */ | |
| 78512 | + IndexSample *pSample; /* A slot in pIdx->aSample[] */ | |
| 78513 | + | |
| 78514 | + if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){ | |
| 78515 | + return SQLITE_OK; | |
| 78516 | + } | |
| 78517 | + | |
| 78518 | + zSql = sqlite3MPrintf(db, | |
| 78519 | + "SELECT idx,count(*) FROM %Q.sqlite_stat3" | |
| 78520 | + " GROUP BY idx", zDb); | |
| 78521 | + if( !zSql ){ | |
| 78522 | + return SQLITE_NOMEM; | |
| 78523 | + } | |
| 78524 | + rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); | |
| 78525 | + sqlite3DbFree(db, zSql); | |
| 78526 | + if( rc ) return rc; | |
| 78527 | + | |
| 78528 | + while( sqlite3_step(pStmt)==SQLITE_ROW ){ | |
| 78529 | + char *zIndex; /* Index name */ | |
| 78530 | + Index *pIdx; /* Pointer to the index object */ | |
| 78531 | + int nSample; /* Number of samples */ | |
| 78532 | + | |
| 78533 | + zIndex = (char *)sqlite3_column_text(pStmt, 0); | |
| 78534 | + if( zIndex==0 ) continue; | |
| 78535 | + nSample = sqlite3_column_int(pStmt, 1); | |
| 78536 | + pIdx = sqlite3FindIndex(db, zIndex, zDb); | |
| 78537 | + if( pIdx==0 ) continue; | |
| 78538 | + assert( pIdx->nSample==0 ); | |
| 78539 | + pIdx->nSample = nSample; | |
| 78540 | + pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) ); | |
| 78541 | + pIdx->avgEq = pIdx->aiRowEst[1]; | |
| 78542 | + if( pIdx->aSample==0 ){ | |
| 78543 | + db->mallocFailed = 1; | |
| 78544 | + sqlite3_finalize(pStmt); | |
| 78545 | + return SQLITE_NOMEM; | |
| 78546 | + } | |
| 78547 | + } | |
| 78548 | + rc = sqlite3_finalize(pStmt); | |
| 78549 | + if( rc ) return rc; | |
| 78550 | + | |
| 78551 | + zSql = sqlite3MPrintf(db, | |
| 78552 | + "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat3", zDb); | |
| 78553 | + if( !zSql ){ | |
| 78554 | + return SQLITE_NOMEM; | |
| 78555 | + } | |
| 78556 | + rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); | |
| 78557 | + sqlite3DbFree(db, zSql); | |
| 78558 | + if( rc ) return rc; | |
| 78559 | + | |
| 78560 | + while( sqlite3_step(pStmt)==SQLITE_ROW ){ | |
| 78561 | + char *zIndex; /* Index name */ | |
| 78562 | + Index *pIdx; /* Pointer to the index object */ | |
| 78563 | + int i; /* Loop counter */ | |
| 78564 | + tRowcnt sumEq; /* Sum of the nEq values */ | |
| 78565 | + | |
| 78566 | + zIndex = (char *)sqlite3_column_text(pStmt, 0); | |
| 78567 | + if( zIndex==0 ) continue; | |
| 78568 | + pIdx = sqlite3FindIndex(db, zIndex, zDb); | |
| 78569 | + if( pIdx==0 ) continue; | |
| 78570 | + if( pIdx==pPrevIdx ){ | |
| 78571 | + idx++; | |
| 78572 | + }else{ | |
| 78573 | + pPrevIdx = pIdx; | |
| 78574 | + idx = 0; | |
| 78575 | + } | |
| 78576 | + assert( idx<pIdx->nSample ); | |
| 78577 | + pSample = &pIdx->aSample[idx]; | |
| 78578 | + pSample->nEq = (tRowcnt)sqlite3_column_int64(pStmt, 1); | |
| 78579 | + pSample->nLt = (tRowcnt)sqlite3_column_int64(pStmt, 2); | |
| 78580 | + pSample->nDLt = (tRowcnt)sqlite3_column_int64(pStmt, 3); | |
| 78581 | + if( idx==pIdx->nSample-1 ){ | |
| 78582 | + if( pSample->nDLt>0 ){ | |
| 78583 | + for(i=0, sumEq=0; i<=idx-1; i++) sumEq += pIdx->aSample[i].nEq; | |
| 78584 | + pIdx->avgEq = (pSample->nLt - sumEq)/pSample->nDLt; | |
| 78585 | + } | |
| 78586 | + if( pIdx->avgEq<=0 ) pIdx->avgEq = 1; | |
| 78587 | + } | |
| 78588 | + eType = sqlite3_column_type(pStmt, 4); | |
| 78589 | + pSample->eType = (u8)eType; | |
| 78590 | + switch( eType ){ | |
| 78591 | + case SQLITE_INTEGER: { | |
| 78592 | + pSample->u.i = sqlite3_column_int64(pStmt, 4); | |
| 78593 | + break; | |
| 78594 | + } | |
| 78595 | + case SQLITE_FLOAT: { | |
| 78596 | + pSample->u.r = sqlite3_column_double(pStmt, 4); | |
| 78597 | + break; | |
| 78598 | + } | |
| 78599 | + case SQLITE_NULL: { | |
| 78600 | + break; | |
| 78601 | + } | |
| 78602 | + default: assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); { | |
| 78603 | + const char *z = (const char *)( | |
| 78604 | + (eType==SQLITE_BLOB) ? | |
| 78605 | + sqlite3_column_blob(pStmt, 4): | |
| 78606 | + sqlite3_column_text(pStmt, 4) | |
| 78607 | + ); | |
| 78608 | + int n = z ? sqlite3_column_bytes(pStmt, 4) : 0; | |
| 78609 | + pSample->nByte = n; | |
| 78610 | + if( n < 1){ | |
| 78611 | + pSample->u.z = 0; | |
| 78612 | + }else{ | |
| 78613 | + pSample->u.z = sqlite3Malloc(n); | |
| 78614 | + if( pSample->u.z==0 ){ | |
| 78615 | + db->mallocFailed = 1; | |
| 78616 | + sqlite3_finalize(pStmt); | |
| 78617 | + return SQLITE_NOMEM; | |
| 78618 | + } | |
| 78619 | + memcpy(pSample->u.z, z, n); | |
| 78620 | + } | |
| 78621 | + } | |
| 78622 | + } | |
| 78623 | + } | |
| 78624 | + return sqlite3_finalize(pStmt); | |
| 78625 | +} | |
| 78626 | +#endif /* SQLITE_ENABLE_STAT3 */ | |
| 78627 | + | |
| 78628 | +/* | |
| 78629 | +** Load the content of the sqlite_stat1 and sqlite_stat3 tables. The | |
| 78184 | 78630 | ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] |
| 78185 | -** arrays. The contents of sqlite_stat2 are used to populate the | |
| 78631 | +** arrays. The contents of sqlite_stat3 are used to populate the | |
| 78186 | 78632 | ** Index.aSample[] arrays. |
| 78187 | 78633 | ** |
| 78188 | 78634 | ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR |
| 78189 | -** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined | |
| 78190 | -** during compilation and the sqlite_stat2 table is present, no data is | |
| 78635 | +** is returned. In this case, even if SQLITE_ENABLE_STAT3 was defined | |
| 78636 | +** during compilation and the sqlite_stat3 table is present, no data is | |
| 78191 | 78637 | ** read from it. |
| 78192 | 78638 | ** |
| 78193 | -** If SQLITE_ENABLE_STAT2 was defined during compilation and the | |
| 78194 | -** sqlite_stat2 table is not present in the database, SQLITE_ERROR is | |
| 78639 | +** If SQLITE_ENABLE_STAT3 was defined during compilation and the | |
| 78640 | +** sqlite_stat3 table is not present in the database, SQLITE_ERROR is | |
| 78195 | 78641 | ** returned. However, in this case, data is read from the sqlite_stat1 |
| 78196 | 78642 | ** table (if it is present) before returning. |
| 78197 | 78643 | ** |
| 78198 | 78644 | ** If an OOM error occurs, this function always sets db->mallocFailed. |
| 78199 | 78645 | ** This means if the caller does not care about other errors, the return |
| @@ -78211,12 +78657,14 @@ | ||
| 78211 | 78657 | /* Clear any prior statistics */ |
| 78212 | 78658 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 78213 | 78659 | for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ |
| 78214 | 78660 | Index *pIdx = sqliteHashData(i); |
| 78215 | 78661 | sqlite3DefaultRowEst(pIdx); |
| 78662 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78216 | 78663 | sqlite3DeleteIndexSamples(db, pIdx); |
| 78217 | 78664 | pIdx->aSample = 0; |
| 78665 | +#endif | |
| 78218 | 78666 | } |
| 78219 | 78667 | |
| 78220 | 78668 | /* Check to make sure the sqlite_stat1 table exists */ |
| 78221 | 78669 | sInfo.db = db; |
| 78222 | 78670 | sInfo.zDatabase = db->aDb[iDb].zName; |
| @@ -78224,91 +78672,23 @@ | ||
| 78224 | 78672 | return SQLITE_ERROR; |
| 78225 | 78673 | } |
| 78226 | 78674 | |
| 78227 | 78675 | /* Load new statistics out of the sqlite_stat1 table */ |
| 78228 | 78676 | zSql = sqlite3MPrintf(db, |
| 78229 | - "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); | |
| 78677 | + "SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase); | |
| 78230 | 78678 | if( zSql==0 ){ |
| 78231 | 78679 | rc = SQLITE_NOMEM; |
| 78232 | 78680 | }else{ |
| 78233 | 78681 | rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); |
| 78234 | 78682 | sqlite3DbFree(db, zSql); |
| 78235 | 78683 | } |
| 78236 | 78684 | |
| 78237 | 78685 | |
| 78238 | - /* Load the statistics from the sqlite_stat2 table. */ | |
| 78239 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 78240 | - if( rc==SQLITE_OK && !sqlite3FindTable(db, "sqlite_stat2", sInfo.zDatabase) ){ | |
| 78241 | - rc = SQLITE_ERROR; | |
| 78242 | - } | |
| 78243 | - if( rc==SQLITE_OK ){ | |
| 78244 | - sqlite3_stmt *pStmt = 0; | |
| 78245 | - | |
| 78246 | - zSql = sqlite3MPrintf(db, | |
| 78247 | - "SELECT idx,sampleno,sample FROM %Q.sqlite_stat2", sInfo.zDatabase); | |
| 78248 | - if( !zSql ){ | |
| 78249 | - rc = SQLITE_NOMEM; | |
| 78250 | - }else{ | |
| 78251 | - rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); | |
| 78252 | - sqlite3DbFree(db, zSql); | |
| 78253 | - } | |
| 78254 | - | |
| 78255 | - if( rc==SQLITE_OK ){ | |
| 78256 | - while( sqlite3_step(pStmt)==SQLITE_ROW ){ | |
| 78257 | - char *zIndex; /* Index name */ | |
| 78258 | - Index *pIdx; /* Pointer to the index object */ | |
| 78259 | - | |
| 78260 | - zIndex = (char *)sqlite3_column_text(pStmt, 0); | |
| 78261 | - pIdx = zIndex ? sqlite3FindIndex(db, zIndex, sInfo.zDatabase) : 0; | |
| 78262 | - if( pIdx ){ | |
| 78263 | - int iSample = sqlite3_column_int(pStmt, 1); | |
| 78264 | - if( iSample<SQLITE_INDEX_SAMPLES && iSample>=0 ){ | |
| 78265 | - int eType = sqlite3_column_type(pStmt, 2); | |
| 78266 | - | |
| 78267 | - if( pIdx->aSample==0 ){ | |
| 78268 | - static const int sz = sizeof(IndexSample)*SQLITE_INDEX_SAMPLES; | |
| 78269 | - pIdx->aSample = (IndexSample *)sqlite3DbMallocRaw(0, sz); | |
| 78270 | - if( pIdx->aSample==0 ){ | |
| 78271 | - db->mallocFailed = 1; | |
| 78272 | - break; | |
| 78273 | - } | |
| 78274 | - memset(pIdx->aSample, 0, sz); | |
| 78275 | - } | |
| 78276 | - | |
| 78277 | - assert( pIdx->aSample ); | |
| 78278 | - { | |
| 78279 | - IndexSample *pSample = &pIdx->aSample[iSample]; | |
| 78280 | - pSample->eType = (u8)eType; | |
| 78281 | - if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ | |
| 78282 | - pSample->u.r = sqlite3_column_double(pStmt, 2); | |
| 78283 | - }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ | |
| 78284 | - const char *z = (const char *)( | |
| 78285 | - (eType==SQLITE_BLOB) ? | |
| 78286 | - sqlite3_column_blob(pStmt, 2): | |
| 78287 | - sqlite3_column_text(pStmt, 2) | |
| 78288 | - ); | |
| 78289 | - int n = sqlite3_column_bytes(pStmt, 2); | |
| 78290 | - if( n>24 ){ | |
| 78291 | - n = 24; | |
| 78292 | - } | |
| 78293 | - pSample->nByte = (u8)n; | |
| 78294 | - if( n < 1){ | |
| 78295 | - pSample->u.z = 0; | |
| 78296 | - }else{ | |
| 78297 | - pSample->u.z = sqlite3DbStrNDup(0, z, n); | |
| 78298 | - if( pSample->u.z==0 ){ | |
| 78299 | - db->mallocFailed = 1; | |
| 78300 | - break; | |
| 78301 | - } | |
| 78302 | - } | |
| 78303 | - } | |
| 78304 | - } | |
| 78305 | - } | |
| 78306 | - } | |
| 78307 | - } | |
| 78308 | - rc = sqlite3_finalize(pStmt); | |
| 78309 | - } | |
| 78686 | + /* Load the statistics from the sqlite_stat3 table. */ | |
| 78687 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 78688 | + if( rc==SQLITE_OK ){ | |
| 78689 | + rc = loadStat3(db, sInfo.zDatabase); | |
| 78310 | 78690 | } |
| 78311 | 78691 | #endif |
| 78312 | 78692 | |
| 78313 | 78693 | if( rc==SQLITE_NOMEM ){ |
| 78314 | 78694 | db->mallocFailed = 1; |
| @@ -78319,10 +78699,11 @@ | ||
| 78319 | 78699 | |
| 78320 | 78700 | #endif /* SQLITE_OMIT_ANALYZE */ |
| 78321 | 78701 | |
| 78322 | 78702 | /************** End of analyze.c *********************************************/ |
| 78323 | 78703 | /************** Begin file attach.c ******************************************/ |
| 78704 | +#line 1 "tsrc/attach.c" | |
| 78324 | 78705 | /* |
| 78325 | 78706 | ** 2003 April 6 |
| 78326 | 78707 | ** |
| 78327 | 78708 | ** The author disclaims copyright to this source code. In place of |
| 78328 | 78709 | ** a legal notice, here is a blessing: |
| @@ -78878,10 +79259,11 @@ | ||
| 78878 | 79259 | } |
| 78879 | 79260 | #endif |
| 78880 | 79261 | |
| 78881 | 79262 | /************** End of attach.c **********************************************/ |
| 78882 | 79263 | /************** Begin file auth.c ********************************************/ |
| 79264 | +#line 1 "tsrc/auth.c" | |
| 78883 | 79265 | /* |
| 78884 | 79266 | ** 2003 January 11 |
| 78885 | 79267 | ** |
| 78886 | 79268 | ** The author disclaims copyright to this source code. In place of |
| 78887 | 79269 | ** a legal notice, here is a blessing: |
| @@ -79129,10 +79511,11 @@ | ||
| 79129 | 79511 | |
| 79130 | 79512 | #endif /* SQLITE_OMIT_AUTHORIZATION */ |
| 79131 | 79513 | |
| 79132 | 79514 | /************** End of auth.c ************************************************/ |
| 79133 | 79515 | /************** Begin file build.c *******************************************/ |
| 79516 | +#line 1 "tsrc/build.c" | |
| 79134 | 79517 | /* |
| 79135 | 79518 | ** 2001 September 15 |
| 79136 | 79519 | ** |
| 79137 | 79520 | ** The author disclaims copyright to this source code. In place of |
| 79138 | 79521 | ** a legal notice, here is a blessing: |
| @@ -81120,11 +81503,15 @@ | ||
| 81120 | 81503 | Parse *pParse, /* The parsing context */ |
| 81121 | 81504 | int iDb, /* The database number */ |
| 81122 | 81505 | const char *zType, /* "idx" or "tbl" */ |
| 81123 | 81506 | const char *zName /* Name of index or table */ |
| 81124 | 81507 | ){ |
| 81125 | - static const char *azStatTab[] = { "sqlite_stat1", "sqlite_stat2" }; | |
| 81508 | + static const char *azStatTab[] = { | |
| 81509 | + "sqlite_stat1", | |
| 81510 | + "sqlite_stat2", | |
| 81511 | + "sqlite_stat3", | |
| 81512 | + }; | |
| 81126 | 81513 | int i; |
| 81127 | 81514 | const char *zDbName = pParse->db->aDb[iDb].zName; |
| 81128 | 81515 | for(i=0; i<ArraySize(azStatTab); i++){ |
| 81129 | 81516 | if( sqlite3FindTable(pParse->db, azStatTab[i], zDbName) ){ |
| 81130 | 81517 | sqlite3NestedParse(pParse, |
| @@ -81132,10 +81519,80 @@ | ||
| 81132 | 81519 | zDbName, azStatTab[i], zType, zName |
| 81133 | 81520 | ); |
| 81134 | 81521 | } |
| 81135 | 81522 | } |
| 81136 | 81523 | } |
| 81524 | + | |
| 81525 | +/* | |
| 81526 | +** Generate code to drop a table. | |
| 81527 | +*/ | |
| 81528 | +SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){ | |
| 81529 | + Vdbe *v; | |
| 81530 | + sqlite3 *db = pParse->db; | |
| 81531 | + Trigger *pTrigger; | |
| 81532 | + Db *pDb = &db->aDb[iDb]; | |
| 81533 | + | |
| 81534 | + v = sqlite3GetVdbe(pParse); | |
| 81535 | + assert( v!=0 ); | |
| 81536 | + sqlite3BeginWriteOperation(pParse, 1, iDb); | |
| 81537 | + | |
| 81538 | +#ifndef SQLITE_OMIT_VIRTUALTABLE | |
| 81539 | + if( IsVirtual(pTab) ){ | |
| 81540 | + sqlite3VdbeAddOp0(v, OP_VBegin); | |
| 81541 | + } | |
| 81542 | +#endif | |
| 81543 | + | |
| 81544 | + /* Drop all triggers associated with the table being dropped. Code | |
| 81545 | + ** is generated to remove entries from sqlite_master and/or | |
| 81546 | + ** sqlite_temp_master if required. | |
| 81547 | + */ | |
| 81548 | + pTrigger = sqlite3TriggerList(pParse, pTab); | |
| 81549 | + while( pTrigger ){ | |
| 81550 | + assert( pTrigger->pSchema==pTab->pSchema || | |
| 81551 | + pTrigger->pSchema==db->aDb[1].pSchema ); | |
| 81552 | + sqlite3DropTriggerPtr(pParse, pTrigger); | |
| 81553 | + pTrigger = pTrigger->pNext; | |
| 81554 | + } | |
| 81555 | + | |
| 81556 | +#ifndef SQLITE_OMIT_AUTOINCREMENT | |
| 81557 | + /* Remove any entries of the sqlite_sequence table associated with | |
| 81558 | + ** the table being dropped. This is done before the table is dropped | |
| 81559 | + ** at the btree level, in case the sqlite_sequence table needs to | |
| 81560 | + ** move as a result of the drop (can happen in auto-vacuum mode). | |
| 81561 | + */ | |
| 81562 | + if( pTab->tabFlags & TF_Autoincrement ){ | |
| 81563 | + sqlite3NestedParse(pParse, | |
| 81564 | + "DELETE FROM %Q.sqlite_sequence WHERE name=%Q", | |
| 81565 | + pDb->zName, pTab->zName | |
| 81566 | + ); | |
| 81567 | + } | |
| 81568 | +#endif | |
| 81569 | + | |
| 81570 | + /* Drop all SQLITE_MASTER table and index entries that refer to the | |
| 81571 | + ** table. The program name loops through the master table and deletes | |
| 81572 | + ** every row that refers to a table of the same name as the one being | |
| 81573 | + ** dropped. Triggers are handled seperately because a trigger can be | |
| 81574 | + ** created in the temp database that refers to a table in another | |
| 81575 | + ** database. | |
| 81576 | + */ | |
| 81577 | + sqlite3NestedParse(pParse, | |
| 81578 | + "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", | |
| 81579 | + pDb->zName, SCHEMA_TABLE(iDb), pTab->zName); | |
| 81580 | + if( !isView && !IsVirtual(pTab) ){ | |
| 81581 | + destroyTable(pParse, pTab); | |
| 81582 | + } | |
| 81583 | + | |
| 81584 | + /* Remove the table entry from SQLite's internal schema and modify | |
| 81585 | + ** the schema cookie. | |
| 81586 | + */ | |
| 81587 | + if( IsVirtual(pTab) ){ | |
| 81588 | + sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0); | |
| 81589 | + } | |
| 81590 | + sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); | |
| 81591 | + sqlite3ChangeCookie(pParse, iDb); | |
| 81592 | + sqliteViewResetAll(db, iDb); | |
| 81593 | +} | |
| 81137 | 81594 | |
| 81138 | 81595 | /* |
| 81139 | 81596 | ** This routine is called to do the work of a DROP TABLE statement. |
| 81140 | 81597 | ** pName is the name of the table to be dropped. |
| 81141 | 81598 | */ |
| @@ -81225,72 +81682,15 @@ | ||
| 81225 | 81682 | /* Generate code to remove the table from the master table |
| 81226 | 81683 | ** on disk. |
| 81227 | 81684 | */ |
| 81228 | 81685 | v = sqlite3GetVdbe(pParse); |
| 81229 | 81686 | if( v ){ |
| 81230 | - Trigger *pTrigger; | |
| 81231 | - Db *pDb = &db->aDb[iDb]; | |
| 81232 | 81687 | sqlite3BeginWriteOperation(pParse, 1, iDb); |
| 81233 | - | |
| 81234 | -#ifndef SQLITE_OMIT_VIRTUALTABLE | |
| 81235 | - if( IsVirtual(pTab) ){ | |
| 81236 | - sqlite3VdbeAddOp0(v, OP_VBegin); | |
| 81237 | - } | |
| 81238 | -#endif | |
| 81688 | + sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName); | |
| 81239 | 81689 | sqlite3FkDropTable(pParse, pName, pTab); |
| 81240 | - | |
| 81241 | - /* Drop all triggers associated with the table being dropped. Code | |
| 81242 | - ** is generated to remove entries from sqlite_master and/or | |
| 81243 | - ** sqlite_temp_master if required. | |
| 81244 | - */ | |
| 81245 | - pTrigger = sqlite3TriggerList(pParse, pTab); | |
| 81246 | - while( pTrigger ){ | |
| 81247 | - assert( pTrigger->pSchema==pTab->pSchema || | |
| 81248 | - pTrigger->pSchema==db->aDb[1].pSchema ); | |
| 81249 | - sqlite3DropTriggerPtr(pParse, pTrigger); | |
| 81250 | - pTrigger = pTrigger->pNext; | |
| 81251 | - } | |
| 81252 | - | |
| 81253 | -#ifndef SQLITE_OMIT_AUTOINCREMENT | |
| 81254 | - /* Remove any entries of the sqlite_sequence table associated with | |
| 81255 | - ** the table being dropped. This is done before the table is dropped | |
| 81256 | - ** at the btree level, in case the sqlite_sequence table needs to | |
| 81257 | - ** move as a result of the drop (can happen in auto-vacuum mode). | |
| 81258 | - */ | |
| 81259 | - if( pTab->tabFlags & TF_Autoincrement ){ | |
| 81260 | - sqlite3NestedParse(pParse, | |
| 81261 | - "DELETE FROM %s.sqlite_sequence WHERE name=%Q", | |
| 81262 | - pDb->zName, pTab->zName | |
| 81263 | - ); | |
| 81264 | - } | |
| 81265 | -#endif | |
| 81266 | - | |
| 81267 | - /* Drop all SQLITE_MASTER table and index entries that refer to the | |
| 81268 | - ** table. The program name loops through the master table and deletes | |
| 81269 | - ** every row that refers to a table of the same name as the one being | |
| 81270 | - ** dropped. Triggers are handled seperately because a trigger can be | |
| 81271 | - ** created in the temp database that refers to a table in another | |
| 81272 | - ** database. | |
| 81273 | - */ | |
| 81274 | - sqlite3NestedParse(pParse, | |
| 81275 | - "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", | |
| 81276 | - pDb->zName, SCHEMA_TABLE(iDb), pTab->zName); | |
| 81277 | - sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName); | |
| 81278 | - if( !isView && !IsVirtual(pTab) ){ | |
| 81279 | - destroyTable(pParse, pTab); | |
| 81280 | - } | |
| 81281 | - | |
| 81282 | - /* Remove the table entry from SQLite's internal schema and modify | |
| 81283 | - ** the schema cookie. | |
| 81284 | - */ | |
| 81285 | - if( IsVirtual(pTab) ){ | |
| 81286 | - sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0); | |
| 81287 | - } | |
| 81288 | - sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); | |
| 81289 | - sqlite3ChangeCookie(pParse, iDb); | |
| 81290 | - } | |
| 81291 | - sqliteViewResetAll(db, iDb); | |
| 81690 | + sqlite3CodeDropTable(pParse, pTab, iDb, isView); | |
| 81691 | + } | |
| 81292 | 81692 | |
| 81293 | 81693 | exit_drop_table: |
| 81294 | 81694 | sqlite3SrcListDelete(db, pName); |
| 81295 | 81695 | } |
| 81296 | 81696 | |
| @@ -81769,24 +82169,24 @@ | ||
| 81769 | 82169 | */ |
| 81770 | 82170 | nName = sqlite3Strlen30(zName); |
| 81771 | 82171 | nCol = pList->nExpr; |
| 81772 | 82172 | pIndex = sqlite3DbMallocZero(db, |
| 81773 | 82173 | sizeof(Index) + /* Index structure */ |
| 82174 | + sizeof(tRowcnt)*(nCol+1) + /* Index.aiRowEst */ | |
| 81774 | 82175 | sizeof(int)*nCol + /* Index.aiColumn */ |
| 81775 | - sizeof(int)*(nCol+1) + /* Index.aiRowEst */ | |
| 81776 | 82176 | sizeof(char *)*nCol + /* Index.azColl */ |
| 81777 | 82177 | sizeof(u8)*nCol + /* Index.aSortOrder */ |
| 81778 | 82178 | nName + 1 + /* Index.zName */ |
| 81779 | 82179 | nExtra /* Collation sequence names */ |
| 81780 | 82180 | ); |
| 81781 | 82181 | if( db->mallocFailed ){ |
| 81782 | 82182 | goto exit_create_index; |
| 81783 | 82183 | } |
| 81784 | - pIndex->azColl = (char**)(&pIndex[1]); | |
| 82184 | + pIndex->aiRowEst = (tRowcnt*)(&pIndex[1]); | |
| 82185 | + pIndex->azColl = (char**)(&pIndex->aiRowEst[nCol+1]); | |
| 81785 | 82186 | pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]); |
| 81786 | - pIndex->aiRowEst = (unsigned *)(&pIndex->aiColumn[nCol]); | |
| 81787 | - pIndex->aSortOrder = (u8 *)(&pIndex->aiRowEst[nCol+1]); | |
| 82187 | + pIndex->aSortOrder = (u8 *)(&pIndex->aiColumn[nCol]); | |
| 81788 | 82188 | pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]); |
| 81789 | 82189 | zExtra = (char *)(&pIndex->zName[nName+1]); |
| 81790 | 82190 | memcpy(pIndex->zName, zName, nName+1); |
| 81791 | 82191 | pIndex->pTable = pTab; |
| 81792 | 82192 | pIndex->nColumn = pList->nExpr; |
| @@ -82059,13 +82459,13 @@ | ||
| 82059 | 82459 | ** Apart from that, we have little to go on besides intuition as to |
| 82060 | 82460 | ** how aiRowEst[] should be initialized. The numbers generated here |
| 82061 | 82461 | ** are based on typical values found in actual indices. |
| 82062 | 82462 | */ |
| 82063 | 82463 | SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){ |
| 82064 | - unsigned *a = pIdx->aiRowEst; | |
| 82464 | + tRowcnt *a = pIdx->aiRowEst; | |
| 82065 | 82465 | int i; |
| 82066 | - unsigned n; | |
| 82466 | + tRowcnt n; | |
| 82067 | 82467 | assert( a!=0 ); |
| 82068 | 82468 | a[0] = pIdx->pTable->nRowEst; |
| 82069 | 82469 | if( a[0]<10 ) a[0] = 10; |
| 82070 | 82470 | n = 10; |
| 82071 | 82471 | for(i=1; i<=pIdx->nColumn; i++){ |
| @@ -82932,10 +83332,11 @@ | ||
| 82932 | 83332 | return pKey; |
| 82933 | 83333 | } |
| 82934 | 83334 | |
| 82935 | 83335 | /************** End of build.c ***********************************************/ |
| 82936 | 83336 | /************** Begin file callback.c ****************************************/ |
| 83337 | +#line 1 "tsrc/callback.c" | |
| 82937 | 83338 | /* |
| 82938 | 83339 | ** 2005 May 23 |
| 82939 | 83340 | ** |
| 82940 | 83341 | ** The author disclaims copyright to this source code. In place of |
| 82941 | 83342 | ** a legal notice, here is a blessing: |
| @@ -83391,10 +83792,11 @@ | ||
| 83391 | 83792 | return p; |
| 83392 | 83793 | } |
| 83393 | 83794 | |
| 83394 | 83795 | /************** End of callback.c ********************************************/ |
| 83395 | 83796 | /************** Begin file delete.c ******************************************/ |
| 83797 | +#line 1 "tsrc/delete.c" | |
| 83396 | 83798 | /* |
| 83397 | 83799 | ** 2001 September 15 |
| 83398 | 83800 | ** |
| 83399 | 83801 | ** The author disclaims copyright to this source code. In place of |
| 83400 | 83802 | ** a legal notice, here is a blessing: |
| @@ -84045,10 +84447,11 @@ | ||
| 84045 | 84447 | return regBase; |
| 84046 | 84448 | } |
| 84047 | 84449 | |
| 84048 | 84450 | /************** End of delete.c **********************************************/ |
| 84049 | 84451 | /************** Begin file func.c ********************************************/ |
| 84452 | +#line 1 "tsrc/func.c" | |
| 84050 | 84453 | /* |
| 84051 | 84454 | ** 2002 February 23 |
| 84052 | 84455 | ** |
| 84053 | 84456 | ** The author disclaims copyright to this source code. In place of |
| 84054 | 84457 | ** a legal notice, here is a blessing: |
| @@ -85653,10 +86056,11 @@ | ||
| 85653 | 86056 | #endif |
| 85654 | 86057 | } |
| 85655 | 86058 | |
| 85656 | 86059 | /************** End of func.c ************************************************/ |
| 85657 | 86060 | /************** Begin file fkey.c ********************************************/ |
| 86061 | +#line 1 "tsrc/fkey.c" | |
| 85658 | 86062 | /* |
| 85659 | 86063 | ** |
| 85660 | 86064 | ** The author disclaims copyright to this source code. In place of |
| 85661 | 86065 | ** a legal notice, here is a blessing: |
| 85662 | 86066 | ** |
| @@ -86873,10 +87277,11 @@ | ||
| 86873 | 87277 | } |
| 86874 | 87278 | #endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */ |
| 86875 | 87279 | |
| 86876 | 87280 | /************** End of fkey.c ************************************************/ |
| 86877 | 87281 | /************** Begin file insert.c ******************************************/ |
| 87282 | +#line 1 "tsrc/insert.c" | |
| 86878 | 87283 | /* |
| 86879 | 87284 | ** 2001 September 15 |
| 86880 | 87285 | ** |
| 86881 | 87286 | ** The author disclaims copyright to this source code. In place of |
| 86882 | 87287 | ** a legal notice, here is a blessing: |
| @@ -88621,10 +89026,13 @@ | ||
| 88621 | 89026 | */ |
| 88622 | 89027 | if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){ |
| 88623 | 89028 | return 0; |
| 88624 | 89029 | } |
| 88625 | 89030 | #endif |
| 89031 | + if( (pParse->db->flags & SQLITE_CountRows)!=0 ){ | |
| 89032 | + return 0; | |
| 89033 | + } | |
| 88626 | 89034 | |
| 88627 | 89035 | /* If we get this far, it means either: |
| 88628 | 89036 | ** |
| 88629 | 89037 | ** * We can always do the transfer if the table contains an |
| 88630 | 89038 | ** an integer primary key |
| @@ -88718,10 +89126,11 @@ | ||
| 88718 | 89126 | } |
| 88719 | 89127 | #endif /* SQLITE_OMIT_XFER_OPT */ |
| 88720 | 89128 | |
| 88721 | 89129 | /************** End of insert.c **********************************************/ |
| 88722 | 89130 | /************** Begin file legacy.c ******************************************/ |
| 89131 | +#line 1 "tsrc/legacy.c" | |
| 88723 | 89132 | /* |
| 88724 | 89133 | ** 2001 September 15 |
| 88725 | 89134 | ** |
| 88726 | 89135 | ** The author disclaims copyright to this source code. In place of |
| 88727 | 89136 | ** a legal notice, here is a blessing: |
| @@ -88865,10 +89274,11 @@ | ||
| 88865 | 89274 | return rc; |
| 88866 | 89275 | } |
| 88867 | 89276 | |
| 88868 | 89277 | /************** End of legacy.c **********************************************/ |
| 88869 | 89278 | /************** Begin file loadext.c *****************************************/ |
| 89279 | +#line 1 "tsrc/loadext.c" | |
| 88870 | 89280 | /* |
| 88871 | 89281 | ** 2006 June 7 |
| 88872 | 89282 | ** |
| 88873 | 89283 | ** The author disclaims copyright to this source code. In place of |
| 88874 | 89284 | ** a legal notice, here is a blessing: |
| @@ -88885,10 +89295,11 @@ | ||
| 88885 | 89295 | #ifndef SQLITE_CORE |
| 88886 | 89296 | #define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ |
| 88887 | 89297 | #endif |
| 88888 | 89298 | /************** Include sqlite3ext.h in the middle of loadext.c **************/ |
| 88889 | 89299 | /************** Begin file sqlite3ext.h **************************************/ |
| 89300 | +#line 1 "tsrc/sqlite3ext.h" | |
| 88890 | 89301 | /* |
| 88891 | 89302 | ** 2006 June 7 |
| 88892 | 89303 | ** |
| 88893 | 89304 | ** The author disclaims copyright to this source code. In place of |
| 88894 | 89305 | ** a legal notice, here is a blessing: |
| @@ -89313,10 +89724,11 @@ | ||
| 89313 | 89724 | |
| 89314 | 89725 | #endif /* _SQLITE3EXT_H_ */ |
| 89315 | 89726 | |
| 89316 | 89727 | /************** End of sqlite3ext.h ******************************************/ |
| 89317 | 89728 | /************** Continuing where we left off in loadext.c ********************/ |
| 89729 | +#line 20 "tsrc/loadext.c" | |
| 89318 | 89730 | /* #include <string.h> */ |
| 89319 | 89731 | |
| 89320 | 89732 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 89321 | 89733 | |
| 89322 | 89734 | /* |
| @@ -89952,10 +90364,11 @@ | ||
| 89952 | 90364 | } |
| 89953 | 90365 | } |
| 89954 | 90366 | |
| 89955 | 90367 | /************** End of loadext.c *********************************************/ |
| 89956 | 90368 | /************** Begin file pragma.c ******************************************/ |
| 90369 | +#line 1 "tsrc/pragma.c" | |
| 89957 | 90370 | /* |
| 89958 | 90371 | ** 2003 April 6 |
| 89959 | 90372 | ** |
| 89960 | 90373 | ** The author disclaims copyright to this source code. In place of |
| 89961 | 90374 | ** a legal notice, here is a blessing: |
| @@ -91480,10 +91893,11 @@ | ||
| 91480 | 91893 | |
| 91481 | 91894 | #endif /* SQLITE_OMIT_PRAGMA */ |
| 91482 | 91895 | |
| 91483 | 91896 | /************** End of pragma.c **********************************************/ |
| 91484 | 91897 | /************** Begin file prepare.c *****************************************/ |
| 91898 | +#line 1 "tsrc/prepare.c" | |
| 91485 | 91899 | /* |
| 91486 | 91900 | ** 2005 May 25 |
| 91487 | 91901 | ** |
| 91488 | 91902 | ** The author disclaims copyright to this source code. In place of |
| 91489 | 91903 | ** a legal notice, here is a blessing: |
| @@ -92340,10 +92754,11 @@ | ||
| 92340 | 92754 | |
| 92341 | 92755 | #endif /* SQLITE_OMIT_UTF16 */ |
| 92342 | 92756 | |
| 92343 | 92757 | /************** End of prepare.c *********************************************/ |
| 92344 | 92758 | /************** Begin file select.c ******************************************/ |
| 92759 | +#line 1 "tsrc/select.c" | |
| 92345 | 92760 | /* |
| 92346 | 92761 | ** 2001 September 15 |
| 92347 | 92762 | ** |
| 92348 | 92763 | ** The author disclaims copyright to this source code. In place of |
| 92349 | 92764 | ** a legal notice, here is a blessing: |
| @@ -96928,10 +97343,11 @@ | ||
| 96928 | 97343 | *****************************************************************************/ |
| 96929 | 97344 | #endif /* defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */ |
| 96930 | 97345 | |
| 96931 | 97346 | /************** End of select.c **********************************************/ |
| 96932 | 97347 | /************** Begin file table.c *******************************************/ |
| 97348 | +#line 1 "tsrc/table.c" | |
| 96933 | 97349 | /* |
| 96934 | 97350 | ** 2001 September 15 |
| 96935 | 97351 | ** |
| 96936 | 97352 | ** The author disclaims copyright to this source code. In place of |
| 96937 | 97353 | ** a legal notice, here is a blessing: |
| @@ -97127,10 +97543,11 @@ | ||
| 97127 | 97543 | |
| 97128 | 97544 | #endif /* SQLITE_OMIT_GET_TABLE */ |
| 97129 | 97545 | |
| 97130 | 97546 | /************** End of table.c ***********************************************/ |
| 97131 | 97547 | /************** Begin file trigger.c *****************************************/ |
| 97548 | +#line 1 "tsrc/trigger.c" | |
| 97132 | 97549 | /* |
| 97133 | 97550 | ** |
| 97134 | 97551 | ** The author disclaims copyright to this source code. In place of |
| 97135 | 97552 | ** a legal notice, here is a blessing: |
| 97136 | 97553 | ** |
| @@ -98252,10 +98669,11 @@ | ||
| 98252 | 98669 | |
| 98253 | 98670 | #endif /* !defined(SQLITE_OMIT_TRIGGER) */ |
| 98254 | 98671 | |
| 98255 | 98672 | /************** End of trigger.c *********************************************/ |
| 98256 | 98673 | /************** Begin file update.c ******************************************/ |
| 98674 | +#line 1 "tsrc/update.c" | |
| 98257 | 98675 | /* |
| 98258 | 98676 | ** 2001 September 15 |
| 98259 | 98677 | ** |
| 98260 | 98678 | ** The author disclaims copyright to this source code. In place of |
| 98261 | 98679 | ** a legal notice, here is a blessing: |
| @@ -98924,10 +99342,11 @@ | ||
| 98924 | 99342 | } |
| 98925 | 99343 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 98926 | 99344 | |
| 98927 | 99345 | /************** End of update.c **********************************************/ |
| 98928 | 99346 | /************** Begin file vacuum.c ******************************************/ |
| 99347 | +#line 1 "tsrc/vacuum.c" | |
| 98929 | 99348 | /* |
| 98930 | 99349 | ** 2003 April 6 |
| 98931 | 99350 | ** |
| 98932 | 99351 | ** The author disclaims copyright to this source code. In place of |
| 98933 | 99352 | ** a legal notice, here is a blessing: |
| @@ -98969,11 +99388,11 @@ | ||
| 98969 | 99388 | if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ |
| 98970 | 99389 | sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db)); |
| 98971 | 99390 | return sqlite3_errcode(db); |
| 98972 | 99391 | } |
| 98973 | 99392 | VVA_ONLY( rc = ) sqlite3_step(pStmt); |
| 98974 | - assert( rc!=SQLITE_ROW ); | |
| 99393 | + assert( rc!=SQLITE_ROW || (db->flags&SQLITE_CountRows) ); | |
| 98975 | 99394 | return vacuumFinalize(db, pStmt, pzErrMsg); |
| 98976 | 99395 | } |
| 98977 | 99396 | |
| 98978 | 99397 | /* |
| 98979 | 99398 | ** Execute zSql on database db. The statement returns exactly |
| @@ -99187,17 +99606,15 @@ | ||
| 99187 | 99606 | " WHERE type='view' OR type='trigger'" |
| 99188 | 99607 | " OR (type='table' AND rootpage=0)" |
| 99189 | 99608 | ); |
| 99190 | 99609 | if( rc ) goto end_of_vacuum; |
| 99191 | 99610 | |
| 99192 | - /* At this point, unless the main db was completely empty, there is now a | |
| 99193 | - ** transaction open on the vacuum database, but not on the main database. | |
| 99194 | - ** Open a btree level transaction on the main database. This allows a | |
| 99195 | - ** call to sqlite3BtreeCopyFile(). The main database btree level | |
| 99196 | - ** transaction is then committed, so the SQL level never knows it was | |
| 99197 | - ** opened for writing. This way, the SQL transaction used to create the | |
| 99198 | - ** temporary database never needs to be committed. | |
| 99611 | + /* At this point, there is a write transaction open on both the | |
| 99612 | + ** vacuum database and the main database. Assuming no error occurs, | |
| 99613 | + ** both transactions are closed by this block - the main database | |
| 99614 | + ** transaction by sqlite3BtreeCopyFile() and the other by an explicit | |
| 99615 | + ** call to sqlite3BtreeCommit(). | |
| 99199 | 99616 | */ |
| 99200 | 99617 | { |
| 99201 | 99618 | u32 meta; |
| 99202 | 99619 | int i; |
| 99203 | 99620 | |
| @@ -99270,10 +99687,11 @@ | ||
| 99270 | 99687 | |
| 99271 | 99688 | #endif /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ |
| 99272 | 99689 | |
| 99273 | 99690 | /************** End of vacuum.c **********************************************/ |
| 99274 | 99691 | /************** Begin file vtab.c ********************************************/ |
| 99692 | +#line 1 "tsrc/vtab.c" | |
| 99275 | 99693 | /* |
| 99276 | 99694 | ** 2006 June 10 |
| 99277 | 99695 | ** |
| 99278 | 99696 | ** The author disclaims copyright to this source code. In place of |
| 99279 | 99697 | ** a legal notice, here is a blessing: |
| @@ -100338,10 +100756,11 @@ | ||
| 100338 | 100756 | |
| 100339 | 100757 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 100340 | 100758 | |
| 100341 | 100759 | /************** End of vtab.c ************************************************/ |
| 100342 | 100760 | /************** Begin file where.c *******************************************/ |
| 100761 | +#line 1 "tsrc/where.c" | |
| 100343 | 100762 | /* |
| 100344 | 100763 | ** 2001 September 15 |
| 100345 | 100764 | ** |
| 100346 | 100765 | ** The author disclaims copyright to this source code. In place of |
| 100347 | 100766 | ** a legal notice, here is a blessing: |
| @@ -100457,25 +100876,35 @@ | ||
| 100457 | 100876 | #define TERM_CODED 0x04 /* This term is already coded */ |
| 100458 | 100877 | #define TERM_COPIED 0x08 /* Has a child */ |
| 100459 | 100878 | #define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ |
| 100460 | 100879 | #define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ |
| 100461 | 100880 | #define TERM_OR_OK 0x40 /* Used during OR-clause processing */ |
| 100462 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 100881 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 100463 | 100882 | # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */ |
| 100464 | 100883 | #else |
| 100465 | -# define TERM_VNULL 0x00 /* Disabled if not using stat2 */ | |
| 100884 | +# define TERM_VNULL 0x00 /* Disabled if not using stat3 */ | |
| 100466 | 100885 | #endif |
| 100467 | 100886 | |
| 100468 | 100887 | /* |
| 100469 | 100888 | ** An instance of the following structure holds all information about a |
| 100470 | 100889 | ** WHERE clause. Mostly this is a container for one or more WhereTerms. |
| 100890 | +** | |
| 100891 | +** Explanation of pOuter: For a WHERE clause of the form | |
| 100892 | +** | |
| 100893 | +** a AND ((b AND c) OR (d AND e)) AND f | |
| 100894 | +** | |
| 100895 | +** There are separate WhereClause objects for the whole clause and for | |
| 100896 | +** the subclauses "(b AND c)" and "(d AND e)". The pOuter field of the | |
| 100897 | +** subclauses points to the WhereClause object for the whole clause. | |
| 100471 | 100898 | */ |
| 100472 | 100899 | struct WhereClause { |
| 100473 | 100900 | Parse *pParse; /* The parser context */ |
| 100474 | 100901 | WhereMaskSet *pMaskSet; /* Mapping of table cursor numbers to bitmasks */ |
| 100475 | 100902 | Bitmask vmask; /* Bitmask identifying virtual table cursors */ |
| 100903 | + WhereClause *pOuter; /* Outer conjunction */ | |
| 100476 | 100904 | u8 op; /* Split operator. TK_AND or TK_OR */ |
| 100905 | + u16 wctrlFlags; /* Might include WHERE_AND_ONLY */ | |
| 100477 | 100906 | int nTerm; /* Number of terms */ |
| 100478 | 100907 | int nSlot; /* Number of entries in a[] */ |
| 100479 | 100908 | WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */ |
| 100480 | 100909 | #if defined(SQLITE_SMALL_STACK) |
| 100481 | 100910 | WhereTerm aStatic[1]; /* Initial static space for a[] */ |
| @@ -100600,18 +101029,21 @@ | ||
| 100600 | 101029 | ** Initialize a preallocated WhereClause structure. |
| 100601 | 101030 | */ |
| 100602 | 101031 | static void whereClauseInit( |
| 100603 | 101032 | WhereClause *pWC, /* The WhereClause to be initialized */ |
| 100604 | 101033 | Parse *pParse, /* The parsing context */ |
| 100605 | - WhereMaskSet *pMaskSet /* Mapping from table cursor numbers to bitmasks */ | |
| 101034 | + WhereMaskSet *pMaskSet, /* Mapping from table cursor numbers to bitmasks */ | |
| 101035 | + u16 wctrlFlags /* Might include WHERE_AND_ONLY */ | |
| 100606 | 101036 | ){ |
| 100607 | 101037 | pWC->pParse = pParse; |
| 100608 | 101038 | pWC->pMaskSet = pMaskSet; |
| 101039 | + pWC->pOuter = 0; | |
| 100609 | 101040 | pWC->nTerm = 0; |
| 100610 | 101041 | pWC->nSlot = ArraySize(pWC->aStatic); |
| 100611 | 101042 | pWC->a = pWC->aStatic; |
| 100612 | 101043 | pWC->vmask = 0; |
| 101044 | + pWC->wctrlFlags = wctrlFlags; | |
| 100613 | 101045 | } |
| 100614 | 101046 | |
| 100615 | 101047 | /* Forward reference */ |
| 100616 | 101048 | static void whereClauseClear(WhereClause*); |
| 100617 | 101049 | |
| @@ -100923,40 +101355,42 @@ | ||
| 100923 | 101355 | ){ |
| 100924 | 101356 | WhereTerm *pTerm; |
| 100925 | 101357 | int k; |
| 100926 | 101358 | assert( iCur>=0 ); |
| 100927 | 101359 | op &= WO_ALL; |
| 100928 | - for(pTerm=pWC->a, k=pWC->nTerm; k; k--, pTerm++){ | |
| 100929 | - if( pTerm->leftCursor==iCur | |
| 100930 | - && (pTerm->prereqRight & notReady)==0 | |
| 100931 | - && pTerm->u.leftColumn==iColumn | |
| 100932 | - && (pTerm->eOperator & op)!=0 | |
| 100933 | - ){ | |
| 100934 | - if( pIdx && pTerm->eOperator!=WO_ISNULL ){ | |
| 100935 | - Expr *pX = pTerm->pExpr; | |
| 100936 | - CollSeq *pColl; | |
| 100937 | - char idxaff; | |
| 100938 | - int j; | |
| 100939 | - Parse *pParse = pWC->pParse; | |
| 100940 | - | |
| 100941 | - idxaff = pIdx->pTable->aCol[iColumn].affinity; | |
| 100942 | - if( !sqlite3IndexAffinityOk(pX, idxaff) ) continue; | |
| 100943 | - | |
| 100944 | - /* Figure out the collation sequence required from an index for | |
| 100945 | - ** it to be useful for optimising expression pX. Store this | |
| 100946 | - ** value in variable pColl. | |
| 100947 | - */ | |
| 100948 | - assert(pX->pLeft); | |
| 100949 | - pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); | |
| 100950 | - assert(pColl || pParse->nErr); | |
| 100951 | - | |
| 100952 | - for(j=0; pIdx->aiColumn[j]!=iColumn; j++){ | |
| 100953 | - if( NEVER(j>=pIdx->nColumn) ) return 0; | |
| 100954 | - } | |
| 100955 | - if( pColl && sqlite3StrICmp(pColl->zName, pIdx->azColl[j]) ) continue; | |
| 100956 | - } | |
| 100957 | - return pTerm; | |
| 101360 | + for(; pWC; pWC=pWC->pOuter){ | |
| 101361 | + for(pTerm=pWC->a, k=pWC->nTerm; k; k--, pTerm++){ | |
| 101362 | + if( pTerm->leftCursor==iCur | |
| 101363 | + && (pTerm->prereqRight & notReady)==0 | |
| 101364 | + && pTerm->u.leftColumn==iColumn | |
| 101365 | + && (pTerm->eOperator & op)!=0 | |
| 101366 | + ){ | |
| 101367 | + if( pIdx && pTerm->eOperator!=WO_ISNULL ){ | |
| 101368 | + Expr *pX = pTerm->pExpr; | |
| 101369 | + CollSeq *pColl; | |
| 101370 | + char idxaff; | |
| 101371 | + int j; | |
| 101372 | + Parse *pParse = pWC->pParse; | |
| 101373 | + | |
| 101374 | + idxaff = pIdx->pTable->aCol[iColumn].affinity; | |
| 101375 | + if( !sqlite3IndexAffinityOk(pX, idxaff) ) continue; | |
| 101376 | + | |
| 101377 | + /* Figure out the collation sequence required from an index for | |
| 101378 | + ** it to be useful for optimising expression pX. Store this | |
| 101379 | + ** value in variable pColl. | |
| 101380 | + */ | |
| 101381 | + assert(pX->pLeft); | |
| 101382 | + pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); | |
| 101383 | + assert(pColl || pParse->nErr); | |
| 101384 | + | |
| 101385 | + for(j=0; pIdx->aiColumn[j]!=iColumn; j++){ | |
| 101386 | + if( NEVER(j>=pIdx->nColumn) ) return 0; | |
| 101387 | + } | |
| 101388 | + if( pColl && sqlite3StrICmp(pColl->zName, pIdx->azColl[j]) ) continue; | |
| 101389 | + } | |
| 101390 | + return pTerm; | |
| 101391 | + } | |
| 100958 | 101392 | } |
| 100959 | 101393 | } |
| 100960 | 101394 | return 0; |
| 100961 | 101395 | } |
| 100962 | 101396 | |
| @@ -101216,11 +101650,11 @@ | ||
| 101216 | 101650 | assert( pExpr->op==TK_OR ); |
| 101217 | 101651 | pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo)); |
| 101218 | 101652 | if( pOrInfo==0 ) return; |
| 101219 | 101653 | pTerm->wtFlags |= TERM_ORINFO; |
| 101220 | 101654 | pOrWc = &pOrInfo->wc; |
| 101221 | - whereClauseInit(pOrWc, pWC->pParse, pMaskSet); | |
| 101655 | + whereClauseInit(pOrWc, pWC->pParse, pMaskSet, pWC->wctrlFlags); | |
| 101222 | 101656 | whereSplit(pOrWc, pExpr, TK_OR); |
| 101223 | 101657 | exprAnalyzeAll(pSrc, pOrWc); |
| 101224 | 101658 | if( db->mallocFailed ) return; |
| 101225 | 101659 | assert( pOrWc->nTerm>=2 ); |
| 101226 | 101660 | |
| @@ -101243,13 +101677,14 @@ | ||
| 101243 | 101677 | Bitmask b = 0; |
| 101244 | 101678 | pOrTerm->u.pAndInfo = pAndInfo; |
| 101245 | 101679 | pOrTerm->wtFlags |= TERM_ANDINFO; |
| 101246 | 101680 | pOrTerm->eOperator = WO_AND; |
| 101247 | 101681 | pAndWC = &pAndInfo->wc; |
| 101248 | - whereClauseInit(pAndWC, pWC->pParse, pMaskSet); | |
| 101682 | + whereClauseInit(pAndWC, pWC->pParse, pMaskSet, pWC->wctrlFlags); | |
| 101249 | 101683 | whereSplit(pAndWC, pOrTerm->pExpr, TK_AND); |
| 101250 | 101684 | exprAnalyzeAll(pSrc, pAndWC); |
| 101685 | + pAndWC->pOuter = pWC; | |
| 101251 | 101686 | testcase( db->mallocFailed ); |
| 101252 | 101687 | if( !db->mallocFailed ){ |
| 101253 | 101688 | for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){ |
| 101254 | 101689 | assert( pAndTerm->pExpr ); |
| 101255 | 101690 | if( allowedOp(pAndTerm->pExpr->op) ){ |
| @@ -101679,12 +102114,12 @@ | ||
| 101679 | 102114 | pNewTerm->prereqAll = pTerm->prereqAll; |
| 101680 | 102115 | } |
| 101681 | 102116 | } |
| 101682 | 102117 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 101683 | 102118 | |
| 101684 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 101685 | - /* When sqlite_stat2 histogram data is available an operator of the | |
| 102119 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 102120 | + /* When sqlite_stat3 histogram data is available an operator of the | |
| 101686 | 102121 | ** form "x IS NOT NULL" can sometimes be evaluated more efficiently |
| 101687 | 102122 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a |
| 101688 | 102123 | ** virtual term of that form. |
| 101689 | 102124 | ** |
| 101690 | 102125 | ** Note that the virtual term must be tagged with TERM_VNULL. This |
| @@ -101718,11 +102153,11 @@ | ||
| 101718 | 102153 | pTerm->nChild = 1; |
| 101719 | 102154 | pTerm->wtFlags |= TERM_COPIED; |
| 101720 | 102155 | pNewTerm->prereqAll = pTerm->prereqAll; |
| 101721 | 102156 | } |
| 101722 | 102157 | } |
| 101723 | -#endif /* SQLITE_ENABLE_STAT2 */ | |
| 102158 | +#endif /* SQLITE_ENABLE_STAT */ | |
| 101724 | 102159 | |
| 101725 | 102160 | /* Prevent ON clause terms of a LEFT JOIN from being used to drive |
| 101726 | 102161 | ** an index for tables to the left of the join. |
| 101727 | 102162 | */ |
| 101728 | 102163 | pTerm->prereqRight |= extraRight; |
| @@ -102140,14 +102575,17 @@ | ||
| 102140 | 102575 | const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| 102141 | 102576 | const Bitmask maskSrc = getMask(pWC->pMaskSet, iCur); /* Bitmask for pSrc */ |
| 102142 | 102577 | WhereTerm * const pWCEnd = &pWC->a[pWC->nTerm]; /* End of pWC->a[] */ |
| 102143 | 102578 | WhereTerm *pTerm; /* A single term of the WHERE clause */ |
| 102144 | 102579 | |
| 102145 | - /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses | |
| 102146 | - ** are used */ | |
| 102580 | + /* The OR-clause optimization is disallowed if the INDEXED BY or | |
| 102581 | + ** NOT INDEXED clauses are used or if the WHERE_AND_ONLY bit is set. */ | |
| 102147 | 102582 | if( pSrc->notIndexed || pSrc->pIndex!=0 ){ |
| 102148 | 102583 | return; |
| 102584 | + } | |
| 102585 | + if( pWC->wctrlFlags & WHERE_AND_ONLY ){ | |
| 102586 | + return; | |
| 102149 | 102587 | } |
| 102150 | 102588 | |
| 102151 | 102589 | /* Search the WHERE clause terms for a usable WO_OR term. */ |
| 102152 | 102590 | for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){ |
| 102153 | 102591 | if( pTerm->eOperator==WO_OR |
| @@ -102172,10 +102610,11 @@ | ||
| 102172 | 102610 | bestIndex(pParse, pAndWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 102173 | 102611 | }else if( pOrTerm->leftCursor==iCur ){ |
| 102174 | 102612 | WhereClause tempWC; |
| 102175 | 102613 | tempWC.pParse = pWC->pParse; |
| 102176 | 102614 | tempWC.pMaskSet = pWC->pMaskSet; |
| 102615 | + tempWC.pOuter = pWC; | |
| 102177 | 102616 | tempWC.op = TK_AND; |
| 102178 | 102617 | tempWC.a = pOrTerm; |
| 102179 | 102618 | tempWC.nTerm = 1; |
| 102180 | 102619 | bestIndex(pParse, &tempWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 102181 | 102620 | }else{ |
| @@ -102766,71 +103205,90 @@ | ||
| 102766 | 103205 | */ |
| 102767 | 103206 | bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); |
| 102768 | 103207 | } |
| 102769 | 103208 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 102770 | 103209 | |
| 103210 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 102771 | 103211 | /* |
| 102772 | -** Argument pIdx is a pointer to an index structure that has an array of | |
| 102773 | -** SQLITE_INDEX_SAMPLES evenly spaced samples of the first indexed column | |
| 102774 | -** stored in Index.aSample. These samples divide the domain of values stored | |
| 102775 | -** the index into (SQLITE_INDEX_SAMPLES+1) regions. | |
| 102776 | -** Region 0 contains all values less than the first sample value. Region | |
| 102777 | -** 1 contains values between the first and second samples. Region 2 contains | |
| 102778 | -** values between samples 2 and 3. And so on. Region SQLITE_INDEX_SAMPLES | |
| 102779 | -** contains values larger than the last sample. | |
| 102780 | -** | |
| 102781 | -** If the index contains many duplicates of a single value, then it is | |
| 102782 | -** possible that two or more adjacent samples can hold the same value. | |
| 102783 | -** When that is the case, the smallest possible region code is returned | |
| 102784 | -** when roundUp is false and the largest possible region code is returned | |
| 102785 | -** when roundUp is true. | |
| 102786 | -** | |
| 102787 | -** If successful, this function determines which of the regions value | |
| 102788 | -** pVal lies in, sets *piRegion to the region index (a value between 0 | |
| 102789 | -** and SQLITE_INDEX_SAMPLES+1, inclusive) and returns SQLITE_OK. | |
| 102790 | -** Or, if an OOM occurs while converting text values between encodings, | |
| 102791 | -** SQLITE_NOMEM is returned and *piRegion is undefined. | |
| 102792 | -*/ | |
| 102793 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 102794 | -static int whereRangeRegion( | |
| 103212 | +** Estimate the location of a particular key among all keys in an | |
| 103213 | +** index. Store the results in aStat as follows: | |
| 103214 | +** | |
| 103215 | +** aStat[0] Est. number of rows less than pVal | |
| 103216 | +** aStat[1] Est. number of rows equal to pVal | |
| 103217 | +** | |
| 103218 | +** Return SQLITE_OK on success. | |
| 103219 | +*/ | |
| 103220 | +static int whereKeyStats( | |
| 102795 | 103221 | Parse *pParse, /* Database connection */ |
| 102796 | 103222 | Index *pIdx, /* Index to consider domain of */ |
| 102797 | 103223 | sqlite3_value *pVal, /* Value to consider */ |
| 102798 | - int roundUp, /* Return largest valid region if true */ | |
| 102799 | - int *piRegion /* OUT: Region of domain in which value lies */ | |
| 103224 | + int roundUp, /* Round up if true. Round down if false */ | |
| 103225 | + tRowcnt *aStat /* OUT: stats written here */ | |
| 102800 | 103226 | ){ |
| 103227 | + tRowcnt n; | |
| 103228 | + IndexSample *aSample; | |
| 103229 | + int i, eType; | |
| 103230 | + int isEq = 0; | |
| 103231 | + i64 v; | |
| 103232 | + double r, rS; | |
| 103233 | + | |
| 102801 | 103234 | assert( roundUp==0 || roundUp==1 ); |
| 102802 | - if( ALWAYS(pVal) ){ | |
| 102803 | - IndexSample *aSample = pIdx->aSample; | |
| 102804 | - int i = 0; | |
| 102805 | - int eType = sqlite3_value_type(pVal); | |
| 102806 | - | |
| 102807 | - if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ | |
| 102808 | - double r = sqlite3_value_double(pVal); | |
| 102809 | - for(i=0; i<SQLITE_INDEX_SAMPLES; i++){ | |
| 102810 | - if( aSample[i].eType==SQLITE_NULL ) continue; | |
| 102811 | - if( aSample[i].eType>=SQLITE_TEXT ) break; | |
| 102812 | - if( roundUp ){ | |
| 102813 | - if( aSample[i].u.r>r ) break; | |
| 102814 | - }else{ | |
| 102815 | - if( aSample[i].u.r>=r ) break; | |
| 102816 | - } | |
| 102817 | - } | |
| 102818 | - }else if( eType==SQLITE_NULL ){ | |
| 102819 | - i = 0; | |
| 102820 | - if( roundUp ){ | |
| 102821 | - while( i<SQLITE_INDEX_SAMPLES && aSample[i].eType==SQLITE_NULL ) i++; | |
| 102822 | - } | |
| 102823 | - }else{ | |
| 103235 | + assert( pIdx->nSample>0 ); | |
| 103236 | + if( pVal==0 ) return SQLITE_ERROR; | |
| 103237 | + n = pIdx->aiRowEst[0]; | |
| 103238 | + aSample = pIdx->aSample; | |
| 103239 | + i = 0; | |
| 103240 | + eType = sqlite3_value_type(pVal); | |
| 103241 | + | |
| 103242 | + if( eType==SQLITE_INTEGER ){ | |
| 103243 | + v = sqlite3_value_int64(pVal); | |
| 103244 | + r = (i64)v; | |
| 103245 | + for(i=0; i<pIdx->nSample; i++){ | |
| 103246 | + if( aSample[i].eType==SQLITE_NULL ) continue; | |
| 103247 | + if( aSample[i].eType>=SQLITE_TEXT ) break; | |
| 103248 | + if( aSample[i].eType==SQLITE_INTEGER ){ | |
| 103249 | + if( aSample[i].u.i>=v ){ | |
| 103250 | + isEq = aSample[i].u.i==v; | |
| 103251 | + break; | |
| 103252 | + } | |
| 103253 | + }else{ | |
| 103254 | + assert( aSample[i].eType==SQLITE_FLOAT ); | |
| 103255 | + if( aSample[i].u.r>=r ){ | |
| 103256 | + isEq = aSample[i].u.r==r; | |
| 103257 | + break; | |
| 103258 | + } | |
| 103259 | + } | |
| 103260 | + } | |
| 103261 | + }else if( eType==SQLITE_FLOAT ){ | |
| 103262 | + r = sqlite3_value_double(pVal); | |
| 103263 | + for(i=0; i<pIdx->nSample; i++){ | |
| 103264 | + if( aSample[i].eType==SQLITE_NULL ) continue; | |
| 103265 | + if( aSample[i].eType>=SQLITE_TEXT ) break; | |
| 103266 | + if( aSample[i].eType==SQLITE_FLOAT ){ | |
| 103267 | + rS = aSample[i].u.r; | |
| 103268 | + }else{ | |
| 103269 | + rS = aSample[i].u.i; | |
| 103270 | + } | |
| 103271 | + if( rS>=r ){ | |
| 103272 | + isEq = rS==r; | |
| 103273 | + break; | |
| 103274 | + } | |
| 103275 | + } | |
| 103276 | + }else if( eType==SQLITE_NULL ){ | |
| 103277 | + i = 0; | |
| 103278 | + if( aSample[0].eType==SQLITE_NULL ) isEq = 1; | |
| 103279 | + }else{ | |
| 103280 | + assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); | |
| 103281 | + for(i=0; i<pIdx->nSample; i++){ | |
| 103282 | + if( aSample[i].eType==SQLITE_TEXT || aSample[i].eType==SQLITE_BLOB ){ | |
| 103283 | + break; | |
| 103284 | + } | |
| 103285 | + } | |
| 103286 | + if( i<pIdx->nSample ){ | |
| 102824 | 103287 | sqlite3 *db = pParse->db; |
| 102825 | 103288 | CollSeq *pColl; |
| 102826 | 103289 | const u8 *z; |
| 102827 | - int n; | |
| 102828 | - | |
| 102829 | - /* pVal comes from sqlite3ValueFromExpr() so the type cannot be NULL */ | |
| 102830 | - assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); | |
| 102831 | - | |
| 102832 | 103290 | if( eType==SQLITE_BLOB ){ |
| 102833 | 103291 | z = (const u8 *)sqlite3_value_blob(pVal); |
| 102834 | 103292 | pColl = db->pDfltColl; |
| 102835 | 103293 | assert( pColl->enc==SQLITE_UTF8 ); |
| 102836 | 103294 | }else{ |
| @@ -102845,16 +103303,16 @@ | ||
| 102845 | 103303 | return SQLITE_NOMEM; |
| 102846 | 103304 | } |
| 102847 | 103305 | assert( z && pColl && pColl->xCmp ); |
| 102848 | 103306 | } |
| 102849 | 103307 | n = sqlite3ValueBytes(pVal, pColl->enc); |
| 102850 | - | |
| 102851 | - for(i=0; i<SQLITE_INDEX_SAMPLES; i++){ | |
| 103308 | + | |
| 103309 | + for(; i<pIdx->nSample; i++){ | |
| 102852 | 103310 | int c; |
| 102853 | 103311 | int eSampletype = aSample[i].eType; |
| 102854 | - if( eSampletype==SQLITE_NULL || eSampletype<eType ) continue; | |
| 102855 | - if( (eSampletype!=eType) ) break; | |
| 103312 | + if( eSampletype<eType ) continue; | |
| 103313 | + if( eSampletype!=eType ) break; | |
| 102856 | 103314 | #ifndef SQLITE_OMIT_UTF16 |
| 102857 | 103315 | if( pColl->enc!=SQLITE_UTF8 ){ |
| 102858 | 103316 | int nSample; |
| 102859 | 103317 | char *zSample = sqlite3Utf8to16( |
| 102860 | 103318 | db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample |
| @@ -102868,20 +103326,51 @@ | ||
| 102868 | 103326 | }else |
| 102869 | 103327 | #endif |
| 102870 | 103328 | { |
| 102871 | 103329 | c = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z); |
| 102872 | 103330 | } |
| 102873 | - if( c-roundUp>=0 ) break; | |
| 103331 | + if( c>=0 ){ | |
| 103332 | + if( c==0 ) isEq = 1; | |
| 103333 | + break; | |
| 103334 | + } | |
| 102874 | 103335 | } |
| 102875 | 103336 | } |
| 103337 | + } | |
| 102876 | 103338 | |
| 102877 | - assert( i>=0 && i<=SQLITE_INDEX_SAMPLES ); | |
| 102878 | - *piRegion = i; | |
| 103339 | + /* At this point, aSample[i] is the first sample that is greater than | |
| 103340 | + ** or equal to pVal. Or if i==pIdx->nSample, then all samples are less | |
| 103341 | + ** than pVal. If aSample[i]==pVal, then isEq==1. | |
| 103342 | + */ | |
| 103343 | + if( isEq ){ | |
| 103344 | + assert( i<pIdx->nSample ); | |
| 103345 | + aStat[0] = aSample[i].nLt; | |
| 103346 | + aStat[1] = aSample[i].nEq; | |
| 103347 | + }else{ | |
| 103348 | + tRowcnt iLower, iUpper, iGap; | |
| 103349 | + if( i==0 ){ | |
| 103350 | + iLower = 0; | |
| 103351 | + iUpper = aSample[0].nLt; | |
| 103352 | + }else{ | |
| 103353 | + iUpper = i>=pIdx->nSample ? n : aSample[i].nLt; | |
| 103354 | + iLower = aSample[i-1].nEq + aSample[i-1].nLt; | |
| 103355 | + } | |
| 103356 | + aStat[1] = pIdx->avgEq; | |
| 103357 | + if( iLower>=iUpper ){ | |
| 103358 | + iGap = 0; | |
| 103359 | + }else{ | |
| 103360 | + iGap = iUpper - iLower; | |
| 103361 | + } | |
| 103362 | + if( roundUp ){ | |
| 103363 | + iGap = (iGap*2)/3; | |
| 103364 | + }else{ | |
| 103365 | + iGap = iGap/3; | |
| 103366 | + } | |
| 103367 | + aStat[0] = iLower + iGap; | |
| 102879 | 103368 | } |
| 102880 | 103369 | return SQLITE_OK; |
| 102881 | 103370 | } |
| 102882 | -#endif /* #ifdef SQLITE_ENABLE_STAT2 */ | |
| 103371 | +#endif /* SQLITE_ENABLE_STAT3 */ | |
| 102883 | 103372 | |
| 102884 | 103373 | /* |
| 102885 | 103374 | ** If expression pExpr represents a literal value, set *pp to point to |
| 102886 | 103375 | ** an sqlite3_value structure containing the same value, with affinity |
| 102887 | 103376 | ** aff applied to it, before returning. It is the responsibility of the |
| @@ -102895,11 +103384,11 @@ | ||
| 102895 | 103384 | ** |
| 102896 | 103385 | ** If neither of the above apply, set *pp to NULL. |
| 102897 | 103386 | ** |
| 102898 | 103387 | ** If an error occurs, return an error code. Otherwise, SQLITE_OK. |
| 102899 | 103388 | */ |
| 102900 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 103389 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 102901 | 103390 | static int valueFromExpr( |
| 102902 | 103391 | Parse *pParse, |
| 102903 | 103392 | Expr *pExpr, |
| 102904 | 103393 | u8 aff, |
| 102905 | 103394 | sqlite3_value **pp |
| @@ -102943,106 +103432,92 @@ | ||
| 102943 | 103432 | ** |
| 102944 | 103433 | ** ... FROM t1 WHERE a > ? AND a < ? ... |
| 102945 | 103434 | ** |
| 102946 | 103435 | ** then nEq should be passed 0. |
| 102947 | 103436 | ** |
| 102948 | -** The returned value is an integer between 1 and 100, inclusive. A return | |
| 102949 | -** value of 1 indicates that the proposed range scan is expected to visit | |
| 102950 | -** approximately 1/100th (1%) of the rows selected by the nEq equality | |
| 102951 | -** constraints (if any). A return value of 100 indicates that it is expected | |
| 102952 | -** that the range scan will visit every row (100%) selected by the equality | |
| 102953 | -** constraints. | |
| 103437 | +** The returned value is an integer divisor to reduce the estimated | |
| 103438 | +** search space. A return value of 1 means that range constraints are | |
| 103439 | +** no help at all. A return value of 2 means range constraints are | |
| 103440 | +** expected to reduce the search space by half. And so forth... | |
| 102954 | 103441 | ** |
| 102955 | -** In the absence of sqlite_stat2 ANALYZE data, each range inequality | |
| 102956 | -** reduces the search space by 3/4ths. Hence a single constraint (x>?) | |
| 102957 | -** results in a return of 25 and a range constraint (x>? AND x<?) results | |
| 102958 | -** in a return of 6. | |
| 103442 | +** In the absence of sqlite_stat3 ANALYZE data, each range inequality | |
| 103443 | +** reduces the search space by a factor of 4. Hence a single constraint (x>?) | |
| 103444 | +** results in a return of 4 and a range constraint (x>? AND x<?) results | |
| 103445 | +** in a return of 16. | |
| 102959 | 103446 | */ |
| 102960 | 103447 | static int whereRangeScanEst( |
| 102961 | 103448 | Parse *pParse, /* Parsing & code generating context */ |
| 102962 | 103449 | Index *p, /* The index containing the range-compared column; "x" */ |
| 102963 | 103450 | int nEq, /* index into p->aCol[] of the range-compared column */ |
| 102964 | 103451 | WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */ |
| 102965 | 103452 | WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ |
| 102966 | - int *piEst /* OUT: Return value */ | |
| 103453 | + double *pRangeDiv /* OUT: Reduce search space by this divisor */ | |
| 102967 | 103454 | ){ |
| 102968 | 103455 | int rc = SQLITE_OK; |
| 102969 | 103456 | |
| 102970 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 102971 | - | |
| 102972 | - if( nEq==0 && p->aSample ){ | |
| 102973 | - sqlite3_value *pLowerVal = 0; | |
| 102974 | - sqlite3_value *pUpperVal = 0; | |
| 102975 | - int iEst; | |
| 102976 | - int iLower = 0; | |
| 102977 | - int iUpper = SQLITE_INDEX_SAMPLES; | |
| 102978 | - int roundUpUpper = 0; | |
| 102979 | - int roundUpLower = 0; | |
| 103457 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 103458 | + | |
| 103459 | + if( nEq==0 && p->nSample ){ | |
| 103460 | + sqlite3_value *pRangeVal; | |
| 103461 | + tRowcnt iLower = 0; | |
| 103462 | + tRowcnt iUpper = p->aiRowEst[0]; | |
| 103463 | + tRowcnt a[2]; | |
| 102980 | 103464 | u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity; |
| 102981 | 103465 | |
| 102982 | 103466 | if( pLower ){ |
| 102983 | 103467 | Expr *pExpr = pLower->pExpr->pRight; |
| 102984 | - rc = valueFromExpr(pParse, pExpr, aff, &pLowerVal); | |
| 103468 | + rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal); | |
| 102985 | 103469 | assert( pLower->eOperator==WO_GT || pLower->eOperator==WO_GE ); |
| 102986 | - roundUpLower = (pLower->eOperator==WO_GT) ?1:0; | |
| 103470 | + if( rc==SQLITE_OK | |
| 103471 | + && whereKeyStats(pParse, p, pRangeVal, 0, a)==SQLITE_OK | |
| 103472 | + ){ | |
| 103473 | + iLower = a[0]; | |
| 103474 | + if( pLower->eOperator==WO_GT ) iLower += a[1]; | |
| 103475 | + } | |
| 103476 | + sqlite3ValueFree(pRangeVal); | |
| 102987 | 103477 | } |
| 102988 | 103478 | if( rc==SQLITE_OK && pUpper ){ |
| 102989 | 103479 | Expr *pExpr = pUpper->pExpr->pRight; |
| 102990 | - rc = valueFromExpr(pParse, pExpr, aff, &pUpperVal); | |
| 103480 | + rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal); | |
| 102991 | 103481 | assert( pUpper->eOperator==WO_LT || pUpper->eOperator==WO_LE ); |
| 102992 | - roundUpUpper = (pUpper->eOperator==WO_LE) ?1:0; | |
| 102993 | - } | |
| 102994 | - | |
| 102995 | - if( rc!=SQLITE_OK || (pLowerVal==0 && pUpperVal==0) ){ | |
| 102996 | - sqlite3ValueFree(pLowerVal); | |
| 102997 | - sqlite3ValueFree(pUpperVal); | |
| 102998 | - goto range_est_fallback; | |
| 102999 | - }else if( pLowerVal==0 ){ | |
| 103000 | - rc = whereRangeRegion(pParse, p, pUpperVal, roundUpUpper, &iUpper); | |
| 103001 | - if( pLower ) iLower = iUpper/2; | |
| 103002 | - }else if( pUpperVal==0 ){ | |
| 103003 | - rc = whereRangeRegion(pParse, p, pLowerVal, roundUpLower, &iLower); | |
| 103004 | - if( pUpper ) iUpper = (iLower + SQLITE_INDEX_SAMPLES + 1)/2; | |
| 103005 | - }else{ | |
| 103006 | - rc = whereRangeRegion(pParse, p, pUpperVal, roundUpUpper, &iUpper); | |
| 103007 | - if( rc==SQLITE_OK ){ | |
| 103008 | - rc = whereRangeRegion(pParse, p, pLowerVal, roundUpLower, &iLower); | |
| 103009 | - } | |
| 103010 | - } | |
| 103011 | - WHERETRACE(("range scan regions: %d..%d\n", iLower, iUpper)); | |
| 103012 | - | |
| 103013 | - iEst = iUpper - iLower; | |
| 103014 | - testcase( iEst==SQLITE_INDEX_SAMPLES ); | |
| 103015 | - assert( iEst<=SQLITE_INDEX_SAMPLES ); | |
| 103016 | - if( iEst<1 ){ | |
| 103017 | - *piEst = 50/SQLITE_INDEX_SAMPLES; | |
| 103018 | - }else{ | |
| 103019 | - *piEst = (iEst*100)/SQLITE_INDEX_SAMPLES; | |
| 103020 | - } | |
| 103021 | - sqlite3ValueFree(pLowerVal); | |
| 103022 | - sqlite3ValueFree(pUpperVal); | |
| 103023 | - return rc; | |
| 103024 | - } | |
| 103025 | -range_est_fallback: | |
| 103482 | + if( rc==SQLITE_OK | |
| 103483 | + && whereKeyStats(pParse, p, pRangeVal, 1, a)==SQLITE_OK | |
| 103484 | + ){ | |
| 103485 | + iUpper = a[0]; | |
| 103486 | + if( pUpper->eOperator==WO_LE ) iUpper += a[1]; | |
| 103487 | + } | |
| 103488 | + sqlite3ValueFree(pRangeVal); | |
| 103489 | + } | |
| 103490 | + if( rc==SQLITE_OK ){ | |
| 103491 | + if( iUpper<=iLower ){ | |
| 103492 | + *pRangeDiv = (double)p->aiRowEst[0]; | |
| 103493 | + }else{ | |
| 103494 | + *pRangeDiv = (double)p->aiRowEst[0]/(double)(iUpper - iLower); | |
| 103495 | + } | |
| 103496 | + WHERETRACE(("range scan regions: %u..%u div=%g\n", | |
| 103497 | + (u32)iLower, (u32)iUpper, *pRangeDiv)); | |
| 103498 | + return SQLITE_OK; | |
| 103499 | + } | |
| 103500 | + } | |
| 103026 | 103501 | #else |
| 103027 | 103502 | UNUSED_PARAMETER(pParse); |
| 103028 | 103503 | UNUSED_PARAMETER(p); |
| 103029 | 103504 | UNUSED_PARAMETER(nEq); |
| 103030 | 103505 | #endif |
| 103031 | 103506 | assert( pLower || pUpper ); |
| 103032 | - *piEst = 100; | |
| 103033 | - if( pLower && (pLower->wtFlags & TERM_VNULL)==0 ) *piEst /= 4; | |
| 103034 | - if( pUpper ) *piEst /= 4; | |
| 103507 | + *pRangeDiv = (double)1; | |
| 103508 | + if( pLower && (pLower->wtFlags & TERM_VNULL)==0 ) *pRangeDiv *= (double)4; | |
| 103509 | + if( pUpper ) *pRangeDiv *= (double)4; | |
| 103035 | 103510 | return rc; |
| 103036 | 103511 | } |
| 103037 | 103512 | |
| 103038 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 103513 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 103039 | 103514 | /* |
| 103040 | 103515 | ** Estimate the number of rows that will be returned based on |
| 103041 | 103516 | ** an equality constraint x=VALUE and where that VALUE occurs in |
| 103042 | 103517 | ** the histogram data. This only works when x is the left-most |
| 103043 | -** column of an index and sqlite_stat2 histogram data is available | |
| 103518 | +** column of an index and sqlite_stat3 histogram data is available | |
| 103044 | 103519 | ** for that index. When pExpr==NULL that means the constraint is |
| 103045 | 103520 | ** "x IS NULL" instead of "x=VALUE". |
| 103046 | 103521 | ** |
| 103047 | 103522 | ** Write the estimated row count into *pnRow and return SQLITE_OK. |
| 103048 | 103523 | ** If unable to make an estimate, leave *pnRow unchanged and return |
| @@ -103058,44 +103533,36 @@ | ||
| 103058 | 103533 | Index *p, /* The index whose left-most column is pTerm */ |
| 103059 | 103534 | Expr *pExpr, /* Expression for VALUE in the x=VALUE constraint */ |
| 103060 | 103535 | double *pnRow /* Write the revised row estimate here */ |
| 103061 | 103536 | ){ |
| 103062 | 103537 | sqlite3_value *pRhs = 0; /* VALUE on right-hand side of pTerm */ |
| 103063 | - int iLower, iUpper; /* Range of histogram regions containing pRhs */ | |
| 103064 | 103538 | u8 aff; /* Column affinity */ |
| 103065 | 103539 | int rc; /* Subfunction return code */ |
| 103066 | - double nRowEst; /* New estimate of the number of rows */ | |
| 103540 | + tRowcnt a[2]; /* Statistics */ | |
| 103067 | 103541 | |
| 103068 | 103542 | assert( p->aSample!=0 ); |
| 103543 | + assert( p->nSample>0 ); | |
| 103069 | 103544 | aff = p->pTable->aCol[p->aiColumn[0]].affinity; |
| 103070 | 103545 | if( pExpr ){ |
| 103071 | 103546 | rc = valueFromExpr(pParse, pExpr, aff, &pRhs); |
| 103072 | 103547 | if( rc ) goto whereEqualScanEst_cancel; |
| 103073 | 103548 | }else{ |
| 103074 | 103549 | pRhs = sqlite3ValueNew(pParse->db); |
| 103075 | 103550 | } |
| 103076 | 103551 | if( pRhs==0 ) return SQLITE_NOTFOUND; |
| 103077 | - rc = whereRangeRegion(pParse, p, pRhs, 0, &iLower); | |
| 103078 | - if( rc ) goto whereEqualScanEst_cancel; | |
| 103079 | - rc = whereRangeRegion(pParse, p, pRhs, 1, &iUpper); | |
| 103080 | - if( rc ) goto whereEqualScanEst_cancel; | |
| 103081 | - WHERETRACE(("equality scan regions: %d..%d\n", iLower, iUpper)); | |
| 103082 | - if( iLower>=iUpper ){ | |
| 103083 | - nRowEst = p->aiRowEst[0]/(SQLITE_INDEX_SAMPLES*2); | |
| 103084 | - if( nRowEst<*pnRow ) *pnRow = nRowEst; | |
| 103085 | - }else{ | |
| 103086 | - nRowEst = (iUpper-iLower)*p->aiRowEst[0]/SQLITE_INDEX_SAMPLES; | |
| 103087 | - *pnRow = nRowEst; | |
| 103088 | - } | |
| 103089 | - | |
| 103552 | + rc = whereKeyStats(pParse, p, pRhs, 0, a); | |
| 103553 | + if( rc==SQLITE_OK ){ | |
| 103554 | + WHERETRACE(("equality scan regions: %d\n", (int)a[1])); | |
| 103555 | + *pnRow = a[1]; | |
| 103556 | + } | |
| 103090 | 103557 | whereEqualScanEst_cancel: |
| 103091 | 103558 | sqlite3ValueFree(pRhs); |
| 103092 | 103559 | return rc; |
| 103093 | 103560 | } |
| 103094 | -#endif /* defined(SQLITE_ENABLE_STAT2) */ | |
| 103561 | +#endif /* defined(SQLITE_ENABLE_STAT3) */ | |
| 103095 | 103562 | |
| 103096 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 103563 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 103097 | 103564 | /* |
| 103098 | 103565 | ** Estimate the number of rows that will be returned based on |
| 103099 | 103566 | ** an IN constraint where the right-hand side of the IN operator |
| 103100 | 103567 | ** is a list of values. Example: |
| 103101 | 103568 | ** |
| @@ -103114,64 +103581,29 @@ | ||
| 103114 | 103581 | Parse *pParse, /* Parsing & code generating context */ |
| 103115 | 103582 | Index *p, /* The index whose left-most column is pTerm */ |
| 103116 | 103583 | ExprList *pList, /* The value list on the RHS of "x IN (v1,v2,v3,...)" */ |
| 103117 | 103584 | double *pnRow /* Write the revised row estimate here */ |
| 103118 | 103585 | ){ |
| 103119 | - sqlite3_value *pVal = 0; /* One value from list */ | |
| 103120 | - int iLower, iUpper; /* Range of histogram regions containing pRhs */ | |
| 103121 | - u8 aff; /* Column affinity */ | |
| 103122 | - int rc = SQLITE_OK; /* Subfunction return code */ | |
| 103123 | - double nRowEst; /* New estimate of the number of rows */ | |
| 103124 | - int nSpan = 0; /* Number of histogram regions spanned */ | |
| 103125 | - int nSingle = 0; /* Histogram regions hit by a single value */ | |
| 103126 | - int nNotFound = 0; /* Count of values that are not constants */ | |
| 103127 | - int i; /* Loop counter */ | |
| 103128 | - u8 aSpan[SQLITE_INDEX_SAMPLES+1]; /* Histogram regions that are spanned */ | |
| 103129 | - u8 aSingle[SQLITE_INDEX_SAMPLES+1]; /* Histogram regions hit once */ | |
| 103586 | + int rc = SQLITE_OK; /* Subfunction return code */ | |
| 103587 | + double nEst; /* Number of rows for a single term */ | |
| 103588 | + double nRowEst = (double)0; /* New estimate of the number of rows */ | |
| 103589 | + int i; /* Loop counter */ | |
| 103130 | 103590 | |
| 103131 | 103591 | assert( p->aSample!=0 ); |
| 103132 | - aff = p->pTable->aCol[p->aiColumn[0]].affinity; | |
| 103133 | - memset(aSpan, 0, sizeof(aSpan)); | |
| 103134 | - memset(aSingle, 0, sizeof(aSingle)); | |
| 103135 | - for(i=0; i<pList->nExpr; i++){ | |
| 103136 | - sqlite3ValueFree(pVal); | |
| 103137 | - rc = valueFromExpr(pParse, pList->a[i].pExpr, aff, &pVal); | |
| 103138 | - if( rc ) break; | |
| 103139 | - if( pVal==0 || sqlite3_value_type(pVal)==SQLITE_NULL ){ | |
| 103140 | - nNotFound++; | |
| 103141 | - continue; | |
| 103142 | - } | |
| 103143 | - rc = whereRangeRegion(pParse, p, pVal, 0, &iLower); | |
| 103144 | - if( rc ) break; | |
| 103145 | - rc = whereRangeRegion(pParse, p, pVal, 1, &iUpper); | |
| 103146 | - if( rc ) break; | |
| 103147 | - if( iLower>=iUpper ){ | |
| 103148 | - aSingle[iLower] = 1; | |
| 103149 | - }else{ | |
| 103150 | - assert( iLower>=0 && iUpper<=SQLITE_INDEX_SAMPLES ); | |
| 103151 | - while( iLower<iUpper ) aSpan[iLower++] = 1; | |
| 103152 | - } | |
| 103592 | + for(i=0; rc==SQLITE_OK && i<pList->nExpr; i++){ | |
| 103593 | + nEst = p->aiRowEst[0]; | |
| 103594 | + rc = whereEqualScanEst(pParse, p, pList->a[i].pExpr, &nEst); | |
| 103595 | + nRowEst += nEst; | |
| 103153 | 103596 | } |
| 103154 | 103597 | if( rc==SQLITE_OK ){ |
| 103155 | - for(i=nSpan=0; i<=SQLITE_INDEX_SAMPLES; i++){ | |
| 103156 | - if( aSpan[i] ){ | |
| 103157 | - nSpan++; | |
| 103158 | - }else if( aSingle[i] ){ | |
| 103159 | - nSingle++; | |
| 103160 | - } | |
| 103161 | - } | |
| 103162 | - nRowEst = (nSpan*2+nSingle)*p->aiRowEst[0]/(2*SQLITE_INDEX_SAMPLES) | |
| 103163 | - + nNotFound*p->aiRowEst[1]; | |
| 103164 | 103598 | if( nRowEst > p->aiRowEst[0] ) nRowEst = p->aiRowEst[0]; |
| 103165 | 103599 | *pnRow = nRowEst; |
| 103166 | - WHERETRACE(("IN row estimate: nSpan=%d, nSingle=%d, nNotFound=%d, est=%g\n", | |
| 103167 | - nSpan, nSingle, nNotFound, nRowEst)); | |
| 103600 | + WHERETRACE(("IN row estimate: est=%g\n", nRowEst)); | |
| 103168 | 103601 | } |
| 103169 | - sqlite3ValueFree(pVal); | |
| 103170 | 103602 | return rc; |
| 103171 | 103603 | } |
| 103172 | -#endif /* defined(SQLITE_ENABLE_STAT2) */ | |
| 103604 | +#endif /* defined(SQLITE_ENABLE_STAT3) */ | |
| 103173 | 103605 | |
| 103174 | 103606 | |
| 103175 | 103607 | /* |
| 103176 | 103608 | ** Find the best query plan for accessing a particular table. Write the |
| 103177 | 103609 | ** best query plan and its cost into the WhereCost object supplied as the |
| @@ -103214,11 +103646,11 @@ | ||
| 103214 | 103646 | Index *pProbe; /* An index we are evaluating */ |
| 103215 | 103647 | Index *pIdx; /* Copy of pProbe, or zero for IPK index */ |
| 103216 | 103648 | int eqTermMask; /* Current mask of valid equality operators */ |
| 103217 | 103649 | int idxEqTermMask; /* Index mask of valid equality operators */ |
| 103218 | 103650 | Index sPk; /* A fake index object for the primary key */ |
| 103219 | - unsigned int aiRowEstPk[2]; /* The aiRowEst[] value for the sPk index */ | |
| 103651 | + tRowcnt aiRowEstPk[2]; /* The aiRowEst[] value for the sPk index */ | |
| 103220 | 103652 | int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ |
| 103221 | 103653 | int wsFlagMask; /* Allowed flags in pCost->plan.wsFlag */ |
| 103222 | 103654 | |
| 103223 | 103655 | /* Initialize the cost to a worst-case value */ |
| 103224 | 103656 | memset(pCost, 0, sizeof(*pCost)); |
| @@ -103269,14 +103701,14 @@ | ||
| 103269 | 103701 | } |
| 103270 | 103702 | |
| 103271 | 103703 | /* Loop over all indices looking for the best one to use |
| 103272 | 103704 | */ |
| 103273 | 103705 | for(; pProbe; pIdx=pProbe=pProbe->pNext){ |
| 103274 | - const unsigned int * const aiRowEst = pProbe->aiRowEst; | |
| 103706 | + const tRowcnt * const aiRowEst = pProbe->aiRowEst; | |
| 103275 | 103707 | double cost; /* Cost of using pProbe */ |
| 103276 | 103708 | double nRow; /* Estimated number of rows in result set */ |
| 103277 | - double log10N; /* base-10 logarithm of nRow (inexact) */ | |
| 103709 | + double log10N = (double)1; /* base-10 logarithm of nRow (inexact) */ | |
| 103278 | 103710 | int rev; /* True to scan in reverse order */ |
| 103279 | 103711 | int wsFlags = 0; |
| 103280 | 103712 | Bitmask used = 0; |
| 103281 | 103713 | |
| 103282 | 103714 | /* The following variables are populated based on the properties of |
| @@ -103312,18 +103744,16 @@ | ||
| 103312 | 103744 | ** Set to true if there was at least one "x IN (SELECT ...)" term used |
| 103313 | 103745 | ** in determining the value of nInMul. Note that the RHS of the |
| 103314 | 103746 | ** IN operator must be a SELECT, not a value list, for this variable |
| 103315 | 103747 | ** to be true. |
| 103316 | 103748 | ** |
| 103317 | - ** estBound: | |
| 103318 | - ** An estimate on the amount of the table that must be searched. A | |
| 103319 | - ** value of 100 means the entire table is searched. Range constraints | |
| 103320 | - ** might reduce this to a value less than 100 to indicate that only | |
| 103321 | - ** a fraction of the table needs searching. In the absence of | |
| 103322 | - ** sqlite_stat2 ANALYZE data, a single inequality reduces the search | |
| 103323 | - ** space to 1/4rd its original size. So an x>? constraint reduces | |
| 103324 | - ** estBound to 25. Two constraints (x>? AND x<?) reduce estBound to 6. | |
| 103749 | + ** rangeDiv: | |
| 103750 | + ** An estimate of a divisor by which to reduce the search space due | |
| 103751 | + ** to inequality constraints. In the absence of sqlite_stat3 ANALYZE | |
| 103752 | + ** data, a single inequality reduces the search space to 1/4rd its | |
| 103753 | + ** original size (rangeDiv==4). Two inequalities reduce the search | |
| 103754 | + ** space to 1/16th of its original size (rangeDiv==16). | |
| 103325 | 103755 | ** |
| 103326 | 103756 | ** bSort: |
| 103327 | 103757 | ** Boolean. True if there is an ORDER BY clause that will require an |
| 103328 | 103758 | ** external sort (i.e. scanning the index being evaluated will not |
| 103329 | 103759 | ** correctly order records). |
| @@ -103344,26 +103774,27 @@ | ||
| 103344 | 103774 | ** SELECT a, b, c FROM tbl WHERE a = 1; |
| 103345 | 103775 | */ |
| 103346 | 103776 | int nEq; /* Number of == or IN terms matching index */ |
| 103347 | 103777 | int bInEst = 0; /* True if "x IN (SELECT...)" seen */ |
| 103348 | 103778 | int nInMul = 1; /* Number of distinct equalities to lookup */ |
| 103349 | - int estBound = 100; /* Estimated reduction in search space */ | |
| 103779 | + double rangeDiv = (double)1; /* Estimated reduction in search space */ | |
| 103350 | 103780 | int nBound = 0; /* Number of range constraints seen */ |
| 103351 | 103781 | int bSort = !!pOrderBy; /* True if external sort required */ |
| 103352 | 103782 | int bDist = !!pDistinct; /* True if index cannot help with DISTINCT */ |
| 103353 | 103783 | int bLookup = 0; /* True if not a covering index */ |
| 103354 | 103784 | WhereTerm *pTerm; /* A single term of the WHERE clause */ |
| 103355 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 103785 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 103356 | 103786 | WhereTerm *pFirstTerm = 0; /* First term matching the index */ |
| 103357 | 103787 | #endif |
| 103358 | 103788 | |
| 103359 | 103789 | /* Determine the values of nEq and nInMul */ |
| 103360 | 103790 | for(nEq=0; nEq<pProbe->nColumn; nEq++){ |
| 103361 | 103791 | int j = pProbe->aiColumn[nEq]; |
| 103362 | 103792 | pTerm = findTerm(pWC, iCur, j, notReady, eqTermMask, pIdx); |
| 103363 | 103793 | if( pTerm==0 ) break; |
| 103364 | 103794 | wsFlags |= (WHERE_COLUMN_EQ|WHERE_ROWID_EQ); |
| 103795 | + testcase( pTerm->pWC!=pWC ); | |
| 103365 | 103796 | if( pTerm->eOperator & WO_IN ){ |
| 103366 | 103797 | Expr *pExpr = pTerm->pExpr; |
| 103367 | 103798 | wsFlags |= WHERE_COLUMN_IN; |
| 103368 | 103799 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 103369 | 103800 | /* "x IN (SELECT ...)": Assume the SELECT returns 25 rows */ |
| @@ -103374,32 +103805,34 @@ | ||
| 103374 | 103805 | nInMul *= pExpr->x.pList->nExpr; |
| 103375 | 103806 | } |
| 103376 | 103807 | }else if( pTerm->eOperator & WO_ISNULL ){ |
| 103377 | 103808 | wsFlags |= WHERE_COLUMN_NULL; |
| 103378 | 103809 | } |
| 103379 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 103810 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 103380 | 103811 | if( nEq==0 && pProbe->aSample ) pFirstTerm = pTerm; |
| 103381 | 103812 | #endif |
| 103382 | 103813 | used |= pTerm->prereqRight; |
| 103383 | 103814 | } |
| 103384 | 103815 | |
| 103385 | - /* Determine the value of estBound. */ | |
| 103816 | + /* Determine the value of rangeDiv */ | |
| 103386 | 103817 | if( nEq<pProbe->nColumn && pProbe->bUnordered==0 ){ |
| 103387 | 103818 | int j = pProbe->aiColumn[nEq]; |
| 103388 | 103819 | if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pIdx) ){ |
| 103389 | 103820 | WhereTerm *pTop = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pIdx); |
| 103390 | 103821 | WhereTerm *pBtm = findTerm(pWC, iCur, j, notReady, WO_GT|WO_GE, pIdx); |
| 103391 | - whereRangeScanEst(pParse, pProbe, nEq, pBtm, pTop, &estBound); | |
| 103822 | + whereRangeScanEst(pParse, pProbe, nEq, pBtm, pTop, &rangeDiv); | |
| 103392 | 103823 | if( pTop ){ |
| 103393 | 103824 | nBound = 1; |
| 103394 | 103825 | wsFlags |= WHERE_TOP_LIMIT; |
| 103395 | 103826 | used |= pTop->prereqRight; |
| 103827 | + testcase( pTop->pWC!=pWC ); | |
| 103396 | 103828 | } |
| 103397 | 103829 | if( pBtm ){ |
| 103398 | 103830 | nBound++; |
| 103399 | 103831 | wsFlags |= WHERE_BTM_LIMIT; |
| 103400 | 103832 | used |= pBtm->prereqRight; |
| 103833 | + testcase( pBtm->pWC!=pWC ); | |
| 103401 | 103834 | } |
| 103402 | 103835 | wsFlags |= (WHERE_COLUMN_RANGE|WHERE_ROWID_RANGE); |
| 103403 | 103836 | } |
| 103404 | 103837 | }else if( pProbe->onError!=OE_None ){ |
| 103405 | 103838 | testcase( wsFlags & WHERE_COLUMN_IN ); |
| @@ -103458,32 +103891,34 @@ | ||
| 103458 | 103891 | if( bInEst && nRow*2>aiRowEst[0] ){ |
| 103459 | 103892 | nRow = aiRowEst[0]/2; |
| 103460 | 103893 | nInMul = (int)(nRow / aiRowEst[nEq]); |
| 103461 | 103894 | } |
| 103462 | 103895 | |
| 103463 | -#ifdef SQLITE_ENABLE_STAT2 | |
| 103896 | +#ifdef SQLITE_ENABLE_STAT3 | |
| 103464 | 103897 | /* If the constraint is of the form x=VALUE or x IN (E1,E2,...) |
| 103465 | 103898 | ** and we do not think that values of x are unique and if histogram |
| 103466 | 103899 | ** data is available for column x, then it might be possible |
| 103467 | 103900 | ** to get a better estimate on the number of rows based on |
| 103468 | 103901 | ** VALUE and how common that value is according to the histogram. |
| 103469 | 103902 | */ |
| 103470 | 103903 | if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 && aiRowEst[1]>1 ){ |
| 103904 | + assert( (pFirstTerm->eOperator & (WO_EQ|WO_ISNULL|WO_IN))!=0 ); | |
| 103471 | 103905 | if( pFirstTerm->eOperator & (WO_EQ|WO_ISNULL) ){ |
| 103472 | 103906 | testcase( pFirstTerm->eOperator==WO_EQ ); |
| 103473 | 103907 | testcase( pFirstTerm->eOperator==WO_ISNULL ); |
| 103474 | 103908 | whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight, &nRow); |
| 103475 | - }else if( pFirstTerm->eOperator==WO_IN && bInEst==0 ){ | |
| 103909 | + }else if( bInEst==0 ){ | |
| 103910 | + assert( pFirstTerm->eOperator==WO_IN ); | |
| 103476 | 103911 | whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList, &nRow); |
| 103477 | 103912 | } |
| 103478 | 103913 | } |
| 103479 | -#endif /* SQLITE_ENABLE_STAT2 */ | |
| 103914 | +#endif /* SQLITE_ENABLE_STAT3 */ | |
| 103480 | 103915 | |
| 103481 | 103916 | /* Adjust the number of output rows and downward to reflect rows |
| 103482 | 103917 | ** that are excluded by range constraints. |
| 103483 | 103918 | */ |
| 103484 | - nRow = (nRow * (double)estBound) / (double)100; | |
| 103919 | + nRow = nRow/rangeDiv; | |
| 103485 | 103920 | if( nRow<1 ) nRow = 1; |
| 103486 | 103921 | |
| 103487 | 103922 | /* Experiments run on real SQLite databases show that the time needed |
| 103488 | 103923 | ** to do a binary search to locate a row in a table or index is roughly |
| 103489 | 103924 | ** log10(N) times the time to move from one row to the next row within |
| @@ -103608,14 +104043,14 @@ | ||
| 103608 | 104043 | if( nRow<2 ) nRow = 2; |
| 103609 | 104044 | } |
| 103610 | 104045 | |
| 103611 | 104046 | |
| 103612 | 104047 | WHERETRACE(( |
| 103613 | - "%s(%s): nEq=%d nInMul=%d estBound=%d bSort=%d bLookup=%d wsFlags=0x%x\n" | |
| 104048 | + "%s(%s): nEq=%d nInMul=%d rangeDiv=%d bSort=%d bLookup=%d wsFlags=0x%x\n" | |
| 103614 | 104049 | " notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f used=0x%llx\n", |
| 103615 | 104050 | pSrc->pTab->zName, (pIdx ? pIdx->zName : "ipk"), |
| 103616 | - nEq, nInMul, estBound, bSort, bLookup, wsFlags, | |
| 104051 | + nEq, nInMul, (int)rangeDiv, bSort, bLookup, wsFlags, | |
| 103617 | 104052 | notReady, log10N, nRow, cost, used |
| 103618 | 104053 | )); |
| 103619 | 104054 | |
| 103620 | 104055 | /* If this index is the best we have seen so far, then record this |
| 103621 | 104056 | ** index and its cost in the pCost structure. |
| @@ -104115,11 +104550,12 @@ | ||
| 104115 | 104550 | */ |
| 104116 | 104551 | static Bitmask codeOneLoopStart( |
| 104117 | 104552 | WhereInfo *pWInfo, /* Complete information about the WHERE clause */ |
| 104118 | 104553 | int iLevel, /* Which level of pWInfo->a[] should be coded */ |
| 104119 | 104554 | u16 wctrlFlags, /* One of the WHERE_* flags defined in sqliteInt.h */ |
| 104120 | - Bitmask notReady /* Which tables are currently available */ | |
| 104555 | + Bitmask notReady, /* Which tables are currently available */ | |
| 104556 | + Expr *pWhere /* Complete WHERE clause */ | |
| 104121 | 104557 | ){ |
| 104122 | 104558 | int j, k; /* Loop counters */ |
| 104123 | 104559 | int iCur; /* The VDBE cursor for the table */ |
| 104124 | 104560 | int addrNxt; /* Where to jump to continue with the next IN case */ |
| 104125 | 104561 | int omitTable; /* True if we use the index only */ |
| @@ -104597,11 +105033,12 @@ | ||
| 104597 | 105033 | int regRowset = 0; /* Register for RowSet object */ |
| 104598 | 105034 | int regRowid = 0; /* Register holding rowid */ |
| 104599 | 105035 | int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */ |
| 104600 | 105036 | int iRetInit; /* Address of regReturn init */ |
| 104601 | 105037 | int untestedTerms = 0; /* Some terms not completely tested */ |
| 104602 | - int ii; | |
| 105038 | + int ii; /* Loop counter */ | |
| 105039 | + Expr *pAndExpr = 0; /* An ".. AND (...)" expression */ | |
| 104603 | 105040 | |
| 104604 | 105041 | pTerm = pLevel->plan.u.pTerm; |
| 104605 | 105042 | assert( pTerm!=0 ); |
| 104606 | 105043 | assert( pTerm->eOperator==WO_OR ); |
| 104607 | 105044 | assert( (pTerm->wtFlags & TERM_ORINFO)!=0 ); |
| @@ -104646,18 +105083,33 @@ | ||
| 104646 | 105083 | regRowset = ++pParse->nMem; |
| 104647 | 105084 | regRowid = ++pParse->nMem; |
| 104648 | 105085 | sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); |
| 104649 | 105086 | } |
| 104650 | 105087 | iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn); |
| 105088 | + | |
| 105089 | + /* If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y | |
| 105090 | + ** Then for every term xN, evaluate as the subexpression: xN AND z | |
| 105091 | + ** That way, terms in y that are factored into the disjunction will | |
| 105092 | + ** be picked up by the recursive calls to sqlite3WhereBegin() below. | |
| 105093 | + */ | |
| 105094 | + if( pWC->nTerm>1 ){ | |
| 105095 | + pAndExpr = sqlite3ExprAlloc(pParse->db, TK_AND, 0, 0); | |
| 105096 | + pAndExpr->pRight = pWhere; | |
| 105097 | + } | |
| 104651 | 105098 | |
| 104652 | 105099 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 104653 | 105100 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 104654 | 105101 | if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){ |
| 104655 | 105102 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 105103 | + Expr *pOrExpr = pOrTerm->pExpr; | |
| 105104 | + if( pAndExpr ){ | |
| 105105 | + pAndExpr->pLeft = pOrExpr; | |
| 105106 | + pOrExpr = pAndExpr; | |
| 105107 | + } | |
| 104656 | 105108 | /* Loop through table entries that match term pOrTerm. */ |
| 104657 | - pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrTerm->pExpr, 0, 0, | |
| 104658 | - WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | | |
| 105109 | + pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, | |
| 105110 | + WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY | | |
| 104659 | 105111 | WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY); |
| 104660 | 105112 | if( pSubWInfo ){ |
| 104661 | 105113 | explainOneScan( |
| 104662 | 105114 | pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0 |
| 104663 | 105115 | ); |
| @@ -104681,10 +105133,11 @@ | ||
| 104681 | 105133 | /* Finish the loop through table entries that match term pOrTerm. */ |
| 104682 | 105134 | sqlite3WhereEnd(pSubWInfo); |
| 104683 | 105135 | } |
| 104684 | 105136 | } |
| 104685 | 105137 | } |
| 105138 | + sqlite3DbFree(pParse->db, pAndExpr); | |
| 104686 | 105139 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 104687 | 105140 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); |
| 104688 | 105141 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 104689 | 105142 | |
| 104690 | 105143 | if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab); |
| @@ -104962,11 +105415,11 @@ | ||
| 104962 | 105415 | |
| 104963 | 105416 | /* Split the WHERE clause into separate subexpressions where each |
| 104964 | 105417 | ** subexpression is separated by an AND operator. |
| 104965 | 105418 | */ |
| 104966 | 105419 | initMaskSet(pMaskSet); |
| 104967 | - whereClauseInit(pWC, pParse, pMaskSet); | |
| 105420 | + whereClauseInit(pWC, pParse, pMaskSet, wctrlFlags); | |
| 104968 | 105421 | sqlite3ExprCodeConstants(pParse, pWhere); |
| 104969 | 105422 | whereSplit(pWC, pWhere, TK_AND); /* IMP: R-15842-53296 */ |
| 104970 | 105423 | |
| 104971 | 105424 | /* Special case: a WHERE clause that is constant. Evaluate the |
| 104972 | 105425 | ** expression and either jump over all of the code or fall thru. |
| @@ -105290,11 +105743,11 @@ | ||
| 105290 | 105743 | int iCur = pTabItem->iCursor; |
| 105291 | 105744 | sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB); |
| 105292 | 105745 | }else |
| 105293 | 105746 | #endif |
| 105294 | 105747 | if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 |
| 105295 | - && (wctrlFlags & WHERE_OMIT_OPEN)==0 ){ | |
| 105748 | + && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){ | |
| 105296 | 105749 | int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead; |
| 105297 | 105750 | sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op); |
| 105298 | 105751 | testcase( pTab->nCol==BMS-1 ); |
| 105299 | 105752 | testcase( pTab->nCol==BMS ); |
| 105300 | 105753 | if( !pWInfo->okOnePass && pTab->nCol<BMS ){ |
| @@ -105335,11 +105788,11 @@ | ||
| 105335 | 105788 | */ |
| 105336 | 105789 | notReady = ~(Bitmask)0; |
| 105337 | 105790 | for(i=0; i<nTabList; i++){ |
| 105338 | 105791 | pLevel = &pWInfo->a[i]; |
| 105339 | 105792 | explainOneScan(pParse, pTabList, pLevel, i, pLevel->iFrom, wctrlFlags); |
| 105340 | - notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); | |
| 105793 | + notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady, pWhere); | |
| 105341 | 105794 | pWInfo->iContinue = pLevel->addrCont; |
| 105342 | 105795 | } |
| 105343 | 105796 | |
| 105344 | 105797 | #ifdef SQLITE_TEST /* For testing and debugging use only */ |
| 105345 | 105798 | /* Record in the query plan information about the current table |
| @@ -105470,11 +105923,11 @@ | ||
| 105470 | 105923 | struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom]; |
| 105471 | 105924 | Table *pTab = pTabItem->pTab; |
| 105472 | 105925 | assert( pTab!=0 ); |
| 105473 | 105926 | if( (pTab->tabFlags & TF_Ephemeral)==0 |
| 105474 | 105927 | && pTab->pSelect==0 |
| 105475 | - && (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0 | |
| 105928 | + && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 | |
| 105476 | 105929 | ){ |
| 105477 | 105930 | int ws = pLevel->plan.wsFlags; |
| 105478 | 105931 | if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){ |
| 105479 | 105932 | sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor); |
| 105480 | 105933 | } |
| @@ -105531,10 +105984,11 @@ | ||
| 105531 | 105984 | return; |
| 105532 | 105985 | } |
| 105533 | 105986 | |
| 105534 | 105987 | /************** End of where.c ***********************************************/ |
| 105535 | 105988 | /************** Begin file parse.c *******************************************/ |
| 105989 | +#line 1 "tsrc/parse.c" | |
| 105536 | 105990 | /* Driver template for the LEMON parser generator. |
| 105537 | 105991 | ** The author disclaims copyright to this source code. |
| 105538 | 105992 | ** |
| 105539 | 105993 | ** This version of "lempar.c" is modified, slightly, for use by SQLite. |
| 105540 | 105994 | ** The only modifications are the addition of a couple of NEVER() |
| @@ -105543,10 +105997,11 @@ | ||
| 105543 | 105997 | ** specific grammar used by SQLite. |
| 105544 | 105998 | */ |
| 105545 | 105999 | /* First off, code is included that follows the "include" declaration |
| 105546 | 106000 | ** in the input grammar file. */ |
| 105547 | 106001 | /* #include <stdio.h> */ |
| 106002 | +#line 51 "parse.y" | |
| 105548 | 106003 | |
| 105549 | 106004 | |
| 105550 | 106005 | /* |
| 105551 | 106006 | ** Disable all error recovery processing in the parser push-down |
| 105552 | 106007 | ** automaton. |
| @@ -105590,10 +106045,11 @@ | ||
| 105590 | 106045 | /* |
| 105591 | 106046 | ** An instance of this structure holds the ATTACH key and the key type. |
| 105592 | 106047 | */ |
| 105593 | 106048 | struct AttachKey { int type; Token key; }; |
| 105594 | 106049 | |
| 106050 | +#line 722 "parse.y" | |
| 105595 | 106051 | |
| 105596 | 106052 | /* This is a utility routine used to set the ExprSpan.zStart and |
| 105597 | 106053 | ** ExprSpan.zEnd values of pOut so that the span covers the complete |
| 105598 | 106054 | ** range of text beginning with pStart and going to the end of pEnd. |
| 105599 | 106055 | */ |
| @@ -105609,10 +106065,11 @@ | ||
| 105609 | 106065 | static void spanExpr(ExprSpan *pOut, Parse *pParse, int op, Token *pValue){ |
| 105610 | 106066 | pOut->pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue); |
| 105611 | 106067 | pOut->zStart = pValue->z; |
| 105612 | 106068 | pOut->zEnd = &pValue->z[pValue->n]; |
| 105613 | 106069 | } |
| 106070 | +#line 817 "parse.y" | |
| 105614 | 106071 | |
| 105615 | 106072 | /* This routine constructs a binary expression node out of two ExprSpan |
| 105616 | 106073 | ** objects and uses the result to populate a new ExprSpan object. |
| 105617 | 106074 | */ |
| 105618 | 106075 | static void spanBinaryExpr( |
| @@ -105624,10 +106081,11 @@ | ||
| 105624 | 106081 | ){ |
| 105625 | 106082 | pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0); |
| 105626 | 106083 | pOut->zStart = pLeft->zStart; |
| 105627 | 106084 | pOut->zEnd = pRight->zEnd; |
| 105628 | 106085 | } |
| 106086 | +#line 873 "parse.y" | |
| 105629 | 106087 | |
| 105630 | 106088 | /* Construct an expression node for a unary postfix operator |
| 105631 | 106089 | */ |
| 105632 | 106090 | static void spanUnaryPostfix( |
| 105633 | 106091 | ExprSpan *pOut, /* Write the new expression node here */ |
| @@ -105638,10 +106096,11 @@ | ||
| 105638 | 106096 | ){ |
| 105639 | 106097 | pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0); |
| 105640 | 106098 | pOut->zStart = pOperand->zStart; |
| 105641 | 106099 | pOut->zEnd = &pPostOp->z[pPostOp->n]; |
| 105642 | 106100 | } |
| 106101 | +#line 892 "parse.y" | |
| 105643 | 106102 | |
| 105644 | 106103 | /* A routine to convert a binary TK_IS or TK_ISNOT expression into a |
| 105645 | 106104 | ** unary TK_ISNULL or TK_NOTNULL expression. */ |
| 105646 | 106105 | static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){ |
| 105647 | 106106 | sqlite3 *db = pParse->db; |
| @@ -105649,10 +106108,11 @@ | ||
| 105649 | 106108 | pA->op = (u8)op; |
| 105650 | 106109 | sqlite3ExprDelete(db, pA->pRight); |
| 105651 | 106110 | pA->pRight = 0; |
| 105652 | 106111 | } |
| 105653 | 106112 | } |
| 106113 | +#line 920 "parse.y" | |
| 105654 | 106114 | |
| 105655 | 106115 | /* Construct an expression node for a unary prefix operator |
| 105656 | 106116 | */ |
| 105657 | 106117 | static void spanUnaryPrefix( |
| 105658 | 106118 | ExprSpan *pOut, /* Write the new expression node here */ |
| @@ -105663,10 +106123,11 @@ | ||
| 105663 | 106123 | ){ |
| 105664 | 106124 | pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0); |
| 105665 | 106125 | pOut->zStart = pPreOp->z; |
| 105666 | 106126 | pOut->zEnd = pOperand->zEnd; |
| 105667 | 106127 | } |
| 106128 | +#line 141 "parse.c" | |
| 105668 | 106129 | /* Next is all token values, in a form suitable for use by makeheaders. |
| 105669 | 106130 | ** This section will be null unless lemon is run with the -m switch. |
| 105670 | 106131 | */ |
| 105671 | 106132 | /* |
| 105672 | 106133 | ** These constants (all generated automatically by the parser generator) |
| @@ -106918,17 +107379,21 @@ | ||
| 106918 | 107379 | ** inside the C code. |
| 106919 | 107380 | */ |
| 106920 | 107381 | case 160: /* select */ |
| 106921 | 107382 | case 194: /* oneselect */ |
| 106922 | 107383 | { |
| 107384 | +#line 403 "parse.y" | |
| 106923 | 107385 | sqlite3SelectDelete(pParse->db, (yypminor->yy387)); |
| 107386 | +#line 1399 "parse.c" | |
| 106924 | 107387 | } |
| 106925 | 107388 | break; |
| 106926 | 107389 | case 174: /* term */ |
| 106927 | 107390 | case 175: /* expr */ |
| 106928 | 107391 | { |
| 107392 | +#line 720 "parse.y" | |
| 106929 | 107393 | sqlite3ExprDelete(pParse->db, (yypminor->yy118).pExpr); |
| 107394 | +#line 1407 "parse.c" | |
| 106930 | 107395 | } |
| 106931 | 107396 | break; |
| 106932 | 107397 | case 179: /* idxlist_opt */ |
| 106933 | 107398 | case 187: /* idxlist */ |
| 106934 | 107399 | case 197: /* selcollist */ |
| @@ -106940,19 +107405,23 @@ | ||
| 106940 | 107405 | case 217: /* setlist */ |
| 106941 | 107406 | case 220: /* itemlist */ |
| 106942 | 107407 | case 221: /* exprlist */ |
| 106943 | 107408 | case 226: /* case_exprlist */ |
| 106944 | 107409 | { |
| 107410 | +#line 1103 "parse.y" | |
| 106945 | 107411 | sqlite3ExprListDelete(pParse->db, (yypminor->yy322)); |
| 107412 | +#line 1425 "parse.c" | |
| 106946 | 107413 | } |
| 106947 | 107414 | break; |
| 106948 | 107415 | case 193: /* fullname */ |
| 106949 | 107416 | case 198: /* from */ |
| 106950 | 107417 | case 206: /* seltablist */ |
| 106951 | 107418 | case 207: /* stl_prefix */ |
| 106952 | 107419 | { |
| 107420 | +#line 534 "parse.y" | |
| 106953 | 107421 | sqlite3SrcListDelete(pParse->db, (yypminor->yy259)); |
| 107422 | +#line 1435 "parse.c" | |
| 106954 | 107423 | } |
| 106955 | 107424 | break; |
| 106956 | 107425 | case 199: /* where_opt */ |
| 106957 | 107426 | case 201: /* having_opt */ |
| 106958 | 107427 | case 210: /* on_opt */ |
| @@ -106960,29 +107429,37 @@ | ||
| 106960 | 107429 | case 225: /* case_operand */ |
| 106961 | 107430 | case 227: /* case_else */ |
| 106962 | 107431 | case 238: /* when_clause */ |
| 106963 | 107432 | case 243: /* key_opt */ |
| 106964 | 107433 | { |
| 107434 | +#line 644 "parse.y" | |
| 106965 | 107435 | sqlite3ExprDelete(pParse->db, (yypminor->yy314)); |
| 107436 | +#line 1449 "parse.c" | |
| 106966 | 107437 | } |
| 106967 | 107438 | break; |
| 106968 | 107439 | case 211: /* using_opt */ |
| 106969 | 107440 | case 213: /* inscollist */ |
| 106970 | 107441 | case 219: /* inscollist_opt */ |
| 106971 | 107442 | { |
| 107443 | +#line 566 "parse.y" | |
| 106972 | 107444 | sqlite3IdListDelete(pParse->db, (yypminor->yy384)); |
| 107445 | +#line 1458 "parse.c" | |
| 106973 | 107446 | } |
| 106974 | 107447 | break; |
| 106975 | 107448 | case 234: /* trigger_cmd_list */ |
| 106976 | 107449 | case 239: /* trigger_cmd */ |
| 106977 | 107450 | { |
| 107451 | +#line 1210 "parse.y" | |
| 106978 | 107452 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203)); |
| 107453 | +#line 1466 "parse.c" | |
| 106979 | 107454 | } |
| 106980 | 107455 | break; |
| 106981 | 107456 | case 236: /* trigger_event */ |
| 106982 | 107457 | { |
| 107458 | +#line 1196 "parse.y" | |
| 106983 | 107459 | sqlite3IdListDelete(pParse->db, (yypminor->yy90).b); |
| 107460 | +#line 1473 "parse.c" | |
| 106984 | 107461 | } |
| 106985 | 107462 | break; |
| 106986 | 107463 | default: break; /* If no destructor action specified: do nothing */ |
| 106987 | 107464 | } |
| 106988 | 107465 | } |
| @@ -107164,14 +107641,16 @@ | ||
| 107164 | 107641 | } |
| 107165 | 107642 | #endif |
| 107166 | 107643 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 107167 | 107644 | /* Here code is inserted which will execute if the parser |
| 107168 | 107645 | ** stack every overflows */ |
| 107646 | +#line 38 "parse.y" | |
| 107169 | 107647 | |
| 107170 | 107648 | UNUSED_PARAMETER(yypMinor); /* Silence some compiler warnings */ |
| 107171 | 107649 | sqlite3ErrorMsg(pParse, "parser stack overflow"); |
| 107172 | 107650 | pParse->parseError = 1; |
| 107651 | +#line 1664 "parse.c" | |
| 107173 | 107652 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ |
| 107174 | 107653 | } |
| 107175 | 107654 | |
| 107176 | 107655 | /* |
| 107177 | 107656 | ** Perform a shift action. |
| @@ -107608,66 +108087,94 @@ | ||
| 107608 | 108087 | ** { ... } // User supplied code |
| 107609 | 108088 | ** #line <lineno> <thisfile> |
| 107610 | 108089 | ** break; |
| 107611 | 108090 | */ |
| 107612 | 108091 | case 5: /* explain ::= */ |
| 108092 | +#line 107 "parse.y" | |
| 107613 | 108093 | { sqlite3BeginParse(pParse, 0); } |
| 108094 | +#line 2107 "parse.c" | |
| 107614 | 108095 | break; |
| 107615 | 108096 | case 6: /* explain ::= EXPLAIN */ |
| 108097 | +#line 109 "parse.y" | |
| 107616 | 108098 | { sqlite3BeginParse(pParse, 1); } |
| 108099 | +#line 2112 "parse.c" | |
| 107617 | 108100 | break; |
| 107618 | 108101 | case 7: /* explain ::= EXPLAIN QUERY PLAN */ |
| 108102 | +#line 110 "parse.y" | |
| 107619 | 108103 | { sqlite3BeginParse(pParse, 2); } |
| 108104 | +#line 2117 "parse.c" | |
| 107620 | 108105 | break; |
| 107621 | 108106 | case 8: /* cmdx ::= cmd */ |
| 108107 | +#line 112 "parse.y" | |
| 107622 | 108108 | { sqlite3FinishCoding(pParse); } |
| 108109 | +#line 2122 "parse.c" | |
| 107623 | 108110 | break; |
| 107624 | 108111 | case 9: /* cmd ::= BEGIN transtype trans_opt */ |
| 108112 | +#line 117 "parse.y" | |
| 107625 | 108113 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);} |
| 108114 | +#line 2127 "parse.c" | |
| 107626 | 108115 | break; |
| 107627 | 108116 | case 13: /* transtype ::= */ |
| 108117 | +#line 122 "parse.y" | |
| 107628 | 108118 | {yygotominor.yy4 = TK_DEFERRED;} |
| 108119 | +#line 2132 "parse.c" | |
| 107629 | 108120 | break; |
| 107630 | 108121 | case 14: /* transtype ::= DEFERRED */ |
| 107631 | 108122 | case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15); |
| 107632 | 108123 | case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16); |
| 107633 | 108124 | case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115); |
| 107634 | 108125 | case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117); |
| 108126 | +#line 123 "parse.y" | |
| 107635 | 108127 | {yygotominor.yy4 = yymsp[0].major;} |
| 108128 | +#line 2141 "parse.c" | |
| 107636 | 108129 | break; |
| 107637 | 108130 | case 17: /* cmd ::= COMMIT trans_opt */ |
| 107638 | 108131 | case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18); |
| 108132 | +#line 126 "parse.y" | |
| 107639 | 108133 | {sqlite3CommitTransaction(pParse);} |
| 108134 | +#line 2147 "parse.c" | |
| 107640 | 108135 | break; |
| 107641 | 108136 | case 19: /* cmd ::= ROLLBACK trans_opt */ |
| 108137 | +#line 128 "parse.y" | |
| 107642 | 108138 | {sqlite3RollbackTransaction(pParse);} |
| 108139 | +#line 2152 "parse.c" | |
| 107643 | 108140 | break; |
| 107644 | 108141 | case 22: /* cmd ::= SAVEPOINT nm */ |
| 108142 | +#line 132 "parse.y" | |
| 107645 | 108143 | { |
| 107646 | 108144 | sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0); |
| 107647 | 108145 | } |
| 108146 | +#line 2159 "parse.c" | |
| 107648 | 108147 | break; |
| 107649 | 108148 | case 23: /* cmd ::= RELEASE savepoint_opt nm */ |
| 108149 | +#line 135 "parse.y" | |
| 107650 | 108150 | { |
| 107651 | 108151 | sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0); |
| 107652 | 108152 | } |
| 108153 | +#line 2166 "parse.c" | |
| 107653 | 108154 | break; |
| 107654 | 108155 | case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 108156 | +#line 138 "parse.y" | |
| 107655 | 108157 | { |
| 107656 | 108158 | sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); |
| 107657 | 108159 | } |
| 108160 | +#line 2173 "parse.c" | |
| 107658 | 108161 | break; |
| 107659 | 108162 | case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 108163 | +#line 145 "parse.y" | |
| 107660 | 108164 | { |
| 107661 | 108165 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4); |
| 107662 | 108166 | } |
| 108167 | +#line 2180 "parse.c" | |
| 107663 | 108168 | break; |
| 107664 | 108169 | case 27: /* createkw ::= CREATE */ |
| 108170 | +#line 148 "parse.y" | |
| 107665 | 108171 | { |
| 107666 | 108172 | pParse->db->lookaside.bEnabled = 0; |
| 107667 | 108173 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 107668 | 108174 | } |
| 108175 | +#line 2188 "parse.c" | |
| 107669 | 108176 | break; |
| 107670 | 108177 | case 28: /* ifnotexists ::= */ |
| 107671 | 108178 | case 31: /* temp ::= */ yytestcase(yyruleno==31); |
| 107672 | 108179 | case 70: /* autoinc ::= */ yytestcase(yyruleno==70); |
| 107673 | 108180 | case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83); |
| @@ -107677,44 +108184,56 @@ | ||
| 107677 | 108184 | case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 107678 | 108185 | case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120); |
| 107679 | 108186 | case 121: /* distinct ::= */ yytestcase(yyruleno==121); |
| 107680 | 108187 | case 222: /* between_op ::= BETWEEN */ yytestcase(yyruleno==222); |
| 107681 | 108188 | case 225: /* in_op ::= IN */ yytestcase(yyruleno==225); |
| 108189 | +#line 153 "parse.y" | |
| 107682 | 108190 | {yygotominor.yy4 = 0;} |
| 108191 | +#line 2204 "parse.c" | |
| 107683 | 108192 | break; |
| 107684 | 108193 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 107685 | 108194 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 107686 | 108195 | case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71); |
| 107687 | 108196 | case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86); |
| 107688 | 108197 | case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 107689 | 108198 | case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119); |
| 107690 | 108199 | case 223: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==223); |
| 107691 | 108200 | case 226: /* in_op ::= NOT IN */ yytestcase(yyruleno==226); |
| 108201 | +#line 154 "parse.y" | |
| 107692 | 108202 | {yygotominor.yy4 = 1;} |
| 108203 | +#line 2216 "parse.c" | |
| 107693 | 108204 | break; |
| 107694 | 108205 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| 108206 | +#line 160 "parse.y" | |
| 107695 | 108207 | { |
| 107696 | 108208 | sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); |
| 107697 | 108209 | } |
| 108210 | +#line 2223 "parse.c" | |
| 107698 | 108211 | break; |
| 107699 | 108212 | case 33: /* create_table_args ::= AS select */ |
| 108213 | +#line 163 "parse.y" | |
| 107700 | 108214 | { |
| 107701 | 108215 | sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy387); |
| 107702 | 108216 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 107703 | 108217 | } |
| 108218 | +#line 2231 "parse.c" | |
| 107704 | 108219 | break; |
| 107705 | 108220 | case 36: /* column ::= columnid type carglist */ |
| 108221 | +#line 175 "parse.y" | |
| 107706 | 108222 | { |
| 107707 | 108223 | yygotominor.yy0.z = yymsp[-2].minor.yy0.z; |
| 107708 | 108224 | yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n; |
| 107709 | 108225 | } |
| 108226 | +#line 2239 "parse.c" | |
| 107710 | 108227 | break; |
| 107711 | 108228 | case 37: /* columnid ::= nm */ |
| 108229 | +#line 179 "parse.y" | |
| 107712 | 108230 | { |
| 107713 | 108231 | sqlite3AddColumn(pParse,&yymsp[0].minor.yy0); |
| 107714 | 108232 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 107715 | 108233 | } |
| 108234 | +#line 2247 "parse.c" | |
| 107716 | 108235 | break; |
| 107717 | 108236 | case 38: /* id ::= ID */ |
| 107718 | 108237 | case 39: /* id ::= INDEXED */ yytestcase(yyruleno==39); |
| 107719 | 108238 | case 40: /* ids ::= ID|STRING */ yytestcase(yyruleno==40); |
| 107720 | 108239 | case 41: /* nm ::= id */ yytestcase(yyruleno==41); |
| @@ -107734,256 +108253,373 @@ | ||
| 107734 | 108253 | case 264: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==264); |
| 107735 | 108254 | case 265: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==265); |
| 107736 | 108255 | case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266); |
| 107737 | 108256 | case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267); |
| 107738 | 108257 | case 285: /* trnm ::= nm */ yytestcase(yyruleno==285); |
| 108258 | +#line 189 "parse.y" | |
| 107739 | 108259 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 108260 | +#line 2273 "parse.c" | |
| 107740 | 108261 | break; |
| 107741 | 108262 | case 45: /* type ::= typetoken */ |
| 108263 | +#line 251 "parse.y" | |
| 107742 | 108264 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 108265 | +#line 2278 "parse.c" | |
| 107743 | 108266 | break; |
| 107744 | 108267 | case 47: /* typetoken ::= typename LP signed RP */ |
| 108268 | +#line 253 "parse.y" | |
| 107745 | 108269 | { |
| 107746 | 108270 | yygotominor.yy0.z = yymsp[-3].minor.yy0.z; |
| 107747 | 108271 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); |
| 107748 | 108272 | } |
| 108273 | +#line 2286 "parse.c" | |
| 107749 | 108274 | break; |
| 107750 | 108275 | case 48: /* typetoken ::= typename LP signed COMMA signed RP */ |
| 108276 | +#line 257 "parse.y" | |
| 107751 | 108277 | { |
| 107752 | 108278 | yygotominor.yy0.z = yymsp[-5].minor.yy0.z; |
| 107753 | 108279 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); |
| 107754 | 108280 | } |
| 108281 | +#line 2294 "parse.c" | |
| 107755 | 108282 | break; |
| 107756 | 108283 | case 50: /* typename ::= typename ids */ |
| 108284 | +#line 263 "parse.y" | |
| 107757 | 108285 | {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 108286 | +#line 2299 "parse.c" | |
| 107758 | 108287 | break; |
| 107759 | 108288 | case 57: /* ccons ::= DEFAULT term */ |
| 107760 | 108289 | case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59); |
| 108290 | +#line 274 "parse.y" | |
| 107761 | 108291 | {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy118);} |
| 108292 | +#line 2305 "parse.c" | |
| 107762 | 108293 | break; |
| 107763 | 108294 | case 58: /* ccons ::= DEFAULT LP expr RP */ |
| 108295 | +#line 275 "parse.y" | |
| 107764 | 108296 | {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy118);} |
| 108297 | +#line 2310 "parse.c" | |
| 107765 | 108298 | break; |
| 107766 | 108299 | case 60: /* ccons ::= DEFAULT MINUS term */ |
| 108300 | +#line 277 "parse.y" | |
| 107767 | 108301 | { |
| 107768 | 108302 | ExprSpan v; |
| 107769 | 108303 | v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0); |
| 107770 | 108304 | v.zStart = yymsp[-1].minor.yy0.z; |
| 107771 | 108305 | v.zEnd = yymsp[0].minor.yy118.zEnd; |
| 107772 | 108306 | sqlite3AddDefaultValue(pParse,&v); |
| 107773 | 108307 | } |
| 108308 | +#line 2321 "parse.c" | |
| 107774 | 108309 | break; |
| 107775 | 108310 | case 61: /* ccons ::= DEFAULT id */ |
| 108311 | +#line 284 "parse.y" | |
| 107776 | 108312 | { |
| 107777 | 108313 | ExprSpan v; |
| 107778 | 108314 | spanExpr(&v, pParse, TK_STRING, &yymsp[0].minor.yy0); |
| 107779 | 108315 | sqlite3AddDefaultValue(pParse,&v); |
| 107780 | 108316 | } |
| 108317 | +#line 2330 "parse.c" | |
| 107781 | 108318 | break; |
| 107782 | 108319 | case 63: /* ccons ::= NOT NULL onconf */ |
| 108320 | +#line 294 "parse.y" | |
| 107783 | 108321 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);} |
| 108322 | +#line 2335 "parse.c" | |
| 107784 | 108323 | break; |
| 107785 | 108324 | case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 108325 | +#line 296 "parse.y" | |
| 107786 | 108326 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);} |
| 108327 | +#line 2340 "parse.c" | |
| 107787 | 108328 | break; |
| 107788 | 108329 | case 65: /* ccons ::= UNIQUE onconf */ |
| 108330 | +#line 297 "parse.y" | |
| 107789 | 108331 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0);} |
| 108332 | +#line 2345 "parse.c" | |
| 107790 | 108333 | break; |
| 107791 | 108334 | case 66: /* ccons ::= CHECK LP expr RP */ |
| 108335 | +#line 298 "parse.y" | |
| 107792 | 108336 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy118.pExpr);} |
| 108337 | +#line 2350 "parse.c" | |
| 107793 | 108338 | break; |
| 107794 | 108339 | case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */ |
| 108340 | +#line 300 "parse.y" | |
| 107795 | 108341 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);} |
| 108342 | +#line 2355 "parse.c" | |
| 107796 | 108343 | break; |
| 107797 | 108344 | case 68: /* ccons ::= defer_subclause */ |
| 108345 | +#line 301 "parse.y" | |
| 107798 | 108346 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);} |
| 108347 | +#line 2360 "parse.c" | |
| 107799 | 108348 | break; |
| 107800 | 108349 | case 69: /* ccons ::= COLLATE ids */ |
| 108350 | +#line 302 "parse.y" | |
| 107801 | 108351 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 108352 | +#line 2365 "parse.c" | |
| 107802 | 108353 | break; |
| 107803 | 108354 | case 72: /* refargs ::= */ |
| 108355 | +#line 315 "parse.y" | |
| 107804 | 108356 | { yygotominor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 108357 | +#line 2370 "parse.c" | |
| 107805 | 108358 | break; |
| 107806 | 108359 | case 73: /* refargs ::= refargs refarg */ |
| 108360 | +#line 316 "parse.y" | |
| 107807 | 108361 | { yygotominor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; } |
| 108362 | +#line 2375 "parse.c" | |
| 107808 | 108363 | break; |
| 107809 | 108364 | case 74: /* refarg ::= MATCH nm */ |
| 107810 | 108365 | case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75); |
| 108366 | +#line 318 "parse.y" | |
| 107811 | 108367 | { yygotominor.yy215.value = 0; yygotominor.yy215.mask = 0x000000; } |
| 108368 | +#line 2381 "parse.c" | |
| 107812 | 108369 | break; |
| 107813 | 108370 | case 76: /* refarg ::= ON DELETE refact */ |
| 108371 | +#line 320 "parse.y" | |
| 107814 | 108372 | { yygotominor.yy215.value = yymsp[0].minor.yy4; yygotominor.yy215.mask = 0x0000ff; } |
| 108373 | +#line 2386 "parse.c" | |
| 107815 | 108374 | break; |
| 107816 | 108375 | case 77: /* refarg ::= ON UPDATE refact */ |
| 108376 | +#line 321 "parse.y" | |
| 107817 | 108377 | { yygotominor.yy215.value = yymsp[0].minor.yy4<<8; yygotominor.yy215.mask = 0x00ff00; } |
| 108378 | +#line 2391 "parse.c" | |
| 107818 | 108379 | break; |
| 107819 | 108380 | case 78: /* refact ::= SET NULL */ |
| 108381 | +#line 323 "parse.y" | |
| 107820 | 108382 | { yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */} |
| 108383 | +#line 2396 "parse.c" | |
| 107821 | 108384 | break; |
| 107822 | 108385 | case 79: /* refact ::= SET DEFAULT */ |
| 108386 | +#line 324 "parse.y" | |
| 107823 | 108387 | { yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 108388 | +#line 2401 "parse.c" | |
| 107824 | 108389 | break; |
| 107825 | 108390 | case 80: /* refact ::= CASCADE */ |
| 108391 | +#line 325 "parse.y" | |
| 107826 | 108392 | { yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */} |
| 108393 | +#line 2406 "parse.c" | |
| 107827 | 108394 | break; |
| 107828 | 108395 | case 81: /* refact ::= RESTRICT */ |
| 108396 | +#line 326 "parse.y" | |
| 107829 | 108397 | { yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */} |
| 108398 | +#line 2411 "parse.c" | |
| 107830 | 108399 | break; |
| 107831 | 108400 | case 82: /* refact ::= NO ACTION */ |
| 108401 | +#line 327 "parse.y" | |
| 107832 | 108402 | { yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */} |
| 108403 | +#line 2416 "parse.c" | |
| 107833 | 108404 | break; |
| 107834 | 108405 | case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 107835 | 108406 | case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99); |
| 107836 | 108407 | case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101); |
| 107837 | 108408 | case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104); |
| 108409 | +#line 330 "parse.y" | |
| 107838 | 108410 | {yygotominor.yy4 = yymsp[0].minor.yy4;} |
| 108411 | +#line 2424 "parse.c" | |
| 107839 | 108412 | break; |
| 107840 | 108413 | case 88: /* conslist_opt ::= */ |
| 108414 | +#line 339 "parse.y" | |
| 107841 | 108415 | {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;} |
| 108416 | +#line 2429 "parse.c" | |
| 107842 | 108417 | break; |
| 107843 | 108418 | case 89: /* conslist_opt ::= COMMA conslist */ |
| 108419 | +#line 340 "parse.y" | |
| 107844 | 108420 | {yygotominor.yy0 = yymsp[-1].minor.yy0;} |
| 108421 | +#line 2434 "parse.c" | |
| 107845 | 108422 | break; |
| 107846 | 108423 | case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 108424 | +#line 346 "parse.y" | |
| 107847 | 108425 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);} |
| 108426 | +#line 2439 "parse.c" | |
| 107848 | 108427 | break; |
| 107849 | 108428 | case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 108429 | +#line 348 "parse.y" | |
| 107850 | 108430 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0);} |
| 108431 | +#line 2444 "parse.c" | |
| 107851 | 108432 | break; |
| 107852 | 108433 | case 96: /* tcons ::= CHECK LP expr RP onconf */ |
| 108434 | +#line 350 "parse.y" | |
| 107853 | 108435 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy118.pExpr);} |
| 108436 | +#line 2449 "parse.c" | |
| 107854 | 108437 | break; |
| 107855 | 108438 | case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 108439 | +#line 352 "parse.y" | |
| 107856 | 108440 | { |
| 107857 | 108441 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4); |
| 107858 | 108442 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); |
| 107859 | 108443 | } |
| 108444 | +#line 2457 "parse.c" | |
| 107860 | 108445 | break; |
| 107861 | 108446 | case 100: /* onconf ::= */ |
| 108447 | +#line 366 "parse.y" | |
| 107862 | 108448 | {yygotominor.yy4 = OE_Default;} |
| 108449 | +#line 2462 "parse.c" | |
| 107863 | 108450 | break; |
| 107864 | 108451 | case 102: /* orconf ::= */ |
| 108452 | +#line 368 "parse.y" | |
| 107865 | 108453 | {yygotominor.yy210 = OE_Default;} |
| 108454 | +#line 2467 "parse.c" | |
| 107866 | 108455 | break; |
| 107867 | 108456 | case 103: /* orconf ::= OR resolvetype */ |
| 108457 | +#line 369 "parse.y" | |
| 107868 | 108458 | {yygotominor.yy210 = (u8)yymsp[0].minor.yy4;} |
| 108459 | +#line 2472 "parse.c" | |
| 107869 | 108460 | break; |
| 107870 | 108461 | case 105: /* resolvetype ::= IGNORE */ |
| 108462 | +#line 371 "parse.y" | |
| 107871 | 108463 | {yygotominor.yy4 = OE_Ignore;} |
| 108464 | +#line 2477 "parse.c" | |
| 107872 | 108465 | break; |
| 107873 | 108466 | case 106: /* resolvetype ::= REPLACE */ |
| 108467 | +#line 372 "parse.y" | |
| 107874 | 108468 | {yygotominor.yy4 = OE_Replace;} |
| 108469 | +#line 2482 "parse.c" | |
| 107875 | 108470 | break; |
| 107876 | 108471 | case 107: /* cmd ::= DROP TABLE ifexists fullname */ |
| 108472 | +#line 376 "parse.y" | |
| 107877 | 108473 | { |
| 107878 | 108474 | sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4); |
| 107879 | 108475 | } |
| 108476 | +#line 2489 "parse.c" | |
| 107880 | 108477 | break; |
| 107881 | 108478 | case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 108479 | +#line 386 "parse.y" | |
| 107882 | 108480 | { |
| 107883 | 108481 | sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4); |
| 107884 | 108482 | } |
| 108483 | +#line 2496 "parse.c" | |
| 107885 | 108484 | break; |
| 107886 | 108485 | case 111: /* cmd ::= DROP VIEW ifexists fullname */ |
| 108486 | +#line 389 "parse.y" | |
| 107887 | 108487 | { |
| 107888 | 108488 | sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4); |
| 107889 | 108489 | } |
| 108490 | +#line 2503 "parse.c" | |
| 107890 | 108491 | break; |
| 107891 | 108492 | case 112: /* cmd ::= select */ |
| 108493 | +#line 396 "parse.y" | |
| 107892 | 108494 | { |
| 107893 | 108495 | SelectDest dest = {SRT_Output, 0, 0, 0, 0}; |
| 107894 | 108496 | sqlite3Select(pParse, yymsp[0].minor.yy387, &dest); |
| 107895 | 108497 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 107896 | 108498 | } |
| 108499 | +#line 2512 "parse.c" | |
| 107897 | 108500 | break; |
| 107898 | 108501 | case 113: /* select ::= oneselect */ |
| 108502 | +#line 407 "parse.y" | |
| 107899 | 108503 | {yygotominor.yy387 = yymsp[0].minor.yy387;} |
| 108504 | +#line 2517 "parse.c" | |
| 107900 | 108505 | break; |
| 107901 | 108506 | case 114: /* select ::= select multiselect_op oneselect */ |
| 108507 | +#line 409 "parse.y" | |
| 107902 | 108508 | { |
| 107903 | 108509 | if( yymsp[0].minor.yy387 ){ |
| 107904 | 108510 | yymsp[0].minor.yy387->op = (u8)yymsp[-1].minor.yy4; |
| 107905 | 108511 | yymsp[0].minor.yy387->pPrior = yymsp[-2].minor.yy387; |
| 107906 | 108512 | }else{ |
| 107907 | 108513 | sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy387); |
| 107908 | 108514 | } |
| 107909 | 108515 | yygotominor.yy387 = yymsp[0].minor.yy387; |
| 107910 | 108516 | } |
| 108517 | +#line 2530 "parse.c" | |
| 107911 | 108518 | break; |
| 107912 | 108519 | case 116: /* multiselect_op ::= UNION ALL */ |
| 108520 | +#line 420 "parse.y" | |
| 107913 | 108521 | {yygotominor.yy4 = TK_ALL;} |
| 108522 | +#line 2535 "parse.c" | |
| 107914 | 108523 | break; |
| 107915 | 108524 | case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 108525 | +#line 424 "parse.y" | |
| 107916 | 108526 | { |
| 107917 | 108527 | yygotominor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy292.pLimit,yymsp[0].minor.yy292.pOffset); |
| 107918 | 108528 | } |
| 108529 | +#line 2542 "parse.c" | |
| 107919 | 108530 | break; |
| 107920 | 108531 | case 122: /* sclp ::= selcollist COMMA */ |
| 107921 | 108532 | case 247: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==247); |
| 108533 | +#line 445 "parse.y" | |
| 107922 | 108534 | {yygotominor.yy322 = yymsp[-1].minor.yy322;} |
| 108535 | +#line 2548 "parse.c" | |
| 107923 | 108536 | break; |
| 107924 | 108537 | case 123: /* sclp ::= */ |
| 107925 | 108538 | case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151); |
| 107926 | 108539 | case 159: /* groupby_opt ::= */ yytestcase(yyruleno==159); |
| 107927 | 108540 | case 240: /* exprlist ::= */ yytestcase(yyruleno==240); |
| 107928 | 108541 | case 246: /* idxlist_opt ::= */ yytestcase(yyruleno==246); |
| 108542 | +#line 446 "parse.y" | |
| 107929 | 108543 | {yygotominor.yy322 = 0;} |
| 108544 | +#line 2557 "parse.c" | |
| 107930 | 108545 | break; |
| 107931 | 108546 | case 124: /* selcollist ::= sclp expr as */ |
| 108547 | +#line 447 "parse.y" | |
| 107932 | 108548 | { |
| 107933 | 108549 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr); |
| 107934 | 108550 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[0].minor.yy0, 1); |
| 107935 | 108551 | sqlite3ExprListSetSpan(pParse,yygotominor.yy322,&yymsp[-1].minor.yy118); |
| 107936 | 108552 | } |
| 108553 | +#line 2566 "parse.c" | |
| 107937 | 108554 | break; |
| 107938 | 108555 | case 125: /* selcollist ::= sclp STAR */ |
| 108556 | +#line 452 "parse.y" | |
| 107939 | 108557 | { |
| 107940 | 108558 | Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0); |
| 107941 | 108559 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy322, p); |
| 107942 | 108560 | } |
| 108561 | +#line 2574 "parse.c" | |
| 107943 | 108562 | break; |
| 107944 | 108563 | case 126: /* selcollist ::= sclp nm DOT STAR */ |
| 108564 | +#line 456 "parse.y" | |
| 107945 | 108565 | { |
| 107946 | 108566 | Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0); |
| 107947 | 108567 | Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 107948 | 108568 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); |
| 107949 | 108569 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, pDot); |
| 107950 | 108570 | } |
| 108571 | +#line 2584 "parse.c" | |
| 107951 | 108572 | break; |
| 107952 | 108573 | case 129: /* as ::= */ |
| 108574 | +#line 469 "parse.y" | |
| 107953 | 108575 | {yygotominor.yy0.n = 0;} |
| 108576 | +#line 2589 "parse.c" | |
| 107954 | 108577 | break; |
| 107955 | 108578 | case 130: /* from ::= */ |
| 108579 | +#line 481 "parse.y" | |
| 107956 | 108580 | {yygotominor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy259));} |
| 108581 | +#line 2594 "parse.c" | |
| 107957 | 108582 | break; |
| 107958 | 108583 | case 131: /* from ::= FROM seltablist */ |
| 108584 | +#line 482 "parse.y" | |
| 107959 | 108585 | { |
| 107960 | 108586 | yygotominor.yy259 = yymsp[0].minor.yy259; |
| 107961 | 108587 | sqlite3SrcListShiftJoinType(yygotominor.yy259); |
| 107962 | 108588 | } |
| 108589 | +#line 2602 "parse.c" | |
| 107963 | 108590 | break; |
| 107964 | 108591 | case 132: /* stl_prefix ::= seltablist joinop */ |
| 108592 | +#line 490 "parse.y" | |
| 107965 | 108593 | { |
| 107966 | 108594 | yygotominor.yy259 = yymsp[-1].minor.yy259; |
| 107967 | 108595 | if( ALWAYS(yygotominor.yy259 && yygotominor.yy259->nSrc>0) ) yygotominor.yy259->a[yygotominor.yy259->nSrc-1].jointype = (u8)yymsp[0].minor.yy4; |
| 107968 | 108596 | } |
| 108597 | +#line 2610 "parse.c" | |
| 107969 | 108598 | break; |
| 107970 | 108599 | case 133: /* stl_prefix ::= */ |
| 108600 | +#line 494 "parse.y" | |
| 107971 | 108601 | {yygotominor.yy259 = 0;} |
| 108602 | +#line 2615 "parse.c" | |
| 107972 | 108603 | break; |
| 107973 | 108604 | case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 108605 | +#line 495 "parse.y" | |
| 107974 | 108606 | { |
| 107975 | 108607 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 107976 | 108608 | sqlite3SrcListIndexedBy(pParse, yygotominor.yy259, &yymsp[-2].minor.yy0); |
| 107977 | 108609 | } |
| 108610 | +#line 2623 "parse.c" | |
| 107978 | 108611 | break; |
| 107979 | 108612 | case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 108613 | +#line 501 "parse.y" | |
| 107980 | 108614 | { |
| 107981 | 108615 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 107982 | 108616 | } |
| 108617 | +#line 2630 "parse.c" | |
| 107983 | 108618 | break; |
| 107984 | 108619 | case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 108620 | +#line 505 "parse.y" | |
| 107985 | 108621 | { |
| 107986 | 108622 | if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){ |
| 107987 | 108623 | yygotominor.yy259 = yymsp[-4].minor.yy259; |
| 107988 | 108624 | }else{ |
| 107989 | 108625 | Select *pSubquery; |
| @@ -107990,180 +108626,260 @@ | ||
| 107990 | 108626 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259); |
| 107991 | 108627 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,0,0,0); |
| 107992 | 108628 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 107993 | 108629 | } |
| 107994 | 108630 | } |
| 108631 | +#line 2644 "parse.c" | |
| 107995 | 108632 | break; |
| 107996 | 108633 | case 137: /* dbnm ::= */ |
| 107997 | 108634 | case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146); |
| 108635 | +#line 530 "parse.y" | |
| 107998 | 108636 | {yygotominor.yy0.z=0; yygotominor.yy0.n=0;} |
| 108637 | +#line 2650 "parse.c" | |
| 107999 | 108638 | break; |
| 108000 | 108639 | case 139: /* fullname ::= nm dbnm */ |
| 108640 | +#line 535 "parse.y" | |
| 108001 | 108641 | {yygotominor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 108642 | +#line 2655 "parse.c" | |
| 108002 | 108643 | break; |
| 108003 | 108644 | case 140: /* joinop ::= COMMA|JOIN */ |
| 108645 | +#line 539 "parse.y" | |
| 108004 | 108646 | { yygotominor.yy4 = JT_INNER; } |
| 108647 | +#line 2660 "parse.c" | |
| 108005 | 108648 | break; |
| 108006 | 108649 | case 141: /* joinop ::= JOIN_KW JOIN */ |
| 108650 | +#line 540 "parse.y" | |
| 108007 | 108651 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 108652 | +#line 2665 "parse.c" | |
| 108008 | 108653 | break; |
| 108009 | 108654 | case 142: /* joinop ::= JOIN_KW nm JOIN */ |
| 108655 | +#line 541 "parse.y" | |
| 108010 | 108656 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 108657 | +#line 2670 "parse.c" | |
| 108011 | 108658 | break; |
| 108012 | 108659 | case 143: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 108660 | +#line 543 "parse.y" | |
| 108013 | 108661 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 108662 | +#line 2675 "parse.c" | |
| 108014 | 108663 | break; |
| 108015 | 108664 | case 144: /* on_opt ::= ON expr */ |
| 108016 | 108665 | case 155: /* sortitem ::= expr */ yytestcase(yyruleno==155); |
| 108017 | 108666 | case 162: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==162); |
| 108018 | 108667 | case 169: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==169); |
| 108019 | 108668 | case 235: /* case_else ::= ELSE expr */ yytestcase(yyruleno==235); |
| 108020 | 108669 | case 237: /* case_operand ::= expr */ yytestcase(yyruleno==237); |
| 108670 | +#line 547 "parse.y" | |
| 108021 | 108671 | {yygotominor.yy314 = yymsp[0].minor.yy118.pExpr;} |
| 108672 | +#line 2685 "parse.c" | |
| 108022 | 108673 | break; |
| 108023 | 108674 | case 145: /* on_opt ::= */ |
| 108024 | 108675 | case 161: /* having_opt ::= */ yytestcase(yyruleno==161); |
| 108025 | 108676 | case 168: /* where_opt ::= */ yytestcase(yyruleno==168); |
| 108026 | 108677 | case 236: /* case_else ::= */ yytestcase(yyruleno==236); |
| 108027 | 108678 | case 238: /* case_operand ::= */ yytestcase(yyruleno==238); |
| 108679 | +#line 548 "parse.y" | |
| 108028 | 108680 | {yygotominor.yy314 = 0;} |
| 108681 | +#line 2694 "parse.c" | |
| 108029 | 108682 | break; |
| 108030 | 108683 | case 148: /* indexed_opt ::= NOT INDEXED */ |
| 108684 | +#line 563 "parse.y" | |
| 108031 | 108685 | {yygotominor.yy0.z=0; yygotominor.yy0.n=1;} |
| 108686 | +#line 2699 "parse.c" | |
| 108032 | 108687 | break; |
| 108033 | 108688 | case 149: /* using_opt ::= USING LP inscollist RP */ |
| 108034 | 108689 | case 181: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==181); |
| 108690 | +#line 567 "parse.y" | |
| 108035 | 108691 | {yygotominor.yy384 = yymsp[-1].minor.yy384;} |
| 108692 | +#line 2705 "parse.c" | |
| 108036 | 108693 | break; |
| 108037 | 108694 | case 150: /* using_opt ::= */ |
| 108038 | 108695 | case 180: /* inscollist_opt ::= */ yytestcase(yyruleno==180); |
| 108696 | +#line 568 "parse.y" | |
| 108039 | 108697 | {yygotominor.yy384 = 0;} |
| 108698 | +#line 2711 "parse.c" | |
| 108040 | 108699 | break; |
| 108041 | 108700 | case 152: /* orderby_opt ::= ORDER BY sortlist */ |
| 108042 | 108701 | case 160: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==160); |
| 108043 | 108702 | case 239: /* exprlist ::= nexprlist */ yytestcase(yyruleno==239); |
| 108703 | +#line 579 "parse.y" | |
| 108044 | 108704 | {yygotominor.yy322 = yymsp[0].minor.yy322;} |
| 108705 | +#line 2718 "parse.c" | |
| 108045 | 108706 | break; |
| 108046 | 108707 | case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ |
| 108708 | +#line 580 "parse.y" | |
| 108047 | 108709 | { |
| 108048 | 108710 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314); |
| 108049 | 108711 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108050 | 108712 | } |
| 108713 | +#line 2726 "parse.c" | |
| 108051 | 108714 | break; |
| 108052 | 108715 | case 154: /* sortlist ::= sortitem sortorder */ |
| 108716 | +#line 584 "parse.y" | |
| 108053 | 108717 | { |
| 108054 | 108718 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314); |
| 108055 | 108719 | if( yygotominor.yy322 && ALWAYS(yygotominor.yy322->a) ) yygotominor.yy322->a[0].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108056 | 108720 | } |
| 108721 | +#line 2734 "parse.c" | |
| 108057 | 108722 | break; |
| 108058 | 108723 | case 156: /* sortorder ::= ASC */ |
| 108059 | 108724 | case 158: /* sortorder ::= */ yytestcase(yyruleno==158); |
| 108725 | +#line 592 "parse.y" | |
| 108060 | 108726 | {yygotominor.yy4 = SQLITE_SO_ASC;} |
| 108727 | +#line 2740 "parse.c" | |
| 108061 | 108728 | break; |
| 108062 | 108729 | case 157: /* sortorder ::= DESC */ |
| 108730 | +#line 593 "parse.y" | |
| 108063 | 108731 | {yygotominor.yy4 = SQLITE_SO_DESC;} |
| 108732 | +#line 2745 "parse.c" | |
| 108064 | 108733 | break; |
| 108065 | 108734 | case 163: /* limit_opt ::= */ |
| 108735 | +#line 619 "parse.y" | |
| 108066 | 108736 | {yygotominor.yy292.pLimit = 0; yygotominor.yy292.pOffset = 0;} |
| 108737 | +#line 2750 "parse.c" | |
| 108067 | 108738 | break; |
| 108068 | 108739 | case 164: /* limit_opt ::= LIMIT expr */ |
| 108740 | +#line 620 "parse.y" | |
| 108069 | 108741 | {yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; yygotominor.yy292.pOffset = 0;} |
| 108742 | +#line 2755 "parse.c" | |
| 108070 | 108743 | break; |
| 108071 | 108744 | case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 108745 | +#line 622 "parse.y" | |
| 108072 | 108746 | {yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr;} |
| 108747 | +#line 2760 "parse.c" | |
| 108073 | 108748 | break; |
| 108074 | 108749 | case 166: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 108750 | +#line 624 "parse.y" | |
| 108075 | 108751 | {yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr;} |
| 108752 | +#line 2765 "parse.c" | |
| 108076 | 108753 | break; |
| 108077 | 108754 | case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ |
| 108755 | +#line 637 "parse.y" | |
| 108078 | 108756 | { |
| 108079 | 108757 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0); |
| 108080 | 108758 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314); |
| 108081 | 108759 | } |
| 108760 | +#line 2773 "parse.c" | |
| 108082 | 108761 | break; |
| 108083 | 108762 | case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 108763 | +#line 660 "parse.y" | |
| 108084 | 108764 | { |
| 108085 | 108765 | sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0); |
| 108086 | 108766 | sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); |
| 108087 | 108767 | sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy210); |
| 108088 | 108768 | } |
| 108769 | +#line 2782 "parse.c" | |
| 108089 | 108770 | break; |
| 108090 | 108771 | case 171: /* setlist ::= setlist COMMA nm EQ expr */ |
| 108772 | +#line 670 "parse.y" | |
| 108091 | 108773 | { |
| 108092 | 108774 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr); |
| 108093 | 108775 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108094 | 108776 | } |
| 108777 | +#line 2790 "parse.c" | |
| 108095 | 108778 | break; |
| 108096 | 108779 | case 172: /* setlist ::= nm EQ expr */ |
| 108780 | +#line 674 "parse.y" | |
| 108097 | 108781 | { |
| 108098 | 108782 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); |
| 108099 | 108783 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108100 | 108784 | } |
| 108785 | +#line 2798 "parse.c" | |
| 108101 | 108786 | break; |
| 108102 | 108787 | case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */ |
| 108788 | +#line 683 "parse.y" | |
| 108103 | 108789 | {sqlite3Insert(pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210);} |
| 108790 | +#line 2803 "parse.c" | |
| 108104 | 108791 | break; |
| 108105 | 108792 | case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ |
| 108793 | +#line 685 "parse.y" | |
| 108106 | 108794 | {sqlite3Insert(pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210);} |
| 108795 | +#line 2808 "parse.c" | |
| 108107 | 108796 | break; |
| 108108 | 108797 | case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 108798 | +#line 687 "parse.y" | |
| 108109 | 108799 | {sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210);} |
| 108800 | +#line 2813 "parse.c" | |
| 108110 | 108801 | break; |
| 108111 | 108802 | case 176: /* insert_cmd ::= INSERT orconf */ |
| 108803 | +#line 690 "parse.y" | |
| 108112 | 108804 | {yygotominor.yy210 = yymsp[0].minor.yy210;} |
| 108805 | +#line 2818 "parse.c" | |
| 108113 | 108806 | break; |
| 108114 | 108807 | case 177: /* insert_cmd ::= REPLACE */ |
| 108808 | +#line 691 "parse.y" | |
| 108115 | 108809 | {yygotominor.yy210 = OE_Replace;} |
| 108810 | +#line 2823 "parse.c" | |
| 108116 | 108811 | break; |
| 108117 | 108812 | case 178: /* itemlist ::= itemlist COMMA expr */ |
| 108118 | 108813 | case 241: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==241); |
| 108814 | +#line 698 "parse.y" | |
| 108119 | 108815 | {yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy118.pExpr);} |
| 108816 | +#line 2829 "parse.c" | |
| 108120 | 108817 | break; |
| 108121 | 108818 | case 179: /* itemlist ::= expr */ |
| 108122 | 108819 | case 242: /* nexprlist ::= expr */ yytestcase(yyruleno==242); |
| 108820 | +#line 700 "parse.y" | |
| 108123 | 108821 | {yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy118.pExpr);} |
| 108822 | +#line 2835 "parse.c" | |
| 108124 | 108823 | break; |
| 108125 | 108824 | case 182: /* inscollist ::= inscollist COMMA nm */ |
| 108825 | +#line 710 "parse.y" | |
| 108126 | 108826 | {yygotominor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);} |
| 108827 | +#line 2840 "parse.c" | |
| 108127 | 108828 | break; |
| 108128 | 108829 | case 183: /* inscollist ::= nm */ |
| 108830 | +#line 712 "parse.y" | |
| 108129 | 108831 | {yygotominor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 108832 | +#line 2845 "parse.c" | |
| 108130 | 108833 | break; |
| 108131 | 108834 | case 184: /* expr ::= term */ |
| 108835 | +#line 743 "parse.y" | |
| 108132 | 108836 | {yygotominor.yy118 = yymsp[0].minor.yy118;} |
| 108837 | +#line 2850 "parse.c" | |
| 108133 | 108838 | break; |
| 108134 | 108839 | case 185: /* expr ::= LP expr RP */ |
| 108840 | +#line 744 "parse.y" | |
| 108135 | 108841 | {yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 108842 | +#line 2855 "parse.c" | |
| 108136 | 108843 | break; |
| 108137 | 108844 | case 186: /* term ::= NULL */ |
| 108138 | 108845 | case 191: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==191); |
| 108139 | 108846 | case 192: /* term ::= STRING */ yytestcase(yyruleno==192); |
| 108847 | +#line 745 "parse.y" | |
| 108140 | 108848 | {spanExpr(&yygotominor.yy118, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 108849 | +#line 2862 "parse.c" | |
| 108141 | 108850 | break; |
| 108142 | 108851 | case 187: /* expr ::= id */ |
| 108143 | 108852 | case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188); |
| 108853 | +#line 746 "parse.y" | |
| 108144 | 108854 | {spanExpr(&yygotominor.yy118, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 108855 | +#line 2868 "parse.c" | |
| 108145 | 108856 | break; |
| 108146 | 108857 | case 189: /* expr ::= nm DOT nm */ |
| 108858 | +#line 748 "parse.y" | |
| 108147 | 108859 | { |
| 108148 | 108860 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 108149 | 108861 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 108150 | 108862 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 108151 | 108863 | spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 108152 | 108864 | } |
| 108865 | +#line 2878 "parse.c" | |
| 108153 | 108866 | break; |
| 108154 | 108867 | case 190: /* expr ::= nm DOT nm DOT nm */ |
| 108868 | +#line 754 "parse.y" | |
| 108155 | 108869 | { |
| 108156 | 108870 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 108157 | 108871 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 108158 | 108872 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 108159 | 108873 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 108160 | 108874 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 108161 | 108875 | spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 108162 | 108876 | } |
| 108877 | +#line 2890 "parse.c" | |
| 108163 | 108878 | break; |
| 108164 | 108879 | case 193: /* expr ::= REGISTER */ |
| 108880 | +#line 764 "parse.y" | |
| 108165 | 108881 | { |
| 108166 | 108882 | /* When doing a nested parse, one can include terms in an expression |
| 108167 | 108883 | ** that look like this: #1 #2 ... These terms refer to registers |
| 108168 | 108884 | ** in the virtual machine. #N is the N-th register. */ |
| 108169 | 108885 | if( pParse->nested==0 ){ |
| @@ -108173,32 +108889,40 @@ | ||
| 108173 | 108889 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0); |
| 108174 | 108890 | if( yygotominor.yy118.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy118.pExpr->iTable); |
| 108175 | 108891 | } |
| 108176 | 108892 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108177 | 108893 | } |
| 108894 | +#line 2907 "parse.c" | |
| 108178 | 108895 | break; |
| 108179 | 108896 | case 194: /* expr ::= VARIABLE */ |
| 108897 | +#line 777 "parse.y" | |
| 108180 | 108898 | { |
| 108181 | 108899 | spanExpr(&yygotominor.yy118, pParse, TK_VARIABLE, &yymsp[0].minor.yy0); |
| 108182 | 108900 | sqlite3ExprAssignVarNumber(pParse, yygotominor.yy118.pExpr); |
| 108183 | 108901 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108184 | 108902 | } |
| 108903 | +#line 2916 "parse.c" | |
| 108185 | 108904 | break; |
| 108186 | 108905 | case 195: /* expr ::= expr COLLATE ids */ |
| 108906 | +#line 782 "parse.y" | |
| 108187 | 108907 | { |
| 108188 | 108908 | yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy118.pExpr, &yymsp[0].minor.yy0); |
| 108189 | 108909 | yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 108190 | 108910 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108191 | 108911 | } |
| 108912 | +#line 2925 "parse.c" | |
| 108192 | 108913 | break; |
| 108193 | 108914 | case 196: /* expr ::= CAST LP expr AS typetoken RP */ |
| 108915 | +#line 788 "parse.y" | |
| 108194 | 108916 | { |
| 108195 | 108917 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, &yymsp[-1].minor.yy0); |
| 108196 | 108918 | spanSet(&yygotominor.yy118,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 108197 | 108919 | } |
| 108920 | +#line 2933 "parse.c" | |
| 108198 | 108921 | break; |
| 108199 | 108922 | case 197: /* expr ::= ID LP distinct exprlist RP */ |
| 108923 | +#line 793 "parse.y" | |
| 108200 | 108924 | { |
| 108201 | 108925 | if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 108202 | 108926 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 108203 | 108927 | } |
| 108204 | 108928 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| @@ -108205,47 +108929,59 @@ | ||
| 108205 | 108929 | spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 108206 | 108930 | if( yymsp[-2].minor.yy4 && yygotominor.yy118.pExpr ){ |
| 108207 | 108931 | yygotominor.yy118.pExpr->flags |= EP_Distinct; |
| 108208 | 108932 | } |
| 108209 | 108933 | } |
| 108934 | +#line 2947 "parse.c" | |
| 108210 | 108935 | break; |
| 108211 | 108936 | case 198: /* expr ::= ID LP STAR RP */ |
| 108937 | +#line 803 "parse.y" | |
| 108212 | 108938 | { |
| 108213 | 108939 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 108214 | 108940 | spanSet(&yygotominor.yy118,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 108215 | 108941 | } |
| 108942 | +#line 2955 "parse.c" | |
| 108216 | 108943 | break; |
| 108217 | 108944 | case 199: /* term ::= CTIME_KW */ |
| 108945 | +#line 807 "parse.y" | |
| 108218 | 108946 | { |
| 108219 | 108947 | /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are |
| 108220 | 108948 | ** treated as functions that return constants */ |
| 108221 | 108949 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0); |
| 108222 | 108950 | if( yygotominor.yy118.pExpr ){ |
| 108223 | 108951 | yygotominor.yy118.pExpr->op = TK_CONST_FUNC; |
| 108224 | 108952 | } |
| 108225 | 108953 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108226 | 108954 | } |
| 108955 | +#line 2968 "parse.c" | |
| 108227 | 108956 | break; |
| 108228 | 108957 | case 200: /* expr ::= expr AND expr */ |
| 108229 | 108958 | case 201: /* expr ::= expr OR expr */ yytestcase(yyruleno==201); |
| 108230 | 108959 | case 202: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==202); |
| 108231 | 108960 | case 203: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==203); |
| 108232 | 108961 | case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==204); |
| 108233 | 108962 | case 205: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==205); |
| 108234 | 108963 | case 206: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==206); |
| 108235 | 108964 | case 207: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==207); |
| 108965 | +#line 834 "parse.y" | |
| 108236 | 108966 | {spanBinaryExpr(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118);} |
| 108967 | +#line 2980 "parse.c" | |
| 108237 | 108968 | break; |
| 108238 | 108969 | case 208: /* likeop ::= LIKE_KW */ |
| 108239 | 108970 | case 210: /* likeop ::= MATCH */ yytestcase(yyruleno==210); |
| 108971 | +#line 847 "parse.y" | |
| 108240 | 108972 | {yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 0;} |
| 108973 | +#line 2986 "parse.c" | |
| 108241 | 108974 | break; |
| 108242 | 108975 | case 209: /* likeop ::= NOT LIKE_KW */ |
| 108243 | 108976 | case 211: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==211); |
| 108977 | +#line 848 "parse.y" | |
| 108244 | 108978 | {yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 1;} |
| 108979 | +#line 2992 "parse.c" | |
| 108245 | 108980 | break; |
| 108246 | 108981 | case 212: /* expr ::= expr likeop expr */ |
| 108982 | +#line 851 "parse.y" | |
| 108247 | 108983 | { |
| 108248 | 108984 | ExprList *pList; |
| 108249 | 108985 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy118.pExpr); |
| 108250 | 108986 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy118.pExpr); |
| 108251 | 108987 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy342.eOperator); |
| @@ -108252,12 +108988,14 @@ | ||
| 108252 | 108988 | if( yymsp[-1].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108253 | 108989 | yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 108254 | 108990 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108255 | 108991 | if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 108256 | 108992 | } |
| 108993 | +#line 3006 "parse.c" | |
| 108257 | 108994 | break; |
| 108258 | 108995 | case 213: /* expr ::= expr likeop expr ESCAPE expr */ |
| 108996 | +#line 861 "parse.y" | |
| 108259 | 108997 | { |
| 108260 | 108998 | ExprList *pList; |
| 108261 | 108999 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 108262 | 109000 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy118.pExpr); |
| 108263 | 109001 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| @@ -108265,40 +109003,56 @@ | ||
| 108265 | 109003 | if( yymsp[-3].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108266 | 109004 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108267 | 109005 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108268 | 109006 | if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 108269 | 109007 | } |
| 109008 | +#line 3021 "parse.c" | |
| 108270 | 109009 | break; |
| 108271 | 109010 | case 214: /* expr ::= expr ISNULL|NOTNULL */ |
| 109011 | +#line 889 "parse.y" | |
| 108272 | 109012 | {spanUnaryPostfix(&yygotominor.yy118,pParse,yymsp[0].major,&yymsp[-1].minor.yy118,&yymsp[0].minor.yy0);} |
| 109013 | +#line 3026 "parse.c" | |
| 108273 | 109014 | break; |
| 108274 | 109015 | case 215: /* expr ::= expr NOT NULL */ |
| 109016 | +#line 890 "parse.y" | |
| 108275 | 109017 | {spanUnaryPostfix(&yygotominor.yy118,pParse,TK_NOTNULL,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy0);} |
| 109018 | +#line 3031 "parse.c" | |
| 108276 | 109019 | break; |
| 108277 | 109020 | case 216: /* expr ::= expr IS expr */ |
| 109021 | +#line 911 "parse.y" | |
| 108278 | 109022 | { |
| 108279 | 109023 | spanBinaryExpr(&yygotominor.yy118,pParse,TK_IS,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118); |
| 108280 | 109024 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL); |
| 108281 | 109025 | } |
| 109026 | +#line 3039 "parse.c" | |
| 108282 | 109027 | break; |
| 108283 | 109028 | case 217: /* expr ::= expr IS NOT expr */ |
| 109029 | +#line 915 "parse.y" | |
| 108284 | 109030 | { |
| 108285 | 109031 | spanBinaryExpr(&yygotominor.yy118,pParse,TK_ISNOT,&yymsp[-3].minor.yy118,&yymsp[0].minor.yy118); |
| 108286 | 109032 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL); |
| 108287 | 109033 | } |
| 109034 | +#line 3047 "parse.c" | |
| 108288 | 109035 | break; |
| 108289 | 109036 | case 218: /* expr ::= NOT expr */ |
| 108290 | 109037 | case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219); |
| 109038 | +#line 938 "parse.y" | |
| 108291 | 109039 | {spanUnaryPrefix(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 109040 | +#line 3053 "parse.c" | |
| 108292 | 109041 | break; |
| 108293 | 109042 | case 220: /* expr ::= MINUS expr */ |
| 109043 | +#line 941 "parse.y" | |
| 108294 | 109044 | {spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UMINUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 109045 | +#line 3058 "parse.c" | |
| 108295 | 109046 | break; |
| 108296 | 109047 | case 221: /* expr ::= PLUS expr */ |
| 109048 | +#line 943 "parse.y" | |
| 108297 | 109049 | {spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UPLUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 109050 | +#line 3063 "parse.c" | |
| 108298 | 109051 | break; |
| 108299 | 109052 | case 224: /* expr ::= expr between_op expr AND expr */ |
| 109053 | +#line 948 "parse.y" | |
| 108300 | 109054 | { |
| 108301 | 109055 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 108302 | 109056 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| 108303 | 109057 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 108304 | 109058 | if( yygotominor.yy118.pExpr ){ |
| @@ -108308,12 +109062,14 @@ | ||
| 108308 | 109062 | } |
| 108309 | 109063 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108310 | 109064 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108311 | 109065 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108312 | 109066 | } |
| 109067 | +#line 3080 "parse.c" | |
| 108313 | 109068 | break; |
| 108314 | 109069 | case 227: /* expr ::= expr in_op LP exprlist RP */ |
| 109070 | +#line 965 "parse.y" | |
| 108315 | 109071 | { |
| 108316 | 109072 | if( yymsp[-1].minor.yy322==0 ){ |
| 108317 | 109073 | /* Expressions of the form |
| 108318 | 109074 | ** |
| 108319 | 109075 | ** expr1 IN () |
| @@ -108335,12 +109091,14 @@ | ||
| 108335 | 109091 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108336 | 109092 | } |
| 108337 | 109093 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108338 | 109094 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108339 | 109095 | } |
| 109096 | +#line 3109 "parse.c" | |
| 108340 | 109097 | break; |
| 108341 | 109098 | case 228: /* expr ::= LP select RP */ |
| 109099 | +#line 990 "parse.y" | |
| 108342 | 109100 | { |
| 108343 | 109101 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 108344 | 109102 | if( yygotominor.yy118.pExpr ){ |
| 108345 | 109103 | yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 108346 | 109104 | ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| @@ -108349,12 +109107,14 @@ | ||
| 108349 | 109107 | sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 108350 | 109108 | } |
| 108351 | 109109 | yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; |
| 108352 | 109110 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108353 | 109111 | } |
| 109112 | +#line 3125 "parse.c" | |
| 108354 | 109113 | break; |
| 108355 | 109114 | case 229: /* expr ::= expr in_op LP select RP */ |
| 109115 | +#line 1002 "parse.y" | |
| 108356 | 109116 | { |
| 108357 | 109117 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 108358 | 109118 | if( yygotominor.yy118.pExpr ){ |
| 108359 | 109119 | yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 108360 | 109120 | ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| @@ -108364,12 +109124,14 @@ | ||
| 108364 | 109124 | } |
| 108365 | 109125 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108366 | 109126 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108367 | 109127 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108368 | 109128 | } |
| 109129 | +#line 3142 "parse.c" | |
| 108369 | 109130 | break; |
| 108370 | 109131 | case 230: /* expr ::= expr in_op nm dbnm */ |
| 109132 | +#line 1015 "parse.y" | |
| 108371 | 109133 | { |
| 108372 | 109134 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 108373 | 109135 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0); |
| 108374 | 109136 | if( yygotominor.yy118.pExpr ){ |
| 108375 | 109137 | yygotominor.yy118.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| @@ -108380,12 +109142,14 @@ | ||
| 108380 | 109142 | } |
| 108381 | 109143 | if( yymsp[-2].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108382 | 109144 | yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; |
| 108383 | 109145 | yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]; |
| 108384 | 109146 | } |
| 109147 | +#line 3160 "parse.c" | |
| 108385 | 109148 | break; |
| 108386 | 109149 | case 231: /* expr ::= EXISTS LP select RP */ |
| 109150 | +#line 1029 "parse.y" | |
| 108387 | 109151 | { |
| 108388 | 109152 | Expr *p = yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 108389 | 109153 | if( p ){ |
| 108390 | 109154 | p->x.pSelect = yymsp[-1].minor.yy387; |
| 108391 | 109155 | ExprSetProperty(p, EP_xIsSelect); |
| @@ -108394,12 +109158,14 @@ | ||
| 108394 | 109158 | sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 108395 | 109159 | } |
| 108396 | 109160 | yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 108397 | 109161 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108398 | 109162 | } |
| 109163 | +#line 3176 "parse.c" | |
| 108399 | 109164 | break; |
| 108400 | 109165 | case 232: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 109166 | +#line 1044 "parse.y" | |
| 108401 | 109167 | { |
| 108402 | 109168 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0); |
| 108403 | 109169 | if( yygotominor.yy118.pExpr ){ |
| 108404 | 109170 | yygotominor.yy118.pExpr->x.pList = yymsp[-2].minor.yy322; |
| 108405 | 109171 | sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| @@ -108407,38 +109173,50 @@ | ||
| 108407 | 109173 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322); |
| 108408 | 109174 | } |
| 108409 | 109175 | yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; |
| 108410 | 109176 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108411 | 109177 | } |
| 109178 | +#line 3191 "parse.c" | |
| 108412 | 109179 | break; |
| 108413 | 109180 | case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 109181 | +#line 1057 "parse.y" | |
| 108414 | 109182 | { |
| 108415 | 109183 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr); |
| 108416 | 109184 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 108417 | 109185 | } |
| 109186 | +#line 3199 "parse.c" | |
| 108418 | 109187 | break; |
| 108419 | 109188 | case 234: /* case_exprlist ::= WHEN expr THEN expr */ |
| 109189 | +#line 1061 "parse.y" | |
| 108420 | 109190 | { |
| 108421 | 109191 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 108422 | 109192 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 108423 | 109193 | } |
| 109194 | +#line 3207 "parse.c" | |
| 108424 | 109195 | break; |
| 108425 | 109196 | case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ |
| 109197 | +#line 1090 "parse.y" | |
| 108426 | 109198 | { |
| 108427 | 109199 | sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, |
| 108428 | 109200 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4, |
| 108429 | 109201 | &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4); |
| 108430 | 109202 | } |
| 109203 | +#line 3216 "parse.c" | |
| 108431 | 109204 | break; |
| 108432 | 109205 | case 244: /* uniqueflag ::= UNIQUE */ |
| 108433 | 109206 | case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298); |
| 109207 | +#line 1097 "parse.y" | |
| 108434 | 109208 | {yygotominor.yy4 = OE_Abort;} |
| 109209 | +#line 3222 "parse.c" | |
| 108435 | 109210 | break; |
| 108436 | 109211 | case 245: /* uniqueflag ::= */ |
| 109212 | +#line 1098 "parse.y" | |
| 108437 | 109213 | {yygotominor.yy4 = OE_None;} |
| 109214 | +#line 3227 "parse.c" | |
| 108438 | 109215 | break; |
| 108439 | 109216 | case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 109217 | +#line 1107 "parse.y" | |
| 108440 | 109218 | { |
| 108441 | 109219 | Expr *p = 0; |
| 108442 | 109220 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 108443 | 109221 | p = sqlite3Expr(pParse->db, TK_COLUMN, 0); |
| 108444 | 109222 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -108446,12 +109224,14 @@ | ||
| 108446 | 109224 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, p); |
| 108447 | 109225 | sqlite3ExprListSetName(pParse,yygotominor.yy322,&yymsp[-2].minor.yy0,1); |
| 108448 | 109226 | sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 108449 | 109227 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108450 | 109228 | } |
| 109229 | +#line 3242 "parse.c" | |
| 108451 | 109230 | break; |
| 108452 | 109231 | case 249: /* idxlist ::= nm collate sortorder */ |
| 109232 | +#line 1118 "parse.y" | |
| 108453 | 109233 | { |
| 108454 | 109234 | Expr *p = 0; |
| 108455 | 109235 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 108456 | 109236 | p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); |
| 108457 | 109237 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -108459,214 +109239,307 @@ | ||
| 108459 | 109239 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, p); |
| 108460 | 109240 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108461 | 109241 | sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 108462 | 109242 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108463 | 109243 | } |
| 109244 | +#line 3257 "parse.c" | |
| 108464 | 109245 | break; |
| 108465 | 109246 | case 250: /* collate ::= */ |
| 109247 | +#line 1131 "parse.y" | |
| 108466 | 109248 | {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;} |
| 109249 | +#line 3262 "parse.c" | |
| 108467 | 109250 | break; |
| 108468 | 109251 | case 252: /* cmd ::= DROP INDEX ifexists fullname */ |
| 109252 | +#line 1137 "parse.y" | |
| 108469 | 109253 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);} |
| 109254 | +#line 3267 "parse.c" | |
| 108470 | 109255 | break; |
| 108471 | 109256 | case 253: /* cmd ::= VACUUM */ |
| 108472 | 109257 | case 254: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==254); |
| 109258 | +#line 1143 "parse.y" | |
| 108473 | 109259 | {sqlite3Vacuum(pParse);} |
| 109260 | +#line 3273 "parse.c" | |
| 108474 | 109261 | break; |
| 108475 | 109262 | case 255: /* cmd ::= PRAGMA nm dbnm */ |
| 109263 | +#line 1151 "parse.y" | |
| 108476 | 109264 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 109265 | +#line 3278 "parse.c" | |
| 108477 | 109266 | break; |
| 108478 | 109267 | case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 109268 | +#line 1152 "parse.y" | |
| 108479 | 109269 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 109270 | +#line 3283 "parse.c" | |
| 108480 | 109271 | break; |
| 108481 | 109272 | case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 109273 | +#line 1153 "parse.y" | |
| 108482 | 109274 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 109275 | +#line 3288 "parse.c" | |
| 108483 | 109276 | break; |
| 108484 | 109277 | case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 109278 | +#line 1155 "parse.y" | |
| 108485 | 109279 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 109280 | +#line 3293 "parse.c" | |
| 108486 | 109281 | break; |
| 108487 | 109282 | case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 109283 | +#line 1157 "parse.y" | |
| 108488 | 109284 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 109285 | +#line 3298 "parse.c" | |
| 108489 | 109286 | break; |
| 108490 | 109287 | case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 109288 | +#line 1175 "parse.y" | |
| 108491 | 109289 | { |
| 108492 | 109290 | Token all; |
| 108493 | 109291 | all.z = yymsp[-3].minor.yy0.z; |
| 108494 | 109292 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 108495 | 109293 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all); |
| 108496 | 109294 | } |
| 109295 | +#line 3308 "parse.c" | |
| 108497 | 109296 | break; |
| 108498 | 109297 | case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 109298 | +#line 1184 "parse.y" | |
| 108499 | 109299 | { |
| 108500 | 109300 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4); |
| 108501 | 109301 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 108502 | 109302 | } |
| 109303 | +#line 3316 "parse.c" | |
| 108503 | 109304 | break; |
| 108504 | 109305 | case 272: /* trigger_time ::= BEFORE */ |
| 108505 | 109306 | case 275: /* trigger_time ::= */ yytestcase(yyruleno==275); |
| 109307 | +#line 1190 "parse.y" | |
| 108506 | 109308 | { yygotominor.yy4 = TK_BEFORE; } |
| 109309 | +#line 3322 "parse.c" | |
| 108507 | 109310 | break; |
| 108508 | 109311 | case 273: /* trigger_time ::= AFTER */ |
| 109312 | +#line 1191 "parse.y" | |
| 108509 | 109313 | { yygotominor.yy4 = TK_AFTER; } |
| 109314 | +#line 3327 "parse.c" | |
| 108510 | 109315 | break; |
| 108511 | 109316 | case 274: /* trigger_time ::= INSTEAD OF */ |
| 109317 | +#line 1192 "parse.y" | |
| 108512 | 109318 | { yygotominor.yy4 = TK_INSTEAD;} |
| 109319 | +#line 3332 "parse.c" | |
| 108513 | 109320 | break; |
| 108514 | 109321 | case 276: /* trigger_event ::= DELETE|INSERT */ |
| 108515 | 109322 | case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277); |
| 109323 | +#line 1197 "parse.y" | |
| 108516 | 109324 | {yygotominor.yy90.a = yymsp[0].major; yygotominor.yy90.b = 0;} |
| 109325 | +#line 3338 "parse.c" | |
| 108517 | 109326 | break; |
| 108518 | 109327 | case 278: /* trigger_event ::= UPDATE OF inscollist */ |
| 109328 | +#line 1199 "parse.y" | |
| 108519 | 109329 | {yygotominor.yy90.a = TK_UPDATE; yygotominor.yy90.b = yymsp[0].minor.yy384;} |
| 109330 | +#line 3343 "parse.c" | |
| 108520 | 109331 | break; |
| 108521 | 109332 | case 281: /* when_clause ::= */ |
| 108522 | 109333 | case 303: /* key_opt ::= */ yytestcase(yyruleno==303); |
| 109334 | +#line 1206 "parse.y" | |
| 108523 | 109335 | { yygotominor.yy314 = 0; } |
| 109336 | +#line 3349 "parse.c" | |
| 108524 | 109337 | break; |
| 108525 | 109338 | case 282: /* when_clause ::= WHEN expr */ |
| 108526 | 109339 | case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304); |
| 109340 | +#line 1207 "parse.y" | |
| 108527 | 109341 | { yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; } |
| 109342 | +#line 3355 "parse.c" | |
| 108528 | 109343 | break; |
| 108529 | 109344 | case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 109345 | +#line 1211 "parse.y" | |
| 108530 | 109346 | { |
| 108531 | 109347 | assert( yymsp[-2].minor.yy203!=0 ); |
| 108532 | 109348 | yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203; |
| 108533 | 109349 | yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 108534 | 109350 | yygotominor.yy203 = yymsp[-2].minor.yy203; |
| 108535 | 109351 | } |
| 109352 | +#line 3365 "parse.c" | |
| 108536 | 109353 | break; |
| 108537 | 109354 | case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 109355 | +#line 1217 "parse.y" | |
| 108538 | 109356 | { |
| 108539 | 109357 | assert( yymsp[-1].minor.yy203!=0 ); |
| 108540 | 109358 | yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 108541 | 109359 | yygotominor.yy203 = yymsp[-1].minor.yy203; |
| 108542 | 109360 | } |
| 109361 | +#line 3374 "parse.c" | |
| 108543 | 109362 | break; |
| 108544 | 109363 | case 286: /* trnm ::= nm DOT nm */ |
| 109364 | +#line 1229 "parse.y" | |
| 108545 | 109365 | { |
| 108546 | 109366 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 108547 | 109367 | sqlite3ErrorMsg(pParse, |
| 108548 | 109368 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 108549 | 109369 | "statements within triggers"); |
| 108550 | 109370 | } |
| 109371 | +#line 3384 "parse.c" | |
| 108551 | 109372 | break; |
| 108552 | 109373 | case 288: /* tridxby ::= INDEXED BY nm */ |
| 109374 | +#line 1241 "parse.y" | |
| 108553 | 109375 | { |
| 108554 | 109376 | sqlite3ErrorMsg(pParse, |
| 108555 | 109377 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 108556 | 109378 | "within triggers"); |
| 108557 | 109379 | } |
| 109380 | +#line 3393 "parse.c" | |
| 108558 | 109381 | break; |
| 108559 | 109382 | case 289: /* tridxby ::= NOT INDEXED */ |
| 109383 | +#line 1246 "parse.y" | |
| 108560 | 109384 | { |
| 108561 | 109385 | sqlite3ErrorMsg(pParse, |
| 108562 | 109386 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 108563 | 109387 | "within triggers"); |
| 108564 | 109388 | } |
| 109389 | +#line 3402 "parse.c" | |
| 108565 | 109390 | break; |
| 108566 | 109391 | case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 109392 | +#line 1259 "parse.y" | |
| 108567 | 109393 | { yygotominor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); } |
| 109394 | +#line 3407 "parse.c" | |
| 108568 | 109395 | break; |
| 108569 | 109396 | case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */ |
| 109397 | +#line 1264 "parse.y" | |
| 108570 | 109398 | {yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210);} |
| 109399 | +#line 3412 "parse.c" | |
| 108571 | 109400 | break; |
| 108572 | 109401 | case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 109402 | +#line 1267 "parse.y" | |
| 108573 | 109403 | {yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210);} |
| 109404 | +#line 3417 "parse.c" | |
| 108574 | 109405 | break; |
| 108575 | 109406 | case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 109407 | +#line 1271 "parse.y" | |
| 108576 | 109408 | {yygotominor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy314);} |
| 109409 | +#line 3422 "parse.c" | |
| 108577 | 109410 | break; |
| 108578 | 109411 | case 294: /* trigger_cmd ::= select */ |
| 109412 | +#line 1274 "parse.y" | |
| 108579 | 109413 | {yygotominor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy387); } |
| 109414 | +#line 3427 "parse.c" | |
| 108580 | 109415 | break; |
| 108581 | 109416 | case 295: /* expr ::= RAISE LP IGNORE RP */ |
| 109417 | +#line 1277 "parse.y" | |
| 108582 | 109418 | { |
| 108583 | 109419 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 108584 | 109420 | if( yygotominor.yy118.pExpr ){ |
| 108585 | 109421 | yygotominor.yy118.pExpr->affinity = OE_Ignore; |
| 108586 | 109422 | } |
| 108587 | 109423 | yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 108588 | 109424 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108589 | 109425 | } |
| 109426 | +#line 3439 "parse.c" | |
| 108590 | 109427 | break; |
| 108591 | 109428 | case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 109429 | +#line 1285 "parse.y" | |
| 108592 | 109430 | { |
| 108593 | 109431 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 108594 | 109432 | if( yygotominor.yy118.pExpr ) { |
| 108595 | 109433 | yygotominor.yy118.pExpr->affinity = (char)yymsp[-3].minor.yy4; |
| 108596 | 109434 | } |
| 108597 | 109435 | yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; |
| 108598 | 109436 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108599 | 109437 | } |
| 109438 | +#line 3451 "parse.c" | |
| 108600 | 109439 | break; |
| 108601 | 109440 | case 297: /* raisetype ::= ROLLBACK */ |
| 109441 | +#line 1296 "parse.y" | |
| 108602 | 109442 | {yygotominor.yy4 = OE_Rollback;} |
| 109443 | +#line 3456 "parse.c" | |
| 108603 | 109444 | break; |
| 108604 | 109445 | case 299: /* raisetype ::= FAIL */ |
| 109446 | +#line 1298 "parse.y" | |
| 108605 | 109447 | {yygotominor.yy4 = OE_Fail;} |
| 109448 | +#line 3461 "parse.c" | |
| 108606 | 109449 | break; |
| 108607 | 109450 | case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 109451 | +#line 1303 "parse.y" | |
| 108608 | 109452 | { |
| 108609 | 109453 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4); |
| 108610 | 109454 | } |
| 109455 | +#line 3468 "parse.c" | |
| 108611 | 109456 | break; |
| 108612 | 109457 | case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 109458 | +#line 1310 "parse.y" | |
| 108613 | 109459 | { |
| 108614 | 109460 | sqlite3Attach(pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314); |
| 108615 | 109461 | } |
| 109462 | +#line 3475 "parse.c" | |
| 108616 | 109463 | break; |
| 108617 | 109464 | case 302: /* cmd ::= DETACH database_kw_opt expr */ |
| 109465 | +#line 1313 "parse.y" | |
| 108618 | 109466 | { |
| 108619 | 109467 | sqlite3Detach(pParse, yymsp[0].minor.yy118.pExpr); |
| 108620 | 109468 | } |
| 109469 | +#line 3482 "parse.c" | |
| 108621 | 109470 | break; |
| 108622 | 109471 | case 307: /* cmd ::= REINDEX */ |
| 109472 | +#line 1328 "parse.y" | |
| 108623 | 109473 | {sqlite3Reindex(pParse, 0, 0);} |
| 109474 | +#line 3487 "parse.c" | |
| 108624 | 109475 | break; |
| 108625 | 109476 | case 308: /* cmd ::= REINDEX nm dbnm */ |
| 109477 | +#line 1329 "parse.y" | |
| 108626 | 109478 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 109479 | +#line 3492 "parse.c" | |
| 108627 | 109480 | break; |
| 108628 | 109481 | case 309: /* cmd ::= ANALYZE */ |
| 109482 | +#line 1334 "parse.y" | |
| 108629 | 109483 | {sqlite3Analyze(pParse, 0, 0);} |
| 109484 | +#line 3497 "parse.c" | |
| 108630 | 109485 | break; |
| 108631 | 109486 | case 310: /* cmd ::= ANALYZE nm dbnm */ |
| 109487 | +#line 1335 "parse.y" | |
| 108632 | 109488 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 109489 | +#line 3502 "parse.c" | |
| 108633 | 109490 | break; |
| 108634 | 109491 | case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 109492 | +#line 1340 "parse.y" | |
| 108635 | 109493 | { |
| 108636 | 109494 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0); |
| 108637 | 109495 | } |
| 109496 | +#line 3509 "parse.c" | |
| 108638 | 109497 | break; |
| 108639 | 109498 | case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 109499 | +#line 1343 "parse.y" | |
| 108640 | 109500 | { |
| 108641 | 109501 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 108642 | 109502 | } |
| 109503 | +#line 3516 "parse.c" | |
| 108643 | 109504 | break; |
| 108644 | 109505 | case 313: /* add_column_fullname ::= fullname */ |
| 109506 | +#line 1346 "parse.y" | |
| 108645 | 109507 | { |
| 108646 | 109508 | pParse->db->lookaside.bEnabled = 0; |
| 108647 | 109509 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259); |
| 108648 | 109510 | } |
| 109511 | +#line 3524 "parse.c" | |
| 108649 | 109512 | break; |
| 108650 | 109513 | case 316: /* cmd ::= create_vtab */ |
| 109514 | +#line 1356 "parse.y" | |
| 108651 | 109515 | {sqlite3VtabFinishParse(pParse,0);} |
| 109516 | +#line 3529 "parse.c" | |
| 108652 | 109517 | break; |
| 108653 | 109518 | case 317: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 109519 | +#line 1357 "parse.y" | |
| 108654 | 109520 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 109521 | +#line 3534 "parse.c" | |
| 108655 | 109522 | break; |
| 108656 | 109523 | case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */ |
| 109524 | +#line 1358 "parse.y" | |
| 108657 | 109525 | { |
| 108658 | 109526 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 108659 | 109527 | } |
| 109528 | +#line 3541 "parse.c" | |
| 108660 | 109529 | break; |
| 108661 | 109530 | case 321: /* vtabarg ::= */ |
| 109531 | +#line 1363 "parse.y" | |
| 108662 | 109532 | {sqlite3VtabArgInit(pParse);} |
| 109533 | +#line 3546 "parse.c" | |
| 108663 | 109534 | break; |
| 108664 | 109535 | case 323: /* vtabargtoken ::= ANY */ |
| 108665 | 109536 | case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324); |
| 108666 | 109537 | case 325: /* lp ::= LP */ yytestcase(yyruleno==325); |
| 109538 | +#line 1365 "parse.y" | |
| 108667 | 109539 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 109540 | +#line 3553 "parse.c" | |
| 108668 | 109541 | break; |
| 108669 | 109542 | default: |
| 108670 | 109543 | /* (0) input ::= cmdlist */ yytestcase(yyruleno==0); |
| 108671 | 109544 | /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1); |
| 108672 | 109545 | /* (2) cmdlist ::= ecmd */ yytestcase(yyruleno==2); |
| @@ -108764,15 +109637,17 @@ | ||
| 108764 | 109637 | int yymajor, /* The major type of the error token */ |
| 108765 | 109638 | YYMINORTYPE yyminor /* The minor type of the error token */ |
| 108766 | 109639 | ){ |
| 108767 | 109640 | sqlite3ParserARG_FETCH; |
| 108768 | 109641 | #define TOKEN (yyminor.yy0) |
| 109642 | +#line 32 "parse.y" | |
| 108769 | 109643 | |
| 108770 | 109644 | UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ |
| 108771 | 109645 | assert( TOKEN.z[0] ); /* The tokenizer always gives us a token */ |
| 108772 | 109646 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); |
| 108773 | 109647 | pParse->parseError = 1; |
| 109648 | +#line 3661 "parse.c" | |
| 108774 | 109649 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| 108775 | 109650 | } |
| 108776 | 109651 | |
| 108777 | 109652 | /* |
| 108778 | 109653 | ** The following is executed when the parser accepts |
| @@ -108962,10 +109837,11 @@ | ||
| 108962 | 109837 | return; |
| 108963 | 109838 | } |
| 108964 | 109839 | |
| 108965 | 109840 | /************** End of parse.c ***********************************************/ |
| 108966 | 109841 | /************** Begin file tokenize.c ****************************************/ |
| 109842 | +#line 1 "tsrc/tokenize.c" | |
| 108967 | 109843 | /* |
| 108968 | 109844 | ** 2001 September 15 |
| 108969 | 109845 | ** |
| 108970 | 109846 | ** The author disclaims copyright to this source code. In place of |
| 108971 | 109847 | ** a legal notice, here is a blessing: |
| @@ -109027,10 +109903,11 @@ | ||
| 109027 | 109903 | ** named keywordhash.h and then included into this source file by |
| 109028 | 109904 | ** the #include below. |
| 109029 | 109905 | */ |
| 109030 | 109906 | /************** Include keywordhash.h in the middle of tokenize.c ************/ |
| 109031 | 109907 | /************** Begin file keywordhash.h *************************************/ |
| 109908 | +#line 1 "tsrc/keywordhash.h" | |
| 109032 | 109909 | /***** This file contains automatically generated code ****** |
| 109033 | 109910 | ** |
| 109034 | 109911 | ** The code in this file has been automatically generated by |
| 109035 | 109912 | ** |
| 109036 | 109913 | ** sqlite/tool/mkkeywordhash.c |
| @@ -109300,10 +110177,11 @@ | ||
| 109300 | 110177 | } |
| 109301 | 110178 | #define SQLITE_N_KEYWORD 121 |
| 109302 | 110179 | |
| 109303 | 110180 | /************** End of keywordhash.h *****************************************/ |
| 109304 | 110181 | /************** Continuing where we left off in tokenize.c *******************/ |
| 110182 | +#line 66 "tsrc/tokenize.c" | |
| 109305 | 110183 | |
| 109306 | 110184 | |
| 109307 | 110185 | /* |
| 109308 | 110186 | ** If X is a character that can be used in an identifier then |
| 109309 | 110187 | ** IdChar(X) will be true. Otherwise it is false. |
| @@ -109764,10 +110642,11 @@ | ||
| 109764 | 110642 | return nErr; |
| 109765 | 110643 | } |
| 109766 | 110644 | |
| 109767 | 110645 | /************** End of tokenize.c ********************************************/ |
| 109768 | 110646 | /************** Begin file complete.c ****************************************/ |
| 110647 | +#line 1 "tsrc/complete.c" | |
| 109769 | 110648 | /* |
| 109770 | 110649 | ** 2001 September 15 |
| 109771 | 110650 | ** |
| 109772 | 110651 | ** The author disclaims copyright to this source code. In place of |
| 109773 | 110652 | ** a legal notice, here is a blessing: |
| @@ -110049,10 +110928,11 @@ | ||
| 110049 | 110928 | #endif /* SQLITE_OMIT_UTF16 */ |
| 110050 | 110929 | #endif /* SQLITE_OMIT_COMPLETE */ |
| 110051 | 110930 | |
| 110052 | 110931 | /************** End of complete.c ********************************************/ |
| 110053 | 110932 | /************** Begin file main.c ********************************************/ |
| 110933 | +#line 1 "tsrc/main.c" | |
| 110054 | 110934 | /* |
| 110055 | 110935 | ** 2001 September 15 |
| 110056 | 110936 | ** |
| 110057 | 110937 | ** The author disclaims copyright to this source code. In place of |
| 110058 | 110938 | ** a legal notice, here is a blessing: |
| @@ -110069,10 +110949,11 @@ | ||
| 110069 | 110949 | */ |
| 110070 | 110950 | |
| 110071 | 110951 | #ifdef SQLITE_ENABLE_FTS3 |
| 110072 | 110952 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 110073 | 110953 | /************** Begin file fts3.h ********************************************/ |
| 110954 | +#line 1 "tsrc/fts3.h" | |
| 110074 | 110955 | /* |
| 110075 | 110956 | ** 2006 Oct 10 |
| 110076 | 110957 | ** |
| 110077 | 110958 | ** The author disclaims copyright to this source code. In place of |
| 110078 | 110959 | ** a legal notice, here is a blessing: |
| @@ -110097,14 +110978,16 @@ | ||
| 110097 | 110978 | } /* extern "C" */ |
| 110098 | 110979 | #endif /* __cplusplus */ |
| 110099 | 110980 | |
| 110100 | 110981 | /************** End of fts3.h ************************************************/ |
| 110101 | 110982 | /************** Continuing where we left off in main.c ***********************/ |
| 110983 | +#line 21 "tsrc/main.c" | |
| 110102 | 110984 | #endif |
| 110103 | 110985 | #ifdef SQLITE_ENABLE_RTREE |
| 110104 | 110986 | /************** Include rtree.h in the middle of main.c **********************/ |
| 110105 | 110987 | /************** Begin file rtree.h *******************************************/ |
| 110988 | +#line 1 "tsrc/rtree.h" | |
| 110106 | 110989 | /* |
| 110107 | 110990 | ** 2008 May 26 |
| 110108 | 110991 | ** |
| 110109 | 110992 | ** The author disclaims copyright to this source code. In place of |
| 110110 | 110993 | ** a legal notice, here is a blessing: |
| @@ -110129,14 +111012,16 @@ | ||
| 110129 | 111012 | } /* extern "C" */ |
| 110130 | 111013 | #endif /* __cplusplus */ |
| 110131 | 111014 | |
| 110132 | 111015 | /************** End of rtree.h ***********************************************/ |
| 110133 | 111016 | /************** Continuing where we left off in main.c ***********************/ |
| 111017 | +#line 24 "tsrc/main.c" | |
| 110134 | 111018 | #endif |
| 110135 | 111019 | #ifdef SQLITE_ENABLE_ICU |
| 110136 | 111020 | /************** Include sqliteicu.h in the middle of main.c ******************/ |
| 110137 | 111021 | /************** Begin file sqliteicu.h ***************************************/ |
| 111022 | +#line 1 "tsrc/sqliteicu.h" | |
| 110138 | 111023 | /* |
| 110139 | 111024 | ** 2008 May 26 |
| 110140 | 111025 | ** |
| 110141 | 111026 | ** The author disclaims copyright to this source code. In place of |
| 110142 | 111027 | ** a legal notice, here is a blessing: |
| @@ -110162,10 +111047,11 @@ | ||
| 110162 | 111047 | #endif /* __cplusplus */ |
| 110163 | 111048 | |
| 110164 | 111049 | |
| 110165 | 111050 | /************** End of sqliteicu.h *******************************************/ |
| 110166 | 111051 | /************** Continuing where we left off in main.c ***********************/ |
| 111052 | +#line 27 "tsrc/main.c" | |
| 110167 | 111053 | #endif |
| 110168 | 111054 | |
| 110169 | 111055 | #ifndef SQLITE_AMALGAMATION |
| 110170 | 111056 | /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant |
| 110171 | 111057 | ** contains the text of SQLITE_VERSION macro. |
| @@ -113092,10 +113978,11 @@ | ||
| 113092 | 113978 | return 0; |
| 113093 | 113979 | } |
| 113094 | 113980 | |
| 113095 | 113981 | /************** End of main.c ************************************************/ |
| 113096 | 113982 | /************** Begin file notify.c ******************************************/ |
| 113983 | +#line 1 "tsrc/notify.c" | |
| 113097 | 113984 | /* |
| 113098 | 113985 | ** 2009 March 3 |
| 113099 | 113986 | ** |
| 113100 | 113987 | ** The author disclaims copyright to this source code. In place of |
| 113101 | 113988 | ** a legal notice, here is a blessing: |
| @@ -113425,10 +114312,11 @@ | ||
| 113425 | 114312 | } |
| 113426 | 114313 | #endif |
| 113427 | 114314 | |
| 113428 | 114315 | /************** End of notify.c **********************************************/ |
| 113429 | 114316 | /************** Begin file fts3.c ********************************************/ |
| 114317 | +#line 1 "tsrc/fts3.c" | |
| 113430 | 114318 | /* |
| 113431 | 114319 | ** 2006 Oct 10 |
| 113432 | 114320 | ** |
| 113433 | 114321 | ** The author disclaims copyright to this source code. In place of |
| 113434 | 114322 | ** a legal notice, here is a blessing: |
| @@ -113721,10 +114609,11 @@ | ||
| 113721 | 114609 | ** into a single segment. |
| 113722 | 114610 | */ |
| 113723 | 114611 | |
| 113724 | 114612 | /************** Include fts3Int.h in the middle of fts3.c ********************/ |
| 113725 | 114613 | /************** Begin file fts3Int.h *****************************************/ |
| 114614 | +#line 1 "tsrc/fts3Int.h" | |
| 113726 | 114615 | /* |
| 113727 | 114616 | ** 2009 Nov 12 |
| 113728 | 114617 | ** |
| 113729 | 114618 | ** The author disclaims copyright to this source code. In place of |
| 113730 | 114619 | ** a legal notice, here is a blessing: |
| @@ -113759,10 +114648,11 @@ | ||
| 113759 | 114648 | SQLITE_API extern const sqlite3_api_routines *sqlite3_api; |
| 113760 | 114649 | #endif |
| 113761 | 114650 | |
| 113762 | 114651 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 113763 | 114652 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 114653 | +#line 1 "tsrc/fts3_tokenizer.h" | |
| 113764 | 114654 | /* |
| 113765 | 114655 | ** 2006 July 10 |
| 113766 | 114656 | ** |
| 113767 | 114657 | ** The author disclaims copyright to this source code. |
| 113768 | 114658 | ** |
| @@ -113913,12 +114803,14 @@ | ||
| 113913 | 114803 | |
| 113914 | 114804 | #endif /* _FTS3_TOKENIZER_H_ */ |
| 113915 | 114805 | |
| 113916 | 114806 | /************** End of fts3_tokenizer.h **************************************/ |
| 113917 | 114807 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 114808 | +#line 40 "tsrc/fts3Int.h" | |
| 113918 | 114809 | /************** Include fts3_hash.h in the middle of fts3Int.h ***************/ |
| 113919 | 114810 | /************** Begin file fts3_hash.h ***************************************/ |
| 114811 | +#line 1 "tsrc/fts3_hash.h" | |
| 113920 | 114812 | /* |
| 113921 | 114813 | ** 2001 September 22 |
| 113922 | 114814 | ** |
| 113923 | 114815 | ** The author disclaims copyright to this source code. In place of |
| 113924 | 114816 | ** a legal notice, here is a blessing: |
| @@ -114030,10 +114922,11 @@ | ||
| 114030 | 114922 | |
| 114031 | 114923 | #endif /* _FTS3_HASH_H_ */ |
| 114032 | 114924 | |
| 114033 | 114925 | /************** End of fts3_hash.h *******************************************/ |
| 114034 | 114926 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 114927 | +#line 41 "tsrc/fts3Int.h" | |
| 114035 | 114928 | |
| 114036 | 114929 | /* |
| 114037 | 114930 | ** This constant controls how often segments are merged. Once there are |
| 114038 | 114931 | ** FTS3_MERGE_COUNT segments of level N, they are merged into a single |
| 114039 | 114932 | ** segment of level N+1. |
| @@ -114506,10 +115399,11 @@ | ||
| 114506 | 115399 | #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */ |
| 114507 | 115400 | #endif /* _FTSINT_H */ |
| 114508 | 115401 | |
| 114509 | 115402 | /************** End of fts3Int.h *********************************************/ |
| 114510 | 115403 | /************** Continuing where we left off in fts3.c ***********************/ |
| 115404 | +#line 296 "tsrc/fts3.c" | |
| 114511 | 115405 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 114512 | 115406 | |
| 114513 | 115407 | #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) |
| 114514 | 115408 | # define SQLITE_CORE 1 |
| 114515 | 115409 | #endif |
| @@ -119055,10 +119949,11 @@ | ||
| 119055 | 119949 | |
| 119056 | 119950 | #endif |
| 119057 | 119951 | |
| 119058 | 119952 | /************** End of fts3.c ************************************************/ |
| 119059 | 119953 | /************** Begin file fts3_aux.c ****************************************/ |
| 119954 | +#line 1 "tsrc/fts3_aux.c" | |
| 119060 | 119955 | /* |
| 119061 | 119956 | ** 2011 Jan 27 |
| 119062 | 119957 | ** |
| 119063 | 119958 | ** The author disclaims copyright to this source code. In place of |
| 119064 | 119959 | ** a legal notice, here is a blessing: |
| @@ -119531,10 +120426,11 @@ | ||
| 119531 | 120426 | |
| 119532 | 120427 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 119533 | 120428 | |
| 119534 | 120429 | /************** End of fts3_aux.c ********************************************/ |
| 119535 | 120430 | /************** Begin file fts3_expr.c ***************************************/ |
| 120431 | +#line 1 "tsrc/fts3_expr.c" | |
| 119536 | 120432 | /* |
| 119537 | 120433 | ** 2008 Nov 28 |
| 119538 | 120434 | ** |
| 119539 | 120435 | ** The author disclaims copyright to this source code. In place of |
| 119540 | 120436 | ** a legal notice, here is a blessing: |
| @@ -120497,10 +121393,11 @@ | ||
| 120497 | 121393 | #endif |
| 120498 | 121394 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 120499 | 121395 | |
| 120500 | 121396 | /************** End of fts3_expr.c *******************************************/ |
| 120501 | 121397 | /************** Begin file fts3_hash.c ***************************************/ |
| 121398 | +#line 1 "tsrc/fts3_hash.c" | |
| 120502 | 121399 | /* |
| 120503 | 121400 | ** 2001 September 22 |
| 120504 | 121401 | ** |
| 120505 | 121402 | ** The author disclaims copyright to this source code. In place of |
| 120506 | 121403 | ** a legal notice, here is a blessing: |
| @@ -120881,10 +121778,11 @@ | ||
| 120881 | 121778 | |
| 120882 | 121779 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 120883 | 121780 | |
| 120884 | 121781 | /************** End of fts3_hash.c *******************************************/ |
| 120885 | 121782 | /************** Begin file fts3_porter.c *************************************/ |
| 121783 | +#line 1 "tsrc/fts3_porter.c" | |
| 120886 | 121784 | /* |
| 120887 | 121785 | ** 2006 September 30 |
| 120888 | 121786 | ** |
| 120889 | 121787 | ** The author disclaims copyright to this source code. In place of |
| 120890 | 121788 | ** a legal notice, here is a blessing: |
| @@ -121527,10 +122425,11 @@ | ||
| 121527 | 122425 | |
| 121528 | 122426 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 121529 | 122427 | |
| 121530 | 122428 | /************** End of fts3_porter.c *****************************************/ |
| 121531 | 122429 | /************** Begin file fts3_tokenizer.c **********************************/ |
| 122430 | +#line 1 "tsrc/fts3_tokenizer.c" | |
| 121532 | 122431 | /* |
| 121533 | 122432 | ** 2007 June 22 |
| 121534 | 122433 | ** |
| 121535 | 122434 | ** The author disclaims copyright to this source code. In place of |
| 121536 | 122435 | ** a legal notice, here is a blessing: |
| @@ -122018,10 +122917,11 @@ | ||
| 122018 | 122917 | |
| 122019 | 122918 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 122020 | 122919 | |
| 122021 | 122920 | /************** End of fts3_tokenizer.c **************************************/ |
| 122022 | 122921 | /************** Begin file fts3_tokenizer1.c *********************************/ |
| 122922 | +#line 1 "tsrc/fts3_tokenizer1.c" | |
| 122023 | 122923 | /* |
| 122024 | 122924 | ** 2006 Oct 10 |
| 122025 | 122925 | ** |
| 122026 | 122926 | ** The author disclaims copyright to this source code. In place of |
| 122027 | 122927 | ** a legal notice, here is a blessing: |
| @@ -122252,10 +123152,11 @@ | ||
| 122252 | 123152 | |
| 122253 | 123153 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 122254 | 123154 | |
| 122255 | 123155 | /************** End of fts3_tokenizer1.c *************************************/ |
| 122256 | 123156 | /************** Begin file fts3_write.c **************************************/ |
| 123157 | +#line 1 "tsrc/fts3_write.c" | |
| 122257 | 123158 | /* |
| 122258 | 123159 | ** 2009 Oct 23 |
| 122259 | 123160 | ** |
| 122260 | 123161 | ** The author disclaims copyright to this source code. In place of |
| 122261 | 123162 | ** a legal notice, here is a blessing: |
| @@ -125522,10 +126423,11 @@ | ||
| 125522 | 126423 | |
| 125523 | 126424 | #endif |
| 125524 | 126425 | |
| 125525 | 126426 | /************** End of fts3_write.c ******************************************/ |
| 125526 | 126427 | /************** Begin file fts3_snippet.c ************************************/ |
| 126428 | +#line 1 "tsrc/fts3_snippet.c" | |
| 125527 | 126429 | /* |
| 125528 | 126430 | ** 2009 Oct 23 |
| 125529 | 126431 | ** |
| 125530 | 126432 | ** The author disclaims copyright to this source code. In place of |
| 125531 | 126433 | ** a legal notice, here is a blessing: |
| @@ -127023,10 +127925,11 @@ | ||
| 127023 | 127925 | |
| 127024 | 127926 | #endif |
| 127025 | 127927 | |
| 127026 | 127928 | /************** End of fts3_snippet.c ****************************************/ |
| 127027 | 127929 | /************** Begin file rtree.c *******************************************/ |
| 127930 | +#line 1 "tsrc/rtree.c" | |
| 127028 | 127931 | /* |
| 127029 | 127932 | ** 2001 September 15 |
| 127030 | 127933 | ** |
| 127031 | 127934 | ** The author disclaims copyright to this source code. In place of |
| 127032 | 127935 | ** a legal notice, here is a blessing: |
| @@ -130304,10 +131207,11 @@ | ||
| 130304 | 131207 | |
| 130305 | 131208 | #endif |
| 130306 | 131209 | |
| 130307 | 131210 | /************** End of rtree.c ***********************************************/ |
| 130308 | 131211 | /************** Begin file icu.c *********************************************/ |
| 131212 | +#line 1 "tsrc/icu.c" | |
| 130309 | 131213 | /* |
| 130310 | 131214 | ** 2007 May 6 |
| 130311 | 131215 | ** |
| 130312 | 131216 | ** The author disclaims copyright to this source code. In place of |
| 130313 | 131217 | ** a legal notice, here is a blessing: |
| @@ -130806,10 +131710,11 @@ | ||
| 130806 | 131710 | |
| 130807 | 131711 | #endif |
| 130808 | 131712 | |
| 130809 | 131713 | /************** End of icu.c *************************************************/ |
| 130810 | 131714 | /************** Begin file fts3_icu.c ****************************************/ |
| 131715 | +#line 1 "tsrc/fts3_icu.c" | |
| 130811 | 131716 | /* |
| 130812 | 131717 | ** 2007 June 22 |
| 130813 | 131718 | ** |
| 130814 | 131719 | ** The author disclaims copyright to this source code. In place of |
| 130815 | 131720 | ** a legal notice, here is a blessing: |
| 130816 | 131721 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.7.8. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -24,10 +24,11 @@ | |
| 24 | #endif |
| 25 | #ifndef SQLITE_API |
| 26 | # define SQLITE_API |
| 27 | #endif |
| 28 | /************** Begin file sqliteInt.h ***************************************/ |
| 29 | /* |
| 30 | ** 2001 September 15 |
| 31 | ** |
| 32 | ** The author disclaims copyright to this source code. In place of |
| 33 | ** a legal notice, here is a blessing: |
| @@ -78,10 +79,11 @@ | |
| 78 | #include "config.h" |
| 79 | #endif |
| 80 | |
| 81 | /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ |
| 82 | /************** Begin file sqliteLimit.h *************************************/ |
| 83 | /* |
| 84 | ** 2007 May 7 |
| 85 | ** |
| 86 | ** The author disclaims copyright to this source code. In place of |
| 87 | ** a legal notice, here is a blessing: |
| @@ -289,10 +291,11 @@ | |
| 289 | # define SQLITE_MAX_TRIGGER_DEPTH 1000 |
| 290 | #endif |
| 291 | |
| 292 | /************** End of sqliteLimit.h *****************************************/ |
| 293 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 294 | |
| 295 | /* Disable nuisance warnings on Borland compilers */ |
| 296 | #if defined(__BORLANDC__) |
| 297 | #pragma warn -rch /* unreachable code */ |
| 298 | #pragma warn -ccc /* Condition is always true or false */ |
| @@ -394,11 +397,11 @@ | |
| 394 | ** assert() macro is enabled, each call into the Win32 native heap subsystem |
| 395 | ** will cause HeapValidate to be called. If heap validation should fail, an |
| 396 | ** assertion will be triggered. |
| 397 | ** |
| 398 | ** (Historical note: There used to be several other options, but we've |
| 399 | ** pared it down to just these two.) |
| 400 | ** |
| 401 | ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as |
| 402 | ** the default. |
| 403 | */ |
| 404 | #if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)>1 |
| @@ -545,10 +548,11 @@ | |
| 545 | # define unlikely(X) !!(X) |
| 546 | #endif |
| 547 | |
| 548 | /************** Include sqlite3.h in the middle of sqliteInt.h ***************/ |
| 549 | /************** Begin file sqlite3.h *****************************************/ |
| 550 | /* |
| 551 | ** 2001 September 15 |
| 552 | ** |
| 553 | ** The author disclaims copyright to this source code. In place of |
| 554 | ** a legal notice, here is a blessing: |
| @@ -654,13 +658,13 @@ | |
| 654 | ** |
| 655 | ** See also: [sqlite3_libversion()], |
| 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 658 | */ |
| 659 | #define SQLITE_VERSION "3.7.8" |
| 660 | #define SQLITE_VERSION_NUMBER 3007008 |
| 661 | #define SQLITE_SOURCE_ID "2011-09-19 14:49:19 3e0da808d2f5b4d12046e05980ca04578f581177" |
| 662 | |
| 663 | /* |
| 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 666 | ** |
| @@ -1318,11 +1322,15 @@ | |
| 1318 | ** in order for the database to be readable. The fourth parameter to |
| 1319 | ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
| 1320 | ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent |
| 1321 | ** WAL mode. If the integer is -1, then it is overwritten with the current |
| 1322 | ** WAL persistence setting. |
| 1323 | ** |
| 1324 | */ |
| 1325 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1326 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1327 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1328 | #define SQLITE_LAST_ERRNO 4 |
| @@ -1330,10 +1338,11 @@ | |
| 1330 | #define SQLITE_FCNTL_CHUNK_SIZE 6 |
| 1331 | #define SQLITE_FCNTL_FILE_POINTER 7 |
| 1332 | #define SQLITE_FCNTL_SYNC_OMITTED 8 |
| 1333 | #define SQLITE_FCNTL_WIN32_AV_RETRY 9 |
| 1334 | #define SQLITE_FCNTL_PERSIST_WAL 10 |
| 1335 | |
| 1336 | /* |
| 1337 | ** CAPI3REF: Mutex Handle |
| 1338 | ** |
| 1339 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| @@ -3397,11 +3406,11 @@ | |
| 3397 | ** a schema change, on the first [sqlite3_step()] call following any change |
| 3398 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 3399 | ** ^The specific value of WHERE-clause [parameter] might influence the |
| 3400 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 3401 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 3402 | ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. |
| 3403 | ** the |
| 3404 | ** </li> |
| 3405 | ** </ol> |
| 3406 | */ |
| 3407 | SQLITE_API int sqlite3_prepare( |
| @@ -3900,10 +3909,16 @@ | |
| 3900 | ** current row of the result set of [prepared statement] P. |
| 3901 | ** ^If prepared statement P does not have results ready to return |
| 3902 | ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 3903 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 3904 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 3905 | ** |
| 3906 | ** See also: [sqlite3_column_count()] |
| 3907 | */ |
| 3908 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 3909 | |
| @@ -6362,20 +6377,34 @@ | |
| 6362 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6363 | ** and lookaside memory used by all prepared statements associated with |
| 6364 | ** the database connection.)^ |
| 6365 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6366 | ** </dd> |
| 6367 | ** </dl> |
| 6368 | */ |
| 6369 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6370 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6371 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 6372 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 6373 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 6374 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 6375 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 6376 | #define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ |
| 6377 | |
| 6378 | |
| 6379 | /* |
| 6380 | ** CAPI3REF: Prepared Statement Status |
| 6381 | ** |
| @@ -6425,11 +6454,10 @@ | |
| 6425 | ** <dd>^This is the number of rows inserted into transient indices that |
| 6426 | ** were created automatically in order to help joins run faster. |
| 6427 | ** A non-zero value in this counter may indicate an opportunity to |
| 6428 | ** improvement performance by adding permanent indices that do not |
| 6429 | ** need to be reinitialized each time the statement is run.</dd> |
| 6430 | ** |
| 6431 | ** </dl> |
| 6432 | */ |
| 6433 | #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
| 6434 | #define SQLITE_STMTSTATUS_SORT 2 |
| 6435 | #define SQLITE_STMTSTATUS_AUTOINDEX 3 |
| @@ -7305,12 +7333,14 @@ | |
| 7305 | #endif /* ifndef _SQLITE3RTREE_H_ */ |
| 7306 | |
| 7307 | |
| 7308 | /************** End of sqlite3.h *********************************************/ |
| 7309 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7310 | /************** Include hash.h in the middle of sqliteInt.h ******************/ |
| 7311 | /************** Begin file hash.h ********************************************/ |
| 7312 | /* |
| 7313 | ** 2001 September 22 |
| 7314 | ** |
| 7315 | ** The author disclaims copyright to this source code. In place of |
| 7316 | ** a legal notice, here is a blessing: |
| @@ -7406,12 +7436,14 @@ | |
| 7406 | |
| 7407 | #endif /* _SQLITE_HASH_H_ */ |
| 7408 | |
| 7409 | /************** End of hash.h ************************************************/ |
| 7410 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7411 | /************** Include parse.h in the middle of sqliteInt.h *****************/ |
| 7412 | /************** Begin file parse.h *******************************************/ |
| 7413 | #define TK_SEMI 1 |
| 7414 | #define TK_EXPLAIN 2 |
| 7415 | #define TK_QUERY 3 |
| 7416 | #define TK_PLAN 4 |
| 7417 | #define TK_BEGIN 5 |
| @@ -7568,10 +7600,11 @@ | |
| 7568 | #define TK_UMINUS 156 |
| 7569 | #define TK_UPLUS 157 |
| 7570 | |
| 7571 | /************** End of parse.h ***********************************************/ |
| 7572 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7573 | #include <stdio.h> |
| 7574 | #include <stdlib.h> |
| 7575 | #include <string.h> |
| 7576 | #include <assert.h> |
| 7577 | #include <stddef.h> |
| @@ -7711,10 +7744,22 @@ | |
| 7711 | ** is 0x00000000ffffffff. But because of quirks of some compilers, we |
| 7712 | ** have to specify the value in the less intuitive manner shown: |
| 7713 | */ |
| 7714 | #define SQLITE_MAX_U32 ((((u64)1)<<32)-1) |
| 7715 | |
| 7716 | /* |
| 7717 | ** Macros to determine whether the machine is big or little endian, |
| 7718 | ** evaluated at runtime. |
| 7719 | */ |
| 7720 | #ifdef SQLITE_AMALGAMATION |
| @@ -7911,10 +7956,11 @@ | |
| 7911 | ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque |
| 7912 | ** pointer types (i.e. FuncDef) defined above. |
| 7913 | */ |
| 7914 | /************** Include btree.h in the middle of sqliteInt.h *****************/ |
| 7915 | /************** Begin file btree.h *******************************************/ |
| 7916 | /* |
| 7917 | ** 2001 September 15 |
| 7918 | ** |
| 7919 | ** The author disclaims copyright to this source code. In place of |
| 7920 | ** a legal notice, here is a blessing: |
| @@ -8155,12 +8201,14 @@ | |
| 8155 | |
| 8156 | #endif /* _BTREE_H_ */ |
| 8157 | |
| 8158 | /************** End of btree.h ***********************************************/ |
| 8159 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8160 | /************** Include vdbe.h in the middle of sqliteInt.h ******************/ |
| 8161 | /************** Begin file vdbe.h ********************************************/ |
| 8162 | /* |
| 8163 | ** 2001 September 15 |
| 8164 | ** |
| 8165 | ** The author disclaims copyright to this source code. In place of |
| 8166 | ** a legal notice, here is a blessing: |
| @@ -8321,10 +8369,11 @@ | |
| 8321 | ** The makefile scans the vdbe.c source file and creates the "opcodes.h" |
| 8322 | ** header file that defines a number for each opcode used by the VDBE. |
| 8323 | */ |
| 8324 | /************** Include opcodes.h in the middle of vdbe.h ********************/ |
| 8325 | /************** Begin file opcodes.h *****************************************/ |
| 8326 | /* Automatically generated. Do not edit */ |
| 8327 | /* See the mkopcodeh.awk script for details */ |
| 8328 | #define OP_Goto 1 |
| 8329 | #define OP_Gosub 2 |
| 8330 | #define OP_Return 3 |
| @@ -8509,10 +8558,11 @@ | |
| 8509 | /* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\ |
| 8510 | /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,} |
| 8511 | |
| 8512 | /************** End of opcodes.h *********************************************/ |
| 8513 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 8514 | |
| 8515 | /* |
| 8516 | ** Prototypes for the VDBE interface. See comments on the implementation |
| 8517 | ** for a description of what each of these routines does. |
| 8518 | */ |
| @@ -8583,12 +8633,14 @@ | |
| 8583 | |
| 8584 | #endif |
| 8585 | |
| 8586 | /************** End of vdbe.h ************************************************/ |
| 8587 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8588 | /************** Include pager.h in the middle of sqliteInt.h *****************/ |
| 8589 | /************** Begin file pager.h *******************************************/ |
| 8590 | /* |
| 8591 | ** 2001 September 15 |
| 8592 | ** |
| 8593 | ** The author disclaims copyright to this source code. In place of |
| 8594 | ** a legal notice, here is a blessing: |
| @@ -8742,10 +8794,11 @@ | |
| 8742 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); |
| 8743 | SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); |
| 8744 | SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); |
| 8745 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| 8746 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); |
| 8747 | |
| 8748 | /* Functions used to truncate the database file. */ |
| 8749 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 8750 | |
| 8751 | #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
| @@ -8769,12 +8822,14 @@ | |
| 8769 | |
| 8770 | #endif /* _PAGER_H_ */ |
| 8771 | |
| 8772 | /************** End of pager.h ***********************************************/ |
| 8773 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8774 | /************** Include pcache.h in the middle of sqliteInt.h ****************/ |
| 8775 | /************** Begin file pcache.h ******************************************/ |
| 8776 | /* |
| 8777 | ** 2008 August 05 |
| 8778 | ** |
| 8779 | ** The author disclaims copyright to this source code. In place of |
| 8780 | ** a legal notice, here is a blessing: |
| @@ -8929,13 +8984,15 @@ | |
| 8929 | |
| 8930 | #endif /* _PCACHE_H_ */ |
| 8931 | |
| 8932 | /************** End of pcache.h **********************************************/ |
| 8933 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8934 | |
| 8935 | /************** Include os.h in the middle of sqliteInt.h ********************/ |
| 8936 | /************** Begin file os.h **********************************************/ |
| 8937 | /* |
| 8938 | ** 2001 September 16 |
| 8939 | ** |
| 8940 | ** The author disclaims copyright to this source code. In place of |
| 8941 | ** a legal notice, here is a blessing: |
| @@ -9214,12 +9271,14 @@ | |
| 9214 | |
| 9215 | #endif /* _SQLITE_OS_H_ */ |
| 9216 | |
| 9217 | /************** End of os.h **************************************************/ |
| 9218 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 9219 | /************** Include mutex.h in the middle of sqliteInt.h *****************/ |
| 9220 | /************** Begin file mutex.h *******************************************/ |
| 9221 | /* |
| 9222 | ** 2007 August 28 |
| 9223 | ** |
| 9224 | ** The author disclaims copyright to this source code. In place of |
| 9225 | ** a legal notice, here is a blessing: |
| @@ -9290,10 +9349,11 @@ | |
| 9290 | #define sqlite3MutexEnd() |
| 9291 | #endif /* defined(SQLITE_MUTEX_OMIT) */ |
| 9292 | |
| 9293 | /************** End of mutex.h ***********************************************/ |
| 9294 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 9295 | |
| 9296 | |
| 9297 | /* |
| 9298 | ** Each database file to be accessed by the system is an instance |
| 9299 | ** of the following structure. There are normally two of these structures |
| @@ -9918,11 +9978,11 @@ | |
| 9918 | int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ |
| 9919 | int nCol; /* Number of columns in this table */ |
| 9920 | Column *aCol; /* Information about each column */ |
| 9921 | Index *pIndex; /* List of SQL indexes on this table. */ |
| 9922 | int tnum; /* Root BTree node for this table (see note above) */ |
| 9923 | unsigned nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ |
| 9924 | Select *pSelect; /* NULL for tables. Points to definition if a view. */ |
| 9925 | u16 nRef; /* Number of pointers to this Table */ |
| 9926 | u8 tabFlags; /* Mask of TF_* values */ |
| 9927 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
| 9928 | FKey *pFKey; /* Linked list of all foreign keys in this table */ |
| @@ -10117,11 +10177,11 @@ | |
| 10117 | */ |
| 10118 | struct Index { |
| 10119 | char *zName; /* Name of this index */ |
| 10120 | int nColumn; /* Number of columns in the table used by this index */ |
| 10121 | int *aiColumn; /* Which columns are used by this index. 1st is 0 */ |
| 10122 | unsigned *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ |
| 10123 | Table *pTable; /* The SQL table being indexed */ |
| 10124 | int tnum; /* Page containing root of this index in database file */ |
| 10125 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 10126 | u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ |
| 10127 | u8 bUnordered; /* Use this index for == or IN queries only */ |
| @@ -10128,24 +10188,32 @@ | |
| 10128 | char *zColAff; /* String defining the affinity of each column */ |
| 10129 | Index *pNext; /* The next index associated with the same table */ |
| 10130 | Schema *pSchema; /* Schema containing this index */ |
| 10131 | u8 *aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ |
| 10132 | char **azColl; /* Array of collation sequence names for index */ |
| 10133 | IndexSample *aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ |
| 10134 | }; |
| 10135 | |
| 10136 | /* |
| 10137 | ** Each sample stored in the sqlite_stat2 table is represented in memory |
| 10138 | ** using a structure of this type. |
| 10139 | */ |
| 10140 | struct IndexSample { |
| 10141 | union { |
| 10142 | char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */ |
| 10143 | double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ |
| 10144 | } u; |
| 10145 | u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ |
| 10146 | u8 nByte; /* Size in byte of text or blob. */ |
| 10147 | }; |
| 10148 | |
| 10149 | /* |
| 10150 | ** Each token coming out of the lexer is an instance of |
| 10151 | ** this structure. Tokens are also used as part of an expression. |
| @@ -10593,14 +10661,14 @@ | |
| 10593 | #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ |
| 10594 | #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ |
| 10595 | #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ |
| 10596 | #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
| 10597 | #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
| 10598 | #define WHERE_OMIT_OPEN 0x0010 /* Table cursors are already open */ |
| 10599 | #define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ |
| 10600 | #define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */ |
| 10601 | #define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */ |
| 10602 | |
| 10603 | /* |
| 10604 | ** The WHERE clause processing routine has two halves. The |
| 10605 | ** first part does the start of the WHERE loop and the second |
| 10606 | ** half does the tail of the WHERE loop. An instance of |
| @@ -11350,10 +11418,11 @@ | |
| 11350 | #else |
| 11351 | # define sqlite3ViewGetColumnNames(A,B) 0 |
| 11352 | #endif |
| 11353 | |
| 11354 | SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int); |
| 11355 | SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*); |
| 11356 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 11357 | SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); |
| 11358 | SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse); |
| 11359 | #else |
| @@ -11606,11 +11675,11 @@ | |
| 11606 | SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, |
| 11607 | void(*)(void*)); |
| 11608 | SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*); |
| 11609 | SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *); |
| 11610 | SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); |
| 11611 | #ifdef SQLITE_ENABLE_STAT2 |
| 11612 | SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *); |
| 11613 | #endif |
| 11614 | SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); |
| 11615 | SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); |
| 11616 | #ifndef SQLITE_AMALGAMATION |
| @@ -11893,10 +11962,11 @@ | |
| 11893 | |
| 11894 | #endif /* _SQLITEINT_H_ */ |
| 11895 | |
| 11896 | /************** End of sqliteInt.h *******************************************/ |
| 11897 | /************** Begin file global.c ******************************************/ |
| 11898 | /* |
| 11899 | ** 2008 June 13 |
| 11900 | ** |
| 11901 | ** The author disclaims copyright to this source code. In place of |
| 11902 | ** a legal notice, here is a blessing: |
| @@ -12115,10 +12185,11 @@ | |
| 12115 | */ |
| 12116 | SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER; |
| 12117 | |
| 12118 | /************** End of global.c **********************************************/ |
| 12119 | /************** Begin file ctime.c *******************************************/ |
| 12120 | /* |
| 12121 | ** 2010 February 23 |
| 12122 | ** |
| 12123 | ** The author disclaims copyright to this source code. In place of |
| 12124 | ** a legal notice, here is a blessing: |
| @@ -12232,10 +12303,13 @@ | |
| 12232 | #ifdef SQLITE_ENABLE_RTREE |
| 12233 | "ENABLE_RTREE", |
| 12234 | #endif |
| 12235 | #ifdef SQLITE_ENABLE_STAT2 |
| 12236 | "ENABLE_STAT2", |
| 12237 | #endif |
| 12238 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 12239 | "ENABLE_UNLOCK_NOTIFY", |
| 12240 | #endif |
| 12241 | #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT |
| @@ -12445,13 +12519,10 @@ | |
| 12445 | "OMIT_WSD", |
| 12446 | #endif |
| 12447 | #ifdef SQLITE_OMIT_XFER_OPT |
| 12448 | "OMIT_XFER_OPT", |
| 12449 | #endif |
| 12450 | #ifdef SQLITE_PAGECACHE_BLOCKALLOC |
| 12451 | "PAGECACHE_BLOCKALLOC", |
| 12452 | #endif |
| 12453 | #ifdef SQLITE_PERFORMANCE_TRACE |
| 12454 | "PERFORMANCE_TRACE", |
| 12455 | #endif |
| 12456 | #ifdef SQLITE_PROXY_DEBUG |
| 12457 | "PROXY_DEBUG", |
| @@ -12519,10 +12590,11 @@ | |
| 12519 | |
| 12520 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| 12521 | |
| 12522 | /************** End of ctime.c ***********************************************/ |
| 12523 | /************** Begin file status.c ******************************************/ |
| 12524 | /* |
| 12525 | ** 2008 June 18 |
| 12526 | ** |
| 12527 | ** The author disclaims copyright to this source code. In place of |
| 12528 | ** a legal notice, here is a blessing: |
| @@ -12536,10 +12608,11 @@ | |
| 12536 | ** This module implements the sqlite3_status() interface and related |
| 12537 | ** functionality. |
| 12538 | */ |
| 12539 | /************** Include vdbeInt.h in the middle of status.c ******************/ |
| 12540 | /************** Begin file vdbeInt.h *****************************************/ |
| 12541 | /* |
| 12542 | ** 2003 September 6 |
| 12543 | ** |
| 12544 | ** The author disclaims copyright to this source code. In place of |
| 12545 | ** a legal notice, here is a blessing: |
| @@ -12987,10 +13060,11 @@ | |
| 12987 | |
| 12988 | #endif /* !defined(_VDBEINT_H_) */ |
| 12989 | |
| 12990 | /************** End of vdbeInt.h *********************************************/ |
| 12991 | /************** Continuing where we left off in status.c *********************/ |
| 12992 | |
| 12993 | /* |
| 12994 | ** Variables in which to record status information. |
| 12995 | */ |
| 12996 | typedef struct sqlite3StatType sqlite3StatType; |
| @@ -13189,10 +13263,32 @@ | |
| 13189 | *pHighwater = 0; |
| 13190 | *pCurrent = nByte; |
| 13191 | |
| 13192 | break; |
| 13193 | } |
| 13194 | |
| 13195 | default: { |
| 13196 | rc = SQLITE_ERROR; |
| 13197 | } |
| 13198 | } |
| @@ -13200,10 +13296,11 @@ | |
| 13200 | return rc; |
| 13201 | } |
| 13202 | |
| 13203 | /************** End of status.c **********************************************/ |
| 13204 | /************** Begin file date.c ********************************************/ |
| 13205 | /* |
| 13206 | ** 2003 October 31 |
| 13207 | ** |
| 13208 | ** The author disclaims copyright to this source code. In place of |
| 13209 | ** a legal notice, here is a blessing: |
| @@ -14327,10 +14424,11 @@ | |
| 14327 | } |
| 14328 | } |
| 14329 | |
| 14330 | /************** End of date.c ************************************************/ |
| 14331 | /************** Begin file os.c **********************************************/ |
| 14332 | /* |
| 14333 | ** 2005 November 29 |
| 14334 | ** |
| 14335 | ** The author disclaims copyright to this source code. In place of |
| 14336 | ** a legal notice, here is a blessing: |
| @@ -14660,10 +14758,11 @@ | |
| 14660 | return SQLITE_OK; |
| 14661 | } |
| 14662 | |
| 14663 | /************** End of os.c **************************************************/ |
| 14664 | /************** Begin file fault.c *******************************************/ |
| 14665 | /* |
| 14666 | ** 2008 Jan 22 |
| 14667 | ** |
| 14668 | ** The author disclaims copyright to this source code. In place of |
| 14669 | ** a legal notice, here is a blessing: |
| @@ -14749,10 +14848,11 @@ | |
| 14749 | |
| 14750 | #endif /* #ifndef SQLITE_OMIT_BUILTIN_TEST */ |
| 14751 | |
| 14752 | /************** End of fault.c ***********************************************/ |
| 14753 | /************** Begin file mem0.c ********************************************/ |
| 14754 | /* |
| 14755 | ** 2008 October 28 |
| 14756 | ** |
| 14757 | ** The author disclaims copyright to this source code. In place of |
| 14758 | ** a legal notice, here is a blessing: |
| @@ -14810,10 +14910,11 @@ | |
| 14810 | |
| 14811 | #endif /* SQLITE_ZERO_MALLOC */ |
| 14812 | |
| 14813 | /************** End of mem0.c ************************************************/ |
| 14814 | /************** Begin file mem1.c ********************************************/ |
| 14815 | /* |
| 14816 | ** 2007 August 14 |
| 14817 | ** |
| 14818 | ** The author disclaims copyright to this source code. In place of |
| 14819 | ** a legal notice, here is a blessing: |
| @@ -14962,10 +15063,11 @@ | |
| 14962 | |
| 14963 | #endif /* SQLITE_SYSTEM_MALLOC */ |
| 14964 | |
| 14965 | /************** End of mem1.c ************************************************/ |
| 14966 | /************** Begin file mem2.c ********************************************/ |
| 14967 | /* |
| 14968 | ** 2007 August 15 |
| 14969 | ** |
| 14970 | ** The author disclaims copyright to this source code. In place of |
| 14971 | ** a legal notice, here is a blessing: |
| @@ -15492,10 +15594,11 @@ | |
| 15492 | |
| 15493 | #endif /* SQLITE_MEMDEBUG */ |
| 15494 | |
| 15495 | /************** End of mem2.c ************************************************/ |
| 15496 | /************** Begin file mem3.c ********************************************/ |
| 15497 | /* |
| 15498 | ** 2007 October 14 |
| 15499 | ** |
| 15500 | ** The author disclaims copyright to this source code. In place of |
| 15501 | ** a legal notice, here is a blessing: |
| @@ -16181,10 +16284,11 @@ | |
| 16181 | |
| 16182 | #endif /* SQLITE_ENABLE_MEMSYS3 */ |
| 16183 | |
| 16184 | /************** End of mem3.c ************************************************/ |
| 16185 | /************** Begin file mem5.c ********************************************/ |
| 16186 | /* |
| 16187 | ** 2007 October 14 |
| 16188 | ** |
| 16189 | ** The author disclaims copyright to this source code. In place of |
| 16190 | ** a legal notice, here is a blessing: |
| @@ -16764,10 +16868,11 @@ | |
| 16764 | |
| 16765 | #endif /* SQLITE_ENABLE_MEMSYS5 */ |
| 16766 | |
| 16767 | /************** End of mem5.c ************************************************/ |
| 16768 | /************** Begin file mutex.c *******************************************/ |
| 16769 | /* |
| 16770 | ** 2007 August 14 |
| 16771 | ** |
| 16772 | ** The author disclaims copyright to this source code. In place of |
| 16773 | ** a legal notice, here is a blessing: |
| @@ -16919,10 +17024,11 @@ | |
| 16919 | |
| 16920 | #endif /* SQLITE_MUTEX_OMIT */ |
| 16921 | |
| 16922 | /************** End of mutex.c ***********************************************/ |
| 16923 | /************** Begin file mutex_noop.c **************************************/ |
| 16924 | /* |
| 16925 | ** 2008 October 07 |
| 16926 | ** |
| 16927 | ** The author disclaims copyright to this source code. In place of |
| 16928 | ** a legal notice, here is a blessing: |
| @@ -17127,10 +17233,11 @@ | |
| 17127 | #endif /* SQLITE_MUTEX_NOOP */ |
| 17128 | #endif /* SQLITE_MUTEX_OMIT */ |
| 17129 | |
| 17130 | /************** End of mutex_noop.c ******************************************/ |
| 17131 | /************** Begin file mutex_os2.c ***************************************/ |
| 17132 | /* |
| 17133 | ** 2007 August 28 |
| 17134 | ** |
| 17135 | ** The author disclaims copyright to this source code. In place of |
| 17136 | ** a legal notice, here is a blessing: |
| @@ -17403,10 +17510,11 @@ | |
| 17403 | } |
| 17404 | #endif /* SQLITE_MUTEX_OS2 */ |
| 17405 | |
| 17406 | /************** End of mutex_os2.c *******************************************/ |
| 17407 | /************** Begin file mutex_unix.c **************************************/ |
| 17408 | /* |
| 17409 | ** 2007 August 28 |
| 17410 | ** |
| 17411 | ** The author disclaims copyright to this source code. In place of |
| 17412 | ** a legal notice, here is a blessing: |
| @@ -17756,10 +17864,11 @@ | |
| 17756 | |
| 17757 | #endif /* SQLITE_MUTEX_PTHREAD */ |
| 17758 | |
| 17759 | /************** End of mutex_unix.c ******************************************/ |
| 17760 | /************** Begin file mutex_w32.c ***************************************/ |
| 17761 | /* |
| 17762 | ** 2007 August 14 |
| 17763 | ** |
| 17764 | ** The author disclaims copyright to this source code. In place of |
| 17765 | ** a legal notice, here is a blessing: |
| @@ -18090,10 +18199,11 @@ | |
| 18090 | } |
| 18091 | #endif /* SQLITE_MUTEX_W32 */ |
| 18092 | |
| 18093 | /************** End of mutex_w32.c *******************************************/ |
| 18094 | /************** Begin file malloc.c ******************************************/ |
| 18095 | /* |
| 18096 | ** 2001 September 15 |
| 18097 | ** |
| 18098 | ** The author disclaims copyright to this source code. In place of |
| 18099 | ** a legal notice, here is a blessing: |
| @@ -18869,10 +18979,11 @@ | |
| 18869 | return rc & (db ? db->errMask : 0xff); |
| 18870 | } |
| 18871 | |
| 18872 | /************** End of malloc.c **********************************************/ |
| 18873 | /************** Begin file printf.c ******************************************/ |
| 18874 | /* |
| 18875 | ** The "printf" code that follows dates from the 1980's. It is in |
| 18876 | ** the public domain. The original comments are included here for |
| 18877 | ** completeness. They are very out-of-date but might be useful as |
| 18878 | ** an historical reference. Most of the "enhancements" have been backed |
| @@ -19900,10 +20011,11 @@ | |
| 19900 | } |
| 19901 | #endif |
| 19902 | |
| 19903 | /************** End of printf.c **********************************************/ |
| 19904 | /************** Begin file random.c ******************************************/ |
| 19905 | /* |
| 19906 | ** 2001 September 15 |
| 19907 | ** |
| 19908 | ** The author disclaims copyright to this source code. In place of |
| 19909 | ** a legal notice, here is a blessing: |
| @@ -20047,10 +20159,11 @@ | |
| 20047 | } |
| 20048 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 20049 | |
| 20050 | /************** End of random.c **********************************************/ |
| 20051 | /************** Begin file utf.c *********************************************/ |
| 20052 | /* |
| 20053 | ** 2004 April 13 |
| 20054 | ** |
| 20055 | ** The author disclaims copyright to this source code. In place of |
| 20056 | ** a legal notice, here is a blessing: |
| @@ -20511,11 +20624,11 @@ | |
| 20511 | ** no longer required. |
| 20512 | ** |
| 20513 | ** If a malloc failure occurs, NULL is returned and the db.mallocFailed |
| 20514 | ** flag set. |
| 20515 | */ |
| 20516 | #ifdef SQLITE_ENABLE_STAT2 |
| 20517 | SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *db, u8 enc, char *z, int n, int *pnOut){ |
| 20518 | Mem m; |
| 20519 | memset(&m, 0, sizeof(m)); |
| 20520 | m.db = db; |
| 20521 | sqlite3VdbeMemSetStr(&m, z, n, SQLITE_UTF8, SQLITE_STATIC); |
| @@ -20608,10 +20721,11 @@ | |
| 20608 | #endif /* SQLITE_TEST */ |
| 20609 | #endif /* SQLITE_OMIT_UTF16 */ |
| 20610 | |
| 20611 | /************** End of utf.c *************************************************/ |
| 20612 | /************** Begin file util.c ********************************************/ |
| 20613 | /* |
| 20614 | ** 2001 September 15 |
| 20615 | ** |
| 20616 | ** The author disclaims copyright to this source code. In place of |
| 20617 | ** a legal notice, here is a blessing: |
| @@ -21790,10 +21904,11 @@ | |
| 21790 | } |
| 21791 | #endif |
| 21792 | |
| 21793 | /************** End of util.c ************************************************/ |
| 21794 | /************** Begin file hash.c ********************************************/ |
| 21795 | /* |
| 21796 | ** 2001 September 22 |
| 21797 | ** |
| 21798 | ** The author disclaims copyright to this source code. In place of |
| 21799 | ** a legal notice, here is a blessing: |
| @@ -22069,10 +22184,11 @@ | |
| 22069 | return 0; |
| 22070 | } |
| 22071 | |
| 22072 | /************** End of hash.c ************************************************/ |
| 22073 | /************** Begin file opcodes.c *****************************************/ |
| 22074 | /* Automatically generated. Do not edit */ |
| 22075 | /* See the mkopcodec.awk script for details. */ |
| 22076 | #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) |
| 22077 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ |
| 22078 | static const char *const azName[] = { "?", |
| @@ -22231,10 +22347,11 @@ | |
| 22231 | } |
| 22232 | #endif |
| 22233 | |
| 22234 | /************** End of opcodes.c *********************************************/ |
| 22235 | /************** Begin file os_os2.c ******************************************/ |
| 22236 | /* |
| 22237 | ** 2006 Feb 14 |
| 22238 | ** |
| 22239 | ** The author disclaims copyright to this source code. In place of |
| 22240 | ** a legal notice, here is a blessing: |
| @@ -22287,10 +22404,11 @@ | |
| 22287 | /* |
| 22288 | ** Include code that is common to all os_*.c files |
| 22289 | */ |
| 22290 | /************** Include os_common.h in the middle of os_os2.c ****************/ |
| 22291 | /************** Begin file os_common.h ***************************************/ |
| 22292 | /* |
| 22293 | ** 2004 May 22 |
| 22294 | ** |
| 22295 | ** The author disclaims copyright to this source code. In place of |
| 22296 | ** a legal notice, here is a blessing: |
| @@ -22340,10 +22458,11 @@ | |
| 22340 | ** hwtime.h contains inline assembler code for implementing |
| 22341 | ** high-performance timing routines. |
| 22342 | */ |
| 22343 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 22344 | /************** Begin file hwtime.h ******************************************/ |
| 22345 | /* |
| 22346 | ** 2008 May 27 |
| 22347 | ** |
| 22348 | ** The author disclaims copyright to this source code. In place of |
| 22349 | ** a legal notice, here is a blessing: |
| @@ -22428,10 +22547,11 @@ | |
| 22428 | |
| 22429 | #endif /* !defined(_HWTIME_H_) */ |
| 22430 | |
| 22431 | /************** End of hwtime.h **********************************************/ |
| 22432 | /************** Continuing where we left off in os_common.h ******************/ |
| 22433 | |
| 22434 | static sqlite_uint64 g_start; |
| 22435 | static sqlite_uint64 g_elapsed; |
| 22436 | #define TIMER_START g_start=sqlite3Hwtime() |
| 22437 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -22494,10 +22614,11 @@ | |
| 22494 | |
| 22495 | #endif /* !defined(_OS_COMMON_H_) */ |
| 22496 | |
| 22497 | /************** End of os_common.h *******************************************/ |
| 22498 | /************** Continuing where we left off in os_os2.c *********************/ |
| 22499 | |
| 22500 | /* Forward references */ |
| 22501 | typedef struct os2File os2File; /* The file structure */ |
| 22502 | typedef struct os2ShmNode os2ShmNode; /* A shared descritive memory node */ |
| 22503 | typedef struct os2ShmLink os2ShmLink; /* A connection to shared-memory */ |
| @@ -24365,10 +24486,11 @@ | |
| 24365 | |
| 24366 | #endif /* SQLITE_OS_OS2 */ |
| 24367 | |
| 24368 | /************** End of os_os2.c **********************************************/ |
| 24369 | /************** Begin file os_unix.c *****************************************/ |
| 24370 | /* |
| 24371 | ** 2004 May 22 |
| 24372 | ** |
| 24373 | ** The author disclaims copyright to this source code. In place of |
| 24374 | ** a legal notice, here is a blessing: |
| @@ -24629,10 +24751,11 @@ | |
| 24629 | /* |
| 24630 | ** Include code that is common to all os_*.c files |
| 24631 | */ |
| 24632 | /************** Include os_common.h in the middle of os_unix.c ***************/ |
| 24633 | /************** Begin file os_common.h ***************************************/ |
| 24634 | /* |
| 24635 | ** 2004 May 22 |
| 24636 | ** |
| 24637 | ** The author disclaims copyright to this source code. In place of |
| 24638 | ** a legal notice, here is a blessing: |
| @@ -24682,10 +24805,11 @@ | |
| 24682 | ** hwtime.h contains inline assembler code for implementing |
| 24683 | ** high-performance timing routines. |
| 24684 | */ |
| 24685 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 24686 | /************** Begin file hwtime.h ******************************************/ |
| 24687 | /* |
| 24688 | ** 2008 May 27 |
| 24689 | ** |
| 24690 | ** The author disclaims copyright to this source code. In place of |
| 24691 | ** a legal notice, here is a blessing: |
| @@ -24770,10 +24894,11 @@ | |
| 24770 | |
| 24771 | #endif /* !defined(_HWTIME_H_) */ |
| 24772 | |
| 24773 | /************** End of hwtime.h **********************************************/ |
| 24774 | /************** Continuing where we left off in os_common.h ******************/ |
| 24775 | |
| 24776 | static sqlite_uint64 g_start; |
| 24777 | static sqlite_uint64 g_elapsed; |
| 24778 | #define TIMER_START g_start=sqlite3Hwtime() |
| 24779 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -24836,10 +24961,11 @@ | |
| 24836 | |
| 24837 | #endif /* !defined(_OS_COMMON_H_) */ |
| 24838 | |
| 24839 | /************** End of os_common.h *******************************************/ |
| 24840 | /************** Continuing where we left off in os_unix.c ********************/ |
| 24841 | |
| 24842 | /* |
| 24843 | ** Define various macros that are missing from some systems. |
| 24844 | */ |
| 24845 | #ifndef O_LARGEFILE |
| @@ -29462,12 +29588,20 @@ | |
| 29462 | ** |
| 29463 | ** where NN is a 4 digit decimal number. The NN naming schemes are |
| 29464 | ** used by the test_multiplex.c module. |
| 29465 | */ |
| 29466 | nDb = sqlite3Strlen30(zPath) - 1; |
| 29467 | while( nDb>0 && zPath[nDb]!='-' ) nDb--; |
| 29468 | if( nDb==0 ) return SQLITE_OK; |
| 29469 | memcpy(zDb, zPath, nDb); |
| 29470 | zDb[nDb] = '\0'; |
| 29471 | |
| 29472 | if( 0==osStat(zDb, &sStat) ){ |
| 29473 | *pMode = sStat.st_mode & 0777; |
| @@ -31345,10 +31479,11 @@ | |
| 31345 | |
| 31346 | #endif /* SQLITE_OS_UNIX */ |
| 31347 | |
| 31348 | /************** End of os_unix.c *********************************************/ |
| 31349 | /************** Begin file os_win.c ******************************************/ |
| 31350 | /* |
| 31351 | ** 2004 May 22 |
| 31352 | ** |
| 31353 | ** The author disclaims copyright to this source code. In place of |
| 31354 | ** a legal notice, here is a blessing: |
| @@ -31406,10 +31541,11 @@ | |
| 31406 | /* |
| 31407 | ** Include code that is common to all os_*.c files |
| 31408 | */ |
| 31409 | /************** Include os_common.h in the middle of os_win.c ****************/ |
| 31410 | /************** Begin file os_common.h ***************************************/ |
| 31411 | /* |
| 31412 | ** 2004 May 22 |
| 31413 | ** |
| 31414 | ** The author disclaims copyright to this source code. In place of |
| 31415 | ** a legal notice, here is a blessing: |
| @@ -31459,10 +31595,11 @@ | |
| 31459 | ** hwtime.h contains inline assembler code for implementing |
| 31460 | ** high-performance timing routines. |
| 31461 | */ |
| 31462 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 31463 | /************** Begin file hwtime.h ******************************************/ |
| 31464 | /* |
| 31465 | ** 2008 May 27 |
| 31466 | ** |
| 31467 | ** The author disclaims copyright to this source code. In place of |
| 31468 | ** a legal notice, here is a blessing: |
| @@ -31547,10 +31684,11 @@ | |
| 31547 | |
| 31548 | #endif /* !defined(_HWTIME_H_) */ |
| 31549 | |
| 31550 | /************** End of hwtime.h **********************************************/ |
| 31551 | /************** Continuing where we left off in os_common.h ******************/ |
| 31552 | |
| 31553 | static sqlite_uint64 g_start; |
| 31554 | static sqlite_uint64 g_elapsed; |
| 31555 | #define TIMER_START g_start=sqlite3Hwtime() |
| 31556 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -31613,10 +31751,11 @@ | |
| 31613 | |
| 31614 | #endif /* !defined(_OS_COMMON_H_) */ |
| 31615 | |
| 31616 | /************** End of os_common.h *******************************************/ |
| 31617 | /************** Continuing where we left off in os_win.c *********************/ |
| 31618 | |
| 31619 | /* |
| 31620 | ** Some microsoft compilers lack this definition. |
| 31621 | */ |
| 31622 | #ifndef INVALID_FILE_ATTRIBUTES |
| @@ -34169,11 +34308,11 @@ | |
| 34169 | |
| 34170 | if( h==INVALID_HANDLE_VALUE ){ |
| 34171 | pFile->lastErrno = GetLastError(); |
| 34172 | winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); |
| 34173 | free(zConverted); |
| 34174 | if( isReadWrite ){ |
| 34175 | return winOpen(pVfs, zName, id, |
| 34176 | ((flags|SQLITE_OPEN_READONLY)&~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), pOutFlags); |
| 34177 | }else{ |
| 34178 | return SQLITE_CANTOPEN_BKPT; |
| 34179 | } |
| @@ -34758,10 +34897,11 @@ | |
| 34758 | |
| 34759 | #endif /* SQLITE_OS_WIN */ |
| 34760 | |
| 34761 | /************** End of os_win.c **********************************************/ |
| 34762 | /************** Begin file bitvec.c ******************************************/ |
| 34763 | /* |
| 34764 | ** 2008 February 16 |
| 34765 | ** |
| 34766 | ** The author disclaims copyright to this source code. In place of |
| 34767 | ** a legal notice, here is a blessing: |
| @@ -35168,10 +35308,11 @@ | |
| 35168 | } |
| 35169 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 35170 | |
| 35171 | /************** End of bitvec.c **********************************************/ |
| 35172 | /************** Begin file pcache.c ******************************************/ |
| 35173 | /* |
| 35174 | ** 2008 August 05 |
| 35175 | ** |
| 35176 | ** The author disclaims copyright to this source code. In place of |
| 35177 | ** a legal notice, here is a blessing: |
| @@ -35764,10 +35905,11 @@ | |
| 35764 | } |
| 35765 | #endif |
| 35766 | |
| 35767 | /************** End of pcache.c **********************************************/ |
| 35768 | /************** Begin file pcache1.c *****************************************/ |
| 35769 | /* |
| 35770 | ** 2008 November 05 |
| 35771 | ** |
| 35772 | ** The author disclaims copyright to this source code. In place of |
| 35773 | ** a legal notice, here is a blessing: |
| @@ -35789,12 +35931,10 @@ | |
| 35789 | typedef struct PCache1 PCache1; |
| 35790 | typedef struct PgHdr1 PgHdr1; |
| 35791 | typedef struct PgFreeslot PgFreeslot; |
| 35792 | typedef struct PGroup PGroup; |
| 35793 | |
| 35794 | typedef struct PGroupBlock PGroupBlock; |
| 35795 | typedef struct PGroupBlockList PGroupBlockList; |
| 35796 | |
| 35797 | /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set |
| 35798 | ** of one or more PCaches that are able to recycle each others unpinned |
| 35799 | ** pages when they are under memory pressure. A PGroup is an instance of |
| 35800 | ** the following object. |
| @@ -35821,69 +35961,11 @@ | |
| 35821 | int nMaxPage; /* Sum of nMax for purgeable caches */ |
| 35822 | int nMinPage; /* Sum of nMin for purgeable caches */ |
| 35823 | int mxPinned; /* nMaxpage + 10 - nMinPage */ |
| 35824 | int nCurrentPage; /* Number of purgeable pages allocated */ |
| 35825 | PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ |
| 35826 | #ifdef SQLITE_PAGECACHE_BLOCKALLOC |
| 35827 | int isBusy; /* Do not run ReleaseMemory() if true */ |
| 35828 | PGroupBlockList *pBlockList; /* List of block-lists for this group */ |
| 35829 | #endif |
| 35830 | }; |
| 35831 | |
| 35832 | /* |
| 35833 | ** If SQLITE_PAGECACHE_BLOCKALLOC is defined when the library is built, |
| 35834 | ** each PGroup structure has a linked list of the the following starting |
| 35835 | ** at PGroup.pBlockList. There is one entry for each distinct page-size |
| 35836 | ** currently used by members of the PGroup (i.e. 1024 bytes, 4096 bytes |
| 35837 | ** etc.). Variable PGroupBlockList.nByte is set to the actual allocation |
| 35838 | ** size requested by each pcache, which is the database page-size plus |
| 35839 | ** the various header structures used by the pcache, pager and btree layers. |
| 35840 | ** Usually around (pgsz+200) bytes. |
| 35841 | ** |
| 35842 | ** This size (pgsz+200) bytes is not allocated efficiently by some |
| 35843 | ** implementations of malloc. In particular, some implementations are only |
| 35844 | ** able to allocate blocks of memory chunks of 2^N bytes, where N is some |
| 35845 | ** integer value. Since the page-size is a power of 2, this means we |
| 35846 | ** end up wasting (pgsz-200) bytes in each allocation. |
| 35847 | ** |
| 35848 | ** If SQLITE_PAGECACHE_BLOCKALLOC is defined, the (pgsz+200) byte blocks |
| 35849 | ** are not allocated directly. Instead, blocks of roughly M*(pgsz+200) bytes |
| 35850 | ** are requested from malloc allocator. After a block is returned, |
| 35851 | ** sqlite3MallocSize() is used to determine how many (pgsz+200) byte |
| 35852 | ** allocations can fit in the space returned by malloc(). This value may |
| 35853 | ** be more than M. |
| 35854 | ** |
| 35855 | ** The blocks are stored in a doubly-linked list. Variable PGroupBlock.nEntry |
| 35856 | ** contains the number of allocations that will fit in the aData[] space. |
| 35857 | ** nEntry is limited to the number of bits in bitmask mUsed. If a slot |
| 35858 | ** within aData is in use, the corresponding bit in mUsed is set. Thus |
| 35859 | ** when (mUsed+1==(1 << nEntry)) the block is completely full. |
| 35860 | ** |
| 35861 | ** Each time a slot within a block is freed, the block is moved to the start |
| 35862 | ** of the linked-list. And if a block becomes completely full, then it is |
| 35863 | ** moved to the end of the list. As a result, when searching for a free |
| 35864 | ** slot, only the first block in the list need be examined. If it is full, |
| 35865 | ** then it is guaranteed that all blocks are full. |
| 35866 | */ |
| 35867 | struct PGroupBlockList { |
| 35868 | int nByte; /* Size of each allocation in bytes */ |
| 35869 | PGroupBlock *pFirst; /* First PGroupBlock in list */ |
| 35870 | PGroupBlock *pLast; /* Last PGroupBlock in list */ |
| 35871 | PGroupBlockList *pNext; /* Next block-list attached to group */ |
| 35872 | }; |
| 35873 | |
| 35874 | struct PGroupBlock { |
| 35875 | Bitmask mUsed; /* Mask of used slots */ |
| 35876 | int nEntry; /* Maximum number of allocations in aData[] */ |
| 35877 | u8 *aData; /* Pointer to data block */ |
| 35878 | PGroupBlock *pNext; /* Next PGroupBlock in list */ |
| 35879 | PGroupBlock *pPrev; /* Previous PGroupBlock in list */ |
| 35880 | PGroupBlockList *pList; /* Owner list */ |
| 35881 | }; |
| 35882 | |
| 35883 | /* Minimum value for PGroupBlock.nEntry */ |
| 35884 | #define PAGECACHE_BLOCKALLOC_MINENTRY 15 |
| 35885 | |
| 35886 | /* Each page cache is an instance of the following object. Every |
| 35887 | ** open database file (including each in-memory database and each |
| 35888 | ** temporary or transient database) has a single page cache which |
| 35889 | ** is an instance of this object. |
| @@ -35983,21 +36065,10 @@ | |
| 35983 | ** |
| 35984 | ** assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X ); |
| 35985 | */ |
| 35986 | #define PGHDR1_TO_PAGE(p) (void*)(((char*)p) - p->pCache->szPage) |
| 35987 | #define PAGE_TO_PGHDR1(c, p) (PgHdr1*)(((char*)p) + c->szPage) |
| 35988 | |
| 35989 | /* |
| 35990 | ** Blocks used by the SQLITE_PAGECACHE_BLOCKALLOC blocks to store/retrieve |
| 35991 | ** a PGroupBlock pointer based on a pointer to a page buffer. |
| 35992 | */ |
| 35993 | #define PAGE_SET_BLOCKPTR(pCache, pPg, pBlock) \ |
| 35994 | ( *(PGroupBlock **)&(((u8*)pPg)[sizeof(PgHdr1) + pCache->szPage]) = pBlock ) |
| 35995 | |
| 35996 | #define PAGE_GET_BLOCKPTR(pCache, pPg) \ |
| 35997 | ( *(PGroupBlock **)&(((u8*)pPg)[sizeof(PgHdr1) + pCache->szPage]) ) |
| 35998 | |
| 35999 | |
| 36000 | /* |
| 36001 | ** Macros to enter and leave the PCache LRU mutex. |
| 36002 | */ |
| 36003 | #define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex) |
| @@ -36120,159 +36191,32 @@ | |
| 36120 | return iSize; |
| 36121 | } |
| 36122 | } |
| 36123 | #endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */ |
| 36124 | |
| 36125 | #ifdef SQLITE_PAGECACHE_BLOCKALLOC |
| 36126 | /* |
| 36127 | ** The block pBlock belongs to list pList but is not currently linked in. |
| 36128 | ** Insert it into the start of the list. |
| 36129 | */ |
| 36130 | static void addBlockToList(PGroupBlockList *pList, PGroupBlock *pBlock){ |
| 36131 | pBlock->pPrev = 0; |
| 36132 | pBlock->pNext = pList->pFirst; |
| 36133 | pList->pFirst = pBlock; |
| 36134 | if( pBlock->pNext ){ |
| 36135 | pBlock->pNext->pPrev = pBlock; |
| 36136 | }else{ |
| 36137 | assert( pList->pLast==0 ); |
| 36138 | pList->pLast = pBlock; |
| 36139 | } |
| 36140 | } |
| 36141 | |
| 36142 | /* |
| 36143 | ** If there are no blocks in the list headed by pList, remove pList |
| 36144 | ** from the pGroup->pBlockList list and free it with sqlite3_free(). |
| 36145 | */ |
| 36146 | static void freeListIfEmpty(PGroup *pGroup, PGroupBlockList *pList){ |
| 36147 | assert( sqlite3_mutex_held(pGroup->mutex) ); |
| 36148 | if( pList->pFirst==0 ){ |
| 36149 | PGroupBlockList **pp; |
| 36150 | for(pp=&pGroup->pBlockList; *pp!=pList; pp=&(*pp)->pNext); |
| 36151 | *pp = (*pp)->pNext; |
| 36152 | sqlite3_free(pList); |
| 36153 | } |
| 36154 | } |
| 36155 | #endif /* SQLITE_PAGECACHE_BLOCKALLOC */ |
| 36156 | |
| 36157 | /* |
| 36158 | ** Allocate a new page object initially associated with cache pCache. |
| 36159 | */ |
| 36160 | static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ |
| 36161 | int nByte = sizeof(PgHdr1) + pCache->szPage; |
| 36162 | void *pPg = 0; |
| 36163 | PgHdr1 *p; |
| 36164 | |
| 36165 | #ifdef SQLITE_PAGECACHE_BLOCKALLOC |
| 36166 | PGroup *pGroup = pCache->pGroup; |
| 36167 | PGroupBlockList *pList; |
| 36168 | PGroupBlock *pBlock; |
| 36169 | int i; |
| 36170 | |
| 36171 | nByte += sizeof(PGroupBlockList *); |
| 36172 | nByte = ROUND8(nByte); |
| 36173 | |
| 36174 | for(pList=pGroup->pBlockList; pList; pList=pList->pNext){ |
| 36175 | if( pList->nByte==nByte ) break; |
| 36176 | } |
| 36177 | if( pList==0 ){ |
| 36178 | PGroupBlockList *pNew; |
| 36179 | assert( pGroup->isBusy==0 ); |
| 36180 | assert( sqlite3_mutex_held(pGroup->mutex) ); |
| 36181 | pGroup->isBusy = 1; /* Disable sqlite3PcacheReleaseMemory() */ |
| 36182 | pNew = (PGroupBlockList *)sqlite3MallocZero(sizeof(PGroupBlockList)); |
| 36183 | pGroup->isBusy = 0; /* Reenable sqlite3PcacheReleaseMemory() */ |
| 36184 | if( pNew==0 ){ |
| 36185 | /* malloc() failure. Return early. */ |
| 36186 | return 0; |
| 36187 | } |
| 36188 | #ifdef SQLITE_DEBUG |
| 36189 | for(pList=pGroup->pBlockList; pList; pList=pList->pNext){ |
| 36190 | assert( pList->nByte!=nByte ); |
| 36191 | } |
| 36192 | #endif |
| 36193 | pNew->nByte = nByte; |
| 36194 | pNew->pNext = pGroup->pBlockList; |
| 36195 | pGroup->pBlockList = pNew; |
| 36196 | pList = pNew; |
| 36197 | } |
| 36198 | |
| 36199 | pBlock = pList->pFirst; |
| 36200 | if( pBlock==0 || pBlock->mUsed==(((Bitmask)1<<pBlock->nEntry)-1) ){ |
| 36201 | int sz; |
| 36202 | |
| 36203 | /* Allocate a new block. Try to allocate enough space for the PGroupBlock |
| 36204 | ** structure and MINENTRY allocations of nByte bytes each. If the |
| 36205 | ** allocator returns more memory than requested, then more than MINENTRY |
| 36206 | ** allocations may fit in it. */ |
| 36207 | assert( sqlite3_mutex_held(pGroup->mutex) ); |
| 36208 | pcache1LeaveMutex(pCache->pGroup); |
| 36209 | sz = sizeof(PGroupBlock) + PAGECACHE_BLOCKALLOC_MINENTRY * nByte; |
| 36210 | pBlock = (PGroupBlock *)sqlite3Malloc(sz); |
| 36211 | pcache1EnterMutex(pCache->pGroup); |
| 36212 | |
| 36213 | if( !pBlock ){ |
| 36214 | freeListIfEmpty(pGroup, pList); |
| 36215 | return 0; |
| 36216 | } |
| 36217 | pBlock->nEntry = (sqlite3MallocSize(pBlock) - sizeof(PGroupBlock)) / nByte; |
| 36218 | if( pBlock->nEntry>=BMS ){ |
| 36219 | pBlock->nEntry = BMS-1; |
| 36220 | } |
| 36221 | pBlock->pList = pList; |
| 36222 | pBlock->mUsed = 0; |
| 36223 | pBlock->aData = (u8 *)&pBlock[1]; |
| 36224 | addBlockToList(pList, pBlock); |
| 36225 | |
| 36226 | sz = sqlite3MallocSize(pBlock); |
| 36227 | sqlite3_mutex_enter(pcache1.mutex); |
| 36228 | sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz); |
| 36229 | sqlite3_mutex_leave(pcache1.mutex); |
| 36230 | } |
| 36231 | |
| 36232 | for(i=0; pPg==0 && ALWAYS(i<pBlock->nEntry); i++){ |
| 36233 | if( 0==(pBlock->mUsed & ((Bitmask)1<<i)) ){ |
| 36234 | pBlock->mUsed |= ((Bitmask)1<<i); |
| 36235 | pPg = (void *)&pBlock->aData[pList->nByte * i]; |
| 36236 | } |
| 36237 | } |
| 36238 | assert( pPg ); |
| 36239 | PAGE_SET_BLOCKPTR(pCache, pPg, pBlock); |
| 36240 | |
| 36241 | /* If the block is now full, shift it to the end of the list */ |
| 36242 | if( pBlock->mUsed==(((Bitmask)1<<pBlock->nEntry)-1) && pList->pLast!=pBlock ){ |
| 36243 | assert( pList->pFirst==pBlock ); |
| 36244 | assert( pBlock->pPrev==0 ); |
| 36245 | assert( pList->pLast->pNext==0 ); |
| 36246 | pList->pFirst = pBlock->pNext; |
| 36247 | pList->pFirst->pPrev = 0; |
| 36248 | pBlock->pPrev = pList->pLast; |
| 36249 | pBlock->pNext = 0; |
| 36250 | pList->pLast->pNext = pBlock; |
| 36251 | pList->pLast = pBlock; |
| 36252 | } |
| 36253 | p = PAGE_TO_PGHDR1(pCache, pPg); |
| 36254 | if( pCache->bPurgeable ){ |
| 36255 | pCache->pGroup->nCurrentPage++; |
| 36256 | } |
| 36257 | #else |
| 36258 | /* The group mutex must be released before pcache1Alloc() is called. This |
| 36259 | ** is because it may call sqlite3_release_memory(), which assumes that |
| 36260 | ** this mutex is not held. */ |
| 36261 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 36262 | pcache1LeaveMutex(pCache->pGroup); |
| 36263 | pPg = pcache1Alloc(nByte); |
| 36264 | pcache1EnterMutex(pCache->pGroup); |
| 36265 | if( pPg ){ |
| 36266 | p = PAGE_TO_PGHDR1(pCache, pPg); |
| 36267 | if( pCache->bPurgeable ){ |
| 36268 | pCache->pGroup->nCurrentPage++; |
| 36269 | } |
| 36270 | }else{ |
| 36271 | p = 0; |
| 36272 | } |
| 36273 | #endif |
| 36274 | return p; |
| 36275 | } |
| 36276 | |
| 36277 | /* |
| 36278 | ** Free a page object allocated by pcache1AllocPage(). |
| @@ -36282,53 +36226,12 @@ | |
| 36282 | ** with a NULL pointer, so we mark the NULL test with ALWAYS(). |
| 36283 | */ |
| 36284 | static void pcache1FreePage(PgHdr1 *p){ |
| 36285 | if( ALWAYS(p) ){ |
| 36286 | PCache1 *pCache = p->pCache; |
| 36287 | void *pPg = PGHDR1_TO_PAGE(p); |
| 36288 | |
| 36289 | #ifdef SQLITE_PAGECACHE_BLOCKALLOC |
| 36290 | PGroupBlock *pBlock = PAGE_GET_BLOCKPTR(pCache, pPg); |
| 36291 | PGroupBlockList *pList = pBlock->pList; |
| 36292 | int i = ((u8 *)pPg - pBlock->aData) / pList->nByte; |
| 36293 | |
| 36294 | assert( pPg==(void *)&pBlock->aData[i*pList->nByte] ); |
| 36295 | assert( pBlock->mUsed & ((Bitmask)1<<i) ); |
| 36296 | pBlock->mUsed &= ~((Bitmask)1<<i); |
| 36297 | |
| 36298 | /* Remove the block from the list. If it is completely empty, free it. |
| 36299 | ** Or if it is not completely empty, re-insert it at the start of the |
| 36300 | ** list. */ |
| 36301 | if( pList->pFirst==pBlock ){ |
| 36302 | pList->pFirst = pBlock->pNext; |
| 36303 | if( pList->pFirst ) pList->pFirst->pPrev = 0; |
| 36304 | }else{ |
| 36305 | pBlock->pPrev->pNext = pBlock->pNext; |
| 36306 | } |
| 36307 | if( pList->pLast==pBlock ){ |
| 36308 | pList->pLast = pBlock->pPrev; |
| 36309 | if( pList->pLast ) pList->pLast->pNext = 0; |
| 36310 | }else{ |
| 36311 | pBlock->pNext->pPrev = pBlock->pPrev; |
| 36312 | } |
| 36313 | |
| 36314 | if( pBlock->mUsed==0 ){ |
| 36315 | PGroup *pGroup = p->pCache->pGroup; |
| 36316 | |
| 36317 | int sz = sqlite3MallocSize(pBlock); |
| 36318 | sqlite3_mutex_enter(pcache1.mutex); |
| 36319 | sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -sz); |
| 36320 | sqlite3_mutex_leave(pcache1.mutex); |
| 36321 | freeListIfEmpty(pGroup, pList); |
| 36322 | sqlite3_free(pBlock); |
| 36323 | }else{ |
| 36324 | addBlockToList(pList, pBlock); |
| 36325 | } |
| 36326 | #else |
| 36327 | assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) ); |
| 36328 | pcache1Free(pPg); |
| 36329 | #endif |
| 36330 | if( pCache->bPurgeable ){ |
| 36331 | pCache->pGroup->nCurrentPage--; |
| 36332 | } |
| 36333 | } |
| 36334 | } |
| @@ -36935,13 +36838,10 @@ | |
| 36935 | ** been released, the function returns. The return value is the total number |
| 36936 | ** of bytes of memory released. |
| 36937 | */ |
| 36938 | SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){ |
| 36939 | int nFree = 0; |
| 36940 | #ifdef SQLITE_PAGECACHE_BLOCKALLOC |
| 36941 | if( pcache1.grp.isBusy ) return 0; |
| 36942 | #endif |
| 36943 | assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); |
| 36944 | assert( sqlite3_mutex_notheld(pcache1.mutex) ); |
| 36945 | if( pcache1.pStart==0 ){ |
| 36946 | PgHdr1 *p; |
| 36947 | pcache1EnterMutex(&pcache1.grp); |
| @@ -36980,10 +36880,11 @@ | |
| 36980 | } |
| 36981 | #endif |
| 36982 | |
| 36983 | /************** End of pcache1.c *********************************************/ |
| 36984 | /************** Begin file rowset.c ******************************************/ |
| 36985 | /* |
| 36986 | ** 2008 December 3 |
| 36987 | ** |
| 36988 | ** The author disclaims copyright to this source code. In place of |
| 36989 | ** a legal notice, here is a blessing: |
| @@ -37404,10 +37305,11 @@ | |
| 37404 | return 0; |
| 37405 | } |
| 37406 | |
| 37407 | /************** End of rowset.c **********************************************/ |
| 37408 | /************** Begin file pager.c *******************************************/ |
| 37409 | /* |
| 37410 | ** 2001 September 15 |
| 37411 | ** |
| 37412 | ** The author disclaims copyright to this source code. In place of |
| 37413 | ** a legal notice, here is a blessing: |
| @@ -37427,10 +37329,11 @@ | |
| 37427 | ** another is writing. |
| 37428 | */ |
| 37429 | #ifndef SQLITE_OMIT_DISKIO |
| 37430 | /************** Include wal.h in the middle of pager.c ***********************/ |
| 37431 | /************** Begin file wal.h *********************************************/ |
| 37432 | /* |
| 37433 | ** 2010 February 1 |
| 37434 | ** |
| 37435 | ** The author disclaims copyright to this source code. In place of |
| 37436 | ** a legal notice, here is a blessing: |
| @@ -37551,10 +37454,11 @@ | |
| 37551 | #endif /* ifndef SQLITE_OMIT_WAL */ |
| 37552 | #endif /* _WAL_H_ */ |
| 37553 | |
| 37554 | /************** End of wal.h *************************************************/ |
| 37555 | /************** Continuing where we left off in pager.c **********************/ |
| 37556 | |
| 37557 | |
| 37558 | /******************* NOTES ON THE DESIGN OF THE PAGER ************************ |
| 37559 | ** |
| 37560 | ** This comment block describes invariants that hold when using a rollback |
| @@ -38200,12 +38104,12 @@ | |
| 38200 | i64 journalSizeLimit; /* Size limit for persistent journal files */ |
| 38201 | char *zFilename; /* Name of the database file */ |
| 38202 | char *zJournal; /* Name of the journal file */ |
| 38203 | int (*xBusyHandler)(void*); /* Function to call when busy */ |
| 38204 | void *pBusyHandlerArg; /* Context argument for xBusyHandler */ |
| 38205 | #ifdef SQLITE_TEST |
| 38206 | int nHit, nMiss; /* Cache hits and missing */ |
| 38207 | int nRead, nWrite; /* Database pages read/written */ |
| 38208 | #endif |
| 38209 | void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */ |
| 38210 | #ifdef SQLITE_HAS_CODEC |
| 38211 | void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ |
| @@ -41699,11 +41603,11 @@ | |
| 41699 | ** The doNotSpill flag inhibits all cache spilling regardless of whether |
| 41700 | ** or not a sync is required. This is set during a rollback. |
| 41701 | ** |
| 41702 | ** Spilling is also prohibited when in an error state since that could |
| 41703 | ** lead to database corruption. In the current implementaton it |
| 41704 | ** is impossible for sqlite3PCacheFetch() to be called with createFlag==1 |
| 41705 | ** while in the error state, hence it is impossible for this routine to |
| 41706 | ** be called in the error state. Nevertheless, we include a NEVER() |
| 41707 | ** test for the error state as a safeguard against future changes. |
| 41708 | */ |
| 41709 | if( NEVER(pPager->errCode) ) return SQLITE_OK; |
| @@ -42535,18 +42439,17 @@ | |
| 42535 | |
| 42536 | if( (*ppPage)->pPager && !noContent ){ |
| 42537 | /* In this case the pcache already contains an initialized copy of |
| 42538 | ** the page. Return without further ado. */ |
| 42539 | assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) ); |
| 42540 | PAGER_INCR(pPager->nHit); |
| 42541 | return SQLITE_OK; |
| 42542 | |
| 42543 | }else{ |
| 42544 | /* The pager cache has created a new page. Its content needs to |
| 42545 | ** be initialized. */ |
| 42546 | |
| 42547 | PAGER_INCR(pPager->nMiss); |
| 42548 | pPg = *ppPage; |
| 42549 | pPg->pPager = pPager; |
| 42550 | |
| 42551 | /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page |
| 42552 | ** number greater than this, or the unused locking-page, is requested. */ |
| @@ -42578,10 +42481,11 @@ | |
| 42578 | } |
| 42579 | memset(pPg->pData, 0, pPager->pageSize); |
| 42580 | IOTRACE(("ZERO %p %d\n", pPager, pgno)); |
| 42581 | }else{ |
| 42582 | assert( pPg->pPager==pPager ); |
| 42583 | rc = readDbPage(pPg); |
| 42584 | if( rc!=SQLITE_OK ){ |
| 42585 | goto pager_acquire_err; |
| 42586 | } |
| 42587 | } |
| @@ -43611,10 +43515,35 @@ | |
| 43611 | a[9] = pPager->nRead; |
| 43612 | a[10] = pPager->nWrite; |
| 43613 | return a; |
| 43614 | } |
| 43615 | #endif |
| 43616 | |
| 43617 | /* |
| 43618 | ** Return true if this is an in-memory pager. |
| 43619 | */ |
| 43620 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){ |
| @@ -44362,10 +44291,11 @@ | |
| 44362 | |
| 44363 | #endif /* SQLITE_OMIT_DISKIO */ |
| 44364 | |
| 44365 | /************** End of pager.c ***********************************************/ |
| 44366 | /************** Begin file wal.c *********************************************/ |
| 44367 | /* |
| 44368 | ** 2010 February 1 |
| 44369 | ** |
| 44370 | ** The author disclaims copyright to this source code. In place of |
| 44371 | ** a legal notice, here is a blessing: |
| @@ -47316,10 +47246,11 @@ | |
| 47316 | |
| 47317 | #endif /* #ifndef SQLITE_OMIT_WAL */ |
| 47318 | |
| 47319 | /************** End of wal.c *************************************************/ |
| 47320 | /************** Begin file btmutex.c *****************************************/ |
| 47321 | /* |
| 47322 | ** 2007 August 27 |
| 47323 | ** |
| 47324 | ** The author disclaims copyright to this source code. In place of |
| 47325 | ** a legal notice, here is a blessing: |
| @@ -47335,10 +47266,11 @@ | |
| 47335 | ** big and we want to break it down some. This packaged seemed like |
| 47336 | ** a good breakout. |
| 47337 | */ |
| 47338 | /************** Include btreeInt.h in the middle of btmutex.c ****************/ |
| 47339 | /************** Begin file btreeInt.h ****************************************/ |
| 47340 | /* |
| 47341 | ** 2004 April 6 |
| 47342 | ** |
| 47343 | ** The author disclaims copyright to this source code. In place of |
| 47344 | ** a legal notice, here is a blessing: |
| @@ -47980,10 +47912,11 @@ | |
| 47980 | #define get4byte sqlite3Get4byte |
| 47981 | #define put4byte sqlite3Put4byte |
| 47982 | |
| 47983 | /************** End of btreeInt.h ********************************************/ |
| 47984 | /************** Continuing where we left off in btmutex.c ********************/ |
| 47985 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 47986 | #if SQLITE_THREADSAFE |
| 47987 | |
| 47988 | /* |
| 47989 | ** Obtain the BtShared mutex associated with B-Tree handle p. Also, |
| @@ -48252,10 +48185,11 @@ | |
| 48252 | #endif /* if SQLITE_THREADSAFE */ |
| 48253 | #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ |
| 48254 | |
| 48255 | /************** End of btmutex.c *********************************************/ |
| 48256 | /************** Begin file btree.c *******************************************/ |
| 48257 | /* |
| 48258 | ** 2004 April 6 |
| 48259 | ** |
| 48260 | ** The author disclaims copyright to this source code. In place of |
| 48261 | ** a legal notice, here is a blessing: |
| @@ -56439,10 +56373,11 @@ | |
| 56439 | return rc; |
| 56440 | } |
| 56441 | |
| 56442 | /************** End of btree.c ***********************************************/ |
| 56443 | /************** Begin file backup.c ******************************************/ |
| 56444 | /* |
| 56445 | ** 2009 January 28 |
| 56446 | ** |
| 56447 | ** The author disclaims copyright to this source code. In place of |
| 56448 | ** a legal notice, here is a blessing: |
| @@ -57108,13 +57043,21 @@ | |
| 57108 | ** goes wrong, the transaction on pTo is rolled back. If successful, the |
| 57109 | ** transaction is committed before returning. |
| 57110 | */ |
| 57111 | SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ |
| 57112 | int rc; |
| 57113 | sqlite3_backup b; |
| 57114 | sqlite3BtreeEnter(pTo); |
| 57115 | sqlite3BtreeEnter(pFrom); |
| 57116 | |
| 57117 | /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set |
| 57118 | ** to 0. This is used by the implementations of sqlite3_backup_step() |
| 57119 | ** and sqlite3_backup_finish() to detect that they are being called |
| 57120 | ** from this function, not directly by the user. |
| @@ -57137,18 +57080,20 @@ | |
| 57137 | rc = sqlite3_backup_finish(&b); |
| 57138 | if( rc==SQLITE_OK ){ |
| 57139 | pTo->pBt->pageSizeFixed = 0; |
| 57140 | } |
| 57141 | |
| 57142 | sqlite3BtreeLeave(pFrom); |
| 57143 | sqlite3BtreeLeave(pTo); |
| 57144 | return rc; |
| 57145 | } |
| 57146 | #endif /* SQLITE_OMIT_VACUUM */ |
| 57147 | |
| 57148 | /************** End of backup.c **********************************************/ |
| 57149 | /************** Begin file vdbemem.c *****************************************/ |
| 57150 | /* |
| 57151 | ** 2004 May 26 |
| 57152 | ** |
| 57153 | ** The author disclaims copyright to this source code. In place of |
| 57154 | ** a legal notice, here is a blessing: |
| @@ -58171,15 +58116,15 @@ | |
| 58171 | *ppVal = 0; |
| 58172 | return SQLITE_OK; |
| 58173 | } |
| 58174 | op = pExpr->op; |
| 58175 | |
| 58176 | /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT2. |
| 58177 | ** The ifdef here is to enable us to achieve 100% branch test coverage even |
| 58178 | ** when SQLITE_ENABLE_STAT2 is omitted. |
| 58179 | */ |
| 58180 | #ifdef SQLITE_ENABLE_STAT2 |
| 58181 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 58182 | #else |
| 58183 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 58184 | #endif |
| 58185 | |
| @@ -58299,10 +58244,11 @@ | |
| 58299 | return 0; |
| 58300 | } |
| 58301 | |
| 58302 | /************** End of vdbemem.c *********************************************/ |
| 58303 | /************** Begin file vdbeaux.c *****************************************/ |
| 58304 | /* |
| 58305 | ** 2003 September 6 |
| 58306 | ** |
| 58307 | ** The author disclaims copyright to this source code. In place of |
| 58308 | ** a legal notice, here is a blessing: |
| @@ -58874,12 +58820,12 @@ | |
| 58874 | /* |
| 58875 | ** Change the P2 operand of instruction addr so that it points to |
| 58876 | ** the address of the next instruction to be coded. |
| 58877 | */ |
| 58878 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){ |
| 58879 | assert( addr>=0 ); |
| 58880 | sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 58881 | } |
| 58882 | |
| 58883 | |
| 58884 | /* |
| 58885 | ** If the input FuncDef structure is ephemeral, then free it. If |
| @@ -59441,11 +59387,11 @@ | |
| 59441 | SubProgram **apSub = 0; /* Array of sub-vdbes */ |
| 59442 | Mem *pSub = 0; /* Memory cell hold array of subprogs */ |
| 59443 | sqlite3 *db = p->db; /* The database connection */ |
| 59444 | int i; /* Loop counter */ |
| 59445 | int rc = SQLITE_OK; /* Return code */ |
| 59446 | Mem *pMem = p->pResultSet = &p->aMem[1]; /* First Mem of result set */ |
| 59447 | |
| 59448 | assert( p->explain ); |
| 59449 | assert( p->magic==VDBE_MAGIC_RUN ); |
| 59450 | assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM ); |
| 59451 | |
| @@ -59452,10 +59398,11 @@ | |
| 59452 | /* Even though this opcode does not use dynamic strings for |
| 59453 | ** the result, result columns may become dynamic if the user calls |
| 59454 | ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. |
| 59455 | */ |
| 59456 | releaseMemArray(pMem, 8); |
| 59457 | |
| 59458 | if( p->rc==SQLITE_NOMEM ){ |
| 59459 | /* This happens if a malloc() inside a call to sqlite3_column_text() or |
| 59460 | ** sqlite3_column_text16() failed. */ |
| 59461 | db->mallocFailed = 1; |
| @@ -59606,10 +59553,11 @@ | |
| 59606 | pMem->type = SQLITE_NULL; |
| 59607 | } |
| 59608 | } |
| 59609 | |
| 59610 | p->nResColumn = 8 - 4*(p->explain-1); |
| 59611 | p->rc = SQLITE_OK; |
| 59612 | rc = SQLITE_ROW; |
| 59613 | } |
| 59614 | return rc; |
| 59615 | } |
| @@ -61538,10 +61486,11 @@ | |
| 61538 | } |
| 61539 | } |
| 61540 | |
| 61541 | /************** End of vdbeaux.c *********************************************/ |
| 61542 | /************** Begin file vdbeapi.c *****************************************/ |
| 61543 | /* |
| 61544 | ** 2004 May 26 |
| 61545 | ** |
| 61546 | ** The author disclaims copyright to this source code. In place of |
| 61547 | ** a legal notice, here is a blessing: |
| @@ -62845,10 +62794,11 @@ | |
| 62845 | return v; |
| 62846 | } |
| 62847 | |
| 62848 | /************** End of vdbeapi.c *********************************************/ |
| 62849 | /************** Begin file vdbetrace.c ***************************************/ |
| 62850 | /* |
| 62851 | ** 2009 November 25 |
| 62852 | ** |
| 62853 | ** The author disclaims copyright to this source code. In place of |
| 62854 | ** a legal notice, here is a blessing: |
| @@ -63000,10 +62950,11 @@ | |
| 63000 | |
| 63001 | #endif /* #ifndef SQLITE_OMIT_TRACE */ |
| 63002 | |
| 63003 | /************** End of vdbetrace.c *******************************************/ |
| 63004 | /************** Begin file vdbe.c ********************************************/ |
| 63005 | /* |
| 63006 | ** 2001 September 15 |
| 63007 | ** |
| 63008 | ** The author disclaims copyright to this source code. In place of |
| 63009 | ** a legal notice, here is a blessing: |
| @@ -63469,10 +63420,11 @@ | |
| 63469 | ** hwtime.h contains inline assembler code for implementing |
| 63470 | ** high-performance timing routines. |
| 63471 | */ |
| 63472 | /************** Include hwtime.h in the middle of vdbe.c *********************/ |
| 63473 | /************** Begin file hwtime.h ******************************************/ |
| 63474 | /* |
| 63475 | ** 2008 May 27 |
| 63476 | ** |
| 63477 | ** The author disclaims copyright to this source code. In place of |
| 63478 | ** a legal notice, here is a blessing: |
| @@ -63557,10 +63509,11 @@ | |
| 63557 | |
| 63558 | #endif /* !defined(_HWTIME_H_) */ |
| 63559 | |
| 63560 | /************** End of hwtime.h **********************************************/ |
| 63561 | /************** Continuing where we left off in vdbe.c ***********************/ |
| 63562 | |
| 63563 | #endif |
| 63564 | |
| 63565 | /* |
| 63566 | ** The CHECK_FOR_INTERRUPT macro defined here looks to see if the |
| @@ -69801,10 +69754,11 @@ | |
| 69801 | goto vdbe_error_halt; |
| 69802 | } |
| 69803 | |
| 69804 | /************** End of vdbe.c ************************************************/ |
| 69805 | /************** Begin file vdbeblob.c ****************************************/ |
| 69806 | /* |
| 69807 | ** 2007 May 1 |
| 69808 | ** |
| 69809 | ** The author disclaims copyright to this source code. In place of |
| 69810 | ** a legal notice, here is a blessing: |
| @@ -70271,10 +70225,11 @@ | |
| 70271 | |
| 70272 | #endif /* #ifndef SQLITE_OMIT_INCRBLOB */ |
| 70273 | |
| 70274 | /************** End of vdbeblob.c ********************************************/ |
| 70275 | /************** Begin file vdbesort.c ****************************************/ |
| 70276 | /* |
| 70277 | ** 2011 July 9 |
| 70278 | ** |
| 70279 | ** The author disclaims copyright to this source code. In place of |
| 70280 | ** a legal notice, here is a blessing: |
| @@ -71154,10 +71109,11 @@ | |
| 71154 | |
| 71155 | #endif /* #ifndef SQLITE_OMIT_MERGE_SORT */ |
| 71156 | |
| 71157 | /************** End of vdbesort.c ********************************************/ |
| 71158 | /************** Begin file journal.c *****************************************/ |
| 71159 | /* |
| 71160 | ** 2007 August 22 |
| 71161 | ** |
| 71162 | ** The author disclaims copyright to this source code. In place of |
| 71163 | ** a legal notice, here is a blessing: |
| @@ -71394,10 +71350,11 @@ | |
| 71394 | } |
| 71395 | #endif |
| 71396 | |
| 71397 | /************** End of journal.c *********************************************/ |
| 71398 | /************** Begin file memjournal.c **************************************/ |
| 71399 | /* |
| 71400 | ** 2008 October 7 |
| 71401 | ** |
| 71402 | ** The author disclaims copyright to this source code. In place of |
| 71403 | ** a legal notice, here is a blessing: |
| @@ -71655,10 +71612,11 @@ | |
| 71655 | return sizeof(MemJournal); |
| 71656 | } |
| 71657 | |
| 71658 | /************** End of memjournal.c ******************************************/ |
| 71659 | /************** Begin file walker.c ******************************************/ |
| 71660 | /* |
| 71661 | ** 2008 August 16 |
| 71662 | ** |
| 71663 | ** The author disclaims copyright to this source code. In place of |
| 71664 | ** a legal notice, here is a blessing: |
| @@ -71793,10 +71751,11 @@ | |
| 71793 | return rc & WRC_Abort; |
| 71794 | } |
| 71795 | |
| 71796 | /************** End of walker.c **********************************************/ |
| 71797 | /************** Begin file resolve.c *****************************************/ |
| 71798 | /* |
| 71799 | ** 2008 August 18 |
| 71800 | ** |
| 71801 | ** The author disclaims copyright to this source code. In place of |
| 71802 | ** a legal notice, here is a blessing: |
| @@ -73013,10 +72972,11 @@ | |
| 73013 | sqlite3WalkSelect(&w, p); |
| 73014 | } |
| 73015 | |
| 73016 | /************** End of resolve.c *********************************************/ |
| 73017 | /************** Begin file expr.c ********************************************/ |
| 73018 | /* |
| 73019 | ** 2001 September 15 |
| 73020 | ** |
| 73021 | ** The author disclaims copyright to this source code. In place of |
| 73022 | ** a legal notice, here is a blessing: |
| @@ -76770,10 +76730,11 @@ | |
| 76770 | } |
| 76771 | } |
| 76772 | |
| 76773 | /************** End of expr.c ************************************************/ |
| 76774 | /************** Begin file alter.c *******************************************/ |
| 76775 | /* |
| 76776 | ** 2005 February 15 |
| 76777 | ** |
| 76778 | ** The author disclaims copyright to this source code. In place of |
| 76779 | ** a legal notice, here is a blessing: |
| @@ -77598,10 +77559,11 @@ | |
| 77598 | } |
| 77599 | #endif /* SQLITE_ALTER_TABLE */ |
| 77600 | |
| 77601 | /************** End of alter.c ***********************************************/ |
| 77602 | /************** Begin file analyze.c *****************************************/ |
| 77603 | /* |
| 77604 | ** 2005 July 8 |
| 77605 | ** |
| 77606 | ** The author disclaims copyright to this source code. In place of |
| 77607 | ** a legal notice, here is a blessing: |
| @@ -77610,10 +77572,112 @@ | |
| 77610 | ** May you find forgiveness for yourself and forgive others. |
| 77611 | ** May you share freely, never taking more than you give. |
| 77612 | ** |
| 77613 | ************************************************************************* |
| 77614 | ** This file contains code associated with the ANALYZE command. |
| 77615 | */ |
| 77616 | #ifndef SQLITE_OMIT_ANALYZE |
| 77617 | |
| 77618 | /* |
| 77619 | ** This routine generates code that opens the sqlite_stat1 table for |
| @@ -77641,12 +77705,18 @@ | |
| 77641 | static const struct { |
| 77642 | const char *zName; |
| 77643 | const char *zCols; |
| 77644 | } aTable[] = { |
| 77645 | { "sqlite_stat1", "tbl,idx,stat" }, |
| 77646 | #ifdef SQLITE_ENABLE_STAT2 |
| 77647 | { "sqlite_stat2", "tbl,idx,sampleno,sample" }, |
| 77648 | #endif |
| 77649 | }; |
| 77650 | |
| 77651 | int aRoot[] = {0, 0}; |
| 77652 | u8 aCreateTbl[] = {0, 0}; |
| @@ -77658,10 +77728,24 @@ | |
| 77658 | if( v==0 ) return; |
| 77659 | assert( sqlite3BtreeHoldsAllMutexes(db) ); |
| 77660 | assert( sqlite3VdbeDb(v)==db ); |
| 77661 | pDb = &db->aDb[iDb]; |
| 77662 | |
| 77663 | for(i=0; i<ArraySize(aTable); i++){ |
| 77664 | const char *zTab = aTable[i].zName; |
| 77665 | Table *pStat; |
| 77666 | if( (pStat = sqlite3FindTable(db, zTab, pDb->zName))==0 ){ |
| 77667 | /* The sqlite_stat[12] table does not exist. Create it. Note that a |
| @@ -77688,17 +77772,237 @@ | |
| 77688 | sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb); |
| 77689 | } |
| 77690 | } |
| 77691 | } |
| 77692 | |
| 77693 | /* Open the sqlite_stat[12] tables for writing. */ |
| 77694 | for(i=0; i<ArraySize(aTable); i++){ |
| 77695 | sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb); |
| 77696 | sqlite3VdbeChangeP4(v, -1, (char *)3, P4_INT32); |
| 77697 | sqlite3VdbeChangeP5(v, aCreateTbl[i]); |
| 77698 | } |
| 77699 | } |
| 77700 | |
| 77701 | /* |
| 77702 | ** Generate code to do an analysis of all indices associated with |
| 77703 | ** a single table. |
| 77704 | */ |
| @@ -77718,24 +78022,31 @@ | |
| 77718 | int endOfLoop; /* The end of the loop */ |
| 77719 | int jZeroRows = -1; /* Jump from here if number of rows is zero */ |
| 77720 | int iDb; /* Index of database containing pTab */ |
| 77721 | int regTabname = iMem++; /* Register containing table name */ |
| 77722 | int regIdxname = iMem++; /* Register containing index name */ |
| 77723 | int regSampleno = iMem++; /* Register containing next sample number */ |
| 77724 | int regCol = iMem++; /* Content of a column analyzed table */ |
| 77725 | int regRec = iMem++; /* Register holding completed record */ |
| 77726 | int regTemp = iMem++; /* Temporary use register */ |
| 77727 | int regRowid = iMem++; /* Rowid for the inserted record */ |
| 77728 | |
| 77729 | #ifdef SQLITE_ENABLE_STAT2 |
| 77730 | int addr = 0; /* Instruction address */ |
| 77731 | int regTemp2 = iMem++; /* Temporary use register */ |
| 77732 | int regSamplerecno = iMem++; /* Index of next sample to record */ |
| 77733 | int regRecno = iMem++; /* Current sample index */ |
| 77734 | int regLast = iMem++; /* Index of last sample to record */ |
| 77735 | int regFirst = iMem++; /* Index of first sample to record */ |
| 77736 | #endif |
| 77737 | |
| 77738 | v = sqlite3GetVdbe(pParse); |
| 77739 | if( v==0 || NEVER(pTab==0) ){ |
| 77740 | return; |
| 77741 | } |
| @@ -77764,13 +78075,18 @@ | |
| 77764 | iIdxCur = pParse->nTab++; |
| 77765 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0); |
| 77766 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 77767 | int nCol; |
| 77768 | KeyInfo *pKey; |
| 77769 | |
| 77770 | if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; |
| 77771 | nCol = pIdx->nColumn; |
| 77772 | pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 77773 | if( iMem+1+(nCol*2)>pParse->nMem ){ |
| 77774 | pParse->nMem = iMem+1+(nCol*2); |
| 77775 | } |
| 77776 | |
| @@ -77781,35 +78097,24 @@ | |
| 77781 | VdbeComment((v, "%s", pIdx->zName)); |
| 77782 | |
| 77783 | /* Populate the register containing the index name. */ |
| 77784 | sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0); |
| 77785 | |
| 77786 | #ifdef SQLITE_ENABLE_STAT2 |
| 77787 | |
| 77788 | /* If this iteration of the loop is generating code to analyze the |
| 77789 | ** first index in the pTab->pIndex list, then register regLast has |
| 77790 | ** not been populated. In this case populate it now. */ |
| 77791 | if( pTab->pIndex==pIdx ){ |
| 77792 | sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regSamplerecno); |
| 77793 | sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2-1, regTemp); |
| 77794 | sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES*2, regTemp2); |
| 77795 | |
| 77796 | sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regLast); |
| 77797 | sqlite3VdbeAddOp2(v, OP_Null, 0, regFirst); |
| 77798 | addr = sqlite3VdbeAddOp3(v, OP_Lt, regSamplerecno, 0, regLast); |
| 77799 | sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regLast, regFirst); |
| 77800 | sqlite3VdbeAddOp3(v, OP_Multiply, regLast, regTemp, regLast); |
| 77801 | sqlite3VdbeAddOp2(v, OP_AddImm, regLast, SQLITE_INDEX_SAMPLES*2-2); |
| 77802 | sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regLast, regLast); |
| 77803 | sqlite3VdbeJumpHere(v, addr); |
| 77804 | } |
| 77805 | |
| 77806 | /* Zero the regSampleno and regRecno registers. */ |
| 77807 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regSampleno); |
| 77808 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regRecno); |
| 77809 | sqlite3VdbeAddOp2(v, OP_Copy, regFirst, regSamplerecno); |
| 77810 | #endif |
| 77811 | |
| 77812 | /* The block of memory cells initialized here is used as follows. |
| 77813 | ** |
| 77814 | ** iMem: |
| 77815 | ** The total number of rows in the table. |
| @@ -77835,79 +78140,87 @@ | |
| 77835 | /* Start the analysis loop. This loop runs through all the entries in |
| 77836 | ** the index b-tree. */ |
| 77837 | endOfLoop = sqlite3VdbeMakeLabel(v); |
| 77838 | sqlite3VdbeAddOp2(v, OP_Rewind, iIdxCur, endOfLoop); |
| 77839 | topOfLoop = sqlite3VdbeCurrentAddr(v); |
| 77840 | sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1); |
| 77841 | |
| 77842 | for(i=0; i<nCol; i++){ |
| 77843 | CollSeq *pColl; |
| 77844 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol); |
| 77845 | if( i==0 ){ |
| 77846 | #ifdef SQLITE_ENABLE_STAT2 |
| 77847 | /* Check if the record that cursor iIdxCur points to contains a |
| 77848 | ** value that should be stored in the sqlite_stat2 table. If so, |
| 77849 | ** store it. */ |
| 77850 | int ne = sqlite3VdbeAddOp3(v, OP_Ne, regRecno, 0, regSamplerecno); |
| 77851 | assert( regTabname+1==regIdxname |
| 77852 | && regTabname+2==regSampleno |
| 77853 | && regTabname+3==regCol |
| 77854 | ); |
| 77855 | sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); |
| 77856 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 4, regRec, "aaab", 0); |
| 77857 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regRowid); |
| 77858 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regRec, regRowid); |
| 77859 | |
| 77860 | /* Calculate new values for regSamplerecno and regSampleno. |
| 77861 | ** |
| 77862 | ** sampleno = sampleno + 1 |
| 77863 | ** samplerecno = samplerecno+(remaining records)/(remaining samples) |
| 77864 | */ |
| 77865 | sqlite3VdbeAddOp2(v, OP_AddImm, regSampleno, 1); |
| 77866 | sqlite3VdbeAddOp3(v, OP_Subtract, regRecno, regLast, regTemp); |
| 77867 | sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); |
| 77868 | sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_INDEX_SAMPLES, regTemp2); |
| 77869 | sqlite3VdbeAddOp3(v, OP_Subtract, regSampleno, regTemp2, regTemp2); |
| 77870 | sqlite3VdbeAddOp3(v, OP_Divide, regTemp2, regTemp, regTemp); |
| 77871 | sqlite3VdbeAddOp3(v, OP_Add, regSamplerecno, regTemp, regSamplerecno); |
| 77872 | |
| 77873 | sqlite3VdbeJumpHere(v, ne); |
| 77874 | sqlite3VdbeAddOp2(v, OP_AddImm, regRecno, 1); |
| 77875 | #endif |
| 77876 | |
| 77877 | /* Always record the very first row */ |
| 77878 | sqlite3VdbeAddOp1(v, OP_IfNot, iMem+1); |
| 77879 | } |
| 77880 | assert( pIdx->azColl!=0 ); |
| 77881 | assert( pIdx->azColl[i]!=0 ); |
| 77882 | pColl = sqlite3LocateCollSeq(pParse, pIdx->azColl[i]); |
| 77883 | sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem+nCol+i+1, |
| 77884 | (char*)pColl, P4_COLLSEQ); |
| 77885 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 77886 | } |
| 77887 | if( db->mallocFailed ){ |
| 77888 | /* If a malloc failure has occurred, then the result of the expression |
| 77889 | ** passed as the second argument to the call to sqlite3VdbeJumpHere() |
| 77890 | ** below may be negative. Which causes an assert() to fail (or an |
| 77891 | ** out-of-bounds write if SQLITE_DEBUG is not defined). */ |
| 77892 | return; |
| 77893 | } |
| 77894 | sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop); |
| 77895 | for(i=0; i<nCol; i++){ |
| 77896 | int addr2 = sqlite3VdbeCurrentAddr(v) - (nCol*2); |
| 77897 | if( i==0 ){ |
| 77898 | sqlite3VdbeJumpHere(v, addr2-1); /* Set jump dest for the OP_IfNot */ |
| 77899 | } |
| 77900 | sqlite3VdbeJumpHere(v, addr2); /* Set jump dest for the OP_Ne */ |
| 77901 | sqlite3VdbeAddOp2(v, OP_AddImm, iMem+i+1, 1); |
| 77902 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, iMem+nCol+i+1); |
| 77903 | } |
| 77904 | |
| 77905 | /* End of the analysis loop. */ |
| 77906 | sqlite3VdbeResolveLabel(v, endOfLoop); |
| 77907 | sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, topOfLoop); |
| 77908 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 77909 | |
| 77910 | /* Store the results in sqlite_stat1. |
| 77911 | ** |
| 77912 | ** The result is a single row of the sqlite_stat1 table. The first |
| 77913 | ** two columns are the names of the table and index. The third column |
| @@ -77923,50 +78236,51 @@ | |
| 77923 | ** |
| 77924 | ** If K==0 then no entry is made into the sqlite_stat1 table. |
| 77925 | ** If K>0 then it is always the case the D>0 so division by zero |
| 77926 | ** is never possible. |
| 77927 | */ |
| 77928 | sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regSampleno); |
| 77929 | if( jZeroRows<0 ){ |
| 77930 | jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); |
| 77931 | } |
| 77932 | for(i=0; i<nCol; i++){ |
| 77933 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0); |
| 77934 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); |
| 77935 | sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp); |
| 77936 | sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); |
| 77937 | sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp); |
| 77938 | sqlite3VdbeAddOp1(v, OP_ToInt, regTemp); |
| 77939 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regSampleno, regSampleno); |
| 77940 | } |
| 77941 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 77942 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); |
| 77943 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); |
| 77944 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 77945 | } |
| 77946 | |
| 77947 | /* If the table has no indices, create a single sqlite_stat1 entry |
| 77948 | ** containing NULL as the index name and the row count as the content. |
| 77949 | */ |
| 77950 | if( pTab->pIndex==0 ){ |
| 77951 | sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb); |
| 77952 | VdbeComment((v, "%s", pTab->zName)); |
| 77953 | sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regSampleno); |
| 77954 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 77955 | jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regSampleno); |
| 77956 | }else{ |
| 77957 | sqlite3VdbeJumpHere(v, jZeroRows); |
| 77958 | jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto); |
| 77959 | } |
| 77960 | sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); |
| 77961 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 77962 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regRowid); |
| 77963 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regRowid); |
| 77964 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 77965 | if( pParse->nMem<regRec ) pParse->nMem = regRec; |
| 77966 | sqlite3VdbeJumpHere(v, jZeroRows); |
| 77967 | } |
| 77968 | |
| 77969 | /* |
| 77970 | ** Generate code that will cause the most recent index analysis to |
| 77971 | ** be loaded into internal hash tables where is can be used. |
| 77972 | */ |
| @@ -77987,11 +78301,11 @@ | |
| 77987 | int iStatCur; |
| 77988 | int iMem; |
| 77989 | |
| 77990 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| 77991 | iStatCur = pParse->nTab; |
| 77992 | pParse->nTab += 2; |
| 77993 | openStatTable(pParse, iDb, iStatCur, 0, 0); |
| 77994 | iMem = pParse->nMem+1; |
| 77995 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 77996 | for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 77997 | Table *pTab = (Table*)sqliteHashData(k); |
| @@ -78012,11 +78326,11 @@ | |
| 78012 | assert( pTab!=0 ); |
| 78013 | assert( sqlite3BtreeHoldsAllMutexes(pParse->db) ); |
| 78014 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
| 78015 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| 78016 | iStatCur = pParse->nTab; |
| 78017 | pParse->nTab += 2; |
| 78018 | if( pOnlyIdx ){ |
| 78019 | openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, "idx"); |
| 78020 | }else{ |
| 78021 | openStatTable(pParse, iDb, iStatCur, pTab->zName, "tbl"); |
| 78022 | } |
| @@ -78117,11 +78431,11 @@ | |
| 78117 | static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){ |
| 78118 | analysisInfo *pInfo = (analysisInfo*)pData; |
| 78119 | Index *pIndex; |
| 78120 | Table *pTable; |
| 78121 | int i, c, n; |
| 78122 | unsigned int v; |
| 78123 | const char *z; |
| 78124 | |
| 78125 | assert( argc==3 ); |
| 78126 | UNUSED_PARAMETER2(NotUsed, argc); |
| 78127 | |
| @@ -78160,40 +78474,172 @@ | |
| 78160 | /* |
| 78161 | ** If the Index.aSample variable is not NULL, delete the aSample[] array |
| 78162 | ** and its contents. |
| 78163 | */ |
| 78164 | SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){ |
| 78165 | #ifdef SQLITE_ENABLE_STAT2 |
| 78166 | if( pIdx->aSample ){ |
| 78167 | int j; |
| 78168 | for(j=0; j<SQLITE_INDEX_SAMPLES; j++){ |
| 78169 | IndexSample *p = &pIdx->aSample[j]; |
| 78170 | if( p->eType==SQLITE_TEXT || p->eType==SQLITE_BLOB ){ |
| 78171 | sqlite3DbFree(db, p->u.z); |
| 78172 | } |
| 78173 | } |
| 78174 | sqlite3DbFree(db, pIdx->aSample); |
| 78175 | } |
| 78176 | #else |
| 78177 | UNUSED_PARAMETER(db); |
| 78178 | UNUSED_PARAMETER(pIdx); |
| 78179 | #endif |
| 78180 | } |
| 78181 | |
| 78182 | /* |
| 78183 | ** Load the content of the sqlite_stat1 and sqlite_stat2 tables. The |
| 78184 | ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] |
| 78185 | ** arrays. The contents of sqlite_stat2 are used to populate the |
| 78186 | ** Index.aSample[] arrays. |
| 78187 | ** |
| 78188 | ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR |
| 78189 | ** is returned. In this case, even if SQLITE_ENABLE_STAT2 was defined |
| 78190 | ** during compilation and the sqlite_stat2 table is present, no data is |
| 78191 | ** read from it. |
| 78192 | ** |
| 78193 | ** If SQLITE_ENABLE_STAT2 was defined during compilation and the |
| 78194 | ** sqlite_stat2 table is not present in the database, SQLITE_ERROR is |
| 78195 | ** returned. However, in this case, data is read from the sqlite_stat1 |
| 78196 | ** table (if it is present) before returning. |
| 78197 | ** |
| 78198 | ** If an OOM error occurs, this function always sets db->mallocFailed. |
| 78199 | ** This means if the caller does not care about other errors, the return |
| @@ -78211,12 +78657,14 @@ | |
| 78211 | /* Clear any prior statistics */ |
| 78212 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 78213 | for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ |
| 78214 | Index *pIdx = sqliteHashData(i); |
| 78215 | sqlite3DefaultRowEst(pIdx); |
| 78216 | sqlite3DeleteIndexSamples(db, pIdx); |
| 78217 | pIdx->aSample = 0; |
| 78218 | } |
| 78219 | |
| 78220 | /* Check to make sure the sqlite_stat1 table exists */ |
| 78221 | sInfo.db = db; |
| 78222 | sInfo.zDatabase = db->aDb[iDb].zName; |
| @@ -78224,91 +78672,23 @@ | |
| 78224 | return SQLITE_ERROR; |
| 78225 | } |
| 78226 | |
| 78227 | /* Load new statistics out of the sqlite_stat1 table */ |
| 78228 | zSql = sqlite3MPrintf(db, |
| 78229 | "SELECT tbl, idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase); |
| 78230 | if( zSql==0 ){ |
| 78231 | rc = SQLITE_NOMEM; |
| 78232 | }else{ |
| 78233 | rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); |
| 78234 | sqlite3DbFree(db, zSql); |
| 78235 | } |
| 78236 | |
| 78237 | |
| 78238 | /* Load the statistics from the sqlite_stat2 table. */ |
| 78239 | #ifdef SQLITE_ENABLE_STAT2 |
| 78240 | if( rc==SQLITE_OK && !sqlite3FindTable(db, "sqlite_stat2", sInfo.zDatabase) ){ |
| 78241 | rc = SQLITE_ERROR; |
| 78242 | } |
| 78243 | if( rc==SQLITE_OK ){ |
| 78244 | sqlite3_stmt *pStmt = 0; |
| 78245 | |
| 78246 | zSql = sqlite3MPrintf(db, |
| 78247 | "SELECT idx,sampleno,sample FROM %Q.sqlite_stat2", sInfo.zDatabase); |
| 78248 | if( !zSql ){ |
| 78249 | rc = SQLITE_NOMEM; |
| 78250 | }else{ |
| 78251 | rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); |
| 78252 | sqlite3DbFree(db, zSql); |
| 78253 | } |
| 78254 | |
| 78255 | if( rc==SQLITE_OK ){ |
| 78256 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 78257 | char *zIndex; /* Index name */ |
| 78258 | Index *pIdx; /* Pointer to the index object */ |
| 78259 | |
| 78260 | zIndex = (char *)sqlite3_column_text(pStmt, 0); |
| 78261 | pIdx = zIndex ? sqlite3FindIndex(db, zIndex, sInfo.zDatabase) : 0; |
| 78262 | if( pIdx ){ |
| 78263 | int iSample = sqlite3_column_int(pStmt, 1); |
| 78264 | if( iSample<SQLITE_INDEX_SAMPLES && iSample>=0 ){ |
| 78265 | int eType = sqlite3_column_type(pStmt, 2); |
| 78266 | |
| 78267 | if( pIdx->aSample==0 ){ |
| 78268 | static const int sz = sizeof(IndexSample)*SQLITE_INDEX_SAMPLES; |
| 78269 | pIdx->aSample = (IndexSample *)sqlite3DbMallocRaw(0, sz); |
| 78270 | if( pIdx->aSample==0 ){ |
| 78271 | db->mallocFailed = 1; |
| 78272 | break; |
| 78273 | } |
| 78274 | memset(pIdx->aSample, 0, sz); |
| 78275 | } |
| 78276 | |
| 78277 | assert( pIdx->aSample ); |
| 78278 | { |
| 78279 | IndexSample *pSample = &pIdx->aSample[iSample]; |
| 78280 | pSample->eType = (u8)eType; |
| 78281 | if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 78282 | pSample->u.r = sqlite3_column_double(pStmt, 2); |
| 78283 | }else if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){ |
| 78284 | const char *z = (const char *)( |
| 78285 | (eType==SQLITE_BLOB) ? |
| 78286 | sqlite3_column_blob(pStmt, 2): |
| 78287 | sqlite3_column_text(pStmt, 2) |
| 78288 | ); |
| 78289 | int n = sqlite3_column_bytes(pStmt, 2); |
| 78290 | if( n>24 ){ |
| 78291 | n = 24; |
| 78292 | } |
| 78293 | pSample->nByte = (u8)n; |
| 78294 | if( n < 1){ |
| 78295 | pSample->u.z = 0; |
| 78296 | }else{ |
| 78297 | pSample->u.z = sqlite3DbStrNDup(0, z, n); |
| 78298 | if( pSample->u.z==0 ){ |
| 78299 | db->mallocFailed = 1; |
| 78300 | break; |
| 78301 | } |
| 78302 | } |
| 78303 | } |
| 78304 | } |
| 78305 | } |
| 78306 | } |
| 78307 | } |
| 78308 | rc = sqlite3_finalize(pStmt); |
| 78309 | } |
| 78310 | } |
| 78311 | #endif |
| 78312 | |
| 78313 | if( rc==SQLITE_NOMEM ){ |
| 78314 | db->mallocFailed = 1; |
| @@ -78319,10 +78699,11 @@ | |
| 78319 | |
| 78320 | #endif /* SQLITE_OMIT_ANALYZE */ |
| 78321 | |
| 78322 | /************** End of analyze.c *********************************************/ |
| 78323 | /************** Begin file attach.c ******************************************/ |
| 78324 | /* |
| 78325 | ** 2003 April 6 |
| 78326 | ** |
| 78327 | ** The author disclaims copyright to this source code. In place of |
| 78328 | ** a legal notice, here is a blessing: |
| @@ -78878,10 +79259,11 @@ | |
| 78878 | } |
| 78879 | #endif |
| 78880 | |
| 78881 | /************** End of attach.c **********************************************/ |
| 78882 | /************** Begin file auth.c ********************************************/ |
| 78883 | /* |
| 78884 | ** 2003 January 11 |
| 78885 | ** |
| 78886 | ** The author disclaims copyright to this source code. In place of |
| 78887 | ** a legal notice, here is a blessing: |
| @@ -79129,10 +79511,11 @@ | |
| 79129 | |
| 79130 | #endif /* SQLITE_OMIT_AUTHORIZATION */ |
| 79131 | |
| 79132 | /************** End of auth.c ************************************************/ |
| 79133 | /************** Begin file build.c *******************************************/ |
| 79134 | /* |
| 79135 | ** 2001 September 15 |
| 79136 | ** |
| 79137 | ** The author disclaims copyright to this source code. In place of |
| 79138 | ** a legal notice, here is a blessing: |
| @@ -81120,11 +81503,15 @@ | |
| 81120 | Parse *pParse, /* The parsing context */ |
| 81121 | int iDb, /* The database number */ |
| 81122 | const char *zType, /* "idx" or "tbl" */ |
| 81123 | const char *zName /* Name of index or table */ |
| 81124 | ){ |
| 81125 | static const char *azStatTab[] = { "sqlite_stat1", "sqlite_stat2" }; |
| 81126 | int i; |
| 81127 | const char *zDbName = pParse->db->aDb[iDb].zName; |
| 81128 | for(i=0; i<ArraySize(azStatTab); i++){ |
| 81129 | if( sqlite3FindTable(pParse->db, azStatTab[i], zDbName) ){ |
| 81130 | sqlite3NestedParse(pParse, |
| @@ -81132,10 +81519,80 @@ | |
| 81132 | zDbName, azStatTab[i], zType, zName |
| 81133 | ); |
| 81134 | } |
| 81135 | } |
| 81136 | } |
| 81137 | |
| 81138 | /* |
| 81139 | ** This routine is called to do the work of a DROP TABLE statement. |
| 81140 | ** pName is the name of the table to be dropped. |
| 81141 | */ |
| @@ -81225,72 +81682,15 @@ | |
| 81225 | /* Generate code to remove the table from the master table |
| 81226 | ** on disk. |
| 81227 | */ |
| 81228 | v = sqlite3GetVdbe(pParse); |
| 81229 | if( v ){ |
| 81230 | Trigger *pTrigger; |
| 81231 | Db *pDb = &db->aDb[iDb]; |
| 81232 | sqlite3BeginWriteOperation(pParse, 1, iDb); |
| 81233 | |
| 81234 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 81235 | if( IsVirtual(pTab) ){ |
| 81236 | sqlite3VdbeAddOp0(v, OP_VBegin); |
| 81237 | } |
| 81238 | #endif |
| 81239 | sqlite3FkDropTable(pParse, pName, pTab); |
| 81240 | |
| 81241 | /* Drop all triggers associated with the table being dropped. Code |
| 81242 | ** is generated to remove entries from sqlite_master and/or |
| 81243 | ** sqlite_temp_master if required. |
| 81244 | */ |
| 81245 | pTrigger = sqlite3TriggerList(pParse, pTab); |
| 81246 | while( pTrigger ){ |
| 81247 | assert( pTrigger->pSchema==pTab->pSchema || |
| 81248 | pTrigger->pSchema==db->aDb[1].pSchema ); |
| 81249 | sqlite3DropTriggerPtr(pParse, pTrigger); |
| 81250 | pTrigger = pTrigger->pNext; |
| 81251 | } |
| 81252 | |
| 81253 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 81254 | /* Remove any entries of the sqlite_sequence table associated with |
| 81255 | ** the table being dropped. This is done before the table is dropped |
| 81256 | ** at the btree level, in case the sqlite_sequence table needs to |
| 81257 | ** move as a result of the drop (can happen in auto-vacuum mode). |
| 81258 | */ |
| 81259 | if( pTab->tabFlags & TF_Autoincrement ){ |
| 81260 | sqlite3NestedParse(pParse, |
| 81261 | "DELETE FROM %s.sqlite_sequence WHERE name=%Q", |
| 81262 | pDb->zName, pTab->zName |
| 81263 | ); |
| 81264 | } |
| 81265 | #endif |
| 81266 | |
| 81267 | /* Drop all SQLITE_MASTER table and index entries that refer to the |
| 81268 | ** table. The program name loops through the master table and deletes |
| 81269 | ** every row that refers to a table of the same name as the one being |
| 81270 | ** dropped. Triggers are handled seperately because a trigger can be |
| 81271 | ** created in the temp database that refers to a table in another |
| 81272 | ** database. |
| 81273 | */ |
| 81274 | sqlite3NestedParse(pParse, |
| 81275 | "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", |
| 81276 | pDb->zName, SCHEMA_TABLE(iDb), pTab->zName); |
| 81277 | sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName); |
| 81278 | if( !isView && !IsVirtual(pTab) ){ |
| 81279 | destroyTable(pParse, pTab); |
| 81280 | } |
| 81281 | |
| 81282 | /* Remove the table entry from SQLite's internal schema and modify |
| 81283 | ** the schema cookie. |
| 81284 | */ |
| 81285 | if( IsVirtual(pTab) ){ |
| 81286 | sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0); |
| 81287 | } |
| 81288 | sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); |
| 81289 | sqlite3ChangeCookie(pParse, iDb); |
| 81290 | } |
| 81291 | sqliteViewResetAll(db, iDb); |
| 81292 | |
| 81293 | exit_drop_table: |
| 81294 | sqlite3SrcListDelete(db, pName); |
| 81295 | } |
| 81296 | |
| @@ -81769,24 +82169,24 @@ | |
| 81769 | */ |
| 81770 | nName = sqlite3Strlen30(zName); |
| 81771 | nCol = pList->nExpr; |
| 81772 | pIndex = sqlite3DbMallocZero(db, |
| 81773 | sizeof(Index) + /* Index structure */ |
| 81774 | sizeof(int)*nCol + /* Index.aiColumn */ |
| 81775 | sizeof(int)*(nCol+1) + /* Index.aiRowEst */ |
| 81776 | sizeof(char *)*nCol + /* Index.azColl */ |
| 81777 | sizeof(u8)*nCol + /* Index.aSortOrder */ |
| 81778 | nName + 1 + /* Index.zName */ |
| 81779 | nExtra /* Collation sequence names */ |
| 81780 | ); |
| 81781 | if( db->mallocFailed ){ |
| 81782 | goto exit_create_index; |
| 81783 | } |
| 81784 | pIndex->azColl = (char**)(&pIndex[1]); |
| 81785 | pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]); |
| 81786 | pIndex->aiRowEst = (unsigned *)(&pIndex->aiColumn[nCol]); |
| 81787 | pIndex->aSortOrder = (u8 *)(&pIndex->aiRowEst[nCol+1]); |
| 81788 | pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]); |
| 81789 | zExtra = (char *)(&pIndex->zName[nName+1]); |
| 81790 | memcpy(pIndex->zName, zName, nName+1); |
| 81791 | pIndex->pTable = pTab; |
| 81792 | pIndex->nColumn = pList->nExpr; |
| @@ -82059,13 +82459,13 @@ | |
| 82059 | ** Apart from that, we have little to go on besides intuition as to |
| 82060 | ** how aiRowEst[] should be initialized. The numbers generated here |
| 82061 | ** are based on typical values found in actual indices. |
| 82062 | */ |
| 82063 | SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){ |
| 82064 | unsigned *a = pIdx->aiRowEst; |
| 82065 | int i; |
| 82066 | unsigned n; |
| 82067 | assert( a!=0 ); |
| 82068 | a[0] = pIdx->pTable->nRowEst; |
| 82069 | if( a[0]<10 ) a[0] = 10; |
| 82070 | n = 10; |
| 82071 | for(i=1; i<=pIdx->nColumn; i++){ |
| @@ -82932,10 +83332,11 @@ | |
| 82932 | return pKey; |
| 82933 | } |
| 82934 | |
| 82935 | /************** End of build.c ***********************************************/ |
| 82936 | /************** Begin file callback.c ****************************************/ |
| 82937 | /* |
| 82938 | ** 2005 May 23 |
| 82939 | ** |
| 82940 | ** The author disclaims copyright to this source code. In place of |
| 82941 | ** a legal notice, here is a blessing: |
| @@ -83391,10 +83792,11 @@ | |
| 83391 | return p; |
| 83392 | } |
| 83393 | |
| 83394 | /************** End of callback.c ********************************************/ |
| 83395 | /************** Begin file delete.c ******************************************/ |
| 83396 | /* |
| 83397 | ** 2001 September 15 |
| 83398 | ** |
| 83399 | ** The author disclaims copyright to this source code. In place of |
| 83400 | ** a legal notice, here is a blessing: |
| @@ -84045,10 +84447,11 @@ | |
| 84045 | return regBase; |
| 84046 | } |
| 84047 | |
| 84048 | /************** End of delete.c **********************************************/ |
| 84049 | /************** Begin file func.c ********************************************/ |
| 84050 | /* |
| 84051 | ** 2002 February 23 |
| 84052 | ** |
| 84053 | ** The author disclaims copyright to this source code. In place of |
| 84054 | ** a legal notice, here is a blessing: |
| @@ -85653,10 +86056,11 @@ | |
| 85653 | #endif |
| 85654 | } |
| 85655 | |
| 85656 | /************** End of func.c ************************************************/ |
| 85657 | /************** Begin file fkey.c ********************************************/ |
| 85658 | /* |
| 85659 | ** |
| 85660 | ** The author disclaims copyright to this source code. In place of |
| 85661 | ** a legal notice, here is a blessing: |
| 85662 | ** |
| @@ -86873,10 +87277,11 @@ | |
| 86873 | } |
| 86874 | #endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */ |
| 86875 | |
| 86876 | /************** End of fkey.c ************************************************/ |
| 86877 | /************** Begin file insert.c ******************************************/ |
| 86878 | /* |
| 86879 | ** 2001 September 15 |
| 86880 | ** |
| 86881 | ** The author disclaims copyright to this source code. In place of |
| 86882 | ** a legal notice, here is a blessing: |
| @@ -88621,10 +89026,13 @@ | |
| 88621 | */ |
| 88622 | if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){ |
| 88623 | return 0; |
| 88624 | } |
| 88625 | #endif |
| 88626 | |
| 88627 | /* If we get this far, it means either: |
| 88628 | ** |
| 88629 | ** * We can always do the transfer if the table contains an |
| 88630 | ** an integer primary key |
| @@ -88718,10 +89126,11 @@ | |
| 88718 | } |
| 88719 | #endif /* SQLITE_OMIT_XFER_OPT */ |
| 88720 | |
| 88721 | /************** End of insert.c **********************************************/ |
| 88722 | /************** Begin file legacy.c ******************************************/ |
| 88723 | /* |
| 88724 | ** 2001 September 15 |
| 88725 | ** |
| 88726 | ** The author disclaims copyright to this source code. In place of |
| 88727 | ** a legal notice, here is a blessing: |
| @@ -88865,10 +89274,11 @@ | |
| 88865 | return rc; |
| 88866 | } |
| 88867 | |
| 88868 | /************** End of legacy.c **********************************************/ |
| 88869 | /************** Begin file loadext.c *****************************************/ |
| 88870 | /* |
| 88871 | ** 2006 June 7 |
| 88872 | ** |
| 88873 | ** The author disclaims copyright to this source code. In place of |
| 88874 | ** a legal notice, here is a blessing: |
| @@ -88885,10 +89295,11 @@ | |
| 88885 | #ifndef SQLITE_CORE |
| 88886 | #define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ |
| 88887 | #endif |
| 88888 | /************** Include sqlite3ext.h in the middle of loadext.c **************/ |
| 88889 | /************** Begin file sqlite3ext.h **************************************/ |
| 88890 | /* |
| 88891 | ** 2006 June 7 |
| 88892 | ** |
| 88893 | ** The author disclaims copyright to this source code. In place of |
| 88894 | ** a legal notice, here is a blessing: |
| @@ -89313,10 +89724,11 @@ | |
| 89313 | |
| 89314 | #endif /* _SQLITE3EXT_H_ */ |
| 89315 | |
| 89316 | /************** End of sqlite3ext.h ******************************************/ |
| 89317 | /************** Continuing where we left off in loadext.c ********************/ |
| 89318 | /* #include <string.h> */ |
| 89319 | |
| 89320 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 89321 | |
| 89322 | /* |
| @@ -89952,10 +90364,11 @@ | |
| 89952 | } |
| 89953 | } |
| 89954 | |
| 89955 | /************** End of loadext.c *********************************************/ |
| 89956 | /************** Begin file pragma.c ******************************************/ |
| 89957 | /* |
| 89958 | ** 2003 April 6 |
| 89959 | ** |
| 89960 | ** The author disclaims copyright to this source code. In place of |
| 89961 | ** a legal notice, here is a blessing: |
| @@ -91480,10 +91893,11 @@ | |
| 91480 | |
| 91481 | #endif /* SQLITE_OMIT_PRAGMA */ |
| 91482 | |
| 91483 | /************** End of pragma.c **********************************************/ |
| 91484 | /************** Begin file prepare.c *****************************************/ |
| 91485 | /* |
| 91486 | ** 2005 May 25 |
| 91487 | ** |
| 91488 | ** The author disclaims copyright to this source code. In place of |
| 91489 | ** a legal notice, here is a blessing: |
| @@ -92340,10 +92754,11 @@ | |
| 92340 | |
| 92341 | #endif /* SQLITE_OMIT_UTF16 */ |
| 92342 | |
| 92343 | /************** End of prepare.c *********************************************/ |
| 92344 | /************** Begin file select.c ******************************************/ |
| 92345 | /* |
| 92346 | ** 2001 September 15 |
| 92347 | ** |
| 92348 | ** The author disclaims copyright to this source code. In place of |
| 92349 | ** a legal notice, here is a blessing: |
| @@ -96928,10 +97343,11 @@ | |
| 96928 | *****************************************************************************/ |
| 96929 | #endif /* defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */ |
| 96930 | |
| 96931 | /************** End of select.c **********************************************/ |
| 96932 | /************** Begin file table.c *******************************************/ |
| 96933 | /* |
| 96934 | ** 2001 September 15 |
| 96935 | ** |
| 96936 | ** The author disclaims copyright to this source code. In place of |
| 96937 | ** a legal notice, here is a blessing: |
| @@ -97127,10 +97543,11 @@ | |
| 97127 | |
| 97128 | #endif /* SQLITE_OMIT_GET_TABLE */ |
| 97129 | |
| 97130 | /************** End of table.c ***********************************************/ |
| 97131 | /************** Begin file trigger.c *****************************************/ |
| 97132 | /* |
| 97133 | ** |
| 97134 | ** The author disclaims copyright to this source code. In place of |
| 97135 | ** a legal notice, here is a blessing: |
| 97136 | ** |
| @@ -98252,10 +98669,11 @@ | |
| 98252 | |
| 98253 | #endif /* !defined(SQLITE_OMIT_TRIGGER) */ |
| 98254 | |
| 98255 | /************** End of trigger.c *********************************************/ |
| 98256 | /************** Begin file update.c ******************************************/ |
| 98257 | /* |
| 98258 | ** 2001 September 15 |
| 98259 | ** |
| 98260 | ** The author disclaims copyright to this source code. In place of |
| 98261 | ** a legal notice, here is a blessing: |
| @@ -98924,10 +99342,11 @@ | |
| 98924 | } |
| 98925 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 98926 | |
| 98927 | /************** End of update.c **********************************************/ |
| 98928 | /************** Begin file vacuum.c ******************************************/ |
| 98929 | /* |
| 98930 | ** 2003 April 6 |
| 98931 | ** |
| 98932 | ** The author disclaims copyright to this source code. In place of |
| 98933 | ** a legal notice, here is a blessing: |
| @@ -98969,11 +99388,11 @@ | |
| 98969 | if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ |
| 98970 | sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db)); |
| 98971 | return sqlite3_errcode(db); |
| 98972 | } |
| 98973 | VVA_ONLY( rc = ) sqlite3_step(pStmt); |
| 98974 | assert( rc!=SQLITE_ROW ); |
| 98975 | return vacuumFinalize(db, pStmt, pzErrMsg); |
| 98976 | } |
| 98977 | |
| 98978 | /* |
| 98979 | ** Execute zSql on database db. The statement returns exactly |
| @@ -99187,17 +99606,15 @@ | |
| 99187 | " WHERE type='view' OR type='trigger'" |
| 99188 | " OR (type='table' AND rootpage=0)" |
| 99189 | ); |
| 99190 | if( rc ) goto end_of_vacuum; |
| 99191 | |
| 99192 | /* At this point, unless the main db was completely empty, there is now a |
| 99193 | ** transaction open on the vacuum database, but not on the main database. |
| 99194 | ** Open a btree level transaction on the main database. This allows a |
| 99195 | ** call to sqlite3BtreeCopyFile(). The main database btree level |
| 99196 | ** transaction is then committed, so the SQL level never knows it was |
| 99197 | ** opened for writing. This way, the SQL transaction used to create the |
| 99198 | ** temporary database never needs to be committed. |
| 99199 | */ |
| 99200 | { |
| 99201 | u32 meta; |
| 99202 | int i; |
| 99203 | |
| @@ -99270,10 +99687,11 @@ | |
| 99270 | |
| 99271 | #endif /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ |
| 99272 | |
| 99273 | /************** End of vacuum.c **********************************************/ |
| 99274 | /************** Begin file vtab.c ********************************************/ |
| 99275 | /* |
| 99276 | ** 2006 June 10 |
| 99277 | ** |
| 99278 | ** The author disclaims copyright to this source code. In place of |
| 99279 | ** a legal notice, here is a blessing: |
| @@ -100338,10 +100756,11 @@ | |
| 100338 | |
| 100339 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 100340 | |
| 100341 | /************** End of vtab.c ************************************************/ |
| 100342 | /************** Begin file where.c *******************************************/ |
| 100343 | /* |
| 100344 | ** 2001 September 15 |
| 100345 | ** |
| 100346 | ** The author disclaims copyright to this source code. In place of |
| 100347 | ** a legal notice, here is a blessing: |
| @@ -100457,25 +100876,35 @@ | |
| 100457 | #define TERM_CODED 0x04 /* This term is already coded */ |
| 100458 | #define TERM_COPIED 0x08 /* Has a child */ |
| 100459 | #define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ |
| 100460 | #define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ |
| 100461 | #define TERM_OR_OK 0x40 /* Used during OR-clause processing */ |
| 100462 | #ifdef SQLITE_ENABLE_STAT2 |
| 100463 | # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */ |
| 100464 | #else |
| 100465 | # define TERM_VNULL 0x00 /* Disabled if not using stat2 */ |
| 100466 | #endif |
| 100467 | |
| 100468 | /* |
| 100469 | ** An instance of the following structure holds all information about a |
| 100470 | ** WHERE clause. Mostly this is a container for one or more WhereTerms. |
| 100471 | */ |
| 100472 | struct WhereClause { |
| 100473 | Parse *pParse; /* The parser context */ |
| 100474 | WhereMaskSet *pMaskSet; /* Mapping of table cursor numbers to bitmasks */ |
| 100475 | Bitmask vmask; /* Bitmask identifying virtual table cursors */ |
| 100476 | u8 op; /* Split operator. TK_AND or TK_OR */ |
| 100477 | int nTerm; /* Number of terms */ |
| 100478 | int nSlot; /* Number of entries in a[] */ |
| 100479 | WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */ |
| 100480 | #if defined(SQLITE_SMALL_STACK) |
| 100481 | WhereTerm aStatic[1]; /* Initial static space for a[] */ |
| @@ -100600,18 +101029,21 @@ | |
| 100600 | ** Initialize a preallocated WhereClause structure. |
| 100601 | */ |
| 100602 | static void whereClauseInit( |
| 100603 | WhereClause *pWC, /* The WhereClause to be initialized */ |
| 100604 | Parse *pParse, /* The parsing context */ |
| 100605 | WhereMaskSet *pMaskSet /* Mapping from table cursor numbers to bitmasks */ |
| 100606 | ){ |
| 100607 | pWC->pParse = pParse; |
| 100608 | pWC->pMaskSet = pMaskSet; |
| 100609 | pWC->nTerm = 0; |
| 100610 | pWC->nSlot = ArraySize(pWC->aStatic); |
| 100611 | pWC->a = pWC->aStatic; |
| 100612 | pWC->vmask = 0; |
| 100613 | } |
| 100614 | |
| 100615 | /* Forward reference */ |
| 100616 | static void whereClauseClear(WhereClause*); |
| 100617 | |
| @@ -100923,40 +101355,42 @@ | |
| 100923 | ){ |
| 100924 | WhereTerm *pTerm; |
| 100925 | int k; |
| 100926 | assert( iCur>=0 ); |
| 100927 | op &= WO_ALL; |
| 100928 | for(pTerm=pWC->a, k=pWC->nTerm; k; k--, pTerm++){ |
| 100929 | if( pTerm->leftCursor==iCur |
| 100930 | && (pTerm->prereqRight & notReady)==0 |
| 100931 | && pTerm->u.leftColumn==iColumn |
| 100932 | && (pTerm->eOperator & op)!=0 |
| 100933 | ){ |
| 100934 | if( pIdx && pTerm->eOperator!=WO_ISNULL ){ |
| 100935 | Expr *pX = pTerm->pExpr; |
| 100936 | CollSeq *pColl; |
| 100937 | char idxaff; |
| 100938 | int j; |
| 100939 | Parse *pParse = pWC->pParse; |
| 100940 | |
| 100941 | idxaff = pIdx->pTable->aCol[iColumn].affinity; |
| 100942 | if( !sqlite3IndexAffinityOk(pX, idxaff) ) continue; |
| 100943 | |
| 100944 | /* Figure out the collation sequence required from an index for |
| 100945 | ** it to be useful for optimising expression pX. Store this |
| 100946 | ** value in variable pColl. |
| 100947 | */ |
| 100948 | assert(pX->pLeft); |
| 100949 | pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); |
| 100950 | assert(pColl || pParse->nErr); |
| 100951 | |
| 100952 | for(j=0; pIdx->aiColumn[j]!=iColumn; j++){ |
| 100953 | if( NEVER(j>=pIdx->nColumn) ) return 0; |
| 100954 | } |
| 100955 | if( pColl && sqlite3StrICmp(pColl->zName, pIdx->azColl[j]) ) continue; |
| 100956 | } |
| 100957 | return pTerm; |
| 100958 | } |
| 100959 | } |
| 100960 | return 0; |
| 100961 | } |
| 100962 | |
| @@ -101216,11 +101650,11 @@ | |
| 101216 | assert( pExpr->op==TK_OR ); |
| 101217 | pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo)); |
| 101218 | if( pOrInfo==0 ) return; |
| 101219 | pTerm->wtFlags |= TERM_ORINFO; |
| 101220 | pOrWc = &pOrInfo->wc; |
| 101221 | whereClauseInit(pOrWc, pWC->pParse, pMaskSet); |
| 101222 | whereSplit(pOrWc, pExpr, TK_OR); |
| 101223 | exprAnalyzeAll(pSrc, pOrWc); |
| 101224 | if( db->mallocFailed ) return; |
| 101225 | assert( pOrWc->nTerm>=2 ); |
| 101226 | |
| @@ -101243,13 +101677,14 @@ | |
| 101243 | Bitmask b = 0; |
| 101244 | pOrTerm->u.pAndInfo = pAndInfo; |
| 101245 | pOrTerm->wtFlags |= TERM_ANDINFO; |
| 101246 | pOrTerm->eOperator = WO_AND; |
| 101247 | pAndWC = &pAndInfo->wc; |
| 101248 | whereClauseInit(pAndWC, pWC->pParse, pMaskSet); |
| 101249 | whereSplit(pAndWC, pOrTerm->pExpr, TK_AND); |
| 101250 | exprAnalyzeAll(pSrc, pAndWC); |
| 101251 | testcase( db->mallocFailed ); |
| 101252 | if( !db->mallocFailed ){ |
| 101253 | for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){ |
| 101254 | assert( pAndTerm->pExpr ); |
| 101255 | if( allowedOp(pAndTerm->pExpr->op) ){ |
| @@ -101679,12 +102114,12 @@ | |
| 101679 | pNewTerm->prereqAll = pTerm->prereqAll; |
| 101680 | } |
| 101681 | } |
| 101682 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 101683 | |
| 101684 | #ifdef SQLITE_ENABLE_STAT2 |
| 101685 | /* When sqlite_stat2 histogram data is available an operator of the |
| 101686 | ** form "x IS NOT NULL" can sometimes be evaluated more efficiently |
| 101687 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a |
| 101688 | ** virtual term of that form. |
| 101689 | ** |
| 101690 | ** Note that the virtual term must be tagged with TERM_VNULL. This |
| @@ -101718,11 +102153,11 @@ | |
| 101718 | pTerm->nChild = 1; |
| 101719 | pTerm->wtFlags |= TERM_COPIED; |
| 101720 | pNewTerm->prereqAll = pTerm->prereqAll; |
| 101721 | } |
| 101722 | } |
| 101723 | #endif /* SQLITE_ENABLE_STAT2 */ |
| 101724 | |
| 101725 | /* Prevent ON clause terms of a LEFT JOIN from being used to drive |
| 101726 | ** an index for tables to the left of the join. |
| 101727 | */ |
| 101728 | pTerm->prereqRight |= extraRight; |
| @@ -102140,14 +102575,17 @@ | |
| 102140 | const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| 102141 | const Bitmask maskSrc = getMask(pWC->pMaskSet, iCur); /* Bitmask for pSrc */ |
| 102142 | WhereTerm * const pWCEnd = &pWC->a[pWC->nTerm]; /* End of pWC->a[] */ |
| 102143 | WhereTerm *pTerm; /* A single term of the WHERE clause */ |
| 102144 | |
| 102145 | /* No OR-clause optimization allowed if the INDEXED BY or NOT INDEXED clauses |
| 102146 | ** are used */ |
| 102147 | if( pSrc->notIndexed || pSrc->pIndex!=0 ){ |
| 102148 | return; |
| 102149 | } |
| 102150 | |
| 102151 | /* Search the WHERE clause terms for a usable WO_OR term. */ |
| 102152 | for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){ |
| 102153 | if( pTerm->eOperator==WO_OR |
| @@ -102172,10 +102610,11 @@ | |
| 102172 | bestIndex(pParse, pAndWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 102173 | }else if( pOrTerm->leftCursor==iCur ){ |
| 102174 | WhereClause tempWC; |
| 102175 | tempWC.pParse = pWC->pParse; |
| 102176 | tempWC.pMaskSet = pWC->pMaskSet; |
| 102177 | tempWC.op = TK_AND; |
| 102178 | tempWC.a = pOrTerm; |
| 102179 | tempWC.nTerm = 1; |
| 102180 | bestIndex(pParse, &tempWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 102181 | }else{ |
| @@ -102766,71 +103205,90 @@ | |
| 102766 | */ |
| 102767 | bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); |
| 102768 | } |
| 102769 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 102770 | |
| 102771 | /* |
| 102772 | ** Argument pIdx is a pointer to an index structure that has an array of |
| 102773 | ** SQLITE_INDEX_SAMPLES evenly spaced samples of the first indexed column |
| 102774 | ** stored in Index.aSample. These samples divide the domain of values stored |
| 102775 | ** the index into (SQLITE_INDEX_SAMPLES+1) regions. |
| 102776 | ** Region 0 contains all values less than the first sample value. Region |
| 102777 | ** 1 contains values between the first and second samples. Region 2 contains |
| 102778 | ** values between samples 2 and 3. And so on. Region SQLITE_INDEX_SAMPLES |
| 102779 | ** contains values larger than the last sample. |
| 102780 | ** |
| 102781 | ** If the index contains many duplicates of a single value, then it is |
| 102782 | ** possible that two or more adjacent samples can hold the same value. |
| 102783 | ** When that is the case, the smallest possible region code is returned |
| 102784 | ** when roundUp is false and the largest possible region code is returned |
| 102785 | ** when roundUp is true. |
| 102786 | ** |
| 102787 | ** If successful, this function determines which of the regions value |
| 102788 | ** pVal lies in, sets *piRegion to the region index (a value between 0 |
| 102789 | ** and SQLITE_INDEX_SAMPLES+1, inclusive) and returns SQLITE_OK. |
| 102790 | ** Or, if an OOM occurs while converting text values between encodings, |
| 102791 | ** SQLITE_NOMEM is returned and *piRegion is undefined. |
| 102792 | */ |
| 102793 | #ifdef SQLITE_ENABLE_STAT2 |
| 102794 | static int whereRangeRegion( |
| 102795 | Parse *pParse, /* Database connection */ |
| 102796 | Index *pIdx, /* Index to consider domain of */ |
| 102797 | sqlite3_value *pVal, /* Value to consider */ |
| 102798 | int roundUp, /* Return largest valid region if true */ |
| 102799 | int *piRegion /* OUT: Region of domain in which value lies */ |
| 102800 | ){ |
| 102801 | assert( roundUp==0 || roundUp==1 ); |
| 102802 | if( ALWAYS(pVal) ){ |
| 102803 | IndexSample *aSample = pIdx->aSample; |
| 102804 | int i = 0; |
| 102805 | int eType = sqlite3_value_type(pVal); |
| 102806 | |
| 102807 | if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 102808 | double r = sqlite3_value_double(pVal); |
| 102809 | for(i=0; i<SQLITE_INDEX_SAMPLES; i++){ |
| 102810 | if( aSample[i].eType==SQLITE_NULL ) continue; |
| 102811 | if( aSample[i].eType>=SQLITE_TEXT ) break; |
| 102812 | if( roundUp ){ |
| 102813 | if( aSample[i].u.r>r ) break; |
| 102814 | }else{ |
| 102815 | if( aSample[i].u.r>=r ) break; |
| 102816 | } |
| 102817 | } |
| 102818 | }else if( eType==SQLITE_NULL ){ |
| 102819 | i = 0; |
| 102820 | if( roundUp ){ |
| 102821 | while( i<SQLITE_INDEX_SAMPLES && aSample[i].eType==SQLITE_NULL ) i++; |
| 102822 | } |
| 102823 | }else{ |
| 102824 | sqlite3 *db = pParse->db; |
| 102825 | CollSeq *pColl; |
| 102826 | const u8 *z; |
| 102827 | int n; |
| 102828 | |
| 102829 | /* pVal comes from sqlite3ValueFromExpr() so the type cannot be NULL */ |
| 102830 | assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); |
| 102831 | |
| 102832 | if( eType==SQLITE_BLOB ){ |
| 102833 | z = (const u8 *)sqlite3_value_blob(pVal); |
| 102834 | pColl = db->pDfltColl; |
| 102835 | assert( pColl->enc==SQLITE_UTF8 ); |
| 102836 | }else{ |
| @@ -102845,16 +103303,16 @@ | |
| 102845 | return SQLITE_NOMEM; |
| 102846 | } |
| 102847 | assert( z && pColl && pColl->xCmp ); |
| 102848 | } |
| 102849 | n = sqlite3ValueBytes(pVal, pColl->enc); |
| 102850 | |
| 102851 | for(i=0; i<SQLITE_INDEX_SAMPLES; i++){ |
| 102852 | int c; |
| 102853 | int eSampletype = aSample[i].eType; |
| 102854 | if( eSampletype==SQLITE_NULL || eSampletype<eType ) continue; |
| 102855 | if( (eSampletype!=eType) ) break; |
| 102856 | #ifndef SQLITE_OMIT_UTF16 |
| 102857 | if( pColl->enc!=SQLITE_UTF8 ){ |
| 102858 | int nSample; |
| 102859 | char *zSample = sqlite3Utf8to16( |
| 102860 | db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample |
| @@ -102868,20 +103326,51 @@ | |
| 102868 | }else |
| 102869 | #endif |
| 102870 | { |
| 102871 | c = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z); |
| 102872 | } |
| 102873 | if( c-roundUp>=0 ) break; |
| 102874 | } |
| 102875 | } |
| 102876 | |
| 102877 | assert( i>=0 && i<=SQLITE_INDEX_SAMPLES ); |
| 102878 | *piRegion = i; |
| 102879 | } |
| 102880 | return SQLITE_OK; |
| 102881 | } |
| 102882 | #endif /* #ifdef SQLITE_ENABLE_STAT2 */ |
| 102883 | |
| 102884 | /* |
| 102885 | ** If expression pExpr represents a literal value, set *pp to point to |
| 102886 | ** an sqlite3_value structure containing the same value, with affinity |
| 102887 | ** aff applied to it, before returning. It is the responsibility of the |
| @@ -102895,11 +103384,11 @@ | |
| 102895 | ** |
| 102896 | ** If neither of the above apply, set *pp to NULL. |
| 102897 | ** |
| 102898 | ** If an error occurs, return an error code. Otherwise, SQLITE_OK. |
| 102899 | */ |
| 102900 | #ifdef SQLITE_ENABLE_STAT2 |
| 102901 | static int valueFromExpr( |
| 102902 | Parse *pParse, |
| 102903 | Expr *pExpr, |
| 102904 | u8 aff, |
| 102905 | sqlite3_value **pp |
| @@ -102943,106 +103432,92 @@ | |
| 102943 | ** |
| 102944 | ** ... FROM t1 WHERE a > ? AND a < ? ... |
| 102945 | ** |
| 102946 | ** then nEq should be passed 0. |
| 102947 | ** |
| 102948 | ** The returned value is an integer between 1 and 100, inclusive. A return |
| 102949 | ** value of 1 indicates that the proposed range scan is expected to visit |
| 102950 | ** approximately 1/100th (1%) of the rows selected by the nEq equality |
| 102951 | ** constraints (if any). A return value of 100 indicates that it is expected |
| 102952 | ** that the range scan will visit every row (100%) selected by the equality |
| 102953 | ** constraints. |
| 102954 | ** |
| 102955 | ** In the absence of sqlite_stat2 ANALYZE data, each range inequality |
| 102956 | ** reduces the search space by 3/4ths. Hence a single constraint (x>?) |
| 102957 | ** results in a return of 25 and a range constraint (x>? AND x<?) results |
| 102958 | ** in a return of 6. |
| 102959 | */ |
| 102960 | static int whereRangeScanEst( |
| 102961 | Parse *pParse, /* Parsing & code generating context */ |
| 102962 | Index *p, /* The index containing the range-compared column; "x" */ |
| 102963 | int nEq, /* index into p->aCol[] of the range-compared column */ |
| 102964 | WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */ |
| 102965 | WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ |
| 102966 | int *piEst /* OUT: Return value */ |
| 102967 | ){ |
| 102968 | int rc = SQLITE_OK; |
| 102969 | |
| 102970 | #ifdef SQLITE_ENABLE_STAT2 |
| 102971 | |
| 102972 | if( nEq==0 && p->aSample ){ |
| 102973 | sqlite3_value *pLowerVal = 0; |
| 102974 | sqlite3_value *pUpperVal = 0; |
| 102975 | int iEst; |
| 102976 | int iLower = 0; |
| 102977 | int iUpper = SQLITE_INDEX_SAMPLES; |
| 102978 | int roundUpUpper = 0; |
| 102979 | int roundUpLower = 0; |
| 102980 | u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity; |
| 102981 | |
| 102982 | if( pLower ){ |
| 102983 | Expr *pExpr = pLower->pExpr->pRight; |
| 102984 | rc = valueFromExpr(pParse, pExpr, aff, &pLowerVal); |
| 102985 | assert( pLower->eOperator==WO_GT || pLower->eOperator==WO_GE ); |
| 102986 | roundUpLower = (pLower->eOperator==WO_GT) ?1:0; |
| 102987 | } |
| 102988 | if( rc==SQLITE_OK && pUpper ){ |
| 102989 | Expr *pExpr = pUpper->pExpr->pRight; |
| 102990 | rc = valueFromExpr(pParse, pExpr, aff, &pUpperVal); |
| 102991 | assert( pUpper->eOperator==WO_LT || pUpper->eOperator==WO_LE ); |
| 102992 | roundUpUpper = (pUpper->eOperator==WO_LE) ?1:0; |
| 102993 | } |
| 102994 | |
| 102995 | if( rc!=SQLITE_OK || (pLowerVal==0 && pUpperVal==0) ){ |
| 102996 | sqlite3ValueFree(pLowerVal); |
| 102997 | sqlite3ValueFree(pUpperVal); |
| 102998 | goto range_est_fallback; |
| 102999 | }else if( pLowerVal==0 ){ |
| 103000 | rc = whereRangeRegion(pParse, p, pUpperVal, roundUpUpper, &iUpper); |
| 103001 | if( pLower ) iLower = iUpper/2; |
| 103002 | }else if( pUpperVal==0 ){ |
| 103003 | rc = whereRangeRegion(pParse, p, pLowerVal, roundUpLower, &iLower); |
| 103004 | if( pUpper ) iUpper = (iLower + SQLITE_INDEX_SAMPLES + 1)/2; |
| 103005 | }else{ |
| 103006 | rc = whereRangeRegion(pParse, p, pUpperVal, roundUpUpper, &iUpper); |
| 103007 | if( rc==SQLITE_OK ){ |
| 103008 | rc = whereRangeRegion(pParse, p, pLowerVal, roundUpLower, &iLower); |
| 103009 | } |
| 103010 | } |
| 103011 | WHERETRACE(("range scan regions: %d..%d\n", iLower, iUpper)); |
| 103012 | |
| 103013 | iEst = iUpper - iLower; |
| 103014 | testcase( iEst==SQLITE_INDEX_SAMPLES ); |
| 103015 | assert( iEst<=SQLITE_INDEX_SAMPLES ); |
| 103016 | if( iEst<1 ){ |
| 103017 | *piEst = 50/SQLITE_INDEX_SAMPLES; |
| 103018 | }else{ |
| 103019 | *piEst = (iEst*100)/SQLITE_INDEX_SAMPLES; |
| 103020 | } |
| 103021 | sqlite3ValueFree(pLowerVal); |
| 103022 | sqlite3ValueFree(pUpperVal); |
| 103023 | return rc; |
| 103024 | } |
| 103025 | range_est_fallback: |
| 103026 | #else |
| 103027 | UNUSED_PARAMETER(pParse); |
| 103028 | UNUSED_PARAMETER(p); |
| 103029 | UNUSED_PARAMETER(nEq); |
| 103030 | #endif |
| 103031 | assert( pLower || pUpper ); |
| 103032 | *piEst = 100; |
| 103033 | if( pLower && (pLower->wtFlags & TERM_VNULL)==0 ) *piEst /= 4; |
| 103034 | if( pUpper ) *piEst /= 4; |
| 103035 | return rc; |
| 103036 | } |
| 103037 | |
| 103038 | #ifdef SQLITE_ENABLE_STAT2 |
| 103039 | /* |
| 103040 | ** Estimate the number of rows that will be returned based on |
| 103041 | ** an equality constraint x=VALUE and where that VALUE occurs in |
| 103042 | ** the histogram data. This only works when x is the left-most |
| 103043 | ** column of an index and sqlite_stat2 histogram data is available |
| 103044 | ** for that index. When pExpr==NULL that means the constraint is |
| 103045 | ** "x IS NULL" instead of "x=VALUE". |
| 103046 | ** |
| 103047 | ** Write the estimated row count into *pnRow and return SQLITE_OK. |
| 103048 | ** If unable to make an estimate, leave *pnRow unchanged and return |
| @@ -103058,44 +103533,36 @@ | |
| 103058 | Index *p, /* The index whose left-most column is pTerm */ |
| 103059 | Expr *pExpr, /* Expression for VALUE in the x=VALUE constraint */ |
| 103060 | double *pnRow /* Write the revised row estimate here */ |
| 103061 | ){ |
| 103062 | sqlite3_value *pRhs = 0; /* VALUE on right-hand side of pTerm */ |
| 103063 | int iLower, iUpper; /* Range of histogram regions containing pRhs */ |
| 103064 | u8 aff; /* Column affinity */ |
| 103065 | int rc; /* Subfunction return code */ |
| 103066 | double nRowEst; /* New estimate of the number of rows */ |
| 103067 | |
| 103068 | assert( p->aSample!=0 ); |
| 103069 | aff = p->pTable->aCol[p->aiColumn[0]].affinity; |
| 103070 | if( pExpr ){ |
| 103071 | rc = valueFromExpr(pParse, pExpr, aff, &pRhs); |
| 103072 | if( rc ) goto whereEqualScanEst_cancel; |
| 103073 | }else{ |
| 103074 | pRhs = sqlite3ValueNew(pParse->db); |
| 103075 | } |
| 103076 | if( pRhs==0 ) return SQLITE_NOTFOUND; |
| 103077 | rc = whereRangeRegion(pParse, p, pRhs, 0, &iLower); |
| 103078 | if( rc ) goto whereEqualScanEst_cancel; |
| 103079 | rc = whereRangeRegion(pParse, p, pRhs, 1, &iUpper); |
| 103080 | if( rc ) goto whereEqualScanEst_cancel; |
| 103081 | WHERETRACE(("equality scan regions: %d..%d\n", iLower, iUpper)); |
| 103082 | if( iLower>=iUpper ){ |
| 103083 | nRowEst = p->aiRowEst[0]/(SQLITE_INDEX_SAMPLES*2); |
| 103084 | if( nRowEst<*pnRow ) *pnRow = nRowEst; |
| 103085 | }else{ |
| 103086 | nRowEst = (iUpper-iLower)*p->aiRowEst[0]/SQLITE_INDEX_SAMPLES; |
| 103087 | *pnRow = nRowEst; |
| 103088 | } |
| 103089 | |
| 103090 | whereEqualScanEst_cancel: |
| 103091 | sqlite3ValueFree(pRhs); |
| 103092 | return rc; |
| 103093 | } |
| 103094 | #endif /* defined(SQLITE_ENABLE_STAT2) */ |
| 103095 | |
| 103096 | #ifdef SQLITE_ENABLE_STAT2 |
| 103097 | /* |
| 103098 | ** Estimate the number of rows that will be returned based on |
| 103099 | ** an IN constraint where the right-hand side of the IN operator |
| 103100 | ** is a list of values. Example: |
| 103101 | ** |
| @@ -103114,64 +103581,29 @@ | |
| 103114 | Parse *pParse, /* Parsing & code generating context */ |
| 103115 | Index *p, /* The index whose left-most column is pTerm */ |
| 103116 | ExprList *pList, /* The value list on the RHS of "x IN (v1,v2,v3,...)" */ |
| 103117 | double *pnRow /* Write the revised row estimate here */ |
| 103118 | ){ |
| 103119 | sqlite3_value *pVal = 0; /* One value from list */ |
| 103120 | int iLower, iUpper; /* Range of histogram regions containing pRhs */ |
| 103121 | u8 aff; /* Column affinity */ |
| 103122 | int rc = SQLITE_OK; /* Subfunction return code */ |
| 103123 | double nRowEst; /* New estimate of the number of rows */ |
| 103124 | int nSpan = 0; /* Number of histogram regions spanned */ |
| 103125 | int nSingle = 0; /* Histogram regions hit by a single value */ |
| 103126 | int nNotFound = 0; /* Count of values that are not constants */ |
| 103127 | int i; /* Loop counter */ |
| 103128 | u8 aSpan[SQLITE_INDEX_SAMPLES+1]; /* Histogram regions that are spanned */ |
| 103129 | u8 aSingle[SQLITE_INDEX_SAMPLES+1]; /* Histogram regions hit once */ |
| 103130 | |
| 103131 | assert( p->aSample!=0 ); |
| 103132 | aff = p->pTable->aCol[p->aiColumn[0]].affinity; |
| 103133 | memset(aSpan, 0, sizeof(aSpan)); |
| 103134 | memset(aSingle, 0, sizeof(aSingle)); |
| 103135 | for(i=0; i<pList->nExpr; i++){ |
| 103136 | sqlite3ValueFree(pVal); |
| 103137 | rc = valueFromExpr(pParse, pList->a[i].pExpr, aff, &pVal); |
| 103138 | if( rc ) break; |
| 103139 | if( pVal==0 || sqlite3_value_type(pVal)==SQLITE_NULL ){ |
| 103140 | nNotFound++; |
| 103141 | continue; |
| 103142 | } |
| 103143 | rc = whereRangeRegion(pParse, p, pVal, 0, &iLower); |
| 103144 | if( rc ) break; |
| 103145 | rc = whereRangeRegion(pParse, p, pVal, 1, &iUpper); |
| 103146 | if( rc ) break; |
| 103147 | if( iLower>=iUpper ){ |
| 103148 | aSingle[iLower] = 1; |
| 103149 | }else{ |
| 103150 | assert( iLower>=0 && iUpper<=SQLITE_INDEX_SAMPLES ); |
| 103151 | while( iLower<iUpper ) aSpan[iLower++] = 1; |
| 103152 | } |
| 103153 | } |
| 103154 | if( rc==SQLITE_OK ){ |
| 103155 | for(i=nSpan=0; i<=SQLITE_INDEX_SAMPLES; i++){ |
| 103156 | if( aSpan[i] ){ |
| 103157 | nSpan++; |
| 103158 | }else if( aSingle[i] ){ |
| 103159 | nSingle++; |
| 103160 | } |
| 103161 | } |
| 103162 | nRowEst = (nSpan*2+nSingle)*p->aiRowEst[0]/(2*SQLITE_INDEX_SAMPLES) |
| 103163 | + nNotFound*p->aiRowEst[1]; |
| 103164 | if( nRowEst > p->aiRowEst[0] ) nRowEst = p->aiRowEst[0]; |
| 103165 | *pnRow = nRowEst; |
| 103166 | WHERETRACE(("IN row estimate: nSpan=%d, nSingle=%d, nNotFound=%d, est=%g\n", |
| 103167 | nSpan, nSingle, nNotFound, nRowEst)); |
| 103168 | } |
| 103169 | sqlite3ValueFree(pVal); |
| 103170 | return rc; |
| 103171 | } |
| 103172 | #endif /* defined(SQLITE_ENABLE_STAT2) */ |
| 103173 | |
| 103174 | |
| 103175 | /* |
| 103176 | ** Find the best query plan for accessing a particular table. Write the |
| 103177 | ** best query plan and its cost into the WhereCost object supplied as the |
| @@ -103214,11 +103646,11 @@ | |
| 103214 | Index *pProbe; /* An index we are evaluating */ |
| 103215 | Index *pIdx; /* Copy of pProbe, or zero for IPK index */ |
| 103216 | int eqTermMask; /* Current mask of valid equality operators */ |
| 103217 | int idxEqTermMask; /* Index mask of valid equality operators */ |
| 103218 | Index sPk; /* A fake index object for the primary key */ |
| 103219 | unsigned int aiRowEstPk[2]; /* The aiRowEst[] value for the sPk index */ |
| 103220 | int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ |
| 103221 | int wsFlagMask; /* Allowed flags in pCost->plan.wsFlag */ |
| 103222 | |
| 103223 | /* Initialize the cost to a worst-case value */ |
| 103224 | memset(pCost, 0, sizeof(*pCost)); |
| @@ -103269,14 +103701,14 @@ | |
| 103269 | } |
| 103270 | |
| 103271 | /* Loop over all indices looking for the best one to use |
| 103272 | */ |
| 103273 | for(; pProbe; pIdx=pProbe=pProbe->pNext){ |
| 103274 | const unsigned int * const aiRowEst = pProbe->aiRowEst; |
| 103275 | double cost; /* Cost of using pProbe */ |
| 103276 | double nRow; /* Estimated number of rows in result set */ |
| 103277 | double log10N; /* base-10 logarithm of nRow (inexact) */ |
| 103278 | int rev; /* True to scan in reverse order */ |
| 103279 | int wsFlags = 0; |
| 103280 | Bitmask used = 0; |
| 103281 | |
| 103282 | /* The following variables are populated based on the properties of |
| @@ -103312,18 +103744,16 @@ | |
| 103312 | ** Set to true if there was at least one "x IN (SELECT ...)" term used |
| 103313 | ** in determining the value of nInMul. Note that the RHS of the |
| 103314 | ** IN operator must be a SELECT, not a value list, for this variable |
| 103315 | ** to be true. |
| 103316 | ** |
| 103317 | ** estBound: |
| 103318 | ** An estimate on the amount of the table that must be searched. A |
| 103319 | ** value of 100 means the entire table is searched. Range constraints |
| 103320 | ** might reduce this to a value less than 100 to indicate that only |
| 103321 | ** a fraction of the table needs searching. In the absence of |
| 103322 | ** sqlite_stat2 ANALYZE data, a single inequality reduces the search |
| 103323 | ** space to 1/4rd its original size. So an x>? constraint reduces |
| 103324 | ** estBound to 25. Two constraints (x>? AND x<?) reduce estBound to 6. |
| 103325 | ** |
| 103326 | ** bSort: |
| 103327 | ** Boolean. True if there is an ORDER BY clause that will require an |
| 103328 | ** external sort (i.e. scanning the index being evaluated will not |
| 103329 | ** correctly order records). |
| @@ -103344,26 +103774,27 @@ | |
| 103344 | ** SELECT a, b, c FROM tbl WHERE a = 1; |
| 103345 | */ |
| 103346 | int nEq; /* Number of == or IN terms matching index */ |
| 103347 | int bInEst = 0; /* True if "x IN (SELECT...)" seen */ |
| 103348 | int nInMul = 1; /* Number of distinct equalities to lookup */ |
| 103349 | int estBound = 100; /* Estimated reduction in search space */ |
| 103350 | int nBound = 0; /* Number of range constraints seen */ |
| 103351 | int bSort = !!pOrderBy; /* True if external sort required */ |
| 103352 | int bDist = !!pDistinct; /* True if index cannot help with DISTINCT */ |
| 103353 | int bLookup = 0; /* True if not a covering index */ |
| 103354 | WhereTerm *pTerm; /* A single term of the WHERE clause */ |
| 103355 | #ifdef SQLITE_ENABLE_STAT2 |
| 103356 | WhereTerm *pFirstTerm = 0; /* First term matching the index */ |
| 103357 | #endif |
| 103358 | |
| 103359 | /* Determine the values of nEq and nInMul */ |
| 103360 | for(nEq=0; nEq<pProbe->nColumn; nEq++){ |
| 103361 | int j = pProbe->aiColumn[nEq]; |
| 103362 | pTerm = findTerm(pWC, iCur, j, notReady, eqTermMask, pIdx); |
| 103363 | if( pTerm==0 ) break; |
| 103364 | wsFlags |= (WHERE_COLUMN_EQ|WHERE_ROWID_EQ); |
| 103365 | if( pTerm->eOperator & WO_IN ){ |
| 103366 | Expr *pExpr = pTerm->pExpr; |
| 103367 | wsFlags |= WHERE_COLUMN_IN; |
| 103368 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 103369 | /* "x IN (SELECT ...)": Assume the SELECT returns 25 rows */ |
| @@ -103374,32 +103805,34 @@ | |
| 103374 | nInMul *= pExpr->x.pList->nExpr; |
| 103375 | } |
| 103376 | }else if( pTerm->eOperator & WO_ISNULL ){ |
| 103377 | wsFlags |= WHERE_COLUMN_NULL; |
| 103378 | } |
| 103379 | #ifdef SQLITE_ENABLE_STAT2 |
| 103380 | if( nEq==0 && pProbe->aSample ) pFirstTerm = pTerm; |
| 103381 | #endif |
| 103382 | used |= pTerm->prereqRight; |
| 103383 | } |
| 103384 | |
| 103385 | /* Determine the value of estBound. */ |
| 103386 | if( nEq<pProbe->nColumn && pProbe->bUnordered==0 ){ |
| 103387 | int j = pProbe->aiColumn[nEq]; |
| 103388 | if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pIdx) ){ |
| 103389 | WhereTerm *pTop = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pIdx); |
| 103390 | WhereTerm *pBtm = findTerm(pWC, iCur, j, notReady, WO_GT|WO_GE, pIdx); |
| 103391 | whereRangeScanEst(pParse, pProbe, nEq, pBtm, pTop, &estBound); |
| 103392 | if( pTop ){ |
| 103393 | nBound = 1; |
| 103394 | wsFlags |= WHERE_TOP_LIMIT; |
| 103395 | used |= pTop->prereqRight; |
| 103396 | } |
| 103397 | if( pBtm ){ |
| 103398 | nBound++; |
| 103399 | wsFlags |= WHERE_BTM_LIMIT; |
| 103400 | used |= pBtm->prereqRight; |
| 103401 | } |
| 103402 | wsFlags |= (WHERE_COLUMN_RANGE|WHERE_ROWID_RANGE); |
| 103403 | } |
| 103404 | }else if( pProbe->onError!=OE_None ){ |
| 103405 | testcase( wsFlags & WHERE_COLUMN_IN ); |
| @@ -103458,32 +103891,34 @@ | |
| 103458 | if( bInEst && nRow*2>aiRowEst[0] ){ |
| 103459 | nRow = aiRowEst[0]/2; |
| 103460 | nInMul = (int)(nRow / aiRowEst[nEq]); |
| 103461 | } |
| 103462 | |
| 103463 | #ifdef SQLITE_ENABLE_STAT2 |
| 103464 | /* If the constraint is of the form x=VALUE or x IN (E1,E2,...) |
| 103465 | ** and we do not think that values of x are unique and if histogram |
| 103466 | ** data is available for column x, then it might be possible |
| 103467 | ** to get a better estimate on the number of rows based on |
| 103468 | ** VALUE and how common that value is according to the histogram. |
| 103469 | */ |
| 103470 | if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 && aiRowEst[1]>1 ){ |
| 103471 | if( pFirstTerm->eOperator & (WO_EQ|WO_ISNULL) ){ |
| 103472 | testcase( pFirstTerm->eOperator==WO_EQ ); |
| 103473 | testcase( pFirstTerm->eOperator==WO_ISNULL ); |
| 103474 | whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight, &nRow); |
| 103475 | }else if( pFirstTerm->eOperator==WO_IN && bInEst==0 ){ |
| 103476 | whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList, &nRow); |
| 103477 | } |
| 103478 | } |
| 103479 | #endif /* SQLITE_ENABLE_STAT2 */ |
| 103480 | |
| 103481 | /* Adjust the number of output rows and downward to reflect rows |
| 103482 | ** that are excluded by range constraints. |
| 103483 | */ |
| 103484 | nRow = (nRow * (double)estBound) / (double)100; |
| 103485 | if( nRow<1 ) nRow = 1; |
| 103486 | |
| 103487 | /* Experiments run on real SQLite databases show that the time needed |
| 103488 | ** to do a binary search to locate a row in a table or index is roughly |
| 103489 | ** log10(N) times the time to move from one row to the next row within |
| @@ -103608,14 +104043,14 @@ | |
| 103608 | if( nRow<2 ) nRow = 2; |
| 103609 | } |
| 103610 | |
| 103611 | |
| 103612 | WHERETRACE(( |
| 103613 | "%s(%s): nEq=%d nInMul=%d estBound=%d bSort=%d bLookup=%d wsFlags=0x%x\n" |
| 103614 | " notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f used=0x%llx\n", |
| 103615 | pSrc->pTab->zName, (pIdx ? pIdx->zName : "ipk"), |
| 103616 | nEq, nInMul, estBound, bSort, bLookup, wsFlags, |
| 103617 | notReady, log10N, nRow, cost, used |
| 103618 | )); |
| 103619 | |
| 103620 | /* If this index is the best we have seen so far, then record this |
| 103621 | ** index and its cost in the pCost structure. |
| @@ -104115,11 +104550,12 @@ | |
| 104115 | */ |
| 104116 | static Bitmask codeOneLoopStart( |
| 104117 | WhereInfo *pWInfo, /* Complete information about the WHERE clause */ |
| 104118 | int iLevel, /* Which level of pWInfo->a[] should be coded */ |
| 104119 | u16 wctrlFlags, /* One of the WHERE_* flags defined in sqliteInt.h */ |
| 104120 | Bitmask notReady /* Which tables are currently available */ |
| 104121 | ){ |
| 104122 | int j, k; /* Loop counters */ |
| 104123 | int iCur; /* The VDBE cursor for the table */ |
| 104124 | int addrNxt; /* Where to jump to continue with the next IN case */ |
| 104125 | int omitTable; /* True if we use the index only */ |
| @@ -104597,11 +105033,12 @@ | |
| 104597 | int regRowset = 0; /* Register for RowSet object */ |
| 104598 | int regRowid = 0; /* Register holding rowid */ |
| 104599 | int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */ |
| 104600 | int iRetInit; /* Address of regReturn init */ |
| 104601 | int untestedTerms = 0; /* Some terms not completely tested */ |
| 104602 | int ii; |
| 104603 | |
| 104604 | pTerm = pLevel->plan.u.pTerm; |
| 104605 | assert( pTerm!=0 ); |
| 104606 | assert( pTerm->eOperator==WO_OR ); |
| 104607 | assert( (pTerm->wtFlags & TERM_ORINFO)!=0 ); |
| @@ -104646,18 +105083,33 @@ | |
| 104646 | regRowset = ++pParse->nMem; |
| 104647 | regRowid = ++pParse->nMem; |
| 104648 | sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); |
| 104649 | } |
| 104650 | iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn); |
| 104651 | |
| 104652 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 104653 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 104654 | if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){ |
| 104655 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 104656 | /* Loop through table entries that match term pOrTerm. */ |
| 104657 | pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrTerm->pExpr, 0, 0, |
| 104658 | WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | |
| 104659 | WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY); |
| 104660 | if( pSubWInfo ){ |
| 104661 | explainOneScan( |
| 104662 | pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0 |
| 104663 | ); |
| @@ -104681,10 +105133,11 @@ | |
| 104681 | /* Finish the loop through table entries that match term pOrTerm. */ |
| 104682 | sqlite3WhereEnd(pSubWInfo); |
| 104683 | } |
| 104684 | } |
| 104685 | } |
| 104686 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 104687 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); |
| 104688 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 104689 | |
| 104690 | if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab); |
| @@ -104962,11 +105415,11 @@ | |
| 104962 | |
| 104963 | /* Split the WHERE clause into separate subexpressions where each |
| 104964 | ** subexpression is separated by an AND operator. |
| 104965 | */ |
| 104966 | initMaskSet(pMaskSet); |
| 104967 | whereClauseInit(pWC, pParse, pMaskSet); |
| 104968 | sqlite3ExprCodeConstants(pParse, pWhere); |
| 104969 | whereSplit(pWC, pWhere, TK_AND); /* IMP: R-15842-53296 */ |
| 104970 | |
| 104971 | /* Special case: a WHERE clause that is constant. Evaluate the |
| 104972 | ** expression and either jump over all of the code or fall thru. |
| @@ -105290,11 +105743,11 @@ | |
| 105290 | int iCur = pTabItem->iCursor; |
| 105291 | sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB); |
| 105292 | }else |
| 105293 | #endif |
| 105294 | if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 |
| 105295 | && (wctrlFlags & WHERE_OMIT_OPEN)==0 ){ |
| 105296 | int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead; |
| 105297 | sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op); |
| 105298 | testcase( pTab->nCol==BMS-1 ); |
| 105299 | testcase( pTab->nCol==BMS ); |
| 105300 | if( !pWInfo->okOnePass && pTab->nCol<BMS ){ |
| @@ -105335,11 +105788,11 @@ | |
| 105335 | */ |
| 105336 | notReady = ~(Bitmask)0; |
| 105337 | for(i=0; i<nTabList; i++){ |
| 105338 | pLevel = &pWInfo->a[i]; |
| 105339 | explainOneScan(pParse, pTabList, pLevel, i, pLevel->iFrom, wctrlFlags); |
| 105340 | notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); |
| 105341 | pWInfo->iContinue = pLevel->addrCont; |
| 105342 | } |
| 105343 | |
| 105344 | #ifdef SQLITE_TEST /* For testing and debugging use only */ |
| 105345 | /* Record in the query plan information about the current table |
| @@ -105470,11 +105923,11 @@ | |
| 105470 | struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom]; |
| 105471 | Table *pTab = pTabItem->pTab; |
| 105472 | assert( pTab!=0 ); |
| 105473 | if( (pTab->tabFlags & TF_Ephemeral)==0 |
| 105474 | && pTab->pSelect==0 |
| 105475 | && (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0 |
| 105476 | ){ |
| 105477 | int ws = pLevel->plan.wsFlags; |
| 105478 | if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){ |
| 105479 | sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor); |
| 105480 | } |
| @@ -105531,10 +105984,11 @@ | |
| 105531 | return; |
| 105532 | } |
| 105533 | |
| 105534 | /************** End of where.c ***********************************************/ |
| 105535 | /************** Begin file parse.c *******************************************/ |
| 105536 | /* Driver template for the LEMON parser generator. |
| 105537 | ** The author disclaims copyright to this source code. |
| 105538 | ** |
| 105539 | ** This version of "lempar.c" is modified, slightly, for use by SQLite. |
| 105540 | ** The only modifications are the addition of a couple of NEVER() |
| @@ -105543,10 +105997,11 @@ | |
| 105543 | ** specific grammar used by SQLite. |
| 105544 | */ |
| 105545 | /* First off, code is included that follows the "include" declaration |
| 105546 | ** in the input grammar file. */ |
| 105547 | /* #include <stdio.h> */ |
| 105548 | |
| 105549 | |
| 105550 | /* |
| 105551 | ** Disable all error recovery processing in the parser push-down |
| 105552 | ** automaton. |
| @@ -105590,10 +106045,11 @@ | |
| 105590 | /* |
| 105591 | ** An instance of this structure holds the ATTACH key and the key type. |
| 105592 | */ |
| 105593 | struct AttachKey { int type; Token key; }; |
| 105594 | |
| 105595 | |
| 105596 | /* This is a utility routine used to set the ExprSpan.zStart and |
| 105597 | ** ExprSpan.zEnd values of pOut so that the span covers the complete |
| 105598 | ** range of text beginning with pStart and going to the end of pEnd. |
| 105599 | */ |
| @@ -105609,10 +106065,11 @@ | |
| 105609 | static void spanExpr(ExprSpan *pOut, Parse *pParse, int op, Token *pValue){ |
| 105610 | pOut->pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue); |
| 105611 | pOut->zStart = pValue->z; |
| 105612 | pOut->zEnd = &pValue->z[pValue->n]; |
| 105613 | } |
| 105614 | |
| 105615 | /* This routine constructs a binary expression node out of two ExprSpan |
| 105616 | ** objects and uses the result to populate a new ExprSpan object. |
| 105617 | */ |
| 105618 | static void spanBinaryExpr( |
| @@ -105624,10 +106081,11 @@ | |
| 105624 | ){ |
| 105625 | pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0); |
| 105626 | pOut->zStart = pLeft->zStart; |
| 105627 | pOut->zEnd = pRight->zEnd; |
| 105628 | } |
| 105629 | |
| 105630 | /* Construct an expression node for a unary postfix operator |
| 105631 | */ |
| 105632 | static void spanUnaryPostfix( |
| 105633 | ExprSpan *pOut, /* Write the new expression node here */ |
| @@ -105638,10 +106096,11 @@ | |
| 105638 | ){ |
| 105639 | pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0); |
| 105640 | pOut->zStart = pOperand->zStart; |
| 105641 | pOut->zEnd = &pPostOp->z[pPostOp->n]; |
| 105642 | } |
| 105643 | |
| 105644 | /* A routine to convert a binary TK_IS or TK_ISNOT expression into a |
| 105645 | ** unary TK_ISNULL or TK_NOTNULL expression. */ |
| 105646 | static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){ |
| 105647 | sqlite3 *db = pParse->db; |
| @@ -105649,10 +106108,11 @@ | |
| 105649 | pA->op = (u8)op; |
| 105650 | sqlite3ExprDelete(db, pA->pRight); |
| 105651 | pA->pRight = 0; |
| 105652 | } |
| 105653 | } |
| 105654 | |
| 105655 | /* Construct an expression node for a unary prefix operator |
| 105656 | */ |
| 105657 | static void spanUnaryPrefix( |
| 105658 | ExprSpan *pOut, /* Write the new expression node here */ |
| @@ -105663,10 +106123,11 @@ | |
| 105663 | ){ |
| 105664 | pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0); |
| 105665 | pOut->zStart = pPreOp->z; |
| 105666 | pOut->zEnd = pOperand->zEnd; |
| 105667 | } |
| 105668 | /* Next is all token values, in a form suitable for use by makeheaders. |
| 105669 | ** This section will be null unless lemon is run with the -m switch. |
| 105670 | */ |
| 105671 | /* |
| 105672 | ** These constants (all generated automatically by the parser generator) |
| @@ -106918,17 +107379,21 @@ | |
| 106918 | ** inside the C code. |
| 106919 | */ |
| 106920 | case 160: /* select */ |
| 106921 | case 194: /* oneselect */ |
| 106922 | { |
| 106923 | sqlite3SelectDelete(pParse->db, (yypminor->yy387)); |
| 106924 | } |
| 106925 | break; |
| 106926 | case 174: /* term */ |
| 106927 | case 175: /* expr */ |
| 106928 | { |
| 106929 | sqlite3ExprDelete(pParse->db, (yypminor->yy118).pExpr); |
| 106930 | } |
| 106931 | break; |
| 106932 | case 179: /* idxlist_opt */ |
| 106933 | case 187: /* idxlist */ |
| 106934 | case 197: /* selcollist */ |
| @@ -106940,19 +107405,23 @@ | |
| 106940 | case 217: /* setlist */ |
| 106941 | case 220: /* itemlist */ |
| 106942 | case 221: /* exprlist */ |
| 106943 | case 226: /* case_exprlist */ |
| 106944 | { |
| 106945 | sqlite3ExprListDelete(pParse->db, (yypminor->yy322)); |
| 106946 | } |
| 106947 | break; |
| 106948 | case 193: /* fullname */ |
| 106949 | case 198: /* from */ |
| 106950 | case 206: /* seltablist */ |
| 106951 | case 207: /* stl_prefix */ |
| 106952 | { |
| 106953 | sqlite3SrcListDelete(pParse->db, (yypminor->yy259)); |
| 106954 | } |
| 106955 | break; |
| 106956 | case 199: /* where_opt */ |
| 106957 | case 201: /* having_opt */ |
| 106958 | case 210: /* on_opt */ |
| @@ -106960,29 +107429,37 @@ | |
| 106960 | case 225: /* case_operand */ |
| 106961 | case 227: /* case_else */ |
| 106962 | case 238: /* when_clause */ |
| 106963 | case 243: /* key_opt */ |
| 106964 | { |
| 106965 | sqlite3ExprDelete(pParse->db, (yypminor->yy314)); |
| 106966 | } |
| 106967 | break; |
| 106968 | case 211: /* using_opt */ |
| 106969 | case 213: /* inscollist */ |
| 106970 | case 219: /* inscollist_opt */ |
| 106971 | { |
| 106972 | sqlite3IdListDelete(pParse->db, (yypminor->yy384)); |
| 106973 | } |
| 106974 | break; |
| 106975 | case 234: /* trigger_cmd_list */ |
| 106976 | case 239: /* trigger_cmd */ |
| 106977 | { |
| 106978 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203)); |
| 106979 | } |
| 106980 | break; |
| 106981 | case 236: /* trigger_event */ |
| 106982 | { |
| 106983 | sqlite3IdListDelete(pParse->db, (yypminor->yy90).b); |
| 106984 | } |
| 106985 | break; |
| 106986 | default: break; /* If no destructor action specified: do nothing */ |
| 106987 | } |
| 106988 | } |
| @@ -107164,14 +107641,16 @@ | |
| 107164 | } |
| 107165 | #endif |
| 107166 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 107167 | /* Here code is inserted which will execute if the parser |
| 107168 | ** stack every overflows */ |
| 107169 | |
| 107170 | UNUSED_PARAMETER(yypMinor); /* Silence some compiler warnings */ |
| 107171 | sqlite3ErrorMsg(pParse, "parser stack overflow"); |
| 107172 | pParse->parseError = 1; |
| 107173 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ |
| 107174 | } |
| 107175 | |
| 107176 | /* |
| 107177 | ** Perform a shift action. |
| @@ -107608,66 +108087,94 @@ | |
| 107608 | ** { ... } // User supplied code |
| 107609 | ** #line <lineno> <thisfile> |
| 107610 | ** break; |
| 107611 | */ |
| 107612 | case 5: /* explain ::= */ |
| 107613 | { sqlite3BeginParse(pParse, 0); } |
| 107614 | break; |
| 107615 | case 6: /* explain ::= EXPLAIN */ |
| 107616 | { sqlite3BeginParse(pParse, 1); } |
| 107617 | break; |
| 107618 | case 7: /* explain ::= EXPLAIN QUERY PLAN */ |
| 107619 | { sqlite3BeginParse(pParse, 2); } |
| 107620 | break; |
| 107621 | case 8: /* cmdx ::= cmd */ |
| 107622 | { sqlite3FinishCoding(pParse); } |
| 107623 | break; |
| 107624 | case 9: /* cmd ::= BEGIN transtype trans_opt */ |
| 107625 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);} |
| 107626 | break; |
| 107627 | case 13: /* transtype ::= */ |
| 107628 | {yygotominor.yy4 = TK_DEFERRED;} |
| 107629 | break; |
| 107630 | case 14: /* transtype ::= DEFERRED */ |
| 107631 | case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15); |
| 107632 | case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16); |
| 107633 | case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115); |
| 107634 | case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117); |
| 107635 | {yygotominor.yy4 = yymsp[0].major;} |
| 107636 | break; |
| 107637 | case 17: /* cmd ::= COMMIT trans_opt */ |
| 107638 | case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18); |
| 107639 | {sqlite3CommitTransaction(pParse);} |
| 107640 | break; |
| 107641 | case 19: /* cmd ::= ROLLBACK trans_opt */ |
| 107642 | {sqlite3RollbackTransaction(pParse);} |
| 107643 | break; |
| 107644 | case 22: /* cmd ::= SAVEPOINT nm */ |
| 107645 | { |
| 107646 | sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0); |
| 107647 | } |
| 107648 | break; |
| 107649 | case 23: /* cmd ::= RELEASE savepoint_opt nm */ |
| 107650 | { |
| 107651 | sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0); |
| 107652 | } |
| 107653 | break; |
| 107654 | case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 107655 | { |
| 107656 | sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); |
| 107657 | } |
| 107658 | break; |
| 107659 | case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 107660 | { |
| 107661 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4); |
| 107662 | } |
| 107663 | break; |
| 107664 | case 27: /* createkw ::= CREATE */ |
| 107665 | { |
| 107666 | pParse->db->lookaside.bEnabled = 0; |
| 107667 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 107668 | } |
| 107669 | break; |
| 107670 | case 28: /* ifnotexists ::= */ |
| 107671 | case 31: /* temp ::= */ yytestcase(yyruleno==31); |
| 107672 | case 70: /* autoinc ::= */ yytestcase(yyruleno==70); |
| 107673 | case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83); |
| @@ -107677,44 +108184,56 @@ | |
| 107677 | case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 107678 | case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120); |
| 107679 | case 121: /* distinct ::= */ yytestcase(yyruleno==121); |
| 107680 | case 222: /* between_op ::= BETWEEN */ yytestcase(yyruleno==222); |
| 107681 | case 225: /* in_op ::= IN */ yytestcase(yyruleno==225); |
| 107682 | {yygotominor.yy4 = 0;} |
| 107683 | break; |
| 107684 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 107685 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 107686 | case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71); |
| 107687 | case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86); |
| 107688 | case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 107689 | case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119); |
| 107690 | case 223: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==223); |
| 107691 | case 226: /* in_op ::= NOT IN */ yytestcase(yyruleno==226); |
| 107692 | {yygotominor.yy4 = 1;} |
| 107693 | break; |
| 107694 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| 107695 | { |
| 107696 | sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); |
| 107697 | } |
| 107698 | break; |
| 107699 | case 33: /* create_table_args ::= AS select */ |
| 107700 | { |
| 107701 | sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy387); |
| 107702 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 107703 | } |
| 107704 | break; |
| 107705 | case 36: /* column ::= columnid type carglist */ |
| 107706 | { |
| 107707 | yygotominor.yy0.z = yymsp[-2].minor.yy0.z; |
| 107708 | yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n; |
| 107709 | } |
| 107710 | break; |
| 107711 | case 37: /* columnid ::= nm */ |
| 107712 | { |
| 107713 | sqlite3AddColumn(pParse,&yymsp[0].minor.yy0); |
| 107714 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 107715 | } |
| 107716 | break; |
| 107717 | case 38: /* id ::= ID */ |
| 107718 | case 39: /* id ::= INDEXED */ yytestcase(yyruleno==39); |
| 107719 | case 40: /* ids ::= ID|STRING */ yytestcase(yyruleno==40); |
| 107720 | case 41: /* nm ::= id */ yytestcase(yyruleno==41); |
| @@ -107734,256 +108253,373 @@ | |
| 107734 | case 264: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==264); |
| 107735 | case 265: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==265); |
| 107736 | case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266); |
| 107737 | case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267); |
| 107738 | case 285: /* trnm ::= nm */ yytestcase(yyruleno==285); |
| 107739 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 107740 | break; |
| 107741 | case 45: /* type ::= typetoken */ |
| 107742 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 107743 | break; |
| 107744 | case 47: /* typetoken ::= typename LP signed RP */ |
| 107745 | { |
| 107746 | yygotominor.yy0.z = yymsp[-3].minor.yy0.z; |
| 107747 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); |
| 107748 | } |
| 107749 | break; |
| 107750 | case 48: /* typetoken ::= typename LP signed COMMA signed RP */ |
| 107751 | { |
| 107752 | yygotominor.yy0.z = yymsp[-5].minor.yy0.z; |
| 107753 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); |
| 107754 | } |
| 107755 | break; |
| 107756 | case 50: /* typename ::= typename ids */ |
| 107757 | {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 107758 | break; |
| 107759 | case 57: /* ccons ::= DEFAULT term */ |
| 107760 | case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59); |
| 107761 | {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy118);} |
| 107762 | break; |
| 107763 | case 58: /* ccons ::= DEFAULT LP expr RP */ |
| 107764 | {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy118);} |
| 107765 | break; |
| 107766 | case 60: /* ccons ::= DEFAULT MINUS term */ |
| 107767 | { |
| 107768 | ExprSpan v; |
| 107769 | v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0); |
| 107770 | v.zStart = yymsp[-1].minor.yy0.z; |
| 107771 | v.zEnd = yymsp[0].minor.yy118.zEnd; |
| 107772 | sqlite3AddDefaultValue(pParse,&v); |
| 107773 | } |
| 107774 | break; |
| 107775 | case 61: /* ccons ::= DEFAULT id */ |
| 107776 | { |
| 107777 | ExprSpan v; |
| 107778 | spanExpr(&v, pParse, TK_STRING, &yymsp[0].minor.yy0); |
| 107779 | sqlite3AddDefaultValue(pParse,&v); |
| 107780 | } |
| 107781 | break; |
| 107782 | case 63: /* ccons ::= NOT NULL onconf */ |
| 107783 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);} |
| 107784 | break; |
| 107785 | case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 107786 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);} |
| 107787 | break; |
| 107788 | case 65: /* ccons ::= UNIQUE onconf */ |
| 107789 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0);} |
| 107790 | break; |
| 107791 | case 66: /* ccons ::= CHECK LP expr RP */ |
| 107792 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy118.pExpr);} |
| 107793 | break; |
| 107794 | case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */ |
| 107795 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);} |
| 107796 | break; |
| 107797 | case 68: /* ccons ::= defer_subclause */ |
| 107798 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);} |
| 107799 | break; |
| 107800 | case 69: /* ccons ::= COLLATE ids */ |
| 107801 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 107802 | break; |
| 107803 | case 72: /* refargs ::= */ |
| 107804 | { yygotominor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 107805 | break; |
| 107806 | case 73: /* refargs ::= refargs refarg */ |
| 107807 | { yygotominor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; } |
| 107808 | break; |
| 107809 | case 74: /* refarg ::= MATCH nm */ |
| 107810 | case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75); |
| 107811 | { yygotominor.yy215.value = 0; yygotominor.yy215.mask = 0x000000; } |
| 107812 | break; |
| 107813 | case 76: /* refarg ::= ON DELETE refact */ |
| 107814 | { yygotominor.yy215.value = yymsp[0].minor.yy4; yygotominor.yy215.mask = 0x0000ff; } |
| 107815 | break; |
| 107816 | case 77: /* refarg ::= ON UPDATE refact */ |
| 107817 | { yygotominor.yy215.value = yymsp[0].minor.yy4<<8; yygotominor.yy215.mask = 0x00ff00; } |
| 107818 | break; |
| 107819 | case 78: /* refact ::= SET NULL */ |
| 107820 | { yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */} |
| 107821 | break; |
| 107822 | case 79: /* refact ::= SET DEFAULT */ |
| 107823 | { yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 107824 | break; |
| 107825 | case 80: /* refact ::= CASCADE */ |
| 107826 | { yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */} |
| 107827 | break; |
| 107828 | case 81: /* refact ::= RESTRICT */ |
| 107829 | { yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */} |
| 107830 | break; |
| 107831 | case 82: /* refact ::= NO ACTION */ |
| 107832 | { yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */} |
| 107833 | break; |
| 107834 | case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 107835 | case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99); |
| 107836 | case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101); |
| 107837 | case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104); |
| 107838 | {yygotominor.yy4 = yymsp[0].minor.yy4;} |
| 107839 | break; |
| 107840 | case 88: /* conslist_opt ::= */ |
| 107841 | {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;} |
| 107842 | break; |
| 107843 | case 89: /* conslist_opt ::= COMMA conslist */ |
| 107844 | {yygotominor.yy0 = yymsp[-1].minor.yy0;} |
| 107845 | break; |
| 107846 | case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 107847 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);} |
| 107848 | break; |
| 107849 | case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 107850 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0);} |
| 107851 | break; |
| 107852 | case 96: /* tcons ::= CHECK LP expr RP onconf */ |
| 107853 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy118.pExpr);} |
| 107854 | break; |
| 107855 | case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 107856 | { |
| 107857 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4); |
| 107858 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); |
| 107859 | } |
| 107860 | break; |
| 107861 | case 100: /* onconf ::= */ |
| 107862 | {yygotominor.yy4 = OE_Default;} |
| 107863 | break; |
| 107864 | case 102: /* orconf ::= */ |
| 107865 | {yygotominor.yy210 = OE_Default;} |
| 107866 | break; |
| 107867 | case 103: /* orconf ::= OR resolvetype */ |
| 107868 | {yygotominor.yy210 = (u8)yymsp[0].minor.yy4;} |
| 107869 | break; |
| 107870 | case 105: /* resolvetype ::= IGNORE */ |
| 107871 | {yygotominor.yy4 = OE_Ignore;} |
| 107872 | break; |
| 107873 | case 106: /* resolvetype ::= REPLACE */ |
| 107874 | {yygotominor.yy4 = OE_Replace;} |
| 107875 | break; |
| 107876 | case 107: /* cmd ::= DROP TABLE ifexists fullname */ |
| 107877 | { |
| 107878 | sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4); |
| 107879 | } |
| 107880 | break; |
| 107881 | case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 107882 | { |
| 107883 | sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4); |
| 107884 | } |
| 107885 | break; |
| 107886 | case 111: /* cmd ::= DROP VIEW ifexists fullname */ |
| 107887 | { |
| 107888 | sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4); |
| 107889 | } |
| 107890 | break; |
| 107891 | case 112: /* cmd ::= select */ |
| 107892 | { |
| 107893 | SelectDest dest = {SRT_Output, 0, 0, 0, 0}; |
| 107894 | sqlite3Select(pParse, yymsp[0].minor.yy387, &dest); |
| 107895 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 107896 | } |
| 107897 | break; |
| 107898 | case 113: /* select ::= oneselect */ |
| 107899 | {yygotominor.yy387 = yymsp[0].minor.yy387;} |
| 107900 | break; |
| 107901 | case 114: /* select ::= select multiselect_op oneselect */ |
| 107902 | { |
| 107903 | if( yymsp[0].minor.yy387 ){ |
| 107904 | yymsp[0].minor.yy387->op = (u8)yymsp[-1].minor.yy4; |
| 107905 | yymsp[0].minor.yy387->pPrior = yymsp[-2].minor.yy387; |
| 107906 | }else{ |
| 107907 | sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy387); |
| 107908 | } |
| 107909 | yygotominor.yy387 = yymsp[0].minor.yy387; |
| 107910 | } |
| 107911 | break; |
| 107912 | case 116: /* multiselect_op ::= UNION ALL */ |
| 107913 | {yygotominor.yy4 = TK_ALL;} |
| 107914 | break; |
| 107915 | case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 107916 | { |
| 107917 | yygotominor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy292.pLimit,yymsp[0].minor.yy292.pOffset); |
| 107918 | } |
| 107919 | break; |
| 107920 | case 122: /* sclp ::= selcollist COMMA */ |
| 107921 | case 247: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==247); |
| 107922 | {yygotominor.yy322 = yymsp[-1].minor.yy322;} |
| 107923 | break; |
| 107924 | case 123: /* sclp ::= */ |
| 107925 | case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151); |
| 107926 | case 159: /* groupby_opt ::= */ yytestcase(yyruleno==159); |
| 107927 | case 240: /* exprlist ::= */ yytestcase(yyruleno==240); |
| 107928 | case 246: /* idxlist_opt ::= */ yytestcase(yyruleno==246); |
| 107929 | {yygotominor.yy322 = 0;} |
| 107930 | break; |
| 107931 | case 124: /* selcollist ::= sclp expr as */ |
| 107932 | { |
| 107933 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr); |
| 107934 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[0].minor.yy0, 1); |
| 107935 | sqlite3ExprListSetSpan(pParse,yygotominor.yy322,&yymsp[-1].minor.yy118); |
| 107936 | } |
| 107937 | break; |
| 107938 | case 125: /* selcollist ::= sclp STAR */ |
| 107939 | { |
| 107940 | Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0); |
| 107941 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy322, p); |
| 107942 | } |
| 107943 | break; |
| 107944 | case 126: /* selcollist ::= sclp nm DOT STAR */ |
| 107945 | { |
| 107946 | Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0); |
| 107947 | Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 107948 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); |
| 107949 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, pDot); |
| 107950 | } |
| 107951 | break; |
| 107952 | case 129: /* as ::= */ |
| 107953 | {yygotominor.yy0.n = 0;} |
| 107954 | break; |
| 107955 | case 130: /* from ::= */ |
| 107956 | {yygotominor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy259));} |
| 107957 | break; |
| 107958 | case 131: /* from ::= FROM seltablist */ |
| 107959 | { |
| 107960 | yygotominor.yy259 = yymsp[0].minor.yy259; |
| 107961 | sqlite3SrcListShiftJoinType(yygotominor.yy259); |
| 107962 | } |
| 107963 | break; |
| 107964 | case 132: /* stl_prefix ::= seltablist joinop */ |
| 107965 | { |
| 107966 | yygotominor.yy259 = yymsp[-1].minor.yy259; |
| 107967 | if( ALWAYS(yygotominor.yy259 && yygotominor.yy259->nSrc>0) ) yygotominor.yy259->a[yygotominor.yy259->nSrc-1].jointype = (u8)yymsp[0].minor.yy4; |
| 107968 | } |
| 107969 | break; |
| 107970 | case 133: /* stl_prefix ::= */ |
| 107971 | {yygotominor.yy259 = 0;} |
| 107972 | break; |
| 107973 | case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 107974 | { |
| 107975 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 107976 | sqlite3SrcListIndexedBy(pParse, yygotominor.yy259, &yymsp[-2].minor.yy0); |
| 107977 | } |
| 107978 | break; |
| 107979 | case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 107980 | { |
| 107981 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 107982 | } |
| 107983 | break; |
| 107984 | case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 107985 | { |
| 107986 | if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){ |
| 107987 | yygotominor.yy259 = yymsp[-4].minor.yy259; |
| 107988 | }else{ |
| 107989 | Select *pSubquery; |
| @@ -107990,180 +108626,260 @@ | |
| 107990 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259); |
| 107991 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,0,0,0); |
| 107992 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 107993 | } |
| 107994 | } |
| 107995 | break; |
| 107996 | case 137: /* dbnm ::= */ |
| 107997 | case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146); |
| 107998 | {yygotominor.yy0.z=0; yygotominor.yy0.n=0;} |
| 107999 | break; |
| 108000 | case 139: /* fullname ::= nm dbnm */ |
| 108001 | {yygotominor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 108002 | break; |
| 108003 | case 140: /* joinop ::= COMMA|JOIN */ |
| 108004 | { yygotominor.yy4 = JT_INNER; } |
| 108005 | break; |
| 108006 | case 141: /* joinop ::= JOIN_KW JOIN */ |
| 108007 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 108008 | break; |
| 108009 | case 142: /* joinop ::= JOIN_KW nm JOIN */ |
| 108010 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 108011 | break; |
| 108012 | case 143: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 108013 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 108014 | break; |
| 108015 | case 144: /* on_opt ::= ON expr */ |
| 108016 | case 155: /* sortitem ::= expr */ yytestcase(yyruleno==155); |
| 108017 | case 162: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==162); |
| 108018 | case 169: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==169); |
| 108019 | case 235: /* case_else ::= ELSE expr */ yytestcase(yyruleno==235); |
| 108020 | case 237: /* case_operand ::= expr */ yytestcase(yyruleno==237); |
| 108021 | {yygotominor.yy314 = yymsp[0].minor.yy118.pExpr;} |
| 108022 | break; |
| 108023 | case 145: /* on_opt ::= */ |
| 108024 | case 161: /* having_opt ::= */ yytestcase(yyruleno==161); |
| 108025 | case 168: /* where_opt ::= */ yytestcase(yyruleno==168); |
| 108026 | case 236: /* case_else ::= */ yytestcase(yyruleno==236); |
| 108027 | case 238: /* case_operand ::= */ yytestcase(yyruleno==238); |
| 108028 | {yygotominor.yy314 = 0;} |
| 108029 | break; |
| 108030 | case 148: /* indexed_opt ::= NOT INDEXED */ |
| 108031 | {yygotominor.yy0.z=0; yygotominor.yy0.n=1;} |
| 108032 | break; |
| 108033 | case 149: /* using_opt ::= USING LP inscollist RP */ |
| 108034 | case 181: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==181); |
| 108035 | {yygotominor.yy384 = yymsp[-1].minor.yy384;} |
| 108036 | break; |
| 108037 | case 150: /* using_opt ::= */ |
| 108038 | case 180: /* inscollist_opt ::= */ yytestcase(yyruleno==180); |
| 108039 | {yygotominor.yy384 = 0;} |
| 108040 | break; |
| 108041 | case 152: /* orderby_opt ::= ORDER BY sortlist */ |
| 108042 | case 160: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==160); |
| 108043 | case 239: /* exprlist ::= nexprlist */ yytestcase(yyruleno==239); |
| 108044 | {yygotominor.yy322 = yymsp[0].minor.yy322;} |
| 108045 | break; |
| 108046 | case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ |
| 108047 | { |
| 108048 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314); |
| 108049 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108050 | } |
| 108051 | break; |
| 108052 | case 154: /* sortlist ::= sortitem sortorder */ |
| 108053 | { |
| 108054 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314); |
| 108055 | if( yygotominor.yy322 && ALWAYS(yygotominor.yy322->a) ) yygotominor.yy322->a[0].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108056 | } |
| 108057 | break; |
| 108058 | case 156: /* sortorder ::= ASC */ |
| 108059 | case 158: /* sortorder ::= */ yytestcase(yyruleno==158); |
| 108060 | {yygotominor.yy4 = SQLITE_SO_ASC;} |
| 108061 | break; |
| 108062 | case 157: /* sortorder ::= DESC */ |
| 108063 | {yygotominor.yy4 = SQLITE_SO_DESC;} |
| 108064 | break; |
| 108065 | case 163: /* limit_opt ::= */ |
| 108066 | {yygotominor.yy292.pLimit = 0; yygotominor.yy292.pOffset = 0;} |
| 108067 | break; |
| 108068 | case 164: /* limit_opt ::= LIMIT expr */ |
| 108069 | {yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; yygotominor.yy292.pOffset = 0;} |
| 108070 | break; |
| 108071 | case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 108072 | {yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr;} |
| 108073 | break; |
| 108074 | case 166: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 108075 | {yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr;} |
| 108076 | break; |
| 108077 | case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ |
| 108078 | { |
| 108079 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0); |
| 108080 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314); |
| 108081 | } |
| 108082 | break; |
| 108083 | case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 108084 | { |
| 108085 | sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0); |
| 108086 | sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); |
| 108087 | sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy210); |
| 108088 | } |
| 108089 | break; |
| 108090 | case 171: /* setlist ::= setlist COMMA nm EQ expr */ |
| 108091 | { |
| 108092 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr); |
| 108093 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108094 | } |
| 108095 | break; |
| 108096 | case 172: /* setlist ::= nm EQ expr */ |
| 108097 | { |
| 108098 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); |
| 108099 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108100 | } |
| 108101 | break; |
| 108102 | case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */ |
| 108103 | {sqlite3Insert(pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210);} |
| 108104 | break; |
| 108105 | case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ |
| 108106 | {sqlite3Insert(pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210);} |
| 108107 | break; |
| 108108 | case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 108109 | {sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210);} |
| 108110 | break; |
| 108111 | case 176: /* insert_cmd ::= INSERT orconf */ |
| 108112 | {yygotominor.yy210 = yymsp[0].minor.yy210;} |
| 108113 | break; |
| 108114 | case 177: /* insert_cmd ::= REPLACE */ |
| 108115 | {yygotominor.yy210 = OE_Replace;} |
| 108116 | break; |
| 108117 | case 178: /* itemlist ::= itemlist COMMA expr */ |
| 108118 | case 241: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==241); |
| 108119 | {yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy118.pExpr);} |
| 108120 | break; |
| 108121 | case 179: /* itemlist ::= expr */ |
| 108122 | case 242: /* nexprlist ::= expr */ yytestcase(yyruleno==242); |
| 108123 | {yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy118.pExpr);} |
| 108124 | break; |
| 108125 | case 182: /* inscollist ::= inscollist COMMA nm */ |
| 108126 | {yygotominor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);} |
| 108127 | break; |
| 108128 | case 183: /* inscollist ::= nm */ |
| 108129 | {yygotominor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 108130 | break; |
| 108131 | case 184: /* expr ::= term */ |
| 108132 | {yygotominor.yy118 = yymsp[0].minor.yy118;} |
| 108133 | break; |
| 108134 | case 185: /* expr ::= LP expr RP */ |
| 108135 | {yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 108136 | break; |
| 108137 | case 186: /* term ::= NULL */ |
| 108138 | case 191: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==191); |
| 108139 | case 192: /* term ::= STRING */ yytestcase(yyruleno==192); |
| 108140 | {spanExpr(&yygotominor.yy118, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 108141 | break; |
| 108142 | case 187: /* expr ::= id */ |
| 108143 | case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188); |
| 108144 | {spanExpr(&yygotominor.yy118, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 108145 | break; |
| 108146 | case 189: /* expr ::= nm DOT nm */ |
| 108147 | { |
| 108148 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 108149 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 108150 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 108151 | spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 108152 | } |
| 108153 | break; |
| 108154 | case 190: /* expr ::= nm DOT nm DOT nm */ |
| 108155 | { |
| 108156 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 108157 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 108158 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 108159 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 108160 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 108161 | spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 108162 | } |
| 108163 | break; |
| 108164 | case 193: /* expr ::= REGISTER */ |
| 108165 | { |
| 108166 | /* When doing a nested parse, one can include terms in an expression |
| 108167 | ** that look like this: #1 #2 ... These terms refer to registers |
| 108168 | ** in the virtual machine. #N is the N-th register. */ |
| 108169 | if( pParse->nested==0 ){ |
| @@ -108173,32 +108889,40 @@ | |
| 108173 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0); |
| 108174 | if( yygotominor.yy118.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy118.pExpr->iTable); |
| 108175 | } |
| 108176 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108177 | } |
| 108178 | break; |
| 108179 | case 194: /* expr ::= VARIABLE */ |
| 108180 | { |
| 108181 | spanExpr(&yygotominor.yy118, pParse, TK_VARIABLE, &yymsp[0].minor.yy0); |
| 108182 | sqlite3ExprAssignVarNumber(pParse, yygotominor.yy118.pExpr); |
| 108183 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108184 | } |
| 108185 | break; |
| 108186 | case 195: /* expr ::= expr COLLATE ids */ |
| 108187 | { |
| 108188 | yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy118.pExpr, &yymsp[0].minor.yy0); |
| 108189 | yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 108190 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108191 | } |
| 108192 | break; |
| 108193 | case 196: /* expr ::= CAST LP expr AS typetoken RP */ |
| 108194 | { |
| 108195 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, &yymsp[-1].minor.yy0); |
| 108196 | spanSet(&yygotominor.yy118,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 108197 | } |
| 108198 | break; |
| 108199 | case 197: /* expr ::= ID LP distinct exprlist RP */ |
| 108200 | { |
| 108201 | if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 108202 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 108203 | } |
| 108204 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| @@ -108205,47 +108929,59 @@ | |
| 108205 | spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 108206 | if( yymsp[-2].minor.yy4 && yygotominor.yy118.pExpr ){ |
| 108207 | yygotominor.yy118.pExpr->flags |= EP_Distinct; |
| 108208 | } |
| 108209 | } |
| 108210 | break; |
| 108211 | case 198: /* expr ::= ID LP STAR RP */ |
| 108212 | { |
| 108213 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 108214 | spanSet(&yygotominor.yy118,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 108215 | } |
| 108216 | break; |
| 108217 | case 199: /* term ::= CTIME_KW */ |
| 108218 | { |
| 108219 | /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are |
| 108220 | ** treated as functions that return constants */ |
| 108221 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0); |
| 108222 | if( yygotominor.yy118.pExpr ){ |
| 108223 | yygotominor.yy118.pExpr->op = TK_CONST_FUNC; |
| 108224 | } |
| 108225 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108226 | } |
| 108227 | break; |
| 108228 | case 200: /* expr ::= expr AND expr */ |
| 108229 | case 201: /* expr ::= expr OR expr */ yytestcase(yyruleno==201); |
| 108230 | case 202: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==202); |
| 108231 | case 203: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==203); |
| 108232 | case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==204); |
| 108233 | case 205: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==205); |
| 108234 | case 206: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==206); |
| 108235 | case 207: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==207); |
| 108236 | {spanBinaryExpr(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118);} |
| 108237 | break; |
| 108238 | case 208: /* likeop ::= LIKE_KW */ |
| 108239 | case 210: /* likeop ::= MATCH */ yytestcase(yyruleno==210); |
| 108240 | {yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 0;} |
| 108241 | break; |
| 108242 | case 209: /* likeop ::= NOT LIKE_KW */ |
| 108243 | case 211: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==211); |
| 108244 | {yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 1;} |
| 108245 | break; |
| 108246 | case 212: /* expr ::= expr likeop expr */ |
| 108247 | { |
| 108248 | ExprList *pList; |
| 108249 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy118.pExpr); |
| 108250 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy118.pExpr); |
| 108251 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy342.eOperator); |
| @@ -108252,12 +108988,14 @@ | |
| 108252 | if( yymsp[-1].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108253 | yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 108254 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108255 | if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 108256 | } |
| 108257 | break; |
| 108258 | case 213: /* expr ::= expr likeop expr ESCAPE expr */ |
| 108259 | { |
| 108260 | ExprList *pList; |
| 108261 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 108262 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy118.pExpr); |
| 108263 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| @@ -108265,40 +109003,56 @@ | |
| 108265 | if( yymsp[-3].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108266 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108267 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108268 | if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 108269 | } |
| 108270 | break; |
| 108271 | case 214: /* expr ::= expr ISNULL|NOTNULL */ |
| 108272 | {spanUnaryPostfix(&yygotominor.yy118,pParse,yymsp[0].major,&yymsp[-1].minor.yy118,&yymsp[0].minor.yy0);} |
| 108273 | break; |
| 108274 | case 215: /* expr ::= expr NOT NULL */ |
| 108275 | {spanUnaryPostfix(&yygotominor.yy118,pParse,TK_NOTNULL,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy0);} |
| 108276 | break; |
| 108277 | case 216: /* expr ::= expr IS expr */ |
| 108278 | { |
| 108279 | spanBinaryExpr(&yygotominor.yy118,pParse,TK_IS,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118); |
| 108280 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL); |
| 108281 | } |
| 108282 | break; |
| 108283 | case 217: /* expr ::= expr IS NOT expr */ |
| 108284 | { |
| 108285 | spanBinaryExpr(&yygotominor.yy118,pParse,TK_ISNOT,&yymsp[-3].minor.yy118,&yymsp[0].minor.yy118); |
| 108286 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL); |
| 108287 | } |
| 108288 | break; |
| 108289 | case 218: /* expr ::= NOT expr */ |
| 108290 | case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219); |
| 108291 | {spanUnaryPrefix(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 108292 | break; |
| 108293 | case 220: /* expr ::= MINUS expr */ |
| 108294 | {spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UMINUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 108295 | break; |
| 108296 | case 221: /* expr ::= PLUS expr */ |
| 108297 | {spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UPLUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 108298 | break; |
| 108299 | case 224: /* expr ::= expr between_op expr AND expr */ |
| 108300 | { |
| 108301 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 108302 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| 108303 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 108304 | if( yygotominor.yy118.pExpr ){ |
| @@ -108308,12 +109062,14 @@ | |
| 108308 | } |
| 108309 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108310 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108311 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108312 | } |
| 108313 | break; |
| 108314 | case 227: /* expr ::= expr in_op LP exprlist RP */ |
| 108315 | { |
| 108316 | if( yymsp[-1].minor.yy322==0 ){ |
| 108317 | /* Expressions of the form |
| 108318 | ** |
| 108319 | ** expr1 IN () |
| @@ -108335,12 +109091,14 @@ | |
| 108335 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108336 | } |
| 108337 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108338 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108339 | } |
| 108340 | break; |
| 108341 | case 228: /* expr ::= LP select RP */ |
| 108342 | { |
| 108343 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 108344 | if( yygotominor.yy118.pExpr ){ |
| 108345 | yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 108346 | ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| @@ -108349,12 +109107,14 @@ | |
| 108349 | sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 108350 | } |
| 108351 | yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; |
| 108352 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108353 | } |
| 108354 | break; |
| 108355 | case 229: /* expr ::= expr in_op LP select RP */ |
| 108356 | { |
| 108357 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 108358 | if( yygotominor.yy118.pExpr ){ |
| 108359 | yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 108360 | ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| @@ -108364,12 +109124,14 @@ | |
| 108364 | } |
| 108365 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108366 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 108367 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108368 | } |
| 108369 | break; |
| 108370 | case 230: /* expr ::= expr in_op nm dbnm */ |
| 108371 | { |
| 108372 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 108373 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0); |
| 108374 | if( yygotominor.yy118.pExpr ){ |
| 108375 | yygotominor.yy118.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| @@ -108380,12 +109142,14 @@ | |
| 108380 | } |
| 108381 | if( yymsp[-2].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108382 | yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; |
| 108383 | yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]; |
| 108384 | } |
| 108385 | break; |
| 108386 | case 231: /* expr ::= EXISTS LP select RP */ |
| 108387 | { |
| 108388 | Expr *p = yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 108389 | if( p ){ |
| 108390 | p->x.pSelect = yymsp[-1].minor.yy387; |
| 108391 | ExprSetProperty(p, EP_xIsSelect); |
| @@ -108394,12 +109158,14 @@ | |
| 108394 | sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 108395 | } |
| 108396 | yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 108397 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108398 | } |
| 108399 | break; |
| 108400 | case 232: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 108401 | { |
| 108402 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0); |
| 108403 | if( yygotominor.yy118.pExpr ){ |
| 108404 | yygotominor.yy118.pExpr->x.pList = yymsp[-2].minor.yy322; |
| 108405 | sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| @@ -108407,38 +109173,50 @@ | |
| 108407 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322); |
| 108408 | } |
| 108409 | yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; |
| 108410 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108411 | } |
| 108412 | break; |
| 108413 | case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 108414 | { |
| 108415 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr); |
| 108416 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 108417 | } |
| 108418 | break; |
| 108419 | case 234: /* case_exprlist ::= WHEN expr THEN expr */ |
| 108420 | { |
| 108421 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 108422 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 108423 | } |
| 108424 | break; |
| 108425 | case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ |
| 108426 | { |
| 108427 | sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, |
| 108428 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4, |
| 108429 | &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4); |
| 108430 | } |
| 108431 | break; |
| 108432 | case 244: /* uniqueflag ::= UNIQUE */ |
| 108433 | case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298); |
| 108434 | {yygotominor.yy4 = OE_Abort;} |
| 108435 | break; |
| 108436 | case 245: /* uniqueflag ::= */ |
| 108437 | {yygotominor.yy4 = OE_None;} |
| 108438 | break; |
| 108439 | case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 108440 | { |
| 108441 | Expr *p = 0; |
| 108442 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 108443 | p = sqlite3Expr(pParse->db, TK_COLUMN, 0); |
| 108444 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -108446,12 +109224,14 @@ | |
| 108446 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, p); |
| 108447 | sqlite3ExprListSetName(pParse,yygotominor.yy322,&yymsp[-2].minor.yy0,1); |
| 108448 | sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 108449 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108450 | } |
| 108451 | break; |
| 108452 | case 249: /* idxlist ::= nm collate sortorder */ |
| 108453 | { |
| 108454 | Expr *p = 0; |
| 108455 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 108456 | p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); |
| 108457 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -108459,214 +109239,307 @@ | |
| 108459 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, p); |
| 108460 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108461 | sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 108462 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108463 | } |
| 108464 | break; |
| 108465 | case 250: /* collate ::= */ |
| 108466 | {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;} |
| 108467 | break; |
| 108468 | case 252: /* cmd ::= DROP INDEX ifexists fullname */ |
| 108469 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);} |
| 108470 | break; |
| 108471 | case 253: /* cmd ::= VACUUM */ |
| 108472 | case 254: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==254); |
| 108473 | {sqlite3Vacuum(pParse);} |
| 108474 | break; |
| 108475 | case 255: /* cmd ::= PRAGMA nm dbnm */ |
| 108476 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 108477 | break; |
| 108478 | case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 108479 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 108480 | break; |
| 108481 | case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 108482 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 108483 | break; |
| 108484 | case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 108485 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 108486 | break; |
| 108487 | case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 108488 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 108489 | break; |
| 108490 | case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 108491 | { |
| 108492 | Token all; |
| 108493 | all.z = yymsp[-3].minor.yy0.z; |
| 108494 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 108495 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all); |
| 108496 | } |
| 108497 | break; |
| 108498 | case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 108499 | { |
| 108500 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4); |
| 108501 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 108502 | } |
| 108503 | break; |
| 108504 | case 272: /* trigger_time ::= BEFORE */ |
| 108505 | case 275: /* trigger_time ::= */ yytestcase(yyruleno==275); |
| 108506 | { yygotominor.yy4 = TK_BEFORE; } |
| 108507 | break; |
| 108508 | case 273: /* trigger_time ::= AFTER */ |
| 108509 | { yygotominor.yy4 = TK_AFTER; } |
| 108510 | break; |
| 108511 | case 274: /* trigger_time ::= INSTEAD OF */ |
| 108512 | { yygotominor.yy4 = TK_INSTEAD;} |
| 108513 | break; |
| 108514 | case 276: /* trigger_event ::= DELETE|INSERT */ |
| 108515 | case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277); |
| 108516 | {yygotominor.yy90.a = yymsp[0].major; yygotominor.yy90.b = 0;} |
| 108517 | break; |
| 108518 | case 278: /* trigger_event ::= UPDATE OF inscollist */ |
| 108519 | {yygotominor.yy90.a = TK_UPDATE; yygotominor.yy90.b = yymsp[0].minor.yy384;} |
| 108520 | break; |
| 108521 | case 281: /* when_clause ::= */ |
| 108522 | case 303: /* key_opt ::= */ yytestcase(yyruleno==303); |
| 108523 | { yygotominor.yy314 = 0; } |
| 108524 | break; |
| 108525 | case 282: /* when_clause ::= WHEN expr */ |
| 108526 | case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304); |
| 108527 | { yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; } |
| 108528 | break; |
| 108529 | case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 108530 | { |
| 108531 | assert( yymsp[-2].minor.yy203!=0 ); |
| 108532 | yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203; |
| 108533 | yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 108534 | yygotominor.yy203 = yymsp[-2].minor.yy203; |
| 108535 | } |
| 108536 | break; |
| 108537 | case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 108538 | { |
| 108539 | assert( yymsp[-1].minor.yy203!=0 ); |
| 108540 | yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 108541 | yygotominor.yy203 = yymsp[-1].minor.yy203; |
| 108542 | } |
| 108543 | break; |
| 108544 | case 286: /* trnm ::= nm DOT nm */ |
| 108545 | { |
| 108546 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 108547 | sqlite3ErrorMsg(pParse, |
| 108548 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 108549 | "statements within triggers"); |
| 108550 | } |
| 108551 | break; |
| 108552 | case 288: /* tridxby ::= INDEXED BY nm */ |
| 108553 | { |
| 108554 | sqlite3ErrorMsg(pParse, |
| 108555 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 108556 | "within triggers"); |
| 108557 | } |
| 108558 | break; |
| 108559 | case 289: /* tridxby ::= NOT INDEXED */ |
| 108560 | { |
| 108561 | sqlite3ErrorMsg(pParse, |
| 108562 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 108563 | "within triggers"); |
| 108564 | } |
| 108565 | break; |
| 108566 | case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 108567 | { yygotominor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); } |
| 108568 | break; |
| 108569 | case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */ |
| 108570 | {yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210);} |
| 108571 | break; |
| 108572 | case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 108573 | {yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210);} |
| 108574 | break; |
| 108575 | case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 108576 | {yygotominor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy314);} |
| 108577 | break; |
| 108578 | case 294: /* trigger_cmd ::= select */ |
| 108579 | {yygotominor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy387); } |
| 108580 | break; |
| 108581 | case 295: /* expr ::= RAISE LP IGNORE RP */ |
| 108582 | { |
| 108583 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 108584 | if( yygotominor.yy118.pExpr ){ |
| 108585 | yygotominor.yy118.pExpr->affinity = OE_Ignore; |
| 108586 | } |
| 108587 | yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 108588 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108589 | } |
| 108590 | break; |
| 108591 | case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 108592 | { |
| 108593 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 108594 | if( yygotominor.yy118.pExpr ) { |
| 108595 | yygotominor.yy118.pExpr->affinity = (char)yymsp[-3].minor.yy4; |
| 108596 | } |
| 108597 | yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; |
| 108598 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108599 | } |
| 108600 | break; |
| 108601 | case 297: /* raisetype ::= ROLLBACK */ |
| 108602 | {yygotominor.yy4 = OE_Rollback;} |
| 108603 | break; |
| 108604 | case 299: /* raisetype ::= FAIL */ |
| 108605 | {yygotominor.yy4 = OE_Fail;} |
| 108606 | break; |
| 108607 | case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 108608 | { |
| 108609 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4); |
| 108610 | } |
| 108611 | break; |
| 108612 | case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 108613 | { |
| 108614 | sqlite3Attach(pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314); |
| 108615 | } |
| 108616 | break; |
| 108617 | case 302: /* cmd ::= DETACH database_kw_opt expr */ |
| 108618 | { |
| 108619 | sqlite3Detach(pParse, yymsp[0].minor.yy118.pExpr); |
| 108620 | } |
| 108621 | break; |
| 108622 | case 307: /* cmd ::= REINDEX */ |
| 108623 | {sqlite3Reindex(pParse, 0, 0);} |
| 108624 | break; |
| 108625 | case 308: /* cmd ::= REINDEX nm dbnm */ |
| 108626 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 108627 | break; |
| 108628 | case 309: /* cmd ::= ANALYZE */ |
| 108629 | {sqlite3Analyze(pParse, 0, 0);} |
| 108630 | break; |
| 108631 | case 310: /* cmd ::= ANALYZE nm dbnm */ |
| 108632 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 108633 | break; |
| 108634 | case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 108635 | { |
| 108636 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0); |
| 108637 | } |
| 108638 | break; |
| 108639 | case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 108640 | { |
| 108641 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 108642 | } |
| 108643 | break; |
| 108644 | case 313: /* add_column_fullname ::= fullname */ |
| 108645 | { |
| 108646 | pParse->db->lookaside.bEnabled = 0; |
| 108647 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259); |
| 108648 | } |
| 108649 | break; |
| 108650 | case 316: /* cmd ::= create_vtab */ |
| 108651 | {sqlite3VtabFinishParse(pParse,0);} |
| 108652 | break; |
| 108653 | case 317: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 108654 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 108655 | break; |
| 108656 | case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */ |
| 108657 | { |
| 108658 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 108659 | } |
| 108660 | break; |
| 108661 | case 321: /* vtabarg ::= */ |
| 108662 | {sqlite3VtabArgInit(pParse);} |
| 108663 | break; |
| 108664 | case 323: /* vtabargtoken ::= ANY */ |
| 108665 | case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324); |
| 108666 | case 325: /* lp ::= LP */ yytestcase(yyruleno==325); |
| 108667 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 108668 | break; |
| 108669 | default: |
| 108670 | /* (0) input ::= cmdlist */ yytestcase(yyruleno==0); |
| 108671 | /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1); |
| 108672 | /* (2) cmdlist ::= ecmd */ yytestcase(yyruleno==2); |
| @@ -108764,15 +109637,17 @@ | |
| 108764 | int yymajor, /* The major type of the error token */ |
| 108765 | YYMINORTYPE yyminor /* The minor type of the error token */ |
| 108766 | ){ |
| 108767 | sqlite3ParserARG_FETCH; |
| 108768 | #define TOKEN (yyminor.yy0) |
| 108769 | |
| 108770 | UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ |
| 108771 | assert( TOKEN.z[0] ); /* The tokenizer always gives us a token */ |
| 108772 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); |
| 108773 | pParse->parseError = 1; |
| 108774 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| 108775 | } |
| 108776 | |
| 108777 | /* |
| 108778 | ** The following is executed when the parser accepts |
| @@ -108962,10 +109837,11 @@ | |
| 108962 | return; |
| 108963 | } |
| 108964 | |
| 108965 | /************** End of parse.c ***********************************************/ |
| 108966 | /************** Begin file tokenize.c ****************************************/ |
| 108967 | /* |
| 108968 | ** 2001 September 15 |
| 108969 | ** |
| 108970 | ** The author disclaims copyright to this source code. In place of |
| 108971 | ** a legal notice, here is a blessing: |
| @@ -109027,10 +109903,11 @@ | |
| 109027 | ** named keywordhash.h and then included into this source file by |
| 109028 | ** the #include below. |
| 109029 | */ |
| 109030 | /************** Include keywordhash.h in the middle of tokenize.c ************/ |
| 109031 | /************** Begin file keywordhash.h *************************************/ |
| 109032 | /***** This file contains automatically generated code ****** |
| 109033 | ** |
| 109034 | ** The code in this file has been automatically generated by |
| 109035 | ** |
| 109036 | ** sqlite/tool/mkkeywordhash.c |
| @@ -109300,10 +110177,11 @@ | |
| 109300 | } |
| 109301 | #define SQLITE_N_KEYWORD 121 |
| 109302 | |
| 109303 | /************** End of keywordhash.h *****************************************/ |
| 109304 | /************** Continuing where we left off in tokenize.c *******************/ |
| 109305 | |
| 109306 | |
| 109307 | /* |
| 109308 | ** If X is a character that can be used in an identifier then |
| 109309 | ** IdChar(X) will be true. Otherwise it is false. |
| @@ -109764,10 +110642,11 @@ | |
| 109764 | return nErr; |
| 109765 | } |
| 109766 | |
| 109767 | /************** End of tokenize.c ********************************************/ |
| 109768 | /************** Begin file complete.c ****************************************/ |
| 109769 | /* |
| 109770 | ** 2001 September 15 |
| 109771 | ** |
| 109772 | ** The author disclaims copyright to this source code. In place of |
| 109773 | ** a legal notice, here is a blessing: |
| @@ -110049,10 +110928,11 @@ | |
| 110049 | #endif /* SQLITE_OMIT_UTF16 */ |
| 110050 | #endif /* SQLITE_OMIT_COMPLETE */ |
| 110051 | |
| 110052 | /************** End of complete.c ********************************************/ |
| 110053 | /************** Begin file main.c ********************************************/ |
| 110054 | /* |
| 110055 | ** 2001 September 15 |
| 110056 | ** |
| 110057 | ** The author disclaims copyright to this source code. In place of |
| 110058 | ** a legal notice, here is a blessing: |
| @@ -110069,10 +110949,11 @@ | |
| 110069 | */ |
| 110070 | |
| 110071 | #ifdef SQLITE_ENABLE_FTS3 |
| 110072 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 110073 | /************** Begin file fts3.h ********************************************/ |
| 110074 | /* |
| 110075 | ** 2006 Oct 10 |
| 110076 | ** |
| 110077 | ** The author disclaims copyright to this source code. In place of |
| 110078 | ** a legal notice, here is a blessing: |
| @@ -110097,14 +110978,16 @@ | |
| 110097 | } /* extern "C" */ |
| 110098 | #endif /* __cplusplus */ |
| 110099 | |
| 110100 | /************** End of fts3.h ************************************************/ |
| 110101 | /************** Continuing where we left off in main.c ***********************/ |
| 110102 | #endif |
| 110103 | #ifdef SQLITE_ENABLE_RTREE |
| 110104 | /************** Include rtree.h in the middle of main.c **********************/ |
| 110105 | /************** Begin file rtree.h *******************************************/ |
| 110106 | /* |
| 110107 | ** 2008 May 26 |
| 110108 | ** |
| 110109 | ** The author disclaims copyright to this source code. In place of |
| 110110 | ** a legal notice, here is a blessing: |
| @@ -110129,14 +111012,16 @@ | |
| 110129 | } /* extern "C" */ |
| 110130 | #endif /* __cplusplus */ |
| 110131 | |
| 110132 | /************** End of rtree.h ***********************************************/ |
| 110133 | /************** Continuing where we left off in main.c ***********************/ |
| 110134 | #endif |
| 110135 | #ifdef SQLITE_ENABLE_ICU |
| 110136 | /************** Include sqliteicu.h in the middle of main.c ******************/ |
| 110137 | /************** Begin file sqliteicu.h ***************************************/ |
| 110138 | /* |
| 110139 | ** 2008 May 26 |
| 110140 | ** |
| 110141 | ** The author disclaims copyright to this source code. In place of |
| 110142 | ** a legal notice, here is a blessing: |
| @@ -110162,10 +111047,11 @@ | |
| 110162 | #endif /* __cplusplus */ |
| 110163 | |
| 110164 | |
| 110165 | /************** End of sqliteicu.h *******************************************/ |
| 110166 | /************** Continuing where we left off in main.c ***********************/ |
| 110167 | #endif |
| 110168 | |
| 110169 | #ifndef SQLITE_AMALGAMATION |
| 110170 | /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant |
| 110171 | ** contains the text of SQLITE_VERSION macro. |
| @@ -113092,10 +113978,11 @@ | |
| 113092 | return 0; |
| 113093 | } |
| 113094 | |
| 113095 | /************** End of main.c ************************************************/ |
| 113096 | /************** Begin file notify.c ******************************************/ |
| 113097 | /* |
| 113098 | ** 2009 March 3 |
| 113099 | ** |
| 113100 | ** The author disclaims copyright to this source code. In place of |
| 113101 | ** a legal notice, here is a blessing: |
| @@ -113425,10 +114312,11 @@ | |
| 113425 | } |
| 113426 | #endif |
| 113427 | |
| 113428 | /************** End of notify.c **********************************************/ |
| 113429 | /************** Begin file fts3.c ********************************************/ |
| 113430 | /* |
| 113431 | ** 2006 Oct 10 |
| 113432 | ** |
| 113433 | ** The author disclaims copyright to this source code. In place of |
| 113434 | ** a legal notice, here is a blessing: |
| @@ -113721,10 +114609,11 @@ | |
| 113721 | ** into a single segment. |
| 113722 | */ |
| 113723 | |
| 113724 | /************** Include fts3Int.h in the middle of fts3.c ********************/ |
| 113725 | /************** Begin file fts3Int.h *****************************************/ |
| 113726 | /* |
| 113727 | ** 2009 Nov 12 |
| 113728 | ** |
| 113729 | ** The author disclaims copyright to this source code. In place of |
| 113730 | ** a legal notice, here is a blessing: |
| @@ -113759,10 +114648,11 @@ | |
| 113759 | SQLITE_API extern const sqlite3_api_routines *sqlite3_api; |
| 113760 | #endif |
| 113761 | |
| 113762 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 113763 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 113764 | /* |
| 113765 | ** 2006 July 10 |
| 113766 | ** |
| 113767 | ** The author disclaims copyright to this source code. |
| 113768 | ** |
| @@ -113913,12 +114803,14 @@ | |
| 113913 | |
| 113914 | #endif /* _FTS3_TOKENIZER_H_ */ |
| 113915 | |
| 113916 | /************** End of fts3_tokenizer.h **************************************/ |
| 113917 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 113918 | /************** Include fts3_hash.h in the middle of fts3Int.h ***************/ |
| 113919 | /************** Begin file fts3_hash.h ***************************************/ |
| 113920 | /* |
| 113921 | ** 2001 September 22 |
| 113922 | ** |
| 113923 | ** The author disclaims copyright to this source code. In place of |
| 113924 | ** a legal notice, here is a blessing: |
| @@ -114030,10 +114922,11 @@ | |
| 114030 | |
| 114031 | #endif /* _FTS3_HASH_H_ */ |
| 114032 | |
| 114033 | /************** End of fts3_hash.h *******************************************/ |
| 114034 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 114035 | |
| 114036 | /* |
| 114037 | ** This constant controls how often segments are merged. Once there are |
| 114038 | ** FTS3_MERGE_COUNT segments of level N, they are merged into a single |
| 114039 | ** segment of level N+1. |
| @@ -114506,10 +115399,11 @@ | |
| 114506 | #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */ |
| 114507 | #endif /* _FTSINT_H */ |
| 114508 | |
| 114509 | /************** End of fts3Int.h *********************************************/ |
| 114510 | /************** Continuing where we left off in fts3.c ***********************/ |
| 114511 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 114512 | |
| 114513 | #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) |
| 114514 | # define SQLITE_CORE 1 |
| 114515 | #endif |
| @@ -119055,10 +119949,11 @@ | |
| 119055 | |
| 119056 | #endif |
| 119057 | |
| 119058 | /************** End of fts3.c ************************************************/ |
| 119059 | /************** Begin file fts3_aux.c ****************************************/ |
| 119060 | /* |
| 119061 | ** 2011 Jan 27 |
| 119062 | ** |
| 119063 | ** The author disclaims copyright to this source code. In place of |
| 119064 | ** a legal notice, here is a blessing: |
| @@ -119531,10 +120426,11 @@ | |
| 119531 | |
| 119532 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 119533 | |
| 119534 | /************** End of fts3_aux.c ********************************************/ |
| 119535 | /************** Begin file fts3_expr.c ***************************************/ |
| 119536 | /* |
| 119537 | ** 2008 Nov 28 |
| 119538 | ** |
| 119539 | ** The author disclaims copyright to this source code. In place of |
| 119540 | ** a legal notice, here is a blessing: |
| @@ -120497,10 +121393,11 @@ | |
| 120497 | #endif |
| 120498 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 120499 | |
| 120500 | /************** End of fts3_expr.c *******************************************/ |
| 120501 | /************** Begin file fts3_hash.c ***************************************/ |
| 120502 | /* |
| 120503 | ** 2001 September 22 |
| 120504 | ** |
| 120505 | ** The author disclaims copyright to this source code. In place of |
| 120506 | ** a legal notice, here is a blessing: |
| @@ -120881,10 +121778,11 @@ | |
| 120881 | |
| 120882 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 120883 | |
| 120884 | /************** End of fts3_hash.c *******************************************/ |
| 120885 | /************** Begin file fts3_porter.c *************************************/ |
| 120886 | /* |
| 120887 | ** 2006 September 30 |
| 120888 | ** |
| 120889 | ** The author disclaims copyright to this source code. In place of |
| 120890 | ** a legal notice, here is a blessing: |
| @@ -121527,10 +122425,11 @@ | |
| 121527 | |
| 121528 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 121529 | |
| 121530 | /************** End of fts3_porter.c *****************************************/ |
| 121531 | /************** Begin file fts3_tokenizer.c **********************************/ |
| 121532 | /* |
| 121533 | ** 2007 June 22 |
| 121534 | ** |
| 121535 | ** The author disclaims copyright to this source code. In place of |
| 121536 | ** a legal notice, here is a blessing: |
| @@ -122018,10 +122917,11 @@ | |
| 122018 | |
| 122019 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 122020 | |
| 122021 | /************** End of fts3_tokenizer.c **************************************/ |
| 122022 | /************** Begin file fts3_tokenizer1.c *********************************/ |
| 122023 | /* |
| 122024 | ** 2006 Oct 10 |
| 122025 | ** |
| 122026 | ** The author disclaims copyright to this source code. In place of |
| 122027 | ** a legal notice, here is a blessing: |
| @@ -122252,10 +123152,11 @@ | |
| 122252 | |
| 122253 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 122254 | |
| 122255 | /************** End of fts3_tokenizer1.c *************************************/ |
| 122256 | /************** Begin file fts3_write.c **************************************/ |
| 122257 | /* |
| 122258 | ** 2009 Oct 23 |
| 122259 | ** |
| 122260 | ** The author disclaims copyright to this source code. In place of |
| 122261 | ** a legal notice, here is a blessing: |
| @@ -125522,10 +126423,11 @@ | |
| 125522 | |
| 125523 | #endif |
| 125524 | |
| 125525 | /************** End of fts3_write.c ******************************************/ |
| 125526 | /************** Begin file fts3_snippet.c ************************************/ |
| 125527 | /* |
| 125528 | ** 2009 Oct 23 |
| 125529 | ** |
| 125530 | ** The author disclaims copyright to this source code. In place of |
| 125531 | ** a legal notice, here is a blessing: |
| @@ -127023,10 +127925,11 @@ | |
| 127023 | |
| 127024 | #endif |
| 127025 | |
| 127026 | /************** End of fts3_snippet.c ****************************************/ |
| 127027 | /************** Begin file rtree.c *******************************************/ |
| 127028 | /* |
| 127029 | ** 2001 September 15 |
| 127030 | ** |
| 127031 | ** The author disclaims copyright to this source code. In place of |
| 127032 | ** a legal notice, here is a blessing: |
| @@ -130304,10 +131207,11 @@ | |
| 130304 | |
| 130305 | #endif |
| 130306 | |
| 130307 | /************** End of rtree.c ***********************************************/ |
| 130308 | /************** Begin file icu.c *********************************************/ |
| 130309 | /* |
| 130310 | ** 2007 May 6 |
| 130311 | ** |
| 130312 | ** The author disclaims copyright to this source code. In place of |
| 130313 | ** a legal notice, here is a blessing: |
| @@ -130806,10 +131710,11 @@ | |
| 130806 | |
| 130807 | #endif |
| 130808 | |
| 130809 | /************** End of icu.c *************************************************/ |
| 130810 | /************** Begin file fts3_icu.c ****************************************/ |
| 130811 | /* |
| 130812 | ** 2007 June 22 |
| 130813 | ** |
| 130814 | ** The author disclaims copyright to this source code. In place of |
| 130815 | ** a legal notice, here is a blessing: |
| 130816 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -1,8 +1,8 @@ | |
| 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.7.9. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | ** translation unit. |
| @@ -24,10 +24,11 @@ | |
| 24 | #endif |
| 25 | #ifndef SQLITE_API |
| 26 | # define SQLITE_API |
| 27 | #endif |
| 28 | /************** Begin file sqliteInt.h ***************************************/ |
| 29 | #line 1 "tsrc/sqliteInt.h" |
| 30 | /* |
| 31 | ** 2001 September 15 |
| 32 | ** |
| 33 | ** The author disclaims copyright to this source code. In place of |
| 34 | ** a legal notice, here is a blessing: |
| @@ -78,10 +79,11 @@ | |
| 79 | #include "config.h" |
| 80 | #endif |
| 81 | |
| 82 | /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ |
| 83 | /************** Begin file sqliteLimit.h *************************************/ |
| 84 | #line 1 "tsrc/sqliteLimit.h" |
| 85 | /* |
| 86 | ** 2007 May 7 |
| 87 | ** |
| 88 | ** The author disclaims copyright to this source code. In place of |
| 89 | ** a legal notice, here is a blessing: |
| @@ -289,10 +291,11 @@ | |
| 291 | # define SQLITE_MAX_TRIGGER_DEPTH 1000 |
| 292 | #endif |
| 293 | |
| 294 | /************** End of sqliteLimit.h *****************************************/ |
| 295 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 296 | #line 54 "tsrc/sqliteInt.h" |
| 297 | |
| 298 | /* Disable nuisance warnings on Borland compilers */ |
| 299 | #if defined(__BORLANDC__) |
| 300 | #pragma warn -rch /* unreachable code */ |
| 301 | #pragma warn -ccc /* Condition is always true or false */ |
| @@ -394,11 +397,11 @@ | |
| 397 | ** assert() macro is enabled, each call into the Win32 native heap subsystem |
| 398 | ** will cause HeapValidate to be called. If heap validation should fail, an |
| 399 | ** assertion will be triggered. |
| 400 | ** |
| 401 | ** (Historical note: There used to be several other options, but we've |
| 402 | ** pared it down to just these three.) |
| 403 | ** |
| 404 | ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as |
| 405 | ** the default. |
| 406 | */ |
| 407 | #if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)>1 |
| @@ -545,10 +548,11 @@ | |
| 548 | # define unlikely(X) !!(X) |
| 549 | #endif |
| 550 | |
| 551 | /************** Include sqlite3.h in the middle of sqliteInt.h ***************/ |
| 552 | /************** Begin file sqlite3.h *****************************************/ |
| 553 | #line 1 "tsrc/sqlite3.h" |
| 554 | /* |
| 555 | ** 2001 September 15 |
| 556 | ** |
| 557 | ** The author disclaims copyright to this source code. In place of |
| 558 | ** a legal notice, here is a blessing: |
| @@ -654,13 +658,13 @@ | |
| 658 | ** |
| 659 | ** See also: [sqlite3_libversion()], |
| 660 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 661 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 662 | */ |
| 663 | #define SQLITE_VERSION "3.7.9" |
| 664 | #define SQLITE_VERSION_NUMBER 3007009 |
| 665 | #define SQLITE_SOURCE_ID "2011-10-07 18:24:25 d4f95b3b6e9f4a4072606af5daa17ea7c645382e" |
| 666 | |
| 667 | /* |
| 668 | ** CAPI3REF: Run-Time Library Version Numbers |
| 669 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 670 | ** |
| @@ -1318,11 +1322,15 @@ | |
| 1322 | ** in order for the database to be readable. The fourth parameter to |
| 1323 | ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
| 1324 | ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent |
| 1325 | ** WAL mode. If the integer is -1, then it is overwritten with the current |
| 1326 | ** WAL persistence setting. |
| 1327 | ** |
| 1328 | ** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening |
| 1329 | ** a write transaction to indicate that, unless it is rolled back for some |
| 1330 | ** reason, the entire database file will be overwritten by the current |
| 1331 | ** transaction. This is used by VACUUM operations. |
| 1332 | */ |
| 1333 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1334 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1335 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1336 | #define SQLITE_LAST_ERRNO 4 |
| @@ -1330,10 +1338,11 @@ | |
| 1338 | #define SQLITE_FCNTL_CHUNK_SIZE 6 |
| 1339 | #define SQLITE_FCNTL_FILE_POINTER 7 |
| 1340 | #define SQLITE_FCNTL_SYNC_OMITTED 8 |
| 1341 | #define SQLITE_FCNTL_WIN32_AV_RETRY 9 |
| 1342 | #define SQLITE_FCNTL_PERSIST_WAL 10 |
| 1343 | #define SQLITE_FCNTL_OVERWRITE 11 |
| 1344 | |
| 1345 | /* |
| 1346 | ** CAPI3REF: Mutex Handle |
| 1347 | ** |
| 1348 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| @@ -3397,11 +3406,11 @@ | |
| 3406 | ** a schema change, on the first [sqlite3_step()] call following any change |
| 3407 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 3408 | ** ^The specific value of WHERE-clause [parameter] might influence the |
| 3409 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 3410 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 3411 | ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. |
| 3412 | ** the |
| 3413 | ** </li> |
| 3414 | ** </ol> |
| 3415 | */ |
| 3416 | SQLITE_API int sqlite3_prepare( |
| @@ -3900,10 +3909,16 @@ | |
| 3909 | ** current row of the result set of [prepared statement] P. |
| 3910 | ** ^If prepared statement P does not have results ready to return |
| 3911 | ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 3912 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 3913 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 3914 | ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to |
| 3915 | ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) |
| 3916 | ** will return non-zero if previous call to [sqlite3_step](P) returned |
| 3917 | ** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum] |
| 3918 | ** where it always returns zero since each step of that multi-step |
| 3919 | ** pragma returns 0 columns of data. |
| 3920 | ** |
| 3921 | ** See also: [sqlite3_column_count()] |
| 3922 | */ |
| 3923 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 3924 | |
| @@ -6362,20 +6377,34 @@ | |
| 6377 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6378 | ** and lookaside memory used by all prepared statements associated with |
| 6379 | ** the database connection.)^ |
| 6380 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6381 | ** </dd> |
| 6382 | ** |
| 6383 | ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt> |
| 6384 | ** <dd>This parameter returns the number of pager cache hits that have |
| 6385 | ** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT |
| 6386 | ** is always 0. |
| 6387 | ** </dd> |
| 6388 | ** |
| 6389 | ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt> |
| 6390 | ** <dd>This parameter returns the number of pager cache misses that have |
| 6391 | ** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS |
| 6392 | ** is always 0. |
| 6393 | ** </dd> |
| 6394 | ** </dl> |
| 6395 | */ |
| 6396 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6397 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6398 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 6399 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 6400 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 6401 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 6402 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 6403 | #define SQLITE_DBSTATUS_CACHE_HIT 7 |
| 6404 | #define SQLITE_DBSTATUS_CACHE_MISS 8 |
| 6405 | #define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */ |
| 6406 | |
| 6407 | |
| 6408 | /* |
| 6409 | ** CAPI3REF: Prepared Statement Status |
| 6410 | ** |
| @@ -6425,11 +6454,10 @@ | |
| 6454 | ** <dd>^This is the number of rows inserted into transient indices that |
| 6455 | ** were created automatically in order to help joins run faster. |
| 6456 | ** A non-zero value in this counter may indicate an opportunity to |
| 6457 | ** improvement performance by adding permanent indices that do not |
| 6458 | ** need to be reinitialized each time the statement is run.</dd> |
| 6459 | ** </dl> |
| 6460 | */ |
| 6461 | #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
| 6462 | #define SQLITE_STMTSTATUS_SORT 2 |
| 6463 | #define SQLITE_STMTSTATUS_AUTOINDEX 3 |
| @@ -7305,12 +7333,14 @@ | |
| 7333 | #endif /* ifndef _SQLITE3RTREE_H_ */ |
| 7334 | |
| 7335 | |
| 7336 | /************** End of sqlite3.h *********************************************/ |
| 7337 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7338 | #line 309 "tsrc/sqliteInt.h" |
| 7339 | /************** Include hash.h in the middle of sqliteInt.h ******************/ |
| 7340 | /************** Begin file hash.h ********************************************/ |
| 7341 | #line 1 "tsrc/hash.h" |
| 7342 | /* |
| 7343 | ** 2001 September 22 |
| 7344 | ** |
| 7345 | ** The author disclaims copyright to this source code. In place of |
| 7346 | ** a legal notice, here is a blessing: |
| @@ -7406,12 +7436,14 @@ | |
| 7436 | |
| 7437 | #endif /* _SQLITE_HASH_H_ */ |
| 7438 | |
| 7439 | /************** End of hash.h ************************************************/ |
| 7440 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7441 | #line 310 "tsrc/sqliteInt.h" |
| 7442 | /************** Include parse.h in the middle of sqliteInt.h *****************/ |
| 7443 | /************** Begin file parse.h *******************************************/ |
| 7444 | #line 1 "tsrc/parse.h" |
| 7445 | #define TK_SEMI 1 |
| 7446 | #define TK_EXPLAIN 2 |
| 7447 | #define TK_QUERY 3 |
| 7448 | #define TK_PLAN 4 |
| 7449 | #define TK_BEGIN 5 |
| @@ -7568,10 +7600,11 @@ | |
| 7600 | #define TK_UMINUS 156 |
| 7601 | #define TK_UPLUS 157 |
| 7602 | |
| 7603 | /************** End of parse.h ***********************************************/ |
| 7604 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 7605 | #line 311 "tsrc/sqliteInt.h" |
| 7606 | #include <stdio.h> |
| 7607 | #include <stdlib.h> |
| 7608 | #include <string.h> |
| 7609 | #include <assert.h> |
| 7610 | #include <stddef.h> |
| @@ -7711,10 +7744,22 @@ | |
| 7744 | ** is 0x00000000ffffffff. But because of quirks of some compilers, we |
| 7745 | ** have to specify the value in the less intuitive manner shown: |
| 7746 | */ |
| 7747 | #define SQLITE_MAX_U32 ((((u64)1)<<32)-1) |
| 7748 | |
| 7749 | /* |
| 7750 | ** The datatype used to store estimates of the number of rows in a |
| 7751 | ** table or index. This is an unsigned integer type. For 99.9% of |
| 7752 | ** the world, a 32-bit integer is sufficient. But a 64-bit integer |
| 7753 | ** can be used at compile-time if desired. |
| 7754 | */ |
| 7755 | #ifdef SQLITE_64BIT_STATS |
| 7756 | typedef u64 tRowcnt; /* 64-bit only if requested at compile-time */ |
| 7757 | #else |
| 7758 | typedef u32 tRowcnt; /* 32-bit is the default */ |
| 7759 | #endif |
| 7760 | |
| 7761 | /* |
| 7762 | ** Macros to determine whether the machine is big or little endian, |
| 7763 | ** evaluated at runtime. |
| 7764 | */ |
| 7765 | #ifdef SQLITE_AMALGAMATION |
| @@ -7911,10 +7956,11 @@ | |
| 7956 | ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque |
| 7957 | ** pointer types (i.e. FuncDef) defined above. |
| 7958 | */ |
| 7959 | /************** Include btree.h in the middle of sqliteInt.h *****************/ |
| 7960 | /************** Begin file btree.h *******************************************/ |
| 7961 | #line 1 "tsrc/btree.h" |
| 7962 | /* |
| 7963 | ** 2001 September 15 |
| 7964 | ** |
| 7965 | ** The author disclaims copyright to this source code. In place of |
| 7966 | ** a legal notice, here is a blessing: |
| @@ -8155,12 +8201,14 @@ | |
| 8201 | |
| 8202 | #endif /* _BTREE_H_ */ |
| 8203 | |
| 8204 | /************** End of btree.h ***********************************************/ |
| 8205 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8206 | #line 665 "tsrc/sqliteInt.h" |
| 8207 | /************** Include vdbe.h in the middle of sqliteInt.h ******************/ |
| 8208 | /************** Begin file vdbe.h ********************************************/ |
| 8209 | #line 1 "tsrc/vdbe.h" |
| 8210 | /* |
| 8211 | ** 2001 September 15 |
| 8212 | ** |
| 8213 | ** The author disclaims copyright to this source code. In place of |
| 8214 | ** a legal notice, here is a blessing: |
| @@ -8321,10 +8369,11 @@ | |
| 8369 | ** The makefile scans the vdbe.c source file and creates the "opcodes.h" |
| 8370 | ** header file that defines a number for each opcode used by the VDBE. |
| 8371 | */ |
| 8372 | /************** Include opcodes.h in the middle of vdbe.h ********************/ |
| 8373 | /************** Begin file opcodes.h *****************************************/ |
| 8374 | #line 1 "tsrc/opcodes.h" |
| 8375 | /* Automatically generated. Do not edit */ |
| 8376 | /* See the mkopcodeh.awk script for details */ |
| 8377 | #define OP_Goto 1 |
| 8378 | #define OP_Gosub 2 |
| 8379 | #define OP_Return 3 |
| @@ -8509,10 +8558,11 @@ | |
| 8558 | /* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\ |
| 8559 | /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,} |
| 8560 | |
| 8561 | /************** End of opcodes.h *********************************************/ |
| 8562 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 8563 | #line 164 "tsrc/vdbe.h" |
| 8564 | |
| 8565 | /* |
| 8566 | ** Prototypes for the VDBE interface. See comments on the implementation |
| 8567 | ** for a description of what each of these routines does. |
| 8568 | */ |
| @@ -8583,12 +8633,14 @@ | |
| 8633 | |
| 8634 | #endif |
| 8635 | |
| 8636 | /************** End of vdbe.h ************************************************/ |
| 8637 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8638 | #line 666 "tsrc/sqliteInt.h" |
| 8639 | /************** Include pager.h in the middle of sqliteInt.h *****************/ |
| 8640 | /************** Begin file pager.h *******************************************/ |
| 8641 | #line 1 "tsrc/pager.h" |
| 8642 | /* |
| 8643 | ** 2001 September 15 |
| 8644 | ** |
| 8645 | ** The author disclaims copyright to this source code. In place of |
| 8646 | ** a legal notice, here is a blessing: |
| @@ -8742,10 +8794,11 @@ | |
| 8794 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); |
| 8795 | SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); |
| 8796 | SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); |
| 8797 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| 8798 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); |
| 8799 | SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *); |
| 8800 | |
| 8801 | /* Functions used to truncate the database file. */ |
| 8802 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 8803 | |
| 8804 | #if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL) |
| @@ -8769,12 +8822,14 @@ | |
| 8822 | |
| 8823 | #endif /* _PAGER_H_ */ |
| 8824 | |
| 8825 | /************** End of pager.h ***********************************************/ |
| 8826 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8827 | #line 667 "tsrc/sqliteInt.h" |
| 8828 | /************** Include pcache.h in the middle of sqliteInt.h ****************/ |
| 8829 | /************** Begin file pcache.h ******************************************/ |
| 8830 | #line 1 "tsrc/pcache.h" |
| 8831 | /* |
| 8832 | ** 2008 August 05 |
| 8833 | ** |
| 8834 | ** The author disclaims copyright to this source code. In place of |
| 8835 | ** a legal notice, here is a blessing: |
| @@ -8929,13 +8984,15 @@ | |
| 8984 | |
| 8985 | #endif /* _PCACHE_H_ */ |
| 8986 | |
| 8987 | /************** End of pcache.h **********************************************/ |
| 8988 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 8989 | #line 668 "tsrc/sqliteInt.h" |
| 8990 | |
| 8991 | /************** Include os.h in the middle of sqliteInt.h ********************/ |
| 8992 | /************** Begin file os.h **********************************************/ |
| 8993 | #line 1 "tsrc/os.h" |
| 8994 | /* |
| 8995 | ** 2001 September 16 |
| 8996 | ** |
| 8997 | ** The author disclaims copyright to this source code. In place of |
| 8998 | ** a legal notice, here is a blessing: |
| @@ -9214,12 +9271,14 @@ | |
| 9271 | |
| 9272 | #endif /* _SQLITE_OS_H_ */ |
| 9273 | |
| 9274 | /************** End of os.h **************************************************/ |
| 9275 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 9276 | #line 670 "tsrc/sqliteInt.h" |
| 9277 | /************** Include mutex.h in the middle of sqliteInt.h *****************/ |
| 9278 | /************** Begin file mutex.h *******************************************/ |
| 9279 | #line 1 "tsrc/mutex.h" |
| 9280 | /* |
| 9281 | ** 2007 August 28 |
| 9282 | ** |
| 9283 | ** The author disclaims copyright to this source code. In place of |
| 9284 | ** a legal notice, here is a blessing: |
| @@ -9290,10 +9349,11 @@ | |
| 9349 | #define sqlite3MutexEnd() |
| 9350 | #endif /* defined(SQLITE_MUTEX_OMIT) */ |
| 9351 | |
| 9352 | /************** End of mutex.h ***********************************************/ |
| 9353 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 9354 | #line 671 "tsrc/sqliteInt.h" |
| 9355 | |
| 9356 | |
| 9357 | /* |
| 9358 | ** Each database file to be accessed by the system is an instance |
| 9359 | ** of the following structure. There are normally two of these structures |
| @@ -9918,11 +9978,11 @@ | |
| 9978 | int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ |
| 9979 | int nCol; /* Number of columns in this table */ |
| 9980 | Column *aCol; /* Information about each column */ |
| 9981 | Index *pIndex; /* List of SQL indexes on this table. */ |
| 9982 | int tnum; /* Root BTree node for this table (see note above) */ |
| 9983 | tRowcnt nRowEst; /* Estimated rows in table - from sqlite_stat1 table */ |
| 9984 | Select *pSelect; /* NULL for tables. Points to definition if a view. */ |
| 9985 | u16 nRef; /* Number of pointers to this Table */ |
| 9986 | u8 tabFlags; /* Mask of TF_* values */ |
| 9987 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
| 9988 | FKey *pFKey; /* Linked list of all foreign keys in this table */ |
| @@ -10117,11 +10177,11 @@ | |
| 10177 | */ |
| 10178 | struct Index { |
| 10179 | char *zName; /* Name of this index */ |
| 10180 | int nColumn; /* Number of columns in the table used by this index */ |
| 10181 | int *aiColumn; /* Which columns are used by this index. 1st is 0 */ |
| 10182 | tRowcnt *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ |
| 10183 | Table *pTable; /* The SQL table being indexed */ |
| 10184 | int tnum; /* Page containing root of this index in database file */ |
| 10185 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 10186 | u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ |
| 10187 | u8 bUnordered; /* Use this index for == or IN queries only */ |
| @@ -10128,24 +10188,32 @@ | |
| 10188 | char *zColAff; /* String defining the affinity of each column */ |
| 10189 | Index *pNext; /* The next index associated with the same table */ |
| 10190 | Schema *pSchema; /* Schema containing this index */ |
| 10191 | u8 *aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ |
| 10192 | char **azColl; /* Array of collation sequence names for index */ |
| 10193 | #ifdef SQLITE_ENABLE_STAT3 |
| 10194 | int nSample; /* Number of elements in aSample[] */ |
| 10195 | tRowcnt avgEq; /* Average nEq value for key values not in aSample */ |
| 10196 | IndexSample *aSample; /* Samples of the left-most key */ |
| 10197 | #endif |
| 10198 | }; |
| 10199 | |
| 10200 | /* |
| 10201 | ** Each sample stored in the sqlite_stat2 table is represented in memory |
| 10202 | ** using a structure of this type. |
| 10203 | */ |
| 10204 | struct IndexSample { |
| 10205 | union { |
| 10206 | char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */ |
| 10207 | double r; /* Value if eType is SQLITE_FLOAT */ |
| 10208 | i64 i; /* Value if eType is SQLITE_INTEGER */ |
| 10209 | } u; |
| 10210 | u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ |
| 10211 | int nByte; /* Size in byte of text or blob. */ |
| 10212 | tRowcnt nEq; /* Est. number of rows where the key equals this sample */ |
| 10213 | tRowcnt nLt; /* Est. number of rows where key is less than this sample */ |
| 10214 | tRowcnt nDLt; /* Est. number of distinct keys less than this sample */ |
| 10215 | }; |
| 10216 | |
| 10217 | /* |
| 10218 | ** Each token coming out of the lexer is an instance of |
| 10219 | ** this structure. Tokens are also used as part of an expression. |
| @@ -10593,14 +10661,14 @@ | |
| 10661 | #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ |
| 10662 | #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ |
| 10663 | #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ |
| 10664 | #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
| 10665 | #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
| 10666 | #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */ |
| 10667 | #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */ |
| 10668 | #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */ |
| 10669 | #define WHERE_AND_ONLY 0x0080 /* Don't use indices for OR terms */ |
| 10670 | |
| 10671 | /* |
| 10672 | ** The WHERE clause processing routine has two halves. The |
| 10673 | ** first part does the start of the WHERE loop and the second |
| 10674 | ** half does the tail of the WHERE loop. An instance of |
| @@ -11350,10 +11418,11 @@ | |
| 11418 | #else |
| 11419 | # define sqlite3ViewGetColumnNames(A,B) 0 |
| 11420 | #endif |
| 11421 | |
| 11422 | SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int); |
| 11423 | SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int); |
| 11424 | SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*); |
| 11425 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 11426 | SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); |
| 11427 | SQLITE_PRIVATE void sqlite3AutoincrementEnd(Parse *pParse); |
| 11428 | #else |
| @@ -11606,11 +11675,11 @@ | |
| 11675 | SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, |
| 11676 | void(*)(void*)); |
| 11677 | SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*); |
| 11678 | SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *); |
| 11679 | SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); |
| 11680 | #ifdef SQLITE_ENABLE_STAT3 |
| 11681 | SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *); |
| 11682 | #endif |
| 11683 | SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); |
| 11684 | SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); |
| 11685 | #ifndef SQLITE_AMALGAMATION |
| @@ -11893,10 +11962,11 @@ | |
| 11962 | |
| 11963 | #endif /* _SQLITEINT_H_ */ |
| 11964 | |
| 11965 | /************** End of sqliteInt.h *******************************************/ |
| 11966 | /************** Begin file global.c ******************************************/ |
| 11967 | #line 1 "tsrc/global.c" |
| 11968 | /* |
| 11969 | ** 2008 June 13 |
| 11970 | ** |
| 11971 | ** The author disclaims copyright to this source code. In place of |
| 11972 | ** a legal notice, here is a blessing: |
| @@ -12115,10 +12185,11 @@ | |
| 12185 | */ |
| 12186 | SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER; |
| 12187 | |
| 12188 | /************** End of global.c **********************************************/ |
| 12189 | /************** Begin file ctime.c *******************************************/ |
| 12190 | #line 1 "tsrc/ctime.c" |
| 12191 | /* |
| 12192 | ** 2010 February 23 |
| 12193 | ** |
| 12194 | ** The author disclaims copyright to this source code. In place of |
| 12195 | ** a legal notice, here is a blessing: |
| @@ -12232,10 +12303,13 @@ | |
| 12303 | #ifdef SQLITE_ENABLE_RTREE |
| 12304 | "ENABLE_RTREE", |
| 12305 | #endif |
| 12306 | #ifdef SQLITE_ENABLE_STAT2 |
| 12307 | "ENABLE_STAT2", |
| 12308 | #endif |
| 12309 | #ifdef SQLITE_ENABLE_STAT3 |
| 12310 | "ENABLE_STAT3", |
| 12311 | #endif |
| 12312 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY |
| 12313 | "ENABLE_UNLOCK_NOTIFY", |
| 12314 | #endif |
| 12315 | #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT |
| @@ -12445,13 +12519,10 @@ | |
| 12519 | "OMIT_WSD", |
| 12520 | #endif |
| 12521 | #ifdef SQLITE_OMIT_XFER_OPT |
| 12522 | "OMIT_XFER_OPT", |
| 12523 | #endif |
| 12524 | #ifdef SQLITE_PERFORMANCE_TRACE |
| 12525 | "PERFORMANCE_TRACE", |
| 12526 | #endif |
| 12527 | #ifdef SQLITE_PROXY_DEBUG |
| 12528 | "PROXY_DEBUG", |
| @@ -12519,10 +12590,11 @@ | |
| 12590 | |
| 12591 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| 12592 | |
| 12593 | /************** End of ctime.c ***********************************************/ |
| 12594 | /************** Begin file status.c ******************************************/ |
| 12595 | #line 1 "tsrc/status.c" |
| 12596 | /* |
| 12597 | ** 2008 June 18 |
| 12598 | ** |
| 12599 | ** The author disclaims copyright to this source code. In place of |
| 12600 | ** a legal notice, here is a blessing: |
| @@ -12536,10 +12608,11 @@ | |
| 12608 | ** This module implements the sqlite3_status() interface and related |
| 12609 | ** functionality. |
| 12610 | */ |
| 12611 | /************** Include vdbeInt.h in the middle of status.c ******************/ |
| 12612 | /************** Begin file vdbeInt.h *****************************************/ |
| 12613 | #line 1 "tsrc/vdbeInt.h" |
| 12614 | /* |
| 12615 | ** 2003 September 6 |
| 12616 | ** |
| 12617 | ** The author disclaims copyright to this source code. In place of |
| 12618 | ** a legal notice, here is a blessing: |
| @@ -12987,10 +13060,11 @@ | |
| 13060 | |
| 13061 | #endif /* !defined(_VDBEINT_H_) */ |
| 13062 | |
| 13063 | /************** End of vdbeInt.h *********************************************/ |
| 13064 | /************** Continuing where we left off in status.c *********************/ |
| 13065 | #line 18 "tsrc/status.c" |
| 13066 | |
| 13067 | /* |
| 13068 | ** Variables in which to record status information. |
| 13069 | */ |
| 13070 | typedef struct sqlite3StatType sqlite3StatType; |
| @@ -13189,10 +13263,32 @@ | |
| 13263 | *pHighwater = 0; |
| 13264 | *pCurrent = nByte; |
| 13265 | |
| 13266 | break; |
| 13267 | } |
| 13268 | |
| 13269 | /* |
| 13270 | ** Set *pCurrent to the total cache hits or misses encountered by all |
| 13271 | ** pagers the database handle is connected to. *pHighwater is always set |
| 13272 | ** to zero. |
| 13273 | */ |
| 13274 | case SQLITE_DBSTATUS_CACHE_HIT: |
| 13275 | case SQLITE_DBSTATUS_CACHE_MISS: { |
| 13276 | int i; |
| 13277 | int nRet = 0; |
| 13278 | assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 ); |
| 13279 | |
| 13280 | for(i=0; i<db->nDb; i++){ |
| 13281 | if( db->aDb[i].pBt ){ |
| 13282 | Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt); |
| 13283 | sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet); |
| 13284 | } |
| 13285 | } |
| 13286 | *pHighwater = 0; |
| 13287 | *pCurrent = nRet; |
| 13288 | break; |
| 13289 | } |
| 13290 | |
| 13291 | default: { |
| 13292 | rc = SQLITE_ERROR; |
| 13293 | } |
| 13294 | } |
| @@ -13200,10 +13296,11 @@ | |
| 13296 | return rc; |
| 13297 | } |
| 13298 | |
| 13299 | /************** End of status.c **********************************************/ |
| 13300 | /************** Begin file date.c ********************************************/ |
| 13301 | #line 1 "tsrc/date.c" |
| 13302 | /* |
| 13303 | ** 2003 October 31 |
| 13304 | ** |
| 13305 | ** The author disclaims copyright to this source code. In place of |
| 13306 | ** a legal notice, here is a blessing: |
| @@ -14327,10 +14424,11 @@ | |
| 14424 | } |
| 14425 | } |
| 14426 | |
| 14427 | /************** End of date.c ************************************************/ |
| 14428 | /************** Begin file os.c **********************************************/ |
| 14429 | #line 1 "tsrc/os.c" |
| 14430 | /* |
| 14431 | ** 2005 November 29 |
| 14432 | ** |
| 14433 | ** The author disclaims copyright to this source code. In place of |
| 14434 | ** a legal notice, here is a blessing: |
| @@ -14660,10 +14758,11 @@ | |
| 14758 | return SQLITE_OK; |
| 14759 | } |
| 14760 | |
| 14761 | /************** End of os.c **************************************************/ |
| 14762 | /************** Begin file fault.c *******************************************/ |
| 14763 | #line 1 "tsrc/fault.c" |
| 14764 | /* |
| 14765 | ** 2008 Jan 22 |
| 14766 | ** |
| 14767 | ** The author disclaims copyright to this source code. In place of |
| 14768 | ** a legal notice, here is a blessing: |
| @@ -14749,10 +14848,11 @@ | |
| 14848 | |
| 14849 | #endif /* #ifndef SQLITE_OMIT_BUILTIN_TEST */ |
| 14850 | |
| 14851 | /************** End of fault.c ***********************************************/ |
| 14852 | /************** Begin file mem0.c ********************************************/ |
| 14853 | #line 1 "tsrc/mem0.c" |
| 14854 | /* |
| 14855 | ** 2008 October 28 |
| 14856 | ** |
| 14857 | ** The author disclaims copyright to this source code. In place of |
| 14858 | ** a legal notice, here is a blessing: |
| @@ -14810,10 +14910,11 @@ | |
| 14910 | |
| 14911 | #endif /* SQLITE_ZERO_MALLOC */ |
| 14912 | |
| 14913 | /************** End of mem0.c ************************************************/ |
| 14914 | /************** Begin file mem1.c ********************************************/ |
| 14915 | #line 1 "tsrc/mem1.c" |
| 14916 | /* |
| 14917 | ** 2007 August 14 |
| 14918 | ** |
| 14919 | ** The author disclaims copyright to this source code. In place of |
| 14920 | ** a legal notice, here is a blessing: |
| @@ -14962,10 +15063,11 @@ | |
| 15063 | |
| 15064 | #endif /* SQLITE_SYSTEM_MALLOC */ |
| 15065 | |
| 15066 | /************** End of mem1.c ************************************************/ |
| 15067 | /************** Begin file mem2.c ********************************************/ |
| 15068 | #line 1 "tsrc/mem2.c" |
| 15069 | /* |
| 15070 | ** 2007 August 15 |
| 15071 | ** |
| 15072 | ** The author disclaims copyright to this source code. In place of |
| 15073 | ** a legal notice, here is a blessing: |
| @@ -15492,10 +15594,11 @@ | |
| 15594 | |
| 15595 | #endif /* SQLITE_MEMDEBUG */ |
| 15596 | |
| 15597 | /************** End of mem2.c ************************************************/ |
| 15598 | /************** Begin file mem3.c ********************************************/ |
| 15599 | #line 1 "tsrc/mem3.c" |
| 15600 | /* |
| 15601 | ** 2007 October 14 |
| 15602 | ** |
| 15603 | ** The author disclaims copyright to this source code. In place of |
| 15604 | ** a legal notice, here is a blessing: |
| @@ -16181,10 +16284,11 @@ | |
| 16284 | |
| 16285 | #endif /* SQLITE_ENABLE_MEMSYS3 */ |
| 16286 | |
| 16287 | /************** End of mem3.c ************************************************/ |
| 16288 | /************** Begin file mem5.c ********************************************/ |
| 16289 | #line 1 "tsrc/mem5.c" |
| 16290 | /* |
| 16291 | ** 2007 October 14 |
| 16292 | ** |
| 16293 | ** The author disclaims copyright to this source code. In place of |
| 16294 | ** a legal notice, here is a blessing: |
| @@ -16764,10 +16868,11 @@ | |
| 16868 | |
| 16869 | #endif /* SQLITE_ENABLE_MEMSYS5 */ |
| 16870 | |
| 16871 | /************** End of mem5.c ************************************************/ |
| 16872 | /************** Begin file mutex.c *******************************************/ |
| 16873 | #line 1 "tsrc/mutex.c" |
| 16874 | /* |
| 16875 | ** 2007 August 14 |
| 16876 | ** |
| 16877 | ** The author disclaims copyright to this source code. In place of |
| 16878 | ** a legal notice, here is a blessing: |
| @@ -16919,10 +17024,11 @@ | |
| 17024 | |
| 17025 | #endif /* SQLITE_MUTEX_OMIT */ |
| 17026 | |
| 17027 | /************** End of mutex.c ***********************************************/ |
| 17028 | /************** Begin file mutex_noop.c **************************************/ |
| 17029 | #line 1 "tsrc/mutex_noop.c" |
| 17030 | /* |
| 17031 | ** 2008 October 07 |
| 17032 | ** |
| 17033 | ** The author disclaims copyright to this source code. In place of |
| 17034 | ** a legal notice, here is a blessing: |
| @@ -17127,10 +17233,11 @@ | |
| 17233 | #endif /* SQLITE_MUTEX_NOOP */ |
| 17234 | #endif /* SQLITE_MUTEX_OMIT */ |
| 17235 | |
| 17236 | /************** End of mutex_noop.c ******************************************/ |
| 17237 | /************** Begin file mutex_os2.c ***************************************/ |
| 17238 | #line 1 "tsrc/mutex_os2.c" |
| 17239 | /* |
| 17240 | ** 2007 August 28 |
| 17241 | ** |
| 17242 | ** The author disclaims copyright to this source code. In place of |
| 17243 | ** a legal notice, here is a blessing: |
| @@ -17403,10 +17510,11 @@ | |
| 17510 | } |
| 17511 | #endif /* SQLITE_MUTEX_OS2 */ |
| 17512 | |
| 17513 | /************** End of mutex_os2.c *******************************************/ |
| 17514 | /************** Begin file mutex_unix.c **************************************/ |
| 17515 | #line 1 "tsrc/mutex_unix.c" |
| 17516 | /* |
| 17517 | ** 2007 August 28 |
| 17518 | ** |
| 17519 | ** The author disclaims copyright to this source code. In place of |
| 17520 | ** a legal notice, here is a blessing: |
| @@ -17756,10 +17864,11 @@ | |
| 17864 | |
| 17865 | #endif /* SQLITE_MUTEX_PTHREAD */ |
| 17866 | |
| 17867 | /************** End of mutex_unix.c ******************************************/ |
| 17868 | /************** Begin file mutex_w32.c ***************************************/ |
| 17869 | #line 1 "tsrc/mutex_w32.c" |
| 17870 | /* |
| 17871 | ** 2007 August 14 |
| 17872 | ** |
| 17873 | ** The author disclaims copyright to this source code. In place of |
| 17874 | ** a legal notice, here is a blessing: |
| @@ -18090,10 +18199,11 @@ | |
| 18199 | } |
| 18200 | #endif /* SQLITE_MUTEX_W32 */ |
| 18201 | |
| 18202 | /************** End of mutex_w32.c *******************************************/ |
| 18203 | /************** Begin file malloc.c ******************************************/ |
| 18204 | #line 1 "tsrc/malloc.c" |
| 18205 | /* |
| 18206 | ** 2001 September 15 |
| 18207 | ** |
| 18208 | ** The author disclaims copyright to this source code. In place of |
| 18209 | ** a legal notice, here is a blessing: |
| @@ -18869,10 +18979,11 @@ | |
| 18979 | return rc & (db ? db->errMask : 0xff); |
| 18980 | } |
| 18981 | |
| 18982 | /************** End of malloc.c **********************************************/ |
| 18983 | /************** Begin file printf.c ******************************************/ |
| 18984 | #line 1 "tsrc/printf.c" |
| 18985 | /* |
| 18986 | ** The "printf" code that follows dates from the 1980's. It is in |
| 18987 | ** the public domain. The original comments are included here for |
| 18988 | ** completeness. They are very out-of-date but might be useful as |
| 18989 | ** an historical reference. Most of the "enhancements" have been backed |
| @@ -19900,10 +20011,11 @@ | |
| 20011 | } |
| 20012 | #endif |
| 20013 | |
| 20014 | /************** End of printf.c **********************************************/ |
| 20015 | /************** Begin file random.c ******************************************/ |
| 20016 | #line 1 "tsrc/random.c" |
| 20017 | /* |
| 20018 | ** 2001 September 15 |
| 20019 | ** |
| 20020 | ** The author disclaims copyright to this source code. In place of |
| 20021 | ** a legal notice, here is a blessing: |
| @@ -20047,10 +20159,11 @@ | |
| 20159 | } |
| 20160 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 20161 | |
| 20162 | /************** End of random.c **********************************************/ |
| 20163 | /************** Begin file utf.c *********************************************/ |
| 20164 | #line 1 "tsrc/utf.c" |
| 20165 | /* |
| 20166 | ** 2004 April 13 |
| 20167 | ** |
| 20168 | ** The author disclaims copyright to this source code. In place of |
| 20169 | ** a legal notice, here is a blessing: |
| @@ -20511,11 +20624,11 @@ | |
| 20624 | ** no longer required. |
| 20625 | ** |
| 20626 | ** If a malloc failure occurs, NULL is returned and the db.mallocFailed |
| 20627 | ** flag set. |
| 20628 | */ |
| 20629 | #ifdef SQLITE_ENABLE_STAT3 |
| 20630 | SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *db, u8 enc, char *z, int n, int *pnOut){ |
| 20631 | Mem m; |
| 20632 | memset(&m, 0, sizeof(m)); |
| 20633 | m.db = db; |
| 20634 | sqlite3VdbeMemSetStr(&m, z, n, SQLITE_UTF8, SQLITE_STATIC); |
| @@ -20608,10 +20721,11 @@ | |
| 20721 | #endif /* SQLITE_TEST */ |
| 20722 | #endif /* SQLITE_OMIT_UTF16 */ |
| 20723 | |
| 20724 | /************** End of utf.c *************************************************/ |
| 20725 | /************** Begin file util.c ********************************************/ |
| 20726 | #line 1 "tsrc/util.c" |
| 20727 | /* |
| 20728 | ** 2001 September 15 |
| 20729 | ** |
| 20730 | ** The author disclaims copyright to this source code. In place of |
| 20731 | ** a legal notice, here is a blessing: |
| @@ -21790,10 +21904,11 @@ | |
| 21904 | } |
| 21905 | #endif |
| 21906 | |
| 21907 | /************** End of util.c ************************************************/ |
| 21908 | /************** Begin file hash.c ********************************************/ |
| 21909 | #line 1 "tsrc/hash.c" |
| 21910 | /* |
| 21911 | ** 2001 September 22 |
| 21912 | ** |
| 21913 | ** The author disclaims copyright to this source code. In place of |
| 21914 | ** a legal notice, here is a blessing: |
| @@ -22069,10 +22184,11 @@ | |
| 22184 | return 0; |
| 22185 | } |
| 22186 | |
| 22187 | /************** End of hash.c ************************************************/ |
| 22188 | /************** Begin file opcodes.c *****************************************/ |
| 22189 | #line 1 "tsrc/opcodes.c" |
| 22190 | /* Automatically generated. Do not edit */ |
| 22191 | /* See the mkopcodec.awk script for details. */ |
| 22192 | #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) |
| 22193 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ |
| 22194 | static const char *const azName[] = { "?", |
| @@ -22231,10 +22347,11 @@ | |
| 22347 | } |
| 22348 | #endif |
| 22349 | |
| 22350 | /************** End of opcodes.c *********************************************/ |
| 22351 | /************** Begin file os_os2.c ******************************************/ |
| 22352 | #line 1 "tsrc/os_os2.c" |
| 22353 | /* |
| 22354 | ** 2006 Feb 14 |
| 22355 | ** |
| 22356 | ** The author disclaims copyright to this source code. In place of |
| 22357 | ** a legal notice, here is a blessing: |
| @@ -22287,10 +22404,11 @@ | |
| 22404 | /* |
| 22405 | ** Include code that is common to all os_*.c files |
| 22406 | */ |
| 22407 | /************** Include os_common.h in the middle of os_os2.c ****************/ |
| 22408 | /************** Begin file os_common.h ***************************************/ |
| 22409 | #line 1 "tsrc/os_common.h" |
| 22410 | /* |
| 22411 | ** 2004 May 22 |
| 22412 | ** |
| 22413 | ** The author disclaims copyright to this source code. In place of |
| 22414 | ** a legal notice, here is a blessing: |
| @@ -22340,10 +22458,11 @@ | |
| 22458 | ** hwtime.h contains inline assembler code for implementing |
| 22459 | ** high-performance timing routines. |
| 22460 | */ |
| 22461 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 22462 | /************** Begin file hwtime.h ******************************************/ |
| 22463 | #line 1 "tsrc/hwtime.h" |
| 22464 | /* |
| 22465 | ** 2008 May 27 |
| 22466 | ** |
| 22467 | ** The author disclaims copyright to this source code. In place of |
| 22468 | ** a legal notice, here is a blessing: |
| @@ -22428,10 +22547,11 @@ | |
| 22547 | |
| 22548 | #endif /* !defined(_HWTIME_H_) */ |
| 22549 | |
| 22550 | /************** End of hwtime.h **********************************************/ |
| 22551 | /************** Continuing where we left off in os_common.h ******************/ |
| 22552 | #line 53 "tsrc/os_common.h" |
| 22553 | |
| 22554 | static sqlite_uint64 g_start; |
| 22555 | static sqlite_uint64 g_elapsed; |
| 22556 | #define TIMER_START g_start=sqlite3Hwtime() |
| 22557 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -22494,10 +22614,11 @@ | |
| 22614 | |
| 22615 | #endif /* !defined(_OS_COMMON_H_) */ |
| 22616 | |
| 22617 | /************** End of os_common.h *******************************************/ |
| 22618 | /************** Continuing where we left off in os_os2.c *********************/ |
| 22619 | #line 57 "tsrc/os_os2.c" |
| 22620 | |
| 22621 | /* Forward references */ |
| 22622 | typedef struct os2File os2File; /* The file structure */ |
| 22623 | typedef struct os2ShmNode os2ShmNode; /* A shared descritive memory node */ |
| 22624 | typedef struct os2ShmLink os2ShmLink; /* A connection to shared-memory */ |
| @@ -24365,10 +24486,11 @@ | |
| 24486 | |
| 24487 | #endif /* SQLITE_OS_OS2 */ |
| 24488 | |
| 24489 | /************** End of os_os2.c **********************************************/ |
| 24490 | /************** Begin file os_unix.c *****************************************/ |
| 24491 | #line 1 "tsrc/os_unix.c" |
| 24492 | /* |
| 24493 | ** 2004 May 22 |
| 24494 | ** |
| 24495 | ** The author disclaims copyright to this source code. In place of |
| 24496 | ** a legal notice, here is a blessing: |
| @@ -24629,10 +24751,11 @@ | |
| 24751 | /* |
| 24752 | ** Include code that is common to all os_*.c files |
| 24753 | */ |
| 24754 | /************** Include os_common.h in the middle of os_unix.c ***************/ |
| 24755 | /************** Begin file os_common.h ***************************************/ |
| 24756 | #line 1 "tsrc/os_common.h" |
| 24757 | /* |
| 24758 | ** 2004 May 22 |
| 24759 | ** |
| 24760 | ** The author disclaims copyright to this source code. In place of |
| 24761 | ** a legal notice, here is a blessing: |
| @@ -24682,10 +24805,11 @@ | |
| 24805 | ** hwtime.h contains inline assembler code for implementing |
| 24806 | ** high-performance timing routines. |
| 24807 | */ |
| 24808 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 24809 | /************** Begin file hwtime.h ******************************************/ |
| 24810 | #line 1 "tsrc/hwtime.h" |
| 24811 | /* |
| 24812 | ** 2008 May 27 |
| 24813 | ** |
| 24814 | ** The author disclaims copyright to this source code. In place of |
| 24815 | ** a legal notice, here is a blessing: |
| @@ -24770,10 +24894,11 @@ | |
| 24894 | |
| 24895 | #endif /* !defined(_HWTIME_H_) */ |
| 24896 | |
| 24897 | /************** End of hwtime.h **********************************************/ |
| 24898 | /************** Continuing where we left off in os_common.h ******************/ |
| 24899 | #line 53 "tsrc/os_common.h" |
| 24900 | |
| 24901 | static sqlite_uint64 g_start; |
| 24902 | static sqlite_uint64 g_elapsed; |
| 24903 | #define TIMER_START g_start=sqlite3Hwtime() |
| 24904 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -24836,10 +24961,11 @@ | |
| 24961 | |
| 24962 | #endif /* !defined(_OS_COMMON_H_) */ |
| 24963 | |
| 24964 | /************** End of os_common.h *******************************************/ |
| 24965 | /************** Continuing where we left off in os_unix.c ********************/ |
| 24966 | #line 265 "tsrc/os_unix.c" |
| 24967 | |
| 24968 | /* |
| 24969 | ** Define various macros that are missing from some systems. |
| 24970 | */ |
| 24971 | #ifndef O_LARGEFILE |
| @@ -29462,12 +29588,20 @@ | |
| 29588 | ** |
| 29589 | ** where NN is a 4 digit decimal number. The NN naming schemes are |
| 29590 | ** used by the test_multiplex.c module. |
| 29591 | */ |
| 29592 | nDb = sqlite3Strlen30(zPath) - 1; |
| 29593 | #ifdef SQLITE_ENABLE_8_3_NAMES |
| 29594 | while( nDb>0 && zPath[nDb]!='-' && zPath[nDb]!='/' ) nDb--; |
| 29595 | if( nDb==0 || zPath[nDb]=='/' ) return SQLITE_OK; |
| 29596 | #else |
| 29597 | while( zPath[nDb]!='-' ){ |
| 29598 | assert( nDb>0 ); |
| 29599 | assert( zPath[nDb]!='\n' ); |
| 29600 | nDb--; |
| 29601 | } |
| 29602 | #endif |
| 29603 | memcpy(zDb, zPath, nDb); |
| 29604 | zDb[nDb] = '\0'; |
| 29605 | |
| 29606 | if( 0==osStat(zDb, &sStat) ){ |
| 29607 | *pMode = sStat.st_mode & 0777; |
| @@ -31345,10 +31479,11 @@ | |
| 31479 | |
| 31480 | #endif /* SQLITE_OS_UNIX */ |
| 31481 | |
| 31482 | /************** End of os_unix.c *********************************************/ |
| 31483 | /************** Begin file os_win.c ******************************************/ |
| 31484 | #line 1 "tsrc/os_win.c" |
| 31485 | /* |
| 31486 | ** 2004 May 22 |
| 31487 | ** |
| 31488 | ** The author disclaims copyright to this source code. In place of |
| 31489 | ** a legal notice, here is a blessing: |
| @@ -31406,10 +31541,11 @@ | |
| 31541 | /* |
| 31542 | ** Include code that is common to all os_*.c files |
| 31543 | */ |
| 31544 | /************** Include os_common.h in the middle of os_win.c ****************/ |
| 31545 | /************** Begin file os_common.h ***************************************/ |
| 31546 | #line 1 "tsrc/os_common.h" |
| 31547 | /* |
| 31548 | ** 2004 May 22 |
| 31549 | ** |
| 31550 | ** The author disclaims copyright to this source code. In place of |
| 31551 | ** a legal notice, here is a blessing: |
| @@ -31459,10 +31595,11 @@ | |
| 31595 | ** hwtime.h contains inline assembler code for implementing |
| 31596 | ** high-performance timing routines. |
| 31597 | */ |
| 31598 | /************** Include hwtime.h in the middle of os_common.h ****************/ |
| 31599 | /************** Begin file hwtime.h ******************************************/ |
| 31600 | #line 1 "tsrc/hwtime.h" |
| 31601 | /* |
| 31602 | ** 2008 May 27 |
| 31603 | ** |
| 31604 | ** The author disclaims copyright to this source code. In place of |
| 31605 | ** a legal notice, here is a blessing: |
| @@ -31547,10 +31684,11 @@ | |
| 31684 | |
| 31685 | #endif /* !defined(_HWTIME_H_) */ |
| 31686 | |
| 31687 | /************** End of hwtime.h **********************************************/ |
| 31688 | /************** Continuing where we left off in os_common.h ******************/ |
| 31689 | #line 53 "tsrc/os_common.h" |
| 31690 | |
| 31691 | static sqlite_uint64 g_start; |
| 31692 | static sqlite_uint64 g_elapsed; |
| 31693 | #define TIMER_START g_start=sqlite3Hwtime() |
| 31694 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start |
| @@ -31613,10 +31751,11 @@ | |
| 31751 | |
| 31752 | #endif /* !defined(_OS_COMMON_H_) */ |
| 31753 | |
| 31754 | /************** End of os_common.h *******************************************/ |
| 31755 | /************** Continuing where we left off in os_win.c *********************/ |
| 31756 | #line 62 "tsrc/os_win.c" |
| 31757 | |
| 31758 | /* |
| 31759 | ** Some microsoft compilers lack this definition. |
| 31760 | */ |
| 31761 | #ifndef INVALID_FILE_ATTRIBUTES |
| @@ -34169,11 +34308,11 @@ | |
| 34308 | |
| 34309 | if( h==INVALID_HANDLE_VALUE ){ |
| 34310 | pFile->lastErrno = GetLastError(); |
| 34311 | winLogError(SQLITE_CANTOPEN, "winOpen", zUtf8Name); |
| 34312 | free(zConverted); |
| 34313 | if( isReadWrite && !isExclusive ){ |
| 34314 | return winOpen(pVfs, zName, id, |
| 34315 | ((flags|SQLITE_OPEN_READONLY)&~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), pOutFlags); |
| 34316 | }else{ |
| 34317 | return SQLITE_CANTOPEN_BKPT; |
| 34318 | } |
| @@ -34758,10 +34897,11 @@ | |
| 34897 | |
| 34898 | #endif /* SQLITE_OS_WIN */ |
| 34899 | |
| 34900 | /************** End of os_win.c **********************************************/ |
| 34901 | /************** Begin file bitvec.c ******************************************/ |
| 34902 | #line 1 "tsrc/bitvec.c" |
| 34903 | /* |
| 34904 | ** 2008 February 16 |
| 34905 | ** |
| 34906 | ** The author disclaims copyright to this source code. In place of |
| 34907 | ** a legal notice, here is a blessing: |
| @@ -35168,10 +35308,11 @@ | |
| 35308 | } |
| 35309 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 35310 | |
| 35311 | /************** End of bitvec.c **********************************************/ |
| 35312 | /************** Begin file pcache.c ******************************************/ |
| 35313 | #line 1 "tsrc/pcache.c" |
| 35314 | /* |
| 35315 | ** 2008 August 05 |
| 35316 | ** |
| 35317 | ** The author disclaims copyright to this source code. In place of |
| 35318 | ** a legal notice, here is a blessing: |
| @@ -35764,10 +35905,11 @@ | |
| 35905 | } |
| 35906 | #endif |
| 35907 | |
| 35908 | /************** End of pcache.c **********************************************/ |
| 35909 | /************** Begin file pcache1.c *****************************************/ |
| 35910 | #line 1 "tsrc/pcache1.c" |
| 35911 | /* |
| 35912 | ** 2008 November 05 |
| 35913 | ** |
| 35914 | ** The author disclaims copyright to this source code. In place of |
| 35915 | ** a legal notice, here is a blessing: |
| @@ -35789,12 +35931,10 @@ | |
| 35931 | typedef struct PCache1 PCache1; |
| 35932 | typedef struct PgHdr1 PgHdr1; |
| 35933 | typedef struct PgFreeslot PgFreeslot; |
| 35934 | typedef struct PGroup PGroup; |
| 35935 | |
| 35936 | |
| 35937 | /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set |
| 35938 | ** of one or more PCaches that are able to recycle each others unpinned |
| 35939 | ** pages when they are under memory pressure. A PGroup is an instance of |
| 35940 | ** the following object. |
| @@ -35821,69 +35961,11 @@ | |
| 35961 | int nMaxPage; /* Sum of nMax for purgeable caches */ |
| 35962 | int nMinPage; /* Sum of nMin for purgeable caches */ |
| 35963 | int mxPinned; /* nMaxpage + 10 - nMinPage */ |
| 35964 | int nCurrentPage; /* Number of purgeable pages allocated */ |
| 35965 | PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ |
| 35966 | }; |
| 35967 | |
| 35968 | /* Each page cache is an instance of the following object. Every |
| 35969 | ** open database file (including each in-memory database and each |
| 35970 | ** temporary or transient database) has a single page cache which |
| 35971 | ** is an instance of this object. |
| @@ -35983,21 +36065,10 @@ | |
| 36065 | ** |
| 36066 | ** assert( PGHDR1_TO_PAGE(PAGE_TO_PGHDR1(pCache, X))==X ); |
| 36067 | */ |
| 36068 | #define PGHDR1_TO_PAGE(p) (void*)(((char*)p) - p->pCache->szPage) |
| 36069 | #define PAGE_TO_PGHDR1(c, p) (PgHdr1*)(((char*)p) + c->szPage) |
| 36070 | |
| 36071 | /* |
| 36072 | ** Macros to enter and leave the PCache LRU mutex. |
| 36073 | */ |
| 36074 | #define pcache1EnterMutex(X) sqlite3_mutex_enter((X)->mutex) |
| @@ -36120,159 +36191,32 @@ | |
| 36191 | return iSize; |
| 36192 | } |
| 36193 | } |
| 36194 | #endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */ |
| 36195 | |
| 36196 | /* |
| 36197 | ** Allocate a new page object initially associated with cache pCache. |
| 36198 | */ |
| 36199 | static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ |
| 36200 | int nByte = sizeof(PgHdr1) + pCache->szPage; |
| 36201 | PgHdr1 *p = 0; |
| 36202 | void *pPg; |
| 36203 | |
| 36204 | /* The group mutex must be released before pcache1Alloc() is called. This |
| 36205 | ** is because it may call sqlite3_release_memory(), which assumes that |
| 36206 | ** this mutex is not held. */ |
| 36207 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 36208 | pcache1LeaveMutex(pCache->pGroup); |
| 36209 | pPg = pcache1Alloc(nByte); |
| 36210 | pcache1EnterMutex(pCache->pGroup); |
| 36211 | |
| 36212 | if( pPg ){ |
| 36213 | p = PAGE_TO_PGHDR1(pCache, pPg); |
| 36214 | if( pCache->bPurgeable ){ |
| 36215 | pCache->pGroup->nCurrentPage++; |
| 36216 | } |
| 36217 | } |
| 36218 | return p; |
| 36219 | } |
| 36220 | |
| 36221 | /* |
| 36222 | ** Free a page object allocated by pcache1AllocPage(). |
| @@ -36282,53 +36226,12 @@ | |
| 36226 | ** with a NULL pointer, so we mark the NULL test with ALWAYS(). |
| 36227 | */ |
| 36228 | static void pcache1FreePage(PgHdr1 *p){ |
| 36229 | if( ALWAYS(p) ){ |
| 36230 | PCache1 *pCache = p->pCache; |
| 36231 | assert( sqlite3_mutex_held(p->pCache->pGroup->mutex) ); |
| 36232 | pcache1Free(PGHDR1_TO_PAGE(p)); |
| 36233 | if( pCache->bPurgeable ){ |
| 36234 | pCache->pGroup->nCurrentPage--; |
| 36235 | } |
| 36236 | } |
| 36237 | } |
| @@ -36935,13 +36838,10 @@ | |
| 36838 | ** been released, the function returns. The return value is the total number |
| 36839 | ** of bytes of memory released. |
| 36840 | */ |
| 36841 | SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int nReq){ |
| 36842 | int nFree = 0; |
| 36843 | assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); |
| 36844 | assert( sqlite3_mutex_notheld(pcache1.mutex) ); |
| 36845 | if( pcache1.pStart==0 ){ |
| 36846 | PgHdr1 *p; |
| 36847 | pcache1EnterMutex(&pcache1.grp); |
| @@ -36980,10 +36880,11 @@ | |
| 36880 | } |
| 36881 | #endif |
| 36882 | |
| 36883 | /************** End of pcache1.c *********************************************/ |
| 36884 | /************** Begin file rowset.c ******************************************/ |
| 36885 | #line 1 "tsrc/rowset.c" |
| 36886 | /* |
| 36887 | ** 2008 December 3 |
| 36888 | ** |
| 36889 | ** The author disclaims copyright to this source code. In place of |
| 36890 | ** a legal notice, here is a blessing: |
| @@ -37404,10 +37305,11 @@ | |
| 37305 | return 0; |
| 37306 | } |
| 37307 | |
| 37308 | /************** End of rowset.c **********************************************/ |
| 37309 | /************** Begin file pager.c *******************************************/ |
| 37310 | #line 1 "tsrc/pager.c" |
| 37311 | /* |
| 37312 | ** 2001 September 15 |
| 37313 | ** |
| 37314 | ** The author disclaims copyright to this source code. In place of |
| 37315 | ** a legal notice, here is a blessing: |
| @@ -37427,10 +37329,11 @@ | |
| 37329 | ** another is writing. |
| 37330 | */ |
| 37331 | #ifndef SQLITE_OMIT_DISKIO |
| 37332 | /************** Include wal.h in the middle of pager.c ***********************/ |
| 37333 | /************** Begin file wal.h *********************************************/ |
| 37334 | #line 1 "tsrc/wal.h" |
| 37335 | /* |
| 37336 | ** 2010 February 1 |
| 37337 | ** |
| 37338 | ** The author disclaims copyright to this source code. In place of |
| 37339 | ** a legal notice, here is a blessing: |
| @@ -37551,10 +37454,11 @@ | |
| 37454 | #endif /* ifndef SQLITE_OMIT_WAL */ |
| 37455 | #endif /* _WAL_H_ */ |
| 37456 | |
| 37457 | /************** End of wal.h *************************************************/ |
| 37458 | /************** Continuing where we left off in pager.c **********************/ |
| 37459 | #line 24 "tsrc/pager.c" |
| 37460 | |
| 37461 | |
| 37462 | /******************* NOTES ON THE DESIGN OF THE PAGER ************************ |
| 37463 | ** |
| 37464 | ** This comment block describes invariants that hold when using a rollback |
| @@ -38200,12 +38104,12 @@ | |
| 38104 | i64 journalSizeLimit; /* Size limit for persistent journal files */ |
| 38105 | char *zFilename; /* Name of the database file */ |
| 38106 | char *zJournal; /* Name of the journal file */ |
| 38107 | int (*xBusyHandler)(void*); /* Function to call when busy */ |
| 38108 | void *pBusyHandlerArg; /* Context argument for xBusyHandler */ |
| 38109 | int nHit, nMiss; /* Total cache hits and misses */ |
| 38110 | #ifdef SQLITE_TEST |
| 38111 | int nRead, nWrite; /* Database pages read/written */ |
| 38112 | #endif |
| 38113 | void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */ |
| 38114 | #ifdef SQLITE_HAS_CODEC |
| 38115 | void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ |
| @@ -41699,11 +41603,11 @@ | |
| 41603 | ** The doNotSpill flag inhibits all cache spilling regardless of whether |
| 41604 | ** or not a sync is required. This is set during a rollback. |
| 41605 | ** |
| 41606 | ** Spilling is also prohibited when in an error state since that could |
| 41607 | ** lead to database corruption. In the current implementaton it |
| 41608 | ** is impossible for sqlite3PcacheFetch() to be called with createFlag==1 |
| 41609 | ** while in the error state, hence it is impossible for this routine to |
| 41610 | ** be called in the error state. Nevertheless, we include a NEVER() |
| 41611 | ** test for the error state as a safeguard against future changes. |
| 41612 | */ |
| 41613 | if( NEVER(pPager->errCode) ) return SQLITE_OK; |
| @@ -42535,18 +42439,17 @@ | |
| 42439 | |
| 42440 | if( (*ppPage)->pPager && !noContent ){ |
| 42441 | /* In this case the pcache already contains an initialized copy of |
| 42442 | ** the page. Return without further ado. */ |
| 42443 | assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) ); |
| 42444 | pPager->nHit++; |
| 42445 | return SQLITE_OK; |
| 42446 | |
| 42447 | }else{ |
| 42448 | /* The pager cache has created a new page. Its content needs to |
| 42449 | ** be initialized. */ |
| 42450 | |
| 42451 | pPg = *ppPage; |
| 42452 | pPg->pPager = pPager; |
| 42453 | |
| 42454 | /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page |
| 42455 | ** number greater than this, or the unused locking-page, is requested. */ |
| @@ -42578,10 +42481,11 @@ | |
| 42481 | } |
| 42482 | memset(pPg->pData, 0, pPager->pageSize); |
| 42483 | IOTRACE(("ZERO %p %d\n", pPager, pgno)); |
| 42484 | }else{ |
| 42485 | assert( pPg->pPager==pPager ); |
| 42486 | pPager->nMiss++; |
| 42487 | rc = readDbPage(pPg); |
| 42488 | if( rc!=SQLITE_OK ){ |
| 42489 | goto pager_acquire_err; |
| 42490 | } |
| 42491 | } |
| @@ -43611,10 +43515,35 @@ | |
| 43515 | a[9] = pPager->nRead; |
| 43516 | a[10] = pPager->nWrite; |
| 43517 | return a; |
| 43518 | } |
| 43519 | #endif |
| 43520 | |
| 43521 | /* |
| 43522 | ** Parameter eStat must be either SQLITE_DBSTATUS_CACHE_HIT or |
| 43523 | ** SQLITE_DBSTATUS_CACHE_MISS. Before returning, *pnVal is incremented by the |
| 43524 | ** current cache hit or miss count, according to the value of eStat. If the |
| 43525 | ** reset parameter is non-zero, the cache hit or miss count is zeroed before |
| 43526 | ** returning. |
| 43527 | */ |
| 43528 | SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){ |
| 43529 | int *piStat; |
| 43530 | |
| 43531 | assert( eStat==SQLITE_DBSTATUS_CACHE_HIT |
| 43532 | || eStat==SQLITE_DBSTATUS_CACHE_MISS |
| 43533 | ); |
| 43534 | if( eStat==SQLITE_DBSTATUS_CACHE_HIT ){ |
| 43535 | piStat = &pPager->nHit; |
| 43536 | }else{ |
| 43537 | piStat = &pPager->nMiss; |
| 43538 | } |
| 43539 | |
| 43540 | *pnVal += *piStat; |
| 43541 | if( reset ){ |
| 43542 | *piStat = 0; |
| 43543 | } |
| 43544 | } |
| 43545 | |
| 43546 | /* |
| 43547 | ** Return true if this is an in-memory pager. |
| 43548 | */ |
| 43549 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){ |
| @@ -44362,10 +44291,11 @@ | |
| 44291 | |
| 44292 | #endif /* SQLITE_OMIT_DISKIO */ |
| 44293 | |
| 44294 | /************** End of pager.c ***********************************************/ |
| 44295 | /************** Begin file wal.c *********************************************/ |
| 44296 | #line 1 "tsrc/wal.c" |
| 44297 | /* |
| 44298 | ** 2010 February 1 |
| 44299 | ** |
| 44300 | ** The author disclaims copyright to this source code. In place of |
| 44301 | ** a legal notice, here is a blessing: |
| @@ -47316,10 +47246,11 @@ | |
| 47246 | |
| 47247 | #endif /* #ifndef SQLITE_OMIT_WAL */ |
| 47248 | |
| 47249 | /************** End of wal.c *************************************************/ |
| 47250 | /************** Begin file btmutex.c *****************************************/ |
| 47251 | #line 1 "tsrc/btmutex.c" |
| 47252 | /* |
| 47253 | ** 2007 August 27 |
| 47254 | ** |
| 47255 | ** The author disclaims copyright to this source code. In place of |
| 47256 | ** a legal notice, here is a blessing: |
| @@ -47335,10 +47266,11 @@ | |
| 47266 | ** big and we want to break it down some. This packaged seemed like |
| 47267 | ** a good breakout. |
| 47268 | */ |
| 47269 | /************** Include btreeInt.h in the middle of btmutex.c ****************/ |
| 47270 | /************** Begin file btreeInt.h ****************************************/ |
| 47271 | #line 1 "tsrc/btreeInt.h" |
| 47272 | /* |
| 47273 | ** 2004 April 6 |
| 47274 | ** |
| 47275 | ** The author disclaims copyright to this source code. In place of |
| 47276 | ** a legal notice, here is a blessing: |
| @@ -47980,10 +47912,11 @@ | |
| 47912 | #define get4byte sqlite3Get4byte |
| 47913 | #define put4byte sqlite3Put4byte |
| 47914 | |
| 47915 | /************** End of btreeInt.h ********************************************/ |
| 47916 | /************** Continuing where we left off in btmutex.c ********************/ |
| 47917 | #line 19 "tsrc/btmutex.c" |
| 47918 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 47919 | #if SQLITE_THREADSAFE |
| 47920 | |
| 47921 | /* |
| 47922 | ** Obtain the BtShared mutex associated with B-Tree handle p. Also, |
| @@ -48252,10 +48185,11 @@ | |
| 48185 | #endif /* if SQLITE_THREADSAFE */ |
| 48186 | #endif /* ifndef SQLITE_OMIT_SHARED_CACHE */ |
| 48187 | |
| 48188 | /************** End of btmutex.c *********************************************/ |
| 48189 | /************** Begin file btree.c *******************************************/ |
| 48190 | #line 1 "tsrc/btree.c" |
| 48191 | /* |
| 48192 | ** 2004 April 6 |
| 48193 | ** |
| 48194 | ** The author disclaims copyright to this source code. In place of |
| 48195 | ** a legal notice, here is a blessing: |
| @@ -56439,10 +56373,11 @@ | |
| 56373 | return rc; |
| 56374 | } |
| 56375 | |
| 56376 | /************** End of btree.c ***********************************************/ |
| 56377 | /************** Begin file backup.c ******************************************/ |
| 56378 | #line 1 "tsrc/backup.c" |
| 56379 | /* |
| 56380 | ** 2009 January 28 |
| 56381 | ** |
| 56382 | ** The author disclaims copyright to this source code. In place of |
| 56383 | ** a legal notice, here is a blessing: |
| @@ -57108,13 +57043,21 @@ | |
| 57043 | ** goes wrong, the transaction on pTo is rolled back. If successful, the |
| 57044 | ** transaction is committed before returning. |
| 57045 | */ |
| 57046 | SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ |
| 57047 | int rc; |
| 57048 | sqlite3_file *pFd; /* File descriptor for database pTo */ |
| 57049 | sqlite3_backup b; |
| 57050 | sqlite3BtreeEnter(pTo); |
| 57051 | sqlite3BtreeEnter(pFrom); |
| 57052 | |
| 57053 | assert( sqlite3BtreeIsInTrans(pTo) ); |
| 57054 | pFd = sqlite3PagerFile(sqlite3BtreePager(pTo)); |
| 57055 | if( pFd->pMethods ){ |
| 57056 | i64 nByte = sqlite3BtreeGetPageSize(pFrom)*(i64)sqlite3BtreeLastPage(pFrom); |
| 57057 | sqlite3OsFileControl(pFd, SQLITE_FCNTL_OVERWRITE, &nByte); |
| 57058 | } |
| 57059 | |
| 57060 | /* Set up an sqlite3_backup object. sqlite3_backup.pDestDb must be set |
| 57061 | ** to 0. This is used by the implementations of sqlite3_backup_step() |
| 57062 | ** and sqlite3_backup_finish() to detect that they are being called |
| 57063 | ** from this function, not directly by the user. |
| @@ -57137,18 +57080,20 @@ | |
| 57080 | rc = sqlite3_backup_finish(&b); |
| 57081 | if( rc==SQLITE_OK ){ |
| 57082 | pTo->pBt->pageSizeFixed = 0; |
| 57083 | } |
| 57084 | |
| 57085 | assert( sqlite3BtreeIsInTrans(pTo)==0 ); |
| 57086 | sqlite3BtreeLeave(pFrom); |
| 57087 | sqlite3BtreeLeave(pTo); |
| 57088 | return rc; |
| 57089 | } |
| 57090 | #endif /* SQLITE_OMIT_VACUUM */ |
| 57091 | |
| 57092 | /************** End of backup.c **********************************************/ |
| 57093 | /************** Begin file vdbemem.c *****************************************/ |
| 57094 | #line 1 "tsrc/vdbemem.c" |
| 57095 | /* |
| 57096 | ** 2004 May 26 |
| 57097 | ** |
| 57098 | ** The author disclaims copyright to this source code. In place of |
| 57099 | ** a legal notice, here is a blessing: |
| @@ -58171,15 +58116,15 @@ | |
| 58116 | *ppVal = 0; |
| 58117 | return SQLITE_OK; |
| 58118 | } |
| 58119 | op = pExpr->op; |
| 58120 | |
| 58121 | /* op can only be TK_REGISTER if we have compiled with SQLITE_ENABLE_STAT3. |
| 58122 | ** The ifdef here is to enable us to achieve 100% branch test coverage even |
| 58123 | ** when SQLITE_ENABLE_STAT3 is omitted. |
| 58124 | */ |
| 58125 | #ifdef SQLITE_ENABLE_STAT3 |
| 58126 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 58127 | #else |
| 58128 | if( NEVER(op==TK_REGISTER) ) op = pExpr->op2; |
| 58129 | #endif |
| 58130 | |
| @@ -58299,10 +58244,11 @@ | |
| 58244 | return 0; |
| 58245 | } |
| 58246 | |
| 58247 | /************** End of vdbemem.c *********************************************/ |
| 58248 | /************** Begin file vdbeaux.c *****************************************/ |
| 58249 | #line 1 "tsrc/vdbeaux.c" |
| 58250 | /* |
| 58251 | ** 2003 September 6 |
| 58252 | ** |
| 58253 | ** The author disclaims copyright to this source code. In place of |
| 58254 | ** a legal notice, here is a blessing: |
| @@ -58874,12 +58820,12 @@ | |
| 58820 | /* |
| 58821 | ** Change the P2 operand of instruction addr so that it points to |
| 58822 | ** the address of the next instruction to be coded. |
| 58823 | */ |
| 58824 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){ |
| 58825 | assert( addr>=0 || p->db->mallocFailed ); |
| 58826 | if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 58827 | } |
| 58828 | |
| 58829 | |
| 58830 | /* |
| 58831 | ** If the input FuncDef structure is ephemeral, then free it. If |
| @@ -59441,11 +59387,11 @@ | |
| 59387 | SubProgram **apSub = 0; /* Array of sub-vdbes */ |
| 59388 | Mem *pSub = 0; /* Memory cell hold array of subprogs */ |
| 59389 | sqlite3 *db = p->db; /* The database connection */ |
| 59390 | int i; /* Loop counter */ |
| 59391 | int rc = SQLITE_OK; /* Return code */ |
| 59392 | Mem *pMem = &p->aMem[1]; /* First Mem of result set */ |
| 59393 | |
| 59394 | assert( p->explain ); |
| 59395 | assert( p->magic==VDBE_MAGIC_RUN ); |
| 59396 | assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM ); |
| 59397 | |
| @@ -59452,10 +59398,11 @@ | |
| 59398 | /* Even though this opcode does not use dynamic strings for |
| 59399 | ** the result, result columns may become dynamic if the user calls |
| 59400 | ** sqlite3_column_text16(), causing a translation to UTF-16 encoding. |
| 59401 | */ |
| 59402 | releaseMemArray(pMem, 8); |
| 59403 | p->pResultSet = 0; |
| 59404 | |
| 59405 | if( p->rc==SQLITE_NOMEM ){ |
| 59406 | /* This happens if a malloc() inside a call to sqlite3_column_text() or |
| 59407 | ** sqlite3_column_text16() failed. */ |
| 59408 | db->mallocFailed = 1; |
| @@ -59606,10 +59553,11 @@ | |
| 59553 | pMem->type = SQLITE_NULL; |
| 59554 | } |
| 59555 | } |
| 59556 | |
| 59557 | p->nResColumn = 8 - 4*(p->explain-1); |
| 59558 | p->pResultSet = &p->aMem[1]; |
| 59559 | p->rc = SQLITE_OK; |
| 59560 | rc = SQLITE_ROW; |
| 59561 | } |
| 59562 | return rc; |
| 59563 | } |
| @@ -61538,10 +61486,11 @@ | |
| 61486 | } |
| 61487 | } |
| 61488 | |
| 61489 | /************** End of vdbeaux.c *********************************************/ |
| 61490 | /************** Begin file vdbeapi.c *****************************************/ |
| 61491 | #line 1 "tsrc/vdbeapi.c" |
| 61492 | /* |
| 61493 | ** 2004 May 26 |
| 61494 | ** |
| 61495 | ** The author disclaims copyright to this source code. In place of |
| 61496 | ** a legal notice, here is a blessing: |
| @@ -62845,10 +62794,11 @@ | |
| 62794 | return v; |
| 62795 | } |
| 62796 | |
| 62797 | /************** End of vdbeapi.c *********************************************/ |
| 62798 | /************** Begin file vdbetrace.c ***************************************/ |
| 62799 | #line 1 "tsrc/vdbetrace.c" |
| 62800 | /* |
| 62801 | ** 2009 November 25 |
| 62802 | ** |
| 62803 | ** The author disclaims copyright to this source code. In place of |
| 62804 | ** a legal notice, here is a blessing: |
| @@ -63000,10 +62950,11 @@ | |
| 62950 | |
| 62951 | #endif /* #ifndef SQLITE_OMIT_TRACE */ |
| 62952 | |
| 62953 | /************** End of vdbetrace.c *******************************************/ |
| 62954 | /************** Begin file vdbe.c ********************************************/ |
| 62955 | #line 1 "tsrc/vdbe.c" |
| 62956 | /* |
| 62957 | ** 2001 September 15 |
| 62958 | ** |
| 62959 | ** The author disclaims copyright to this source code. In place of |
| 62960 | ** a legal notice, here is a blessing: |
| @@ -63469,10 +63420,11 @@ | |
| 63420 | ** hwtime.h contains inline assembler code for implementing |
| 63421 | ** high-performance timing routines. |
| 63422 | */ |
| 63423 | /************** Include hwtime.h in the middle of vdbe.c *********************/ |
| 63424 | /************** Begin file hwtime.h ******************************************/ |
| 63425 | #line 1 "tsrc/hwtime.h" |
| 63426 | /* |
| 63427 | ** 2008 May 27 |
| 63428 | ** |
| 63429 | ** The author disclaims copyright to this source code. In place of |
| 63430 | ** a legal notice, here is a blessing: |
| @@ -63557,10 +63509,11 @@ | |
| 63509 | |
| 63510 | #endif /* !defined(_HWTIME_H_) */ |
| 63511 | |
| 63512 | /************** End of hwtime.h **********************************************/ |
| 63513 | /************** Continuing where we left off in vdbe.c ***********************/ |
| 63514 | #line 471 "tsrc/vdbe.c" |
| 63515 | |
| 63516 | #endif |
| 63517 | |
| 63518 | /* |
| 63519 | ** The CHECK_FOR_INTERRUPT macro defined here looks to see if the |
| @@ -69801,10 +69754,11 @@ | |
| 69754 | goto vdbe_error_halt; |
| 69755 | } |
| 69756 | |
| 69757 | /************** End of vdbe.c ************************************************/ |
| 69758 | /************** Begin file vdbeblob.c ****************************************/ |
| 69759 | #line 1 "tsrc/vdbeblob.c" |
| 69760 | /* |
| 69761 | ** 2007 May 1 |
| 69762 | ** |
| 69763 | ** The author disclaims copyright to this source code. In place of |
| 69764 | ** a legal notice, here is a blessing: |
| @@ -70271,10 +70225,11 @@ | |
| 70225 | |
| 70226 | #endif /* #ifndef SQLITE_OMIT_INCRBLOB */ |
| 70227 | |
| 70228 | /************** End of vdbeblob.c ********************************************/ |
| 70229 | /************** Begin file vdbesort.c ****************************************/ |
| 70230 | #line 1 "tsrc/vdbesort.c" |
| 70231 | /* |
| 70232 | ** 2011 July 9 |
| 70233 | ** |
| 70234 | ** The author disclaims copyright to this source code. In place of |
| 70235 | ** a legal notice, here is a blessing: |
| @@ -71154,10 +71109,11 @@ | |
| 71109 | |
| 71110 | #endif /* #ifndef SQLITE_OMIT_MERGE_SORT */ |
| 71111 | |
| 71112 | /************** End of vdbesort.c ********************************************/ |
| 71113 | /************** Begin file journal.c *****************************************/ |
| 71114 | #line 1 "tsrc/journal.c" |
| 71115 | /* |
| 71116 | ** 2007 August 22 |
| 71117 | ** |
| 71118 | ** The author disclaims copyright to this source code. In place of |
| 71119 | ** a legal notice, here is a blessing: |
| @@ -71394,10 +71350,11 @@ | |
| 71350 | } |
| 71351 | #endif |
| 71352 | |
| 71353 | /************** End of journal.c *********************************************/ |
| 71354 | /************** Begin file memjournal.c **************************************/ |
| 71355 | #line 1 "tsrc/memjournal.c" |
| 71356 | /* |
| 71357 | ** 2008 October 7 |
| 71358 | ** |
| 71359 | ** The author disclaims copyright to this source code. In place of |
| 71360 | ** a legal notice, here is a blessing: |
| @@ -71655,10 +71612,11 @@ | |
| 71612 | return sizeof(MemJournal); |
| 71613 | } |
| 71614 | |
| 71615 | /************** End of memjournal.c ******************************************/ |
| 71616 | /************** Begin file walker.c ******************************************/ |
| 71617 | #line 1 "tsrc/walker.c" |
| 71618 | /* |
| 71619 | ** 2008 August 16 |
| 71620 | ** |
| 71621 | ** The author disclaims copyright to this source code. In place of |
| 71622 | ** a legal notice, here is a blessing: |
| @@ -71793,10 +71751,11 @@ | |
| 71751 | return rc & WRC_Abort; |
| 71752 | } |
| 71753 | |
| 71754 | /************** End of walker.c **********************************************/ |
| 71755 | /************** Begin file resolve.c *****************************************/ |
| 71756 | #line 1 "tsrc/resolve.c" |
| 71757 | /* |
| 71758 | ** 2008 August 18 |
| 71759 | ** |
| 71760 | ** The author disclaims copyright to this source code. In place of |
| 71761 | ** a legal notice, here is a blessing: |
| @@ -73013,10 +72972,11 @@ | |
| 72972 | sqlite3WalkSelect(&w, p); |
| 72973 | } |
| 72974 | |
| 72975 | /************** End of resolve.c *********************************************/ |
| 72976 | /************** Begin file expr.c ********************************************/ |
| 72977 | #line 1 "tsrc/expr.c" |
| 72978 | /* |
| 72979 | ** 2001 September 15 |
| 72980 | ** |
| 72981 | ** The author disclaims copyright to this source code. In place of |
| 72982 | ** a legal notice, here is a blessing: |
| @@ -76770,10 +76730,11 @@ | |
| 76730 | } |
| 76731 | } |
| 76732 | |
| 76733 | /************** End of expr.c ************************************************/ |
| 76734 | /************** Begin file alter.c *******************************************/ |
| 76735 | #line 1 "tsrc/alter.c" |
| 76736 | /* |
| 76737 | ** 2005 February 15 |
| 76738 | ** |
| 76739 | ** The author disclaims copyright to this source code. In place of |
| 76740 | ** a legal notice, here is a blessing: |
| @@ -77598,10 +77559,11 @@ | |
| 77559 | } |
| 77560 | #endif /* SQLITE_ALTER_TABLE */ |
| 77561 | |
| 77562 | /************** End of alter.c ***********************************************/ |
| 77563 | /************** Begin file analyze.c *****************************************/ |
| 77564 | #line 1 "tsrc/analyze.c" |
| 77565 | /* |
| 77566 | ** 2005 July 8 |
| 77567 | ** |
| 77568 | ** The author disclaims copyright to this source code. In place of |
| 77569 | ** a legal notice, here is a blessing: |
| @@ -77610,10 +77572,112 @@ | |
| 77572 | ** May you find forgiveness for yourself and forgive others. |
| 77573 | ** May you share freely, never taking more than you give. |
| 77574 | ** |
| 77575 | ************************************************************************* |
| 77576 | ** This file contains code associated with the ANALYZE command. |
| 77577 | ** |
| 77578 | ** The ANALYZE command gather statistics about the content of tables |
| 77579 | ** and indices. These statistics are made available to the query planner |
| 77580 | ** to help it make better decisions about how to perform queries. |
| 77581 | ** |
| 77582 | ** The following system tables are or have been supported: |
| 77583 | ** |
| 77584 | ** CREATE TABLE sqlite_stat1(tbl, idx, stat); |
| 77585 | ** CREATE TABLE sqlite_stat2(tbl, idx, sampleno, sample); |
| 77586 | ** CREATE TABLE sqlite_stat3(tbl, idx, nEq, nLt, nDLt, sample); |
| 77587 | ** |
| 77588 | ** Additional tables might be added in future releases of SQLite. |
| 77589 | ** The sqlite_stat2 table is not created or used unless the SQLite version |
| 77590 | ** is between 3.6.18 and 3.7.8, inclusive, and unless SQLite is compiled |
| 77591 | ** with SQLITE_ENABLE_STAT2. The sqlite_stat2 table is deprecated. |
| 77592 | ** The sqlite_stat2 table is superceded by sqlite_stat3, which is only |
| 77593 | ** created and used by SQLite versions 3.7.9 and later and with |
| 77594 | ** SQLITE_ENABLE_STAT3 defined. The fucntionality of sqlite_stat3 |
| 77595 | ** is a superset of sqlite_stat2. |
| 77596 | ** |
| 77597 | ** Format of sqlite_stat1: |
| 77598 | ** |
| 77599 | ** There is normally one row per index, with the index identified by the |
| 77600 | ** name in the idx column. The tbl column is the name of the table to |
| 77601 | ** which the index belongs. In each such row, the stat column will be |
| 77602 | ** a string consisting of a list of integers. The first integer in this |
| 77603 | ** list is the number of rows in the index and in the table. The second |
| 77604 | ** integer is the average number of rows in the index that have the same |
| 77605 | ** value in the first column of the index. The third integer is the average |
| 77606 | ** number of rows in the index that have the same value for the first two |
| 77607 | ** columns. The N-th integer (for N>1) is the average number of rows in |
| 77608 | ** the index which have the same value for the first N-1 columns. For |
| 77609 | ** a K-column index, there will be K+1 integers in the stat column. If |
| 77610 | ** the index is unique, then the last integer will be 1. |
| 77611 | ** |
| 77612 | ** The list of integers in the stat column can optionally be followed |
| 77613 | ** by the keyword "unordered". The "unordered" keyword, if it is present, |
| 77614 | ** must be separated from the last integer by a single space. If the |
| 77615 | ** "unordered" keyword is present, then the query planner assumes that |
| 77616 | ** the index is unordered and will not use the index for a range query. |
| 77617 | ** |
| 77618 | ** If the sqlite_stat1.idx column is NULL, then the sqlite_stat1.stat |
| 77619 | ** column contains a single integer which is the (estimated) number of |
| 77620 | ** rows in the table identified by sqlite_stat1.tbl. |
| 77621 | ** |
| 77622 | ** Format of sqlite_stat2: |
| 77623 | ** |
| 77624 | ** The sqlite_stat2 is only created and is only used if SQLite is compiled |
| 77625 | ** with SQLITE_ENABLE_STAT2 and if the SQLite version number is between |
| 77626 | ** 3.6.18 and 3.7.8. The "stat2" table contains additional information |
| 77627 | ** about the distribution of keys within an index. The index is identified by |
| 77628 | ** the "idx" column and the "tbl" column is the name of the table to which |
| 77629 | ** the index belongs. There are usually 10 rows in the sqlite_stat2 |
| 77630 | ** table for each index. |
| 77631 | ** |
| 77632 | ** The sqlite_stat2 entries for an index that have sampleno between 0 and 9 |
| 77633 | ** inclusive are samples of the left-most key value in the index taken at |
| 77634 | ** evenly spaced points along the index. Let the number of samples be S |
| 77635 | ** (10 in the standard build) and let C be the number of rows in the index. |
| 77636 | ** Then the sampled rows are given by: |
| 77637 | ** |
| 77638 | ** rownumber = (i*C*2 + C)/(S*2) |
| 77639 | ** |
| 77640 | ** For i between 0 and S-1. Conceptually, the index space is divided into |
| 77641 | ** S uniform buckets and the samples are the middle row from each bucket. |
| 77642 | ** |
| 77643 | ** The format for sqlite_stat2 is recorded here for legacy reference. This |
| 77644 | ** version of SQLite does not support sqlite_stat2. It neither reads nor |
| 77645 | ** writes the sqlite_stat2 table. This version of SQLite only supports |
| 77646 | ** sqlite_stat3. |
| 77647 | ** |
| 77648 | ** Format for sqlite_stat3: |
| 77649 | ** |
| 77650 | ** The sqlite_stat3 is an enhancement to sqlite_stat2. A new name is |
| 77651 | ** used to avoid compatibility problems. |
| 77652 | ** |
| 77653 | ** The format of the sqlite_stat3 table is similar to the format of |
| 77654 | ** the sqlite_stat2 table. There are multiple entries for each index. |
| 77655 | ** The idx column names the index and the tbl column is the table of the |
| 77656 | ** index. If the idx and tbl columns are the same, then the sample is |
| 77657 | ** of the INTEGER PRIMARY KEY. The sample column is a value taken from |
| 77658 | ** the left-most column of the index. The nEq column is the approximate |
| 77659 | ** number of entires in the index whose left-most column exactly matches |
| 77660 | ** the sample. nLt is the approximate number of entires whose left-most |
| 77661 | ** column is less than the sample. The nDLt column is the approximate |
| 77662 | ** number of distinct left-most entries in the index that are less than |
| 77663 | ** the sample. |
| 77664 | ** |
| 77665 | ** Future versions of SQLite might change to store a string containing |
| 77666 | ** multiple integers values in the nDLt column of sqlite_stat3. The first |
| 77667 | ** integer will be the number of prior index entires that are distinct in |
| 77668 | ** the left-most column. The second integer will be the number of prior index |
| 77669 | ** entries that are distinct in the first two columns. The third integer |
| 77670 | ** will be the number of prior index entries that are distinct in the first |
| 77671 | ** three columns. And so forth. With that extension, the nDLt field is |
| 77672 | ** similar in function to the sqlite_stat1.stat field. |
| 77673 | ** |
| 77674 | ** There can be an arbitrary number of sqlite_stat3 entries per index. |
| 77675 | ** The ANALYZE command will typically generate sqlite_stat3 tables |
| 77676 | ** that contain between 10 and 40 samples which are distributed across |
| 77677 | ** the key space, though not uniformly, and which include samples with |
| 77678 | ** largest possible nEq values. |
| 77679 | */ |
| 77680 | #ifndef SQLITE_OMIT_ANALYZE |
| 77681 | |
| 77682 | /* |
| 77683 | ** This routine generates code that opens the sqlite_stat1 table for |
| @@ -77641,12 +77705,18 @@ | |
| 77705 | static const struct { |
| 77706 | const char *zName; |
| 77707 | const char *zCols; |
| 77708 | } aTable[] = { |
| 77709 | { "sqlite_stat1", "tbl,idx,stat" }, |
| 77710 | #ifdef SQLITE_ENABLE_STAT3 |
| 77711 | { "sqlite_stat3", "tbl,idx,neq,nlt,ndlt,sample" }, |
| 77712 | #endif |
| 77713 | }; |
| 77714 | static const char *azToDrop[] = { |
| 77715 | "sqlite_stat2", |
| 77716 | #ifndef SQLITE_ENABLE_STAT3 |
| 77717 | "sqlite_stat3", |
| 77718 | #endif |
| 77719 | }; |
| 77720 | |
| 77721 | int aRoot[] = {0, 0}; |
| 77722 | u8 aCreateTbl[] = {0, 0}; |
| @@ -77658,10 +77728,24 @@ | |
| 77728 | if( v==0 ) return; |
| 77729 | assert( sqlite3BtreeHoldsAllMutexes(db) ); |
| 77730 | assert( sqlite3VdbeDb(v)==db ); |
| 77731 | pDb = &db->aDb[iDb]; |
| 77732 | |
| 77733 | /* Drop all statistics tables that this version of SQLite does not |
| 77734 | ** understand. |
| 77735 | */ |
| 77736 | for(i=0; i<ArraySize(azToDrop); i++){ |
| 77737 | Table *pTab = sqlite3FindTable(db, azToDrop[i], pDb->zName); |
| 77738 | if( pTab ){ |
| 77739 | sqlite3CodeDropTable(pParse, pTab, iDb, 0); |
| 77740 | break; |
| 77741 | } |
| 77742 | } |
| 77743 | |
| 77744 | /* Create new statistic tables if they do not exist, or clear them |
| 77745 | ** if they do already exist. |
| 77746 | */ |
| 77747 | for(i=0; i<ArraySize(aTable); i++){ |
| 77748 | const char *zTab = aTable[i].zName; |
| 77749 | Table *pStat; |
| 77750 | if( (pStat = sqlite3FindTable(db, zTab, pDb->zName))==0 ){ |
| 77751 | /* The sqlite_stat[12] table does not exist. Create it. Note that a |
| @@ -77688,17 +77772,237 @@ | |
| 77772 | sqlite3VdbeAddOp2(v, OP_Clear, aRoot[i], iDb); |
| 77773 | } |
| 77774 | } |
| 77775 | } |
| 77776 | |
| 77777 | /* Open the sqlite_stat[13] tables for writing. */ |
| 77778 | for(i=0; i<ArraySize(aTable); i++){ |
| 77779 | sqlite3VdbeAddOp3(v, OP_OpenWrite, iStatCur+i, aRoot[i], iDb); |
| 77780 | sqlite3VdbeChangeP4(v, -1, (char *)3, P4_INT32); |
| 77781 | sqlite3VdbeChangeP5(v, aCreateTbl[i]); |
| 77782 | } |
| 77783 | } |
| 77784 | |
| 77785 | /* |
| 77786 | ** Recommended number of samples for sqlite_stat3 |
| 77787 | */ |
| 77788 | #ifndef SQLITE_STAT3_SAMPLES |
| 77789 | # define SQLITE_STAT3_SAMPLES 24 |
| 77790 | #endif |
| 77791 | |
| 77792 | /* |
| 77793 | ** Three SQL functions - stat3_init(), stat3_push(), and stat3_pop() - |
| 77794 | ** share an instance of the following structure to hold their state |
| 77795 | ** information. |
| 77796 | */ |
| 77797 | typedef struct Stat3Accum Stat3Accum; |
| 77798 | struct Stat3Accum { |
| 77799 | tRowcnt nRow; /* Number of rows in the entire table */ |
| 77800 | tRowcnt nPSample; /* How often to do a periodic sample */ |
| 77801 | int iMin; /* Index of entry with minimum nEq and hash */ |
| 77802 | int mxSample; /* Maximum number of samples to accumulate */ |
| 77803 | int nSample; /* Current number of samples */ |
| 77804 | u32 iPrn; /* Pseudo-random number used for sampling */ |
| 77805 | struct Stat3Sample { |
| 77806 | i64 iRowid; /* Rowid in main table of the key */ |
| 77807 | tRowcnt nEq; /* sqlite_stat3.nEq */ |
| 77808 | tRowcnt nLt; /* sqlite_stat3.nLt */ |
| 77809 | tRowcnt nDLt; /* sqlite_stat3.nDLt */ |
| 77810 | u8 isPSample; /* True if a periodic sample */ |
| 77811 | u32 iHash; /* Tiebreaker hash */ |
| 77812 | } *a; /* An array of samples */ |
| 77813 | }; |
| 77814 | |
| 77815 | #ifdef SQLITE_ENABLE_STAT3 |
| 77816 | /* |
| 77817 | ** Implementation of the stat3_init(C,S) SQL function. The two parameters |
| 77818 | ** are the number of rows in the table or index (C) and the number of samples |
| 77819 | ** to accumulate (S). |
| 77820 | ** |
| 77821 | ** This routine allocates the Stat3Accum object. |
| 77822 | ** |
| 77823 | ** The return value is the Stat3Accum object (P). |
| 77824 | */ |
| 77825 | static void stat3Init( |
| 77826 | sqlite3_context *context, |
| 77827 | int argc, |
| 77828 | sqlite3_value **argv |
| 77829 | ){ |
| 77830 | Stat3Accum *p; |
| 77831 | tRowcnt nRow; |
| 77832 | int mxSample; |
| 77833 | int n; |
| 77834 | |
| 77835 | UNUSED_PARAMETER(argc); |
| 77836 | nRow = (tRowcnt)sqlite3_value_int64(argv[0]); |
| 77837 | mxSample = sqlite3_value_int(argv[1]); |
| 77838 | n = sizeof(*p) + sizeof(p->a[0])*mxSample; |
| 77839 | p = sqlite3_malloc( n ); |
| 77840 | if( p==0 ){ |
| 77841 | sqlite3_result_error_nomem(context); |
| 77842 | return; |
| 77843 | } |
| 77844 | memset(p, 0, n); |
| 77845 | p->a = (struct Stat3Sample*)&p[1]; |
| 77846 | p->nRow = nRow; |
| 77847 | p->mxSample = mxSample; |
| 77848 | p->nPSample = p->nRow/(mxSample/3+1) + 1; |
| 77849 | sqlite3_randomness(sizeof(p->iPrn), &p->iPrn); |
| 77850 | sqlite3_result_blob(context, p, sizeof(p), sqlite3_free); |
| 77851 | } |
| 77852 | static const FuncDef stat3InitFuncdef = { |
| 77853 | 2, /* nArg */ |
| 77854 | SQLITE_UTF8, /* iPrefEnc */ |
| 77855 | 0, /* flags */ |
| 77856 | 0, /* pUserData */ |
| 77857 | 0, /* pNext */ |
| 77858 | stat3Init, /* xFunc */ |
| 77859 | 0, /* xStep */ |
| 77860 | 0, /* xFinalize */ |
| 77861 | "stat3_init", /* zName */ |
| 77862 | 0, /* pHash */ |
| 77863 | 0 /* pDestructor */ |
| 77864 | }; |
| 77865 | |
| 77866 | |
| 77867 | /* |
| 77868 | ** Implementation of the stat3_push(nEq,nLt,nDLt,rowid,P) SQL function. The |
| 77869 | ** arguments describe a single key instance. This routine makes the |
| 77870 | ** decision about whether or not to retain this key for the sqlite_stat3 |
| 77871 | ** table. |
| 77872 | ** |
| 77873 | ** The return value is NULL. |
| 77874 | */ |
| 77875 | static void stat3Push( |
| 77876 | sqlite3_context *context, |
| 77877 | int argc, |
| 77878 | sqlite3_value **argv |
| 77879 | ){ |
| 77880 | Stat3Accum *p = (Stat3Accum*)sqlite3_value_blob(argv[4]); |
| 77881 | tRowcnt nEq = sqlite3_value_int64(argv[0]); |
| 77882 | tRowcnt nLt = sqlite3_value_int64(argv[1]); |
| 77883 | tRowcnt nDLt = sqlite3_value_int64(argv[2]); |
| 77884 | i64 rowid = sqlite3_value_int64(argv[3]); |
| 77885 | u8 isPSample = 0; |
| 77886 | u8 doInsert = 0; |
| 77887 | int iMin = p->iMin; |
| 77888 | struct Stat3Sample *pSample; |
| 77889 | int i; |
| 77890 | u32 h; |
| 77891 | |
| 77892 | UNUSED_PARAMETER(context); |
| 77893 | UNUSED_PARAMETER(argc); |
| 77894 | if( nEq==0 ) return; |
| 77895 | h = p->iPrn = p->iPrn*1103515245 + 12345; |
| 77896 | if( (nLt/p->nPSample)!=((nEq+nLt)/p->nPSample) ){ |
| 77897 | doInsert = isPSample = 1; |
| 77898 | }else if( p->nSample<p->mxSample ){ |
| 77899 | doInsert = 1; |
| 77900 | }else{ |
| 77901 | if( nEq>p->a[iMin].nEq || (nEq==p->a[iMin].nEq && h>p->a[iMin].iHash) ){ |
| 77902 | doInsert = 1; |
| 77903 | } |
| 77904 | } |
| 77905 | if( !doInsert ) return; |
| 77906 | if( p->nSample==p->mxSample ){ |
| 77907 | assert( p->nSample - iMin - 1 >= 0 ); |
| 77908 | memmove(&p->a[iMin], &p->a[iMin+1], sizeof(p->a[0])*(p->nSample-iMin-1)); |
| 77909 | pSample = &p->a[p->nSample-1]; |
| 77910 | }else{ |
| 77911 | pSample = &p->a[p->nSample++]; |
| 77912 | } |
| 77913 | pSample->iRowid = rowid; |
| 77914 | pSample->nEq = nEq; |
| 77915 | pSample->nLt = nLt; |
| 77916 | pSample->nDLt = nDLt; |
| 77917 | pSample->iHash = h; |
| 77918 | pSample->isPSample = isPSample; |
| 77919 | |
| 77920 | /* Find the new minimum */ |
| 77921 | if( p->nSample==p->mxSample ){ |
| 77922 | pSample = p->a; |
| 77923 | i = 0; |
| 77924 | while( pSample->isPSample ){ |
| 77925 | i++; |
| 77926 | pSample++; |
| 77927 | assert( i<p->nSample ); |
| 77928 | } |
| 77929 | nEq = pSample->nEq; |
| 77930 | h = pSample->iHash; |
| 77931 | iMin = i; |
| 77932 | for(i++, pSample++; i<p->nSample; i++, pSample++){ |
| 77933 | if( pSample->isPSample ) continue; |
| 77934 | if( pSample->nEq<nEq |
| 77935 | || (pSample->nEq==nEq && pSample->iHash<h) |
| 77936 | ){ |
| 77937 | iMin = i; |
| 77938 | nEq = pSample->nEq; |
| 77939 | h = pSample->iHash; |
| 77940 | } |
| 77941 | } |
| 77942 | p->iMin = iMin; |
| 77943 | } |
| 77944 | } |
| 77945 | static const FuncDef stat3PushFuncdef = { |
| 77946 | 5, /* nArg */ |
| 77947 | SQLITE_UTF8, /* iPrefEnc */ |
| 77948 | 0, /* flags */ |
| 77949 | 0, /* pUserData */ |
| 77950 | 0, /* pNext */ |
| 77951 | stat3Push, /* xFunc */ |
| 77952 | 0, /* xStep */ |
| 77953 | 0, /* xFinalize */ |
| 77954 | "stat3_push", /* zName */ |
| 77955 | 0, /* pHash */ |
| 77956 | 0 /* pDestructor */ |
| 77957 | }; |
| 77958 | |
| 77959 | /* |
| 77960 | ** Implementation of the stat3_get(P,N,...) SQL function. This routine is |
| 77961 | ** used to query the results. Content is returned for the Nth sqlite_stat3 |
| 77962 | ** row where N is between 0 and S-1 and S is the number of samples. The |
| 77963 | ** value returned depends on the number of arguments. |
| 77964 | ** |
| 77965 | ** argc==2 result: rowid |
| 77966 | ** argc==3 result: nEq |
| 77967 | ** argc==4 result: nLt |
| 77968 | ** argc==5 result: nDLt |
| 77969 | */ |
| 77970 | static void stat3Get( |
| 77971 | sqlite3_context *context, |
| 77972 | int argc, |
| 77973 | sqlite3_value **argv |
| 77974 | ){ |
| 77975 | int n = sqlite3_value_int(argv[1]); |
| 77976 | Stat3Accum *p = (Stat3Accum*)sqlite3_value_blob(argv[0]); |
| 77977 | |
| 77978 | assert( p!=0 ); |
| 77979 | if( p->nSample<=n ) return; |
| 77980 | switch( argc ){ |
| 77981 | case 2: sqlite3_result_int64(context, p->a[n].iRowid); break; |
| 77982 | case 3: sqlite3_result_int64(context, p->a[n].nEq); break; |
| 77983 | case 4: sqlite3_result_int64(context, p->a[n].nLt); break; |
| 77984 | default: sqlite3_result_int64(context, p->a[n].nDLt); break; |
| 77985 | } |
| 77986 | } |
| 77987 | static const FuncDef stat3GetFuncdef = { |
| 77988 | -1, /* nArg */ |
| 77989 | SQLITE_UTF8, /* iPrefEnc */ |
| 77990 | 0, /* flags */ |
| 77991 | 0, /* pUserData */ |
| 77992 | 0, /* pNext */ |
| 77993 | stat3Get, /* xFunc */ |
| 77994 | 0, /* xStep */ |
| 77995 | 0, /* xFinalize */ |
| 77996 | "stat3_get", /* zName */ |
| 77997 | 0, /* pHash */ |
| 77998 | 0 /* pDestructor */ |
| 77999 | }; |
| 78000 | #endif /* SQLITE_ENABLE_STAT3 */ |
| 78001 | |
| 78002 | |
| 78003 | |
| 78004 | |
| 78005 | /* |
| 78006 | ** Generate code to do an analysis of all indices associated with |
| 78007 | ** a single table. |
| 78008 | */ |
| @@ -77718,24 +78022,31 @@ | |
| 78022 | int endOfLoop; /* The end of the loop */ |
| 78023 | int jZeroRows = -1; /* Jump from here if number of rows is zero */ |
| 78024 | int iDb; /* Index of database containing pTab */ |
| 78025 | int regTabname = iMem++; /* Register containing table name */ |
| 78026 | int regIdxname = iMem++; /* Register containing index name */ |
| 78027 | int regStat1 = iMem++; /* The stat column of sqlite_stat1 */ |
| 78028 | #ifdef SQLITE_ENABLE_STAT3 |
| 78029 | int regNumEq = regStat1; /* Number of instances. Same as regStat1 */ |
| 78030 | int regNumLt = iMem++; /* Number of keys less than regSample */ |
| 78031 | int regNumDLt = iMem++; /* Number of distinct keys less than regSample */ |
| 78032 | int regSample = iMem++; /* The next sample value */ |
| 78033 | int regRowid = regSample; /* Rowid of a sample */ |
| 78034 | int regAccum = iMem++; /* Register to hold Stat3Accum object */ |
| 78035 | int regLoop = iMem++; /* Loop counter */ |
| 78036 | int regCount = iMem++; /* Number of rows in the table or index */ |
| 78037 | int regTemp1 = iMem++; /* Intermediate register */ |
| 78038 | int regTemp2 = iMem++; /* Intermediate register */ |
| 78039 | int once = 1; /* One-time initialization */ |
| 78040 | int shortJump = 0; /* Instruction address */ |
| 78041 | int iTabCur = pParse->nTab++; /* Table cursor */ |
| 78042 | #endif |
| 78043 | int regCol = iMem++; /* Content of a column in analyzed table */ |
| 78044 | int regRec = iMem++; /* Register holding completed record */ |
| 78045 | int regTemp = iMem++; /* Temporary use register */ |
| 78046 | int regNewRowid = iMem++; /* Rowid for the inserted record */ |
| 78047 | |
| 78048 | |
| 78049 | v = sqlite3GetVdbe(pParse); |
| 78050 | if( v==0 || NEVER(pTab==0) ){ |
| 78051 | return; |
| 78052 | } |
| @@ -77764,13 +78075,18 @@ | |
| 78075 | iIdxCur = pParse->nTab++; |
| 78076 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0); |
| 78077 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 78078 | int nCol; |
| 78079 | KeyInfo *pKey; |
| 78080 | int addrIfNot = 0; /* address of OP_IfNot */ |
| 78081 | int *aChngAddr; /* Array of jump instruction addresses */ |
| 78082 | |
| 78083 | if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; |
| 78084 | VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName)); |
| 78085 | nCol = pIdx->nColumn; |
| 78086 | aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol); |
| 78087 | if( aChngAddr==0 ) continue; |
| 78088 | pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| 78089 | if( iMem+1+(nCol*2)>pParse->nMem ){ |
| 78090 | pParse->nMem = iMem+1+(nCol*2); |
| 78091 | } |
| 78092 | |
| @@ -77781,35 +78097,24 @@ | |
| 78097 | VdbeComment((v, "%s", pIdx->zName)); |
| 78098 | |
| 78099 | /* Populate the register containing the index name. */ |
| 78100 | sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, pIdx->zName, 0); |
| 78101 | |
| 78102 | #ifdef SQLITE_ENABLE_STAT3 |
| 78103 | if( once ){ |
| 78104 | once = 0; |
| 78105 | sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); |
| 78106 | } |
| 78107 | sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regCount); |
| 78108 | sqlite3VdbeAddOp2(v, OP_Integer, SQLITE_STAT3_SAMPLES, regTemp1); |
| 78109 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regNumEq); |
| 78110 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regNumLt); |
| 78111 | sqlite3VdbeAddOp2(v, OP_Integer, -1, regNumDLt); |
| 78112 | sqlite3VdbeAddOp4(v, OP_Function, 1, regCount, regAccum, |
| 78113 | (char*)&stat3InitFuncdef, P4_FUNCDEF); |
| 78114 | sqlite3VdbeChangeP5(v, 2); |
| 78115 | #endif /* SQLITE_ENABLE_STAT3 */ |
| 78116 | |
| 78117 | /* The block of memory cells initialized here is used as follows. |
| 78118 | ** |
| 78119 | ** iMem: |
| 78120 | ** The total number of rows in the table. |
| @@ -77835,79 +78140,87 @@ | |
| 78140 | /* Start the analysis loop. This loop runs through all the entries in |
| 78141 | ** the index b-tree. */ |
| 78142 | endOfLoop = sqlite3VdbeMakeLabel(v); |
| 78143 | sqlite3VdbeAddOp2(v, OP_Rewind, iIdxCur, endOfLoop); |
| 78144 | topOfLoop = sqlite3VdbeCurrentAddr(v); |
| 78145 | sqlite3VdbeAddOp2(v, OP_AddImm, iMem, 1); /* Increment row counter */ |
| 78146 | |
| 78147 | for(i=0; i<nCol; i++){ |
| 78148 | CollSeq *pColl; |
| 78149 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regCol); |
| 78150 | if( i==0 ){ |
| 78151 | /* Always record the very first row */ |
| 78152 | addrIfNot = sqlite3VdbeAddOp1(v, OP_IfNot, iMem+1); |
| 78153 | } |
| 78154 | assert( pIdx->azColl!=0 ); |
| 78155 | assert( pIdx->azColl[i]!=0 ); |
| 78156 | pColl = sqlite3LocateCollSeq(pParse, pIdx->azColl[i]); |
| 78157 | aChngAddr[i] = sqlite3VdbeAddOp4(v, OP_Ne, regCol, 0, iMem+nCol+i+1, |
| 78158 | (char*)pColl, P4_COLLSEQ); |
| 78159 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 78160 | VdbeComment((v, "jump if column %d changed", i)); |
| 78161 | #ifdef SQLITE_ENABLE_STAT3 |
| 78162 | if( i==0 ){ |
| 78163 | sqlite3VdbeAddOp2(v, OP_AddImm, regNumEq, 1); |
| 78164 | VdbeComment((v, "incr repeat count")); |
| 78165 | } |
| 78166 | #endif |
| 78167 | } |
| 78168 | sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop); |
| 78169 | for(i=0; i<nCol; i++){ |
| 78170 | sqlite3VdbeJumpHere(v, aChngAddr[i]); /* Set jump dest for the OP_Ne */ |
| 78171 | if( i==0 ){ |
| 78172 | sqlite3VdbeJumpHere(v, addrIfNot); /* Jump dest for OP_IfNot */ |
| 78173 | #ifdef SQLITE_ENABLE_STAT3 |
| 78174 | sqlite3VdbeAddOp4(v, OP_Function, 1, regNumEq, regTemp2, |
| 78175 | (char*)&stat3PushFuncdef, P4_FUNCDEF); |
| 78176 | sqlite3VdbeChangeP5(v, 5); |
| 78177 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, pIdx->nColumn, regRowid); |
| 78178 | sqlite3VdbeAddOp3(v, OP_Add, regNumEq, regNumLt, regNumLt); |
| 78179 | sqlite3VdbeAddOp2(v, OP_AddImm, regNumDLt, 1); |
| 78180 | sqlite3VdbeAddOp2(v, OP_Integer, 1, regNumEq); |
| 78181 | #endif |
| 78182 | } |
| 78183 | sqlite3VdbeAddOp2(v, OP_AddImm, iMem+i+1, 1); |
| 78184 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, iMem+nCol+i+1); |
| 78185 | } |
| 78186 | sqlite3DbFree(db, aChngAddr); |
| 78187 | |
| 78188 | /* Always jump here after updating the iMem+1...iMem+1+nCol counters */ |
| 78189 | sqlite3VdbeResolveLabel(v, endOfLoop); |
| 78190 | |
| 78191 | sqlite3VdbeAddOp2(v, OP_Next, iIdxCur, topOfLoop); |
| 78192 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 78193 | #ifdef SQLITE_ENABLE_STAT3 |
| 78194 | sqlite3VdbeAddOp4(v, OP_Function, 1, regNumEq, regTemp2, |
| 78195 | (char*)&stat3PushFuncdef, P4_FUNCDEF); |
| 78196 | sqlite3VdbeChangeP5(v, 5); |
| 78197 | sqlite3VdbeAddOp2(v, OP_Integer, -1, regLoop); |
| 78198 | shortJump = |
| 78199 | sqlite3VdbeAddOp2(v, OP_AddImm, regLoop, 1); |
| 78200 | sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regTemp1, |
| 78201 | (char*)&stat3GetFuncdef, P4_FUNCDEF); |
| 78202 | sqlite3VdbeChangeP5(v, 2); |
| 78203 | sqlite3VdbeAddOp1(v, OP_IsNull, regTemp1); |
| 78204 | sqlite3VdbeAddOp3(v, OP_NotExists, iTabCur, shortJump, regTemp1); |
| 78205 | sqlite3VdbeAddOp3(v, OP_Column, iTabCur, pIdx->aiColumn[0], regSample); |
| 78206 | sqlite3ColumnDefault(v, pTab, pIdx->aiColumn[0], regSample); |
| 78207 | sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumEq, |
| 78208 | (char*)&stat3GetFuncdef, P4_FUNCDEF); |
| 78209 | sqlite3VdbeChangeP5(v, 3); |
| 78210 | sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumLt, |
| 78211 | (char*)&stat3GetFuncdef, P4_FUNCDEF); |
| 78212 | sqlite3VdbeChangeP5(v, 4); |
| 78213 | sqlite3VdbeAddOp4(v, OP_Function, 1, regAccum, regNumDLt, |
| 78214 | (char*)&stat3GetFuncdef, P4_FUNCDEF); |
| 78215 | sqlite3VdbeChangeP5(v, 5); |
| 78216 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 6, regRec, "bbbbbb", 0); |
| 78217 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid); |
| 78218 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur+1, regRec, regNewRowid); |
| 78219 | sqlite3VdbeAddOp2(v, OP_Goto, 0, shortJump); |
| 78220 | sqlite3VdbeJumpHere(v, shortJump+2); |
| 78221 | #endif |
| 78222 | |
| 78223 | /* Store the results in sqlite_stat1. |
| 78224 | ** |
| 78225 | ** The result is a single row of the sqlite_stat1 table. The first |
| 78226 | ** two columns are the names of the table and index. The third column |
| @@ -77923,50 +78236,51 @@ | |
| 78236 | ** |
| 78237 | ** If K==0 then no entry is made into the sqlite_stat1 table. |
| 78238 | ** If K>0 then it is always the case the D>0 so division by zero |
| 78239 | ** is never possible. |
| 78240 | */ |
| 78241 | sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1); |
| 78242 | if( jZeroRows<0 ){ |
| 78243 | jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); |
| 78244 | } |
| 78245 | for(i=0; i<nCol; i++){ |
| 78246 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0); |
| 78247 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); |
| 78248 | sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp); |
| 78249 | sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); |
| 78250 | sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp); |
| 78251 | sqlite3VdbeAddOp1(v, OP_ToInt, regTemp); |
| 78252 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); |
| 78253 | } |
| 78254 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 78255 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 78256 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 78257 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 78258 | } |
| 78259 | |
| 78260 | /* If the table has no indices, create a single sqlite_stat1 entry |
| 78261 | ** containing NULL as the index name and the row count as the content. |
| 78262 | */ |
| 78263 | if( pTab->pIndex==0 ){ |
| 78264 | sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb); |
| 78265 | VdbeComment((v, "%s", pTab->zName)); |
| 78266 | sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1); |
| 78267 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 78268 | jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); |
| 78269 | }else{ |
| 78270 | sqlite3VdbeJumpHere(v, jZeroRows); |
| 78271 | jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto); |
| 78272 | } |
| 78273 | sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); |
| 78274 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 78275 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 78276 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 78277 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 78278 | if( pParse->nMem<regRec ) pParse->nMem = regRec; |
| 78279 | sqlite3VdbeJumpHere(v, jZeroRows); |
| 78280 | } |
| 78281 | |
| 78282 | |
| 78283 | /* |
| 78284 | ** Generate code that will cause the most recent index analysis to |
| 78285 | ** be loaded into internal hash tables where is can be used. |
| 78286 | */ |
| @@ -77987,11 +78301,11 @@ | |
| 78301 | int iStatCur; |
| 78302 | int iMem; |
| 78303 | |
| 78304 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| 78305 | iStatCur = pParse->nTab; |
| 78306 | pParse->nTab += 3; |
| 78307 | openStatTable(pParse, iDb, iStatCur, 0, 0); |
| 78308 | iMem = pParse->nMem+1; |
| 78309 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 78310 | for(k=sqliteHashFirst(&pSchema->tblHash); k; k=sqliteHashNext(k)){ |
| 78311 | Table *pTab = (Table*)sqliteHashData(k); |
| @@ -78012,11 +78326,11 @@ | |
| 78326 | assert( pTab!=0 ); |
| 78327 | assert( sqlite3BtreeHoldsAllMutexes(pParse->db) ); |
| 78328 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
| 78329 | sqlite3BeginWriteOperation(pParse, 0, iDb); |
| 78330 | iStatCur = pParse->nTab; |
| 78331 | pParse->nTab += 3; |
| 78332 | if( pOnlyIdx ){ |
| 78333 | openStatTable(pParse, iDb, iStatCur, pOnlyIdx->zName, "idx"); |
| 78334 | }else{ |
| 78335 | openStatTable(pParse, iDb, iStatCur, pTab->zName, "tbl"); |
| 78336 | } |
| @@ -78117,11 +78431,11 @@ | |
| 78431 | static int analysisLoader(void *pData, int argc, char **argv, char **NotUsed){ |
| 78432 | analysisInfo *pInfo = (analysisInfo*)pData; |
| 78433 | Index *pIndex; |
| 78434 | Table *pTable; |
| 78435 | int i, c, n; |
| 78436 | tRowcnt v; |
| 78437 | const char *z; |
| 78438 | |
| 78439 | assert( argc==3 ); |
| 78440 | UNUSED_PARAMETER2(NotUsed, argc); |
| 78441 | |
| @@ -78160,40 +78474,172 @@ | |
| 78474 | /* |
| 78475 | ** If the Index.aSample variable is not NULL, delete the aSample[] array |
| 78476 | ** and its contents. |
| 78477 | */ |
| 78478 | SQLITE_PRIVATE void sqlite3DeleteIndexSamples(sqlite3 *db, Index *pIdx){ |
| 78479 | #ifdef SQLITE_ENABLE_STAT3 |
| 78480 | if( pIdx->aSample ){ |
| 78481 | int j; |
| 78482 | for(j=0; j<pIdx->nSample; j++){ |
| 78483 | IndexSample *p = &pIdx->aSample[j]; |
| 78484 | if( p->eType==SQLITE_TEXT || p->eType==SQLITE_BLOB ){ |
| 78485 | sqlite3DbFree(db, p->u.z); |
| 78486 | } |
| 78487 | } |
| 78488 | sqlite3DbFree(db, pIdx->aSample); |
| 78489 | } |
| 78490 | if( db && db->pnBytesFreed==0 ){ |
| 78491 | pIdx->nSample = 0; |
| 78492 | pIdx->aSample = 0; |
| 78493 | } |
| 78494 | #else |
| 78495 | UNUSED_PARAMETER(db); |
| 78496 | UNUSED_PARAMETER(pIdx); |
| 78497 | #endif |
| 78498 | } |
| 78499 | |
| 78500 | #ifdef SQLITE_ENABLE_STAT3 |
| 78501 | /* |
| 78502 | ** Load content from the sqlite_stat3 table into the Index.aSample[] |
| 78503 | ** arrays of all indices. |
| 78504 | */ |
| 78505 | static int loadStat3(sqlite3 *db, const char *zDb){ |
| 78506 | int rc; /* Result codes from subroutines */ |
| 78507 | sqlite3_stmt *pStmt = 0; /* An SQL statement being run */ |
| 78508 | char *zSql; /* Text of the SQL statement */ |
| 78509 | Index *pPrevIdx = 0; /* Previous index in the loop */ |
| 78510 | int idx = 0; /* slot in pIdx->aSample[] for next sample */ |
| 78511 | int eType; /* Datatype of a sample */ |
| 78512 | IndexSample *pSample; /* A slot in pIdx->aSample[] */ |
| 78513 | |
| 78514 | if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){ |
| 78515 | return SQLITE_OK; |
| 78516 | } |
| 78517 | |
| 78518 | zSql = sqlite3MPrintf(db, |
| 78519 | "SELECT idx,count(*) FROM %Q.sqlite_stat3" |
| 78520 | " GROUP BY idx", zDb); |
| 78521 | if( !zSql ){ |
| 78522 | return SQLITE_NOMEM; |
| 78523 | } |
| 78524 | rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); |
| 78525 | sqlite3DbFree(db, zSql); |
| 78526 | if( rc ) return rc; |
| 78527 | |
| 78528 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 78529 | char *zIndex; /* Index name */ |
| 78530 | Index *pIdx; /* Pointer to the index object */ |
| 78531 | int nSample; /* Number of samples */ |
| 78532 | |
| 78533 | zIndex = (char *)sqlite3_column_text(pStmt, 0); |
| 78534 | if( zIndex==0 ) continue; |
| 78535 | nSample = sqlite3_column_int(pStmt, 1); |
| 78536 | pIdx = sqlite3FindIndex(db, zIndex, zDb); |
| 78537 | if( pIdx==0 ) continue; |
| 78538 | assert( pIdx->nSample==0 ); |
| 78539 | pIdx->nSample = nSample; |
| 78540 | pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) ); |
| 78541 | pIdx->avgEq = pIdx->aiRowEst[1]; |
| 78542 | if( pIdx->aSample==0 ){ |
| 78543 | db->mallocFailed = 1; |
| 78544 | sqlite3_finalize(pStmt); |
| 78545 | return SQLITE_NOMEM; |
| 78546 | } |
| 78547 | } |
| 78548 | rc = sqlite3_finalize(pStmt); |
| 78549 | if( rc ) return rc; |
| 78550 | |
| 78551 | zSql = sqlite3MPrintf(db, |
| 78552 | "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat3", zDb); |
| 78553 | if( !zSql ){ |
| 78554 | return SQLITE_NOMEM; |
| 78555 | } |
| 78556 | rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); |
| 78557 | sqlite3DbFree(db, zSql); |
| 78558 | if( rc ) return rc; |
| 78559 | |
| 78560 | while( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 78561 | char *zIndex; /* Index name */ |
| 78562 | Index *pIdx; /* Pointer to the index object */ |
| 78563 | int i; /* Loop counter */ |
| 78564 | tRowcnt sumEq; /* Sum of the nEq values */ |
| 78565 | |
| 78566 | zIndex = (char *)sqlite3_column_text(pStmt, 0); |
| 78567 | if( zIndex==0 ) continue; |
| 78568 | pIdx = sqlite3FindIndex(db, zIndex, zDb); |
| 78569 | if( pIdx==0 ) continue; |
| 78570 | if( pIdx==pPrevIdx ){ |
| 78571 | idx++; |
| 78572 | }else{ |
| 78573 | pPrevIdx = pIdx; |
| 78574 | idx = 0; |
| 78575 | } |
| 78576 | assert( idx<pIdx->nSample ); |
| 78577 | pSample = &pIdx->aSample[idx]; |
| 78578 | pSample->nEq = (tRowcnt)sqlite3_column_int64(pStmt, 1); |
| 78579 | pSample->nLt = (tRowcnt)sqlite3_column_int64(pStmt, 2); |
| 78580 | pSample->nDLt = (tRowcnt)sqlite3_column_int64(pStmt, 3); |
| 78581 | if( idx==pIdx->nSample-1 ){ |
| 78582 | if( pSample->nDLt>0 ){ |
| 78583 | for(i=0, sumEq=0; i<=idx-1; i++) sumEq += pIdx->aSample[i].nEq; |
| 78584 | pIdx->avgEq = (pSample->nLt - sumEq)/pSample->nDLt; |
| 78585 | } |
| 78586 | if( pIdx->avgEq<=0 ) pIdx->avgEq = 1; |
| 78587 | } |
| 78588 | eType = sqlite3_column_type(pStmt, 4); |
| 78589 | pSample->eType = (u8)eType; |
| 78590 | switch( eType ){ |
| 78591 | case SQLITE_INTEGER: { |
| 78592 | pSample->u.i = sqlite3_column_int64(pStmt, 4); |
| 78593 | break; |
| 78594 | } |
| 78595 | case SQLITE_FLOAT: { |
| 78596 | pSample->u.r = sqlite3_column_double(pStmt, 4); |
| 78597 | break; |
| 78598 | } |
| 78599 | case SQLITE_NULL: { |
| 78600 | break; |
| 78601 | } |
| 78602 | default: assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); { |
| 78603 | const char *z = (const char *)( |
| 78604 | (eType==SQLITE_BLOB) ? |
| 78605 | sqlite3_column_blob(pStmt, 4): |
| 78606 | sqlite3_column_text(pStmt, 4) |
| 78607 | ); |
| 78608 | int n = z ? sqlite3_column_bytes(pStmt, 4) : 0; |
| 78609 | pSample->nByte = n; |
| 78610 | if( n < 1){ |
| 78611 | pSample->u.z = 0; |
| 78612 | }else{ |
| 78613 | pSample->u.z = sqlite3Malloc(n); |
| 78614 | if( pSample->u.z==0 ){ |
| 78615 | db->mallocFailed = 1; |
| 78616 | sqlite3_finalize(pStmt); |
| 78617 | return SQLITE_NOMEM; |
| 78618 | } |
| 78619 | memcpy(pSample->u.z, z, n); |
| 78620 | } |
| 78621 | } |
| 78622 | } |
| 78623 | } |
| 78624 | return sqlite3_finalize(pStmt); |
| 78625 | } |
| 78626 | #endif /* SQLITE_ENABLE_STAT3 */ |
| 78627 | |
| 78628 | /* |
| 78629 | ** Load the content of the sqlite_stat1 and sqlite_stat3 tables. The |
| 78630 | ** contents of sqlite_stat1 are used to populate the Index.aiRowEst[] |
| 78631 | ** arrays. The contents of sqlite_stat3 are used to populate the |
| 78632 | ** Index.aSample[] arrays. |
| 78633 | ** |
| 78634 | ** If the sqlite_stat1 table is not present in the database, SQLITE_ERROR |
| 78635 | ** is returned. In this case, even if SQLITE_ENABLE_STAT3 was defined |
| 78636 | ** during compilation and the sqlite_stat3 table is present, no data is |
| 78637 | ** read from it. |
| 78638 | ** |
| 78639 | ** If SQLITE_ENABLE_STAT3 was defined during compilation and the |
| 78640 | ** sqlite_stat3 table is not present in the database, SQLITE_ERROR is |
| 78641 | ** returned. However, in this case, data is read from the sqlite_stat1 |
| 78642 | ** table (if it is present) before returning. |
| 78643 | ** |
| 78644 | ** If an OOM error occurs, this function always sets db->mallocFailed. |
| 78645 | ** This means if the caller does not care about other errors, the return |
| @@ -78211,12 +78657,14 @@ | |
| 78657 | /* Clear any prior statistics */ |
| 78658 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 78659 | for(i=sqliteHashFirst(&db->aDb[iDb].pSchema->idxHash);i;i=sqliteHashNext(i)){ |
| 78660 | Index *pIdx = sqliteHashData(i); |
| 78661 | sqlite3DefaultRowEst(pIdx); |
| 78662 | #ifdef SQLITE_ENABLE_STAT3 |
| 78663 | sqlite3DeleteIndexSamples(db, pIdx); |
| 78664 | pIdx->aSample = 0; |
| 78665 | #endif |
| 78666 | } |
| 78667 | |
| 78668 | /* Check to make sure the sqlite_stat1 table exists */ |
| 78669 | sInfo.db = db; |
| 78670 | sInfo.zDatabase = db->aDb[iDb].zName; |
| @@ -78224,91 +78672,23 @@ | |
| 78672 | return SQLITE_ERROR; |
| 78673 | } |
| 78674 | |
| 78675 | /* Load new statistics out of the sqlite_stat1 table */ |
| 78676 | zSql = sqlite3MPrintf(db, |
| 78677 | "SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase); |
| 78678 | if( zSql==0 ){ |
| 78679 | rc = SQLITE_NOMEM; |
| 78680 | }else{ |
| 78681 | rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0); |
| 78682 | sqlite3DbFree(db, zSql); |
| 78683 | } |
| 78684 | |
| 78685 | |
| 78686 | /* Load the statistics from the sqlite_stat3 table. */ |
| 78687 | #ifdef SQLITE_ENABLE_STAT3 |
| 78688 | if( rc==SQLITE_OK ){ |
| 78689 | rc = loadStat3(db, sInfo.zDatabase); |
| 78690 | } |
| 78691 | #endif |
| 78692 | |
| 78693 | if( rc==SQLITE_NOMEM ){ |
| 78694 | db->mallocFailed = 1; |
| @@ -78319,10 +78699,11 @@ | |
| 78699 | |
| 78700 | #endif /* SQLITE_OMIT_ANALYZE */ |
| 78701 | |
| 78702 | /************** End of analyze.c *********************************************/ |
| 78703 | /************** Begin file attach.c ******************************************/ |
| 78704 | #line 1 "tsrc/attach.c" |
| 78705 | /* |
| 78706 | ** 2003 April 6 |
| 78707 | ** |
| 78708 | ** The author disclaims copyright to this source code. In place of |
| 78709 | ** a legal notice, here is a blessing: |
| @@ -78878,10 +79259,11 @@ | |
| 79259 | } |
| 79260 | #endif |
| 79261 | |
| 79262 | /************** End of attach.c **********************************************/ |
| 79263 | /************** Begin file auth.c ********************************************/ |
| 79264 | #line 1 "tsrc/auth.c" |
| 79265 | /* |
| 79266 | ** 2003 January 11 |
| 79267 | ** |
| 79268 | ** The author disclaims copyright to this source code. In place of |
| 79269 | ** a legal notice, here is a blessing: |
| @@ -79129,10 +79511,11 @@ | |
| 79511 | |
| 79512 | #endif /* SQLITE_OMIT_AUTHORIZATION */ |
| 79513 | |
| 79514 | /************** End of auth.c ************************************************/ |
| 79515 | /************** Begin file build.c *******************************************/ |
| 79516 | #line 1 "tsrc/build.c" |
| 79517 | /* |
| 79518 | ** 2001 September 15 |
| 79519 | ** |
| 79520 | ** The author disclaims copyright to this source code. In place of |
| 79521 | ** a legal notice, here is a blessing: |
| @@ -81120,11 +81503,15 @@ | |
| 81503 | Parse *pParse, /* The parsing context */ |
| 81504 | int iDb, /* The database number */ |
| 81505 | const char *zType, /* "idx" or "tbl" */ |
| 81506 | const char *zName /* Name of index or table */ |
| 81507 | ){ |
| 81508 | static const char *azStatTab[] = { |
| 81509 | "sqlite_stat1", |
| 81510 | "sqlite_stat2", |
| 81511 | "sqlite_stat3", |
| 81512 | }; |
| 81513 | int i; |
| 81514 | const char *zDbName = pParse->db->aDb[iDb].zName; |
| 81515 | for(i=0; i<ArraySize(azStatTab); i++){ |
| 81516 | if( sqlite3FindTable(pParse->db, azStatTab[i], zDbName) ){ |
| 81517 | sqlite3NestedParse(pParse, |
| @@ -81132,10 +81519,80 @@ | |
| 81519 | zDbName, azStatTab[i], zType, zName |
| 81520 | ); |
| 81521 | } |
| 81522 | } |
| 81523 | } |
| 81524 | |
| 81525 | /* |
| 81526 | ** Generate code to drop a table. |
| 81527 | */ |
| 81528 | SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){ |
| 81529 | Vdbe *v; |
| 81530 | sqlite3 *db = pParse->db; |
| 81531 | Trigger *pTrigger; |
| 81532 | Db *pDb = &db->aDb[iDb]; |
| 81533 | |
| 81534 | v = sqlite3GetVdbe(pParse); |
| 81535 | assert( v!=0 ); |
| 81536 | sqlite3BeginWriteOperation(pParse, 1, iDb); |
| 81537 | |
| 81538 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 81539 | if( IsVirtual(pTab) ){ |
| 81540 | sqlite3VdbeAddOp0(v, OP_VBegin); |
| 81541 | } |
| 81542 | #endif |
| 81543 | |
| 81544 | /* Drop all triggers associated with the table being dropped. Code |
| 81545 | ** is generated to remove entries from sqlite_master and/or |
| 81546 | ** sqlite_temp_master if required. |
| 81547 | */ |
| 81548 | pTrigger = sqlite3TriggerList(pParse, pTab); |
| 81549 | while( pTrigger ){ |
| 81550 | assert( pTrigger->pSchema==pTab->pSchema || |
| 81551 | pTrigger->pSchema==db->aDb[1].pSchema ); |
| 81552 | sqlite3DropTriggerPtr(pParse, pTrigger); |
| 81553 | pTrigger = pTrigger->pNext; |
| 81554 | } |
| 81555 | |
| 81556 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 81557 | /* Remove any entries of the sqlite_sequence table associated with |
| 81558 | ** the table being dropped. This is done before the table is dropped |
| 81559 | ** at the btree level, in case the sqlite_sequence table needs to |
| 81560 | ** move as a result of the drop (can happen in auto-vacuum mode). |
| 81561 | */ |
| 81562 | if( pTab->tabFlags & TF_Autoincrement ){ |
| 81563 | sqlite3NestedParse(pParse, |
| 81564 | "DELETE FROM %Q.sqlite_sequence WHERE name=%Q", |
| 81565 | pDb->zName, pTab->zName |
| 81566 | ); |
| 81567 | } |
| 81568 | #endif |
| 81569 | |
| 81570 | /* Drop all SQLITE_MASTER table and index entries that refer to the |
| 81571 | ** table. The program name loops through the master table and deletes |
| 81572 | ** every row that refers to a table of the same name as the one being |
| 81573 | ** dropped. Triggers are handled seperately because a trigger can be |
| 81574 | ** created in the temp database that refers to a table in another |
| 81575 | ** database. |
| 81576 | */ |
| 81577 | sqlite3NestedParse(pParse, |
| 81578 | "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'", |
| 81579 | pDb->zName, SCHEMA_TABLE(iDb), pTab->zName); |
| 81580 | if( !isView && !IsVirtual(pTab) ){ |
| 81581 | destroyTable(pParse, pTab); |
| 81582 | } |
| 81583 | |
| 81584 | /* Remove the table entry from SQLite's internal schema and modify |
| 81585 | ** the schema cookie. |
| 81586 | */ |
| 81587 | if( IsVirtual(pTab) ){ |
| 81588 | sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0); |
| 81589 | } |
| 81590 | sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); |
| 81591 | sqlite3ChangeCookie(pParse, iDb); |
| 81592 | sqliteViewResetAll(db, iDb); |
| 81593 | } |
| 81594 | |
| 81595 | /* |
| 81596 | ** This routine is called to do the work of a DROP TABLE statement. |
| 81597 | ** pName is the name of the table to be dropped. |
| 81598 | */ |
| @@ -81225,72 +81682,15 @@ | |
| 81682 | /* Generate code to remove the table from the master table |
| 81683 | ** on disk. |
| 81684 | */ |
| 81685 | v = sqlite3GetVdbe(pParse); |
| 81686 | if( v ){ |
| 81687 | sqlite3BeginWriteOperation(pParse, 1, iDb); |
| 81688 | sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName); |
| 81689 | sqlite3FkDropTable(pParse, pName, pTab); |
| 81690 | sqlite3CodeDropTable(pParse, pTab, iDb, isView); |
| 81691 | } |
| 81692 | |
| 81693 | exit_drop_table: |
| 81694 | sqlite3SrcListDelete(db, pName); |
| 81695 | } |
| 81696 | |
| @@ -81769,24 +82169,24 @@ | |
| 82169 | */ |
| 82170 | nName = sqlite3Strlen30(zName); |
| 82171 | nCol = pList->nExpr; |
| 82172 | pIndex = sqlite3DbMallocZero(db, |
| 82173 | sizeof(Index) + /* Index structure */ |
| 82174 | sizeof(tRowcnt)*(nCol+1) + /* Index.aiRowEst */ |
| 82175 | sizeof(int)*nCol + /* Index.aiColumn */ |
| 82176 | sizeof(char *)*nCol + /* Index.azColl */ |
| 82177 | sizeof(u8)*nCol + /* Index.aSortOrder */ |
| 82178 | nName + 1 + /* Index.zName */ |
| 82179 | nExtra /* Collation sequence names */ |
| 82180 | ); |
| 82181 | if( db->mallocFailed ){ |
| 82182 | goto exit_create_index; |
| 82183 | } |
| 82184 | pIndex->aiRowEst = (tRowcnt*)(&pIndex[1]); |
| 82185 | pIndex->azColl = (char**)(&pIndex->aiRowEst[nCol+1]); |
| 82186 | pIndex->aiColumn = (int *)(&pIndex->azColl[nCol]); |
| 82187 | pIndex->aSortOrder = (u8 *)(&pIndex->aiColumn[nCol]); |
| 82188 | pIndex->zName = (char *)(&pIndex->aSortOrder[nCol]); |
| 82189 | zExtra = (char *)(&pIndex->zName[nName+1]); |
| 82190 | memcpy(pIndex->zName, zName, nName+1); |
| 82191 | pIndex->pTable = pTab; |
| 82192 | pIndex->nColumn = pList->nExpr; |
| @@ -82059,13 +82459,13 @@ | |
| 82459 | ** Apart from that, we have little to go on besides intuition as to |
| 82460 | ** how aiRowEst[] should be initialized. The numbers generated here |
| 82461 | ** are based on typical values found in actual indices. |
| 82462 | */ |
| 82463 | SQLITE_PRIVATE void sqlite3DefaultRowEst(Index *pIdx){ |
| 82464 | tRowcnt *a = pIdx->aiRowEst; |
| 82465 | int i; |
| 82466 | tRowcnt n; |
| 82467 | assert( a!=0 ); |
| 82468 | a[0] = pIdx->pTable->nRowEst; |
| 82469 | if( a[0]<10 ) a[0] = 10; |
| 82470 | n = 10; |
| 82471 | for(i=1; i<=pIdx->nColumn; i++){ |
| @@ -82932,10 +83332,11 @@ | |
| 83332 | return pKey; |
| 83333 | } |
| 83334 | |
| 83335 | /************** End of build.c ***********************************************/ |
| 83336 | /************** Begin file callback.c ****************************************/ |
| 83337 | #line 1 "tsrc/callback.c" |
| 83338 | /* |
| 83339 | ** 2005 May 23 |
| 83340 | ** |
| 83341 | ** The author disclaims copyright to this source code. In place of |
| 83342 | ** a legal notice, here is a blessing: |
| @@ -83391,10 +83792,11 @@ | |
| 83792 | return p; |
| 83793 | } |
| 83794 | |
| 83795 | /************** End of callback.c ********************************************/ |
| 83796 | /************** Begin file delete.c ******************************************/ |
| 83797 | #line 1 "tsrc/delete.c" |
| 83798 | /* |
| 83799 | ** 2001 September 15 |
| 83800 | ** |
| 83801 | ** The author disclaims copyright to this source code. In place of |
| 83802 | ** a legal notice, here is a blessing: |
| @@ -84045,10 +84447,11 @@ | |
| 84447 | return regBase; |
| 84448 | } |
| 84449 | |
| 84450 | /************** End of delete.c **********************************************/ |
| 84451 | /************** Begin file func.c ********************************************/ |
| 84452 | #line 1 "tsrc/func.c" |
| 84453 | /* |
| 84454 | ** 2002 February 23 |
| 84455 | ** |
| 84456 | ** The author disclaims copyright to this source code. In place of |
| 84457 | ** a legal notice, here is a blessing: |
| @@ -85653,10 +86056,11 @@ | |
| 86056 | #endif |
| 86057 | } |
| 86058 | |
| 86059 | /************** End of func.c ************************************************/ |
| 86060 | /************** Begin file fkey.c ********************************************/ |
| 86061 | #line 1 "tsrc/fkey.c" |
| 86062 | /* |
| 86063 | ** |
| 86064 | ** The author disclaims copyright to this source code. In place of |
| 86065 | ** a legal notice, here is a blessing: |
| 86066 | ** |
| @@ -86873,10 +87277,11 @@ | |
| 87277 | } |
| 87278 | #endif /* ifndef SQLITE_OMIT_FOREIGN_KEY */ |
| 87279 | |
| 87280 | /************** End of fkey.c ************************************************/ |
| 87281 | /************** Begin file insert.c ******************************************/ |
| 87282 | #line 1 "tsrc/insert.c" |
| 87283 | /* |
| 87284 | ** 2001 September 15 |
| 87285 | ** |
| 87286 | ** The author disclaims copyright to this source code. In place of |
| 87287 | ** a legal notice, here is a blessing: |
| @@ -88621,10 +89026,13 @@ | |
| 89026 | */ |
| 89027 | if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){ |
| 89028 | return 0; |
| 89029 | } |
| 89030 | #endif |
| 89031 | if( (pParse->db->flags & SQLITE_CountRows)!=0 ){ |
| 89032 | return 0; |
| 89033 | } |
| 89034 | |
| 89035 | /* If we get this far, it means either: |
| 89036 | ** |
| 89037 | ** * We can always do the transfer if the table contains an |
| 89038 | ** an integer primary key |
| @@ -88718,10 +89126,11 @@ | |
| 89126 | } |
| 89127 | #endif /* SQLITE_OMIT_XFER_OPT */ |
| 89128 | |
| 89129 | /************** End of insert.c **********************************************/ |
| 89130 | /************** Begin file legacy.c ******************************************/ |
| 89131 | #line 1 "tsrc/legacy.c" |
| 89132 | /* |
| 89133 | ** 2001 September 15 |
| 89134 | ** |
| 89135 | ** The author disclaims copyright to this source code. In place of |
| 89136 | ** a legal notice, here is a blessing: |
| @@ -88865,10 +89274,11 @@ | |
| 89274 | return rc; |
| 89275 | } |
| 89276 | |
| 89277 | /************** End of legacy.c **********************************************/ |
| 89278 | /************** Begin file loadext.c *****************************************/ |
| 89279 | #line 1 "tsrc/loadext.c" |
| 89280 | /* |
| 89281 | ** 2006 June 7 |
| 89282 | ** |
| 89283 | ** The author disclaims copyright to this source code. In place of |
| 89284 | ** a legal notice, here is a blessing: |
| @@ -88885,10 +89295,11 @@ | |
| 89295 | #ifndef SQLITE_CORE |
| 89296 | #define SQLITE_CORE 1 /* Disable the API redefinition in sqlite3ext.h */ |
| 89297 | #endif |
| 89298 | /************** Include sqlite3ext.h in the middle of loadext.c **************/ |
| 89299 | /************** Begin file sqlite3ext.h **************************************/ |
| 89300 | #line 1 "tsrc/sqlite3ext.h" |
| 89301 | /* |
| 89302 | ** 2006 June 7 |
| 89303 | ** |
| 89304 | ** The author disclaims copyright to this source code. In place of |
| 89305 | ** a legal notice, here is a blessing: |
| @@ -89313,10 +89724,11 @@ | |
| 89724 | |
| 89725 | #endif /* _SQLITE3EXT_H_ */ |
| 89726 | |
| 89727 | /************** End of sqlite3ext.h ******************************************/ |
| 89728 | /************** Continuing where we left off in loadext.c ********************/ |
| 89729 | #line 20 "tsrc/loadext.c" |
| 89730 | /* #include <string.h> */ |
| 89731 | |
| 89732 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 89733 | |
| 89734 | /* |
| @@ -89952,10 +90364,11 @@ | |
| 90364 | } |
| 90365 | } |
| 90366 | |
| 90367 | /************** End of loadext.c *********************************************/ |
| 90368 | /************** Begin file pragma.c ******************************************/ |
| 90369 | #line 1 "tsrc/pragma.c" |
| 90370 | /* |
| 90371 | ** 2003 April 6 |
| 90372 | ** |
| 90373 | ** The author disclaims copyright to this source code. In place of |
| 90374 | ** a legal notice, here is a blessing: |
| @@ -91480,10 +91893,11 @@ | |
| 91893 | |
| 91894 | #endif /* SQLITE_OMIT_PRAGMA */ |
| 91895 | |
| 91896 | /************** End of pragma.c **********************************************/ |
| 91897 | /************** Begin file prepare.c *****************************************/ |
| 91898 | #line 1 "tsrc/prepare.c" |
| 91899 | /* |
| 91900 | ** 2005 May 25 |
| 91901 | ** |
| 91902 | ** The author disclaims copyright to this source code. In place of |
| 91903 | ** a legal notice, here is a blessing: |
| @@ -92340,10 +92754,11 @@ | |
| 92754 | |
| 92755 | #endif /* SQLITE_OMIT_UTF16 */ |
| 92756 | |
| 92757 | /************** End of prepare.c *********************************************/ |
| 92758 | /************** Begin file select.c ******************************************/ |
| 92759 | #line 1 "tsrc/select.c" |
| 92760 | /* |
| 92761 | ** 2001 September 15 |
| 92762 | ** |
| 92763 | ** The author disclaims copyright to this source code. In place of |
| 92764 | ** a legal notice, here is a blessing: |
| @@ -96928,10 +97343,11 @@ | |
| 97343 | *****************************************************************************/ |
| 97344 | #endif /* defined(SQLITE_TEST) || defined(SQLITE_DEBUG) */ |
| 97345 | |
| 97346 | /************** End of select.c **********************************************/ |
| 97347 | /************** Begin file table.c *******************************************/ |
| 97348 | #line 1 "tsrc/table.c" |
| 97349 | /* |
| 97350 | ** 2001 September 15 |
| 97351 | ** |
| 97352 | ** The author disclaims copyright to this source code. In place of |
| 97353 | ** a legal notice, here is a blessing: |
| @@ -97127,10 +97543,11 @@ | |
| 97543 | |
| 97544 | #endif /* SQLITE_OMIT_GET_TABLE */ |
| 97545 | |
| 97546 | /************** End of table.c ***********************************************/ |
| 97547 | /************** Begin file trigger.c *****************************************/ |
| 97548 | #line 1 "tsrc/trigger.c" |
| 97549 | /* |
| 97550 | ** |
| 97551 | ** The author disclaims copyright to this source code. In place of |
| 97552 | ** a legal notice, here is a blessing: |
| 97553 | ** |
| @@ -98252,10 +98669,11 @@ | |
| 98669 | |
| 98670 | #endif /* !defined(SQLITE_OMIT_TRIGGER) */ |
| 98671 | |
| 98672 | /************** End of trigger.c *********************************************/ |
| 98673 | /************** Begin file update.c ******************************************/ |
| 98674 | #line 1 "tsrc/update.c" |
| 98675 | /* |
| 98676 | ** 2001 September 15 |
| 98677 | ** |
| 98678 | ** The author disclaims copyright to this source code. In place of |
| 98679 | ** a legal notice, here is a blessing: |
| @@ -98924,10 +99342,11 @@ | |
| 99342 | } |
| 99343 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 99344 | |
| 99345 | /************** End of update.c **********************************************/ |
| 99346 | /************** Begin file vacuum.c ******************************************/ |
| 99347 | #line 1 "tsrc/vacuum.c" |
| 99348 | /* |
| 99349 | ** 2003 April 6 |
| 99350 | ** |
| 99351 | ** The author disclaims copyright to this source code. In place of |
| 99352 | ** a legal notice, here is a blessing: |
| @@ -98969,11 +99388,11 @@ | |
| 99388 | if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ |
| 99389 | sqlite3SetString(pzErrMsg, db, sqlite3_errmsg(db)); |
| 99390 | return sqlite3_errcode(db); |
| 99391 | } |
| 99392 | VVA_ONLY( rc = ) sqlite3_step(pStmt); |
| 99393 | assert( rc!=SQLITE_ROW || (db->flags&SQLITE_CountRows) ); |
| 99394 | return vacuumFinalize(db, pStmt, pzErrMsg); |
| 99395 | } |
| 99396 | |
| 99397 | /* |
| 99398 | ** Execute zSql on database db. The statement returns exactly |
| @@ -99187,17 +99606,15 @@ | |
| 99606 | " WHERE type='view' OR type='trigger'" |
| 99607 | " OR (type='table' AND rootpage=0)" |
| 99608 | ); |
| 99609 | if( rc ) goto end_of_vacuum; |
| 99610 | |
| 99611 | /* At this point, there is a write transaction open on both the |
| 99612 | ** vacuum database and the main database. Assuming no error occurs, |
| 99613 | ** both transactions are closed by this block - the main database |
| 99614 | ** transaction by sqlite3BtreeCopyFile() and the other by an explicit |
| 99615 | ** call to sqlite3BtreeCommit(). |
| 99616 | */ |
| 99617 | { |
| 99618 | u32 meta; |
| 99619 | int i; |
| 99620 | |
| @@ -99270,10 +99687,11 @@ | |
| 99687 | |
| 99688 | #endif /* SQLITE_OMIT_VACUUM && SQLITE_OMIT_ATTACH */ |
| 99689 | |
| 99690 | /************** End of vacuum.c **********************************************/ |
| 99691 | /************** Begin file vtab.c ********************************************/ |
| 99692 | #line 1 "tsrc/vtab.c" |
| 99693 | /* |
| 99694 | ** 2006 June 10 |
| 99695 | ** |
| 99696 | ** The author disclaims copyright to this source code. In place of |
| 99697 | ** a legal notice, here is a blessing: |
| @@ -100338,10 +100756,11 @@ | |
| 100756 | |
| 100757 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 100758 | |
| 100759 | /************** End of vtab.c ************************************************/ |
| 100760 | /************** Begin file where.c *******************************************/ |
| 100761 | #line 1 "tsrc/where.c" |
| 100762 | /* |
| 100763 | ** 2001 September 15 |
| 100764 | ** |
| 100765 | ** The author disclaims copyright to this source code. In place of |
| 100766 | ** a legal notice, here is a blessing: |
| @@ -100457,25 +100876,35 @@ | |
| 100876 | #define TERM_CODED 0x04 /* This term is already coded */ |
| 100877 | #define TERM_COPIED 0x08 /* Has a child */ |
| 100878 | #define TERM_ORINFO 0x10 /* Need to free the WhereTerm.u.pOrInfo object */ |
| 100879 | #define TERM_ANDINFO 0x20 /* Need to free the WhereTerm.u.pAndInfo obj */ |
| 100880 | #define TERM_OR_OK 0x40 /* Used during OR-clause processing */ |
| 100881 | #ifdef SQLITE_ENABLE_STAT3 |
| 100882 | # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */ |
| 100883 | #else |
| 100884 | # define TERM_VNULL 0x00 /* Disabled if not using stat3 */ |
| 100885 | #endif |
| 100886 | |
| 100887 | /* |
| 100888 | ** An instance of the following structure holds all information about a |
| 100889 | ** WHERE clause. Mostly this is a container for one or more WhereTerms. |
| 100890 | ** |
| 100891 | ** Explanation of pOuter: For a WHERE clause of the form |
| 100892 | ** |
| 100893 | ** a AND ((b AND c) OR (d AND e)) AND f |
| 100894 | ** |
| 100895 | ** There are separate WhereClause objects for the whole clause and for |
| 100896 | ** the subclauses "(b AND c)" and "(d AND e)". The pOuter field of the |
| 100897 | ** subclauses points to the WhereClause object for the whole clause. |
| 100898 | */ |
| 100899 | struct WhereClause { |
| 100900 | Parse *pParse; /* The parser context */ |
| 100901 | WhereMaskSet *pMaskSet; /* Mapping of table cursor numbers to bitmasks */ |
| 100902 | Bitmask vmask; /* Bitmask identifying virtual table cursors */ |
| 100903 | WhereClause *pOuter; /* Outer conjunction */ |
| 100904 | u8 op; /* Split operator. TK_AND or TK_OR */ |
| 100905 | u16 wctrlFlags; /* Might include WHERE_AND_ONLY */ |
| 100906 | int nTerm; /* Number of terms */ |
| 100907 | int nSlot; /* Number of entries in a[] */ |
| 100908 | WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */ |
| 100909 | #if defined(SQLITE_SMALL_STACK) |
| 100910 | WhereTerm aStatic[1]; /* Initial static space for a[] */ |
| @@ -100600,18 +101029,21 @@ | |
| 101029 | ** Initialize a preallocated WhereClause structure. |
| 101030 | */ |
| 101031 | static void whereClauseInit( |
| 101032 | WhereClause *pWC, /* The WhereClause to be initialized */ |
| 101033 | Parse *pParse, /* The parsing context */ |
| 101034 | WhereMaskSet *pMaskSet, /* Mapping from table cursor numbers to bitmasks */ |
| 101035 | u16 wctrlFlags /* Might include WHERE_AND_ONLY */ |
| 101036 | ){ |
| 101037 | pWC->pParse = pParse; |
| 101038 | pWC->pMaskSet = pMaskSet; |
| 101039 | pWC->pOuter = 0; |
| 101040 | pWC->nTerm = 0; |
| 101041 | pWC->nSlot = ArraySize(pWC->aStatic); |
| 101042 | pWC->a = pWC->aStatic; |
| 101043 | pWC->vmask = 0; |
| 101044 | pWC->wctrlFlags = wctrlFlags; |
| 101045 | } |
| 101046 | |
| 101047 | /* Forward reference */ |
| 101048 | static void whereClauseClear(WhereClause*); |
| 101049 | |
| @@ -100923,40 +101355,42 @@ | |
| 101355 | ){ |
| 101356 | WhereTerm *pTerm; |
| 101357 | int k; |
| 101358 | assert( iCur>=0 ); |
| 101359 | op &= WO_ALL; |
| 101360 | for(; pWC; pWC=pWC->pOuter){ |
| 101361 | for(pTerm=pWC->a, k=pWC->nTerm; k; k--, pTerm++){ |
| 101362 | if( pTerm->leftCursor==iCur |
| 101363 | && (pTerm->prereqRight & notReady)==0 |
| 101364 | && pTerm->u.leftColumn==iColumn |
| 101365 | && (pTerm->eOperator & op)!=0 |
| 101366 | ){ |
| 101367 | if( pIdx && pTerm->eOperator!=WO_ISNULL ){ |
| 101368 | Expr *pX = pTerm->pExpr; |
| 101369 | CollSeq *pColl; |
| 101370 | char idxaff; |
| 101371 | int j; |
| 101372 | Parse *pParse = pWC->pParse; |
| 101373 | |
| 101374 | idxaff = pIdx->pTable->aCol[iColumn].affinity; |
| 101375 | if( !sqlite3IndexAffinityOk(pX, idxaff) ) continue; |
| 101376 | |
| 101377 | /* Figure out the collation sequence required from an index for |
| 101378 | ** it to be useful for optimising expression pX. Store this |
| 101379 | ** value in variable pColl. |
| 101380 | */ |
| 101381 | assert(pX->pLeft); |
| 101382 | pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight); |
| 101383 | assert(pColl || pParse->nErr); |
| 101384 | |
| 101385 | for(j=0; pIdx->aiColumn[j]!=iColumn; j++){ |
| 101386 | if( NEVER(j>=pIdx->nColumn) ) return 0; |
| 101387 | } |
| 101388 | if( pColl && sqlite3StrICmp(pColl->zName, pIdx->azColl[j]) ) continue; |
| 101389 | } |
| 101390 | return pTerm; |
| 101391 | } |
| 101392 | } |
| 101393 | } |
| 101394 | return 0; |
| 101395 | } |
| 101396 | |
| @@ -101216,11 +101650,11 @@ | |
| 101650 | assert( pExpr->op==TK_OR ); |
| 101651 | pTerm->u.pOrInfo = pOrInfo = sqlite3DbMallocZero(db, sizeof(*pOrInfo)); |
| 101652 | if( pOrInfo==0 ) return; |
| 101653 | pTerm->wtFlags |= TERM_ORINFO; |
| 101654 | pOrWc = &pOrInfo->wc; |
| 101655 | whereClauseInit(pOrWc, pWC->pParse, pMaskSet, pWC->wctrlFlags); |
| 101656 | whereSplit(pOrWc, pExpr, TK_OR); |
| 101657 | exprAnalyzeAll(pSrc, pOrWc); |
| 101658 | if( db->mallocFailed ) return; |
| 101659 | assert( pOrWc->nTerm>=2 ); |
| 101660 | |
| @@ -101243,13 +101677,14 @@ | |
| 101677 | Bitmask b = 0; |
| 101678 | pOrTerm->u.pAndInfo = pAndInfo; |
| 101679 | pOrTerm->wtFlags |= TERM_ANDINFO; |
| 101680 | pOrTerm->eOperator = WO_AND; |
| 101681 | pAndWC = &pAndInfo->wc; |
| 101682 | whereClauseInit(pAndWC, pWC->pParse, pMaskSet, pWC->wctrlFlags); |
| 101683 | whereSplit(pAndWC, pOrTerm->pExpr, TK_AND); |
| 101684 | exprAnalyzeAll(pSrc, pAndWC); |
| 101685 | pAndWC->pOuter = pWC; |
| 101686 | testcase( db->mallocFailed ); |
| 101687 | if( !db->mallocFailed ){ |
| 101688 | for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){ |
| 101689 | assert( pAndTerm->pExpr ); |
| 101690 | if( allowedOp(pAndTerm->pExpr->op) ){ |
| @@ -101679,12 +102114,12 @@ | |
| 102114 | pNewTerm->prereqAll = pTerm->prereqAll; |
| 102115 | } |
| 102116 | } |
| 102117 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 102118 | |
| 102119 | #ifdef SQLITE_ENABLE_STAT3 |
| 102120 | /* When sqlite_stat3 histogram data is available an operator of the |
| 102121 | ** form "x IS NOT NULL" can sometimes be evaluated more efficiently |
| 102122 | ** as "x>NULL" if x is not an INTEGER PRIMARY KEY. So construct a |
| 102123 | ** virtual term of that form. |
| 102124 | ** |
| 102125 | ** Note that the virtual term must be tagged with TERM_VNULL. This |
| @@ -101718,11 +102153,11 @@ | |
| 102153 | pTerm->nChild = 1; |
| 102154 | pTerm->wtFlags |= TERM_COPIED; |
| 102155 | pNewTerm->prereqAll = pTerm->prereqAll; |
| 102156 | } |
| 102157 | } |
| 102158 | #endif /* SQLITE_ENABLE_STAT */ |
| 102159 | |
| 102160 | /* Prevent ON clause terms of a LEFT JOIN from being used to drive |
| 102161 | ** an index for tables to the left of the join. |
| 102162 | */ |
| 102163 | pTerm->prereqRight |= extraRight; |
| @@ -102140,14 +102575,17 @@ | |
| 102575 | const int iCur = pSrc->iCursor; /* The cursor of the table to be accessed */ |
| 102576 | const Bitmask maskSrc = getMask(pWC->pMaskSet, iCur); /* Bitmask for pSrc */ |
| 102577 | WhereTerm * const pWCEnd = &pWC->a[pWC->nTerm]; /* End of pWC->a[] */ |
| 102578 | WhereTerm *pTerm; /* A single term of the WHERE clause */ |
| 102579 | |
| 102580 | /* The OR-clause optimization is disallowed if the INDEXED BY or |
| 102581 | ** NOT INDEXED clauses are used or if the WHERE_AND_ONLY bit is set. */ |
| 102582 | if( pSrc->notIndexed || pSrc->pIndex!=0 ){ |
| 102583 | return; |
| 102584 | } |
| 102585 | if( pWC->wctrlFlags & WHERE_AND_ONLY ){ |
| 102586 | return; |
| 102587 | } |
| 102588 | |
| 102589 | /* Search the WHERE clause terms for a usable WO_OR term. */ |
| 102590 | for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){ |
| 102591 | if( pTerm->eOperator==WO_OR |
| @@ -102172,10 +102610,11 @@ | |
| 102610 | bestIndex(pParse, pAndWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 102611 | }else if( pOrTerm->leftCursor==iCur ){ |
| 102612 | WhereClause tempWC; |
| 102613 | tempWC.pParse = pWC->pParse; |
| 102614 | tempWC.pMaskSet = pWC->pMaskSet; |
| 102615 | tempWC.pOuter = pWC; |
| 102616 | tempWC.op = TK_AND; |
| 102617 | tempWC.a = pOrTerm; |
| 102618 | tempWC.nTerm = 1; |
| 102619 | bestIndex(pParse, &tempWC, pSrc, notReady, notValid, 0, &sTermCost); |
| 102620 | }else{ |
| @@ -102766,71 +103205,90 @@ | |
| 103205 | */ |
| 103206 | bestOrClauseIndex(pParse, pWC, pSrc, notReady, notValid, pOrderBy, pCost); |
| 103207 | } |
| 103208 | #endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 103209 | |
| 103210 | #ifdef SQLITE_ENABLE_STAT3 |
| 103211 | /* |
| 103212 | ** Estimate the location of a particular key among all keys in an |
| 103213 | ** index. Store the results in aStat as follows: |
| 103214 | ** |
| 103215 | ** aStat[0] Est. number of rows less than pVal |
| 103216 | ** aStat[1] Est. number of rows equal to pVal |
| 103217 | ** |
| 103218 | ** Return SQLITE_OK on success. |
| 103219 | */ |
| 103220 | static int whereKeyStats( |
| 103221 | Parse *pParse, /* Database connection */ |
| 103222 | Index *pIdx, /* Index to consider domain of */ |
| 103223 | sqlite3_value *pVal, /* Value to consider */ |
| 103224 | int roundUp, /* Round up if true. Round down if false */ |
| 103225 | tRowcnt *aStat /* OUT: stats written here */ |
| 103226 | ){ |
| 103227 | tRowcnt n; |
| 103228 | IndexSample *aSample; |
| 103229 | int i, eType; |
| 103230 | int isEq = 0; |
| 103231 | i64 v; |
| 103232 | double r, rS; |
| 103233 | |
| 103234 | assert( roundUp==0 || roundUp==1 ); |
| 103235 | assert( pIdx->nSample>0 ); |
| 103236 | if( pVal==0 ) return SQLITE_ERROR; |
| 103237 | n = pIdx->aiRowEst[0]; |
| 103238 | aSample = pIdx->aSample; |
| 103239 | i = 0; |
| 103240 | eType = sqlite3_value_type(pVal); |
| 103241 | |
| 103242 | if( eType==SQLITE_INTEGER ){ |
| 103243 | v = sqlite3_value_int64(pVal); |
| 103244 | r = (i64)v; |
| 103245 | for(i=0; i<pIdx->nSample; i++){ |
| 103246 | if( aSample[i].eType==SQLITE_NULL ) continue; |
| 103247 | if( aSample[i].eType>=SQLITE_TEXT ) break; |
| 103248 | if( aSample[i].eType==SQLITE_INTEGER ){ |
| 103249 | if( aSample[i].u.i>=v ){ |
| 103250 | isEq = aSample[i].u.i==v; |
| 103251 | break; |
| 103252 | } |
| 103253 | }else{ |
| 103254 | assert( aSample[i].eType==SQLITE_FLOAT ); |
| 103255 | if( aSample[i].u.r>=r ){ |
| 103256 | isEq = aSample[i].u.r==r; |
| 103257 | break; |
| 103258 | } |
| 103259 | } |
| 103260 | } |
| 103261 | }else if( eType==SQLITE_FLOAT ){ |
| 103262 | r = sqlite3_value_double(pVal); |
| 103263 | for(i=0; i<pIdx->nSample; i++){ |
| 103264 | if( aSample[i].eType==SQLITE_NULL ) continue; |
| 103265 | if( aSample[i].eType>=SQLITE_TEXT ) break; |
| 103266 | if( aSample[i].eType==SQLITE_FLOAT ){ |
| 103267 | rS = aSample[i].u.r; |
| 103268 | }else{ |
| 103269 | rS = aSample[i].u.i; |
| 103270 | } |
| 103271 | if( rS>=r ){ |
| 103272 | isEq = rS==r; |
| 103273 | break; |
| 103274 | } |
| 103275 | } |
| 103276 | }else if( eType==SQLITE_NULL ){ |
| 103277 | i = 0; |
| 103278 | if( aSample[0].eType==SQLITE_NULL ) isEq = 1; |
| 103279 | }else{ |
| 103280 | assert( eType==SQLITE_TEXT || eType==SQLITE_BLOB ); |
| 103281 | for(i=0; i<pIdx->nSample; i++){ |
| 103282 | if( aSample[i].eType==SQLITE_TEXT || aSample[i].eType==SQLITE_BLOB ){ |
| 103283 | break; |
| 103284 | } |
| 103285 | } |
| 103286 | if( i<pIdx->nSample ){ |
| 103287 | sqlite3 *db = pParse->db; |
| 103288 | CollSeq *pColl; |
| 103289 | const u8 *z; |
| 103290 | if( eType==SQLITE_BLOB ){ |
| 103291 | z = (const u8 *)sqlite3_value_blob(pVal); |
| 103292 | pColl = db->pDfltColl; |
| 103293 | assert( pColl->enc==SQLITE_UTF8 ); |
| 103294 | }else{ |
| @@ -102845,16 +103303,16 @@ | |
| 103303 | return SQLITE_NOMEM; |
| 103304 | } |
| 103305 | assert( z && pColl && pColl->xCmp ); |
| 103306 | } |
| 103307 | n = sqlite3ValueBytes(pVal, pColl->enc); |
| 103308 | |
| 103309 | for(; i<pIdx->nSample; i++){ |
| 103310 | int c; |
| 103311 | int eSampletype = aSample[i].eType; |
| 103312 | if( eSampletype<eType ) continue; |
| 103313 | if( eSampletype!=eType ) break; |
| 103314 | #ifndef SQLITE_OMIT_UTF16 |
| 103315 | if( pColl->enc!=SQLITE_UTF8 ){ |
| 103316 | int nSample; |
| 103317 | char *zSample = sqlite3Utf8to16( |
| 103318 | db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample |
| @@ -102868,20 +103326,51 @@ | |
| 103326 | }else |
| 103327 | #endif |
| 103328 | { |
| 103329 | c = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z); |
| 103330 | } |
| 103331 | if( c>=0 ){ |
| 103332 | if( c==0 ) isEq = 1; |
| 103333 | break; |
| 103334 | } |
| 103335 | } |
| 103336 | } |
| 103337 | } |
| 103338 | |
| 103339 | /* At this point, aSample[i] is the first sample that is greater than |
| 103340 | ** or equal to pVal. Or if i==pIdx->nSample, then all samples are less |
| 103341 | ** than pVal. If aSample[i]==pVal, then isEq==1. |
| 103342 | */ |
| 103343 | if( isEq ){ |
| 103344 | assert( i<pIdx->nSample ); |
| 103345 | aStat[0] = aSample[i].nLt; |
| 103346 | aStat[1] = aSample[i].nEq; |
| 103347 | }else{ |
| 103348 | tRowcnt iLower, iUpper, iGap; |
| 103349 | if( i==0 ){ |
| 103350 | iLower = 0; |
| 103351 | iUpper = aSample[0].nLt; |
| 103352 | }else{ |
| 103353 | iUpper = i>=pIdx->nSample ? n : aSample[i].nLt; |
| 103354 | iLower = aSample[i-1].nEq + aSample[i-1].nLt; |
| 103355 | } |
| 103356 | aStat[1] = pIdx->avgEq; |
| 103357 | if( iLower>=iUpper ){ |
| 103358 | iGap = 0; |
| 103359 | }else{ |
| 103360 | iGap = iUpper - iLower; |
| 103361 | } |
| 103362 | if( roundUp ){ |
| 103363 | iGap = (iGap*2)/3; |
| 103364 | }else{ |
| 103365 | iGap = iGap/3; |
| 103366 | } |
| 103367 | aStat[0] = iLower + iGap; |
| 103368 | } |
| 103369 | return SQLITE_OK; |
| 103370 | } |
| 103371 | #endif /* SQLITE_ENABLE_STAT3 */ |
| 103372 | |
| 103373 | /* |
| 103374 | ** If expression pExpr represents a literal value, set *pp to point to |
| 103375 | ** an sqlite3_value structure containing the same value, with affinity |
| 103376 | ** aff applied to it, before returning. It is the responsibility of the |
| @@ -102895,11 +103384,11 @@ | |
| 103384 | ** |
| 103385 | ** If neither of the above apply, set *pp to NULL. |
| 103386 | ** |
| 103387 | ** If an error occurs, return an error code. Otherwise, SQLITE_OK. |
| 103388 | */ |
| 103389 | #ifdef SQLITE_ENABLE_STAT3 |
| 103390 | static int valueFromExpr( |
| 103391 | Parse *pParse, |
| 103392 | Expr *pExpr, |
| 103393 | u8 aff, |
| 103394 | sqlite3_value **pp |
| @@ -102943,106 +103432,92 @@ | |
| 103432 | ** |
| 103433 | ** ... FROM t1 WHERE a > ? AND a < ? ... |
| 103434 | ** |
| 103435 | ** then nEq should be passed 0. |
| 103436 | ** |
| 103437 | ** The returned value is an integer divisor to reduce the estimated |
| 103438 | ** search space. A return value of 1 means that range constraints are |
| 103439 | ** no help at all. A return value of 2 means range constraints are |
| 103440 | ** expected to reduce the search space by half. And so forth... |
| 103441 | ** |
| 103442 | ** In the absence of sqlite_stat3 ANALYZE data, each range inequality |
| 103443 | ** reduces the search space by a factor of 4. Hence a single constraint (x>?) |
| 103444 | ** results in a return of 4 and a range constraint (x>? AND x<?) results |
| 103445 | ** in a return of 16. |
| 103446 | */ |
| 103447 | static int whereRangeScanEst( |
| 103448 | Parse *pParse, /* Parsing & code generating context */ |
| 103449 | Index *p, /* The index containing the range-compared column; "x" */ |
| 103450 | int nEq, /* index into p->aCol[] of the range-compared column */ |
| 103451 | WhereTerm *pLower, /* Lower bound on the range. ex: "x>123" Might be NULL */ |
| 103452 | WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */ |
| 103453 | double *pRangeDiv /* OUT: Reduce search space by this divisor */ |
| 103454 | ){ |
| 103455 | int rc = SQLITE_OK; |
| 103456 | |
| 103457 | #ifdef SQLITE_ENABLE_STAT3 |
| 103458 | |
| 103459 | if( nEq==0 && p->nSample ){ |
| 103460 | sqlite3_value *pRangeVal; |
| 103461 | tRowcnt iLower = 0; |
| 103462 | tRowcnt iUpper = p->aiRowEst[0]; |
| 103463 | tRowcnt a[2]; |
| 103464 | u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity; |
| 103465 | |
| 103466 | if( pLower ){ |
| 103467 | Expr *pExpr = pLower->pExpr->pRight; |
| 103468 | rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal); |
| 103469 | assert( pLower->eOperator==WO_GT || pLower->eOperator==WO_GE ); |
| 103470 | if( rc==SQLITE_OK |
| 103471 | && whereKeyStats(pParse, p, pRangeVal, 0, a)==SQLITE_OK |
| 103472 | ){ |
| 103473 | iLower = a[0]; |
| 103474 | if( pLower->eOperator==WO_GT ) iLower += a[1]; |
| 103475 | } |
| 103476 | sqlite3ValueFree(pRangeVal); |
| 103477 | } |
| 103478 | if( rc==SQLITE_OK && pUpper ){ |
| 103479 | Expr *pExpr = pUpper->pExpr->pRight; |
| 103480 | rc = valueFromExpr(pParse, pExpr, aff, &pRangeVal); |
| 103481 | assert( pUpper->eOperator==WO_LT || pUpper->eOperator==WO_LE ); |
| 103482 | if( rc==SQLITE_OK |
| 103483 | && whereKeyStats(pParse, p, pRangeVal, 1, a)==SQLITE_OK |
| 103484 | ){ |
| 103485 | iUpper = a[0]; |
| 103486 | if( pUpper->eOperator==WO_LE ) iUpper += a[1]; |
| 103487 | } |
| 103488 | sqlite3ValueFree(pRangeVal); |
| 103489 | } |
| 103490 | if( rc==SQLITE_OK ){ |
| 103491 | if( iUpper<=iLower ){ |
| 103492 | *pRangeDiv = (double)p->aiRowEst[0]; |
| 103493 | }else{ |
| 103494 | *pRangeDiv = (double)p->aiRowEst[0]/(double)(iUpper - iLower); |
| 103495 | } |
| 103496 | WHERETRACE(("range scan regions: %u..%u div=%g\n", |
| 103497 | (u32)iLower, (u32)iUpper, *pRangeDiv)); |
| 103498 | return SQLITE_OK; |
| 103499 | } |
| 103500 | } |
| 103501 | #else |
| 103502 | UNUSED_PARAMETER(pParse); |
| 103503 | UNUSED_PARAMETER(p); |
| 103504 | UNUSED_PARAMETER(nEq); |
| 103505 | #endif |
| 103506 | assert( pLower || pUpper ); |
| 103507 | *pRangeDiv = (double)1; |
| 103508 | if( pLower && (pLower->wtFlags & TERM_VNULL)==0 ) *pRangeDiv *= (double)4; |
| 103509 | if( pUpper ) *pRangeDiv *= (double)4; |
| 103510 | return rc; |
| 103511 | } |
| 103512 | |
| 103513 | #ifdef SQLITE_ENABLE_STAT3 |
| 103514 | /* |
| 103515 | ** Estimate the number of rows that will be returned based on |
| 103516 | ** an equality constraint x=VALUE and where that VALUE occurs in |
| 103517 | ** the histogram data. This only works when x is the left-most |
| 103518 | ** column of an index and sqlite_stat3 histogram data is available |
| 103519 | ** for that index. When pExpr==NULL that means the constraint is |
| 103520 | ** "x IS NULL" instead of "x=VALUE". |
| 103521 | ** |
| 103522 | ** Write the estimated row count into *pnRow and return SQLITE_OK. |
| 103523 | ** If unable to make an estimate, leave *pnRow unchanged and return |
| @@ -103058,44 +103533,36 @@ | |
| 103533 | Index *p, /* The index whose left-most column is pTerm */ |
| 103534 | Expr *pExpr, /* Expression for VALUE in the x=VALUE constraint */ |
| 103535 | double *pnRow /* Write the revised row estimate here */ |
| 103536 | ){ |
| 103537 | sqlite3_value *pRhs = 0; /* VALUE on right-hand side of pTerm */ |
| 103538 | u8 aff; /* Column affinity */ |
| 103539 | int rc; /* Subfunction return code */ |
| 103540 | tRowcnt a[2]; /* Statistics */ |
| 103541 | |
| 103542 | assert( p->aSample!=0 ); |
| 103543 | assert( p->nSample>0 ); |
| 103544 | aff = p->pTable->aCol[p->aiColumn[0]].affinity; |
| 103545 | if( pExpr ){ |
| 103546 | rc = valueFromExpr(pParse, pExpr, aff, &pRhs); |
| 103547 | if( rc ) goto whereEqualScanEst_cancel; |
| 103548 | }else{ |
| 103549 | pRhs = sqlite3ValueNew(pParse->db); |
| 103550 | } |
| 103551 | if( pRhs==0 ) return SQLITE_NOTFOUND; |
| 103552 | rc = whereKeyStats(pParse, p, pRhs, 0, a); |
| 103553 | if( rc==SQLITE_OK ){ |
| 103554 | WHERETRACE(("equality scan regions: %d\n", (int)a[1])); |
| 103555 | *pnRow = a[1]; |
| 103556 | } |
| 103557 | whereEqualScanEst_cancel: |
| 103558 | sqlite3ValueFree(pRhs); |
| 103559 | return rc; |
| 103560 | } |
| 103561 | #endif /* defined(SQLITE_ENABLE_STAT3) */ |
| 103562 | |
| 103563 | #ifdef SQLITE_ENABLE_STAT3 |
| 103564 | /* |
| 103565 | ** Estimate the number of rows that will be returned based on |
| 103566 | ** an IN constraint where the right-hand side of the IN operator |
| 103567 | ** is a list of values. Example: |
| 103568 | ** |
| @@ -103114,64 +103581,29 @@ | |
| 103581 | Parse *pParse, /* Parsing & code generating context */ |
| 103582 | Index *p, /* The index whose left-most column is pTerm */ |
| 103583 | ExprList *pList, /* The value list on the RHS of "x IN (v1,v2,v3,...)" */ |
| 103584 | double *pnRow /* Write the revised row estimate here */ |
| 103585 | ){ |
| 103586 | int rc = SQLITE_OK; /* Subfunction return code */ |
| 103587 | double nEst; /* Number of rows for a single term */ |
| 103588 | double nRowEst = (double)0; /* New estimate of the number of rows */ |
| 103589 | int i; /* Loop counter */ |
| 103590 | |
| 103591 | assert( p->aSample!=0 ); |
| 103592 | for(i=0; rc==SQLITE_OK && i<pList->nExpr; i++){ |
| 103593 | nEst = p->aiRowEst[0]; |
| 103594 | rc = whereEqualScanEst(pParse, p, pList->a[i].pExpr, &nEst); |
| 103595 | nRowEst += nEst; |
| 103596 | } |
| 103597 | if( rc==SQLITE_OK ){ |
| 103598 | if( nRowEst > p->aiRowEst[0] ) nRowEst = p->aiRowEst[0]; |
| 103599 | *pnRow = nRowEst; |
| 103600 | WHERETRACE(("IN row estimate: est=%g\n", nRowEst)); |
| 103601 | } |
| 103602 | return rc; |
| 103603 | } |
| 103604 | #endif /* defined(SQLITE_ENABLE_STAT3) */ |
| 103605 | |
| 103606 | |
| 103607 | /* |
| 103608 | ** Find the best query plan for accessing a particular table. Write the |
| 103609 | ** best query plan and its cost into the WhereCost object supplied as the |
| @@ -103214,11 +103646,11 @@ | |
| 103646 | Index *pProbe; /* An index we are evaluating */ |
| 103647 | Index *pIdx; /* Copy of pProbe, or zero for IPK index */ |
| 103648 | int eqTermMask; /* Current mask of valid equality operators */ |
| 103649 | int idxEqTermMask; /* Index mask of valid equality operators */ |
| 103650 | Index sPk; /* A fake index object for the primary key */ |
| 103651 | tRowcnt aiRowEstPk[2]; /* The aiRowEst[] value for the sPk index */ |
| 103652 | int aiColumnPk = -1; /* The aColumn[] value for the sPk index */ |
| 103653 | int wsFlagMask; /* Allowed flags in pCost->plan.wsFlag */ |
| 103654 | |
| 103655 | /* Initialize the cost to a worst-case value */ |
| 103656 | memset(pCost, 0, sizeof(*pCost)); |
| @@ -103269,14 +103701,14 @@ | |
| 103701 | } |
| 103702 | |
| 103703 | /* Loop over all indices looking for the best one to use |
| 103704 | */ |
| 103705 | for(; pProbe; pIdx=pProbe=pProbe->pNext){ |
| 103706 | const tRowcnt * const aiRowEst = pProbe->aiRowEst; |
| 103707 | double cost; /* Cost of using pProbe */ |
| 103708 | double nRow; /* Estimated number of rows in result set */ |
| 103709 | double log10N = (double)1; /* base-10 logarithm of nRow (inexact) */ |
| 103710 | int rev; /* True to scan in reverse order */ |
| 103711 | int wsFlags = 0; |
| 103712 | Bitmask used = 0; |
| 103713 | |
| 103714 | /* The following variables are populated based on the properties of |
| @@ -103312,18 +103744,16 @@ | |
| 103744 | ** Set to true if there was at least one "x IN (SELECT ...)" term used |
| 103745 | ** in determining the value of nInMul. Note that the RHS of the |
| 103746 | ** IN operator must be a SELECT, not a value list, for this variable |
| 103747 | ** to be true. |
| 103748 | ** |
| 103749 | ** rangeDiv: |
| 103750 | ** An estimate of a divisor by which to reduce the search space due |
| 103751 | ** to inequality constraints. In the absence of sqlite_stat3 ANALYZE |
| 103752 | ** data, a single inequality reduces the search space to 1/4rd its |
| 103753 | ** original size (rangeDiv==4). Two inequalities reduce the search |
| 103754 | ** space to 1/16th of its original size (rangeDiv==16). |
| 103755 | ** |
| 103756 | ** bSort: |
| 103757 | ** Boolean. True if there is an ORDER BY clause that will require an |
| 103758 | ** external sort (i.e. scanning the index being evaluated will not |
| 103759 | ** correctly order records). |
| @@ -103344,26 +103774,27 @@ | |
| 103774 | ** SELECT a, b, c FROM tbl WHERE a = 1; |
| 103775 | */ |
| 103776 | int nEq; /* Number of == or IN terms matching index */ |
| 103777 | int bInEst = 0; /* True if "x IN (SELECT...)" seen */ |
| 103778 | int nInMul = 1; /* Number of distinct equalities to lookup */ |
| 103779 | double rangeDiv = (double)1; /* Estimated reduction in search space */ |
| 103780 | int nBound = 0; /* Number of range constraints seen */ |
| 103781 | int bSort = !!pOrderBy; /* True if external sort required */ |
| 103782 | int bDist = !!pDistinct; /* True if index cannot help with DISTINCT */ |
| 103783 | int bLookup = 0; /* True if not a covering index */ |
| 103784 | WhereTerm *pTerm; /* A single term of the WHERE clause */ |
| 103785 | #ifdef SQLITE_ENABLE_STAT3 |
| 103786 | WhereTerm *pFirstTerm = 0; /* First term matching the index */ |
| 103787 | #endif |
| 103788 | |
| 103789 | /* Determine the values of nEq and nInMul */ |
| 103790 | for(nEq=0; nEq<pProbe->nColumn; nEq++){ |
| 103791 | int j = pProbe->aiColumn[nEq]; |
| 103792 | pTerm = findTerm(pWC, iCur, j, notReady, eqTermMask, pIdx); |
| 103793 | if( pTerm==0 ) break; |
| 103794 | wsFlags |= (WHERE_COLUMN_EQ|WHERE_ROWID_EQ); |
| 103795 | testcase( pTerm->pWC!=pWC ); |
| 103796 | if( pTerm->eOperator & WO_IN ){ |
| 103797 | Expr *pExpr = pTerm->pExpr; |
| 103798 | wsFlags |= WHERE_COLUMN_IN; |
| 103799 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 103800 | /* "x IN (SELECT ...)": Assume the SELECT returns 25 rows */ |
| @@ -103374,32 +103805,34 @@ | |
| 103805 | nInMul *= pExpr->x.pList->nExpr; |
| 103806 | } |
| 103807 | }else if( pTerm->eOperator & WO_ISNULL ){ |
| 103808 | wsFlags |= WHERE_COLUMN_NULL; |
| 103809 | } |
| 103810 | #ifdef SQLITE_ENABLE_STAT3 |
| 103811 | if( nEq==0 && pProbe->aSample ) pFirstTerm = pTerm; |
| 103812 | #endif |
| 103813 | used |= pTerm->prereqRight; |
| 103814 | } |
| 103815 | |
| 103816 | /* Determine the value of rangeDiv */ |
| 103817 | if( nEq<pProbe->nColumn && pProbe->bUnordered==0 ){ |
| 103818 | int j = pProbe->aiColumn[nEq]; |
| 103819 | if( findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE|WO_GT|WO_GE, pIdx) ){ |
| 103820 | WhereTerm *pTop = findTerm(pWC, iCur, j, notReady, WO_LT|WO_LE, pIdx); |
| 103821 | WhereTerm *pBtm = findTerm(pWC, iCur, j, notReady, WO_GT|WO_GE, pIdx); |
| 103822 | whereRangeScanEst(pParse, pProbe, nEq, pBtm, pTop, &rangeDiv); |
| 103823 | if( pTop ){ |
| 103824 | nBound = 1; |
| 103825 | wsFlags |= WHERE_TOP_LIMIT; |
| 103826 | used |= pTop->prereqRight; |
| 103827 | testcase( pTop->pWC!=pWC ); |
| 103828 | } |
| 103829 | if( pBtm ){ |
| 103830 | nBound++; |
| 103831 | wsFlags |= WHERE_BTM_LIMIT; |
| 103832 | used |= pBtm->prereqRight; |
| 103833 | testcase( pBtm->pWC!=pWC ); |
| 103834 | } |
| 103835 | wsFlags |= (WHERE_COLUMN_RANGE|WHERE_ROWID_RANGE); |
| 103836 | } |
| 103837 | }else if( pProbe->onError!=OE_None ){ |
| 103838 | testcase( wsFlags & WHERE_COLUMN_IN ); |
| @@ -103458,32 +103891,34 @@ | |
| 103891 | if( bInEst && nRow*2>aiRowEst[0] ){ |
| 103892 | nRow = aiRowEst[0]/2; |
| 103893 | nInMul = (int)(nRow / aiRowEst[nEq]); |
| 103894 | } |
| 103895 | |
| 103896 | #ifdef SQLITE_ENABLE_STAT3 |
| 103897 | /* If the constraint is of the form x=VALUE or x IN (E1,E2,...) |
| 103898 | ** and we do not think that values of x are unique and if histogram |
| 103899 | ** data is available for column x, then it might be possible |
| 103900 | ** to get a better estimate on the number of rows based on |
| 103901 | ** VALUE and how common that value is according to the histogram. |
| 103902 | */ |
| 103903 | if( nRow>(double)1 && nEq==1 && pFirstTerm!=0 && aiRowEst[1]>1 ){ |
| 103904 | assert( (pFirstTerm->eOperator & (WO_EQ|WO_ISNULL|WO_IN))!=0 ); |
| 103905 | if( pFirstTerm->eOperator & (WO_EQ|WO_ISNULL) ){ |
| 103906 | testcase( pFirstTerm->eOperator==WO_EQ ); |
| 103907 | testcase( pFirstTerm->eOperator==WO_ISNULL ); |
| 103908 | whereEqualScanEst(pParse, pProbe, pFirstTerm->pExpr->pRight, &nRow); |
| 103909 | }else if( bInEst==0 ){ |
| 103910 | assert( pFirstTerm->eOperator==WO_IN ); |
| 103911 | whereInScanEst(pParse, pProbe, pFirstTerm->pExpr->x.pList, &nRow); |
| 103912 | } |
| 103913 | } |
| 103914 | #endif /* SQLITE_ENABLE_STAT3 */ |
| 103915 | |
| 103916 | /* Adjust the number of output rows and downward to reflect rows |
| 103917 | ** that are excluded by range constraints. |
| 103918 | */ |
| 103919 | nRow = nRow/rangeDiv; |
| 103920 | if( nRow<1 ) nRow = 1; |
| 103921 | |
| 103922 | /* Experiments run on real SQLite databases show that the time needed |
| 103923 | ** to do a binary search to locate a row in a table or index is roughly |
| 103924 | ** log10(N) times the time to move from one row to the next row within |
| @@ -103608,14 +104043,14 @@ | |
| 104043 | if( nRow<2 ) nRow = 2; |
| 104044 | } |
| 104045 | |
| 104046 | |
| 104047 | WHERETRACE(( |
| 104048 | "%s(%s): nEq=%d nInMul=%d rangeDiv=%d bSort=%d bLookup=%d wsFlags=0x%x\n" |
| 104049 | " notReady=0x%llx log10N=%.1f nRow=%.1f cost=%.1f used=0x%llx\n", |
| 104050 | pSrc->pTab->zName, (pIdx ? pIdx->zName : "ipk"), |
| 104051 | nEq, nInMul, (int)rangeDiv, bSort, bLookup, wsFlags, |
| 104052 | notReady, log10N, nRow, cost, used |
| 104053 | )); |
| 104054 | |
| 104055 | /* If this index is the best we have seen so far, then record this |
| 104056 | ** index and its cost in the pCost structure. |
| @@ -104115,11 +104550,12 @@ | |
| 104550 | */ |
| 104551 | static Bitmask codeOneLoopStart( |
| 104552 | WhereInfo *pWInfo, /* Complete information about the WHERE clause */ |
| 104553 | int iLevel, /* Which level of pWInfo->a[] should be coded */ |
| 104554 | u16 wctrlFlags, /* One of the WHERE_* flags defined in sqliteInt.h */ |
| 104555 | Bitmask notReady, /* Which tables are currently available */ |
| 104556 | Expr *pWhere /* Complete WHERE clause */ |
| 104557 | ){ |
| 104558 | int j, k; /* Loop counters */ |
| 104559 | int iCur; /* The VDBE cursor for the table */ |
| 104560 | int addrNxt; /* Where to jump to continue with the next IN case */ |
| 104561 | int omitTable; /* True if we use the index only */ |
| @@ -104597,11 +105033,12 @@ | |
| 105033 | int regRowset = 0; /* Register for RowSet object */ |
| 105034 | int regRowid = 0; /* Register holding rowid */ |
| 105035 | int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */ |
| 105036 | int iRetInit; /* Address of regReturn init */ |
| 105037 | int untestedTerms = 0; /* Some terms not completely tested */ |
| 105038 | int ii; /* Loop counter */ |
| 105039 | Expr *pAndExpr = 0; /* An ".. AND (...)" expression */ |
| 105040 | |
| 105041 | pTerm = pLevel->plan.u.pTerm; |
| 105042 | assert( pTerm!=0 ); |
| 105043 | assert( pTerm->eOperator==WO_OR ); |
| 105044 | assert( (pTerm->wtFlags & TERM_ORINFO)!=0 ); |
| @@ -104646,18 +105083,33 @@ | |
| 105083 | regRowset = ++pParse->nMem; |
| 105084 | regRowid = ++pParse->nMem; |
| 105085 | sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); |
| 105086 | } |
| 105087 | iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn); |
| 105088 | |
| 105089 | /* If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y |
| 105090 | ** Then for every term xN, evaluate as the subexpression: xN AND z |
| 105091 | ** That way, terms in y that are factored into the disjunction will |
| 105092 | ** be picked up by the recursive calls to sqlite3WhereBegin() below. |
| 105093 | */ |
| 105094 | if( pWC->nTerm>1 ){ |
| 105095 | pAndExpr = sqlite3ExprAlloc(pParse->db, TK_AND, 0, 0); |
| 105096 | pAndExpr->pRight = pWhere; |
| 105097 | } |
| 105098 | |
| 105099 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 105100 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 105101 | if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){ |
| 105102 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 105103 | Expr *pOrExpr = pOrTerm->pExpr; |
| 105104 | if( pAndExpr ){ |
| 105105 | pAndExpr->pLeft = pOrExpr; |
| 105106 | pOrExpr = pAndExpr; |
| 105107 | } |
| 105108 | /* Loop through table entries that match term pOrTerm. */ |
| 105109 | pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, |
| 105110 | WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY | |
| 105111 | WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY); |
| 105112 | if( pSubWInfo ){ |
| 105113 | explainOneScan( |
| 105114 | pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0 |
| 105115 | ); |
| @@ -104681,10 +105133,11 @@ | |
| 105133 | /* Finish the loop through table entries that match term pOrTerm. */ |
| 105134 | sqlite3WhereEnd(pSubWInfo); |
| 105135 | } |
| 105136 | } |
| 105137 | } |
| 105138 | sqlite3DbFree(pParse->db, pAndExpr); |
| 105139 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 105140 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); |
| 105141 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 105142 | |
| 105143 | if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab); |
| @@ -104962,11 +105415,11 @@ | |
| 105415 | |
| 105416 | /* Split the WHERE clause into separate subexpressions where each |
| 105417 | ** subexpression is separated by an AND operator. |
| 105418 | */ |
| 105419 | initMaskSet(pMaskSet); |
| 105420 | whereClauseInit(pWC, pParse, pMaskSet, wctrlFlags); |
| 105421 | sqlite3ExprCodeConstants(pParse, pWhere); |
| 105422 | whereSplit(pWC, pWhere, TK_AND); /* IMP: R-15842-53296 */ |
| 105423 | |
| 105424 | /* Special case: a WHERE clause that is constant. Evaluate the |
| 105425 | ** expression and either jump over all of the code or fall thru. |
| @@ -105290,11 +105743,11 @@ | |
| 105743 | int iCur = pTabItem->iCursor; |
| 105744 | sqlite3VdbeAddOp4(v, OP_VOpen, iCur, 0, 0, pVTab, P4_VTAB); |
| 105745 | }else |
| 105746 | #endif |
| 105747 | if( (pLevel->plan.wsFlags & WHERE_IDX_ONLY)==0 |
| 105748 | && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){ |
| 105749 | int op = pWInfo->okOnePass ? OP_OpenWrite : OP_OpenRead; |
| 105750 | sqlite3OpenTable(pParse, pTabItem->iCursor, iDb, pTab, op); |
| 105751 | testcase( pTab->nCol==BMS-1 ); |
| 105752 | testcase( pTab->nCol==BMS ); |
| 105753 | if( !pWInfo->okOnePass && pTab->nCol<BMS ){ |
| @@ -105335,11 +105788,11 @@ | |
| 105788 | */ |
| 105789 | notReady = ~(Bitmask)0; |
| 105790 | for(i=0; i<nTabList; i++){ |
| 105791 | pLevel = &pWInfo->a[i]; |
| 105792 | explainOneScan(pParse, pTabList, pLevel, i, pLevel->iFrom, wctrlFlags); |
| 105793 | notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady, pWhere); |
| 105794 | pWInfo->iContinue = pLevel->addrCont; |
| 105795 | } |
| 105796 | |
| 105797 | #ifdef SQLITE_TEST /* For testing and debugging use only */ |
| 105798 | /* Record in the query plan information about the current table |
| @@ -105470,11 +105923,11 @@ | |
| 105923 | struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom]; |
| 105924 | Table *pTab = pTabItem->pTab; |
| 105925 | assert( pTab!=0 ); |
| 105926 | if( (pTab->tabFlags & TF_Ephemeral)==0 |
| 105927 | && pTab->pSelect==0 |
| 105928 | && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 |
| 105929 | ){ |
| 105930 | int ws = pLevel->plan.wsFlags; |
| 105931 | if( !pWInfo->okOnePass && (ws & WHERE_IDX_ONLY)==0 ){ |
| 105932 | sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor); |
| 105933 | } |
| @@ -105531,10 +105984,11 @@ | |
| 105984 | return; |
| 105985 | } |
| 105986 | |
| 105987 | /************** End of where.c ***********************************************/ |
| 105988 | /************** Begin file parse.c *******************************************/ |
| 105989 | #line 1 "tsrc/parse.c" |
| 105990 | /* Driver template for the LEMON parser generator. |
| 105991 | ** The author disclaims copyright to this source code. |
| 105992 | ** |
| 105993 | ** This version of "lempar.c" is modified, slightly, for use by SQLite. |
| 105994 | ** The only modifications are the addition of a couple of NEVER() |
| @@ -105543,10 +105997,11 @@ | |
| 105997 | ** specific grammar used by SQLite. |
| 105998 | */ |
| 105999 | /* First off, code is included that follows the "include" declaration |
| 106000 | ** in the input grammar file. */ |
| 106001 | /* #include <stdio.h> */ |
| 106002 | #line 51 "parse.y" |
| 106003 | |
| 106004 | |
| 106005 | /* |
| 106006 | ** Disable all error recovery processing in the parser push-down |
| 106007 | ** automaton. |
| @@ -105590,10 +106045,11 @@ | |
| 106045 | /* |
| 106046 | ** An instance of this structure holds the ATTACH key and the key type. |
| 106047 | */ |
| 106048 | struct AttachKey { int type; Token key; }; |
| 106049 | |
| 106050 | #line 722 "parse.y" |
| 106051 | |
| 106052 | /* This is a utility routine used to set the ExprSpan.zStart and |
| 106053 | ** ExprSpan.zEnd values of pOut so that the span covers the complete |
| 106054 | ** range of text beginning with pStart and going to the end of pEnd. |
| 106055 | */ |
| @@ -105609,10 +106065,11 @@ | |
| 106065 | static void spanExpr(ExprSpan *pOut, Parse *pParse, int op, Token *pValue){ |
| 106066 | pOut->pExpr = sqlite3PExpr(pParse, op, 0, 0, pValue); |
| 106067 | pOut->zStart = pValue->z; |
| 106068 | pOut->zEnd = &pValue->z[pValue->n]; |
| 106069 | } |
| 106070 | #line 817 "parse.y" |
| 106071 | |
| 106072 | /* This routine constructs a binary expression node out of two ExprSpan |
| 106073 | ** objects and uses the result to populate a new ExprSpan object. |
| 106074 | */ |
| 106075 | static void spanBinaryExpr( |
| @@ -105624,10 +106081,11 @@ | |
| 106081 | ){ |
| 106082 | pOut->pExpr = sqlite3PExpr(pParse, op, pLeft->pExpr, pRight->pExpr, 0); |
| 106083 | pOut->zStart = pLeft->zStart; |
| 106084 | pOut->zEnd = pRight->zEnd; |
| 106085 | } |
| 106086 | #line 873 "parse.y" |
| 106087 | |
| 106088 | /* Construct an expression node for a unary postfix operator |
| 106089 | */ |
| 106090 | static void spanUnaryPostfix( |
| 106091 | ExprSpan *pOut, /* Write the new expression node here */ |
| @@ -105638,10 +106096,11 @@ | |
| 106096 | ){ |
| 106097 | pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0); |
| 106098 | pOut->zStart = pOperand->zStart; |
| 106099 | pOut->zEnd = &pPostOp->z[pPostOp->n]; |
| 106100 | } |
| 106101 | #line 892 "parse.y" |
| 106102 | |
| 106103 | /* A routine to convert a binary TK_IS or TK_ISNOT expression into a |
| 106104 | ** unary TK_ISNULL or TK_NOTNULL expression. */ |
| 106105 | static void binaryToUnaryIfNull(Parse *pParse, Expr *pY, Expr *pA, int op){ |
| 106106 | sqlite3 *db = pParse->db; |
| @@ -105649,10 +106108,11 @@ | |
| 106108 | pA->op = (u8)op; |
| 106109 | sqlite3ExprDelete(db, pA->pRight); |
| 106110 | pA->pRight = 0; |
| 106111 | } |
| 106112 | } |
| 106113 | #line 920 "parse.y" |
| 106114 | |
| 106115 | /* Construct an expression node for a unary prefix operator |
| 106116 | */ |
| 106117 | static void spanUnaryPrefix( |
| 106118 | ExprSpan *pOut, /* Write the new expression node here */ |
| @@ -105663,10 +106123,11 @@ | |
| 106123 | ){ |
| 106124 | pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0); |
| 106125 | pOut->zStart = pPreOp->z; |
| 106126 | pOut->zEnd = pOperand->zEnd; |
| 106127 | } |
| 106128 | #line 141 "parse.c" |
| 106129 | /* Next is all token values, in a form suitable for use by makeheaders. |
| 106130 | ** This section will be null unless lemon is run with the -m switch. |
| 106131 | */ |
| 106132 | /* |
| 106133 | ** These constants (all generated automatically by the parser generator) |
| @@ -106918,17 +107379,21 @@ | |
| 107379 | ** inside the C code. |
| 107380 | */ |
| 107381 | case 160: /* select */ |
| 107382 | case 194: /* oneselect */ |
| 107383 | { |
| 107384 | #line 403 "parse.y" |
| 107385 | sqlite3SelectDelete(pParse->db, (yypminor->yy387)); |
| 107386 | #line 1399 "parse.c" |
| 107387 | } |
| 107388 | break; |
| 107389 | case 174: /* term */ |
| 107390 | case 175: /* expr */ |
| 107391 | { |
| 107392 | #line 720 "parse.y" |
| 107393 | sqlite3ExprDelete(pParse->db, (yypminor->yy118).pExpr); |
| 107394 | #line 1407 "parse.c" |
| 107395 | } |
| 107396 | break; |
| 107397 | case 179: /* idxlist_opt */ |
| 107398 | case 187: /* idxlist */ |
| 107399 | case 197: /* selcollist */ |
| @@ -106940,19 +107405,23 @@ | |
| 107405 | case 217: /* setlist */ |
| 107406 | case 220: /* itemlist */ |
| 107407 | case 221: /* exprlist */ |
| 107408 | case 226: /* case_exprlist */ |
| 107409 | { |
| 107410 | #line 1103 "parse.y" |
| 107411 | sqlite3ExprListDelete(pParse->db, (yypminor->yy322)); |
| 107412 | #line 1425 "parse.c" |
| 107413 | } |
| 107414 | break; |
| 107415 | case 193: /* fullname */ |
| 107416 | case 198: /* from */ |
| 107417 | case 206: /* seltablist */ |
| 107418 | case 207: /* stl_prefix */ |
| 107419 | { |
| 107420 | #line 534 "parse.y" |
| 107421 | sqlite3SrcListDelete(pParse->db, (yypminor->yy259)); |
| 107422 | #line 1435 "parse.c" |
| 107423 | } |
| 107424 | break; |
| 107425 | case 199: /* where_opt */ |
| 107426 | case 201: /* having_opt */ |
| 107427 | case 210: /* on_opt */ |
| @@ -106960,29 +107429,37 @@ | |
| 107429 | case 225: /* case_operand */ |
| 107430 | case 227: /* case_else */ |
| 107431 | case 238: /* when_clause */ |
| 107432 | case 243: /* key_opt */ |
| 107433 | { |
| 107434 | #line 644 "parse.y" |
| 107435 | sqlite3ExprDelete(pParse->db, (yypminor->yy314)); |
| 107436 | #line 1449 "parse.c" |
| 107437 | } |
| 107438 | break; |
| 107439 | case 211: /* using_opt */ |
| 107440 | case 213: /* inscollist */ |
| 107441 | case 219: /* inscollist_opt */ |
| 107442 | { |
| 107443 | #line 566 "parse.y" |
| 107444 | sqlite3IdListDelete(pParse->db, (yypminor->yy384)); |
| 107445 | #line 1458 "parse.c" |
| 107446 | } |
| 107447 | break; |
| 107448 | case 234: /* trigger_cmd_list */ |
| 107449 | case 239: /* trigger_cmd */ |
| 107450 | { |
| 107451 | #line 1210 "parse.y" |
| 107452 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy203)); |
| 107453 | #line 1466 "parse.c" |
| 107454 | } |
| 107455 | break; |
| 107456 | case 236: /* trigger_event */ |
| 107457 | { |
| 107458 | #line 1196 "parse.y" |
| 107459 | sqlite3IdListDelete(pParse->db, (yypminor->yy90).b); |
| 107460 | #line 1473 "parse.c" |
| 107461 | } |
| 107462 | break; |
| 107463 | default: break; /* If no destructor action specified: do nothing */ |
| 107464 | } |
| 107465 | } |
| @@ -107164,14 +107641,16 @@ | |
| 107641 | } |
| 107642 | #endif |
| 107643 | while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 107644 | /* Here code is inserted which will execute if the parser |
| 107645 | ** stack every overflows */ |
| 107646 | #line 38 "parse.y" |
| 107647 | |
| 107648 | UNUSED_PARAMETER(yypMinor); /* Silence some compiler warnings */ |
| 107649 | sqlite3ErrorMsg(pParse, "parser stack overflow"); |
| 107650 | pParse->parseError = 1; |
| 107651 | #line 1664 "parse.c" |
| 107652 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ |
| 107653 | } |
| 107654 | |
| 107655 | /* |
| 107656 | ** Perform a shift action. |
| @@ -107608,66 +108087,94 @@ | |
| 108087 | ** { ... } // User supplied code |
| 108088 | ** #line <lineno> <thisfile> |
| 108089 | ** break; |
| 108090 | */ |
| 108091 | case 5: /* explain ::= */ |
| 108092 | #line 107 "parse.y" |
| 108093 | { sqlite3BeginParse(pParse, 0); } |
| 108094 | #line 2107 "parse.c" |
| 108095 | break; |
| 108096 | case 6: /* explain ::= EXPLAIN */ |
| 108097 | #line 109 "parse.y" |
| 108098 | { sqlite3BeginParse(pParse, 1); } |
| 108099 | #line 2112 "parse.c" |
| 108100 | break; |
| 108101 | case 7: /* explain ::= EXPLAIN QUERY PLAN */ |
| 108102 | #line 110 "parse.y" |
| 108103 | { sqlite3BeginParse(pParse, 2); } |
| 108104 | #line 2117 "parse.c" |
| 108105 | break; |
| 108106 | case 8: /* cmdx ::= cmd */ |
| 108107 | #line 112 "parse.y" |
| 108108 | { sqlite3FinishCoding(pParse); } |
| 108109 | #line 2122 "parse.c" |
| 108110 | break; |
| 108111 | case 9: /* cmd ::= BEGIN transtype trans_opt */ |
| 108112 | #line 117 "parse.y" |
| 108113 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy4);} |
| 108114 | #line 2127 "parse.c" |
| 108115 | break; |
| 108116 | case 13: /* transtype ::= */ |
| 108117 | #line 122 "parse.y" |
| 108118 | {yygotominor.yy4 = TK_DEFERRED;} |
| 108119 | #line 2132 "parse.c" |
| 108120 | break; |
| 108121 | case 14: /* transtype ::= DEFERRED */ |
| 108122 | case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15); |
| 108123 | case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16); |
| 108124 | case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115); |
| 108125 | case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117); |
| 108126 | #line 123 "parse.y" |
| 108127 | {yygotominor.yy4 = yymsp[0].major;} |
| 108128 | #line 2141 "parse.c" |
| 108129 | break; |
| 108130 | case 17: /* cmd ::= COMMIT trans_opt */ |
| 108131 | case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18); |
| 108132 | #line 126 "parse.y" |
| 108133 | {sqlite3CommitTransaction(pParse);} |
| 108134 | #line 2147 "parse.c" |
| 108135 | break; |
| 108136 | case 19: /* cmd ::= ROLLBACK trans_opt */ |
| 108137 | #line 128 "parse.y" |
| 108138 | {sqlite3RollbackTransaction(pParse);} |
| 108139 | #line 2152 "parse.c" |
| 108140 | break; |
| 108141 | case 22: /* cmd ::= SAVEPOINT nm */ |
| 108142 | #line 132 "parse.y" |
| 108143 | { |
| 108144 | sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0); |
| 108145 | } |
| 108146 | #line 2159 "parse.c" |
| 108147 | break; |
| 108148 | case 23: /* cmd ::= RELEASE savepoint_opt nm */ |
| 108149 | #line 135 "parse.y" |
| 108150 | { |
| 108151 | sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0); |
| 108152 | } |
| 108153 | #line 2166 "parse.c" |
| 108154 | break; |
| 108155 | case 24: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ |
| 108156 | #line 138 "parse.y" |
| 108157 | { |
| 108158 | sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); |
| 108159 | } |
| 108160 | #line 2173 "parse.c" |
| 108161 | break; |
| 108162 | case 26: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 108163 | #line 145 "parse.y" |
| 108164 | { |
| 108165 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy4,0,0,yymsp[-2].minor.yy4); |
| 108166 | } |
| 108167 | #line 2180 "parse.c" |
| 108168 | break; |
| 108169 | case 27: /* createkw ::= CREATE */ |
| 108170 | #line 148 "parse.y" |
| 108171 | { |
| 108172 | pParse->db->lookaside.bEnabled = 0; |
| 108173 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 108174 | } |
| 108175 | #line 2188 "parse.c" |
| 108176 | break; |
| 108177 | case 28: /* ifnotexists ::= */ |
| 108178 | case 31: /* temp ::= */ yytestcase(yyruleno==31); |
| 108179 | case 70: /* autoinc ::= */ yytestcase(yyruleno==70); |
| 108180 | case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83); |
| @@ -107677,44 +108184,56 @@ | |
| 108184 | case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 108185 | case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120); |
| 108186 | case 121: /* distinct ::= */ yytestcase(yyruleno==121); |
| 108187 | case 222: /* between_op ::= BETWEEN */ yytestcase(yyruleno==222); |
| 108188 | case 225: /* in_op ::= IN */ yytestcase(yyruleno==225); |
| 108189 | #line 153 "parse.y" |
| 108190 | {yygotominor.yy4 = 0;} |
| 108191 | #line 2204 "parse.c" |
| 108192 | break; |
| 108193 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 108194 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 108195 | case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71); |
| 108196 | case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86); |
| 108197 | case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 108198 | case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119); |
| 108199 | case 223: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==223); |
| 108200 | case 226: /* in_op ::= NOT IN */ yytestcase(yyruleno==226); |
| 108201 | #line 154 "parse.y" |
| 108202 | {yygotominor.yy4 = 1;} |
| 108203 | #line 2216 "parse.c" |
| 108204 | break; |
| 108205 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| 108206 | #line 160 "parse.y" |
| 108207 | { |
| 108208 | sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); |
| 108209 | } |
| 108210 | #line 2223 "parse.c" |
| 108211 | break; |
| 108212 | case 33: /* create_table_args ::= AS select */ |
| 108213 | #line 163 "parse.y" |
| 108214 | { |
| 108215 | sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy387); |
| 108216 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 108217 | } |
| 108218 | #line 2231 "parse.c" |
| 108219 | break; |
| 108220 | case 36: /* column ::= columnid type carglist */ |
| 108221 | #line 175 "parse.y" |
| 108222 | { |
| 108223 | yygotominor.yy0.z = yymsp[-2].minor.yy0.z; |
| 108224 | yygotominor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-2].minor.yy0.z) + pParse->sLastToken.n; |
| 108225 | } |
| 108226 | #line 2239 "parse.c" |
| 108227 | break; |
| 108228 | case 37: /* columnid ::= nm */ |
| 108229 | #line 179 "parse.y" |
| 108230 | { |
| 108231 | sqlite3AddColumn(pParse,&yymsp[0].minor.yy0); |
| 108232 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 108233 | } |
| 108234 | #line 2247 "parse.c" |
| 108235 | break; |
| 108236 | case 38: /* id ::= ID */ |
| 108237 | case 39: /* id ::= INDEXED */ yytestcase(yyruleno==39); |
| 108238 | case 40: /* ids ::= ID|STRING */ yytestcase(yyruleno==40); |
| 108239 | case 41: /* nm ::= id */ yytestcase(yyruleno==41); |
| @@ -107734,256 +108253,373 @@ | |
| 108253 | case 264: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==264); |
| 108254 | case 265: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==265); |
| 108255 | case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266); |
| 108256 | case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267); |
| 108257 | case 285: /* trnm ::= nm */ yytestcase(yyruleno==285); |
| 108258 | #line 189 "parse.y" |
| 108259 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 108260 | #line 2273 "parse.c" |
| 108261 | break; |
| 108262 | case 45: /* type ::= typetoken */ |
| 108263 | #line 251 "parse.y" |
| 108264 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 108265 | #line 2278 "parse.c" |
| 108266 | break; |
| 108267 | case 47: /* typetoken ::= typename LP signed RP */ |
| 108268 | #line 253 "parse.y" |
| 108269 | { |
| 108270 | yygotominor.yy0.z = yymsp[-3].minor.yy0.z; |
| 108271 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); |
| 108272 | } |
| 108273 | #line 2286 "parse.c" |
| 108274 | break; |
| 108275 | case 48: /* typetoken ::= typename LP signed COMMA signed RP */ |
| 108276 | #line 257 "parse.y" |
| 108277 | { |
| 108278 | yygotominor.yy0.z = yymsp[-5].minor.yy0.z; |
| 108279 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); |
| 108280 | } |
| 108281 | #line 2294 "parse.c" |
| 108282 | break; |
| 108283 | case 50: /* typename ::= typename ids */ |
| 108284 | #line 263 "parse.y" |
| 108285 | {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 108286 | #line 2299 "parse.c" |
| 108287 | break; |
| 108288 | case 57: /* ccons ::= DEFAULT term */ |
| 108289 | case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59); |
| 108290 | #line 274 "parse.y" |
| 108291 | {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy118);} |
| 108292 | #line 2305 "parse.c" |
| 108293 | break; |
| 108294 | case 58: /* ccons ::= DEFAULT LP expr RP */ |
| 108295 | #line 275 "parse.y" |
| 108296 | {sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy118);} |
| 108297 | #line 2310 "parse.c" |
| 108298 | break; |
| 108299 | case 60: /* ccons ::= DEFAULT MINUS term */ |
| 108300 | #line 277 "parse.y" |
| 108301 | { |
| 108302 | ExprSpan v; |
| 108303 | v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy118.pExpr, 0, 0); |
| 108304 | v.zStart = yymsp[-1].minor.yy0.z; |
| 108305 | v.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108306 | sqlite3AddDefaultValue(pParse,&v); |
| 108307 | } |
| 108308 | #line 2321 "parse.c" |
| 108309 | break; |
| 108310 | case 61: /* ccons ::= DEFAULT id */ |
| 108311 | #line 284 "parse.y" |
| 108312 | { |
| 108313 | ExprSpan v; |
| 108314 | spanExpr(&v, pParse, TK_STRING, &yymsp[0].minor.yy0); |
| 108315 | sqlite3AddDefaultValue(pParse,&v); |
| 108316 | } |
| 108317 | #line 2330 "parse.c" |
| 108318 | break; |
| 108319 | case 63: /* ccons ::= NOT NULL onconf */ |
| 108320 | #line 294 "parse.y" |
| 108321 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy4);} |
| 108322 | #line 2335 "parse.c" |
| 108323 | break; |
| 108324 | case 64: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 108325 | #line 296 "parse.y" |
| 108326 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy4,yymsp[0].minor.yy4,yymsp[-2].minor.yy4);} |
| 108327 | #line 2340 "parse.c" |
| 108328 | break; |
| 108329 | case 65: /* ccons ::= UNIQUE onconf */ |
| 108330 | #line 297 "parse.y" |
| 108331 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy4,0,0,0,0);} |
| 108332 | #line 2345 "parse.c" |
| 108333 | break; |
| 108334 | case 66: /* ccons ::= CHECK LP expr RP */ |
| 108335 | #line 298 "parse.y" |
| 108336 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy118.pExpr);} |
| 108337 | #line 2350 "parse.c" |
| 108338 | break; |
| 108339 | case 67: /* ccons ::= REFERENCES nm idxlist_opt refargs */ |
| 108340 | #line 300 "parse.y" |
| 108341 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy4);} |
| 108342 | #line 2355 "parse.c" |
| 108343 | break; |
| 108344 | case 68: /* ccons ::= defer_subclause */ |
| 108345 | #line 301 "parse.y" |
| 108346 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy4);} |
| 108347 | #line 2360 "parse.c" |
| 108348 | break; |
| 108349 | case 69: /* ccons ::= COLLATE ids */ |
| 108350 | #line 302 "parse.y" |
| 108351 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 108352 | #line 2365 "parse.c" |
| 108353 | break; |
| 108354 | case 72: /* refargs ::= */ |
| 108355 | #line 315 "parse.y" |
| 108356 | { yygotominor.yy4 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 108357 | #line 2370 "parse.c" |
| 108358 | break; |
| 108359 | case 73: /* refargs ::= refargs refarg */ |
| 108360 | #line 316 "parse.y" |
| 108361 | { yygotominor.yy4 = (yymsp[-1].minor.yy4 & ~yymsp[0].minor.yy215.mask) | yymsp[0].minor.yy215.value; } |
| 108362 | #line 2375 "parse.c" |
| 108363 | break; |
| 108364 | case 74: /* refarg ::= MATCH nm */ |
| 108365 | case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75); |
| 108366 | #line 318 "parse.y" |
| 108367 | { yygotominor.yy215.value = 0; yygotominor.yy215.mask = 0x000000; } |
| 108368 | #line 2381 "parse.c" |
| 108369 | break; |
| 108370 | case 76: /* refarg ::= ON DELETE refact */ |
| 108371 | #line 320 "parse.y" |
| 108372 | { yygotominor.yy215.value = yymsp[0].minor.yy4; yygotominor.yy215.mask = 0x0000ff; } |
| 108373 | #line 2386 "parse.c" |
| 108374 | break; |
| 108375 | case 77: /* refarg ::= ON UPDATE refact */ |
| 108376 | #line 321 "parse.y" |
| 108377 | { yygotominor.yy215.value = yymsp[0].minor.yy4<<8; yygotominor.yy215.mask = 0x00ff00; } |
| 108378 | #line 2391 "parse.c" |
| 108379 | break; |
| 108380 | case 78: /* refact ::= SET NULL */ |
| 108381 | #line 323 "parse.y" |
| 108382 | { yygotominor.yy4 = OE_SetNull; /* EV: R-33326-45252 */} |
| 108383 | #line 2396 "parse.c" |
| 108384 | break; |
| 108385 | case 79: /* refact ::= SET DEFAULT */ |
| 108386 | #line 324 "parse.y" |
| 108387 | { yygotominor.yy4 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 108388 | #line 2401 "parse.c" |
| 108389 | break; |
| 108390 | case 80: /* refact ::= CASCADE */ |
| 108391 | #line 325 "parse.y" |
| 108392 | { yygotominor.yy4 = OE_Cascade; /* EV: R-33326-45252 */} |
| 108393 | #line 2406 "parse.c" |
| 108394 | break; |
| 108395 | case 81: /* refact ::= RESTRICT */ |
| 108396 | #line 326 "parse.y" |
| 108397 | { yygotominor.yy4 = OE_Restrict; /* EV: R-33326-45252 */} |
| 108398 | #line 2411 "parse.c" |
| 108399 | break; |
| 108400 | case 82: /* refact ::= NO ACTION */ |
| 108401 | #line 327 "parse.y" |
| 108402 | { yygotominor.yy4 = OE_None; /* EV: R-33326-45252 */} |
| 108403 | #line 2416 "parse.c" |
| 108404 | break; |
| 108405 | case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 108406 | case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99); |
| 108407 | case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101); |
| 108408 | case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104); |
| 108409 | #line 330 "parse.y" |
| 108410 | {yygotominor.yy4 = yymsp[0].minor.yy4;} |
| 108411 | #line 2424 "parse.c" |
| 108412 | break; |
| 108413 | case 88: /* conslist_opt ::= */ |
| 108414 | #line 339 "parse.y" |
| 108415 | {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;} |
| 108416 | #line 2429 "parse.c" |
| 108417 | break; |
| 108418 | case 89: /* conslist_opt ::= COMMA conslist */ |
| 108419 | #line 340 "parse.y" |
| 108420 | {yygotominor.yy0 = yymsp[-1].minor.yy0;} |
| 108421 | #line 2434 "parse.c" |
| 108422 | break; |
| 108423 | case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 108424 | #line 346 "parse.y" |
| 108425 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy4,yymsp[-2].minor.yy4,0);} |
| 108426 | #line 2439 "parse.c" |
| 108427 | break; |
| 108428 | case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 108429 | #line 348 "parse.y" |
| 108430 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy4,0,0,0,0);} |
| 108431 | #line 2444 "parse.c" |
| 108432 | break; |
| 108433 | case 96: /* tcons ::= CHECK LP expr RP onconf */ |
| 108434 | #line 350 "parse.y" |
| 108435 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy118.pExpr);} |
| 108436 | #line 2449 "parse.c" |
| 108437 | break; |
| 108438 | case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 108439 | #line 352 "parse.y" |
| 108440 | { |
| 108441 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy4); |
| 108442 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy4); |
| 108443 | } |
| 108444 | #line 2457 "parse.c" |
| 108445 | break; |
| 108446 | case 100: /* onconf ::= */ |
| 108447 | #line 366 "parse.y" |
| 108448 | {yygotominor.yy4 = OE_Default;} |
| 108449 | #line 2462 "parse.c" |
| 108450 | break; |
| 108451 | case 102: /* orconf ::= */ |
| 108452 | #line 368 "parse.y" |
| 108453 | {yygotominor.yy210 = OE_Default;} |
| 108454 | #line 2467 "parse.c" |
| 108455 | break; |
| 108456 | case 103: /* orconf ::= OR resolvetype */ |
| 108457 | #line 369 "parse.y" |
| 108458 | {yygotominor.yy210 = (u8)yymsp[0].minor.yy4;} |
| 108459 | #line 2472 "parse.c" |
| 108460 | break; |
| 108461 | case 105: /* resolvetype ::= IGNORE */ |
| 108462 | #line 371 "parse.y" |
| 108463 | {yygotominor.yy4 = OE_Ignore;} |
| 108464 | #line 2477 "parse.c" |
| 108465 | break; |
| 108466 | case 106: /* resolvetype ::= REPLACE */ |
| 108467 | #line 372 "parse.y" |
| 108468 | {yygotominor.yy4 = OE_Replace;} |
| 108469 | #line 2482 "parse.c" |
| 108470 | break; |
| 108471 | case 107: /* cmd ::= DROP TABLE ifexists fullname */ |
| 108472 | #line 376 "parse.y" |
| 108473 | { |
| 108474 | sqlite3DropTable(pParse, yymsp[0].minor.yy259, 0, yymsp[-1].minor.yy4); |
| 108475 | } |
| 108476 | #line 2489 "parse.c" |
| 108477 | break; |
| 108478 | case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 108479 | #line 386 "parse.y" |
| 108480 | { |
| 108481 | sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy387, yymsp[-6].minor.yy4, yymsp[-4].minor.yy4); |
| 108482 | } |
| 108483 | #line 2496 "parse.c" |
| 108484 | break; |
| 108485 | case 111: /* cmd ::= DROP VIEW ifexists fullname */ |
| 108486 | #line 389 "parse.y" |
| 108487 | { |
| 108488 | sqlite3DropTable(pParse, yymsp[0].minor.yy259, 1, yymsp[-1].minor.yy4); |
| 108489 | } |
| 108490 | #line 2503 "parse.c" |
| 108491 | break; |
| 108492 | case 112: /* cmd ::= select */ |
| 108493 | #line 396 "parse.y" |
| 108494 | { |
| 108495 | SelectDest dest = {SRT_Output, 0, 0, 0, 0}; |
| 108496 | sqlite3Select(pParse, yymsp[0].minor.yy387, &dest); |
| 108497 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy387); |
| 108498 | } |
| 108499 | #line 2512 "parse.c" |
| 108500 | break; |
| 108501 | case 113: /* select ::= oneselect */ |
| 108502 | #line 407 "parse.y" |
| 108503 | {yygotominor.yy387 = yymsp[0].minor.yy387;} |
| 108504 | #line 2517 "parse.c" |
| 108505 | break; |
| 108506 | case 114: /* select ::= select multiselect_op oneselect */ |
| 108507 | #line 409 "parse.y" |
| 108508 | { |
| 108509 | if( yymsp[0].minor.yy387 ){ |
| 108510 | yymsp[0].minor.yy387->op = (u8)yymsp[-1].minor.yy4; |
| 108511 | yymsp[0].minor.yy387->pPrior = yymsp[-2].minor.yy387; |
| 108512 | }else{ |
| 108513 | sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy387); |
| 108514 | } |
| 108515 | yygotominor.yy387 = yymsp[0].minor.yy387; |
| 108516 | } |
| 108517 | #line 2530 "parse.c" |
| 108518 | break; |
| 108519 | case 116: /* multiselect_op ::= UNION ALL */ |
| 108520 | #line 420 "parse.y" |
| 108521 | {yygotominor.yy4 = TK_ALL;} |
| 108522 | #line 2535 "parse.c" |
| 108523 | break; |
| 108524 | case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 108525 | #line 424 "parse.y" |
| 108526 | { |
| 108527 | yygotominor.yy387 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy259,yymsp[-4].minor.yy314,yymsp[-3].minor.yy322,yymsp[-2].minor.yy314,yymsp[-1].minor.yy322,yymsp[-7].minor.yy4,yymsp[0].minor.yy292.pLimit,yymsp[0].minor.yy292.pOffset); |
| 108528 | } |
| 108529 | #line 2542 "parse.c" |
| 108530 | break; |
| 108531 | case 122: /* sclp ::= selcollist COMMA */ |
| 108532 | case 247: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==247); |
| 108533 | #line 445 "parse.y" |
| 108534 | {yygotominor.yy322 = yymsp[-1].minor.yy322;} |
| 108535 | #line 2548 "parse.c" |
| 108536 | break; |
| 108537 | case 123: /* sclp ::= */ |
| 108538 | case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151); |
| 108539 | case 159: /* groupby_opt ::= */ yytestcase(yyruleno==159); |
| 108540 | case 240: /* exprlist ::= */ yytestcase(yyruleno==240); |
| 108541 | case 246: /* idxlist_opt ::= */ yytestcase(yyruleno==246); |
| 108542 | #line 446 "parse.y" |
| 108543 | {yygotominor.yy322 = 0;} |
| 108544 | #line 2557 "parse.c" |
| 108545 | break; |
| 108546 | case 124: /* selcollist ::= sclp expr as */ |
| 108547 | #line 447 "parse.y" |
| 108548 | { |
| 108549 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, yymsp[-1].minor.yy118.pExpr); |
| 108550 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[0].minor.yy0, 1); |
| 108551 | sqlite3ExprListSetSpan(pParse,yygotominor.yy322,&yymsp[-1].minor.yy118); |
| 108552 | } |
| 108553 | #line 2566 "parse.c" |
| 108554 | break; |
| 108555 | case 125: /* selcollist ::= sclp STAR */ |
| 108556 | #line 452 "parse.y" |
| 108557 | { |
| 108558 | Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0); |
| 108559 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy322, p); |
| 108560 | } |
| 108561 | #line 2574 "parse.c" |
| 108562 | break; |
| 108563 | case 126: /* selcollist ::= sclp nm DOT STAR */ |
| 108564 | #line 456 "parse.y" |
| 108565 | { |
| 108566 | Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0); |
| 108567 | Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 108568 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); |
| 108569 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, pDot); |
| 108570 | } |
| 108571 | #line 2584 "parse.c" |
| 108572 | break; |
| 108573 | case 129: /* as ::= */ |
| 108574 | #line 469 "parse.y" |
| 108575 | {yygotominor.yy0.n = 0;} |
| 108576 | #line 2589 "parse.c" |
| 108577 | break; |
| 108578 | case 130: /* from ::= */ |
| 108579 | #line 481 "parse.y" |
| 108580 | {yygotominor.yy259 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy259));} |
| 108581 | #line 2594 "parse.c" |
| 108582 | break; |
| 108583 | case 131: /* from ::= FROM seltablist */ |
| 108584 | #line 482 "parse.y" |
| 108585 | { |
| 108586 | yygotominor.yy259 = yymsp[0].minor.yy259; |
| 108587 | sqlite3SrcListShiftJoinType(yygotominor.yy259); |
| 108588 | } |
| 108589 | #line 2602 "parse.c" |
| 108590 | break; |
| 108591 | case 132: /* stl_prefix ::= seltablist joinop */ |
| 108592 | #line 490 "parse.y" |
| 108593 | { |
| 108594 | yygotominor.yy259 = yymsp[-1].minor.yy259; |
| 108595 | if( ALWAYS(yygotominor.yy259 && yygotominor.yy259->nSrc>0) ) yygotominor.yy259->a[yygotominor.yy259->nSrc-1].jointype = (u8)yymsp[0].minor.yy4; |
| 108596 | } |
| 108597 | #line 2610 "parse.c" |
| 108598 | break; |
| 108599 | case 133: /* stl_prefix ::= */ |
| 108600 | #line 494 "parse.y" |
| 108601 | {yygotominor.yy259 = 0;} |
| 108602 | #line 2615 "parse.c" |
| 108603 | break; |
| 108604 | case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 108605 | #line 495 "parse.y" |
| 108606 | { |
| 108607 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 108608 | sqlite3SrcListIndexedBy(pParse, yygotominor.yy259, &yymsp[-2].minor.yy0); |
| 108609 | } |
| 108610 | #line 2623 "parse.c" |
| 108611 | break; |
| 108612 | case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 108613 | #line 501 "parse.y" |
| 108614 | { |
| 108615 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy387,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 108616 | } |
| 108617 | #line 2630 "parse.c" |
| 108618 | break; |
| 108619 | case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 108620 | #line 505 "parse.y" |
| 108621 | { |
| 108622 | if( yymsp[-6].minor.yy259==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy314==0 && yymsp[0].minor.yy384==0 ){ |
| 108623 | yygotominor.yy259 = yymsp[-4].minor.yy259; |
| 108624 | }else{ |
| 108625 | Select *pSubquery; |
| @@ -107990,180 +108626,260 @@ | |
| 108626 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy259); |
| 108627 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy259,0,0,0,0,0,0,0); |
| 108628 | yygotominor.yy259 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy259,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy314,yymsp[0].minor.yy384); |
| 108629 | } |
| 108630 | } |
| 108631 | #line 2644 "parse.c" |
| 108632 | break; |
| 108633 | case 137: /* dbnm ::= */ |
| 108634 | case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146); |
| 108635 | #line 530 "parse.y" |
| 108636 | {yygotominor.yy0.z=0; yygotominor.yy0.n=0;} |
| 108637 | #line 2650 "parse.c" |
| 108638 | break; |
| 108639 | case 139: /* fullname ::= nm dbnm */ |
| 108640 | #line 535 "parse.y" |
| 108641 | {yygotominor.yy259 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 108642 | #line 2655 "parse.c" |
| 108643 | break; |
| 108644 | case 140: /* joinop ::= COMMA|JOIN */ |
| 108645 | #line 539 "parse.y" |
| 108646 | { yygotominor.yy4 = JT_INNER; } |
| 108647 | #line 2660 "parse.c" |
| 108648 | break; |
| 108649 | case 141: /* joinop ::= JOIN_KW JOIN */ |
| 108650 | #line 540 "parse.y" |
| 108651 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 108652 | #line 2665 "parse.c" |
| 108653 | break; |
| 108654 | case 142: /* joinop ::= JOIN_KW nm JOIN */ |
| 108655 | #line 541 "parse.y" |
| 108656 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 108657 | #line 2670 "parse.c" |
| 108658 | break; |
| 108659 | case 143: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 108660 | #line 543 "parse.y" |
| 108661 | { yygotominor.yy4 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 108662 | #line 2675 "parse.c" |
| 108663 | break; |
| 108664 | case 144: /* on_opt ::= ON expr */ |
| 108665 | case 155: /* sortitem ::= expr */ yytestcase(yyruleno==155); |
| 108666 | case 162: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==162); |
| 108667 | case 169: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==169); |
| 108668 | case 235: /* case_else ::= ELSE expr */ yytestcase(yyruleno==235); |
| 108669 | case 237: /* case_operand ::= expr */ yytestcase(yyruleno==237); |
| 108670 | #line 547 "parse.y" |
| 108671 | {yygotominor.yy314 = yymsp[0].minor.yy118.pExpr;} |
| 108672 | #line 2685 "parse.c" |
| 108673 | break; |
| 108674 | case 145: /* on_opt ::= */ |
| 108675 | case 161: /* having_opt ::= */ yytestcase(yyruleno==161); |
| 108676 | case 168: /* where_opt ::= */ yytestcase(yyruleno==168); |
| 108677 | case 236: /* case_else ::= */ yytestcase(yyruleno==236); |
| 108678 | case 238: /* case_operand ::= */ yytestcase(yyruleno==238); |
| 108679 | #line 548 "parse.y" |
| 108680 | {yygotominor.yy314 = 0;} |
| 108681 | #line 2694 "parse.c" |
| 108682 | break; |
| 108683 | case 148: /* indexed_opt ::= NOT INDEXED */ |
| 108684 | #line 563 "parse.y" |
| 108685 | {yygotominor.yy0.z=0; yygotominor.yy0.n=1;} |
| 108686 | #line 2699 "parse.c" |
| 108687 | break; |
| 108688 | case 149: /* using_opt ::= USING LP inscollist RP */ |
| 108689 | case 181: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==181); |
| 108690 | #line 567 "parse.y" |
| 108691 | {yygotominor.yy384 = yymsp[-1].minor.yy384;} |
| 108692 | #line 2705 "parse.c" |
| 108693 | break; |
| 108694 | case 150: /* using_opt ::= */ |
| 108695 | case 180: /* inscollist_opt ::= */ yytestcase(yyruleno==180); |
| 108696 | #line 568 "parse.y" |
| 108697 | {yygotominor.yy384 = 0;} |
| 108698 | #line 2711 "parse.c" |
| 108699 | break; |
| 108700 | case 152: /* orderby_opt ::= ORDER BY sortlist */ |
| 108701 | case 160: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==160); |
| 108702 | case 239: /* exprlist ::= nexprlist */ yytestcase(yyruleno==239); |
| 108703 | #line 579 "parse.y" |
| 108704 | {yygotominor.yy322 = yymsp[0].minor.yy322;} |
| 108705 | #line 2718 "parse.c" |
| 108706 | break; |
| 108707 | case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ |
| 108708 | #line 580 "parse.y" |
| 108709 | { |
| 108710 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322,yymsp[-1].minor.yy314); |
| 108711 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108712 | } |
| 108713 | #line 2726 "parse.c" |
| 108714 | break; |
| 108715 | case 154: /* sortlist ::= sortitem sortorder */ |
| 108716 | #line 584 "parse.y" |
| 108717 | { |
| 108718 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy314); |
| 108719 | if( yygotominor.yy322 && ALWAYS(yygotominor.yy322->a) ) yygotominor.yy322->a[0].sortOrder = (u8)yymsp[0].minor.yy4; |
| 108720 | } |
| 108721 | #line 2734 "parse.c" |
| 108722 | break; |
| 108723 | case 156: /* sortorder ::= ASC */ |
| 108724 | case 158: /* sortorder ::= */ yytestcase(yyruleno==158); |
| 108725 | #line 592 "parse.y" |
| 108726 | {yygotominor.yy4 = SQLITE_SO_ASC;} |
| 108727 | #line 2740 "parse.c" |
| 108728 | break; |
| 108729 | case 157: /* sortorder ::= DESC */ |
| 108730 | #line 593 "parse.y" |
| 108731 | {yygotominor.yy4 = SQLITE_SO_DESC;} |
| 108732 | #line 2745 "parse.c" |
| 108733 | break; |
| 108734 | case 163: /* limit_opt ::= */ |
| 108735 | #line 619 "parse.y" |
| 108736 | {yygotominor.yy292.pLimit = 0; yygotominor.yy292.pOffset = 0;} |
| 108737 | #line 2750 "parse.c" |
| 108738 | break; |
| 108739 | case 164: /* limit_opt ::= LIMIT expr */ |
| 108740 | #line 620 "parse.y" |
| 108741 | {yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr; yygotominor.yy292.pOffset = 0;} |
| 108742 | #line 2755 "parse.c" |
| 108743 | break; |
| 108744 | case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 108745 | #line 622 "parse.y" |
| 108746 | {yygotominor.yy292.pLimit = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pOffset = yymsp[0].minor.yy118.pExpr;} |
| 108747 | #line 2760 "parse.c" |
| 108748 | break; |
| 108749 | case 166: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 108750 | #line 624 "parse.y" |
| 108751 | {yygotominor.yy292.pOffset = yymsp[-2].minor.yy118.pExpr; yygotominor.yy292.pLimit = yymsp[0].minor.yy118.pExpr;} |
| 108752 | #line 2765 "parse.c" |
| 108753 | break; |
| 108754 | case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ |
| 108755 | #line 637 "parse.y" |
| 108756 | { |
| 108757 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy259, &yymsp[-1].minor.yy0); |
| 108758 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy259,yymsp[0].minor.yy314); |
| 108759 | } |
| 108760 | #line 2773 "parse.c" |
| 108761 | break; |
| 108762 | case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 108763 | #line 660 "parse.y" |
| 108764 | { |
| 108765 | sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy259, &yymsp[-3].minor.yy0); |
| 108766 | sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy322,"set list"); |
| 108767 | sqlite3Update(pParse,yymsp[-4].minor.yy259,yymsp[-1].minor.yy322,yymsp[0].minor.yy314,yymsp[-5].minor.yy210); |
| 108768 | } |
| 108769 | #line 2782 "parse.c" |
| 108770 | break; |
| 108771 | case 171: /* setlist ::= setlist COMMA nm EQ expr */ |
| 108772 | #line 670 "parse.y" |
| 108773 | { |
| 108774 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy118.pExpr); |
| 108775 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108776 | } |
| 108777 | #line 2790 "parse.c" |
| 108778 | break; |
| 108779 | case 172: /* setlist ::= nm EQ expr */ |
| 108780 | #line 674 "parse.y" |
| 108781 | { |
| 108782 | yygotominor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy118.pExpr); |
| 108783 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 108784 | } |
| 108785 | #line 2798 "parse.c" |
| 108786 | break; |
| 108787 | case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */ |
| 108788 | #line 683 "parse.y" |
| 108789 | {sqlite3Insert(pParse, yymsp[-5].minor.yy259, yymsp[-1].minor.yy322, 0, yymsp[-4].minor.yy384, yymsp[-7].minor.yy210);} |
| 108790 | #line 2803 "parse.c" |
| 108791 | break; |
| 108792 | case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ |
| 108793 | #line 685 "parse.y" |
| 108794 | {sqlite3Insert(pParse, yymsp[-2].minor.yy259, 0, yymsp[0].minor.yy387, yymsp[-1].minor.yy384, yymsp[-4].minor.yy210);} |
| 108795 | #line 2808 "parse.c" |
| 108796 | break; |
| 108797 | case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 108798 | #line 687 "parse.y" |
| 108799 | {sqlite3Insert(pParse, yymsp[-3].minor.yy259, 0, 0, yymsp[-2].minor.yy384, yymsp[-5].minor.yy210);} |
| 108800 | #line 2813 "parse.c" |
| 108801 | break; |
| 108802 | case 176: /* insert_cmd ::= INSERT orconf */ |
| 108803 | #line 690 "parse.y" |
| 108804 | {yygotominor.yy210 = yymsp[0].minor.yy210;} |
| 108805 | #line 2818 "parse.c" |
| 108806 | break; |
| 108807 | case 177: /* insert_cmd ::= REPLACE */ |
| 108808 | #line 691 "parse.y" |
| 108809 | {yygotominor.yy210 = OE_Replace;} |
| 108810 | #line 2823 "parse.c" |
| 108811 | break; |
| 108812 | case 178: /* itemlist ::= itemlist COMMA expr */ |
| 108813 | case 241: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==241); |
| 108814 | #line 698 "parse.y" |
| 108815 | {yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy118.pExpr);} |
| 108816 | #line 2829 "parse.c" |
| 108817 | break; |
| 108818 | case 179: /* itemlist ::= expr */ |
| 108819 | case 242: /* nexprlist ::= expr */ yytestcase(yyruleno==242); |
| 108820 | #line 700 "parse.y" |
| 108821 | {yygotominor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy118.pExpr);} |
| 108822 | #line 2835 "parse.c" |
| 108823 | break; |
| 108824 | case 182: /* inscollist ::= inscollist COMMA nm */ |
| 108825 | #line 710 "parse.y" |
| 108826 | {yygotominor.yy384 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy384,&yymsp[0].minor.yy0);} |
| 108827 | #line 2840 "parse.c" |
| 108828 | break; |
| 108829 | case 183: /* inscollist ::= nm */ |
| 108830 | #line 712 "parse.y" |
| 108831 | {yygotominor.yy384 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 108832 | #line 2845 "parse.c" |
| 108833 | break; |
| 108834 | case 184: /* expr ::= term */ |
| 108835 | #line 743 "parse.y" |
| 108836 | {yygotominor.yy118 = yymsp[0].minor.yy118;} |
| 108837 | #line 2850 "parse.c" |
| 108838 | break; |
| 108839 | case 185: /* expr ::= LP expr RP */ |
| 108840 | #line 744 "parse.y" |
| 108841 | {yygotominor.yy118.pExpr = yymsp[-1].minor.yy118.pExpr; spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 108842 | #line 2855 "parse.c" |
| 108843 | break; |
| 108844 | case 186: /* term ::= NULL */ |
| 108845 | case 191: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==191); |
| 108846 | case 192: /* term ::= STRING */ yytestcase(yyruleno==192); |
| 108847 | #line 745 "parse.y" |
| 108848 | {spanExpr(&yygotominor.yy118, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 108849 | #line 2862 "parse.c" |
| 108850 | break; |
| 108851 | case 187: /* expr ::= id */ |
| 108852 | case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188); |
| 108853 | #line 746 "parse.y" |
| 108854 | {spanExpr(&yygotominor.yy118, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 108855 | #line 2868 "parse.c" |
| 108856 | break; |
| 108857 | case 189: /* expr ::= nm DOT nm */ |
| 108858 | #line 748 "parse.y" |
| 108859 | { |
| 108860 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 108861 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 108862 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 108863 | spanSet(&yygotominor.yy118,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 108864 | } |
| 108865 | #line 2878 "parse.c" |
| 108866 | break; |
| 108867 | case 190: /* expr ::= nm DOT nm DOT nm */ |
| 108868 | #line 754 "parse.y" |
| 108869 | { |
| 108870 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 108871 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 108872 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 108873 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 108874 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 108875 | spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 108876 | } |
| 108877 | #line 2890 "parse.c" |
| 108878 | break; |
| 108879 | case 193: /* expr ::= REGISTER */ |
| 108880 | #line 764 "parse.y" |
| 108881 | { |
| 108882 | /* When doing a nested parse, one can include terms in an expression |
| 108883 | ** that look like this: #1 #2 ... These terms refer to registers |
| 108884 | ** in the virtual machine. #N is the N-th register. */ |
| 108885 | if( pParse->nested==0 ){ |
| @@ -108173,32 +108889,40 @@ | |
| 108889 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &yymsp[0].minor.yy0); |
| 108890 | if( yygotominor.yy118.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy118.pExpr->iTable); |
| 108891 | } |
| 108892 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108893 | } |
| 108894 | #line 2907 "parse.c" |
| 108895 | break; |
| 108896 | case 194: /* expr ::= VARIABLE */ |
| 108897 | #line 777 "parse.y" |
| 108898 | { |
| 108899 | spanExpr(&yygotominor.yy118, pParse, TK_VARIABLE, &yymsp[0].minor.yy0); |
| 108900 | sqlite3ExprAssignVarNumber(pParse, yygotominor.yy118.pExpr); |
| 108901 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108902 | } |
| 108903 | #line 2916 "parse.c" |
| 108904 | break; |
| 108905 | case 195: /* expr ::= expr COLLATE ids */ |
| 108906 | #line 782 "parse.y" |
| 108907 | { |
| 108908 | yygotominor.yy118.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy118.pExpr, &yymsp[0].minor.yy0); |
| 108909 | yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 108910 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 108911 | } |
| 108912 | #line 2925 "parse.c" |
| 108913 | break; |
| 108914 | case 196: /* expr ::= CAST LP expr AS typetoken RP */ |
| 108915 | #line 788 "parse.y" |
| 108916 | { |
| 108917 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy118.pExpr, 0, &yymsp[-1].minor.yy0); |
| 108918 | spanSet(&yygotominor.yy118,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 108919 | } |
| 108920 | #line 2933 "parse.c" |
| 108921 | break; |
| 108922 | case 197: /* expr ::= ID LP distinct exprlist RP */ |
| 108923 | #line 793 "parse.y" |
| 108924 | { |
| 108925 | if( yymsp[-1].minor.yy322 && yymsp[-1].minor.yy322->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 108926 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 108927 | } |
| 108928 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0); |
| @@ -108205,47 +108929,59 @@ | |
| 108929 | spanSet(&yygotominor.yy118,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 108930 | if( yymsp[-2].minor.yy4 && yygotominor.yy118.pExpr ){ |
| 108931 | yygotominor.yy118.pExpr->flags |= EP_Distinct; |
| 108932 | } |
| 108933 | } |
| 108934 | #line 2947 "parse.c" |
| 108935 | break; |
| 108936 | case 198: /* expr ::= ID LP STAR RP */ |
| 108937 | #line 803 "parse.y" |
| 108938 | { |
| 108939 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 108940 | spanSet(&yygotominor.yy118,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 108941 | } |
| 108942 | #line 2955 "parse.c" |
| 108943 | break; |
| 108944 | case 199: /* term ::= CTIME_KW */ |
| 108945 | #line 807 "parse.y" |
| 108946 | { |
| 108947 | /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are |
| 108948 | ** treated as functions that return constants */ |
| 108949 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0); |
| 108950 | if( yygotominor.yy118.pExpr ){ |
| 108951 | yygotominor.yy118.pExpr->op = TK_CONST_FUNC; |
| 108952 | } |
| 108953 | spanSet(&yygotominor.yy118, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 108954 | } |
| 108955 | #line 2968 "parse.c" |
| 108956 | break; |
| 108957 | case 200: /* expr ::= expr AND expr */ |
| 108958 | case 201: /* expr ::= expr OR expr */ yytestcase(yyruleno==201); |
| 108959 | case 202: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==202); |
| 108960 | case 203: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==203); |
| 108961 | case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==204); |
| 108962 | case 205: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==205); |
| 108963 | case 206: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==206); |
| 108964 | case 207: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==207); |
| 108965 | #line 834 "parse.y" |
| 108966 | {spanBinaryExpr(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118);} |
| 108967 | #line 2980 "parse.c" |
| 108968 | break; |
| 108969 | case 208: /* likeop ::= LIKE_KW */ |
| 108970 | case 210: /* likeop ::= MATCH */ yytestcase(yyruleno==210); |
| 108971 | #line 847 "parse.y" |
| 108972 | {yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 0;} |
| 108973 | #line 2986 "parse.c" |
| 108974 | break; |
| 108975 | case 209: /* likeop ::= NOT LIKE_KW */ |
| 108976 | case 211: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==211); |
| 108977 | #line 848 "parse.y" |
| 108978 | {yygotominor.yy342.eOperator = yymsp[0].minor.yy0; yygotominor.yy342.not = 1;} |
| 108979 | #line 2992 "parse.c" |
| 108980 | break; |
| 108981 | case 212: /* expr ::= expr likeop expr */ |
| 108982 | #line 851 "parse.y" |
| 108983 | { |
| 108984 | ExprList *pList; |
| 108985 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy118.pExpr); |
| 108986 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy118.pExpr); |
| 108987 | yygotominor.yy118.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy342.eOperator); |
| @@ -108252,12 +108988,14 @@ | |
| 108988 | if( yymsp[-1].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 108989 | yygotominor.yy118.zStart = yymsp[-2].minor.yy118.zStart; |
| 108990 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 108991 | if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 108992 | } |
| 108993 | #line 3006 "parse.c" |
| 108994 | break; |
| 108995 | case 213: /* expr ::= expr likeop expr ESCAPE expr */ |
| 108996 | #line 861 "parse.y" |
| 108997 | { |
| 108998 | ExprList *pList; |
| 108999 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 109000 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy118.pExpr); |
| 109001 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| @@ -108265,40 +109003,56 @@ | |
| 109003 | if( yymsp[-3].minor.yy342.not ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 109004 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 109005 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 109006 | if( yygotominor.yy118.pExpr ) yygotominor.yy118.pExpr->flags |= EP_InfixFunc; |
| 109007 | } |
| 109008 | #line 3021 "parse.c" |
| 109009 | break; |
| 109010 | case 214: /* expr ::= expr ISNULL|NOTNULL */ |
| 109011 | #line 889 "parse.y" |
| 109012 | {spanUnaryPostfix(&yygotominor.yy118,pParse,yymsp[0].major,&yymsp[-1].minor.yy118,&yymsp[0].minor.yy0);} |
| 109013 | #line 3026 "parse.c" |
| 109014 | break; |
| 109015 | case 215: /* expr ::= expr NOT NULL */ |
| 109016 | #line 890 "parse.y" |
| 109017 | {spanUnaryPostfix(&yygotominor.yy118,pParse,TK_NOTNULL,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy0);} |
| 109018 | #line 3031 "parse.c" |
| 109019 | break; |
| 109020 | case 216: /* expr ::= expr IS expr */ |
| 109021 | #line 911 "parse.y" |
| 109022 | { |
| 109023 | spanBinaryExpr(&yygotominor.yy118,pParse,TK_IS,&yymsp[-2].minor.yy118,&yymsp[0].minor.yy118); |
| 109024 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_ISNULL); |
| 109025 | } |
| 109026 | #line 3039 "parse.c" |
| 109027 | break; |
| 109028 | case 217: /* expr ::= expr IS NOT expr */ |
| 109029 | #line 915 "parse.y" |
| 109030 | { |
| 109031 | spanBinaryExpr(&yygotominor.yy118,pParse,TK_ISNOT,&yymsp[-3].minor.yy118,&yymsp[0].minor.yy118); |
| 109032 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy118.pExpr, yygotominor.yy118.pExpr, TK_NOTNULL); |
| 109033 | } |
| 109034 | #line 3047 "parse.c" |
| 109035 | break; |
| 109036 | case 218: /* expr ::= NOT expr */ |
| 109037 | case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219); |
| 109038 | #line 938 "parse.y" |
| 109039 | {spanUnaryPrefix(&yygotominor.yy118,pParse,yymsp[-1].major,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 109040 | #line 3053 "parse.c" |
| 109041 | break; |
| 109042 | case 220: /* expr ::= MINUS expr */ |
| 109043 | #line 941 "parse.y" |
| 109044 | {spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UMINUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 109045 | #line 3058 "parse.c" |
| 109046 | break; |
| 109047 | case 221: /* expr ::= PLUS expr */ |
| 109048 | #line 943 "parse.y" |
| 109049 | {spanUnaryPrefix(&yygotominor.yy118,pParse,TK_UPLUS,&yymsp[0].minor.yy118,&yymsp[-1].minor.yy0);} |
| 109050 | #line 3063 "parse.c" |
| 109051 | break; |
| 109052 | case 224: /* expr ::= expr between_op expr AND expr */ |
| 109053 | #line 948 "parse.y" |
| 109054 | { |
| 109055 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 109056 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy118.pExpr); |
| 109057 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 109058 | if( yygotominor.yy118.pExpr ){ |
| @@ -108308,12 +109062,14 @@ | |
| 109062 | } |
| 109063 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 109064 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 109065 | yygotominor.yy118.zEnd = yymsp[0].minor.yy118.zEnd; |
| 109066 | } |
| 109067 | #line 3080 "parse.c" |
| 109068 | break; |
| 109069 | case 227: /* expr ::= expr in_op LP exprlist RP */ |
| 109070 | #line 965 "parse.y" |
| 109071 | { |
| 109072 | if( yymsp[-1].minor.yy322==0 ){ |
| 109073 | /* Expressions of the form |
| 109074 | ** |
| 109075 | ** expr1 IN () |
| @@ -108335,12 +109091,14 @@ | |
| 109091 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 109092 | } |
| 109093 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 109094 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 109095 | } |
| 109096 | #line 3109 "parse.c" |
| 109097 | break; |
| 109098 | case 228: /* expr ::= LP select RP */ |
| 109099 | #line 990 "parse.y" |
| 109100 | { |
| 109101 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 109102 | if( yygotominor.yy118.pExpr ){ |
| 109103 | yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 109104 | ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| @@ -108349,12 +109107,14 @@ | |
| 109107 | sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 109108 | } |
| 109109 | yygotominor.yy118.zStart = yymsp[-2].minor.yy0.z; |
| 109110 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 109111 | } |
| 109112 | #line 3125 "parse.c" |
| 109113 | break; |
| 109114 | case 229: /* expr ::= expr in_op LP select RP */ |
| 109115 | #line 1002 "parse.y" |
| 109116 | { |
| 109117 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy118.pExpr, 0, 0); |
| 109118 | if( yygotominor.yy118.pExpr ){ |
| 109119 | yygotominor.yy118.pExpr->x.pSelect = yymsp[-1].minor.yy387; |
| 109120 | ExprSetProperty(yygotominor.yy118.pExpr, EP_xIsSelect); |
| @@ -108364,12 +109124,14 @@ | |
| 109124 | } |
| 109125 | if( yymsp[-3].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 109126 | yygotominor.yy118.zStart = yymsp[-4].minor.yy118.zStart; |
| 109127 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 109128 | } |
| 109129 | #line 3142 "parse.c" |
| 109130 | break; |
| 109131 | case 230: /* expr ::= expr in_op nm dbnm */ |
| 109132 | #line 1015 "parse.y" |
| 109133 | { |
| 109134 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 109135 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy118.pExpr, 0, 0); |
| 109136 | if( yygotominor.yy118.pExpr ){ |
| 109137 | yygotominor.yy118.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| @@ -108380,12 +109142,14 @@ | |
| 109142 | } |
| 109143 | if( yymsp[-2].minor.yy4 ) yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy118.pExpr, 0, 0); |
| 109144 | yygotominor.yy118.zStart = yymsp[-3].minor.yy118.zStart; |
| 109145 | yygotominor.yy118.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]; |
| 109146 | } |
| 109147 | #line 3160 "parse.c" |
| 109148 | break; |
| 109149 | case 231: /* expr ::= EXISTS LP select RP */ |
| 109150 | #line 1029 "parse.y" |
| 109151 | { |
| 109152 | Expr *p = yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 109153 | if( p ){ |
| 109154 | p->x.pSelect = yymsp[-1].minor.yy387; |
| 109155 | ExprSetProperty(p, EP_xIsSelect); |
| @@ -108394,12 +109158,14 @@ | |
| 109158 | sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy387); |
| 109159 | } |
| 109160 | yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 109161 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 109162 | } |
| 109163 | #line 3176 "parse.c" |
| 109164 | break; |
| 109165 | case 232: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 109166 | #line 1044 "parse.y" |
| 109167 | { |
| 109168 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy314, yymsp[-1].minor.yy314, 0); |
| 109169 | if( yygotominor.yy118.pExpr ){ |
| 109170 | yygotominor.yy118.pExpr->x.pList = yymsp[-2].minor.yy322; |
| 109171 | sqlite3ExprSetHeight(pParse, yygotominor.yy118.pExpr); |
| @@ -108407,38 +109173,50 @@ | |
| 109173 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322); |
| 109174 | } |
| 109175 | yygotominor.yy118.zStart = yymsp[-4].minor.yy0.z; |
| 109176 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 109177 | } |
| 109178 | #line 3191 "parse.c" |
| 109179 | break; |
| 109180 | case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 109181 | #line 1057 "parse.y" |
| 109182 | { |
| 109183 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy118.pExpr); |
| 109184 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 109185 | } |
| 109186 | #line 3199 "parse.c" |
| 109187 | break; |
| 109188 | case 234: /* case_exprlist ::= WHEN expr THEN expr */ |
| 109189 | #line 1061 "parse.y" |
| 109190 | { |
| 109191 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy118.pExpr); |
| 109192 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yygotominor.yy322, yymsp[0].minor.yy118.pExpr); |
| 109193 | } |
| 109194 | #line 3207 "parse.c" |
| 109195 | break; |
| 109196 | case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ |
| 109197 | #line 1090 "parse.y" |
| 109198 | { |
| 109199 | sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, |
| 109200 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy322, yymsp[-9].minor.yy4, |
| 109201 | &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy4); |
| 109202 | } |
| 109203 | #line 3216 "parse.c" |
| 109204 | break; |
| 109205 | case 244: /* uniqueflag ::= UNIQUE */ |
| 109206 | case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298); |
| 109207 | #line 1097 "parse.y" |
| 109208 | {yygotominor.yy4 = OE_Abort;} |
| 109209 | #line 3222 "parse.c" |
| 109210 | break; |
| 109211 | case 245: /* uniqueflag ::= */ |
| 109212 | #line 1098 "parse.y" |
| 109213 | {yygotominor.yy4 = OE_None;} |
| 109214 | #line 3227 "parse.c" |
| 109215 | break; |
| 109216 | case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 109217 | #line 1107 "parse.y" |
| 109218 | { |
| 109219 | Expr *p = 0; |
| 109220 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 109221 | p = sqlite3Expr(pParse->db, TK_COLUMN, 0); |
| 109222 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -108446,12 +109224,14 @@ | |
| 109224 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, p); |
| 109225 | sqlite3ExprListSetName(pParse,yygotominor.yy322,&yymsp[-2].minor.yy0,1); |
| 109226 | sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 109227 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 109228 | } |
| 109229 | #line 3242 "parse.c" |
| 109230 | break; |
| 109231 | case 249: /* idxlist ::= nm collate sortorder */ |
| 109232 | #line 1118 "parse.y" |
| 109233 | { |
| 109234 | Expr *p = 0; |
| 109235 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 109236 | p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); |
| 109237 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -108459,214 +109239,307 @@ | |
| 109239 | yygotominor.yy322 = sqlite3ExprListAppend(pParse,0, p); |
| 109240 | sqlite3ExprListSetName(pParse, yygotominor.yy322, &yymsp[-2].minor.yy0, 1); |
| 109241 | sqlite3ExprListCheckLength(pParse, yygotominor.yy322, "index"); |
| 109242 | if( yygotominor.yy322 ) yygotominor.yy322->a[yygotominor.yy322->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy4; |
| 109243 | } |
| 109244 | #line 3257 "parse.c" |
| 109245 | break; |
| 109246 | case 250: /* collate ::= */ |
| 109247 | #line 1131 "parse.y" |
| 109248 | {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;} |
| 109249 | #line 3262 "parse.c" |
| 109250 | break; |
| 109251 | case 252: /* cmd ::= DROP INDEX ifexists fullname */ |
| 109252 | #line 1137 "parse.y" |
| 109253 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy259, yymsp[-1].minor.yy4);} |
| 109254 | #line 3267 "parse.c" |
| 109255 | break; |
| 109256 | case 253: /* cmd ::= VACUUM */ |
| 109257 | case 254: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==254); |
| 109258 | #line 1143 "parse.y" |
| 109259 | {sqlite3Vacuum(pParse);} |
| 109260 | #line 3273 "parse.c" |
| 109261 | break; |
| 109262 | case 255: /* cmd ::= PRAGMA nm dbnm */ |
| 109263 | #line 1151 "parse.y" |
| 109264 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 109265 | #line 3278 "parse.c" |
| 109266 | break; |
| 109267 | case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 109268 | #line 1152 "parse.y" |
| 109269 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 109270 | #line 3283 "parse.c" |
| 109271 | break; |
| 109272 | case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 109273 | #line 1153 "parse.y" |
| 109274 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 109275 | #line 3288 "parse.c" |
| 109276 | break; |
| 109277 | case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 109278 | #line 1155 "parse.y" |
| 109279 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 109280 | #line 3293 "parse.c" |
| 109281 | break; |
| 109282 | case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 109283 | #line 1157 "parse.y" |
| 109284 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 109285 | #line 3298 "parse.c" |
| 109286 | break; |
| 109287 | case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 109288 | #line 1175 "parse.y" |
| 109289 | { |
| 109290 | Token all; |
| 109291 | all.z = yymsp[-3].minor.yy0.z; |
| 109292 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 109293 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy203, &all); |
| 109294 | } |
| 109295 | #line 3308 "parse.c" |
| 109296 | break; |
| 109297 | case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 109298 | #line 1184 "parse.y" |
| 109299 | { |
| 109300 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy4, yymsp[-4].minor.yy90.a, yymsp[-4].minor.yy90.b, yymsp[-2].minor.yy259, yymsp[0].minor.yy314, yymsp[-10].minor.yy4, yymsp[-8].minor.yy4); |
| 109301 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 109302 | } |
| 109303 | #line 3316 "parse.c" |
| 109304 | break; |
| 109305 | case 272: /* trigger_time ::= BEFORE */ |
| 109306 | case 275: /* trigger_time ::= */ yytestcase(yyruleno==275); |
| 109307 | #line 1190 "parse.y" |
| 109308 | { yygotominor.yy4 = TK_BEFORE; } |
| 109309 | #line 3322 "parse.c" |
| 109310 | break; |
| 109311 | case 273: /* trigger_time ::= AFTER */ |
| 109312 | #line 1191 "parse.y" |
| 109313 | { yygotominor.yy4 = TK_AFTER; } |
| 109314 | #line 3327 "parse.c" |
| 109315 | break; |
| 109316 | case 274: /* trigger_time ::= INSTEAD OF */ |
| 109317 | #line 1192 "parse.y" |
| 109318 | { yygotominor.yy4 = TK_INSTEAD;} |
| 109319 | #line 3332 "parse.c" |
| 109320 | break; |
| 109321 | case 276: /* trigger_event ::= DELETE|INSERT */ |
| 109322 | case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277); |
| 109323 | #line 1197 "parse.y" |
| 109324 | {yygotominor.yy90.a = yymsp[0].major; yygotominor.yy90.b = 0;} |
| 109325 | #line 3338 "parse.c" |
| 109326 | break; |
| 109327 | case 278: /* trigger_event ::= UPDATE OF inscollist */ |
| 109328 | #line 1199 "parse.y" |
| 109329 | {yygotominor.yy90.a = TK_UPDATE; yygotominor.yy90.b = yymsp[0].minor.yy384;} |
| 109330 | #line 3343 "parse.c" |
| 109331 | break; |
| 109332 | case 281: /* when_clause ::= */ |
| 109333 | case 303: /* key_opt ::= */ yytestcase(yyruleno==303); |
| 109334 | #line 1206 "parse.y" |
| 109335 | { yygotominor.yy314 = 0; } |
| 109336 | #line 3349 "parse.c" |
| 109337 | break; |
| 109338 | case 282: /* when_clause ::= WHEN expr */ |
| 109339 | case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304); |
| 109340 | #line 1207 "parse.y" |
| 109341 | { yygotominor.yy314 = yymsp[0].minor.yy118.pExpr; } |
| 109342 | #line 3355 "parse.c" |
| 109343 | break; |
| 109344 | case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 109345 | #line 1211 "parse.y" |
| 109346 | { |
| 109347 | assert( yymsp[-2].minor.yy203!=0 ); |
| 109348 | yymsp[-2].minor.yy203->pLast->pNext = yymsp[-1].minor.yy203; |
| 109349 | yymsp[-2].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 109350 | yygotominor.yy203 = yymsp[-2].minor.yy203; |
| 109351 | } |
| 109352 | #line 3365 "parse.c" |
| 109353 | break; |
| 109354 | case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 109355 | #line 1217 "parse.y" |
| 109356 | { |
| 109357 | assert( yymsp[-1].minor.yy203!=0 ); |
| 109358 | yymsp[-1].minor.yy203->pLast = yymsp[-1].minor.yy203; |
| 109359 | yygotominor.yy203 = yymsp[-1].minor.yy203; |
| 109360 | } |
| 109361 | #line 3374 "parse.c" |
| 109362 | break; |
| 109363 | case 286: /* trnm ::= nm DOT nm */ |
| 109364 | #line 1229 "parse.y" |
| 109365 | { |
| 109366 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 109367 | sqlite3ErrorMsg(pParse, |
| 109368 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 109369 | "statements within triggers"); |
| 109370 | } |
| 109371 | #line 3384 "parse.c" |
| 109372 | break; |
| 109373 | case 288: /* tridxby ::= INDEXED BY nm */ |
| 109374 | #line 1241 "parse.y" |
| 109375 | { |
| 109376 | sqlite3ErrorMsg(pParse, |
| 109377 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 109378 | "within triggers"); |
| 109379 | } |
| 109380 | #line 3393 "parse.c" |
| 109381 | break; |
| 109382 | case 289: /* tridxby ::= NOT INDEXED */ |
| 109383 | #line 1246 "parse.y" |
| 109384 | { |
| 109385 | sqlite3ErrorMsg(pParse, |
| 109386 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 109387 | "within triggers"); |
| 109388 | } |
| 109389 | #line 3402 "parse.c" |
| 109390 | break; |
| 109391 | case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 109392 | #line 1259 "parse.y" |
| 109393 | { yygotominor.yy203 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy322, yymsp[0].minor.yy314, yymsp[-5].minor.yy210); } |
| 109394 | #line 3407 "parse.c" |
| 109395 | break; |
| 109396 | case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */ |
| 109397 | #line 1264 "parse.y" |
| 109398 | {yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy384, yymsp[-1].minor.yy322, 0, yymsp[-7].minor.yy210);} |
| 109399 | #line 3412 "parse.c" |
| 109400 | break; |
| 109401 | case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 109402 | #line 1267 "parse.y" |
| 109403 | {yygotominor.yy203 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy384, 0, yymsp[0].minor.yy387, yymsp[-4].minor.yy210);} |
| 109404 | #line 3417 "parse.c" |
| 109405 | break; |
| 109406 | case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 109407 | #line 1271 "parse.y" |
| 109408 | {yygotominor.yy203 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy314);} |
| 109409 | #line 3422 "parse.c" |
| 109410 | break; |
| 109411 | case 294: /* trigger_cmd ::= select */ |
| 109412 | #line 1274 "parse.y" |
| 109413 | {yygotominor.yy203 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy387); } |
| 109414 | #line 3427 "parse.c" |
| 109415 | break; |
| 109416 | case 295: /* expr ::= RAISE LP IGNORE RP */ |
| 109417 | #line 1277 "parse.y" |
| 109418 | { |
| 109419 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 109420 | if( yygotominor.yy118.pExpr ){ |
| 109421 | yygotominor.yy118.pExpr->affinity = OE_Ignore; |
| 109422 | } |
| 109423 | yygotominor.yy118.zStart = yymsp[-3].minor.yy0.z; |
| 109424 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 109425 | } |
| 109426 | #line 3439 "parse.c" |
| 109427 | break; |
| 109428 | case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 109429 | #line 1285 "parse.y" |
| 109430 | { |
| 109431 | yygotominor.yy118.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 109432 | if( yygotominor.yy118.pExpr ) { |
| 109433 | yygotominor.yy118.pExpr->affinity = (char)yymsp[-3].minor.yy4; |
| 109434 | } |
| 109435 | yygotominor.yy118.zStart = yymsp[-5].minor.yy0.z; |
| 109436 | yygotominor.yy118.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 109437 | } |
| 109438 | #line 3451 "parse.c" |
| 109439 | break; |
| 109440 | case 297: /* raisetype ::= ROLLBACK */ |
| 109441 | #line 1296 "parse.y" |
| 109442 | {yygotominor.yy4 = OE_Rollback;} |
| 109443 | #line 3456 "parse.c" |
| 109444 | break; |
| 109445 | case 299: /* raisetype ::= FAIL */ |
| 109446 | #line 1298 "parse.y" |
| 109447 | {yygotominor.yy4 = OE_Fail;} |
| 109448 | #line 3461 "parse.c" |
| 109449 | break; |
| 109450 | case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 109451 | #line 1303 "parse.y" |
| 109452 | { |
| 109453 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy259,yymsp[-1].minor.yy4); |
| 109454 | } |
| 109455 | #line 3468 "parse.c" |
| 109456 | break; |
| 109457 | case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 109458 | #line 1310 "parse.y" |
| 109459 | { |
| 109460 | sqlite3Attach(pParse, yymsp[-3].minor.yy118.pExpr, yymsp[-1].minor.yy118.pExpr, yymsp[0].minor.yy314); |
| 109461 | } |
| 109462 | #line 3475 "parse.c" |
| 109463 | break; |
| 109464 | case 302: /* cmd ::= DETACH database_kw_opt expr */ |
| 109465 | #line 1313 "parse.y" |
| 109466 | { |
| 109467 | sqlite3Detach(pParse, yymsp[0].minor.yy118.pExpr); |
| 109468 | } |
| 109469 | #line 3482 "parse.c" |
| 109470 | break; |
| 109471 | case 307: /* cmd ::= REINDEX */ |
| 109472 | #line 1328 "parse.y" |
| 109473 | {sqlite3Reindex(pParse, 0, 0);} |
| 109474 | #line 3487 "parse.c" |
| 109475 | break; |
| 109476 | case 308: /* cmd ::= REINDEX nm dbnm */ |
| 109477 | #line 1329 "parse.y" |
| 109478 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 109479 | #line 3492 "parse.c" |
| 109480 | break; |
| 109481 | case 309: /* cmd ::= ANALYZE */ |
| 109482 | #line 1334 "parse.y" |
| 109483 | {sqlite3Analyze(pParse, 0, 0);} |
| 109484 | #line 3497 "parse.c" |
| 109485 | break; |
| 109486 | case 310: /* cmd ::= ANALYZE nm dbnm */ |
| 109487 | #line 1335 "parse.y" |
| 109488 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 109489 | #line 3502 "parse.c" |
| 109490 | break; |
| 109491 | case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 109492 | #line 1340 "parse.y" |
| 109493 | { |
| 109494 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy259,&yymsp[0].minor.yy0); |
| 109495 | } |
| 109496 | #line 3509 "parse.c" |
| 109497 | break; |
| 109498 | case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 109499 | #line 1343 "parse.y" |
| 109500 | { |
| 109501 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 109502 | } |
| 109503 | #line 3516 "parse.c" |
| 109504 | break; |
| 109505 | case 313: /* add_column_fullname ::= fullname */ |
| 109506 | #line 1346 "parse.y" |
| 109507 | { |
| 109508 | pParse->db->lookaside.bEnabled = 0; |
| 109509 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy259); |
| 109510 | } |
| 109511 | #line 3524 "parse.c" |
| 109512 | break; |
| 109513 | case 316: /* cmd ::= create_vtab */ |
| 109514 | #line 1356 "parse.y" |
| 109515 | {sqlite3VtabFinishParse(pParse,0);} |
| 109516 | #line 3529 "parse.c" |
| 109517 | break; |
| 109518 | case 317: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 109519 | #line 1357 "parse.y" |
| 109520 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 109521 | #line 3534 "parse.c" |
| 109522 | break; |
| 109523 | case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */ |
| 109524 | #line 1358 "parse.y" |
| 109525 | { |
| 109526 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 109527 | } |
| 109528 | #line 3541 "parse.c" |
| 109529 | break; |
| 109530 | case 321: /* vtabarg ::= */ |
| 109531 | #line 1363 "parse.y" |
| 109532 | {sqlite3VtabArgInit(pParse);} |
| 109533 | #line 3546 "parse.c" |
| 109534 | break; |
| 109535 | case 323: /* vtabargtoken ::= ANY */ |
| 109536 | case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324); |
| 109537 | case 325: /* lp ::= LP */ yytestcase(yyruleno==325); |
| 109538 | #line 1365 "parse.y" |
| 109539 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 109540 | #line 3553 "parse.c" |
| 109541 | break; |
| 109542 | default: |
| 109543 | /* (0) input ::= cmdlist */ yytestcase(yyruleno==0); |
| 109544 | /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1); |
| 109545 | /* (2) cmdlist ::= ecmd */ yytestcase(yyruleno==2); |
| @@ -108764,15 +109637,17 @@ | |
| 109637 | int yymajor, /* The major type of the error token */ |
| 109638 | YYMINORTYPE yyminor /* The minor type of the error token */ |
| 109639 | ){ |
| 109640 | sqlite3ParserARG_FETCH; |
| 109641 | #define TOKEN (yyminor.yy0) |
| 109642 | #line 32 "parse.y" |
| 109643 | |
| 109644 | UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ |
| 109645 | assert( TOKEN.z[0] ); /* The tokenizer always gives us a token */ |
| 109646 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); |
| 109647 | pParse->parseError = 1; |
| 109648 | #line 3661 "parse.c" |
| 109649 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| 109650 | } |
| 109651 | |
| 109652 | /* |
| 109653 | ** The following is executed when the parser accepts |
| @@ -108962,10 +109837,11 @@ | |
| 109837 | return; |
| 109838 | } |
| 109839 | |
| 109840 | /************** End of parse.c ***********************************************/ |
| 109841 | /************** Begin file tokenize.c ****************************************/ |
| 109842 | #line 1 "tsrc/tokenize.c" |
| 109843 | /* |
| 109844 | ** 2001 September 15 |
| 109845 | ** |
| 109846 | ** The author disclaims copyright to this source code. In place of |
| 109847 | ** a legal notice, here is a blessing: |
| @@ -109027,10 +109903,11 @@ | |
| 109903 | ** named keywordhash.h and then included into this source file by |
| 109904 | ** the #include below. |
| 109905 | */ |
| 109906 | /************** Include keywordhash.h in the middle of tokenize.c ************/ |
| 109907 | /************** Begin file keywordhash.h *************************************/ |
| 109908 | #line 1 "tsrc/keywordhash.h" |
| 109909 | /***** This file contains automatically generated code ****** |
| 109910 | ** |
| 109911 | ** The code in this file has been automatically generated by |
| 109912 | ** |
| 109913 | ** sqlite/tool/mkkeywordhash.c |
| @@ -109300,10 +110177,11 @@ | |
| 110177 | } |
| 110178 | #define SQLITE_N_KEYWORD 121 |
| 110179 | |
| 110180 | /************** End of keywordhash.h *****************************************/ |
| 110181 | /************** Continuing where we left off in tokenize.c *******************/ |
| 110182 | #line 66 "tsrc/tokenize.c" |
| 110183 | |
| 110184 | |
| 110185 | /* |
| 110186 | ** If X is a character that can be used in an identifier then |
| 110187 | ** IdChar(X) will be true. Otherwise it is false. |
| @@ -109764,10 +110642,11 @@ | |
| 110642 | return nErr; |
| 110643 | } |
| 110644 | |
| 110645 | /************** End of tokenize.c ********************************************/ |
| 110646 | /************** Begin file complete.c ****************************************/ |
| 110647 | #line 1 "tsrc/complete.c" |
| 110648 | /* |
| 110649 | ** 2001 September 15 |
| 110650 | ** |
| 110651 | ** The author disclaims copyright to this source code. In place of |
| 110652 | ** a legal notice, here is a blessing: |
| @@ -110049,10 +110928,11 @@ | |
| 110928 | #endif /* SQLITE_OMIT_UTF16 */ |
| 110929 | #endif /* SQLITE_OMIT_COMPLETE */ |
| 110930 | |
| 110931 | /************** End of complete.c ********************************************/ |
| 110932 | /************** Begin file main.c ********************************************/ |
| 110933 | #line 1 "tsrc/main.c" |
| 110934 | /* |
| 110935 | ** 2001 September 15 |
| 110936 | ** |
| 110937 | ** The author disclaims copyright to this source code. In place of |
| 110938 | ** a legal notice, here is a blessing: |
| @@ -110069,10 +110949,11 @@ | |
| 110949 | */ |
| 110950 | |
| 110951 | #ifdef SQLITE_ENABLE_FTS3 |
| 110952 | /************** Include fts3.h in the middle of main.c ***********************/ |
| 110953 | /************** Begin file fts3.h ********************************************/ |
| 110954 | #line 1 "tsrc/fts3.h" |
| 110955 | /* |
| 110956 | ** 2006 Oct 10 |
| 110957 | ** |
| 110958 | ** The author disclaims copyright to this source code. In place of |
| 110959 | ** a legal notice, here is a blessing: |
| @@ -110097,14 +110978,16 @@ | |
| 110978 | } /* extern "C" */ |
| 110979 | #endif /* __cplusplus */ |
| 110980 | |
| 110981 | /************** End of fts3.h ************************************************/ |
| 110982 | /************** Continuing where we left off in main.c ***********************/ |
| 110983 | #line 21 "tsrc/main.c" |
| 110984 | #endif |
| 110985 | #ifdef SQLITE_ENABLE_RTREE |
| 110986 | /************** Include rtree.h in the middle of main.c **********************/ |
| 110987 | /************** Begin file rtree.h *******************************************/ |
| 110988 | #line 1 "tsrc/rtree.h" |
| 110989 | /* |
| 110990 | ** 2008 May 26 |
| 110991 | ** |
| 110992 | ** The author disclaims copyright to this source code. In place of |
| 110993 | ** a legal notice, here is a blessing: |
| @@ -110129,14 +111012,16 @@ | |
| 111012 | } /* extern "C" */ |
| 111013 | #endif /* __cplusplus */ |
| 111014 | |
| 111015 | /************** End of rtree.h ***********************************************/ |
| 111016 | /************** Continuing where we left off in main.c ***********************/ |
| 111017 | #line 24 "tsrc/main.c" |
| 111018 | #endif |
| 111019 | #ifdef SQLITE_ENABLE_ICU |
| 111020 | /************** Include sqliteicu.h in the middle of main.c ******************/ |
| 111021 | /************** Begin file sqliteicu.h ***************************************/ |
| 111022 | #line 1 "tsrc/sqliteicu.h" |
| 111023 | /* |
| 111024 | ** 2008 May 26 |
| 111025 | ** |
| 111026 | ** The author disclaims copyright to this source code. In place of |
| 111027 | ** a legal notice, here is a blessing: |
| @@ -110162,10 +111047,11 @@ | |
| 111047 | #endif /* __cplusplus */ |
| 111048 | |
| 111049 | |
| 111050 | /************** End of sqliteicu.h *******************************************/ |
| 111051 | /************** Continuing where we left off in main.c ***********************/ |
| 111052 | #line 27 "tsrc/main.c" |
| 111053 | #endif |
| 111054 | |
| 111055 | #ifndef SQLITE_AMALGAMATION |
| 111056 | /* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant |
| 111057 | ** contains the text of SQLITE_VERSION macro. |
| @@ -113092,10 +113978,11 @@ | |
| 113978 | return 0; |
| 113979 | } |
| 113980 | |
| 113981 | /************** End of main.c ************************************************/ |
| 113982 | /************** Begin file notify.c ******************************************/ |
| 113983 | #line 1 "tsrc/notify.c" |
| 113984 | /* |
| 113985 | ** 2009 March 3 |
| 113986 | ** |
| 113987 | ** The author disclaims copyright to this source code. In place of |
| 113988 | ** a legal notice, here is a blessing: |
| @@ -113425,10 +114312,11 @@ | |
| 114312 | } |
| 114313 | #endif |
| 114314 | |
| 114315 | /************** End of notify.c **********************************************/ |
| 114316 | /************** Begin file fts3.c ********************************************/ |
| 114317 | #line 1 "tsrc/fts3.c" |
| 114318 | /* |
| 114319 | ** 2006 Oct 10 |
| 114320 | ** |
| 114321 | ** The author disclaims copyright to this source code. In place of |
| 114322 | ** a legal notice, here is a blessing: |
| @@ -113721,10 +114609,11 @@ | |
| 114609 | ** into a single segment. |
| 114610 | */ |
| 114611 | |
| 114612 | /************** Include fts3Int.h in the middle of fts3.c ********************/ |
| 114613 | /************** Begin file fts3Int.h *****************************************/ |
| 114614 | #line 1 "tsrc/fts3Int.h" |
| 114615 | /* |
| 114616 | ** 2009 Nov 12 |
| 114617 | ** |
| 114618 | ** The author disclaims copyright to this source code. In place of |
| 114619 | ** a legal notice, here is a blessing: |
| @@ -113759,10 +114648,11 @@ | |
| 114648 | SQLITE_API extern const sqlite3_api_routines *sqlite3_api; |
| 114649 | #endif |
| 114650 | |
| 114651 | /************** Include fts3_tokenizer.h in the middle of fts3Int.h **********/ |
| 114652 | /************** Begin file fts3_tokenizer.h **********************************/ |
| 114653 | #line 1 "tsrc/fts3_tokenizer.h" |
| 114654 | /* |
| 114655 | ** 2006 July 10 |
| 114656 | ** |
| 114657 | ** The author disclaims copyright to this source code. |
| 114658 | ** |
| @@ -113913,12 +114803,14 @@ | |
| 114803 | |
| 114804 | #endif /* _FTS3_TOKENIZER_H_ */ |
| 114805 | |
| 114806 | /************** End of fts3_tokenizer.h **************************************/ |
| 114807 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 114808 | #line 40 "tsrc/fts3Int.h" |
| 114809 | /************** Include fts3_hash.h in the middle of fts3Int.h ***************/ |
| 114810 | /************** Begin file fts3_hash.h ***************************************/ |
| 114811 | #line 1 "tsrc/fts3_hash.h" |
| 114812 | /* |
| 114813 | ** 2001 September 22 |
| 114814 | ** |
| 114815 | ** The author disclaims copyright to this source code. In place of |
| 114816 | ** a legal notice, here is a blessing: |
| @@ -114030,10 +114922,11 @@ | |
| 114922 | |
| 114923 | #endif /* _FTS3_HASH_H_ */ |
| 114924 | |
| 114925 | /************** End of fts3_hash.h *******************************************/ |
| 114926 | /************** Continuing where we left off in fts3Int.h ********************/ |
| 114927 | #line 41 "tsrc/fts3Int.h" |
| 114928 | |
| 114929 | /* |
| 114930 | ** This constant controls how often segments are merged. Once there are |
| 114931 | ** FTS3_MERGE_COUNT segments of level N, they are merged into a single |
| 114932 | ** segment of level N+1. |
| @@ -114506,10 +115399,11 @@ | |
| 115399 | #endif /* !SQLITE_CORE || SQLITE_ENABLE_FTS3 */ |
| 115400 | #endif /* _FTSINT_H */ |
| 115401 | |
| 115402 | /************** End of fts3Int.h *********************************************/ |
| 115403 | /************** Continuing where we left off in fts3.c ***********************/ |
| 115404 | #line 296 "tsrc/fts3.c" |
| 115405 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 115406 | |
| 115407 | #if defined(SQLITE_ENABLE_FTS3) && !defined(SQLITE_CORE) |
| 115408 | # define SQLITE_CORE 1 |
| 115409 | #endif |
| @@ -119055,10 +119949,11 @@ | |
| 119949 | |
| 119950 | #endif |
| 119951 | |
| 119952 | /************** End of fts3.c ************************************************/ |
| 119953 | /************** Begin file fts3_aux.c ****************************************/ |
| 119954 | #line 1 "tsrc/fts3_aux.c" |
| 119955 | /* |
| 119956 | ** 2011 Jan 27 |
| 119957 | ** |
| 119958 | ** The author disclaims copyright to this source code. In place of |
| 119959 | ** a legal notice, here is a blessing: |
| @@ -119531,10 +120426,11 @@ | |
| 120426 | |
| 120427 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 120428 | |
| 120429 | /************** End of fts3_aux.c ********************************************/ |
| 120430 | /************** Begin file fts3_expr.c ***************************************/ |
| 120431 | #line 1 "tsrc/fts3_expr.c" |
| 120432 | /* |
| 120433 | ** 2008 Nov 28 |
| 120434 | ** |
| 120435 | ** The author disclaims copyright to this source code. In place of |
| 120436 | ** a legal notice, here is a blessing: |
| @@ -120497,10 +121393,11 @@ | |
| 121393 | #endif |
| 121394 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 121395 | |
| 121396 | /************** End of fts3_expr.c *******************************************/ |
| 121397 | /************** Begin file fts3_hash.c ***************************************/ |
| 121398 | #line 1 "tsrc/fts3_hash.c" |
| 121399 | /* |
| 121400 | ** 2001 September 22 |
| 121401 | ** |
| 121402 | ** The author disclaims copyright to this source code. In place of |
| 121403 | ** a legal notice, here is a blessing: |
| @@ -120881,10 +121778,11 @@ | |
| 121778 | |
| 121779 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 121780 | |
| 121781 | /************** End of fts3_hash.c *******************************************/ |
| 121782 | /************** Begin file fts3_porter.c *************************************/ |
| 121783 | #line 1 "tsrc/fts3_porter.c" |
| 121784 | /* |
| 121785 | ** 2006 September 30 |
| 121786 | ** |
| 121787 | ** The author disclaims copyright to this source code. In place of |
| 121788 | ** a legal notice, here is a blessing: |
| @@ -121527,10 +122425,11 @@ | |
| 122425 | |
| 122426 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 122427 | |
| 122428 | /************** End of fts3_porter.c *****************************************/ |
| 122429 | /************** Begin file fts3_tokenizer.c **********************************/ |
| 122430 | #line 1 "tsrc/fts3_tokenizer.c" |
| 122431 | /* |
| 122432 | ** 2007 June 22 |
| 122433 | ** |
| 122434 | ** The author disclaims copyright to this source code. In place of |
| 122435 | ** a legal notice, here is a blessing: |
| @@ -122018,10 +122917,11 @@ | |
| 122917 | |
| 122918 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 122919 | |
| 122920 | /************** End of fts3_tokenizer.c **************************************/ |
| 122921 | /************** Begin file fts3_tokenizer1.c *********************************/ |
| 122922 | #line 1 "tsrc/fts3_tokenizer1.c" |
| 122923 | /* |
| 122924 | ** 2006 Oct 10 |
| 122925 | ** |
| 122926 | ** The author disclaims copyright to this source code. In place of |
| 122927 | ** a legal notice, here is a blessing: |
| @@ -122252,10 +123152,11 @@ | |
| 123152 | |
| 123153 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 123154 | |
| 123155 | /************** End of fts3_tokenizer1.c *************************************/ |
| 123156 | /************** Begin file fts3_write.c **************************************/ |
| 123157 | #line 1 "tsrc/fts3_write.c" |
| 123158 | /* |
| 123159 | ** 2009 Oct 23 |
| 123160 | ** |
| 123161 | ** The author disclaims copyright to this source code. In place of |
| 123162 | ** a legal notice, here is a blessing: |
| @@ -125522,10 +126423,11 @@ | |
| 126423 | |
| 126424 | #endif |
| 126425 | |
| 126426 | /************** End of fts3_write.c ******************************************/ |
| 126427 | /************** Begin file fts3_snippet.c ************************************/ |
| 126428 | #line 1 "tsrc/fts3_snippet.c" |
| 126429 | /* |
| 126430 | ** 2009 Oct 23 |
| 126431 | ** |
| 126432 | ** The author disclaims copyright to this source code. In place of |
| 126433 | ** a legal notice, here is a blessing: |
| @@ -127023,10 +127925,11 @@ | |
| 127925 | |
| 127926 | #endif |
| 127927 | |
| 127928 | /************** End of fts3_snippet.c ****************************************/ |
| 127929 | /************** Begin file rtree.c *******************************************/ |
| 127930 | #line 1 "tsrc/rtree.c" |
| 127931 | /* |
| 127932 | ** 2001 September 15 |
| 127933 | ** |
| 127934 | ** The author disclaims copyright to this source code. In place of |
| 127935 | ** a legal notice, here is a blessing: |
| @@ -130304,10 +131207,11 @@ | |
| 131207 | |
| 131208 | #endif |
| 131209 | |
| 131210 | /************** End of rtree.c ***********************************************/ |
| 131211 | /************** Begin file icu.c *********************************************/ |
| 131212 | #line 1 "tsrc/icu.c" |
| 131213 | /* |
| 131214 | ** 2007 May 6 |
| 131215 | ** |
| 131216 | ** The author disclaims copyright to this source code. In place of |
| 131217 | ** a legal notice, here is a blessing: |
| @@ -130806,10 +131710,11 @@ | |
| 131710 | |
| 131711 | #endif |
| 131712 | |
| 131713 | /************** End of icu.c *************************************************/ |
| 131714 | /************** Begin file fts3_icu.c ****************************************/ |
| 131715 | #line 1 "tsrc/fts3_icu.c" |
| 131716 | /* |
| 131717 | ** 2007 June 22 |
| 131718 | ** |
| 131719 | ** The author disclaims copyright to this source code. In place of |
| 131720 | ** a legal notice, here is a blessing: |
| 131721 |
+31
-7
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -105,13 +105,13 @@ | ||
| 105 | 105 | ** |
| 106 | 106 | ** See also: [sqlite3_libversion()], |
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | -#define SQLITE_VERSION "3.7.8" | |
| 111 | -#define SQLITE_VERSION_NUMBER 3007008 | |
| 112 | -#define SQLITE_SOURCE_ID "2011-09-19 14:49:19 3e0da808d2f5b4d12046e05980ca04578f581177" | |
| 110 | +#define SQLITE_VERSION "3.7.9" | |
| 111 | +#define SQLITE_VERSION_NUMBER 3007009 | |
| 112 | +#define SQLITE_SOURCE_ID "2011-10-07 18:24:25 d4f95b3b6e9f4a4072606af5daa17ea7c645382e" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -769,11 +769,15 @@ | ||
| 769 | 769 | ** in order for the database to be readable. The fourth parameter to |
| 770 | 770 | ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
| 771 | 771 | ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent |
| 772 | 772 | ** WAL mode. If the integer is -1, then it is overwritten with the current |
| 773 | 773 | ** WAL persistence setting. |
| 774 | -** | |
| 774 | +** | |
| 775 | +** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening | |
| 776 | +** a write transaction to indicate that, unless it is rolled back for some | |
| 777 | +** reason, the entire database file will be overwritten by the current | |
| 778 | +** transaction. This is used by VACUUM operations. | |
| 775 | 779 | */ |
| 776 | 780 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 777 | 781 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 778 | 782 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 779 | 783 | #define SQLITE_LAST_ERRNO 4 |
| @@ -781,10 +785,11 @@ | ||
| 781 | 785 | #define SQLITE_FCNTL_CHUNK_SIZE 6 |
| 782 | 786 | #define SQLITE_FCNTL_FILE_POINTER 7 |
| 783 | 787 | #define SQLITE_FCNTL_SYNC_OMITTED 8 |
| 784 | 788 | #define SQLITE_FCNTL_WIN32_AV_RETRY 9 |
| 785 | 789 | #define SQLITE_FCNTL_PERSIST_WAL 10 |
| 790 | +#define SQLITE_FCNTL_OVERWRITE 11 | |
| 786 | 791 | |
| 787 | 792 | /* |
| 788 | 793 | ** CAPI3REF: Mutex Handle |
| 789 | 794 | ** |
| 790 | 795 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| @@ -2848,11 +2853,11 @@ | ||
| 2848 | 2853 | ** a schema change, on the first [sqlite3_step()] call following any change |
| 2849 | 2854 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 2850 | 2855 | ** ^The specific value of WHERE-clause [parameter] might influence the |
| 2851 | 2856 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 2852 | 2857 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 2853 | -** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. | |
| 2858 | +** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. | |
| 2854 | 2859 | ** the |
| 2855 | 2860 | ** </li> |
| 2856 | 2861 | ** </ol> |
| 2857 | 2862 | */ |
| 2858 | 2863 | SQLITE_API int sqlite3_prepare( |
| @@ -3351,10 +3356,16 @@ | ||
| 3351 | 3356 | ** current row of the result set of [prepared statement] P. |
| 3352 | 3357 | ** ^If prepared statement P does not have results ready to return |
| 3353 | 3358 | ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 3354 | 3359 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 3355 | 3360 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 3361 | +** ^The sqlite3_data_count(P) routine returns 0 if the previous call to | |
| 3362 | +** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) | |
| 3363 | +** will return non-zero if previous call to [sqlite3_step](P) returned | |
| 3364 | +** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum] | |
| 3365 | +** where it always returns zero since each step of that multi-step | |
| 3366 | +** pragma returns 0 columns of data. | |
| 3356 | 3367 | ** |
| 3357 | 3368 | ** See also: [sqlite3_column_count()] |
| 3358 | 3369 | */ |
| 3359 | 3370 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 3360 | 3371 | |
| @@ -5813,20 +5824,34 @@ | ||
| 5813 | 5824 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5814 | 5825 | ** and lookaside memory used by all prepared statements associated with |
| 5815 | 5826 | ** the database connection.)^ |
| 5816 | 5827 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5817 | 5828 | ** </dd> |
| 5829 | +** | |
| 5830 | +** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt> | |
| 5831 | +** <dd>This parameter returns the number of pager cache hits that have | |
| 5832 | +** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT | |
| 5833 | +** is always 0. | |
| 5834 | +** </dd> | |
| 5835 | +** | |
| 5836 | +** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt> | |
| 5837 | +** <dd>This parameter returns the number of pager cache misses that have | |
| 5838 | +** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS | |
| 5839 | +** is always 0. | |
| 5840 | +** </dd> | |
| 5818 | 5841 | ** </dl> |
| 5819 | 5842 | */ |
| 5820 | 5843 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5821 | 5844 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 5822 | 5845 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 5823 | 5846 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 5824 | 5847 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 5825 | 5848 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 5826 | 5849 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 5827 | -#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ | |
| 5850 | +#define SQLITE_DBSTATUS_CACHE_HIT 7 | |
| 5851 | +#define SQLITE_DBSTATUS_CACHE_MISS 8 | |
| 5852 | +#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */ | |
| 5828 | 5853 | |
| 5829 | 5854 | |
| 5830 | 5855 | /* |
| 5831 | 5856 | ** CAPI3REF: Prepared Statement Status |
| 5832 | 5857 | ** |
| @@ -5876,11 +5901,10 @@ | ||
| 5876 | 5901 | ** <dd>^This is the number of rows inserted into transient indices that |
| 5877 | 5902 | ** were created automatically in order to help joins run faster. |
| 5878 | 5903 | ** A non-zero value in this counter may indicate an opportunity to |
| 5879 | 5904 | ** improvement performance by adding permanent indices that do not |
| 5880 | 5905 | ** need to be reinitialized each time the statement is run.</dd> |
| 5881 | -** | |
| 5882 | 5906 | ** </dl> |
| 5883 | 5907 | */ |
| 5884 | 5908 | #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
| 5885 | 5909 | #define SQLITE_STMTSTATUS_SORT 2 |
| 5886 | 5910 | #define SQLITE_STMTSTATUS_AUTOINDEX 3 |
| 5887 | 5911 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -105,13 +105,13 @@ | |
| 105 | ** |
| 106 | ** See also: [sqlite3_libversion()], |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.8" |
| 111 | #define SQLITE_VERSION_NUMBER 3007008 |
| 112 | #define SQLITE_SOURCE_ID "2011-09-19 14:49:19 3e0da808d2f5b4d12046e05980ca04578f581177" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -769,11 +769,15 @@ | |
| 769 | ** in order for the database to be readable. The fourth parameter to |
| 770 | ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
| 771 | ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent |
| 772 | ** WAL mode. If the integer is -1, then it is overwritten with the current |
| 773 | ** WAL persistence setting. |
| 774 | ** |
| 775 | */ |
| 776 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 777 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 778 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 779 | #define SQLITE_LAST_ERRNO 4 |
| @@ -781,10 +785,11 @@ | |
| 781 | #define SQLITE_FCNTL_CHUNK_SIZE 6 |
| 782 | #define SQLITE_FCNTL_FILE_POINTER 7 |
| 783 | #define SQLITE_FCNTL_SYNC_OMITTED 8 |
| 784 | #define SQLITE_FCNTL_WIN32_AV_RETRY 9 |
| 785 | #define SQLITE_FCNTL_PERSIST_WAL 10 |
| 786 | |
| 787 | /* |
| 788 | ** CAPI3REF: Mutex Handle |
| 789 | ** |
| 790 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| @@ -2848,11 +2853,11 @@ | |
| 2848 | ** a schema change, on the first [sqlite3_step()] call following any change |
| 2849 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 2850 | ** ^The specific value of WHERE-clause [parameter] might influence the |
| 2851 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 2852 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 2853 | ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled. |
| 2854 | ** the |
| 2855 | ** </li> |
| 2856 | ** </ol> |
| 2857 | */ |
| 2858 | SQLITE_API int sqlite3_prepare( |
| @@ -3351,10 +3356,16 @@ | |
| 3351 | ** current row of the result set of [prepared statement] P. |
| 3352 | ** ^If prepared statement P does not have results ready to return |
| 3353 | ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 3354 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 3355 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 3356 | ** |
| 3357 | ** See also: [sqlite3_column_count()] |
| 3358 | */ |
| 3359 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 3360 | |
| @@ -5813,20 +5824,34 @@ | |
| 5813 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5814 | ** and lookaside memory used by all prepared statements associated with |
| 5815 | ** the database connection.)^ |
| 5816 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5817 | ** </dd> |
| 5818 | ** </dl> |
| 5819 | */ |
| 5820 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5821 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 5822 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 5823 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 5824 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 5825 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 5826 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 5827 | #define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ |
| 5828 | |
| 5829 | |
| 5830 | /* |
| 5831 | ** CAPI3REF: Prepared Statement Status |
| 5832 | ** |
| @@ -5876,11 +5901,10 @@ | |
| 5876 | ** <dd>^This is the number of rows inserted into transient indices that |
| 5877 | ** were created automatically in order to help joins run faster. |
| 5878 | ** A non-zero value in this counter may indicate an opportunity to |
| 5879 | ** improvement performance by adding permanent indices that do not |
| 5880 | ** need to be reinitialized each time the statement is run.</dd> |
| 5881 | ** |
| 5882 | ** </dl> |
| 5883 | */ |
| 5884 | #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
| 5885 | #define SQLITE_STMTSTATUS_SORT 2 |
| 5886 | #define SQLITE_STMTSTATUS_AUTOINDEX 3 |
| 5887 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -105,13 +105,13 @@ | |
| 105 | ** |
| 106 | ** See also: [sqlite3_libversion()], |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.9" |
| 111 | #define SQLITE_VERSION_NUMBER 3007009 |
| 112 | #define SQLITE_SOURCE_ID "2011-10-07 18:24:25 d4f95b3b6e9f4a4072606af5daa17ea7c645382e" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -769,11 +769,15 @@ | |
| 769 | ** in order for the database to be readable. The fourth parameter to |
| 770 | ** [sqlite3_file_control()] for this opcode should be a pointer to an integer. |
| 771 | ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent |
| 772 | ** WAL mode. If the integer is -1, then it is overwritten with the current |
| 773 | ** WAL persistence setting. |
| 774 | ** |
| 775 | ** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening |
| 776 | ** a write transaction to indicate that, unless it is rolled back for some |
| 777 | ** reason, the entire database file will be overwritten by the current |
| 778 | ** transaction. This is used by VACUUM operations. |
| 779 | */ |
| 780 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 781 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 782 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 783 | #define SQLITE_LAST_ERRNO 4 |
| @@ -781,10 +785,11 @@ | |
| 785 | #define SQLITE_FCNTL_CHUNK_SIZE 6 |
| 786 | #define SQLITE_FCNTL_FILE_POINTER 7 |
| 787 | #define SQLITE_FCNTL_SYNC_OMITTED 8 |
| 788 | #define SQLITE_FCNTL_WIN32_AV_RETRY 9 |
| 789 | #define SQLITE_FCNTL_PERSIST_WAL 10 |
| 790 | #define SQLITE_FCNTL_OVERWRITE 11 |
| 791 | |
| 792 | /* |
| 793 | ** CAPI3REF: Mutex Handle |
| 794 | ** |
| 795 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| @@ -2848,11 +2853,11 @@ | |
| 2853 | ** a schema change, on the first [sqlite3_step()] call following any change |
| 2854 | ** to the [sqlite3_bind_text | bindings] of that [parameter]. |
| 2855 | ** ^The specific value of WHERE-clause [parameter] might influence the |
| 2856 | ** choice of query plan if the parameter is the left-hand side of a [LIKE] |
| 2857 | ** or [GLOB] operator or if the parameter is compared to an indexed column |
| 2858 | ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. |
| 2859 | ** the |
| 2860 | ** </li> |
| 2861 | ** </ol> |
| 2862 | */ |
| 2863 | SQLITE_API int sqlite3_prepare( |
| @@ -3351,10 +3356,16 @@ | |
| 3356 | ** current row of the result set of [prepared statement] P. |
| 3357 | ** ^If prepared statement P does not have results ready to return |
| 3358 | ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of |
| 3359 | ** interfaces) then sqlite3_data_count(P) returns 0. |
| 3360 | ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer. |
| 3361 | ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to |
| 3362 | ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P) |
| 3363 | ** will return non-zero if previous call to [sqlite3_step](P) returned |
| 3364 | ** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum] |
| 3365 | ** where it always returns zero since each step of that multi-step |
| 3366 | ** pragma returns 0 columns of data. |
| 3367 | ** |
| 3368 | ** See also: [sqlite3_column_count()] |
| 3369 | */ |
| 3370 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 3371 | |
| @@ -5813,20 +5824,34 @@ | |
| 5824 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5825 | ** and lookaside memory used by all prepared statements associated with |
| 5826 | ** the database connection.)^ |
| 5827 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5828 | ** </dd> |
| 5829 | ** |
| 5830 | ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt> |
| 5831 | ** <dd>This parameter returns the number of pager cache hits that have |
| 5832 | ** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT |
| 5833 | ** is always 0. |
| 5834 | ** </dd> |
| 5835 | ** |
| 5836 | ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt> |
| 5837 | ** <dd>This parameter returns the number of pager cache misses that have |
| 5838 | ** occurred. ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS |
| 5839 | ** is always 0. |
| 5840 | ** </dd> |
| 5841 | ** </dl> |
| 5842 | */ |
| 5843 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5844 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 5845 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 5846 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 5847 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 5848 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 5849 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 5850 | #define SQLITE_DBSTATUS_CACHE_HIT 7 |
| 5851 | #define SQLITE_DBSTATUS_CACHE_MISS 8 |
| 5852 | #define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */ |
| 5853 | |
| 5854 | |
| 5855 | /* |
| 5856 | ** CAPI3REF: Prepared Statement Status |
| 5857 | ** |
| @@ -5876,11 +5901,10 @@ | |
| 5901 | ** <dd>^This is the number of rows inserted into transient indices that |
| 5902 | ** were created automatically in order to help joins run faster. |
| 5903 | ** A non-zero value in this counter may indicate an opportunity to |
| 5904 | ** improvement performance by adding permanent indices that do not |
| 5905 | ** need to be reinitialized each time the statement is run.</dd> |
| 5906 | ** </dl> |
| 5907 | */ |
| 5908 | #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 |
| 5909 | #define SQLITE_STMTSTATUS_SORT 2 |
| 5910 | #define SQLITE_STMTSTATUS_AUTOINDEX 3 |
| 5911 |