| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.8.11.1. By combining all the individual C code files into this |
| 3 | +** version 3.8.12. 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. |
| | @@ -323,13 +323,13 @@ |
| 323 | 323 | ** |
| 324 | 324 | ** See also: [sqlite3_libversion()], |
| 325 | 325 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 326 | 326 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 327 | 327 | */ |
| 328 | | -#define SQLITE_VERSION "3.8.11.1" |
| 329 | | -#define SQLITE_VERSION_NUMBER 3008011 |
| 330 | | -#define SQLITE_SOURCE_ID "2015-07-29 20:00:57 cf538e2783e468bbc25e7cb2a9ee64d3e0e80b2f" |
| 328 | +#define SQLITE_VERSION "3.8.12" |
| 329 | +#define SQLITE_VERSION_NUMBER 3008012 |
| 330 | +#define SQLITE_SOURCE_ID "2015-09-11 01:22:41 d6cadbe9fefce9a7af6b2d0cb83362f967d7d89a" |
| 331 | 331 | |
| 332 | 332 | /* |
| 333 | 333 | ** CAPI3REF: Run-Time Library Version Numbers |
| 334 | 334 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 335 | 335 | ** |
| | @@ -689,10 +689,11 @@ |
| 689 | 689 | #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) |
| 690 | 690 | #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) |
| 691 | 691 | #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) |
| 692 | 692 | #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) |
| 693 | 693 | #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) |
| 694 | +#define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8)) |
| 694 | 695 | #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) |
| 695 | 696 | #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) |
| 696 | 697 | #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) |
| 697 | 698 | #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) |
| 698 | 699 | #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) |
| | @@ -3585,11 +3586,12 @@ |
| 3585 | 3586 | ** CAPI3REF: Determine If A Prepared Statement Has Been Reset |
| 3586 | 3587 | ** METHOD: sqlite3_stmt |
| 3587 | 3588 | ** |
| 3588 | 3589 | ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the |
| 3589 | 3590 | ** [prepared statement] S has been stepped at least once using |
| 3590 | | -** [sqlite3_step(S)] but has not run to completion and/or has not |
| 3591 | +** [sqlite3_step(S)] but has neither run to completion (returned |
| 3592 | +** [SQLITE_DONE] from [sqlite3_step(S)]) nor |
| 3591 | 3593 | ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S) |
| 3592 | 3594 | ** interface returns false if S is a NULL pointer. If S is not a |
| 3593 | 3595 | ** NULL pointer and is not a pointer to a valid [prepared statement] |
| 3594 | 3596 | ** object, then the behavior is undefined and probably undesirable. |
| 3595 | 3597 | ** |
| | @@ -4567,10 +4569,26 @@ |
| 4567 | 4569 | SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*); |
| 4568 | 4570 | SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*); |
| 4569 | 4571 | SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*); |
| 4570 | 4572 | SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*); |
| 4571 | 4573 | |
| 4574 | +/* |
| 4575 | +** CAPI3REF: Obtaining SQL Values |
| 4576 | +** METHOD: sqlite3_value |
| 4577 | +** |
| 4578 | +** The sqlite3_value_subtype(V) function returns the subtype for |
| 4579 | +** an [application-defined SQL function] argument V. The subtype |
| 4580 | +** information can be used to pass a limited amount of context from |
| 4581 | +** one SQL function to another. Use the [sqlite3_result_subtype()] |
| 4582 | +** routine to set the subtype for the return value of an SQL function. |
| 4583 | +** |
| 4584 | +** SQLite makes no use of subtype itself. It merely passes the subtype |
| 4585 | +** from the result of one [application-defined SQL function] into the |
| 4586 | +** input of another. |
| 4587 | +*/ |
| 4588 | +SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value*); |
| 4589 | + |
| 4572 | 4590 | /* |
| 4573 | 4591 | ** CAPI3REF: Copy And Free SQL Values |
| 4574 | 4592 | ** METHOD: sqlite3_value |
| 4575 | 4593 | ** |
| 4576 | 4594 | ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value] |
| | @@ -4866,10 +4884,25 @@ |
| 4866 | 4884 | SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 4867 | 4885 | SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 4868 | 4886 | SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 4869 | 4887 | SQLITE_API int SQLITE_STDCALL sqlite3_result_zeroblob64(sqlite3_context*, sqlite3_uint64 n); |
| 4870 | 4888 | |
| 4889 | + |
| 4890 | +/* |
| 4891 | +** CAPI3REF: Setting The Subtype Of An SQL Function |
| 4892 | +** METHOD: sqlite3_context |
| 4893 | +** |
| 4894 | +** The sqlite3_result_subtype(C,T) function causes the subtype of |
| 4895 | +** the result from the [application-defined SQL function] with |
| 4896 | +** [sqlite3_context] C to be the value T. Only the lower 8 bits |
| 4897 | +** of the subtype T are preserved in current versions of SQLite; |
| 4898 | +** higher order bits are discarded. |
| 4899 | +** The number of subtype bytes preserved by SQLite might increase |
| 4900 | +** in future releases of SQLite. |
| 4901 | +*/ |
| 4902 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_subtype(sqlite3_context*,unsigned int); |
| 4903 | + |
| 4871 | 4904 | /* |
| 4872 | 4905 | ** CAPI3REF: Define New Collating Sequences |
| 4873 | 4906 | ** METHOD: sqlite3 |
| 4874 | 4907 | ** |
| 4875 | 4908 | ** ^These functions add, remove, or modify a [collation] associated |
| | @@ -8361,19 +8394,22 @@ |
| 8361 | 8394 | # define SQLITE_NOINLINE |
| 8362 | 8395 | #endif |
| 8363 | 8396 | |
| 8364 | 8397 | /* |
| 8365 | 8398 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 8366 | | -** compiling with an appropriate version of MSVC. |
| 8399 | +** compiling with an appropriate version of MSVC unless prevented by |
| 8400 | +** the SQLITE_DISABLE_INTRINSIC define. |
| 8367 | 8401 | */ |
| 8368 | | -#if defined(_MSC_VER) && _MSC_VER>=1300 |
| 8369 | | -# if !defined(_WIN32_WCE) |
| 8370 | | -# include <intrin.h> |
| 8371 | | -# pragma intrinsic(_byteswap_ushort) |
| 8372 | | -# pragma intrinsic(_byteswap_ulong) |
| 8373 | | -# else |
| 8374 | | -# include <cmnintrin.h> |
| 8402 | +#if !defined(SQLITE_DISABLE_INTRINSIC) |
| 8403 | +# if defined(_MSC_VER) && _MSC_VER>=1300 |
| 8404 | +# if !defined(_WIN32_WCE) |
| 8405 | +# include <intrin.h> |
| 8406 | +# pragma intrinsic(_byteswap_ushort) |
| 8407 | +# pragma intrinsic(_byteswap_ulong) |
| 8408 | +# else |
| 8409 | +# include <cmnintrin.h> |
| 8410 | +# endif |
| 8375 | 8411 | # endif |
| 8376 | 8412 | #endif |
| 8377 | 8413 | |
| 8378 | 8414 | /* |
| 8379 | 8415 | ** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2. |
| | @@ -10050,16 +10086,20 @@ |
| 10050 | 10086 | */ |
| 10051 | 10087 | SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse*); |
| 10052 | 10088 | SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int); |
| 10053 | 10089 | SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int); |
| 10054 | 10090 | SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int); |
| 10091 | +SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe*,int); |
| 10092 | +SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe*,int,const char*); |
| 10093 | +SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe*,int,const char*,...); |
| 10055 | 10094 | SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); |
| 10056 | 10095 | SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); |
| 10057 | 10096 | SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8(Vdbe*,int,int,int,int,const u8*,int); |
| 10058 | 10097 | SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); |
| 10059 | 10098 | SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp, int iLineno); |
| 10060 | 10099 | SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); |
| 10100 | +SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8); |
| 10061 | 10101 | SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1); |
| 10062 | 10102 | SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2); |
| 10063 | 10103 | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3); |
| 10064 | 10104 | SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5); |
| 10065 | 10105 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); |
| | @@ -11333,22 +11373,24 @@ |
| 11333 | 11373 | /* |
| 11334 | 11374 | ** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF |
| 11335 | 11375 | ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. There |
| 11336 | 11376 | ** are assert() statements in the code to verify this. |
| 11337 | 11377 | */ |
| 11338 | | -#define SQLITE_FUNC_ENCMASK 0x003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ |
| 11339 | | -#define SQLITE_FUNC_LIKE 0x004 /* Candidate for the LIKE optimization */ |
| 11340 | | -#define SQLITE_FUNC_CASE 0x008 /* Case-sensitive LIKE-type function */ |
| 11341 | | -#define SQLITE_FUNC_EPHEM 0x010 /* Ephemeral. Delete with VDBE */ |
| 11342 | | -#define SQLITE_FUNC_NEEDCOLL 0x020 /* sqlite3GetFuncCollSeq() might be called */ |
| 11343 | | -#define SQLITE_FUNC_LENGTH 0x040 /* Built-in length() function */ |
| 11344 | | -#define SQLITE_FUNC_TYPEOF 0x080 /* Built-in typeof() function */ |
| 11345 | | -#define SQLITE_FUNC_COUNT 0x100 /* Built-in count(*) aggregate */ |
| 11346 | | -#define SQLITE_FUNC_COALESCE 0x200 /* Built-in coalesce() or ifnull() */ |
| 11347 | | -#define SQLITE_FUNC_UNLIKELY 0x400 /* Built-in unlikely() function */ |
| 11348 | | -#define SQLITE_FUNC_CONSTANT 0x800 /* Constant inputs give a constant output */ |
| 11349 | | -#define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ |
| 11378 | +#define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ |
| 11379 | +#define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */ |
| 11380 | +#define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */ |
| 11381 | +#define SQLITE_FUNC_EPHEM 0x0010 /* Ephemeral. Delete with VDBE */ |
| 11382 | +#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/ |
| 11383 | +#define SQLITE_FUNC_LENGTH 0x0040 /* Built-in length() function */ |
| 11384 | +#define SQLITE_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */ |
| 11385 | +#define SQLITE_FUNC_COUNT 0x0100 /* Built-in count(*) aggregate */ |
| 11386 | +#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */ |
| 11387 | +#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */ |
| 11388 | +#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */ |
| 11389 | +#define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */ |
| 11390 | +#define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a |
| 11391 | + ** single query - might change over time */ |
| 11350 | 11392 | |
| 11351 | 11393 | /* |
| 11352 | 11394 | ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are |
| 11353 | 11395 | ** used to create the initializers for the FuncDef structures. |
| 11354 | 11396 | ** |
| | @@ -11359,10 +11401,16 @@ |
| 11359 | 11401 | ** as the user-data (sqlite3_user_data()) for the function. If |
| 11360 | 11402 | ** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. |
| 11361 | 11403 | ** |
| 11362 | 11404 | ** VFUNCTION(zName, nArg, iArg, bNC, xFunc) |
| 11363 | 11405 | ** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag. |
| 11406 | +** |
| 11407 | +** DFUNCTION(zName, nArg, iArg, bNC, xFunc) |
| 11408 | +** Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and |
| 11409 | +** adds the SQLITE_FUNC_SLOCHNG flag. Used for date & time functions |
| 11410 | +** and functions like sqlite_version() that can change, but not during |
| 11411 | +** a single query. |
| 11364 | 11412 | ** |
| 11365 | 11413 | ** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) |
| 11366 | 11414 | ** Used to create an aggregate function definition implemented by |
| 11367 | 11415 | ** the C functions xStep and xFinal. The first four parameters |
| 11368 | 11416 | ** are interpreted in the same way as the first 4 parameters to |
| | @@ -11380,15 +11428,18 @@ |
| 11380 | 11428 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 11381 | 11429 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
| 11382 | 11430 | #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 11383 | 11431 | {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 11384 | 11432 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
| 11433 | +#define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 11434 | + {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 11435 | + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
| 11385 | 11436 | #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
| 11386 | 11437 | {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
| 11387 | 11438 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
| 11388 | 11439 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 11389 | | - {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 11440 | + {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 11390 | 11441 | pArg, 0, xFunc, 0, 0, #zName, 0, 0} |
| 11391 | 11442 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| 11392 | 11443 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
| 11393 | 11444 | (void *)arg, 0, likeFunc, 0, 0, #zName, 0, 0} |
| 11394 | 11445 | #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ |
| | @@ -11428,10 +11479,11 @@ |
| 11428 | 11479 | struct Module { |
| 11429 | 11480 | const sqlite3_module *pModule; /* Callback pointers */ |
| 11430 | 11481 | const char *zName; /* Name passed to create_module() */ |
| 11431 | 11482 | void *pAux; /* pAux passed to create_module() */ |
| 11432 | 11483 | void (*xDestroy)(void *); /* Module destructor function */ |
| 11484 | + Table *pEpoTab; /* Eponymous table for this module */ |
| 11433 | 11485 | }; |
| 11434 | 11486 | |
| 11435 | 11487 | /* |
| 11436 | 11488 | ** information about each column of an SQL table is held in an instance |
| 11437 | 11489 | ** of this structure. |
| | @@ -11473,10 +11525,11 @@ |
| 11473 | 11525 | /* |
| 11474 | 11526 | ** A sort order can be either ASC or DESC. |
| 11475 | 11527 | */ |
| 11476 | 11528 | #define SQLITE_SO_ASC 0 /* Sort in ascending order */ |
| 11477 | 11529 | #define SQLITE_SO_DESC 1 /* Sort in ascending order */ |
| 11530 | +#define SQLITE_SO_UNDEFINED -1 /* No sort order specified */ |
| 11478 | 11531 | |
| 11479 | 11532 | /* |
| 11480 | 11533 | ** Column affinity types. |
| 11481 | 11534 | ** |
| 11482 | 11535 | ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and |
| | @@ -11579,13 +11632,12 @@ |
| 11579 | 11632 | Column *aCol; /* Information about each column */ |
| 11580 | 11633 | Index *pIndex; /* List of SQL indexes on this table. */ |
| 11581 | 11634 | Select *pSelect; /* NULL for tables. Points to definition if a view. */ |
| 11582 | 11635 | FKey *pFKey; /* Linked list of all foreign keys in this table */ |
| 11583 | 11636 | char *zColAff; /* String defining the affinity of each column */ |
| 11584 | | -#ifndef SQLITE_OMIT_CHECK |
| 11585 | 11637 | ExprList *pCheck; /* All CHECK constraints */ |
| 11586 | | -#endif |
| 11638 | + /* ... also used as column name list in a VIEW */ |
| 11587 | 11639 | int tnum; /* Root BTree page for this table */ |
| 11588 | 11640 | i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */ |
| 11589 | 11641 | i16 nCol; /* Number of columns in this table */ |
| 11590 | 11642 | u16 nRef; /* Number of pointers to this Table */ |
| 11591 | 11643 | LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */ |
| | @@ -11598,11 +11650,11 @@ |
| 11598 | 11650 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 11599 | 11651 | int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ |
| 11600 | 11652 | #endif |
| 11601 | 11653 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 11602 | 11654 | int nModuleArg; /* Number of arguments to the module */ |
| 11603 | | - char **azModuleArg; /* Text of all module args. [0] is module name */ |
| 11655 | + char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */ |
| 11604 | 11656 | VTable *pVTable; /* List of VTable objects. */ |
| 11605 | 11657 | #endif |
| 11606 | 11658 | Trigger *pTrigger; /* List of triggers stored in pSchema */ |
| 11607 | 11659 | Schema *pSchema; /* Schema that contains this table */ |
| 11608 | 11660 | Table *pNextZombie; /* Next on the Parse.pZombieTab list */ |
| | @@ -11819,10 +11871,11 @@ |
| 11819 | 11871 | Index *pNext; /* The next index associated with the same table */ |
| 11820 | 11872 | Schema *pSchema; /* Schema containing this index */ |
| 11821 | 11873 | u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ |
| 11822 | 11874 | char **azColl; /* Array of collation sequence names for index */ |
| 11823 | 11875 | Expr *pPartIdxWhere; /* WHERE clause for partial indices */ |
| 11876 | + ExprList *aColExpr; /* Column expressions */ |
| 11824 | 11877 | int tnum; /* DB Page containing root of this index */ |
| 11825 | 11878 | LogEst szIdxRow; /* Estimated average row size in bytes */ |
| 11826 | 11879 | u16 nKeyCol; /* Number of columns forming the key */ |
| 11827 | 11880 | u16 nColumn; /* Number of columns stored in the index */ |
| 11828 | 11881 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| | @@ -12068,13 +12121,14 @@ |
| 12068 | 12121 | #define EP_TokenOnly 0x004000 /* Expr struct EXPR_TOKENONLYSIZE bytes only */ |
| 12069 | 12122 | #define EP_Static 0x008000 /* Held in memory not obtained from malloc() */ |
| 12070 | 12123 | #define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */ |
| 12071 | 12124 | #define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */ |
| 12072 | 12125 | #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */ |
| 12073 | | -#define EP_ConstFunc 0x080000 /* Node is a SQLITE_FUNC_CONSTANT function */ |
| 12126 | +#define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ |
| 12074 | 12127 | #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ |
| 12075 | 12128 | #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */ |
| 12129 | +#define EP_Alias 0x400000 /* Is an alias for a result set column */ |
| 12076 | 12130 | |
| 12077 | 12131 | /* |
| 12078 | 12132 | ** Combinations of two or more EP_* flags |
| 12079 | 12133 | */ |
| 12080 | 12134 | #define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */ |
| | @@ -12233,24 +12287,31 @@ |
| 12233 | 12287 | Table *pTab; /* An SQL table corresponding to zName */ |
| 12234 | 12288 | Select *pSelect; /* A SELECT statement used in place of a table name */ |
| 12235 | 12289 | int addrFillSub; /* Address of subroutine to manifest a subquery */ |
| 12236 | 12290 | int regReturn; /* Register holding return address of addrFillSub */ |
| 12237 | 12291 | int regResult; /* Registers holding results of a co-routine */ |
| 12238 | | - u8 jointype; /* Type of join between this able and the previous */ |
| 12239 | | - unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ |
| 12240 | | - unsigned isCorrelated :1; /* True if sub-query is correlated */ |
| 12241 | | - unsigned viaCoroutine :1; /* Implemented as a co-routine */ |
| 12242 | | - unsigned isRecursive :1; /* True for recursive reference in WITH */ |
| 12292 | + struct { |
| 12293 | + u8 jointype; /* Type of join between this able and the previous */ |
| 12294 | + unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ |
| 12295 | + unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ |
| 12296 | + unsigned isTabFunc :1; /* True if table-valued-function syntax */ |
| 12297 | + unsigned isCorrelated :1; /* True if sub-query is correlated */ |
| 12298 | + unsigned viaCoroutine :1; /* Implemented as a co-routine */ |
| 12299 | + unsigned isRecursive :1; /* True for recursive reference in WITH */ |
| 12300 | + } fg; |
| 12243 | 12301 | #ifndef SQLITE_OMIT_EXPLAIN |
| 12244 | 12302 | u8 iSelectId; /* If pSelect!=0, the id of the sub-select in EQP */ |
| 12245 | 12303 | #endif |
| 12246 | 12304 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 12247 | 12305 | Expr *pOn; /* The ON clause of a join */ |
| 12248 | 12306 | IdList *pUsing; /* The USING clause of a join */ |
| 12249 | 12307 | Bitmask colUsed; /* Bit N (1<<N) set if column N of pTab is used */ |
| 12250 | | - char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */ |
| 12251 | | - Index *pIndex; /* Index structure corresponding to zIndex, if any */ |
| 12308 | + union { |
| 12309 | + char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */ |
| 12310 | + ExprList *pFuncArg; /* Arguments to table-valued-function */ |
| 12311 | + } u1; |
| 12312 | + Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */ |
| 12252 | 12313 | } a[1]; /* One entry for each identifier on the list */ |
| 12253 | 12314 | }; |
| 12254 | 12315 | |
| 12255 | 12316 | /* |
| 12256 | 12317 | ** Permitted values of the SrcList.a.jointype field |
| | @@ -12332,10 +12393,11 @@ |
| 12332 | 12393 | #define NC_AllowAgg 0x0001 /* Aggregate functions are allowed here */ |
| 12333 | 12394 | #define NC_HasAgg 0x0002 /* One or more aggregate functions seen */ |
| 12334 | 12395 | #define NC_IsCheck 0x0004 /* True if resolving names in a CHECK constraint */ |
| 12335 | 12396 | #define NC_InAggFunc 0x0008 /* True if analyzing arguments to an agg func */ |
| 12336 | 12397 | #define NC_PartIdx 0x0010 /* True if resolving a partial index WHERE */ |
| 12398 | +#define NC_IdxExpr 0x0020 /* True if resolving columns of CREATE INDEX */ |
| 12337 | 12399 | #define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */ |
| 12338 | 12400 | |
| 12339 | 12401 | /* |
| 12340 | 12402 | ** An instance of the following structure contains all information |
| 12341 | 12403 | ** needed to generate code for a single SELECT statement. |
| | @@ -12601,11 +12663,11 @@ |
| 12601 | 12663 | int nSet; /* Number of sets used so far */ |
| 12602 | 12664 | int nOnce; /* Number of OP_Once instructions so far */ |
| 12603 | 12665 | int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */ |
| 12604 | 12666 | int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */ |
| 12605 | 12667 | int ckBase; /* Base register of data during check constraints */ |
| 12606 | | - int iPartIdxTab; /* Table corresponding to a partial index */ |
| 12668 | + int iSelfTab; /* Table of an index whose exprs are being coded */ |
| 12607 | 12669 | int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ |
| 12608 | 12670 | int iCacheCnt; /* Counter used to generate aColCache[].lru values */ |
| 12609 | 12671 | int nLabel; /* Number of labels used */ |
| 12610 | 12672 | int *aLabel; /* Space to hold the labels */ |
| 12611 | 12673 | struct yColCache { |
| | @@ -12971,11 +13033,11 @@ |
| 12971 | 13033 | With *pOuter; /* Containing WITH clause, or NULL */ |
| 12972 | 13034 | struct Cte { /* For each CTE in the WITH clause.... */ |
| 12973 | 13035 | char *zName; /* Name of this CTE */ |
| 12974 | 13036 | ExprList *pCols; /* List of explicit column names, or NULL */ |
| 12975 | 13037 | Select *pSelect; /* The definition of this CTE */ |
| 12976 | | - const char *zErr; /* Error message for circular references */ |
| 13038 | + const char *zCteErr; /* Error message for circular references */ |
| 12977 | 13039 | } a[1]; |
| 12978 | 13040 | }; |
| 12979 | 13041 | |
| 12980 | 13042 | #ifdef SQLITE_DEBUG |
| 12981 | 13043 | /* |
| | @@ -13119,10 +13181,15 @@ |
| 13119 | 13181 | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3NoopMutex(void); |
| 13120 | 13182 | SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int); |
| 13121 | 13183 | SQLITE_PRIVATE int sqlite3MutexInit(void); |
| 13122 | 13184 | SQLITE_PRIVATE int sqlite3MutexEnd(void); |
| 13123 | 13185 | #endif |
| 13186 | +#if !defined(SQLITE_MUTEX_OMIT) && !defined(SQLITE_MUTEX_NOOP) |
| 13187 | +SQLITE_PRIVATE void sqlite3MemoryBarrier(void); |
| 13188 | +#else |
| 13189 | +# define sqlite3MemoryBarrier(); |
| 13190 | +#endif |
| 13124 | 13191 | |
| 13125 | 13192 | SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int); |
| 13126 | 13193 | SQLITE_PRIVATE void sqlite3StatusUp(int, int); |
| 13127 | 13194 | SQLITE_PRIVATE void sqlite3StatusDown(int, int); |
| 13128 | 13195 | SQLITE_PRIVATE void sqlite3StatusSet(int, int); |
| | @@ -13185,10 +13252,11 @@ |
| 13185 | 13252 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3*,Expr*, Expr*); |
| 13186 | 13253 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*); |
| 13187 | 13254 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*); |
| 13188 | 13255 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 13189 | 13256 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 13257 | +SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int); |
| 13190 | 13258 | SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); |
| 13191 | 13259 | SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*); |
| 13192 | 13260 | SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*); |
| 13193 | 13261 | SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*); |
| 13194 | 13262 | SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**); |
| | @@ -13197,10 +13265,12 @@ |
| 13197 | 13265 | SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*); |
| 13198 | 13266 | SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int); |
| 13199 | 13267 | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*); |
| 13200 | 13268 | SQLITE_PRIVATE void sqlite3BeginParse(Parse*,int); |
| 13201 | 13269 | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); |
| 13270 | +SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*); |
| 13271 | +SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); |
| 13202 | 13272 | SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*); |
| 13203 | 13273 | SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int); |
| 13204 | 13274 | SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*); |
| 13205 | 13275 | SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16); |
| 13206 | 13276 | SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int); |
| | @@ -13238,11 +13308,11 @@ |
| 13238 | 13308 | SQLITE_PRIVATE void sqlite3RowSetClear(RowSet*); |
| 13239 | 13309 | SQLITE_PRIVATE void sqlite3RowSetInsert(RowSet*, i64); |
| 13240 | 13310 | SQLITE_PRIVATE int sqlite3RowSetTest(RowSet*, int iBatch, i64); |
| 13241 | 13311 | SQLITE_PRIVATE int sqlite3RowSetNext(RowSet*, i64*); |
| 13242 | 13312 | |
| 13243 | | -SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int); |
| 13313 | +SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,ExprList*,Select*,int,int); |
| 13244 | 13314 | |
| 13245 | 13315 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 13246 | 13316 | SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse*,Table*); |
| 13247 | 13317 | #else |
| 13248 | 13318 | # define sqlite3ViewGetColumnNames(A,B) 0 |
| | @@ -13268,10 +13338,11 @@ |
| 13268 | 13338 | SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int); |
| 13269 | 13339 | SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*); |
| 13270 | 13340 | SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*, |
| 13271 | 13341 | Token*, Select*, Expr*, IdList*); |
| 13272 | 13342 | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *); |
| 13343 | +SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse*, SrcList*, ExprList*); |
| 13273 | 13344 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *, struct SrcList_item *); |
| 13274 | 13345 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); |
| 13275 | 13346 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
| 13276 | 13347 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); |
| 13277 | 13348 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*); |
| | @@ -13298,10 +13369,11 @@ |
| 13298 | 13369 | SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*); |
| 13299 | 13370 | SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*); |
| 13300 | 13371 | SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*); |
| 13301 | 13372 | SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*); |
| 13302 | 13373 | SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*); |
| 13374 | +SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn(Parse*, Index*, int, int, int); |
| 13303 | 13375 | SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); |
| 13304 | 13376 | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); |
| 13305 | 13377 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); |
| 13306 | 13378 | SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int); |
| 13307 | 13379 | SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*); |
| | @@ -13313,13 +13385,14 @@ |
| 13313 | 13385 | SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int); |
| 13314 | 13386 | SQLITE_PRIVATE void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8); |
| 13315 | 13387 | SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*); |
| 13316 | 13388 | SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int); |
| 13317 | 13389 | SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int); |
| 13318 | | -SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, u8); |
| 13390 | +SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8); |
| 13319 | 13391 | #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */ |
| 13320 | 13392 | #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */ |
| 13393 | +#define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */ |
| 13321 | 13394 | SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int); |
| 13322 | 13395 | SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int); |
| 13323 | 13396 | SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int); |
| 13324 | 13397 | SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*); |
| 13325 | 13398 | SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*); |
| | @@ -13487,11 +13560,11 @@ |
| 13487 | 13560 | sqlite3PutVarint((A),(B))) |
| 13488 | 13561 | #define getVarint sqlite3GetVarint |
| 13489 | 13562 | #define putVarint sqlite3PutVarint |
| 13490 | 13563 | |
| 13491 | 13564 | |
| 13492 | | -SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *, Index *); |
| 13565 | +SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*); |
| 13493 | 13566 | SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int); |
| 13494 | 13567 | SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2); |
| 13495 | 13568 | SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); |
| 13496 | 13569 | SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr); |
| 13497 | 13570 | SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8); |
| | @@ -13559,10 +13632,11 @@ |
| 13559 | 13632 | SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int); |
| 13560 | 13633 | SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); |
| 13561 | 13634 | SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p); |
| 13562 | 13635 | SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*); |
| 13563 | 13636 | SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 13637 | +SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*); |
| 13564 | 13638 | SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); |
| 13565 | 13639 | SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); |
| 13566 | 13640 | SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); |
| 13567 | 13641 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); |
| 13568 | 13642 | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); |
| | @@ -13667,10 +13741,12 @@ |
| 13667 | 13741 | SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *, int, int); |
| 13668 | 13742 | SQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe*, sqlite3_vtab*); |
| 13669 | 13743 | SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3*, Table*); |
| 13670 | 13744 | # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0) |
| 13671 | 13745 | #endif |
| 13746 | +SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); |
| 13747 | +SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); |
| 13672 | 13748 | SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*); |
| 13673 | 13749 | SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int); |
| 13674 | 13750 | SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse*, Token*); |
| 13675 | 13751 | SQLITE_PRIVATE void sqlite3VtabArgInit(Parse*); |
| 13676 | 13752 | SQLITE_PRIVATE void sqlite3VtabArgExtend(Parse*, Token*); |
| | @@ -14770,10 +14846,11 @@ |
| 14770 | 14846 | RowSet *pRowSet; /* Used only when flags==MEM_RowSet */ |
| 14771 | 14847 | VdbeFrame *pFrame; /* Used when flags==MEM_Frame */ |
| 14772 | 14848 | } u; |
| 14773 | 14849 | u16 flags; /* Some combination of MEM_Null, MEM_Str, MEM_Dyn, etc. */ |
| 14774 | 14850 | u8 enc; /* SQLITE_UTF8, SQLITE_UTF16BE, SQLITE_UTF16LE */ |
| 14851 | + u8 eSubtype; /* Subtype for this value */ |
| 14775 | 14852 | int n; /* Number of characters in string value, excluding '\0' */ |
| 14776 | 14853 | char *z; /* String or BLOB value */ |
| 14777 | 14854 | /* ShallowCopy only needs to copy the information above */ |
| 14778 | 14855 | char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */ |
| 14779 | 14856 | int szMalloc; /* Size of the zMalloc allocation */ |
| | @@ -16546,18 +16623,18 @@ |
| 16546 | 16623 | ** external linkage. |
| 16547 | 16624 | */ |
| 16548 | 16625 | SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){ |
| 16549 | 16626 | static SQLITE_WSD FuncDef aDateTimeFuncs[] = { |
| 16550 | 16627 | #ifndef SQLITE_OMIT_DATETIME_FUNCS |
| 16551 | | - FUNCTION(julianday, -1, 0, 0, juliandayFunc ), |
| 16552 | | - FUNCTION(date, -1, 0, 0, dateFunc ), |
| 16553 | | - FUNCTION(time, -1, 0, 0, timeFunc ), |
| 16554 | | - FUNCTION(datetime, -1, 0, 0, datetimeFunc ), |
| 16555 | | - FUNCTION(strftime, -1, 0, 0, strftimeFunc ), |
| 16556 | | - FUNCTION(current_time, 0, 0, 0, ctimeFunc ), |
| 16557 | | - FUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc), |
| 16558 | | - FUNCTION(current_date, 0, 0, 0, cdateFunc ), |
| 16628 | + DFUNCTION(julianday, -1, 0, 0, juliandayFunc ), |
| 16629 | + DFUNCTION(date, -1, 0, 0, dateFunc ), |
| 16630 | + DFUNCTION(time, -1, 0, 0, timeFunc ), |
| 16631 | + DFUNCTION(datetime, -1, 0, 0, datetimeFunc ), |
| 16632 | + DFUNCTION(strftime, -1, 0, 0, strftimeFunc ), |
| 16633 | + DFUNCTION(current_time, 0, 0, 0, ctimeFunc ), |
| 16634 | + DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc), |
| 16635 | + DFUNCTION(current_date, 0, 0, 0, cdateFunc ), |
| 16559 | 16636 | #else |
| 16560 | 16637 | STR_FUNCTION(current_time, 0, "%H:%M:%S", 0, currentTimeFunc), |
| 16561 | 16638 | STR_FUNCTION(current_date, 0, "%Y-%m-%d", 0, currentTimeFunc), |
| 16562 | 16639 | STR_FUNCTION(current_timestamp, 0, "%Y-%m-%d %H:%M:%S", 0, currentTimeFunc), |
| 16563 | 16640 | #endif |
| | @@ -19273,10 +19350,11 @@ |
| 19273 | 19350 | pTo->xMutexEnter = pFrom->xMutexEnter; |
| 19274 | 19351 | pTo->xMutexTry = pFrom->xMutexTry; |
| 19275 | 19352 | pTo->xMutexLeave = pFrom->xMutexLeave; |
| 19276 | 19353 | pTo->xMutexHeld = pFrom->xMutexHeld; |
| 19277 | 19354 | pTo->xMutexNotheld = pFrom->xMutexNotheld; |
| 19355 | + sqlite3MemoryBarrier(); |
| 19278 | 19356 | pTo->xMutexAlloc = pFrom->xMutexAlloc; |
| 19279 | 19357 | } |
| 19280 | 19358 | rc = sqlite3GlobalConfig.mutex.xMutexInit(); |
| 19281 | 19359 | |
| 19282 | 19360 | #ifdef SQLITE_DEBUG |
| | @@ -19679,10 +19757,21 @@ |
| 19679 | 19757 | } |
| 19680 | 19758 | static int pthreadMutexNotheld(sqlite3_mutex *p){ |
| 19681 | 19759 | return p->nRef==0 || pthread_equal(p->owner, pthread_self())==0; |
| 19682 | 19760 | } |
| 19683 | 19761 | #endif |
| 19762 | + |
| 19763 | +/* |
| 19764 | +** Try to provide a memory barrier operation, needed for initialization only. |
| 19765 | +*/ |
| 19766 | +SQLITE_PRIVATE void sqlite3MemoryBarrier(void){ |
| 19767 | +#if defined(SQLITE_MEMORY_BARRIER) |
| 19768 | + SQLITE_MEMORY_BARRIER; |
| 19769 | +#elif defined(__GNUC__) |
| 19770 | + __sync_synchronize(); |
| 19771 | +#endif |
| 19772 | +} |
| 19684 | 19773 | |
| 19685 | 19774 | /* |
| 19686 | 19775 | ** Initialize and deinitialize the mutex subsystem. |
| 19687 | 19776 | */ |
| 19688 | 19777 | static int pthreadMutexInit(void){ return SQLITE_OK; } |
| | @@ -20341,10 +20430,23 @@ |
| 20341 | 20430 | static int winMutexNotheld(sqlite3_mutex *p){ |
| 20342 | 20431 | DWORD tid = GetCurrentThreadId(); |
| 20343 | 20432 | return winMutexNotheld2(p, tid); |
| 20344 | 20433 | } |
| 20345 | 20434 | #endif |
| 20435 | + |
| 20436 | +/* |
| 20437 | +** Try to provide a memory barrier operation, needed for initialization only. |
| 20438 | +*/ |
| 20439 | +SQLITE_PRIVATE void sqlite3MemoryBarrier(void){ |
| 20440 | +#if defined(SQLITE_MEMORY_BARRIER) |
| 20441 | + SQLITE_MEMORY_BARRIER; |
| 20442 | +#elif defined(__GNUC__) |
| 20443 | + __sync_synchronize(); |
| 20444 | +#else |
| 20445 | + MemoryBarrier(); |
| 20446 | +#endif |
| 20447 | +} |
| 20346 | 20448 | |
| 20347 | 20449 | /* |
| 20348 | 20450 | ** Initialize and deinitialize the mutex subsystem. |
| 20349 | 20451 | */ |
| 20350 | 20452 | static sqlite3_mutex winMutex_staticMutexes[] = { |
| | @@ -20695,20 +20797,11 @@ |
| 20695 | 20797 | /* |
| 20696 | 20798 | ** State information local to the memory allocation subsystem. |
| 20697 | 20799 | */ |
| 20698 | 20800 | static SQLITE_WSD struct Mem0Global { |
| 20699 | 20801 | sqlite3_mutex *mutex; /* Mutex to serialize access */ |
| 20700 | | - |
| 20701 | | - /* |
| 20702 | | - ** The alarm callback and its arguments. The mem0.mutex lock will |
| 20703 | | - ** be held while the callback is running. Recursive calls into |
| 20704 | | - ** the memory subsystem are allowed, but no new callbacks will be |
| 20705 | | - ** issued. |
| 20706 | | - */ |
| 20707 | | - sqlite3_int64 alarmThreshold; |
| 20708 | | - void (*alarmCallback)(void*, sqlite3_int64,int); |
| 20709 | | - void *alarmArg; |
| 20802 | + sqlite3_int64 alarmThreshold; /* The soft heap limit */ |
| 20710 | 20803 | |
| 20711 | 20804 | /* |
| 20712 | 20805 | ** Pointers to the end of sqlite3GlobalConfig.pScratch memory |
| 20713 | 20806 | ** (so that a range test can be used to determine if an allocation |
| 20714 | 20807 | ** being freed came from pScratch) and a pointer to the list of |
| | @@ -20721,11 +20814,11 @@ |
| 20721 | 20814 | /* |
| 20722 | 20815 | ** True if heap is nearly "full" where "full" is defined by the |
| 20723 | 20816 | ** sqlite3_soft_heap_limit() setting. |
| 20724 | 20817 | */ |
| 20725 | 20818 | int nearlyFull; |
| 20726 | | -} mem0 = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
| 20819 | +} mem0 = { 0, 0, 0, 0, 0, 0 }; |
| 20727 | 20820 | |
| 20728 | 20821 | #define mem0 GLOBAL(struct Mem0Global, mem0) |
| 20729 | 20822 | |
| 20730 | 20823 | /* |
| 20731 | 20824 | ** Return the memory allocator mutex. sqlite3_status() needs it. |
| | @@ -20732,54 +20825,25 @@ |
| 20732 | 20825 | */ |
| 20733 | 20826 | SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){ |
| 20734 | 20827 | return mem0.mutex; |
| 20735 | 20828 | } |
| 20736 | 20829 | |
| 20737 | | -/* |
| 20738 | | -** This routine runs when the memory allocator sees that the |
| 20739 | | -** total memory allocation is about to exceed the soft heap |
| 20740 | | -** limit. |
| 20741 | | -*/ |
| 20742 | | -static void softHeapLimitEnforcer( |
| 20743 | | - void *NotUsed, |
| 20744 | | - sqlite3_int64 NotUsed2, |
| 20745 | | - int allocSize |
| 20746 | | -){ |
| 20747 | | - UNUSED_PARAMETER2(NotUsed, NotUsed2); |
| 20748 | | - sqlite3_release_memory(allocSize); |
| 20749 | | -} |
| 20750 | | - |
| 20751 | | -/* |
| 20752 | | -** Change the alarm callback |
| 20753 | | -*/ |
| 20754 | | -static int sqlite3MemoryAlarm( |
| 20755 | | - void(*xCallback)(void *pArg, sqlite3_int64 used,int N), |
| 20756 | | - void *pArg, |
| 20757 | | - sqlite3_int64 iThreshold |
| 20758 | | -){ |
| 20759 | | - sqlite3_int64 nUsed; |
| 20760 | | - sqlite3_mutex_enter(mem0.mutex); |
| 20761 | | - mem0.alarmCallback = xCallback; |
| 20762 | | - mem0.alarmArg = pArg; |
| 20763 | | - mem0.alarmThreshold = iThreshold; |
| 20764 | | - nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 20765 | | - mem0.nearlyFull = (iThreshold>0 && iThreshold<=nUsed); |
| 20766 | | - sqlite3_mutex_leave(mem0.mutex); |
| 20767 | | - return SQLITE_OK; |
| 20768 | | -} |
| 20769 | | - |
| 20770 | 20830 | #ifndef SQLITE_OMIT_DEPRECATED |
| 20771 | 20831 | /* |
| 20772 | | -** Deprecated external interface. Internal/core SQLite code |
| 20773 | | -** should call sqlite3MemoryAlarm. |
| 20832 | +** Deprecated external interface. It used to set an alarm callback |
| 20833 | +** that was invoked when memory usage grew too large. Now it is a |
| 20834 | +** no-op. |
| 20774 | 20835 | */ |
| 20775 | 20836 | SQLITE_API int SQLITE_STDCALL sqlite3_memory_alarm( |
| 20776 | 20837 | void(*xCallback)(void *pArg, sqlite3_int64 used,int N), |
| 20777 | 20838 | void *pArg, |
| 20778 | 20839 | sqlite3_int64 iThreshold |
| 20779 | 20840 | ){ |
| 20780 | | - return sqlite3MemoryAlarm(xCallback, pArg, iThreshold); |
| 20841 | + (void)xCallback; |
| 20842 | + (void)pArg; |
| 20843 | + (void)iThreshold; |
| 20844 | + return SQLITE_OK; |
| 20781 | 20845 | } |
| 20782 | 20846 | #endif |
| 20783 | 20847 | |
| 20784 | 20848 | /* |
| 20785 | 20849 | ** Set the soft heap-size limit for the library. Passing a zero or |
| | @@ -20786,23 +20850,25 @@ |
| 20786 | 20850 | ** negative value indicates no limit. |
| 20787 | 20851 | */ |
| 20788 | 20852 | SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){ |
| 20789 | 20853 | sqlite3_int64 priorLimit; |
| 20790 | 20854 | sqlite3_int64 excess; |
| 20855 | + sqlite3_int64 nUsed; |
| 20791 | 20856 | #ifndef SQLITE_OMIT_AUTOINIT |
| 20792 | 20857 | int rc = sqlite3_initialize(); |
| 20793 | 20858 | if( rc ) return -1; |
| 20794 | 20859 | #endif |
| 20795 | 20860 | sqlite3_mutex_enter(mem0.mutex); |
| 20796 | 20861 | priorLimit = mem0.alarmThreshold; |
| 20862 | + if( n<0 ){ |
| 20863 | + sqlite3_mutex_leave(mem0.mutex); |
| 20864 | + return priorLimit; |
| 20865 | + } |
| 20866 | + mem0.alarmThreshold = n; |
| 20867 | + nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 20868 | + mem0.nearlyFull = (n>0 && n<=nUsed); |
| 20797 | 20869 | sqlite3_mutex_leave(mem0.mutex); |
| 20798 | | - if( n<0 ) return priorLimit; |
| 20799 | | - if( n>0 ){ |
| 20800 | | - sqlite3MemoryAlarm(softHeapLimitEnforcer, 0, n); |
| 20801 | | - }else{ |
| 20802 | | - sqlite3MemoryAlarm(0, 0, 0); |
| 20803 | | - } |
| 20804 | 20870 | excess = sqlite3_memory_used() - n; |
| 20805 | 20871 | if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff)); |
| 20806 | 20872 | return priorLimit; |
| 20807 | 20873 | } |
| 20808 | 20874 | SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){ |
| | @@ -20895,23 +20961,14 @@ |
| 20895 | 20961 | |
| 20896 | 20962 | /* |
| 20897 | 20963 | ** Trigger the alarm |
| 20898 | 20964 | */ |
| 20899 | 20965 | static void sqlite3MallocAlarm(int nByte){ |
| 20900 | | - void (*xCallback)(void*,sqlite3_int64,int); |
| 20901 | | - sqlite3_int64 nowUsed; |
| 20902 | | - void *pArg; |
| 20903 | | - if( mem0.alarmCallback==0 ) return; |
| 20904 | | - xCallback = mem0.alarmCallback; |
| 20905 | | - nowUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 20906 | | - pArg = mem0.alarmArg; |
| 20907 | | - mem0.alarmCallback = 0; |
| 20966 | + if( mem0.alarmThreshold<=0 ) return; |
| 20908 | 20967 | sqlite3_mutex_leave(mem0.mutex); |
| 20909 | | - xCallback(pArg, nowUsed, nByte); |
| 20968 | + sqlite3_release_memory(nByte); |
| 20910 | 20969 | sqlite3_mutex_enter(mem0.mutex); |
| 20911 | | - mem0.alarmCallback = xCallback; |
| 20912 | | - mem0.alarmArg = pArg; |
| 20913 | 20970 | } |
| 20914 | 20971 | |
| 20915 | 20972 | /* |
| 20916 | 20973 | ** Do a memory allocation with statistics and alarms. Assume the |
| 20917 | 20974 | ** lock is already held. |
| | @@ -20920,11 +20977,11 @@ |
| 20920 | 20977 | int nFull; |
| 20921 | 20978 | void *p; |
| 20922 | 20979 | assert( sqlite3_mutex_held(mem0.mutex) ); |
| 20923 | 20980 | nFull = sqlite3GlobalConfig.m.xRoundup(n); |
| 20924 | 20981 | sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n); |
| 20925 | | - if( mem0.alarmCallback!=0 ){ |
| 20982 | + if( mem0.alarmThreshold>0 ){ |
| 20926 | 20983 | sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 20927 | 20984 | if( nUsed >= mem0.alarmThreshold - nFull ){ |
| 20928 | 20985 | mem0.nearlyFull = 1; |
| 20929 | 20986 | sqlite3MallocAlarm(nFull); |
| 20930 | 20987 | }else{ |
| | @@ -20931,11 +20988,11 @@ |
| 20931 | 20988 | mem0.nearlyFull = 0; |
| 20932 | 20989 | } |
| 20933 | 20990 | } |
| 20934 | 20991 | p = sqlite3GlobalConfig.m.xMalloc(nFull); |
| 20935 | 20992 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 20936 | | - if( p==0 && mem0.alarmCallback ){ |
| 20993 | + if( p==0 && mem0.alarmThreshold>0 ){ |
| 20937 | 20994 | sqlite3MallocAlarm(nFull); |
| 20938 | 20995 | p = sqlite3GlobalConfig.m.xMalloc(nFull); |
| 20939 | 20996 | } |
| 20940 | 20997 | #endif |
| 20941 | 20998 | if( p ){ |
| | @@ -21106,23 +21163,24 @@ |
| 21106 | 21163 | SQLITE_PRIVATE int sqlite3MallocSize(void *p){ |
| 21107 | 21164 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 21108 | 21165 | return sqlite3GlobalConfig.m.xSize(p); |
| 21109 | 21166 | } |
| 21110 | 21167 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ |
| 21111 | | - if( db==0 ){ |
| 21112 | | - assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 21113 | | - assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 21114 | | - return sqlite3MallocSize(p); |
| 21115 | | - }else{ |
| 21116 | | - assert( sqlite3_mutex_held(db->mutex) ); |
| 21117 | | - if( isLookaside(db, p) ){ |
| 21118 | | - return db->lookaside.sz; |
| 21168 | + if( db==0 || !isLookaside(db,p) ){ |
| 21169 | +#if SQLITE_DEBUG |
| 21170 | + if( db==0 ){ |
| 21171 | + assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 21172 | + assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 21119 | 21173 | }else{ |
| 21120 | 21174 | assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 21121 | 21175 | assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) ); |
| 21122 | | - return sqlite3GlobalConfig.m.xSize(p); |
| 21123 | 21176 | } |
| 21177 | +#endif |
| 21178 | + return sqlite3GlobalConfig.m.xSize(p); |
| 21179 | + }else{ |
| 21180 | + assert( sqlite3_mutex_held(db->mutex) ); |
| 21181 | + return db->lookaside.sz; |
| 21124 | 21182 | } |
| 21125 | 21183 | } |
| 21126 | 21184 | SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void *p){ |
| 21127 | 21185 | assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| 21128 | 21186 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| | @@ -21219,11 +21277,11 @@ |
| 21219 | 21277 | if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= |
| 21220 | 21278 | mem0.alarmThreshold-nDiff ){ |
| 21221 | 21279 | sqlite3MallocAlarm(nDiff); |
| 21222 | 21280 | } |
| 21223 | 21281 | pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); |
| 21224 | | - if( pNew==0 && mem0.alarmCallback ){ |
| 21282 | + if( pNew==0 && mem0.alarmThreshold>0 ){ |
| 21225 | 21283 | sqlite3MallocAlarm((int)nBytes); |
| 21226 | 21284 | pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew); |
| 21227 | 21285 | } |
| 21228 | 21286 | if( pNew ){ |
| 21229 | 21287 | nNew = sqlite3MallocSize(pNew); |
| | @@ -21933,25 +21991,20 @@ |
| 21933 | 21991 | break; |
| 21934 | 21992 | } |
| 21935 | 21993 | if( realvalue>0.0 ){ |
| 21936 | 21994 | LONGDOUBLE_TYPE scale = 1.0; |
| 21937 | 21995 | while( realvalue>=1e100*scale && exp<=350 ){ scale *= 1e100;exp+=100;} |
| 21938 | | - while( realvalue>=1e64*scale && exp<=350 ){ scale *= 1e64; exp+=64; } |
| 21939 | | - while( realvalue>=1e8*scale && exp<=350 ){ scale *= 1e8; exp+=8; } |
| 21996 | + while( realvalue>=1e10*scale && exp<=350 ){ scale *= 1e10; exp+=10; } |
| 21940 | 21997 | while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; } |
| 21941 | 21998 | realvalue /= scale; |
| 21942 | 21999 | while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; } |
| 21943 | 22000 | while( realvalue<1.0 ){ realvalue *= 10.0; exp--; } |
| 21944 | 22001 | if( exp>350 ){ |
| 21945 | | - if( prefix=='-' ){ |
| 21946 | | - bufpt = "-Inf"; |
| 21947 | | - }else if( prefix=='+' ){ |
| 21948 | | - bufpt = "+Inf"; |
| 21949 | | - }else{ |
| 21950 | | - bufpt = "Inf"; |
| 21951 | | - } |
| 21952 | | - length = sqlite3Strlen30(bufpt); |
| 22002 | + bufpt = buf; |
| 22003 | + buf[0] = prefix; |
| 22004 | + memcpy(buf+(prefix!=0),"Inf",4); |
| 22005 | + length = 3+(prefix!=0); |
| 21953 | 22006 | break; |
| 21954 | 22007 | } |
| 21955 | 22008 | } |
| 21956 | 22009 | bufpt = buf; |
| 21957 | 22010 | /* |
| | @@ -22096,27 +22149,28 @@ |
| 22096 | 22149 | break; |
| 22097 | 22150 | case etSTRING: |
| 22098 | 22151 | case etDYNSTRING: |
| 22099 | 22152 | if( bArgList ){ |
| 22100 | 22153 | bufpt = getTextArg(pArgList); |
| 22154 | + xtype = etSTRING; |
| 22101 | 22155 | }else{ |
| 22102 | 22156 | bufpt = va_arg(ap,char*); |
| 22103 | 22157 | } |
| 22104 | 22158 | if( bufpt==0 ){ |
| 22105 | 22159 | bufpt = ""; |
| 22106 | | - }else if( xtype==etDYNSTRING && !bArgList ){ |
| 22160 | + }else if( xtype==etDYNSTRING ){ |
| 22107 | 22161 | zExtra = bufpt; |
| 22108 | 22162 | } |
| 22109 | 22163 | if( precision>=0 ){ |
| 22110 | 22164 | for(length=0; length<precision && bufpt[length]; length++){} |
| 22111 | 22165 | }else{ |
| 22112 | 22166 | length = sqlite3Strlen30(bufpt); |
| 22113 | 22167 | } |
| 22114 | 22168 | break; |
| 22115 | | - case etSQLESCAPE: |
| 22116 | | - case etSQLESCAPE2: |
| 22117 | | - case etSQLESCAPE3: { |
| 22169 | + case etSQLESCAPE: /* Escape ' characters */ |
| 22170 | + case etSQLESCAPE2: /* Escape ' and enclose in '...' */ |
| 22171 | + case etSQLESCAPE3: { /* Escape " characters */ |
| 22118 | 22172 | int i, j, k, n, isnull; |
| 22119 | 22173 | int needQuote; |
| 22120 | 22174 | char ch; |
| 22121 | 22175 | char q = ((xtype==etSQLESCAPE3)?'"':'\''); /* Quote character */ |
| 22122 | 22176 | char *escarg; |
| | @@ -22131,11 +22185,11 @@ |
| 22131 | 22185 | k = precision; |
| 22132 | 22186 | for(i=n=0; k!=0 && (ch=escarg[i])!=0; i++, k--){ |
| 22133 | 22187 | if( ch==q ) n++; |
| 22134 | 22188 | } |
| 22135 | 22189 | needQuote = !isnull && xtype==etSQLESCAPE2; |
| 22136 | | - n += i + 1 + needQuote*2; |
| 22190 | + n += i + 3; |
| 22137 | 22191 | if( n>etBUFSIZE ){ |
| 22138 | 22192 | bufpt = zExtra = sqlite3Malloc( n ); |
| 22139 | 22193 | if( bufpt==0 ){ |
| 22140 | 22194 | setStrAccumError(pAccum, STRACCUM_NOMEM); |
| 22141 | 22195 | return; |
| | @@ -22527,11 +22581,12 @@ |
| 22527 | 22581 | } |
| 22528 | 22582 | #endif |
| 22529 | 22583 | |
| 22530 | 22584 | |
| 22531 | 22585 | /* |
| 22532 | | -** variable-argument wrapper around sqlite3VXPrintf(). |
| 22586 | +** variable-argument wrapper around sqlite3VXPrintf(). The bFlags argument |
| 22587 | +** can contain the bit SQLITE_PRINTF_INTERNAL enable internal formats. |
| 22533 | 22588 | */ |
| 22534 | 22589 | SQLITE_PRIVATE void sqlite3XPrintf(StrAccum *p, u32 bFlags, const char *zFormat, ...){ |
| 22535 | 22590 | va_list ap; |
| 22536 | 22591 | va_start(ap,zFormat); |
| 22537 | 22592 | sqlite3VXPrintf(p, bFlags, zFormat, ap); |
| | @@ -22625,94 +22680,104 @@ |
| 22625 | 22680 | /* |
| 22626 | 22681 | ** Generate a human-readable description of a the Select object. |
| 22627 | 22682 | */ |
| 22628 | 22683 | SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){ |
| 22629 | 22684 | int n = 0; |
| 22630 | | - pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 22631 | | - sqlite3TreeViewLine(pView, "SELECT%s%s (0x%p) selFlags=0x%x", |
| 22632 | | - ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""), |
| 22633 | | - ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""), p, p->selFlags |
| 22634 | | - ); |
| 22635 | | - if( p->pSrc && p->pSrc->nSrc ) n++; |
| 22636 | | - if( p->pWhere ) n++; |
| 22637 | | - if( p->pGroupBy ) n++; |
| 22638 | | - if( p->pHaving ) n++; |
| 22639 | | - if( p->pOrderBy ) n++; |
| 22640 | | - if( p->pLimit ) n++; |
| 22641 | | - if( p->pOffset ) n++; |
| 22642 | | - if( p->pPrior ) n++; |
| 22643 | | - sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set"); |
| 22644 | | - if( p->pSrc && p->pSrc->nSrc ){ |
| 22645 | | - int i; |
| 22646 | | - pView = sqlite3TreeViewPush(pView, (n--)>0); |
| 22647 | | - sqlite3TreeViewLine(pView, "FROM"); |
| 22648 | | - for(i=0; i<p->pSrc->nSrc; i++){ |
| 22649 | | - struct SrcList_item *pItem = &p->pSrc->a[i]; |
| 22650 | | - StrAccum x; |
| 22651 | | - char zLine[100]; |
| 22652 | | - sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 22653 | | - sqlite3XPrintf(&x, 0, "{%d,*}", pItem->iCursor); |
| 22654 | | - if( pItem->zDatabase ){ |
| 22655 | | - sqlite3XPrintf(&x, 0, " %s.%s", pItem->zDatabase, pItem->zName); |
| 22656 | | - }else if( pItem->zName ){ |
| 22657 | | - sqlite3XPrintf(&x, 0, " %s", pItem->zName); |
| 22658 | | - } |
| 22659 | | - if( pItem->pTab ){ |
| 22660 | | - sqlite3XPrintf(&x, 0, " tabname=%Q", pItem->pTab->zName); |
| 22661 | | - } |
| 22662 | | - if( pItem->zAlias ){ |
| 22663 | | - sqlite3XPrintf(&x, 0, " (AS %s)", pItem->zAlias); |
| 22664 | | - } |
| 22665 | | - if( pItem->jointype & JT_LEFT ){ |
| 22666 | | - sqlite3XPrintf(&x, 0, " LEFT-JOIN"); |
| 22667 | | - } |
| 22668 | | - sqlite3StrAccumFinish(&x); |
| 22669 | | - sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1); |
| 22670 | | - if( pItem->pSelect ){ |
| 22671 | | - sqlite3TreeViewSelect(pView, pItem->pSelect, 0); |
| 22672 | | - } |
| 22673 | | - sqlite3TreeViewPop(pView); |
| 22674 | | - } |
| 22675 | | - sqlite3TreeViewPop(pView); |
| 22676 | | - } |
| 22677 | | - if( p->pWhere ){ |
| 22678 | | - sqlite3TreeViewItem(pView, "WHERE", (n--)>0); |
| 22679 | | - sqlite3TreeViewExpr(pView, p->pWhere, 0); |
| 22680 | | - sqlite3TreeViewPop(pView); |
| 22681 | | - } |
| 22682 | | - if( p->pGroupBy ){ |
| 22683 | | - sqlite3TreeViewExprList(pView, p->pGroupBy, (n--)>0, "GROUPBY"); |
| 22684 | | - } |
| 22685 | | - if( p->pHaving ){ |
| 22686 | | - sqlite3TreeViewItem(pView, "HAVING", (n--)>0); |
| 22687 | | - sqlite3TreeViewExpr(pView, p->pHaving, 0); |
| 22688 | | - sqlite3TreeViewPop(pView); |
| 22689 | | - } |
| 22690 | | - if( p->pOrderBy ){ |
| 22691 | | - sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, "ORDERBY"); |
| 22692 | | - } |
| 22693 | | - if( p->pLimit ){ |
| 22694 | | - sqlite3TreeViewItem(pView, "LIMIT", (n--)>0); |
| 22695 | | - sqlite3TreeViewExpr(pView, p->pLimit, 0); |
| 22696 | | - sqlite3TreeViewPop(pView); |
| 22697 | | - } |
| 22698 | | - if( p->pOffset ){ |
| 22699 | | - sqlite3TreeViewItem(pView, "OFFSET", (n--)>0); |
| 22700 | | - sqlite3TreeViewExpr(pView, p->pOffset, 0); |
| 22701 | | - sqlite3TreeViewPop(pView); |
| 22702 | | - } |
| 22703 | | - if( p->pPrior ){ |
| 22704 | | - const char *zOp = "UNION"; |
| 22705 | | - switch( p->op ){ |
| 22706 | | - case TK_ALL: zOp = "UNION ALL"; break; |
| 22707 | | - case TK_INTERSECT: zOp = "INTERSECT"; break; |
| 22708 | | - case TK_EXCEPT: zOp = "EXCEPT"; break; |
| 22709 | | - } |
| 22710 | | - sqlite3TreeViewItem(pView, zOp, (n--)>0); |
| 22711 | | - sqlite3TreeViewSelect(pView, p->pPrior, 0); |
| 22712 | | - sqlite3TreeViewPop(pView); |
| 22713 | | - } |
| 22685 | + int cnt = 0; |
| 22686 | + pView = sqlite3TreeViewPush(pView, moreToFollow); |
| 22687 | + do{ |
| 22688 | + sqlite3TreeViewLine(pView, "SELECT%s%s (0x%p) selFlags=0x%x", |
| 22689 | + ((p->selFlags & SF_Distinct) ? " DISTINCT" : ""), |
| 22690 | + ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""), p, p->selFlags |
| 22691 | + ); |
| 22692 | + if( cnt++ ) sqlite3TreeViewPop(pView); |
| 22693 | + if( p->pPrior ){ |
| 22694 | + n = 1000; |
| 22695 | + }else{ |
| 22696 | + n = 0; |
| 22697 | + if( p->pSrc && p->pSrc->nSrc ) n++; |
| 22698 | + if( p->pWhere ) n++; |
| 22699 | + if( p->pGroupBy ) n++; |
| 22700 | + if( p->pHaving ) n++; |
| 22701 | + if( p->pOrderBy ) n++; |
| 22702 | + if( p->pLimit ) n++; |
| 22703 | + if( p->pOffset ) n++; |
| 22704 | + } |
| 22705 | + sqlite3TreeViewExprList(pView, p->pEList, (n--)>0, "result-set"); |
| 22706 | + if( p->pSrc && p->pSrc->nSrc ){ |
| 22707 | + int i; |
| 22708 | + pView = sqlite3TreeViewPush(pView, (n--)>0); |
| 22709 | + sqlite3TreeViewLine(pView, "FROM"); |
| 22710 | + for(i=0; i<p->pSrc->nSrc; i++){ |
| 22711 | + struct SrcList_item *pItem = &p->pSrc->a[i]; |
| 22712 | + StrAccum x; |
| 22713 | + char zLine[100]; |
| 22714 | + sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0); |
| 22715 | + sqlite3XPrintf(&x, 0, "{%d,*}", pItem->iCursor); |
| 22716 | + if( pItem->zDatabase ){ |
| 22717 | + sqlite3XPrintf(&x, 0, " %s.%s", pItem->zDatabase, pItem->zName); |
| 22718 | + }else if( pItem->zName ){ |
| 22719 | + sqlite3XPrintf(&x, 0, " %s", pItem->zName); |
| 22720 | + } |
| 22721 | + if( pItem->pTab ){ |
| 22722 | + sqlite3XPrintf(&x, 0, " tabname=%Q", pItem->pTab->zName); |
| 22723 | + } |
| 22724 | + if( pItem->zAlias ){ |
| 22725 | + sqlite3XPrintf(&x, 0, " (AS %s)", pItem->zAlias); |
| 22726 | + } |
| 22727 | + if( pItem->fg.jointype & JT_LEFT ){ |
| 22728 | + sqlite3XPrintf(&x, 0, " LEFT-JOIN"); |
| 22729 | + } |
| 22730 | + sqlite3StrAccumFinish(&x); |
| 22731 | + sqlite3TreeViewItem(pView, zLine, i<p->pSrc->nSrc-1); |
| 22732 | + if( pItem->pSelect ){ |
| 22733 | + sqlite3TreeViewSelect(pView, pItem->pSelect, 0); |
| 22734 | + } |
| 22735 | + if( pItem->fg.isTabFunc ){ |
| 22736 | + sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:"); |
| 22737 | + } |
| 22738 | + sqlite3TreeViewPop(pView); |
| 22739 | + } |
| 22740 | + sqlite3TreeViewPop(pView); |
| 22741 | + } |
| 22742 | + if( p->pWhere ){ |
| 22743 | + sqlite3TreeViewItem(pView, "WHERE", (n--)>0); |
| 22744 | + sqlite3TreeViewExpr(pView, p->pWhere, 0); |
| 22745 | + sqlite3TreeViewPop(pView); |
| 22746 | + } |
| 22747 | + if( p->pGroupBy ){ |
| 22748 | + sqlite3TreeViewExprList(pView, p->pGroupBy, (n--)>0, "GROUPBY"); |
| 22749 | + } |
| 22750 | + if( p->pHaving ){ |
| 22751 | + sqlite3TreeViewItem(pView, "HAVING", (n--)>0); |
| 22752 | + sqlite3TreeViewExpr(pView, p->pHaving, 0); |
| 22753 | + sqlite3TreeViewPop(pView); |
| 22754 | + } |
| 22755 | + if( p->pOrderBy ){ |
| 22756 | + sqlite3TreeViewExprList(pView, p->pOrderBy, (n--)>0, "ORDERBY"); |
| 22757 | + } |
| 22758 | + if( p->pLimit ){ |
| 22759 | + sqlite3TreeViewItem(pView, "LIMIT", (n--)>0); |
| 22760 | + sqlite3TreeViewExpr(pView, p->pLimit, 0); |
| 22761 | + sqlite3TreeViewPop(pView); |
| 22762 | + } |
| 22763 | + if( p->pOffset ){ |
| 22764 | + sqlite3TreeViewItem(pView, "OFFSET", (n--)>0); |
| 22765 | + sqlite3TreeViewExpr(pView, p->pOffset, 0); |
| 22766 | + sqlite3TreeViewPop(pView); |
| 22767 | + } |
| 22768 | + if( p->pPrior ){ |
| 22769 | + const char *zOp = "UNION"; |
| 22770 | + switch( p->op ){ |
| 22771 | + case TK_ALL: zOp = "UNION ALL"; break; |
| 22772 | + case TK_INTERSECT: zOp = "INTERSECT"; break; |
| 22773 | + case TK_EXCEPT: zOp = "EXCEPT"; break; |
| 22774 | + } |
| 22775 | + sqlite3TreeViewItem(pView, zOp, 1); |
| 22776 | + } |
| 22777 | + p = p->pPrior; |
| 22778 | + }while( p!=0 ); |
| 22714 | 22779 | sqlite3TreeViewPop(pView); |
| 22715 | 22780 | } |
| 22716 | 22781 | |
| 22717 | 22782 | /* |
| 22718 | 22783 | ** Generate a human-readable explanation of an expression tree. |
| | @@ -22783,15 +22848,10 @@ |
| 22783 | 22848 | } |
| 22784 | 22849 | case TK_REGISTER: { |
| 22785 | 22850 | sqlite3TreeViewLine(pView,"REGISTER(%d)", pExpr->iTable); |
| 22786 | 22851 | break; |
| 22787 | 22852 | } |
| 22788 | | - case TK_AS: { |
| 22789 | | - sqlite3TreeViewLine(pView,"AS %Q", pExpr->u.zToken); |
| 22790 | | - sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 22791 | | - break; |
| 22792 | | - } |
| 22793 | 22853 | case TK_ID: { |
| 22794 | 22854 | sqlite3TreeViewLine(pView,"ID \"%w\"", pExpr->u.zToken); |
| 22795 | 22855 | break; |
| 22796 | 22856 | } |
| 22797 | 22857 | #ifndef SQLITE_OMIT_CAST |
| | @@ -22962,11 +23022,17 @@ |
| 22962 | 23022 | if( pList==0 ){ |
| 22963 | 23023 | sqlite3TreeViewLine(pView, "%s (empty)", zLabel); |
| 22964 | 23024 | }else{ |
| 22965 | 23025 | sqlite3TreeViewLine(pView, "%s", zLabel); |
| 22966 | 23026 | for(i=0; i<pList->nExpr; i++){ |
| 23027 | + int j = pList->a[i].u.x.iOrderByCol; |
| 23028 | + if( j ){ |
| 23029 | + sqlite3TreeViewPush(pView, 0); |
| 23030 | + sqlite3TreeViewLine(pView, "iOrderByCol=%d", j); |
| 23031 | + } |
| 22967 | 23032 | sqlite3TreeViewExpr(pView, pList->a[i].pExpr, i<pList->nExpr-1); |
| 23033 | + if( j ) sqlite3TreeViewPop(pView); |
| 22968 | 23034 | } |
| 22969 | 23035 | } |
| 22970 | 23036 | sqlite3TreeViewPop(pView); |
| 22971 | 23037 | } |
| 22972 | 23038 | |
| | @@ -24977,15 +25043,12 @@ |
| 24977 | 25043 | /* |
| 24978 | 25044 | ** Return the number of bytes that will be needed to store the given |
| 24979 | 25045 | ** 64-bit integer. |
| 24980 | 25046 | */ |
| 24981 | 25047 | SQLITE_PRIVATE int sqlite3VarintLen(u64 v){ |
| 24982 | | - int i = 0; |
| 24983 | | - do{ |
| 24984 | | - i++; |
| 24985 | | - v >>= 7; |
| 24986 | | - }while( v!=0 && ALWAYS(i<9) ); |
| 25048 | + int i; |
| 25049 | + for(i=1; (v >>= 7)!=0; i++){ assert( i<9 ); } |
| 24987 | 25050 | return i; |
| 24988 | 25051 | } |
| 24989 | 25052 | |
| 24990 | 25053 | |
| 24991 | 25054 | /* |
| | @@ -24994,15 +25057,17 @@ |
| 24994 | 25057 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 24995 | 25058 | #if SQLITE_BYTEORDER==4321 |
| 24996 | 25059 | u32 x; |
| 24997 | 25060 | memcpy(&x,p,4); |
| 24998 | 25061 | return x; |
| 24999 | | -#elif SQLITE_BYTEORDER==1234 && defined(__GNUC__) && GCC_VERSION>=4003000 |
| 25062 | +#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 25063 | + && defined(__GNUC__) && GCC_VERSION>=4003000 |
| 25000 | 25064 | u32 x; |
| 25001 | 25065 | memcpy(&x,p,4); |
| 25002 | 25066 | return __builtin_bswap32(x); |
| 25003 | | -#elif SQLITE_BYTEORDER==1234 && defined(_MSC_VER) && _MSC_VER>=1300 |
| 25067 | +#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 25068 | + && defined(_MSC_VER) && _MSC_VER>=1300 |
| 25004 | 25069 | u32 x; |
| 25005 | 25070 | memcpy(&x,p,4); |
| 25006 | 25071 | return _byteswap_ulong(x); |
| 25007 | 25072 | #else |
| 25008 | 25073 | testcase( p[0]&0x80 ); |
| | @@ -29103,11 +29168,10 @@ |
| 29103 | 29168 | i64 newOffset; |
| 29104 | 29169 | #endif |
| 29105 | 29170 | TIMER_START; |
| 29106 | 29171 | assert( cnt==(cnt&0x1ffff) ); |
| 29107 | 29172 | assert( id->h>2 ); |
| 29108 | | - cnt &= 0x1ffff; |
| 29109 | 29173 | do{ |
| 29110 | 29174 | #if defined(USE_PREAD) |
| 29111 | 29175 | got = osPread(id->h, pBuf, cnt, offset); |
| 29112 | 29176 | SimulateIOError( got = -1 ); |
| 29113 | 29177 | #elif defined(USE_PREAD64) |
| | @@ -29320,20 +29384,20 @@ |
| 29320 | 29384 | amt -= nCopy; |
| 29321 | 29385 | offset += nCopy; |
| 29322 | 29386 | } |
| 29323 | 29387 | } |
| 29324 | 29388 | #endif |
| 29325 | | - |
| 29326 | | - while( amt>0 && (wrote = seekAndWrite(pFile, offset, pBuf, amt))>0 ){ |
| 29389 | + |
| 29390 | + while( (wrote = seekAndWrite(pFile, offset, pBuf, amt))<amt && wrote>0 ){ |
| 29327 | 29391 | amt -= wrote; |
| 29328 | 29392 | offset += wrote; |
| 29329 | 29393 | pBuf = &((char*)pBuf)[wrote]; |
| 29330 | 29394 | } |
| 29331 | 29395 | SimulateIOError(( wrote=(-1), amt=1 )); |
| 29332 | 29396 | SimulateDiskfullError(( wrote=0, amt=1 )); |
| 29333 | 29397 | |
| 29334 | | - if( amt>0 ){ |
| 29398 | + if( amt>wrote ){ |
| 29335 | 29399 | if( wrote<0 && pFile->lastErrno!=ENOSPC ){ |
| 29336 | 29400 | /* lastErrno set by seekAndWrite */ |
| 29337 | 29401 | return SQLITE_IOERR_WRITE; |
| 29338 | 29402 | }else{ |
| 29339 | 29403 | storeLastErrno(pFile, 0); /* not a system error */ |
| | @@ -39798,11 +39862,11 @@ |
| 39798 | 39862 | ** A complete page cache is an instance of this structure. |
| 39799 | 39863 | */ |
| 39800 | 39864 | struct PCache { |
| 39801 | 39865 | PgHdr *pDirty, *pDirtyTail; /* List of dirty pages in LRU order */ |
| 39802 | 39866 | PgHdr *pSynced; /* Last synced page in dirty page list */ |
| 39803 | | - int nRef; /* Number of referenced pages */ |
| 39867 | + int nRefSum; /* Sum of ref counts over all pages */ |
| 39804 | 39868 | int szCache; /* Configured cache size */ |
| 39805 | 39869 | int szPage; /* Size of every page in this cache */ |
| 39806 | 39870 | int szExtra; /* Size of extra space for each page */ |
| 39807 | 39871 | u8 bPurgeable; /* True if pages are on backing store */ |
| 39808 | 39872 | u8 eCreate; /* eCreate value for for xFetch() */ |
| | @@ -39963,11 +40027,11 @@ |
| 39963 | 40027 | /* |
| 39964 | 40028 | ** Change the page size for PCache object. The caller must ensure that there |
| 39965 | 40029 | ** are no outstanding page references when this function is called. |
| 39966 | 40030 | */ |
| 39967 | 40031 | SQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){ |
| 39968 | | - assert( pCache->nRef==0 && pCache->pDirty==0 ); |
| 40032 | + assert( pCache->nRefSum==0 && pCache->pDirty==0 ); |
| 39969 | 40033 | if( pCache->szPage ){ |
| 39970 | 40034 | sqlite3_pcache *pNew; |
| 39971 | 40035 | pNew = sqlite3GlobalConfig.pcache2.xCreate( |
| 39972 | 40036 | szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)), |
| 39973 | 40037 | pCache->bPurgeable |
| | @@ -40130,13 +40194,11 @@ |
| 40130 | 40194 | pPgHdr = (PgHdr *)pPage->pExtra; |
| 40131 | 40195 | |
| 40132 | 40196 | if( !pPgHdr->pPage ){ |
| 40133 | 40197 | return pcacheFetchFinishWithInit(pCache, pgno, pPage); |
| 40134 | 40198 | } |
| 40135 | | - if( 0==pPgHdr->nRef ){ |
| 40136 | | - pCache->nRef++; |
| 40137 | | - } |
| 40199 | + pCache->nRefSum++; |
| 40138 | 40200 | pPgHdr->nRef++; |
| 40139 | 40201 | return pPgHdr; |
| 40140 | 40202 | } |
| 40141 | 40203 | |
| 40142 | 40204 | /* |
| | @@ -40143,13 +40205,12 @@ |
| 40143 | 40205 | ** Decrement the reference count on a page. If the page is clean and the |
| 40144 | 40206 | ** reference count drops to 0, then it is made eligible for recycling. |
| 40145 | 40207 | */ |
| 40146 | 40208 | SQLITE_PRIVATE void SQLITE_NOINLINE sqlite3PcacheRelease(PgHdr *p){ |
| 40147 | 40209 | assert( p->nRef>0 ); |
| 40148 | | - p->nRef--; |
| 40149 | | - if( p->nRef==0 ){ |
| 40150 | | - p->pCache->nRef--; |
| 40210 | + p->pCache->nRefSum--; |
| 40211 | + if( (--p->nRef)==0 ){ |
| 40151 | 40212 | if( p->flags&PGHDR_CLEAN ){ |
| 40152 | 40213 | pcacheUnpin(p); |
| 40153 | 40214 | }else if( p->pDirtyPrev!=0 ){ |
| 40154 | 40215 | /* Move the page to the head of the dirty list. */ |
| 40155 | 40216 | pcacheManageDirtyList(p, PCACHE_DIRTYLIST_FRONT); |
| | @@ -40161,10 +40222,11 @@ |
| 40161 | 40222 | ** Increase the reference count of a supplied page by 1. |
| 40162 | 40223 | */ |
| 40163 | 40224 | SQLITE_PRIVATE void sqlite3PcacheRef(PgHdr *p){ |
| 40164 | 40225 | assert(p->nRef>0); |
| 40165 | 40226 | p->nRef++; |
| 40227 | + p->pCache->nRefSum++; |
| 40166 | 40228 | } |
| 40167 | 40229 | |
| 40168 | 40230 | /* |
| 40169 | 40231 | ** Drop a page from the cache. There must be exactly one reference to the |
| 40170 | 40232 | ** page. This function deletes that reference, so after it returns the |
| | @@ -40173,11 +40235,11 @@ |
| 40173 | 40235 | SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){ |
| 40174 | 40236 | assert( p->nRef==1 ); |
| 40175 | 40237 | if( p->flags&PGHDR_DIRTY ){ |
| 40176 | 40238 | pcacheManageDirtyList(p, PCACHE_DIRTYLIST_REMOVE); |
| 40177 | 40239 | } |
| 40178 | | - p->pCache->nRef--; |
| 40240 | + p->pCache->nRefSum--; |
| 40179 | 40241 | sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 1); |
| 40180 | 40242 | } |
| 40181 | 40243 | |
| 40182 | 40244 | /* |
| 40183 | 40245 | ** Make sure the page is marked as dirty. If it isn't dirty already, |
| | @@ -40269,15 +40331,15 @@ |
| 40269 | 40331 | if( ALWAYS(p->pgno>pgno) ){ |
| 40270 | 40332 | assert( p->flags&PGHDR_DIRTY ); |
| 40271 | 40333 | sqlite3PcacheMakeClean(p); |
| 40272 | 40334 | } |
| 40273 | 40335 | } |
| 40274 | | - if( pgno==0 && pCache->nRef ){ |
| 40336 | + if( pgno==0 && pCache->nRefSum ){ |
| 40275 | 40337 | sqlite3_pcache_page *pPage1; |
| 40276 | 40338 | pPage1 = sqlite3GlobalConfig.pcache2.xFetch(pCache->pCache,1,0); |
| 40277 | 40339 | if( ALWAYS(pPage1) ){ /* Page 1 is always available in cache, because |
| 40278 | | - ** pCache->nRef>0 */ |
| 40340 | + ** pCache->nRefSum>0 */ |
| 40279 | 40341 | memset(pPage1->pBuf, 0, pCache->szPage); |
| 40280 | 40342 | pgno = 1; |
| 40281 | 40343 | } |
| 40282 | 40344 | } |
| 40283 | 40345 | sqlite3GlobalConfig.pcache2.xTruncate(pCache->pCache, pgno+1); |
| | @@ -40379,14 +40441,17 @@ |
| 40379 | 40441 | } |
| 40380 | 40442 | return pcacheSortDirtyList(pCache->pDirty); |
| 40381 | 40443 | } |
| 40382 | 40444 | |
| 40383 | 40445 | /* |
| 40384 | | -** Return the total number of referenced pages held by the cache. |
| 40446 | +** Return the total number of references to all pages held by the cache. |
| 40447 | +** |
| 40448 | +** This is not the total number of pages referenced, but the sum of the |
| 40449 | +** reference count for all pages. |
| 40385 | 40450 | */ |
| 40386 | 40451 | SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache *pCache){ |
| 40387 | | - return pCache->nRef; |
| 40452 | + return pCache->nRefSum; |
| 40388 | 40453 | } |
| 40389 | 40454 | |
| 40390 | 40455 | /* |
| 40391 | 40456 | ** Return the number of references to the page supplied as an argument. |
| 40392 | 40457 | */ |
| | @@ -40517,11 +40582,11 @@ |
| 40517 | 40582 | ** |
| 40518 | 40583 | ** The third case is a chunk of heap memory (defaulting to 100 pages worth) |
| 40519 | 40584 | ** that is allocated when the page cache is created. The size of the local |
| 40520 | 40585 | ** bulk allocation can be adjusted using |
| 40521 | 40586 | ** |
| 40522 | | -** sqlite3_config(SQLITE_CONFIG_PCACHE, 0, 0, N). |
| 40587 | +** sqlite3_config(SQLITE_CONFIG_PAGECACHE, 0, 0, N). |
| 40523 | 40588 | ** |
| 40524 | 40589 | ** If N is positive, then N pages worth of memory are allocated using a single |
| 40525 | 40590 | ** sqlite3Malloc() call and that memory is used for the first N pages allocated. |
| 40526 | 40591 | ** Or if N is negative, then -1024*N bytes of memory are allocated and used |
| 40527 | 40592 | ** for as many pages as can be accomodated. |
| | @@ -40538,10 +40603,28 @@ |
| 40538 | 40603 | |
| 40539 | 40604 | typedef struct PCache1 PCache1; |
| 40540 | 40605 | typedef struct PgHdr1 PgHdr1; |
| 40541 | 40606 | typedef struct PgFreeslot PgFreeslot; |
| 40542 | 40607 | typedef struct PGroup PGroup; |
| 40608 | + |
| 40609 | +/* |
| 40610 | +** Each cache entry is represented by an instance of the following |
| 40611 | +** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of |
| 40612 | +** PgHdr1.pCache->szPage bytes is allocated directly before this structure |
| 40613 | +** in memory. |
| 40614 | +*/ |
| 40615 | +struct PgHdr1 { |
| 40616 | + sqlite3_pcache_page page; /* Base class. Must be first. pBuf & pExtra */ |
| 40617 | + unsigned int iKey; /* Key value (page number) */ |
| 40618 | + u8 isPinned; /* Page in use, not on the LRU list */ |
| 40619 | + u8 isBulkLocal; /* This page from bulk local storage */ |
| 40620 | + u8 isAnchor; /* This is the PGroup.lru element */ |
| 40621 | + PgHdr1 *pNext; /* Next in hash table chain */ |
| 40622 | + PCache1 *pCache; /* Cache that currently owns this page */ |
| 40623 | + PgHdr1 *pLruNext; /* Next in LRU list of unpinned pages */ |
| 40624 | + PgHdr1 *pLruPrev; /* Previous in LRU list of unpinned pages */ |
| 40625 | +}; |
| 40543 | 40626 | |
| 40544 | 40627 | /* Each page cache (or PCache) belongs to a PGroup. A PGroup is a set |
| 40545 | 40628 | ** of one or more PCaches that are able to recycle each other's unpinned |
| 40546 | 40629 | ** pages when they are under memory pressure. A PGroup is an instance of |
| 40547 | 40630 | ** the following object. |
| | @@ -40567,11 +40650,11 @@ |
| 40567 | 40650 | sqlite3_mutex *mutex; /* MUTEX_STATIC_LRU or NULL */ |
| 40568 | 40651 | unsigned int nMaxPage; /* Sum of nMax for purgeable caches */ |
| 40569 | 40652 | unsigned int nMinPage; /* Sum of nMin for purgeable caches */ |
| 40570 | 40653 | unsigned int mxPinned; /* nMaxpage + 10 - nMinPage */ |
| 40571 | 40654 | unsigned int nCurrentPage; /* Number of purgeable pages allocated */ |
| 40572 | | - PgHdr1 *pLruHead, *pLruTail; /* LRU list of unpinned pages */ |
| 40655 | + PgHdr1 lru; /* The beginning and end of the LRU list */ |
| 40573 | 40656 | }; |
| 40574 | 40657 | |
| 40575 | 40658 | /* Each page cache is an instance of the following object. Every |
| 40576 | 40659 | ** open database file (including each in-memory database and each |
| 40577 | 40660 | ** temporary or transient database) has a single page cache which |
| | @@ -40605,27 +40688,10 @@ |
| 40605 | 40688 | PgHdr1 **apHash; /* Hash table for fast lookup by key */ |
| 40606 | 40689 | PgHdr1 *pFree; /* List of unused pcache-local pages */ |
| 40607 | 40690 | void *pBulk; /* Bulk memory used by pcache-local */ |
| 40608 | 40691 | }; |
| 40609 | 40692 | |
| 40610 | | -/* |
| 40611 | | -** Each cache entry is represented by an instance of the following |
| 40612 | | -** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of |
| 40613 | | -** PgHdr1.pCache->szPage bytes is allocated directly before this structure |
| 40614 | | -** in memory. |
| 40615 | | -*/ |
| 40616 | | -struct PgHdr1 { |
| 40617 | | - sqlite3_pcache_page page; |
| 40618 | | - unsigned int iKey; /* Key value (page number) */ |
| 40619 | | - u8 isPinned; /* Page in use, not on the LRU list */ |
| 40620 | | - u8 isBulkLocal; /* This page from bulk local storage */ |
| 40621 | | - PgHdr1 *pNext; /* Next in hash table chain */ |
| 40622 | | - PCache1 *pCache; /* Cache that currently owns this page */ |
| 40623 | | - PgHdr1 *pLruNext; /* Next in LRU list of unpinned pages */ |
| 40624 | | - PgHdr1 *pLruPrev; /* Previous in LRU list of unpinned pages */ |
| 40625 | | -}; |
| 40626 | | - |
| 40627 | 40693 | /* |
| 40628 | 40694 | ** Free slots in the allocator used to divide up the global page cache |
| 40629 | 40695 | ** buffer provided using the SQLITE_CONFIG_PAGECACHE mechanism. |
| 40630 | 40696 | */ |
| 40631 | 40697 | struct PgFreeslot { |
| | @@ -40681,10 +40747,11 @@ |
| 40681 | 40747 | # define PCACHE1_MIGHT_USE_GROUP_MUTEX 1 |
| 40682 | 40748 | #endif |
| 40683 | 40749 | |
| 40684 | 40750 | /******************************************************************************/ |
| 40685 | 40751 | /******** Page Allocation/SQLITE_CONFIG_PCACHE Related Functions **************/ |
| 40752 | + |
| 40686 | 40753 | |
| 40687 | 40754 | /* |
| 40688 | 40755 | ** This function is called during initialization if a static buffer is |
| 40689 | 40756 | ** supplied to use for the page-cache by passing the SQLITE_CONFIG_PAGECACHE |
| 40690 | 40757 | ** verb to sqlite3_config(). Parameter pBuf points to an allocation large |
| | @@ -40741,10 +40808,11 @@ |
| 40741 | 40808 | for(i=0; i<nBulk; i++){ |
| 40742 | 40809 | PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; |
| 40743 | 40810 | pX->page.pBuf = zBulk; |
| 40744 | 40811 | pX->page.pExtra = &pX[1]; |
| 40745 | 40812 | pX->isBulkLocal = 1; |
| 40813 | + pX->isAnchor = 0; |
| 40746 | 40814 | pX->pNext = pCache->pFree; |
| 40747 | 40815 | pCache->pFree = pX; |
| 40748 | 40816 | zBulk += pCache->szAlloc; |
| 40749 | 40817 | } |
| 40750 | 40818 | } |
| | @@ -40844,11 +40912,11 @@ |
| 40844 | 40912 | #endif /* SQLITE_ENABLE_MEMORY_MANAGEMENT */ |
| 40845 | 40913 | |
| 40846 | 40914 | /* |
| 40847 | 40915 | ** Allocate a new page object initially associated with cache pCache. |
| 40848 | 40916 | */ |
| 40849 | | -static PgHdr1 *pcache1AllocPage(PCache1 *pCache){ |
| 40917 | +static PgHdr1 *pcache1AllocPage(PCache1 *pCache, int benignMalloc){ |
| 40850 | 40918 | PgHdr1 *p = 0; |
| 40851 | 40919 | void *pPg; |
| 40852 | 40920 | |
| 40853 | 40921 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 40854 | 40922 | if( pCache->pFree || (pCache->nPage==0 && pcache1InitBulk(pCache)) ){ |
| | @@ -40862,10 +40930,11 @@ |
| 40862 | 40930 | ** this mutex is not held. */ |
| 40863 | 40931 | assert( pcache1.separateCache==0 ); |
| 40864 | 40932 | assert( pCache->pGroup==&pcache1.grp ); |
| 40865 | 40933 | pcache1LeaveMutex(pCache->pGroup); |
| 40866 | 40934 | #endif |
| 40935 | + if( benignMalloc ) sqlite3BeginBenignMalloc(); |
| 40867 | 40936 | #ifdef SQLITE_PCACHE_SEPARATE_HEADER |
| 40868 | 40937 | pPg = pcache1Alloc(pCache->szPage); |
| 40869 | 40938 | p = sqlite3Malloc(sizeof(PgHdr1) + pCache->szExtra); |
| 40870 | 40939 | if( !pPg || !p ){ |
| 40871 | 40940 | pcache1Free(pPg); |
| | @@ -40874,17 +40943,19 @@ |
| 40874 | 40943 | } |
| 40875 | 40944 | #else |
| 40876 | 40945 | pPg = pcache1Alloc(pCache->szAlloc); |
| 40877 | 40946 | p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage]; |
| 40878 | 40947 | #endif |
| 40948 | + if( benignMalloc ) sqlite3EndBenignMalloc(); |
| 40879 | 40949 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 40880 | 40950 | pcache1EnterMutex(pCache->pGroup); |
| 40881 | 40951 | #endif |
| 40882 | 40952 | if( pPg==0 ) return 0; |
| 40883 | 40953 | p->page.pBuf = pPg; |
| 40884 | 40954 | p->page.pExtra = &p[1]; |
| 40885 | 40955 | p->isBulkLocal = 0; |
| 40956 | + p->isAnchor = 0; |
| 40886 | 40957 | } |
| 40887 | 40958 | if( pCache->bPurgeable ){ |
| 40888 | 40959 | pCache->pGroup->nCurrentPage++; |
| 40889 | 40960 | } |
| 40890 | 40961 | return p; |
| | @@ -41007,26 +41078,20 @@ |
| 41007 | 41078 | PCache1 *pCache; |
| 41008 | 41079 | |
| 41009 | 41080 | assert( pPage!=0 ); |
| 41010 | 41081 | assert( pPage->isPinned==0 ); |
| 41011 | 41082 | pCache = pPage->pCache; |
| 41012 | | - assert( pPage->pLruNext || pPage==pCache->pGroup->pLruTail ); |
| 41013 | | - assert( pPage->pLruPrev || pPage==pCache->pGroup->pLruHead ); |
| 41083 | + assert( pPage->pLruNext ); |
| 41084 | + assert( pPage->pLruPrev ); |
| 41014 | 41085 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 41015 | | - if( pPage->pLruPrev ){ |
| 41016 | | - pPage->pLruPrev->pLruNext = pPage->pLruNext; |
| 41017 | | - }else{ |
| 41018 | | - pCache->pGroup->pLruHead = pPage->pLruNext; |
| 41019 | | - } |
| 41020 | | - if( pPage->pLruNext ){ |
| 41021 | | - pPage->pLruNext->pLruPrev = pPage->pLruPrev; |
| 41022 | | - }else{ |
| 41023 | | - pCache->pGroup->pLruTail = pPage->pLruPrev; |
| 41024 | | - } |
| 41086 | + pPage->pLruPrev->pLruNext = pPage->pLruNext; |
| 41087 | + pPage->pLruNext->pLruPrev = pPage->pLruPrev; |
| 41025 | 41088 | pPage->pLruNext = 0; |
| 41026 | 41089 | pPage->pLruPrev = 0; |
| 41027 | 41090 | pPage->isPinned = 1; |
| 41091 | + assert( pPage->isAnchor==0 ); |
| 41092 | + assert( pCache->pGroup->lru.isAnchor==1 ); |
| 41028 | 41093 | pCache->nRecyclable--; |
| 41029 | 41094 | return pPage; |
| 41030 | 41095 | } |
| 41031 | 41096 | |
| 41032 | 41097 | |
| | @@ -41055,13 +41120,15 @@ |
| 41055 | 41120 | ** If there are currently more than nMaxPage pages allocated, try |
| 41056 | 41121 | ** to recycle pages to reduce the number allocated to nMaxPage. |
| 41057 | 41122 | */ |
| 41058 | 41123 | static void pcache1EnforceMaxPage(PCache1 *pCache){ |
| 41059 | 41124 | PGroup *pGroup = pCache->pGroup; |
| 41125 | + PgHdr1 *p; |
| 41060 | 41126 | assert( sqlite3_mutex_held(pGroup->mutex) ); |
| 41061 | | - while( pGroup->nCurrentPage>pGroup->nMaxPage && pGroup->pLruTail ){ |
| 41062 | | - PgHdr1 *p = pGroup->pLruTail; |
| 41127 | + while( pGroup->nCurrentPage>pGroup->nMaxPage |
| 41128 | + && (p=pGroup->lru.pLruPrev)->isAnchor==0 |
| 41129 | + ){ |
| 41063 | 41130 | assert( p->pCache->pGroup==pGroup ); |
| 41064 | 41131 | assert( p->isPinned==0 ); |
| 41065 | 41132 | pcache1PinPage(p); |
| 41066 | 41133 | pcache1RemoveFromHash(p, 1); |
| 41067 | 41134 | } |
| | @@ -41191,10 +41258,14 @@ |
| 41191 | 41258 | pGroup = (PGroup*)&pCache[1]; |
| 41192 | 41259 | pGroup->mxPinned = 10; |
| 41193 | 41260 | }else{ |
| 41194 | 41261 | pGroup = &pcache1.grp; |
| 41195 | 41262 | } |
| 41263 | + if( pGroup->lru.isAnchor==0 ){ |
| 41264 | + pGroup->lru.isAnchor = 1; |
| 41265 | + pGroup->lru.pLruPrev = pGroup->lru.pLruNext = &pGroup->lru; |
| 41266 | + } |
| 41196 | 41267 | pCache->pGroup = pGroup; |
| 41197 | 41268 | pCache->szPage = szPage; |
| 41198 | 41269 | pCache->szExtra = szExtra; |
| 41199 | 41270 | pCache->szAlloc = szPage + szExtra + ROUND8(sizeof(PgHdr1)); |
| 41200 | 41271 | pCache->bPurgeable = (bPurgeable ? 1 : 0); |
| | @@ -41298,15 +41369,15 @@ |
| 41298 | 41369 | if( pCache->nPage>=pCache->nHash ) pcache1ResizeHash(pCache); |
| 41299 | 41370 | assert( pCache->nHash>0 && pCache->apHash ); |
| 41300 | 41371 | |
| 41301 | 41372 | /* Step 4. Try to recycle a page. */ |
| 41302 | 41373 | if( pCache->bPurgeable |
| 41303 | | - && pGroup->pLruTail |
| 41374 | + && !pGroup->lru.pLruPrev->isAnchor |
| 41304 | 41375 | && ((pCache->nPage+1>=pCache->nMax) || pcache1UnderMemoryPressure(pCache)) |
| 41305 | 41376 | ){ |
| 41306 | 41377 | PCache1 *pOther; |
| 41307 | | - pPage = pGroup->pLruTail; |
| 41378 | + pPage = pGroup->lru.pLruPrev; |
| 41308 | 41379 | assert( pPage->isPinned==0 ); |
| 41309 | 41380 | pcache1RemoveFromHash(pPage, 0); |
| 41310 | 41381 | pcache1PinPage(pPage); |
| 41311 | 41382 | pOther = pPage->pCache; |
| 41312 | 41383 | if( pOther->szAlloc != pCache->szAlloc ){ |
| | @@ -41319,13 +41390,11 @@ |
| 41319 | 41390 | |
| 41320 | 41391 | /* Step 5. If a usable page buffer has still not been found, |
| 41321 | 41392 | ** attempt to allocate a new one. |
| 41322 | 41393 | */ |
| 41323 | 41394 | if( !pPage ){ |
| 41324 | | - if( createFlag==1 ){ sqlite3BeginBenignMalloc(); } |
| 41325 | | - pPage = pcache1AllocPage(pCache); |
| 41326 | | - if( createFlag==1 ){ sqlite3EndBenignMalloc(); } |
| 41395 | + pPage = pcache1AllocPage(pCache, createFlag==1); |
| 41327 | 41396 | } |
| 41328 | 41397 | |
| 41329 | 41398 | if( pPage ){ |
| 41330 | 41399 | unsigned int h = iKey % pCache->nHash; |
| 41331 | 41400 | pCache->nPage++; |
| | @@ -41413,11 +41482,14 @@ |
| 41413 | 41482 | |
| 41414 | 41483 | /* Step 1: Search the hash table for an existing entry. */ |
| 41415 | 41484 | pPage = pCache->apHash[iKey % pCache->nHash]; |
| 41416 | 41485 | while( pPage && pPage->iKey!=iKey ){ pPage = pPage->pNext; } |
| 41417 | 41486 | |
| 41418 | | - /* Step 2: Abort if no existing page is found and createFlag is 0 */ |
| 41487 | + /* Step 2: If the page was found in the hash table, then return it. |
| 41488 | + ** If the page was not in the hash table and createFlag is 0, abort. |
| 41489 | + ** Otherwise (page not in hash and createFlag!=0) continue with |
| 41490 | + ** subsequent steps to try to create the page. */ |
| 41419 | 41491 | if( pPage ){ |
| 41420 | 41492 | if( !pPage->isPinned ){ |
| 41421 | 41493 | return pcache1PinPage(pPage); |
| 41422 | 41494 | }else{ |
| 41423 | 41495 | return pPage; |
| | @@ -41490,25 +41562,20 @@ |
| 41490 | 41562 | |
| 41491 | 41563 | /* It is an error to call this function if the page is already |
| 41492 | 41564 | ** part of the PGroup LRU list. |
| 41493 | 41565 | */ |
| 41494 | 41566 | assert( pPage->pLruPrev==0 && pPage->pLruNext==0 ); |
| 41495 | | - assert( pGroup->pLruHead!=pPage && pGroup->pLruTail!=pPage ); |
| 41496 | 41567 | assert( pPage->isPinned==1 ); |
| 41497 | 41568 | |
| 41498 | 41569 | if( reuseUnlikely || pGroup->nCurrentPage>pGroup->nMaxPage ){ |
| 41499 | 41570 | pcache1RemoveFromHash(pPage, 1); |
| 41500 | 41571 | }else{ |
| 41501 | 41572 | /* Add the page to the PGroup LRU list. */ |
| 41502 | | - if( pGroup->pLruHead ){ |
| 41503 | | - pGroup->pLruHead->pLruPrev = pPage; |
| 41504 | | - pPage->pLruNext = pGroup->pLruHead; |
| 41505 | | - pGroup->pLruHead = pPage; |
| 41506 | | - }else{ |
| 41507 | | - pGroup->pLruTail = pPage; |
| 41508 | | - pGroup->pLruHead = pPage; |
| 41509 | | - } |
| 41573 | + PgHdr1 **ppFirst = &pGroup->lru.pLruNext; |
| 41574 | + pPage->pLruPrev = &pGroup->lru; |
| 41575 | + (pPage->pLruNext = *ppFirst)->pLruPrev = pPage; |
| 41576 | + *ppFirst = pPage; |
| 41510 | 41577 | pCache->nRecyclable++; |
| 41511 | 41578 | pPage->isPinned = 0; |
| 41512 | 41579 | } |
| 41513 | 41580 | |
| 41514 | 41581 | pcache1LeaveMutex(pCache->pGroup); |
| | @@ -41642,11 +41709,14 @@ |
| 41642 | 41709 | assert( sqlite3_mutex_notheld(pcache1.grp.mutex) ); |
| 41643 | 41710 | assert( sqlite3_mutex_notheld(pcache1.mutex) ); |
| 41644 | 41711 | if( sqlite3GlobalConfig.nPage==0 ){ |
| 41645 | 41712 | PgHdr1 *p; |
| 41646 | 41713 | pcache1EnterMutex(&pcache1.grp); |
| 41647 | | - while( (nReq<0 || nFree<nReq) && ((p=pcache1.grp.pLruTail)!=0) ){ |
| 41714 | + while( (nReq<0 || nFree<nReq) |
| 41715 | + && (p=pcache1.grp.lru.pLruPrev)!=0 |
| 41716 | + && p->isAnchor==0 |
| 41717 | + ){ |
| 41648 | 41718 | nFree += pcache1MemSize(p->page.pBuf); |
| 41649 | 41719 | #ifdef SQLITE_PCACHE_SEPARATE_HEADER |
| 41650 | 41720 | nFree += sqlite3MemSize(p); |
| 41651 | 41721 | #endif |
| 41652 | 41722 | assert( p->isPinned==0 ); |
| | @@ -41670,11 +41740,11 @@ |
| 41670 | 41740 | int *pnMin, /* OUT: Sum of PCache1.nMin for purgeable caches */ |
| 41671 | 41741 | int *pnRecyclable /* OUT: Total number of pages available for recycling */ |
| 41672 | 41742 | ){ |
| 41673 | 41743 | PgHdr1 *p; |
| 41674 | 41744 | int nRecyclable = 0; |
| 41675 | | - for(p=pcache1.grp.pLruHead; p; p=p->pLruNext){ |
| 41745 | + for(p=pcache1.grp.lru.pLruNext; p && !p->isAnchor; p=p->pLruNext){ |
| 41676 | 41746 | assert( p->isPinned==0 ); |
| 41677 | 41747 | nRecyclable++; |
| 41678 | 41748 | } |
| 41679 | 41749 | *pnCurrent = pcache1.grp.nCurrentPage; |
| 41680 | 41750 | *pnMax = (int)pcache1.grp.nMaxPage; |
| | @@ -42984,11 +43054,11 @@ |
| 42984 | 43054 | u8 changeCountDone; /* Set after incrementing the change-counter */ |
| 42985 | 43055 | u8 setMaster; /* True if a m-j name has been written to jrnl */ |
| 42986 | 43056 | u8 doNotSpill; /* Do not spill the cache when non-zero */ |
| 42987 | 43057 | u8 subjInMemory; /* True to use in-memory sub-journals */ |
| 42988 | 43058 | u8 bUseFetch; /* True to use xFetch() */ |
| 42989 | | - u8 hasBeenUsed; /* True if any content previously read */ |
| 43059 | + u8 hasHeldSharedLock; /* True if a shared lock has ever been held */ |
| 42990 | 43060 | Pgno dbSize; /* Number of pages in the database */ |
| 42991 | 43061 | Pgno dbOrigSize; /* dbSize before the current transaction */ |
| 42992 | 43062 | Pgno dbFileSize; /* Number of pages in the database file */ |
| 42993 | 43063 | Pgno dbHintSize; /* Value passed to FCNTL_SIZE_HINT call */ |
| 42994 | 43064 | int errCode; /* One of several kinds of errors */ |
| | @@ -47434,14 +47504,14 @@ |
| 47434 | 47504 | assert( (pPager->eLock==SHARED_LOCK) |
| 47435 | 47505 | || (pPager->exclusiveMode && pPager->eLock>SHARED_LOCK) |
| 47436 | 47506 | ); |
| 47437 | 47507 | } |
| 47438 | 47508 | |
| 47439 | | - if( !pPager->tempFile && pPager->hasBeenUsed ){ |
| 47509 | + if( !pPager->tempFile && pPager->hasHeldSharedLock ){ |
| 47440 | 47510 | /* The shared-lock has just been acquired then check to |
| 47441 | 47511 | ** see if the database has been modified. If the database has changed, |
| 47442 | | - ** flush the cache. The pPager->hasBeenUsed flag prevents this from |
| 47512 | + ** flush the cache. The hasHeldSharedLock flag prevents this from |
| 47443 | 47513 | ** occurring on the very first access to a file, in order to save a |
| 47444 | 47514 | ** single unnecessary sqlite3OsRead() call at the start-up. |
| 47445 | 47515 | ** |
| 47446 | 47516 | ** Database changes are detected by looking at 15 bytes beginning |
| 47447 | 47517 | ** at offset 24 into the file. The first 4 of these 16 bytes are |
| | @@ -47507,10 +47577,11 @@ |
| 47507 | 47577 | assert( !MEMDB ); |
| 47508 | 47578 | pager_unlock(pPager); |
| 47509 | 47579 | assert( pPager->eState==PAGER_OPEN ); |
| 47510 | 47580 | }else{ |
| 47511 | 47581 | pPager->eState = PAGER_READER; |
| 47582 | + pPager->hasHeldSharedLock = 1; |
| 47512 | 47583 | } |
| 47513 | 47584 | return rc; |
| 47514 | 47585 | } |
| 47515 | 47586 | |
| 47516 | 47587 | /* |
| | @@ -47590,25 +47661,29 @@ |
| 47590 | 47661 | |
| 47591 | 47662 | /* It is acceptable to use a read-only (mmap) page for any page except |
| 47592 | 47663 | ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY |
| 47593 | 47664 | ** flag was specified by the caller. And so long as the db is not a |
| 47594 | 47665 | ** temporary or in-memory database. */ |
| 47595 | | - const int bMmapOk = (pgno!=1 && USEFETCH(pPager) |
| 47666 | + const int bMmapOk = (pgno>1 && USEFETCH(pPager) |
| 47596 | 47667 | && (pPager->eState==PAGER_READER || (flags & PAGER_GET_READONLY)) |
| 47597 | 47668 | #ifdef SQLITE_HAS_CODEC |
| 47598 | 47669 | && pPager->xCodec==0 |
| 47599 | 47670 | #endif |
| 47600 | 47671 | ); |
| 47601 | 47672 | |
| 47673 | + /* Optimization note: Adding the "pgno<=1" term before "pgno==0" here |
| 47674 | + ** allows the compiler optimizer to reuse the results of the "pgno>1" |
| 47675 | + ** test in the previous statement, and avoid testing pgno==0 in the |
| 47676 | + ** common case where pgno is large. */ |
| 47677 | + if( pgno<=1 && pgno==0 ){ |
| 47678 | + return SQLITE_CORRUPT_BKPT; |
| 47679 | + } |
| 47602 | 47680 | assert( pPager->eState>=PAGER_READER ); |
| 47603 | 47681 | assert( assert_pager_state(pPager) ); |
| 47604 | 47682 | assert( noContent==0 || bMmapOk==0 ); |
| 47605 | 47683 | |
| 47606 | | - if( pgno==0 ){ |
| 47607 | | - return SQLITE_CORRUPT_BKPT; |
| 47608 | | - } |
| 47609 | | - pPager->hasBeenUsed = 1; |
| 47684 | + assert( pPager->hasHeldSharedLock==1 ); |
| 47610 | 47685 | |
| 47611 | 47686 | /* If the pager is in the error state, return an error immediately. |
| 47612 | 47687 | ** Otherwise, request the page from the PCache layer. */ |
| 47613 | 47688 | if( pPager->errCode!=SQLITE_OK ){ |
| 47614 | 47689 | rc = pPager->errCode; |
| | @@ -47759,11 +47834,11 @@ |
| 47759 | 47834 | sqlite3_pcache_page *pPage; |
| 47760 | 47835 | assert( pPager!=0 ); |
| 47761 | 47836 | assert( pgno!=0 ); |
| 47762 | 47837 | assert( pPager->pPCache!=0 ); |
| 47763 | 47838 | pPage = sqlite3PcacheFetch(pPager->pPCache, pgno, 0); |
| 47764 | | - assert( pPage==0 || pPager->hasBeenUsed ); |
| 47839 | + assert( pPage==0 || pPager->hasHeldSharedLock ); |
| 47765 | 47840 | if( pPage==0 ) return 0; |
| 47766 | 47841 | return sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pPage); |
| 47767 | 47842 | } |
| 47768 | 47843 | |
| 47769 | 47844 | /* |
| | @@ -48726,11 +48801,11 @@ |
| 48726 | 48801 | return pPager->readOnly; |
| 48727 | 48802 | } |
| 48728 | 48803 | |
| 48729 | 48804 | #ifdef SQLITE_DEBUG |
| 48730 | 48805 | /* |
| 48731 | | -** Return the number of references to the pager. |
| 48806 | +** Return the sum of the reference counts for all pages held by pPager. |
| 48732 | 48807 | */ |
| 48733 | 48808 | SQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){ |
| 48734 | 48809 | return sqlite3PcacheRefCount(pPager->pPCache); |
| 48735 | 48810 | } |
| 48736 | 48811 | #endif |
| | @@ -50038,10 +50113,11 @@ |
| 50038 | 50113 | u8 readOnly; /* WAL_RDWR, WAL_RDONLY, or WAL_SHM_RDONLY */ |
| 50039 | 50114 | u8 truncateOnCommit; /* True to truncate WAL file on commit */ |
| 50040 | 50115 | u8 syncHeader; /* Fsync the WAL header if true */ |
| 50041 | 50116 | u8 padToSectorBoundary; /* Pad transactions out to the next sector */ |
| 50042 | 50117 | WalIndexHdr hdr; /* Wal-index header for current transaction */ |
| 50118 | + u32 minFrame; /* Ignore wal frames before this one */ |
| 50043 | 50119 | const char *zWalName; /* Name of WAL file */ |
| 50044 | 50120 | u32 nCkpt; /* Checkpoint sequence counter in the wal-header */ |
| 50045 | 50121 | #ifdef SQLITE_DEBUG |
| 50046 | 50122 | u8 lockError; /* True if a locking error has occurred */ |
| 50047 | 50123 | #endif |
| | @@ -51906,16 +51982,31 @@ |
| 51906 | 51982 | ** copied into the database by a checkpointer. If either of these things |
| 51907 | 51983 | ** happened, then reading the database with the current value of |
| 51908 | 51984 | ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry |
| 51909 | 51985 | ** instead. |
| 51910 | 51986 | ** |
| 51911 | | - ** This does not guarantee that the copy of the wal-index header is up to |
| 51912 | | - ** date before proceeding. That would not be possible without somehow |
| 51913 | | - ** blocking writers. It only guarantees that a dangerous checkpoint or |
| 51914 | | - ** log-wrap (either of which would require an exclusive lock on |
| 51915 | | - ** WAL_READ_LOCK(mxI)) has not occurred since the snapshot was valid. |
| 51987 | + ** Before checking that the live wal-index header has not changed |
| 51988 | + ** since it was read, set Wal.minFrame to the first frame in the wal |
| 51989 | + ** file that has not yet been checkpointed. This client will not need |
| 51990 | + ** to read any frames earlier than minFrame from the wal file - they |
| 51991 | + ** can be safely read directly from the database file. |
| 51992 | + ** |
| 51993 | + ** Because a ShmBarrier() call is made between taking the copy of |
| 51994 | + ** nBackfill and checking that the wal-header in shared-memory still |
| 51995 | + ** matches the one cached in pWal->hdr, it is guaranteed that the |
| 51996 | + ** checkpointer that set nBackfill was not working with a wal-index |
| 51997 | + ** header newer than that cached in pWal->hdr. If it were, that could |
| 51998 | + ** cause a problem. The checkpointer could omit to checkpoint |
| 51999 | + ** a version of page X that lies before pWal->minFrame (call that version |
| 52000 | + ** A) on the basis that there is a newer version (version B) of the same |
| 52001 | + ** page later in the wal file. But if version B happens to like past |
| 52002 | + ** frame pWal->hdr.mxFrame - then the client would incorrectly assume |
| 52003 | + ** that it can read version A from the database file. However, since |
| 52004 | + ** we can guarantee that the checkpointer that set nBackfill could not |
| 52005 | + ** see any pages past pWal->hdr.mxFrame, this problem does not come up. |
| 51916 | 52006 | */ |
| 52007 | + pWal->minFrame = pInfo->nBackfill+1; |
| 51917 | 52008 | walShmBarrier(pWal); |
| 51918 | 52009 | if( pInfo->aReadMark[mxI]!=mxReadMark |
| 51919 | 52010 | || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) |
| 51920 | 52011 | ){ |
| 51921 | 52012 | walUnlockShared(pWal, WAL_READ_LOCK(mxI)); |
| | @@ -51982,10 +52073,11 @@ |
| 51982 | 52073 | u32 *piRead /* OUT: Frame number (or zero) */ |
| 51983 | 52074 | ){ |
| 51984 | 52075 | u32 iRead = 0; /* If !=0, WAL frame to return data from */ |
| 51985 | 52076 | u32 iLast = pWal->hdr.mxFrame; /* Last page in WAL for this reader */ |
| 51986 | 52077 | int iHash; /* Used to loop through N hash tables */ |
| 52078 | + int iMinHash; |
| 51987 | 52079 | |
| 51988 | 52080 | /* This routine is only be called from within a read transaction. */ |
| 51989 | 52081 | assert( pWal->readLock>=0 || pWal->lockError ); |
| 51990 | 52082 | |
| 51991 | 52083 | /* If the "last page" field of the wal-index header snapshot is 0, then |
| | @@ -52022,11 +52114,12 @@ |
| 52022 | 52114 | ** |
| 52023 | 52115 | ** (iFrame<=iLast): |
| 52024 | 52116 | ** This condition filters out entries that were added to the hash |
| 52025 | 52117 | ** table after the current read-transaction had started. |
| 52026 | 52118 | */ |
| 52027 | | - for(iHash=walFramePage(iLast); iHash>=0 && iRead==0; iHash--){ |
| 52119 | + iMinHash = walFramePage(pWal->minFrame); |
| 52120 | + for(iHash=walFramePage(iLast); iHash>=iMinHash && iRead==0; iHash--){ |
| 52028 | 52121 | volatile ht_slot *aHash; /* Pointer to hash table */ |
| 52029 | 52122 | volatile u32 *aPgno; /* Pointer to array of page numbers */ |
| 52030 | 52123 | u32 iZero; /* Frame number corresponding to aPgno[0] */ |
| 52031 | 52124 | int iKey; /* Hash slot index */ |
| 52032 | 52125 | int nCollide; /* Number of hash collisions remaining */ |
| | @@ -52037,11 +52130,11 @@ |
| 52037 | 52130 | return rc; |
| 52038 | 52131 | } |
| 52039 | 52132 | nCollide = HASHTABLE_NSLOT; |
| 52040 | 52133 | for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){ |
| 52041 | 52134 | u32 iFrame = aHash[iKey] + iZero; |
| 52042 | | - if( iFrame<=iLast && aPgno[aHash[iKey]]==pgno ){ |
| 52135 | + if( iFrame<=iLast && iFrame>=pWal->minFrame && aPgno[aHash[iKey]]==pgno ){ |
| 52043 | 52136 | assert( iFrame>iRead || CORRUPT_DB ); |
| 52044 | 52137 | iRead = iFrame; |
| 52045 | 52138 | } |
| 52046 | 52139 | if( (nCollide--)==0 ){ |
| 52047 | 52140 | return SQLITE_CORRUPT_BKPT; |
| | @@ -52054,11 +52147,12 @@ |
| 52054 | 52147 | ** of the wal-index file content. Make sure the results agree with the |
| 52055 | 52148 | ** result obtained using the hash indexes above. */ |
| 52056 | 52149 | { |
| 52057 | 52150 | u32 iRead2 = 0; |
| 52058 | 52151 | u32 iTest; |
| 52059 | | - for(iTest=iLast; iTest>0; iTest--){ |
| 52152 | + assert( pWal->minFrame>0 ); |
| 52153 | + for(iTest=iLast; iTest>=pWal->minFrame; iTest--){ |
| 52060 | 52154 | if( walFramePgno(pWal, iTest)==pgno ){ |
| 52061 | 52155 | iRead2 = iTest; |
| 52062 | 52156 | break; |
| 52063 | 52157 | } |
| 52064 | 52158 | } |
| | @@ -53494,13 +53588,15 @@ |
| 53494 | 53588 | ** two-byte aligned address. get2bytea() is only used for accessing the |
| 53495 | 53589 | ** cell addresses in a btree header. |
| 53496 | 53590 | */ |
| 53497 | 53591 | #if SQLITE_BYTEORDER==4321 |
| 53498 | 53592 | # define get2byteAligned(x) (*(u16*)(x)) |
| 53499 | | -#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4008000 |
| 53593 | +#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 53594 | + && GCC_VERSION>=4008000 |
| 53500 | 53595 | # define get2byteAligned(x) __builtin_bswap16(*(u16*)(x)) |
| 53501 | | -#elif SQLITE_BYTEORDER==1234 && defined(_MSC_VER) && _MSC_VER>=1300 |
| 53596 | +#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 53597 | + && defined(_MSC_VER) && _MSC_VER>=1300 |
| 53502 | 53598 | # define get2byteAligned(x) _byteswap_ushort(*(u16*)(x)) |
| 53503 | 53599 | #else |
| 53504 | 53600 | # define get2byteAligned(x) ((x)[0]<<8 | (x)[1]) |
| 53505 | 53601 | #endif |
| 53506 | 53602 | |
| | @@ -62492,21 +62588,19 @@ |
| 62492 | 62588 | IntegrityCk *pCheck, |
| 62493 | 62589 | const char *zFormat, |
| 62494 | 62590 | ... |
| 62495 | 62591 | ){ |
| 62496 | 62592 | va_list ap; |
| 62497 | | - char zBuf[200]; |
| 62498 | 62593 | if( !pCheck->mxErr ) return; |
| 62499 | 62594 | pCheck->mxErr--; |
| 62500 | 62595 | pCheck->nErr++; |
| 62501 | 62596 | va_start(ap, zFormat); |
| 62502 | 62597 | if( pCheck->errMsg.nChar ){ |
| 62503 | 62598 | sqlite3StrAccumAppend(&pCheck->errMsg, "\n", 1); |
| 62504 | 62599 | } |
| 62505 | 62600 | if( pCheck->zPfx ){ |
| 62506 | | - sqlite3_snprintf(sizeof(zBuf), zBuf, pCheck->zPfx, pCheck->v1, pCheck->v2); |
| 62507 | | - sqlite3StrAccumAppendAll(&pCheck->errMsg, zBuf); |
| 62601 | + sqlite3XPrintf(&pCheck->errMsg, 0, pCheck->zPfx, pCheck->v1, pCheck->v2); |
| 62508 | 62602 | } |
| 62509 | 62603 | sqlite3VXPrintf(&pCheck->errMsg, 1, zFormat, ap); |
| 62510 | 62604 | va_end(ap); |
| 62511 | 62605 | if( pCheck->errMsg.accError==STRACCUM_NOMEM ){ |
| 62512 | 62606 | pCheck->mallocFailed = 1; |
| | @@ -65327,11 +65421,11 @@ |
| 65327 | 65421 | /* |
| 65328 | 65422 | ** The expression object indicated by the second argument is guaranteed |
| 65329 | 65423 | ** to be a scalar SQL function. If |
| 65330 | 65424 | ** |
| 65331 | 65425 | ** * all function arguments are SQL literals, |
| 65332 | | -** * the SQLITE_FUNC_CONSTANT function flag is set, and |
| 65426 | +** * one of the SQLITE_FUNC_CONSTANT or _SLOCHNG function flags is set, and |
| 65333 | 65427 | ** * the SQLITE_FUNC_NEEDCOLL function flag is not set, |
| 65334 | 65428 | ** |
| 65335 | 65429 | ** then this routine attempts to invoke the SQL function. Assuming no |
| 65336 | 65430 | ** error occurs, output parameter (*ppVal) is set to point to a value |
| 65337 | 65431 | ** object containing the result before returning SQLITE_OK. |
| | @@ -65368,11 +65462,11 @@ |
| 65368 | 65462 | pList = p->x.pList; |
| 65369 | 65463 | if( pList ) nVal = pList->nExpr; |
| 65370 | 65464 | nName = sqlite3Strlen30(p->u.zToken); |
| 65371 | 65465 | pFunc = sqlite3FindFunction(db, p->u.zToken, nName, nVal, enc, 0); |
| 65372 | 65466 | assert( pFunc ); |
| 65373 | | - if( (pFunc->funcFlags & SQLITE_FUNC_CONSTANT)==0 |
| 65467 | + if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 |
| 65374 | 65468 | || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL) |
| 65375 | 65469 | ){ |
| 65376 | 65470 | return SQLITE_OK; |
| 65377 | 65471 | } |
| 65378 | 65472 | |
| | @@ -65962,11 +66056,11 @@ |
| 65962 | 66056 | /* |
| 65963 | 66057 | ** Return the SQL associated with a prepared statement |
| 65964 | 66058 | */ |
| 65965 | 66059 | SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){ |
| 65966 | 66060 | Vdbe *p = (Vdbe *)pStmt; |
| 65967 | | - return (p && p->isPrepareV2) ? p->zSql : 0; |
| 66061 | + return p ? p->zSql : 0; |
| 65968 | 66062 | } |
| 65969 | 66063 | |
| 65970 | 66064 | /* |
| 65971 | 66065 | ** Swap all content between two VDBE structures. |
| 65972 | 66066 | */ |
| | @@ -66109,10 +66203,48 @@ |
| 66109 | 66203 | } |
| 66110 | 66204 | SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe *p, int op, int p1, int p2){ |
| 66111 | 66205 | return sqlite3VdbeAddOp3(p, op, p1, p2, 0); |
| 66112 | 66206 | } |
| 66113 | 66207 | |
| 66208 | +/* Generate code for an unconditional jump to instruction iDest |
| 66209 | +*/ |
| 66210 | +SQLITE_PRIVATE int sqlite3VdbeGoto(Vdbe *p, int iDest){ |
| 66211 | + return sqlite3VdbeAddOp3(p, OP_Goto, 0, iDest, 0); |
| 66212 | +} |
| 66213 | + |
| 66214 | +/* Generate code to cause the string zStr to be loaded into |
| 66215 | +** register iDest |
| 66216 | +*/ |
| 66217 | +SQLITE_PRIVATE int sqlite3VdbeLoadString(Vdbe *p, int iDest, const char *zStr){ |
| 66218 | + return sqlite3VdbeAddOp4(p, OP_String8, 0, iDest, 0, zStr, 0); |
| 66219 | +} |
| 66220 | + |
| 66221 | +/* |
| 66222 | +** Generate code that initializes multiple registers to string or integer |
| 66223 | +** constants. The registers begin with iDest and increase consecutively. |
| 66224 | +** One register is initialized for each characgter in zTypes[]. For each |
| 66225 | +** "s" character in zTypes[], the register is a string if the argument is |
| 66226 | +** not NULL, or OP_Null if the value is a null pointer. For each "i" character |
| 66227 | +** in zTypes[], the register is initialized to an integer. |
| 66228 | +*/ |
| 66229 | +SQLITE_PRIVATE void sqlite3VdbeMultiLoad(Vdbe *p, int iDest, const char *zTypes, ...){ |
| 66230 | + va_list ap; |
| 66231 | + int i; |
| 66232 | + char c; |
| 66233 | + va_start(ap, zTypes); |
| 66234 | + for(i=0; (c = zTypes[i])!=0; i++){ |
| 66235 | + if( c=='s' ){ |
| 66236 | + const char *z = va_arg(ap, const char*); |
| 66237 | + int addr = sqlite3VdbeAddOp2(p, z==0 ? OP_Null : OP_String8, 0, iDest++); |
| 66238 | + if( z ) sqlite3VdbeChangeP4(p, addr, z, 0); |
| 66239 | + }else{ |
| 66240 | + assert( c=='i' ); |
| 66241 | + sqlite3VdbeAddOp2(p, OP_Integer, va_arg(ap, int), iDest++); |
| 66242 | + } |
| 66243 | + } |
| 66244 | + va_end(ap); |
| 66245 | +} |
| 66114 | 66246 | |
| 66115 | 66247 | /* |
| 66116 | 66248 | ** Add an opcode that includes the p4 value as a pointer. |
| 66117 | 66249 | */ |
| 66118 | 66250 | SQLITE_PRIVATE int sqlite3VdbeAddOp4( |
| | @@ -66128,11 +66260,12 @@ |
| 66128 | 66260 | sqlite3VdbeChangeP4(p, addr, zP4, p4type); |
| 66129 | 66261 | return addr; |
| 66130 | 66262 | } |
| 66131 | 66263 | |
| 66132 | 66264 | /* |
| 66133 | | -** Add an opcode that includes the p4 value with a P4_INT64 type. |
| 66265 | +** Add an opcode that includes the p4 value with a P4_INT64 or |
| 66266 | +** P4_REAL type. |
| 66134 | 66267 | */ |
| 66135 | 66268 | SQLITE_PRIVATE int sqlite3VdbeAddOp4Dup8( |
| 66136 | 66269 | Vdbe *p, /* Add the opcode to this VM */ |
| 66137 | 66270 | int op, /* The new opcode */ |
| 66138 | 66271 | int p1, /* The P1 operand */ |
| | @@ -66213,11 +66346,12 @@ |
| 66213 | 66346 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){ |
| 66214 | 66347 | Parse *p = v->pParse; |
| 66215 | 66348 | int j = -1-x; |
| 66216 | 66349 | assert( v->magic==VDBE_MAGIC_INIT ); |
| 66217 | 66350 | assert( j<p->nLabel ); |
| 66218 | | - if( ALWAYS(j>=0) && p->aLabel ){ |
| 66351 | + assert( j>=0 ); |
| 66352 | + if( p->aLabel ){ |
| 66219 | 66353 | p->aLabel[j] = v->nOp; |
| 66220 | 66354 | } |
| 66221 | 66355 | p->iFixedOp = v->nOp - 1; |
| 66222 | 66356 | } |
| 66223 | 66357 | |
| | @@ -66357,21 +66491,25 @@ |
| 66357 | 66491 | || (hasCreateTable && hasInitCoroutine) ); |
| 66358 | 66492 | } |
| 66359 | 66493 | #endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */ |
| 66360 | 66494 | |
| 66361 | 66495 | /* |
| 66362 | | -** Loop through the program looking for P2 values that are negative |
| 66363 | | -** on jump instructions. Each such value is a label. Resolve the |
| 66364 | | -** label by setting the P2 value to its correct non-zero value. |
| 66365 | | -** |
| 66366 | | -** This routine is called once after all opcodes have been inserted. |
| 66367 | | -** |
| 66368 | | -** Variable *pMaxFuncArgs is set to the maximum value of any P2 argument |
| 66369 | | -** to an OP_Function, OP_AggStep or OP_VFilter opcode. This is used by |
| 66370 | | -** sqlite3VdbeMakeReady() to size the Vdbe.apArg[] array. |
| 66371 | | -** |
| 66372 | | -** The Op.opflags field is set on all opcodes. |
| 66496 | +** This routine is called after all opcodes have been inserted. It loops |
| 66497 | +** through all the opcodes and fixes up some details. |
| 66498 | +** |
| 66499 | +** (1) For each jump instruction with a negative P2 value (a label) |
| 66500 | +** resolve the P2 value to an actual address. |
| 66501 | +** |
| 66502 | +** (2) Compute the maximum number of arguments used by any SQL function |
| 66503 | +** and store that value in *pMaxFuncArgs. |
| 66504 | +** |
| 66505 | +** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately |
| 66506 | +** indicate what the prepared statement actually does. |
| 66507 | +** |
| 66508 | +** (4) Initialize the p4.xAdvance pointer on opcodes that use it. |
| 66509 | +** |
| 66510 | +** (5) Reclaim the memory allocated for storing labels. |
| 66373 | 66511 | */ |
| 66374 | 66512 | static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){ |
| 66375 | 66513 | int i; |
| 66376 | 66514 | int nMaxArgs = *pMaxFuncArgs; |
| 66377 | 66515 | Op *pOp; |
| | @@ -66480,50 +66618,48 @@ |
| 66480 | 66618 | /* |
| 66481 | 66619 | ** Add a whole list of operations to the operation stack. Return the |
| 66482 | 66620 | ** address of the first operation added. |
| 66483 | 66621 | */ |
| 66484 | 66622 | SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp, int iLineno){ |
| 66485 | | - int addr; |
| 66623 | + int addr, i; |
| 66624 | + VdbeOp *pOut; |
| 66625 | + assert( nOp>0 ); |
| 66486 | 66626 | assert( p->magic==VDBE_MAGIC_INIT ); |
| 66487 | 66627 | if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){ |
| 66488 | 66628 | return 0; |
| 66489 | 66629 | } |
| 66490 | 66630 | addr = p->nOp; |
| 66491 | | - if( ALWAYS(nOp>0) ){ |
| 66492 | | - int i; |
| 66493 | | - VdbeOpList const *pIn = aOp; |
| 66494 | | - for(i=0; i<nOp; i++, pIn++){ |
| 66495 | | - int p2 = pIn->p2; |
| 66496 | | - VdbeOp *pOut = &p->aOp[i+addr]; |
| 66497 | | - pOut->opcode = pIn->opcode; |
| 66498 | | - pOut->p1 = pIn->p1; |
| 66499 | | - if( p2<0 ){ |
| 66500 | | - assert( sqlite3OpcodeProperty[pOut->opcode] & OPFLG_JUMP ); |
| 66501 | | - pOut->p2 = addr + ADDR(p2); |
| 66502 | | - }else{ |
| 66503 | | - pOut->p2 = p2; |
| 66504 | | - } |
| 66505 | | - pOut->p3 = pIn->p3; |
| 66506 | | - pOut->p4type = P4_NOTUSED; |
| 66507 | | - pOut->p4.p = 0; |
| 66508 | | - pOut->p5 = 0; |
| 66631 | + pOut = &p->aOp[addr]; |
| 66632 | + for(i=0; i<nOp; i++, aOp++, pOut++){ |
| 66633 | + int p2 = aOp->p2; |
| 66634 | + pOut->opcode = aOp->opcode; |
| 66635 | + pOut->p1 = aOp->p1; |
| 66636 | + if( p2<0 ){ |
| 66637 | + assert( sqlite3OpcodeProperty[pOut->opcode] & OPFLG_JUMP ); |
| 66638 | + pOut->p2 = addr + ADDR(p2); |
| 66639 | + }else{ |
| 66640 | + pOut->p2 = p2; |
| 66641 | + } |
| 66642 | + pOut->p3 = aOp->p3; |
| 66643 | + pOut->p4type = P4_NOTUSED; |
| 66644 | + pOut->p4.p = 0; |
| 66645 | + pOut->p5 = 0; |
| 66509 | 66646 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 66510 | | - pOut->zComment = 0; |
| 66647 | + pOut->zComment = 0; |
| 66511 | 66648 | #endif |
| 66512 | 66649 | #ifdef SQLITE_VDBE_COVERAGE |
| 66513 | | - pOut->iSrcLine = iLineno+i; |
| 66650 | + pOut->iSrcLine = iLineno+i; |
| 66514 | 66651 | #else |
| 66515 | | - (void)iLineno; |
| 66652 | + (void)iLineno; |
| 66516 | 66653 | #endif |
| 66517 | 66654 | #ifdef SQLITE_DEBUG |
| 66518 | | - if( p->db->flags & SQLITE_VdbeAddopTrace ){ |
| 66519 | | - sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]); |
| 66520 | | - } |
| 66655 | + if( p->db->flags & SQLITE_VdbeAddopTrace ){ |
| 66656 | + sqlite3VdbePrintOp(0, i+addr, &p->aOp[i+addr]); |
| 66657 | + } |
| 66521 | 66658 | #endif |
| 66522 | | - } |
| 66523 | | - p->nOp += nOp; |
| 66524 | 66659 | } |
| 66660 | + p->nOp += nOp; |
| 66525 | 66661 | return addr; |
| 66526 | 66662 | } |
| 66527 | 66663 | |
| 66528 | 66664 | #if defined(SQLITE_ENABLE_STMT_SCANSTATUS) |
| 66529 | 66665 | /* |
| | @@ -66552,62 +66688,36 @@ |
| 66552 | 66688 | } |
| 66553 | 66689 | #endif |
| 66554 | 66690 | |
| 66555 | 66691 | |
| 66556 | 66692 | /* |
| 66557 | | -** Change the value of the P1 operand for a specific instruction. |
| 66558 | | -** This routine is useful when a large program is loaded from a |
| 66559 | | -** static array using sqlite3VdbeAddOpList but we want to make a |
| 66560 | | -** few minor changes to the program. |
| 66693 | +** Change the value of the opcode, or P1, P2, P3, or P5 operands |
| 66694 | +** for a specific instruction. |
| 66561 | 66695 | */ |
| 66696 | +SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe *p, u32 addr, u8 iNewOpcode){ |
| 66697 | + sqlite3VdbeGetOp(p,addr)->opcode = iNewOpcode; |
| 66698 | +} |
| 66562 | 66699 | SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe *p, u32 addr, int val){ |
| 66563 | | - assert( p!=0 ); |
| 66564 | | - if( ((u32)p->nOp)>addr ){ |
| 66565 | | - p->aOp[addr].p1 = val; |
| 66566 | | - } |
| 66567 | | -} |
| 66568 | | - |
| 66569 | | -/* |
| 66570 | | -** Change the value of the P2 operand for a specific instruction. |
| 66571 | | -** This routine is useful for setting a jump destination. |
| 66572 | | -*/ |
| 66700 | + sqlite3VdbeGetOp(p,addr)->p1 = val; |
| 66701 | +} |
| 66573 | 66702 | SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe *p, u32 addr, int val){ |
| 66574 | | - assert( p!=0 ); |
| 66575 | | - if( ((u32)p->nOp)>addr ){ |
| 66576 | | - p->aOp[addr].p2 = val; |
| 66577 | | - } |
| 66578 | | -} |
| 66579 | | - |
| 66580 | | -/* |
| 66581 | | -** Change the value of the P3 operand for a specific instruction. |
| 66582 | | -*/ |
| 66703 | + sqlite3VdbeGetOp(p,addr)->p2 = val; |
| 66704 | +} |
| 66583 | 66705 | SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe *p, u32 addr, int val){ |
| 66584 | | - assert( p!=0 ); |
| 66585 | | - if( ((u32)p->nOp)>addr ){ |
| 66586 | | - p->aOp[addr].p3 = val; |
| 66587 | | - } |
| 66588 | | -} |
| 66589 | | - |
| 66590 | | -/* |
| 66591 | | -** Change the value of the P5 operand for the most recently |
| 66592 | | -** added operation. |
| 66593 | | -*/ |
| 66594 | | -SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u8 val){ |
| 66595 | | - assert( p!=0 ); |
| 66596 | | - if( p->aOp ){ |
| 66597 | | - assert( p->nOp>0 ); |
| 66598 | | - p->aOp[p->nOp-1].p5 = val; |
| 66599 | | - } |
| 66706 | + sqlite3VdbeGetOp(p,addr)->p3 = val; |
| 66707 | +} |
| 66708 | +SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe *p, u8 p5){ |
| 66709 | + sqlite3VdbeGetOp(p,-1)->p5 = p5; |
| 66600 | 66710 | } |
| 66601 | 66711 | |
| 66602 | 66712 | /* |
| 66603 | 66713 | ** Change the P2 operand of instruction addr so that it points to |
| 66604 | 66714 | ** the address of the next instruction to be coded. |
| 66605 | 66715 | */ |
| 66606 | 66716 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){ |
| 66607 | | - sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 66608 | 66717 | p->pParse->iFixedOp = p->nOp - 1; |
| 66718 | + sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 66609 | 66719 | } |
| 66610 | 66720 | |
| 66611 | 66721 | |
| 66612 | 66722 | /* |
| 66613 | 66723 | ** If the input FuncDef structure is ephemeral, then free it. If |
| | @@ -66988,12 +67098,13 @@ |
| 66988 | 67098 | int n = sqlite3Strlen30(zColl); |
| 66989 | 67099 | if( n==6 && memcmp(zColl,"BINARY",6)==0 ){ |
| 66990 | 67100 | zColl = "B"; |
| 66991 | 67101 | n = 1; |
| 66992 | 67102 | } |
| 66993 | | - if( i+n>nTemp-6 ){ |
| 67103 | + if( i+n>nTemp-7 ){ |
| 66994 | 67104 | memcpy(&zTemp[i],",...",4); |
| 67105 | + i += 4; |
| 66995 | 67106 | break; |
| 66996 | 67107 | } |
| 66997 | 67108 | zTemp[i++] = ','; |
| 66998 | 67109 | if( pKeyInfo->aSortOrder[j] ){ |
| 66999 | 67110 | zTemp[i++] = '-'; |
| | @@ -70329,10 +70440,13 @@ |
| 70329 | 70440 | SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){ |
| 70330 | 70441 | return (int)sqlite3VdbeIntValue((Mem*)pVal); |
| 70331 | 70442 | } |
| 70332 | 70443 | SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){ |
| 70333 | 70444 | return sqlite3VdbeIntValue((Mem*)pVal); |
| 70445 | +} |
| 70446 | +SQLITE_API unsigned int SQLITE_STDCALL sqlite3_value_subtype(sqlite3_value *pVal){ |
| 70447 | + return ((Mem*)pVal)->eSubtype; |
| 70334 | 70448 | } |
| 70335 | 70449 | SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value *pVal){ |
| 70336 | 70450 | return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8); |
| 70337 | 70451 | } |
| 70338 | 70452 | #ifndef SQLITE_OMIT_UTF16 |
| | @@ -70507,10 +70621,14 @@ |
| 70507 | 70621 | sqlite3VdbeMemSetInt64(pCtx->pOut, iVal); |
| 70508 | 70622 | } |
| 70509 | 70623 | SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){ |
| 70510 | 70624 | assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 70511 | 70625 | sqlite3VdbeMemSetNull(pCtx->pOut); |
| 70626 | +} |
| 70627 | +SQLITE_API void SQLITE_STDCALL sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){ |
| 70628 | + assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) ); |
| 70629 | + pCtx->pOut->eSubtype = eSubtype & 0xff; |
| 70512 | 70630 | } |
| 70513 | 70631 | SQLITE_API void SQLITE_STDCALL sqlite3_result_text( |
| 70514 | 70632 | sqlite3_context *pCtx, |
| 70515 | 70633 | const char *z, |
| 70516 | 70634 | int n, |
| | @@ -70754,11 +70872,11 @@ |
| 70754 | 70872 | ** be one of the values in the first assert() below. Variable p->rc |
| 70755 | 70873 | ** contains the value that would be returned if sqlite3_finalize() |
| 70756 | 70874 | ** were called on statement p. |
| 70757 | 70875 | */ |
| 70758 | 70876 | assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR |
| 70759 | | - || rc==SQLITE_BUSY || rc==SQLITE_MISUSE |
| 70877 | + || (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE |
| 70760 | 70878 | ); |
| 70761 | 70879 | assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp ); |
| 70762 | 70880 | if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){ |
| 70763 | 70881 | /* If this statement was prepared using sqlite3_prepare_v2(), and an |
| 70764 | 70882 | ** error has occurred, then return the error code in p->rc to the |
| | @@ -70839,11 +70957,11 @@ |
| 70839 | 70957 | ** parameter) of the sqlite3_create_function() and |
| 70840 | 70958 | ** sqlite3_create_function16() routines that originally registered the |
| 70841 | 70959 | ** application defined function. |
| 70842 | 70960 | */ |
| 70843 | 70961 | SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context *p){ |
| 70844 | | - assert( p && p->pFunc ); |
| 70962 | + assert( p && p->pOut ); |
| 70845 | 70963 | return p->pOut->db; |
| 70846 | 70964 | } |
| 70847 | 70965 | |
| 70848 | 70966 | /* |
| 70849 | 70967 | ** Return the current time for a statement. If the current time |
| | @@ -72657,11 +72775,11 @@ |
| 72657 | 72775 | if( p->rc==SQLITE_NOMEM ){ |
| 72658 | 72776 | /* This happens if a malloc() inside a call to sqlite3_column_text() or |
| 72659 | 72777 | ** sqlite3_column_text16() failed. */ |
| 72660 | 72778 | goto no_mem; |
| 72661 | 72779 | } |
| 72662 | | - assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY ); |
| 72780 | + assert( p->rc==SQLITE_OK || (p->rc&0xff)==SQLITE_BUSY ); |
| 72663 | 72781 | assert( p->bIsReader || p->readOnly!=0 ); |
| 72664 | 72782 | p->rc = SQLITE_OK; |
| 72665 | 72783 | p->iCurrentTime = 0; |
| 72666 | 72784 | assert( p->explain==0 ); |
| 72667 | 72785 | p->pResultSet = 0; |
| | @@ -75094,16 +75212,16 @@ |
| 75094 | 75212 | db->autoCommit = 1; |
| 75095 | 75213 | }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){ |
| 75096 | 75214 | goto vdbe_return; |
| 75097 | 75215 | }else{ |
| 75098 | 75216 | db->autoCommit = (u8)desiredAutoCommit; |
| 75099 | | - if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){ |
| 75100 | | - p->pc = (int)(pOp - aOp); |
| 75101 | | - db->autoCommit = (u8)(1-desiredAutoCommit); |
| 75102 | | - p->rc = rc = SQLITE_BUSY; |
| 75103 | | - goto vdbe_return; |
| 75104 | | - } |
| 75217 | + } |
| 75218 | + if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){ |
| 75219 | + p->pc = (int)(pOp - aOp); |
| 75220 | + db->autoCommit = (u8)(1-desiredAutoCommit); |
| 75221 | + p->rc = rc = SQLITE_BUSY; |
| 75222 | + goto vdbe_return; |
| 75105 | 75223 | } |
| 75106 | 75224 | assert( db->nStatement==0 ); |
| 75107 | 75225 | sqlite3CloseSavepoints(db); |
| 75108 | 75226 | if( p->rc==SQLITE_OK ){ |
| 75109 | 75227 | rc = SQLITE_DONE; |
| | @@ -75171,13 +75289,15 @@ |
| 75171 | 75289 | } |
| 75172 | 75290 | pBt = db->aDb[pOp->p1].pBt; |
| 75173 | 75291 | |
| 75174 | 75292 | if( pBt ){ |
| 75175 | 75293 | rc = sqlite3BtreeBeginTrans(pBt, pOp->p2); |
| 75176 | | - if( rc==SQLITE_BUSY ){ |
| 75294 | + testcase( rc==SQLITE_BUSY_SNAPSHOT ); |
| 75295 | + testcase( rc==SQLITE_BUSY_RECOVERY ); |
| 75296 | + if( (rc&0xff)==SQLITE_BUSY ){ |
| 75177 | 75297 | p->pc = (int)(pOp - aOp); |
| 75178 | | - p->rc = rc = SQLITE_BUSY; |
| 75298 | + p->rc = rc; |
| 75179 | 75299 | goto vdbe_return; |
| 75180 | 75300 | } |
| 75181 | 75301 | if( rc!=SQLITE_OK ){ |
| 75182 | 75302 | goto abort_due_to_error; |
| 75183 | 75303 | } |
| | @@ -79009,11 +79129,12 @@ |
| 79009 | 79129 | } |
| 79010 | 79130 | #endif |
| 79011 | 79131 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 79012 | 79132 | int j; |
| 79013 | 79133 | for(j=0; j<pIdx->nKeyCol; j++){ |
| 79014 | | - if( pIdx->aiColumn[j]==iCol ){ |
| 79134 | + /* FIXME: Be smarter about indexes that use expressions */ |
| 79135 | + if( pIdx->aiColumn[j]==iCol || pIdx->aiColumn[j]==(-2) ){ |
| 79015 | 79136 | zFault = "indexed"; |
| 79016 | 79137 | } |
| 79017 | 79138 | } |
| 79018 | 79139 | } |
| 79019 | 79140 | if( zFault ){ |
| | @@ -82590,10 +82711,15 @@ |
| 82590 | 82711 | if( ALWAYS(pSrc) ){ |
| 82591 | 82712 | for(i=pSrc->nSrc, pItem=pSrc->a; i>0; i--, pItem++){ |
| 82592 | 82713 | if( sqlite3WalkSelect(pWalker, pItem->pSelect) ){ |
| 82593 | 82714 | return WRC_Abort; |
| 82594 | 82715 | } |
| 82716 | + if( pItem->fg.isTabFunc |
| 82717 | + && sqlite3WalkExprList(pWalker, pItem->u1.pFuncArg) |
| 82718 | + ){ |
| 82719 | + return WRC_Abort; |
| 82720 | + } |
| 82595 | 82721 | } |
| 82596 | 82722 | } |
| 82597 | 82723 | return WRC_Continue; |
| 82598 | 82724 | } |
| 82599 | 82725 | |
| | @@ -82687,34 +82813,10 @@ |
| 82687 | 82813 | |
| 82688 | 82814 | /* |
| 82689 | 82815 | ** Turn the pExpr expression into an alias for the iCol-th column of the |
| 82690 | 82816 | ** result set in pEList. |
| 82691 | 82817 | ** |
| 82692 | | -** If the result set column is a simple column reference, then this routine |
| 82693 | | -** makes an exact copy. But for any other kind of expression, this |
| 82694 | | -** routine make a copy of the result set column as the argument to the |
| 82695 | | -** TK_AS operator. The TK_AS operator causes the expression to be |
| 82696 | | -** evaluated just once and then reused for each alias. |
| 82697 | | -** |
| 82698 | | -** The reason for suppressing the TK_AS term when the expression is a simple |
| 82699 | | -** column reference is so that the column reference will be recognized as |
| 82700 | | -** usable by indices within the WHERE clause processing logic. |
| 82701 | | -** |
| 82702 | | -** The TK_AS operator is inhibited if zType[0]=='G'. This means |
| 82703 | | -** that in a GROUP BY clause, the expression is evaluated twice. Hence: |
| 82704 | | -** |
| 82705 | | -** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x |
| 82706 | | -** |
| 82707 | | -** Is equivalent to: |
| 82708 | | -** |
| 82709 | | -** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5 |
| 82710 | | -** |
| 82711 | | -** The result of random()%5 in the GROUP BY clause is probably different |
| 82712 | | -** from the result in the result-set. On the other hand Standard SQL does |
| 82713 | | -** not allow the GROUP BY clause to contain references to result-set columns. |
| 82714 | | -** So this should never come up in well-formed queries. |
| 82715 | | -** |
| 82716 | 82818 | ** If the reference is followed by a COLLATE operator, then make sure |
| 82717 | 82819 | ** the COLLATE operator is preserved. For example: |
| 82718 | 82820 | ** |
| 82719 | 82821 | ** SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase; |
| 82720 | 82822 | ** |
| | @@ -82744,23 +82846,15 @@ |
| 82744 | 82846 | pOrig = pEList->a[iCol].pExpr; |
| 82745 | 82847 | assert( pOrig!=0 ); |
| 82746 | 82848 | db = pParse->db; |
| 82747 | 82849 | pDup = sqlite3ExprDup(db, pOrig, 0); |
| 82748 | 82850 | if( pDup==0 ) return; |
| 82749 | | - if( pOrig->op!=TK_COLUMN && zType[0]!='G' ){ |
| 82750 | | - incrAggFunctionDepth(pDup, nSubquery); |
| 82751 | | - pDup = sqlite3PExpr(pParse, TK_AS, pDup, 0, 0); |
| 82752 | | - if( pDup==0 ) return; |
| 82753 | | - ExprSetProperty(pDup, EP_Skip); |
| 82754 | | - if( pEList->a[iCol].u.x.iAlias==0 ){ |
| 82755 | | - pEList->a[iCol].u.x.iAlias = (u16)(++pParse->nAlias); |
| 82756 | | - } |
| 82757 | | - pDup->iTable = pEList->a[iCol].u.x.iAlias; |
| 82758 | | - } |
| 82851 | + if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery); |
| 82759 | 82852 | if( pExpr->op==TK_COLLATE ){ |
| 82760 | 82853 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); |
| 82761 | 82854 | } |
| 82855 | + ExprSetProperty(pDup, EP_Alias); |
| 82762 | 82856 | |
| 82763 | 82857 | /* Before calling sqlite3ExprDelete(), set the EP_Static flag. This |
| 82764 | 82858 | ** prevents ExprDelete() from deleting the Expr structure itself, |
| 82765 | 82859 | ** allowing it to be repopulated by the memcpy() on the following line. |
| 82766 | 82860 | ** The pExpr->u.zToken might point into memory that will be freed by the |
| | @@ -82948,11 +83042,11 @@ |
| 82948 | 83042 | /* If there has been exactly one prior match and this match |
| 82949 | 83043 | ** is for the right-hand table of a NATURAL JOIN or is in a |
| 82950 | 83044 | ** USING clause, then skip this match. |
| 82951 | 83045 | */ |
| 82952 | 83046 | if( cnt==1 ){ |
| 82953 | | - if( pItem->jointype & JT_NATURAL ) continue; |
| 83047 | + if( pItem->fg.jointype & JT_NATURAL ) continue; |
| 82954 | 83048 | if( nameInUsingClause(pItem->pUsing, zCol) ) continue; |
| 82955 | 83049 | } |
| 82956 | 83050 | cnt++; |
| 82957 | 83051 | pMatch = pItem; |
| 82958 | 83052 | /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */ |
| | @@ -82963,12 +83057,12 @@ |
| 82963 | 83057 | } |
| 82964 | 83058 | if( pMatch ){ |
| 82965 | 83059 | pExpr->iTable = pMatch->iCursor; |
| 82966 | 83060 | pExpr->pTab = pMatch->pTab; |
| 82967 | 83061 | /* RIGHT JOIN not (yet) supported */ |
| 82968 | | - assert( (pMatch->jointype & JT_RIGHT)==0 ); |
| 82969 | | - if( (pMatch->jointype & JT_LEFT)!=0 ){ |
| 83062 | + assert( (pMatch->fg.jointype & JT_RIGHT)==0 ); |
| 83063 | + if( (pMatch->fg.jointype & JT_LEFT)!=0 ){ |
| 82970 | 83064 | ExprSetProperty(pExpr, EP_CanBeNull); |
| 82971 | 83065 | } |
| 82972 | 83066 | pSchema = pExpr->pTab->pSchema; |
| 82973 | 83067 | } |
| 82974 | 83068 | } /* if( pSrcList ) */ |
| | @@ -83049,13 +83143,13 @@ |
| 83049 | 83143 | ** forms the result set entry ("a+b" in the example) and return immediately. |
| 83050 | 83144 | ** Note that the expression in the result set should have already been |
| 83051 | 83145 | ** resolved by the time the WHERE clause is resolved. |
| 83052 | 83146 | ** |
| 83053 | 83147 | ** The ability to use an output result-set column in the WHERE, GROUP BY, |
| 83054 | | - ** or HAVING clauses, or as part of a larger expression in the ORDRE BY |
| 83148 | + ** or HAVING clauses, or as part of a larger expression in the ORDER BY |
| 83055 | 83149 | ** clause is not standard SQL. This is a (goofy) SQLite extension, that |
| 83056 | | - ** is supported for backwards compatibility only. TO DO: Issue a warning |
| 83150 | + ** is supported for backwards compatibility only. Hence, we issue a warning |
| 83057 | 83151 | ** on sqlite3_log() whenever the capability is used. |
| 83058 | 83152 | */ |
| 83059 | 83153 | if( (pEList = pNC->pEList)!=0 |
| 83060 | 83154 | && zTab==0 |
| 83061 | 83155 | && cnt==0 |
| | @@ -83148,11 +83242,11 @@ |
| 83148 | 83242 | pExpr->pRight = 0; |
| 83149 | 83243 | pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN); |
| 83150 | 83244 | lookupname_end: |
| 83151 | 83245 | if( cnt==1 ){ |
| 83152 | 83246 | assert( pNC!=0 ); |
| 83153 | | - if( pExpr->op!=TK_AS ){ |
| 83247 | + if( !ExprHasProperty(pExpr, EP_Alias) ){ |
| 83154 | 83248 | sqlite3AuthRead(pParse, pExpr, pSchema, pNC->pSrcList); |
| 83155 | 83249 | } |
| 83156 | 83250 | /* Increment the nRef value on all name contexts from TopNC up to |
| 83157 | 83251 | ** the point where the name matched. */ |
| 83158 | 83252 | for(;;){ |
| | @@ -83189,40 +83283,29 @@ |
| 83189 | 83283 | } |
| 83190 | 83284 | return p; |
| 83191 | 83285 | } |
| 83192 | 83286 | |
| 83193 | 83287 | /* |
| 83194 | | -** Report an error that an expression is not valid for a partial index WHERE |
| 83195 | | -** clause. |
| 83196 | | -*/ |
| 83197 | | -static void notValidPartIdxWhere( |
| 83198 | | - Parse *pParse, /* Leave error message here */ |
| 83199 | | - NameContext *pNC, /* The name context */ |
| 83200 | | - const char *zMsg /* Type of error */ |
| 83201 | | -){ |
| 83202 | | - if( (pNC->ncFlags & NC_PartIdx)!=0 ){ |
| 83203 | | - sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses", |
| 83204 | | - zMsg); |
| 83205 | | - } |
| 83206 | | -} |
| 83207 | | - |
| 83208 | | -#ifndef SQLITE_OMIT_CHECK |
| 83209 | | -/* |
| 83210 | | -** Report an error that an expression is not valid for a CHECK constraint. |
| 83211 | | -*/ |
| 83212 | | -static void notValidCheckConstraint( |
| 83213 | | - Parse *pParse, /* Leave error message here */ |
| 83214 | | - NameContext *pNC, /* The name context */ |
| 83215 | | - const char *zMsg /* Type of error */ |
| 83216 | | -){ |
| 83217 | | - if( (pNC->ncFlags & NC_IsCheck)!=0 ){ |
| 83218 | | - sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg); |
| 83219 | | - } |
| 83220 | | -} |
| 83221 | | -#else |
| 83222 | | -# define notValidCheckConstraint(P,N,M) |
| 83223 | | -#endif |
| 83288 | +** Report an error that an expression is not valid for some set of |
| 83289 | +** pNC->ncFlags values determined by validMask. |
| 83290 | +*/ |
| 83291 | +static void notValid( |
| 83292 | + Parse *pParse, /* Leave error message here */ |
| 83293 | + NameContext *pNC, /* The name context */ |
| 83294 | + const char *zMsg, /* Type of error */ |
| 83295 | + int validMask /* Set of contexts for which prohibited */ |
| 83296 | +){ |
| 83297 | + assert( (validMask&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr))==0 ); |
| 83298 | + if( (pNC->ncFlags & validMask)!=0 ){ |
| 83299 | + const char *zIn = "partial index WHERE clauses"; |
| 83300 | + if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions"; |
| 83301 | +#ifndef SQLITE_OMIT_CHECK |
| 83302 | + else if( pNC->ncFlags & NC_IsCheck ) zIn = "CHECK constraints"; |
| 83303 | +#endif |
| 83304 | + sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn); |
| 83305 | + } |
| 83306 | +} |
| 83224 | 83307 | |
| 83225 | 83308 | /* |
| 83226 | 83309 | ** Expression p should encode a floating point value between 1.0 and 0.0. |
| 83227 | 83310 | ** Return 1024 times this value. Or return -1 if p is not a floating point |
| 83228 | 83311 | ** value between 1.0 and 0.0. |
| | @@ -83303,10 +83386,12 @@ |
| 83303 | 83386 | const char *zTable; |
| 83304 | 83387 | const char *zDb; |
| 83305 | 83388 | Expr *pRight; |
| 83306 | 83389 | |
| 83307 | 83390 | /* if( pSrcList==0 ) break; */ |
| 83391 | + notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); |
| 83392 | + /*notValid(pParse, pNC, "the \".\" operator", NC_PartIdx|NC_IsCheck, 1);*/ |
| 83308 | 83393 | pRight = pExpr->pRight; |
| 83309 | 83394 | if( pRight->op==TK_ID ){ |
| 83310 | 83395 | zDb = 0; |
| 83311 | 83396 | zTable = pExpr->pLeft->u.zToken; |
| 83312 | 83397 | zColumn = pRight->u.zToken; |
| | @@ -83332,11 +83417,11 @@ |
| 83332 | 83417 | const char *zId; /* The function name. */ |
| 83333 | 83418 | FuncDef *pDef; /* Information about the function */ |
| 83334 | 83419 | u8 enc = ENC(pParse->db); /* The database encoding */ |
| 83335 | 83420 | |
| 83336 | 83421 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 83337 | | - notValidPartIdxWhere(pParse, pNC, "functions"); |
| 83422 | + notValid(pParse, pNC, "functions", NC_PartIdx); |
| 83338 | 83423 | zId = pExpr->u.zToken; |
| 83339 | 83424 | nId = sqlite3Strlen30(zId); |
| 83340 | 83425 | pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0); |
| 83341 | 83426 | if( pDef==0 ){ |
| 83342 | 83427 | pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0); |
| | @@ -83380,13 +83465,22 @@ |
| 83380 | 83465 | } |
| 83381 | 83466 | pExpr->op = TK_NULL; |
| 83382 | 83467 | return WRC_Prune; |
| 83383 | 83468 | } |
| 83384 | 83469 | #endif |
| 83385 | | - if( pDef->funcFlags & SQLITE_FUNC_CONSTANT ){ |
| 83470 | + if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){ |
| 83471 | + /* For the purposes of the EP_ConstFunc flag, date and time |
| 83472 | + ** functions and other functions that change slowly are considered |
| 83473 | + ** constant because they are constant for the duration of one query */ |
| 83386 | 83474 | ExprSetProperty(pExpr,EP_ConstFunc); |
| 83387 | 83475 | } |
| 83476 | + if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ |
| 83477 | + /* Date/time functions that use 'now', and other functions like |
| 83478 | + ** sqlite_version() that might change over time cannot be used |
| 83479 | + ** in an index. */ |
| 83480 | + notValid(pParse, pNC, "non-deterministic functions", NC_IdxExpr); |
| 83481 | + } |
| 83388 | 83482 | } |
| 83389 | 83483 | if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){ |
| 83390 | 83484 | sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); |
| 83391 | 83485 | pNC->nErr++; |
| 83392 | 83486 | is_agg = 0; |
| | @@ -83428,23 +83522,21 @@ |
| 83428 | 83522 | #endif |
| 83429 | 83523 | case TK_IN: { |
| 83430 | 83524 | testcase( pExpr->op==TK_IN ); |
| 83431 | 83525 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 83432 | 83526 | int nRef = pNC->nRef; |
| 83433 | | - notValidCheckConstraint(pParse, pNC, "subqueries"); |
| 83434 | | - notValidPartIdxWhere(pParse, pNC, "subqueries"); |
| 83527 | + notValid(pParse, pNC, "subqueries", NC_IsCheck|NC_PartIdx|NC_IdxExpr); |
| 83435 | 83528 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 83436 | 83529 | assert( pNC->nRef>=nRef ); |
| 83437 | 83530 | if( nRef!=pNC->nRef ){ |
| 83438 | 83531 | ExprSetProperty(pExpr, EP_VarSelect); |
| 83439 | 83532 | } |
| 83440 | 83533 | } |
| 83441 | 83534 | break; |
| 83442 | 83535 | } |
| 83443 | 83536 | case TK_VARIABLE: { |
| 83444 | | - notValidCheckConstraint(pParse, pNC, "parameters"); |
| 83445 | | - notValidPartIdxWhere(pParse, pNC, "parameters"); |
| 83537 | + notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr); |
| 83446 | 83538 | break; |
| 83447 | 83539 | } |
| 83448 | 83540 | } |
| 83449 | 83541 | return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue; |
| 83450 | 83542 | } |
| | @@ -83784,11 +83876,10 @@ |
| 83784 | 83876 | NameContext *pOuterNC; /* Context that contains this SELECT */ |
| 83785 | 83877 | NameContext sNC; /* Name context of this SELECT */ |
| 83786 | 83878 | int isCompound; /* True if p is a compound select */ |
| 83787 | 83879 | int nCompound; /* Number of compound terms processed so far */ |
| 83788 | 83880 | Parse *pParse; /* Parsing context */ |
| 83789 | | - ExprList *pEList; /* Result set expression list */ |
| 83790 | 83881 | int i; /* Loop counter */ |
| 83791 | 83882 | ExprList *pGroupBy; /* The GROUP BY clause */ |
| 83792 | 83883 | Select *pLeftmost; /* Left-most of SELECT of a compound */ |
| 83793 | 83884 | sqlite3 *db; /* Database connection */ |
| 83794 | 83885 | |
| | @@ -83857,21 +83948,21 @@ |
| 83857 | 83948 | |
| 83858 | 83949 | /* Count the total number of references to pOuterNC and all of its |
| 83859 | 83950 | ** parent contexts. After resolving references to expressions in |
| 83860 | 83951 | ** pItem->pSelect, check if this value has changed. If so, then |
| 83861 | 83952 | ** SELECT statement pItem->pSelect must be correlated. Set the |
| 83862 | | - ** pItem->isCorrelated flag if this is the case. */ |
| 83953 | + ** pItem->fg.isCorrelated flag if this is the case. */ |
| 83863 | 83954 | for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef += pNC->nRef; |
| 83864 | 83955 | |
| 83865 | 83956 | if( pItem->zName ) pParse->zAuthContext = pItem->zName; |
| 83866 | 83957 | sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC); |
| 83867 | 83958 | pParse->zAuthContext = zSavedContext; |
| 83868 | 83959 | if( pParse->nErr || db->mallocFailed ) return WRC_Abort; |
| 83869 | 83960 | |
| 83870 | 83961 | for(pNC=pOuterNC; pNC; pNC=pNC->pNext) nRef -= pNC->nRef; |
| 83871 | | - assert( pItem->isCorrelated==0 && nRef<=0 ); |
| 83872 | | - pItem->isCorrelated = (nRef!=0); |
| 83962 | + assert( pItem->fg.isCorrelated==0 && nRef<=0 ); |
| 83963 | + pItem->fg.isCorrelated = (nRef!=0); |
| 83873 | 83964 | } |
| 83874 | 83965 | } |
| 83875 | 83966 | |
| 83876 | 83967 | /* Set up the local name-context to pass to sqlite3ResolveExprNames() to |
| 83877 | 83968 | ** resolve the result-set expression list. |
| | @@ -83879,18 +83970,11 @@ |
| 83879 | 83970 | sNC.ncFlags = NC_AllowAgg; |
| 83880 | 83971 | sNC.pSrcList = p->pSrc; |
| 83881 | 83972 | sNC.pNext = pOuterNC; |
| 83882 | 83973 | |
| 83883 | 83974 | /* Resolve names in the result set. */ |
| 83884 | | - pEList = p->pEList; |
| 83885 | | - assert( pEList!=0 ); |
| 83886 | | - for(i=0; i<pEList->nExpr; i++){ |
| 83887 | | - Expr *pX = pEList->a[i].pExpr; |
| 83888 | | - if( sqlite3ResolveExprNames(&sNC, pX) ){ |
| 83889 | | - return WRC_Abort; |
| 83890 | | - } |
| 83891 | | - } |
| 83975 | + if( sqlite3ResolveExprListNames(&sNC, p->pEList) ) return WRC_Abort; |
| 83892 | 83976 | |
| 83893 | 83977 | /* If there are no aggregate functions in the result-set, and no GROUP BY |
| 83894 | 83978 | ** expression, do not allow aggregates in any of the other expressions. |
| 83895 | 83979 | */ |
| 83896 | 83980 | assert( (p->selFlags & SF_Aggregate)==0 ); |
| | @@ -83918,10 +84002,20 @@ |
| 83918 | 84002 | ** re-evaluated for each reference to it. |
| 83919 | 84003 | */ |
| 83920 | 84004 | sNC.pEList = p->pEList; |
| 83921 | 84005 | if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort; |
| 83922 | 84006 | if( sqlite3ResolveExprNames(&sNC, p->pWhere) ) return WRC_Abort; |
| 84007 | + |
| 84008 | + /* Resolve names in table-valued-function arguments */ |
| 84009 | + for(i=0; i<p->pSrc->nSrc; i++){ |
| 84010 | + struct SrcList_item *pItem = &p->pSrc->a[i]; |
| 84011 | + if( pItem->fg.isTabFunc |
| 84012 | + && sqlite3ResolveExprListNames(&sNC, pItem->u1.pFuncArg) |
| 84013 | + ){ |
| 84014 | + return WRC_Abort; |
| 84015 | + } |
| 84016 | + } |
| 83923 | 84017 | |
| 83924 | 84018 | /* The ORDER BY and GROUP BY clauses may not refer to terms in |
| 83925 | 84019 | ** outer queries |
| 83926 | 84020 | */ |
| 83927 | 84021 | sNC.pNext = 0; |
| | @@ -84082,10 +84176,26 @@ |
| 84082 | 84176 | } |
| 84083 | 84177 | pNC->ncFlags |= savedHasAgg; |
| 84084 | 84178 | return ExprHasProperty(pExpr, EP_Error); |
| 84085 | 84179 | } |
| 84086 | 84180 | |
| 84181 | +/* |
| 84182 | +** Resolve all names for all expression in an expression list. This is |
| 84183 | +** just like sqlite3ResolveExprNames() except that it works for an expression |
| 84184 | +** list rather than a single expression. |
| 84185 | +*/ |
| 84186 | +SQLITE_PRIVATE int sqlite3ResolveExprListNames( |
| 84187 | + NameContext *pNC, /* Namespace to resolve expressions in. */ |
| 84188 | + ExprList *pList /* The expression list to be analyzed. */ |
| 84189 | +){ |
| 84190 | + int i; |
| 84191 | + assert( pList!=0 ); |
| 84192 | + for(i=0; i<pList->nExpr; i++){ |
| 84193 | + if( sqlite3ResolveExprNames(pNC, pList->a[i].pExpr) ) return WRC_Abort; |
| 84194 | + } |
| 84195 | + return WRC_Continue; |
| 84196 | +} |
| 84087 | 84197 | |
| 84088 | 84198 | /* |
| 84089 | 84199 | ** Resolve all names in all expressions of a SELECT and in all |
| 84090 | 84200 | ** decendents of the SELECT, including compounds off of p->pPrior, |
| 84091 | 84201 | ** subqueries in expressions, and subqueries used as FROM clause |
| | @@ -84125,19 +84235,18 @@ |
| 84125 | 84235 | ** Any errors cause an error message to be set in pParse. |
| 84126 | 84236 | */ |
| 84127 | 84237 | SQLITE_PRIVATE void sqlite3ResolveSelfReference( |
| 84128 | 84238 | Parse *pParse, /* Parsing context */ |
| 84129 | 84239 | Table *pTab, /* The table being referenced */ |
| 84130 | | - int type, /* NC_IsCheck or NC_PartIdx */ |
| 84240 | + int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */ |
| 84131 | 84241 | Expr *pExpr, /* Expression to resolve. May be NULL. */ |
| 84132 | 84242 | ExprList *pList /* Expression list to resolve. May be NUL. */ |
| 84133 | 84243 | ){ |
| 84134 | 84244 | SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ |
| 84135 | 84245 | NameContext sNC; /* Name context for pParse->pNewTable */ |
| 84136 | | - int i; /* Loop counter */ |
| 84137 | 84246 | |
| 84138 | | - assert( type==NC_IsCheck || type==NC_PartIdx ); |
| 84247 | + assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr ); |
| 84139 | 84248 | memset(&sNC, 0, sizeof(sNC)); |
| 84140 | 84249 | memset(&sSrc, 0, sizeof(sSrc)); |
| 84141 | 84250 | sSrc.nSrc = 1; |
| 84142 | 84251 | sSrc.a[0].zName = pTab->zName; |
| 84143 | 84252 | sSrc.a[0].pTab = pTab; |
| | @@ -84144,17 +84253,11 @@ |
| 84144 | 84253 | sSrc.a[0].iCursor = -1; |
| 84145 | 84254 | sNC.pParse = pParse; |
| 84146 | 84255 | sNC.pSrcList = &sSrc; |
| 84147 | 84256 | sNC.ncFlags = type; |
| 84148 | 84257 | if( sqlite3ResolveExprNames(&sNC, pExpr) ) return; |
| 84149 | | - if( pList ){ |
| 84150 | | - for(i=0; i<pList->nExpr; i++){ |
| 84151 | | - if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){ |
| 84152 | | - return; |
| 84153 | | - } |
| 84154 | | - } |
| 84155 | | - } |
| 84258 | + if( pList ) sqlite3ResolveExprListNames(&sNC, pList); |
| 84156 | 84259 | } |
| 84157 | 84260 | |
| 84158 | 84261 | /************** End of resolve.c *********************************************/ |
| 84159 | 84262 | /************** Begin file expr.c ********************************************/ |
| 84160 | 84263 | /* |
| | @@ -84248,11 +84351,11 @@ |
| 84248 | 84351 | s.n = sqlite3Strlen30(s.z); |
| 84249 | 84352 | return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0); |
| 84250 | 84353 | } |
| 84251 | 84354 | |
| 84252 | 84355 | /* |
| 84253 | | -** Skip over any TK_COLLATE or TK_AS operators and any unlikely() |
| 84356 | +** Skip over any TK_COLLATE operators and any unlikely() |
| 84254 | 84357 | ** or likelihood() function at the root of an expression. |
| 84255 | 84358 | */ |
| 84256 | 84359 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){ |
| 84257 | 84360 | while( pExpr && ExprHasProperty(pExpr, EP_Skip) ){ |
| 84258 | 84361 | if( ExprHasProperty(pExpr, EP_Unlikely) ){ |
| | @@ -84259,11 +84362,11 @@ |
| 84259 | 84362 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 84260 | 84363 | assert( pExpr->x.pList->nExpr>0 ); |
| 84261 | 84364 | assert( pExpr->op==TK_FUNCTION ); |
| 84262 | 84365 | pExpr = pExpr->x.pList->a[0].pExpr; |
| 84263 | 84366 | }else{ |
| 84264 | | - assert( pExpr->op==TK_COLLATE || pExpr->op==TK_AS ); |
| 84367 | + assert( pExpr->op==TK_COLLATE ); |
| 84265 | 84368 | pExpr = pExpr->pLeft; |
| 84266 | 84369 | } |
| 84267 | 84370 | } |
| 84268 | 84371 | return pExpr; |
| 84269 | 84372 | } |
| | @@ -84590,11 +84693,11 @@ |
| 84590 | 84693 | ** for this node and for the pToken argument is a single allocation |
| 84591 | 84694 | ** obtained from sqlite3DbMalloc(). The calling function |
| 84592 | 84695 | ** is responsible for making sure the node eventually gets freed. |
| 84593 | 84696 | ** |
| 84594 | 84697 | ** If dequote is true, then the token (if it exists) is dequoted. |
| 84595 | | -** If dequote is false, no dequoting is performance. The deQuote |
| 84698 | +** If dequote is false, no dequoting is performed. The deQuote |
| 84596 | 84699 | ** parameter is ignored if pToken is NULL or if the token does not |
| 84597 | 84700 | ** appear to be quoted. If the quotes were of the form "..." (double-quotes) |
| 84598 | 84701 | ** then the EP_DblQuoted flag is set on the expression node. |
| 84599 | 84702 | ** |
| 84600 | 84703 | ** Special case: If op==TK_INTEGER and pToken points to a string that |
| | @@ -85191,20 +85294,22 @@ |
| 85191 | 85294 | Table *pTab; |
| 85192 | 85295 | pNewItem->pSchema = pOldItem->pSchema; |
| 85193 | 85296 | pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase); |
| 85194 | 85297 | pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName); |
| 85195 | 85298 | pNewItem->zAlias = sqlite3DbStrDup(db, pOldItem->zAlias); |
| 85196 | | - pNewItem->jointype = pOldItem->jointype; |
| 85299 | + pNewItem->fg = pOldItem->fg; |
| 85197 | 85300 | pNewItem->iCursor = pOldItem->iCursor; |
| 85198 | 85301 | pNewItem->addrFillSub = pOldItem->addrFillSub; |
| 85199 | 85302 | pNewItem->regReturn = pOldItem->regReturn; |
| 85200 | | - pNewItem->isCorrelated = pOldItem->isCorrelated; |
| 85201 | | - pNewItem->viaCoroutine = pOldItem->viaCoroutine; |
| 85202 | | - pNewItem->isRecursive = pOldItem->isRecursive; |
| 85203 | | - pNewItem->zIndexedBy = sqlite3DbStrDup(db, pOldItem->zIndexedBy); |
| 85204 | | - pNewItem->notIndexed = pOldItem->notIndexed; |
| 85205 | | - pNewItem->pIndex = pOldItem->pIndex; |
| 85303 | + if( pNewItem->fg.isIndexedBy ){ |
| 85304 | + pNewItem->u1.zIndexedBy = sqlite3DbStrDup(db, pOldItem->u1.zIndexedBy); |
| 85305 | + } |
| 85306 | + pNewItem->pIBIndex = pOldItem->pIBIndex; |
| 85307 | + if( pNewItem->fg.isTabFunc ){ |
| 85308 | + pNewItem->u1.pFuncArg = |
| 85309 | + sqlite3ExprListDup(db, pOldItem->u1.pFuncArg, flags); |
| 85310 | + } |
| 85206 | 85311 | pTab = pNewItem->pTab = pOldItem->pTab; |
| 85207 | 85312 | if( pTab ){ |
| 85208 | 85313 | pTab->nRef++; |
| 85209 | 85314 | } |
| 85210 | 85315 | pNewItem->pSelect = sqlite3SelectDup(db, pOldItem->pSelect, flags); |
| | @@ -85314,10 +85419,24 @@ |
| 85314 | 85419 | /* Avoid leaking memory if malloc has failed. */ |
| 85315 | 85420 | sqlite3ExprDelete(db, pExpr); |
| 85316 | 85421 | sqlite3ExprListDelete(db, pList); |
| 85317 | 85422 | return 0; |
| 85318 | 85423 | } |
| 85424 | + |
| 85425 | +/* |
| 85426 | +** Set the sort order for the last element on the given ExprList. |
| 85427 | +*/ |
| 85428 | +SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder){ |
| 85429 | + if( p==0 ) return; |
| 85430 | + assert( SQLITE_SO_UNDEFINED<0 && SQLITE_SO_ASC>=0 && SQLITE_SO_DESC>0 ); |
| 85431 | + assert( p->nExpr>0 ); |
| 85432 | + if( iSortOrder<0 ){ |
| 85433 | + assert( p->a[p->nExpr-1].sortOrder==SQLITE_SO_ASC ); |
| 85434 | + return; |
| 85435 | + } |
| 85436 | + p->a[p->nExpr-1].sortOrder = (u8)iSortOrder; |
| 85437 | +} |
| 85319 | 85438 | |
| 85320 | 85439 | /* |
| 85321 | 85440 | ** Set the ExprList.a[].zName element of the most recently added item |
| 85322 | 85441 | ** on the expression list. |
| 85323 | 85442 | ** |
| | @@ -86286,11 +86405,11 @@ |
| 86286 | 86405 | } |
| 86287 | 86406 | sqlite3ReleaseTempReg(pParse, regToFree); |
| 86288 | 86407 | } |
| 86289 | 86408 | if( regCkNull ){ |
| 86290 | 86409 | sqlite3VdbeAddOp2(v, OP_IsNull, regCkNull, destIfNull); VdbeCoverage(v); |
| 86291 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse); |
| 86410 | + sqlite3VdbeGoto(v, destIfFalse); |
| 86292 | 86411 | } |
| 86293 | 86412 | sqlite3VdbeResolveLabel(v, labelOk); |
| 86294 | 86413 | sqlite3ReleaseTempReg(pParse, regCkNull); |
| 86295 | 86414 | }else{ |
| 86296 | 86415 | |
| | @@ -86304,11 +86423,11 @@ |
| 86304 | 86423 | sqlite3VdbeAddOp2(v, OP_IsNull, r1, destIfNull); VdbeCoverage(v); |
| 86305 | 86424 | }else{ |
| 86306 | 86425 | int addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, r1); VdbeCoverage(v); |
| 86307 | 86426 | sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse); |
| 86308 | 86427 | VdbeCoverage(v); |
| 86309 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull); |
| 86428 | + sqlite3VdbeGoto(v, destIfNull); |
| 86310 | 86429 | sqlite3VdbeJumpHere(v, addr1); |
| 86311 | 86430 | } |
| 86312 | 86431 | } |
| 86313 | 86432 | |
| 86314 | 86433 | if( eType==IN_INDEX_ROWID ){ |
| | @@ -86354,11 +86473,11 @@ |
| 86354 | 86473 | */ |
| 86355 | 86474 | j1 = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0, r1, 1); |
| 86356 | 86475 | VdbeCoverage(v); |
| 86357 | 86476 | sqlite3VdbeAddOp2(v, OP_IsNull, rRhsHasNull, destIfNull); |
| 86358 | 86477 | VdbeCoverage(v); |
| 86359 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfFalse); |
| 86478 | + sqlite3VdbeGoto(v, destIfFalse); |
| 86360 | 86479 | sqlite3VdbeJumpHere(v, j1); |
| 86361 | 86480 | } |
| 86362 | 86481 | } |
| 86363 | 86482 | } |
| 86364 | 86483 | sqlite3ReleaseTempReg(pParse, r1); |
| | @@ -86572,10 +86691,32 @@ |
| 86572 | 86691 | if( p->iReg==iReg ){ |
| 86573 | 86692 | p->tempReg = 0; |
| 86574 | 86693 | } |
| 86575 | 86694 | } |
| 86576 | 86695 | } |
| 86696 | + |
| 86697 | +/* Generate code that will load into register regOut a value that is |
| 86698 | +** appropriate for the iIdxCol-th column of index pIdx. |
| 86699 | +*/ |
| 86700 | +SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn( |
| 86701 | + Parse *pParse, /* The parsing context */ |
| 86702 | + Index *pIdx, /* The index whose column is to be loaded */ |
| 86703 | + int iTabCur, /* Cursor pointing to a table row */ |
| 86704 | + int iIdxCol, /* The column of the index to be loaded */ |
| 86705 | + int regOut /* Store the index column value in this register */ |
| 86706 | +){ |
| 86707 | + i16 iTabCol = pIdx->aiColumn[iIdxCol]; |
| 86708 | + if( iTabCol>=(-1) ){ |
| 86709 | + sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur, |
| 86710 | + iTabCol, regOut); |
| 86711 | + return; |
| 86712 | + } |
| 86713 | + assert( pIdx->aColExpr ); |
| 86714 | + assert( pIdx->aColExpr->nExpr>iIdxCol ); |
| 86715 | + pParse->iSelfTab = iTabCur; |
| 86716 | + sqlite3ExprCode(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); |
| 86717 | +} |
| 86577 | 86718 | |
| 86578 | 86719 | /* |
| 86579 | 86720 | ** Generate code to extract the value of the iCol-th column of a table. |
| 86580 | 86721 | */ |
| 86581 | 86722 | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable( |
| | @@ -86758,12 +86899,13 @@ |
| 86758 | 86899 | if( pParse->ckBase>0 ){ |
| 86759 | 86900 | /* Generating CHECK constraints or inserting into partial index */ |
| 86760 | 86901 | inReg = pExpr->iColumn + pParse->ckBase; |
| 86761 | 86902 | break; |
| 86762 | 86903 | }else{ |
| 86763 | | - /* Deleting from a partial index */ |
| 86764 | | - iTab = pParse->iPartIdxTab; |
| 86904 | + /* Coding an expression that is part of an index where column names |
| 86905 | + ** in the index refer to the table to which the index belongs */ |
| 86906 | + iTab = pParse->iSelfTab; |
| 86765 | 86907 | } |
| 86766 | 86908 | } |
| 86767 | 86909 | inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 86768 | 86910 | pExpr->iColumn, iTab, target, |
| 86769 | 86911 | pExpr->op2); |
| | @@ -86780,11 +86922,11 @@ |
| 86780 | 86922 | break; |
| 86781 | 86923 | } |
| 86782 | 86924 | #endif |
| 86783 | 86925 | case TK_STRING: { |
| 86784 | 86926 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 86785 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr->u.zToken, 0); |
| 86927 | + sqlite3VdbeLoadString(v, target, pExpr->u.zToken); |
| 86786 | 86928 | break; |
| 86787 | 86929 | } |
| 86788 | 86930 | case TK_NULL: { |
| 86789 | 86931 | sqlite3VdbeAddOp2(v, OP_Null, 0, target); |
| 86790 | 86932 | break; |
| | @@ -86819,14 +86961,10 @@ |
| 86819 | 86961 | } |
| 86820 | 86962 | case TK_REGISTER: { |
| 86821 | 86963 | inReg = pExpr->iTable; |
| 86822 | 86964 | break; |
| 86823 | 86965 | } |
| 86824 | | - case TK_AS: { |
| 86825 | | - inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 86826 | | - break; |
| 86827 | | - } |
| 86828 | 86966 | #ifndef SQLITE_OMIT_CAST |
| 86829 | 86967 | case TK_CAST: { |
| 86830 | 86968 | /* Expressions of the form: CAST(pLeft AS token) */ |
| 86831 | 86969 | inReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft, target); |
| 86832 | 86970 | if( inReg!=target ){ |
| | @@ -87053,11 +87191,11 @@ |
| 87053 | 87191 | pDef->funcFlags & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG); |
| 87054 | 87192 | } |
| 87055 | 87193 | } |
| 87056 | 87194 | |
| 87057 | 87195 | sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */ |
| 87058 | | - sqlite3ExprCodeExprList(pParse, pFarg, r1, |
| 87196 | + sqlite3ExprCodeExprList(pParse, pFarg, r1, 0, |
| 87059 | 87197 | SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR); |
| 87060 | 87198 | sqlite3ExprCachePop(pParse); /* Ticket 2ea2425d34be */ |
| 87061 | 87199 | }else{ |
| 87062 | 87200 | r1 = 0; |
| 87063 | 87201 | } |
| | @@ -87277,11 +87415,11 @@ |
| 87277 | 87415 | nextCase = sqlite3VdbeMakeLabel(v); |
| 87278 | 87416 | testcase( pTest->op==TK_COLUMN ); |
| 87279 | 87417 | sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL); |
| 87280 | 87418 | testcase( aListelem[i+1].pExpr->op==TK_COLUMN ); |
| 87281 | 87419 | sqlite3ExprCode(pParse, aListelem[i+1].pExpr, target); |
| 87282 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, endLabel); |
| 87420 | + sqlite3VdbeGoto(v, endLabel); |
| 87283 | 87421 | sqlite3ExprCachePop(pParse); |
| 87284 | 87422 | sqlite3VdbeResolveLabel(v, nextCase); |
| 87285 | 87423 | } |
| 87286 | 87424 | if( (nExpr&1)!=0 ){ |
| 87287 | 87425 | sqlite3ExprCachePush(pParse); |
| | @@ -87469,29 +87607,32 @@ |
| 87469 | 87607 | */ |
| 87470 | 87608 | SQLITE_PRIVATE int sqlite3ExprCodeExprList( |
| 87471 | 87609 | Parse *pParse, /* Parsing context */ |
| 87472 | 87610 | ExprList *pList, /* The expression list to be coded */ |
| 87473 | 87611 | int target, /* Where to write results */ |
| 87612 | + int srcReg, /* Source registers if SQLITE_ECEL_REF */ |
| 87474 | 87613 | u8 flags /* SQLITE_ECEL_* flags */ |
| 87475 | 87614 | ){ |
| 87476 | 87615 | struct ExprList_item *pItem; |
| 87477 | | - int i, n; |
| 87616 | + int i, j, n; |
| 87478 | 87617 | u8 copyOp = (flags & SQLITE_ECEL_DUP) ? OP_Copy : OP_SCopy; |
| 87618 | + Vdbe *v = pParse->pVdbe; |
| 87479 | 87619 | assert( pList!=0 ); |
| 87480 | 87620 | assert( target>0 ); |
| 87481 | 87621 | assert( pParse->pVdbe!=0 ); /* Never gets this far otherwise */ |
| 87482 | 87622 | n = pList->nExpr; |
| 87483 | 87623 | if( !ConstFactorOk(pParse) ) flags &= ~SQLITE_ECEL_FACTOR; |
| 87484 | 87624 | for(pItem=pList->a, i=0; i<n; i++, pItem++){ |
| 87485 | 87625 | Expr *pExpr = pItem->pExpr; |
| 87486 | | - if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){ |
| 87626 | + if( (flags & SQLITE_ECEL_REF)!=0 && (j = pList->a[i].u.x.iOrderByCol)>0 ){ |
| 87627 | + sqlite3VdbeAddOp2(v, copyOp, j+srcReg-1, target+i); |
| 87628 | + }else if( (flags & SQLITE_ECEL_FACTOR)!=0 && sqlite3ExprIsConstant(pExpr) ){ |
| 87487 | 87629 | sqlite3ExprCodeAtInit(pParse, pExpr, target+i, 0); |
| 87488 | 87630 | }else{ |
| 87489 | 87631 | int inReg = sqlite3ExprCodeTarget(pParse, pExpr, target+i); |
| 87490 | 87632 | if( inReg!=target+i ){ |
| 87491 | 87633 | VdbeOp *pOp; |
| 87492 | | - Vdbe *v = pParse->pVdbe; |
| 87493 | 87634 | if( copyOp==OP_Copy |
| 87494 | 87635 | && (pOp=sqlite3VdbeGetOp(v, -1))->opcode==OP_Copy |
| 87495 | 87636 | && pOp->p1+pOp->p3+1==inReg |
| 87496 | 87637 | && pOp->p2+pOp->p3+1==target+i |
| 87497 | 87638 | ){ |
| | @@ -87664,18 +87805,18 @@ |
| 87664 | 87805 | #ifndef SQLITE_OMIT_SUBQUERY |
| 87665 | 87806 | case TK_IN: { |
| 87666 | 87807 | int destIfFalse = sqlite3VdbeMakeLabel(v); |
| 87667 | 87808 | int destIfNull = jumpIfNull ? dest : destIfFalse; |
| 87668 | 87809 | sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull); |
| 87669 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, dest); |
| 87810 | + sqlite3VdbeGoto(v, dest); |
| 87670 | 87811 | sqlite3VdbeResolveLabel(v, destIfFalse); |
| 87671 | 87812 | break; |
| 87672 | 87813 | } |
| 87673 | 87814 | #endif |
| 87674 | 87815 | default: { |
| 87675 | 87816 | if( exprAlwaysTrue(pExpr) ){ |
| 87676 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, dest); |
| 87817 | + sqlite3VdbeGoto(v, dest); |
| 87677 | 87818 | }else if( exprAlwaysFalse(pExpr) ){ |
| 87678 | 87819 | /* No-op */ |
| 87679 | 87820 | }else{ |
| 87680 | 87821 | r1 = sqlite3ExprCodeTemp(pParse, pExpr, ®Free1); |
| 87681 | 87822 | sqlite3VdbeAddOp3(v, OP_If, r1, dest, jumpIfNull!=0); |
| | @@ -87827,11 +87968,11 @@ |
| 87827 | 87968 | break; |
| 87828 | 87969 | } |
| 87829 | 87970 | #endif |
| 87830 | 87971 | default: { |
| 87831 | 87972 | if( exprAlwaysFalse(pExpr) ){ |
| 87832 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, dest); |
| 87973 | + sqlite3VdbeGoto(v, dest); |
| 87833 | 87974 | }else if( exprAlwaysTrue(pExpr) ){ |
| 87834 | 87975 | /* no-op */ |
| 87835 | 87976 | }else{ |
| 87836 | 87977 | r1 = sqlite3ExprCodeTemp(pParse, pExpr, ®Free1); |
| 87837 | 87978 | sqlite3VdbeAddOp3(v, OP_IfNot, r1, dest, jumpIfNull!=0); |
| | @@ -87903,11 +88044,13 @@ |
| 87903 | 88044 | return 1; |
| 87904 | 88045 | } |
| 87905 | 88046 | return 2; |
| 87906 | 88047 | } |
| 87907 | 88048 | if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken ){ |
| 87908 | | - if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ |
| 88049 | + if( pA->op==TK_FUNCTION ){ |
| 88050 | + if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; |
| 88051 | + }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ |
| 87909 | 88052 | return pA->op==TK_COLLATE ? 1 : 2; |
| 87910 | 88053 | } |
| 87911 | 88054 | } |
| 87912 | 88055 | if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2; |
| 87913 | 88056 | if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){ |
| | @@ -88811,11 +88954,11 @@ |
| 88811 | 88954 | ** SQLite tables) that are identified by the name of the virtual table. |
| 88812 | 88955 | */ |
| 88813 | 88956 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 88814 | 88957 | if( pVTab ){ |
| 88815 | 88958 | int i = ++pParse->nMem; |
| 88816 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, i, 0, zName, 0); |
| 88959 | + sqlite3VdbeLoadString(v, i, zName); |
| 88817 | 88960 | sqlite3VdbeAddOp4(v, OP_VRename, i, 0, 0,(const char*)pVTab, P4_VTAB); |
| 88818 | 88961 | sqlite3MayAbort(pParse); |
| 88819 | 88962 | } |
| 88820 | 88963 | #endif |
| 88821 | 88964 | |
| | @@ -90169,11 +90312,11 @@ |
| 90169 | 90312 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
| 90170 | 90313 | iTabCur = iTab++; |
| 90171 | 90314 | iIdxCur = iTab++; |
| 90172 | 90315 | pParse->nTab = MAX(pParse->nTab, iTab); |
| 90173 | 90316 | sqlite3OpenTable(pParse, iTabCur, iDb, pTab, OP_OpenRead); |
| 90174 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, regTabname, 0, pTab->zName, 0); |
| 90317 | + sqlite3VdbeLoadString(v, regTabname, pTab->zName); |
| 90175 | 90318 | |
| 90176 | 90319 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 90177 | 90320 | int nCol; /* Number of columns in pIdx. "N" */ |
| 90178 | 90321 | int addrRewind; /* Address of "OP_Rewind iIdxCur" */ |
| 90179 | 90322 | int addrNextRow; /* Address of "next_row:" */ |
| | @@ -90191,11 +90334,11 @@ |
| 90191 | 90334 | zIdxName = pIdx->zName; |
| 90192 | 90335 | nColTest = pIdx->uniqNotNull ? pIdx->nKeyCol-1 : nCol-1; |
| 90193 | 90336 | } |
| 90194 | 90337 | |
| 90195 | 90338 | /* Populate the register containing the index name. */ |
| 90196 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, regIdxname, 0, zIdxName, 0); |
| 90339 | + sqlite3VdbeLoadString(v, regIdxname, zIdxName); |
| 90197 | 90340 | VdbeComment((v, "Analysis for %s.%s", pTab->zName, zIdxName)); |
| 90198 | 90341 | |
| 90199 | 90342 | /* |
| 90200 | 90343 | ** Pseudo-code for loop that calls stat_push(): |
| 90201 | 90344 | ** |
| | @@ -90305,11 +90448,11 @@ |
| 90305 | 90448 | sqlite3VdbeAddOp4(v, OP_Ne, regTemp, 0, regPrev+i, pColl, P4_COLLSEQ); |
| 90306 | 90449 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 90307 | 90450 | VdbeCoverage(v); |
| 90308 | 90451 | } |
| 90309 | 90452 | sqlite3VdbeAddOp2(v, OP_Integer, nColTest, regChng); |
| 90310 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, endDistinctTest); |
| 90453 | + sqlite3VdbeGoto(v, endDistinctTest); |
| 90311 | 90454 | |
| 90312 | 90455 | |
| 90313 | 90456 | /* |
| 90314 | 90457 | ** chng_addr_0: |
| 90315 | 90458 | ** regPrev(0) = idx(0) |
| | @@ -90341,10 +90484,11 @@ |
| 90341 | 90484 | Index *pPk = sqlite3PrimaryKeyIndex(pIdx->pTable); |
| 90342 | 90485 | int j, k, regKey; |
| 90343 | 90486 | regKey = sqlite3GetTempRange(pParse, pPk->nKeyCol); |
| 90344 | 90487 | for(j=0; j<pPk->nKeyCol; j++){ |
| 90345 | 90488 | k = sqlite3ColumnOfIndex(pIdx, pPk->aiColumn[j]); |
| 90489 | + assert( k>=0 && k<pTab->nCol ); |
| 90346 | 90490 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, k, regKey+j); |
| 90347 | 90491 | VdbeComment((v, "%s", pTab->aCol[pPk->aiColumn[j]].zName)); |
| 90348 | 90492 | } |
| 90349 | 90493 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regKey, pPk->nKeyCol, regRowid); |
| 90350 | 90494 | sqlite3ReleaseTempRange(pParse, regKey, pPk->nKeyCol); |
| | @@ -90390,16 +90534,14 @@ |
| 90390 | 90534 | /* We know that the regSampleRowid row exists because it was read by |
| 90391 | 90535 | ** the previous loop. Thus the not-found jump of seekOp will never |
| 90392 | 90536 | ** be taken */ |
| 90393 | 90537 | VdbeCoverageNeverTaken(v); |
| 90394 | 90538 | #ifdef SQLITE_ENABLE_STAT3 |
| 90395 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, |
| 90396 | | - pIdx->aiColumn[0], regSample); |
| 90539 | + sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, 0, regSample); |
| 90397 | 90540 | #else |
| 90398 | 90541 | for(i=0; i<nCol; i++){ |
| 90399 | | - i16 iCol = pIdx->aiColumn[i]; |
| 90400 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, iCol, regCol+i); |
| 90542 | + sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iTabCur, i, regCol+i); |
| 90401 | 90543 | } |
| 90402 | 90544 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regCol, nCol, regSample); |
| 90403 | 90545 | #endif |
| 90404 | 90546 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regTabname, 6, regTemp); |
| 90405 | 90547 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur+1, regNewRowid); |
| | @@ -92121,11 +92263,11 @@ |
| 92121 | 92263 | sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg); |
| 92122 | 92264 | } |
| 92123 | 92265 | } |
| 92124 | 92266 | |
| 92125 | 92267 | /* Finally, jump back to the beginning of the executable code. */ |
| 92126 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, 1); |
| 92268 | + sqlite3VdbeGoto(v, 1); |
| 92127 | 92269 | } |
| 92128 | 92270 | } |
| 92129 | 92271 | |
| 92130 | 92272 | |
| 92131 | 92273 | /* Get the VDBE program ready for execution |
| | @@ -92256,10 +92398,21 @@ |
| 92256 | 92398 | } |
| 92257 | 92399 | |
| 92258 | 92400 | p = sqlite3FindTable(pParse->db, zName, zDbase); |
| 92259 | 92401 | if( p==0 ){ |
| 92260 | 92402 | const char *zMsg = isView ? "no such view" : "no such table"; |
| 92403 | +#ifndef SQLITE_OMIT_VIRTUALTABLE |
| 92404 | + if( sqlite3FindDbName(pParse->db, zDbase)<1 ){ |
| 92405 | + /* If zName is the not the name of a table in the schema created using |
| 92406 | + ** CREATE, then check to see if it is the name of an virtual table that |
| 92407 | + ** can be an eponymous virtual table. */ |
| 92408 | + Module *pMod = (Module*)sqlite3HashFind(&pParse->db->aModule, zName); |
| 92409 | + if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){ |
| 92410 | + return pMod->pEpoTab; |
| 92411 | + } |
| 92412 | + } |
| 92413 | +#endif |
| 92261 | 92414 | if( zDbase ){ |
| 92262 | 92415 | sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); |
| 92263 | 92416 | }else{ |
| 92264 | 92417 | sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); |
| 92265 | 92418 | } |
| | @@ -92334,10 +92487,11 @@ |
| 92334 | 92487 | static void freeIndex(sqlite3 *db, Index *p){ |
| 92335 | 92488 | #ifndef SQLITE_OMIT_ANALYZE |
| 92336 | 92489 | sqlite3DeleteIndexSamples(db, p); |
| 92337 | 92490 | #endif |
| 92338 | 92491 | sqlite3ExprDelete(db, p->pPartIdxWhere); |
| 92492 | + sqlite3ExprListDelete(db, p->aColExpr); |
| 92339 | 92493 | sqlite3DbFree(db, p->zColAff); |
| 92340 | 92494 | if( p->isResized ) sqlite3DbFree(db, p->azColl); |
| 92341 | 92495 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 92342 | 92496 | sqlite3_free(p->aiRowEst); |
| 92343 | 92497 | #endif |
| | @@ -92460,11 +92614,11 @@ |
| 92460 | 92614 | |
| 92461 | 92615 | /* |
| 92462 | 92616 | ** Delete memory allocated for the column names of a table or view (the |
| 92463 | 92617 | ** Table.aCol[] array). |
| 92464 | 92618 | */ |
| 92465 | | -static void sqliteDeleteColumnNames(sqlite3 *db, Table *pTable){ |
| 92619 | +SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){ |
| 92466 | 92620 | int i; |
| 92467 | 92621 | Column *pCol; |
| 92468 | 92622 | assert( pTable!=0 ); |
| 92469 | 92623 | if( (pCol = pTable->aCol)!=0 ){ |
| 92470 | 92624 | for(i=0; i<pTable->nCol; i++, pCol++){ |
| | @@ -92527,17 +92681,15 @@ |
| 92527 | 92681 | /* Delete any foreign keys attached to this table. */ |
| 92528 | 92682 | sqlite3FkDelete(db, pTable); |
| 92529 | 92683 | |
| 92530 | 92684 | /* Delete the Table structure itself. |
| 92531 | 92685 | */ |
| 92532 | | - sqliteDeleteColumnNames(db, pTable); |
| 92686 | + sqlite3DeleteColumnNames(db, pTable); |
| 92533 | 92687 | sqlite3DbFree(db, pTable->zName); |
| 92534 | 92688 | sqlite3DbFree(db, pTable->zColAff); |
| 92535 | 92689 | sqlite3SelectDelete(db, pTable->pSelect); |
| 92536 | | -#ifndef SQLITE_OMIT_CHECK |
| 92537 | 92690 | sqlite3ExprListDelete(db, pTable->pCheck); |
| 92538 | | -#endif |
| 92539 | 92691 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 92540 | 92692 | sqlite3VtabClear(db, pTable); |
| 92541 | 92693 | #endif |
| 92542 | 92694 | sqlite3DbFree(db, pTable); |
| 92543 | 92695 | |
| | @@ -92876,10 +93028,12 @@ |
| 92876 | 93028 | */ |
| 92877 | 93029 | if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){ |
| 92878 | 93030 | int j1; |
| 92879 | 93031 | int fileFormat; |
| 92880 | 93032 | int reg1, reg2, reg3; |
| 93033 | + /* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */ |
| 93034 | + static const char nullRow[] = { 6, 0, 0, 0, 0, 0 }; |
| 92881 | 93035 | sqlite3BeginWriteOperation(pParse, 1, iDb); |
| 92882 | 93036 | |
| 92883 | 93037 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 92884 | 93038 | if( isVirtual ){ |
| 92885 | 93039 | sqlite3VdbeAddOp0(v, OP_VBegin); |
| | @@ -92920,11 +93074,11 @@ |
| 92920 | 93074 | { |
| 92921 | 93075 | pParse->addrCrTab = sqlite3VdbeAddOp2(v, OP_CreateTable, iDb, reg2); |
| 92922 | 93076 | } |
| 92923 | 93077 | sqlite3OpenMasterTable(pParse, iDb); |
| 92924 | 93078 | sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1); |
| 92925 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, reg3); |
| 93079 | + sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC); |
| 92926 | 93080 | sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1); |
| 92927 | 93081 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 92928 | 93082 | sqlite3VdbeAddOp0(v, OP_Close); |
| 92929 | 93083 | } |
| 92930 | 93084 | |
| | @@ -93201,22 +93355,27 @@ |
| 93201 | 93355 | zType = pTab->aCol[iCol].zType; |
| 93202 | 93356 | nTerm = 1; |
| 93203 | 93357 | }else{ |
| 93204 | 93358 | nTerm = pList->nExpr; |
| 93205 | 93359 | for(i=0; i<nTerm; i++){ |
| 93206 | | - for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 93207 | | - if( sqlite3StrICmp(pList->a[i].zName, pTab->aCol[iCol].zName)==0 ){ |
| 93208 | | - pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; |
| 93209 | | - zType = pTab->aCol[iCol].zType; |
| 93210 | | - break; |
| 93360 | + Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr); |
| 93361 | + assert( pCExpr!=0 ); |
| 93362 | + if( pCExpr->op==TK_ID ){ |
| 93363 | + const char *zCName = pCExpr->u.zToken; |
| 93364 | + for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 93365 | + if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){ |
| 93366 | + pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; |
| 93367 | + zType = pTab->aCol[iCol].zType; |
| 93368 | + break; |
| 93369 | + } |
| 93211 | 93370 | } |
| 93212 | 93371 | } |
| 93213 | 93372 | } |
| 93214 | 93373 | } |
| 93215 | 93374 | if( nTerm==1 |
| 93216 | 93375 | && zType && sqlite3StrICmp(zType, "INTEGER")==0 |
| 93217 | | - && sortOrder==SQLITE_SO_ASC |
| 93376 | + && sortOrder!=SQLITE_SO_DESC |
| 93218 | 93377 | ){ |
| 93219 | 93378 | pTab->iPKey = iCol; |
| 93220 | 93379 | pTab->keyConf = (u8)onError; |
| 93221 | 93380 | assert( autoInc==0 || autoInc==1 ); |
| 93222 | 93381 | pTab->tabFlags |= autoInc*TF_Autoincrement; |
| | @@ -93579,22 +93738,24 @@ |
| 93579 | 93738 | ** root-page for the table into an OP_CreateIndex opcode. The index |
| 93580 | 93739 | ** created will become the PRIMARY KEY index. |
| 93581 | 93740 | */ |
| 93582 | 93741 | if( pParse->addrCrTab ){ |
| 93583 | 93742 | assert( v ); |
| 93584 | | - sqlite3VdbeGetOp(v, pParse->addrCrTab)->opcode = OP_CreateIndex; |
| 93743 | + sqlite3VdbeChangeOpcode(v, pParse->addrCrTab, OP_CreateIndex); |
| 93585 | 93744 | } |
| 93586 | 93745 | |
| 93587 | 93746 | /* Locate the PRIMARY KEY index. Or, if this table was originally |
| 93588 | 93747 | ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. |
| 93589 | 93748 | */ |
| 93590 | 93749 | if( pTab->iPKey>=0 ){ |
| 93591 | 93750 | ExprList *pList; |
| 93592 | | - pList = sqlite3ExprListAppend(pParse, 0, 0); |
| 93751 | + Token ipkToken; |
| 93752 | + ipkToken.z = pTab->aCol[pTab->iPKey].zName; |
| 93753 | + ipkToken.n = sqlite3Strlen30(ipkToken.z); |
| 93754 | + pList = sqlite3ExprListAppend(pParse, 0, |
| 93755 | + sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0)); |
| 93593 | 93756 | if( pList==0 ) return; |
| 93594 | | - pList->a[0].zName = sqlite3DbStrDup(pParse->db, |
| 93595 | | - pTab->aCol[pTab->iPKey].zName); |
| 93596 | 93757 | pList->a[0].sortOrder = pParse->iPkSortOrder; |
| 93597 | 93758 | assert( pParse->pNewTable==pTab ); |
| 93598 | 93759 | pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0); |
| 93599 | 93760 | if( pPk==0 ) return; |
| 93600 | 93761 | pPk->idxType = SQLITE_IDXTYPE_PRIMARYKEY; |
| | @@ -93606,11 +93767,11 @@ |
| 93606 | 93767 | ** table entry. This is only required if currently generating VDBE |
| 93607 | 93768 | ** code for a CREATE TABLE (not when parsing one as part of reading |
| 93608 | 93769 | ** a database schema). */ |
| 93609 | 93770 | if( v ){ |
| 93610 | 93771 | assert( db->init.busy==0 ); |
| 93611 | | - sqlite3VdbeGetOp(v, pPk->tnum)->opcode = OP_Goto; |
| 93772 | + sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto); |
| 93612 | 93773 | } |
| 93613 | 93774 | |
| 93614 | 93775 | /* |
| 93615 | 93776 | ** Remove all redundant columns from the PRIMARY KEY. For example, change |
| 93616 | 93777 | ** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)". Later |
| | @@ -93716,13 +93877,14 @@ |
| 93716 | 93877 | Table *p; /* The new table */ |
| 93717 | 93878 | sqlite3 *db = pParse->db; /* The database connection */ |
| 93718 | 93879 | int iDb; /* Database in which the table lives */ |
| 93719 | 93880 | Index *pIdx; /* An implied index of the table */ |
| 93720 | 93881 | |
| 93721 | | - if( (pEnd==0 && pSelect==0) || db->mallocFailed ){ |
| 93882 | + if( pEnd==0 && pSelect==0 ){ |
| 93722 | 93883 | return; |
| 93723 | 93884 | } |
| 93885 | + assert( !db->mallocFailed ); |
| 93724 | 93886 | p = pParse->pNewTable; |
| 93725 | 93887 | if( p==0 ) return; |
| 93726 | 93888 | |
| 93727 | 93889 | assert( !db->init.busy || !pSelect ); |
| 93728 | 93890 | |
| | @@ -93849,11 +94011,11 @@ |
| 93849 | 94011 | VdbeCoverage(v); |
| 93850 | 94012 | sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec); |
| 93851 | 94013 | sqlite3TableAffinity(v, p, 0); |
| 93852 | 94014 | sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid); |
| 93853 | 94015 | sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid); |
| 93854 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrInsLoop); |
| 94016 | + sqlite3VdbeGoto(v, addrInsLoop); |
| 93855 | 94017 | sqlite3VdbeJumpHere(v, addrInsLoop); |
| 93856 | 94018 | sqlite3VdbeAddOp1(v, OP_Close, 1); |
| 93857 | 94019 | } |
| 93858 | 94020 | |
| 93859 | 94021 | /* Compute the complete text of the CREATE statement */ |
| | @@ -93946,10 +94108,11 @@ |
| 93946 | 94108 | SQLITE_PRIVATE void sqlite3CreateView( |
| 93947 | 94109 | Parse *pParse, /* The parsing context */ |
| 93948 | 94110 | Token *pBegin, /* The CREATE token that begins the statement */ |
| 93949 | 94111 | Token *pName1, /* The token that holds the name of the view */ |
| 93950 | 94112 | Token *pName2, /* The token that holds the name of the view */ |
| 94113 | + ExprList *pCNames, /* Optional list of view column names */ |
| 93951 | 94114 | Select *pSelect, /* A SELECT statement that will become the new view */ |
| 93952 | 94115 | int isTemp, /* TRUE for a TEMPORARY view */ |
| 93953 | 94116 | int noErr /* Suppress error messages if VIEW already exists */ |
| 93954 | 94117 | ){ |
| 93955 | 94118 | Table *p; |
| | @@ -93966,52 +94129,47 @@ |
| 93966 | 94129 | sqlite3SelectDelete(db, pSelect); |
| 93967 | 94130 | return; |
| 93968 | 94131 | } |
| 93969 | 94132 | sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr); |
| 93970 | 94133 | p = pParse->pNewTable; |
| 93971 | | - if( p==0 || pParse->nErr ){ |
| 93972 | | - sqlite3SelectDelete(db, pSelect); |
| 93973 | | - return; |
| 93974 | | - } |
| 94134 | + if( p==0 || pParse->nErr ) goto create_view_fail; |
| 93975 | 94135 | sqlite3TwoPartName(pParse, pName1, pName2, &pName); |
| 93976 | 94136 | iDb = sqlite3SchemaToIndex(db, p->pSchema); |
| 93977 | 94137 | sqlite3FixInit(&sFix, pParse, iDb, "view", pName); |
| 93978 | | - if( sqlite3FixSelect(&sFix, pSelect) ){ |
| 93979 | | - sqlite3SelectDelete(db, pSelect); |
| 93980 | | - return; |
| 93981 | | - } |
| 94138 | + if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail; |
| 93982 | 94139 | |
| 93983 | 94140 | /* Make a copy of the entire SELECT statement that defines the view. |
| 93984 | 94141 | ** This will force all the Expr.token.z values to be dynamically |
| 93985 | 94142 | ** allocated rather than point to the input string - which means that |
| 93986 | 94143 | ** they will persist after the current sqlite3_exec() call returns. |
| 93987 | 94144 | */ |
| 93988 | 94145 | p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); |
| 93989 | | - sqlite3SelectDelete(db, pSelect); |
| 93990 | | - if( db->mallocFailed ){ |
| 93991 | | - return; |
| 93992 | | - } |
| 93993 | | - if( !db->init.busy ){ |
| 93994 | | - sqlite3ViewGetColumnNames(pParse, p); |
| 93995 | | - } |
| 94146 | + p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE); |
| 94147 | + if( db->mallocFailed ) goto create_view_fail; |
| 93996 | 94148 | |
| 93997 | 94149 | /* Locate the end of the CREATE VIEW statement. Make sEnd point to |
| 93998 | 94150 | ** the end. |
| 93999 | 94151 | */ |
| 94000 | 94152 | sEnd = pParse->sLastToken; |
| 94001 | | - if( ALWAYS(sEnd.z[0]!=0) && sEnd.z[0]!=';' ){ |
| 94153 | + assert( sEnd.z[0]!=0 ); |
| 94154 | + if( sEnd.z[0]!=';' ){ |
| 94002 | 94155 | sEnd.z += sEnd.n; |
| 94003 | 94156 | } |
| 94004 | 94157 | sEnd.n = 0; |
| 94005 | 94158 | n = (int)(sEnd.z - pBegin->z); |
| 94159 | + assert( n>0 ); |
| 94006 | 94160 | z = pBegin->z; |
| 94007 | | - while( ALWAYS(n>0) && sqlite3Isspace(z[n-1]) ){ n--; } |
| 94161 | + while( sqlite3Isspace(z[n-1]) ){ n--; } |
| 94008 | 94162 | sEnd.z = &z[n-1]; |
| 94009 | 94163 | sEnd.n = 1; |
| 94010 | 94164 | |
| 94011 | 94165 | /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */ |
| 94012 | 94166 | sqlite3EndTable(pParse, 0, &sEnd, 0, 0); |
| 94167 | + |
| 94168 | +create_view_fail: |
| 94169 | + sqlite3SelectDelete(db, pSelect); |
| 94170 | + sqlite3ExprListDelete(db, pCNames); |
| 94013 | 94171 | return; |
| 94014 | 94172 | } |
| 94015 | 94173 | #endif /* SQLITE_OMIT_VIEW */ |
| 94016 | 94174 | |
| 94017 | 94175 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) |
| | @@ -94025,10 +94183,11 @@ |
| 94025 | 94183 | Select *pSel; /* Copy of the SELECT that implements the view */ |
| 94026 | 94184 | int nErr = 0; /* Number of errors encountered */ |
| 94027 | 94185 | int n; /* Temporarily holds the number of cursors assigned */ |
| 94028 | 94186 | sqlite3 *db = pParse->db; /* Database connection for malloc errors */ |
| 94029 | 94187 | sqlite3_xauth xAuth; /* Saved xAuth pointer */ |
| 94188 | + u8 bEnabledLA; /* Saved db->lookaside.bEnabled state */ |
| 94030 | 94189 | |
| 94031 | 94190 | assert( pTable ); |
| 94032 | 94191 | |
| 94033 | 94192 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 94034 | 94193 | if( sqlite3VtabCallConnect(pParse, pTable) ){ |
| | @@ -94070,44 +94229,50 @@ |
| 94070 | 94229 | ** to the elements of the FROM clause. But we do not want these changes |
| 94071 | 94230 | ** to be permanent. So the computation is done on a copy of the SELECT |
| 94072 | 94231 | ** statement that defines the view. |
| 94073 | 94232 | */ |
| 94074 | 94233 | assert( pTable->pSelect ); |
| 94075 | | - pSel = sqlite3SelectDup(db, pTable->pSelect, 0); |
| 94076 | | - if( pSel ){ |
| 94077 | | - u8 enableLookaside = db->lookaside.bEnabled; |
| 94078 | | - n = pParse->nTab; |
| 94079 | | - sqlite3SrcListAssignCursors(pParse, pSel->pSrc); |
| 94080 | | - pTable->nCol = -1; |
| 94081 | | - db->lookaside.bEnabled = 0; |
| 94082 | | -#ifndef SQLITE_OMIT_AUTHORIZATION |
| 94083 | | - xAuth = db->xAuth; |
| 94084 | | - db->xAuth = 0; |
| 94085 | | - pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); |
| 94086 | | - db->xAuth = xAuth; |
| 94087 | | -#else |
| 94088 | | - pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); |
| 94089 | | -#endif |
| 94090 | | - db->lookaside.bEnabled = enableLookaside; |
| 94091 | | - pParse->nTab = n; |
| 94092 | | - if( pSelTab ){ |
| 94093 | | - assert( pTable->aCol==0 ); |
| 94094 | | - pTable->nCol = pSelTab->nCol; |
| 94095 | | - pTable->aCol = pSelTab->aCol; |
| 94096 | | - pSelTab->nCol = 0; |
| 94097 | | - pSelTab->aCol = 0; |
| 94098 | | - sqlite3DeleteTable(db, pSelTab); |
| 94099 | | - assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); |
| 94100 | | - pTable->pSchema->schemaFlags |= DB_UnresetViews; |
| 94101 | | - }else{ |
| 94102 | | - pTable->nCol = 0; |
| 94103 | | - nErr++; |
| 94104 | | - } |
| 94105 | | - sqlite3SelectDelete(db, pSel); |
| 94106 | | - } else { |
| 94107 | | - nErr++; |
| 94108 | | - } |
| 94234 | + bEnabledLA = db->lookaside.bEnabled; |
| 94235 | + if( pTable->pCheck ){ |
| 94236 | + db->lookaside.bEnabled = 0; |
| 94237 | + sqlite3ColumnsFromExprList(pParse, pTable->pCheck, |
| 94238 | + &pTable->nCol, &pTable->aCol); |
| 94239 | + }else{ |
| 94240 | + pSel = sqlite3SelectDup(db, pTable->pSelect, 0); |
| 94241 | + if( pSel ){ |
| 94242 | + n = pParse->nTab; |
| 94243 | + sqlite3SrcListAssignCursors(pParse, pSel->pSrc); |
| 94244 | + pTable->nCol = -1; |
| 94245 | + db->lookaside.bEnabled = 0; |
| 94246 | +#ifndef SQLITE_OMIT_AUTHORIZATION |
| 94247 | + xAuth = db->xAuth; |
| 94248 | + db->xAuth = 0; |
| 94249 | + pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); |
| 94250 | + db->xAuth = xAuth; |
| 94251 | +#else |
| 94252 | + pSelTab = sqlite3ResultSetOfSelect(pParse, pSel); |
| 94253 | +#endif |
| 94254 | + pParse->nTab = n; |
| 94255 | + if( pSelTab ){ |
| 94256 | + assert( pTable->aCol==0 ); |
| 94257 | + pTable->nCol = pSelTab->nCol; |
| 94258 | + pTable->aCol = pSelTab->aCol; |
| 94259 | + pSelTab->nCol = 0; |
| 94260 | + pSelTab->aCol = 0; |
| 94261 | + sqlite3DeleteTable(db, pSelTab); |
| 94262 | + assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) ); |
| 94263 | + }else{ |
| 94264 | + pTable->nCol = 0; |
| 94265 | + nErr++; |
| 94266 | + } |
| 94267 | + sqlite3SelectDelete(db, pSel); |
| 94268 | + } else { |
| 94269 | + nErr++; |
| 94270 | + } |
| 94271 | + } |
| 94272 | + db->lookaside.bEnabled = bEnabledLA; |
| 94273 | + pTable->pSchema->schemaFlags |= DB_UnresetViews; |
| 94109 | 94274 | #endif /* SQLITE_OMIT_VIEW */ |
| 94110 | 94275 | return nErr; |
| 94111 | 94276 | } |
| 94112 | 94277 | #endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */ |
| 94113 | 94278 | |
| | @@ -94120,11 +94285,11 @@ |
| 94120 | 94285 | assert( sqlite3SchemaMutexHeld(db, idx, 0) ); |
| 94121 | 94286 | if( !DbHasProperty(db, idx, DB_UnresetViews) ) return; |
| 94122 | 94287 | for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){ |
| 94123 | 94288 | Table *pTab = sqliteHashData(i); |
| 94124 | 94289 | if( pTab->pSelect ){ |
| 94125 | | - sqliteDeleteColumnNames(db, pTab); |
| 94290 | + sqlite3DeleteColumnNames(db, pTab); |
| 94126 | 94291 | pTab->aCol = 0; |
| 94127 | 94292 | pTab->nCol = 0; |
| 94128 | 94293 | } |
| 94129 | 94294 | } |
| 94130 | 94295 | DbClearProperty(db, idx, DB_UnresetViews); |
| | @@ -94675,11 +94840,11 @@ |
| 94675 | 94840 | |
| 94676 | 94841 | addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); VdbeCoverage(v); |
| 94677 | 94842 | assert( pKey!=0 || db->mallocFailed || pParse->nErr ); |
| 94678 | 94843 | if( IsUniqueIndex(pIndex) && pKey!=0 ){ |
| 94679 | 94844 | int j2 = sqlite3VdbeCurrentAddr(v) + 3; |
| 94680 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, j2); |
| 94845 | + sqlite3VdbeGoto(v, j2); |
| 94681 | 94846 | addr2 = sqlite3VdbeCurrentAddr(v); |
| 94682 | 94847 | sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord, |
| 94683 | 94848 | pIndex->nKeyCol); VdbeCoverage(v); |
| 94684 | 94849 | sqlite3UniqueConstraint(pParse, OE_Abort, pIndex); |
| 94685 | 94850 | }else{ |
| | @@ -94730,10 +94895,34 @@ |
| 94730 | 94895 | p->nKeyCol = nCol - 1; |
| 94731 | 94896 | *ppExtra = ((char*)p) + nByte; |
| 94732 | 94897 | } |
| 94733 | 94898 | return p; |
| 94734 | 94899 | } |
| 94900 | + |
| 94901 | +/* |
| 94902 | +** Backwards Compatibility Hack: |
| 94903 | +** |
| 94904 | +** Historical versions of SQLite accepted strings as column names in |
| 94905 | +** indexes and PRIMARY KEY constraints and in UNIQUE constraints. Example: |
| 94906 | +** |
| 94907 | +** CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim) |
| 94908 | +** CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC); |
| 94909 | +** |
| 94910 | +** This is goofy. But to preserve backwards compatibility we continue to |
| 94911 | +** accept it. This routine does the necessary conversion. It converts |
| 94912 | +** the expression given in its argument from a TK_STRING into a TK_ID |
| 94913 | +** if the expression is just a TK_STRING with an optional COLLATE clause. |
| 94914 | +** If the epxression is anything other than TK_STRING, the expression is |
| 94915 | +** unchanged. |
| 94916 | +*/ |
| 94917 | +static void sqlite3StringToId(Expr *p){ |
| 94918 | + if( p->op==TK_STRING ){ |
| 94919 | + p->op = TK_ID; |
| 94920 | + }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){ |
| 94921 | + p->pLeft->op = TK_ID; |
| 94922 | + } |
| 94923 | +} |
| 94735 | 94924 | |
| 94736 | 94925 | /* |
| 94737 | 94926 | ** Create a new index for an SQL table. pName1.pName2 is the name of the index |
| 94738 | 94927 | ** and pTblList is the name of the table that is to be indexed. Both will |
| 94739 | 94928 | ** be NULL for a primary key or an index that is created to satisfy a |
| | @@ -94772,11 +94961,10 @@ |
| 94772 | 94961 | sqlite3 *db = pParse->db; |
| 94773 | 94962 | Db *pDb; /* The specific table containing the indexed database */ |
| 94774 | 94963 | int iDb; /* Index of the database that is being written */ |
| 94775 | 94964 | Token *pName = 0; /* Unqualified name of the index to create */ |
| 94776 | 94965 | struct ExprList_item *pListItem; /* For looping over pList */ |
| 94777 | | - const Column *pTabCol; /* A column in the table */ |
| 94778 | 94966 | int nExtra = 0; /* Space allocated for zExtra[] */ |
| 94779 | 94967 | int nExtraCol; /* Number of extra columns needed */ |
| 94780 | 94968 | char *zExtra = 0; /* Extra space after the Index object */ |
| 94781 | 94969 | Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */ |
| 94782 | 94970 | |
| | @@ -94927,24 +95115,29 @@ |
| 94927 | 95115 | /* If pList==0, it means this routine was called to make a primary |
| 94928 | 95116 | ** key out of the last column added to the table under construction. |
| 94929 | 95117 | ** So create a fake list to simulate this. |
| 94930 | 95118 | */ |
| 94931 | 95119 | if( pList==0 ){ |
| 94932 | | - pList = sqlite3ExprListAppend(pParse, 0, 0); |
| 95120 | + Token prevCol; |
| 95121 | + prevCol.z = pTab->aCol[pTab->nCol-1].zName; |
| 95122 | + prevCol.n = sqlite3Strlen30(prevCol.z); |
| 95123 | + pList = sqlite3ExprListAppend(pParse, 0, |
| 95124 | + sqlite3ExprAlloc(db, TK_ID, &prevCol, 0)); |
| 94933 | 95125 | if( pList==0 ) goto exit_create_index; |
| 94934 | | - pList->a[0].zName = sqlite3DbStrDup(pParse->db, |
| 94935 | | - pTab->aCol[pTab->nCol-1].zName); |
| 94936 | | - pList->a[0].sortOrder = (u8)sortOrder; |
| 95126 | + assert( pList->nExpr==1 ); |
| 95127 | + sqlite3ExprListSetSortOrder(pList, sortOrder); |
| 95128 | + }else{ |
| 95129 | + sqlite3ExprListCheckLength(pParse, pList, "index"); |
| 94937 | 95130 | } |
| 94938 | 95131 | |
| 94939 | 95132 | /* Figure out how many bytes of space are required to store explicitly |
| 94940 | 95133 | ** specified collation sequence names. |
| 94941 | 95134 | */ |
| 94942 | 95135 | for(i=0; i<pList->nExpr; i++){ |
| 94943 | 95136 | Expr *pExpr = pList->a[i].pExpr; |
| 94944 | | - if( pExpr ){ |
| 94945 | | - assert( pExpr->op==TK_COLLATE ); |
| 95137 | + assert( pExpr!=0 ); |
| 95138 | + if( pExpr->op==TK_COLLATE ){ |
| 94946 | 95139 | nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken)); |
| 94947 | 95140 | } |
| 94948 | 95141 | } |
| 94949 | 95142 | |
| 94950 | 95143 | /* |
| | @@ -94981,61 +95174,85 @@ |
| 94981 | 95174 | sortOrderMask = -1; /* Honor DESC */ |
| 94982 | 95175 | }else{ |
| 94983 | 95176 | sortOrderMask = 0; /* Ignore DESC */ |
| 94984 | 95177 | } |
| 94985 | 95178 | |
| 94986 | | - /* Scan the names of the columns of the table to be indexed and |
| 94987 | | - ** load the column indices into the Index structure. Report an error |
| 94988 | | - ** if any column is not found. |
| 95179 | + /* Analyze the list of expressions that form the terms of the index and |
| 95180 | + ** report any errors. In the common case where the expression is exactly |
| 95181 | + ** a table column, store that column in aiColumn[]. For general expressions, |
| 95182 | + ** populate pIndex->aColExpr and store -2 in aiColumn[]. |
| 94989 | 95183 | ** |
| 94990 | | - ** TODO: Add a test to make sure that the same column is not named |
| 94991 | | - ** more than once within the same index. Only the first instance of |
| 94992 | | - ** the column will ever be used by the optimizer. Note that using the |
| 94993 | | - ** same column more than once cannot be an error because that would |
| 94994 | | - ** break backwards compatibility - it needs to be a warning. |
| 95184 | + ** TODO: Issue a warning if two or more columns of the index are identical. |
| 95185 | + ** TODO: Issue a warning if the table primary key is used as part of the |
| 95186 | + ** index key. |
| 94995 | 95187 | */ |
| 94996 | 95188 | for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){ |
| 94997 | | - const char *zColName = pListItem->zName; |
| 94998 | | - int requestedSortOrder; |
| 95189 | + Expr *pCExpr; /* The i-th index expression */ |
| 95190 | + int requestedSortOrder; /* ASC or DESC on the i-th expression */ |
| 94999 | 95191 | char *zColl; /* Collation sequence name */ |
| 95000 | 95192 | |
| 95001 | | - for(j=0, pTabCol=pTab->aCol; j<pTab->nCol; j++, pTabCol++){ |
| 95002 | | - if( sqlite3StrICmp(zColName, pTabCol->zName)==0 ) break; |
| 95003 | | - } |
| 95004 | | - if( j>=pTab->nCol ){ |
| 95005 | | - sqlite3ErrorMsg(pParse, "table %s has no column named %s", |
| 95006 | | - pTab->zName, zColName); |
| 95007 | | - pParse->checkSchema = 1; |
| 95008 | | - goto exit_create_index; |
| 95009 | | - } |
| 95010 | | - assert( j<=0x7fff ); |
| 95011 | | - pIndex->aiColumn[i] = (i16)j; |
| 95012 | | - if( pListItem->pExpr ){ |
| 95013 | | - int nColl; |
| 95014 | | - assert( pListItem->pExpr->op==TK_COLLATE ); |
| 95193 | + sqlite3StringToId(pListItem->pExpr); |
| 95194 | + sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0); |
| 95195 | + if( pParse->nErr ) goto exit_create_index; |
| 95196 | + pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr); |
| 95197 | + if( pCExpr->op!=TK_COLUMN ){ |
| 95198 | + if( pTab==pParse->pNewTable ){ |
| 95199 | + sqlite3ErrorMsg(pParse, "expressions prohibited in PRIMARY KEY and " |
| 95200 | + "UNIQUE constraints"); |
| 95201 | + goto exit_create_index; |
| 95202 | + } |
| 95203 | + if( pIndex->aColExpr==0 ){ |
| 95204 | + ExprList *pCopy = sqlite3ExprListDup(db, pList, 0); |
| 95205 | + pIndex->aColExpr = pCopy; |
| 95206 | + if( !db->mallocFailed ){ |
| 95207 | + assert( pCopy!=0 ); |
| 95208 | + pListItem = &pCopy->a[i]; |
| 95209 | + } |
| 95210 | + } |
| 95211 | + j = -2; |
| 95212 | + pIndex->aiColumn[i] = -2; |
| 95213 | + pIndex->uniqNotNull = 0; |
| 95214 | + }else{ |
| 95215 | + j = pCExpr->iColumn; |
| 95216 | + assert( j<=0x7fff ); |
| 95217 | + if( j<0 ){ |
| 95218 | + j = pTab->iPKey; |
| 95219 | + }else if( pTab->aCol[j].notNull==0 ){ |
| 95220 | + pIndex->uniqNotNull = 0; |
| 95221 | + } |
| 95222 | + pIndex->aiColumn[i] = (i16)j; |
| 95223 | + } |
| 95224 | + zColl = 0; |
| 95225 | + if( pListItem->pExpr->op==TK_COLLATE ){ |
| 95226 | + int nColl; |
| 95015 | 95227 | zColl = pListItem->pExpr->u.zToken; |
| 95016 | 95228 | nColl = sqlite3Strlen30(zColl) + 1; |
| 95017 | 95229 | assert( nExtra>=nColl ); |
| 95018 | 95230 | memcpy(zExtra, zColl, nColl); |
| 95019 | 95231 | zColl = zExtra; |
| 95020 | 95232 | zExtra += nColl; |
| 95021 | 95233 | nExtra -= nColl; |
| 95022 | | - }else{ |
| 95234 | + }else if( j>=0 ){ |
| 95023 | 95235 | zColl = pTab->aCol[j].zColl; |
| 95024 | | - if( !zColl ) zColl = "BINARY"; |
| 95025 | 95236 | } |
| 95237 | + if( !zColl ) zColl = "BINARY"; |
| 95026 | 95238 | if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){ |
| 95027 | 95239 | goto exit_create_index; |
| 95028 | 95240 | } |
| 95029 | 95241 | pIndex->azColl[i] = zColl; |
| 95030 | 95242 | requestedSortOrder = pListItem->sortOrder & sortOrderMask; |
| 95031 | 95243 | pIndex->aSortOrder[i] = (u8)requestedSortOrder; |
| 95032 | | - if( pTab->aCol[j].notNull==0 ) pIndex->uniqNotNull = 0; |
| 95033 | 95244 | } |
| 95245 | + |
| 95246 | + /* Append the table key to the end of the index. For WITHOUT ROWID |
| 95247 | + ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For |
| 95248 | + ** normal tables (when pPk==0) this will be the rowid. |
| 95249 | + */ |
| 95034 | 95250 | if( pPk ){ |
| 95035 | 95251 | for(j=0; j<pPk->nKeyCol; j++){ |
| 95036 | 95252 | int x = pPk->aiColumn[j]; |
| 95253 | + assert( x>=0 ); |
| 95037 | 95254 | if( hasColumn(pIndex->aiColumn, pIndex->nKeyCol, x) ){ |
| 95038 | 95255 | pIndex->nColumn--; |
| 95039 | 95256 | }else{ |
| 95040 | 95257 | pIndex->aiColumn[i] = x; |
| 95041 | 95258 | pIndex->azColl[i] = pPk->azColl[j]; |
| | @@ -95082,10 +95299,11 @@ |
| 95082 | 95299 | |
| 95083 | 95300 | if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue; |
| 95084 | 95301 | for(k=0; k<pIdx->nKeyCol; k++){ |
| 95085 | 95302 | const char *z1; |
| 95086 | 95303 | const char *z2; |
| 95304 | + assert( pIdx->aiColumn[k]>=0 ); |
| 95087 | 95305 | if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break; |
| 95088 | 95306 | z1 = pIdx->azColl[k]; |
| 95089 | 95307 | z2 = pIndex->azColl[k]; |
| 95090 | 95308 | if( z1!=z2 && sqlite3StrICmp(z1, z2) ) break; |
| 95091 | 95309 | } |
| | @@ -95113,10 +95331,11 @@ |
| 95113 | 95331 | } |
| 95114 | 95332 | |
| 95115 | 95333 | /* Link the new Index structure to its table and to the other |
| 95116 | 95334 | ** in-memory database structures. |
| 95117 | 95335 | */ |
| 95336 | + assert( pParse->nErr==0 ); |
| 95118 | 95337 | if( db->init.busy ){ |
| 95119 | 95338 | Index *p; |
| 95120 | 95339 | assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); |
| 95121 | 95340 | p = sqlite3HashInsert(&pIndex->pSchema->idxHash, |
| 95122 | 95341 | pIndex->zName, pIndex); |
| | @@ -95142,11 +95361,11 @@ |
| 95142 | 95361 | ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY |
| 95143 | 95362 | ** or UNIQUE index in a CREATE TABLE statement. Since the table |
| 95144 | 95363 | ** has just been created, it contains no data and the index initialization |
| 95145 | 95364 | ** step can be skipped. |
| 95146 | 95365 | */ |
| 95147 | | - else if( pParse->nErr==0 && (HasRowid(pTab) || pTblName!=0) ){ |
| 95366 | + else if( HasRowid(pTab) || pTblName!=0 ){ |
| 95148 | 95367 | Vdbe *v; |
| 95149 | 95368 | char *zStmt; |
| 95150 | 95369 | int iMem = ++pParse->nMem; |
| 95151 | 95370 | |
| 95152 | 95371 | v = sqlite3GetVdbe(pParse); |
| | @@ -95602,11 +95821,12 @@ |
| 95602 | 95821 | if( pList==0 ) return; |
| 95603 | 95822 | for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){ |
| 95604 | 95823 | sqlite3DbFree(db, pItem->zDatabase); |
| 95605 | 95824 | sqlite3DbFree(db, pItem->zName); |
| 95606 | 95825 | sqlite3DbFree(db, pItem->zAlias); |
| 95607 | | - sqlite3DbFree(db, pItem->zIndexedBy); |
| 95826 | + if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy); |
| 95827 | + if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg); |
| 95608 | 95828 | sqlite3DeleteTable(db, pItem->pTab); |
| 95609 | 95829 | sqlite3SelectDelete(db, pItem->pSelect); |
| 95610 | 95830 | sqlite3ExprDelete(db, pItem->pOn); |
| 95611 | 95831 | sqlite3IdListDelete(db, pItem->pUsing); |
| 95612 | 95832 | } |
| | @@ -95675,20 +95895,40 @@ |
| 95675 | 95895 | */ |
| 95676 | 95896 | SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){ |
| 95677 | 95897 | assert( pIndexedBy!=0 ); |
| 95678 | 95898 | if( p && ALWAYS(p->nSrc>0) ){ |
| 95679 | 95899 | struct SrcList_item *pItem = &p->a[p->nSrc-1]; |
| 95680 | | - assert( pItem->notIndexed==0 && pItem->zIndexedBy==0 ); |
| 95900 | + assert( pItem->fg.notIndexed==0 ); |
| 95901 | + assert( pItem->fg.isIndexedBy==0 ); |
| 95902 | + assert( pItem->fg.isTabFunc==0 ); |
| 95681 | 95903 | if( pIndexedBy->n==1 && !pIndexedBy->z ){ |
| 95682 | 95904 | /* A "NOT INDEXED" clause was supplied. See parse.y |
| 95683 | 95905 | ** construct "indexed_opt" for details. */ |
| 95684 | | - pItem->notIndexed = 1; |
| 95906 | + pItem->fg.notIndexed = 1; |
| 95685 | 95907 | }else{ |
| 95686 | | - pItem->zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy); |
| 95908 | + pItem->u1.zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy); |
| 95909 | + pItem->fg.isIndexedBy = (pItem->u1.zIndexedBy!=0); |
| 95687 | 95910 | } |
| 95688 | 95911 | } |
| 95689 | 95912 | } |
| 95913 | + |
| 95914 | +/* |
| 95915 | +** Add the list of function arguments to the SrcList entry for a |
| 95916 | +** table-valued-function. |
| 95917 | +*/ |
| 95918 | +SQLITE_PRIVATE void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){ |
| 95919 | + if( p && pList ){ |
| 95920 | + struct SrcList_item *pItem = &p->a[p->nSrc-1]; |
| 95921 | + assert( pItem->fg.notIndexed==0 ); |
| 95922 | + assert( pItem->fg.isIndexedBy==0 ); |
| 95923 | + assert( pItem->fg.isTabFunc==0 ); |
| 95924 | + pItem->u1.pFuncArg = pList; |
| 95925 | + pItem->fg.isTabFunc = 1; |
| 95926 | + }else{ |
| 95927 | + sqlite3ExprListDelete(pParse->db, pList); |
| 95928 | + } |
| 95929 | +} |
| 95690 | 95930 | |
| 95691 | 95931 | /* |
| 95692 | 95932 | ** When building up a FROM clause in the parser, the join operator |
| 95693 | 95933 | ** is initially attached to the left operand. But the code generator |
| 95694 | 95934 | ** expects the join operator to be on the right operand. This routine |
| | @@ -95705,13 +95945,13 @@ |
| 95705 | 95945 | */ |
| 95706 | 95946 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){ |
| 95707 | 95947 | if( p ){ |
| 95708 | 95948 | int i; |
| 95709 | 95949 | for(i=p->nSrc-1; i>0; i--){ |
| 95710 | | - p->a[i].jointype = p->a[i-1].jointype; |
| 95950 | + p->a[i].fg.jointype = p->a[i-1].fg.jointype; |
| 95711 | 95951 | } |
| 95712 | | - p->a[0].jointype = 0; |
| 95952 | + p->a[0].fg.jointype = 0; |
| 95713 | 95953 | } |
| 95714 | 95954 | } |
| 95715 | 95955 | |
| 95716 | 95956 | /* |
| 95717 | 95957 | ** Begin a transaction |
| | @@ -95951,16 +96191,20 @@ |
| 95951 | 96191 | int j; |
| 95952 | 96192 | StrAccum errMsg; |
| 95953 | 96193 | Table *pTab = pIdx->pTable; |
| 95954 | 96194 | |
| 95955 | 96195 | sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200); |
| 95956 | | - for(j=0; j<pIdx->nKeyCol; j++){ |
| 95957 | | - char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName; |
| 95958 | | - if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2); |
| 95959 | | - sqlite3StrAccumAppendAll(&errMsg, pTab->zName); |
| 95960 | | - sqlite3StrAccumAppend(&errMsg, ".", 1); |
| 95961 | | - sqlite3StrAccumAppendAll(&errMsg, zCol); |
| 96196 | + if( pIdx->aColExpr ){ |
| 96197 | + sqlite3XPrintf(&errMsg, 0, "index '%q'", pIdx->zName); |
| 96198 | + }else{ |
| 96199 | + for(j=0; j<pIdx->nKeyCol; j++){ |
| 96200 | + char *zCol; |
| 96201 | + assert( pIdx->aiColumn[j]>=0 ); |
| 96202 | + zCol = pTab->aCol[pIdx->aiColumn[j]].zName; |
| 96203 | + if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2); |
| 96204 | + sqlite3XPrintf(&errMsg, 0, "%s.%s", pTab->zName, zCol); |
| 96205 | + } |
| 95962 | 96206 | } |
| 95963 | 96207 | zErr = sqlite3StrAccumFinish(&errMsg); |
| 95964 | 96208 | sqlite3HaltConstraint(pParse, |
| 95965 | 96209 | IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY |
| 95966 | 96210 | : SQLITE_CONSTRAINT_UNIQUE, |
| | @@ -96201,11 +96445,11 @@ |
| 96201 | 96445 | pNew = pWith; |
| 96202 | 96446 | }else{ |
| 96203 | 96447 | pNew->a[pNew->nCte].pSelect = pQuery; |
| 96204 | 96448 | pNew->a[pNew->nCte].pCols = pArglist; |
| 96205 | 96449 | pNew->a[pNew->nCte].zName = zName; |
| 96206 | | - pNew->a[pNew->nCte].zErr = 0; |
| 96450 | + pNew->a[pNew->nCte].zCteErr = 0; |
| 96207 | 96451 | pNew->nCte++; |
| 96208 | 96452 | } |
| 96209 | 96453 | |
| 96210 | 96454 | return pNew; |
| 96211 | 96455 | } |
| | @@ -97120,10 +97364,11 @@ |
| 97120 | 97364 | } |
| 97121 | 97365 | |
| 97122 | 97366 | /* Extract the rowid or primary key for the current row */ |
| 97123 | 97367 | if( pPk ){ |
| 97124 | 97368 | for(i=0; i<nPk; i++){ |
| 97369 | + assert( pPk->aiColumn[i]>=(-1) ); |
| 97125 | 97370 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iTabCur, |
| 97126 | 97371 | pPk->aiColumn[i], iPk+i); |
| 97127 | 97372 | } |
| 97128 | 97373 | iKey = iPk; |
| 97129 | 97374 | }else{ |
| | @@ -97152,11 +97397,11 @@ |
| 97152 | 97397 | }else if( pPk ){ |
| 97153 | 97398 | /* Construct a composite key for the row to be deleted and remember it */ |
| 97154 | 97399 | iKey = ++pParse->nMem; |
| 97155 | 97400 | nKey = 0; /* Zero tells OP_Found to use a composite key */ |
| 97156 | 97401 | sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, iKey, |
| 97157 | | - sqlite3IndexAffinityStr(v, pPk), nPk); |
| 97402 | + sqlite3IndexAffinityStr(pParse->db, pPk), nPk); |
| 97158 | 97403 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iEphCur, iKey); |
| 97159 | 97404 | }else{ |
| 97160 | 97405 | /* Get the rowid of the row to be deleted and remember it in the RowSet */ |
| 97161 | 97406 | nKey = 1; /* OP_Seek always uses a single rowid */ |
| 97162 | 97407 | sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey); |
| | @@ -97165,11 +97410,11 @@ |
| 97165 | 97410 | /* End of the WHERE loop */ |
| 97166 | 97411 | sqlite3WhereEnd(pWInfo); |
| 97167 | 97412 | if( okOnePass ){ |
| 97168 | 97413 | /* Bypass the delete logic below if the WHERE loop found zero rows */ |
| 97169 | 97414 | addrBypass = sqlite3VdbeMakeLabel(v); |
| 97170 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrBypass); |
| 97415 | + sqlite3VdbeGoto(v, addrBypass); |
| 97171 | 97416 | sqlite3VdbeJumpHere(v, addrDelete); |
| 97172 | 97417 | } |
| 97173 | 97418 | |
| 97174 | 97419 | /* Unless this is a view, open cursors for the table we are |
| 97175 | 97420 | ** deleting from and all its indices. If this is a view, then the |
| | @@ -97227,11 +97472,11 @@ |
| 97227 | 97472 | sqlite3VdbeResolveLabel(v, addrBypass); |
| 97228 | 97473 | }else if( pPk ){ |
| 97229 | 97474 | sqlite3VdbeAddOp2(v, OP_Next, iEphCur, addrLoop+1); VdbeCoverage(v); |
| 97230 | 97475 | sqlite3VdbeJumpHere(v, addrLoop); |
| 97231 | 97476 | }else{ |
| 97232 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrLoop); |
| 97477 | + sqlite3VdbeGoto(v, addrLoop); |
| 97233 | 97478 | sqlite3VdbeJumpHere(v, addrLoop); |
| 97234 | 97479 | } |
| 97235 | 97480 | |
| 97236 | 97481 | /* Close the cursors open on the table and its indexes. */ |
| 97237 | 97482 | if( !isView && !IsVirtual(pTab) ){ |
| | @@ -97498,18 +97743,17 @@ |
| 97498 | 97743 | Index *pPrior, /* Previously generated index key */ |
| 97499 | 97744 | int regPrior /* Register holding previous generated key */ |
| 97500 | 97745 | ){ |
| 97501 | 97746 | Vdbe *v = pParse->pVdbe; |
| 97502 | 97747 | int j; |
| 97503 | | - Table *pTab = pIdx->pTable; |
| 97504 | 97748 | int regBase; |
| 97505 | 97749 | int nCol; |
| 97506 | 97750 | |
| 97507 | 97751 | if( piPartIdxLabel ){ |
| 97508 | 97752 | if( pIdx->pPartIdxWhere ){ |
| 97509 | 97753 | *piPartIdxLabel = sqlite3VdbeMakeLabel(v); |
| 97510 | | - pParse->iPartIdxTab = iDataCur; |
| 97754 | + pParse->iSelfTab = iDataCur; |
| 97511 | 97755 | sqlite3ExprCachePush(pParse); |
| 97512 | 97756 | sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, |
| 97513 | 97757 | SQLITE_JUMPIFNULL); |
| 97514 | 97758 | }else{ |
| 97515 | 97759 | *piPartIdxLabel = 0; |
| | @@ -97517,13 +97761,18 @@ |
| 97517 | 97761 | } |
| 97518 | 97762 | nCol = (prefixOnly && pIdx->uniqNotNull) ? pIdx->nKeyCol : pIdx->nColumn; |
| 97519 | 97763 | regBase = sqlite3GetTempRange(pParse, nCol); |
| 97520 | 97764 | if( pPrior && (regBase!=regPrior || pPrior->pPartIdxWhere) ) pPrior = 0; |
| 97521 | 97765 | for(j=0; j<nCol; j++){ |
| 97522 | | - if( pPrior && pPrior->aiColumn[j]==pIdx->aiColumn[j] ) continue; |
| 97523 | | - sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, pIdx->aiColumn[j], |
| 97524 | | - regBase+j); |
| 97766 | + if( pPrior |
| 97767 | + && pPrior->aiColumn[j]==pIdx->aiColumn[j] |
| 97768 | + && pPrior->aiColumn[j]>=(-1) |
| 97769 | + ){ |
| 97770 | + /* This column was already computed by the previous index */ |
| 97771 | + continue; |
| 97772 | + } |
| 97773 | + sqlite3ExprCodeLoadIndexColumn(pParse, pIdx, iDataCur, j, regBase+j); |
| 97525 | 97774 | /* If the column affinity is REAL but the number is an integer, then it |
| 97526 | 97775 | ** might be stored in the table as an integer (using a compact |
| 97527 | 97776 | ** representation) then converted to REAL by an OP_RealAffinity opcode. |
| 97528 | 97777 | ** But we are getting ready to store this value back into an index, where |
| 97529 | 97778 | ** it should be converted by to INTEGER again. So omit the OP_RealAffinity |
| | @@ -99288,19 +99537,19 @@ |
| 99288 | 99537 | FUNCTION2(likelihood, 2, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), |
| 99289 | 99538 | FUNCTION2(likely, 1, 0, 0, noopFunc, SQLITE_FUNC_UNLIKELY), |
| 99290 | 99539 | VFUNCTION(random, 0, 0, 0, randomFunc ), |
| 99291 | 99540 | VFUNCTION(randomblob, 1, 0, 0, randomBlob ), |
| 99292 | 99541 | FUNCTION(nullif, 2, 0, 1, nullifFunc ), |
| 99293 | | - FUNCTION(sqlite_version, 0, 0, 0, versionFunc ), |
| 99294 | | - FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), |
| 99542 | + DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ), |
| 99543 | + DFUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), |
| 99295 | 99544 | FUNCTION(sqlite_log, 2, 0, 0, errlogFunc ), |
| 99296 | 99545 | #if SQLITE_USER_AUTHENTICATION |
| 99297 | 99546 | FUNCTION(sqlite_crypt, 2, 0, 0, sqlite3CryptFunc ), |
| 99298 | 99547 | #endif |
| 99299 | 99548 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
| 99300 | | - FUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc ), |
| 99301 | | - FUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc ), |
| 99549 | + DFUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc ), |
| 99550 | + DFUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc ), |
| 99302 | 99551 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| 99303 | 99552 | FUNCTION(quote, 1, 0, 0, quoteFunc ), |
| 99304 | 99553 | VFUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid), |
| 99305 | 99554 | VFUNCTION(changes, 0, 0, 0, changes ), |
| 99306 | 99555 | VFUNCTION(total_changes, 0, 0, 0, total_changes ), |
| | @@ -99308,12 +99557,12 @@ |
| 99308 | 99557 | FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc ), |
| 99309 | 99558 | #ifdef SQLITE_SOUNDEX |
| 99310 | 99559 | FUNCTION(soundex, 1, 0, 0, soundexFunc ), |
| 99311 | 99560 | #endif |
| 99312 | 99561 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 99313 | | - FUNCTION(load_extension, 1, 0, 0, loadExt ), |
| 99314 | | - FUNCTION(load_extension, 2, 0, 0, loadExt ), |
| 99562 | + VFUNCTION(load_extension, 1, 0, 0, loadExt ), |
| 99563 | + VFUNCTION(load_extension, 2, 0, 0, loadExt ), |
| 99315 | 99564 | #endif |
| 99316 | 99565 | AGGREGATE(sum, 1, 0, 0, sumStep, sumFinalize ), |
| 99317 | 99566 | AGGREGATE(total, 1, 0, 0, sumStep, totalFinalize ), |
| 99318 | 99567 | AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ), |
| 99319 | 99568 | AGGREGATE2(count, 0, 0, 0, countStep, countFinalize, |
| | @@ -99724,11 +99973,11 @@ |
| 99724 | 99973 | sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); |
| 99725 | 99974 | } |
| 99726 | 99975 | |
| 99727 | 99976 | sqlite3OpenTable(pParse, iCur, iDb, pTab, OP_OpenRead); |
| 99728 | 99977 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, 0, regTemp); VdbeCoverage(v); |
| 99729 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk); |
| 99978 | + sqlite3VdbeGoto(v, iOk); |
| 99730 | 99979 | sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
| 99731 | 99980 | sqlite3VdbeJumpHere(v, iMustBeInt); |
| 99732 | 99981 | sqlite3ReleaseTempReg(pParse, regTemp); |
| 99733 | 99982 | }else{ |
| 99734 | 99983 | int nCol = pFKey->nCol; |
| | @@ -99762,15 +100011,15 @@ |
| 99762 | 100011 | iParent = regData; |
| 99763 | 100012 | } |
| 99764 | 100013 | sqlite3VdbeAddOp3(v, OP_Ne, iChild, iJump, iParent); VdbeCoverage(v); |
| 99765 | 100014 | sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); |
| 99766 | 100015 | } |
| 99767 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, iOk); |
| 100016 | + sqlite3VdbeGoto(v, iOk); |
| 99768 | 100017 | } |
| 99769 | 100018 | |
| 99770 | 100019 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTemp, nCol, regRec, |
| 99771 | | - sqlite3IndexAffinityStr(v,pIdx), nCol); |
| 100020 | + sqlite3IndexAffinityStr(pParse->db,pIdx), nCol); |
| 99772 | 100021 | sqlite3VdbeAddOp4Int(v, OP_Found, iCur, iOk, regRec, 0); VdbeCoverage(v); |
| 99773 | 100022 | |
| 99774 | 100023 | sqlite3ReleaseTempReg(pParse, regRec); |
| 99775 | 100024 | sqlite3ReleaseTempRange(pParse, regTemp, nCol); |
| 99776 | 100025 | } |
| | @@ -100823,11 +101072,11 @@ |
| 100823 | 101072 | ** |
| 100824 | 101073 | ** Memory for the buffer containing the column index affinity string |
| 100825 | 101074 | ** is managed along with the rest of the Index structure. It will be |
| 100826 | 101075 | ** released when sqlite3DeleteIndex() is called. |
| 100827 | 101076 | */ |
| 100828 | | -SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(Vdbe *v, Index *pIdx){ |
| 101077 | +SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){ |
| 100829 | 101078 | if( !pIdx->zColAff ){ |
| 100830 | 101079 | /* The first time a column affinity string for a particular index is |
| 100831 | 101080 | ** required, it is allocated and populated here. It is then stored as |
| 100832 | 101081 | ** a member of the Index structure for subsequent use. |
| 100833 | 101082 | ** |
| | @@ -100835,19 +101084,29 @@ |
| 100835 | 101084 | ** sqliteDeleteIndex() when the Index structure itself is cleaned |
| 100836 | 101085 | ** up. |
| 100837 | 101086 | */ |
| 100838 | 101087 | int n; |
| 100839 | 101088 | Table *pTab = pIdx->pTable; |
| 100840 | | - sqlite3 *db = sqlite3VdbeDb(v); |
| 100841 | 101089 | pIdx->zColAff = (char *)sqlite3DbMallocRaw(0, pIdx->nColumn+1); |
| 100842 | 101090 | if( !pIdx->zColAff ){ |
| 100843 | 101091 | db->mallocFailed = 1; |
| 100844 | 101092 | return 0; |
| 100845 | 101093 | } |
| 100846 | 101094 | for(n=0; n<pIdx->nColumn; n++){ |
| 100847 | 101095 | i16 x = pIdx->aiColumn[n]; |
| 100848 | | - pIdx->zColAff[n] = x<0 ? SQLITE_AFF_INTEGER : pTab->aCol[x].affinity; |
| 101096 | + if( x>=0 ){ |
| 101097 | + pIdx->zColAff[n] = pTab->aCol[x].affinity; |
| 101098 | + }else if( x==(-1) ){ |
| 101099 | + pIdx->zColAff[n] = SQLITE_AFF_INTEGER; |
| 101100 | + }else{ |
| 101101 | + char aff; |
| 101102 | + assert( x==(-2) ); |
| 101103 | + assert( pIdx->aColExpr!=0 ); |
| 101104 | + aff = sqlite3ExprAffinity(pIdx->aColExpr->a[n].pExpr); |
| 101105 | + if( aff==0 ) aff = SQLITE_AFF_BLOB; |
| 101106 | + pIdx->zColAff[n] = aff; |
| 101107 | + } |
| 100849 | 101108 | } |
| 100850 | 101109 | pIdx->zColAff[n] = 0; |
| 100851 | 101110 | } |
| 100852 | 101111 | |
| 100853 | 101112 | return pIdx->zColAff; |
| | @@ -101014,18 +101273,18 @@ |
| 101014 | 101273 | memId = p->regCtr; |
| 101015 | 101274 | assert( sqlite3SchemaMutexHeld(db, 0, pDb->pSchema) ); |
| 101016 | 101275 | sqlite3OpenTable(pParse, 0, p->iDb, pDb->pSchema->pSeqTab, OP_OpenRead); |
| 101017 | 101276 | sqlite3VdbeAddOp3(v, OP_Null, 0, memId, memId+1); |
| 101018 | 101277 | addr = sqlite3VdbeCurrentAddr(v); |
| 101019 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, memId-1, 0, p->pTab->zName, 0); |
| 101278 | + sqlite3VdbeLoadString(v, memId-1, p->pTab->zName); |
| 101020 | 101279 | sqlite3VdbeAddOp2(v, OP_Rewind, 0, addr+9); VdbeCoverage(v); |
| 101021 | 101280 | sqlite3VdbeAddOp3(v, OP_Column, 0, 0, memId); |
| 101022 | 101281 | sqlite3VdbeAddOp3(v, OP_Ne, memId-1, addr+7, memId); VdbeCoverage(v); |
| 101023 | 101282 | sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL); |
| 101024 | 101283 | sqlite3VdbeAddOp2(v, OP_Rowid, 0, memId+1); |
| 101025 | 101284 | sqlite3VdbeAddOp3(v, OP_Column, 0, 1, memId); |
| 101026 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addr+9); |
| 101285 | + sqlite3VdbeGoto(v, addr+9); |
| 101027 | 101286 | sqlite3VdbeAddOp2(v, OP_Next, 0, addr+2); VdbeCoverage(v); |
| 101028 | 101287 | sqlite3VdbeAddOp2(v, OP_Integer, 0, memId); |
| 101029 | 101288 | sqlite3VdbeAddOp0(v, OP_Close); |
| 101030 | 101289 | } |
| 101031 | 101290 | } |
| | @@ -101445,11 +101704,11 @@ |
| 101445 | 101704 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn); |
| 101446 | 101705 | addrL = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); VdbeCoverage(v); |
| 101447 | 101706 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec); |
| 101448 | 101707 | sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid); |
| 101449 | 101708 | sqlite3VdbeAddOp3(v, OP_Insert, srcTab, regRec, regTempRowid); |
| 101450 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrL); |
| 101709 | + sqlite3VdbeGoto(v, addrL); |
| 101451 | 101710 | sqlite3VdbeJumpHere(v, addrL); |
| 101452 | 101711 | sqlite3ReleaseTempReg(pParse, regRec); |
| 101453 | 101712 | sqlite3ReleaseTempReg(pParse, regTempRowid); |
| 101454 | 101713 | } |
| 101455 | 101714 | }else{ |
| | @@ -101459,15 +101718,17 @@ |
| 101459 | 101718 | NameContext sNC; |
| 101460 | 101719 | memset(&sNC, 0, sizeof(sNC)); |
| 101461 | 101720 | sNC.pParse = pParse; |
| 101462 | 101721 | srcTab = -1; |
| 101463 | 101722 | assert( useTempTable==0 ); |
| 101464 | | - nColumn = pList ? pList->nExpr : 0; |
| 101465 | | - for(i=0; i<nColumn; i++){ |
| 101466 | | - if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){ |
| 101723 | + if( pList ){ |
| 101724 | + nColumn = pList->nExpr; |
| 101725 | + if( sqlite3ResolveExprListNames(&sNC, pList) ){ |
| 101467 | 101726 | goto insert_cleanup; |
| 101468 | 101727 | } |
| 101728 | + }else{ |
| 101729 | + nColumn = 0; |
| 101469 | 101730 | } |
| 101470 | 101731 | } |
| 101471 | 101732 | |
| 101472 | 101733 | /* If there is no IDLIST term but the table has an integer primary |
| 101473 | 101734 | ** key, the set the ipkColumn variable to the integer primary key |
| | @@ -101744,11 +102005,11 @@ |
| 101744 | 102005 | if( useTempTable ){ |
| 101745 | 102006 | sqlite3VdbeAddOp2(v, OP_Next, srcTab, addrCont); VdbeCoverage(v); |
| 101746 | 102007 | sqlite3VdbeJumpHere(v, addrInsTop); |
| 101747 | 102008 | sqlite3VdbeAddOp1(v, OP_Close, srcTab); |
| 101748 | 102009 | }else if( pSelect ){ |
| 101749 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrCont); |
| 102010 | + sqlite3VdbeGoto(v, addrCont); |
| 101750 | 102011 | sqlite3VdbeJumpHere(v, addrInsTop); |
| 101751 | 102012 | } |
| 101752 | 102013 | |
| 101753 | 102014 | if( !IsVirtual(pTab) && !isView ){ |
| 101754 | 102015 | /* Close all tables opened */ |
| | @@ -101991,11 +102252,11 @@ |
| 101991 | 102252 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 101992 | 102253 | for(i=0; i<pCheck->nExpr; i++){ |
| 101993 | 102254 | int allOk = sqlite3VdbeMakeLabel(v); |
| 101994 | 102255 | sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL); |
| 101995 | 102256 | if( onError==OE_Ignore ){ |
| 101996 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 102257 | + sqlite3VdbeGoto(v, ignoreDest); |
| 101997 | 102258 | }else{ |
| 101998 | 102259 | char *zName = pCheck->a[i].zName; |
| 101999 | 102260 | if( zName==0 ) zName = pTab->zName; |
| 102000 | 102261 | if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */ |
| 102001 | 102262 | sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_CHECK, |
| | @@ -102099,11 +102360,11 @@ |
| 102099 | 102360 | seenReplace = 1; |
| 102100 | 102361 | break; |
| 102101 | 102362 | } |
| 102102 | 102363 | case OE_Ignore: { |
| 102103 | 102364 | /*assert( seenReplace==0 );*/ |
| 102104 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 102365 | + sqlite3VdbeGoto(v, ignoreDest); |
| 102105 | 102366 | break; |
| 102106 | 102367 | } |
| 102107 | 102368 | } |
| 102108 | 102369 | sqlite3VdbeResolveLabel(v, addrRowidOk); |
| 102109 | 102370 | if( ipkTop ){ |
| | @@ -102147,19 +102408,26 @@ |
| 102147 | 102408 | */ |
| 102148 | 102409 | regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn); |
| 102149 | 102410 | for(i=0; i<pIdx->nColumn; i++){ |
| 102150 | 102411 | int iField = pIdx->aiColumn[i]; |
| 102151 | 102412 | int x; |
| 102152 | | - if( iField<0 || iField==pTab->iPKey ){ |
| 102153 | | - if( regRowid==regIdx+i ) continue; /* ROWID already in regIdx+i */ |
| 102154 | | - x = regNewData; |
| 102155 | | - regRowid = pIdx->pPartIdxWhere ? -1 : regIdx+i; |
| 102413 | + if( iField==(-2) ){ |
| 102414 | + pParse->ckBase = regNewData+1; |
| 102415 | + sqlite3ExprCode(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i); |
| 102416 | + pParse->ckBase = 0; |
| 102417 | + VdbeComment((v, "%s column %d", pIdx->zName, i)); |
| 102156 | 102418 | }else{ |
| 102157 | | - x = iField + regNewData + 1; |
| 102419 | + if( iField==(-1) || iField==pTab->iPKey ){ |
| 102420 | + if( regRowid==regIdx+i ) continue; /* ROWID already in regIdx+i */ |
| 102421 | + x = regNewData; |
| 102422 | + regRowid = pIdx->pPartIdxWhere ? -1 : regIdx+i; |
| 102423 | + }else{ |
| 102424 | + x = iField + regNewData + 1; |
| 102425 | + } |
| 102426 | + sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i); |
| 102427 | + VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName)); |
| 102158 | 102428 | } |
| 102159 | | - sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i); |
| 102160 | | - VdbeComment((v, "%s", iField<0 ? "rowid" : pTab->aCol[iField].zName)); |
| 102161 | 102429 | } |
| 102162 | 102430 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]); |
| 102163 | 102431 | VdbeComment((v, "for %s", pIdx->zName)); |
| 102164 | 102432 | sqlite3ExprCacheAffinityChange(pParse, regIdx, pIdx->nColumn); |
| 102165 | 102433 | |
| | @@ -102252,11 +102520,11 @@ |
| 102252 | 102520 | case OE_Fail: { |
| 102253 | 102521 | sqlite3UniqueConstraint(pParse, onError, pIdx); |
| 102254 | 102522 | break; |
| 102255 | 102523 | } |
| 102256 | 102524 | case OE_Ignore: { |
| 102257 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 102525 | + sqlite3VdbeGoto(v, ignoreDest); |
| 102258 | 102526 | break; |
| 102259 | 102527 | } |
| 102260 | 102528 | default: { |
| 102261 | 102529 | Trigger *pTrigger = 0; |
| 102262 | 102530 | assert( onError==OE_Replace ); |
| | @@ -102273,11 +102541,11 @@ |
| 102273 | 102541 | sqlite3VdbeResolveLabel(v, addrUniqueOk); |
| 102274 | 102542 | sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn); |
| 102275 | 102543 | if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField); |
| 102276 | 102544 | } |
| 102277 | 102545 | if( ipkTop ){ |
| 102278 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, ipkTop+1); |
| 102546 | + sqlite3VdbeGoto(v, ipkTop+1); |
| 102279 | 102547 | sqlite3VdbeJumpHere(v, ipkBottom); |
| 102280 | 102548 | } |
| 102281 | 102549 | |
| 102282 | 102550 | *pbMayReplace = seenReplace; |
| 102283 | 102551 | VdbeModuleComment((v, "END: GenCnstCks(%d)", seenReplace)); |
| | @@ -102475,10 +102743,17 @@ |
| 102475 | 102743 | return 0; /* Different conflict resolution strategies */ |
| 102476 | 102744 | } |
| 102477 | 102745 | for(i=0; i<pSrc->nKeyCol; i++){ |
| 102478 | 102746 | if( pSrc->aiColumn[i]!=pDest->aiColumn[i] ){ |
| 102479 | 102747 | return 0; /* Different columns indexed */ |
| 102748 | + } |
| 102749 | + if( pSrc->aiColumn[i]==(-2) ){ |
| 102750 | + assert( pSrc->aColExpr!=0 && pDest->aColExpr!=0 ); |
| 102751 | + if( sqlite3ExprCompare(pSrc->aColExpr->a[i].pExpr, |
| 102752 | + pDest->aColExpr->a[i].pExpr, -1)!=0 ){ |
| 102753 | + return 0; /* Different expressions in the index */ |
| 102754 | + } |
| 102480 | 102755 | } |
| 102481 | 102756 | if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){ |
| 102482 | 102757 | return 0; /* Different sort orders */ |
| 102483 | 102758 | } |
| 102484 | 102759 | if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){ |
| | @@ -102719,11 +102994,11 @@ |
| 102719 | 102994 | ** is unable to test uniqueness.) |
| 102720 | 102995 | ** |
| 102721 | 102996 | ** (3) onError is something other than OE_Abort and OE_Rollback. |
| 102722 | 102997 | */ |
| 102723 | 102998 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0); VdbeCoverage(v); |
| 102724 | | - emptyDestTest = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); |
| 102999 | + emptyDestTest = sqlite3VdbeAddOp0(v, OP_Goto); |
| 102725 | 103000 | sqlite3VdbeJumpHere(v, addr1); |
| 102726 | 103001 | } |
| 102727 | 103002 | if( HasRowid(pSrc) ){ |
| 102728 | 103003 | sqlite3OpenTable(pParse, iSrc, iDbSrc, pSrc, OP_OpenRead); |
| 102729 | 103004 | emptySrcTest = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v); |
| | @@ -103256,10 +103531,13 @@ |
| 103256 | 103531 | /* Version 3.8.11 and later */ |
| 103257 | 103532 | sqlite3_value *(*value_dup)(const sqlite3_value*); |
| 103258 | 103533 | void (*value_free)(sqlite3_value*); |
| 103259 | 103534 | int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64); |
| 103260 | 103535 | int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64); |
| 103536 | + /* Version 3.8.12 and later */ |
| 103537 | + unsigned int (*value_subtype)(sqlite3_value*); |
| 103538 | + void (*result_subtype)(sqlite3_context*,unsigned int); |
| 103261 | 103539 | }; |
| 103262 | 103540 | |
| 103263 | 103541 | /* |
| 103264 | 103542 | ** The following macros redefine the API routines so that they are |
| 103265 | 103543 | ** redirected through the global sqlite3_api structure. |
| | @@ -103269,11 +103547,11 @@ |
| 103269 | 103547 | ** it can get access to the sqlite3_api_routines structure |
| 103270 | 103548 | ** definition. But the main library does not want to redefine |
| 103271 | 103549 | ** the API. So the redefinition macros are only valid if the |
| 103272 | 103550 | ** SQLITE_CORE macros is undefined. |
| 103273 | 103551 | */ |
| 103274 | | -#ifndef SQLITE_CORE |
| 103552 | +#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 103275 | 103553 | #define sqlite3_aggregate_context sqlite3_api->aggregate_context |
| 103276 | 103554 | #ifndef SQLITE_OMIT_DEPRECATED |
| 103277 | 103555 | #define sqlite3_aggregate_count sqlite3_api->aggregate_count |
| 103278 | 103556 | #endif |
| 103279 | 103557 | #define sqlite3_bind_blob sqlite3_api->bind_blob |
| | @@ -103396,10 +103674,11 @@ |
| 103396 | 103674 | #define sqlite3_value_text16 sqlite3_api->value_text16 |
| 103397 | 103675 | #define sqlite3_value_text16be sqlite3_api->value_text16be |
| 103398 | 103676 | #define sqlite3_value_text16le sqlite3_api->value_text16le |
| 103399 | 103677 | #define sqlite3_value_type sqlite3_api->value_type |
| 103400 | 103678 | #define sqlite3_vmprintf sqlite3_api->vmprintf |
| 103679 | +#define sqlite3_vsnprintf sqlite3_api->vsnprintf |
| 103401 | 103680 | #define sqlite3_overload_function sqlite3_api->overload_function |
| 103402 | 103681 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 |
| 103403 | 103682 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 |
| 103404 | 103683 | #define sqlite3_clear_bindings sqlite3_api->clear_bindings |
| 103405 | 103684 | #define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob |
| | @@ -103491,13 +103770,16 @@ |
| 103491 | 103770 | /* Version 3.8.11 and later */ |
| 103492 | 103771 | #define sqlite3_value_dup sqlite3_api->value_dup |
| 103493 | 103772 | #define sqlite3_value_free sqlite3_api->value_free |
| 103494 | 103773 | #define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64 |
| 103495 | 103774 | #define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64 |
| 103496 | | -#endif /* SQLITE_CORE */ |
| 103775 | +/* Version 3.8.12 and later */ |
| 103776 | +#define sqlite3_value_subtype sqlite3_api->value_subtype |
| 103777 | +#define sqlite3_result_subtype sqlite3_api->result_subtype |
| 103778 | +#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 103497 | 103779 | |
| 103498 | | -#ifndef SQLITE_CORE |
| 103780 | +#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 103499 | 103781 | /* This case when the file really is being compiled as a loadable |
| 103500 | 103782 | ** extension */ |
| 103501 | 103783 | # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; |
| 103502 | 103784 | # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; |
| 103503 | 103785 | # define SQLITE_EXTENSION_INIT3 \ |
| | @@ -103902,11 +104184,14 @@ |
| 103902 | 104184 | sqlite3_strglob, |
| 103903 | 104185 | /* Version 3.8.11 and later */ |
| 103904 | 104186 | (sqlite3_value*(*)(const sqlite3_value*))sqlite3_value_dup, |
| 103905 | 104187 | sqlite3_value_free, |
| 103906 | 104188 | sqlite3_result_zeroblob64, |
| 103907 | | - sqlite3_bind_zeroblob64 |
| 104189 | + sqlite3_bind_zeroblob64, |
| 104190 | + /* Version 3.8.12 and later */ |
| 104191 | + sqlite3_value_subtype, |
| 104192 | + sqlite3_result_subtype |
| 103908 | 104193 | }; |
| 103909 | 104194 | |
| 103910 | 104195 | /* |
| 103911 | 104196 | ** Attempt to load an SQLite extension library contained in the file |
| 103912 | 104197 | ** zFile. The entry point is zProc. zProc may be 0 in which case a |
| | @@ -104898,25 +105183,51 @@ |
| 104898 | 105183 | } |
| 104899 | 105184 | db->temp_store = (u8)ts; |
| 104900 | 105185 | return SQLITE_OK; |
| 104901 | 105186 | } |
| 104902 | 105187 | #endif /* SQLITE_PAGER_PRAGMAS */ |
| 105188 | + |
| 105189 | +/* |
| 105190 | +** Set the names of the first N columns to the values in azCol[] |
| 105191 | +*/ |
| 105192 | +static void setAllColumnNames( |
| 105193 | + Vdbe *v, /* The query under construction */ |
| 105194 | + int N, /* Number of columns */ |
| 105195 | + const char **azCol /* Names of columns */ |
| 105196 | +){ |
| 105197 | + int i; |
| 105198 | + sqlite3VdbeSetNumCols(v, N); |
| 105199 | + for(i=0; i<N; i++){ |
| 105200 | + sqlite3VdbeSetColName(v, i, COLNAME_NAME, azCol[i], SQLITE_STATIC); |
| 105201 | + } |
| 105202 | +} |
| 105203 | +static void setOneColumnName(Vdbe *v, const char *z){ |
| 105204 | + setAllColumnNames(v, 1, &z); |
| 105205 | +} |
| 104903 | 105206 | |
| 104904 | 105207 | /* |
| 104905 | 105208 | ** Generate code to return a single integer value. |
| 104906 | 105209 | */ |
| 104907 | | -static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){ |
| 104908 | | - Vdbe *v = sqlite3GetVdbe(pParse); |
| 104909 | | - int nMem = ++pParse->nMem; |
| 104910 | | - i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value)); |
| 104911 | | - if( pI64 ){ |
| 104912 | | - memcpy(pI64, &value, sizeof(value)); |
| 104913 | | - } |
| 104914 | | - sqlite3VdbeAddOp4(v, OP_Int64, 0, nMem, 0, (char*)pI64, P4_INT64); |
| 104915 | | - sqlite3VdbeSetNumCols(v, 1); |
| 104916 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC); |
| 104917 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1); |
| 105210 | +static void returnSingleInt(Vdbe *v, const char *zLabel, i64 value){ |
| 105211 | + sqlite3VdbeAddOp4Dup8(v, OP_Int64, 0, 1, 0, (const u8*)&value, P4_INT64); |
| 105212 | + setOneColumnName(v, zLabel); |
| 105213 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 105214 | +} |
| 105215 | + |
| 105216 | +/* |
| 105217 | +** Generate code to return a single text value. |
| 105218 | +*/ |
| 105219 | +static void returnSingleText( |
| 105220 | + Vdbe *v, /* Prepared statement under construction */ |
| 105221 | + const char *zLabel, /* Name of the result column */ |
| 105222 | + const char *zValue /* Value to be returned */ |
| 105223 | +){ |
| 105224 | + if( zValue ){ |
| 105225 | + sqlite3VdbeLoadString(v, 1, (const char*)zValue); |
| 105226 | + setOneColumnName(v, zLabel); |
| 105227 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 105228 | + } |
| 104918 | 105229 | } |
| 104919 | 105230 | |
| 104920 | 105231 | |
| 104921 | 105232 | /* |
| 104922 | 105233 | ** Set the safety_level and pager flags for pager iDb. Or if iDb<0 |
| | @@ -105076,18 +105387,12 @@ |
| 105076 | 105387 | aFcntl[2] = zRight; |
| 105077 | 105388 | aFcntl[3] = 0; |
| 105078 | 105389 | db->busyHandler.nBusy = 0; |
| 105079 | 105390 | rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl); |
| 105080 | 105391 | if( rc==SQLITE_OK ){ |
| 105081 | | - if( aFcntl[0] ){ |
| 105082 | | - int nMem = ++pParse->nMem; |
| 105083 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, nMem, 0, aFcntl[0], 0); |
| 105084 | | - sqlite3VdbeSetNumCols(v, 1); |
| 105085 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC); |
| 105086 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1); |
| 105087 | | - sqlite3_free(aFcntl[0]); |
| 105088 | | - } |
| 105392 | + returnSingleText(v, "result", aFcntl[0]); |
| 105393 | + sqlite3_free(aFcntl[0]); |
| 105089 | 105394 | goto pragma_out; |
| 105090 | 105395 | } |
| 105091 | 105396 | if( rc!=SQLITE_NOTFOUND ){ |
| 105092 | 105397 | if( aFcntl[0] ){ |
| 105093 | 105398 | sqlite3ErrorMsg(pParse, "%s", aFcntl[0]); |
| | @@ -105153,12 +105458,11 @@ |
| 105153 | 105458 | { OP_ResultRow, 1, 1, 0}, |
| 105154 | 105459 | }; |
| 105155 | 105460 | int addr; |
| 105156 | 105461 | sqlite3VdbeUsesBtree(v, iDb); |
| 105157 | 105462 | if( !zRight ){ |
| 105158 | | - sqlite3VdbeSetNumCols(v, 1); |
| 105159 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cache_size", SQLITE_STATIC); |
| 105463 | + setOneColumnName(v, "cache_size"); |
| 105160 | 105464 | pParse->nMem += 2; |
| 105161 | 105465 | addr = sqlite3VdbeAddOpList(v, ArraySize(getCacheSize), getCacheSize,iLn); |
| 105162 | 105466 | sqlite3VdbeChangeP1(v, addr, iDb); |
| 105163 | 105467 | sqlite3VdbeChangeP1(v, addr+1, iDb); |
| 105164 | 105468 | sqlite3VdbeChangeP1(v, addr+6, SQLITE_DEFAULT_CACHE_SIZE); |
| | @@ -105188,11 +105492,11 @@ |
| 105188 | 105492 | case PragTyp_PAGE_SIZE: { |
| 105189 | 105493 | Btree *pBt = pDb->pBt; |
| 105190 | 105494 | assert( pBt!=0 ); |
| 105191 | 105495 | if( !zRight ){ |
| 105192 | 105496 | int size = ALWAYS(pBt) ? sqlite3BtreeGetPageSize(pBt) : 0; |
| 105193 | | - returnSingleInt(pParse, "page_size", size); |
| 105497 | + returnSingleInt(v, "page_size", size); |
| 105194 | 105498 | }else{ |
| 105195 | 105499 | /* Malloc may fail when setting the page-size, as there is an internal |
| 105196 | 105500 | ** buffer that the pager module resizes using sqlite3_realloc(). |
| 105197 | 105501 | */ |
| 105198 | 105502 | db->nextPagesize = sqlite3Atoi(zRight); |
| | @@ -105223,11 +105527,11 @@ |
| 105223 | 105527 | for(ii=0; ii<db->nDb; ii++){ |
| 105224 | 105528 | sqlite3BtreeSecureDelete(db->aDb[ii].pBt, b); |
| 105225 | 105529 | } |
| 105226 | 105530 | } |
| 105227 | 105531 | b = sqlite3BtreeSecureDelete(pBt, b); |
| 105228 | | - returnSingleInt(pParse, "secure_delete", b); |
| 105532 | + returnSingleInt(v, "secure_delete", b); |
| 105229 | 105533 | break; |
| 105230 | 105534 | } |
| 105231 | 105535 | |
| 105232 | 105536 | /* |
| 105233 | 105537 | ** PRAGMA [database.]max_page_count |
| | @@ -105302,14 +105606,11 @@ |
| 105302 | 105606 | assert( eMode==PAGER_LOCKINGMODE_NORMAL |
| 105303 | 105607 | || eMode==PAGER_LOCKINGMODE_EXCLUSIVE ); |
| 105304 | 105608 | if( eMode==PAGER_LOCKINGMODE_EXCLUSIVE ){ |
| 105305 | 105609 | zRet = "exclusive"; |
| 105306 | 105610 | } |
| 105307 | | - sqlite3VdbeSetNumCols(v, 1); |
| 105308 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "locking_mode", SQLITE_STATIC); |
| 105309 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zRet, 0); |
| 105310 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 105611 | + returnSingleText(v, "locking_mode", zRet); |
| 105311 | 105612 | break; |
| 105312 | 105613 | } |
| 105313 | 105614 | |
| 105314 | 105615 | /* |
| 105315 | 105616 | ** PRAGMA [database.]journal_mode |
| | @@ -105318,13 +105619,11 @@ |
| 105318 | 105619 | */ |
| 105319 | 105620 | case PragTyp_JOURNAL_MODE: { |
| 105320 | 105621 | int eMode; /* One of the PAGER_JOURNALMODE_XXX symbols */ |
| 105321 | 105622 | int ii; /* Loop counter */ |
| 105322 | 105623 | |
| 105323 | | - sqlite3VdbeSetNumCols(v, 1); |
| 105324 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", SQLITE_STATIC); |
| 105325 | | - |
| 105624 | + setOneColumnName(v, "journal_mode"); |
| 105326 | 105625 | if( zRight==0 ){ |
| 105327 | 105626 | /* If there is no "=MODE" part of the pragma, do a query for the |
| 105328 | 105627 | ** current mode */ |
| 105329 | 105628 | eMode = PAGER_JOURNALMODE_QUERY; |
| 105330 | 105629 | }else{ |
| | @@ -105366,11 +105665,11 @@ |
| 105366 | 105665 | if( zRight ){ |
| 105367 | 105666 | sqlite3DecOrHexToI64(zRight, &iLimit); |
| 105368 | 105667 | if( iLimit<-1 ) iLimit = -1; |
| 105369 | 105668 | } |
| 105370 | 105669 | iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); |
| 105371 | | - returnSingleInt(pParse, "journal_size_limit", iLimit); |
| 105670 | + returnSingleInt(v, "journal_size_limit", iLimit); |
| 105372 | 105671 | break; |
| 105373 | 105672 | } |
| 105374 | 105673 | |
| 105375 | 105674 | #endif /* SQLITE_OMIT_PAGER_PRAGMAS */ |
| 105376 | 105675 | |
| | @@ -105384,11 +105683,11 @@ |
| 105384 | 105683 | #ifndef SQLITE_OMIT_AUTOVACUUM |
| 105385 | 105684 | case PragTyp_AUTO_VACUUM: { |
| 105386 | 105685 | Btree *pBt = pDb->pBt; |
| 105387 | 105686 | assert( pBt!=0 ); |
| 105388 | 105687 | if( !zRight ){ |
| 105389 | | - returnSingleInt(pParse, "auto_vacuum", sqlite3BtreeGetAutoVacuum(pBt)); |
| 105688 | + returnSingleInt(v, "auto_vacuum", sqlite3BtreeGetAutoVacuum(pBt)); |
| 105390 | 105689 | }else{ |
| 105391 | 105690 | int eAuto = getAutoVacuum(zRight); |
| 105392 | 105691 | assert( eAuto>=0 && eAuto<=2 ); |
| 105393 | 105692 | db->nextAutovac = (u8)eAuto; |
| 105394 | 105693 | /* Call SetAutoVacuum() to set initialize the internal auto and |
| | @@ -105462,11 +105761,11 @@ |
| 105462 | 105761 | */ |
| 105463 | 105762 | case PragTyp_CACHE_SIZE: { |
| 105464 | 105763 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 105465 | 105764 | if( !zRight ){ |
| 105466 | 105765 | if( sqlite3ReadSchema(pParse) ) goto pragma_out; |
| 105467 | | - returnSingleInt(pParse, "cache_size", pDb->pSchema->cache_size); |
| 105766 | + returnSingleInt(v, "cache_size", pDb->pSchema->cache_size); |
| 105468 | 105767 | }else{ |
| 105469 | 105768 | int size = sqlite3Atoi(zRight); |
| 105470 | 105769 | pDb->pSchema->cache_size = size; |
| 105471 | 105770 | sqlite3BtreeSetCacheSize(pDb->pBt, pDb->pSchema->cache_size); |
| 105472 | 105771 | if( sqlite3ReadSchema(pParse) ) goto pragma_out; |
| | @@ -105508,11 +105807,11 @@ |
| 105508 | 105807 | #else |
| 105509 | 105808 | sz = 0; |
| 105510 | 105809 | rc = SQLITE_OK; |
| 105511 | 105810 | #endif |
| 105512 | 105811 | if( rc==SQLITE_OK ){ |
| 105513 | | - returnSingleInt(pParse, "mmap_size", sz); |
| 105812 | + returnSingleInt(v, "mmap_size", sz); |
| 105514 | 105813 | }else if( rc!=SQLITE_NOTFOUND ){ |
| 105515 | 105814 | pParse->nErr++; |
| 105516 | 105815 | pParse->rc = rc; |
| 105517 | 105816 | } |
| 105518 | 105817 | break; |
| | @@ -105529,11 +105828,11 @@ |
| 105529 | 105828 | ** Note that it is possible for the library compile-time options to |
| 105530 | 105829 | ** override this setting |
| 105531 | 105830 | */ |
| 105532 | 105831 | case PragTyp_TEMP_STORE: { |
| 105533 | 105832 | if( !zRight ){ |
| 105534 | | - returnSingleInt(pParse, "temp_store", db->temp_store); |
| 105833 | + returnSingleInt(v, "temp_store", db->temp_store); |
| 105535 | 105834 | }else{ |
| 105536 | 105835 | changeTempStorage(pParse, zRight); |
| 105537 | 105836 | } |
| 105538 | 105837 | break; |
| 105539 | 105838 | } |
| | @@ -105548,17 +105847,11 @@ |
| 105548 | 105847 | ** If temporary directory is changed, then invalidateTempStorage. |
| 105549 | 105848 | ** |
| 105550 | 105849 | */ |
| 105551 | 105850 | case PragTyp_TEMP_STORE_DIRECTORY: { |
| 105552 | 105851 | if( !zRight ){ |
| 105553 | | - if( sqlite3_temp_directory ){ |
| 105554 | | - sqlite3VdbeSetNumCols(v, 1); |
| 105555 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, |
| 105556 | | - "temp_store_directory", SQLITE_STATIC); |
| 105557 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_temp_directory, 0); |
| 105558 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 105559 | | - } |
| 105852 | + returnSingleText(v, "temp_store_directory", sqlite3_temp_directory); |
| 105560 | 105853 | }else{ |
| 105561 | 105854 | #ifndef SQLITE_OMIT_WSD |
| 105562 | 105855 | if( zRight[0] ){ |
| 105563 | 105856 | int res; |
| 105564 | 105857 | rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res); |
| | @@ -105598,17 +105891,11 @@ |
| 105598 | 105891 | ** by this setting, regardless of its value. |
| 105599 | 105892 | ** |
| 105600 | 105893 | */ |
| 105601 | 105894 | case PragTyp_DATA_STORE_DIRECTORY: { |
| 105602 | 105895 | if( !zRight ){ |
| 105603 | | - if( sqlite3_data_directory ){ |
| 105604 | | - sqlite3VdbeSetNumCols(v, 1); |
| 105605 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, |
| 105606 | | - "data_store_directory", SQLITE_STATIC); |
| 105607 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, sqlite3_data_directory, 0); |
| 105608 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 105609 | | - } |
| 105896 | + returnSingleText(v, "data_store_directory", sqlite3_data_directory); |
| 105610 | 105897 | }else{ |
| 105611 | 105898 | #ifndef SQLITE_OMIT_WSD |
| 105612 | 105899 | if( zRight[0] ){ |
| 105613 | 105900 | int res; |
| 105614 | 105901 | rc = sqlite3OsAccess(db->pVfs, zRight, SQLITE_ACCESS_READWRITE, &res); |
| | @@ -105643,18 +105930,11 @@ |
| 105643 | 105930 | Pager *pPager = sqlite3BtreePager(pDb->pBt); |
| 105644 | 105931 | char *proxy_file_path = NULL; |
| 105645 | 105932 | sqlite3_file *pFile = sqlite3PagerFile(pPager); |
| 105646 | 105933 | sqlite3OsFileControlHint(pFile, SQLITE_GET_LOCKPROXYFILE, |
| 105647 | 105934 | &proxy_file_path); |
| 105648 | | - |
| 105649 | | - if( proxy_file_path ){ |
| 105650 | | - sqlite3VdbeSetNumCols(v, 1); |
| 105651 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, |
| 105652 | | - "lock_proxy_file", SQLITE_STATIC); |
| 105653 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, proxy_file_path, 0); |
| 105654 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 105655 | | - } |
| 105935 | + returnSingleText(v, "lock_proxy_file", proxy_file_path); |
| 105656 | 105936 | }else{ |
| 105657 | 105937 | Pager *pPager = sqlite3BtreePager(pDb->pBt); |
| 105658 | 105938 | sqlite3_file *pFile = sqlite3PagerFile(pPager); |
| 105659 | 105939 | int res; |
| 105660 | 105940 | if( zRight[0] ){ |
| | @@ -105682,11 +105962,11 @@ |
| 105682 | 105962 | ** default value will be restored the next time the database is |
| 105683 | 105963 | ** opened. |
| 105684 | 105964 | */ |
| 105685 | 105965 | case PragTyp_SYNCHRONOUS: { |
| 105686 | 105966 | if( !zRight ){ |
| 105687 | | - returnSingleInt(pParse, "synchronous", pDb->safety_level-1); |
| 105967 | + returnSingleInt(v, "synchronous", pDb->safety_level-1); |
| 105688 | 105968 | }else{ |
| 105689 | 105969 | if( !db->autoCommit ){ |
| 105690 | 105970 | sqlite3ErrorMsg(pParse, |
| 105691 | 105971 | "Safety level may not be changed inside a transaction"); |
| 105692 | 105972 | }else{ |
| | @@ -105701,11 +105981,11 @@ |
| 105701 | 105981 | #endif /* SQLITE_OMIT_PAGER_PRAGMAS */ |
| 105702 | 105982 | |
| 105703 | 105983 | #ifndef SQLITE_OMIT_FLAG_PRAGMAS |
| 105704 | 105984 | case PragTyp_FLAG: { |
| 105705 | 105985 | if( zRight==0 ){ |
| 105706 | | - returnSingleInt(pParse, pPragma->zName, (db->flags & pPragma->iArg)!=0 ); |
| 105986 | + returnSingleInt(v, pPragma->zName, (db->flags & pPragma->iArg)!=0 ); |
| 105707 | 105987 | }else{ |
| 105708 | 105988 | int mask = pPragma->iArg; /* Mask of bits to set or clear. */ |
| 105709 | 105989 | if( db->autoCommit==0 ){ |
| 105710 | 105990 | /* Foreign key support may not be enabled or disabled while not |
| 105711 | 105991 | ** in auto-commit mode. */ |
| | @@ -105751,79 +106031,67 @@ |
| 105751 | 106031 | */ |
| 105752 | 106032 | case PragTyp_TABLE_INFO: if( zRight ){ |
| 105753 | 106033 | Table *pTab; |
| 105754 | 106034 | pTab = sqlite3FindTable(db, zRight, zDb); |
| 105755 | 106035 | if( pTab ){ |
| 106036 | + static const char *azCol[] = { |
| 106037 | + "cid", "name", "type", "notnull", "dflt_value", "pk" |
| 106038 | + }; |
| 105756 | 106039 | int i, k; |
| 105757 | 106040 | int nHidden = 0; |
| 105758 | 106041 | Column *pCol; |
| 105759 | 106042 | Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 105760 | | - sqlite3VdbeSetNumCols(v, 6); |
| 105761 | 106043 | pParse->nMem = 6; |
| 105762 | 106044 | sqlite3CodeVerifySchema(pParse, iDb); |
| 105763 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", SQLITE_STATIC); |
| 105764 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); |
| 105765 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "type", SQLITE_STATIC); |
| 105766 | | - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "notnull", SQLITE_STATIC); |
| 105767 | | - sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "dflt_value", SQLITE_STATIC); |
| 105768 | | - sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "pk", SQLITE_STATIC); |
| 106045 | + setAllColumnNames(v, 6, azCol); assert( 6==ArraySize(azCol) ); |
| 105769 | 106046 | sqlite3ViewGetColumnNames(pParse, pTab); |
| 105770 | 106047 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 105771 | 106048 | if( IsHiddenColumn(pCol) ){ |
| 105772 | 106049 | nHidden++; |
| 105773 | 106050 | continue; |
| 105774 | 106051 | } |
| 105775 | | - sqlite3VdbeAddOp2(v, OP_Integer, i-nHidden, 1); |
| 105776 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pCol->zName, 0); |
| 105777 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, |
| 105778 | | - pCol->zType ? pCol->zType : "", 0); |
| 105779 | | - sqlite3VdbeAddOp2(v, OP_Integer, (pCol->notNull ? 1 : 0), 4); |
| 105780 | | - if( pCol->zDflt ){ |
| 105781 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, (char*)pCol->zDflt, 0); |
| 105782 | | - }else{ |
| 105783 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, 5); |
| 105784 | | - } |
| 105785 | 106052 | if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){ |
| 105786 | 106053 | k = 0; |
| 105787 | 106054 | }else if( pPk==0 ){ |
| 105788 | 106055 | k = 1; |
| 105789 | 106056 | }else{ |
| 105790 | 106057 | for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} |
| 105791 | 106058 | } |
| 105792 | | - sqlite3VdbeAddOp2(v, OP_Integer, k, 6); |
| 106059 | + sqlite3VdbeMultiLoad(v, 1, "issisi", |
| 106060 | + i-nHidden, |
| 106061 | + pCol->zName, |
| 106062 | + pCol->zType ? pCol->zType : "", |
| 106063 | + pCol->notNull ? 1 : 0, |
| 106064 | + pCol->zDflt, |
| 106065 | + k); |
| 105793 | 106066 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); |
| 105794 | 106067 | } |
| 105795 | 106068 | } |
| 105796 | 106069 | } |
| 105797 | 106070 | break; |
| 105798 | 106071 | |
| 105799 | 106072 | case PragTyp_STATS: { |
| 106073 | + static const char *azCol[] = { "table", "index", "width", "height" }; |
| 105800 | 106074 | Index *pIdx; |
| 105801 | 106075 | HashElem *i; |
| 105802 | 106076 | v = sqlite3GetVdbe(pParse); |
| 105803 | | - sqlite3VdbeSetNumCols(v, 4); |
| 105804 | 106077 | pParse->nMem = 4; |
| 105805 | 106078 | sqlite3CodeVerifySchema(pParse, iDb); |
| 105806 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC); |
| 105807 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC); |
| 105808 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC); |
| 105809 | | - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC); |
| 106079 | + setAllColumnNames(v, 4, azCol); assert( 4==ArraySize(azCol) ); |
| 105810 | 106080 | for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){ |
| 105811 | 106081 | Table *pTab = sqliteHashData(i); |
| 105812 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0); |
| 105813 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, 2); |
| 105814 | | - sqlite3VdbeAddOp2(v, OP_Integer, |
| 105815 | | - (int)sqlite3LogEstToInt(pTab->szTabRow), 3); |
| 105816 | | - sqlite3VdbeAddOp2(v, OP_Integer, |
| 105817 | | - (int)sqlite3LogEstToInt(pTab->nRowLogEst), 4); |
| 106082 | + sqlite3VdbeMultiLoad(v, 1, "ssii", |
| 106083 | + pTab->zName, |
| 106084 | + 0, |
| 106085 | + (int)sqlite3LogEstToInt(pTab->szTabRow), |
| 106086 | + (int)sqlite3LogEstToInt(pTab->nRowLogEst)); |
| 105818 | 106087 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); |
| 105819 | 106088 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 105820 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); |
| 105821 | | - sqlite3VdbeAddOp2(v, OP_Integer, |
| 105822 | | - (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3); |
| 105823 | | - sqlite3VdbeAddOp2(v, OP_Integer, |
| 105824 | | - (int)sqlite3LogEstToInt(pIdx->aiRowLogEst[0]), 4); |
| 106089 | + sqlite3VdbeMultiLoad(v, 2, "sii", |
| 106090 | + pIdx->zName, |
| 106091 | + (int)sqlite3LogEstToInt(pIdx->szIdxRow), |
| 106092 | + (int)sqlite3LogEstToInt(pIdx->aiRowLogEst[0])); |
| 105825 | 106093 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); |
| 105826 | 106094 | } |
| 105827 | 106095 | } |
| 105828 | 106096 | } |
| 105829 | 106097 | break; |
| | @@ -105831,10 +106099,13 @@ |
| 105831 | 106099 | case PragTyp_INDEX_INFO: if( zRight ){ |
| 105832 | 106100 | Index *pIdx; |
| 105833 | 106101 | Table *pTab; |
| 105834 | 106102 | pIdx = sqlite3FindIndex(db, zRight, zDb); |
| 105835 | 106103 | if( pIdx ){ |
| 106104 | + static const char *azCol[] = { |
| 106105 | + "seqno", "cid", "name", "desc", "coll", "key" |
| 106106 | + }; |
| 105836 | 106107 | int i; |
| 105837 | 106108 | int mx; |
| 105838 | 106109 | if( pPragma->iArg ){ |
| 105839 | 106110 | /* PRAGMA index_xinfo (newer version with more rows and columns) */ |
| 105840 | 106111 | mx = pIdx->nColumn; |
| | @@ -105843,33 +106114,22 @@ |
| 105843 | 106114 | /* PRAGMA index_info (legacy version) */ |
| 105844 | 106115 | mx = pIdx->nKeyCol; |
| 105845 | 106116 | pParse->nMem = 3; |
| 105846 | 106117 | } |
| 105847 | 106118 | pTab = pIdx->pTable; |
| 105848 | | - sqlite3VdbeSetNumCols(v, pParse->nMem); |
| 105849 | 106119 | sqlite3CodeVerifySchema(pParse, iDb); |
| 105850 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC); |
| 105851 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC); |
| 105852 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC); |
| 105853 | | - if( pPragma->iArg ){ |
| 105854 | | - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC); |
| 105855 | | - sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC); |
| 105856 | | - sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC); |
| 105857 | | - } |
| 106120 | + assert( pParse->nMem<=ArraySize(azCol) ); |
| 106121 | + setAllColumnNames(v, pParse->nMem, azCol); |
| 105858 | 106122 | for(i=0; i<mx; i++){ |
| 105859 | 106123 | i16 cnum = pIdx->aiColumn[i]; |
| 105860 | | - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); |
| 105861 | | - sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2); |
| 105862 | | - if( cnum<0 ){ |
| 105863 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, 3); |
| 105864 | | - }else{ |
| 105865 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0); |
| 105866 | | - } |
| 106124 | + sqlite3VdbeMultiLoad(v, 1, "iis", i, cnum, |
| 106125 | + cnum<0 ? 0 : pTab->aCol[cnum].zName); |
| 105867 | 106126 | if( pPragma->iArg ){ |
| 105868 | | - sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4); |
| 105869 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0); |
| 105870 | | - sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6); |
| 106127 | + sqlite3VdbeMultiLoad(v, 4, "isi", |
| 106128 | + pIdx->aSortOrder[i], |
| 106129 | + pIdx->azColl[i], |
| 106130 | + i<pIdx->nKeyCol); |
| 105871 | 106131 | } |
| 105872 | 106132 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem); |
| 105873 | 106133 | } |
| 105874 | 106134 | } |
| 105875 | 106135 | } |
| | @@ -105879,62 +106139,57 @@ |
| 105879 | 106139 | Index *pIdx; |
| 105880 | 106140 | Table *pTab; |
| 105881 | 106141 | int i; |
| 105882 | 106142 | pTab = sqlite3FindTable(db, zRight, zDb); |
| 105883 | 106143 | if( pTab ){ |
| 106144 | + static const char *azCol[] = { |
| 106145 | + "seq", "name", "unique", "origin", "partial" |
| 106146 | + }; |
| 105884 | 106147 | v = sqlite3GetVdbe(pParse); |
| 105885 | | - sqlite3VdbeSetNumCols(v, 5); |
| 105886 | 106148 | pParse->nMem = 5; |
| 105887 | 106149 | sqlite3CodeVerifySchema(pParse, iDb); |
| 105888 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); |
| 105889 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); |
| 105890 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC); |
| 105891 | | - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "origin", SQLITE_STATIC); |
| 105892 | | - sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "partial", SQLITE_STATIC); |
| 106150 | + setAllColumnNames(v, 5, azCol); assert( 5==ArraySize(azCol) ); |
| 105893 | 106151 | for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){ |
| 105894 | 106152 | const char *azOrigin[] = { "c", "u", "pk" }; |
| 105895 | | - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); |
| 105896 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); |
| 105897 | | - sqlite3VdbeAddOp2(v, OP_Integer, IsUniqueIndex(pIdx), 3); |
| 105898 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, azOrigin[pIdx->idxType], 0); |
| 105899 | | - sqlite3VdbeAddOp2(v, OP_Integer, pIdx->pPartIdxWhere!=0, 5); |
| 106153 | + sqlite3VdbeMultiLoad(v, 1, "isisi", |
| 106154 | + i, |
| 106155 | + pIdx->zName, |
| 106156 | + IsUniqueIndex(pIdx), |
| 106157 | + azOrigin[pIdx->idxType], |
| 106158 | + pIdx->pPartIdxWhere!=0); |
| 105900 | 106159 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5); |
| 105901 | 106160 | } |
| 105902 | 106161 | } |
| 105903 | 106162 | } |
| 105904 | 106163 | break; |
| 105905 | 106164 | |
| 105906 | 106165 | case PragTyp_DATABASE_LIST: { |
| 106166 | + static const char *azCol[] = { "seq", "name", "file" }; |
| 105907 | 106167 | int i; |
| 105908 | | - sqlite3VdbeSetNumCols(v, 3); |
| 105909 | 106168 | pParse->nMem = 3; |
| 105910 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); |
| 105911 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); |
| 105912 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "file", SQLITE_STATIC); |
| 106169 | + setAllColumnNames(v, 3, azCol); assert( 3==ArraySize(azCol) ); |
| 105913 | 106170 | for(i=0; i<db->nDb; i++){ |
| 105914 | 106171 | if( db->aDb[i].pBt==0 ) continue; |
| 105915 | 106172 | assert( db->aDb[i].zName!=0 ); |
| 105916 | | - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); |
| 105917 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, db->aDb[i].zName, 0); |
| 105918 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, |
| 105919 | | - sqlite3BtreeGetFilename(db->aDb[i].pBt), 0); |
| 106173 | + sqlite3VdbeMultiLoad(v, 1, "iss", |
| 106174 | + i, |
| 106175 | + db->aDb[i].zName, |
| 106176 | + sqlite3BtreeGetFilename(db->aDb[i].pBt)); |
| 105920 | 106177 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); |
| 105921 | 106178 | } |
| 105922 | 106179 | } |
| 105923 | 106180 | break; |
| 105924 | 106181 | |
| 105925 | 106182 | case PragTyp_COLLATION_LIST: { |
| 106183 | + static const char *azCol[] = { "seq", "name" }; |
| 105926 | 106184 | int i = 0; |
| 105927 | 106185 | HashElem *p; |
| 105928 | | - sqlite3VdbeSetNumCols(v, 2); |
| 105929 | 106186 | pParse->nMem = 2; |
| 105930 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); |
| 105931 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); |
| 106187 | + setAllColumnNames(v, 2, azCol); assert( 2==ArraySize(azCol) ); |
| 105932 | 106188 | for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){ |
| 105933 | 106189 | CollSeq *pColl = (CollSeq *)sqliteHashData(p); |
| 105934 | | - sqlite3VdbeAddOp2(v, OP_Integer, i++, 1); |
| 105935 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pColl->zName, 0); |
| 106190 | + sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName); |
| 105936 | 106191 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2); |
| 105937 | 106192 | } |
| 105938 | 106193 | } |
| 105939 | 106194 | break; |
| 105940 | 106195 | #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */ |
| | @@ -105946,37 +106201,30 @@ |
| 105946 | 106201 | pTab = sqlite3FindTable(db, zRight, zDb); |
| 105947 | 106202 | if( pTab ){ |
| 105948 | 106203 | v = sqlite3GetVdbe(pParse); |
| 105949 | 106204 | pFK = pTab->pFKey; |
| 105950 | 106205 | if( pFK ){ |
| 106206 | + static const char *azCol[] = { |
| 106207 | + "id", "seq", "table", "from", "to", "on_update", "on_delete", |
| 106208 | + "match" |
| 106209 | + }; |
| 105951 | 106210 | int i = 0; |
| 105952 | | - sqlite3VdbeSetNumCols(v, 8); |
| 105953 | 106211 | pParse->nMem = 8; |
| 105954 | 106212 | sqlite3CodeVerifySchema(pParse, iDb); |
| 105955 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "id", SQLITE_STATIC); |
| 105956 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "seq", SQLITE_STATIC); |
| 105957 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "table", SQLITE_STATIC); |
| 105958 | | - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "from", SQLITE_STATIC); |
| 105959 | | - sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "to", SQLITE_STATIC); |
| 105960 | | - sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "on_update", SQLITE_STATIC); |
| 105961 | | - sqlite3VdbeSetColName(v, 6, COLNAME_NAME, "on_delete", SQLITE_STATIC); |
| 105962 | | - sqlite3VdbeSetColName(v, 7, COLNAME_NAME, "match", SQLITE_STATIC); |
| 106213 | + setAllColumnNames(v, 8, azCol); assert( 8==ArraySize(azCol) ); |
| 105963 | 106214 | while(pFK){ |
| 105964 | 106215 | int j; |
| 105965 | 106216 | for(j=0; j<pFK->nCol; j++){ |
| 105966 | | - char *zCol = pFK->aCol[j].zCol; |
| 105967 | | - char *zOnDelete = (char *)actionName(pFK->aAction[0]); |
| 105968 | | - char *zOnUpdate = (char *)actionName(pFK->aAction[1]); |
| 105969 | | - sqlite3VdbeAddOp2(v, OP_Integer, i, 1); |
| 105970 | | - sqlite3VdbeAddOp2(v, OP_Integer, j, 2); |
| 105971 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pFK->zTo, 0); |
| 105972 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, |
| 105973 | | - pTab->aCol[pFK->aCol[j].iFrom].zName, 0); |
| 105974 | | - sqlite3VdbeAddOp4(v, zCol ? OP_String8 : OP_Null, 0, 5, 0, zCol, 0); |
| 105975 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 6, 0, zOnUpdate, 0); |
| 105976 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 7, 0, zOnDelete, 0); |
| 105977 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 8, 0, "NONE", 0); |
| 106217 | + sqlite3VdbeMultiLoad(v, 1, "iissssss", |
| 106218 | + i, |
| 106219 | + j, |
| 106220 | + pFK->zTo, |
| 106221 | + pTab->aCol[pFK->aCol[j].iFrom].zName, |
| 106222 | + pFK->aCol[j].zCol, |
| 106223 | + actionName(pFK->aAction[1]), /* ON UPDATE */ |
| 106224 | + actionName(pFK->aAction[0]), /* ON DELETE */ |
| 106225 | + "NONE"); |
| 105978 | 106226 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8); |
| 105979 | 106227 | } |
| 105980 | 106228 | ++i; |
| 105981 | 106229 | pFK = pFK->pNextFrom; |
| 105982 | 106230 | } |
| | @@ -106001,21 +106249,18 @@ |
| 106001 | 106249 | int regKey; /* Register to hold key for checking the FK */ |
| 106002 | 106250 | int regRow; /* Registers to hold a row from pTab */ |
| 106003 | 106251 | int addrTop; /* Top of a loop checking foreign keys */ |
| 106004 | 106252 | int addrOk; /* Jump here if the key is OK */ |
| 106005 | 106253 | int *aiCols; /* child to parent column mapping */ |
| 106254 | + static const char *azCol[] = { "table", "rowid", "parent", "fkid" }; |
| 106006 | 106255 | |
| 106007 | 106256 | regResult = pParse->nMem+1; |
| 106008 | 106257 | pParse->nMem += 4; |
| 106009 | 106258 | regKey = ++pParse->nMem; |
| 106010 | 106259 | regRow = ++pParse->nMem; |
| 106011 | 106260 | v = sqlite3GetVdbe(pParse); |
| 106012 | | - sqlite3VdbeSetNumCols(v, 4); |
| 106013 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC); |
| 106014 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "rowid", SQLITE_STATIC); |
| 106015 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "parent", SQLITE_STATIC); |
| 106016 | | - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "fkid", SQLITE_STATIC); |
| 106261 | + setAllColumnNames(v, 4, azCol); assert( 4==ArraySize(azCol) ); |
| 106017 | 106262 | sqlite3CodeVerifySchema(pParse, iDb); |
| 106018 | 106263 | k = sqliteHashFirst(&db->aDb[iDb].pSchema->tblHash); |
| 106019 | 106264 | while( k ){ |
| 106020 | 106265 | if( zRight ){ |
| 106021 | 106266 | pTab = sqlite3LocateTable(pParse, 0, zRight, zDb); |
| | @@ -106026,12 +106271,11 @@ |
| 106026 | 106271 | } |
| 106027 | 106272 | if( pTab==0 || pTab->pFKey==0 ) continue; |
| 106028 | 106273 | sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName); |
| 106029 | 106274 | if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow; |
| 106030 | 106275 | sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead); |
| 106031 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName, |
| 106032 | | - P4_TRANSIENT); |
| 106276 | + sqlite3VdbeLoadString(v, regResult, pTab->zName); |
| 106033 | 106277 | for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ |
| 106034 | 106278 | pParent = sqlite3FindTable(db, pFK->zTo, zDb); |
| 106035 | 106279 | if( pParent==0 ) continue; |
| 106036 | 106280 | pIdx = 0; |
| 106037 | 106281 | sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName); |
| | @@ -106072,29 +106316,27 @@ |
| 106072 | 106316 | sqlite3VdbeCurrentAddr(v)+3); VdbeCoverage(v); |
| 106073 | 106317 | }else{ |
| 106074 | 106318 | sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); |
| 106075 | 106319 | } |
| 106076 | 106320 | sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); VdbeCoverage(v); |
| 106077 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk); |
| 106321 | + sqlite3VdbeGoto(v, addrOk); |
| 106078 | 106322 | sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
| 106079 | 106323 | }else{ |
| 106080 | 106324 | for(j=0; j<pFK->nCol; j++){ |
| 106081 | 106325 | sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, |
| 106082 | 106326 | aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j); |
| 106083 | 106327 | sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v); |
| 106084 | 106328 | } |
| 106085 | 106329 | if( pParent ){ |
| 106086 | 106330 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regRow, pFK->nCol, regKey, |
| 106087 | | - sqlite3IndexAffinityStr(v,pIdx), pFK->nCol); |
| 106331 | + sqlite3IndexAffinityStr(db,pIdx), pFK->nCol); |
| 106088 | 106332 | sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); |
| 106089 | 106333 | VdbeCoverage(v); |
| 106090 | 106334 | } |
| 106091 | 106335 | } |
| 106092 | 106336 | sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); |
| 106093 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0, |
| 106094 | | - pFK->zTo, P4_TRANSIENT); |
| 106095 | | - sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3); |
| 106337 | + sqlite3VdbeMultiLoad(v, regResult+2, "si", pFK->zTo, i-1); |
| 106096 | 106338 | sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, 4); |
| 106097 | 106339 | sqlite3VdbeResolveLabel(v, addrOk); |
| 106098 | 106340 | sqlite3DbFree(db, aiCols); |
| 106099 | 106341 | } |
| 106100 | 106342 | sqlite3VdbeAddOp2(v, OP_Next, 0, addrTop+1); VdbeCoverage(v); |
| | @@ -106166,12 +106408,11 @@ |
| 106166 | 106408 | assert( iDb==0 || pId2->z ); |
| 106167 | 106409 | if( pId2->z==0 ) iDb = -1; |
| 106168 | 106410 | |
| 106169 | 106411 | /* Initialize the VDBE program */ |
| 106170 | 106412 | pParse->nMem = 6; |
| 106171 | | - sqlite3VdbeSetNumCols(v, 1); |
| 106172 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "integrity_check", SQLITE_STATIC); |
| 106413 | + setOneColumnName(v, "integrity_check"); |
| 106173 | 106414 | |
| 106174 | 106415 | /* Set the maximum error count */ |
| 106175 | 106416 | mxErr = SQLITE_INTEGRITY_CHECK_ERROR_MAX; |
| 106176 | 106417 | if( zRight ){ |
| 106177 | 106418 | sqlite3GetInt32(zRight, &mxErr); |
| | @@ -106289,17 +106530,15 @@ |
| 106289 | 106530 | sqlite3VdbeAddOp2(v, OP_AddImm, 8+j, 1); /* increment entry count */ |
| 106290 | 106531 | /* Verify that an index entry exists for the current table row */ |
| 106291 | 106532 | jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, iIdxCur+j, ckUniq, r1, |
| 106292 | 106533 | pIdx->nColumn); VdbeCoverage(v); |
| 106293 | 106534 | sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */ |
| 106294 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, "row ", P4_STATIC); |
| 106535 | + sqlite3VdbeLoadString(v, 3, "row "); |
| 106295 | 106536 | sqlite3VdbeAddOp3(v, OP_Concat, 7, 3, 3); |
| 106296 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, |
| 106297 | | - " missing from index ", P4_STATIC); |
| 106537 | + sqlite3VdbeLoadString(v, 4, " missing from index "); |
| 106298 | 106538 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 106299 | | - jmp5 = sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, |
| 106300 | | - pIdx->zName, P4_TRANSIENT); |
| 106539 | + jmp5 = sqlite3VdbeLoadString(v, 4, pIdx->zName); |
| 106301 | 106540 | sqlite3VdbeAddOp3(v, OP_Concat, 4, 3, 3); |
| 106302 | 106541 | sqlite3VdbeAddOp2(v, OP_ResultRow, 3, 1); |
| 106303 | 106542 | jmp4 = sqlite3VdbeAddOp1(v, OP_IfPos, 1); VdbeCoverage(v); |
| 106304 | 106543 | sqlite3VdbeAddOp0(v, OP_Halt); |
| 106305 | 106544 | sqlite3VdbeJumpHere(v, jmp2); |
| | @@ -106316,38 +106555,36 @@ |
| 106316 | 106555 | if( pTab->aCol[iCol].notNull ) continue; |
| 106317 | 106556 | sqlite3VdbeAddOp2(v, OP_IsNull, r1+kk, uniqOk); |
| 106318 | 106557 | VdbeCoverage(v); |
| 106319 | 106558 | } |
| 106320 | 106559 | jmp6 = sqlite3VdbeAddOp1(v, OP_Next, iIdxCur+j); VdbeCoverage(v); |
| 106321 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, uniqOk); |
| 106560 | + sqlite3VdbeGoto(v, uniqOk); |
| 106322 | 106561 | sqlite3VdbeJumpHere(v, jmp6); |
| 106323 | 106562 | sqlite3VdbeAddOp4Int(v, OP_IdxGT, iIdxCur+j, uniqOk, r1, |
| 106324 | 106563 | pIdx->nKeyCol); VdbeCoverage(v); |
| 106325 | 106564 | sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); /* Decrement error limit */ |
| 106326 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, |
| 106327 | | - "non-unique entry in index ", P4_STATIC); |
| 106328 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, jmp5); |
| 106565 | + sqlite3VdbeLoadString(v, 3, "non-unique entry in index "); |
| 106566 | + sqlite3VdbeGoto(v, jmp5); |
| 106329 | 106567 | sqlite3VdbeResolveLabel(v, uniqOk); |
| 106330 | 106568 | } |
| 106331 | 106569 | sqlite3VdbeJumpHere(v, jmp4); |
| 106332 | 106570 | sqlite3ResolvePartIdxLabel(pParse, jmp3); |
| 106333 | 106571 | } |
| 106334 | 106572 | sqlite3VdbeAddOp2(v, OP_Next, iDataCur, loopTop); VdbeCoverage(v); |
| 106335 | 106573 | sqlite3VdbeJumpHere(v, loopTop-1); |
| 106336 | 106574 | #ifndef SQLITE_OMIT_BTREECOUNT |
| 106337 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, |
| 106338 | | - "wrong # of entries in index ", P4_STATIC); |
| 106575 | + sqlite3VdbeLoadString(v, 2, "wrong # of entries in index "); |
| 106339 | 106576 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 106340 | 106577 | if( pPk==pIdx ) continue; |
| 106341 | 106578 | addr = sqlite3VdbeCurrentAddr(v); |
| 106342 | 106579 | sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2); VdbeCoverage(v); |
| 106343 | 106580 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 106344 | 106581 | sqlite3VdbeAddOp2(v, OP_Count, iIdxCur+j, 3); |
| 106345 | 106582 | sqlite3VdbeAddOp3(v, OP_Eq, 8+j, addr+8, 3); VdbeCoverage(v); |
| 106346 | 106583 | sqlite3VdbeChangeP5(v, SQLITE_NOTNULL); |
| 106347 | 106584 | sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); |
| 106348 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT); |
| 106585 | + sqlite3VdbeLoadString(v, 3, pIdx->zName); |
| 106349 | 106586 | sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7); |
| 106350 | 106587 | sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1); |
| 106351 | 106588 | } |
| 106352 | 106589 | #endif /* SQLITE_OMIT_BTREECOUNT */ |
| 106353 | 106590 | } |
| | @@ -106399,18 +106636,14 @@ |
| 106399 | 106636 | { 0, 0 } |
| 106400 | 106637 | }; |
| 106401 | 106638 | const struct EncName *pEnc; |
| 106402 | 106639 | if( !zRight ){ /* "PRAGMA encoding" */ |
| 106403 | 106640 | if( sqlite3ReadSchema(pParse) ) goto pragma_out; |
| 106404 | | - sqlite3VdbeSetNumCols(v, 1); |
| 106405 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "encoding", SQLITE_STATIC); |
| 106406 | | - sqlite3VdbeAddOp2(v, OP_String8, 0, 1); |
| 106407 | 106641 | assert( encnames[SQLITE_UTF8].enc==SQLITE_UTF8 ); |
| 106408 | 106642 | assert( encnames[SQLITE_UTF16LE].enc==SQLITE_UTF16LE ); |
| 106409 | 106643 | assert( encnames[SQLITE_UTF16BE].enc==SQLITE_UTF16BE ); |
| 106410 | | - sqlite3VdbeChangeP4(v, -1, encnames[ENC(pParse->db)].zName, P4_STATIC); |
| 106411 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 106644 | + returnSingleText(v, "encoding", encnames[ENC(pParse->db)].zName); |
| 106412 | 106645 | }else{ /* "PRAGMA encoding = XXX" */ |
| 106413 | 106646 | /* Only change the value of sqlite.enc if the database handle is not |
| 106414 | 106647 | ** initialized. If the main database exists, the new sqlite.enc value |
| 106415 | 106648 | ** will be overwritten when the schema is next loaded. If it does not |
| 106416 | 106649 | ** already exists, it will be created to use the new encoding value. |
| | @@ -106507,15 +106740,14 @@ |
| 106507 | 106740 | ** one option per row. |
| 106508 | 106741 | */ |
| 106509 | 106742 | case PragTyp_COMPILE_OPTIONS: { |
| 106510 | 106743 | int i = 0; |
| 106511 | 106744 | const char *zOpt; |
| 106512 | | - sqlite3VdbeSetNumCols(v, 1); |
| 106513 | 106745 | pParse->nMem = 1; |
| 106514 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "compile_option", SQLITE_STATIC); |
| 106746 | + setOneColumnName(v, "compile_option"); |
| 106515 | 106747 | while( (zOpt = sqlite3_compileoption_get(i++))!=0 ){ |
| 106516 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zOpt, 0); |
| 106748 | + sqlite3VdbeLoadString(v, 1, zOpt); |
| 106517 | 106749 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); |
| 106518 | 106750 | } |
| 106519 | 106751 | } |
| 106520 | 106752 | break; |
| 106521 | 106753 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ |
| | @@ -106525,10 +106757,11 @@ |
| 106525 | 106757 | ** PRAGMA [database.]wal_checkpoint = passive|full|restart|truncate |
| 106526 | 106758 | ** |
| 106527 | 106759 | ** Checkpoint the database. |
| 106528 | 106760 | */ |
| 106529 | 106761 | case PragTyp_WAL_CHECKPOINT: { |
| 106762 | + static const char *azCol[] = { "busy", "log", "checkpointed" }; |
| 106530 | 106763 | int iBt = (pId2->z?iDb:SQLITE_MAX_ATTACHED); |
| 106531 | 106764 | int eMode = SQLITE_CHECKPOINT_PASSIVE; |
| 106532 | 106765 | if( zRight ){ |
| 106533 | 106766 | if( sqlite3StrICmp(zRight, "full")==0 ){ |
| 106534 | 106767 | eMode = SQLITE_CHECKPOINT_FULL; |
| | @@ -106536,16 +106769,12 @@ |
| 106536 | 106769 | eMode = SQLITE_CHECKPOINT_RESTART; |
| 106537 | 106770 | }else if( sqlite3StrICmp(zRight, "truncate")==0 ){ |
| 106538 | 106771 | eMode = SQLITE_CHECKPOINT_TRUNCATE; |
| 106539 | 106772 | } |
| 106540 | 106773 | } |
| 106541 | | - sqlite3VdbeSetNumCols(v, 3); |
| 106774 | + setAllColumnNames(v, 3, azCol); assert( 3==ArraySize(azCol) ); |
| 106542 | 106775 | pParse->nMem = 3; |
| 106543 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "busy", SQLITE_STATIC); |
| 106544 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "log", SQLITE_STATIC); |
| 106545 | | - sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "checkpointed", SQLITE_STATIC); |
| 106546 | | - |
| 106547 | 106776 | sqlite3VdbeAddOp3(v, OP_Checkpoint, iBt, eMode, 1); |
| 106548 | 106777 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); |
| 106549 | 106778 | } |
| 106550 | 106779 | break; |
| 106551 | 106780 | |
| | @@ -106559,11 +106788,11 @@ |
| 106559 | 106788 | */ |
| 106560 | 106789 | case PragTyp_WAL_AUTOCHECKPOINT: { |
| 106561 | 106790 | if( zRight ){ |
| 106562 | 106791 | sqlite3_wal_autocheckpoint(db, sqlite3Atoi(zRight)); |
| 106563 | 106792 | } |
| 106564 | | - returnSingleInt(pParse, "wal_autocheckpoint", |
| 106793 | + returnSingleInt(v, "wal_autocheckpoint", |
| 106565 | 106794 | db->xWalCallback==sqlite3WalDefaultHook ? |
| 106566 | 106795 | SQLITE_PTR_TO_INT(db->pWalArg) : 0); |
| 106567 | 106796 | } |
| 106568 | 106797 | break; |
| 106569 | 106798 | #endif |
| | @@ -106592,11 +106821,11 @@ |
| 106592 | 106821 | /*case PragTyp_BUSY_TIMEOUT*/ default: { |
| 106593 | 106822 | assert( pPragma->ePragTyp==PragTyp_BUSY_TIMEOUT ); |
| 106594 | 106823 | if( zRight ){ |
| 106595 | 106824 | sqlite3_busy_timeout(db, sqlite3Atoi(zRight)); |
| 106596 | 106825 | } |
| 106597 | | - returnSingleInt(pParse, "timeout", db->busyTimeout); |
| 106826 | + returnSingleInt(v, "timeout", db->busyTimeout); |
| 106598 | 106827 | break; |
| 106599 | 106828 | } |
| 106600 | 106829 | |
| 106601 | 106830 | /* |
| 106602 | 106831 | ** PRAGMA soft_heap_limit |
| | @@ -106612,11 +106841,11 @@ |
| 106612 | 106841 | case PragTyp_SOFT_HEAP_LIMIT: { |
| 106613 | 106842 | sqlite3_int64 N; |
| 106614 | 106843 | if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){ |
| 106615 | 106844 | sqlite3_soft_heap_limit64(N); |
| 106616 | 106845 | } |
| 106617 | | - returnSingleInt(pParse, "soft_heap_limit", sqlite3_soft_heap_limit64(-1)); |
| 106846 | + returnSingleInt(v, "soft_heap_limit", sqlite3_soft_heap_limit64(-1)); |
| 106618 | 106847 | break; |
| 106619 | 106848 | } |
| 106620 | 106849 | |
| 106621 | 106850 | /* |
| 106622 | 106851 | ** PRAGMA threads |
| | @@ -106631,11 +106860,11 @@ |
| 106631 | 106860 | && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK |
| 106632 | 106861 | && N>=0 |
| 106633 | 106862 | ){ |
| 106634 | 106863 | sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, (int)(N&0x7fffffff)); |
| 106635 | 106864 | } |
| 106636 | | - returnSingleInt(pParse, "threads", |
| 106865 | + returnSingleInt(v, "threads", |
| 106637 | 106866 | sqlite3_limit(db, SQLITE_LIMIT_WORKER_THREADS, -1)); |
| 106638 | 106867 | break; |
| 106639 | 106868 | } |
| 106640 | 106869 | |
| 106641 | 106870 | #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) |
| | @@ -106644,29 +106873,27 @@ |
| 106644 | 106873 | */ |
| 106645 | 106874 | case PragTyp_LOCK_STATUS: { |
| 106646 | 106875 | static const char *const azLockName[] = { |
| 106647 | 106876 | "unlocked", "shared", "reserved", "pending", "exclusive" |
| 106648 | 106877 | }; |
| 106878 | + static const char *azCol[] = { "database", "status" }; |
| 106649 | 106879 | int i; |
| 106650 | | - sqlite3VdbeSetNumCols(v, 2); |
| 106880 | + setAllColumnNames(v, 2, azCol); assert( 2==ArraySize(azCol) ); |
| 106651 | 106881 | pParse->nMem = 2; |
| 106652 | | - sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC); |
| 106653 | | - sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", SQLITE_STATIC); |
| 106654 | 106882 | for(i=0; i<db->nDb; i++){ |
| 106655 | 106883 | Btree *pBt; |
| 106656 | 106884 | const char *zState = "unknown"; |
| 106657 | 106885 | int j; |
| 106658 | 106886 | if( db->aDb[i].zName==0 ) continue; |
| 106659 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db->aDb[i].zName, P4_STATIC); |
| 106660 | 106887 | pBt = db->aDb[i].pBt; |
| 106661 | 106888 | if( pBt==0 || sqlite3BtreePager(pBt)==0 ){ |
| 106662 | 106889 | zState = "closed"; |
| 106663 | 106890 | }else if( sqlite3_file_control(db, i ? db->aDb[i].zName : 0, |
| 106664 | 106891 | SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){ |
| 106665 | 106892 | zState = azLockName[j]; |
| 106666 | 106893 | } |
| 106667 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, zState, P4_STATIC); |
| 106894 | + sqlite3VdbeMultiLoad(v, 1, "ss", db->aDb[i].zName, zState); |
| 106668 | 106895 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2); |
| 106669 | 106896 | } |
| 106670 | 106897 | break; |
| 106671 | 106898 | } |
| 106672 | 106899 | #endif |
| | @@ -108027,16 +108254,16 @@ |
| 108027 | 108254 | Table *pLeftTab = pLeft->pTab; |
| 108028 | 108255 | Table *pRightTab = pRight->pTab; |
| 108029 | 108256 | int isOuter; |
| 108030 | 108257 | |
| 108031 | 108258 | if( NEVER(pLeftTab==0 || pRightTab==0) ) continue; |
| 108032 | | - isOuter = (pRight->jointype & JT_OUTER)!=0; |
| 108259 | + isOuter = (pRight->fg.jointype & JT_OUTER)!=0; |
| 108033 | 108260 | |
| 108034 | 108261 | /* When the NATURAL keyword is present, add WHERE clause terms for |
| 108035 | 108262 | ** every column that the two tables have in common. |
| 108036 | 108263 | */ |
| 108037 | | - if( pRight->jointype & JT_NATURAL ){ |
| 108264 | + if( pRight->fg.jointype & JT_NATURAL ){ |
| 108038 | 108265 | if( pRight->pOn || pRight->pUsing ){ |
| 108039 | 108266 | sqlite3ErrorMsg(pParse, "a NATURAL join may not have " |
| 108040 | 108267 | "an ON or USING clause", 0); |
| 108041 | 108268 | return 1; |
| 108042 | 108269 | } |
| | @@ -108117,10 +108344,11 @@ |
| 108117 | 108344 | static void pushOntoSorter( |
| 108118 | 108345 | Parse *pParse, /* Parser context */ |
| 108119 | 108346 | SortCtx *pSort, /* Information about the ORDER BY clause */ |
| 108120 | 108347 | Select *pSelect, /* The whole SELECT statement */ |
| 108121 | 108348 | int regData, /* First register holding data to be sorted */ |
| 108349 | + int regOrigData, /* First register holding data before packing */ |
| 108122 | 108350 | int nData, /* Number of elements in the data array */ |
| 108123 | 108351 | int nPrefixReg /* No. of reg prior to regData available for use */ |
| 108124 | 108352 | ){ |
| 108125 | 108353 | Vdbe *v = pParse->pVdbe; /* Stmt under construction */ |
| 108126 | 108354 | int bSeq = ((pSort->sortFlags & SORTFLAG_UseSorter)==0); |
| | @@ -108130,18 +108358,20 @@ |
| 108130 | 108358 | int regRecord = ++pParse->nMem; /* Assembled sorter record */ |
| 108131 | 108359 | int nOBSat = pSort->nOBSat; /* ORDER BY terms to skip */ |
| 108132 | 108360 | int op; /* Opcode to add sorter record to sorter */ |
| 108133 | 108361 | |
| 108134 | 108362 | assert( bSeq==0 || bSeq==1 ); |
| 108363 | + assert( nData==1 || regData==regOrigData ); |
| 108135 | 108364 | if( nPrefixReg ){ |
| 108136 | 108365 | assert( nPrefixReg==nExpr+bSeq ); |
| 108137 | 108366 | regBase = regData - nExpr - bSeq; |
| 108138 | 108367 | }else{ |
| 108139 | 108368 | regBase = pParse->nMem + 1; |
| 108140 | 108369 | pParse->nMem += nBase; |
| 108141 | 108370 | } |
| 108142 | | - sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, SQLITE_ECEL_DUP); |
| 108371 | + sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData, |
| 108372 | + SQLITE_ECEL_DUP|SQLITE_ECEL_REF); |
| 108143 | 108373 | if( bSeq ){ |
| 108144 | 108374 | sqlite3VdbeAddOp2(v, OP_Sequence, pSort->iECursor, regBase+nExpr); |
| 108145 | 108375 | } |
| 108146 | 108376 | if( nPrefixReg==0 ){ |
| 108147 | 108377 | sqlite3ExprCodeMove(pParse, regData, regBase+nExpr+bSeq, nData); |
| | @@ -108215,11 +108445,11 @@ |
| 108215 | 108445 | int iContinue /* Jump here to skip the current record */ |
| 108216 | 108446 | ){ |
| 108217 | 108447 | if( iOffset>0 ){ |
| 108218 | 108448 | int addr; |
| 108219 | 108449 | addr = sqlite3VdbeAddOp3(v, OP_IfNeg, iOffset, 0, -1); VdbeCoverage(v); |
| 108220 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, iContinue); |
| 108450 | + sqlite3VdbeGoto(v, iContinue); |
| 108221 | 108451 | VdbeComment((v, "skip OFFSET records")); |
| 108222 | 108452 | sqlite3VdbeJumpHere(v, addr); |
| 108223 | 108453 | } |
| 108224 | 108454 | } |
| 108225 | 108455 | |
| | @@ -108347,11 +108577,11 @@ |
| 108347 | 108577 | if( eDest==SRT_Mem || eDest==SRT_Output || eDest==SRT_Coroutine ){ |
| 108348 | 108578 | ecelFlags = SQLITE_ECEL_DUP; |
| 108349 | 108579 | }else{ |
| 108350 | 108580 | ecelFlags = 0; |
| 108351 | 108581 | } |
| 108352 | | - sqlite3ExprCodeExprList(pParse, pEList, regResult, ecelFlags); |
| 108582 | + sqlite3ExprCodeExprList(pParse, pEList, regResult, 0, ecelFlags); |
| 108353 | 108583 | } |
| 108354 | 108584 | |
| 108355 | 108585 | /* If the DISTINCT keyword was present on the SELECT statement |
| 108356 | 108586 | ** and this row has been seen before, then do not make this row |
| 108357 | 108587 | ** part of the result. |
| | @@ -108463,11 +108693,11 @@ |
| 108463 | 108693 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm+1, r1); |
| 108464 | 108694 | assert( pSort==0 ); |
| 108465 | 108695 | } |
| 108466 | 108696 | #endif |
| 108467 | 108697 | if( pSort ){ |
| 108468 | | - pushOntoSorter(pParse, pSort, p, r1+nPrefixReg, 1, nPrefixReg); |
| 108698 | + pushOntoSorter(pParse, pSort, p, r1+nPrefixReg,regResult,1,nPrefixReg); |
| 108469 | 108699 | }else{ |
| 108470 | 108700 | int r2 = sqlite3GetTempReg(pParse); |
| 108471 | 108701 | sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, r2); |
| 108472 | 108702 | sqlite3VdbeAddOp3(v, OP_Insert, iParm, r1, r2); |
| 108473 | 108703 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| | @@ -108489,11 +108719,11 @@ |
| 108489 | 108719 | if( pSort ){ |
| 108490 | 108720 | /* At first glance you would think we could optimize out the |
| 108491 | 108721 | ** ORDER BY in this case since the order of entries in the set |
| 108492 | 108722 | ** does not matter. But there might be a LIMIT clause, in which |
| 108493 | 108723 | ** case the order does matter */ |
| 108494 | | - pushOntoSorter(pParse, pSort, p, regResult, 1, nPrefixReg); |
| 108724 | + pushOntoSorter(pParse, pSort, p, regResult, regResult, 1, nPrefixReg); |
| 108495 | 108725 | }else{ |
| 108496 | 108726 | int r1 = sqlite3GetTempReg(pParse); |
| 108497 | 108727 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regResult,1,r1, &pDest->affSdst, 1); |
| 108498 | 108728 | sqlite3ExprCacheAffinityChange(pParse, regResult, 1); |
| 108499 | 108729 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iParm, r1); |
| | @@ -108515,11 +108745,11 @@ |
| 108515 | 108745 | ** of the scan loop. |
| 108516 | 108746 | */ |
| 108517 | 108747 | case SRT_Mem: { |
| 108518 | 108748 | assert( nResultCol==1 ); |
| 108519 | 108749 | if( pSort ){ |
| 108520 | | - pushOntoSorter(pParse, pSort, p, regResult, 1, nPrefixReg); |
| 108750 | + pushOntoSorter(pParse, pSort, p, regResult, regResult, 1, nPrefixReg); |
| 108521 | 108751 | }else{ |
| 108522 | 108752 | assert( regResult==iParm ); |
| 108523 | 108753 | /* The LIMIT clause will jump out of the loop for us */ |
| 108524 | 108754 | } |
| 108525 | 108755 | break; |
| | @@ -108529,11 +108759,12 @@ |
| 108529 | 108759 | case SRT_Coroutine: /* Send data to a co-routine */ |
| 108530 | 108760 | case SRT_Output: { /* Return the results */ |
| 108531 | 108761 | testcase( eDest==SRT_Coroutine ); |
| 108532 | 108762 | testcase( eDest==SRT_Output ); |
| 108533 | 108763 | if( pSort ){ |
| 108534 | | - pushOntoSorter(pParse, pSort, p, regResult, nResultCol, nPrefixReg); |
| 108764 | + pushOntoSorter(pParse, pSort, p, regResult, regResult, nResultCol, |
| 108765 | + nPrefixReg); |
| 108535 | 108766 | }else if( eDest==SRT_Coroutine ){ |
| 108536 | 108767 | sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm); |
| 108537 | 108768 | }else{ |
| 108538 | 108769 | sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nResultCol); |
| 108539 | 108770 | sqlite3ExprCacheAffinityChange(pParse, regResult, nResultCol); |
| | @@ -108823,11 +109054,11 @@ |
| 108823 | 109054 | struct ExprList_item *aOutEx = p->pEList->a; |
| 108824 | 109055 | #endif |
| 108825 | 109056 | |
| 108826 | 109057 | if( pSort->labelBkOut ){ |
| 108827 | 109058 | sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut); |
| 108828 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrBreak); |
| 109059 | + sqlite3VdbeGoto(v, addrBreak); |
| 108829 | 109060 | sqlite3VdbeResolveLabel(v, pSort->labelBkOut); |
| 108830 | 109061 | } |
| 108831 | 109062 | iTab = pSort->iECursor; |
| 108832 | 109063 | if( eDest==SRT_Output || eDest==SRT_Coroutine ){ |
| 108833 | 109064 | regRowid = 0; |
| | @@ -109208,11 +109439,11 @@ |
| 109208 | 109439 | ** and other fields of Column are zeroed. |
| 109209 | 109440 | ** |
| 109210 | 109441 | ** Return SQLITE_OK on success. If a memory allocation error occurs, |
| 109211 | 109442 | ** store NULL in *paCol and 0 in *pnCol and return SQLITE_NOMEM. |
| 109212 | 109443 | */ |
| 109213 | | -static int selectColumnsFromExprList( |
| 109444 | +SQLITE_PRIVATE int sqlite3ColumnsFromExprList( |
| 109214 | 109445 | Parse *pParse, /* Parsing context */ |
| 109215 | 109446 | ExprList *pEList, /* Expr list from which to derive column names */ |
| 109216 | 109447 | i16 *pnCol, /* Write the number of columns here */ |
| 109217 | 109448 | Column **paCol /* Write the new column list here */ |
| 109218 | 109449 | ){ |
| | @@ -109375,11 +109606,11 @@ |
| 109375 | 109606 | ** is disabled */ |
| 109376 | 109607 | assert( db->lookaside.bEnabled==0 ); |
| 109377 | 109608 | pTab->nRef = 1; |
| 109378 | 109609 | pTab->zName = 0; |
| 109379 | 109610 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| 109380 | | - selectColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol); |
| 109611 | + sqlite3ColumnsFromExprList(pParse, pSelect->pEList, &pTab->nCol, &pTab->aCol); |
| 109381 | 109612 | selectAddColumnTypeAndCollation(pParse, pTab, pSelect); |
| 109382 | 109613 | pTab->iPKey = -1; |
| 109383 | 109614 | if( db->mallocFailed ){ |
| 109384 | 109615 | sqlite3DeleteTable(db, pTab); |
| 109385 | 109616 | return 0; |
| | @@ -109451,11 +109682,11 @@ |
| 109451 | 109682 | assert( v!=0 ); |
| 109452 | 109683 | if( sqlite3ExprIsInteger(p->pLimit, &n) ){ |
| 109453 | 109684 | sqlite3VdbeAddOp2(v, OP_Integer, n, iLimit); |
| 109454 | 109685 | VdbeComment((v, "LIMIT counter")); |
| 109455 | 109686 | if( n==0 ){ |
| 109456 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, iBreak); |
| 109687 | + sqlite3VdbeGoto(v, iBreak); |
| 109457 | 109688 | }else if( n>=0 && p->nSelectRow>(u64)n ){ |
| 109458 | 109689 | p->nSelectRow = n; |
| 109459 | 109690 | } |
| 109460 | 109691 | }else{ |
| 109461 | 109692 | sqlite3ExprCode(pParse, p->pLimit, iLimit); |
| | @@ -109554,11 +109785,11 @@ |
| 109554 | 109785 | ** \___________/ \_______________/ |
| 109555 | 109786 | ** p->pPrior p |
| 109556 | 109787 | ** |
| 109557 | 109788 | ** |
| 109558 | 109789 | ** There is exactly one reference to the recursive-table in the FROM clause |
| 109559 | | -** of recursive-query, marked with the SrcList->a[].isRecursive flag. |
| 109790 | +** of recursive-query, marked with the SrcList->a[].fg.isRecursive flag. |
| 109560 | 109791 | ** |
| 109561 | 109792 | ** The setup-query runs once to generate an initial set of rows that go |
| 109562 | 109793 | ** into a Queue table. Rows are extracted from the Queue table one by |
| 109563 | 109794 | ** one. Each row extracted from Queue is output to pDest. Then the single |
| 109564 | 109795 | ** extracted row (now in the iCurrent table) becomes the content of the |
| | @@ -109619,11 +109850,11 @@ |
| 109619 | 109850 | p->iLimit = p->iOffset = 0; |
| 109620 | 109851 | pOrderBy = p->pOrderBy; |
| 109621 | 109852 | |
| 109622 | 109853 | /* Locate the cursor number of the Current table */ |
| 109623 | 109854 | for(i=0; ALWAYS(i<pSrc->nSrc); i++){ |
| 109624 | | - if( pSrc->a[i].isRecursive ){ |
| 109855 | + if( pSrc->a[i].fg.isRecursive ){ |
| 109625 | 109856 | iCurrent = pSrc->a[i].iCursor; |
| 109626 | 109857 | break; |
| 109627 | 109858 | } |
| 109628 | 109859 | } |
| 109629 | 109860 | |
| | @@ -109699,11 +109930,11 @@ |
| 109699 | 109930 | assert( p->pPrior==0 ); |
| 109700 | 109931 | p->pPrior = pSetup; |
| 109701 | 109932 | } |
| 109702 | 109933 | |
| 109703 | 109934 | /* Keep running the loop until the Queue is empty */ |
| 109704 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop); |
| 109935 | + sqlite3VdbeGoto(v, addrTop); |
| 109705 | 109936 | sqlite3VdbeResolveLabel(v, addrBreak); |
| 109706 | 109937 | |
| 109707 | 109938 | end_of_recursive_query: |
| 109708 | 109939 | sqlite3ExprListDelete(pParse->db, p->pOrderBy); |
| 109709 | 109940 | p->pOrderBy = pOrderBy; |
| | @@ -110608,11 +110839,11 @@ |
| 110608 | 110839 | }else{ |
| 110609 | 110840 | VdbeNoopComment((v, "eof-A subroutine")); |
| 110610 | 110841 | addrEofA = sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB); |
| 110611 | 110842 | addrEofA_noB = sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, labelEnd); |
| 110612 | 110843 | VdbeCoverage(v); |
| 110613 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofA); |
| 110844 | + sqlite3VdbeGoto(v, addrEofA); |
| 110614 | 110845 | p->nSelectRow += pPrior->nSelectRow; |
| 110615 | 110846 | } |
| 110616 | 110847 | |
| 110617 | 110848 | /* Generate a subroutine to run when the results from select B |
| 110618 | 110849 | ** are exhausted and only data in select A remains. |
| | @@ -110622,19 +110853,19 @@ |
| 110622 | 110853 | if( p->nSelectRow > pPrior->nSelectRow ) p->nSelectRow = pPrior->nSelectRow; |
| 110623 | 110854 | }else{ |
| 110624 | 110855 | VdbeNoopComment((v, "eof-B subroutine")); |
| 110625 | 110856 | addrEofB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA); |
| 110626 | 110857 | sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, labelEnd); VdbeCoverage(v); |
| 110627 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEofB); |
| 110858 | + sqlite3VdbeGoto(v, addrEofB); |
| 110628 | 110859 | } |
| 110629 | 110860 | |
| 110630 | 110861 | /* Generate code to handle the case of A<B |
| 110631 | 110862 | */ |
| 110632 | 110863 | VdbeNoopComment((v, "A-lt-B subroutine")); |
| 110633 | 110864 | addrAltB = sqlite3VdbeAddOp2(v, OP_Gosub, regOutA, addrOutA); |
| 110634 | 110865 | sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v); |
| 110635 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr); |
| 110866 | + sqlite3VdbeGoto(v, labelCmpr); |
| 110636 | 110867 | |
| 110637 | 110868 | /* Generate code to handle the case of A==B |
| 110638 | 110869 | */ |
| 110639 | 110870 | if( op==TK_ALL ){ |
| 110640 | 110871 | addrAeqB = addrAltB; |
| | @@ -110643,11 +110874,11 @@ |
| 110643 | 110874 | addrAltB++; |
| 110644 | 110875 | }else{ |
| 110645 | 110876 | VdbeNoopComment((v, "A-eq-B subroutine")); |
| 110646 | 110877 | addrAeqB = |
| 110647 | 110878 | sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA); VdbeCoverage(v); |
| 110648 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr); |
| 110879 | + sqlite3VdbeGoto(v, labelCmpr); |
| 110649 | 110880 | } |
| 110650 | 110881 | |
| 110651 | 110882 | /* Generate code to handle the case of A>B |
| 110652 | 110883 | */ |
| 110653 | 110884 | VdbeNoopComment((v, "A-gt-B subroutine")); |
| | @@ -110654,11 +110885,11 @@ |
| 110654 | 110885 | addrAgtB = sqlite3VdbeCurrentAddr(v); |
| 110655 | 110886 | if( op==TK_ALL || op==TK_UNION ){ |
| 110656 | 110887 | sqlite3VdbeAddOp2(v, OP_Gosub, regOutB, addrOutB); |
| 110657 | 110888 | } |
| 110658 | 110889 | sqlite3VdbeAddOp2(v, OP_Yield, regAddrB, addrEofB); VdbeCoverage(v); |
| 110659 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, labelCmpr); |
| 110890 | + sqlite3VdbeGoto(v, labelCmpr); |
| 110660 | 110891 | |
| 110661 | 110892 | /* This code runs once to initialize everything. |
| 110662 | 110893 | */ |
| 110663 | 110894 | sqlite3VdbeJumpHere(v, j1); |
| 110664 | 110895 | sqlite3VdbeAddOp2(v, OP_Yield, regAddrA, addrEofA_noB); VdbeCoverage(v); |
| | @@ -111034,11 +111265,11 @@ |
| 111034 | 111265 | ** THIS OVERRIDES OBSOLETE COMMENTS 1 AND 2 ABOVE: |
| 111035 | 111266 | ** Ticket #3300 shows that flattening the right term of a LEFT JOIN |
| 111036 | 111267 | ** is fraught with danger. Best to avoid the whole thing. If the |
| 111037 | 111268 | ** subquery is the right term of a LEFT JOIN, then do not flatten. |
| 111038 | 111269 | */ |
| 111039 | | - if( (pSubitem->jointype & JT_OUTER)!=0 ){ |
| 111270 | + if( (pSubitem->fg.jointype & JT_OUTER)!=0 ){ |
| 111040 | 111271 | return 0; |
| 111041 | 111272 | } |
| 111042 | 111273 | |
| 111043 | 111274 | /* Restriction 17: If the sub-query is a compound SELECT, then it must |
| 111044 | 111275 | ** use only the UNION ALL operator. And none of the simple select queries |
| | @@ -111205,11 +111436,11 @@ |
| 111205 | 111436 | nSubSrc = pSubSrc->nSrc; /* Number of terms in subquery FROM clause */ |
| 111206 | 111437 | pSrc = pParent->pSrc; /* FROM clause of the outer query */ |
| 111207 | 111438 | |
| 111208 | 111439 | if( pSrc ){ |
| 111209 | 111440 | assert( pParent==p ); /* First time through the loop */ |
| 111210 | | - jointype = pSubitem->jointype; |
| 111441 | + jointype = pSubitem->fg.jointype; |
| 111211 | 111442 | }else{ |
| 111212 | 111443 | assert( pParent!=p ); /* 2nd and subsequent times through the loop */ |
| 111213 | 111444 | pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0); |
| 111214 | 111445 | if( pSrc==0 ){ |
| 111215 | 111446 | assert( db->mallocFailed ); |
| | @@ -111245,11 +111476,11 @@ |
| 111245 | 111476 | for(i=0; i<nSubSrc; i++){ |
| 111246 | 111477 | sqlite3IdListDelete(db, pSrc->a[i+iFrom].pUsing); |
| 111247 | 111478 | pSrc->a[i+iFrom] = pSubSrc->a[i]; |
| 111248 | 111479 | memset(&pSubSrc->a[i], 0, sizeof(pSubSrc->a[i])); |
| 111249 | 111480 | } |
| 111250 | | - pSrc->a[iFrom].jointype = jointype; |
| 111481 | + pSrc->a[iFrom].fg.jointype = jointype; |
| 111251 | 111482 | |
| 111252 | 111483 | /* Now begin substituting subquery result set expressions for |
| 111253 | 111484 | ** references to the iParent in the outer query. |
| 111254 | 111485 | ** |
| 111255 | 111486 | ** Example: |
| | @@ -111377,10 +111608,13 @@ |
| 111377 | 111608 | ** close would change the meaning of the LIMIT). |
| 111378 | 111609 | ** |
| 111379 | 111610 | ** (4) The inner query is the right operand of a LEFT JOIN. (The caller |
| 111380 | 111611 | ** enforces this restriction since this routine does not have enough |
| 111381 | 111612 | ** information to know.) |
| 111613 | +** |
| 111614 | +** (5) The WHERE clause expression originates in the ON or USING clause |
| 111615 | +** of a LEFT JOIN. |
| 111382 | 111616 | ** |
| 111383 | 111617 | ** Return 0 if no changes are made and non-zero if one or more WHERE clause |
| 111384 | 111618 | ** terms are duplicated into the subquery. |
| 111385 | 111619 | */ |
| 111386 | 111620 | static int pushDownWhereTerms( |
| | @@ -111400,10 +111634,11 @@ |
| 111400 | 111634 | } |
| 111401 | 111635 | while( pWhere->op==TK_AND ){ |
| 111402 | 111636 | nChng += pushDownWhereTerms(db, pSubq, pWhere->pRight, iCursor); |
| 111403 | 111637 | pWhere = pWhere->pLeft; |
| 111404 | 111638 | } |
| 111639 | + if( ExprHasProperty(pWhere,EP_FromJoin) ) return 0; /* restriction 5 */ |
| 111405 | 111640 | if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){ |
| 111406 | 111641 | nChng++; |
| 111407 | 111642 | while( pSubq ){ |
| 111408 | 111643 | pNew = sqlite3ExprDup(db, pWhere, 0); |
| 111409 | 111644 | pNew = substExpr(db, pNew, iCursor, pSubq->pEList); |
| | @@ -111496,13 +111731,13 @@ |
| 111496 | 111731 | ** was such a clause and the named index cannot be found, return |
| 111497 | 111732 | ** SQLITE_ERROR and leave an error in pParse. Otherwise, populate |
| 111498 | 111733 | ** pFrom->pIndex and return SQLITE_OK. |
| 111499 | 111734 | */ |
| 111500 | 111735 | SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, struct SrcList_item *pFrom){ |
| 111501 | | - if( pFrom->pTab && pFrom->zIndexedBy ){ |
| 111736 | + if( pFrom->pTab && pFrom->fg.isIndexedBy ){ |
| 111502 | 111737 | Table *pTab = pFrom->pTab; |
| 111503 | | - char *zIndexedBy = pFrom->zIndexedBy; |
| 111738 | + char *zIndexedBy = pFrom->u1.zIndexedBy; |
| 111504 | 111739 | Index *pIdx; |
| 111505 | 111740 | for(pIdx=pTab->pIndex; |
| 111506 | 111741 | pIdx && sqlite3StrICmp(pIdx->zName, zIndexedBy); |
| 111507 | 111742 | pIdx=pIdx->pNext |
| 111508 | 111743 | ); |
| | @@ -111509,11 +111744,11 @@ |
| 111509 | 111744 | if( !pIdx ){ |
| 111510 | 111745 | sqlite3ErrorMsg(pParse, "no such index: %s", zIndexedBy, 0); |
| 111511 | 111746 | pParse->checkSchema = 1; |
| 111512 | 111747 | return SQLITE_ERROR; |
| 111513 | 111748 | } |
| 111514 | | - pFrom->pIndex = pIdx; |
| 111749 | + pFrom->pIBIndex = pIdx; |
| 111515 | 111750 | } |
| 111516 | 111751 | return SQLITE_OK; |
| 111517 | 111752 | } |
| 111518 | 111753 | /* |
| 111519 | 111754 | ** Detect compound SELECT statements that use an ORDER BY clause with |
| | @@ -111670,16 +111905,16 @@ |
| 111670 | 111905 | Select *pSel; |
| 111671 | 111906 | Select *pLeft; /* Left-most SELECT statement */ |
| 111672 | 111907 | int bMayRecursive; /* True if compound joined by UNION [ALL] */ |
| 111673 | 111908 | With *pSavedWith; /* Initial value of pParse->pWith */ |
| 111674 | 111909 | |
| 111675 | | - /* If pCte->zErr is non-NULL at this point, then this is an illegal |
| 111910 | + /* If pCte->zCteErr is non-NULL at this point, then this is an illegal |
| 111676 | 111911 | ** recursive reference to CTE pCte. Leave an error in pParse and return |
| 111677 | | - ** early. If pCte->zErr is NULL, then this is not a recursive reference. |
| 111912 | + ** early. If pCte->zCteErr is NULL, then this is not a recursive reference. |
| 111678 | 111913 | ** In this case, proceed. */ |
| 111679 | | - if( pCte->zErr ){ |
| 111680 | | - sqlite3ErrorMsg(pParse, pCte->zErr, pCte->zName); |
| 111914 | + if( pCte->zCteErr ){ |
| 111915 | + sqlite3ErrorMsg(pParse, pCte->zCteErr, pCte->zName); |
| 111681 | 111916 | return SQLITE_ERROR; |
| 111682 | 111917 | } |
| 111683 | 111918 | |
| 111684 | 111919 | assert( pFrom->pTab==0 ); |
| 111685 | 111920 | pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table)); |
| | @@ -111704,11 +111939,11 @@ |
| 111704 | 111939 | if( pItem->zDatabase==0 |
| 111705 | 111940 | && pItem->zName!=0 |
| 111706 | 111941 | && 0==sqlite3StrICmp(pItem->zName, pCte->zName) |
| 111707 | 111942 | ){ |
| 111708 | 111943 | pItem->pTab = pTab; |
| 111709 | | - pItem->isRecursive = 1; |
| 111944 | + pItem->fg.isRecursive = 1; |
| 111710 | 111945 | pTab->nRef++; |
| 111711 | 111946 | pSel->selFlags |= SF_Recursive; |
| 111712 | 111947 | } |
| 111713 | 111948 | } |
| 111714 | 111949 | } |
| | @@ -111720,11 +111955,11 @@ |
| 111720 | 111955 | ); |
| 111721 | 111956 | return SQLITE_ERROR; |
| 111722 | 111957 | } |
| 111723 | 111958 | assert( pTab->nRef==1 || ((pSel->selFlags&SF_Recursive) && pTab->nRef==2 )); |
| 111724 | 111959 | |
| 111725 | | - pCte->zErr = "circular reference: %s"; |
| 111960 | + pCte->zCteErr = "circular reference: %s"; |
| 111726 | 111961 | pSavedWith = pParse->pWith; |
| 111727 | 111962 | pParse->pWith = pWith; |
| 111728 | 111963 | sqlite3WalkSelect(pWalker, bMayRecursive ? pSel->pPrior : pSel); |
| 111729 | 111964 | |
| 111730 | 111965 | for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior); |
| | @@ -111738,20 +111973,20 @@ |
| 111738 | 111973 | return SQLITE_ERROR; |
| 111739 | 111974 | } |
| 111740 | 111975 | pEList = pCte->pCols; |
| 111741 | 111976 | } |
| 111742 | 111977 | |
| 111743 | | - selectColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol); |
| 111978 | + sqlite3ColumnsFromExprList(pParse, pEList, &pTab->nCol, &pTab->aCol); |
| 111744 | 111979 | if( bMayRecursive ){ |
| 111745 | 111980 | if( pSel->selFlags & SF_Recursive ){ |
| 111746 | | - pCte->zErr = "multiple recursive references: %s"; |
| 111981 | + pCte->zCteErr = "multiple recursive references: %s"; |
| 111747 | 111982 | }else{ |
| 111748 | | - pCte->zErr = "recursive reference in a subquery: %s"; |
| 111983 | + pCte->zCteErr = "recursive reference in a subquery: %s"; |
| 111749 | 111984 | } |
| 111750 | 111985 | sqlite3WalkSelect(pWalker, pSel); |
| 111751 | 111986 | } |
| 111752 | | - pCte->zErr = 0; |
| 111987 | + pCte->zCteErr = 0; |
| 111753 | 111988 | pParse->pWith = pSavedWith; |
| 111754 | 111989 | } |
| 111755 | 111990 | |
| 111756 | 111991 | return SQLITE_OK; |
| 111757 | 111992 | } |
| | @@ -111834,12 +112069,12 @@ |
| 111834 | 112069 | ** an entry of the FROM clause is a subquery instead of a table or view, |
| 111835 | 112070 | ** then create a transient table structure to describe the subquery. |
| 111836 | 112071 | */ |
| 111837 | 112072 | for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){ |
| 111838 | 112073 | Table *pTab; |
| 111839 | | - assert( pFrom->isRecursive==0 || pFrom->pTab ); |
| 111840 | | - if( pFrom->isRecursive ) continue; |
| 112074 | + assert( pFrom->fg.isRecursive==0 || pFrom->pTab ); |
| 112075 | + if( pFrom->fg.isRecursive ) continue; |
| 111841 | 112076 | if( pFrom->pTab!=0 ){ |
| 111842 | 112077 | /* This statement has already been prepared. There is no need |
| 111843 | 112078 | ** to go further. */ |
| 111844 | 112079 | assert( i==0 ); |
| 111845 | 112080 | #ifndef SQLITE_OMIT_CTE |
| | @@ -111861,11 +112096,11 @@ |
| 111861 | 112096 | pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table)); |
| 111862 | 112097 | if( pTab==0 ) return WRC_Abort; |
| 111863 | 112098 | pTab->nRef = 1; |
| 111864 | 112099 | pTab->zName = sqlite3MPrintf(db, "sqlite_sq_%p", (void*)pTab); |
| 111865 | 112100 | while( pSel->pPrior ){ pSel = pSel->pPrior; } |
| 111866 | | - selectColumnsFromExprList(pParse, pSel->pEList, &pTab->nCol, &pTab->aCol); |
| 112101 | + sqlite3ColumnsFromExprList(pParse, pSel->pEList,&pTab->nCol,&pTab->aCol); |
| 111867 | 112102 | pTab->iPKey = -1; |
| 111868 | 112103 | pTab->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) ); |
| 111869 | 112104 | pTab->tabFlags |= TF_Ephemeral; |
| 111870 | 112105 | #endif |
| 111871 | 112106 | }else{ |
| | @@ -111998,11 +112233,11 @@ |
| 111998 | 112233 | continue; |
| 111999 | 112234 | } |
| 112000 | 112235 | tableSeen = 1; |
| 112001 | 112236 | |
| 112002 | 112237 | if( i>0 && zTName==0 ){ |
| 112003 | | - if( (pFrom->jointype & JT_NATURAL)!=0 |
| 112238 | + if( (pFrom->fg.jointype & JT_NATURAL)!=0 |
| 112004 | 112239 | && tableAndColumnIndex(pTabList, i, zName, 0, 0) |
| 112005 | 112240 | ){ |
| 112006 | 112241 | /* In a NATURAL join, omit the join columns from the |
| 112007 | 112242 | ** table to the right of the join */ |
| 112008 | 112243 | continue; |
| | @@ -112284,11 +112519,11 @@ |
| 112284 | 112519 | ExprList *pList = pF->pExpr->x.pList; |
| 112285 | 112520 | assert( !ExprHasProperty(pF->pExpr, EP_xIsSelect) ); |
| 112286 | 112521 | if( pList ){ |
| 112287 | 112522 | nArg = pList->nExpr; |
| 112288 | 112523 | regAgg = sqlite3GetTempRange(pParse, nArg); |
| 112289 | | - sqlite3ExprCodeExprList(pParse, pList, regAgg, SQLITE_ECEL_DUP); |
| 112524 | + sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); |
| 112290 | 112525 | }else{ |
| 112291 | 112526 | nArg = 0; |
| 112292 | 112527 | regAgg = 0; |
| 112293 | 112528 | } |
| 112294 | 112529 | if( pF->iDistinct>=0 ){ |
| | @@ -112525,11 +112760,11 @@ |
| 112525 | 112760 | ** for example. In that case, do not regenerate the code to manifest |
| 112526 | 112761 | ** a view or the co-routine to implement a view. The first instance |
| 112527 | 112762 | ** is sufficient, though the subroutine to manifest the view does need |
| 112528 | 112763 | ** to be invoked again. */ |
| 112529 | 112764 | if( pItem->addrFillSub ){ |
| 112530 | | - if( pItem->viaCoroutine==0 ){ |
| 112765 | + if( pItem->fg.viaCoroutine==0 ){ |
| 112531 | 112766 | sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub); |
| 112532 | 112767 | } |
| 112533 | 112768 | continue; |
| 112534 | 112769 | } |
| 112535 | 112770 | |
| | @@ -112543,11 +112778,11 @@ |
| 112543 | 112778 | pParse->nHeight += sqlite3SelectExprHeight(p); |
| 112544 | 112779 | |
| 112545 | 112780 | /* Make copies of constant WHERE-clause terms in the outer query down |
| 112546 | 112781 | ** inside the subquery. This can help the subquery to run more efficiently. |
| 112547 | 112782 | */ |
| 112548 | | - if( (pItem->jointype & JT_OUTER)==0 |
| 112783 | + if( (pItem->fg.jointype & JT_OUTER)==0 |
| 112549 | 112784 | && pushDownWhereTerms(db, pSub, p->pWhere, pItem->iCursor) |
| 112550 | 112785 | ){ |
| 112551 | 112786 | #if SELECTTRACE_ENABLED |
| 112552 | 112787 | if( sqlite3SelectTrace & 0x100 ){ |
| 112553 | 112788 | SELECTTRACE(0x100,pParse,p,("After WHERE-clause push-down:\n")); |
| | @@ -112572,11 +112807,11 @@ |
| 112572 | 112807 | pItem->addrFillSub = addrTop; |
| 112573 | 112808 | sqlite3SelectDestInit(&dest, SRT_Coroutine, pItem->regReturn); |
| 112574 | 112809 | explainSetInteger(pItem->iSelectId, (u8)pParse->iNextSelectId); |
| 112575 | 112810 | sqlite3Select(pParse, pSub, &dest); |
| 112576 | 112811 | pItem->pTab->nRowLogEst = sqlite3LogEst(pSub->nSelectRow); |
| 112577 | | - pItem->viaCoroutine = 1; |
| 112812 | + pItem->fg.viaCoroutine = 1; |
| 112578 | 112813 | pItem->regResult = dest.iSdst; |
| 112579 | 112814 | sqlite3VdbeAddOp1(v, OP_EndCoroutine, pItem->regReturn); |
| 112580 | 112815 | sqlite3VdbeJumpHere(v, addrTop-1); |
| 112581 | 112816 | sqlite3ClearTempRegCache(pParse); |
| 112582 | 112817 | }else{ |
| | @@ -112590,11 +112825,11 @@ |
| 112590 | 112825 | int retAddr; |
| 112591 | 112826 | assert( pItem->addrFillSub==0 ); |
| 112592 | 112827 | pItem->regReturn = ++pParse->nMem; |
| 112593 | 112828 | topAddr = sqlite3VdbeAddOp2(v, OP_Integer, 0, pItem->regReturn); |
| 112594 | 112829 | pItem->addrFillSub = topAddr+1; |
| 112595 | | - if( pItem->isCorrelated==0 ){ |
| 112830 | + if( pItem->fg.isCorrelated==0 ){ |
| 112596 | 112831 | /* If the subquery is not correlated and if we are not inside of |
| 112597 | 112832 | ** a trigger, then we only need to compute the value of the subquery |
| 112598 | 112833 | ** once. */ |
| 112599 | 112834 | onceAddr = sqlite3CodeOnce(pParse); VdbeCoverage(v); |
| 112600 | 112835 | VdbeComment((v, "materialize \"%s\"", pItem->pTab->zName)); |
| | @@ -112688,11 +112923,11 @@ |
| 112688 | 112923 | */ |
| 112689 | 112924 | iEnd = sqlite3VdbeMakeLabel(v); |
| 112690 | 112925 | p->nSelectRow = LARGEST_INT64; |
| 112691 | 112926 | computeLimitRegisters(pParse, p, iEnd); |
| 112692 | 112927 | if( p->iLimit==0 && sSort.addrSortIndex>=0 ){ |
| 112693 | | - sqlite3VdbeGetOp(v, sSort.addrSortIndex)->opcode = OP_SorterOpen; |
| 112928 | + sqlite3VdbeChangeOpcode(v, sSort.addrSortIndex, OP_SorterOpen); |
| 112694 | 112929 | sSort.sortFlags |= SORTFLAG_UseSorter; |
| 112695 | 112930 | } |
| 112696 | 112931 | |
| 112697 | 112932 | /* Open an ephemeral index to use for the distinct set. |
| 112698 | 112933 | */ |
| | @@ -112904,11 +113139,11 @@ |
| 112904 | 113139 | j++; |
| 112905 | 113140 | } |
| 112906 | 113141 | } |
| 112907 | 113142 | regBase = sqlite3GetTempRange(pParse, nCol); |
| 112908 | 113143 | sqlite3ExprCacheClear(pParse); |
| 112909 | | - sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0); |
| 113144 | + sqlite3ExprCodeExprList(pParse, pGroupBy, regBase, 0, 0); |
| 112910 | 113145 | j = nGroupBy; |
| 112911 | 113146 | for(i=0; i<sAggInfo.nColumn; i++){ |
| 112912 | 113147 | struct AggInfo_col *pCol = &sAggInfo.aCol[i]; |
| 112913 | 113148 | if( pCol->iSorterColumn>=j ){ |
| 112914 | 113149 | int r1 = j + regBase; |
| | @@ -113016,11 +113251,11 @@ |
| 113016 | 113251 | sqlite3VdbeAddOp2(v, OP_Gosub, regOutputRow, addrOutputRow); |
| 113017 | 113252 | VdbeComment((v, "output final row")); |
| 113018 | 113253 | |
| 113019 | 113254 | /* Jump over the subroutines |
| 113020 | 113255 | */ |
| 113021 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrEnd); |
| 113256 | + sqlite3VdbeGoto(v, addrEnd); |
| 113022 | 113257 | |
| 113023 | 113258 | /* Generate a subroutine that outputs a single row of the result |
| 113024 | 113259 | ** set. This subroutine first looks at the iUseFlag. If iUseFlag |
| 113025 | 113260 | ** is less than or equal to zero, the subroutine is a no-op. If |
| 113026 | 113261 | ** the processing calls for the query to abort, this subroutine |
| | @@ -113170,11 +113405,11 @@ |
| 113170 | 113405 | goto select_end; |
| 113171 | 113406 | } |
| 113172 | 113407 | updateAccumulator(pParse, &sAggInfo); |
| 113173 | 113408 | assert( pMinMax==0 || pMinMax->nExpr==1 ); |
| 113174 | 113409 | if( sqlite3WhereIsOrdered(pWInfo)>0 ){ |
| 113175 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3WhereBreakLabel(pWInfo)); |
| 113410 | + sqlite3VdbeGoto(v, sqlite3WhereBreakLabel(pWInfo)); |
| 113176 | 113411 | VdbeComment((v, "%s() by index", |
| 113177 | 113412 | (flag==WHERE_ORDERBY_MIN?"min":"max"))); |
| 113178 | 113413 | } |
| 113179 | 113414 | sqlite3WhereEnd(pWInfo); |
| 113180 | 113415 | finalizeAggFunctions(pParse, &sAggInfo); |
| | @@ -114831,20 +115066,23 @@ |
| 114831 | 115066 | |
| 114832 | 115067 | hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey); |
| 114833 | 115068 | |
| 114834 | 115069 | /* There is one entry in the aRegIdx[] array for each index on the table |
| 114835 | 115070 | ** being updated. Fill in aRegIdx[] with a register number that will hold |
| 114836 | | - ** the key for accessing each index. |
| 115071 | + ** the key for accessing each index. |
| 115072 | + ** |
| 115073 | + ** FIXME: Be smarter about omitting indexes that use expressions. |
| 114837 | 115074 | */ |
| 114838 | 115075 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 114839 | 115076 | int reg; |
| 114840 | 115077 | if( chngKey || hasFK || pIdx->pPartIdxWhere || pIdx==pPk ){ |
| 114841 | 115078 | reg = ++pParse->nMem; |
| 114842 | 115079 | }else{ |
| 114843 | 115080 | reg = 0; |
| 114844 | 115081 | for(i=0; i<pIdx->nKeyCol; i++){ |
| 114845 | | - if( aXRef[pIdx->aiColumn[i]]>=0 ){ |
| 115082 | + i16 iIdxCol = pIdx->aiColumn[i]; |
| 115083 | + if( iIdxCol<0 || aXRef[iIdxCol]>=0 ){ |
| 114846 | 115084 | reg = ++pParse->nMem; |
| 114847 | 115085 | break; |
| 114848 | 115086 | } |
| 114849 | 115087 | } |
| 114850 | 115088 | } |
| | @@ -114940,20 +115178,21 @@ |
| 114940 | 115178 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, |
| 114941 | 115179 | WHERE_ONEPASS_DESIRED, iIdxCur); |
| 114942 | 115180 | if( pWInfo==0 ) goto update_cleanup; |
| 114943 | 115181 | okOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass); |
| 114944 | 115182 | for(i=0; i<nPk; i++){ |
| 115183 | + assert( pPk->aiColumn[i]>=(-1) ); |
| 114945 | 115184 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, pPk->aiColumn[i], |
| 114946 | 115185 | iPk+i); |
| 114947 | 115186 | } |
| 114948 | 115187 | if( okOnePass ){ |
| 114949 | 115188 | sqlite3VdbeChangeToNoop(v, addrOpen); |
| 114950 | 115189 | nKey = nPk; |
| 114951 | 115190 | regKey = iPk; |
| 114952 | 115191 | }else{ |
| 114953 | 115192 | sqlite3VdbeAddOp4(v, OP_MakeRecord, iPk, nPk, regKey, |
| 114954 | | - sqlite3IndexAffinityStr(v, pPk), nPk); |
| 115193 | + sqlite3IndexAffinityStr(db, pPk), nPk); |
| 114955 | 115194 | sqlite3VdbeAddOp2(v, OP_IdxInsert, iEph, regKey); |
| 114956 | 115195 | } |
| 114957 | 115196 | sqlite3WhereEnd(pWInfo); |
| 114958 | 115197 | } |
| 114959 | 115198 | |
| | @@ -115186,11 +115425,11 @@ |
| 115186 | 115425 | /* Nothing to do at end-of-loop for a single-pass */ |
| 115187 | 115426 | }else if( pPk ){ |
| 115188 | 115427 | sqlite3VdbeResolveLabel(v, labelContinue); |
| 115189 | 115428 | sqlite3VdbeAddOp2(v, OP_Next, iEph, addrTop); VdbeCoverage(v); |
| 115190 | 115429 | }else{ |
| 115191 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, labelContinue); |
| 115430 | + sqlite3VdbeGoto(v, labelContinue); |
| 115192 | 115431 | } |
| 115193 | 115432 | sqlite3VdbeResolveLabel(v, labelBreak); |
| 115194 | 115433 | |
| 115195 | 115434 | /* Close all tables */ |
| 115196 | 115435 | for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| | @@ -115768,10 +116007,11 @@ |
| 115768 | 116007 | memcpy(zCopy, zName, nName+1); |
| 115769 | 116008 | pMod->zName = zCopy; |
| 115770 | 116009 | pMod->pModule = pModule; |
| 115771 | 116010 | pMod->pAux = pAux; |
| 115772 | 116011 | pMod->xDestroy = xDestroy; |
| 116012 | + pMod->pEpoTab = 0; |
| 115773 | 116013 | pDel = (Module *)sqlite3HashInsert(&db->aModule,zCopy,(void*)pMod); |
| 115774 | 116014 | assert( pDel==0 || pDel==pMod ); |
| 115775 | 116015 | if( pDel ){ |
| 115776 | 116016 | db->mallocFailed = 1; |
| 115777 | 116017 | sqlite3DbFree(db, pDel); |
| | @@ -115995,27 +116235,21 @@ |
| 115995 | 116235 | ** The string is not copied - the pointer is stored. The |
| 115996 | 116236 | ** string will be freed automatically when the table is |
| 115997 | 116237 | ** deleted. |
| 115998 | 116238 | */ |
| 115999 | 116239 | static void addModuleArgument(sqlite3 *db, Table *pTable, char *zArg){ |
| 116000 | | - int i = pTable->nModuleArg++; |
| 116001 | | - int nBytes = sizeof(char *)*(1+pTable->nModuleArg); |
| 116240 | + int nBytes = sizeof(char *)*(2+pTable->nModuleArg); |
| 116002 | 116241 | char **azModuleArg; |
| 116003 | 116242 | azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes); |
| 116004 | 116243 | if( azModuleArg==0 ){ |
| 116005 | | - int j; |
| 116006 | | - for(j=0; j<i; j++){ |
| 116007 | | - sqlite3DbFree(db, pTable->azModuleArg[j]); |
| 116008 | | - } |
| 116009 | 116244 | sqlite3DbFree(db, zArg); |
| 116010 | | - sqlite3DbFree(db, pTable->azModuleArg); |
| 116011 | | - pTable->nModuleArg = 0; |
| 116012 | 116245 | }else{ |
| 116246 | + int i = pTable->nModuleArg++; |
| 116013 | 116247 | azModuleArg[i] = zArg; |
| 116014 | 116248 | azModuleArg[i+1] = 0; |
| 116249 | + pTable->azModuleArg = azModuleArg; |
| 116015 | 116250 | } |
| 116016 | | - pTable->azModuleArg = azModuleArg; |
| 116017 | 116251 | } |
| 116018 | 116252 | |
| 116019 | 116253 | /* |
| 116020 | 116254 | ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE |
| 116021 | 116255 | ** statement. The module name has been parsed, but the optional list |
| | @@ -116138,11 +116372,11 @@ |
| 116138 | 116372 | sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); |
| 116139 | 116373 | zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); |
| 116140 | 116374 | sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); |
| 116141 | 116375 | |
| 116142 | 116376 | iReg = ++pParse->nMem; |
| 116143 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, iReg, 0, pTab->zName, 0); |
| 116377 | + sqlite3VdbeLoadString(v, iReg, pTab->zName); |
| 116144 | 116378 | sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg); |
| 116145 | 116379 | } |
| 116146 | 116380 | |
| 116147 | 116381 | /* If we are rereading the sqlite_master table create the in-memory |
| 116148 | 116382 | ** record of the table. The xConnect() method is not called until |
| | @@ -116414,11 +116648,11 @@ |
| 116414 | 116648 | |
| 116415 | 116649 | /* If the module has been registered and includes a Create method, |
| 116416 | 116650 | ** invoke it now. If the module has not been registered, return an |
| 116417 | 116651 | ** error. Otherwise, do nothing. |
| 116418 | 116652 | */ |
| 116419 | | - if( !pMod ){ |
| 116653 | + if( pMod==0 || pMod->pModule->xCreate==0 || pMod->pModule->xDestroy==0 ){ |
| 116420 | 116654 | *pzErr = sqlite3MPrintf(db, "no such module: %s", zMod); |
| 116421 | 116655 | rc = SQLITE_ERROR; |
| 116422 | 116656 | }else{ |
| 116423 | 116657 | rc = vtabCallConstructor(db, pTab, pMod, pMod->pModule->xCreate, pzErr); |
| 116424 | 116658 | } |
| | @@ -116516,18 +116750,21 @@ |
| 116516 | 116750 | Table *pTab; |
| 116517 | 116751 | |
| 116518 | 116752 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName); |
| 116519 | 116753 | if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){ |
| 116520 | 116754 | VTable *p; |
| 116755 | + int (*xDestroy)(sqlite3_vtab *); |
| 116521 | 116756 | for(p=pTab->pVTable; p; p=p->pNext){ |
| 116522 | 116757 | assert( p->pVtab ); |
| 116523 | 116758 | if( p->pVtab->nRef>0 ){ |
| 116524 | 116759 | return SQLITE_LOCKED; |
| 116525 | 116760 | } |
| 116526 | 116761 | } |
| 116527 | 116762 | p = vtabDisconnectAll(db, pTab); |
| 116528 | | - rc = p->pMod->pModule->xDestroy(p->pVtab); |
| 116763 | + xDestroy = p->pMod->pModule->xDestroy; |
| 116764 | + assert( xDestroy!=0 ); /* Checked before the virtual table is created */ |
| 116765 | + rc = xDestroy(p->pVtab); |
| 116529 | 116766 | /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ |
| 116530 | 116767 | if( rc==SQLITE_OK ){ |
| 116531 | 116768 | assert( pTab->pVTable==p && p->pNext==0 ); |
| 116532 | 116769 | p->pVtab = 0; |
| 116533 | 116770 | pTab->pVTable = 0; |
| | @@ -116801,10 +117038,71 @@ |
| 116801 | 117038 | pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab; |
| 116802 | 117039 | }else{ |
| 116803 | 117040 | pToplevel->db->mallocFailed = 1; |
| 116804 | 117041 | } |
| 116805 | 117042 | } |
| 117043 | + |
| 117044 | +/* |
| 117045 | +** Check to see if virtual tale module pMod can be have an eponymous |
| 117046 | +** virtual table instance. If it can, create one if one does not already |
| 117047 | +** exist. Return non-zero if the eponymous virtual table instance exists |
| 117048 | +** when this routine returns, and return zero if it does not exist. |
| 117049 | +** |
| 117050 | +** An eponymous virtual table instance is one that is named after its |
| 117051 | +** module, and more importantly, does not require a CREATE VIRTUAL TABLE |
| 117052 | +** statement in order to come into existance. Eponymous virtual table |
| 117053 | +** instances always exist. They cannot be DROP-ed. |
| 117054 | +** |
| 117055 | +** Any virtual table module for which xConnect and xCreate are the same |
| 117056 | +** method can have an eponymous virtual table instance. |
| 117057 | +*/ |
| 117058 | +SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ |
| 117059 | + const sqlite3_module *pModule = pMod->pModule; |
| 117060 | + Table *pTab; |
| 117061 | + char *zErr = 0; |
| 117062 | + int nName; |
| 117063 | + int rc; |
| 117064 | + sqlite3 *db = pParse->db; |
| 117065 | + if( pMod->pEpoTab ) return 1; |
| 117066 | + if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0; |
| 117067 | + nName = sqlite3Strlen30(pMod->zName) + 1; |
| 117068 | + pTab = sqlite3DbMallocZero(db, sizeof(Table) + nName); |
| 117069 | + if( pTab==0 ) return 0; |
| 117070 | + pMod->pEpoTab = pTab; |
| 117071 | + pTab->zName = (char*)&pTab[1]; |
| 117072 | + memcpy(pTab->zName, pMod->zName, nName); |
| 117073 | + pTab->nRef = 1; |
| 117074 | + pTab->pSchema = db->aDb[0].pSchema; |
| 117075 | + pTab->tabFlags |= TF_Virtual; |
| 117076 | + pTab->nModuleArg = 0; |
| 117077 | + pTab->iPKey = -1; |
| 117078 | + addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| 117079 | + addModuleArgument(db, pTab, 0); |
| 117080 | + addModuleArgument(db, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| 117081 | + rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr); |
| 117082 | + if( rc ){ |
| 117083 | + sqlite3ErrorMsg(pParse, "%s", zErr); |
| 117084 | + sqlite3DbFree(db, zErr); |
| 117085 | + sqlite3VtabEponymousTableClear(db, pMod); |
| 117086 | + return 0; |
| 117087 | + } |
| 117088 | + return 1; |
| 117089 | +} |
| 117090 | + |
| 117091 | +/* |
| 117092 | +** Erase the eponymous virtual table instance associated with |
| 117093 | +** virtual table module pMod, if it exists. |
| 117094 | +*/ |
| 117095 | +SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){ |
| 117096 | + Table *pTab = pMod->pEpoTab; |
| 117097 | + if( (pTab = pMod->pEpoTab)!=0 ){ |
| 117098 | + sqlite3DeleteColumnNames(db, pTab); |
| 117099 | + sqlite3VtabClear(db, pTab); |
| 117100 | + sqlite3DbFree(db, pTab); |
| 117101 | + pMod->pEpoTab = 0; |
| 117102 | + } |
| 117103 | +} |
| 116806 | 117104 | |
| 116807 | 117105 | /* |
| 116808 | 117106 | ** Return the ON CONFLICT resolution mode in effect for the virtual |
| 116809 | 117107 | ** table update operation currently in progress. |
| 116810 | 117108 | ** |
| | @@ -117172,16 +117470,18 @@ |
| 117172 | 117470 | */ |
| 117173 | 117471 | struct WhereScan { |
| 117174 | 117472 | WhereClause *pOrigWC; /* Original, innermost WhereClause */ |
| 117175 | 117473 | WhereClause *pWC; /* WhereClause currently being scanned */ |
| 117176 | 117474 | char *zCollName; /* Required collating sequence, if not NULL */ |
| 117475 | + Expr *pIdxExpr; /* Search for this index expression */ |
| 117177 | 117476 | char idxaff; /* Must match this affinity, if zCollName!=NULL */ |
| 117178 | 117477 | unsigned char nEquiv; /* Number of entries in aEquiv[] */ |
| 117179 | 117478 | unsigned char iEquiv; /* Next unused slot in aEquiv[] */ |
| 117180 | 117479 | u32 opMask; /* Acceptable operators */ |
| 117181 | 117480 | int k; /* Resume scanning at this->pWC->a[this->k] */ |
| 117182 | | - int aEquiv[22]; /* Cursor,Column pairs for equivalence classes */ |
| 117481 | + int aiCur[11]; /* Cursors in the equivalence class */ |
| 117482 | + i16 aiColumn[11]; /* Corresponding column number in the eq-class */ |
| 117183 | 117483 | }; |
| 117184 | 117484 | |
| 117185 | 117485 | /* |
| 117186 | 117486 | ** An instance of the following structure holds all information about a |
| 117187 | 117487 | ** WHERE clause. Mostly this is a container for one or more WhereTerms. |
| | @@ -117361,10 +117661,11 @@ |
| 117361 | 117661 | SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*); |
| 117362 | 117662 | SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8); |
| 117363 | 117663 | SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*); |
| 117364 | 117664 | SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*); |
| 117365 | 117665 | SQLITE_PRIVATE void sqlite3WhereExprAnalyze(SrcList*, WhereClause*); |
| 117666 | +SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, struct SrcList_item*, WhereClause*); |
| 117366 | 117667 | |
| 117367 | 117668 | |
| 117368 | 117669 | |
| 117369 | 117670 | |
| 117370 | 117671 | |
| | @@ -117437,10 +117738,20 @@ |
| 117437 | 117738 | if( iTerm ) sqlite3StrAccumAppend(pStr, " AND ", 5); |
| 117438 | 117739 | sqlite3StrAccumAppendAll(pStr, zColumn); |
| 117439 | 117740 | sqlite3StrAccumAppend(pStr, zOp, 1); |
| 117440 | 117741 | sqlite3StrAccumAppend(pStr, "?", 1); |
| 117441 | 117742 | } |
| 117743 | + |
| 117744 | +/* |
| 117745 | +** Return the name of the i-th column of the pIdx index. |
| 117746 | +*/ |
| 117747 | +static const char *explainIndexColumnName(Index *pIdx, int i){ |
| 117748 | + i = pIdx->aiColumn[i]; |
| 117749 | + if( i==(-2) ) return "<expr>"; |
| 117750 | + if( i==(-1) ) return "rowid"; |
| 117751 | + return pIdx->pTable->aCol[i].zName; |
| 117752 | +} |
| 117442 | 117753 | |
| 117443 | 117754 | /* |
| 117444 | 117755 | ** Argument pLevel describes a strategy for scanning table pTab. This |
| 117445 | 117756 | ** function appends text to pStr that describes the subset of table |
| 117446 | 117757 | ** rows scanned by the strategy in the form of an SQL expression. |
| | @@ -117457,32 +117768,26 @@ |
| 117457 | 117768 | static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop, Table *pTab){ |
| 117458 | 117769 | Index *pIndex = pLoop->u.btree.pIndex; |
| 117459 | 117770 | u16 nEq = pLoop->u.btree.nEq; |
| 117460 | 117771 | u16 nSkip = pLoop->nSkip; |
| 117461 | 117772 | int i, j; |
| 117462 | | - Column *aCol = pTab->aCol; |
| 117463 | | - i16 *aiColumn = pIndex->aiColumn; |
| 117464 | 117773 | |
| 117465 | 117774 | if( nEq==0 && (pLoop->wsFlags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))==0 ) return; |
| 117466 | 117775 | sqlite3StrAccumAppend(pStr, " (", 2); |
| 117467 | 117776 | for(i=0; i<nEq; i++){ |
| 117468 | | - char *z = aiColumn[i] < 0 ? "rowid" : aCol[aiColumn[i]].zName; |
| 117469 | | - if( i>=nSkip ){ |
| 117470 | | - explainAppendTerm(pStr, i, z, "="); |
| 117471 | | - }else{ |
| 117472 | | - if( i ) sqlite3StrAccumAppend(pStr, " AND ", 5); |
| 117473 | | - sqlite3XPrintf(pStr, 0, "ANY(%s)", z); |
| 117474 | | - } |
| 117777 | + const char *z = explainIndexColumnName(pIndex, i); |
| 117778 | + if( i ) sqlite3StrAccumAppend(pStr, " AND ", 5); |
| 117779 | + sqlite3XPrintf(pStr, 0, i>=nSkip ? "%s=?" : "ANY(%s)", z); |
| 117475 | 117780 | } |
| 117476 | 117781 | |
| 117477 | 117782 | j = i; |
| 117478 | 117783 | if( pLoop->wsFlags&WHERE_BTM_LIMIT ){ |
| 117479 | | - char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName; |
| 117784 | + const char *z = explainIndexColumnName(pIndex, i); |
| 117480 | 117785 | explainAppendTerm(pStr, i++, z, ">"); |
| 117481 | 117786 | } |
| 117482 | 117787 | if( pLoop->wsFlags&WHERE_TOP_LIMIT ){ |
| 117483 | | - char *z = aiColumn[j] < 0 ? "rowid" : aCol[aiColumn[j]].zName; |
| 117788 | + const char *z = explainIndexColumnName(pIndex, j); |
| 117484 | 117789 | explainAppendTerm(pStr, i, z, "<"); |
| 117485 | 117790 | } |
| 117486 | 117791 | sqlite3StrAccumAppend(pStr, ")", 1); |
| 117487 | 117792 | } |
| 117488 | 117793 | |
| | @@ -117562,23 +117867,22 @@ |
| 117562 | 117867 | sqlite3StrAccumAppend(&str, " USING ", 7); |
| 117563 | 117868 | sqlite3XPrintf(&str, 0, zFmt, pIdx->zName); |
| 117564 | 117869 | explainIndexRange(&str, pLoop, pItem->pTab); |
| 117565 | 117870 | } |
| 117566 | 117871 | }else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){ |
| 117567 | | - const char *zRange; |
| 117872 | + const char *zRangeOp; |
| 117568 | 117873 | if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){ |
| 117569 | | - zRange = "(rowid=?)"; |
| 117874 | + zRangeOp = "="; |
| 117570 | 117875 | }else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){ |
| 117571 | | - zRange = "(rowid>? AND rowid<?)"; |
| 117876 | + zRangeOp = ">? AND rowid<"; |
| 117572 | 117877 | }else if( flags&WHERE_BTM_LIMIT ){ |
| 117573 | | - zRange = "(rowid>?)"; |
| 117878 | + zRangeOp = ">"; |
| 117574 | 117879 | }else{ |
| 117575 | 117880 | assert( flags&WHERE_TOP_LIMIT); |
| 117576 | | - zRange = "(rowid<?)"; |
| 117881 | + zRangeOp = "<"; |
| 117577 | 117882 | } |
| 117578 | | - sqlite3StrAccumAppendAll(&str, " USING INTEGER PRIMARY KEY "); |
| 117579 | | - sqlite3StrAccumAppendAll(&str, zRange); |
| 117883 | + sqlite3XPrintf(&str, 0, " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp); |
| 117580 | 117884 | } |
| 117581 | 117885 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 117582 | 117886 | else if( (flags & WHERE_VIRTUALTABLE)!=0 ){ |
| 117583 | 117887 | sqlite3XPrintf(&str, 0, " VIRTUAL TABLE INDEX %d:%s", |
| 117584 | 117888 | pLoop->u.vtab.idxNum, pLoop->u.vtab.idxStr); |
| | @@ -117889,11 +118193,11 @@ |
| 117889 | 118193 | */ |
| 117890 | 118194 | regBase = pParse->nMem + 1; |
| 117891 | 118195 | nReg = pLoop->u.btree.nEq + nExtraReg; |
| 117892 | 118196 | pParse->nMem += nReg; |
| 117893 | 118197 | |
| 117894 | | - zAff = sqlite3DbStrDup(pParse->db, sqlite3IndexAffinityStr(v, pIdx)); |
| 118198 | + zAff = sqlite3DbStrDup(pParse->db,sqlite3IndexAffinityStr(pParse->db,pIdx)); |
| 117895 | 118199 | if( !zAff ){ |
| 117896 | 118200 | pParse->db->mallocFailed = 1; |
| 117897 | 118201 | } |
| 117898 | 118202 | |
| 117899 | 118203 | if( nSkip ){ |
| | @@ -118043,18 +118347,18 @@ |
| 118043 | 118347 | |
| 118044 | 118348 | /* If this is the right table of a LEFT OUTER JOIN, allocate and |
| 118045 | 118349 | ** initialize a memory cell that records if this table matches any |
| 118046 | 118350 | ** row of the left table of the join. |
| 118047 | 118351 | */ |
| 118048 | | - if( pLevel->iFrom>0 && (pTabItem[0].jointype & JT_LEFT)!=0 ){ |
| 118352 | + if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){ |
| 118049 | 118353 | pLevel->iLeftJoin = ++pParse->nMem; |
| 118050 | 118354 | sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin); |
| 118051 | 118355 | VdbeComment((v, "init LEFT JOIN no-match flag")); |
| 118052 | 118356 | } |
| 118053 | 118357 | |
| 118054 | 118358 | /* Special case of a FROM clause subquery implemented as a co-routine */ |
| 118055 | | - if( pTabItem->viaCoroutine ){ |
| 118359 | + if( pTabItem->fg.viaCoroutine ){ |
| 118056 | 118360 | int regYield = pTabItem->regReturn; |
| 118057 | 118361 | sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub); |
| 118058 | 118362 | pLevel->p2 = sqlite3VdbeAddOp2(v, OP_Yield, regYield, addrBrk); |
| 118059 | 118363 | VdbeCoverage(v); |
| 118060 | 118364 | VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName)); |
| | @@ -118777,11 +119081,11 @@ |
| 118777 | 119081 | if( pAndExpr ){ |
| 118778 | 119082 | pAndExpr->pLeft = 0; |
| 118779 | 119083 | sqlite3ExprDelete(db, pAndExpr); |
| 118780 | 119084 | } |
| 118781 | 119085 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 118782 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); |
| 119086 | + sqlite3VdbeGoto(v, pLevel->addrBrk); |
| 118783 | 119087 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 118784 | 119088 | |
| 118785 | 119089 | if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab); |
| 118786 | 119090 | if( !untestedTerms ) disableTerm(pLevel, pTerm); |
| 118787 | 119091 | }else |
| | @@ -118792,11 +119096,11 @@ |
| 118792 | 119096 | ** scan of the entire table. |
| 118793 | 119097 | */ |
| 118794 | 119098 | static const u8 aStep[] = { OP_Next, OP_Prev }; |
| 118795 | 119099 | static const u8 aStart[] = { OP_Rewind, OP_Last }; |
| 118796 | 119100 | assert( bRev==0 || bRev==1 ); |
| 118797 | | - if( pTabItem->isRecursive ){ |
| 119101 | + if( pTabItem->fg.isRecursive ){ |
| 118798 | 119102 | /* Tables marked isRecursive have only a single row that is stored in |
| 118799 | 119103 | ** a pseudo-cursor. No need to Rewind or Next such cursors. */ |
| 118800 | 119104 | pLevel->op = OP_Noop; |
| 118801 | 119105 | }else{ |
| 118802 | 119106 | pLevel->op = aStep[bRev]; |
| | @@ -119699,10 +120003,55 @@ |
| 119699 | 120003 | } |
| 119700 | 120004 | pS = pS->pPrior; |
| 119701 | 120005 | } |
| 119702 | 120006 | return mask; |
| 119703 | 120007 | } |
| 120008 | + |
| 120009 | +/* |
| 120010 | +** Expression pExpr is one operand of a comparison operator that might |
| 120011 | +** be useful for indexing. This routine checks to see if pExpr appears |
| 120012 | +** in any index. Return TRUE (1) if pExpr is an indexed term and return |
| 120013 | +** FALSE (0) if not. If TRUE is returned, also set *piCur to the cursor |
| 120014 | +** number of the table that is indexed and *piColumn to the column number |
| 120015 | +** of the column that is indexed, or -2 if an expression is being indexed. |
| 120016 | +** |
| 120017 | +** If pExpr is a TK_COLUMN column reference, then this routine always returns |
| 120018 | +** true even if that particular column is not indexed, because the column |
| 120019 | +** might be added to an automatic index later. |
| 120020 | +*/ |
| 120021 | +static int exprMightBeIndexed( |
| 120022 | + SrcList *pFrom, /* The FROM clause */ |
| 120023 | + Bitmask mPrereq, /* Bitmask of FROM clause terms referenced by pExpr */ |
| 120024 | + Expr *pExpr, /* An operand of a comparison operator */ |
| 120025 | + int *piCur, /* Write the referenced table cursor number here */ |
| 120026 | + int *piColumn /* Write the referenced table column number here */ |
| 120027 | +){ |
| 120028 | + Index *pIdx; |
| 120029 | + int i; |
| 120030 | + int iCur; |
| 120031 | + if( pExpr->op==TK_COLUMN ){ |
| 120032 | + *piCur = pExpr->iTable; |
| 120033 | + *piColumn = pExpr->iColumn; |
| 120034 | + return 1; |
| 120035 | + } |
| 120036 | + if( mPrereq==0 ) return 0; /* No table references */ |
| 120037 | + if( (mPrereq&(mPrereq-1))!=0 ) return 0; /* Refs more than one table */ |
| 120038 | + for(i=0; mPrereq>1; i++, mPrereq>>=1){} |
| 120039 | + iCur = pFrom->a[i].iCursor; |
| 120040 | + for(pIdx=pFrom->a[i].pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 120041 | + if( pIdx->aColExpr==0 ) continue; |
| 120042 | + for(i=0; i<pIdx->nKeyCol; i++){ |
| 120043 | + if( pIdx->aiColumn[i]!=(-2) ) continue; |
| 120044 | + if( sqlite3ExprCompare(pExpr, pIdx->aColExpr->a[i].pExpr, iCur)==0 ){ |
| 120045 | + *piCur = iCur; |
| 120046 | + *piColumn = -2; |
| 120047 | + return 1; |
| 120048 | + } |
| 120049 | + } |
| 120050 | + } |
| 120051 | + return 0; |
| 120052 | +} |
| 119704 | 120053 | |
| 119705 | 120054 | /* |
| 119706 | 120055 | ** The input to this routine is an WhereTerm structure with only the |
| 119707 | 120056 | ** "pExpr" field filled in. The job of this routine is to analyze the |
| 119708 | 120057 | ** subexpression and populate all the other fields of the WhereTerm |
| | @@ -119770,20 +120119,23 @@ |
| 119770 | 120119 | pTerm->prereqAll = prereqAll; |
| 119771 | 120120 | pTerm->leftCursor = -1; |
| 119772 | 120121 | pTerm->iParent = -1; |
| 119773 | 120122 | pTerm->eOperator = 0; |
| 119774 | 120123 | if( allowedOp(op) ){ |
| 120124 | + int iCur, iColumn; |
| 119775 | 120125 | Expr *pLeft = sqlite3ExprSkipCollate(pExpr->pLeft); |
| 119776 | 120126 | Expr *pRight = sqlite3ExprSkipCollate(pExpr->pRight); |
| 119777 | 120127 | u16 opMask = (pTerm->prereqRight & prereqLeft)==0 ? WO_ALL : WO_EQUIV; |
| 119778 | | - if( pLeft->op==TK_COLUMN ){ |
| 119779 | | - pTerm->leftCursor = pLeft->iTable; |
| 119780 | | - pTerm->u.leftColumn = pLeft->iColumn; |
| 120128 | + if( exprMightBeIndexed(pSrc, prereqLeft, pLeft, &iCur, &iColumn) ){ |
| 120129 | + pTerm->leftCursor = iCur; |
| 120130 | + pTerm->u.leftColumn = iColumn; |
| 119781 | 120131 | pTerm->eOperator = operatorMask(op) & opMask; |
| 119782 | 120132 | } |
| 119783 | 120133 | if( op==TK_IS ) pTerm->wtFlags |= TERM_IS; |
| 119784 | | - if( pRight && pRight->op==TK_COLUMN ){ |
| 120134 | + if( pRight |
| 120135 | + && exprMightBeIndexed(pSrc, pTerm->prereqRight, pRight, &iCur, &iColumn) |
| 120136 | + ){ |
| 119785 | 120137 | WhereTerm *pNew; |
| 119786 | 120138 | Expr *pDup; |
| 119787 | 120139 | u16 eExtraOp = 0; /* Extra bits for pNew->eOperator */ |
| 119788 | 120140 | if( pTerm->leftCursor>=0 ){ |
| 119789 | 120141 | int idxNew; |
| | @@ -119808,12 +120160,12 @@ |
| 119808 | 120160 | pDup = pExpr; |
| 119809 | 120161 | pNew = pTerm; |
| 119810 | 120162 | } |
| 119811 | 120163 | exprCommute(pParse, pDup); |
| 119812 | 120164 | pLeft = sqlite3ExprSkipCollate(pDup->pLeft); |
| 119813 | | - pNew->leftCursor = pLeft->iTable; |
| 119814 | | - pNew->u.leftColumn = pLeft->iColumn; |
| 120165 | + pNew->leftCursor = iCur; |
| 120166 | + pNew->u.leftColumn = iColumn; |
| 119815 | 120167 | testcase( (prereqLeft | extraRight) != prereqLeft ); |
| 119816 | 120168 | pNew->prereqRight = prereqLeft | extraRight; |
| 119817 | 120169 | pNew->prereqAll = prereqAll; |
| 119818 | 120170 | pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask; |
| 119819 | 120171 | } |
| | @@ -120152,10 +120504,50 @@ |
| 120152 | 120504 | int i; |
| 120153 | 120505 | for(i=pWC->nTerm-1; i>=0; i--){ |
| 120154 | 120506 | exprAnalyze(pTabList, pWC, i); |
| 120155 | 120507 | } |
| 120156 | 120508 | } |
| 120509 | + |
| 120510 | +/* |
| 120511 | +** For table-valued-functions, transform the function arguments into |
| 120512 | +** new WHERE clause terms. |
| 120513 | +** |
| 120514 | +** Each function argument translates into an equality constraint against |
| 120515 | +** a HIDDEN column in the table. |
| 120516 | +*/ |
| 120517 | +SQLITE_PRIVATE void sqlite3WhereTabFuncArgs( |
| 120518 | + Parse *pParse, /* Parsing context */ |
| 120519 | + struct SrcList_item *pItem, /* The FROM clause term to process */ |
| 120520 | + WhereClause *pWC /* Xfer function arguments to here */ |
| 120521 | +){ |
| 120522 | + Table *pTab; |
| 120523 | + int j, k; |
| 120524 | + ExprList *pArgs; |
| 120525 | + Expr *pColRef; |
| 120526 | + Expr *pTerm; |
| 120527 | + if( pItem->fg.isTabFunc==0 ) return; |
| 120528 | + pTab = pItem->pTab; |
| 120529 | + assert( pTab!=0 ); |
| 120530 | + pArgs = pItem->u1.pFuncArg; |
| 120531 | + assert( pArgs!=0 ); |
| 120532 | + for(j=k=0; j<pArgs->nExpr; j++){ |
| 120533 | + while( k<pTab->nCol && (pTab->aCol[k].colFlags & COLFLAG_HIDDEN)==0 ){ k++; } |
| 120534 | + if( k>=pTab->nCol ){ |
| 120535 | + sqlite3ErrorMsg(pParse, "too many arguments on %s() - max %d", |
| 120536 | + pTab->zName, j); |
| 120537 | + return; |
| 120538 | + } |
| 120539 | + pColRef = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); |
| 120540 | + if( pColRef==0 ) return; |
| 120541 | + pColRef->iTable = pItem->iCursor; |
| 120542 | + pColRef->iColumn = k++; |
| 120543 | + pColRef->pTab = pTab; |
| 120544 | + pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, |
| 120545 | + sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); |
| 120546 | + whereClauseInsert(pWC, pTerm, TERM_DYNAMIC); |
| 120547 | + } |
| 120548 | +} |
| 120157 | 120549 | |
| 120158 | 120550 | /************** End of whereexpr.c *******************************************/ |
| 120159 | 120551 | /************** Begin file where.c *******************************************/ |
| 120160 | 120552 | /* |
| 120161 | 120553 | ** 2001 September 15 |
| | @@ -120328,41 +120720,44 @@ |
| 120328 | 120720 | ** established when the pScan object was initialized by whereScanInit(). |
| 120329 | 120721 | ** Return NULL if there are no more matching WhereTerms. |
| 120330 | 120722 | */ |
| 120331 | 120723 | static WhereTerm *whereScanNext(WhereScan *pScan){ |
| 120332 | 120724 | int iCur; /* The cursor on the LHS of the term */ |
| 120333 | | - int iColumn; /* The column on the LHS of the term. -1 for IPK */ |
| 120725 | + i16 iColumn; /* The column on the LHS of the term. -1 for IPK */ |
| 120334 | 120726 | Expr *pX; /* An expression being tested */ |
| 120335 | 120727 | WhereClause *pWC; /* Shorthand for pScan->pWC */ |
| 120336 | 120728 | WhereTerm *pTerm; /* The term being tested */ |
| 120337 | 120729 | int k = pScan->k; /* Where to start scanning */ |
| 120338 | 120730 | |
| 120339 | 120731 | while( pScan->iEquiv<=pScan->nEquiv ){ |
| 120340 | | - iCur = pScan->aEquiv[pScan->iEquiv-2]; |
| 120341 | | - iColumn = pScan->aEquiv[pScan->iEquiv-1]; |
| 120732 | + iCur = pScan->aiCur[pScan->iEquiv-1]; |
| 120733 | + iColumn = pScan->aiColumn[pScan->iEquiv-1]; |
| 120734 | + assert( iColumn!=(-2) || pScan->pIdxExpr!=0 ); |
| 120342 | 120735 | while( (pWC = pScan->pWC)!=0 ){ |
| 120343 | 120736 | for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){ |
| 120344 | 120737 | if( pTerm->leftCursor==iCur |
| 120345 | 120738 | && pTerm->u.leftColumn==iColumn |
| 120346 | | - && (pScan->iEquiv<=2 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin)) |
| 120739 | + && (iColumn!=(-2) |
| 120740 | + || sqlite3ExprCompare(pTerm->pExpr->pLeft,pScan->pIdxExpr,iCur)==0) |
| 120741 | + && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin)) |
| 120347 | 120742 | ){ |
| 120348 | 120743 | if( (pTerm->eOperator & WO_EQUIV)!=0 |
| 120349 | | - && pScan->nEquiv<ArraySize(pScan->aEquiv) |
| 120744 | + && pScan->nEquiv<ArraySize(pScan->aiCur) |
| 120350 | 120745 | ){ |
| 120351 | 120746 | int j; |
| 120352 | 120747 | pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight); |
| 120353 | 120748 | assert( pX->op==TK_COLUMN ); |
| 120354 | | - for(j=0; j<pScan->nEquiv; j+=2){ |
| 120355 | | - if( pScan->aEquiv[j]==pX->iTable |
| 120356 | | - && pScan->aEquiv[j+1]==pX->iColumn ){ |
| 120749 | + for(j=0; j<pScan->nEquiv; j++){ |
| 120750 | + if( pScan->aiCur[j]==pX->iTable |
| 120751 | + && pScan->aiColumn[j]==pX->iColumn ){ |
| 120357 | 120752 | break; |
| 120358 | 120753 | } |
| 120359 | 120754 | } |
| 120360 | 120755 | if( j==pScan->nEquiv ){ |
| 120361 | | - pScan->aEquiv[j] = pX->iTable; |
| 120362 | | - pScan->aEquiv[j+1] = pX->iColumn; |
| 120363 | | - pScan->nEquiv += 2; |
| 120756 | + pScan->aiCur[j] = pX->iTable; |
| 120757 | + pScan->aiColumn[j] = pX->iColumn; |
| 120758 | + pScan->nEquiv++; |
| 120364 | 120759 | } |
| 120365 | 120760 | } |
| 120366 | 120761 | if( (pTerm->eOperator & pScan->opMask)!=0 ){ |
| 120367 | 120762 | /* Verify the affinity and collating sequence match */ |
| 120368 | 120763 | if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){ |
| | @@ -120380,12 +120775,12 @@ |
| 120380 | 120775 | continue; |
| 120381 | 120776 | } |
| 120382 | 120777 | } |
| 120383 | 120778 | if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0 |
| 120384 | 120779 | && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN |
| 120385 | | - && pX->iTable==pScan->aEquiv[0] |
| 120386 | | - && pX->iColumn==pScan->aEquiv[1] |
| 120780 | + && pX->iTable==pScan->aiCur[0] |
| 120781 | + && pX->iColumn==pScan->aiColumn[0] |
| 120387 | 120782 | ){ |
| 120388 | 120783 | testcase( pTerm->eOperator & WO_IS ); |
| 120389 | 120784 | continue; |
| 120390 | 120785 | } |
| 120391 | 120786 | pScan->k = k+1; |
| | @@ -120396,11 +120791,11 @@ |
| 120396 | 120791 | pScan->pWC = pScan->pWC->pOuter; |
| 120397 | 120792 | k = 0; |
| 120398 | 120793 | } |
| 120399 | 120794 | pScan->pWC = pScan->pOrigWC; |
| 120400 | 120795 | k = 0; |
| 120401 | | - pScan->iEquiv += 2; |
| 120796 | + pScan->iEquiv++; |
| 120402 | 120797 | } |
| 120403 | 120798 | return 0; |
| 120404 | 120799 | } |
| 120405 | 120800 | |
| 120406 | 120801 | /* |
| | @@ -120425,49 +120820,53 @@ |
| 120425 | 120820 | int iCur, /* Cursor to scan for */ |
| 120426 | 120821 | int iColumn, /* Column to scan for */ |
| 120427 | 120822 | u32 opMask, /* Operator(s) to scan for */ |
| 120428 | 120823 | Index *pIdx /* Must be compatible with this index */ |
| 120429 | 120824 | ){ |
| 120430 | | - int j; |
| 120825 | + int j = 0; |
| 120431 | 120826 | |
| 120432 | 120827 | /* memset(pScan, 0, sizeof(*pScan)); */ |
| 120433 | 120828 | pScan->pOrigWC = pWC; |
| 120434 | 120829 | pScan->pWC = pWC; |
| 120830 | + pScan->pIdxExpr = 0; |
| 120831 | + if( pIdx ){ |
| 120832 | + j = iColumn; |
| 120833 | + iColumn = pIdx->aiColumn[j]; |
| 120834 | + if( iColumn==(-2) ) pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr; |
| 120835 | + } |
| 120435 | 120836 | if( pIdx && iColumn>=0 ){ |
| 120436 | 120837 | pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity; |
| 120437 | | - for(j=0; pIdx->aiColumn[j]!=iColumn; j++){ |
| 120438 | | - if( NEVER(j>pIdx->nColumn) ) return 0; |
| 120439 | | - } |
| 120440 | 120838 | pScan->zCollName = pIdx->azColl[j]; |
| 120441 | 120839 | }else{ |
| 120442 | 120840 | pScan->idxaff = 0; |
| 120443 | 120841 | pScan->zCollName = 0; |
| 120444 | 120842 | } |
| 120445 | 120843 | pScan->opMask = opMask; |
| 120446 | 120844 | pScan->k = 0; |
| 120447 | | - pScan->aEquiv[0] = iCur; |
| 120448 | | - pScan->aEquiv[1] = iColumn; |
| 120449 | | - pScan->nEquiv = 2; |
| 120450 | | - pScan->iEquiv = 2; |
| 120845 | + pScan->aiCur[0] = iCur; |
| 120846 | + pScan->aiColumn[0] = iColumn; |
| 120847 | + pScan->nEquiv = 1; |
| 120848 | + pScan->iEquiv = 1; |
| 120451 | 120849 | return whereScanNext(pScan); |
| 120452 | 120850 | } |
| 120453 | 120851 | |
| 120454 | 120852 | /* |
| 120455 | 120853 | ** Search for a term in the WHERE clause that is of the form "X <op> <expr>" |
| 120456 | 120854 | ** where X is a reference to the iColumn of table iCur and <op> is one of |
| 120457 | 120855 | ** the WO_xx operator codes specified by the op parameter. |
| 120458 | 120856 | ** Return a pointer to the term. Return 0 if not found. |
| 120857 | +** |
| 120858 | +** If pIdx!=0 then search for terms matching the iColumn-th column of pIdx |
| 120859 | +** rather than the iColumn-th column of table iCur. |
| 120459 | 120860 | ** |
| 120460 | 120861 | ** The term returned might by Y=<expr> if there is another constraint in |
| 120461 | 120862 | ** the WHERE clause that specifies that X=Y. Any such constraints will be |
| 120462 | 120863 | ** identified by the WO_EQUIV bit in the pTerm->eOperator field. The |
| 120463 | | -** aEquiv[] array holds X and all its equivalents, with each SQL variable |
| 120464 | | -** taking up two slots in aEquiv[]. The first slot is for the cursor number |
| 120465 | | -** and the second is for the column number. There are 22 slots in aEquiv[] |
| 120466 | | -** so that means we can look for X plus up to 10 other equivalent values. |
| 120467 | | -** Hence a search for X will return <expr> if X=A1 and A1=A2 and A2=A3 |
| 120468 | | -** and ... and A9=A10 and A10=<expr>. |
| 120864 | +** aiCur[]/iaColumn[] arrays hold X and all its equivalents. There are 11 |
| 120865 | +** slots in aiCur[]/aiColumn[] so that means we can look for X plus up to 10 |
| 120866 | +** other equivalent values. Hence a search for X will return <expr> if X=A1 |
| 120867 | +** and A1=A2 and A2=A3 and ... and A9=A10 and A10=<expr>. |
| 120469 | 120868 | ** |
| 120470 | 120869 | ** If there are multiple terms in the WHERE clause of the form "X <op> <expr>" |
| 120471 | 120870 | ** then try for the one with no dependencies on <expr> - in other words where |
| 120472 | 120871 | ** <expr> is a constant expression of some kind. Only return entries of |
| 120473 | 120872 | ** the form "X <op> Y" where Y is a column in another table if no terms of |
| | @@ -120531,10 +120930,29 @@ |
| 120531 | 120930 | } |
| 120532 | 120931 | } |
| 120533 | 120932 | |
| 120534 | 120933 | return -1; |
| 120535 | 120934 | } |
| 120935 | + |
| 120936 | +/* |
| 120937 | +** Return TRUE if the iCol-th column of index pIdx is NOT NULL |
| 120938 | +*/ |
| 120939 | +static int indexColumnNotNull(Index *pIdx, int iCol){ |
| 120940 | + int j; |
| 120941 | + assert( pIdx!=0 ); |
| 120942 | + assert( iCol>=0 && iCol<pIdx->nColumn ); |
| 120943 | + j = pIdx->aiColumn[iCol]; |
| 120944 | + if( j>=0 ){ |
| 120945 | + return pIdx->pTable->aCol[j].notNull; |
| 120946 | + }else if( j==(-1) ){ |
| 120947 | + return 1; |
| 120948 | + }else{ |
| 120949 | + assert( j==(-2) ); |
| 120950 | + return 0; /* Assume an indexed expression can always yield a NULL */ |
| 120951 | + |
| 120952 | + } |
| 120953 | +} |
| 120536 | 120954 | |
| 120537 | 120955 | /* |
| 120538 | 120956 | ** Return true if the DISTINCT expression-list passed as the third argument |
| 120539 | 120957 | ** is redundant. |
| 120540 | 120958 | ** |
| | @@ -120582,16 +121000,13 @@ |
| 120582 | 121000 | ** contain a "col=X" term are subject to a NOT NULL constraint. |
| 120583 | 121001 | */ |
| 120584 | 121002 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 120585 | 121003 | if( !IsUniqueIndex(pIdx) ) continue; |
| 120586 | 121004 | for(i=0; i<pIdx->nKeyCol; i++){ |
| 120587 | | - i16 iCol = pIdx->aiColumn[i]; |
| 120588 | | - if( 0==sqlite3WhereFindTerm(pWC, iBase, iCol, ~(Bitmask)0, WO_EQ, pIdx) ){ |
| 120589 | | - int iIdxCol = findIndexCol(pParse, pDistinct, iBase, pIdx, i); |
| 120590 | | - if( iIdxCol<0 || pTab->aCol[iCol].notNull==0 ){ |
| 120591 | | - break; |
| 120592 | | - } |
| 121005 | + if( 0==sqlite3WhereFindTerm(pWC, iBase, i, ~(Bitmask)0, WO_EQ, pIdx) ){ |
| 121006 | + if( findIndexCol(pParse, pDistinct, iBase, pIdx, i)<0 ) break; |
| 121007 | + if( indexColumnNotNull(pIdx, i)==0 ) break; |
| 120593 | 121008 | } |
| 120594 | 121009 | } |
| 120595 | 121010 | if( i==pIdx->nKeyCol ){ |
| 120596 | 121011 | /* This index implies that the DISTINCT qualifier is redundant. */ |
| 120597 | 121012 | return 1; |
| | @@ -120866,11 +121281,11 @@ |
| 120866 | 121281 | VdbeComment((v, "for %s", pTable->zName)); |
| 120867 | 121282 | |
| 120868 | 121283 | /* Fill the automatic index with content */ |
| 120869 | 121284 | sqlite3ExprCachePush(pParse); |
| 120870 | 121285 | pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom]; |
| 120871 | | - if( pTabItem->viaCoroutine ){ |
| 121286 | + if( pTabItem->fg.viaCoroutine ){ |
| 120872 | 121287 | int regYield = pTabItem->regReturn; |
| 120873 | 121288 | sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, pTabItem->addrFillSub); |
| 120874 | 121289 | addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield); |
| 120875 | 121290 | VdbeCoverage(v); |
| 120876 | 121291 | VdbeComment((v, "next row of \"%s\"", pTabItem->pTab->zName)); |
| | @@ -120885,14 +121300,14 @@ |
| 120885 | 121300 | regRecord = sqlite3GetTempReg(pParse); |
| 120886 | 121301 | sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0); |
| 120887 | 121302 | sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord); |
| 120888 | 121303 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 120889 | 121304 | if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue); |
| 120890 | | - if( pTabItem->viaCoroutine ){ |
| 121305 | + if( pTabItem->fg.viaCoroutine ){ |
| 120891 | 121306 | translateColumnToCopy(v, addrTop, pLevel->iTabCur, pTabItem->regResult); |
| 120892 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, addrTop); |
| 120893 | | - pTabItem->viaCoroutine = 0; |
| 121307 | + sqlite3VdbeGoto(v, addrTop); |
| 121308 | + pTabItem->fg.viaCoroutine = 0; |
| 120894 | 121309 | }else{ |
| 120895 | 121310 | sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v); |
| 120896 | 121311 | } |
| 120897 | 121312 | sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); |
| 120898 | 121313 | sqlite3VdbeJumpHere(v, addrTop); |
| | @@ -120939,10 +121354,11 @@ |
| 120939 | 121354 | testcase( pTerm->eOperator & WO_ISNULL ); |
| 120940 | 121355 | testcase( pTerm->eOperator & WO_IS ); |
| 120941 | 121356 | testcase( pTerm->eOperator & WO_ALL ); |
| 120942 | 121357 | if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV|WO_IS))==0 ) continue; |
| 120943 | 121358 | if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 121359 | + assert( pTerm->u.leftColumn>=(-1) ); |
| 120944 | 121360 | nTerm++; |
| 120945 | 121361 | } |
| 120946 | 121362 | |
| 120947 | 121363 | /* If the ORDER BY clause contains only columns in the current |
| 120948 | 121364 | ** virtual table then allocate space for the aOrderBy part of |
| | @@ -120994,10 +121410,11 @@ |
| 120994 | 121410 | testcase( pTerm->eOperator & WO_IS ); |
| 120995 | 121411 | testcase( pTerm->eOperator & WO_ISNULL ); |
| 120996 | 121412 | testcase( pTerm->eOperator & WO_ALL ); |
| 120997 | 121413 | if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV|WO_IS))==0 ) continue; |
| 120998 | 121414 | if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 121415 | + assert( pTerm->u.leftColumn>=(-1) ); |
| 120999 | 121416 | pIdxCons[j].iColumn = pTerm->u.leftColumn; |
| 121000 | 121417 | pIdxCons[j].iTermOffset = i; |
| 121001 | 121418 | op = (u8)pTerm->eOperator & WO_ALL; |
| 121002 | 121419 | if( op==WO_IN ) op = WO_EQ; |
| 121003 | 121420 | pIdxCons[j].op = op; |
| | @@ -121283,10 +121700,24 @@ |
| 121283 | 121700 | nRet -= 20; assert( 20==sqlite3LogEst(4) ); |
| 121284 | 121701 | } |
| 121285 | 121702 | } |
| 121286 | 121703 | return nRet; |
| 121287 | 121704 | } |
| 121705 | + |
| 121706 | + |
| 121707 | +#ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 121708 | +/* |
| 121709 | +** Return the affinity for a single column of an index. |
| 121710 | +*/ |
| 121711 | +static char sqlite3IndexColumnAffinity(sqlite3 *db, Index *pIdx, int iCol){ |
| 121712 | + if( !pIdx->zColAff ){ |
| 121713 | + if( sqlite3IndexAffinityStr(db, pIdx)==0 ) return SQLITE_AFF_BLOB; |
| 121714 | + } |
| 121715 | + return pIdx->zColAff[iCol]; |
| 121716 | +} |
| 121717 | +#endif |
| 121718 | + |
| 121288 | 121719 | |
| 121289 | 121720 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 121290 | 121721 | /* |
| 121291 | 121722 | ** This function is called to estimate the number of rows visited by a |
| 121292 | 121723 | ** range-scan on a skip-scan index. For example: |
| | @@ -121334,11 +121765,11 @@ |
| 121334 | 121765 | sqlite3 *db = pParse->db; |
| 121335 | 121766 | int nLower = -1; |
| 121336 | 121767 | int nUpper = p->nSample+1; |
| 121337 | 121768 | int rc = SQLITE_OK; |
| 121338 | 121769 | int iCol = p->aiColumn[nEq]; |
| 121339 | | - u8 aff = iCol>=0 ? p->pTable->aCol[iCol].affinity : SQLITE_AFF_INTEGER; |
| 121770 | + u8 aff = sqlite3IndexColumnAffinity(db, p, iCol); |
| 121340 | 121771 | CollSeq *pColl; |
| 121341 | 121772 | |
| 121342 | 121773 | sqlite3_value *p1 = 0; /* Value extracted from pLower */ |
| 121343 | 121774 | sqlite3_value *p2 = 0; /* Value extracted from pUpper */ |
| 121344 | 121775 | sqlite3_value *pVal = 0; /* Value extracted from record */ |
| | @@ -121482,15 +121913,12 @@ |
| 121482 | 121913 | |
| 121483 | 121914 | if( pRec ){ |
| 121484 | 121915 | testcase( pRec->nField!=pBuilder->nRecValid ); |
| 121485 | 121916 | pRec->nField = pBuilder->nRecValid; |
| 121486 | 121917 | } |
| 121487 | | - if( nEq==p->nKeyCol ){ |
| 121488 | | - aff = SQLITE_AFF_INTEGER; |
| 121489 | | - }else{ |
| 121490 | | - aff = p->pTable->aCol[p->aiColumn[nEq]].affinity; |
| 121491 | | - } |
| 121918 | + aff = sqlite3IndexColumnAffinity(pParse->db, p, nEq); |
| 121919 | + assert( nEq!=p->nKeyCol || aff==SQLITE_AFF_INTEGER ); |
| 121492 | 121920 | /* Determine iLower and iUpper using ($P) only. */ |
| 121493 | 121921 | if( nEq==0 ){ |
| 121494 | 121922 | iLower = 0; |
| 121495 | 121923 | iUpper = p->nRowEst0; |
| 121496 | 121924 | }else{ |
| | @@ -121644,11 +122072,11 @@ |
| 121644 | 122072 | if( nEq>=p->nColumn ){ |
| 121645 | 122073 | *pnRow = 1; |
| 121646 | 122074 | return SQLITE_OK; |
| 121647 | 122075 | } |
| 121648 | 122076 | |
| 121649 | | - aff = p->pTable->aCol[p->aiColumn[nEq-1]].affinity; |
| 122077 | + aff = sqlite3IndexColumnAffinity(pParse->db, p, nEq-1); |
| 121650 | 122078 | rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq-1, &bOk); |
| 121651 | 122079 | pBuilder->pRec = pRec; |
| 121652 | 122080 | if( rc!=SQLITE_OK ) return rc; |
| 121653 | 122081 | if( bOk==0 ) return SQLITE_NOTFOUND; |
| 121654 | 122082 | pBuilder->nRecValid = nEq; |
| | @@ -122071,22 +122499,24 @@ |
| 122071 | 122499 | |
| 122072 | 122500 | /* If pBuilder->pOrSet is defined, then only keep track of the costs |
| 122073 | 122501 | ** and prereqs. |
| 122074 | 122502 | */ |
| 122075 | 122503 | if( pBuilder->pOrSet!=0 ){ |
| 122504 | + if( pTemplate->nLTerm ){ |
| 122076 | 122505 | #if WHERETRACE_ENABLED |
| 122077 | | - u16 n = pBuilder->pOrSet->n; |
| 122078 | | - int x = |
| 122506 | + u16 n = pBuilder->pOrSet->n; |
| 122507 | + int x = |
| 122079 | 122508 | #endif |
| 122080 | | - whereOrInsert(pBuilder->pOrSet, pTemplate->prereq, pTemplate->rRun, |
| 122509 | + whereOrInsert(pBuilder->pOrSet, pTemplate->prereq, pTemplate->rRun, |
| 122081 | 122510 | pTemplate->nOut); |
| 122082 | 122511 | #if WHERETRACE_ENABLED /* 0x8 */ |
| 122083 | | - if( sqlite3WhereTrace & 0x8 ){ |
| 122084 | | - sqlite3DebugPrintf(x?" or-%d: ":" or-X: ", n); |
| 122085 | | - whereLoopPrint(pTemplate, pBuilder->pWC); |
| 122512 | + if( sqlite3WhereTrace & 0x8 ){ |
| 122513 | + sqlite3DebugPrintf(x?" or-%d: ":" or-X: ", n); |
| 122514 | + whereLoopPrint(pTemplate, pBuilder->pWC); |
| 122515 | + } |
| 122516 | +#endif |
| 122086 | 122517 | } |
| 122087 | | -#endif |
| 122088 | 122518 | return SQLITE_OK; |
| 122089 | 122519 | } |
| 122090 | 122520 | |
| 122091 | 122521 | /* Look for an existing WhereLoop to replace with pTemplate |
| 122092 | 122522 | */ |
| | @@ -122272,11 +122702,10 @@ |
| 122272 | 122702 | u16 saved_nLTerm; /* Original value of pNew->nLTerm */ |
| 122273 | 122703 | u16 saved_nEq; /* Original value of pNew->u.btree.nEq */ |
| 122274 | 122704 | u16 saved_nSkip; /* Original value of pNew->nSkip */ |
| 122275 | 122705 | u32 saved_wsFlags; /* Original value of pNew->wsFlags */ |
| 122276 | 122706 | LogEst saved_nOut; /* Original value of pNew->nOut */ |
| 122277 | | - int iCol; /* Index of the column in the table */ |
| 122278 | 122707 | int rc = SQLITE_OK; /* Return code */ |
| 122279 | 122708 | LogEst rSize; /* Number of rows in the table */ |
| 122280 | 122709 | LogEst rLogSize; /* Logarithm of table size */ |
| 122281 | 122710 | WhereTerm *pTop = 0, *pBtm = 0; /* Top and bottom range constraints */ |
| 122282 | 122711 | |
| | @@ -122285,28 +122714,27 @@ |
| 122285 | 122714 | |
| 122286 | 122715 | assert( (pNew->wsFlags & WHERE_VIRTUALTABLE)==0 ); |
| 122287 | 122716 | assert( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 ); |
| 122288 | 122717 | if( pNew->wsFlags & WHERE_BTM_LIMIT ){ |
| 122289 | 122718 | opMask = WO_LT|WO_LE; |
| 122290 | | - }else if( /*pProbe->tnum<=0 ||*/ (pSrc->jointype & JT_LEFT)!=0 ){ |
| 122719 | + }else if( /*pProbe->tnum<=0 ||*/ (pSrc->fg.jointype & JT_LEFT)!=0 ){ |
| 122291 | 122720 | opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE; |
| 122292 | 122721 | }else{ |
| 122293 | 122722 | opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS; |
| 122294 | 122723 | } |
| 122295 | 122724 | if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE); |
| 122296 | 122725 | |
| 122297 | 122726 | assert( pNew->u.btree.nEq<pProbe->nColumn ); |
| 122298 | | - iCol = pProbe->aiColumn[pNew->u.btree.nEq]; |
| 122299 | 122727 | |
| 122300 | | - pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol, |
| 122301 | | - opMask, pProbe); |
| 122302 | 122728 | saved_nEq = pNew->u.btree.nEq; |
| 122303 | 122729 | saved_nSkip = pNew->nSkip; |
| 122304 | 122730 | saved_nLTerm = pNew->nLTerm; |
| 122305 | 122731 | saved_wsFlags = pNew->wsFlags; |
| 122306 | 122732 | saved_prereq = pNew->prereq; |
| 122307 | 122733 | saved_nOut = pNew->nOut; |
| 122734 | + pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, saved_nEq, |
| 122735 | + opMask, pProbe); |
| 122308 | 122736 | pNew->rSetup = 0; |
| 122309 | 122737 | rSize = pProbe->aiRowLogEst[0]; |
| 122310 | 122738 | rLogSize = estLog(rSize); |
| 122311 | 122739 | for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){ |
| 122312 | 122740 | u16 eOp = pTerm->eOperator; /* Shorthand for pTerm->eOperator */ |
| | @@ -122315,11 +122743,11 @@ |
| 122315 | 122743 | int nIn = 0; |
| 122316 | 122744 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 122317 | 122745 | int nRecValid = pBuilder->nRecValid; |
| 122318 | 122746 | #endif |
| 122319 | 122747 | if( (eOp==WO_ISNULL || (pTerm->wtFlags&TERM_VNULL)!=0) |
| 122320 | | - && (iCol<0 || pSrc->pTab->aCol[iCol].notNull) |
| 122748 | + && indexColumnNotNull(pProbe, saved_nEq) |
| 122321 | 122749 | ){ |
| 122322 | 122750 | continue; /* ignore IS [NOT] NULL constraints on NOT NULL columns */ |
| 122323 | 122751 | } |
| 122324 | 122752 | if( pTerm->prereqRight & pNew->maskSelf ) continue; |
| 122325 | 122753 | |
| | @@ -122352,12 +122780,14 @@ |
| 122352 | 122780 | } |
| 122353 | 122781 | assert( nIn>0 ); /* RHS always has 2 or more terms... The parser |
| 122354 | 122782 | ** changes "x IN (?)" into "x=?". */ |
| 122355 | 122783 | |
| 122356 | 122784 | }else if( eOp & (WO_EQ|WO_IS) ){ |
| 122785 | + int iCol = pProbe->aiColumn[saved_nEq]; |
| 122357 | 122786 | pNew->wsFlags |= WHERE_COLUMN_EQ; |
| 122358 | | - if( iCol<0 || (nInMul==0 && pNew->u.btree.nEq==pProbe->nKeyCol-1) ){ |
| 122787 | + assert( saved_nEq==pNew->u.btree.nEq ); |
| 122788 | + if( iCol==(-1) || (iCol>0 && nInMul==0 && saved_nEq==pProbe->nKeyCol-1) ){ |
| 122359 | 122789 | if( iCol>=0 && pProbe->uniqNotNull==0 ){ |
| 122360 | 122790 | pNew->wsFlags |= WHERE_UNQ_WANTED; |
| 122361 | 122791 | }else{ |
| 122362 | 122792 | pNew->wsFlags |= WHERE_ONEROW; |
| 122363 | 122793 | } |
| | @@ -122404,11 +122834,11 @@ |
| 122404 | 122834 | }else{ |
| 122405 | 122835 | int nEq = ++pNew->u.btree.nEq; |
| 122406 | 122836 | assert( eOp & (WO_ISNULL|WO_EQ|WO_IN|WO_IS) ); |
| 122407 | 122837 | |
| 122408 | 122838 | assert( pNew->nOut==saved_nOut ); |
| 122409 | | - if( pTerm->truthProb<=0 && iCol>=0 ){ |
| 122839 | + if( pTerm->truthProb<=0 && pProbe->aiColumn[saved_nEq]>=0 ){ |
| 122410 | 122840 | assert( (eOp & WO_IN) || nIn==0 ); |
| 122411 | 122841 | testcase( eOp & WO_IN ); |
| 122412 | 122842 | pNew->nOut += pTerm->truthProb; |
| 122413 | 122843 | pNew->nOut -= nIn; |
| 122414 | 122844 | }else{ |
| | @@ -122580,10 +123010,14 @@ |
| 122580 | 123010 | ** in the current query. Return true if it can be and false if not. |
| 122581 | 123011 | */ |
| 122582 | 123012 | static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){ |
| 122583 | 123013 | int i; |
| 122584 | 123014 | WhereTerm *pTerm; |
| 123015 | + while( pWhere->op==TK_AND ){ |
| 123016 | + if( !whereUsablePartialIndex(iTab,pWC,pWhere->pLeft) ) return 0; |
| 123017 | + pWhere = pWhere->pRight; |
| 123018 | + } |
| 122585 | 123019 | for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 122586 | 123020 | Expr *pExpr = pTerm->pExpr; |
| 122587 | 123021 | if( sqlite3ExprImpliesExpr(pExpr, pWhere, iTab) |
| 122588 | 123022 | && (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab) |
| 122589 | 123023 | ){ |
| | @@ -122655,13 +123089,13 @@ |
| 122655 | 123089 | pSrc = pTabList->a + pNew->iTab; |
| 122656 | 123090 | pTab = pSrc->pTab; |
| 122657 | 123091 | pWC = pBuilder->pWC; |
| 122658 | 123092 | assert( !IsVirtual(pSrc->pTab) ); |
| 122659 | 123093 | |
| 122660 | | - if( pSrc->pIndex ){ |
| 123094 | + if( pSrc->pIBIndex ){ |
| 122661 | 123095 | /* An INDEXED BY clause specifies a particular index to use */ |
| 122662 | | - pProbe = pSrc->pIndex; |
| 123096 | + pProbe = pSrc->pIBIndex; |
| 122663 | 123097 | }else if( !HasRowid(pTab) ){ |
| 122664 | 123098 | pProbe = pTab->pIndex; |
| 122665 | 123099 | }else{ |
| 122666 | 123100 | /* There is no INDEXED BY clause. Create a fake Index object in local |
| 122667 | 123101 | ** variable sPk to represent the rowid primary key index. Make this |
| | @@ -122677,11 +123111,11 @@ |
| 122677 | 123111 | sPk.pTable = pTab; |
| 122678 | 123112 | sPk.szIdxRow = pTab->szTabRow; |
| 122679 | 123113 | aiRowEstPk[0] = pTab->nRowLogEst; |
| 122680 | 123114 | aiRowEstPk[1] = 0; |
| 122681 | 123115 | pFirst = pSrc->pTab->pIndex; |
| 122682 | | - if( pSrc->notIndexed==0 ){ |
| 123116 | + if( pSrc->fg.notIndexed==0 ){ |
| 122683 | 123117 | /* The real indices of the table are only considered if the |
| 122684 | 123118 | ** NOT INDEXED qualifier is omitted from the FROM clause */ |
| 122685 | 123119 | sPk.pNext = pFirst; |
| 122686 | 123120 | } |
| 122687 | 123121 | pProbe = &sPk; |
| | @@ -122689,18 +123123,18 @@ |
| 122689 | 123123 | rSize = pTab->nRowLogEst; |
| 122690 | 123124 | rLogSize = estLog(rSize); |
| 122691 | 123125 | |
| 122692 | 123126 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 122693 | 123127 | /* Automatic indexes */ |
| 122694 | | - if( !pBuilder->pOrSet /* Not part of an OR optimization */ |
| 123128 | + if( !pBuilder->pOrSet /* Not part of an OR optimization */ |
| 122695 | 123129 | && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0 |
| 122696 | 123130 | && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 |
| 122697 | | - && pSrc->pIndex==0 /* Has no INDEXED BY clause */ |
| 122698 | | - && !pSrc->notIndexed /* Has no NOT INDEXED clause */ |
| 122699 | | - && HasRowid(pTab) /* Is not a WITHOUT ROWID table. (FIXME: Why not?) */ |
| 122700 | | - && !pSrc->isCorrelated /* Not a correlated subquery */ |
| 122701 | | - && !pSrc->isRecursive /* Not a recursive common table expression. */ |
| 123131 | + && pSrc->pIBIndex==0 /* Has no INDEXED BY clause */ |
| 123132 | + && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */ |
| 123133 | + && HasRowid(pTab) /* Is not a WITHOUT ROWID table. (FIXME: Why not?) */ |
| 123134 | + && !pSrc->fg.isCorrelated /* Not a correlated subquery */ |
| 123135 | + && !pSrc->fg.isRecursive /* Not a recursive common table expression. */ |
| 122702 | 123136 | ){ |
| 122703 | 123137 | /* Generate auto-index WhereLoops */ |
| 122704 | 123138 | WhereTerm *pTerm; |
| 122705 | 123139 | WhereTerm *pWCEnd = pWC->a + pWC->nTerm; |
| 122706 | 123140 | for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){ |
| | @@ -122817,11 +123251,11 @@ |
| 122817 | 123251 | pBuilder->pRec = 0; |
| 122818 | 123252 | #endif |
| 122819 | 123253 | |
| 122820 | 123254 | /* If there was an INDEXED BY clause, then only that one index is |
| 122821 | 123255 | ** considered. */ |
| 122822 | | - if( pSrc->pIndex ) break; |
| 123256 | + if( pSrc->pIBIndex ) break; |
| 122823 | 123257 | } |
| 122824 | 123258 | return rc; |
| 122825 | 123259 | } |
| 122826 | 123260 | |
| 122827 | 123261 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| | @@ -123163,20 +123597,20 @@ |
| 123163 | 123597 | whereLoopInit(pNew); |
| 123164 | 123598 | for(iTab=0, pItem=pTabList->a; pItem<pEnd; iTab++, pItem++){ |
| 123165 | 123599 | Bitmask mUnusable = 0; |
| 123166 | 123600 | pNew->iTab = iTab; |
| 123167 | 123601 | pNew->maskSelf = sqlite3WhereGetMask(&pWInfo->sMaskSet, pItem->iCursor); |
| 123168 | | - if( ((pItem->jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){ |
| 123602 | + if( ((pItem->fg.jointype|priorJointype) & (JT_LEFT|JT_CROSS))!=0 ){ |
| 123169 | 123603 | /* This condition is true when pItem is the FROM clause term on the |
| 123170 | 123604 | ** right-hand-side of a LEFT or CROSS JOIN. */ |
| 123171 | 123605 | mExtra = mPrior; |
| 123172 | 123606 | } |
| 123173 | | - priorJointype = pItem->jointype; |
| 123607 | + priorJointype = pItem->fg.jointype; |
| 123174 | 123608 | if( IsVirtual(pItem->pTab) ){ |
| 123175 | 123609 | struct SrcList_item *p; |
| 123176 | 123610 | for(p=&pItem[1]; p<pEnd; p++){ |
| 123177 | | - if( mUnusable || (p->jointype & (JT_LEFT|JT_CROSS)) ){ |
| 123611 | + if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){ |
| 123178 | 123612 | mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor); |
| 123179 | 123613 | } |
| 123180 | 123614 | } |
| 123181 | 123615 | rc = whereLoopAddVirtual(pBuilder, mExtra, mUnusable); |
| 123182 | 123616 | }else{ |
| | @@ -123902,11 +124336,11 @@ |
| 123902 | 124336 | if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0; |
| 123903 | 124337 | assert( pWInfo->pTabList->nSrc>=1 ); |
| 123904 | 124338 | pItem = pWInfo->pTabList->a; |
| 123905 | 124339 | pTab = pItem->pTab; |
| 123906 | 124340 | if( IsVirtual(pTab) ) return 0; |
| 123907 | | - if( pItem->zIndexedBy ) return 0; |
| 124341 | + if( pItem->fg.isIndexedBy ) return 0; |
| 123908 | 124342 | iCur = pItem->iCursor; |
| 123909 | 124343 | pWC = &pWInfo->sWC; |
| 123910 | 124344 | pLoop = pBuilder->pNew; |
| 123911 | 124345 | pLoop->wsFlags = 0; |
| 123912 | 124346 | pLoop->nSkip = 0; |
| | @@ -123927,11 +124361,11 @@ |
| 123927 | 124361 | || pIdx->pPartIdxWhere!=0 |
| 123928 | 124362 | || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace) |
| 123929 | 124363 | ) continue; |
| 123930 | 124364 | opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ; |
| 123931 | 124365 | for(j=0; j<pIdx->nKeyCol; j++){ |
| 123932 | | - pTerm = sqlite3WhereFindTerm(pWC, iCur, pIdx->aiColumn[j], 0, opMask, pIdx); |
| 124366 | + pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx); |
| 123933 | 124367 | if( pTerm==0 ) break; |
| 123934 | 124368 | testcase( pTerm->eOperator & WO_IS ); |
| 123935 | 124369 | pLoop->aLTerm[j] = pTerm; |
| 123936 | 124370 | } |
| 123937 | 124371 | if( j!=pIdx->nKeyCol ) continue; |
| | @@ -124167,35 +124601,30 @@ |
| 124167 | 124601 | } |
| 124168 | 124602 | } |
| 124169 | 124603 | |
| 124170 | 124604 | /* Assign a bit from the bitmask to every term in the FROM clause. |
| 124171 | 124605 | ** |
| 124172 | | - ** When assigning bitmask values to FROM clause cursors, it must be |
| 124173 | | - ** the case that if X is the bitmask for the N-th FROM clause term then |
| 124174 | | - ** the bitmask for all FROM clause terms to the left of the N-th term |
| 124175 | | - ** is (X-1). An expression from the ON clause of a LEFT JOIN can use |
| 124176 | | - ** its Expr.iRightJoinTable value to find the bitmask of the right table |
| 124177 | | - ** of the join. Subtracting one from the right table bitmask gives a |
| 124178 | | - ** bitmask for all tables to the left of the join. Knowing the bitmask |
| 124179 | | - ** for all tables to the left of a left join is important. Ticket #3015. |
| 124606 | + ** The N-th term of the FROM clause is assigned a bitmask of 1<<N. |
| 124607 | + ** |
| 124608 | + ** The rule of the previous sentence ensures thta if X is the bitmask for |
| 124609 | + ** a table T, then X-1 is the bitmask for all other tables to the left of T. |
| 124610 | + ** Knowing the bitmask for all tables to the left of a left join is |
| 124611 | + ** important. Ticket #3015. |
| 124180 | 124612 | ** |
| 124181 | 124613 | ** Note that bitmasks are created for all pTabList->nSrc tables in |
| 124182 | 124614 | ** pTabList, not just the first nTabList tables. nTabList is normally |
| 124183 | 124615 | ** equal to pTabList->nSrc but might be shortened to 1 if the |
| 124184 | 124616 | ** WHERE_ONETABLE_ONLY flag is set. |
| 124185 | 124617 | */ |
| 124186 | 124618 | for(ii=0; ii<pTabList->nSrc; ii++){ |
| 124187 | 124619 | createMask(pMaskSet, pTabList->a[ii].iCursor); |
| 124188 | | - } |
| 124189 | | -#ifndef NDEBUG |
| 124190 | | - { |
| 124191 | | - Bitmask toTheLeft = 0; |
| 124192 | | - for(ii=0; ii<pTabList->nSrc; ii++){ |
| 124193 | | - Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor); |
| 124194 | | - assert( (m-1)==toTheLeft ); |
| 124195 | | - toTheLeft |= m; |
| 124196 | | - } |
| 124620 | + sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC); |
| 124621 | + } |
| 124622 | +#ifdef SQLITE_DEBUG |
| 124623 | + for(ii=0; ii<pTabList->nSrc; ii++){ |
| 124624 | + Bitmask m = sqlite3WhereGetMask(pMaskSet, pTabList->a[ii].iCursor); |
| 124625 | + assert( m==MASKBIT(ii) ); |
| 124197 | 124626 | } |
| 124198 | 124627 | #endif |
| 124199 | 124628 | |
| 124200 | 124629 | /* Analyze all of the subexpressions. */ |
| 124201 | 124630 | sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC); |
| | @@ -124289,11 +124718,11 @@ |
| 124289 | 124718 | tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy); |
| 124290 | 124719 | } |
| 124291 | 124720 | while( pWInfo->nLevel>=2 ){ |
| 124292 | 124721 | WhereTerm *pTerm, *pEnd; |
| 124293 | 124722 | pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop; |
| 124294 | | - if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break; |
| 124723 | + if( (pWInfo->pTabList->a[pLoop->iTab].fg.jointype & JT_LEFT)==0 ) break; |
| 124295 | 124724 | if( (wctrlFlags & WHERE_WANT_DISTINCT)==0 |
| 124296 | 124725 | && (pLoop->wsFlags & WHERE_ONEROW)==0 |
| 124297 | 124726 | ){ |
| 124298 | 124727 | break; |
| 124299 | 124728 | } |
| | @@ -124527,11 +124956,11 @@ |
| 124527 | 124956 | sqlite3VdbeJumpHere(v, pIn->addrInTop-1); |
| 124528 | 124957 | } |
| 124529 | 124958 | } |
| 124530 | 124959 | sqlite3VdbeResolveLabel(v, pLevel->addrBrk); |
| 124531 | 124960 | if( pLevel->addrSkip ){ |
| 124532 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip); |
| 124961 | + sqlite3VdbeGoto(v, pLevel->addrSkip); |
| 124533 | 124962 | VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName)); |
| 124534 | 124963 | sqlite3VdbeJumpHere(v, pLevel->addrSkip); |
| 124535 | 124964 | sqlite3VdbeJumpHere(v, pLevel->addrSkip-2); |
| 124536 | 124965 | } |
| 124537 | 124966 | if( pLevel->addrLikeRep ){ |
| | @@ -124555,11 +124984,11 @@ |
| 124555 | 124984 | sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur); |
| 124556 | 124985 | } |
| 124557 | 124986 | if( pLevel->op==OP_Return ){ |
| 124558 | 124987 | sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst); |
| 124559 | 124988 | }else{ |
| 124560 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrFirst); |
| 124989 | + sqlite3VdbeGoto(v, pLevel->addrFirst); |
| 124561 | 124990 | } |
| 124562 | 124991 | sqlite3VdbeJumpHere(v, addr); |
| 124563 | 124992 | } |
| 124564 | 124993 | VdbeModuleComment((v, "End WHERE-loop%d: %s", i, |
| 124565 | 124994 | pWInfo->pTabList->a[pLevel->iFrom].pTab->zName)); |
| | @@ -124582,11 +125011,11 @@ |
| 124582 | 125011 | |
| 124583 | 125012 | /* For a co-routine, change all OP_Column references to the table of |
| 124584 | 125013 | ** the co-routine into OP_Copy of result contained in a register. |
| 124585 | 125014 | ** OP_Rowid becomes OP_Null. |
| 124586 | 125015 | */ |
| 124587 | | - if( pTabItem->viaCoroutine && !db->mallocFailed ){ |
| 125016 | + if( pTabItem->fg.viaCoroutine && !db->mallocFailed ){ |
| 124588 | 125017 | translateColumnToCopy(v, pLevel->addrBody, pLevel->iTabCur, |
| 124589 | 125018 | pTabItem->regResult); |
| 124590 | 125019 | continue; |
| 124591 | 125020 | } |
| 124592 | 125021 | |
| | @@ -124816,10 +125245,33 @@ |
| 124816 | 125245 | ){ |
| 124817 | 125246 | pOut->pExpr = sqlite3PExpr(pParse, op, pOperand->pExpr, 0, 0); |
| 124818 | 125247 | pOut->zStart = pPreOp->z; |
| 124819 | 125248 | pOut->zEnd = pOperand->zEnd; |
| 124820 | 125249 | } |
| 125250 | + |
| 125251 | + /* Add a single new term to an ExprList that is used to store a |
| 125252 | + ** list of identifiers. Report an error if the ID list contains |
| 125253 | + ** a COLLATE clause or an ASC or DESC keyword, except ignore the |
| 125254 | + ** error while parsing a legacy schema. |
| 125255 | + */ |
| 125256 | + static ExprList *parserAddExprIdListTerm( |
| 125257 | + Parse *pParse, |
| 125258 | + ExprList *pPrior, |
| 125259 | + Token *pIdToken, |
| 125260 | + int hasCollate, |
| 125261 | + int sortOrder |
| 125262 | + ){ |
| 125263 | + ExprList *p = sqlite3ExprListAppend(pParse, pPrior, 0); |
| 125264 | + if( (hasCollate || sortOrder!=SQLITE_SO_UNDEFINED) |
| 125265 | + && pParse->db->init.busy==0 |
| 125266 | + ){ |
| 125267 | + sqlite3ErrorMsg(pParse, "syntax error after column name \"%.*s\"", |
| 125268 | + pIdToken->n, pIdToken->z); |
| 125269 | + } |
| 125270 | + sqlite3ExprListSetName(pParse, p, pIdToken, 1); |
| 125271 | + return p; |
| 125272 | + } |
| 124821 | 125273 | /* Next is all token values, in a form suitable for use by makeheaders. |
| 124822 | 125274 | ** This section will be null unless lemon is run with the -m switch. |
| 124823 | 125275 | */ |
| 124824 | 125276 | /* |
| 124825 | 125277 | ** These constants (all generated automatically by the parser generator) |
| | @@ -124860,14 +125312,21 @@ |
| 124860 | 125312 | ** zero the stack is dynamically sized using realloc() |
| 124861 | 125313 | ** sqlite3ParserARG_SDECL A static variable declaration for the %extra_argument |
| 124862 | 125314 | ** sqlite3ParserARG_PDECL A parameter declaration for the %extra_argument |
| 124863 | 125315 | ** sqlite3ParserARG_STORE Code to store %extra_argument into yypParser |
| 124864 | 125316 | ** sqlite3ParserARG_FETCH Code to extract %extra_argument from yypParser |
| 125317 | +** YYERRORSYMBOL is the code number of the error symbol. If not |
| 125318 | +** defined, then do no error processing. |
| 124865 | 125319 | ** YYNSTATE the combined number of states. |
| 124866 | 125320 | ** YYNRULE the number of rules in the grammar |
| 124867 | | -** YYERRORSYMBOL is the code number of the error symbol. If not |
| 124868 | | -** defined, then do no error processing. |
| 125321 | +** YY_MAX_SHIFT Maximum value for shift actions |
| 125322 | +** YY_MIN_SHIFTREDUCE Minimum value for shift-reduce actions |
| 125323 | +** YY_MAX_SHIFTREDUCE Maximum value for shift-reduce actions |
| 125324 | +** YY_MIN_REDUCE Maximum value for reduce actions |
| 125325 | +** YY_ERROR_ACTION The yy_action[] code for syntax error |
| 125326 | +** YY_ACCEPT_ACTION The yy_action[] code for accept |
| 125327 | +** YY_NO_ACTION The yy_action[] code for no-op |
| 124869 | 125328 | */ |
| 124870 | 125329 | #define YYCODETYPE unsigned char |
| 124871 | 125330 | #define YYNOCODE 254 |
| 124872 | 125331 | #define YYACTIONTYPE unsigned short int |
| 124873 | 125332 | #define YYWILDCARD 70 |
| | @@ -124896,16 +125355,21 @@ |
| 124896 | 125355 | #endif |
| 124897 | 125356 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 124898 | 125357 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 124899 | 125358 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 124900 | 125359 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 124901 | | -#define YYNSTATE 642 |
| 124902 | | -#define YYNRULE 327 |
| 124903 | 125360 | #define YYFALLBACK 1 |
| 124904 | | -#define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 124905 | | -#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 124906 | | -#define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| 125361 | +#define YYNSTATE 436 |
| 125362 | +#define YYNRULE 328 |
| 125363 | +#define YY_MAX_SHIFT 435 |
| 125364 | +#define YY_MIN_SHIFTREDUCE 649 |
| 125365 | +#define YY_MAX_SHIFTREDUCE 976 |
| 125366 | +#define YY_MIN_REDUCE 977 |
| 125367 | +#define YY_MAX_REDUCE 1304 |
| 125368 | +#define YY_ERROR_ACTION 1305 |
| 125369 | +#define YY_ACCEPT_ACTION 1306 |
| 125370 | +#define YY_NO_ACTION 1307 |
| 124907 | 125371 | |
| 124908 | 125372 | /* The yyzerominor constant is used to initialize instances of |
| 124909 | 125373 | ** YYMINORTYPE objects to zero. */ |
| 124910 | 125374 | static const YYMINORTYPE yyzerominor = { 0 }; |
| 124911 | 125375 | |
| | @@ -124928,20 +125392,24 @@ |
| 124928 | 125392 | ** action integer. |
| 124929 | 125393 | ** |
| 124930 | 125394 | ** Suppose the action integer is N. Then the action is determined as |
| 124931 | 125395 | ** follows |
| 124932 | 125396 | ** |
| 124933 | | -** 0 <= N < YYNSTATE Shift N. That is, push the lookahead |
| 125397 | +** 0 <= N <= YY_MAX_SHIFT Shift N. That is, push the lookahead |
| 124934 | 125398 | ** token onto the stack and goto state N. |
| 124935 | 125399 | ** |
| 124936 | | -** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. |
| 125400 | +** N between YY_MIN_SHIFTREDUCE Shift to an arbitrary state then |
| 125401 | +** and YY_MAX_SHIFTREDUCE reduce by rule N-YY_MIN_SHIFTREDUCE. |
| 124937 | 125402 | ** |
| 124938 | | -** N == YYNSTATE+YYNRULE A syntax error has occurred. |
| 125403 | +** N between YY_MIN_REDUCE Reduce by rule N-YY_MIN_REDUCE |
| 125404 | +** and YY_MAX_REDUCE |
| 125405 | + |
| 125406 | +** N == YY_ERROR_ACTION A syntax error has occurred. |
| 124939 | 125407 | ** |
| 124940 | | -** N == YYNSTATE+YYNRULE+1 The parser accepts its input. |
| 125408 | +** N == YY_ACCEPT_ACTION The parser accepts its input. |
| 124941 | 125409 | ** |
| 124942 | | -** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused |
| 125410 | +** N == YY_NO_ACTION No such action. Denotes unused |
| 124943 | 125411 | ** slots in the yy_action[] table. |
| 124944 | 125412 | ** |
| 124945 | 125413 | ** The action table is constructed as a single large table named yy_action[]. |
| 124946 | 125414 | ** Given state S and lookahead X, the action is computed as |
| 124947 | 125415 | ** |
| | @@ -124967,467 +125435,450 @@ |
| 124967 | 125435 | ** shifting terminals. |
| 124968 | 125436 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 124969 | 125437 | ** shifting non-terminals after a reduce. |
| 124970 | 125438 | ** yy_default[] Default action for each state. |
| 124971 | 125439 | */ |
| 124972 | | -#define YY_ACTTAB_COUNT (1497) |
| 125440 | +#define YY_ACTTAB_COUNT (1501) |
| 124973 | 125441 | static const YYACTIONTYPE yy_action[] = { |
| 124974 | | - /* 0 */ 306, 212, 432, 955, 639, 191, 955, 295, 559, 88, |
| 124975 | | - /* 10 */ 88, 88, 88, 81, 86, 86, 86, 86, 85, 85, |
| 124976 | | - /* 20 */ 84, 84, 84, 83, 330, 185, 184, 183, 635, 635, |
| 124977 | | - /* 30 */ 292, 606, 606, 88, 88, 88, 88, 683, 86, 86, |
| 124978 | | - /* 40 */ 86, 86, 85, 85, 84, 84, 84, 83, 330, 16, |
| 124979 | | - /* 50 */ 436, 597, 89, 90, 80, 600, 599, 601, 601, 87, |
| 124980 | | - /* 60 */ 87, 88, 88, 88, 88, 684, 86, 86, 86, 86, |
| 124981 | | - /* 70 */ 85, 85, 84, 84, 84, 83, 330, 306, 559, 84, |
| 124982 | | - /* 80 */ 84, 84, 83, 330, 65, 86, 86, 86, 86, 85, |
| 124983 | | - /* 90 */ 85, 84, 84, 84, 83, 330, 635, 635, 634, 633, |
| 124984 | | - /* 100 */ 182, 682, 550, 379, 376, 375, 17, 322, 606, 606, |
| 124985 | | - /* 110 */ 371, 198, 479, 91, 374, 82, 79, 165, 85, 85, |
| 124986 | | - /* 120 */ 84, 84, 84, 83, 330, 598, 635, 635, 107, 89, |
| 124987 | | - /* 130 */ 90, 80, 600, 599, 601, 601, 87, 87, 88, 88, |
| 124988 | | - /* 140 */ 88, 88, 186, 86, 86, 86, 86, 85, 85, 84, |
| 124989 | | - /* 150 */ 84, 84, 83, 330, 306, 594, 594, 142, 328, 327, |
| 124990 | | - /* 160 */ 484, 249, 344, 238, 635, 635, 634, 633, 585, 448, |
| 124991 | | - /* 170 */ 526, 525, 229, 388, 1, 394, 450, 584, 449, 635, |
| 124992 | | - /* 180 */ 635, 635, 635, 319, 395, 606, 606, 199, 157, 273, |
| 124993 | | - /* 190 */ 382, 268, 381, 187, 635, 635, 634, 633, 311, 555, |
| 124994 | | - /* 200 */ 266, 593, 593, 266, 347, 588, 89, 90, 80, 600, |
| 124995 | | - /* 210 */ 599, 601, 601, 87, 87, 88, 88, 88, 88, 478, |
| 124996 | | - /* 220 */ 86, 86, 86, 86, 85, 85, 84, 84, 84, 83, |
| 124997 | | - /* 230 */ 330, 306, 272, 536, 634, 633, 146, 610, 197, 310, |
| 124998 | | - /* 240 */ 575, 182, 482, 271, 379, 376, 375, 506, 21, 634, |
| 124999 | | - /* 250 */ 633, 634, 633, 635, 635, 374, 611, 574, 548, 440, |
| 125000 | | - /* 260 */ 111, 563, 606, 606, 634, 633, 324, 479, 608, 608, |
| 125001 | | - /* 270 */ 608, 300, 435, 573, 119, 407, 210, 162, 562, 883, |
| 125002 | | - /* 280 */ 592, 592, 306, 89, 90, 80, 600, 599, 601, 601, |
| 125003 | | - /* 290 */ 87, 87, 88, 88, 88, 88, 506, 86, 86, 86, |
| 125004 | | - /* 300 */ 86, 85, 85, 84, 84, 84, 83, 330, 620, 111, |
| 125005 | | - /* 310 */ 635, 635, 361, 606, 606, 358, 249, 349, 248, 433, |
| 125006 | | - /* 320 */ 243, 479, 586, 634, 633, 195, 611, 93, 119, 221, |
| 125007 | | - /* 330 */ 575, 497, 534, 534, 89, 90, 80, 600, 599, 601, |
| 125008 | | - /* 340 */ 601, 87, 87, 88, 88, 88, 88, 574, 86, 86, |
| 125009 | | - /* 350 */ 86, 86, 85, 85, 84, 84, 84, 83, 330, 306, |
| 125010 | | - /* 360 */ 77, 429, 638, 573, 589, 530, 240, 230, 242, 105, |
| 125011 | | - /* 370 */ 249, 349, 248, 515, 588, 208, 460, 529, 564, 173, |
| 125012 | | - /* 380 */ 634, 633, 970, 144, 430, 2, 424, 228, 380, 557, |
| 125013 | | - /* 390 */ 606, 606, 190, 153, 159, 158, 514, 51, 632, 631, |
| 125014 | | - /* 400 */ 630, 71, 536, 432, 954, 196, 610, 954, 614, 45, |
| 125015 | | - /* 410 */ 18, 89, 90, 80, 600, 599, 601, 601, 87, 87, |
| 125016 | | - /* 420 */ 88, 88, 88, 88, 261, 86, 86, 86, 86, 85, |
| 125017 | | - /* 430 */ 85, 84, 84, 84, 83, 330, 306, 608, 608, 608, |
| 125018 | | - /* 440 */ 542, 424, 402, 385, 241, 506, 451, 320, 211, 543, |
| 125019 | | - /* 450 */ 164, 436, 386, 293, 451, 587, 108, 496, 111, 334, |
| 125020 | | - /* 460 */ 391, 591, 424, 614, 27, 452, 453, 606, 606, 72, |
| 125021 | | - /* 470 */ 257, 70, 259, 452, 339, 342, 564, 582, 68, 415, |
| 125022 | | - /* 480 */ 469, 328, 327, 62, 614, 45, 110, 393, 89, 90, |
| 125023 | | - /* 490 */ 80, 600, 599, 601, 601, 87, 87, 88, 88, 88, |
| 125024 | | - /* 500 */ 88, 152, 86, 86, 86, 86, 85, 85, 84, 84, |
| 125025 | | - /* 510 */ 84, 83, 330, 306, 110, 499, 520, 538, 402, 389, |
| 125026 | | - /* 520 */ 424, 110, 566, 500, 593, 593, 454, 82, 79, 165, |
| 125027 | | - /* 530 */ 424, 591, 384, 564, 340, 615, 188, 162, 424, 350, |
| 125028 | | - /* 540 */ 616, 424, 614, 44, 606, 606, 445, 582, 300, 434, |
| 125029 | | - /* 550 */ 151, 19, 614, 9, 568, 580, 348, 615, 469, 567, |
| 125030 | | - /* 560 */ 614, 26, 616, 614, 45, 89, 90, 80, 600, 599, |
| 125031 | | - /* 570 */ 601, 601, 87, 87, 88, 88, 88, 88, 411, 86, |
| 125032 | | - /* 580 */ 86, 86, 86, 85, 85, 84, 84, 84, 83, 330, |
| 125033 | | - /* 590 */ 306, 579, 110, 578, 521, 282, 433, 398, 400, 255, |
| 125034 | | - /* 600 */ 486, 82, 79, 165, 487, 164, 82, 79, 165, 488, |
| 125035 | | - /* 610 */ 488, 364, 387, 424, 544, 544, 509, 350, 362, 155, |
| 125036 | | - /* 620 */ 191, 606, 606, 559, 642, 640, 333, 82, 79, 165, |
| 125037 | | - /* 630 */ 305, 564, 507, 312, 357, 614, 45, 329, 596, 595, |
| 125038 | | - /* 640 */ 194, 337, 89, 90, 80, 600, 599, 601, 601, 87, |
| 125039 | | - /* 650 */ 87, 88, 88, 88, 88, 424, 86, 86, 86, 86, |
| 125040 | | - /* 660 */ 85, 85, 84, 84, 84, 83, 330, 306, 20, 323, |
| 125041 | | - /* 670 */ 150, 263, 211, 543, 421, 596, 595, 614, 22, 424, |
| 125042 | | - /* 680 */ 193, 424, 284, 424, 391, 424, 509, 424, 577, 424, |
| 125043 | | - /* 690 */ 186, 335, 424, 559, 424, 313, 120, 546, 606, 606, |
| 125044 | | - /* 700 */ 67, 614, 47, 614, 50, 614, 48, 614, 100, 614, |
| 125045 | | - /* 710 */ 99, 614, 101, 576, 614, 102, 614, 109, 326, 89, |
| 125046 | | - /* 720 */ 90, 80, 600, 599, 601, 601, 87, 87, 88, 88, |
| 125047 | | - /* 730 */ 88, 88, 424, 86, 86, 86, 86, 85, 85, 84, |
| 125048 | | - /* 740 */ 84, 84, 83, 330, 306, 424, 311, 424, 585, 54, |
| 125049 | | - /* 750 */ 424, 516, 517, 590, 614, 112, 424, 584, 424, 572, |
| 125050 | | - /* 760 */ 424, 195, 424, 571, 424, 67, 424, 614, 94, 614, |
| 125051 | | - /* 770 */ 98, 424, 614, 97, 264, 606, 606, 195, 614, 46, |
| 125052 | | - /* 780 */ 614, 96, 614, 30, 614, 49, 614, 115, 614, 114, |
| 125053 | | - /* 790 */ 418, 229, 388, 614, 113, 306, 89, 90, 80, 600, |
| 125054 | | - /* 800 */ 599, 601, 601, 87, 87, 88, 88, 88, 88, 424, |
| 125055 | | - /* 810 */ 86, 86, 86, 86, 85, 85, 84, 84, 84, 83, |
| 125056 | | - /* 820 */ 330, 119, 424, 590, 110, 372, 606, 606, 195, 53, |
| 125057 | | - /* 830 */ 250, 614, 29, 195, 472, 438, 729, 190, 302, 498, |
| 125058 | | - /* 840 */ 14, 523, 641, 2, 614, 43, 306, 89, 90, 80, |
| 125059 | | - /* 850 */ 600, 599, 601, 601, 87, 87, 88, 88, 88, 88, |
| 125060 | | - /* 860 */ 424, 86, 86, 86, 86, 85, 85, 84, 84, 84, |
| 125061 | | - /* 870 */ 83, 330, 424, 613, 964, 964, 354, 606, 606, 420, |
| 125062 | | - /* 880 */ 312, 64, 614, 42, 391, 355, 283, 437, 301, 255, |
| 125063 | | - /* 890 */ 414, 410, 495, 492, 614, 28, 471, 306, 89, 90, |
| 125064 | | - /* 900 */ 80, 600, 599, 601, 601, 87, 87, 88, 88, 88, |
| 125065 | | - /* 910 */ 88, 424, 86, 86, 86, 86, 85, 85, 84, 84, |
| 125066 | | - /* 920 */ 84, 83, 330, 424, 110, 110, 110, 110, 606, 606, |
| 125067 | | - /* 930 */ 110, 254, 13, 614, 41, 532, 531, 283, 481, 531, |
| 125068 | | - /* 940 */ 457, 284, 119, 561, 356, 614, 40, 284, 306, 89, |
| 125069 | | - /* 950 */ 78, 80, 600, 599, 601, 601, 87, 87, 88, 88, |
| 125070 | | - /* 960 */ 88, 88, 424, 86, 86, 86, 86, 85, 85, 84, |
| 125071 | | - /* 970 */ 84, 84, 83, 330, 110, 424, 341, 220, 555, 606, |
| 125072 | | - /* 980 */ 606, 351, 555, 318, 614, 95, 413, 255, 83, 330, |
| 125073 | | - /* 990 */ 284, 284, 255, 640, 333, 356, 255, 614, 39, 306, |
| 125074 | | - /* 1000 */ 356, 90, 80, 600, 599, 601, 601, 87, 87, 88, |
| 125075 | | - /* 1010 */ 88, 88, 88, 424, 86, 86, 86, 86, 85, 85, |
| 125076 | | - /* 1020 */ 84, 84, 84, 83, 330, 424, 317, 316, 141, 465, |
| 125077 | | - /* 1030 */ 606, 606, 219, 619, 463, 614, 10, 417, 462, 255, |
| 125078 | | - /* 1040 */ 189, 510, 553, 351, 207, 363, 161, 614, 38, 315, |
| 125079 | | - /* 1050 */ 218, 255, 255, 80, 600, 599, 601, 601, 87, 87, |
| 125080 | | - /* 1060 */ 88, 88, 88, 88, 424, 86, 86, 86, 86, 85, |
| 125081 | | - /* 1070 */ 85, 84, 84, 84, 83, 330, 76, 419, 255, 3, |
| 125082 | | - /* 1080 */ 878, 461, 424, 247, 331, 331, 614, 37, 217, 76, |
| 125083 | | - /* 1090 */ 419, 390, 3, 216, 215, 422, 4, 331, 331, 424, |
| 125084 | | - /* 1100 */ 547, 12, 424, 545, 614, 36, 424, 541, 422, 424, |
| 125085 | | - /* 1110 */ 540, 424, 214, 424, 408, 424, 539, 403, 605, 605, |
| 125086 | | - /* 1120 */ 237, 614, 25, 119, 614, 24, 588, 408, 614, 45, |
| 125087 | | - /* 1130 */ 118, 614, 35, 614, 34, 614, 33, 614, 23, 588, |
| 125088 | | - /* 1140 */ 60, 223, 603, 602, 513, 378, 73, 74, 140, 139, |
| 125089 | | - /* 1150 */ 424, 110, 265, 75, 426, 425, 59, 424, 610, 73, |
| 125090 | | - /* 1160 */ 74, 549, 402, 404, 424, 373, 75, 426, 425, 604, |
| 125091 | | - /* 1170 */ 138, 610, 614, 11, 392, 76, 419, 181, 3, 614, |
| 125092 | | - /* 1180 */ 32, 271, 369, 331, 331, 493, 614, 31, 149, 608, |
| 125093 | | - /* 1190 */ 608, 608, 607, 15, 422, 365, 614, 8, 137, 489, |
| 125094 | | - /* 1200 */ 136, 190, 608, 608, 608, 607, 15, 485, 176, 135, |
| 125095 | | - /* 1210 */ 7, 252, 477, 408, 174, 133, 175, 474, 57, 56, |
| 125096 | | - /* 1220 */ 132, 130, 119, 76, 419, 588, 3, 468, 245, 464, |
| 125097 | | - /* 1230 */ 171, 331, 331, 125, 123, 456, 447, 122, 446, 104, |
| 125098 | | - /* 1240 */ 336, 231, 422, 166, 154, 73, 74, 332, 116, 431, |
| 125099 | | - /* 1250 */ 121, 309, 75, 426, 425, 222, 106, 610, 308, 637, |
| 125100 | | - /* 1260 */ 204, 408, 629, 627, 628, 6, 200, 428, 427, 290, |
| 125101 | | - /* 1270 */ 203, 622, 201, 588, 62, 63, 289, 66, 419, 399, |
| 125102 | | - /* 1280 */ 3, 401, 288, 92, 143, 331, 331, 287, 608, 608, |
| 125103 | | - /* 1290 */ 608, 607, 15, 73, 74, 227, 422, 325, 69, 416, |
| 125104 | | - /* 1300 */ 75, 426, 425, 612, 412, 610, 192, 61, 569, 209, |
| 125105 | | - /* 1310 */ 396, 226, 278, 225, 383, 408, 527, 558, 276, 533, |
| 125106 | | - /* 1320 */ 552, 528, 321, 523, 370, 508, 180, 588, 494, 179, |
| 125107 | | - /* 1330 */ 366, 117, 253, 269, 522, 503, 608, 608, 608, 607, |
| 125108 | | - /* 1340 */ 15, 551, 502, 58, 274, 524, 178, 73, 74, 304, |
| 125109 | | - /* 1350 */ 501, 368, 303, 206, 75, 426, 425, 491, 360, 610, |
| 125110 | | - /* 1360 */ 213, 177, 483, 131, 345, 298, 297, 296, 202, 294, |
| 125111 | | - /* 1370 */ 480, 490, 466, 134, 172, 129, 444, 346, 470, 128, |
| 125112 | | - /* 1380 */ 314, 459, 103, 127, 126, 148, 124, 167, 443, 235, |
| 125113 | | - /* 1390 */ 608, 608, 608, 607, 15, 442, 439, 623, 234, 299, |
| 125114 | | - /* 1400 */ 145, 583, 291, 377, 581, 160, 119, 156, 270, 636, |
| 125115 | | - /* 1410 */ 971, 169, 279, 626, 520, 625, 473, 624, 170, 621, |
| 125116 | | - /* 1420 */ 618, 119, 168, 55, 409, 423, 537, 609, 286, 285, |
| 125117 | | - /* 1430 */ 405, 570, 560, 556, 5, 52, 458, 554, 147, 267, |
| 125118 | | - /* 1440 */ 519, 504, 518, 406, 262, 239, 260, 512, 343, 511, |
| 125119 | | - /* 1450 */ 258, 353, 565, 256, 224, 251, 359, 277, 275, 476, |
| 125120 | | - /* 1460 */ 475, 246, 352, 244, 467, 455, 236, 233, 232, 307, |
| 125121 | | - /* 1470 */ 441, 281, 205, 163, 397, 280, 535, 505, 330, 617, |
| 125122 | | - /* 1480 */ 971, 971, 971, 971, 367, 971, 971, 971, 971, 971, |
| 125123 | | - /* 1490 */ 971, 971, 971, 971, 971, 971, 338, |
| 125442 | + /* 0 */ 311, 1306, 145, 651, 2, 192, 652, 338, 780, 92, |
| 125443 | + /* 10 */ 92, 92, 92, 85, 90, 90, 90, 90, 89, 89, |
| 125444 | + /* 20 */ 88, 88, 88, 87, 335, 88, 88, 88, 87, 335, |
| 125445 | + /* 30 */ 327, 856, 856, 92, 92, 92, 92, 776, 90, 90, |
| 125446 | + /* 40 */ 90, 90, 89, 89, 88, 88, 88, 87, 335, 86, |
| 125447 | + /* 50 */ 83, 166, 93, 94, 84, 868, 871, 860, 860, 91, |
| 125448 | + /* 60 */ 91, 92, 92, 92, 92, 335, 90, 90, 90, 90, |
| 125449 | + /* 70 */ 89, 89, 88, 88, 88, 87, 335, 311, 780, 90, |
| 125450 | + /* 80 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 335, |
| 125451 | + /* 90 */ 123, 808, 689, 689, 689, 689, 112, 230, 430, 257, |
| 125452 | + /* 100 */ 809, 698, 430, 86, 83, 166, 324, 55, 856, 856, |
| 125453 | + /* 110 */ 201, 158, 276, 387, 271, 386, 188, 689, 689, 828, |
| 125454 | + /* 120 */ 833, 49, 944, 269, 833, 49, 123, 87, 335, 93, |
| 125455 | + /* 130 */ 94, 84, 868, 871, 860, 860, 91, 91, 92, 92, |
| 125456 | + /* 140 */ 92, 92, 342, 90, 90, 90, 90, 89, 89, 88, |
| 125457 | + /* 150 */ 88, 88, 87, 335, 311, 328, 333, 332, 701, 408, |
| 125458 | + /* 160 */ 394, 69, 690, 691, 690, 691, 715, 910, 251, 354, |
| 125459 | + /* 170 */ 250, 698, 704, 430, 908, 430, 909, 89, 89, 88, |
| 125460 | + /* 180 */ 88, 88, 87, 335, 391, 856, 856, 690, 691, 183, |
| 125461 | + /* 190 */ 95, 340, 384, 381, 380, 833, 31, 833, 49, 912, |
| 125462 | + /* 200 */ 912, 333, 332, 379, 123, 311, 93, 94, 84, 868, |
| 125463 | + /* 210 */ 871, 860, 860, 91, 91, 92, 92, 92, 92, 114, |
| 125464 | + /* 220 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87, |
| 125465 | + /* 230 */ 335, 430, 408, 399, 435, 657, 856, 856, 346, 57, |
| 125466 | + /* 240 */ 232, 828, 109, 20, 912, 912, 231, 393, 937, 760, |
| 125467 | + /* 250 */ 97, 751, 752, 833, 49, 708, 708, 93, 94, 84, |
| 125468 | + /* 260 */ 868, 871, 860, 860, 91, 91, 92, 92, 92, 92, |
| 125469 | + /* 270 */ 707, 90, 90, 90, 90, 89, 89, 88, 88, 88, |
| 125470 | + /* 280 */ 87, 335, 311, 114, 22, 706, 688, 58, 408, 390, |
| 125471 | + /* 290 */ 251, 349, 240, 749, 752, 689, 689, 847, 685, 115, |
| 125472 | + /* 300 */ 21, 231, 393, 689, 689, 697, 183, 355, 430, 384, |
| 125473 | + /* 310 */ 381, 380, 192, 856, 856, 780, 123, 160, 159, 223, |
| 125474 | + /* 320 */ 379, 738, 25, 315, 362, 841, 143, 689, 689, 835, |
| 125475 | + /* 330 */ 833, 48, 339, 937, 93, 94, 84, 868, 871, 860, |
| 125476 | + /* 340 */ 860, 91, 91, 92, 92, 92, 92, 914, 90, 90, |
| 125477 | + /* 350 */ 90, 90, 89, 89, 88, 88, 88, 87, 335, 311, |
| 125478 | + /* 360 */ 840, 840, 840, 266, 430, 690, 691, 778, 114, 1300, |
| 125479 | + /* 370 */ 1300, 430, 1, 690, 691, 697, 688, 689, 689, 689, |
| 125480 | + /* 380 */ 689, 689, 689, 287, 298, 780, 833, 10, 686, 115, |
| 125481 | + /* 390 */ 856, 856, 355, 833, 10, 828, 366, 690, 691, 363, |
| 125482 | + /* 400 */ 321, 76, 123, 74, 23, 737, 807, 323, 356, 353, |
| 125483 | + /* 410 */ 847, 93, 94, 84, 868, 871, 860, 860, 91, 91, |
| 125484 | + /* 420 */ 92, 92, 92, 92, 940, 90, 90, 90, 90, 89, |
| 125485 | + /* 430 */ 89, 88, 88, 88, 87, 335, 311, 806, 841, 429, |
| 125486 | + /* 440 */ 713, 941, 835, 430, 251, 354, 250, 690, 691, 690, |
| 125487 | + /* 450 */ 691, 690, 691, 86, 83, 166, 24, 942, 151, 753, |
| 125488 | + /* 460 */ 285, 907, 403, 907, 164, 833, 10, 856, 856, 965, |
| 125489 | + /* 470 */ 306, 754, 679, 840, 840, 840, 795, 216, 794, 222, |
| 125490 | + /* 480 */ 906, 344, 906, 904, 86, 83, 166, 286, 93, 94, |
| 125491 | + /* 490 */ 84, 868, 871, 860, 860, 91, 91, 92, 92, 92, |
| 125492 | + /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88, |
| 125493 | + /* 510 */ 88, 87, 335, 311, 430, 724, 352, 705, 427, 699, |
| 125494 | + /* 520 */ 700, 376, 210, 833, 49, 793, 397, 857, 857, 940, |
| 125495 | + /* 530 */ 213, 762, 727, 334, 699, 700, 833, 10, 86, 83, |
| 125496 | + /* 540 */ 166, 345, 396, 902, 856, 856, 941, 385, 833, 9, |
| 125497 | + /* 550 */ 406, 869, 872, 187, 890, 728, 347, 398, 404, 977, |
| 125498 | + /* 560 */ 652, 338, 942, 954, 413, 93, 94, 84, 868, 871, |
| 125499 | + /* 570 */ 860, 860, 91, 91, 92, 92, 92, 92, 861, 90, |
| 125500 | + /* 580 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 335, |
| 125501 | + /* 590 */ 311, 1219, 114, 430, 834, 430, 5, 165, 192, 688, |
| 125502 | + /* 600 */ 832, 780, 430, 723, 430, 234, 325, 189, 163, 316, |
| 125503 | + /* 610 */ 356, 955, 115, 235, 269, 833, 35, 833, 36, 747, |
| 125504 | + /* 620 */ 720, 856, 856, 793, 833, 12, 833, 27, 745, 174, |
| 125505 | + /* 630 */ 968, 1290, 968, 1291, 1290, 310, 1291, 693, 317, 245, |
| 125506 | + /* 640 */ 264, 311, 93, 94, 84, 868, 871, 860, 860, 91, |
| 125507 | + /* 650 */ 91, 92, 92, 92, 92, 832, 90, 90, 90, 90, |
| 125508 | + /* 660 */ 89, 89, 88, 88, 88, 87, 335, 430, 320, 213, |
| 125509 | + /* 670 */ 762, 780, 856, 856, 920, 920, 369, 257, 966, 220, |
| 125510 | + /* 680 */ 966, 396, 663, 664, 665, 242, 259, 244, 262, 833, |
| 125511 | + /* 690 */ 37, 650, 2, 93, 94, 84, 868, 871, 860, 860, |
| 125512 | + /* 700 */ 91, 91, 92, 92, 92, 92, 430, 90, 90, 90, |
| 125513 | + /* 710 */ 90, 89, 89, 88, 88, 88, 87, 335, 311, 430, |
| 125514 | + /* 720 */ 239, 430, 917, 368, 430, 238, 916, 793, 833, 38, |
| 125515 | + /* 730 */ 430, 825, 430, 66, 430, 392, 430, 766, 766, 430, |
| 125516 | + /* 740 */ 367, 833, 39, 833, 28, 430, 833, 29, 68, 856, |
| 125517 | + /* 750 */ 856, 900, 833, 40, 833, 41, 833, 42, 833, 11, |
| 125518 | + /* 760 */ 72, 833, 43, 243, 305, 970, 114, 833, 99, 961, |
| 125519 | + /* 770 */ 93, 94, 84, 868, 871, 860, 860, 91, 91, 92, |
| 125520 | + /* 780 */ 92, 92, 92, 430, 90, 90, 90, 90, 89, 89, |
| 125521 | + /* 790 */ 88, 88, 88, 87, 335, 311, 430, 361, 430, 165, |
| 125522 | + /* 800 */ 147, 430, 186, 185, 184, 833, 44, 430, 289, 430, |
| 125523 | + /* 810 */ 246, 430, 971, 430, 212, 163, 430, 357, 833, 45, |
| 125524 | + /* 820 */ 833, 32, 932, 833, 46, 793, 856, 856, 718, 833, |
| 125525 | + /* 830 */ 47, 833, 33, 833, 117, 833, 118, 75, 833, 119, |
| 125526 | + /* 840 */ 288, 305, 967, 214, 935, 322, 311, 93, 94, 84, |
| 125527 | + /* 850 */ 868, 871, 860, 860, 91, 91, 92, 92, 92, 92, |
| 125528 | + /* 860 */ 430, 90, 90, 90, 90, 89, 89, 88, 88, 88, |
| 125529 | + /* 870 */ 87, 335, 430, 832, 426, 317, 288, 856, 856, 114, |
| 125530 | + /* 880 */ 763, 257, 833, 53, 930, 219, 364, 257, 257, 971, |
| 125531 | + /* 890 */ 361, 396, 257, 257, 833, 34, 257, 311, 93, 94, |
| 125532 | + /* 900 */ 84, 868, 871, 860, 860, 91, 91, 92, 92, 92, |
| 125533 | + /* 910 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88, |
| 125534 | + /* 920 */ 88, 87, 335, 430, 217, 318, 124, 253, 856, 856, |
| 125535 | + /* 930 */ 218, 943, 257, 833, 100, 898, 759, 774, 361, 755, |
| 125536 | + /* 940 */ 423, 329, 758, 1017, 289, 833, 50, 682, 311, 93, |
| 125537 | + /* 950 */ 82, 84, 868, 871, 860, 860, 91, 91, 92, 92, |
| 125538 | + /* 960 */ 92, 92, 430, 90, 90, 90, 90, 89, 89, 88, |
| 125539 | + /* 970 */ 88, 88, 87, 335, 430, 256, 419, 114, 249, 856, |
| 125540 | + /* 980 */ 856, 331, 114, 400, 833, 101, 359, 187, 1064, 726, |
| 125541 | + /* 990 */ 725, 739, 401, 416, 420, 360, 833, 102, 424, 311, |
| 125542 | + /* 1000 */ 258, 94, 84, 868, 871, 860, 860, 91, 91, 92, |
| 125543 | + /* 1010 */ 92, 92, 92, 430, 90, 90, 90, 90, 89, 89, |
| 125544 | + /* 1020 */ 88, 88, 88, 87, 335, 430, 221, 261, 114, 114, |
| 125545 | + /* 1030 */ 856, 856, 808, 114, 156, 833, 98, 772, 733, 734, |
| 125546 | + /* 1040 */ 275, 809, 771, 316, 263, 265, 960, 833, 116, 307, |
| 125547 | + /* 1050 */ 741, 274, 722, 84, 868, 871, 860, 860, 91, 91, |
| 125548 | + /* 1060 */ 92, 92, 92, 92, 430, 90, 90, 90, 90, 89, |
| 125549 | + /* 1070 */ 89, 88, 88, 88, 87, 335, 80, 425, 830, 3, |
| 125550 | + /* 1080 */ 1214, 191, 430, 721, 336, 336, 833, 113, 252, 80, |
| 125551 | + /* 1090 */ 425, 68, 3, 913, 913, 428, 270, 336, 336, 430, |
| 125552 | + /* 1100 */ 377, 784, 430, 197, 833, 106, 430, 716, 428, 430, |
| 125553 | + /* 1110 */ 267, 430, 897, 68, 414, 430, 769, 409, 430, 71, |
| 125554 | + /* 1120 */ 430, 833, 105, 123, 833, 103, 847, 414, 833, 49, |
| 125555 | + /* 1130 */ 843, 833, 104, 833, 52, 800, 123, 833, 54, 847, |
| 125556 | + /* 1140 */ 833, 51, 833, 26, 831, 802, 77, 78, 191, 389, |
| 125557 | + /* 1150 */ 430, 372, 114, 79, 432, 431, 911, 911, 835, 77, |
| 125558 | + /* 1160 */ 78, 779, 893, 408, 410, 197, 79, 432, 431, 791, |
| 125559 | + /* 1170 */ 226, 835, 833, 30, 772, 80, 425, 716, 3, 771, |
| 125560 | + /* 1180 */ 411, 412, 897, 336, 336, 290, 291, 839, 703, 840, |
| 125561 | + /* 1190 */ 840, 840, 842, 19, 428, 695, 684, 672, 111, 671, |
| 125562 | + /* 1200 */ 843, 673, 840, 840, 840, 842, 19, 207, 661, 278, |
| 125563 | + /* 1210 */ 148, 304, 280, 414, 282, 6, 822, 348, 248, 241, |
| 125564 | + /* 1220 */ 358, 934, 720, 80, 425, 847, 3, 161, 382, 273, |
| 125565 | + /* 1230 */ 284, 336, 336, 415, 296, 958, 895, 894, 157, 674, |
| 125566 | + /* 1240 */ 107, 194, 428, 948, 135, 77, 78, 777, 953, 951, |
| 125567 | + /* 1250 */ 56, 319, 79, 432, 431, 121, 66, 835, 59, 128, |
| 125568 | + /* 1260 */ 146, 414, 350, 130, 351, 819, 131, 132, 133, 375, |
| 125569 | + /* 1270 */ 173, 149, 138, 847, 936, 365, 178, 70, 425, 827, |
| 125570 | + /* 1280 */ 3, 889, 62, 371, 915, 336, 336, 792, 840, 840, |
| 125571 | + /* 1290 */ 840, 842, 19, 77, 78, 208, 428, 144, 179, 373, |
| 125572 | + /* 1300 */ 79, 432, 431, 255, 180, 835, 260, 675, 181, 308, |
| 125573 | + /* 1310 */ 388, 744, 326, 743, 742, 414, 731, 718, 712, 402, |
| 125574 | + /* 1320 */ 309, 711, 788, 65, 277, 272, 789, 847, 730, 710, |
| 125575 | + /* 1330 */ 709, 279, 193, 787, 281, 876, 840, 840, 840, 842, |
| 125576 | + /* 1340 */ 19, 786, 283, 73, 418, 330, 422, 77, 78, 227, |
| 125577 | + /* 1350 */ 96, 407, 67, 405, 79, 432, 431, 292, 228, 835, |
| 125578 | + /* 1360 */ 215, 202, 229, 293, 767, 303, 302, 301, 204, 299, |
| 125579 | + /* 1370 */ 294, 295, 676, 7, 681, 433, 669, 206, 110, 224, |
| 125580 | + /* 1380 */ 203, 205, 434, 667, 666, 658, 120, 168, 656, 237, |
| 125581 | + /* 1390 */ 840, 840, 840, 842, 19, 337, 155, 233, 236, 341, |
| 125582 | + /* 1400 */ 167, 905, 108, 313, 903, 826, 314, 125, 126, 127, |
| 125583 | + /* 1410 */ 129, 170, 247, 756, 172, 928, 134, 136, 171, 60, |
| 125584 | + /* 1420 */ 61, 123, 169, 137, 175, 933, 176, 927, 8, 13, |
| 125585 | + /* 1430 */ 177, 254, 191, 918, 139, 370, 924, 140, 678, 150, |
| 125586 | + /* 1440 */ 374, 274, 182, 378, 141, 122, 63, 14, 383, 729, |
| 125587 | + /* 1450 */ 268, 15, 64, 225, 846, 845, 874, 16, 765, 770, |
| 125588 | + /* 1460 */ 4, 162, 209, 395, 211, 142, 878, 796, 801, 312, |
| 125589 | + /* 1470 */ 190, 71, 68, 875, 873, 939, 199, 938, 17, 195, |
| 125590 | + /* 1480 */ 18, 196, 417, 975, 152, 653, 976, 198, 153, 421, |
| 125591 | + /* 1490 */ 877, 154, 200, 844, 696, 81, 343, 297, 1019, 1018, |
| 125592 | + /* 1500 */ 300, |
| 125124 | 125593 | }; |
| 125125 | 125594 | static const YYCODETYPE yy_lookahead[] = { |
| 125126 | | - /* 0 */ 19, 22, 22, 23, 1, 24, 26, 15, 27, 80, |
| 125595 | + /* 0 */ 19, 144, 145, 146, 147, 24, 1, 2, 27, 80, |
| 125127 | 125596 | /* 10 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 125128 | | - /* 20 */ 91, 92, 93, 94, 95, 108, 109, 110, 27, 28, |
| 125129 | | - /* 30 */ 23, 50, 51, 80, 81, 82, 83, 122, 85, 86, |
| 125130 | | - /* 40 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 22, |
| 125131 | | - /* 50 */ 70, 23, 71, 72, 73, 74, 75, 76, 77, 78, |
| 125132 | | - /* 60 */ 79, 80, 81, 82, 83, 122, 85, 86, 87, 88, |
| 125133 | | - /* 70 */ 89, 90, 91, 92, 93, 94, 95, 19, 97, 91, |
| 125134 | | - /* 80 */ 92, 93, 94, 95, 26, 85, 86, 87, 88, 89, |
| 125135 | | - /* 90 */ 90, 91, 92, 93, 94, 95, 27, 28, 97, 98, |
| 125136 | | - /* 100 */ 99, 122, 211, 102, 103, 104, 79, 19, 50, 51, |
| 125137 | | - /* 110 */ 19, 122, 59, 55, 113, 224, 225, 226, 89, 90, |
| 125138 | | - /* 120 */ 91, 92, 93, 94, 95, 23, 27, 28, 26, 71, |
| 125597 | + /* 20 */ 91, 92, 93, 94, 95, 91, 92, 93, 94, 95, |
| 125598 | + /* 30 */ 19, 50, 51, 80, 81, 82, 83, 212, 85, 86, |
| 125599 | + /* 40 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 224, |
| 125600 | + /* 50 */ 225, 226, 71, 72, 73, 74, 75, 76, 77, 78, |
| 125601 | + /* 60 */ 79, 80, 81, 82, 83, 95, 85, 86, 87, 88, |
| 125602 | + /* 70 */ 89, 90, 91, 92, 93, 94, 95, 19, 97, 85, |
| 125603 | + /* 80 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, |
| 125604 | + /* 90 */ 66, 33, 27, 28, 27, 28, 22, 201, 152, 152, |
| 125605 | + /* 100 */ 42, 27, 152, 224, 225, 226, 95, 211, 50, 51, |
| 125606 | + /* 110 */ 99, 100, 101, 102, 103, 104, 105, 27, 28, 59, |
| 125607 | + /* 120 */ 174, 175, 243, 112, 174, 175, 66, 94, 95, 71, |
| 125139 | 125608 | /* 130 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 125140 | | - /* 140 */ 82, 83, 51, 85, 86, 87, 88, 89, 90, 91, |
| 125141 | | - /* 150 */ 92, 93, 94, 95, 19, 132, 133, 58, 89, 90, |
| 125142 | | - /* 160 */ 21, 108, 109, 110, 27, 28, 97, 98, 33, 100, |
| 125143 | | - /* 170 */ 7, 8, 119, 120, 22, 19, 107, 42, 109, 27, |
| 125144 | | - /* 180 */ 28, 27, 28, 95, 28, 50, 51, 99, 100, 101, |
| 125145 | | - /* 190 */ 102, 103, 104, 105, 27, 28, 97, 98, 107, 152, |
| 125146 | | - /* 200 */ 112, 132, 133, 112, 65, 69, 71, 72, 73, 74, |
| 125147 | | - /* 210 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 11, |
| 125609 | + /* 140 */ 82, 83, 195, 85, 86, 87, 88, 89, 90, 91, |
| 125610 | + /* 150 */ 92, 93, 94, 95, 19, 209, 89, 90, 173, 209, |
| 125611 | + /* 160 */ 210, 26, 97, 98, 97, 98, 181, 100, 108, 109, |
| 125612 | + /* 170 */ 110, 97, 174, 152, 107, 152, 109, 89, 90, 91, |
| 125613 | + /* 180 */ 92, 93, 94, 95, 163, 50, 51, 97, 98, 99, |
| 125614 | + /* 190 */ 55, 244, 102, 103, 104, 174, 175, 174, 175, 132, |
| 125615 | + /* 200 */ 133, 89, 90, 113, 66, 19, 71, 72, 73, 74, |
| 125616 | + /* 210 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 198, |
| 125148 | 125617 | /* 220 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 125149 | | - /* 230 */ 95, 19, 101, 97, 97, 98, 24, 101, 122, 157, |
| 125150 | | - /* 240 */ 12, 99, 103, 112, 102, 103, 104, 152, 22, 97, |
| 125151 | | - /* 250 */ 98, 97, 98, 27, 28, 113, 27, 29, 91, 164, |
| 125152 | | - /* 260 */ 165, 124, 50, 51, 97, 98, 219, 59, 132, 133, |
| 125153 | | - /* 270 */ 134, 22, 23, 45, 66, 47, 212, 213, 124, 140, |
| 125154 | | - /* 280 */ 132, 133, 19, 71, 72, 73, 74, 75, 76, 77, |
| 125155 | | - /* 290 */ 78, 79, 80, 81, 82, 83, 152, 85, 86, 87, |
| 125156 | | - /* 300 */ 88, 89, 90, 91, 92, 93, 94, 95, 164, 165, |
| 125157 | | - /* 310 */ 27, 28, 230, 50, 51, 233, 108, 109, 110, 70, |
| 125158 | | - /* 320 */ 16, 59, 23, 97, 98, 26, 97, 22, 66, 185, |
| 125159 | | - /* 330 */ 12, 187, 27, 28, 71, 72, 73, 74, 75, 76, |
| 125160 | | - /* 340 */ 77, 78, 79, 80, 81, 82, 83, 29, 85, 86, |
| 125618 | + /* 230 */ 95, 152, 209, 210, 148, 149, 50, 51, 100, 53, |
| 125619 | + /* 240 */ 154, 59, 156, 22, 132, 133, 119, 120, 163, 163, |
| 125620 | + /* 250 */ 22, 192, 193, 174, 175, 27, 28, 71, 72, 73, |
| 125621 | + /* 260 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 125622 | + /* 270 */ 174, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 125623 | + /* 280 */ 94, 95, 19, 198, 198, 174, 152, 24, 209, 210, |
| 125624 | + /* 290 */ 108, 109, 110, 192, 193, 27, 28, 69, 164, 165, |
| 125625 | + /* 300 */ 79, 119, 120, 27, 28, 27, 99, 222, 152, 102, |
| 125626 | + /* 310 */ 103, 104, 24, 50, 51, 27, 66, 89, 90, 185, |
| 125627 | + /* 320 */ 113, 187, 22, 157, 239, 97, 58, 27, 28, 101, |
| 125628 | + /* 330 */ 174, 175, 246, 163, 71, 72, 73, 74, 75, 76, |
| 125629 | + /* 340 */ 77, 78, 79, 80, 81, 82, 83, 11, 85, 86, |
| 125161 | 125630 | /* 350 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 19, |
| 125162 | | - /* 360 */ 22, 148, 149, 45, 23, 47, 62, 154, 64, 156, |
| 125163 | | - /* 370 */ 108, 109, 110, 37, 69, 23, 163, 59, 26, 26, |
| 125164 | | - /* 380 */ 97, 98, 144, 145, 146, 147, 152, 200, 52, 23, |
| 125165 | | - /* 390 */ 50, 51, 26, 22, 89, 90, 60, 210, 7, 8, |
| 125166 | | - /* 400 */ 9, 138, 97, 22, 23, 26, 101, 26, 174, 175, |
| 125167 | | - /* 410 */ 197, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 125168 | | - /* 420 */ 80, 81, 82, 83, 16, 85, 86, 87, 88, 89, |
| 125169 | | - /* 430 */ 90, 91, 92, 93, 94, 95, 19, 132, 133, 134, |
| 125170 | | - /* 440 */ 23, 152, 208, 209, 140, 152, 152, 111, 195, 196, |
| 125171 | | - /* 450 */ 98, 70, 163, 160, 152, 23, 22, 164, 165, 246, |
| 125172 | | - /* 460 */ 207, 27, 152, 174, 175, 171, 172, 50, 51, 137, |
| 125173 | | - /* 470 */ 62, 139, 64, 171, 172, 222, 124, 27, 138, 24, |
| 125174 | | - /* 480 */ 163, 89, 90, 130, 174, 175, 197, 163, 71, 72, |
| 125631 | + /* 360 */ 132, 133, 134, 23, 152, 97, 98, 91, 198, 119, |
| 125632 | + /* 370 */ 120, 152, 22, 97, 98, 97, 152, 27, 28, 27, |
| 125633 | + /* 380 */ 28, 27, 28, 227, 160, 97, 174, 175, 164, 165, |
| 125634 | + /* 390 */ 50, 51, 222, 174, 175, 59, 230, 97, 98, 233, |
| 125635 | + /* 400 */ 188, 137, 66, 139, 234, 187, 177, 188, 152, 239, |
| 125636 | + /* 410 */ 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, |
| 125637 | + /* 420 */ 80, 81, 82, 83, 12, 85, 86, 87, 88, 89, |
| 125638 | + /* 430 */ 90, 91, 92, 93, 94, 95, 19, 177, 97, 152, |
| 125639 | + /* 440 */ 23, 29, 101, 152, 108, 109, 110, 97, 98, 97, |
| 125640 | + /* 450 */ 98, 97, 98, 224, 225, 226, 22, 45, 24, 47, |
| 125641 | + /* 460 */ 152, 152, 152, 152, 152, 174, 175, 50, 51, 249, |
| 125642 | + /* 470 */ 250, 59, 21, 132, 133, 134, 124, 221, 124, 188, |
| 125643 | + /* 480 */ 171, 172, 171, 172, 224, 225, 226, 152, 71, 72, |
| 125175 | 125644 | /* 490 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 125176 | | - /* 500 */ 83, 22, 85, 86, 87, 88, 89, 90, 91, 92, |
| 125177 | | - /* 510 */ 93, 94, 95, 19, 197, 181, 182, 23, 208, 209, |
| 125178 | | - /* 520 */ 152, 197, 26, 189, 132, 133, 232, 224, 225, 226, |
| 125179 | | - /* 530 */ 152, 97, 91, 26, 232, 116, 212, 213, 152, 222, |
| 125180 | | - /* 540 */ 121, 152, 174, 175, 50, 51, 243, 97, 22, 23, |
| 125181 | | - /* 550 */ 22, 234, 174, 175, 177, 23, 239, 116, 163, 177, |
| 125182 | | - /* 560 */ 174, 175, 121, 174, 175, 71, 72, 73, 74, 75, |
| 125183 | | - /* 570 */ 76, 77, 78, 79, 80, 81, 82, 83, 24, 85, |
| 125645 | + /* 500 */ 83, 152, 85, 86, 87, 88, 89, 90, 91, 92, |
| 125646 | + /* 510 */ 93, 94, 95, 19, 152, 183, 65, 23, 170, 171, |
| 125647 | + /* 520 */ 172, 19, 23, 174, 175, 26, 152, 50, 51, 12, |
| 125648 | + /* 530 */ 196, 197, 37, 170, 171, 172, 174, 175, 224, 225, |
| 125649 | + /* 540 */ 226, 232, 208, 232, 50, 51, 29, 52, 174, 175, |
| 125650 | + /* 550 */ 188, 74, 75, 51, 103, 60, 222, 163, 209, 0, |
| 125651 | + /* 560 */ 1, 2, 45, 152, 47, 71, 72, 73, 74, 75, |
| 125652 | + /* 570 */ 76, 77, 78, 79, 80, 81, 82, 83, 101, 85, |
| 125184 | 125653 | /* 580 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, |
| 125185 | | - /* 590 */ 19, 23, 197, 11, 23, 227, 70, 208, 220, 152, |
| 125186 | | - /* 600 */ 31, 224, 225, 226, 35, 98, 224, 225, 226, 108, |
| 125187 | | - /* 610 */ 109, 110, 115, 152, 117, 118, 27, 222, 49, 123, |
| 125188 | | - /* 620 */ 24, 50, 51, 27, 0, 1, 2, 224, 225, 226, |
| 125189 | | - /* 630 */ 166, 124, 168, 169, 239, 174, 175, 170, 171, 172, |
| 125190 | | - /* 640 */ 22, 194, 71, 72, 73, 74, 75, 76, 77, 78, |
| 125654 | + /* 590 */ 19, 140, 198, 152, 23, 152, 22, 98, 24, 152, |
| 125655 | + /* 600 */ 152, 27, 152, 183, 152, 152, 111, 213, 214, 107, |
| 125656 | + /* 610 */ 152, 164, 165, 152, 112, 174, 175, 174, 175, 181, |
| 125657 | + /* 620 */ 182, 50, 51, 124, 174, 175, 174, 175, 190, 26, |
| 125658 | + /* 630 */ 22, 23, 22, 23, 26, 166, 26, 168, 169, 16, |
| 125659 | + /* 640 */ 16, 19, 71, 72, 73, 74, 75, 76, 77, 78, |
| 125191 | 125660 | /* 650 */ 79, 80, 81, 82, 83, 152, 85, 86, 87, 88, |
| 125192 | | - /* 660 */ 89, 90, 91, 92, 93, 94, 95, 19, 22, 208, |
| 125193 | | - /* 670 */ 24, 23, 195, 196, 170, 171, 172, 174, 175, 152, |
| 125194 | | - /* 680 */ 26, 152, 152, 152, 207, 152, 97, 152, 23, 152, |
| 125195 | | - /* 690 */ 51, 244, 152, 97, 152, 247, 248, 23, 50, 51, |
| 125196 | | - /* 700 */ 26, 174, 175, 174, 175, 174, 175, 174, 175, 174, |
| 125197 | | - /* 710 */ 175, 174, 175, 23, 174, 175, 174, 175, 188, 71, |
| 125198 | | - /* 720 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 125199 | | - /* 730 */ 82, 83, 152, 85, 86, 87, 88, 89, 90, 91, |
| 125200 | | - /* 740 */ 92, 93, 94, 95, 19, 152, 107, 152, 33, 24, |
| 125201 | | - /* 750 */ 152, 100, 101, 27, 174, 175, 152, 42, 152, 23, |
| 125202 | | - /* 760 */ 152, 26, 152, 23, 152, 26, 152, 174, 175, 174, |
| 125203 | | - /* 770 */ 175, 152, 174, 175, 23, 50, 51, 26, 174, 175, |
| 125204 | | - /* 780 */ 174, 175, 174, 175, 174, 175, 174, 175, 174, 175, |
| 125205 | | - /* 790 */ 163, 119, 120, 174, 175, 19, 71, 72, 73, 74, |
| 125206 | | - /* 800 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 152, |
| 125207 | | - /* 810 */ 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, |
| 125208 | | - /* 820 */ 95, 66, 152, 97, 197, 23, 50, 51, 26, 53, |
| 125209 | | - /* 830 */ 23, 174, 175, 26, 23, 23, 23, 26, 26, 26, |
| 125210 | | - /* 840 */ 36, 106, 146, 147, 174, 175, 19, 71, 72, 73, |
| 125661 | + /* 660 */ 89, 90, 91, 92, 93, 94, 95, 152, 220, 196, |
| 125662 | + /* 670 */ 197, 97, 50, 51, 108, 109, 110, 152, 70, 221, |
| 125663 | + /* 680 */ 70, 208, 7, 8, 9, 62, 62, 64, 64, 174, |
| 125664 | + /* 690 */ 175, 146, 147, 71, 72, 73, 74, 75, 76, 77, |
| 125665 | + /* 700 */ 78, 79, 80, 81, 82, 83, 152, 85, 86, 87, |
| 125666 | + /* 710 */ 88, 89, 90, 91, 92, 93, 94, 95, 19, 152, |
| 125667 | + /* 720 */ 195, 152, 31, 220, 152, 152, 35, 26, 174, 175, |
| 125668 | + /* 730 */ 152, 163, 152, 130, 152, 115, 152, 117, 118, 152, |
| 125669 | + /* 740 */ 49, 174, 175, 174, 175, 152, 174, 175, 26, 50, |
| 125670 | + /* 750 */ 51, 152, 174, 175, 174, 175, 174, 175, 174, 175, |
| 125671 | + /* 760 */ 138, 174, 175, 140, 22, 23, 198, 174, 175, 152, |
| 125672 | + /* 770 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 125673 | + /* 780 */ 81, 82, 83, 152, 85, 86, 87, 88, 89, 90, |
| 125674 | + /* 790 */ 91, 92, 93, 94, 95, 19, 152, 152, 152, 98, |
| 125675 | + /* 800 */ 24, 152, 108, 109, 110, 174, 175, 152, 152, 152, |
| 125676 | + /* 810 */ 152, 152, 70, 152, 213, 214, 152, 152, 174, 175, |
| 125677 | + /* 820 */ 174, 175, 152, 174, 175, 124, 50, 51, 106, 174, |
| 125678 | + /* 830 */ 175, 174, 175, 174, 175, 174, 175, 138, 174, 175, |
| 125679 | + /* 840 */ 152, 22, 23, 22, 163, 189, 19, 71, 72, 73, |
| 125211 | 125680 | /* 850 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, |
| 125212 | 125681 | /* 860 */ 152, 85, 86, 87, 88, 89, 90, 91, 92, 93, |
| 125213 | | - /* 870 */ 94, 95, 152, 196, 119, 120, 19, 50, 51, 168, |
| 125214 | | - /* 880 */ 169, 26, 174, 175, 207, 28, 152, 249, 250, 152, |
| 125215 | | - /* 890 */ 163, 163, 163, 163, 174, 175, 163, 19, 71, 72, |
| 125682 | + /* 870 */ 94, 95, 152, 152, 168, 169, 152, 50, 51, 198, |
| 125683 | + /* 880 */ 197, 152, 174, 175, 152, 240, 152, 152, 152, 70, |
| 125684 | + /* 890 */ 152, 208, 152, 152, 174, 175, 152, 19, 71, 72, |
| 125216 | 125685 | /* 900 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, |
| 125217 | 125686 | /* 910 */ 83, 152, 85, 86, 87, 88, 89, 90, 91, 92, |
| 125218 | | - /* 920 */ 93, 94, 95, 152, 197, 197, 197, 197, 50, 51, |
| 125219 | | - /* 930 */ 197, 194, 36, 174, 175, 191, 192, 152, 191, 192, |
| 125220 | | - /* 940 */ 163, 152, 66, 124, 152, 174, 175, 152, 19, 71, |
| 125687 | + /* 920 */ 93, 94, 95, 152, 195, 247, 248, 152, 50, 51, |
| 125688 | + /* 930 */ 195, 195, 152, 174, 175, 195, 195, 26, 152, 195, |
| 125689 | + /* 940 */ 252, 220, 163, 122, 152, 174, 175, 163, 19, 71, |
| 125221 | 125690 | /* 950 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, |
| 125222 | 125691 | /* 960 */ 82, 83, 152, 85, 86, 87, 88, 89, 90, 91, |
| 125223 | | - /* 970 */ 92, 93, 94, 95, 197, 152, 100, 188, 152, 50, |
| 125224 | | - /* 980 */ 51, 152, 152, 188, 174, 175, 252, 152, 94, 95, |
| 125225 | | - /* 990 */ 152, 152, 152, 1, 2, 152, 152, 174, 175, 19, |
| 125692 | + /* 970 */ 92, 93, 94, 95, 152, 195, 252, 198, 240, 50, |
| 125693 | + /* 980 */ 51, 189, 198, 19, 174, 175, 19, 51, 23, 100, |
| 125694 | + /* 990 */ 101, 26, 28, 163, 163, 28, 174, 175, 163, 19, |
| 125226 | 125695 | /* 1000 */ 152, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 125227 | 125696 | /* 1010 */ 81, 82, 83, 152, 85, 86, 87, 88, 89, 90, |
| 125228 | | - /* 1020 */ 91, 92, 93, 94, 95, 152, 188, 188, 22, 194, |
| 125229 | | - /* 1030 */ 50, 51, 240, 173, 194, 174, 175, 252, 194, 152, |
| 125230 | | - /* 1040 */ 36, 181, 28, 152, 23, 219, 122, 174, 175, 219, |
| 125231 | | - /* 1050 */ 221, 152, 152, 73, 74, 75, 76, 77, 78, 79, |
| 125697 | + /* 1020 */ 91, 92, 93, 94, 95, 152, 240, 152, 198, 198, |
| 125698 | + /* 1030 */ 50, 51, 33, 198, 123, 174, 175, 116, 7, 8, |
| 125699 | + /* 1040 */ 101, 42, 121, 107, 152, 152, 23, 174, 175, 26, |
| 125700 | + /* 1050 */ 152, 112, 183, 73, 74, 75, 76, 77, 78, 79, |
| 125232 | 125701 | /* 1060 */ 80, 81, 82, 83, 152, 85, 86, 87, 88, 89, |
| 125233 | | - /* 1070 */ 90, 91, 92, 93, 94, 95, 19, 20, 152, 22, |
| 125234 | | - /* 1080 */ 23, 194, 152, 240, 27, 28, 174, 175, 240, 19, |
| 125235 | | - /* 1090 */ 20, 26, 22, 194, 194, 38, 22, 27, 28, 152, |
| 125236 | | - /* 1100 */ 23, 22, 152, 116, 174, 175, 152, 23, 38, 152, |
| 125237 | | - /* 1110 */ 23, 152, 221, 152, 57, 152, 23, 163, 50, 51, |
| 125238 | | - /* 1120 */ 194, 174, 175, 66, 174, 175, 69, 57, 174, 175, |
| 125239 | | - /* 1130 */ 40, 174, 175, 174, 175, 174, 175, 174, 175, 69, |
| 125240 | | - /* 1140 */ 22, 53, 74, 75, 30, 53, 89, 90, 22, 22, |
| 125241 | | - /* 1150 */ 152, 197, 23, 96, 97, 98, 22, 152, 101, 89, |
| 125242 | | - /* 1160 */ 90, 91, 208, 209, 152, 53, 96, 97, 98, 101, |
| 125243 | | - /* 1170 */ 22, 101, 174, 175, 152, 19, 20, 105, 22, 174, |
| 125244 | | - /* 1180 */ 175, 112, 19, 27, 28, 20, 174, 175, 24, 132, |
| 125245 | | - /* 1190 */ 133, 134, 135, 136, 38, 44, 174, 175, 107, 61, |
| 125246 | | - /* 1200 */ 54, 26, 132, 133, 134, 135, 136, 54, 107, 22, |
| 125247 | | - /* 1210 */ 5, 140, 1, 57, 36, 111, 122, 28, 79, 79, |
| 125248 | | - /* 1220 */ 131, 123, 66, 19, 20, 69, 22, 1, 16, 20, |
| 125249 | | - /* 1230 */ 125, 27, 28, 123, 111, 120, 23, 131, 23, 16, |
| 125250 | | - /* 1240 */ 68, 142, 38, 15, 22, 89, 90, 3, 167, 4, |
| 125251 | | - /* 1250 */ 248, 251, 96, 97, 98, 180, 180, 101, 251, 151, |
| 125252 | | - /* 1260 */ 6, 57, 151, 13, 151, 26, 25, 151, 161, 202, |
| 125253 | | - /* 1270 */ 153, 162, 153, 69, 130, 128, 203, 19, 20, 127, |
| 125254 | | - /* 1280 */ 22, 126, 204, 129, 22, 27, 28, 205, 132, 133, |
| 125255 | | - /* 1290 */ 134, 135, 136, 89, 90, 231, 38, 95, 137, 179, |
| 125256 | | - /* 1300 */ 96, 97, 98, 206, 179, 101, 122, 107, 159, 159, |
| 125257 | | - /* 1310 */ 125, 231, 216, 228, 107, 57, 184, 217, 216, 176, |
| 125258 | | - /* 1320 */ 217, 176, 48, 106, 18, 184, 158, 69, 159, 158, |
| 125259 | | - /* 1330 */ 46, 71, 237, 176, 176, 176, 132, 133, 134, 135, |
| 125260 | | - /* 1340 */ 136, 217, 176, 137, 216, 178, 158, 89, 90, 179, |
| 125261 | | - /* 1350 */ 176, 159, 179, 159, 96, 97, 98, 159, 159, 101, |
| 125262 | | - /* 1360 */ 5, 158, 202, 22, 18, 10, 11, 12, 13, 14, |
| 125263 | | - /* 1370 */ 190, 238, 17, 190, 158, 193, 41, 159, 202, 193, |
| 125264 | | - /* 1380 */ 159, 202, 245, 193, 193, 223, 190, 32, 159, 34, |
| 125265 | | - /* 1390 */ 132, 133, 134, 135, 136, 159, 39, 155, 43, 150, |
| 125266 | | - /* 1400 */ 223, 177, 201, 178, 177, 186, 66, 199, 177, 152, |
| 125267 | | - /* 1410 */ 253, 56, 215, 152, 182, 152, 202, 152, 63, 152, |
| 125268 | | - /* 1420 */ 152, 66, 67, 242, 229, 152, 174, 152, 152, 152, |
| 125269 | | - /* 1430 */ 152, 152, 152, 152, 199, 242, 202, 152, 198, 152, |
| 125270 | | - /* 1440 */ 152, 152, 183, 192, 152, 215, 152, 183, 215, 183, |
| 125271 | | - /* 1450 */ 152, 241, 214, 152, 211, 152, 152, 211, 211, 152, |
| 125272 | | - /* 1460 */ 152, 241, 152, 152, 152, 152, 152, 152, 152, 114, |
| 125273 | | - /* 1470 */ 152, 152, 235, 152, 152, 152, 174, 187, 95, 174, |
| 125274 | | - /* 1480 */ 253, 253, 253, 253, 236, 253, 253, 253, 253, 253, |
| 125275 | | - /* 1490 */ 253, 253, 253, 253, 253, 253, 141, |
| 125702 | + /* 1070 */ 90, 91, 92, 93, 94, 95, 19, 20, 23, 22, |
| 125703 | + /* 1080 */ 23, 26, 152, 152, 27, 28, 174, 175, 23, 19, |
| 125704 | + /* 1090 */ 20, 26, 22, 132, 133, 38, 152, 27, 28, 152, |
| 125705 | + /* 1100 */ 23, 215, 152, 26, 174, 175, 152, 27, 38, 152, |
| 125706 | + /* 1110 */ 23, 152, 27, 26, 57, 152, 23, 163, 152, 26, |
| 125707 | + /* 1120 */ 152, 174, 175, 66, 174, 175, 69, 57, 174, 175, |
| 125708 | + /* 1130 */ 27, 174, 175, 174, 175, 152, 66, 174, 175, 69, |
| 125709 | + /* 1140 */ 174, 175, 174, 175, 152, 23, 89, 90, 26, 91, |
| 125710 | + /* 1150 */ 152, 236, 198, 96, 97, 98, 132, 133, 101, 89, |
| 125711 | + /* 1160 */ 90, 152, 23, 209, 210, 26, 96, 97, 98, 152, |
| 125712 | + /* 1170 */ 212, 101, 174, 175, 116, 19, 20, 97, 22, 121, |
| 125713 | + /* 1180 */ 152, 193, 97, 27, 28, 152, 152, 152, 152, 132, |
| 125714 | + /* 1190 */ 133, 134, 135, 136, 38, 23, 152, 152, 26, 152, |
| 125715 | + /* 1200 */ 97, 152, 132, 133, 134, 135, 136, 235, 152, 212, |
| 125716 | + /* 1210 */ 199, 150, 212, 57, 212, 200, 203, 216, 241, 216, |
| 125717 | + /* 1220 */ 241, 203, 182, 19, 20, 69, 22, 186, 178, 177, |
| 125718 | + /* 1230 */ 216, 27, 28, 229, 202, 39, 177, 177, 200, 155, |
| 125719 | + /* 1240 */ 245, 122, 38, 41, 22, 89, 90, 91, 159, 159, |
| 125720 | + /* 1250 */ 242, 159, 96, 97, 98, 71, 130, 101, 242, 191, |
| 125721 | + /* 1260 */ 223, 57, 18, 194, 159, 203, 194, 194, 194, 18, |
| 125722 | + /* 1270 */ 158, 223, 191, 69, 203, 159, 158, 19, 20, 191, |
| 125723 | + /* 1280 */ 22, 203, 137, 46, 238, 27, 28, 159, 132, 133, |
| 125724 | + /* 1290 */ 134, 135, 136, 89, 90, 159, 38, 22, 158, 179, |
| 125725 | + /* 1300 */ 96, 97, 98, 237, 158, 101, 159, 159, 158, 179, |
| 125726 | + /* 1310 */ 107, 176, 48, 176, 176, 57, 184, 106, 176, 125, |
| 125727 | + /* 1320 */ 179, 178, 218, 107, 217, 176, 218, 69, 184, 176, |
| 125728 | + /* 1330 */ 176, 217, 159, 218, 217, 159, 132, 133, 134, 135, |
| 125729 | + /* 1340 */ 136, 218, 217, 137, 179, 95, 179, 89, 90, 228, |
| 125730 | + /* 1350 */ 129, 126, 128, 127, 96, 97, 98, 206, 231, 101, |
| 125731 | + /* 1360 */ 5, 25, 231, 205, 207, 10, 11, 12, 13, 14, |
| 125732 | + /* 1370 */ 204, 203, 17, 26, 162, 161, 13, 6, 180, 180, |
| 125733 | + /* 1380 */ 153, 153, 151, 151, 151, 151, 167, 32, 4, 34, |
| 125734 | + /* 1390 */ 132, 133, 134, 135, 136, 3, 22, 142, 43, 68, |
| 125735 | + /* 1400 */ 15, 23, 16, 251, 23, 120, 251, 248, 131, 111, |
| 125736 | + /* 1410 */ 123, 56, 16, 20, 125, 1, 123, 131, 63, 79, |
| 125737 | + /* 1420 */ 79, 66, 67, 111, 36, 28, 122, 1, 5, 22, |
| 125738 | + /* 1430 */ 107, 140, 26, 54, 54, 44, 61, 107, 20, 24, |
| 125739 | + /* 1440 */ 19, 112, 105, 53, 22, 40, 22, 22, 53, 30, |
| 125740 | + /* 1450 */ 23, 22, 22, 53, 23, 23, 23, 22, 116, 23, |
| 125741 | + /* 1460 */ 22, 122, 23, 26, 23, 22, 11, 124, 28, 114, |
| 125742 | + /* 1470 */ 36, 26, 26, 23, 23, 23, 122, 23, 36, 26, |
| 125743 | + /* 1480 */ 36, 22, 24, 23, 22, 1, 23, 26, 22, 24, |
| 125744 | + /* 1490 */ 23, 22, 122, 23, 23, 22, 141, 23, 122, 122, |
| 125745 | + /* 1500 */ 15, |
| 125276 | 125746 | }; |
| 125277 | | -#define YY_SHIFT_USE_DFLT (-86) |
| 125278 | | -#define YY_SHIFT_COUNT (429) |
| 125279 | | -#define YY_SHIFT_MIN (-85) |
| 125280 | | -#define YY_SHIFT_MAX (1383) |
| 125747 | +#define YY_SHIFT_USE_DFLT (-72) |
| 125748 | +#define YY_SHIFT_COUNT (435) |
| 125749 | +#define YY_SHIFT_MIN (-71) |
| 125750 | +#define YY_SHIFT_MAX (1485) |
| 125281 | 125751 | static const short yy_shift_ofst[] = { |
| 125282 | | - /* 0 */ 992, 1057, 1355, 1156, 1204, 1204, 1, 262, -19, 135, |
| 125283 | | - /* 10 */ 135, 776, 1204, 1204, 1204, 1204, 69, 69, 53, 208, |
| 125284 | | - /* 20 */ 283, 755, 58, 725, 648, 571, 494, 417, 340, 263, |
| 125285 | | - /* 30 */ 212, 827, 827, 827, 827, 827, 827, 827, 827, 827, |
| 125286 | | - /* 40 */ 827, 827, 827, 827, 827, 827, 878, 827, 929, 980, |
| 125287 | | - /* 50 */ 980, 1070, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, |
| 125752 | + /* 0 */ 5, 1057, 1355, 1070, 1204, 1204, 1204, 90, 60, -19, |
| 125753 | + /* 10 */ 58, 58, 186, 1204, 1204, 1204, 1204, 1204, 1204, 1204, |
| 125754 | + /* 20 */ 67, 67, 182, 336, 65, 250, 135, 263, 340, 417, |
| 125755 | + /* 30 */ 494, 571, 622, 699, 776, 827, 827, 827, 827, 827, |
| 125756 | + /* 40 */ 827, 827, 827, 827, 827, 827, 827, 827, 827, 827, |
| 125757 | + /* 50 */ 878, 827, 929, 980, 980, 1156, 1204, 1204, 1204, 1204, |
| 125288 | 125758 | /* 60 */ 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, |
| 125289 | 125759 | /* 70 */ 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, |
| 125290 | | - /* 80 */ 1258, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, |
| 125291 | | - /* 90 */ 1204, 1204, 1204, 1204, -71, -47, -47, -47, -47, -47, |
| 125292 | | - /* 100 */ 0, 29, -12, 283, 283, 139, 91, 392, 392, 894, |
| 125293 | | - /* 110 */ 672, 726, 1383, -86, -86, -86, 88, 318, 318, 99, |
| 125294 | | - /* 120 */ 381, -20, 283, 283, 283, 283, 283, 283, 283, 283, |
| 125295 | | - /* 130 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, |
| 125296 | | - /* 140 */ 283, 283, 283, 283, 624, 876, 726, 672, 1340, 1340, |
| 125297 | | - /* 150 */ 1340, 1340, 1340, 1340, -86, -86, -86, 305, 136, 136, |
| 125298 | | - /* 160 */ 142, 167, 226, 154, 137, 152, 283, 283, 283, 283, |
| 125299 | | - /* 170 */ 283, 283, 283, 283, 283, 283, 283, 283, 283, 283, |
| 125300 | | - /* 180 */ 283, 283, 283, 336, 336, 336, 283, 283, 352, 283, |
| 125301 | | - /* 190 */ 283, 283, 283, 283, 228, 283, 283, 283, 283, 283, |
| 125302 | | - /* 200 */ 283, 283, 283, 283, 283, 501, 569, 596, 596, 596, |
| 125303 | | - /* 210 */ 507, 497, 441, 391, 353, 156, 156, 857, 353, 857, |
| 125304 | | - /* 220 */ 735, 813, 639, 715, 156, 332, 715, 715, 496, 419, |
| 125305 | | - /* 230 */ 646, 1357, 1184, 1184, 1335, 1335, 1184, 1341, 1260, 1144, |
| 125306 | | - /* 240 */ 1346, 1346, 1346, 1346, 1184, 1306, 1144, 1341, 1260, 1260, |
| 125307 | | - /* 250 */ 1144, 1184, 1306, 1206, 1284, 1184, 1184, 1306, 1184, 1306, |
| 125308 | | - /* 260 */ 1184, 1306, 1262, 1207, 1207, 1207, 1274, 1262, 1207, 1217, |
| 125309 | | - /* 270 */ 1207, 1274, 1207, 1207, 1185, 1200, 1185, 1200, 1185, 1200, |
| 125310 | | - /* 280 */ 1184, 1184, 1161, 1262, 1202, 1202, 1262, 1154, 1155, 1147, |
| 125311 | | - /* 290 */ 1152, 1144, 1241, 1239, 1250, 1250, 1254, 1254, 1254, 1254, |
| 125312 | | - /* 300 */ -86, -86, -86, -86, -86, -86, 1068, 304, 526, 249, |
| 125313 | | - /* 310 */ 408, -83, 434, 812, 27, 811, 807, 802, 751, 589, |
| 125314 | | - /* 320 */ 651, 163, 131, 674, 366, 450, 299, 148, 23, 102, |
| 125315 | | - /* 330 */ 229, -21, 1245, 1244, 1222, 1099, 1228, 1172, 1223, 1215, |
| 125316 | | - /* 340 */ 1213, 1115, 1106, 1123, 1110, 1209, 1105, 1212, 1226, 1098, |
| 125317 | | - /* 350 */ 1089, 1140, 1139, 1104, 1189, 1178, 1094, 1211, 1205, 1187, |
| 125318 | | - /* 360 */ 1101, 1071, 1153, 1175, 1146, 1138, 1151, 1091, 1164, 1165, |
| 125319 | | - /* 370 */ 1163, 1069, 1072, 1148, 1112, 1134, 1127, 1129, 1126, 1092, |
| 125320 | | - /* 380 */ 1114, 1118, 1088, 1090, 1093, 1087, 1084, 987, 1079, 1077, |
| 125321 | | - /* 390 */ 1074, 1065, 924, 1021, 1014, 1004, 1006, 819, 739, 896, |
| 125322 | | - /* 400 */ 855, 804, 739, 740, 736, 690, 654, 665, 618, 582, |
| 125323 | | - /* 410 */ 568, 528, 554, 379, 532, 479, 455, 379, 432, 371, |
| 125324 | | - /* 420 */ 341, 28, 338, 116, -11, -57, -85, 7, -8, 3, |
| 125760 | + /* 80 */ 1204, 1204, 1204, 1204, 1258, 1204, 1204, 1204, 1204, 1204, |
| 125761 | + /* 90 */ 1204, 1204, 1204, 1204, 1204, 1204, 1204, 1204, -71, -47, |
| 125762 | + /* 100 */ -47, -47, -47, -47, -6, 88, -66, 65, 65, 451, |
| 125763 | + /* 110 */ 502, 112, 112, 33, 127, 278, -30, -72, -72, -72, |
| 125764 | + /* 120 */ 11, 412, 412, 268, 608, 610, 65, 65, 65, 65, |
| 125765 | + /* 130 */ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, |
| 125766 | + /* 140 */ 65, 65, 65, 65, 65, 559, 138, 278, 127, 24, |
| 125767 | + /* 150 */ 24, 24, 24, 24, 24, -72, -72, -72, 228, 341, |
| 125768 | + /* 160 */ 341, 207, 276, 300, 352, 354, 350, 65, 65, 65, |
| 125769 | + /* 170 */ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, |
| 125770 | + /* 180 */ 65, 65, 65, 65, 495, 495, 495, 65, 65, 499, |
| 125771 | + /* 190 */ 65, 65, 65, 574, 65, 65, 517, 65, 65, 65, |
| 125772 | + /* 200 */ 65, 65, 65, 65, 65, 65, 65, 566, 691, 288, |
| 125773 | + /* 210 */ 288, 288, 701, 620, 1058, 675, 603, 964, 964, 967, |
| 125774 | + /* 220 */ 603, 967, 722, 965, 936, 999, 964, 264, 999, 999, |
| 125775 | + /* 230 */ 911, 921, 434, 1196, 1119, 1119, 1202, 1202, 1119, 1222, |
| 125776 | + /* 240 */ 1184, 1126, 1244, 1244, 1244, 1244, 1119, 1251, 1126, 1222, |
| 125777 | + /* 250 */ 1184, 1184, 1126, 1119, 1251, 1145, 1237, 1119, 1119, 1251, |
| 125778 | + /* 260 */ 1275, 1119, 1251, 1119, 1251, 1275, 1203, 1203, 1203, 1264, |
| 125779 | + /* 270 */ 1275, 1203, 1211, 1203, 1264, 1203, 1203, 1194, 1216, 1194, |
| 125780 | + /* 280 */ 1216, 1194, 1216, 1194, 1216, 1119, 1119, 1206, 1275, 1250, |
| 125781 | + /* 290 */ 1250, 1275, 1221, 1225, 1224, 1226, 1126, 1336, 1347, 1363, |
| 125782 | + /* 300 */ 1363, 1371, 1371, 1371, 1371, -72, -72, -72, -72, -72, |
| 125783 | + /* 310 */ -72, 477, 623, 742, 819, 624, 694, 74, 1023, 221, |
| 125784 | + /* 320 */ 1055, 1065, 1077, 1087, 1080, 889, 1031, 939, 1093, 1122, |
| 125785 | + /* 330 */ 1085, 1139, 961, 1024, 1172, 1103, 821, 1384, 1392, 1374, |
| 125786 | + /* 340 */ 1255, 1385, 1331, 1386, 1378, 1381, 1285, 1277, 1298, 1287, |
| 125787 | + /* 350 */ 1393, 1289, 1396, 1414, 1293, 1286, 1340, 1341, 1312, 1397, |
| 125788 | + /* 360 */ 1388, 1304, 1426, 1423, 1407, 1323, 1291, 1379, 1406, 1380, |
| 125789 | + /* 370 */ 1375, 1391, 1330, 1415, 1418, 1421, 1329, 1337, 1422, 1390, |
| 125790 | + /* 380 */ 1424, 1425, 1427, 1429, 1395, 1419, 1430, 1400, 1405, 1431, |
| 125791 | + /* 390 */ 1432, 1433, 1342, 1435, 1436, 1438, 1437, 1339, 1439, 1441, |
| 125792 | + /* 400 */ 1440, 1434, 1443, 1343, 1445, 1442, 1446, 1444, 1445, 1450, |
| 125793 | + /* 410 */ 1451, 1452, 1453, 1454, 1459, 1455, 1460, 1462, 1458, 1461, |
| 125794 | + /* 420 */ 1463, 1466, 1465, 1461, 1467, 1469, 1470, 1471, 1473, 1354, |
| 125795 | + /* 430 */ 1370, 1376, 1377, 1474, 1485, 1484, |
| 125325 | 125796 | }; |
| 125326 | | -#define YY_REDUCE_USE_DFLT (-110) |
| 125327 | | -#define YY_REDUCE_COUNT (305) |
| 125328 | | -#define YY_REDUCE_MIN (-109) |
| 125329 | | -#define YY_REDUCE_MAX (1323) |
| 125797 | +#define YY_REDUCE_USE_DFLT (-176) |
| 125798 | +#define YY_REDUCE_COUNT (310) |
| 125799 | +#define YY_REDUCE_MIN (-175) |
| 125800 | +#define YY_REDUCE_MAX (1234) |
| 125330 | 125801 | static const short yy_reduce_ofst[] = { |
| 125331 | | - /* 0 */ 238, 954, 213, 289, 310, 234, 144, 317, -109, 382, |
| 125332 | | - /* 10 */ 377, 303, 461, 389, 378, 368, 302, 294, 253, 395, |
| 125333 | | - /* 20 */ 293, 324, 403, 403, 403, 403, 403, 403, 403, 403, |
| 125334 | | - /* 30 */ 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, |
| 125335 | | - /* 40 */ 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, |
| 125336 | | - /* 50 */ 403, 1022, 1012, 1005, 998, 963, 961, 959, 957, 950, |
| 125337 | | - /* 60 */ 947, 930, 912, 873, 861, 823, 810, 771, 759, 720, |
| 125338 | | - /* 70 */ 708, 670, 657, 619, 614, 612, 610, 608, 606, 604, |
| 125339 | | - /* 80 */ 598, 595, 593, 580, 542, 540, 537, 535, 533, 531, |
| 125340 | | - /* 90 */ 529, 527, 503, 386, 403, 403, 403, 403, 403, 403, |
| 125341 | | - /* 100 */ 403, 403, 403, 95, 447, 82, 334, 504, 467, 403, |
| 125342 | | - /* 110 */ 477, 464, 403, 403, 403, 403, 860, 747, 744, 785, |
| 125343 | | - /* 120 */ 638, 638, 926, 891, 900, 899, 887, 844, 840, 835, |
| 125344 | | - /* 130 */ 848, 830, 843, 829, 792, 839, 826, 737, 838, 795, |
| 125345 | | - /* 140 */ 789, 47, 734, 530, 696, 777, 711, 677, 733, 730, |
| 125346 | | - /* 150 */ 729, 728, 727, 627, 448, 64, 187, 1305, 1302, 1252, |
| 125347 | | - /* 160 */ 1290, 1273, 1323, 1322, 1321, 1319, 1318, 1316, 1315, 1314, |
| 125348 | | - /* 170 */ 1313, 1312, 1311, 1310, 1308, 1307, 1304, 1303, 1301, 1298, |
| 125349 | | - /* 180 */ 1294, 1292, 1289, 1266, 1264, 1259, 1288, 1287, 1238, 1285, |
| 125350 | | - /* 190 */ 1281, 1280, 1279, 1278, 1251, 1277, 1276, 1275, 1273, 1268, |
| 125351 | | - /* 200 */ 1267, 1265, 1263, 1261, 1257, 1248, 1237, 1247, 1246, 1243, |
| 125352 | | - /* 210 */ 1238, 1240, 1235, 1249, 1234, 1233, 1230, 1220, 1214, 1210, |
| 125353 | | - /* 220 */ 1225, 1219, 1232, 1231, 1197, 1195, 1227, 1224, 1201, 1208, |
| 125354 | | - /* 230 */ 1242, 1137, 1236, 1229, 1193, 1181, 1221, 1177, 1196, 1179, |
| 125355 | | - /* 240 */ 1191, 1190, 1186, 1182, 1218, 1216, 1176, 1162, 1183, 1180, |
| 125356 | | - /* 250 */ 1160, 1199, 1203, 1133, 1095, 1198, 1194, 1188, 1192, 1171, |
| 125357 | | - /* 260 */ 1169, 1168, 1173, 1174, 1166, 1159, 1141, 1170, 1158, 1167, |
| 125358 | | - /* 270 */ 1157, 1132, 1145, 1143, 1124, 1128, 1103, 1102, 1100, 1096, |
| 125359 | | - /* 280 */ 1150, 1149, 1085, 1125, 1080, 1064, 1120, 1097, 1082, 1078, |
| 125360 | | - /* 290 */ 1073, 1067, 1109, 1107, 1119, 1117, 1116, 1113, 1111, 1108, |
| 125361 | | - /* 300 */ 1007, 1000, 1002, 1076, 1075, 1081, |
| 125802 | + /* 0 */ -143, 954, 86, 21, -50, 23, 79, 134, 170, -175, |
| 125803 | + /* 10 */ 229, 260, -121, 212, 219, 291, -54, 349, 362, 156, |
| 125804 | + /* 20 */ 309, 311, 334, 85, 224, 394, 314, 314, 314, 314, |
| 125805 | + /* 30 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, |
| 125806 | + /* 40 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, |
| 125807 | + /* 50 */ 314, 314, 314, 314, 314, 374, 441, 443, 450, 452, |
| 125808 | + /* 60 */ 515, 554, 567, 569, 572, 578, 580, 582, 584, 587, |
| 125809 | + /* 70 */ 593, 631, 644, 646, 649, 655, 657, 659, 661, 664, |
| 125810 | + /* 80 */ 708, 720, 759, 771, 810, 822, 861, 873, 912, 930, |
| 125811 | + /* 90 */ 947, 950, 957, 959, 963, 966, 968, 998, 314, 314, |
| 125812 | + /* 100 */ 314, 314, 314, 314, 314, 314, 314, 447, -53, 166, |
| 125813 | + /* 110 */ 438, 348, 363, 314, 473, 469, 314, 314, 314, 314, |
| 125814 | + /* 120 */ -15, 59, 101, 688, 220, 220, 525, 256, 729, 735, |
| 125815 | + /* 130 */ 736, 740, 741, 744, 645, 448, 738, 458, 786, 503, |
| 125816 | + /* 140 */ 780, 656, 721, 724, 792, 545, 568, 706, 683, 681, |
| 125817 | + /* 150 */ 779, 784, 830, 831, 835, 678, 601, -104, -2, 96, |
| 125818 | + /* 160 */ 111, 218, 287, 308, 310, 312, 335, 411, 453, 461, |
| 125819 | + /* 170 */ 573, 599, 617, 658, 665, 670, 732, 734, 775, 848, |
| 125820 | + /* 180 */ 875, 892, 893, 898, 332, 420, 869, 931, 944, 886, |
| 125821 | + /* 190 */ 983, 992, 1009, 958, 1017, 1028, 988, 1033, 1034, 1035, |
| 125822 | + /* 200 */ 287, 1036, 1044, 1045, 1047, 1049, 1056, 915, 972, 997, |
| 125823 | + /* 210 */ 1000, 1002, 886, 1011, 1015, 1061, 1013, 1001, 1003, 977, |
| 125824 | + /* 220 */ 1018, 979, 1050, 1041, 1040, 1052, 1014, 1004, 1059, 1060, |
| 125825 | + /* 230 */ 1032, 1038, 1084, 995, 1089, 1090, 1008, 1016, 1092, 1037, |
| 125826 | + /* 240 */ 1068, 1062, 1069, 1072, 1073, 1074, 1105, 1112, 1071, 1048, |
| 125827 | + /* 250 */ 1081, 1088, 1078, 1116, 1118, 1046, 1066, 1128, 1136, 1140, |
| 125828 | + /* 260 */ 1120, 1147, 1146, 1148, 1150, 1130, 1135, 1137, 1138, 1132, |
| 125829 | + /* 270 */ 1141, 1142, 1143, 1149, 1144, 1153, 1154, 1104, 1107, 1108, |
| 125830 | + /* 280 */ 1114, 1115, 1117, 1123, 1125, 1173, 1176, 1121, 1165, 1127, |
| 125831 | + /* 290 */ 1131, 1167, 1157, 1151, 1158, 1166, 1168, 1212, 1214, 1227, |
| 125832 | + /* 300 */ 1228, 1231, 1232, 1233, 1234, 1152, 1155, 1159, 1198, 1199, |
| 125833 | + /* 310 */ 1219, |
| 125362 | 125834 | }; |
| 125363 | 125835 | static const YYACTIONTYPE yy_default[] = { |
| 125364 | | - /* 0 */ 647, 964, 964, 964, 878, 878, 969, 964, 774, 802, |
| 125365 | | - /* 10 */ 802, 938, 969, 969, 969, 876, 969, 969, 969, 964, |
| 125366 | | - /* 20 */ 969, 778, 808, 969, 969, 969, 969, 969, 969, 969, |
| 125367 | | - /* 30 */ 969, 937, 939, 816, 815, 918, 789, 813, 806, 810, |
| 125368 | | - /* 40 */ 879, 872, 873, 871, 875, 880, 969, 809, 841, 856, |
| 125369 | | - /* 50 */ 840, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125370 | | - /* 60 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125371 | | - /* 70 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125372 | | - /* 80 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125373 | | - /* 90 */ 969, 969, 969, 969, 850, 855, 862, 854, 851, 843, |
| 125374 | | - /* 100 */ 842, 844, 845, 969, 969, 673, 739, 969, 969, 846, |
| 125375 | | - /* 110 */ 969, 685, 847, 859, 858, 857, 680, 969, 969, 969, |
| 125376 | | - /* 120 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125377 | | - /* 130 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125378 | | - /* 140 */ 969, 969, 969, 969, 647, 964, 969, 969, 964, 964, |
| 125379 | | - /* 150 */ 964, 964, 964, 964, 956, 778, 768, 969, 969, 969, |
| 125380 | | - /* 160 */ 969, 969, 969, 969, 969, 969, 969, 944, 942, 969, |
| 125381 | | - /* 170 */ 891, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125382 | | - /* 180 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125383 | | - /* 190 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125384 | | - /* 200 */ 969, 969, 969, 969, 653, 969, 911, 774, 774, 774, |
| 125385 | | - /* 210 */ 776, 754, 766, 655, 812, 791, 791, 923, 812, 923, |
| 125386 | | - /* 220 */ 710, 733, 707, 802, 791, 874, 802, 802, 775, 766, |
| 125387 | | - /* 230 */ 969, 949, 782, 782, 941, 941, 782, 821, 743, 812, |
| 125388 | | - /* 240 */ 750, 750, 750, 750, 782, 670, 812, 821, 743, 743, |
| 125389 | | - /* 250 */ 812, 782, 670, 917, 915, 782, 782, 670, 782, 670, |
| 125390 | | - /* 260 */ 782, 670, 884, 741, 741, 741, 725, 884, 741, 710, |
| 125391 | | - /* 270 */ 741, 725, 741, 741, 795, 790, 795, 790, 795, 790, |
| 125392 | | - /* 280 */ 782, 782, 969, 884, 888, 888, 884, 807, 796, 805, |
| 125393 | | - /* 290 */ 803, 812, 676, 728, 663, 663, 652, 652, 652, 652, |
| 125394 | | - /* 300 */ 961, 961, 956, 712, 712, 695, 969, 969, 969, 969, |
| 125395 | | - /* 310 */ 969, 969, 687, 969, 893, 969, 969, 969, 969, 969, |
| 125396 | | - /* 320 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125397 | | - /* 330 */ 969, 828, 969, 648, 951, 969, 969, 948, 969, 969, |
| 125398 | | - /* 340 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125399 | | - /* 350 */ 969, 969, 969, 969, 969, 969, 921, 969, 969, 969, |
| 125400 | | - /* 360 */ 969, 969, 969, 914, 913, 969, 969, 969, 969, 969, |
| 125401 | | - /* 370 */ 969, 969, 969, 969, 969, 969, 969, 969, 969, 969, |
| 125402 | | - /* 380 */ 969, 969, 969, 969, 969, 969, 969, 757, 969, 969, |
| 125403 | | - /* 390 */ 969, 761, 969, 969, 969, 969, 969, 969, 804, 969, |
| 125404 | | - /* 400 */ 797, 969, 877, 969, 969, 969, 969, 969, 969, 969, |
| 125405 | | - /* 410 */ 969, 969, 969, 966, 969, 969, 969, 965, 969, 969, |
| 125406 | | - /* 420 */ 969, 969, 969, 830, 969, 829, 833, 969, 661, 969, |
| 125407 | | - /* 430 */ 644, 649, 960, 963, 962, 959, 958, 957, 952, 950, |
| 125408 | | - /* 440 */ 947, 946, 945, 943, 940, 936, 897, 895, 902, 901, |
| 125409 | | - /* 450 */ 900, 899, 898, 896, 894, 892, 818, 817, 814, 811, |
| 125410 | | - /* 460 */ 753, 935, 890, 752, 749, 748, 669, 953, 920, 929, |
| 125411 | | - /* 470 */ 928, 927, 822, 926, 925, 924, 922, 919, 906, 820, |
| 125412 | | - /* 480 */ 819, 744, 882, 881, 672, 910, 909, 908, 912, 916, |
| 125413 | | - /* 490 */ 907, 784, 751, 671, 668, 675, 679, 731, 732, 740, |
| 125414 | | - /* 500 */ 738, 737, 736, 735, 734, 730, 681, 686, 724, 709, |
| 125415 | | - /* 510 */ 708, 717, 716, 722, 721, 720, 719, 718, 715, 714, |
| 125416 | | - /* 520 */ 713, 706, 705, 711, 704, 727, 726, 723, 703, 747, |
| 125417 | | - /* 530 */ 746, 745, 742, 702, 701, 700, 833, 699, 698, 838, |
| 125418 | | - /* 540 */ 837, 866, 826, 755, 759, 758, 762, 763, 771, 770, |
| 125419 | | - /* 550 */ 769, 780, 781, 793, 792, 824, 823, 794, 779, 773, |
| 125420 | | - /* 560 */ 772, 788, 787, 786, 785, 777, 767, 799, 798, 868, |
| 125421 | | - /* 570 */ 783, 867, 865, 934, 933, 932, 931, 930, 870, 967, |
| 125422 | | - /* 580 */ 968, 887, 889, 886, 801, 800, 885, 869, 839, 836, |
| 125423 | | - /* 590 */ 690, 691, 905, 904, 903, 693, 692, 689, 688, 863, |
| 125424 | | - /* 600 */ 860, 852, 864, 861, 853, 849, 848, 834, 832, 831, |
| 125425 | | - /* 610 */ 827, 835, 760, 756, 825, 765, 764, 697, 696, 694, |
| 125426 | | - /* 620 */ 678, 677, 674, 667, 665, 664, 666, 662, 660, 659, |
| 125427 | | - /* 630 */ 658, 657, 656, 684, 683, 682, 654, 651, 650, 646, |
| 125428 | | - /* 640 */ 645, 643, |
| 125836 | + /* 0 */ 982, 1300, 1300, 1300, 1214, 1214, 1214, 1305, 1300, 1109, |
| 125837 | + /* 10 */ 1138, 1138, 1274, 1305, 1305, 1305, 1305, 1305, 1305, 1212, |
| 125838 | + /* 20 */ 1305, 1305, 1305, 1300, 1305, 1113, 1144, 1305, 1305, 1305, |
| 125839 | + /* 30 */ 1305, 1305, 1305, 1305, 1305, 1273, 1275, 1152, 1151, 1254, |
| 125840 | + /* 40 */ 1125, 1149, 1142, 1146, 1215, 1208, 1209, 1207, 1211, 1216, |
| 125841 | + /* 50 */ 1305, 1145, 1177, 1192, 1176, 1305, 1305, 1305, 1305, 1305, |
| 125842 | + /* 60 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125843 | + /* 70 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125844 | + /* 80 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125845 | + /* 90 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1186, 1191, |
| 125846 | + /* 100 */ 1198, 1190, 1187, 1179, 1178, 1180, 1181, 1305, 1305, 1008, |
| 125847 | + /* 110 */ 1074, 1305, 1305, 1182, 1305, 1020, 1183, 1195, 1194, 1193, |
| 125848 | + /* 120 */ 1015, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125849 | + /* 130 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125850 | + /* 140 */ 1305, 1305, 1305, 1305, 1305, 982, 1300, 1305, 1305, 1300, |
| 125851 | + /* 150 */ 1300, 1300, 1300, 1300, 1300, 1292, 1113, 1103, 1305, 1305, |
| 125852 | + /* 160 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1280, 1278, |
| 125853 | + /* 170 */ 1305, 1227, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125854 | + /* 180 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125855 | + /* 190 */ 1305, 1305, 1305, 1109, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125856 | + /* 200 */ 1305, 1305, 1305, 1305, 1305, 1305, 988, 1305, 1247, 1109, |
| 125857 | + /* 210 */ 1109, 1109, 1111, 1089, 1101, 990, 1148, 1127, 1127, 1259, |
| 125858 | + /* 220 */ 1148, 1259, 1045, 1068, 1042, 1138, 1127, 1210, 1138, 1138, |
| 125859 | + /* 230 */ 1110, 1101, 1305, 1285, 1118, 1118, 1277, 1277, 1118, 1157, |
| 125860 | + /* 240 */ 1078, 1148, 1085, 1085, 1085, 1085, 1118, 1005, 1148, 1157, |
| 125861 | + /* 250 */ 1078, 1078, 1148, 1118, 1005, 1253, 1251, 1118, 1118, 1005, |
| 125862 | + /* 260 */ 1220, 1118, 1005, 1118, 1005, 1220, 1076, 1076, 1076, 1060, |
| 125863 | + /* 270 */ 1220, 1076, 1045, 1076, 1060, 1076, 1076, 1131, 1126, 1131, |
| 125864 | + /* 280 */ 1126, 1131, 1126, 1131, 1126, 1118, 1118, 1305, 1220, 1224, |
| 125865 | + /* 290 */ 1224, 1220, 1143, 1132, 1141, 1139, 1148, 1011, 1063, 998, |
| 125866 | + /* 300 */ 998, 987, 987, 987, 987, 1297, 1297, 1292, 1047, 1047, |
| 125867 | + /* 310 */ 1030, 1305, 1305, 1305, 1305, 1305, 1305, 1022, 1305, 1229, |
| 125868 | + /* 320 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125869 | + /* 330 */ 1305, 1305, 1305, 1305, 1305, 1305, 1164, 1305, 983, 1287, |
| 125870 | + /* 340 */ 1305, 1305, 1284, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125871 | + /* 350 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125872 | + /* 360 */ 1305, 1257, 1305, 1305, 1305, 1305, 1305, 1305, 1250, 1249, |
| 125873 | + /* 370 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125874 | + /* 380 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, |
| 125875 | + /* 390 */ 1305, 1305, 1092, 1305, 1305, 1305, 1096, 1305, 1305, 1305, |
| 125876 | + /* 400 */ 1305, 1305, 1305, 1305, 1140, 1305, 1133, 1305, 1213, 1305, |
| 125877 | + /* 410 */ 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1305, 1302, |
| 125878 | + /* 420 */ 1305, 1305, 1305, 1301, 1305, 1305, 1305, 1305, 1305, 1166, |
| 125879 | + /* 430 */ 1305, 1165, 1169, 1305, 996, 1305, |
| 125429 | 125880 | }; |
| 125430 | 125881 | |
| 125431 | 125882 | /* The next table maps tokens into fallback tokens. If a construct |
| 125432 | 125883 | ** like the following: |
| 125433 | 125884 | ** |
| | @@ -125522,13 +125973,17 @@ |
| 125522 | 125973 | ** (In other words, the "major" token.) |
| 125523 | 125974 | ** |
| 125524 | 125975 | ** + The semantic value stored at this level of the stack. This is |
| 125525 | 125976 | ** the information used by the action routines in the grammar. |
| 125526 | 125977 | ** It is sometimes called the "minor" token. |
| 125978 | +** |
| 125979 | +** After the "shift" half of a SHIFTREDUCE action, the stateno field |
| 125980 | +** actually contains the reduce action for the second half of the |
| 125981 | +** SHIFTREDUCE. |
| 125527 | 125982 | */ |
| 125528 | 125983 | struct yyStackEntry { |
| 125529 | | - YYACTIONTYPE stateno; /* The state-number */ |
| 125984 | + YYACTIONTYPE stateno; /* The state-number, or reduce action in SHIFTREDUCE */ |
| 125530 | 125985 | YYCODETYPE major; /* The major token value. This is the code |
| 125531 | 125986 | ** number for the token at this stack level */ |
| 125532 | 125987 | YYMINORTYPE minor; /* The user-supplied minor token value. This |
| 125533 | 125988 | ** is the value of the token */ |
| 125534 | 125989 | }; |
| | @@ -125630,22 +126085,22 @@ |
| 125630 | 126085 | "createkw", "temp", "ifnotexists", "dbnm", |
| 125631 | 126086 | "columnlist", "conslist_opt", "table_options", "select", |
| 125632 | 126087 | "column", "columnid", "type", "carglist", |
| 125633 | 126088 | "typetoken", "typename", "signed", "plus_num", |
| 125634 | 126089 | "minus_num", "ccons", "term", "expr", |
| 125635 | | - "onconf", "sortorder", "autoinc", "idxlist_opt", |
| 126090 | + "onconf", "sortorder", "autoinc", "eidlist_opt", |
| 125636 | 126091 | "refargs", "defer_subclause", "refarg", "refact", |
| 125637 | 126092 | "init_deferred_pred_opt", "conslist", "tconscomma", "tcons", |
| 125638 | | - "idxlist", "defer_subclause_opt", "orconf", "resolvetype", |
| 125639 | | - "raisetype", "ifexists", "fullname", "selectnowith", |
| 125640 | | - "oneselect", "with", "multiselect_op", "distinct", |
| 125641 | | - "selcollist", "from", "where_opt", "groupby_opt", |
| 125642 | | - "having_opt", "orderby_opt", "limit_opt", "values", |
| 125643 | | - "nexprlist", "exprlist", "sclp", "as", |
| 125644 | | - "seltablist", "stl_prefix", "joinop", "indexed_opt", |
| 125645 | | - "on_opt", "using_opt", "joinop2", "idlist", |
| 125646 | | - "sortlist", "setlist", "insert_cmd", "inscollist_opt", |
| 126093 | + "sortlist", "eidlist", "defer_subclause_opt", "orconf", |
| 126094 | + "resolvetype", "raisetype", "ifexists", "fullname", |
| 126095 | + "selectnowith", "oneselect", "with", "multiselect_op", |
| 126096 | + "distinct", "selcollist", "from", "where_opt", |
| 126097 | + "groupby_opt", "having_opt", "orderby_opt", "limit_opt", |
| 126098 | + "values", "nexprlist", "exprlist", "sclp", |
| 126099 | + "as", "seltablist", "stl_prefix", "joinop", |
| 126100 | + "indexed_opt", "on_opt", "using_opt", "joinop2", |
| 126101 | + "idlist", "setlist", "insert_cmd", "idlist_opt", |
| 125647 | 126102 | "likeop", "between_op", "in_op", "case_operand", |
| 125648 | 126103 | "case_exprlist", "case_else", "uniqueflag", "collate", |
| 125649 | 126104 | "nmnum", "trigger_decl", "trigger_cmd_list", "trigger_time", |
| 125650 | 126105 | "trigger_event", "foreach_clause", "when_clause", "trigger_cmd", |
| 125651 | 126106 | "trnm", "tridxby", "database_kw_opt", "key_opt", |
| | @@ -125722,11 +126177,11 @@ |
| 125722 | 126177 | /* 60 */ "ccons ::= NULL onconf", |
| 125723 | 126178 | /* 61 */ "ccons ::= NOT NULL onconf", |
| 125724 | 126179 | /* 62 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc", |
| 125725 | 126180 | /* 63 */ "ccons ::= UNIQUE onconf", |
| 125726 | 126181 | /* 64 */ "ccons ::= CHECK LP expr RP", |
| 125727 | | - /* 65 */ "ccons ::= REFERENCES nm idxlist_opt refargs", |
| 126182 | + /* 65 */ "ccons ::= REFERENCES nm eidlist_opt refargs", |
| 125728 | 126183 | /* 66 */ "ccons ::= defer_subclause", |
| 125729 | 126184 | /* 67 */ "ccons ::= COLLATE ID|STRING", |
| 125730 | 126185 | /* 68 */ "autoinc ::=", |
| 125731 | 126186 | /* 69 */ "autoinc ::= AUTOINCR", |
| 125732 | 126187 | /* 70 */ "refargs ::=", |
| | @@ -125750,14 +126205,14 @@ |
| 125750 | 126205 | /* 88 */ "conslist ::= conslist tconscomma tcons", |
| 125751 | 126206 | /* 89 */ "conslist ::= tcons", |
| 125752 | 126207 | /* 90 */ "tconscomma ::= COMMA", |
| 125753 | 126208 | /* 91 */ "tconscomma ::=", |
| 125754 | 126209 | /* 92 */ "tcons ::= CONSTRAINT nm", |
| 125755 | | - /* 93 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf", |
| 125756 | | - /* 94 */ "tcons ::= UNIQUE LP idxlist RP onconf", |
| 126210 | + /* 93 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf", |
| 126211 | + /* 94 */ "tcons ::= UNIQUE LP sortlist RP onconf", |
| 125757 | 126212 | /* 95 */ "tcons ::= CHECK LP expr RP onconf", |
| 125758 | | - /* 96 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt", |
| 126213 | + /* 96 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt", |
| 125759 | 126214 | /* 97 */ "defer_subclause_opt ::=", |
| 125760 | 126215 | /* 98 */ "defer_subclause_opt ::= defer_subclause", |
| 125761 | 126216 | /* 99 */ "onconf ::=", |
| 125762 | 126217 | /* 100 */ "onconf ::= ON CONFLICT resolvetype", |
| 125763 | 126218 | /* 101 */ "orconf ::=", |
| | @@ -125766,11 +126221,11 @@ |
| 125766 | 126221 | /* 104 */ "resolvetype ::= IGNORE", |
| 125767 | 126222 | /* 105 */ "resolvetype ::= REPLACE", |
| 125768 | 126223 | /* 106 */ "cmd ::= DROP TABLE ifexists fullname", |
| 125769 | 126224 | /* 107 */ "ifexists ::= IF EXISTS", |
| 125770 | 126225 | /* 108 */ "ifexists ::=", |
| 125771 | | - /* 109 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select", |
| 126226 | + /* 109 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select", |
| 125772 | 126227 | /* 110 */ "cmd ::= DROP VIEW ifexists fullname", |
| 125773 | 126228 | /* 111 */ "cmd ::= select", |
| 125774 | 126229 | /* 112 */ "select ::= with selectnowith", |
| 125775 | 126230 | /* 113 */ "selectnowith ::= oneselect", |
| 125776 | 126231 | /* 114 */ "selectnowith ::= selectnowith multiselect_op oneselect", |
| | @@ -125795,199 +126250,200 @@ |
| 125795 | 126250 | /* 133 */ "from ::=", |
| 125796 | 126251 | /* 134 */ "from ::= FROM seltablist", |
| 125797 | 126252 | /* 135 */ "stl_prefix ::= seltablist joinop", |
| 125798 | 126253 | /* 136 */ "stl_prefix ::=", |
| 125799 | 126254 | /* 137 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", |
| 125800 | | - /* 138 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 125801 | | - /* 139 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 125802 | | - /* 140 */ "dbnm ::=", |
| 125803 | | - /* 141 */ "dbnm ::= DOT nm", |
| 125804 | | - /* 142 */ "fullname ::= nm dbnm", |
| 125805 | | - /* 143 */ "joinop ::= COMMA|JOIN", |
| 125806 | | - /* 144 */ "joinop ::= JOIN_KW JOIN", |
| 125807 | | - /* 145 */ "joinop ::= JOIN_KW nm JOIN", |
| 125808 | | - /* 146 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 125809 | | - /* 147 */ "on_opt ::= ON expr", |
| 125810 | | - /* 148 */ "on_opt ::=", |
| 125811 | | - /* 149 */ "indexed_opt ::=", |
| 125812 | | - /* 150 */ "indexed_opt ::= INDEXED BY nm", |
| 125813 | | - /* 151 */ "indexed_opt ::= NOT INDEXED", |
| 125814 | | - /* 152 */ "using_opt ::= USING LP idlist RP", |
| 125815 | | - /* 153 */ "using_opt ::=", |
| 125816 | | - /* 154 */ "orderby_opt ::=", |
| 125817 | | - /* 155 */ "orderby_opt ::= ORDER BY sortlist", |
| 125818 | | - /* 156 */ "sortlist ::= sortlist COMMA expr sortorder", |
| 125819 | | - /* 157 */ "sortlist ::= expr sortorder", |
| 125820 | | - /* 158 */ "sortorder ::= ASC", |
| 125821 | | - /* 159 */ "sortorder ::= DESC", |
| 125822 | | - /* 160 */ "sortorder ::=", |
| 125823 | | - /* 161 */ "groupby_opt ::=", |
| 125824 | | - /* 162 */ "groupby_opt ::= GROUP BY nexprlist", |
| 125825 | | - /* 163 */ "having_opt ::=", |
| 125826 | | - /* 164 */ "having_opt ::= HAVING expr", |
| 125827 | | - /* 165 */ "limit_opt ::=", |
| 125828 | | - /* 166 */ "limit_opt ::= LIMIT expr", |
| 125829 | | - /* 167 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 125830 | | - /* 168 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 125831 | | - /* 169 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt", |
| 125832 | | - /* 170 */ "where_opt ::=", |
| 125833 | | - /* 171 */ "where_opt ::= WHERE expr", |
| 125834 | | - /* 172 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt", |
| 125835 | | - /* 173 */ "setlist ::= setlist COMMA nm EQ expr", |
| 125836 | | - /* 174 */ "setlist ::= nm EQ expr", |
| 125837 | | - /* 175 */ "cmd ::= with insert_cmd INTO fullname inscollist_opt select", |
| 125838 | | - /* 176 */ "cmd ::= with insert_cmd INTO fullname inscollist_opt DEFAULT VALUES", |
| 125839 | | - /* 177 */ "insert_cmd ::= INSERT orconf", |
| 125840 | | - /* 178 */ "insert_cmd ::= REPLACE", |
| 125841 | | - /* 179 */ "inscollist_opt ::=", |
| 125842 | | - /* 180 */ "inscollist_opt ::= LP idlist RP", |
| 125843 | | - /* 181 */ "idlist ::= idlist COMMA nm", |
| 125844 | | - /* 182 */ "idlist ::= nm", |
| 125845 | | - /* 183 */ "expr ::= term", |
| 125846 | | - /* 184 */ "expr ::= LP expr RP", |
| 125847 | | - /* 185 */ "term ::= NULL", |
| 125848 | | - /* 186 */ "expr ::= ID|INDEXED", |
| 125849 | | - /* 187 */ "expr ::= JOIN_KW", |
| 125850 | | - /* 188 */ "expr ::= nm DOT nm", |
| 125851 | | - /* 189 */ "expr ::= nm DOT nm DOT nm", |
| 125852 | | - /* 190 */ "term ::= INTEGER|FLOAT|BLOB", |
| 125853 | | - /* 191 */ "term ::= STRING", |
| 125854 | | - /* 192 */ "expr ::= VARIABLE", |
| 125855 | | - /* 193 */ "expr ::= expr COLLATE ID|STRING", |
| 125856 | | - /* 194 */ "expr ::= CAST LP expr AS typetoken RP", |
| 125857 | | - /* 195 */ "expr ::= ID|INDEXED LP distinct exprlist RP", |
| 125858 | | - /* 196 */ "expr ::= ID|INDEXED LP STAR RP", |
| 125859 | | - /* 197 */ "term ::= CTIME_KW", |
| 125860 | | - /* 198 */ "expr ::= expr AND expr", |
| 125861 | | - /* 199 */ "expr ::= expr OR expr", |
| 125862 | | - /* 200 */ "expr ::= expr LT|GT|GE|LE expr", |
| 125863 | | - /* 201 */ "expr ::= expr EQ|NE expr", |
| 125864 | | - /* 202 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 125865 | | - /* 203 */ "expr ::= expr PLUS|MINUS expr", |
| 125866 | | - /* 204 */ "expr ::= expr STAR|SLASH|REM expr", |
| 125867 | | - /* 205 */ "expr ::= expr CONCAT expr", |
| 125868 | | - /* 206 */ "likeop ::= LIKE_KW|MATCH", |
| 125869 | | - /* 207 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 125870 | | - /* 208 */ "expr ::= expr likeop expr", |
| 125871 | | - /* 209 */ "expr ::= expr likeop expr ESCAPE expr", |
| 125872 | | - /* 210 */ "expr ::= expr ISNULL|NOTNULL", |
| 125873 | | - /* 211 */ "expr ::= expr NOT NULL", |
| 125874 | | - /* 212 */ "expr ::= expr IS expr", |
| 125875 | | - /* 213 */ "expr ::= expr IS NOT expr", |
| 125876 | | - /* 214 */ "expr ::= NOT expr", |
| 125877 | | - /* 215 */ "expr ::= BITNOT expr", |
| 125878 | | - /* 216 */ "expr ::= MINUS expr", |
| 125879 | | - /* 217 */ "expr ::= PLUS expr", |
| 125880 | | - /* 218 */ "between_op ::= BETWEEN", |
| 125881 | | - /* 219 */ "between_op ::= NOT BETWEEN", |
| 125882 | | - /* 220 */ "expr ::= expr between_op expr AND expr", |
| 125883 | | - /* 221 */ "in_op ::= IN", |
| 125884 | | - /* 222 */ "in_op ::= NOT IN", |
| 125885 | | - /* 223 */ "expr ::= expr in_op LP exprlist RP", |
| 125886 | | - /* 224 */ "expr ::= LP select RP", |
| 125887 | | - /* 225 */ "expr ::= expr in_op LP select RP", |
| 125888 | | - /* 226 */ "expr ::= expr in_op nm dbnm", |
| 125889 | | - /* 227 */ "expr ::= EXISTS LP select RP", |
| 125890 | | - /* 228 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 125891 | | - /* 229 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 125892 | | - /* 230 */ "case_exprlist ::= WHEN expr THEN expr", |
| 125893 | | - /* 231 */ "case_else ::= ELSE expr", |
| 125894 | | - /* 232 */ "case_else ::=", |
| 125895 | | - /* 233 */ "case_operand ::= expr", |
| 125896 | | - /* 234 */ "case_operand ::=", |
| 125897 | | - /* 235 */ "exprlist ::= nexprlist", |
| 125898 | | - /* 236 */ "exprlist ::=", |
| 125899 | | - /* 237 */ "nexprlist ::= nexprlist COMMA expr", |
| 125900 | | - /* 238 */ "nexprlist ::= expr", |
| 125901 | | - /* 239 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt", |
| 125902 | | - /* 240 */ "uniqueflag ::= UNIQUE", |
| 125903 | | - /* 241 */ "uniqueflag ::=", |
| 125904 | | - /* 242 */ "idxlist_opt ::=", |
| 125905 | | - /* 243 */ "idxlist_opt ::= LP idxlist RP", |
| 125906 | | - /* 244 */ "idxlist ::= idxlist COMMA nm collate sortorder", |
| 125907 | | - /* 245 */ "idxlist ::= nm collate sortorder", |
| 125908 | | - /* 246 */ "collate ::=", |
| 125909 | | - /* 247 */ "collate ::= COLLATE ID|STRING", |
| 125910 | | - /* 248 */ "cmd ::= DROP INDEX ifexists fullname", |
| 125911 | | - /* 249 */ "cmd ::= VACUUM", |
| 125912 | | - /* 250 */ "cmd ::= VACUUM nm", |
| 125913 | | - /* 251 */ "cmd ::= PRAGMA nm dbnm", |
| 125914 | | - /* 252 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 125915 | | - /* 253 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 125916 | | - /* 254 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 125917 | | - /* 255 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 125918 | | - /* 256 */ "nmnum ::= plus_num", |
| 125919 | | - /* 257 */ "nmnum ::= nm", |
| 125920 | | - /* 258 */ "nmnum ::= ON", |
| 125921 | | - /* 259 */ "nmnum ::= DELETE", |
| 125922 | | - /* 260 */ "nmnum ::= DEFAULT", |
| 125923 | | - /* 261 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 125924 | | - /* 262 */ "plus_num ::= INTEGER|FLOAT", |
| 125925 | | - /* 263 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 125926 | | - /* 264 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 125927 | | - /* 265 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 125928 | | - /* 266 */ "trigger_time ::= BEFORE", |
| 125929 | | - /* 267 */ "trigger_time ::= AFTER", |
| 125930 | | - /* 268 */ "trigger_time ::= INSTEAD OF", |
| 125931 | | - /* 269 */ "trigger_time ::=", |
| 125932 | | - /* 270 */ "trigger_event ::= DELETE|INSERT", |
| 125933 | | - /* 271 */ "trigger_event ::= UPDATE", |
| 125934 | | - /* 272 */ "trigger_event ::= UPDATE OF idlist", |
| 125935 | | - /* 273 */ "foreach_clause ::=", |
| 125936 | | - /* 274 */ "foreach_clause ::= FOR EACH ROW", |
| 125937 | | - /* 275 */ "when_clause ::=", |
| 125938 | | - /* 276 */ "when_clause ::= WHEN expr", |
| 125939 | | - /* 277 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 125940 | | - /* 278 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 125941 | | - /* 279 */ "trnm ::= nm", |
| 125942 | | - /* 280 */ "trnm ::= nm DOT nm", |
| 125943 | | - /* 281 */ "tridxby ::=", |
| 125944 | | - /* 282 */ "tridxby ::= INDEXED BY nm", |
| 125945 | | - /* 283 */ "tridxby ::= NOT INDEXED", |
| 125946 | | - /* 284 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 125947 | | - /* 285 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select", |
| 125948 | | - /* 286 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 125949 | | - /* 287 */ "trigger_cmd ::= select", |
| 125950 | | - /* 288 */ "expr ::= RAISE LP IGNORE RP", |
| 125951 | | - /* 289 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 125952 | | - /* 290 */ "raisetype ::= ROLLBACK", |
| 125953 | | - /* 291 */ "raisetype ::= ABORT", |
| 125954 | | - /* 292 */ "raisetype ::= FAIL", |
| 125955 | | - /* 293 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 125956 | | - /* 294 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 125957 | | - /* 295 */ "cmd ::= DETACH database_kw_opt expr", |
| 125958 | | - /* 296 */ "key_opt ::=", |
| 125959 | | - /* 297 */ "key_opt ::= KEY expr", |
| 125960 | | - /* 298 */ "database_kw_opt ::= DATABASE", |
| 125961 | | - /* 299 */ "database_kw_opt ::=", |
| 125962 | | - /* 300 */ "cmd ::= REINDEX", |
| 125963 | | - /* 301 */ "cmd ::= REINDEX nm dbnm", |
| 125964 | | - /* 302 */ "cmd ::= ANALYZE", |
| 125965 | | - /* 303 */ "cmd ::= ANALYZE nm dbnm", |
| 125966 | | - /* 304 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 125967 | | - /* 305 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column", |
| 125968 | | - /* 306 */ "add_column_fullname ::= fullname", |
| 125969 | | - /* 307 */ "kwcolumn_opt ::=", |
| 125970 | | - /* 308 */ "kwcolumn_opt ::= COLUMNKW", |
| 125971 | | - /* 309 */ "cmd ::= create_vtab", |
| 125972 | | - /* 310 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 125973 | | - /* 311 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 125974 | | - /* 312 */ "vtabarglist ::= vtabarg", |
| 125975 | | - /* 313 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 125976 | | - /* 314 */ "vtabarg ::=", |
| 125977 | | - /* 315 */ "vtabarg ::= vtabarg vtabargtoken", |
| 125978 | | - /* 316 */ "vtabargtoken ::= ANY", |
| 125979 | | - /* 317 */ "vtabargtoken ::= lp anylist RP", |
| 125980 | | - /* 318 */ "lp ::= LP", |
| 125981 | | - /* 319 */ "anylist ::=", |
| 125982 | | - /* 320 */ "anylist ::= anylist LP anylist RP", |
| 125983 | | - /* 321 */ "anylist ::= anylist ANY", |
| 125984 | | - /* 322 */ "with ::=", |
| 125985 | | - /* 323 */ "with ::= WITH wqlist", |
| 125986 | | - /* 324 */ "with ::= WITH RECURSIVE wqlist", |
| 125987 | | - /* 325 */ "wqlist ::= nm idxlist_opt AS LP select RP", |
| 125988 | | - /* 326 */ "wqlist ::= wqlist COMMA nm idxlist_opt AS LP select RP", |
| 126255 | + /* 138 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt", |
| 126256 | + /* 139 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 126257 | + /* 140 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 126258 | + /* 141 */ "dbnm ::=", |
| 126259 | + /* 142 */ "dbnm ::= DOT nm", |
| 126260 | + /* 143 */ "fullname ::= nm dbnm", |
| 126261 | + /* 144 */ "joinop ::= COMMA|JOIN", |
| 126262 | + /* 145 */ "joinop ::= JOIN_KW JOIN", |
| 126263 | + /* 146 */ "joinop ::= JOIN_KW nm JOIN", |
| 126264 | + /* 147 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 126265 | + /* 148 */ "on_opt ::= ON expr", |
| 126266 | + /* 149 */ "on_opt ::=", |
| 126267 | + /* 150 */ "indexed_opt ::=", |
| 126268 | + /* 151 */ "indexed_opt ::= INDEXED BY nm", |
| 126269 | + /* 152 */ "indexed_opt ::= NOT INDEXED", |
| 126270 | + /* 153 */ "using_opt ::= USING LP idlist RP", |
| 126271 | + /* 154 */ "using_opt ::=", |
| 126272 | + /* 155 */ "orderby_opt ::=", |
| 126273 | + /* 156 */ "orderby_opt ::= ORDER BY sortlist", |
| 126274 | + /* 157 */ "sortlist ::= sortlist COMMA expr sortorder", |
| 126275 | + /* 158 */ "sortlist ::= expr sortorder", |
| 126276 | + /* 159 */ "sortorder ::= ASC", |
| 126277 | + /* 160 */ "sortorder ::= DESC", |
| 126278 | + /* 161 */ "sortorder ::=", |
| 126279 | + /* 162 */ "groupby_opt ::=", |
| 126280 | + /* 163 */ "groupby_opt ::= GROUP BY nexprlist", |
| 126281 | + /* 164 */ "having_opt ::=", |
| 126282 | + /* 165 */ "having_opt ::= HAVING expr", |
| 126283 | + /* 166 */ "limit_opt ::=", |
| 126284 | + /* 167 */ "limit_opt ::= LIMIT expr", |
| 126285 | + /* 168 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 126286 | + /* 169 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 126287 | + /* 170 */ "cmd ::= with DELETE FROM fullname indexed_opt where_opt", |
| 126288 | + /* 171 */ "where_opt ::=", |
| 126289 | + /* 172 */ "where_opt ::= WHERE expr", |
| 126290 | + /* 173 */ "cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt", |
| 126291 | + /* 174 */ "setlist ::= setlist COMMA nm EQ expr", |
| 126292 | + /* 175 */ "setlist ::= nm EQ expr", |
| 126293 | + /* 176 */ "cmd ::= with insert_cmd INTO fullname idlist_opt select", |
| 126294 | + /* 177 */ "cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES", |
| 126295 | + /* 178 */ "insert_cmd ::= INSERT orconf", |
| 126296 | + /* 179 */ "insert_cmd ::= REPLACE", |
| 126297 | + /* 180 */ "idlist_opt ::=", |
| 126298 | + /* 181 */ "idlist_opt ::= LP idlist RP", |
| 126299 | + /* 182 */ "idlist ::= idlist COMMA nm", |
| 126300 | + /* 183 */ "idlist ::= nm", |
| 126301 | + /* 184 */ "expr ::= term", |
| 126302 | + /* 185 */ "expr ::= LP expr RP", |
| 126303 | + /* 186 */ "term ::= NULL", |
| 126304 | + /* 187 */ "expr ::= ID|INDEXED", |
| 126305 | + /* 188 */ "expr ::= JOIN_KW", |
| 126306 | + /* 189 */ "expr ::= nm DOT nm", |
| 126307 | + /* 190 */ "expr ::= nm DOT nm DOT nm", |
| 126308 | + /* 191 */ "term ::= INTEGER|FLOAT|BLOB", |
| 126309 | + /* 192 */ "term ::= STRING", |
| 126310 | + /* 193 */ "expr ::= VARIABLE", |
| 126311 | + /* 194 */ "expr ::= expr COLLATE ID|STRING", |
| 126312 | + /* 195 */ "expr ::= CAST LP expr AS typetoken RP", |
| 126313 | + /* 196 */ "expr ::= ID|INDEXED LP distinct exprlist RP", |
| 126314 | + /* 197 */ "expr ::= ID|INDEXED LP STAR RP", |
| 126315 | + /* 198 */ "term ::= CTIME_KW", |
| 126316 | + /* 199 */ "expr ::= expr AND expr", |
| 126317 | + /* 200 */ "expr ::= expr OR expr", |
| 126318 | + /* 201 */ "expr ::= expr LT|GT|GE|LE expr", |
| 126319 | + /* 202 */ "expr ::= expr EQ|NE expr", |
| 126320 | + /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 126321 | + /* 204 */ "expr ::= expr PLUS|MINUS expr", |
| 126322 | + /* 205 */ "expr ::= expr STAR|SLASH|REM expr", |
| 126323 | + /* 206 */ "expr ::= expr CONCAT expr", |
| 126324 | + /* 207 */ "likeop ::= LIKE_KW|MATCH", |
| 126325 | + /* 208 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 126326 | + /* 209 */ "expr ::= expr likeop expr", |
| 126327 | + /* 210 */ "expr ::= expr likeop expr ESCAPE expr", |
| 126328 | + /* 211 */ "expr ::= expr ISNULL|NOTNULL", |
| 126329 | + /* 212 */ "expr ::= expr NOT NULL", |
| 126330 | + /* 213 */ "expr ::= expr IS expr", |
| 126331 | + /* 214 */ "expr ::= expr IS NOT expr", |
| 126332 | + /* 215 */ "expr ::= NOT expr", |
| 126333 | + /* 216 */ "expr ::= BITNOT expr", |
| 126334 | + /* 217 */ "expr ::= MINUS expr", |
| 126335 | + /* 218 */ "expr ::= PLUS expr", |
| 126336 | + /* 219 */ "between_op ::= BETWEEN", |
| 126337 | + /* 220 */ "between_op ::= NOT BETWEEN", |
| 126338 | + /* 221 */ "expr ::= expr between_op expr AND expr", |
| 126339 | + /* 222 */ "in_op ::= IN", |
| 126340 | + /* 223 */ "in_op ::= NOT IN", |
| 126341 | + /* 224 */ "expr ::= expr in_op LP exprlist RP", |
| 126342 | + /* 225 */ "expr ::= LP select RP", |
| 126343 | + /* 226 */ "expr ::= expr in_op LP select RP", |
| 126344 | + /* 227 */ "expr ::= expr in_op nm dbnm", |
| 126345 | + /* 228 */ "expr ::= EXISTS LP select RP", |
| 126346 | + /* 229 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 126347 | + /* 230 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 126348 | + /* 231 */ "case_exprlist ::= WHEN expr THEN expr", |
| 126349 | + /* 232 */ "case_else ::= ELSE expr", |
| 126350 | + /* 233 */ "case_else ::=", |
| 126351 | + /* 234 */ "case_operand ::= expr", |
| 126352 | + /* 235 */ "case_operand ::=", |
| 126353 | + /* 236 */ "exprlist ::= nexprlist", |
| 126354 | + /* 237 */ "exprlist ::=", |
| 126355 | + /* 238 */ "nexprlist ::= nexprlist COMMA expr", |
| 126356 | + /* 239 */ "nexprlist ::= expr", |
| 126357 | + /* 240 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 126358 | + /* 241 */ "uniqueflag ::= UNIQUE", |
| 126359 | + /* 242 */ "uniqueflag ::=", |
| 126360 | + /* 243 */ "eidlist_opt ::=", |
| 126361 | + /* 244 */ "eidlist_opt ::= LP eidlist RP", |
| 126362 | + /* 245 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 126363 | + /* 246 */ "eidlist ::= nm collate sortorder", |
| 126364 | + /* 247 */ "collate ::=", |
| 126365 | + /* 248 */ "collate ::= COLLATE ID|STRING", |
| 126366 | + /* 249 */ "cmd ::= DROP INDEX ifexists fullname", |
| 126367 | + /* 250 */ "cmd ::= VACUUM", |
| 126368 | + /* 251 */ "cmd ::= VACUUM nm", |
| 126369 | + /* 252 */ "cmd ::= PRAGMA nm dbnm", |
| 126370 | + /* 253 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 126371 | + /* 254 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 126372 | + /* 255 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 126373 | + /* 256 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 126374 | + /* 257 */ "nmnum ::= plus_num", |
| 126375 | + /* 258 */ "nmnum ::= nm", |
| 126376 | + /* 259 */ "nmnum ::= ON", |
| 126377 | + /* 260 */ "nmnum ::= DELETE", |
| 126378 | + /* 261 */ "nmnum ::= DEFAULT", |
| 126379 | + /* 262 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 126380 | + /* 263 */ "plus_num ::= INTEGER|FLOAT", |
| 126381 | + /* 264 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 126382 | + /* 265 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 126383 | + /* 266 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 126384 | + /* 267 */ "trigger_time ::= BEFORE", |
| 126385 | + /* 268 */ "trigger_time ::= AFTER", |
| 126386 | + /* 269 */ "trigger_time ::= INSTEAD OF", |
| 126387 | + /* 270 */ "trigger_time ::=", |
| 126388 | + /* 271 */ "trigger_event ::= DELETE|INSERT", |
| 126389 | + /* 272 */ "trigger_event ::= UPDATE", |
| 126390 | + /* 273 */ "trigger_event ::= UPDATE OF idlist", |
| 126391 | + /* 274 */ "foreach_clause ::=", |
| 126392 | + /* 275 */ "foreach_clause ::= FOR EACH ROW", |
| 126393 | + /* 276 */ "when_clause ::=", |
| 126394 | + /* 277 */ "when_clause ::= WHEN expr", |
| 126395 | + /* 278 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 126396 | + /* 279 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 126397 | + /* 280 */ "trnm ::= nm", |
| 126398 | + /* 281 */ "trnm ::= nm DOT nm", |
| 126399 | + /* 282 */ "tridxby ::=", |
| 126400 | + /* 283 */ "tridxby ::= INDEXED BY nm", |
| 126401 | + /* 284 */ "tridxby ::= NOT INDEXED", |
| 126402 | + /* 285 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 126403 | + /* 286 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select", |
| 126404 | + /* 287 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 126405 | + /* 288 */ "trigger_cmd ::= select", |
| 126406 | + /* 289 */ "expr ::= RAISE LP IGNORE RP", |
| 126407 | + /* 290 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 126408 | + /* 291 */ "raisetype ::= ROLLBACK", |
| 126409 | + /* 292 */ "raisetype ::= ABORT", |
| 126410 | + /* 293 */ "raisetype ::= FAIL", |
| 126411 | + /* 294 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 126412 | + /* 295 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 126413 | + /* 296 */ "cmd ::= DETACH database_kw_opt expr", |
| 126414 | + /* 297 */ "key_opt ::=", |
| 126415 | + /* 298 */ "key_opt ::= KEY expr", |
| 126416 | + /* 299 */ "database_kw_opt ::= DATABASE", |
| 126417 | + /* 300 */ "database_kw_opt ::=", |
| 126418 | + /* 301 */ "cmd ::= REINDEX", |
| 126419 | + /* 302 */ "cmd ::= REINDEX nm dbnm", |
| 126420 | + /* 303 */ "cmd ::= ANALYZE", |
| 126421 | + /* 304 */ "cmd ::= ANALYZE nm dbnm", |
| 126422 | + /* 305 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 126423 | + /* 306 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column", |
| 126424 | + /* 307 */ "add_column_fullname ::= fullname", |
| 126425 | + /* 308 */ "kwcolumn_opt ::=", |
| 126426 | + /* 309 */ "kwcolumn_opt ::= COLUMNKW", |
| 126427 | + /* 310 */ "cmd ::= create_vtab", |
| 126428 | + /* 311 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 126429 | + /* 312 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 126430 | + /* 313 */ "vtabarglist ::= vtabarg", |
| 126431 | + /* 314 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 126432 | + /* 315 */ "vtabarg ::=", |
| 126433 | + /* 316 */ "vtabarg ::= vtabarg vtabargtoken", |
| 126434 | + /* 317 */ "vtabargtoken ::= ANY", |
| 126435 | + /* 318 */ "vtabargtoken ::= lp anylist RP", |
| 126436 | + /* 319 */ "lp ::= LP", |
| 126437 | + /* 320 */ "anylist ::=", |
| 126438 | + /* 321 */ "anylist ::= anylist LP anylist RP", |
| 126439 | + /* 322 */ "anylist ::= anylist ANY", |
| 126440 | + /* 323 */ "with ::=", |
| 126441 | + /* 324 */ "with ::= WITH wqlist", |
| 126442 | + /* 325 */ "with ::= WITH RECURSIVE wqlist", |
| 126443 | + /* 326 */ "wqlist ::= nm eidlist_opt AS LP select RP", |
| 126444 | + /* 327 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", |
| 125989 | 126445 | }; |
| 125990 | 126446 | #endif /* NDEBUG */ |
| 125991 | 126447 | |
| 125992 | 126448 | |
| 125993 | 126449 | #if YYSTACKDEPTH<=0 |
| | @@ -126063,13 +126519,13 @@ |
| 126063 | 126519 | ** Note: during a reduce, the only symbols destroyed are those |
| 126064 | 126520 | ** which appear on the RHS of the rule, but which are not used |
| 126065 | 126521 | ** inside the C code. |
| 126066 | 126522 | */ |
| 126067 | 126523 | case 163: /* select */ |
| 126068 | | - case 195: /* selectnowith */ |
| 126069 | | - case 196: /* oneselect */ |
| 126070 | | - case 207: /* values */ |
| 126524 | + case 196: /* selectnowith */ |
| 126525 | + case 197: /* oneselect */ |
| 126526 | + case 208: /* values */ |
| 126071 | 126527 | { |
| 126072 | 126528 | sqlite3SelectDelete(pParse->db, (yypminor->yy3)); |
| 126073 | 126529 | } |
| 126074 | 126530 | break; |
| 126075 | 126531 | case 174: /* term */ |
| | @@ -126076,53 +126532,53 @@ |
| 126076 | 126532 | case 175: /* expr */ |
| 126077 | 126533 | { |
| 126078 | 126534 | sqlite3ExprDelete(pParse->db, (yypminor->yy346).pExpr); |
| 126079 | 126535 | } |
| 126080 | 126536 | break; |
| 126081 | | - case 179: /* idxlist_opt */ |
| 126082 | | - case 188: /* idxlist */ |
| 126083 | | - case 200: /* selcollist */ |
| 126084 | | - case 203: /* groupby_opt */ |
| 126085 | | - case 205: /* orderby_opt */ |
| 126086 | | - case 208: /* nexprlist */ |
| 126087 | | - case 209: /* exprlist */ |
| 126088 | | - case 210: /* sclp */ |
| 126089 | | - case 220: /* sortlist */ |
| 126537 | + case 179: /* eidlist_opt */ |
| 126538 | + case 188: /* sortlist */ |
| 126539 | + case 189: /* eidlist */ |
| 126540 | + case 201: /* selcollist */ |
| 126541 | + case 204: /* groupby_opt */ |
| 126542 | + case 206: /* orderby_opt */ |
| 126543 | + case 209: /* nexprlist */ |
| 126544 | + case 210: /* exprlist */ |
| 126545 | + case 211: /* sclp */ |
| 126090 | 126546 | case 221: /* setlist */ |
| 126091 | 126547 | case 228: /* case_exprlist */ |
| 126092 | 126548 | { |
| 126093 | 126549 | sqlite3ExprListDelete(pParse->db, (yypminor->yy14)); |
| 126094 | 126550 | } |
| 126095 | 126551 | break; |
| 126096 | | - case 194: /* fullname */ |
| 126097 | | - case 201: /* from */ |
| 126098 | | - case 212: /* seltablist */ |
| 126099 | | - case 213: /* stl_prefix */ |
| 126552 | + case 195: /* fullname */ |
| 126553 | + case 202: /* from */ |
| 126554 | + case 213: /* seltablist */ |
| 126555 | + case 214: /* stl_prefix */ |
| 126100 | 126556 | { |
| 126101 | 126557 | sqlite3SrcListDelete(pParse->db, (yypminor->yy65)); |
| 126102 | 126558 | } |
| 126103 | 126559 | break; |
| 126104 | | - case 197: /* with */ |
| 126560 | + case 198: /* with */ |
| 126105 | 126561 | case 252: /* wqlist */ |
| 126106 | 126562 | { |
| 126107 | 126563 | sqlite3WithDelete(pParse->db, (yypminor->yy59)); |
| 126108 | 126564 | } |
| 126109 | 126565 | break; |
| 126110 | | - case 202: /* where_opt */ |
| 126111 | | - case 204: /* having_opt */ |
| 126112 | | - case 216: /* on_opt */ |
| 126566 | + case 203: /* where_opt */ |
| 126567 | + case 205: /* having_opt */ |
| 126568 | + case 217: /* on_opt */ |
| 126113 | 126569 | case 227: /* case_operand */ |
| 126114 | 126570 | case 229: /* case_else */ |
| 126115 | 126571 | case 238: /* when_clause */ |
| 126116 | 126572 | case 243: /* key_opt */ |
| 126117 | 126573 | { |
| 126118 | 126574 | sqlite3ExprDelete(pParse->db, (yypminor->yy132)); |
| 126119 | 126575 | } |
| 126120 | 126576 | break; |
| 126121 | | - case 217: /* using_opt */ |
| 126122 | | - case 219: /* idlist */ |
| 126123 | | - case 223: /* inscollist_opt */ |
| 126577 | + case 218: /* using_opt */ |
| 126578 | + case 220: /* idlist */ |
| 126579 | + case 223: /* idlist_opt */ |
| 126124 | 126580 | { |
| 126125 | 126581 | sqlite3IdListDelete(pParse->db, (yypminor->yy408)); |
| 126126 | 126582 | } |
| 126127 | 126583 | break; |
| 126128 | 126584 | case 234: /* trigger_cmd_list */ |
| | @@ -126218,14 +126674,14 @@ |
| 126218 | 126674 | YYCODETYPE iLookAhead /* The look-ahead token */ |
| 126219 | 126675 | ){ |
| 126220 | 126676 | int i; |
| 126221 | 126677 | int stateno = pParser->yystack[pParser->yyidx].stateno; |
| 126222 | 126678 | |
| 126223 | | - if( stateno>YY_SHIFT_COUNT |
| 126224 | | - || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ |
| 126225 | | - return yy_default[stateno]; |
| 126226 | | - } |
| 126679 | + if( stateno>=YY_MIN_REDUCE ) return stateno; |
| 126680 | + assert( stateno <= YY_SHIFT_COUNT ); |
| 126681 | + i = yy_shift_ofst[stateno]; |
| 126682 | + if( i==YY_SHIFT_USE_DFLT ) return yy_default[stateno]; |
| 126227 | 126683 | assert( iLookAhead!=YYNOCODE ); |
| 126228 | 126684 | i += iLookAhead; |
| 126229 | 126685 | if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ |
| 126230 | 126686 | if( iLookAhead>0 ){ |
| 126231 | 126687 | #ifdef YYFALLBACK |
| | @@ -126324,11 +126780,33 @@ |
| 126324 | 126780 | sqlite3ErrorMsg(pParse, "parser stack overflow"); |
| 126325 | 126781 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ |
| 126326 | 126782 | } |
| 126327 | 126783 | |
| 126328 | 126784 | /* |
| 126329 | | -** Perform a shift action. |
| 126785 | +** Print tracing information for a SHIFT action |
| 126786 | +*/ |
| 126787 | +#ifndef NDEBUG |
| 126788 | +static void yyTraceShift(yyParser *yypParser, int yyNewState){ |
| 126789 | + if( yyTraceFILE ){ |
| 126790 | + int i; |
| 126791 | + if( yyNewState<YYNSTATE ){ |
| 126792 | + fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); |
| 126793 | + fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); |
| 126794 | + for(i=1; i<=yypParser->yyidx; i++) |
| 126795 | + fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); |
| 126796 | + fprintf(yyTraceFILE,"\n"); |
| 126797 | + }else{ |
| 126798 | + fprintf(yyTraceFILE,"%sShift *\n",yyTracePrompt); |
| 126799 | + } |
| 126800 | + } |
| 126801 | +} |
| 126802 | +#else |
| 126803 | +# define yyTraceShift(X,Y) |
| 126804 | +#endif |
| 126805 | + |
| 126806 | +/* |
| 126807 | +** Perform a shift action. Return the number of errors. |
| 126330 | 126808 | */ |
| 126331 | 126809 | static void yy_shift( |
| 126332 | 126810 | yyParser *yypParser, /* The parser to be shifted */ |
| 126333 | 126811 | int yyNewState, /* The new state to shift in */ |
| 126334 | 126812 | int yyMajor, /* The major token to shift in */ |
| | @@ -126357,20 +126835,11 @@ |
| 126357 | 126835 | #endif |
| 126358 | 126836 | yytos = &yypParser->yystack[yypParser->yyidx]; |
| 126359 | 126837 | yytos->stateno = (YYACTIONTYPE)yyNewState; |
| 126360 | 126838 | yytos->major = (YYCODETYPE)yyMajor; |
| 126361 | 126839 | yytos->minor = *yypMinor; |
| 126362 | | -#ifndef NDEBUG |
| 126363 | | - if( yyTraceFILE && yypParser->yyidx>0 ){ |
| 126364 | | - int i; |
| 126365 | | - fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); |
| 126366 | | - fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); |
| 126367 | | - for(i=1; i<=yypParser->yyidx; i++) |
| 126368 | | - fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); |
| 126369 | | - fprintf(yyTraceFILE,"\n"); |
| 126370 | | - } |
| 126371 | | -#endif |
| 126840 | + yyTraceShift(yypParser, yyNewState); |
| 126372 | 126841 | } |
| 126373 | 126842 | |
| 126374 | 126843 | /* The following table contains information about every rule that |
| 126375 | 126844 | ** is used during the reduce. |
| 126376 | 126845 | */ |
| | @@ -126473,96 +126942,97 @@ |
| 126473 | 126942 | { 187, 2 }, |
| 126474 | 126943 | { 187, 7 }, |
| 126475 | 126944 | { 187, 5 }, |
| 126476 | 126945 | { 187, 5 }, |
| 126477 | 126946 | { 187, 10 }, |
| 126478 | | - { 189, 0 }, |
| 126479 | | - { 189, 1 }, |
| 126947 | + { 190, 0 }, |
| 126948 | + { 190, 1 }, |
| 126480 | 126949 | { 176, 0 }, |
| 126481 | 126950 | { 176, 3 }, |
| 126482 | | - { 190, 0 }, |
| 126483 | | - { 190, 2 }, |
| 126484 | | - { 191, 1 }, |
| 126485 | | - { 191, 1 }, |
| 126486 | | - { 191, 1 }, |
| 126951 | + { 191, 0 }, |
| 126952 | + { 191, 2 }, |
| 126953 | + { 192, 1 }, |
| 126954 | + { 192, 1 }, |
| 126955 | + { 192, 1 }, |
| 126487 | 126956 | { 149, 4 }, |
| 126488 | | - { 193, 2 }, |
| 126489 | | - { 193, 0 }, |
| 126490 | | - { 149, 8 }, |
| 126957 | + { 194, 2 }, |
| 126958 | + { 194, 0 }, |
| 126959 | + { 149, 9 }, |
| 126491 | 126960 | { 149, 4 }, |
| 126492 | 126961 | { 149, 1 }, |
| 126493 | 126962 | { 163, 2 }, |
| 126494 | | - { 195, 1 }, |
| 126495 | | - { 195, 3 }, |
| 126496 | | - { 198, 1 }, |
| 126497 | | - { 198, 2 }, |
| 126498 | | - { 198, 1 }, |
| 126499 | | - { 196, 9 }, |
| 126500 | | - { 196, 1 }, |
| 126501 | | - { 207, 4 }, |
| 126502 | | - { 207, 5 }, |
| 126503 | | - { 199, 1 }, |
| 126504 | | - { 199, 1 }, |
| 126505 | | - { 199, 0 }, |
| 126506 | | - { 210, 2 }, |
| 126507 | | - { 210, 0 }, |
| 126508 | | - { 200, 3 }, |
| 126509 | | - { 200, 2 }, |
| 126510 | | - { 200, 4 }, |
| 126511 | | - { 211, 2 }, |
| 126512 | | - { 211, 1 }, |
| 126513 | | - { 211, 0 }, |
| 126514 | | - { 201, 0 }, |
| 126515 | | - { 201, 2 }, |
| 126516 | | - { 213, 2 }, |
| 126517 | | - { 213, 0 }, |
| 126518 | | - { 212, 7 }, |
| 126519 | | - { 212, 7 }, |
| 126520 | | - { 212, 7 }, |
| 126963 | + { 196, 1 }, |
| 126964 | + { 196, 3 }, |
| 126965 | + { 199, 1 }, |
| 126966 | + { 199, 2 }, |
| 126967 | + { 199, 1 }, |
| 126968 | + { 197, 9 }, |
| 126969 | + { 197, 1 }, |
| 126970 | + { 208, 4 }, |
| 126971 | + { 208, 5 }, |
| 126972 | + { 200, 1 }, |
| 126973 | + { 200, 1 }, |
| 126974 | + { 200, 0 }, |
| 126975 | + { 211, 2 }, |
| 126976 | + { 211, 0 }, |
| 126977 | + { 201, 3 }, |
| 126978 | + { 201, 2 }, |
| 126979 | + { 201, 4 }, |
| 126980 | + { 212, 2 }, |
| 126981 | + { 212, 1 }, |
| 126982 | + { 212, 0 }, |
| 126983 | + { 202, 0 }, |
| 126984 | + { 202, 2 }, |
| 126985 | + { 214, 2 }, |
| 126986 | + { 214, 0 }, |
| 126987 | + { 213, 7 }, |
| 126988 | + { 213, 9 }, |
| 126989 | + { 213, 7 }, |
| 126990 | + { 213, 7 }, |
| 126521 | 126991 | { 159, 0 }, |
| 126522 | 126992 | { 159, 2 }, |
| 126523 | | - { 194, 2 }, |
| 126524 | | - { 214, 1 }, |
| 126525 | | - { 214, 2 }, |
| 126526 | | - { 214, 3 }, |
| 126527 | | - { 214, 4 }, |
| 126528 | | - { 216, 2 }, |
| 126993 | + { 195, 2 }, |
| 126994 | + { 215, 1 }, |
| 126995 | + { 215, 2 }, |
| 126996 | + { 215, 3 }, |
| 126997 | + { 215, 4 }, |
| 126998 | + { 217, 2 }, |
| 126999 | + { 217, 0 }, |
| 126529 | 127000 | { 216, 0 }, |
| 126530 | | - { 215, 0 }, |
| 126531 | | - { 215, 3 }, |
| 126532 | | - { 215, 2 }, |
| 126533 | | - { 217, 4 }, |
| 126534 | | - { 217, 0 }, |
| 126535 | | - { 205, 0 }, |
| 126536 | | - { 205, 3 }, |
| 126537 | | - { 220, 4 }, |
| 126538 | | - { 220, 2 }, |
| 127001 | + { 216, 3 }, |
| 127002 | + { 216, 2 }, |
| 127003 | + { 218, 4 }, |
| 127004 | + { 218, 0 }, |
| 127005 | + { 206, 0 }, |
| 127006 | + { 206, 3 }, |
| 127007 | + { 188, 4 }, |
| 127008 | + { 188, 2 }, |
| 126539 | 127009 | { 177, 1 }, |
| 126540 | 127010 | { 177, 1 }, |
| 126541 | 127011 | { 177, 0 }, |
| 126542 | | - { 203, 0 }, |
| 126543 | | - { 203, 3 }, |
| 126544 | 127012 | { 204, 0 }, |
| 126545 | | - { 204, 2 }, |
| 126546 | | - { 206, 0 }, |
| 126547 | | - { 206, 2 }, |
| 126548 | | - { 206, 4 }, |
| 126549 | | - { 206, 4 }, |
| 127013 | + { 204, 3 }, |
| 127014 | + { 205, 0 }, |
| 127015 | + { 205, 2 }, |
| 127016 | + { 207, 0 }, |
| 127017 | + { 207, 2 }, |
| 127018 | + { 207, 4 }, |
| 127019 | + { 207, 4 }, |
| 126550 | 127020 | { 149, 6 }, |
| 126551 | | - { 202, 0 }, |
| 126552 | | - { 202, 2 }, |
| 127021 | + { 203, 0 }, |
| 127022 | + { 203, 2 }, |
| 126553 | 127023 | { 149, 8 }, |
| 126554 | 127024 | { 221, 5 }, |
| 126555 | 127025 | { 221, 3 }, |
| 126556 | 127026 | { 149, 6 }, |
| 126557 | 127027 | { 149, 7 }, |
| 126558 | 127028 | { 222, 2 }, |
| 126559 | 127029 | { 222, 1 }, |
| 126560 | 127030 | { 223, 0 }, |
| 126561 | 127031 | { 223, 3 }, |
| 126562 | | - { 219, 3 }, |
| 126563 | | - { 219, 1 }, |
| 127032 | + { 220, 3 }, |
| 127033 | + { 220, 1 }, |
| 126564 | 127034 | { 175, 1 }, |
| 126565 | 127035 | { 175, 3 }, |
| 126566 | 127036 | { 174, 1 }, |
| 126567 | 127037 | { 175, 1 }, |
| 126568 | 127038 | { 175, 1 }, |
| | @@ -126611,21 +127081,21 @@ |
| 126611 | 127081 | { 228, 4 }, |
| 126612 | 127082 | { 229, 2 }, |
| 126613 | 127083 | { 229, 0 }, |
| 126614 | 127084 | { 227, 1 }, |
| 126615 | 127085 | { 227, 0 }, |
| 127086 | + { 210, 1 }, |
| 127087 | + { 210, 0 }, |
| 127088 | + { 209, 3 }, |
| 126616 | 127089 | { 209, 1 }, |
| 126617 | | - { 209, 0 }, |
| 126618 | | - { 208, 3 }, |
| 126619 | | - { 208, 1 }, |
| 126620 | 127090 | { 149, 12 }, |
| 126621 | 127091 | { 230, 1 }, |
| 126622 | 127092 | { 230, 0 }, |
| 126623 | 127093 | { 179, 0 }, |
| 126624 | 127094 | { 179, 3 }, |
| 126625 | | - { 188, 5 }, |
| 126626 | | - { 188, 3 }, |
| 127095 | + { 189, 5 }, |
| 127096 | + { 189, 3 }, |
| 126627 | 127097 | { 231, 0 }, |
| 126628 | 127098 | { 231, 2 }, |
| 126629 | 127099 | { 149, 4 }, |
| 126630 | 127100 | { 149, 1 }, |
| 126631 | 127101 | { 149, 2 }, |
| | @@ -126666,13 +127136,13 @@ |
| 126666 | 127136 | { 239, 5 }, |
| 126667 | 127137 | { 239, 5 }, |
| 126668 | 127138 | { 239, 1 }, |
| 126669 | 127139 | { 175, 4 }, |
| 126670 | 127140 | { 175, 6 }, |
| 126671 | | - { 192, 1 }, |
| 126672 | | - { 192, 1 }, |
| 126673 | | - { 192, 1 }, |
| 127141 | + { 193, 1 }, |
| 127142 | + { 193, 1 }, |
| 127143 | + { 193, 1 }, |
| 126674 | 127144 | { 149, 4 }, |
| 126675 | 127145 | { 149, 6 }, |
| 126676 | 127146 | { 149, 3 }, |
| 126677 | 127147 | { 243, 0 }, |
| 126678 | 127148 | { 243, 2 }, |
| | @@ -126698,13 +127168,13 @@ |
| 126698 | 127168 | { 249, 3 }, |
| 126699 | 127169 | { 250, 1 }, |
| 126700 | 127170 | { 251, 0 }, |
| 126701 | 127171 | { 251, 4 }, |
| 126702 | 127172 | { 251, 2 }, |
| 126703 | | - { 197, 0 }, |
| 126704 | | - { 197, 2 }, |
| 126705 | | - { 197, 3 }, |
| 127173 | + { 198, 0 }, |
| 127174 | + { 198, 2 }, |
| 127175 | + { 198, 3 }, |
| 126706 | 127176 | { 252, 6 }, |
| 126707 | 127177 | { 252, 8 }, |
| 126708 | 127178 | }; |
| 126709 | 127179 | |
| 126710 | 127180 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| | @@ -126725,12 +127195,13 @@ |
| 126725 | 127195 | sqlite3ParserARG_FETCH; |
| 126726 | 127196 | yymsp = &yypParser->yystack[yypParser->yyidx]; |
| 126727 | 127197 | #ifndef NDEBUG |
| 126728 | 127198 | if( yyTraceFILE && yyruleno>=0 |
| 126729 | 127199 | && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
| 126730 | | - fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, |
| 126731 | | - yyRuleName[yyruleno]); |
| 127200 | + yysize = yyRuleInfo[yyruleno].nrhs; |
| 127201 | + fprintf(yyTraceFILE, "%sReduce [%s] -> state %d.\n", yyTracePrompt, |
| 127202 | + yyRuleName[yyruleno], yymsp[-yysize].stateno); |
| 126732 | 127203 | } |
| 126733 | 127204 | #endif /* NDEBUG */ |
| 126734 | 127205 | |
| 126735 | 127206 | /* Silence complaints from purify about yygotominor being uninitialized |
| 126736 | 127207 | ** in some cases when it is copied into the stack after the following |
| | @@ -126823,21 +127294,23 @@ |
| 126823 | 127294 | case 81: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==81); |
| 126824 | 127295 | case 83: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==83); |
| 126825 | 127296 | case 85: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==85); |
| 126826 | 127297 | case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97); |
| 126827 | 127298 | case 108: /* ifexists ::= */ yytestcase(yyruleno==108); |
| 126828 | | - case 218: /* between_op ::= BETWEEN */ yytestcase(yyruleno==218); |
| 126829 | | - case 221: /* in_op ::= IN */ yytestcase(yyruleno==221); |
| 127299 | + case 219: /* between_op ::= BETWEEN */ yytestcase(yyruleno==219); |
| 127300 | + case 222: /* in_op ::= IN */ yytestcase(yyruleno==222); |
| 127301 | + case 247: /* collate ::= */ yytestcase(yyruleno==247); |
| 126830 | 127302 | {yygotominor.yy328 = 0;} |
| 126831 | 127303 | break; |
| 126832 | 127304 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 126833 | 127305 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 126834 | 127306 | case 69: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==69); |
| 126835 | 127307 | case 84: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==84); |
| 126836 | 127308 | case 107: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==107); |
| 126837 | | - case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219); |
| 126838 | | - case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222); |
| 127309 | + case 220: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==220); |
| 127310 | + case 223: /* in_op ::= NOT IN */ yytestcase(yyruleno==223); |
| 127311 | + case 248: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==248); |
| 126839 | 127312 | {yygotominor.yy328 = 1;} |
| 126840 | 127313 | break; |
| 126841 | 127314 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 126842 | 127315 | { |
| 126843 | 127316 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy186,0); |
| | @@ -126880,22 +127353,21 @@ |
| 126880 | 127353 | case 42: /* nm ::= JOIN_KW */ yytestcase(yyruleno==42); |
| 126881 | 127354 | case 45: /* typetoken ::= typename */ yytestcase(yyruleno==45); |
| 126882 | 127355 | case 48: /* typename ::= ID|STRING */ yytestcase(yyruleno==48); |
| 126883 | 127356 | case 130: /* as ::= AS nm */ yytestcase(yyruleno==130); |
| 126884 | 127357 | case 131: /* as ::= ID|STRING */ yytestcase(yyruleno==131); |
| 126885 | | - case 141: /* dbnm ::= DOT nm */ yytestcase(yyruleno==141); |
| 126886 | | - case 150: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==150); |
| 126887 | | - case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247); |
| 126888 | | - case 256: /* nmnum ::= plus_num */ yytestcase(yyruleno==256); |
| 126889 | | - case 257: /* nmnum ::= nm */ yytestcase(yyruleno==257); |
| 126890 | | - case 258: /* nmnum ::= ON */ yytestcase(yyruleno==258); |
| 126891 | | - case 259: /* nmnum ::= DELETE */ yytestcase(yyruleno==259); |
| 126892 | | - case 260: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==260); |
| 126893 | | - case 261: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==261); |
| 126894 | | - case 262: /* plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==262); |
| 126895 | | - case 263: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==263); |
| 126896 | | - case 279: /* trnm ::= nm */ yytestcase(yyruleno==279); |
| 127358 | + case 142: /* dbnm ::= DOT nm */ yytestcase(yyruleno==142); |
| 127359 | + case 151: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==151); |
| 127360 | + case 257: /* nmnum ::= plus_num */ yytestcase(yyruleno==257); |
| 127361 | + case 258: /* nmnum ::= nm */ yytestcase(yyruleno==258); |
| 127362 | + case 259: /* nmnum ::= ON */ yytestcase(yyruleno==259); |
| 127363 | + case 260: /* nmnum ::= DELETE */ yytestcase(yyruleno==260); |
| 127364 | + case 261: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==261); |
| 127365 | + case 262: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==262); |
| 127366 | + case 263: /* plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==263); |
| 127367 | + case 264: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==264); |
| 127368 | + case 280: /* trnm ::= nm */ yytestcase(yyruleno==280); |
| 126897 | 127369 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 126898 | 127370 | break; |
| 126899 | 127371 | case 44: /* type ::= typetoken */ |
| 126900 | 127372 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 126901 | 127373 | break; |
| | @@ -126951,11 +127423,11 @@ |
| 126951 | 127423 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy328,0,0,0,0);} |
| 126952 | 127424 | break; |
| 126953 | 127425 | case 64: /* ccons ::= CHECK LP expr RP */ |
| 126954 | 127426 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy346.pExpr);} |
| 126955 | 127427 | break; |
| 126956 | | - case 65: /* ccons ::= REFERENCES nm idxlist_opt refargs */ |
| 127428 | + case 65: /* ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 126957 | 127429 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy328);} |
| 126958 | 127430 | break; |
| 126959 | 127431 | case 66: /* ccons ::= defer_subclause */ |
| 126960 | 127432 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy328);} |
| 126961 | 127433 | break; |
| | @@ -127006,20 +127478,20 @@ |
| 127006 | 127478 | {yygotominor.yy0 = yymsp[-1].minor.yy0;} |
| 127007 | 127479 | break; |
| 127008 | 127480 | case 90: /* tconscomma ::= COMMA */ |
| 127009 | 127481 | {pParse->constraintName.n = 0;} |
| 127010 | 127482 | break; |
| 127011 | | - case 93: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 127483 | + case 93: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 127012 | 127484 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy328,yymsp[-2].minor.yy328,0);} |
| 127013 | 127485 | break; |
| 127014 | | - case 94: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 127486 | + case 94: /* tcons ::= UNIQUE LP sortlist RP onconf */ |
| 127015 | 127487 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy328,0,0,0,0);} |
| 127016 | 127488 | break; |
| 127017 | 127489 | case 95: /* tcons ::= CHECK LP expr RP onconf */ |
| 127018 | 127490 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);} |
| 127019 | 127491 | break; |
| 127020 | | - case 96: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 127492 | + case 96: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 127021 | 127493 | { |
| 127022 | 127494 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy328); |
| 127023 | 127495 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy328); |
| 127024 | 127496 | } |
| 127025 | 127497 | break; |
| | @@ -127041,13 +127513,13 @@ |
| 127041 | 127513 | case 106: /* cmd ::= DROP TABLE ifexists fullname */ |
| 127042 | 127514 | { |
| 127043 | 127515 | sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328); |
| 127044 | 127516 | } |
| 127045 | 127517 | break; |
| 127046 | | - case 109: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 127518 | + case 109: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 127047 | 127519 | { |
| 127048 | | - sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy3, yymsp[-6].minor.yy328, yymsp[-4].minor.yy328); |
| 127520 | + sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[0].minor.yy3, yymsp[-7].minor.yy328, yymsp[-5].minor.yy328); |
| 127049 | 127521 | } |
| 127050 | 127522 | break; |
| 127051 | 127523 | case 110: /* cmd ::= DROP VIEW ifexists fullname */ |
| 127052 | 127524 | { |
| 127053 | 127525 | sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328); |
| | @@ -127160,18 +127632,18 @@ |
| 127160 | 127632 | break; |
| 127161 | 127633 | case 124: /* distinct ::= */ |
| 127162 | 127634 | {yygotominor.yy381 = 0;} |
| 127163 | 127635 | break; |
| 127164 | 127636 | case 125: /* sclp ::= selcollist COMMA */ |
| 127165 | | - case 243: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==243); |
| 127637 | + case 244: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==244); |
| 127166 | 127638 | {yygotominor.yy14 = yymsp[-1].minor.yy14;} |
| 127167 | 127639 | break; |
| 127168 | 127640 | case 126: /* sclp ::= */ |
| 127169 | | - case 154: /* orderby_opt ::= */ yytestcase(yyruleno==154); |
| 127170 | | - case 161: /* groupby_opt ::= */ yytestcase(yyruleno==161); |
| 127171 | | - case 236: /* exprlist ::= */ yytestcase(yyruleno==236); |
| 127172 | | - case 242: /* idxlist_opt ::= */ yytestcase(yyruleno==242); |
| 127641 | + case 155: /* orderby_opt ::= */ yytestcase(yyruleno==155); |
| 127642 | + case 162: /* groupby_opt ::= */ yytestcase(yyruleno==162); |
| 127643 | + case 237: /* exprlist ::= */ yytestcase(yyruleno==237); |
| 127644 | + case 243: /* eidlist_opt ::= */ yytestcase(yyruleno==243); |
| 127173 | 127645 | {yygotominor.yy14 = 0;} |
| 127174 | 127646 | break; |
| 127175 | 127647 | case 127: /* selcollist ::= sclp expr as */ |
| 127176 | 127648 | { |
| 127177 | 127649 | yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, yymsp[-1].minor.yy346.pExpr); |
| | @@ -127206,11 +127678,11 @@ |
| 127206 | 127678 | } |
| 127207 | 127679 | break; |
| 127208 | 127680 | case 135: /* stl_prefix ::= seltablist joinop */ |
| 127209 | 127681 | { |
| 127210 | 127682 | yygotominor.yy65 = yymsp[-1].minor.yy65; |
| 127211 | | - if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].jointype = (u8)yymsp[0].minor.yy328; |
| 127683 | + if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy328; |
| 127212 | 127684 | } |
| 127213 | 127685 | break; |
| 127214 | 127686 | case 136: /* stl_prefix ::= */ |
| 127215 | 127687 | {yygotominor.yy65 = 0;} |
| 127216 | 127688 | break; |
| | @@ -127218,16 +127690,22 @@ |
| 127218 | 127690 | { |
| 127219 | 127691 | yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408); |
| 127220 | 127692 | sqlite3SrcListIndexedBy(pParse, yygotominor.yy65, &yymsp[-2].minor.yy0); |
| 127221 | 127693 | } |
| 127222 | 127694 | break; |
| 127223 | | - case 138: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 127695 | + case 138: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 127696 | +{ |
| 127697 | + yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy65,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408); |
| 127698 | + sqlite3SrcListFuncArgs(pParse, yygotominor.yy65, yymsp[-4].minor.yy14); |
| 127699 | +} |
| 127700 | + break; |
| 127701 | + case 139: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 127224 | 127702 | { |
| 127225 | 127703 | yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy3,yymsp[-1].minor.yy132,yymsp[0].minor.yy408); |
| 127226 | 127704 | } |
| 127227 | 127705 | break; |
| 127228 | | - case 139: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 127706 | + case 140: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 127229 | 127707 | { |
| 127230 | 127708 | if( yymsp[-6].minor.yy65==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy132==0 && yymsp[0].minor.yy408==0 ){ |
| 127231 | 127709 | yygotominor.yy65 = yymsp[-4].minor.yy65; |
| 127232 | 127710 | }else if( yymsp[-4].minor.yy65->nSrc==1 ){ |
| 127233 | 127711 | yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408); |
| | @@ -127247,175 +127725,177 @@ |
| 127247 | 127725 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy65,0,0,0,0,SF_NestedFrom,0,0); |
| 127248 | 127726 | yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy132,yymsp[0].minor.yy408); |
| 127249 | 127727 | } |
| 127250 | 127728 | } |
| 127251 | 127729 | break; |
| 127252 | | - case 140: /* dbnm ::= */ |
| 127253 | | - case 149: /* indexed_opt ::= */ yytestcase(yyruleno==149); |
| 127730 | + case 141: /* dbnm ::= */ |
| 127731 | + case 150: /* indexed_opt ::= */ yytestcase(yyruleno==150); |
| 127254 | 127732 | {yygotominor.yy0.z=0; yygotominor.yy0.n=0;} |
| 127255 | 127733 | break; |
| 127256 | | - case 142: /* fullname ::= nm dbnm */ |
| 127734 | + case 143: /* fullname ::= nm dbnm */ |
| 127257 | 127735 | {yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 127258 | 127736 | break; |
| 127259 | | - case 143: /* joinop ::= COMMA|JOIN */ |
| 127737 | + case 144: /* joinop ::= COMMA|JOIN */ |
| 127260 | 127738 | { yygotominor.yy328 = JT_INNER; } |
| 127261 | 127739 | break; |
| 127262 | | - case 144: /* joinop ::= JOIN_KW JOIN */ |
| 127740 | + case 145: /* joinop ::= JOIN_KW JOIN */ |
| 127263 | 127741 | { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 127264 | 127742 | break; |
| 127265 | | - case 145: /* joinop ::= JOIN_KW nm JOIN */ |
| 127743 | + case 146: /* joinop ::= JOIN_KW nm JOIN */ |
| 127266 | 127744 | { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 127267 | 127745 | break; |
| 127268 | | - case 146: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 127746 | + case 147: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 127269 | 127747 | { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 127270 | 127748 | break; |
| 127271 | | - case 147: /* on_opt ::= ON expr */ |
| 127272 | | - case 164: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==164); |
| 127273 | | - case 171: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==171); |
| 127274 | | - case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231); |
| 127275 | | - case 233: /* case_operand ::= expr */ yytestcase(yyruleno==233); |
| 127749 | + case 148: /* on_opt ::= ON expr */ |
| 127750 | + case 165: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==165); |
| 127751 | + case 172: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==172); |
| 127752 | + case 232: /* case_else ::= ELSE expr */ yytestcase(yyruleno==232); |
| 127753 | + case 234: /* case_operand ::= expr */ yytestcase(yyruleno==234); |
| 127276 | 127754 | {yygotominor.yy132 = yymsp[0].minor.yy346.pExpr;} |
| 127277 | 127755 | break; |
| 127278 | | - case 148: /* on_opt ::= */ |
| 127279 | | - case 163: /* having_opt ::= */ yytestcase(yyruleno==163); |
| 127280 | | - case 170: /* where_opt ::= */ yytestcase(yyruleno==170); |
| 127281 | | - case 232: /* case_else ::= */ yytestcase(yyruleno==232); |
| 127282 | | - case 234: /* case_operand ::= */ yytestcase(yyruleno==234); |
| 127756 | + case 149: /* on_opt ::= */ |
| 127757 | + case 164: /* having_opt ::= */ yytestcase(yyruleno==164); |
| 127758 | + case 171: /* where_opt ::= */ yytestcase(yyruleno==171); |
| 127759 | + case 233: /* case_else ::= */ yytestcase(yyruleno==233); |
| 127760 | + case 235: /* case_operand ::= */ yytestcase(yyruleno==235); |
| 127283 | 127761 | {yygotominor.yy132 = 0;} |
| 127284 | 127762 | break; |
| 127285 | | - case 151: /* indexed_opt ::= NOT INDEXED */ |
| 127763 | + case 152: /* indexed_opt ::= NOT INDEXED */ |
| 127286 | 127764 | {yygotominor.yy0.z=0; yygotominor.yy0.n=1;} |
| 127287 | 127765 | break; |
| 127288 | | - case 152: /* using_opt ::= USING LP idlist RP */ |
| 127289 | | - case 180: /* inscollist_opt ::= LP idlist RP */ yytestcase(yyruleno==180); |
| 127766 | + case 153: /* using_opt ::= USING LP idlist RP */ |
| 127767 | + case 181: /* idlist_opt ::= LP idlist RP */ yytestcase(yyruleno==181); |
| 127290 | 127768 | {yygotominor.yy408 = yymsp[-1].minor.yy408;} |
| 127291 | 127769 | break; |
| 127292 | | - case 153: /* using_opt ::= */ |
| 127293 | | - case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179); |
| 127770 | + case 154: /* using_opt ::= */ |
| 127771 | + case 180: /* idlist_opt ::= */ yytestcase(yyruleno==180); |
| 127294 | 127772 | {yygotominor.yy408 = 0;} |
| 127295 | 127773 | break; |
| 127296 | | - case 155: /* orderby_opt ::= ORDER BY sortlist */ |
| 127297 | | - case 162: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==162); |
| 127298 | | - case 235: /* exprlist ::= nexprlist */ yytestcase(yyruleno==235); |
| 127774 | + case 156: /* orderby_opt ::= ORDER BY sortlist */ |
| 127775 | + case 163: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==163); |
| 127776 | + case 236: /* exprlist ::= nexprlist */ yytestcase(yyruleno==236); |
| 127299 | 127777 | {yygotominor.yy14 = yymsp[0].minor.yy14;} |
| 127300 | 127778 | break; |
| 127301 | | - case 156: /* sortlist ::= sortlist COMMA expr sortorder */ |
| 127779 | + case 157: /* sortlist ::= sortlist COMMA expr sortorder */ |
| 127302 | 127780 | { |
| 127303 | 127781 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14,yymsp[-1].minor.yy346.pExpr); |
| 127304 | | - if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 127782 | + sqlite3ExprListSetSortOrder(yygotominor.yy14,yymsp[0].minor.yy328); |
| 127305 | 127783 | } |
| 127306 | 127784 | break; |
| 127307 | | - case 157: /* sortlist ::= expr sortorder */ |
| 127785 | + case 158: /* sortlist ::= expr sortorder */ |
| 127308 | 127786 | { |
| 127309 | 127787 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy346.pExpr); |
| 127310 | | - if( yygotominor.yy14 && ALWAYS(yygotominor.yy14->a) ) yygotominor.yy14->a[0].sortOrder = (u8)yymsp[0].minor.yy328; |
| 127788 | + sqlite3ExprListSetSortOrder(yygotominor.yy14,yymsp[0].minor.yy328); |
| 127311 | 127789 | } |
| 127312 | 127790 | break; |
| 127313 | | - case 158: /* sortorder ::= ASC */ |
| 127314 | | - case 160: /* sortorder ::= */ yytestcase(yyruleno==160); |
| 127791 | + case 159: /* sortorder ::= ASC */ |
| 127315 | 127792 | {yygotominor.yy328 = SQLITE_SO_ASC;} |
| 127316 | 127793 | break; |
| 127317 | | - case 159: /* sortorder ::= DESC */ |
| 127794 | + case 160: /* sortorder ::= DESC */ |
| 127318 | 127795 | {yygotominor.yy328 = SQLITE_SO_DESC;} |
| 127319 | 127796 | break; |
| 127320 | | - case 165: /* limit_opt ::= */ |
| 127797 | + case 161: /* sortorder ::= */ |
| 127798 | +{yygotominor.yy328 = SQLITE_SO_UNDEFINED;} |
| 127799 | + break; |
| 127800 | + case 166: /* limit_opt ::= */ |
| 127321 | 127801 | {yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;} |
| 127322 | 127802 | break; |
| 127323 | | - case 166: /* limit_opt ::= LIMIT expr */ |
| 127803 | + case 167: /* limit_opt ::= LIMIT expr */ |
| 127324 | 127804 | {yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;} |
| 127325 | 127805 | break; |
| 127326 | | - case 167: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 127806 | + case 168: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 127327 | 127807 | {yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;} |
| 127328 | 127808 | break; |
| 127329 | | - case 168: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 127809 | + case 169: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 127330 | 127810 | {yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;} |
| 127331 | 127811 | break; |
| 127332 | | - case 169: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */ |
| 127812 | + case 170: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */ |
| 127333 | 127813 | { |
| 127334 | 127814 | sqlite3WithPush(pParse, yymsp[-5].minor.yy59, 1); |
| 127335 | 127815 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy65, &yymsp[-1].minor.yy0); |
| 127336 | 127816 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy65,yymsp[0].minor.yy132); |
| 127337 | 127817 | } |
| 127338 | 127818 | break; |
| 127339 | | - case 172: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 127819 | + case 173: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 127340 | 127820 | { |
| 127341 | 127821 | sqlite3WithPush(pParse, yymsp[-7].minor.yy59, 1); |
| 127342 | 127822 | sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy65, &yymsp[-3].minor.yy0); |
| 127343 | 127823 | sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy14,"set list"); |
| 127344 | 127824 | sqlite3Update(pParse,yymsp[-4].minor.yy65,yymsp[-1].minor.yy14,yymsp[0].minor.yy132,yymsp[-5].minor.yy186); |
| 127345 | 127825 | } |
| 127346 | 127826 | break; |
| 127347 | | - case 173: /* setlist ::= setlist COMMA nm EQ expr */ |
| 127827 | + case 174: /* setlist ::= setlist COMMA nm EQ expr */ |
| 127348 | 127828 | { |
| 127349 | 127829 | yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy346.pExpr); |
| 127350 | 127830 | sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1); |
| 127351 | 127831 | } |
| 127352 | 127832 | break; |
| 127353 | | - case 174: /* setlist ::= nm EQ expr */ |
| 127833 | + case 175: /* setlist ::= nm EQ expr */ |
| 127354 | 127834 | { |
| 127355 | 127835 | yygotominor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy346.pExpr); |
| 127356 | 127836 | sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1); |
| 127357 | 127837 | } |
| 127358 | 127838 | break; |
| 127359 | | - case 175: /* cmd ::= with insert_cmd INTO fullname inscollist_opt select */ |
| 127839 | + case 176: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */ |
| 127360 | 127840 | { |
| 127361 | 127841 | sqlite3WithPush(pParse, yymsp[-5].minor.yy59, 1); |
| 127362 | 127842 | sqlite3Insert(pParse, yymsp[-2].minor.yy65, yymsp[0].minor.yy3, yymsp[-1].minor.yy408, yymsp[-4].minor.yy186); |
| 127363 | 127843 | } |
| 127364 | 127844 | break; |
| 127365 | | - case 176: /* cmd ::= with insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 127845 | + case 177: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */ |
| 127366 | 127846 | { |
| 127367 | 127847 | sqlite3WithPush(pParse, yymsp[-6].minor.yy59, 1); |
| 127368 | 127848 | sqlite3Insert(pParse, yymsp[-3].minor.yy65, 0, yymsp[-2].minor.yy408, yymsp[-5].minor.yy186); |
| 127369 | 127849 | } |
| 127370 | 127850 | break; |
| 127371 | | - case 177: /* insert_cmd ::= INSERT orconf */ |
| 127851 | + case 178: /* insert_cmd ::= INSERT orconf */ |
| 127372 | 127852 | {yygotominor.yy186 = yymsp[0].minor.yy186;} |
| 127373 | 127853 | break; |
| 127374 | | - case 178: /* insert_cmd ::= REPLACE */ |
| 127854 | + case 179: /* insert_cmd ::= REPLACE */ |
| 127375 | 127855 | {yygotominor.yy186 = OE_Replace;} |
| 127376 | 127856 | break; |
| 127377 | | - case 181: /* idlist ::= idlist COMMA nm */ |
| 127857 | + case 182: /* idlist ::= idlist COMMA nm */ |
| 127378 | 127858 | {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);} |
| 127379 | 127859 | break; |
| 127380 | | - case 182: /* idlist ::= nm */ |
| 127860 | + case 183: /* idlist ::= nm */ |
| 127381 | 127861 | {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 127382 | 127862 | break; |
| 127383 | | - case 183: /* expr ::= term */ |
| 127863 | + case 184: /* expr ::= term */ |
| 127384 | 127864 | {yygotominor.yy346 = yymsp[0].minor.yy346;} |
| 127385 | 127865 | break; |
| 127386 | | - case 184: /* expr ::= LP expr RP */ |
| 127866 | + case 185: /* expr ::= LP expr RP */ |
| 127387 | 127867 | {yygotominor.yy346.pExpr = yymsp[-1].minor.yy346.pExpr; spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 127388 | 127868 | break; |
| 127389 | | - case 185: /* term ::= NULL */ |
| 127390 | | - case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190); |
| 127391 | | - case 191: /* term ::= STRING */ yytestcase(yyruleno==191); |
| 127869 | + case 186: /* term ::= NULL */ |
| 127870 | + case 191: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==191); |
| 127871 | + case 192: /* term ::= STRING */ yytestcase(yyruleno==192); |
| 127392 | 127872 | {spanExpr(&yygotominor.yy346, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 127393 | 127873 | break; |
| 127394 | | - case 186: /* expr ::= ID|INDEXED */ |
| 127395 | | - case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187); |
| 127874 | + case 187: /* expr ::= ID|INDEXED */ |
| 127875 | + case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188); |
| 127396 | 127876 | {spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 127397 | 127877 | break; |
| 127398 | | - case 188: /* expr ::= nm DOT nm */ |
| 127878 | + case 189: /* expr ::= nm DOT nm */ |
| 127399 | 127879 | { |
| 127400 | 127880 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 127401 | 127881 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 127402 | 127882 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 127403 | 127883 | spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 127404 | 127884 | } |
| 127405 | 127885 | break; |
| 127406 | | - case 189: /* expr ::= nm DOT nm DOT nm */ |
| 127886 | + case 190: /* expr ::= nm DOT nm DOT nm */ |
| 127407 | 127887 | { |
| 127408 | 127888 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 127409 | 127889 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 127410 | 127890 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 127411 | 127891 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 127412 | 127892 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 127413 | 127893 | spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 127414 | 127894 | } |
| 127415 | 127895 | break; |
| 127416 | | - case 192: /* expr ::= VARIABLE */ |
| 127896 | + case 193: /* expr ::= VARIABLE */ |
| 127417 | 127897 | { |
| 127418 | 127898 | if( yymsp[0].minor.yy0.n>=2 && yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1]) ){ |
| 127419 | 127899 | /* When doing a nested parse, one can include terms in an expression |
| 127420 | 127900 | ** that look like this: #1 #2 ... These terms refer to registers |
| 127421 | 127901 | ** in the virtual machine. #N is the N-th register. */ |
| | @@ -127431,24 +127911,24 @@ |
| 127431 | 127911 | sqlite3ExprAssignVarNumber(pParse, yygotominor.yy346.pExpr); |
| 127432 | 127912 | } |
| 127433 | 127913 | spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 127434 | 127914 | } |
| 127435 | 127915 | break; |
| 127436 | | - case 193: /* expr ::= expr COLLATE ID|STRING */ |
| 127916 | + case 194: /* expr ::= expr COLLATE ID|STRING */ |
| 127437 | 127917 | { |
| 127438 | 127918 | yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0, 1); |
| 127439 | 127919 | yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart; |
| 127440 | 127920 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127441 | 127921 | } |
| 127442 | 127922 | break; |
| 127443 | | - case 194: /* expr ::= CAST LP expr AS typetoken RP */ |
| 127923 | + case 195: /* expr ::= CAST LP expr AS typetoken RP */ |
| 127444 | 127924 | { |
| 127445 | 127925 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy346.pExpr, 0, &yymsp[-1].minor.yy0); |
| 127446 | 127926 | spanSet(&yygotominor.yy346,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 127447 | 127927 | } |
| 127448 | 127928 | break; |
| 127449 | | - case 195: /* expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 127929 | + case 196: /* expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 127450 | 127930 | { |
| 127451 | 127931 | if( yymsp[-1].minor.yy14 && yymsp[-1].minor.yy14->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 127452 | 127932 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 127453 | 127933 | } |
| 127454 | 127934 | yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0); |
| | @@ -127456,39 +127936,39 @@ |
| 127456 | 127936 | if( yymsp[-2].minor.yy381==SF_Distinct && yygotominor.yy346.pExpr ){ |
| 127457 | 127937 | yygotominor.yy346.pExpr->flags |= EP_Distinct; |
| 127458 | 127938 | } |
| 127459 | 127939 | } |
| 127460 | 127940 | break; |
| 127461 | | - case 196: /* expr ::= ID|INDEXED LP STAR RP */ |
| 127941 | + case 197: /* expr ::= ID|INDEXED LP STAR RP */ |
| 127462 | 127942 | { |
| 127463 | 127943 | yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 127464 | 127944 | spanSet(&yygotominor.yy346,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 127465 | 127945 | } |
| 127466 | 127946 | break; |
| 127467 | | - case 197: /* term ::= CTIME_KW */ |
| 127947 | + case 198: /* term ::= CTIME_KW */ |
| 127468 | 127948 | { |
| 127469 | 127949 | yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0); |
| 127470 | 127950 | spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 127471 | 127951 | } |
| 127472 | 127952 | break; |
| 127473 | | - case 198: /* expr ::= expr AND expr */ |
| 127474 | | - case 199: /* expr ::= expr OR expr */ yytestcase(yyruleno==199); |
| 127475 | | - case 200: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==200); |
| 127476 | | - case 201: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==201); |
| 127477 | | - case 202: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==202); |
| 127478 | | - case 203: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==203); |
| 127479 | | - case 204: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==204); |
| 127480 | | - case 205: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==205); |
| 127953 | + case 199: /* expr ::= expr AND expr */ |
| 127954 | + case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200); |
| 127955 | + case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201); |
| 127956 | + case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202); |
| 127957 | + case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203); |
| 127958 | + case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204); |
| 127959 | + case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205); |
| 127960 | + case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206); |
| 127481 | 127961 | {spanBinaryExpr(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);} |
| 127482 | 127962 | break; |
| 127483 | | - case 206: /* likeop ::= LIKE_KW|MATCH */ |
| 127963 | + case 207: /* likeop ::= LIKE_KW|MATCH */ |
| 127484 | 127964 | {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.bNot = 0;} |
| 127485 | 127965 | break; |
| 127486 | | - case 207: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 127966 | + case 208: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 127487 | 127967 | {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.bNot = 1;} |
| 127488 | 127968 | break; |
| 127489 | | - case 208: /* expr ::= expr likeop expr */ |
| 127969 | + case 209: /* expr ::= expr likeop expr */ |
| 127490 | 127970 | { |
| 127491 | 127971 | ExprList *pList; |
| 127492 | 127972 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy346.pExpr); |
| 127493 | 127973 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy346.pExpr); |
| 127494 | 127974 | yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy96.eOperator); |
| | @@ -127496,11 +127976,11 @@ |
| 127496 | 127976 | yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart; |
| 127497 | 127977 | yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd; |
| 127498 | 127978 | if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc; |
| 127499 | 127979 | } |
| 127500 | 127980 | break; |
| 127501 | | - case 209: /* expr ::= expr likeop expr ESCAPE expr */ |
| 127981 | + case 210: /* expr ::= expr likeop expr ESCAPE expr */ |
| 127502 | 127982 | { |
| 127503 | 127983 | ExprList *pList; |
| 127504 | 127984 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr); |
| 127505 | 127985 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy346.pExpr); |
| 127506 | 127986 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr); |
| | @@ -127509,39 +127989,39 @@ |
| 127509 | 127989 | yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart; |
| 127510 | 127990 | yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd; |
| 127511 | 127991 | if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc; |
| 127512 | 127992 | } |
| 127513 | 127993 | break; |
| 127514 | | - case 210: /* expr ::= expr ISNULL|NOTNULL */ |
| 127994 | + case 211: /* expr ::= expr ISNULL|NOTNULL */ |
| 127515 | 127995 | {spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);} |
| 127516 | 127996 | break; |
| 127517 | | - case 211: /* expr ::= expr NOT NULL */ |
| 127997 | + case 212: /* expr ::= expr NOT NULL */ |
| 127518 | 127998 | {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);} |
| 127519 | 127999 | break; |
| 127520 | | - case 212: /* expr ::= expr IS expr */ |
| 128000 | + case 213: /* expr ::= expr IS expr */ |
| 127521 | 128001 | { |
| 127522 | 128002 | spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346); |
| 127523 | 128003 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL); |
| 127524 | 128004 | } |
| 127525 | 128005 | break; |
| 127526 | | - case 213: /* expr ::= expr IS NOT expr */ |
| 128006 | + case 214: /* expr ::= expr IS NOT expr */ |
| 127527 | 128007 | { |
| 127528 | 128008 | spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346); |
| 127529 | 128009 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL); |
| 127530 | 128010 | } |
| 127531 | 128011 | break; |
| 127532 | | - case 214: /* expr ::= NOT expr */ |
| 127533 | | - case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215); |
| 128012 | + case 215: /* expr ::= NOT expr */ |
| 128013 | + case 216: /* expr ::= BITNOT expr */ yytestcase(yyruleno==216); |
| 127534 | 128014 | {spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);} |
| 127535 | 128015 | break; |
| 127536 | | - case 216: /* expr ::= MINUS expr */ |
| 128016 | + case 217: /* expr ::= MINUS expr */ |
| 127537 | 128017 | {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);} |
| 127538 | 128018 | break; |
| 127539 | | - case 217: /* expr ::= PLUS expr */ |
| 128019 | + case 218: /* expr ::= PLUS expr */ |
| 127540 | 128020 | {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);} |
| 127541 | 128021 | break; |
| 127542 | | - case 220: /* expr ::= expr between_op expr AND expr */ |
| 128022 | + case 221: /* expr ::= expr between_op expr AND expr */ |
| 127543 | 128023 | { |
| 127544 | 128024 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr); |
| 127545 | 128025 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr); |
| 127546 | 128026 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy346.pExpr, 0, 0); |
| 127547 | 128027 | if( yygotominor.yy346.pExpr ){ |
| | @@ -127552,11 +128032,11 @@ |
| 127552 | 128032 | if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0); |
| 127553 | 128033 | yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart; |
| 127554 | 128034 | yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd; |
| 127555 | 128035 | } |
| 127556 | 128036 | break; |
| 127557 | | - case 223: /* expr ::= expr in_op LP exprlist RP */ |
| 128037 | + case 224: /* expr ::= expr in_op LP exprlist RP */ |
| 127558 | 128038 | { |
| 127559 | 128039 | if( yymsp[-1].minor.yy14==0 ){ |
| 127560 | 128040 | /* Expressions of the form |
| 127561 | 128041 | ** |
| 127562 | 128042 | ** expr1 IN () |
| | @@ -127606,11 +128086,11 @@ |
| 127606 | 128086 | } |
| 127607 | 128087 | yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart; |
| 127608 | 128088 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127609 | 128089 | } |
| 127610 | 128090 | break; |
| 127611 | | - case 224: /* expr ::= LP select RP */ |
| 128091 | + case 225: /* expr ::= LP select RP */ |
| 127612 | 128092 | { |
| 127613 | 128093 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 127614 | 128094 | if( yygotominor.yy346.pExpr ){ |
| 127615 | 128095 | yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3; |
| 127616 | 128096 | ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect|EP_Subquery); |
| | @@ -127620,11 +128100,11 @@ |
| 127620 | 128100 | } |
| 127621 | 128101 | yygotominor.yy346.zStart = yymsp[-2].minor.yy0.z; |
| 127622 | 128102 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127623 | 128103 | } |
| 127624 | 128104 | break; |
| 127625 | | - case 225: /* expr ::= expr in_op LP select RP */ |
| 128105 | + case 226: /* expr ::= expr in_op LP select RP */ |
| 127626 | 128106 | { |
| 127627 | 128107 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0); |
| 127628 | 128108 | if( yygotominor.yy346.pExpr ){ |
| 127629 | 128109 | yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3; |
| 127630 | 128110 | ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect|EP_Subquery); |
| | @@ -127635,11 +128115,11 @@ |
| 127635 | 128115 | if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0); |
| 127636 | 128116 | yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart; |
| 127637 | 128117 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127638 | 128118 | } |
| 127639 | 128119 | break; |
| 127640 | | - case 226: /* expr ::= expr in_op nm dbnm */ |
| 128120 | + case 227: /* expr ::= expr in_op nm dbnm */ |
| 127641 | 128121 | { |
| 127642 | 128122 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 127643 | 128123 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0); |
| 127644 | 128124 | if( yygotominor.yy346.pExpr ){ |
| 127645 | 128125 | yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| | @@ -127651,11 +128131,11 @@ |
| 127651 | 128131 | if( yymsp[-2].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0); |
| 127652 | 128132 | yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart; |
| 127653 | 128133 | yygotominor.yy346.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]; |
| 127654 | 128134 | } |
| 127655 | 128135 | break; |
| 127656 | | - case 227: /* expr ::= EXISTS LP select RP */ |
| 128136 | + case 228: /* expr ::= EXISTS LP select RP */ |
| 127657 | 128137 | { |
| 127658 | 128138 | Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 127659 | 128139 | if( p ){ |
| 127660 | 128140 | p->x.pSelect = yymsp[-1].minor.yy3; |
| 127661 | 128141 | ExprSetProperty(p, EP_xIsSelect|EP_Subquery); |
| | @@ -127665,11 +128145,11 @@ |
| 127665 | 128145 | } |
| 127666 | 128146 | yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z; |
| 127667 | 128147 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127668 | 128148 | } |
| 127669 | 128149 | break; |
| 127670 | | - case 228: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 128150 | + case 229: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 127671 | 128151 | { |
| 127672 | 128152 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, 0, 0); |
| 127673 | 128153 | if( yygotominor.yy346.pExpr ){ |
| 127674 | 128154 | yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy132 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy132) : yymsp[-2].minor.yy14; |
| 127675 | 128155 | sqlite3ExprSetHeightAndFlags(pParse, yygotominor.yy346.pExpr); |
| | @@ -127679,274 +128159,263 @@ |
| 127679 | 128159 | } |
| 127680 | 128160 | yygotominor.yy346.zStart = yymsp[-4].minor.yy0.z; |
| 127681 | 128161 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127682 | 128162 | } |
| 127683 | 128163 | break; |
| 127684 | | - case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 128164 | + case 230: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 127685 | 128165 | { |
| 127686 | 128166 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy346.pExpr); |
| 127687 | 128167 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr); |
| 127688 | 128168 | } |
| 127689 | 128169 | break; |
| 127690 | | - case 230: /* case_exprlist ::= WHEN expr THEN expr */ |
| 128170 | + case 231: /* case_exprlist ::= WHEN expr THEN expr */ |
| 127691 | 128171 | { |
| 127692 | 128172 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr); |
| 127693 | 128173 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr); |
| 127694 | 128174 | } |
| 127695 | 128175 | break; |
| 127696 | | - case 237: /* nexprlist ::= nexprlist COMMA expr */ |
| 128176 | + case 238: /* nexprlist ::= nexprlist COMMA expr */ |
| 127697 | 128177 | {yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy346.pExpr);} |
| 127698 | 128178 | break; |
| 127699 | | - case 238: /* nexprlist ::= expr */ |
| 128179 | + case 239: /* nexprlist ::= expr */ |
| 127700 | 128180 | {yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);} |
| 127701 | 128181 | break; |
| 127702 | | - case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */ |
| 128182 | + case 240: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 127703 | 128183 | { |
| 127704 | 128184 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 127705 | 128185 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy14, yymsp[-10].minor.yy328, |
| 127706 | 128186 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy132, SQLITE_SO_ASC, yymsp[-8].minor.yy328); |
| 127707 | 128187 | } |
| 127708 | 128188 | break; |
| 127709 | | - case 240: /* uniqueflag ::= UNIQUE */ |
| 127710 | | - case 291: /* raisetype ::= ABORT */ yytestcase(yyruleno==291); |
| 128189 | + case 241: /* uniqueflag ::= UNIQUE */ |
| 128190 | + case 292: /* raisetype ::= ABORT */ yytestcase(yyruleno==292); |
| 127711 | 128191 | {yygotominor.yy328 = OE_Abort;} |
| 127712 | 128192 | break; |
| 127713 | | - case 241: /* uniqueflag ::= */ |
| 128193 | + case 242: /* uniqueflag ::= */ |
| 127714 | 128194 | {yygotominor.yy328 = OE_None;} |
| 127715 | 128195 | break; |
| 127716 | | - case 244: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 127717 | | -{ |
| 127718 | | - Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1); |
| 127719 | | - yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p); |
| 127720 | | - sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1); |
| 127721 | | - sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index"); |
| 127722 | | - if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 127723 | | -} |
| 127724 | | - break; |
| 127725 | | - case 245: /* idxlist ::= nm collate sortorder */ |
| 127726 | | -{ |
| 127727 | | - Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1); |
| 127728 | | - yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p); |
| 127729 | | - sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1); |
| 127730 | | - sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index"); |
| 127731 | | - if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 127732 | | -} |
| 127733 | | - break; |
| 127734 | | - case 246: /* collate ::= */ |
| 127735 | | -{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;} |
| 127736 | | - break; |
| 127737 | | - case 248: /* cmd ::= DROP INDEX ifexists fullname */ |
| 128196 | + case 245: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 128197 | +{ |
| 128198 | + yygotominor.yy14 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy328, yymsp[0].minor.yy328); |
| 128199 | +} |
| 128200 | + break; |
| 128201 | + case 246: /* eidlist ::= nm collate sortorder */ |
| 128202 | +{ |
| 128203 | + yygotominor.yy14 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy328, yymsp[0].minor.yy328); |
| 128204 | +} |
| 128205 | + break; |
| 128206 | + case 249: /* cmd ::= DROP INDEX ifexists fullname */ |
| 127738 | 128207 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);} |
| 127739 | 128208 | break; |
| 127740 | | - case 249: /* cmd ::= VACUUM */ |
| 127741 | | - case 250: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==250); |
| 128209 | + case 250: /* cmd ::= VACUUM */ |
| 128210 | + case 251: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==251); |
| 127742 | 128211 | {sqlite3Vacuum(pParse);} |
| 127743 | 128212 | break; |
| 127744 | | - case 251: /* cmd ::= PRAGMA nm dbnm */ |
| 128213 | + case 252: /* cmd ::= PRAGMA nm dbnm */ |
| 127745 | 128214 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 127746 | 128215 | break; |
| 127747 | | - case 252: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 128216 | + case 253: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 127748 | 128217 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 127749 | 128218 | break; |
| 127750 | | - case 253: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 128219 | + case 254: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 127751 | 128220 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 127752 | 128221 | break; |
| 127753 | | - case 254: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 128222 | + case 255: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 127754 | 128223 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 127755 | 128224 | break; |
| 127756 | | - case 255: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 128225 | + case 256: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 127757 | 128226 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 127758 | 128227 | break; |
| 127759 | | - case 264: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 128228 | + case 265: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 127760 | 128229 | { |
| 127761 | 128230 | Token all; |
| 127762 | 128231 | all.z = yymsp[-3].minor.yy0.z; |
| 127763 | 128232 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 127764 | 128233 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all); |
| 127765 | 128234 | } |
| 127766 | 128235 | break; |
| 127767 | | - case 265: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 128236 | + case 266: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 127768 | 128237 | { |
| 127769 | 128238 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy328, yymsp[-4].minor.yy378.a, yymsp[-4].minor.yy378.b, yymsp[-2].minor.yy65, yymsp[0].minor.yy132, yymsp[-10].minor.yy328, yymsp[-8].minor.yy328); |
| 127770 | 128239 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 127771 | 128240 | } |
| 127772 | 128241 | break; |
| 127773 | | - case 266: /* trigger_time ::= BEFORE */ |
| 127774 | | - case 269: /* trigger_time ::= */ yytestcase(yyruleno==269); |
| 128242 | + case 267: /* trigger_time ::= BEFORE */ |
| 128243 | + case 270: /* trigger_time ::= */ yytestcase(yyruleno==270); |
| 127775 | 128244 | { yygotominor.yy328 = TK_BEFORE; } |
| 127776 | 128245 | break; |
| 127777 | | - case 267: /* trigger_time ::= AFTER */ |
| 128246 | + case 268: /* trigger_time ::= AFTER */ |
| 127778 | 128247 | { yygotominor.yy328 = TK_AFTER; } |
| 127779 | 128248 | break; |
| 127780 | | - case 268: /* trigger_time ::= INSTEAD OF */ |
| 128249 | + case 269: /* trigger_time ::= INSTEAD OF */ |
| 127781 | 128250 | { yygotominor.yy328 = TK_INSTEAD;} |
| 127782 | 128251 | break; |
| 127783 | | - case 270: /* trigger_event ::= DELETE|INSERT */ |
| 127784 | | - case 271: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==271); |
| 128252 | + case 271: /* trigger_event ::= DELETE|INSERT */ |
| 128253 | + case 272: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==272); |
| 127785 | 128254 | {yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;} |
| 127786 | 128255 | break; |
| 127787 | | - case 272: /* trigger_event ::= UPDATE OF idlist */ |
| 128256 | + case 273: /* trigger_event ::= UPDATE OF idlist */ |
| 127788 | 128257 | {yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;} |
| 127789 | 128258 | break; |
| 127790 | | - case 275: /* when_clause ::= */ |
| 127791 | | - case 296: /* key_opt ::= */ yytestcase(yyruleno==296); |
| 128259 | + case 276: /* when_clause ::= */ |
| 128260 | + case 297: /* key_opt ::= */ yytestcase(yyruleno==297); |
| 127792 | 128261 | { yygotominor.yy132 = 0; } |
| 127793 | 128262 | break; |
| 127794 | | - case 276: /* when_clause ::= WHEN expr */ |
| 127795 | | - case 297: /* key_opt ::= KEY expr */ yytestcase(yyruleno==297); |
| 128263 | + case 277: /* when_clause ::= WHEN expr */ |
| 128264 | + case 298: /* key_opt ::= KEY expr */ yytestcase(yyruleno==298); |
| 127796 | 128265 | { yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; } |
| 127797 | 128266 | break; |
| 127798 | | - case 277: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 128267 | + case 278: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 127799 | 128268 | { |
| 127800 | 128269 | assert( yymsp[-2].minor.yy473!=0 ); |
| 127801 | 128270 | yymsp[-2].minor.yy473->pLast->pNext = yymsp[-1].minor.yy473; |
| 127802 | 128271 | yymsp[-2].minor.yy473->pLast = yymsp[-1].minor.yy473; |
| 127803 | 128272 | yygotominor.yy473 = yymsp[-2].minor.yy473; |
| 127804 | 128273 | } |
| 127805 | 128274 | break; |
| 127806 | | - case 278: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 128275 | + case 279: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 127807 | 128276 | { |
| 127808 | 128277 | assert( yymsp[-1].minor.yy473!=0 ); |
| 127809 | 128278 | yymsp[-1].minor.yy473->pLast = yymsp[-1].minor.yy473; |
| 127810 | 128279 | yygotominor.yy473 = yymsp[-1].minor.yy473; |
| 127811 | 128280 | } |
| 127812 | 128281 | break; |
| 127813 | | - case 280: /* trnm ::= nm DOT nm */ |
| 128282 | + case 281: /* trnm ::= nm DOT nm */ |
| 127814 | 128283 | { |
| 127815 | 128284 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 127816 | 128285 | sqlite3ErrorMsg(pParse, |
| 127817 | 128286 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 127818 | 128287 | "statements within triggers"); |
| 127819 | 128288 | } |
| 127820 | 128289 | break; |
| 127821 | | - case 282: /* tridxby ::= INDEXED BY nm */ |
| 128290 | + case 283: /* tridxby ::= INDEXED BY nm */ |
| 127822 | 128291 | { |
| 127823 | 128292 | sqlite3ErrorMsg(pParse, |
| 127824 | 128293 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 127825 | 128294 | "within triggers"); |
| 127826 | 128295 | } |
| 127827 | 128296 | break; |
| 127828 | | - case 283: /* tridxby ::= NOT INDEXED */ |
| 128297 | + case 284: /* tridxby ::= NOT INDEXED */ |
| 127829 | 128298 | { |
| 127830 | 128299 | sqlite3ErrorMsg(pParse, |
| 127831 | 128300 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 127832 | 128301 | "within triggers"); |
| 127833 | 128302 | } |
| 127834 | 128303 | break; |
| 127835 | | - case 284: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 128304 | + case 285: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 127836 | 128305 | { yygotominor.yy473 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy14, yymsp[0].minor.yy132, yymsp[-5].minor.yy186); } |
| 127837 | 128306 | break; |
| 127838 | | - case 285: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 128307 | + case 286: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */ |
| 127839 | 128308 | {yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy408, yymsp[0].minor.yy3, yymsp[-4].minor.yy186);} |
| 127840 | 128309 | break; |
| 127841 | | - case 286: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 128310 | + case 287: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 127842 | 128311 | {yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);} |
| 127843 | 128312 | break; |
| 127844 | | - case 287: /* trigger_cmd ::= select */ |
| 128313 | + case 288: /* trigger_cmd ::= select */ |
| 127845 | 128314 | {yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); } |
| 127846 | 128315 | break; |
| 127847 | | - case 288: /* expr ::= RAISE LP IGNORE RP */ |
| 128316 | + case 289: /* expr ::= RAISE LP IGNORE RP */ |
| 127848 | 128317 | { |
| 127849 | 128318 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 127850 | 128319 | if( yygotominor.yy346.pExpr ){ |
| 127851 | 128320 | yygotominor.yy346.pExpr->affinity = OE_Ignore; |
| 127852 | 128321 | } |
| 127853 | 128322 | yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z; |
| 127854 | 128323 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127855 | 128324 | } |
| 127856 | 128325 | break; |
| 127857 | | - case 289: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 128326 | + case 290: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 127858 | 128327 | { |
| 127859 | 128328 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 127860 | 128329 | if( yygotominor.yy346.pExpr ) { |
| 127861 | 128330 | yygotominor.yy346.pExpr->affinity = (char)yymsp[-3].minor.yy328; |
| 127862 | 128331 | } |
| 127863 | 128332 | yygotominor.yy346.zStart = yymsp[-5].minor.yy0.z; |
| 127864 | 128333 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 127865 | 128334 | } |
| 127866 | 128335 | break; |
| 127867 | | - case 290: /* raisetype ::= ROLLBACK */ |
| 128336 | + case 291: /* raisetype ::= ROLLBACK */ |
| 127868 | 128337 | {yygotominor.yy328 = OE_Rollback;} |
| 127869 | 128338 | break; |
| 127870 | | - case 292: /* raisetype ::= FAIL */ |
| 128339 | + case 293: /* raisetype ::= FAIL */ |
| 127871 | 128340 | {yygotominor.yy328 = OE_Fail;} |
| 127872 | 128341 | break; |
| 127873 | | - case 293: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 128342 | + case 294: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 127874 | 128343 | { |
| 127875 | 128344 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328); |
| 127876 | 128345 | } |
| 127877 | 128346 | break; |
| 127878 | | - case 294: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 128347 | + case 295: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 127879 | 128348 | { |
| 127880 | 128349 | sqlite3Attach(pParse, yymsp[-3].minor.yy346.pExpr, yymsp[-1].minor.yy346.pExpr, yymsp[0].minor.yy132); |
| 127881 | 128350 | } |
| 127882 | 128351 | break; |
| 127883 | | - case 295: /* cmd ::= DETACH database_kw_opt expr */ |
| 128352 | + case 296: /* cmd ::= DETACH database_kw_opt expr */ |
| 127884 | 128353 | { |
| 127885 | 128354 | sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr); |
| 127886 | 128355 | } |
| 127887 | 128356 | break; |
| 127888 | | - case 300: /* cmd ::= REINDEX */ |
| 128357 | + case 301: /* cmd ::= REINDEX */ |
| 127889 | 128358 | {sqlite3Reindex(pParse, 0, 0);} |
| 127890 | 128359 | break; |
| 127891 | | - case 301: /* cmd ::= REINDEX nm dbnm */ |
| 128360 | + case 302: /* cmd ::= REINDEX nm dbnm */ |
| 127892 | 128361 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 127893 | 128362 | break; |
| 127894 | | - case 302: /* cmd ::= ANALYZE */ |
| 128363 | + case 303: /* cmd ::= ANALYZE */ |
| 127895 | 128364 | {sqlite3Analyze(pParse, 0, 0);} |
| 127896 | 128365 | break; |
| 127897 | | - case 303: /* cmd ::= ANALYZE nm dbnm */ |
| 128366 | + case 304: /* cmd ::= ANALYZE nm dbnm */ |
| 127898 | 128367 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 127899 | 128368 | break; |
| 127900 | | - case 304: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 128369 | + case 305: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 127901 | 128370 | { |
| 127902 | 128371 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0); |
| 127903 | 128372 | } |
| 127904 | 128373 | break; |
| 127905 | | - case 305: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 128374 | + case 306: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 127906 | 128375 | { |
| 127907 | 128376 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 127908 | 128377 | } |
| 127909 | 128378 | break; |
| 127910 | | - case 306: /* add_column_fullname ::= fullname */ |
| 128379 | + case 307: /* add_column_fullname ::= fullname */ |
| 127911 | 128380 | { |
| 127912 | 128381 | pParse->db->lookaside.bEnabled = 0; |
| 127913 | 128382 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65); |
| 127914 | 128383 | } |
| 127915 | 128384 | break; |
| 127916 | | - case 309: /* cmd ::= create_vtab */ |
| 128385 | + case 310: /* cmd ::= create_vtab */ |
| 127917 | 128386 | {sqlite3VtabFinishParse(pParse,0);} |
| 127918 | 128387 | break; |
| 127919 | | - case 310: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 128388 | + case 311: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 127920 | 128389 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 127921 | 128390 | break; |
| 127922 | | - case 311: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 128391 | + case 312: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 127923 | 128392 | { |
| 127924 | 128393 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy328); |
| 127925 | 128394 | } |
| 127926 | 128395 | break; |
| 127927 | | - case 314: /* vtabarg ::= */ |
| 128396 | + case 315: /* vtabarg ::= */ |
| 127928 | 128397 | {sqlite3VtabArgInit(pParse);} |
| 127929 | 128398 | break; |
| 127930 | | - case 316: /* vtabargtoken ::= ANY */ |
| 127931 | | - case 317: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==317); |
| 127932 | | - case 318: /* lp ::= LP */ yytestcase(yyruleno==318); |
| 128399 | + case 317: /* vtabargtoken ::= ANY */ |
| 128400 | + case 318: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==318); |
| 128401 | + case 319: /* lp ::= LP */ yytestcase(yyruleno==319); |
| 127933 | 128402 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 127934 | 128403 | break; |
| 127935 | | - case 322: /* with ::= */ |
| 128404 | + case 323: /* with ::= */ |
| 127936 | 128405 | {yygotominor.yy59 = 0;} |
| 127937 | 128406 | break; |
| 127938 | | - case 323: /* with ::= WITH wqlist */ |
| 127939 | | - case 324: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==324); |
| 128407 | + case 324: /* with ::= WITH wqlist */ |
| 128408 | + case 325: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==325); |
| 127940 | 128409 | { yygotominor.yy59 = yymsp[0].minor.yy59; } |
| 127941 | 128410 | break; |
| 127942 | | - case 325: /* wqlist ::= nm idxlist_opt AS LP select RP */ |
| 128411 | + case 326: /* wqlist ::= nm eidlist_opt AS LP select RP */ |
| 127943 | 128412 | { |
| 127944 | 128413 | yygotominor.yy59 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy3); |
| 127945 | 128414 | } |
| 127946 | 128415 | break; |
| 127947 | | - case 326: /* wqlist ::= wqlist COMMA nm idxlist_opt AS LP select RP */ |
| 128416 | + case 327: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ |
| 127948 | 128417 | { |
| 127949 | 128418 | yygotominor.yy59 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy59, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy3); |
| 127950 | 128419 | } |
| 127951 | 128420 | break; |
| 127952 | 128421 | default: |
| | @@ -127970,49 +128439,48 @@ |
| 127970 | 128439 | /* (53) carglist ::= */ yytestcase(yyruleno==53); |
| 127971 | 128440 | /* (60) ccons ::= NULL onconf */ yytestcase(yyruleno==60); |
| 127972 | 128441 | /* (88) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==88); |
| 127973 | 128442 | /* (89) conslist ::= tcons */ yytestcase(yyruleno==89); |
| 127974 | 128443 | /* (91) tconscomma ::= */ yytestcase(yyruleno==91); |
| 127975 | | - /* (273) foreach_clause ::= */ yytestcase(yyruleno==273); |
| 127976 | | - /* (274) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==274); |
| 127977 | | - /* (281) tridxby ::= */ yytestcase(yyruleno==281); |
| 127978 | | - /* (298) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==298); |
| 127979 | | - /* (299) database_kw_opt ::= */ yytestcase(yyruleno==299); |
| 127980 | | - /* (307) kwcolumn_opt ::= */ yytestcase(yyruleno==307); |
| 127981 | | - /* (308) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==308); |
| 127982 | | - /* (312) vtabarglist ::= vtabarg */ yytestcase(yyruleno==312); |
| 127983 | | - /* (313) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==313); |
| 127984 | | - /* (315) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==315); |
| 127985 | | - /* (319) anylist ::= */ yytestcase(yyruleno==319); |
| 127986 | | - /* (320) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==320); |
| 127987 | | - /* (321) anylist ::= anylist ANY */ yytestcase(yyruleno==321); |
| 128444 | + /* (274) foreach_clause ::= */ yytestcase(yyruleno==274); |
| 128445 | + /* (275) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==275); |
| 128446 | + /* (282) tridxby ::= */ yytestcase(yyruleno==282); |
| 128447 | + /* (299) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==299); |
| 128448 | + /* (300) database_kw_opt ::= */ yytestcase(yyruleno==300); |
| 128449 | + /* (308) kwcolumn_opt ::= */ yytestcase(yyruleno==308); |
| 128450 | + /* (309) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==309); |
| 128451 | + /* (313) vtabarglist ::= vtabarg */ yytestcase(yyruleno==313); |
| 128452 | + /* (314) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==314); |
| 128453 | + /* (316) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==316); |
| 128454 | + /* (320) anylist ::= */ yytestcase(yyruleno==320); |
| 128455 | + /* (321) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==321); |
| 128456 | + /* (322) anylist ::= anylist ANY */ yytestcase(yyruleno==322); |
| 127988 | 128457 | break; |
| 127989 | 128458 | }; |
| 127990 | 128459 | assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); |
| 127991 | 128460 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 127992 | 128461 | yysize = yyRuleInfo[yyruleno].nrhs; |
| 127993 | 128462 | yypParser->yyidx -= yysize; |
| 127994 | 128463 | yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); |
| 127995 | | - if( yyact < YYNSTATE ){ |
| 127996 | | -#ifdef NDEBUG |
| 127997 | | - /* If we are not debugging and the reduce action popped at least |
| 128464 | + if( yyact <= YY_MAX_SHIFTREDUCE ){ |
| 128465 | + if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 128466 | + /* If the reduce action popped at least |
| 127998 | 128467 | ** one element off the stack, then we can push the new element back |
| 127999 | 128468 | ** onto the stack here, and skip the stack overflow test in yy_shift(). |
| 128000 | 128469 | ** That gives a significant speed improvement. */ |
| 128001 | 128470 | if( yysize ){ |
| 128002 | 128471 | yypParser->yyidx++; |
| 128003 | 128472 | yymsp -= yysize-1; |
| 128004 | 128473 | yymsp->stateno = (YYACTIONTYPE)yyact; |
| 128005 | 128474 | yymsp->major = (YYCODETYPE)yygoto; |
| 128006 | 128475 | yymsp->minor = yygotominor; |
| 128007 | | - }else |
| 128008 | | -#endif |
| 128009 | | - { |
| 128476 | + yyTraceShift(yypParser, yyact); |
| 128477 | + }else{ |
| 128010 | 128478 | yy_shift(yypParser,yyact,yygoto,&yygotominor); |
| 128011 | 128479 | } |
| 128012 | 128480 | }else{ |
| 128013 | | - assert( yyact == YYNSTATE + YYNRULE + 1 ); |
| 128481 | + assert( yyact == YY_ACCEPT_ACTION ); |
| 128014 | 128482 | yy_accept(yypParser); |
| 128015 | 128483 | } |
| 128016 | 128484 | } |
| 128017 | 128485 | |
| 128018 | 128486 | /* |
| | @@ -128133,16 +128601,17 @@ |
| 128133 | 128601 | } |
| 128134 | 128602 | #endif |
| 128135 | 128603 | |
| 128136 | 128604 | do{ |
| 128137 | 128605 | yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); |
| 128138 | | - if( yyact<YYNSTATE ){ |
| 128606 | + if( yyact <= YY_MAX_SHIFTREDUCE ){ |
| 128607 | + if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 128139 | 128608 | yy_shift(yypParser,yyact,yymajor,&yyminorunion); |
| 128140 | 128609 | yypParser->yyerrcnt--; |
| 128141 | 128610 | yymajor = YYNOCODE; |
| 128142 | | - }else if( yyact < YYNSTATE + YYNRULE ){ |
| 128143 | | - yy_reduce(yypParser,yyact-YYNSTATE); |
| 128611 | + }else if( yyact <= YY_MAX_REDUCE ){ |
| 128612 | + yy_reduce(yypParser,yyact-YY_MIN_REDUCE); |
| 128144 | 128613 | }else{ |
| 128145 | 128614 | assert( yyact == YY_ERROR_ACTION ); |
| 128146 | 128615 | #ifdef YYERRORSYMBOL |
| 128147 | 128616 | int yymx; |
| 128148 | 128617 | #endif |
| | @@ -128188,11 +128657,11 @@ |
| 128188 | 128657 | while( |
| 128189 | 128658 | yypParser->yyidx >= 0 && |
| 128190 | 128659 | yymx != YYERRORSYMBOL && |
| 128191 | 128660 | (yyact = yy_find_reduce_action( |
| 128192 | 128661 | yypParser->yystack[yypParser->yyidx].stateno, |
| 128193 | | - YYERRORSYMBOL)) >= YYNSTATE |
| 128662 | + YYERRORSYMBOL)) >= YY_MIN_REDUCE |
| 128194 | 128663 | ){ |
| 128195 | 128664 | yy_pop_parser_stack(yypParser); |
| 128196 | 128665 | } |
| 128197 | 128666 | if( yypParser->yyidx < 0 || yymajor==0 ){ |
| 128198 | 128667 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| | @@ -128238,10 +128707,15 @@ |
| 128238 | 128707 | } |
| 128239 | 128708 | yymajor = YYNOCODE; |
| 128240 | 128709 | #endif |
| 128241 | 128710 | } |
| 128242 | 128711 | }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
| 128712 | +#ifndef NDEBUG |
| 128713 | + if( yyTraceFILE ){ |
| 128714 | + fprintf(yyTraceFILE,"%sReturn\n",yyTracePrompt); |
| 128715 | + } |
| 128716 | +#endif |
| 128243 | 128717 | return; |
| 128244 | 128718 | } |
| 128245 | 128719 | |
| 128246 | 128720 | /************** End of parse.c ***********************************************/ |
| 128247 | 128721 | /************** Begin file tokenize.c ****************************************/ |
| | @@ -128926,10 +129400,11 @@ |
| 128926 | 129400 | } |
| 128927 | 129401 | pParse->rc = SQLITE_OK; |
| 128928 | 129402 | pParse->zTail = zSql; |
| 128929 | 129403 | i = 0; |
| 128930 | 129404 | assert( pzErrMsg!=0 ); |
| 129405 | + /* sqlite3ParserTrace(stdout, "parser: "); */ |
| 128931 | 129406 | pEngine = sqlite3ParserAlloc(sqlite3Malloc); |
| 128932 | 129407 | if( pEngine==0 ){ |
| 128933 | 129408 | db->mallocFailed = 1; |
| 128934 | 129409 | return SQLITE_NOMEM; |
| 128935 | 129410 | } |
| | @@ -130370,20 +130845,26 @@ |
| 130370 | 130845 | ** db. This is called when db is being closed. |
| 130371 | 130846 | */ |
| 130372 | 130847 | static void disconnectAllVtab(sqlite3 *db){ |
| 130373 | 130848 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 130374 | 130849 | int i; |
| 130850 | + HashElem *p; |
| 130375 | 130851 | sqlite3BtreeEnterAll(db); |
| 130376 | 130852 | for(i=0; i<db->nDb; i++){ |
| 130377 | 130853 | Schema *pSchema = db->aDb[i].pSchema; |
| 130378 | 130854 | if( db->aDb[i].pSchema ){ |
| 130379 | | - HashElem *p; |
| 130380 | 130855 | for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){ |
| 130381 | 130856 | Table *pTab = (Table *)sqliteHashData(p); |
| 130382 | 130857 | if( IsVirtual(pTab) ) sqlite3VtabDisconnect(db, pTab); |
| 130383 | 130858 | } |
| 130384 | 130859 | } |
| 130860 | + } |
| 130861 | + for(p=sqliteHashFirst(&db->aModule); p; p=sqliteHashNext(p)){ |
| 130862 | + Module *pMod = (Module *)sqliteHashData(p); |
| 130863 | + if( pMod->pEpoTab ){ |
| 130864 | + sqlite3VtabDisconnect(db, pMod->pEpoTab); |
| 130865 | + } |
| 130385 | 130866 | } |
| 130386 | 130867 | sqlite3VtabUnlockList(db); |
| 130387 | 130868 | sqlite3BtreeLeaveAll(db); |
| 130388 | 130869 | #else |
| 130389 | 130870 | UNUSED_PARAMETER(db); |
| | @@ -130558,10 +131039,11 @@ |
| 130558 | 131039 | for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){ |
| 130559 | 131040 | Module *pMod = (Module *)sqliteHashData(i); |
| 130560 | 131041 | if( pMod->xDestroy ){ |
| 130561 | 131042 | pMod->xDestroy(pMod->pAux); |
| 130562 | 131043 | } |
| 131044 | + sqlite3VtabEponymousTableClear(db, pMod); |
| 130563 | 131045 | sqlite3DbFree(db, pMod); |
| 130564 | 131046 | } |
| 130565 | 131047 | sqlite3HashClear(&db->aModule); |
| 130566 | 131048 | #endif |
| 130567 | 131049 | |
| | @@ -156962,14 +157444,10 @@ |
| 156962 | 157444 | |
| 156963 | 157445 | /* #include <assert.h> */ |
| 156964 | 157446 | /* #include <string.h> */ |
| 156965 | 157447 | /* #include <stdio.h> */ |
| 156966 | 157448 | |
| 156967 | | -#if !defined(_WIN32) |
| 156968 | | -/* # include <unistd.h> */ |
| 156969 | | -#endif |
| 156970 | | - |
| 156971 | 157449 | /* #include "sqlite3.h" */ |
| 156972 | 157450 | |
| 156973 | 157451 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_RBU) |
| 156974 | 157452 | /************** Include sqlite3rbu.h in the middle of sqlite3rbu.c ***********/ |
| 156975 | 157453 | /************** Begin file sqlite3rbu.h **************************************/ |
| | @@ -157070,10 +157548,22 @@ |
| 157070 | 157548 | ** |
| 157071 | 157549 | ** CREATE TABLE data_t1(a INTEGER, b TEXT, c, rbu_control); |
| 157072 | 157550 | ** |
| 157073 | 157551 | ** The order of the columns in the data_% table does not matter. |
| 157074 | 157552 | ** |
| 157553 | +** Instead of a regular table, the RBU database may also contain virtual |
| 157554 | +** tables or view named using the data_<target> naming scheme. |
| 157555 | +** |
| 157556 | +** Instead of the plain data_<target> naming scheme, RBU database tables |
| 157557 | +** may also be named data<integer>_<target>, where <integer> is any sequence |
| 157558 | +** of zero or more numeric characters (0-9). This can be significant because |
| 157559 | +** tables within the RBU database are always processed in order sorted by |
| 157560 | +** name. By judicious selection of the the <integer> portion of the names |
| 157561 | +** of the RBU tables the user can therefore control the order in which they |
| 157562 | +** are processed. This can be useful, for example, to ensure that "external |
| 157563 | +** content" FTS4 tables are updated before their underlying content tables. |
| 157564 | +** |
| 157075 | 157565 | ** If the target database table is a virtual table or a table that has no |
| 157076 | 157566 | ** PRIMARY KEY declaration, the data_% table must also contain a column |
| 157077 | 157567 | ** named "rbu_rowid". This column is mapped to the tables implicit primary |
| 157078 | 157568 | ** key column - "rowid". Virtual tables for which the "rowid" column does |
| 157079 | 157569 | ** not function like a primary key value cannot be updated using RBU. For |
| | @@ -157149,10 +157639,18 @@ |
| 157149 | 157639 | ** INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..d'); |
| 157150 | 157640 | ** |
| 157151 | 157641 | ** is similar to an UPDATE statement such as: |
| 157152 | 157642 | ** |
| 157153 | 157643 | ** UPDATE t1 SET c = rbu_delta(c, 'usa') WHERE a = 4; |
| 157644 | +** |
| 157645 | +** Finally, if an 'f' character appears in place of a 'd' or 's' in an |
| 157646 | +** ota_control string, the contents of the data_xxx table column is assumed |
| 157647 | +** to be a "fossil delta" - a patch to be applied to a blob value in the |
| 157648 | +** format used by the fossil source-code management system. In this case |
| 157649 | +** the existing value within the target database table must be of type BLOB. |
| 157650 | +** It is replaced by the result of applying the specified fossil delta to |
| 157651 | +** itself. |
| 157154 | 157652 | ** |
| 157155 | 157653 | ** If the target database table is a virtual table or a table with no PRIMARY |
| 157156 | 157654 | ** KEY, the rbu_control value should not include a character corresponding |
| 157157 | 157655 | ** to the rbu_rowid value. For example, this: |
| 157158 | 157656 | ** |
| | @@ -157307,10 +157805,22 @@ |
| 157307 | 157805 | ** SQLITE_OK, all subsequent calls on the same RBU handle are no-ops |
| 157308 | 157806 | ** that immediately return the same value. |
| 157309 | 157807 | */ |
| 157310 | 157808 | SQLITE_API int SQLITE_STDCALL sqlite3rbu_step(sqlite3rbu *pRbu); |
| 157311 | 157809 | |
| 157810 | +/* |
| 157811 | +** Force RBU to save its state to disk. |
| 157812 | +** |
| 157813 | +** If a power failure or application crash occurs during an update, following |
| 157814 | +** system recovery RBU may resume the update from the point at which the state |
| 157815 | +** was last saved. In other words, from the most recent successful call to |
| 157816 | +** sqlite3rbu_close() or this function. |
| 157817 | +** |
| 157818 | +** SQLITE_OK is returned if successful, or an SQLite error code otherwise. |
| 157819 | +*/ |
| 157820 | +SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *pRbu); |
| 157821 | + |
| 157312 | 157822 | /* |
| 157313 | 157823 | ** Close an RBU handle. |
| 157314 | 157824 | ** |
| 157315 | 157825 | ** If the RBU update has been completely applied, mark the RBU database |
| 157316 | 157826 | ** as fully applied. Otherwise, assuming no error has occurred, save the |
| | @@ -157539,10 +158049,11 @@ |
| 157539 | 158049 | int eType; /* Table type - an RBU_PK_XXX value */ |
| 157540 | 158050 | |
| 157541 | 158051 | /* Output variables. zTbl==0 implies EOF. */ |
| 157542 | 158052 | int bCleanup; /* True in "cleanup" state */ |
| 157543 | 158053 | const char *zTbl; /* Name of target db table */ |
| 158054 | + const char *zDataTbl; /* Name of rbu db table (or null) */ |
| 157544 | 158055 | const char *zIdx; /* Name of target db index (or null) */ |
| 157545 | 158056 | int iTnum; /* Root page of current object */ |
| 157546 | 158057 | int iPkTnum; /* If eType==EXTERNAL, root of PK index */ |
| 157547 | 158058 | int bUnique; /* Current index is unique */ |
| 157548 | 158059 | |
| | @@ -157549,11 +158060,11 @@ |
| 157549 | 158060 | /* Statements created by rbuObjIterPrepareAll() */ |
| 157550 | 158061 | int nCol; /* Number of columns in current object */ |
| 157551 | 158062 | sqlite3_stmt *pSelect; /* Source data */ |
| 157552 | 158063 | sqlite3_stmt *pInsert; /* Statement for INSERT operations */ |
| 157553 | 158064 | sqlite3_stmt *pDelete; /* Statement for DELETE ops */ |
| 157554 | | - sqlite3_stmt *pTmpInsert; /* Insert into rbu_tmp_$zTbl */ |
| 158065 | + sqlite3_stmt *pTmpInsert; /* Insert into rbu_tmp_$zDataTbl */ |
| 157555 | 158066 | |
| 157556 | 158067 | /* Last UPDATE used (for PK b-tree updates only), or NULL. */ |
| 157557 | 158068 | RbuUpdateStmt *pRbuUpdate; |
| 157558 | 158069 | }; |
| 157559 | 158070 | |
| | @@ -157659,10 +158170,256 @@ |
| 157659 | 158170 | const char *zWal; /* Wal filename for this main db file */ |
| 157660 | 158171 | rbu_file *pWalFd; /* Wal file descriptor for this main db */ |
| 157661 | 158172 | rbu_file *pMainNext; /* Next MAIN_DB file */ |
| 157662 | 158173 | }; |
| 157663 | 158174 | |
| 158175 | + |
| 158176 | +/************************************************************************* |
| 158177 | +** The following three functions, found below: |
| 158178 | +** |
| 158179 | +** rbuDeltaGetInt() |
| 158180 | +** rbuDeltaChecksum() |
| 158181 | +** rbuDeltaApply() |
| 158182 | +** |
| 158183 | +** are lifted from the fossil source code (http://fossil-scm.org). They |
| 158184 | +** are used to implement the scalar SQL function rbu_fossil_delta(). |
| 158185 | +*/ |
| 158186 | + |
| 158187 | +/* |
| 158188 | +** Read bytes from *pz and convert them into a positive integer. When |
| 158189 | +** finished, leave *pz pointing to the first character past the end of |
| 158190 | +** the integer. The *pLen parameter holds the length of the string |
| 158191 | +** in *pz and is decremented once for each character in the integer. |
| 158192 | +*/ |
| 158193 | +static unsigned int rbuDeltaGetInt(const char **pz, int *pLen){ |
| 158194 | + static const signed char zValue[] = { |
| 158195 | + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 158196 | + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 158197 | + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 158198 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, |
| 158199 | + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
| 158200 | + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, 36, |
| 158201 | + -1, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158202 | + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, -1, -1, -1, 63, -1, |
| 158203 | + }; |
| 158204 | + unsigned int v = 0; |
| 158205 | + int c; |
| 158206 | + unsigned char *z = (unsigned char*)*pz; |
| 158207 | + unsigned char *zStart = z; |
| 158208 | + while( (c = zValue[0x7f&*(z++)])>=0 ){ |
| 158209 | + v = (v<<6) + c; |
| 158210 | + } |
| 158211 | + z--; |
| 158212 | + *pLen -= z - zStart; |
| 158213 | + *pz = (char*)z; |
| 158214 | + return v; |
| 158215 | +} |
| 158216 | + |
| 158217 | +/* |
| 158218 | +** Compute a 32-bit checksum on the N-byte buffer. Return the result. |
| 158219 | +*/ |
| 158220 | +static unsigned int rbuDeltaChecksum(const char *zIn, size_t N){ |
| 158221 | + const unsigned char *z = (const unsigned char *)zIn; |
| 158222 | + unsigned sum0 = 0; |
| 158223 | + unsigned sum1 = 0; |
| 158224 | + unsigned sum2 = 0; |
| 158225 | + unsigned sum3 = 0; |
| 158226 | + while(N >= 16){ |
| 158227 | + sum0 += ((unsigned)z[0] + z[4] + z[8] + z[12]); |
| 158228 | + sum1 += ((unsigned)z[1] + z[5] + z[9] + z[13]); |
| 158229 | + sum2 += ((unsigned)z[2] + z[6] + z[10]+ z[14]); |
| 158230 | + sum3 += ((unsigned)z[3] + z[7] + z[11]+ z[15]); |
| 158231 | + z += 16; |
| 158232 | + N -= 16; |
| 158233 | + } |
| 158234 | + while(N >= 4){ |
| 158235 | + sum0 += z[0]; |
| 158236 | + sum1 += z[1]; |
| 158237 | + sum2 += z[2]; |
| 158238 | + sum3 += z[3]; |
| 158239 | + z += 4; |
| 158240 | + N -= 4; |
| 158241 | + } |
| 158242 | + sum3 += (sum2 << 8) + (sum1 << 16) + (sum0 << 24); |
| 158243 | + switch(N){ |
| 158244 | + case 3: sum3 += (z[2] << 8); |
| 158245 | + case 2: sum3 += (z[1] << 16); |
| 158246 | + case 1: sum3 += (z[0] << 24); |
| 158247 | + default: ; |
| 158248 | + } |
| 158249 | + return sum3; |
| 158250 | +} |
| 158251 | + |
| 158252 | +/* |
| 158253 | +** Apply a delta. |
| 158254 | +** |
| 158255 | +** The output buffer should be big enough to hold the whole output |
| 158256 | +** file and a NUL terminator at the end. The delta_output_size() |
| 158257 | +** routine will determine this size for you. |
| 158258 | +** |
| 158259 | +** The delta string should be null-terminated. But the delta string |
| 158260 | +** may contain embedded NUL characters (if the input and output are |
| 158261 | +** binary files) so we also have to pass in the length of the delta in |
| 158262 | +** the lenDelta parameter. |
| 158263 | +** |
| 158264 | +** This function returns the size of the output file in bytes (excluding |
| 158265 | +** the final NUL terminator character). Except, if the delta string is |
| 158266 | +** malformed or intended for use with a source file other than zSrc, |
| 158267 | +** then this routine returns -1. |
| 158268 | +** |
| 158269 | +** Refer to the delta_create() documentation above for a description |
| 158270 | +** of the delta file format. |
| 158271 | +*/ |
| 158272 | +static int rbuDeltaApply( |
| 158273 | + const char *zSrc, /* The source or pattern file */ |
| 158274 | + int lenSrc, /* Length of the source file */ |
| 158275 | + const char *zDelta, /* Delta to apply to the pattern */ |
| 158276 | + int lenDelta, /* Length of the delta */ |
| 158277 | + char *zOut /* Write the output into this preallocated buffer */ |
| 158278 | +){ |
| 158279 | + unsigned int limit; |
| 158280 | + unsigned int total = 0; |
| 158281 | +#ifndef FOSSIL_OMIT_DELTA_CKSUM_TEST |
| 158282 | + char *zOrigOut = zOut; |
| 158283 | +#endif |
| 158284 | + |
| 158285 | + limit = rbuDeltaGetInt(&zDelta, &lenDelta); |
| 158286 | + if( *zDelta!='\n' ){ |
| 158287 | + /* ERROR: size integer not terminated by "\n" */ |
| 158288 | + return -1; |
| 158289 | + } |
| 158290 | + zDelta++; lenDelta--; |
| 158291 | + while( *zDelta && lenDelta>0 ){ |
| 158292 | + unsigned int cnt, ofst; |
| 158293 | + cnt = rbuDeltaGetInt(&zDelta, &lenDelta); |
| 158294 | + switch( zDelta[0] ){ |
| 158295 | + case '@': { |
| 158296 | + zDelta++; lenDelta--; |
| 158297 | + ofst = rbuDeltaGetInt(&zDelta, &lenDelta); |
| 158298 | + if( lenDelta>0 && zDelta[0]!=',' ){ |
| 158299 | + /* ERROR: copy command not terminated by ',' */ |
| 158300 | + return -1; |
| 158301 | + } |
| 158302 | + zDelta++; lenDelta--; |
| 158303 | + total += cnt; |
| 158304 | + if( total>limit ){ |
| 158305 | + /* ERROR: copy exceeds output file size */ |
| 158306 | + return -1; |
| 158307 | + } |
| 158308 | + if( (int)(ofst+cnt) > lenSrc ){ |
| 158309 | + /* ERROR: copy extends past end of input */ |
| 158310 | + return -1; |
| 158311 | + } |
| 158312 | + memcpy(zOut, &zSrc[ofst], cnt); |
| 158313 | + zOut += cnt; |
| 158314 | + break; |
| 158315 | + } |
| 158316 | + case ':': { |
| 158317 | + zDelta++; lenDelta--; |
| 158318 | + total += cnt; |
| 158319 | + if( total>limit ){ |
| 158320 | + /* ERROR: insert command gives an output larger than predicted */ |
| 158321 | + return -1; |
| 158322 | + } |
| 158323 | + if( (int)cnt>lenDelta ){ |
| 158324 | + /* ERROR: insert count exceeds size of delta */ |
| 158325 | + return -1; |
| 158326 | + } |
| 158327 | + memcpy(zOut, zDelta, cnt); |
| 158328 | + zOut += cnt; |
| 158329 | + zDelta += cnt; |
| 158330 | + lenDelta -= cnt; |
| 158331 | + break; |
| 158332 | + } |
| 158333 | + case ';': { |
| 158334 | + zDelta++; lenDelta--; |
| 158335 | + zOut[0] = 0; |
| 158336 | +#ifndef FOSSIL_OMIT_DELTA_CKSUM_TEST |
| 158337 | + if( cnt!=rbuDeltaChecksum(zOrigOut, total) ){ |
| 158338 | + /* ERROR: bad checksum */ |
| 158339 | + return -1; |
| 158340 | + } |
| 158341 | +#endif |
| 158342 | + if( total!=limit ){ |
| 158343 | + /* ERROR: generated size does not match predicted size */ |
| 158344 | + return -1; |
| 158345 | + } |
| 158346 | + return total; |
| 158347 | + } |
| 158348 | + default: { |
| 158349 | + /* ERROR: unknown delta operator */ |
| 158350 | + return -1; |
| 158351 | + } |
| 158352 | + } |
| 158353 | + } |
| 158354 | + /* ERROR: unterminated delta */ |
| 158355 | + return -1; |
| 158356 | +} |
| 158357 | + |
| 158358 | +static int rbuDeltaOutputSize(const char *zDelta, int lenDelta){ |
| 158359 | + int size; |
| 158360 | + size = rbuDeltaGetInt(&zDelta, &lenDelta); |
| 158361 | + if( *zDelta!='\n' ){ |
| 158362 | + /* ERROR: size integer not terminated by "\n" */ |
| 158363 | + return -1; |
| 158364 | + } |
| 158365 | + return size; |
| 158366 | +} |
| 158367 | + |
| 158368 | +/* |
| 158369 | +** End of code taken from fossil. |
| 158370 | +*************************************************************************/ |
| 158371 | + |
| 158372 | +/* |
| 158373 | +** Implementation of SQL scalar function rbu_fossil_delta(). |
| 158374 | +** |
| 158375 | +** This function applies a fossil delta patch to a blob. Exactly two |
| 158376 | +** arguments must be passed to this function. The first is the blob to |
| 158377 | +** patch and the second the patch to apply. If no error occurs, this |
| 158378 | +** function returns the patched blob. |
| 158379 | +*/ |
| 158380 | +static void rbuFossilDeltaFunc( |
| 158381 | + sqlite3_context *context, |
| 158382 | + int argc, |
| 158383 | + sqlite3_value **argv |
| 158384 | +){ |
| 158385 | + const char *aDelta; |
| 158386 | + int nDelta; |
| 158387 | + const char *aOrig; |
| 158388 | + int nOrig; |
| 158389 | + |
| 158390 | + int nOut; |
| 158391 | + int nOut2; |
| 158392 | + char *aOut; |
| 158393 | + |
| 158394 | + assert( argc==2 ); |
| 158395 | + |
| 158396 | + nOrig = sqlite3_value_bytes(argv[0]); |
| 158397 | + aOrig = (const char*)sqlite3_value_blob(argv[0]); |
| 158398 | + nDelta = sqlite3_value_bytes(argv[1]); |
| 158399 | + aDelta = (const char*)sqlite3_value_blob(argv[1]); |
| 158400 | + |
| 158401 | + /* Figure out the size of the output */ |
| 158402 | + nOut = rbuDeltaOutputSize(aDelta, nDelta); |
| 158403 | + if( nOut<0 ){ |
| 158404 | + sqlite3_result_error(context, "corrupt fossil delta", -1); |
| 158405 | + return; |
| 158406 | + } |
| 158407 | + |
| 158408 | + aOut = sqlite3_malloc(nOut+1); |
| 158409 | + if( aOut==0 ){ |
| 158410 | + sqlite3_result_error_nomem(context); |
| 158411 | + }else{ |
| 158412 | + nOut2 = rbuDeltaApply(aOrig, nOrig, aDelta, nDelta, aOut); |
| 158413 | + if( nOut2!=nOut ){ |
| 158414 | + sqlite3_result_error(context, "corrupt fossil delta", -1); |
| 158415 | + }else{ |
| 158416 | + sqlite3_result_blob(context, aOut, nOut, sqlite3_free); |
| 158417 | + } |
| 158418 | + } |
| 158419 | +} |
| 158420 | + |
| 157664 | 158421 | |
| 157665 | 158422 | /* |
| 157666 | 158423 | ** Prepare the SQL statement in buffer zSql against database handle db. |
| 157667 | 158424 | ** If successful, set *ppStmt to point to the new statement and return |
| 157668 | 158425 | ** SQLITE_OK. |
| | @@ -157826,11 +158583,12 @@ |
| 157826 | 158583 | if( rc!=SQLITE_ROW ){ |
| 157827 | 158584 | rc = resetAndCollectError(pIter->pTblIter, &p->zErrmsg); |
| 157828 | 158585 | pIter->zTbl = 0; |
| 157829 | 158586 | }else{ |
| 157830 | 158587 | pIter->zTbl = (const char*)sqlite3_column_text(pIter->pTblIter, 0); |
| 157831 | | - rc = pIter->zTbl ? SQLITE_OK : SQLITE_NOMEM; |
| 158588 | + pIter->zDataTbl = (const char*)sqlite3_column_text(pIter->pTblIter,1); |
| 158589 | + rc = (pIter->zDataTbl && pIter->zTbl) ? SQLITE_OK : SQLITE_NOMEM; |
| 157832 | 158590 | } |
| 157833 | 158591 | }else{ |
| 157834 | 158592 | if( pIter->zIdx==0 ){ |
| 157835 | 158593 | sqlite3_stmt *pIdx = pIter->pIdxIter; |
| 157836 | 158594 | rc = sqlite3_bind_text(pIdx, 1, pIter->zTbl, -1, SQLITE_STATIC); |
| | @@ -157857,10 +158615,44 @@ |
| 157857 | 158615 | p->rc = rc; |
| 157858 | 158616 | } |
| 157859 | 158617 | return rc; |
| 157860 | 158618 | } |
| 157861 | 158619 | |
| 158620 | + |
| 158621 | +/* |
| 158622 | +** The implementation of the rbu_target_name() SQL function. This function |
| 158623 | +** accepts one argument - the name of a table in the RBU database. If the |
| 158624 | +** table name matches the pattern: |
| 158625 | +** |
| 158626 | +** data[0-9]_<name> |
| 158627 | +** |
| 158628 | +** where <name> is any sequence of 1 or more characters, <name> is returned. |
| 158629 | +** Otherwise, if the only argument does not match the above pattern, an SQL |
| 158630 | +** NULL is returned. |
| 158631 | +** |
| 158632 | +** "data_t1" -> "t1" |
| 158633 | +** "data0123_t2" -> "t2" |
| 158634 | +** "dataAB_t3" -> NULL |
| 158635 | +*/ |
| 158636 | +static void rbuTargetNameFunc( |
| 158637 | + sqlite3_context *context, |
| 158638 | + int argc, |
| 158639 | + sqlite3_value **argv |
| 158640 | +){ |
| 158641 | + const char *zIn; |
| 158642 | + assert( argc==1 ); |
| 158643 | + |
| 158644 | + zIn = (const char*)sqlite3_value_text(argv[0]); |
| 158645 | + if( zIn && strlen(zIn)>4 && memcmp("data", zIn, 4)==0 ){ |
| 158646 | + int i; |
| 158647 | + for(i=4; zIn[i]>='0' && zIn[i]<='9'; i++); |
| 158648 | + if( zIn[i]=='_' && zIn[i+1] ){ |
| 158649 | + sqlite3_result_text(context, &zIn[i+1], -1, SQLITE_STATIC); |
| 158650 | + } |
| 158651 | + } |
| 158652 | +} |
| 158653 | + |
| 157862 | 158654 | /* |
| 157863 | 158655 | ** Initialize the iterator structure passed as the second argument. |
| 157864 | 158656 | ** |
| 157865 | 158657 | ** If no error occurs, SQLITE_OK is returned and the iterator is left |
| 157866 | 158658 | ** pointing to the first entry. Otherwise, an error code and message is |
| | @@ -157870,12 +158662,13 @@ |
| 157870 | 158662 | static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){ |
| 157871 | 158663 | int rc; |
| 157872 | 158664 | memset(pIter, 0, sizeof(RbuObjIter)); |
| 157873 | 158665 | |
| 157874 | 158666 | rc = prepareAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, |
| 157875 | | - "SELECT substr(name, 6) FROM sqlite_master " |
| 157876 | | - "WHERE type IN ('table', 'view') AND name LIKE 'data_%'" |
| 158667 | + "SELECT rbu_target_name(name) AS target, name FROM sqlite_master " |
| 158668 | + "WHERE type IN ('table', 'view') AND target IS NOT NULL " |
| 158669 | + "ORDER BY name" |
| 157877 | 158670 | ); |
| 157878 | 158671 | |
| 157879 | 158672 | if( rc==SQLITE_OK ){ |
| 157880 | 158673 | rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg, |
| 157881 | 158674 | "SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' " |
| | @@ -158138,11 +158931,11 @@ |
| 158138 | 158931 | } |
| 158139 | 158932 | *peType = RBU_PK_NONE; |
| 158140 | 158933 | } |
| 158141 | 158934 | |
| 158142 | 158935 | rbuTableType_end: { |
| 158143 | | - int i; |
| 158936 | + unsigned int i; |
| 158144 | 158937 | for(i=0; i<sizeof(aStmt)/sizeof(aStmt[0]); i++){ |
| 158145 | 158938 | rbuFinalize(p, aStmt[i]); |
| 158146 | 158939 | } |
| 158147 | 158940 | } |
| 158148 | 158941 | } |
| | @@ -158217,11 +159010,11 @@ |
| 158217 | 159010 | |
| 158218 | 159011 | /* Populate the azTblCol[] and nTblCol variables based on the columns |
| 158219 | 159012 | ** of the input table. Ignore any input table columns that begin with |
| 158220 | 159013 | ** "rbu_". */ |
| 158221 | 159014 | p->rc = prepareFreeAndCollectError(p->dbRbu, &pStmt, &p->zErrmsg, |
| 158222 | | - sqlite3_mprintf("SELECT * FROM 'data_%q'", pIter->zTbl) |
| 159015 | + sqlite3_mprintf("SELECT * FROM '%q'", pIter->zDataTbl) |
| 158223 | 159016 | ); |
| 158224 | 159017 | if( p->rc==SQLITE_OK ){ |
| 158225 | 159018 | nCol = sqlite3_column_count(pStmt); |
| 158226 | 159019 | rbuAllocateIterArrays(p, pIter, nCol); |
| 158227 | 159020 | } |
| | @@ -158242,11 +159035,11 @@ |
| 158242 | 159035 | if( p->rc==SQLITE_OK |
| 158243 | 159036 | && bRbuRowid!=(pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE) |
| 158244 | 159037 | ){ |
| 158245 | 159038 | p->rc = SQLITE_ERROR; |
| 158246 | 159039 | p->zErrmsg = sqlite3_mprintf( |
| 158247 | | - "table data_%q %s rbu_rowid column", pIter->zTbl, |
| 159040 | + "table %q %s rbu_rowid column", pIter->zDataTbl, |
| 158248 | 159041 | (bRbuRowid ? "may not have" : "requires") |
| 158249 | 159042 | ); |
| 158250 | 159043 | } |
| 158251 | 159044 | |
| 158252 | 159045 | /* Check that all non-HIDDEN columns in the destination table are also |
| | @@ -158263,12 +159056,12 @@ |
| 158263 | 159056 | for(i=iOrder; i<pIter->nTblCol; i++){ |
| 158264 | 159057 | if( 0==strcmp(zName, pIter->azTblCol[i]) ) break; |
| 158265 | 159058 | } |
| 158266 | 159059 | if( i==pIter->nTblCol ){ |
| 158267 | 159060 | p->rc = SQLITE_ERROR; |
| 158268 | | - p->zErrmsg = sqlite3_mprintf("column missing from data_%q: %s", |
| 158269 | | - pIter->zTbl, zName |
| 159061 | + p->zErrmsg = sqlite3_mprintf("column missing from %q: %s", |
| 159062 | + pIter->zDataTbl, zName |
| 158270 | 159063 | ); |
| 158271 | 159064 | }else{ |
| 158272 | 159065 | int iPk = sqlite3_column_int(pStmt, 5); |
| 158273 | 159066 | int bNotNull = sqlite3_column_int(pStmt, 3); |
| 158274 | 159067 | const char *zType = (const char*)sqlite3_column_text(pStmt, 2); |
| | @@ -158551,11 +159344,11 @@ |
| 158551 | 159344 | ){ |
| 158552 | 159345 | char *zList = 0; |
| 158553 | 159346 | if( p->rc==SQLITE_OK ){ |
| 158554 | 159347 | int i; |
| 158555 | 159348 | |
| 158556 | | - if( strlen(zMask)!=pIter->nTblCol ){ |
| 159349 | + if( (int)strlen(zMask)!=pIter->nTblCol ){ |
| 158557 | 159350 | rbuBadControlError(p); |
| 158558 | 159351 | }else{ |
| 158559 | 159352 | const char *zSep = ""; |
| 158560 | 159353 | for(i=0; i<pIter->nTblCol; i++){ |
| 158561 | 159354 | char c = zMask[pIter->aiSrcOrder[i]]; |
| | @@ -158563,15 +159356,21 @@ |
| 158563 | 159356 | zList = rbuMPrintf(p, "%z%s\"%w\"=?%d", |
| 158564 | 159357 | zList, zSep, pIter->azTblCol[i], i+1 |
| 158565 | 159358 | ); |
| 158566 | 159359 | zSep = ", "; |
| 158567 | 159360 | } |
| 158568 | | - if( c=='d' ){ |
| 159361 | + else if( c=='d' ){ |
| 158569 | 159362 | zList = rbuMPrintf(p, "%z%s\"%w\"=rbu_delta(\"%w\", ?%d)", |
| 158570 | 159363 | zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1 |
| 158571 | 159364 | ); |
| 158572 | 159365 | zSep = ", "; |
| 159366 | + } |
| 159367 | + else if( c=='f' ){ |
| 159368 | + zList = rbuMPrintf(p, "%z%s\"%w\"=rbu_fossil_delta(\"%w\", ?%d)", |
| 159369 | + zList, zSep, pIter->azTblCol[i], pIter->azTblCol[i], i+1 |
| 159370 | + ); |
| 159371 | + zSep = ", "; |
| 158573 | 159372 | } |
| 158574 | 159373 | } |
| 158575 | 159374 | } |
| 158576 | 159375 | } |
| 158577 | 159376 | return zList; |
| | @@ -158819,11 +159618,11 @@ |
| 158819 | 159618 | if( zBind ){ |
| 158820 | 159619 | assert( pIter->pTmpInsert==0 ); |
| 158821 | 159620 | p->rc = prepareFreeAndCollectError( |
| 158822 | 159621 | p->dbRbu, &pIter->pTmpInsert, &p->zErrmsg, sqlite3_mprintf( |
| 158823 | 159622 | "INSERT INTO %s.'rbu_tmp_%q'(rbu_control,%s%s) VALUES(%z)", |
| 158824 | | - p->zStateDb, pIter->zTbl, zCollist, zRbuRowid, zBind |
| 159623 | + p->zStateDb, pIter->zDataTbl, zCollist, zRbuRowid, zBind |
| 158825 | 159624 | )); |
| 158826 | 159625 | } |
| 158827 | 159626 | } |
| 158828 | 159627 | |
| 158829 | 159628 | static void rbuTmpInsertFunc( |
| | @@ -158915,22 +159714,22 @@ |
| 158915 | 159714 | if( p->rc==SQLITE_OK ){ |
| 158916 | 159715 | char *zSql; |
| 158917 | 159716 | if( pIter->eType==RBU_PK_EXTERNAL || pIter->eType==RBU_PK_NONE ){ |
| 158918 | 159717 | zSql = sqlite3_mprintf( |
| 158919 | 159718 | "SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' ORDER BY %s%s", |
| 158920 | | - zCollist, p->zStateDb, pIter->zTbl, |
| 159719 | + zCollist, p->zStateDb, pIter->zDataTbl, |
| 158921 | 159720 | zCollist, zLimit |
| 158922 | 159721 | ); |
| 158923 | 159722 | }else{ |
| 158924 | 159723 | zSql = sqlite3_mprintf( |
| 158925 | | - "SELECT %s, rbu_control FROM 'data_%q' " |
| 159724 | + "SELECT %s, rbu_control FROM '%q' " |
| 158926 | 159725 | "WHERE typeof(rbu_control)='integer' AND rbu_control!=1 " |
| 158927 | 159726 | "UNION ALL " |
| 158928 | 159727 | "SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' " |
| 158929 | 159728 | "ORDER BY %s%s", |
| 158930 | | - zCollist, pIter->zTbl, |
| 158931 | | - zCollist, p->zStateDb, pIter->zTbl, |
| 159729 | + zCollist, pIter->zDataTbl, |
| 159730 | + zCollist, p->zStateDb, pIter->zDataTbl, |
| 158932 | 159731 | zCollist, zLimit |
| 158933 | 159732 | ); |
| 158934 | 159733 | } |
| 158935 | 159734 | p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, zSql); |
| 158936 | 159735 | } |
| | @@ -158950,20 +159749,10 @@ |
| 158950 | 159749 | char *zNewlist = rbuObjIterGetOldlist(p, pIter, "new"); |
| 158951 | 159750 | |
| 158952 | 159751 | zCollist = rbuObjIterGetCollist(p, pIter); |
| 158953 | 159752 | pIter->nCol = pIter->nTblCol; |
| 158954 | 159753 | |
| 158955 | | - /* Create the SELECT statement to read keys from data_xxx */ |
| 158956 | | - if( p->rc==SQLITE_OK ){ |
| 158957 | | - p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, |
| 158958 | | - sqlite3_mprintf( |
| 158959 | | - "SELECT %s, rbu_control%s FROM 'data_%q'%s", |
| 158960 | | - zCollist, (bRbuRowid ? ", rbu_rowid" : ""), zTbl, zLimit |
| 158961 | | - ) |
| 158962 | | - ); |
| 158963 | | - } |
| 158964 | | - |
| 158965 | 159754 | /* Create the imposter table or tables (if required). */ |
| 158966 | 159755 | rbuCreateImposterTable(p, pIter); |
| 158967 | 159756 | rbuCreateImposterTable2(p, pIter); |
| 158968 | 159757 | zWrite = (pIter->eType==RBU_PK_VTAB ? "" : "rbu_imp_"); |
| 158969 | 159758 | |
| | @@ -158993,14 +159782,14 @@ |
| 158993 | 159782 | } |
| 158994 | 159783 | |
| 158995 | 159784 | /* Create the rbu_tmp_xxx table and the triggers to populate it. */ |
| 158996 | 159785 | rbuMPrintfExec(p, p->dbRbu, |
| 158997 | 159786 | "CREATE TABLE IF NOT EXISTS %s.'rbu_tmp_%q' AS " |
| 158998 | | - "SELECT *%s FROM 'data_%q' WHERE 0;" |
| 158999 | | - , p->zStateDb |
| 159000 | | - , zTbl, (pIter->eType==RBU_PK_EXTERNAL ? ", 0 AS rbu_rowid" : "") |
| 159001 | | - , zTbl |
| 159787 | + "SELECT *%s FROM '%q' WHERE 0;" |
| 159788 | + , p->zStateDb, pIter->zDataTbl |
| 159789 | + , (pIter->eType==RBU_PK_EXTERNAL ? ", 0 AS rbu_rowid" : "") |
| 159790 | + , pIter->zDataTbl |
| 159002 | 159791 | ); |
| 159003 | 159792 | |
| 159004 | 159793 | rbuMPrintfExec(p, p->dbMain, |
| 159005 | 159794 | "CREATE TEMP TRIGGER rbu_delete_tr BEFORE DELETE ON \"%s%w\" " |
| 159006 | 159795 | "BEGIN " |
| | @@ -159031,10 +159820,21 @@ |
| 159031 | 159820 | ); |
| 159032 | 159821 | } |
| 159033 | 159822 | |
| 159034 | 159823 | rbuObjIterPrepareTmpInsert(p, pIter, zCollist, zRbuRowid); |
| 159035 | 159824 | } |
| 159825 | + |
| 159826 | + /* Create the SELECT statement to read keys from data_xxx */ |
| 159827 | + if( p->rc==SQLITE_OK ){ |
| 159828 | + p->rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pSelect, pz, |
| 159829 | + sqlite3_mprintf( |
| 159830 | + "SELECT %s, rbu_control%s FROM '%q'%s", |
| 159831 | + zCollist, (bRbuRowid ? ", rbu_rowid" : ""), |
| 159832 | + pIter->zDataTbl, zLimit |
| 159833 | + ) |
| 159834 | + ); |
| 159835 | + } |
| 159036 | 159836 | |
| 159037 | 159837 | sqlite3_free(zWhere); |
| 159038 | 159838 | sqlite3_free(zOldlist); |
| 159039 | 159839 | sqlite3_free(zNewlist); |
| 159040 | 159840 | sqlite3_free(zBindings); |
| | @@ -159161,10 +159961,22 @@ |
| 159161 | 159961 | if( p->rc==SQLITE_OK ){ |
| 159162 | 159962 | p->rc = sqlite3_create_function(p->dbMain, |
| 159163 | 159963 | "rbu_tmp_insert", -1, SQLITE_UTF8, (void*)p, rbuTmpInsertFunc, 0, 0 |
| 159164 | 159964 | ); |
| 159165 | 159965 | } |
| 159966 | + |
| 159967 | + if( p->rc==SQLITE_OK ){ |
| 159968 | + p->rc = sqlite3_create_function(p->dbMain, |
| 159969 | + "rbu_fossil_delta", 2, SQLITE_UTF8, 0, rbuFossilDeltaFunc, 0, 0 |
| 159970 | + ); |
| 159971 | + } |
| 159972 | + |
| 159973 | + if( p->rc==SQLITE_OK ){ |
| 159974 | + p->rc = sqlite3_create_function(p->dbRbu, |
| 159975 | + "rbu_target_name", 1, SQLITE_UTF8, (void*)p, rbuTargetNameFunc, 0, 0 |
| 159976 | + ); |
| 159977 | + } |
| 159166 | 159978 | |
| 159167 | 159979 | if( p->rc==SQLITE_OK ){ |
| 159168 | 159980 | p->rc = sqlite3_file_control(p->dbMain, "main", SQLITE_FCNTL_RBU, (void*)p); |
| 159169 | 159981 | } |
| 159170 | 159982 | rbuMPrintfExec(p, p->dbMain, "SELECT * FROM sqlite_master"); |
| | @@ -159591,11 +160403,11 @@ |
| 159591 | 160403 | rbuGetUpdateStmt(p, pIter, zMask, &pUpdate); |
| 159592 | 160404 | if( pUpdate ){ |
| 159593 | 160405 | for(i=0; p->rc==SQLITE_OK && i<pIter->nCol; i++){ |
| 159594 | 160406 | char c = zMask[pIter->aiSrcOrder[i]]; |
| 159595 | 160407 | pVal = sqlite3_column_value(pIter->pSelect, i); |
| 159596 | | - if( pIter->abTblPk[i] || c=='x' || c=='d' ){ |
| 160408 | + if( pIter->abTblPk[i] || c!='.' ){ |
| 159597 | 160409 | p->rc = sqlite3_bind_value(pUpdate, i+1, pVal); |
| 159598 | 160410 | } |
| 159599 | 160411 | } |
| 159600 | 160412 | if( p->rc==SQLITE_OK |
| 159601 | 160413 | && (pIter->eType==RBU_PK_VTAB || pIter->eType==RBU_PK_NONE) |
| | @@ -159703,11 +160515,11 @@ |
| 159703 | 160515 | /* Clean up the rbu_tmp_xxx table for the previous table. It |
| 159704 | 160516 | ** cannot be dropped as there are currently active SQL statements. |
| 159705 | 160517 | ** But the contents can be deleted. */ |
| 159706 | 160518 | if( pIter->abIndexed ){ |
| 159707 | 160519 | rbuMPrintfExec(p, p->dbRbu, |
| 159708 | | - "DELETE FROM %s.'rbu_tmp_%q'", p->zStateDb, pIter->zTbl |
| 160520 | + "DELETE FROM %s.'rbu_tmp_%q'", p->zStateDb, pIter->zDataTbl |
| 159709 | 160521 | ); |
| 159710 | 160522 | } |
| 159711 | 160523 | }else{ |
| 159712 | 160524 | rbuObjIterPrepareAll(p, pIter, 0); |
| 159713 | 160525 | |
| | @@ -159926,14 +160738,17 @@ |
| 159926 | 160738 | ** If there is a "*-oal" file in the file-system corresponding to the |
| 159927 | 160739 | ** target database in the file-system, delete it. If an error occurs, |
| 159928 | 160740 | ** leave an error code and error message in the rbu handle. |
| 159929 | 160741 | */ |
| 159930 | 160742 | static void rbuDeleteOalFile(sqlite3rbu *p){ |
| 159931 | | - char *zOal = sqlite3_mprintf("%s-oal", p->zTarget); |
| 159932 | | - assert( p->rc==SQLITE_OK && p->zErrmsg==0 ); |
| 159933 | | - unlink(zOal); |
| 159934 | | - sqlite3_free(zOal); |
| 160743 | + char *zOal = rbuMPrintf(p, "%s-oal", p->zTarget); |
| 160744 | + if( zOal ){ |
| 160745 | + sqlite3_vfs *pVfs = sqlite3_vfs_find(0); |
| 160746 | + assert( pVfs && p->rc==SQLITE_OK && p->zErrmsg==0 ); |
| 160747 | + pVfs->xDelete(pVfs, zOal, 0); |
| 160748 | + sqlite3_free(zOal); |
| 160749 | + } |
| 159935 | 160750 | } |
| 159936 | 160751 | |
| 159937 | 160752 | /* |
| 159938 | 160753 | ** Allocate a private rbu VFS for the rbu handle passed as the only |
| 159939 | 160754 | ** argument. This VFS will be used unless the call to sqlite3rbu_open() |
| | @@ -160042,18 +160857,29 @@ |
| 160042 | 160857 | p->zErrmsg = sqlite3_mprintf("database modified during rbu update"); |
| 160043 | 160858 | } |
| 160044 | 160859 | |
| 160045 | 160860 | if( p->rc==SQLITE_OK ){ |
| 160046 | 160861 | if( p->eStage==RBU_STAGE_OAL ){ |
| 160862 | + sqlite3 *db = p->dbMain; |
| 160047 | 160863 | |
| 160048 | 160864 | /* Open transactions both databases. The *-oal file is opened or |
| 160049 | 160865 | ** created at this point. */ |
| 160050 | | - p->rc = sqlite3_exec(p->dbMain, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg); |
| 160866 | + p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg); |
| 160051 | 160867 | if( p->rc==SQLITE_OK ){ |
| 160052 | 160868 | p->rc = sqlite3_exec(p->dbRbu, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg); |
| 160053 | 160869 | } |
| 160054 | | - |
| 160870 | + |
| 160871 | + /* Check if the main database is a zipvfs db. If it is, set the upper |
| 160872 | + ** level pager to use "journal_mode=off". This prevents it from |
| 160873 | + ** generating a large journal using a temp file. */ |
| 160874 | + if( p->rc==SQLITE_OK ){ |
| 160875 | + int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0); |
| 160876 | + if( frc==SQLITE_OK ){ |
| 160877 | + p->rc = sqlite3_exec(db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg); |
| 160878 | + } |
| 160879 | + } |
| 160880 | + |
| 160055 | 160881 | /* Point the object iterator at the first object */ |
| 160056 | 160882 | if( p->rc==SQLITE_OK ){ |
| 160057 | 160883 | p->rc = rbuObjIterFirst(p, &p->objiter); |
| 160058 | 160884 | } |
| 160059 | 160885 | |
| | @@ -160162,10 +160988,36 @@ |
| 160162 | 160988 | ** current RBU update was started. |
| 160163 | 160989 | */ |
| 160164 | 160990 | SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3rbu_progress(sqlite3rbu *pRbu){ |
| 160165 | 160991 | return pRbu->nProgress; |
| 160166 | 160992 | } |
| 160993 | + |
| 160994 | +SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *p){ |
| 160995 | + int rc = p->rc; |
| 160996 | + |
| 160997 | + if( rc==SQLITE_DONE ) return SQLITE_OK; |
| 160998 | + |
| 160999 | + assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE ); |
| 161000 | + if( p->eStage==RBU_STAGE_OAL ){ |
| 161001 | + assert( rc!=SQLITE_DONE ); |
| 161002 | + if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "COMMIT", 0, 0, 0); |
| 161003 | + } |
| 161004 | + |
| 161005 | + p->rc = rc; |
| 161006 | + rbuSaveState(p, p->eStage); |
| 161007 | + rc = p->rc; |
| 161008 | + |
| 161009 | + if( p->eStage==RBU_STAGE_OAL ){ |
| 161010 | + assert( rc!=SQLITE_DONE ); |
| 161011 | + if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0); |
| 161012 | + if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "BEGIN IMMEDIATE", 0, 0, 0); |
| 161013 | + if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "BEGIN IMMEDIATE", 0, 0,0); |
| 161014 | + } |
| 161015 | + |
| 161016 | + p->rc = rc; |
| 161017 | + return rc; |
| 161018 | +} |
| 160167 | 161019 | |
| 160168 | 161020 | /************************************************************************** |
| 160169 | 161021 | ** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour |
| 160170 | 161022 | ** of a standard VFS in the following ways: |
| 160171 | 161023 | ** |
| | @@ -160642,11 +161494,12 @@ |
| 160642 | 161494 | rbuVfsSectorSize, /* xSectorSize */ |
| 160643 | 161495 | rbuVfsDeviceCharacteristics, /* xDeviceCharacteristics */ |
| 160644 | 161496 | rbuVfsShmMap, /* xShmMap */ |
| 160645 | 161497 | rbuVfsShmLock, /* xShmLock */ |
| 160646 | 161498 | rbuVfsShmBarrier, /* xShmBarrier */ |
| 160647 | | - rbuVfsShmUnmap /* xShmUnmap */ |
| 161499 | + rbuVfsShmUnmap, /* xShmUnmap */ |
| 161500 | + 0, 0 /* xFetch, xUnfetch */ |
| 160648 | 161501 | }; |
| 160649 | 161502 | rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs; |
| 160650 | 161503 | sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs; |
| 160651 | 161504 | rbu_file *pFd = (rbu_file *)pFile; |
| 160652 | 161505 | int rc = SQLITE_OK; |
| | @@ -160984,10 +161837,13 @@ |
| 160984 | 161837 | ** |
| 160985 | 161838 | ** The dbstat virtual table is used to extract low-level formatting |
| 160986 | 161839 | ** information from an SQLite database in order to implement the |
| 160987 | 161840 | ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script |
| 160988 | 161841 | ** for an example implementation. |
| 161842 | +** |
| 161843 | +** Additional information is available on the "dbstat.html" page of the |
| 161844 | +** official SQLite documentation. |
| 160989 | 161845 | */ |
| 160990 | 161846 | |
| 160991 | 161847 | /* #include "sqliteInt.h" ** Requires access to internal data structures ** */ |
| 160992 | 161848 | #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \ |
| 160993 | 161849 | && !defined(SQLITE_OMIT_VIRTUALTABLE) |
| | @@ -161032,11 +161888,12 @@ |
| 161032 | 161888 | " ncell INTEGER, /* Cells on page (0 for overflow) */" \ |
| 161033 | 161889 | " payload INTEGER, /* Bytes of payload on this page */" \ |
| 161034 | 161890 | " unused INTEGER, /* Bytes of unused space on this page */" \ |
| 161035 | 161891 | " mx_payload INTEGER, /* Largest payload size of all cells */" \ |
| 161036 | 161892 | " pgoffset INTEGER, /* Offset of page in file */" \ |
| 161037 | | - " pgsize INTEGER /* Size of the page */" \ |
| 161893 | + " pgsize INTEGER, /* Size of the page */" \ |
| 161894 | + " schema TEXT HIDDEN /* Database schema being analyzed */" \ |
| 161038 | 161895 | ");" |
| 161039 | 161896 | |
| 161040 | 161897 | |
| 161041 | 161898 | typedef struct StatTable StatTable; |
| 161042 | 161899 | typedef struct StatCursor StatCursor; |
| | @@ -161070,10 +161927,11 @@ |
| 161070 | 161927 | |
| 161071 | 161928 | struct StatCursor { |
| 161072 | 161929 | sqlite3_vtab_cursor base; |
| 161073 | 161930 | sqlite3_stmt *pStmt; /* Iterates through set of root pages */ |
| 161074 | 161931 | int isEof; /* After pStmt has returned SQLITE_DONE */ |
| 161932 | + int iDb; /* Schema used for this query */ |
| 161075 | 161933 | |
| 161076 | 161934 | StatPage aPage[32]; |
| 161077 | 161935 | int iPage; /* Current entry in aPage[] */ |
| 161078 | 161936 | |
| 161079 | 161937 | /* Values to return. */ |
| | @@ -161147,13 +162005,36 @@ |
| 161147 | 162005 | return SQLITE_OK; |
| 161148 | 162006 | } |
| 161149 | 162007 | |
| 161150 | 162008 | /* |
| 161151 | 162009 | ** There is no "best-index". This virtual table always does a linear |
| 161152 | | -** scan of the binary VFS log file. |
| 162010 | +** scan. However, a schema=? constraint should cause this table to |
| 162011 | +** operate on a different database schema, so check for it. |
| 162012 | +** |
| 162013 | +** idxNum is normally 0, but will be 1 if a schema=? constraint exists. |
| 161153 | 162014 | */ |
| 161154 | 162015 | static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ |
| 162016 | + int i; |
| 162017 | + |
| 162018 | + pIdxInfo->estimatedCost = 1.0e6; /* Initial cost estimate */ |
| 162019 | + |
| 162020 | + /* Look for a valid schema=? constraint. If found, change the idxNum to |
| 162021 | + ** 1 and request the value of that constraint be sent to xFilter. And |
| 162022 | + ** lower the cost estimate to encourage the constrained version to be |
| 162023 | + ** used. |
| 162024 | + */ |
| 162025 | + for(i=0; i<pIdxInfo->nConstraint; i++){ |
| 162026 | + if( pIdxInfo->aConstraint[i].usable==0 ) continue; |
| 162027 | + if( pIdxInfo->aConstraint[i].op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; |
| 162028 | + if( pIdxInfo->aConstraint[i].iColumn!=10 ) continue; |
| 162029 | + pIdxInfo->idxNum = 1; |
| 162030 | + pIdxInfo->estimatedCost = 1.0; |
| 162031 | + pIdxInfo->aConstraintUsage[i].argvIndex = 1; |
| 162032 | + pIdxInfo->aConstraintUsage[i].omit = 1; |
| 162033 | + break; |
| 162034 | + } |
| 162035 | + |
| 161155 | 162036 | |
| 161156 | 162037 | /* Records are always returned in ascending order of (name, path). |
| 161157 | 162038 | ** If this will satisfy the client, set the orderByConsumed flag so that |
| 161158 | 162039 | ** SQLite does not do an external sort. |
| 161159 | 162040 | */ |
| | @@ -161169,50 +162050,31 @@ |
| 161169 | 162050 | ) |
| 161170 | 162051 | ){ |
| 161171 | 162052 | pIdxInfo->orderByConsumed = 1; |
| 161172 | 162053 | } |
| 161173 | 162054 | |
| 161174 | | - pIdxInfo->estimatedCost = 10.0; |
| 161175 | 162055 | return SQLITE_OK; |
| 161176 | 162056 | } |
| 161177 | 162057 | |
| 161178 | 162058 | /* |
| 161179 | 162059 | ** Open a new statvfs cursor. |
| 161180 | 162060 | */ |
| 161181 | 162061 | static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ |
| 161182 | 162062 | StatTable *pTab = (StatTable *)pVTab; |
| 161183 | 162063 | StatCursor *pCsr; |
| 161184 | | - int rc; |
| 161185 | 162064 | |
| 161186 | 162065 | pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor)); |
| 161187 | 162066 | if( pCsr==0 ){ |
| 161188 | | - rc = SQLITE_NOMEM; |
| 162067 | + return SQLITE_NOMEM; |
| 161189 | 162068 | }else{ |
| 161190 | | - char *zSql; |
| 161191 | 162069 | memset(pCsr, 0, sizeof(StatCursor)); |
| 161192 | 162070 | pCsr->base.pVtab = pVTab; |
| 161193 | | - |
| 161194 | | - zSql = sqlite3_mprintf( |
| 161195 | | - "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type" |
| 161196 | | - " UNION ALL " |
| 161197 | | - "SELECT name, rootpage, type" |
| 161198 | | - " FROM \"%w\".sqlite_master WHERE rootpage!=0" |
| 161199 | | - " ORDER BY name", pTab->db->aDb[pTab->iDb].zName); |
| 161200 | | - if( zSql==0 ){ |
| 161201 | | - rc = SQLITE_NOMEM; |
| 161202 | | - }else{ |
| 161203 | | - rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0); |
| 161204 | | - sqlite3_free(zSql); |
| 161205 | | - } |
| 161206 | | - if( rc!=SQLITE_OK ){ |
| 161207 | | - sqlite3_free(pCsr); |
| 161208 | | - pCsr = 0; |
| 161209 | | - } |
| 162071 | + pCsr->iDb = pTab->iDb; |
| 161210 | 162072 | } |
| 161211 | 162073 | |
| 161212 | 162074 | *ppCursor = (sqlite3_vtab_cursor *)pCsr; |
| 161213 | | - return rc; |
| 162075 | + return SQLITE_OK; |
| 161214 | 162076 | } |
| 161215 | 162077 | |
| 161216 | 162078 | static void statClearPage(StatPage *p){ |
| 161217 | 162079 | int i; |
| 161218 | 162080 | if( p->aCell ){ |
| | @@ -161233,10 +162095,11 @@ |
| 161233 | 162095 | statClearPage(&pCsr->aPage[i]); |
| 161234 | 162096 | } |
| 161235 | 162097 | pCsr->iPage = 0; |
| 161236 | 162098 | sqlite3_free(pCsr->zPath); |
| 161237 | 162099 | pCsr->zPath = 0; |
| 162100 | + pCsr->isEof = 0; |
| 161238 | 162101 | } |
| 161239 | 162102 | |
| 161240 | 162103 | /* |
| 161241 | 162104 | ** Close a statvfs cursor. |
| 161242 | 162105 | */ |
| | @@ -161395,11 +162258,11 @@ |
| 161395 | 162258 | int rc; |
| 161396 | 162259 | int nPayload; |
| 161397 | 162260 | char *z; |
| 161398 | 162261 | StatCursor *pCsr = (StatCursor *)pCursor; |
| 161399 | 162262 | StatTable *pTab = (StatTable *)pCursor->pVtab; |
| 161400 | | - Btree *pBt = pTab->db->aDb[pTab->iDb].pBt; |
| 162263 | + Btree *pBt = pTab->db->aDb[pCsr->iDb].pBt; |
| 161401 | 162264 | Pager *pPager = sqlite3BtreePager(pBt); |
| 161402 | 162265 | |
| 161403 | 162266 | sqlite3_free(pCsr->zPath); |
| 161404 | 162267 | pCsr->zPath = 0; |
| 161405 | 162268 | |
| | @@ -161533,13 +162396,47 @@ |
| 161533 | 162396 | sqlite3_vtab_cursor *pCursor, |
| 161534 | 162397 | int idxNum, const char *idxStr, |
| 161535 | 162398 | int argc, sqlite3_value **argv |
| 161536 | 162399 | ){ |
| 161537 | 162400 | StatCursor *pCsr = (StatCursor *)pCursor; |
| 162401 | + StatTable *pTab = (StatTable*)(pCursor->pVtab); |
| 162402 | + char *zSql; |
| 162403 | + int rc = SQLITE_OK; |
| 162404 | + char *zMaster; |
| 161538 | 162405 | |
| 162406 | + if( idxNum==1 ){ |
| 162407 | + const char *zDbase = (const char*)sqlite3_value_text(argv[0]); |
| 162408 | + pCsr->iDb = sqlite3FindDbName(pTab->db, zDbase); |
| 162409 | + if( pCsr->iDb<0 ){ |
| 162410 | + sqlite3_free(pCursor->pVtab->zErrMsg); |
| 162411 | + pCursor->pVtab->zErrMsg = sqlite3_mprintf("no such schema: %s", zDbase); |
| 162412 | + return pCursor->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; |
| 162413 | + } |
| 162414 | + }else{ |
| 162415 | + pCsr->iDb = pTab->iDb; |
| 162416 | + } |
| 161539 | 162417 | statResetCsr(pCsr); |
| 161540 | | - return statNext(pCursor); |
| 162418 | + sqlite3_finalize(pCsr->pStmt); |
| 162419 | + pCsr->pStmt = 0; |
| 162420 | + zMaster = pCsr->iDb==1 ? "sqlite_temp_master" : "sqlite_master"; |
| 162421 | + zSql = sqlite3_mprintf( |
| 162422 | + "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type" |
| 162423 | + " UNION ALL " |
| 162424 | + "SELECT name, rootpage, type" |
| 162425 | + " FROM \"%w\".%s WHERE rootpage!=0" |
| 162426 | + " ORDER BY name", pTab->db->aDb[pCsr->iDb].zName, zMaster); |
| 162427 | + if( zSql==0 ){ |
| 162428 | + return SQLITE_NOMEM; |
| 162429 | + }else{ |
| 162430 | + rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0); |
| 162431 | + sqlite3_free(zSql); |
| 162432 | + } |
| 162433 | + |
| 162434 | + if( rc==SQLITE_OK ){ |
| 162435 | + rc = statNext(pCursor); |
| 162436 | + } |
| 162437 | + return rc; |
| 161541 | 162438 | } |
| 161542 | 162439 | |
| 161543 | 162440 | static int statColumn( |
| 161544 | 162441 | sqlite3_vtab_cursor *pCursor, |
| 161545 | 162442 | sqlite3_context *ctx, |
| | @@ -161572,14 +162469,19 @@ |
| 161572 | 162469 | sqlite3_result_int(ctx, pCsr->nMxPayload); |
| 161573 | 162470 | break; |
| 161574 | 162471 | case 8: /* pgoffset */ |
| 161575 | 162472 | sqlite3_result_int64(ctx, pCsr->iOffset); |
| 161576 | 162473 | break; |
| 161577 | | - default: /* pgsize */ |
| 161578 | | - assert( i==9 ); |
| 162474 | + case 9: /* pgsize */ |
| 161579 | 162475 | sqlite3_result_int(ctx, pCsr->szPage); |
| 161580 | 162476 | break; |
| 162477 | + default: { /* schema */ |
| 162478 | + sqlite3 *db = sqlite3_context_db_handle(ctx); |
| 162479 | + int iDb = pCsr->iDb; |
| 162480 | + sqlite3_result_text(ctx, db->aDb[iDb].zName, -1, SQLITE_STATIC); |
| 162481 | + break; |
| 162482 | + } |
| 161581 | 162483 | } |
| 161582 | 162484 | return SQLITE_OK; |
| 161583 | 162485 | } |
| 161584 | 162486 | |
| 161585 | 162487 | static int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){ |
| 161586 | 162488 | |