| | @@ -399,13 +399,10 @@ |
| 399 | 399 | ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the |
| 400 | 400 | ** assert() macro is enabled, each call into the Win32 native heap subsystem |
| 401 | 401 | ** will cause HeapValidate to be called. If heap validation should fail, an |
| 402 | 402 | ** assertion will be triggered. |
| 403 | 403 | ** |
| 404 | | -** (Historical note: There used to be several other options, but we've |
| 405 | | -** pared it down to just these three.) |
| 406 | | -** |
| 407 | 404 | ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as |
| 408 | 405 | ** the default. |
| 409 | 406 | */ |
| 410 | 407 | #if defined(SQLITE_SYSTEM_MALLOC) \ |
| 411 | 408 | + defined(SQLITE_WIN32_MALLOC) \ |
| | @@ -439,24 +436,17 @@ |
| 439 | 436 | */ |
| 440 | 437 | #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) |
| 441 | 438 | # define _XOPEN_SOURCE 600 |
| 442 | 439 | #endif |
| 443 | 440 | |
| 444 | | -/* |
| 445 | | -** The TCL headers are only needed when compiling the TCL bindings. |
| 446 | | -*/ |
| 447 | | -#if defined(SQLITE_TCL) || defined(TCLSH) |
| 448 | | -# include <tcl.h> |
| 449 | | -#endif |
| 450 | | - |
| 451 | 441 | /* |
| 452 | 442 | ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that |
| 453 | 443 | ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true, |
| 454 | 444 | ** make it true by defining or undefining NDEBUG. |
| 455 | 445 | ** |
| 456 | | -** Setting NDEBUG makes the code smaller and run faster by disabling the |
| 457 | | -** number assert() statements in the code. So we want the default action |
| 446 | +** Setting NDEBUG makes the code smaller and faster by disabling the |
| 447 | +** assert() statements in the code. So we want the default action |
| 458 | 448 | ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG |
| 459 | 449 | ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out |
| 460 | 450 | ** feature. |
| 461 | 451 | */ |
| 462 | 452 | #if !defined(NDEBUG) && !defined(SQLITE_DEBUG) |
| | @@ -522,11 +512,11 @@ |
| 522 | 512 | ** hint of unplanned behavior. |
| 523 | 513 | ** |
| 524 | 514 | ** In other words, ALWAYS and NEVER are added for defensive code. |
| 525 | 515 | ** |
| 526 | 516 | ** When doing coverage testing ALWAYS and NEVER are hard-coded to |
| 527 | | -** be true and false so that the unreachable code then specify will |
| 517 | +** be true and false so that the unreachable code they specify will |
| 528 | 518 | ** not be counted as untested code. |
| 529 | 519 | */ |
| 530 | 520 | #if defined(SQLITE_COVERAGE_TEST) |
| 531 | 521 | # define ALWAYS(X) (1) |
| 532 | 522 | # define NEVER(X) (0) |
| | @@ -546,20 +536,16 @@ |
| 546 | 536 | #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0) |
| 547 | 537 | |
| 548 | 538 | /* |
| 549 | 539 | ** The macro unlikely() is a hint that surrounds a boolean |
| 550 | 540 | ** expression that is usually false. Macro likely() surrounds |
| 551 | | -** a boolean expression that is usually true. GCC is able to |
| 552 | | -** use these hints to generate better code, sometimes. |
| 541 | +** a boolean expression that is usually true. These hints could, |
| 542 | +** in theory, be used by the compiler to generate better code, but |
| 543 | +** currently they are just comments for human readers. |
| 553 | 544 | */ |
| 554 | | -#if defined(__GNUC__) && 0 |
| 555 | | -# define likely(X) __builtin_expect((X),1) |
| 556 | | -# define unlikely(X) __builtin_expect((X),0) |
| 557 | | -#else |
| 558 | | -# define likely(X) !!(X) |
| 559 | | -# define unlikely(X) !!(X) |
| 560 | | -#endif |
| 545 | +#define likely(X) (X) |
| 546 | +#define unlikely(X) (X) |
| 561 | 547 | |
| 562 | 548 | /************** Include sqlite3.h in the middle of sqliteInt.h ***************/ |
| 563 | 549 | /************** Begin file sqlite3.h *****************************************/ |
| 564 | 550 | /* |
| 565 | 551 | ** 2001 September 15 |
| | @@ -670,11 +656,11 @@ |
| 670 | 656 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 671 | 657 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 672 | 658 | */ |
| 673 | 659 | #define SQLITE_VERSION "3.8.0" |
| 674 | 660 | #define SQLITE_VERSION_NUMBER 3008000 |
| 675 | | -#define SQLITE_SOURCE_ID "2013-07-18 14:50:56 5dcffa671f592ae9355628afa439ae9a2d26f0cd" |
| 661 | +#define SQLITE_SOURCE_ID "2013-08-05 12:31:41 4b8b426f10f8ae13bf553f7adf5ae09383fa0bd4" |
| 676 | 662 | |
| 677 | 663 | /* |
| 678 | 664 | ** CAPI3REF: Run-Time Library Version Numbers |
| 679 | 665 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 680 | 666 | ** |
| | @@ -1039,10 +1025,11 @@ |
| 1039 | 1025 | #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) |
| 1040 | 1026 | #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) |
| 1041 | 1027 | #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) |
| 1042 | 1028 | #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) |
| 1043 | 1029 | #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8)) |
| 1030 | +#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8)) |
| 1044 | 1031 | #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) |
| 1045 | 1032 | #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) |
| 1046 | 1033 | #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) |
| 1047 | 1034 | #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) |
| 1048 | 1035 | #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) |
| | @@ -3122,11 +3109,12 @@ |
| 3122 | 3109 | ** interface is to keep a GUI updated during a large query. |
| 3123 | 3110 | ** |
| 3124 | 3111 | ** ^The parameter P is passed through as the only parameter to the |
| 3125 | 3112 | ** callback function X. ^The parameter N is the approximate number of |
| 3126 | 3113 | ** [virtual machine instructions] that are evaluated between successive |
| 3127 | | -** invocations of the callback X. |
| 3114 | +** invocations of the callback X. ^If N is less than one then the progress |
| 3115 | +** handler is disabled. |
| 3128 | 3116 | ** |
| 3129 | 3117 | ** ^Only a single progress handler may be defined at one time per |
| 3130 | 3118 | ** [database connection]; setting a new progress handler cancels the |
| 3131 | 3119 | ** old one. ^Setting parameter X to NULL disables the progress handler. |
| 3132 | 3120 | ** ^The progress handler is also disabled by setting N to a value less |
| | @@ -4742,50 +4730,49 @@ |
| 4742 | 4730 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); |
| 4743 | 4731 | |
| 4744 | 4732 | /* |
| 4745 | 4733 | ** CAPI3REF: Function Auxiliary Data |
| 4746 | 4734 | ** |
| 4747 | | -** The following two functions may be used by scalar SQL functions to |
| 4735 | +** These functions may be used by (non-aggregate) SQL functions to |
| 4748 | 4736 | ** associate metadata with argument values. If the same value is passed to |
| 4749 | 4737 | ** multiple invocations of the same SQL function during query execution, under |
| 4750 | | -** some circumstances the associated metadata may be preserved. This might |
| 4751 | | -** be used, for example, in a regular-expression matching |
| 4752 | | -** function. The compiled version of the regular expression is stored as |
| 4753 | | -** metadata associated with the SQL value passed as the regular expression |
| 4754 | | -** pattern. The compiled regular expression can be reused on multiple |
| 4755 | | -** invocations of the same function so that the original pattern string |
| 4756 | | -** does not need to be recompiled on each invocation. |
| 4738 | +** some circumstances the associated metadata may be preserved. An example |
| 4739 | +** of where this might be useful is in a regular-expression matching |
| 4740 | +** function. The compiled version of the regular expression can be stored as |
| 4741 | +** metadata associated with the pattern string. |
| 4742 | +** Then as long as the pattern string remains the same, |
| 4743 | +** the compiled regular expression can be reused on multiple |
| 4744 | +** invocations of the same function. |
| 4757 | 4745 | ** |
| 4758 | 4746 | ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata |
| 4759 | 4747 | ** associated by the sqlite3_set_auxdata() function with the Nth argument |
| 4760 | | -** value to the application-defined function. ^If no metadata has been ever |
| 4761 | | -** been set for the Nth argument of the function, or if the corresponding |
| 4762 | | -** function parameter has changed since the meta-data was set, |
| 4763 | | -** then sqlite3_get_auxdata() returns a NULL pointer. |
| 4748 | +** value to the application-defined function. ^If there is no metadata |
| 4749 | +** associated with the function argument, this sqlite3_get_auxdata() interface |
| 4750 | +** returns a NULL pointer. |
| 4764 | 4751 | ** |
| 4765 | 4752 | ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th |
| 4766 | 4753 | ** argument of the application-defined function. ^Subsequent |
| 4767 | 4754 | ** calls to sqlite3_get_auxdata(C,N) return P from the most recent |
| 4768 | | -** sqlite3_set_auxdata(C,N,P,X) call if the data has not been dropped, or |
| 4769 | | -** NULL if the data has been dropped. |
| 4770 | | -** ^(If it is not NULL, SQLite will invoke the destructor |
| 4771 | | -** function X passed to sqlite3_set_auxdata(C,N,P,X) when <ul> |
| 4772 | | -** <li> the corresponding function parameter changes, |
| 4773 | | -** <li> [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 4774 | | -** SQL statement, |
| 4775 | | -** <li> sqlite3_set_auxdata() is invoked again on the same parameter, or |
| 4776 | | -** <li> a memory allocation error occurs. </ul>)^ |
| 4755 | +** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or |
| 4756 | +** NULL if the metadata has been discarded. |
| 4757 | +** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 4758 | +** SQLite will invoke the destructor function X with parameter P exactly |
| 4759 | +** once, when the metadata is discarded. |
| 4760 | +** SQLite is free to discard the metadata at any time, including: <ul> |
| 4761 | +** <li> when the corresponding function parameter changes, or |
| 4762 | +** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 4763 | +** SQL statement, or |
| 4764 | +** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or |
| 4765 | +** <li> during the original sqlite3_set_auxdata() call when a memory |
| 4766 | +** allocation error occurs. </ul>)^ |
| 4777 | 4767 | ** |
| 4778 | | -** SQLite is free to call the destructor and drop metadata on any |
| 4779 | | -** parameter of any function at any time. ^The only guarantee is that |
| 4780 | | -** the destructor will be called when the [prepared statement] is destroyed. |
| 4781 | | -** Note in particular that the destructor X in the call to |
| 4782 | | -** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before |
| 4783 | | -** the sqlite3_set_auxdata() call even returns. Hence sqlite3_set_auxdata() |
| 4768 | +** Note the last bullet in particular. The destructor X in |
| 4769 | +** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the |
| 4770 | +** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 4784 | 4771 | ** should be called near the end of the function implementation and the |
| 4785 | | -** implementation should not make any use of P after sqlite3_set_auxdata() |
| 4786 | | -** has been called. |
| 4772 | +** function implementation should not make any use of P after |
| 4773 | +** sqlite3_set_auxdata() has been called. |
| 4787 | 4774 | ** |
| 4788 | 4775 | ** ^(In practice, metadata is preserved between function calls for |
| 4789 | 4776 | ** function parameters that are compile-time constants, including literal |
| 4790 | 4777 | ** values and [parameters] and expressions composed from the same.)^ |
| 4791 | 4778 | ** |
| | @@ -6829,13 +6816,13 @@ |
| 6829 | 6816 | ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The |
| 6830 | 6817 | ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0. |
| 6831 | 6818 | ** </dd> |
| 6832 | 6819 | ** |
| 6833 | 6820 | ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt> |
| 6834 | | -** <dd>This parameter returns the zero for the current value if and only if |
| 6835 | | -** there all foreign key constraints (deferred or immediate) have been |
| 6836 | | -** resolved. The highwater mark is always 0. |
| 6821 | +** <dd>This parameter returns zero for the current value if and only if |
| 6822 | +** all foreign key constraints (deferred or immediate) have been |
| 6823 | +** resolved.)^ ^The highwater mark is always 0. |
| 6837 | 6824 | ** </dd> |
| 6838 | 6825 | ** </dl> |
| 6839 | 6826 | */ |
| 6840 | 6827 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6841 | 6828 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| | @@ -8824,11 +8811,10 @@ |
| 8824 | 8811 | |
| 8825 | 8812 | /* |
| 8826 | 8813 | ** The names of the following types declared in vdbeInt.h are required |
| 8827 | 8814 | ** for the VdbeOp definition. |
| 8828 | 8815 | */ |
| 8829 | | -typedef struct VdbeFunc VdbeFunc; |
| 8830 | 8816 | typedef struct Mem Mem; |
| 8831 | 8817 | typedef struct SubProgram SubProgram; |
| 8832 | 8818 | |
| 8833 | 8819 | /* |
| 8834 | 8820 | ** A single instruction of the virtual machine has an opcode |
| | @@ -8848,11 +8834,10 @@ |
| 8848 | 8834 | void *p; /* Generic pointer */ |
| 8849 | 8835 | char *z; /* Pointer to data for string (char array) types */ |
| 8850 | 8836 | i64 *pI64; /* Used when p4type is P4_INT64 */ |
| 8851 | 8837 | double *pReal; /* Used when p4type is P4_REAL */ |
| 8852 | 8838 | FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */ |
| 8853 | | - VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ |
| 8854 | 8839 | CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */ |
| 8855 | 8840 | Mem *pMem; /* Used when p4type is P4_MEM */ |
| 8856 | 8841 | VTable *pVtab; /* Used when p4type is P4_VTAB */ |
| 8857 | 8842 | KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ |
| 8858 | 8843 | int *ai; /* Used when p4type is P4_INTARRAY */ |
| | @@ -8902,11 +8887,10 @@ |
| 8902 | 8887 | #define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */ |
| 8903 | 8888 | #define P4_STATIC (-2) /* Pointer to a static string */ |
| 8904 | 8889 | #define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */ |
| 8905 | 8890 | #define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */ |
| 8906 | 8891 | #define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */ |
| 8907 | | -#define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */ |
| 8908 | 8892 | #define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */ |
| 8909 | 8893 | #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */ |
| 8910 | 8894 | #define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */ |
| 8911 | 8895 | #define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */ |
| 8912 | 8896 | #define P4_REAL (-12) /* P4 is a 64-bit floating point value */ |
| | @@ -9190,11 +9174,11 @@ |
| 9190 | 9174 | SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*); |
| 9191 | 9175 | SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*); |
| 9192 | 9176 | SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); |
| 9193 | 9177 | SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*); |
| 9194 | 9178 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); |
| 9195 | | -SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); |
| 9179 | +SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8); |
| 9196 | 9180 | SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int); |
| 9197 | 9181 | #ifndef SQLITE_OMIT_TRACE |
| 9198 | 9182 | SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*); |
| 9199 | 9183 | #endif |
| 9200 | 9184 | |
| | @@ -10762,10 +10746,11 @@ |
| 10762 | 10746 | char *zColAff; /* String defining the affinity of each column */ |
| 10763 | 10747 | Index *pNext; /* The next index associated with the same table */ |
| 10764 | 10748 | Schema *pSchema; /* Schema containing this index */ |
| 10765 | 10749 | u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ |
| 10766 | 10750 | char **azColl; /* Array of collation sequence names for index */ |
| 10751 | + Expr *pPartIdxWhere; /* WHERE clause for partial indices */ |
| 10767 | 10752 | int tnum; /* DB Page containing root of this index */ |
| 10768 | 10753 | u16 nColumn; /* Number of columns in table used by this index */ |
| 10769 | 10754 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 10770 | 10755 | unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */ |
| 10771 | 10756 | unsigned bUnordered:1; /* Use this index for == or IN queries only */ |
| | @@ -11242,10 +11227,11 @@ |
| 11242 | 11227 | #define NC_HasAgg 0x02 /* One or more aggregate functions seen */ |
| 11243 | 11228 | #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */ |
| 11244 | 11229 | #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */ |
| 11245 | 11230 | #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only |
| 11246 | 11231 | ** if no other resolution is available */ |
| 11232 | +#define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */ |
| 11247 | 11233 | |
| 11248 | 11234 | /* |
| 11249 | 11235 | ** An instance of the following structure contains all information |
| 11250 | 11236 | ** needed to generate code for a single SELECT statement. |
| 11251 | 11237 | ** |
| | @@ -11426,10 +11412,11 @@ |
| 11426 | 11412 | int nTab; /* Number of previously allocated VDBE cursors */ |
| 11427 | 11413 | int nMem; /* Number of memory cells used so far */ |
| 11428 | 11414 | int nSet; /* Number of sets used so far */ |
| 11429 | 11415 | int nOnce; /* Number of OP_Once instructions so far */ |
| 11430 | 11416 | int ckBase; /* Base register of data during check constraints */ |
| 11417 | + int iPartIdxTab; /* Table corresponding to a partial index */ |
| 11431 | 11418 | int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ |
| 11432 | 11419 | int iCacheCnt; /* Counter used to generate aColCache[].lru values */ |
| 11433 | 11420 | struct yColCache { |
| 11434 | 11421 | int iTable; /* Table cursor number */ |
| 11435 | 11422 | int iColumn; /* Table column number */ |
| | @@ -12007,11 +11994,11 @@ |
| 12007 | 11994 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); |
| 12008 | 11995 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
| 12009 | 11996 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); |
| 12010 | 11997 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*); |
| 12011 | 11998 | SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 12012 | | - Token*, int, int); |
| 11999 | + Expr*, int, int); |
| 12013 | 12000 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 12014 | 12001 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 12015 | 12002 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 12016 | 12003 | Expr*,ExprList*,u16,Expr*,Expr*); |
| 12017 | 12004 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| | @@ -12055,12 +12042,13 @@ |
| 12055 | 12042 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); |
| 12056 | 12043 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
| 12057 | 12044 | SQLITE_PRIVATE void sqlite3Vacuum(Parse*); |
| 12058 | 12045 | SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*); |
| 12059 | 12046 | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*); |
| 12060 | | -SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*); |
| 12061 | | -SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*); |
| 12047 | +SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int); |
| 12048 | +SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int); |
| 12049 | +SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int); |
| 12062 | 12050 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 12063 | 12051 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 12064 | 12052 | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); |
| 12065 | 12053 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| 12066 | 12054 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); |
| | @@ -12083,11 +12071,11 @@ |
| 12083 | 12071 | SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); |
| 12084 | 12072 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 12085 | 12073 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 12086 | 12074 | SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); |
| 12087 | 12075 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*); |
| 12088 | | -SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int); |
| 12076 | +SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*); |
| 12089 | 12077 | SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, |
| 12090 | 12078 | int*,int,int,int,int,int*); |
| 12091 | 12079 | SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); |
| 12092 | 12080 | SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); |
| 12093 | 12081 | SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int); |
| | @@ -12286,10 +12274,11 @@ |
| 12286 | 12274 | SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int); |
| 12287 | 12275 | SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); |
| 12288 | 12276 | SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*); |
| 12289 | 12277 | SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 12290 | 12278 | SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); |
| 12279 | +SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); |
| 12291 | 12280 | SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); |
| 12292 | 12281 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); |
| 12293 | 12282 | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); |
| 12294 | 12283 | SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); |
| 12295 | 12284 | SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); |
| | @@ -13257,10 +13246,13 @@ |
| 13257 | 13246 | typedef struct VdbeSorter VdbeSorter; |
| 13258 | 13247 | |
| 13259 | 13248 | /* Opaque type used by the explainer */ |
| 13260 | 13249 | typedef struct Explain Explain; |
| 13261 | 13250 | |
| 13251 | +/* Elements of the linked list at Vdbe.pAuxData */ |
| 13252 | +typedef struct AuxData AuxData; |
| 13253 | + |
| 13262 | 13254 | /* |
| 13263 | 13255 | ** A cursor is a pointer into a single BTree within a database file. |
| 13264 | 13256 | ** The cursor can seek to a BTree entry with a particular key, or |
| 13265 | 13257 | ** loop over all entries of the Btree. You can also insert new BTree |
| 13266 | 13258 | ** entries or retrieve the key or data from the entry that the cursor |
| | @@ -13443,27 +13435,23 @@ |
| 13443 | 13435 | */ |
| 13444 | 13436 | #ifdef SQLITE_DEBUG |
| 13445 | 13437 | #define memIsValid(M) ((M)->flags & MEM_Invalid)==0 |
| 13446 | 13438 | #endif |
| 13447 | 13439 | |
| 13448 | | - |
| 13449 | | -/* A VdbeFunc is just a FuncDef (defined in sqliteInt.h) that contains |
| 13450 | | -** additional information about auxiliary information bound to arguments |
| 13451 | | -** of the function. This is used to implement the sqlite3_get_auxdata() |
| 13452 | | -** and sqlite3_set_auxdata() APIs. The "auxdata" is some auxiliary data |
| 13453 | | -** that can be associated with a constant argument to a function. This |
| 13454 | | -** allows functions such as "regexp" to compile their constant regular |
| 13455 | | -** expression argument once and reused the compiled code for multiple |
| 13456 | | -** invocations. |
| 13440 | +/* |
| 13441 | +** Each auxilliary data pointer stored by a user defined function |
| 13442 | +** implementation calling sqlite3_set_auxdata() is stored in an instance |
| 13443 | +** of this structure. All such structures associated with a single VM |
| 13444 | +** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed |
| 13445 | +** when the VM is halted (if not before). |
| 13457 | 13446 | */ |
| 13458 | | -struct VdbeFunc { |
| 13459 | | - FuncDef *pFunc; /* The definition of the function */ |
| 13460 | | - int nAux; /* Number of entries allocated for apAux[] */ |
| 13461 | | - struct AuxData { |
| 13462 | | - void *pAux; /* Aux data for the i-th argument */ |
| 13463 | | - void (*xDelete)(void *); /* Destructor for the aux data */ |
| 13464 | | - } apAux[1]; /* One slot for each function argument */ |
| 13447 | +struct AuxData { |
| 13448 | + int iOp; /* Instruction number of OP_Function opcode */ |
| 13449 | + int iArg; /* Index of function argument. */ |
| 13450 | + void *pAux; /* Aux data pointer */ |
| 13451 | + void (*xDelete)(void *); /* Destructor for the aux data */ |
| 13452 | + AuxData *pNext; /* Next element in list */ |
| 13465 | 13453 | }; |
| 13466 | 13454 | |
| 13467 | 13455 | /* |
| 13468 | 13456 | ** The "context" argument for a installable function. A pointer to an |
| 13469 | 13457 | ** instance of this structure is the first argument to the routines used |
| | @@ -13477,16 +13465,17 @@ |
| 13477 | 13465 | ** This structure is defined inside of vdbeInt.h because it uses substructures |
| 13478 | 13466 | ** (Mem) which are only defined there. |
| 13479 | 13467 | */ |
| 13480 | 13468 | struct sqlite3_context { |
| 13481 | 13469 | FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */ |
| 13482 | | - VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */ |
| 13483 | 13470 | Mem s; /* The return value is stored here */ |
| 13484 | 13471 | Mem *pMem; /* Memory cell used to store aggregate context */ |
| 13485 | 13472 | CollSeq *pColl; /* Collating sequence */ |
| 13486 | 13473 | int isError; /* Error code returned by the function. */ |
| 13487 | 13474 | int skipFlag; /* Skip skip accumulator loading if true */ |
| 13475 | + int iOp; /* Instruction number of OP_Function */ |
| 13476 | + Vdbe *pVdbe; /* The VM that owns this context */ |
| 13488 | 13477 | }; |
| 13489 | 13478 | |
| 13490 | 13479 | /* |
| 13491 | 13480 | ** An Explain object accumulates indented output which is helpful |
| 13492 | 13481 | ** in describing recursive data structures. |
| | @@ -13581,10 +13570,11 @@ |
| 13581 | 13570 | int nFrame; /* Number of frames in pFrame list */ |
| 13582 | 13571 | u32 expmask; /* Binding to these vars invalidates VM */ |
| 13583 | 13572 | SubProgram *pProgram; /* Linked list of all sub-programs used by VM */ |
| 13584 | 13573 | int nOnceFlag; /* Size of array aOnceFlag[] */ |
| 13585 | 13574 | u8 *aOnceFlag; /* Flags for OP_Once */ |
| 13575 | + AuxData *pAuxData; /* Linked list of auxdata allocations */ |
| 13586 | 13576 | }; |
| 13587 | 13577 | |
| 13588 | 13578 | /* |
| 13589 | 13579 | ** The following are allowed values for Vdbe.magic |
| 13590 | 13580 | */ |
| | @@ -13604,11 +13594,11 @@ |
| 13604 | 13594 | #endif |
| 13605 | 13595 | SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32); |
| 13606 | 13596 | SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int); |
| 13607 | 13597 | SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int); |
| 13608 | 13598 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*); |
| 13609 | | -SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); |
| 13599 | +SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int); |
| 13610 | 13600 | |
| 13611 | 13601 | int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); |
| 13612 | 13602 | SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*); |
| 13613 | 13603 | SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *); |
| 13614 | 13604 | SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); |
| | @@ -30499,10 +30489,11 @@ |
| 30499 | 30489 | */ |
| 30500 | 30490 | #if SQLITE_OS_WIN /* This file is used for Windows only */ |
| 30501 | 30491 | |
| 30502 | 30492 | #ifdef __CYGWIN__ |
| 30503 | 30493 | # include <sys/cygwin.h> |
| 30494 | +/* # include <errno.h> */ |
| 30504 | 30495 | #endif |
| 30505 | 30496 | |
| 30506 | 30497 | /* |
| 30507 | 30498 | ** Include code that is common to all os_*.c files |
| 30508 | 30499 | */ |
| | @@ -30919,10 +30910,11 @@ |
| 30919 | 30910 | * zero for the default behavior. |
| 30920 | 30911 | */ |
| 30921 | 30912 | #ifndef SQLITE_WIN32_HEAP_FLAGS |
| 30922 | 30913 | # define SQLITE_WIN32_HEAP_FLAGS (0) |
| 30923 | 30914 | #endif |
| 30915 | + |
| 30924 | 30916 | |
| 30925 | 30917 | /* |
| 30926 | 30918 | ** The winMemData structure stores information required by the Win32-specific |
| 30927 | 30919 | ** sqlite3_mem_methods implementation. |
| 30928 | 30920 | */ |
| | @@ -34384,14 +34376,14 @@ |
| 34384 | 34376 | OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n", |
| 34385 | 34377 | osGetCurrentProcessId(), pFd)); |
| 34386 | 34378 | return SQLITE_OK; |
| 34387 | 34379 | } |
| 34388 | 34380 | assert( (nMap % winSysInfo.dwPageSize)==0 ); |
| 34389 | | -#if SQLITE_OS_WINRT |
| 34390 | | - pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap); |
| 34391 | | -#else |
| 34392 | 34381 | assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff ); |
| 34382 | +#if SQLITE_OS_WINRT |
| 34383 | + pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap); |
| 34384 | +#else |
| 34393 | 34385 | pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap); |
| 34394 | 34386 | #endif |
| 34395 | 34387 | if( pNew==NULL ){ |
| 34396 | 34388 | osCloseHandle(pFd->hMap); |
| 34397 | 34389 | pFd->hMap = NULL; |
| | @@ -34556,10 +34548,19 @@ |
| 34556 | 34548 | #endif |
| 34557 | 34549 | /* caller will handle out of memory */ |
| 34558 | 34550 | return zConverted; |
| 34559 | 34551 | } |
| 34560 | 34552 | |
| 34553 | +/* |
| 34554 | +** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is |
| 34555 | +** in characters, so we allocate 3 bytes per character assuming worst-case |
| 34556 | +** 3-bytes-per-character UTF8. |
| 34557 | +*/ |
| 34558 | +#ifndef SQLITE_WIN32_MAX_PATH |
| 34559 | +# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3) |
| 34560 | +#endif |
| 34561 | + |
| 34561 | 34562 | /* |
| 34562 | 34563 | ** Create a temporary file name in zBuf. zBuf must be big enough to |
| 34563 | 34564 | ** hold at pVfs->mxPathname characters. |
| 34564 | 34565 | */ |
| 34565 | 34566 | static int getTempname(int nBuf, char *zBuf){ |
| | @@ -34567,53 +34568,74 @@ |
| 34567 | 34568 | "abcdefghijklmnopqrstuvwxyz" |
| 34568 | 34569 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 34569 | 34570 | "0123456789"; |
| 34570 | 34571 | size_t i, j; |
| 34571 | 34572 | int nTempPath; |
| 34572 | | - char zTempPath[MAX_PATH+2]; |
| 34573 | + char zTempPath[SQLITE_WIN32_MAX_PATH+2]; |
| 34573 | 34574 | |
| 34574 | 34575 | /* It's odd to simulate an io-error here, but really this is just |
| 34575 | 34576 | ** using the io-error infrastructure to test that SQLite handles this |
| 34576 | 34577 | ** function failing. |
| 34577 | 34578 | */ |
| 34578 | 34579 | SimulateIOError( return SQLITE_IOERR ); |
| 34579 | 34580 | |
| 34580 | | - memset(zTempPath, 0, MAX_PATH+2); |
| 34581 | | - |
| 34582 | 34581 | if( sqlite3_temp_directory ){ |
| 34583 | | - sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); |
| 34582 | + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", |
| 34583 | + sqlite3_temp_directory); |
| 34584 | 34584 | } |
| 34585 | 34585 | #if !SQLITE_OS_WINRT |
| 34586 | 34586 | else if( isNT() ){ |
| 34587 | 34587 | char *zMulti; |
| 34588 | 34588 | WCHAR zWidePath[MAX_PATH]; |
| 34589 | | - osGetTempPathW(MAX_PATH-30, zWidePath); |
| 34589 | + if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){ |
| 34590 | + OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); |
| 34591 | + return SQLITE_IOERR_GETTEMPPATH; |
| 34592 | + } |
| 34590 | 34593 | zMulti = unicodeToUtf8(zWidePath); |
| 34591 | 34594 | if( zMulti ){ |
| 34592 | | - sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti); |
| 34595 | + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti); |
| 34593 | 34596 | sqlite3_free(zMulti); |
| 34594 | 34597 | }else{ |
| 34595 | 34598 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34596 | 34599 | return SQLITE_IOERR_NOMEM; |
| 34597 | 34600 | } |
| 34598 | 34601 | } |
| 34599 | 34602 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 34600 | 34603 | else{ |
| 34601 | 34604 | char *zUtf8; |
| 34602 | | - char zMbcsPath[MAX_PATH]; |
| 34603 | | - osGetTempPathA(MAX_PATH-30, zMbcsPath); |
| 34605 | + char zMbcsPath[SQLITE_WIN32_MAX_PATH]; |
| 34606 | + if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){ |
| 34607 | + OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); |
| 34608 | + return SQLITE_IOERR_GETTEMPPATH; |
| 34609 | + } |
| 34604 | 34610 | zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); |
| 34605 | 34611 | if( zUtf8 ){ |
| 34606 | | - sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8); |
| 34612 | + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8); |
| 34607 | 34613 | sqlite3_free(zUtf8); |
| 34608 | 34614 | }else{ |
| 34609 | 34615 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34610 | 34616 | return SQLITE_IOERR_NOMEM; |
| 34611 | 34617 | } |
| 34612 | 34618 | } |
| 34613 | | -#endif |
| 34614 | | -#endif |
| 34619 | +#else |
| 34620 | + else{ |
| 34621 | + /* |
| 34622 | + ** Compiled without ANSI support and the current operating system |
| 34623 | + ** is not Windows NT; therefore, just zero the temporary buffer. |
| 34624 | + */ |
| 34625 | + memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2); |
| 34626 | + } |
| 34627 | +#endif /* SQLITE_WIN32_HAS_ANSI */ |
| 34628 | +#else |
| 34629 | + else{ |
| 34630 | + /* |
| 34631 | + ** Compiled for WinRT and the sqlite3_temp_directory is not set; |
| 34632 | + ** therefore, just zero the temporary buffer. |
| 34633 | + */ |
| 34634 | + memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2); |
| 34635 | + } |
| 34636 | +#endif /* !SQLITE_OS_WINRT */ |
| 34615 | 34637 | |
| 34616 | 34638 | /* Check that the output buffer is large enough for the temporary file |
| 34617 | 34639 | ** name. If it is not, return SQLITE_ERROR. |
| 34618 | 34640 | */ |
| 34619 | 34641 | nTempPath = sqlite3Strlen30(zTempPath); |
| | @@ -34695,11 +34717,11 @@ |
| 34695 | 34717 | int cnt = 0; |
| 34696 | 34718 | |
| 34697 | 34719 | /* If argument zPath is a NULL pointer, this function is required to open |
| 34698 | 34720 | ** a temporary file. Use this buffer to store the file name in. |
| 34699 | 34721 | */ |
| 34700 | | - char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */ |
| 34722 | + char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */ |
| 34701 | 34723 | |
| 34702 | 34724 | int rc = SQLITE_OK; /* Function Return Code */ |
| 34703 | 34725 | #if !defined(NDEBUG) || SQLITE_OS_WINCE |
| 34704 | 34726 | int eType = flags&0xFFFFFF00; /* Type of file to open */ |
| 34705 | 34727 | #endif |
| | @@ -34761,12 +34783,11 @@ |
| 34761 | 34783 | /* If the second argument to this function is NULL, generate a |
| 34762 | 34784 | ** temporary file name to use |
| 34763 | 34785 | */ |
| 34764 | 34786 | if( !zUtf8Name ){ |
| 34765 | 34787 | assert(isDelete && !isOpenJournal); |
| 34766 | | - memset(zTmpname, 0, MAX_PATH+2); |
| 34767 | | - rc = getTempname(MAX_PATH+2, zTmpname); |
| 34788 | + rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname); |
| 34768 | 34789 | if( rc!=SQLITE_OK ){ |
| 34769 | 34790 | OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc))); |
| 34770 | 34791 | return rc; |
| 34771 | 34792 | } |
| 34772 | 34793 | zUtf8Name = zTmpname; |
| | @@ -35193,27 +35214,34 @@ |
| 35193 | 35214 | ){ |
| 35194 | 35215 | |
| 35195 | 35216 | #if defined(__CYGWIN__) |
| 35196 | 35217 | SimulateIOError( return SQLITE_ERROR ); |
| 35197 | 35218 | UNUSED_PARAMETER(nFull); |
| 35198 | | - assert( pVfs->mxPathname>=MAX_PATH ); |
| 35219 | + assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH ); |
| 35199 | 35220 | assert( nFull>=pVfs->mxPathname ); |
| 35200 | 35221 | if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ |
| 35201 | 35222 | /* |
| 35202 | 35223 | ** NOTE: We are dealing with a relative path name and the data |
| 35203 | 35224 | ** directory has been set. Therefore, use it as the basis |
| 35204 | 35225 | ** for converting the relative path name to an absolute |
| 35205 | 35226 | ** one by prepending the data directory and a slash. |
| 35206 | 35227 | */ |
| 35207 | | - char zOut[MAX_PATH+1]; |
| 35208 | | - memset(zOut, 0, MAX_PATH+1); |
| 35209 | | - cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, |
| 35210 | | - MAX_PATH+1); |
| 35228 | + char zOut[SQLITE_WIN32_MAX_PATH+1]; |
| 35229 | + if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, |
| 35230 | + SQLITE_WIN32_MAX_PATH+1)<0 ){ |
| 35231 | + winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", |
| 35232 | + zRelative); |
| 35233 | + return SQLITE_CANTOPEN_FULLPATH; |
| 35234 | + } |
| 35211 | 35235 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", |
| 35212 | 35236 | sqlite3_data_directory, zOut); |
| 35213 | 35237 | }else{ |
| 35214 | | - cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull); |
| 35238 | + if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ |
| 35239 | + winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", |
| 35240 | + zRelative); |
| 35241 | + return SQLITE_CANTOPEN_FULLPATH; |
| 35242 | + } |
| 35215 | 35243 | } |
| 35216 | 35244 | return SQLITE_OK; |
| 35217 | 35245 | #endif |
| 35218 | 35246 | |
| 35219 | 35247 | #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__) |
| | @@ -35551,11 +35579,11 @@ |
| 35551 | 35579 | */ |
| 35552 | 35580 | SQLITE_API int sqlite3_os_init(void){ |
| 35553 | 35581 | static sqlite3_vfs winVfs = { |
| 35554 | 35582 | 3, /* iVersion */ |
| 35555 | 35583 | sizeof(winFile), /* szOsFile */ |
| 35556 | | - MAX_PATH, /* mxPathname */ |
| 35584 | + SQLITE_WIN32_MAX_PATH, /* mxPathname */ |
| 35557 | 35585 | 0, /* pNext */ |
| 35558 | 35586 | "win32", /* zName */ |
| 35559 | 35587 | 0, /* pAppData */ |
| 35560 | 35588 | winOpen, /* xOpen */ |
| 35561 | 35589 | winDelete, /* xDelete */ |
| | @@ -60176,12 +60204,12 @@ |
| 60176 | 60204 | ** a prior call to sqlite3VdbeMakeLabel(). |
| 60177 | 60205 | */ |
| 60178 | 60206 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){ |
| 60179 | 60207 | int j = -1-x; |
| 60180 | 60208 | assert( p->magic==VDBE_MAGIC_INIT ); |
| 60181 | | - assert( j>=0 && j<p->nLabel ); |
| 60182 | | - if( p->aLabel ){ |
| 60209 | + assert( j<p->nLabel ); |
| 60210 | + if( j>=0 && p->aLabel ){ |
| 60183 | 60211 | p->aLabel[j] = p->nOp; |
| 60184 | 60212 | } |
| 60185 | 60213 | } |
| 60186 | 60214 | |
| 60187 | 60215 | /* |
| | @@ -60501,12 +60529,11 @@ |
| 60501 | 60529 | /* |
| 60502 | 60530 | ** Change the P2 operand of instruction addr so that it points to |
| 60503 | 60531 | ** the address of the next instruction to be coded. |
| 60504 | 60532 | */ |
| 60505 | 60533 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){ |
| 60506 | | - assert( addr>=0 || p->db->mallocFailed ); |
| 60507 | | - if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 60534 | + if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 60508 | 60535 | } |
| 60509 | 60536 | |
| 60510 | 60537 | |
| 60511 | 60538 | /* |
| 60512 | 60539 | ** If the input FuncDef structure is ephemeral, then free it. If |
| | @@ -60538,17 +60565,10 @@ |
| 60538 | 60565 | } |
| 60539 | 60566 | case P4_MPRINTF: { |
| 60540 | 60567 | if( db->pnBytesFreed==0 ) sqlite3_free(p4); |
| 60541 | 60568 | break; |
| 60542 | 60569 | } |
| 60543 | | - case P4_VDBEFUNC: { |
| 60544 | | - VdbeFunc *pVdbeFunc = (VdbeFunc *)p4; |
| 60545 | | - freeEphemeralFunction(db, pVdbeFunc->pFunc); |
| 60546 | | - if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0); |
| 60547 | | - sqlite3DbFree(db, pVdbeFunc); |
| 60548 | | - break; |
| 60549 | | - } |
| 60550 | 60570 | case P4_FUNCDEF: { |
| 60551 | 60571 | freeEphemeralFunction(db, (FuncDef*)p4); |
| 60552 | 60572 | break; |
| 60553 | 60573 | } |
| 60554 | 60574 | case P4_MEM: { |
| | @@ -61574,10 +61594,14 @@ |
| 61574 | 61594 | while( p->pDelFrame ){ |
| 61575 | 61595 | VdbeFrame *pDel = p->pDelFrame; |
| 61576 | 61596 | p->pDelFrame = pDel->pParent; |
| 61577 | 61597 | sqlite3VdbeFrameDelete(pDel); |
| 61578 | 61598 | } |
| 61599 | + |
| 61600 | + /* Delete any auxdata allocations made by the VM */ |
| 61601 | + sqlite3VdbeDeleteAuxData(p, -1, 0); |
| 61602 | + assert( p->pAuxData==0 ); |
| 61579 | 61603 | } |
| 61580 | 61604 | |
| 61581 | 61605 | /* |
| 61582 | 61606 | ** Clean up the VM after execution. |
| 61583 | 61607 | ** |
| | @@ -62372,24 +62396,39 @@ |
| 62372 | 62396 | sqlite3VdbeDelete(p); |
| 62373 | 62397 | return rc; |
| 62374 | 62398 | } |
| 62375 | 62399 | |
| 62376 | 62400 | /* |
| 62377 | | -** Call the destructor for each auxdata entry in pVdbeFunc for which |
| 62378 | | -** the corresponding bit in mask is clear. Auxdata entries beyond 31 |
| 62379 | | -** are always destroyed. To destroy all auxdata entries, call this |
| 62380 | | -** routine with mask==0. |
| 62401 | +** If parameter iOp is less than zero, then invoke the destructor for |
| 62402 | +** all auxiliary data pointers currently cached by the VM passed as |
| 62403 | +** the first argument. |
| 62404 | +** |
| 62405 | +** Or, if iOp is greater than or equal to zero, then the destructor is |
| 62406 | +** only invoked for those auxiliary data pointers created by the user |
| 62407 | +** function invoked by the OP_Function opcode at instruction iOp of |
| 62408 | +** VM pVdbe, and only then if: |
| 62409 | +** |
| 62410 | +** * the associated function parameter is the 32nd or later (counting |
| 62411 | +** from left to right), or |
| 62412 | +** |
| 62413 | +** * the corresponding bit in argument mask is clear (where the first |
| 62414 | +** function parameter corrsponds to bit 0 etc.). |
| 62381 | 62415 | */ |
| 62382 | | -SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){ |
| 62383 | | - int i; |
| 62384 | | - for(i=0; i<pVdbeFunc->nAux; i++){ |
| 62385 | | - struct AuxData *pAux = &pVdbeFunc->apAux[i]; |
| 62386 | | - if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){ |
| 62416 | +SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 62417 | + AuxData **pp = &pVdbe->pAuxData; |
| 62418 | + while( *pp ){ |
| 62419 | + AuxData *pAux = *pp; |
| 62420 | + if( (iOp<0) |
| 62421 | + || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg)))) |
| 62422 | + ){ |
| 62387 | 62423 | if( pAux->xDelete ){ |
| 62388 | 62424 | pAux->xDelete(pAux->pAux); |
| 62389 | 62425 | } |
| 62390 | | - pAux->pAux = 0; |
| 62426 | + *pp = pAux->pNext; |
| 62427 | + sqlite3DbFree(pVdbe->db, pAux); |
| 62428 | + }else{ |
| 62429 | + pp= &pAux->pNext; |
| 62391 | 62430 | } |
| 62392 | 62431 | } |
| 62393 | 62432 | } |
| 62394 | 62433 | |
| 62395 | 62434 | /* |
| | @@ -62904,11 +62943,11 @@ |
| 62904 | 62943 | */ |
| 62905 | 62944 | SQLITE_PRIVATE int sqlite3VdbeRecordCompare( |
| 62906 | 62945 | int nKey1, const void *pKey1, /* Left key */ |
| 62907 | 62946 | UnpackedRecord *pPKey2 /* Right key */ |
| 62908 | 62947 | ){ |
| 62909 | | - int d1; /* Offset into aKey[] of next data element */ |
| 62948 | + u32 d1; /* Offset into aKey[] of next data element */ |
| 62910 | 62949 | u32 idx1; /* Offset into aKey[] of next header element */ |
| 62911 | 62950 | u32 szHdr1; /* Number of bytes in header */ |
| 62912 | 62951 | int i = 0; |
| 62913 | 62952 | int nField; |
| 62914 | 62953 | int rc = 0; |
| | @@ -62938,11 +62977,11 @@ |
| 62938 | 62977 | while( idx1<szHdr1 && i<pPKey2->nField ){ |
| 62939 | 62978 | u32 serial_type1; |
| 62940 | 62979 | |
| 62941 | 62980 | /* Read the serial types for the next element in each key. */ |
| 62942 | 62981 | idx1 += getVarint32( aKey1+idx1, serial_type1 ); |
| 62943 | | - if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break; |
| 62982 | + if( d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 ) break; |
| 62944 | 62983 | |
| 62945 | 62984 | /* Extract the values to be compared. |
| 62946 | 62985 | */ |
| 62947 | 62986 | d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1); |
| 62948 | 62987 | |
| | @@ -63167,11 +63206,11 @@ |
| 63167 | 63206 | ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_* |
| 63168 | 63207 | ** constants) to the value before returning it. |
| 63169 | 63208 | ** |
| 63170 | 63209 | ** The returned value must be freed by the caller using sqlite3ValueFree(). |
| 63171 | 63210 | */ |
| 63172 | | -SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){ |
| 63211 | +SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ |
| 63173 | 63212 | assert( iVar>0 ); |
| 63174 | 63213 | if( v ){ |
| 63175 | 63214 | Mem *pMem = &v->aVar[iVar-1]; |
| 63176 | 63215 | if( 0==(pMem->flags & MEM_Null) ){ |
| 63177 | 63216 | sqlite3_value *pRet = sqlite3ValueNew(v->db); |
| | @@ -63784,18 +63823,18 @@ |
| 63784 | 63823 | /* |
| 63785 | 63824 | ** Return the auxilary data pointer, if any, for the iArg'th argument to |
| 63786 | 63825 | ** the user-function defined by pCtx. |
| 63787 | 63826 | */ |
| 63788 | 63827 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 63789 | | - VdbeFunc *pVdbeFunc; |
| 63828 | + AuxData *pAuxData; |
| 63790 | 63829 | |
| 63791 | 63830 | assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); |
| 63792 | | - pVdbeFunc = pCtx->pVdbeFunc; |
| 63793 | | - if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){ |
| 63794 | | - return 0; |
| 63831 | + for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 63832 | + if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 63795 | 63833 | } |
| 63796 | | - return pVdbeFunc->apAux[iArg].pAux; |
| 63834 | + |
| 63835 | + return (pAuxData ? pAuxData->pAux : 0); |
| 63797 | 63836 | } |
| 63798 | 63837 | |
| 63799 | 63838 | /* |
| 63800 | 63839 | ** Set the auxilary data pointer and delete function, for the iArg'th |
| 63801 | 63840 | ** argument to the user-function defined by pCtx. Any previous value is |
| | @@ -63805,33 +63844,30 @@ |
| 63805 | 63844 | sqlite3_context *pCtx, |
| 63806 | 63845 | int iArg, |
| 63807 | 63846 | void *pAux, |
| 63808 | 63847 | void (*xDelete)(void*) |
| 63809 | 63848 | ){ |
| 63810 | | - struct AuxData *pAuxData; |
| 63811 | | - VdbeFunc *pVdbeFunc; |
| 63812 | | - if( iArg<0 ) goto failed; |
| 63849 | + AuxData *pAuxData; |
| 63850 | + Vdbe *pVdbe = pCtx->pVdbe; |
| 63813 | 63851 | |
| 63814 | 63852 | assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); |
| 63815 | | - pVdbeFunc = pCtx->pVdbeFunc; |
| 63816 | | - if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){ |
| 63817 | | - int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0); |
| 63818 | | - int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg; |
| 63819 | | - pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc); |
| 63820 | | - if( !pVdbeFunc ){ |
| 63821 | | - goto failed; |
| 63822 | | - } |
| 63823 | | - pCtx->pVdbeFunc = pVdbeFunc; |
| 63824 | | - memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); |
| 63825 | | - pVdbeFunc->nAux = iArg+1; |
| 63826 | | - pVdbeFunc->pFunc = pCtx->pFunc; |
| 63827 | | - } |
| 63828 | | - |
| 63829 | | - pAuxData = &pVdbeFunc->apAux[iArg]; |
| 63830 | | - if( pAuxData->pAux && pAuxData->xDelete ){ |
| 63853 | + if( iArg<0 ) goto failed; |
| 63854 | + |
| 63855 | + for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 63856 | + if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 63857 | + } |
| 63858 | + if( pAuxData==0 ){ |
| 63859 | + pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData)); |
| 63860 | + if( !pAuxData ) goto failed; |
| 63861 | + pAuxData->iOp = pCtx->iOp; |
| 63862 | + pAuxData->iArg = iArg; |
| 63863 | + pAuxData->pNext = pVdbe->pAuxData; |
| 63864 | + pVdbe->pAuxData = pAuxData; |
| 63865 | + }else if( pAuxData->xDelete ){ |
| 63831 | 63866 | pAuxData->xDelete(pAuxData->pAux); |
| 63832 | 63867 | } |
| 63868 | + |
| 63833 | 63869 | pAuxData->pAux = pAux; |
| 63834 | 63870 | pAuxData->xDelete = xDelete; |
| 63835 | 63871 | return; |
| 63836 | 63872 | |
| 63837 | 63873 | failed: |
| | @@ -65439,11 +65475,11 @@ |
| 65439 | 65475 | u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ |
| 65440 | 65476 | u8 encoding = ENC(db); /* The database encoding */ |
| 65441 | 65477 | int iCompare = 0; /* Result of last OP_Compare operation */ |
| 65442 | 65478 | unsigned nVmStep = 0; /* Number of virtual machine steps */ |
| 65443 | 65479 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 65444 | | - unsigned nProgressOps = 0; /* nVmStep at last progress callback. */ |
| 65480 | + unsigned nProgressLimit; /* Invoke xProgress() when nVmStep reaches this */ |
| 65445 | 65481 | #endif |
| 65446 | 65482 | Mem *aMem = p->aMem; /* Copy of p->aMem */ |
| 65447 | 65483 | Mem *pIn1 = 0; /* 1st input operand */ |
| 65448 | 65484 | Mem *pIn2 = 0; /* 2nd input operand */ |
| 65449 | 65485 | Mem *pIn3 = 0; /* 3rd input operand */ |
| | @@ -65898,10 +65934,21 @@ |
| 65898 | 65934 | assert( p->explain==0 ); |
| 65899 | 65935 | p->pResultSet = 0; |
| 65900 | 65936 | db->busyHandler.nBusy = 0; |
| 65901 | 65937 | CHECK_FOR_INTERRUPT; |
| 65902 | 65938 | sqlite3VdbeIOTraceSql(p); |
| 65939 | +#ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 65940 | + if( db->xProgress ){ |
| 65941 | + assert( 0 < db->nProgressOps ); |
| 65942 | + nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1]; |
| 65943 | + if( nProgressLimit==0 ){ |
| 65944 | + nProgressLimit = db->nProgressOps; |
| 65945 | + }else{ |
| 65946 | + nProgressLimit %= (unsigned)db->nProgressOps; |
| 65947 | + } |
| 65948 | + } |
| 65949 | +#endif |
| 65903 | 65950 | #ifdef SQLITE_DEBUG |
| 65904 | 65951 | sqlite3BeginBenignMalloc(); |
| 65905 | 65952 | if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){ |
| 65906 | 65953 | int i; |
| 65907 | 65954 | printf("VDBE Program Listing:\n"); |
| | @@ -66058,18 +66105,20 @@ |
| 66058 | 66105 | ** of VDBE ops have been executed (either since this invocation of |
| 66059 | 66106 | ** sqlite3VdbeExec() or since last time the progress callback was called). |
| 66060 | 66107 | ** If the progress callback returns non-zero, exit the virtual machine with |
| 66061 | 66108 | ** a return code SQLITE_ABORT. |
| 66062 | 66109 | */ |
| 66063 | | - if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){ |
| 66110 | + if( db->xProgress!=0 && nVmStep>=nProgressLimit ){ |
| 66064 | 66111 | int prc; |
| 66065 | 66112 | prc = db->xProgress(db->pProgressArg); |
| 66066 | 66113 | if( prc!=0 ){ |
| 66067 | 66114 | rc = SQLITE_INTERRUPT; |
| 66068 | 66115 | goto vdbe_error_halt; |
| 66069 | 66116 | } |
| 66070 | | - nProgressOps = nVmStep; |
| 66117 | + if( db->xProgress!=0 ){ |
| 66118 | + nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps); |
| 66119 | + } |
| 66071 | 66120 | } |
| 66072 | 66121 | #endif |
| 66073 | 66122 | |
| 66074 | 66123 | break; |
| 66075 | 66124 | } |
| | @@ -66751,23 +66800,18 @@ |
| 66751 | 66800 | Deephemeralize(u.ai.pArg); |
| 66752 | 66801 | sqlite3VdbeMemStoreType(u.ai.pArg); |
| 66753 | 66802 | REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg); |
| 66754 | 66803 | } |
| 66755 | 66804 | |
| 66756 | | - assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC ); |
| 66757 | | - if( pOp->p4type==P4_FUNCDEF ){ |
| 66758 | | - u.ai.ctx.pFunc = pOp->p4.pFunc; |
| 66759 | | - u.ai.ctx.pVdbeFunc = 0; |
| 66760 | | - }else{ |
| 66761 | | - u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc; |
| 66762 | | - u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc; |
| 66763 | | - } |
| 66764 | | - |
| 66805 | + assert( pOp->p4type==P4_FUNCDEF ); |
| 66806 | + u.ai.ctx.pFunc = pOp->p4.pFunc; |
| 66765 | 66807 | u.ai.ctx.s.flags = MEM_Null; |
| 66766 | 66808 | u.ai.ctx.s.db = db; |
| 66767 | 66809 | u.ai.ctx.s.xDel = 0; |
| 66768 | 66810 | u.ai.ctx.s.zMalloc = 0; |
| 66811 | + u.ai.ctx.iOp = pc; |
| 66812 | + u.ai.ctx.pVdbe = p; |
| 66769 | 66813 | |
| 66770 | 66814 | /* The output cell may already have a buffer allocated. Move |
| 66771 | 66815 | ** the pointer to u.ai.ctx.s so in case the user-function can use |
| 66772 | 66816 | ** the already allocated buffer instead of allocating a new one. |
| 66773 | 66817 | */ |
| | @@ -66786,15 +66830,11 @@ |
| 66786 | 66830 | lastRowid = db->lastRowid; |
| 66787 | 66831 | |
| 66788 | 66832 | /* If any auxiliary data functions have been called by this user function, |
| 66789 | 66833 | ** immediately call the destructor for any non-static values. |
| 66790 | 66834 | */ |
| 66791 | | - if( u.ai.ctx.pVdbeFunc ){ |
| 66792 | | - sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1); |
| 66793 | | - pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc; |
| 66794 | | - pOp->p4type = P4_VDBEFUNC; |
| 66795 | | - } |
| 66835 | + sqlite3VdbeDeleteAuxData(p, pc, pOp->p1); |
| 66796 | 66836 | |
| 66797 | 66837 | if( db->mallocFailed ){ |
| 66798 | 66838 | /* Even though a malloc() has failed, the implementation of the |
| 66799 | 66839 | ** user function may have called an sqlite3_result_XXX() function |
| 66800 | 66840 | ** to return a value. The following call releases any resources |
| | @@ -74157,15 +74197,24 @@ |
| 74157 | 74197 | /* Translate the schema name in zDb into a pointer to the corresponding |
| 74158 | 74198 | ** schema. If not found, pSchema will remain NULL and nothing will match |
| 74159 | 74199 | ** resulting in an appropriate error message toward the end of this routine |
| 74160 | 74200 | */ |
| 74161 | 74201 | if( zDb ){ |
| 74162 | | - for(i=0; i<db->nDb; i++){ |
| 74163 | | - assert( db->aDb[i].zName ); |
| 74164 | | - if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){ |
| 74165 | | - pSchema = db->aDb[i].pSchema; |
| 74166 | | - break; |
| 74202 | + testcase( pNC->ncFlags & NC_PartIdx ); |
| 74203 | + testcase( pNC->ncFlags & NC_IsCheck ); |
| 74204 | + if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){ |
| 74205 | + /* Silently ignore database qualifiers inside CHECK constraints and partial |
| 74206 | + ** indices. Do not raise errors because that might break legacy and |
| 74207 | + ** because it does not hurt anything to just ignore the database name. */ |
| 74208 | + zDb = 0; |
| 74209 | + }else{ |
| 74210 | + for(i=0; i<db->nDb; i++){ |
| 74211 | + assert( db->aDb[i].zName ); |
| 74212 | + if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){ |
| 74213 | + pSchema = db->aDb[i].pSchema; |
| 74214 | + break; |
| 74215 | + } |
| 74167 | 74216 | } |
| 74168 | 74217 | } |
| 74169 | 74218 | } |
| 74170 | 74219 | |
| 74171 | 74220 | /* Start at the inner-most context and move outward until a match is found */ |
| | @@ -74438,10 +74487,43 @@ |
| 74438 | 74487 | } |
| 74439 | 74488 | ExprSetProperty(p, EP_Resolved); |
| 74440 | 74489 | } |
| 74441 | 74490 | return p; |
| 74442 | 74491 | } |
| 74492 | + |
| 74493 | +/* |
| 74494 | +** Report an error that an expression is not valid for a partial index WHERE |
| 74495 | +** clause. |
| 74496 | +*/ |
| 74497 | +static void notValidPartIdxWhere( |
| 74498 | + Parse *pParse, /* Leave error message here */ |
| 74499 | + NameContext *pNC, /* The name context */ |
| 74500 | + const char *zMsg /* Type of error */ |
| 74501 | +){ |
| 74502 | + if( (pNC->ncFlags & NC_PartIdx)!=0 ){ |
| 74503 | + sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses", |
| 74504 | + zMsg); |
| 74505 | + } |
| 74506 | +} |
| 74507 | + |
| 74508 | +#ifndef SQLITE_OMIT_CHECK |
| 74509 | +/* |
| 74510 | +** Report an error that an expression is not valid for a CHECK constraint. |
| 74511 | +*/ |
| 74512 | +static void notValidCheckConstraint( |
| 74513 | + Parse *pParse, /* Leave error message here */ |
| 74514 | + NameContext *pNC, /* The name context */ |
| 74515 | + const char *zMsg /* Type of error */ |
| 74516 | +){ |
| 74517 | + if( (pNC->ncFlags & NC_IsCheck)!=0 ){ |
| 74518 | + sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg); |
| 74519 | + } |
| 74520 | +} |
| 74521 | +#else |
| 74522 | +# define notValidCheckConstraint(P,N,M) |
| 74523 | +#endif |
| 74524 | + |
| 74443 | 74525 | |
| 74444 | 74526 | /* |
| 74445 | 74527 | ** This routine is callback for sqlite3WalkExpr(). |
| 74446 | 74528 | ** |
| 74447 | 74529 | ** Resolve symbolic names into TK_COLUMN operators for the current |
| | @@ -74538,10 +74620,11 @@ |
| 74538 | 74620 | FuncDef *pDef; /* Information about the function */ |
| 74539 | 74621 | u8 enc = ENC(pParse->db); /* The database encoding */ |
| 74540 | 74622 | |
| 74541 | 74623 | testcase( pExpr->op==TK_CONST_FUNC ); |
| 74542 | 74624 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 74625 | + notValidPartIdxWhere(pParse, pNC, "functions"); |
| 74543 | 74626 | zId = pExpr->u.zToken; |
| 74544 | 74627 | nId = sqlite3Strlen30(zId); |
| 74545 | 74628 | pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0); |
| 74546 | 74629 | if( pDef==0 ){ |
| 74547 | 74630 | pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0); |
| | @@ -74603,31 +74686,25 @@ |
| 74603 | 74686 | #endif |
| 74604 | 74687 | case TK_IN: { |
| 74605 | 74688 | testcase( pExpr->op==TK_IN ); |
| 74606 | 74689 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 74607 | 74690 | int nRef = pNC->nRef; |
| 74608 | | -#ifndef SQLITE_OMIT_CHECK |
| 74609 | | - if( (pNC->ncFlags & NC_IsCheck)!=0 ){ |
| 74610 | | - sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints"); |
| 74611 | | - } |
| 74612 | | -#endif |
| 74691 | + notValidCheckConstraint(pParse, pNC, "subqueries"); |
| 74692 | + notValidPartIdxWhere(pParse, pNC, "subqueries"); |
| 74613 | 74693 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 74614 | 74694 | assert( pNC->nRef>=nRef ); |
| 74615 | 74695 | if( nRef!=pNC->nRef ){ |
| 74616 | 74696 | ExprSetProperty(pExpr, EP_VarSelect); |
| 74617 | 74697 | } |
| 74618 | 74698 | } |
| 74619 | 74699 | break; |
| 74620 | 74700 | } |
| 74621 | | -#ifndef SQLITE_OMIT_CHECK |
| 74622 | 74701 | case TK_VARIABLE: { |
| 74623 | | - if( (pNC->ncFlags & NC_IsCheck)!=0 ){ |
| 74624 | | - sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints"); |
| 74625 | | - } |
| 74702 | + notValidCheckConstraint(pParse, pNC, "parameters"); |
| 74703 | + notValidPartIdxWhere(pParse, pNC, "parameters"); |
| 74626 | 74704 | break; |
| 74627 | 74705 | } |
| 74628 | | -#endif |
| 74629 | 74706 | } |
| 74630 | 74707 | return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue; |
| 74631 | 74708 | } |
| 74632 | 74709 | |
| 74633 | 74710 | /* |
| | @@ -74714,11 +74791,11 @@ |
| 74714 | 74791 | /* Try to match the ORDER BY expression against an expression |
| 74715 | 74792 | ** in the result set. Return an 1-based index of the matching |
| 74716 | 74793 | ** result-set entry. |
| 74717 | 74794 | */ |
| 74718 | 74795 | for(i=0; i<pEList->nExpr; i++){ |
| 74719 | | - if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){ |
| 74796 | + if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){ |
| 74720 | 74797 | return i+1; |
| 74721 | 74798 | } |
| 74722 | 74799 | } |
| 74723 | 74800 | |
| 74724 | 74801 | /* If no match, return 0. */ |
| | @@ -74942,11 +75019,11 @@ |
| 74942 | 75019 | pItem->iOrderByCol = 0; |
| 74943 | 75020 | if( sqlite3ResolveExprNames(pNC, pE) ){ |
| 74944 | 75021 | return 1; |
| 74945 | 75022 | } |
| 74946 | 75023 | for(j=0; j<pSelect->pEList->nExpr; j++){ |
| 74947 | | - if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){ |
| 75024 | + if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){ |
| 74948 | 75025 | pItem->iOrderByCol = j+1; |
| 74949 | 75026 | } |
| 74950 | 75027 | } |
| 74951 | 75028 | } |
| 74952 | 75029 | return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType); |
| | @@ -75248,10 +75325,52 @@ |
| 75248 | 75325 | w.xSelectCallback = resolveSelectStep; |
| 75249 | 75326 | w.pParse = pParse; |
| 75250 | 75327 | w.u.pNC = pOuterNC; |
| 75251 | 75328 | sqlite3WalkSelect(&w, p); |
| 75252 | 75329 | } |
| 75330 | + |
| 75331 | +/* |
| 75332 | +** Resolve names in expressions that can only reference a single table: |
| 75333 | +** |
| 75334 | +** * CHECK constraints |
| 75335 | +** * WHERE clauses on partial indices |
| 75336 | +** |
| 75337 | +** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression |
| 75338 | +** is set to -1 and the Expr.iColumn value is set to the column number. |
| 75339 | +** |
| 75340 | +** Any errors cause an error message to be set in pParse. |
| 75341 | +*/ |
| 75342 | +SQLITE_PRIVATE void sqlite3ResolveSelfReference( |
| 75343 | + Parse *pParse, /* Parsing context */ |
| 75344 | + Table *pTab, /* The table being referenced */ |
| 75345 | + int type, /* NC_IsCheck or NC_PartIdx */ |
| 75346 | + Expr *pExpr, /* Expression to resolve. May be NULL. */ |
| 75347 | + ExprList *pList /* Expression list to resolve. May be NUL. */ |
| 75348 | +){ |
| 75349 | + SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ |
| 75350 | + NameContext sNC; /* Name context for pParse->pNewTable */ |
| 75351 | + int i; /* Loop counter */ |
| 75352 | + |
| 75353 | + assert( type==NC_IsCheck || type==NC_PartIdx ); |
| 75354 | + memset(&sNC, 0, sizeof(sNC)); |
| 75355 | + memset(&sSrc, 0, sizeof(sSrc)); |
| 75356 | + sSrc.nSrc = 1; |
| 75357 | + sSrc.a[0].zName = pTab->zName; |
| 75358 | + sSrc.a[0].pTab = pTab; |
| 75359 | + sSrc.a[0].iCursor = -1; |
| 75360 | + sNC.pParse = pParse; |
| 75361 | + sNC.pSrcList = &sSrc; |
| 75362 | + sNC.ncFlags = type; |
| 75363 | + if( sqlite3ResolveExprNames(&sNC, pExpr) ) return; |
| 75364 | + if( pList ){ |
| 75365 | + for(i=0; i<pList->nExpr; i++){ |
| 75366 | + if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){ |
| 75367 | + return; |
| 75368 | + } |
| 75369 | + } |
| 75370 | + } |
| 75371 | +} |
| 75253 | 75372 | |
| 75254 | 75373 | /************** End of resolve.c *********************************************/ |
| 75255 | 75374 | /************** Begin file expr.c ********************************************/ |
| 75256 | 75375 | /* |
| 75257 | 75376 | ** 2001 September 15 |
| | @@ -77614,19 +77733,24 @@ |
| 77614 | 77733 | break; |
| 77615 | 77734 | } |
| 77616 | 77735 | /* Otherwise, fall thru into the TK_COLUMN case */ |
| 77617 | 77736 | } |
| 77618 | 77737 | case TK_COLUMN: { |
| 77619 | | - if( pExpr->iTable<0 ){ |
| 77620 | | - /* This only happens when coding check constraints */ |
| 77621 | | - assert( pParse->ckBase>0 ); |
| 77622 | | - inReg = pExpr->iColumn + pParse->ckBase; |
| 77623 | | - }else{ |
| 77624 | | - inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 77625 | | - pExpr->iColumn, pExpr->iTable, target, |
| 77626 | | - pExpr->op2); |
| 77627 | | - } |
| 77738 | + int iTab = pExpr->iTable; |
| 77739 | + if( iTab<0 ){ |
| 77740 | + if( pParse->ckBase>0 ){ |
| 77741 | + /* Generating CHECK constraints or inserting into partial index */ |
| 77742 | + inReg = pExpr->iColumn + pParse->ckBase; |
| 77743 | + break; |
| 77744 | + }else{ |
| 77745 | + /* Deleting from a partial index */ |
| 77746 | + iTab = pParse->iPartIdxTab; |
| 77747 | + } |
| 77748 | + } |
| 77749 | + inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 77750 | + pExpr->iColumn, iTab, target, |
| 77751 | + pExpr->op2); |
| 77628 | 77752 | break; |
| 77629 | 77753 | } |
| 77630 | 77754 | case TK_INTEGER: { |
| 77631 | 77755 | codeInteger(pParse, pExpr, 0, target); |
| 77632 | 77756 | break; |
| | @@ -79045,10 +79169,16 @@ |
| 79045 | 79169 | ** Do a deep comparison of two expression trees. Return 0 if the two |
| 79046 | 79170 | ** expressions are completely identical. Return 1 if they differ only |
| 79047 | 79171 | ** by a COLLATE operator at the top level. Return 2 if there are differences |
| 79048 | 79172 | ** other than the top-level COLLATE operator. |
| 79049 | 79173 | ** |
| 79174 | +** If any subelement of pB has Expr.iTable==(-1) then it is allowed |
| 79175 | +** to compare equal to an equivalent element in pA with Expr.iTable==iTab. |
| 79176 | +** |
| 79177 | +** The pA side might be using TK_REGISTER. If that is the case and pB is |
| 79178 | +** not using TK_REGISTER but is otherwise equivalent, then still return 0. |
| 79179 | +** |
| 79050 | 79180 | ** Sometimes this routine will return 2 even if the two expressions |
| 79051 | 79181 | ** really are equivalent. If we cannot prove that the expressions are |
| 79052 | 79182 | ** identical, we return 2 just to be safe. So if this routine |
| 79053 | 79183 | ** returns 2, then you do not really know for certain if the two |
| 79054 | 79184 | ** expressions are the same. But if you get a 0 or 1 return, then you |
| | @@ -79055,33 +79185,36 @@ |
| 79055 | 79185 | ** can be sure the expressions are the same. In the places where |
| 79056 | 79186 | ** this routine is used, it does not hurt to get an extra 2 - that |
| 79057 | 79187 | ** just might result in some slightly slower code. But returning |
| 79058 | 79188 | ** an incorrect 0 or 1 could lead to a malfunction. |
| 79059 | 79189 | */ |
| 79060 | | -SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){ |
| 79190 | +SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){ |
| 79061 | 79191 | if( pA==0||pB==0 ){ |
| 79062 | 79192 | return pB==pA ? 0 : 2; |
| 79063 | 79193 | } |
| 79064 | 79194 | assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) ); |
| 79065 | 79195 | assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) ); |
| 79066 | 79196 | if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){ |
| 79067 | 79197 | return 2; |
| 79068 | 79198 | } |
| 79069 | 79199 | if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2; |
| 79070 | | - if( pA->op!=pB->op ){ |
| 79071 | | - if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){ |
| 79200 | + if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){ |
| 79201 | + if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){ |
| 79072 | 79202 | return 1; |
| 79073 | 79203 | } |
| 79074 | | - if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){ |
| 79204 | + if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){ |
| 79075 | 79205 | return 1; |
| 79076 | 79206 | } |
| 79077 | 79207 | return 2; |
| 79078 | 79208 | } |
| 79079 | | - if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2; |
| 79080 | | - if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2; |
| 79081 | | - if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2; |
| 79082 | | - if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2; |
| 79209 | + if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2; |
| 79210 | + if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2; |
| 79211 | + if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2; |
| 79212 | + if( pA->iColumn!=pB->iColumn ) return 2; |
| 79213 | + if( pA->iTable!=pB->iTable |
| 79214 | + && pA->op!=TK_REGISTER |
| 79215 | + && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2; |
| 79083 | 79216 | if( ExprHasProperty(pA, EP_IntValue) ){ |
| 79084 | 79217 | if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){ |
| 79085 | 79218 | return 2; |
| 79086 | 79219 | } |
| 79087 | 79220 | }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){ |
| | @@ -79095,28 +79228,70 @@ |
| 79095 | 79228 | |
| 79096 | 79229 | /* |
| 79097 | 79230 | ** Compare two ExprList objects. Return 0 if they are identical and |
| 79098 | 79231 | ** non-zero if they differ in any way. |
| 79099 | 79232 | ** |
| 79233 | +** If any subelement of pB has Expr.iTable==(-1) then it is allowed |
| 79234 | +** to compare equal to an equivalent element in pA with Expr.iTable==iTab. |
| 79235 | +** |
| 79100 | 79236 | ** This routine might return non-zero for equivalent ExprLists. The |
| 79101 | 79237 | ** only consequence will be disabled optimizations. But this routine |
| 79102 | 79238 | ** must never return 0 if the two ExprList objects are different, or |
| 79103 | 79239 | ** a malfunction will result. |
| 79104 | 79240 | ** |
| 79105 | 79241 | ** Two NULL pointers are considered to be the same. But a NULL pointer |
| 79106 | 79242 | ** always differs from a non-NULL pointer. |
| 79107 | 79243 | */ |
| 79108 | | -SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){ |
| 79244 | +SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){ |
| 79109 | 79245 | int i; |
| 79110 | 79246 | if( pA==0 && pB==0 ) return 0; |
| 79111 | 79247 | if( pA==0 || pB==0 ) return 1; |
| 79112 | 79248 | if( pA->nExpr!=pB->nExpr ) return 1; |
| 79113 | 79249 | for(i=0; i<pA->nExpr; i++){ |
| 79114 | 79250 | Expr *pExprA = pA->a[i].pExpr; |
| 79115 | 79251 | Expr *pExprB = pB->a[i].pExpr; |
| 79116 | 79252 | if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1; |
| 79117 | | - if( sqlite3ExprCompare(pExprA, pExprB) ) return 1; |
| 79253 | + if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1; |
| 79254 | + } |
| 79255 | + return 0; |
| 79256 | +} |
| 79257 | + |
| 79258 | +/* |
| 79259 | +** Return true if we can prove the pE2 will always be true if pE1 is |
| 79260 | +** true. Return false if we cannot complete the proof or if pE2 might |
| 79261 | +** be false. Examples: |
| 79262 | +** |
| 79263 | +** pE1: x==5 pE2: x==5 Result: true |
| 79264 | +** pE1: x>0 pE2: x==5 Result: false |
| 79265 | +** pE1: x=21 pE2: x=21 OR y=43 Result: true |
| 79266 | +** pE1: x!=123 pE2: x IS NOT NULL Result: true |
| 79267 | +** pE1: x!=?1 pE2: x IS NOT NULL Result: true |
| 79268 | +** pE1: x IS NULL pE2: x IS NOT NULL Result: false |
| 79269 | +** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false |
| 79270 | +** |
| 79271 | +** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has |
| 79272 | +** Expr.iTable<0 then assume a table number given by iTab. |
| 79273 | +** |
| 79274 | +** When in doubt, return false. Returning true might give a performance |
| 79275 | +** improvement. Returning false might cause a performance reduction, but |
| 79276 | +** it will always give the correct answer and is hence always safe. |
| 79277 | +*/ |
| 79278 | +SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){ |
| 79279 | + if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){ |
| 79280 | + return 1; |
| 79281 | + } |
| 79282 | + if( pE2->op==TK_OR |
| 79283 | + && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab) |
| 79284 | + || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) ) |
| 79285 | + ){ |
| 79286 | + return 1; |
| 79287 | + } |
| 79288 | + if( pE2->op==TK_NOTNULL |
| 79289 | + && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0 |
| 79290 | + && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS) |
| 79291 | + ){ |
| 79292 | + return 1; |
| 79118 | 79293 | } |
| 79119 | 79294 | return 0; |
| 79120 | 79295 | } |
| 79121 | 79296 | |
| 79122 | 79297 | /* |
| | @@ -79297,11 +79472,11 @@ |
| 79297 | 79472 | /* Check to see if pExpr is a duplicate of another aggregate |
| 79298 | 79473 | ** function that is already in the pAggInfo structure |
| 79299 | 79474 | */ |
| 79300 | 79475 | struct AggInfo_func *pItem = pAggInfo->aFunc; |
| 79301 | 79476 | for(i=0; i<pAggInfo->nFunc; i++, pItem++){ |
| 79302 | | - if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){ |
| 79477 | + if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){ |
| 79303 | 79478 | break; |
| 79304 | 79479 | } |
| 79305 | 79480 | } |
| 79306 | 79481 | if( i>=pAggInfo->nFunc ){ |
| 79307 | 79482 | /* pExpr is original. Make a new entry in pAggInfo->aFunc[] |
| | @@ -80714,10 +80889,11 @@ |
| 80714 | 80889 | int i; /* Loop counter */ |
| 80715 | 80890 | int topOfLoop; /* The top of the loop */ |
| 80716 | 80891 | int endOfLoop; /* The end of the loop */ |
| 80717 | 80892 | int jZeroRows = -1; /* Jump from here if number of rows is zero */ |
| 80718 | 80893 | int iDb; /* Index of database containing pTab */ |
| 80894 | + u8 needTableCnt = 1; /* True to count the table */ |
| 80719 | 80895 | int regTabname = iMem++; /* Register containing table name */ |
| 80720 | 80896 | int regIdxname = iMem++; /* Register containing index name */ |
| 80721 | 80897 | int regStat1 = iMem++; /* The stat column of sqlite_stat1 */ |
| 80722 | 80898 | #ifdef SQLITE_ENABLE_STAT3 |
| 80723 | 80899 | int regNumEq = regStat1; /* Number of instances. Same as regStat1 */ |
| | @@ -80773,10 +80949,11 @@ |
| 80773 | 80949 | KeyInfo *pKey; |
| 80774 | 80950 | int addrIfNot = 0; /* address of OP_IfNot */ |
| 80775 | 80951 | int *aChngAddr; /* Array of jump instruction addresses */ |
| 80776 | 80952 | |
| 80777 | 80953 | if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; |
| 80954 | + if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0; |
| 80778 | 80955 | VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName)); |
| 80779 | 80956 | nCol = pIdx->nColumn; |
| 80780 | 80957 | aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol); |
| 80781 | 80958 | if( aChngAddr==0 ) continue; |
| 80782 | 80959 | pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| | @@ -80932,48 +81109,45 @@ |
| 80932 | 81109 | ** If K==0 then no entry is made into the sqlite_stat1 table. |
| 80933 | 81110 | ** If K>0 then it is always the case the D>0 so division by zero |
| 80934 | 81111 | ** is never possible. |
| 80935 | 81112 | */ |
| 80936 | 81113 | sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1); |
| 80937 | | - if( jZeroRows<0 ){ |
| 80938 | | - jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); |
| 80939 | | - } |
| 81114 | + jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); |
| 80940 | 81115 | for(i=0; i<nCol; i++){ |
| 80941 | 81116 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0); |
| 80942 | 81117 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); |
| 80943 | 81118 | sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp); |
| 80944 | 81119 | sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); |
| 80945 | 81120 | sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp); |
| 80946 | 81121 | sqlite3VdbeAddOp1(v, OP_ToInt, regTemp); |
| 80947 | 81122 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); |
| 80948 | 81123 | } |
| 81124 | + if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows); |
| 80949 | 81125 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 80950 | 81126 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 80951 | 81127 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 80952 | 81128 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 81129 | + if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows); |
| 80953 | 81130 | } |
| 80954 | 81131 | |
| 80955 | | - /* If the table has no indices, create a single sqlite_stat1 entry |
| 80956 | | - ** containing NULL as the index name and the row count as the content. |
| 81132 | + /* Create a single sqlite_stat1 entry containing NULL as the index |
| 81133 | + ** name and the row count as the content. |
| 80957 | 81134 | */ |
| 80958 | | - if( pTab->pIndex==0 ){ |
| 81135 | + if( pOnlyIdx==0 && needTableCnt ){ |
| 80959 | 81136 | sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb); |
| 80960 | 81137 | VdbeComment((v, "%s", pTab->zName)); |
| 80961 | 81138 | sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1); |
| 80962 | 81139 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 80963 | 81140 | jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); |
| 80964 | | - }else{ |
| 80965 | | - sqlite3VdbeJumpHere(v, jZeroRows); |
| 80966 | | - jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto); |
| 80967 | | - } |
| 80968 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); |
| 80969 | | - sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 80970 | | - sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 80971 | | - sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 80972 | | - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 80973 | | - if( pParse->nMem<regRec ) pParse->nMem = regRec; |
| 80974 | | - sqlite3VdbeJumpHere(v, jZeroRows); |
| 81141 | + sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); |
| 81142 | + sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 81143 | + sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 81144 | + sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 81145 | + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 81146 | + sqlite3VdbeJumpHere(v, jZeroRows); |
| 81147 | + } |
| 81148 | + if( pParse->nMem<regRec ) pParse->nMem = regRec; |
| 80975 | 81149 | } |
| 80976 | 81150 | |
| 80977 | 81151 | |
| 80978 | 81152 | /* |
| 80979 | 81153 | ** Generate code that will cause the most recent index analysis to |
| | @@ -81152,12 +81326,14 @@ |
| 81152 | 81326 | v = 0; |
| 81153 | 81327 | while( (c=z[0])>='0' && c<='9' ){ |
| 81154 | 81328 | v = v*10 + c - '0'; |
| 81155 | 81329 | z++; |
| 81156 | 81330 | } |
| 81157 | | - if( i==0 ) pTable->nRowEst = v; |
| 81158 | | - if( pIndex==0 ) break; |
| 81331 | + if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){ |
| 81332 | + if( v>0 ) pTable->nRowEst = v; |
| 81333 | + if( pIndex==0 ) break; |
| 81334 | + } |
| 81159 | 81335 | pIndex->aiRowEst[i] = v; |
| 81160 | 81336 | if( *z==' ' ) z++; |
| 81161 | 81337 | if( strcmp(z, "unordered")==0 ){ |
| 81162 | 81338 | pIndex->bUnordered = 1; |
| 81163 | 81339 | break; |
| | @@ -82593,10 +82769,11 @@ |
| 82593 | 82769 | */ |
| 82594 | 82770 | static void freeIndex(sqlite3 *db, Index *p){ |
| 82595 | 82771 | #ifndef SQLITE_OMIT_ANALYZE |
| 82596 | 82772 | sqlite3DeleteIndexSamples(db, p); |
| 82597 | 82773 | #endif |
| 82774 | + sqlite3ExprDelete(db, p->pPartIdxWhere); |
| 82598 | 82775 | sqlite3DbFree(db, p->zColAff); |
| 82599 | 82776 | sqlite3DbFree(db, p); |
| 82600 | 82777 | } |
| 82601 | 82778 | |
| 82602 | 82779 | /* |
| | @@ -83436,11 +83613,12 @@ |
| 83436 | 83613 | sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " |
| 83437 | 83614 | "INTEGER PRIMARY KEY"); |
| 83438 | 83615 | #endif |
| 83439 | 83616 | }else{ |
| 83440 | 83617 | Index *p; |
| 83441 | | - p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0); |
| 83618 | + p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, |
| 83619 | + 0, sortOrder, 0); |
| 83442 | 83620 | if( p ){ |
| 83443 | 83621 | p->autoIndex = 2; |
| 83444 | 83622 | } |
| 83445 | 83623 | pList = 0; |
| 83446 | 83624 | } |
| | @@ -83731,30 +83909,11 @@ |
| 83731 | 83909 | |
| 83732 | 83910 | #ifndef SQLITE_OMIT_CHECK |
| 83733 | 83911 | /* Resolve names in all CHECK constraint expressions. |
| 83734 | 83912 | */ |
| 83735 | 83913 | if( p->pCheck ){ |
| 83736 | | - SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ |
| 83737 | | - NameContext sNC; /* Name context for pParse->pNewTable */ |
| 83738 | | - ExprList *pList; /* List of all CHECK constraints */ |
| 83739 | | - int i; /* Loop counter */ |
| 83740 | | - |
| 83741 | | - memset(&sNC, 0, sizeof(sNC)); |
| 83742 | | - memset(&sSrc, 0, sizeof(sSrc)); |
| 83743 | | - sSrc.nSrc = 1; |
| 83744 | | - sSrc.a[0].zName = p->zName; |
| 83745 | | - sSrc.a[0].pTab = p; |
| 83746 | | - sSrc.a[0].iCursor = -1; |
| 83747 | | - sNC.pParse = pParse; |
| 83748 | | - sNC.pSrcList = &sSrc; |
| 83749 | | - sNC.ncFlags = NC_IsCheck; |
| 83750 | | - pList = p->pCheck; |
| 83751 | | - for(i=0; i<pList->nExpr; i++){ |
| 83752 | | - if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){ |
| 83753 | | - return; |
| 83754 | | - } |
| 83755 | | - } |
| 83914 | + sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck); |
| 83756 | 83915 | } |
| 83757 | 83916 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 83758 | 83917 | |
| 83759 | 83918 | /* If the db->init.busy is 1 it means we are reading the SQL off the |
| 83760 | 83919 | ** "sqlite_master" or "sqlite_temp_master" table on the disk. |
| | @@ -84602,10 +84761,11 @@ |
| 84602 | 84761 | int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */ |
| 84603 | 84762 | int iSorter; /* Cursor opened by OpenSorter (if in use) */ |
| 84604 | 84763 | int addr1; /* Address of top of loop */ |
| 84605 | 84764 | int addr2; /* Address to jump to for next iteration */ |
| 84606 | 84765 | int tnum; /* Root page of index */ |
| 84766 | + int iPartIdxLabel; /* Jump to this label to skip a row */ |
| 84607 | 84767 | Vdbe *v; /* Generate code into this virtual machine */ |
| 84608 | 84768 | KeyInfo *pKey; /* KeyInfo for index */ |
| 84609 | 84769 | int regRecord; /* Register holding assemblied index record */ |
| 84610 | 84770 | sqlite3 *db = pParse->db; /* The database connection */ |
| 84611 | 84771 | int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema); |
| | @@ -84641,12 +84801,13 @@ |
| 84641 | 84801 | ** records into the sorter. */ |
| 84642 | 84802 | sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); |
| 84643 | 84803 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); |
| 84644 | 84804 | regRecord = sqlite3GetTempReg(pParse); |
| 84645 | 84805 | |
| 84646 | | - sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); |
| 84806 | + sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel); |
| 84647 | 84807 | sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord); |
| 84808 | + sqlite3VdbeResolveLabel(v, iPartIdxLabel); |
| 84648 | 84809 | sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); |
| 84649 | 84810 | sqlite3VdbeJumpHere(v, addr1); |
| 84650 | 84811 | addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); |
| 84651 | 84812 | if( pIndex->onError!=OE_None ){ |
| 84652 | 84813 | int j2 = sqlite3VdbeCurrentAddr(v) + 3; |
| | @@ -84693,11 +84854,11 @@ |
| 84693 | 84854 | Token *pName2, /* Second part of index name. May be NULL */ |
| 84694 | 84855 | SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */ |
| 84695 | 84856 | ExprList *pList, /* A list of columns to be indexed */ |
| 84696 | 84857 | int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 84697 | 84858 | Token *pStart, /* The CREATE token that begins this statement */ |
| 84698 | | - Token *pEnd, /* The ")" that closes the CREATE INDEX statement */ |
| 84859 | + Expr *pPIWhere, /* WHERE clause for partial indices */ |
| 84699 | 84860 | int sortOrder, /* Sort order of primary key when pList==NULL */ |
| 84700 | 84861 | int ifNotExist /* Omit error if index already exists */ |
| 84701 | 84862 | ){ |
| 84702 | 84863 | Index *pRet = 0; /* Pointer to return */ |
| 84703 | 84864 | Table *pTab = 0; /* Table to be indexed */ |
| | @@ -84715,11 +84876,10 @@ |
| 84715 | 84876 | struct ExprList_item *pListItem; /* For looping over pList */ |
| 84716 | 84877 | int nCol; |
| 84717 | 84878 | int nExtra = 0; |
| 84718 | 84879 | char *zExtra; |
| 84719 | 84880 | |
| 84720 | | - assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */ |
| 84721 | 84881 | assert( pParse->nErr==0 ); /* Never called with prior errors */ |
| 84722 | 84882 | if( db->mallocFailed || IN_DECLARE_VTAB ){ |
| 84723 | 84883 | goto exit_create_index; |
| 84724 | 84884 | } |
| 84725 | 84885 | if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ |
| | @@ -84761,11 +84921,16 @@ |
| 84761 | 84921 | assert(0); |
| 84762 | 84922 | } |
| 84763 | 84923 | pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]); |
| 84764 | 84924 | assert( db->mallocFailed==0 || pTab==0 ); |
| 84765 | 84925 | if( pTab==0 ) goto exit_create_index; |
| 84766 | | - assert( db->aDb[iDb].pSchema==pTab->pSchema ); |
| 84926 | + if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){ |
| 84927 | + sqlite3ErrorMsg(pParse, |
| 84928 | + "cannot create a TEMP index on non-TEMP table \"%s\"", |
| 84929 | + pTab->zName); |
| 84930 | + goto exit_create_index; |
| 84931 | + } |
| 84767 | 84932 | }else{ |
| 84768 | 84933 | assert( pName==0 ); |
| 84769 | 84934 | assert( pStart==0 ); |
| 84770 | 84935 | pTab = pParse->pNewTable; |
| 84771 | 84936 | if( !pTab ) goto exit_create_index; |
| | @@ -84910,10 +85075,15 @@ |
| 84910 | 85075 | pIndex->nColumn = pList->nExpr; |
| 84911 | 85076 | pIndex->onError = (u8)onError; |
| 84912 | 85077 | pIndex->uniqNotNull = onError==OE_Abort; |
| 84913 | 85078 | pIndex->autoIndex = (u8)(pName==0); |
| 84914 | 85079 | pIndex->pSchema = db->aDb[iDb].pSchema; |
| 85080 | + if( pPIWhere ){ |
| 85081 | + sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0); |
| 85082 | + pIndex->pPartIdxWhere = pPIWhere; |
| 85083 | + pPIWhere = 0; |
| 85084 | + } |
| 84915 | 85085 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 84916 | 85086 | |
| 84917 | 85087 | /* Check to see if we should honor DESC requests on index columns |
| 84918 | 85088 | */ |
| 84919 | 85089 | if( pDb->pSchema->file_format>=4 ){ |
| | @@ -85065,11 +85235,11 @@ |
| 85065 | 85235 | ** If pTblName==0 it means this index is generated as a primary key |
| 85066 | 85236 | ** or UNIQUE constraint of a CREATE TABLE statement. Since the table |
| 85067 | 85237 | ** has just been created, it contains no data and the index initialization |
| 85068 | 85238 | ** step can be skipped. |
| 85069 | 85239 | */ |
| 85070 | | - else{ /* if( db->init.busy==0 ) */ |
| 85240 | + else if( pParse->nErr==0 ){ |
| 85071 | 85241 | Vdbe *v; |
| 85072 | 85242 | char *zStmt; |
| 85073 | 85243 | int iMem = ++pParse->nMem; |
| 85074 | 85244 | |
| 85075 | 85245 | v = sqlite3GetVdbe(pParse); |
| | @@ -85083,16 +85253,15 @@ |
| 85083 | 85253 | |
| 85084 | 85254 | /* Gather the complete text of the CREATE INDEX statement into |
| 85085 | 85255 | ** the zStmt variable |
| 85086 | 85256 | */ |
| 85087 | 85257 | if( pStart ){ |
| 85088 | | - assert( pEnd!=0 ); |
| 85258 | + int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n; |
| 85259 | + if( pName->z[n-1]==';' ) n--; |
| 85089 | 85260 | /* A named index with an explicit CREATE INDEX statement */ |
| 85090 | 85261 | zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s", |
| 85091 | | - onError==OE_None ? "" : " UNIQUE", |
| 85092 | | - (int)(pEnd->z - pName->z) + 1, |
| 85093 | | - pName->z); |
| 85262 | + onError==OE_None ? "" : " UNIQUE", n, pName->z); |
| 85094 | 85263 | }else{ |
| 85095 | 85264 | /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ |
| 85096 | 85265 | /* zStmt = sqlite3MPrintf(""); */ |
| 85097 | 85266 | zStmt = 0; |
| 85098 | 85267 | } |
| | @@ -85144,14 +85313,12 @@ |
| 85144 | 85313 | pIndex = 0; |
| 85145 | 85314 | } |
| 85146 | 85315 | |
| 85147 | 85316 | /* Clean up before exiting */ |
| 85148 | 85317 | exit_create_index: |
| 85149 | | - if( pIndex ){ |
| 85150 | | - sqlite3DbFree(db, pIndex->zColAff); |
| 85151 | | - sqlite3DbFree(db, pIndex); |
| 85152 | | - } |
| 85318 | + if( pIndex ) freeIndex(db, pIndex); |
| 85319 | + sqlite3ExprDelete(db, pPIWhere); |
| 85153 | 85320 | sqlite3ExprListDelete(db, pList); |
| 85154 | 85321 | sqlite3SrcListDelete(db, pTblName); |
| 85155 | 85322 | sqlite3DbFree(db, zName); |
| 85156 | 85323 | return pRet; |
| 85157 | 85324 | } |
| | @@ -87123,15 +87290,18 @@ |
| 87123 | 87290 | int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ |
| 87124 | 87291 | ){ |
| 87125 | 87292 | int i; |
| 87126 | 87293 | Index *pIdx; |
| 87127 | 87294 | int r1; |
| 87295 | + int iPartIdxLabel; |
| 87296 | + Vdbe *v = pParse->pVdbe; |
| 87128 | 87297 | |
| 87129 | 87298 | for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ |
| 87130 | 87299 | if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue; |
| 87131 | | - r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0); |
| 87132 | | - sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1); |
| 87300 | + r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel); |
| 87301 | + sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1); |
| 87302 | + sqlite3VdbeResolveLabel(v, iPartIdxLabel); |
| 87133 | 87303 | } |
| 87134 | 87304 | } |
| 87135 | 87305 | |
| 87136 | 87306 | /* |
| 87137 | 87307 | ** Generate code that will assemble an index key and put it in register |
| | @@ -87141,24 +87311,42 @@ |
| 87141 | 87311 | ** |
| 87142 | 87312 | ** Return a register number which is the first in a block of |
| 87143 | 87313 | ** registers that holds the elements of the index key. The |
| 87144 | 87314 | ** block of registers has already been deallocated by the time |
| 87145 | 87315 | ** this routine returns. |
| 87316 | +** |
| 87317 | +** If *piPartIdxLabel is not NULL, fill it in with a label and jump |
| 87318 | +** to that label if pIdx is a partial index that should be skipped. |
| 87319 | +** A partial index should be skipped if its WHERE clause evaluates |
| 87320 | +** to false or null. If pIdx is not a partial index, *piPartIdxLabel |
| 87321 | +** will be set to zero which is an empty label that is ignored by |
| 87322 | +** sqlite3VdbeResolveLabel(). |
| 87146 | 87323 | */ |
| 87147 | 87324 | SQLITE_PRIVATE int sqlite3GenerateIndexKey( |
| 87148 | | - Parse *pParse, /* Parsing context */ |
| 87149 | | - Index *pIdx, /* The index for which to generate a key */ |
| 87150 | | - int iCur, /* Cursor number for the pIdx->pTable table */ |
| 87151 | | - int regOut, /* Write the new index key to this register */ |
| 87152 | | - int doMakeRec /* Run the OP_MakeRecord instruction if true */ |
| 87325 | + Parse *pParse, /* Parsing context */ |
| 87326 | + Index *pIdx, /* The index for which to generate a key */ |
| 87327 | + int iCur, /* Cursor number for the pIdx->pTable table */ |
| 87328 | + int regOut, /* Write the new index key to this register */ |
| 87329 | + int doMakeRec, /* Run the OP_MakeRecord instruction if true */ |
| 87330 | + int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */ |
| 87153 | 87331 | ){ |
| 87154 | 87332 | Vdbe *v = pParse->pVdbe; |
| 87155 | 87333 | int j; |
| 87156 | 87334 | Table *pTab = pIdx->pTable; |
| 87157 | 87335 | int regBase; |
| 87158 | 87336 | int nCol; |
| 87159 | 87337 | |
| 87338 | + if( piPartIdxLabel ){ |
| 87339 | + if( pIdx->pPartIdxWhere ){ |
| 87340 | + *piPartIdxLabel = sqlite3VdbeMakeLabel(v); |
| 87341 | + pParse->iPartIdxTab = iCur; |
| 87342 | + sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, |
| 87343 | + SQLITE_JUMPIFNULL); |
| 87344 | + }else{ |
| 87345 | + *piPartIdxLabel = 0; |
| 87346 | + } |
| 87347 | + } |
| 87160 | 87348 | nCol = pIdx->nColumn; |
| 87161 | 87349 | regBase = sqlite3GetTempRange(pParse, nCol+1); |
| 87162 | 87350 | sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol); |
| 87163 | 87351 | for(j=0; j<nCol; j++){ |
| 87164 | 87352 | int idx = pIdx->aiColumn[j]; |
| | @@ -91518,12 +91706,22 @@ |
| 91518 | 91706 | ** Add the new records to the indices as we go. |
| 91519 | 91707 | */ |
| 91520 | 91708 | for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){ |
| 91521 | 91709 | int regIdx; |
| 91522 | 91710 | int regR; |
| 91711 | + int addrSkipRow = 0; |
| 91523 | 91712 | |
| 91524 | 91713 | if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */ |
| 91714 | + |
| 91715 | + if( pIdx->pPartIdxWhere ){ |
| 91716 | + sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]); |
| 91717 | + addrSkipRow = sqlite3VdbeMakeLabel(v); |
| 91718 | + pParse->ckBase = regData; |
| 91719 | + sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow, |
| 91720 | + SQLITE_JUMPIFNULL); |
| 91721 | + pParse->ckBase = 0; |
| 91722 | + } |
| 91525 | 91723 | |
| 91526 | 91724 | /* Create a key for accessing the index entry */ |
| 91527 | 91725 | regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1); |
| 91528 | 91726 | for(i=0; i<pIdx->nColumn; i++){ |
| 91529 | 91727 | int idx = pIdx->aiColumn[i]; |
| | @@ -91540,10 +91738,11 @@ |
| 91540 | 91738 | |
| 91541 | 91739 | /* Find out what action to take in case there is an indexing conflict */ |
| 91542 | 91740 | onError = pIdx->onError; |
| 91543 | 91741 | if( onError==OE_None ){ |
| 91544 | 91742 | sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1); |
| 91743 | + sqlite3VdbeResolveLabel(v, addrSkipRow); |
| 91545 | 91744 | continue; /* pIdx is not a UNIQUE index */ |
| 91546 | 91745 | } |
| 91547 | 91746 | if( overrideError!=OE_Default ){ |
| 91548 | 91747 | onError = overrideError; |
| 91549 | 91748 | }else if( onError==OE_Default ){ |
| | @@ -91609,10 +91808,11 @@ |
| 91609 | 91808 | seenReplace = 1; |
| 91610 | 91809 | break; |
| 91611 | 91810 | } |
| 91612 | 91811 | } |
| 91613 | 91812 | sqlite3VdbeJumpHere(v, j3); |
| 91813 | + sqlite3VdbeResolveLabel(v, addrSkipRow); |
| 91614 | 91814 | sqlite3ReleaseTempReg(pParse, regR); |
| 91615 | 91815 | } |
| 91616 | 91816 | |
| 91617 | 91817 | if( pbMayReplace ){ |
| 91618 | 91818 | *pbMayReplace = seenReplace; |
| | @@ -91638,22 +91838,23 @@ |
| 91638 | 91838 | int appendBias, /* True if this is likely to be an append */ |
| 91639 | 91839 | int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */ |
| 91640 | 91840 | ){ |
| 91641 | 91841 | int i; |
| 91642 | 91842 | Vdbe *v; |
| 91643 | | - int nIdx; |
| 91644 | 91843 | Index *pIdx; |
| 91645 | 91844 | u8 pik_flags; |
| 91646 | 91845 | int regData; |
| 91647 | 91846 | int regRec; |
| 91648 | 91847 | |
| 91649 | 91848 | v = sqlite3GetVdbe(pParse); |
| 91650 | 91849 | assert( v!=0 ); |
| 91651 | 91850 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ |
| 91652 | | - for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){} |
| 91653 | | - for(i=nIdx-1; i>=0; i--){ |
| 91851 | + for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 91654 | 91852 | if( aRegIdx[i]==0 ) continue; |
| 91853 | + if( pIdx->pPartIdxWhere ){ |
| 91854 | + sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2); |
| 91855 | + } |
| 91655 | 91856 | sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]); |
| 91656 | 91857 | if( useSeekResult ){ |
| 91657 | 91858 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 91658 | 91859 | } |
| 91659 | 91860 | } |
| | @@ -91751,10 +91952,11 @@ |
| 91751 | 91952 | ** |
| 91752 | 91953 | ** * The index is over the same set of columns |
| 91753 | 91954 | ** * The same DESC and ASC markings occurs on all columns |
| 91754 | 91955 | ** * The same onError processing (OE_Abort, OE_Ignore, etc) |
| 91755 | 91956 | ** * The same collating sequence on each column |
| 91957 | +** * The index has the exact same WHERE clause |
| 91756 | 91958 | */ |
| 91757 | 91959 | static int xferCompatibleIndex(Index *pDest, Index *pSrc){ |
| 91758 | 91960 | int i; |
| 91759 | 91961 | assert( pDest && pSrc ); |
| 91760 | 91962 | assert( pDest->pTable!=pSrc->pTable ); |
| | @@ -91772,10 +91974,13 @@ |
| 91772 | 91974 | return 0; /* Different sort orders */ |
| 91773 | 91975 | } |
| 91774 | 91976 | if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){ |
| 91775 | 91977 | return 0; /* Different collating sequences */ |
| 91776 | 91978 | } |
| 91979 | + } |
| 91980 | + if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){ |
| 91981 | + return 0; /* Different WHERE clauses */ |
| 91777 | 91982 | } |
| 91778 | 91983 | |
| 91779 | 91984 | /* If no test above fails then the indices must be compatible */ |
| 91780 | 91985 | return 1; |
| 91781 | 91986 | } |
| | @@ -91928,11 +92133,11 @@ |
| 91928 | 92133 | if( pSrcIdx==0 ){ |
| 91929 | 92134 | return 0; /* pDestIdx has no corresponding index in pSrc */ |
| 91930 | 92135 | } |
| 91931 | 92136 | } |
| 91932 | 92137 | #ifndef SQLITE_OMIT_CHECK |
| 91933 | | - if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){ |
| 92138 | + if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){ |
| 91934 | 92139 | return 0; /* Tables have different CHECK constraints. Ticket #2252 */ |
| 91935 | 92140 | } |
| 91936 | 92141 | #endif |
| 91937 | 92142 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 91938 | 92143 | /* Disallow the transfer optimization if the destination table constains |
| | @@ -94841,13 +95046,11 @@ |
| 94841 | 95046 | cnt++; |
| 94842 | 95047 | } |
| 94843 | 95048 | } |
| 94844 | 95049 | |
| 94845 | 95050 | /* Make sure sufficient number of registers have been allocated */ |
| 94846 | | - if( pParse->nMem < cnt+4 ){ |
| 94847 | | - pParse->nMem = cnt+4; |
| 94848 | | - } |
| 95051 | + pParse->nMem = MAX( pParse->nMem, cnt+7 ); |
| 94849 | 95052 | |
| 94850 | 95053 | /* Do the b-tree integrity checks */ |
| 94851 | 95054 | sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1); |
| 94852 | 95055 | sqlite3VdbeChangeP5(v, (u8)i); |
| 94853 | 95056 | addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); |
| | @@ -94868,16 +95071,19 @@ |
| 94868 | 95071 | |
| 94869 | 95072 | if( pTab->pIndex==0 ) continue; |
| 94870 | 95073 | addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */ |
| 94871 | 95074 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 94872 | 95075 | sqlite3VdbeJumpHere(v, addr); |
| 95076 | + sqlite3ExprCacheClear(pParse); |
| 94873 | 95077 | sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); |
| 94874 | | - sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */ |
| 94875 | | - loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0); |
| 94876 | | - sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */ |
| 95078 | + for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 95079 | + sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */ |
| 95080 | + } |
| 95081 | + pParse->nMem = MAX(pParse->nMem, 7+j); |
| 95082 | + loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1; |
| 94877 | 95083 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 94878 | | - int jmp2; |
| 95084 | + int jmp2, jmp3; |
| 94879 | 95085 | int r1; |
| 94880 | 95086 | static const VdbeOpList idxErr[] = { |
| 94881 | 95087 | { OP_AddImm, 1, -1, 0}, |
| 94882 | 95088 | { OP_String8, 0, 3, 0}, /* 1 */ |
| 94883 | 95089 | { OP_Rowid, 1, 4, 0}, |
| | @@ -94888,47 +95094,38 @@ |
| 94888 | 95094 | { OP_Concat, 6, 3, 3}, |
| 94889 | 95095 | { OP_ResultRow, 3, 1, 0}, |
| 94890 | 95096 | { OP_IfPos, 1, 0, 0}, /* 9 */ |
| 94891 | 95097 | { OP_Halt, 0, 0, 0}, |
| 94892 | 95098 | }; |
| 94893 | | - r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0); |
| 95099 | + r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3); |
| 95100 | + sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */ |
| 94894 | 95101 | jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1); |
| 94895 | 95102 | addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); |
| 94896 | 95103 | sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC); |
| 94897 | 95104 | sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC); |
| 94898 | 95105 | sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT); |
| 94899 | 95106 | sqlite3VdbeJumpHere(v, addr+9); |
| 94900 | 95107 | sqlite3VdbeJumpHere(v, jmp2); |
| 95108 | + sqlite3VdbeResolveLabel(v, jmp3); |
| 94901 | 95109 | } |
| 94902 | | - sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1); |
| 94903 | | - sqlite3VdbeJumpHere(v, loopTop); |
| 95110 | + sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop); |
| 95111 | + sqlite3VdbeJumpHere(v, loopTop-1); |
| 95112 | +#ifndef SQLITE_OMIT_BTREECOUNT |
| 95113 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, |
| 95114 | + "wrong # of entries in index ", P4_STATIC); |
| 94904 | 95115 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 94905 | | - static const VdbeOpList cntIdx[] = { |
| 94906 | | - { OP_Integer, 0, 3, 0}, |
| 94907 | | - { OP_Rewind, 0, 0, 0}, /* 1 */ |
| 94908 | | - { OP_AddImm, 3, 1, 0}, |
| 94909 | | - { OP_Next, 0, 0, 0}, /* 3 */ |
| 94910 | | - { OP_Eq, 2, 0, 3}, /* 4 */ |
| 94911 | | - { OP_AddImm, 1, -1, 0}, |
| 94912 | | - { OP_String8, 0, 2, 0}, /* 6 */ |
| 94913 | | - { OP_String8, 0, 3, 0}, /* 7 */ |
| 94914 | | - { OP_Concat, 3, 2, 2}, |
| 94915 | | - { OP_ResultRow, 2, 1, 0}, |
| 94916 | | - }; |
| 94917 | | - addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); |
| 95116 | + addr = sqlite3VdbeCurrentAddr(v); |
| 95117 | + sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2); |
| 94918 | 95118 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 94919 | | - sqlite3VdbeJumpHere(v, addr); |
| 94920 | | - addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); |
| 94921 | | - sqlite3VdbeChangeP1(v, addr+1, j+2); |
| 94922 | | - sqlite3VdbeChangeP2(v, addr+1, addr+4); |
| 94923 | | - sqlite3VdbeChangeP1(v, addr+3, j+2); |
| 94924 | | - sqlite3VdbeChangeP2(v, addr+3, addr+2); |
| 94925 | | - sqlite3VdbeJumpHere(v, addr+4); |
| 94926 | | - sqlite3VdbeChangeP4(v, addr+6, |
| 94927 | | - "wrong # of entries in index ", P4_STATIC); |
| 94928 | | - sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT); |
| 94929 | | - } |
| 95119 | + sqlite3VdbeAddOp2(v, OP_Count, j+2, 3); |
| 95120 | + sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3); |
| 95121 | + sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); |
| 95122 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT); |
| 95123 | + sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7); |
| 95124 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1); |
| 95125 | + } |
| 95126 | +#endif /* SQLITE_OMIT_BTREECOUNT */ |
| 94930 | 95127 | } |
| 94931 | 95128 | } |
| 94932 | 95129 | addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode); |
| 94933 | 95130 | sqlite3VdbeChangeP2(v, addr, -mxErr); |
| 94934 | 95131 | sqlite3VdbeJumpHere(v, addr+1); |
| | @@ -100327,11 +100524,11 @@ |
| 100327 | 100524 | ** will cause elements to come out in the correct order. This is |
| 100328 | 100525 | ** an optimization - the correct answer should result regardless. |
| 100329 | 100526 | ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER |
| 100330 | 100527 | ** to disable this optimization for testing purposes. |
| 100331 | 100528 | */ |
| 100332 | | - if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0 |
| 100529 | + if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0 |
| 100333 | 100530 | && OptimizationEnabled(db, SQLITE_GroupByOrder) ){ |
| 100334 | 100531 | pOrderBy = 0; |
| 100335 | 100532 | } |
| 100336 | 100533 | |
| 100337 | 100534 | /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and |
| | @@ -100348,11 +100545,11 @@ |
| 100348 | 100545 | ** used for both the ORDER BY and DISTINCT processing. As originally |
| 100349 | 100546 | ** written the query must use a temp-table for at least one of the ORDER |
| 100350 | 100547 | ** BY and DISTINCT, and an index or separate temp-table for the other. |
| 100351 | 100548 | */ |
| 100352 | 100549 | if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct |
| 100353 | | - && sqlite3ExprListCompare(pOrderBy, p->pEList)==0 |
| 100550 | + && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0 |
| 100354 | 100551 | ){ |
| 100355 | 100552 | p->selFlags &= ~SF_Distinct; |
| 100356 | 100553 | p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0); |
| 100357 | 100554 | pGroupBy = p->pGroupBy; |
| 100358 | 100555 | pOrderBy = 0; |
| | @@ -102575,11 +102772,11 @@ |
| 102575 | 102772 | aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx ); |
| 102576 | 102773 | if( aRegIdx==0 ) goto update_cleanup; |
| 102577 | 102774 | } |
| 102578 | 102775 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 102579 | 102776 | int reg; |
| 102580 | | - if( hasFK || chngRowid ){ |
| 102777 | + if( hasFK || chngRowid || pIdx->pPartIdxWhere ){ |
| 102581 | 102778 | reg = ++pParse->nMem; |
| 102582 | 102779 | }else{ |
| 102583 | 102780 | reg = 0; |
| 102584 | 102781 | for(i=0; i<pIdx->nColumn; i++){ |
| 102585 | 102782 | if( aXRef[pIdx->aiColumn[i]]>=0 ){ |
| | @@ -105115,11 +105312,11 @@ |
| 105115 | 105312 | ** the pWC->a[] array. |
| 105116 | 105313 | */ |
| 105117 | 105314 | static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){ |
| 105118 | 105315 | WhereTerm *pTerm; |
| 105119 | 105316 | int idx; |
| 105120 | | - testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */ |
| 105317 | + testcase( wtFlags & TERM_VIRTUAL ); |
| 105121 | 105318 | if( pWC->nTerm>=pWC->nSlot ){ |
| 105122 | 105319 | WhereTerm *pOld = pWC->a; |
| 105123 | 105320 | sqlite3 *db = pWC->pWInfo->pParse->db; |
| 105124 | 105321 | pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 ); |
| 105125 | 105322 | if( pWC->a==0 ){ |
| | @@ -105260,17 +105457,10 @@ |
| 105260 | 105457 | |
| 105261 | 105458 | /* |
| 105262 | 105459 | ** Return TRUE if the given operator is one of the operators that is |
| 105263 | 105460 | ** allowed for an indexable WHERE clause term. The allowed operators are |
| 105264 | 105461 | ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL" |
| 105265 | | -** |
| 105266 | | -** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be |
| 105267 | | -** of one of the following forms: column = expression column > expression |
| 105268 | | -** column >= expression column < expression column <= expression |
| 105269 | | -** expression = column expression > column expression >= column |
| 105270 | | -** expression < column expression <= column column IN |
| 105271 | | -** (expression-list) column IN (subquery) column IS NULL |
| 105272 | 105462 | */ |
| 105273 | 105463 | static int allowedOp(int op){ |
| 105274 | 105464 | assert( TK_GT>TK_EQ && TK_GT<TK_GE ); |
| 105275 | 105465 | assert( TK_LT>TK_EQ && TK_LT<TK_GE ); |
| 105276 | 105466 | assert( TK_LE>TK_EQ && TK_LE<TK_GE ); |
| | @@ -105585,11 +105775,11 @@ |
| 105585 | 105775 | op = pRight->op2; |
| 105586 | 105776 | } |
| 105587 | 105777 | if( op==TK_VARIABLE ){ |
| 105588 | 105778 | Vdbe *pReprepare = pParse->pReprepare; |
| 105589 | 105779 | int iCol = pRight->iColumn; |
| 105590 | | - pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE); |
| 105780 | + pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE); |
| 105591 | 105781 | if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){ |
| 105592 | 105782 | z = (char *)sqlite3_value_text(pVal); |
| 105593 | 105783 | } |
| 105594 | 105784 | sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); |
| 105595 | 105785 | assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER ); |
| | @@ -105940,12 +106130,10 @@ |
| 105940 | 106130 | } |
| 105941 | 106131 | |
| 105942 | 106132 | /* At this point, okToChngToIN is true if original pTerm satisfies |
| 105943 | 106133 | ** case 1. In that case, construct a new virtual term that is |
| 105944 | 106134 | ** pTerm converted into an IN operator. |
| 105945 | | - ** |
| 105946 | | - ** EV: R-00211-15100 |
| 105947 | 106135 | */ |
| 105948 | 106136 | if( okToChngToIN ){ |
| 105949 | 106137 | Expr *pDup; /* A transient duplicate expression */ |
| 105950 | 106138 | ExprList *pList = 0; /* The RHS of the IN operator */ |
| 105951 | 106139 | Expr *pLeft = 0; /* The LHS of the IN operator */ |
| | @@ -106183,13 +106371,11 @@ |
| 106183 | 106371 | ** wildcard. But if we increment '@', that will push it into the |
| 106184 | 106372 | ** alphabetic range where case conversions will mess up the |
| 106185 | 106373 | ** inequality. To avoid this, make sure to also run the full |
| 106186 | 106374 | ** LIKE on all candidate expressions by clearing the isComplete flag |
| 106187 | 106375 | */ |
| 106188 | | - if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */ |
| 106189 | | - |
| 106190 | | - |
| 106376 | + if( c=='A'-1 ) isComplete = 0; |
| 106191 | 106377 | c = sqlite3UpperToLower[c]; |
| 106192 | 106378 | } |
| 106193 | 106379 | *pC = c + 1; |
| 106194 | 106380 | } |
| 106195 | 106381 | sCollSeqName.z = noCase ? "NOCASE" : "BINARY"; |
| | @@ -106692,11 +106878,11 @@ |
| 106692 | 106878 | VdbeComment((v, "for %s", pTable->zName)); |
| 106693 | 106879 | |
| 106694 | 106880 | /* Fill the automatic index with content */ |
| 106695 | 106881 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); |
| 106696 | 106882 | regRecord = sqlite3GetTempReg(pParse); |
| 106697 | | - sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1); |
| 106883 | + sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0); |
| 106698 | 106884 | sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord); |
| 106699 | 106885 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 106700 | 106886 | sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); |
| 106701 | 106887 | sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); |
| 106702 | 106888 | sqlite3VdbeJumpHere(v, addrTop); |
| | @@ -107049,11 +107235,11 @@ |
| 107049 | 107235 | if( pExpr->op==TK_VARIABLE |
| 107050 | 107236 | || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) |
| 107051 | 107237 | ){ |
| 107052 | 107238 | int iVar = pExpr->iColumn; |
| 107053 | 107239 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); |
| 107054 | | - *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 107240 | + *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff); |
| 107055 | 107241 | return SQLITE_OK; |
| 107056 | 107242 | } |
| 107057 | 107243 | return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp); |
| 107058 | 107244 | } |
| 107059 | 107245 | #endif |
| | @@ -107275,13 +107461,10 @@ |
| 107275 | 107461 | ** |
| 107276 | 107462 | ** The t2.z='ok' is disabled in the in (2) because it originates |
| 107277 | 107463 | ** in the ON clause. The term is disabled in (3) because it is not part |
| 107278 | 107464 | ** of a LEFT OUTER JOIN. In (1), the term is not disabled. |
| 107279 | 107465 | ** |
| 107280 | | -** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are |
| 107281 | | -** completely satisfied by indices. |
| 107282 | | -** |
| 107283 | 107466 | ** Disabling a term causes that term to not be tested in the inner loop |
| 107284 | 107467 | ** of the join. Disabling is an optimization. When terms are satisfied |
| 107285 | 107468 | ** by indices, we disable them to prevent redundant tests in the inner |
| 107286 | 107469 | ** loop. We would get the correct results if nothing were ever disabled, |
| 107287 | 107470 | ** but joins might run a little slower. The trick is to disable as much |
| | @@ -107507,11 +107690,11 @@ |
| 107507 | 107690 | pTerm = pLoop->aLTerm[j]; |
| 107508 | 107691 | assert( pTerm!=0 ); |
| 107509 | 107692 | /* The following true for indices with redundant columns. |
| 107510 | 107693 | ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ |
| 107511 | 107694 | testcase( (pTerm->wtFlags & TERM_CODED)!=0 ); |
| 107512 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 107695 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 107513 | 107696 | r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j); |
| 107514 | 107697 | if( r1!=regBase+j ){ |
| 107515 | 107698 | if( nReg==1 ){ |
| 107516 | 107699 | sqlite3ReleaseTempReg(pParse, regBase); |
| 107517 | 107700 | regBase = r1; |
| | @@ -107707,10 +107890,11 @@ |
| 107707 | 107890 | WhereLevel *pLevel; /* The where level to be coded */ |
| 107708 | 107891 | WhereLoop *pLoop; /* The WhereLoop object being coded */ |
| 107709 | 107892 | WhereClause *pWC; /* Decomposition of the entire WHERE clause */ |
| 107710 | 107893 | WhereTerm *pTerm; /* A WHERE clause term */ |
| 107711 | 107894 | Parse *pParse; /* Parsing context */ |
| 107895 | + sqlite3 *db; /* Database connection */ |
| 107712 | 107896 | Vdbe *v; /* The prepared stmt under constructions */ |
| 107713 | 107897 | struct SrcList_item *pTabItem; /* FROM clause term being coded */ |
| 107714 | 107898 | int addrBrk; /* Jump here to break out of the loop */ |
| 107715 | 107899 | int addrCont; /* Jump here to continue with next cycle */ |
| 107716 | 107900 | int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ |
| | @@ -107718,10 +107902,11 @@ |
| 107718 | 107902 | Bitmask newNotReady; /* Return value */ |
| 107719 | 107903 | |
| 107720 | 107904 | pParse = pWInfo->pParse; |
| 107721 | 107905 | v = pParse->pVdbe; |
| 107722 | 107906 | pWC = &pWInfo->sWC; |
| 107907 | + db = pParse->db; |
| 107723 | 107908 | pLevel = &pWInfo->a[iLevel]; |
| 107724 | 107909 | pLoop = pLevel->pWLoop; |
| 107725 | 107910 | pTabItem = &pWInfo->pTabList->a[pLevel->iFrom]; |
| 107726 | 107911 | iCur = pTabItem->iCursor; |
| 107727 | 107912 | bRev = (pWInfo->revMask>>iLevel)&1; |
| | @@ -107816,11 +108001,11 @@ |
| 107816 | 108001 | iReleaseReg = sqlite3GetTempReg(pParse); |
| 107817 | 108002 | pTerm = pLoop->aLTerm[0]; |
| 107818 | 108003 | assert( pTerm!=0 ); |
| 107819 | 108004 | assert( pTerm->pExpr!=0 ); |
| 107820 | 108005 | assert( omitTable==0 ); |
| 107821 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108006 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 107822 | 108007 | iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg); |
| 107823 | 108008 | addrNxt = pLevel->addrNxt; |
| 107824 | 108009 | sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); |
| 107825 | 108010 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); |
| 107826 | 108011 | sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); |
| | @@ -107864,11 +108049,11 @@ |
| 107864 | 108049 | assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */ |
| 107865 | 108050 | assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */ |
| 107866 | 108051 | assert( TK_GE==TK_GT+3 ); /* ... is correcct. */ |
| 107867 | 108052 | |
| 107868 | 108053 | assert( (pStart->wtFlags & TERM_VNULL)==0 ); |
| 107869 | | - testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108054 | + testcase( pStart->wtFlags & TERM_VIRTUAL ); |
| 107870 | 108055 | pX = pStart->pExpr; |
| 107871 | 108056 | assert( pX!=0 ); |
| 107872 | 108057 | testcase( pStart->leftCursor!=iCur ); /* transitive constraints */ |
| 107873 | 108058 | r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp); |
| 107874 | 108059 | sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1); |
| | @@ -107883,11 +108068,11 @@ |
| 107883 | 108068 | Expr *pX; |
| 107884 | 108069 | pX = pEnd->pExpr; |
| 107885 | 108070 | assert( pX!=0 ); |
| 107886 | 108071 | assert( (pEnd->wtFlags & TERM_VNULL)==0 ); |
| 107887 | 108072 | testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */ |
| 107888 | | - testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108073 | + testcase( pEnd->wtFlags & TERM_VIRTUAL ); |
| 107889 | 108074 | memEndValue = ++pParse->nMem; |
| 107890 | 108075 | sqlite3ExprCode(pParse, pX->pRight, memEndValue); |
| 107891 | 108076 | if( pX->op==TK_LT || pX->op==TK_GT ){ |
| 107892 | 108077 | testOp = bRev ? OP_Le : OP_Ge; |
| 107893 | 108078 | }else{ |
| | @@ -108008,11 +108193,11 @@ |
| 108008 | 108193 | /* Generate code to evaluate all constraint terms using == or IN |
| 108009 | 108194 | ** and store the values of those terms in an array of registers |
| 108010 | 108195 | ** starting at regBase. |
| 108011 | 108196 | */ |
| 108012 | 108197 | regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff); |
| 108013 | | - zEndAff = sqlite3DbStrDup(pParse->db, zStartAff); |
| 108198 | + zEndAff = sqlite3DbStrDup(db, zStartAff); |
| 108014 | 108199 | addrNxt = pLevel->addrNxt; |
| 108015 | 108200 | |
| 108016 | 108201 | /* If we are doing a reverse order scan on an ascending index, or |
| 108017 | 108202 | ** a forward order scan on a descending index, interchange the |
| 108018 | 108203 | ** start and end terms (pRangeStart and pRangeEnd). |
| | @@ -108049,11 +108234,11 @@ |
| 108049 | 108234 | if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){ |
| 108050 | 108235 | zStartAff[nEq] = SQLITE_AFF_NONE; |
| 108051 | 108236 | } |
| 108052 | 108237 | } |
| 108053 | 108238 | nConstraint++; |
| 108054 | | - testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108239 | + testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); |
| 108055 | 108240 | }else if( isMinQuery ){ |
| 108056 | 108241 | sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq); |
| 108057 | 108242 | nConstraint++; |
| 108058 | 108243 | startEq = 0; |
| 108059 | 108244 | start_constraints = 1; |
| | @@ -108091,14 +108276,14 @@ |
| 108091 | 108276 | zEndAff[nEq] = SQLITE_AFF_NONE; |
| 108092 | 108277 | } |
| 108093 | 108278 | } |
| 108094 | 108279 | codeApplyAffinity(pParse, regBase, nEq+1, zEndAff); |
| 108095 | 108280 | nConstraint++; |
| 108096 | | - testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108281 | + testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); |
| 108097 | 108282 | } |
| 108098 | | - sqlite3DbFree(pParse->db, zStartAff); |
| 108099 | | - sqlite3DbFree(pParse->db, zEndAff); |
| 108283 | + sqlite3DbFree(db, zStartAff); |
| 108284 | + sqlite3DbFree(db, zEndAff); |
| 108100 | 108285 | |
| 108101 | 108286 | /* Top of the loop body */ |
| 108102 | 108287 | pLevel->p2 = sqlite3VdbeCurrentAddr(v); |
| 108103 | 108288 | |
| 108104 | 108289 | /* Check if the index cursor is past the end of the range. */ |
| | @@ -108221,11 +108406,11 @@ |
| 108221 | 108406 | */ |
| 108222 | 108407 | if( pWInfo->nLevel>1 ){ |
| 108223 | 108408 | int nNotReady; /* The number of notReady tables */ |
| 108224 | 108409 | struct SrcList_item *origSrc; /* Original list of tables */ |
| 108225 | 108410 | nNotReady = pWInfo->nLevel - iLevel - 1; |
| 108226 | | - pOrTab = sqlite3StackAllocRaw(pParse->db, |
| 108411 | + pOrTab = sqlite3StackAllocRaw(db, |
| 108227 | 108412 | sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0])); |
| 108228 | 108413 | if( pOrTab==0 ) return notReady; |
| 108229 | 108414 | pOrTab->nAlloc = (u8)(nNotReady + 1); |
| 108230 | 108415 | pOrTab->nSrc = pOrTab->nAlloc; |
| 108231 | 108416 | memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem)); |
| | @@ -108275,12 +108460,12 @@ |
| 108275 | 108460 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 108276 | 108461 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 108277 | 108462 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 108278 | 108463 | if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue; |
| 108279 | 108464 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 108280 | | - pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 108281 | | - pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr); |
| 108465 | + pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 108466 | + pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 108282 | 108467 | } |
| 108283 | 108468 | if( pAndExpr ){ |
| 108284 | 108469 | pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0); |
| 108285 | 108470 | } |
| 108286 | 108471 | } |
| | @@ -108296,11 +108481,11 @@ |
| 108296 | 108481 | } |
| 108297 | 108482 | /* Loop through table entries that match term pOrTerm. */ |
| 108298 | 108483 | pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, |
| 108299 | 108484 | WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY | |
| 108300 | 108485 | WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur); |
| 108301 | | - assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed ); |
| 108486 | + assert( pSubWInfo || pParse->nErr || db->mallocFailed ); |
| 108302 | 108487 | if( pSubWInfo ){ |
| 108303 | 108488 | WhereLoop *pSubLoop; |
| 108304 | 108489 | explainOneScan( |
| 108305 | 108490 | pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0 |
| 108306 | 108491 | ); |
| | @@ -108351,17 +108536,17 @@ |
| 108351 | 108536 | } |
| 108352 | 108537 | pLevel->u.pCovidx = pCov; |
| 108353 | 108538 | if( pCov ) pLevel->iIdxCur = iCovCur; |
| 108354 | 108539 | if( pAndExpr ){ |
| 108355 | 108540 | pAndExpr->pLeft = 0; |
| 108356 | | - sqlite3ExprDelete(pParse->db, pAndExpr); |
| 108541 | + sqlite3ExprDelete(db, pAndExpr); |
| 108357 | 108542 | } |
| 108358 | 108543 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 108359 | 108544 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); |
| 108360 | 108545 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 108361 | 108546 | |
| 108362 | | - if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab); |
| 108547 | + if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab); |
| 108363 | 108548 | if( !untestedTerms ) disableTerm(pLevel, pTerm); |
| 108364 | 108549 | }else |
| 108365 | 108550 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
| 108366 | 108551 | |
| 108367 | 108552 | { |
| | @@ -108378,18 +108563,14 @@ |
| 108378 | 108563 | } |
| 108379 | 108564 | newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur); |
| 108380 | 108565 | |
| 108381 | 108566 | /* Insert code to test every subexpression that can be completely |
| 108382 | 108567 | ** computed using the current set of tables. |
| 108383 | | - ** |
| 108384 | | - ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through |
| 108385 | | - ** the use of indices become tests that are evaluated against each row of |
| 108386 | | - ** the relevant input tables. |
| 108387 | 108568 | */ |
| 108388 | 108569 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 108389 | 108570 | Expr *pE; |
| 108390 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ |
| 108571 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 108391 | 108572 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 108392 | 108573 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 108393 | 108574 | if( (pTerm->prereqAll & newNotReady)!=0 ){ |
| 108394 | 108575 | testcase( pWInfo->untestedTerms==0 |
| 108395 | 108576 | && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ); |
| | @@ -108412,13 +108593,12 @@ |
| 108412 | 108593 | ** and we are coding the t1 loop and the t2 loop has not yet coded, |
| 108413 | 108594 | ** then we cannot use the "t1.a=t2.b" constraint, but we can code |
| 108414 | 108595 | ** the implied "t1.a=123" constraint. |
| 108415 | 108596 | */ |
| 108416 | 108597 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 108417 | | - Expr *pE; |
| 108598 | + Expr *pE, *pEAlt; |
| 108418 | 108599 | WhereTerm *pAlt; |
| 108419 | | - Expr sEq; |
| 108420 | 108600 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 108421 | 108601 | if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue; |
| 108422 | 108602 | if( pTerm->leftCursor!=iCur ) continue; |
| 108423 | 108603 | if( pLevel->iLeftJoin ) continue; |
| 108424 | 108604 | pE = pTerm->pExpr; |
| | @@ -108428,13 +108608,17 @@ |
| 108428 | 108608 | if( pAlt==0 ) continue; |
| 108429 | 108609 | if( pAlt->wtFlags & (TERM_CODED) ) continue; |
| 108430 | 108610 | testcase( pAlt->eOperator & WO_EQ ); |
| 108431 | 108611 | testcase( pAlt->eOperator & WO_IN ); |
| 108432 | 108612 | VdbeNoopComment((v, "begin transitive constraint")); |
| 108433 | | - sEq = *pAlt->pExpr; |
| 108434 | | - sEq.pLeft = pE->pLeft; |
| 108435 | | - sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL); |
| 108613 | + pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt)); |
| 108614 | + if( pEAlt ){ |
| 108615 | + *pEAlt = *pAlt->pExpr; |
| 108616 | + pEAlt->pLeft = pE->pLeft; |
| 108617 | + sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL); |
| 108618 | + sqlite3StackFree(db, pEAlt); |
| 108619 | + } |
| 108436 | 108620 | } |
| 108437 | 108621 | |
| 108438 | 108622 | /* For a LEFT OUTER JOIN, generate code that will record the fact that |
| 108439 | 108623 | ** at least one row of the right table has matched the left table. |
| 108440 | 108624 | */ |
| | @@ -108442,11 +108626,11 @@ |
| 108442 | 108626 | pLevel->addrFirst = sqlite3VdbeCurrentAddr(v); |
| 108443 | 108627 | sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin); |
| 108444 | 108628 | VdbeComment((v, "record LEFT JOIN hit")); |
| 108445 | 108629 | sqlite3ExprCacheClear(pParse); |
| 108446 | 108630 | for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){ |
| 108447 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ |
| 108631 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 108448 | 108632 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 108449 | 108633 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 108450 | 108634 | if( (pTerm->prereqAll & newNotReady)!=0 ){ |
| 108451 | 108635 | assert( pWInfo->untestedTerms ); |
| 108452 | 108636 | continue; |
| | @@ -108883,11 +109067,12 @@ |
| 108883 | 109067 | rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut); |
| 108884 | 109068 | }else if( (pTerm->eOperator & WO_IN) |
| 108885 | 109069 | && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){ |
| 108886 | 109070 | rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut); |
| 108887 | 109071 | } |
| 108888 | | - if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut); |
| 109072 | + assert( nOut==0 || rc==SQLITE_OK ); |
| 109073 | + if( nOut ) pNew->nOut = whereCost(nOut); |
| 108889 | 109074 | } |
| 108890 | 109075 | #endif |
| 108891 | 109076 | if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){ |
| 108892 | 109077 | /* Each row involves a step of the index, then a binary search of |
| 108893 | 109078 | ** the main table */ |
| | @@ -108955,10 +109140,21 @@ |
| 108955 | 109140 | if( x<BMS-1 ) m |= MASKBIT(x); |
| 108956 | 109141 | } |
| 108957 | 109142 | return m; |
| 108958 | 109143 | } |
| 108959 | 109144 | |
| 109145 | +/* Check to see if a partial index with pPartIndexWhere can be used |
| 109146 | +** in the current query. Return true if it can be and false if not. |
| 109147 | +*/ |
| 109148 | +static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){ |
| 109149 | + int i; |
| 109150 | + WhereTerm *pTerm; |
| 109151 | + for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 109152 | + if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1; |
| 109153 | + } |
| 109154 | + return 0; |
| 109155 | +} |
| 108960 | 109156 | |
| 108961 | 109157 | /* |
| 108962 | 109158 | ** Add all WhereLoop objects for a single table of the join where the table |
| 108963 | 109159 | ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be |
| 108964 | 109160 | ** a b-tree table, not a virtual table. |
| | @@ -108978,15 +109174,17 @@ |
| 108978 | 109174 | int rc = SQLITE_OK; /* Return code */ |
| 108979 | 109175 | int iSortIdx = 1; /* Index number */ |
| 108980 | 109176 | int b; /* A boolean value */ |
| 108981 | 109177 | WhereCost rSize; /* number of rows in the table */ |
| 108982 | 109178 | WhereCost rLogSize; /* Logarithm of the number of rows in the table */ |
| 109179 | + WhereClause *pWC; /* The parsed WHERE clause */ |
| 108983 | 109180 | |
| 108984 | 109181 | pNew = pBuilder->pNew; |
| 108985 | 109182 | pWInfo = pBuilder->pWInfo; |
| 108986 | 109183 | pTabList = pWInfo->pTabList; |
| 108987 | 109184 | pSrc = pTabList->a + pNew->iTab; |
| 109185 | + pWC = pBuilder->pWC; |
| 108988 | 109186 | assert( !IsVirtual(pSrc->pTab) ); |
| 108989 | 109187 | |
| 108990 | 109188 | if( pSrc->pIndex ){ |
| 108991 | 109189 | /* An INDEXED BY clause specifies a particular index to use */ |
| 108992 | 109190 | pProbe = pSrc->pIndex; |
| | @@ -109022,11 +109220,10 @@ |
| 109022 | 109220 | && !pSrc->viaCoroutine |
| 109023 | 109221 | && !pSrc->notIndexed |
| 109024 | 109222 | && !pSrc->isCorrelated |
| 109025 | 109223 | ){ |
| 109026 | 109224 | /* Generate auto-index WhereLoops */ |
| 109027 | | - WhereClause *pWC = pBuilder->pWC; |
| 109028 | 109225 | WhereTerm *pTerm; |
| 109029 | 109226 | WhereTerm *pWCEnd = pWC->a + pWC->nTerm; |
| 109030 | 109227 | for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){ |
| 109031 | 109228 | if( pTerm->prereqRight & pNew->maskSelf ) continue; |
| 109032 | 109229 | if( termCanDriveIndex(pTerm, pSrc, 0) ){ |
| | @@ -109052,10 +109249,14 @@ |
| 109052 | 109249 | } |
| 109053 | 109250 | |
| 109054 | 109251 | /* Loop over all indices |
| 109055 | 109252 | */ |
| 109056 | 109253 | for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){ |
| 109254 | + if( pProbe->pPartIdxWhere!=0 |
| 109255 | + && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){ |
| 109256 | + continue; /* Partial index inappropriate for this query */ |
| 109257 | + } |
| 109057 | 109258 | pNew->u.btree.nEq = 0; |
| 109058 | 109259 | pNew->nLTerm = 0; |
| 109059 | 109260 | pNew->iSortIdx = 0; |
| 109060 | 109261 | pNew->rSetup = 0; |
| 109061 | 109262 | pNew->prereq = mExtra; |
| | @@ -109992,11 +110193,11 @@ |
| 109992 | 110193 | pLoop->u.btree.nEq = 1; |
| 109993 | 110194 | /* TUNING: Cost of a rowid lookup is 10 */ |
| 109994 | 110195 | pLoop->rRun = 33; /* 33==whereCost(10) */ |
| 109995 | 110196 | }else{ |
| 109996 | 110197 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 109997 | | - if( pIdx->onError==OE_None ) continue; |
| 110198 | + if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue; |
| 109998 | 110199 | for(j=0; j<pIdx->nColumn; j++){ |
| 109999 | 110200 | pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx); |
| 110000 | 110201 | if( pTerm==0 ) break; |
| 110001 | 110202 | whereLoopResize(pWInfo->pParse->db, pLoop, j); |
| 110002 | 110203 | pLoop->aLTerm[j] = pTerm; |
| | @@ -110198,11 +110399,11 @@ |
| 110198 | 110399 | ** subexpression is separated by an AND operator. |
| 110199 | 110400 | */ |
| 110200 | 110401 | initMaskSet(pMaskSet); |
| 110201 | 110402 | whereClauseInit(&pWInfo->sWC, pWInfo); |
| 110202 | 110403 | sqlite3ExprCodeConstants(pParse, pWhere); |
| 110203 | | - whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */ |
| 110404 | + whereSplit(&pWInfo->sWC, pWhere, TK_AND); |
| 110204 | 110405 | sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */ |
| 110205 | 110406 | |
| 110206 | 110407 | /* Special case: a WHERE clause that is constant. Evaluate the |
| 110207 | 110408 | ** expression and either jump over all of the code or fall thru. |
| 110208 | 110409 | */ |
| | @@ -110832,11 +111033,11 @@ |
| 110832 | 111033 | #endif |
| 110833 | 111034 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 110834 | 111035 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 110835 | 111036 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 110836 | 111037 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 110837 | | -#define YYNSTATE 627 |
| 111038 | +#define YYNSTATE 628 |
| 110838 | 111039 | #define YYNRULE 327 |
| 110839 | 111040 | #define YYFALLBACK 1 |
| 110840 | 111041 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 110841 | 111042 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 110842 | 111043 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| | @@ -110905,167 +111106,167 @@ |
| 110905 | 111106 | ** shifting non-terminals after a reduce. |
| 110906 | 111107 | ** yy_default[] Default action for each state. |
| 110907 | 111108 | */ |
| 110908 | 111109 | #define YY_ACTTAB_COUNT (1564) |
| 110909 | 111110 | static const YYACTIONTYPE yy_action[] = { |
| 110910 | | - /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56, |
| 111111 | + /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56, |
| 110911 | 111112 | /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52, |
| 110912 | | - /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234, |
| 110913 | | - /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54, |
| 110914 | | - /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57, |
| 110915 | | - /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 110916 | | - /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52, |
| 110917 | | - /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194, |
| 111113 | + /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234, |
| 111114 | + /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54, |
| 111115 | + /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57, |
| 111116 | + /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 111117 | + /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52, |
| 111118 | + /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194, |
| 110918 | 111119 | /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 110919 | | - /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376, |
| 110920 | | - /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59, |
| 111120 | + /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377, |
| 111121 | + /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59, |
| 110921 | 111122 | /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146, |
| 110922 | | - /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580, |
| 111123 | + /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581, |
| 110923 | 111124 | /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54, |
| 110924 | | - /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223, |
| 110925 | | - /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168, |
| 110926 | | - /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438, |
| 110927 | | - /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581, |
| 110928 | | - /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439, |
| 110929 | | - /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48, |
| 110930 | | - /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56, |
| 110931 | | - /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 110932 | | - /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385, |
| 110933 | | - /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262, |
| 110934 | | - /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568, |
| 110935 | | - /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380, |
| 110936 | | - /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592, |
| 110937 | | - /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55, |
| 110938 | | - /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53, |
| 110939 | | - /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616, |
| 110940 | | - /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548, |
| 110941 | | - /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618, |
| 110942 | | - /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598, |
| 110943 | | - /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512, |
| 110944 | | - /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578, |
| 110945 | | - /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54, |
| 111125 | + /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223, |
| 111126 | + /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168, |
| 111127 | + /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439, |
| 111128 | + /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582, |
| 111129 | + /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440, |
| 111130 | + /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48, |
| 111131 | + /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 111132 | + /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111133 | + /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386, |
| 111134 | + /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263, |
| 111135 | + /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569, |
| 111136 | + /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381, |
| 111137 | + /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593, |
| 111138 | + /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 111139 | + /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53, |
| 111140 | + /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617, |
| 111141 | + /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549, |
| 111142 | + /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619, |
| 111143 | + /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599, |
| 111144 | + /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513, |
| 111145 | + /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579, |
| 111146 | + /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54, |
| 110946 | 111147 | /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 110947 | | - /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617, |
| 110948 | | - /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619, |
| 110949 | | - /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489, |
| 110950 | | - /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469, |
| 110951 | | - /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57, |
| 110952 | | - /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 111148 | + /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618, |
| 111149 | + /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620, |
| 111150 | + /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490, |
| 111151 | + /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470, |
| 111152 | + /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57, |
| 111153 | + /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 110953 | 111154 | /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52, |
| 110954 | | - /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576, |
| 110955 | | - /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504, |
| 110956 | | - /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181, |
| 110957 | | - /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561, |
| 110958 | | - /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598, |
| 110959 | | - /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580, |
| 110960 | | - /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54, |
| 110961 | | - /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327, |
| 110962 | | - /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248, |
| 110963 | | - /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557, |
| 110964 | | - /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581, |
| 110965 | | - /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69, |
| 110966 | | - /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48, |
| 110967 | | - /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56, |
| 110968 | | - /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 110969 | | - /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597, |
| 110970 | | - /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613, |
| 110971 | | - /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47, |
| 110972 | | - /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555, |
| 110973 | | - /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423, |
| 110974 | | - /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55, |
| 111155 | + /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577, |
| 111156 | + /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505, |
| 111157 | + /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181, |
| 111158 | + /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562, |
| 111159 | + /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599, |
| 111160 | + /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581, |
| 111161 | + /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54, |
| 111162 | + /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328, |
| 111163 | + /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248, |
| 111164 | + /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558, |
| 111165 | + /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582, |
| 111166 | + /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69, |
| 111167 | + /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48, |
| 111168 | + /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 111169 | + /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111170 | + /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598, |
| 111171 | + /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614, |
| 111172 | + /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47, |
| 111173 | + /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556, |
| 111174 | + /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424, |
| 111175 | + /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 110975 | 111176 | /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53, |
| 110976 | | - /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260, |
| 110977 | | - /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420, |
| 110978 | | - /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594, |
| 110979 | | - /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598, |
| 110980 | | - /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50, |
| 110981 | | - /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578, |
| 110982 | | - /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54, |
| 111177 | + /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261, |
| 111178 | + /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421, |
| 111179 | + /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595, |
| 111180 | + /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599, |
| 111181 | + /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50, |
| 111182 | + /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579, |
| 111183 | + /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54, |
| 110983 | 111184 | /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 110984 | | - /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362, |
| 110985 | | - /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412, |
| 110986 | | - /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412, |
| 110987 | | - /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521, |
| 110988 | | - /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57, |
| 110989 | | - /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 110990 | | - /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52, |
| 110991 | | - /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50, |
| 110992 | | - /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337, |
| 110993 | | - /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98, |
| 110994 | | - /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618, |
| 110995 | | - /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93, |
| 110996 | | - /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580, |
| 110997 | | - /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54, |
| 110998 | | - /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409, |
| 110999 | | - /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598, |
| 111000 | | - /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228, |
| 111001 | | - /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581, |
| 111002 | | - /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136, |
| 111003 | | - /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48, |
| 111004 | | - /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56, |
| 111005 | | - /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111006 | | - /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597, |
| 111007 | | - /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618, |
| 111008 | | - /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598, |
| 111009 | | - /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598, |
| 111010 | | - /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597, |
| 111011 | | - /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55, |
| 111012 | | - /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53, |
| 111013 | | - /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412, |
| 111014 | | - /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370, |
| 111015 | | - /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618, |
| 111016 | | - /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618, |
| 111017 | | - /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85, |
| 111018 | | - /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578, |
| 111019 | | - /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54, |
| 111185 | + /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363, |
| 111186 | + /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413, |
| 111187 | + /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413, |
| 111188 | + /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522, |
| 111189 | + /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57, |
| 111190 | + /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 111191 | + /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52, |
| 111192 | + /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50, |
| 111193 | + /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338, |
| 111194 | + /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98, |
| 111195 | + /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619, |
| 111196 | + /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93, |
| 111197 | + /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581, |
| 111198 | + /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54, |
| 111199 | + /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410, |
| 111200 | + /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599, |
| 111201 | + /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228, |
| 111202 | + /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582, |
| 111203 | + /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136, |
| 111204 | + /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48, |
| 111205 | + /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 111206 | + /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111207 | + /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598, |
| 111208 | + /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619, |
| 111209 | + /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599, |
| 111210 | + /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599, |
| 111211 | + /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598, |
| 111212 | + /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55, |
| 111213 | + /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53, |
| 111214 | + /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413, |
| 111215 | + /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371, |
| 111216 | + /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619, |
| 111217 | + /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619, |
| 111218 | + /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85, |
| 111219 | + /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579, |
| 111220 | + /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54, |
| 111020 | 111221 | /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 111021 | | - /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591, |
| 111022 | | - /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412, |
| 111023 | | - /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412, |
| 111024 | | - /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257, |
| 111025 | | - /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447, |
| 111026 | | - /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 111027 | | - /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52, |
| 111028 | | - /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459, |
| 111029 | | - /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348, |
| 111030 | | - /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618, |
| 111031 | | - /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412, |
| 111032 | | - /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216, |
| 111033 | | - /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618, |
| 111034 | | - /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123, |
| 111035 | | - /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411, |
| 111036 | | - /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598, |
| 111037 | | - /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598, |
| 111038 | | - /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597, |
| 111039 | | - /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13, |
| 111040 | | - /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3, |
| 111041 | | - /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590, |
| 111042 | | - /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34, |
| 111043 | | - /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330, |
| 111044 | | - /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79, |
| 111045 | | - /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610, |
| 111046 | | - /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235, |
| 111047 | | - /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618, |
| 111048 | | - /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61, |
| 111049 | | - /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618, |
| 111050 | | - /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31, |
| 111051 | | - /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589, |
| 111052 | | - /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299, |
| 111053 | | - /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590, |
| 111054 | | - /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533, |
| 111055 | | - /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240, |
| 111056 | | - /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486, |
| 111057 | | - /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371, |
| 111058 | | - /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476, |
| 111059 | | - /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116, |
| 111060 | | - /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111, |
| 111061 | | - /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606, |
| 111062 | | - /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570, |
| 111063 | | - /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302, |
| 111064 | | - /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444, |
| 111065 | | - /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399, |
| 111066 | | - /* 1560 */ 295, 498, 956, 488, |
| 111222 | + /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592, |
| 111223 | + /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413, |
| 111224 | + /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413, |
| 111225 | + /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258, |
| 111226 | + /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448, |
| 111227 | + /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 111228 | + /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52, |
| 111229 | + /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460, |
| 111230 | + /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349, |
| 111231 | + /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619, |
| 111232 | + /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413, |
| 111233 | + /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216, |
| 111234 | + /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619, |
| 111235 | + /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123, |
| 111236 | + /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412, |
| 111237 | + /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599, |
| 111238 | + /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599, |
| 111239 | + /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598, |
| 111240 | + /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13, |
| 111241 | + /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3, |
| 111242 | + /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591, |
| 111243 | + /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34, |
| 111244 | + /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331, |
| 111245 | + /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79, |
| 111246 | + /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611, |
| 111247 | + /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235, |
| 111248 | + /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619, |
| 111249 | + /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61, |
| 111250 | + /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619, |
| 111251 | + /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31, |
| 111252 | + /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590, |
| 111253 | + /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300, |
| 111254 | + /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591, |
| 111255 | + /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534, |
| 111256 | + /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240, |
| 111257 | + /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487, |
| 111258 | + /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372, |
| 111259 | + /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477, |
| 111260 | + /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116, |
| 111261 | + /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111, |
| 111262 | + /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427, |
| 111263 | + /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594, |
| 111264 | + /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403, |
| 111265 | + /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5, |
| 111266 | + /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369, |
| 111267 | + /* 1560 */ 400, 499, 523, 233, |
| 111067 | 111268 | }; |
| 111068 | 111269 | static const YYCODETYPE yy_lookahead[] = { |
| 111069 | 111270 | /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78, |
| 111070 | 111271 | /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, |
| 111071 | 111272 | /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197, |
| | @@ -111213,21 +111414,21 @@ |
| 111213 | 111414 | /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211, |
| 111214 | 111415 | /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42, |
| 111215 | 111416 | /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175, |
| 111216 | 111417 | /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18, |
| 111217 | 111418 | /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157, |
| 111218 | | - /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22, |
| 111419 | + /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22, |
| 111219 | 111420 | /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192, |
| 111220 | | - /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153, |
| 111221 | | - /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230, |
| 111222 | | - /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148, |
| 111223 | | - /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199, |
| 111224 | | - /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191, |
| 111225 | | - /* 1560 */ 195, 182, 250, 186, |
| 111421 | + /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38, |
| 111422 | + /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166, |
| 111423 | + /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226, |
| 111424 | + /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196, |
| 111425 | + /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234, |
| 111426 | + /* 1560 */ 191, 182, 173, 92, |
| 111226 | 111427 | }; |
| 111227 | 111428 | #define YY_SHIFT_USE_DFLT (-70) |
| 111228 | | -#define YY_SHIFT_COUNT (416) |
| 111429 | +#define YY_SHIFT_COUNT (417) |
| 111229 | 111430 | #define YY_SHIFT_MIN (-69) |
| 111230 | 111431 | #define YY_SHIFT_MAX (1487) |
| 111231 | 111432 | static const short yy_shift_ofst[] = { |
| 111232 | 111433 | /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19, |
| 111233 | 111434 | /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165, |
| | @@ -111240,44 +111441,44 @@ |
| 111240 | 111441 | /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869, |
| 111241 | 111442 | /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45, |
| 111242 | 111443 | /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362, |
| 111243 | 111444 | /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111244 | 111445 | /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362, |
| 111245 | | - /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57, |
| 111446 | + /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57, |
| 111246 | 111447 | /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362, |
| 111247 | 111448 | /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111248 | 111449 | /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111249 | 111450 | /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111250 | 111451 | /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70, |
| 111251 | 111452 | /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511, |
| 111252 | 111453 | /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12, |
| 111253 | 111454 | /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730, |
| 111254 | 111455 | /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723, |
| 111255 | | - /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308, |
| 111256 | | - /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487, |
| 111257 | | - /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441, |
| 111258 | | - /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348, |
| 111259 | | - /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348, |
| 111260 | | - /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280, |
| 111261 | | - /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338, |
| 111262 | | - /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013, |
| 111263 | | - /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667, |
| 111264 | | - /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300, |
| 111265 | | - /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139, |
| 111266 | | - /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174, |
| 111267 | | - /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147, |
| 111268 | | - /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057, |
| 111269 | | - /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955, |
| 111270 | | - /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747, |
| 111271 | | - /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579, |
| 111272 | | - /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120, |
| 111273 | | - /* 410 */ 92, 75, 45, 114, 25, 11, 5, |
| 111456 | + /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308, |
| 111457 | + /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487, |
| 111458 | + /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355, |
| 111459 | + /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, |
| 111460 | + /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, |
| 111461 | + /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, |
| 111462 | + /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, |
| 111463 | + /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, |
| 111464 | + /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760, |
| 111465 | + /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306, |
| 111466 | + /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, |
| 111467 | + /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, |
| 111468 | + /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, |
| 111469 | + /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, |
| 111470 | + /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910, |
| 111471 | + /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834, |
| 111472 | + /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603, |
| 111473 | + /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185, |
| 111474 | + /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5, |
| 111274 | 111475 | }; |
| 111275 | 111476 | #define YY_REDUCE_USE_DFLT (-169) |
| 111276 | | -#define YY_REDUCE_COUNT (308) |
| 111477 | +#define YY_REDUCE_COUNT (309) |
| 111277 | 111478 | #define YY_REDUCE_MIN (-168) |
| 111278 | | -#define YY_REDUCE_MAX (1391) |
| 111479 | +#define YY_REDUCE_MAX (1397) |
| 111279 | 111480 | static const short yy_reduce_ofst[] = { |
| 111280 | 111481 | /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104, |
| 111281 | 111482 | /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181, |
| 111282 | 111483 | /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962, |
| 111283 | 111484 | /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813, |
| | @@ -111294,87 +111495,87 @@ |
| 111294 | 111495 | /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222, |
| 111295 | 111496 | /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158, |
| 111296 | 111497 | /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072, |
| 111297 | 111498 | /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894, |
| 111298 | 111499 | /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646, |
| 111299 | | - /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368, |
| 111300 | | - /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365, |
| 111301 | | - /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341, |
| 111302 | | - /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333, |
| 111303 | | - /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358, |
| 111304 | | - /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312, |
| 111305 | | - /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248, |
| 111306 | | - /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295, |
| 111307 | | - /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281, |
| 111308 | | - /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189, |
| 111309 | | - /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216, |
| 111310 | | - /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164, |
| 111500 | + /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369, |
| 111501 | + /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352, |
| 111502 | + /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341, |
| 111503 | + /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318, |
| 111504 | + /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358, |
| 111505 | + /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312, |
| 111506 | + /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252, |
| 111507 | + /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, |
| 111508 | + /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, |
| 111509 | + /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, |
| 111510 | + /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, |
| 111511 | + /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164, |
| 111311 | 111512 | }; |
| 111312 | 111513 | static const YYACTIONTYPE yy_default[] = { |
| 111313 | | - /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756, |
| 111314 | | - /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954, |
| 111315 | | - /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111316 | | - /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111317 | | - /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111318 | | - /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111319 | | - /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790, |
| 111320 | | - /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929, |
| 111321 | | - /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861, |
| 111322 | | - /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843, |
| 111323 | | - /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954, |
| 111324 | | - /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111325 | | - /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954, |
| 111326 | | - /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663, |
| 111327 | | - /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111328 | | - /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954, |
| 111329 | | - /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111330 | | - /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111331 | | - /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760, |
| 111332 | | - /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111333 | | - /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737, |
| 111334 | | - /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794, |
| 111335 | | - /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773, |
| 111336 | | - /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764, |
| 111337 | | - /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736, |
| 111338 | | - /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904, |
| 111339 | | - /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727, |
| 111340 | | - /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727, |
| 111341 | | - /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954, |
| 111342 | | - /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637, |
| 111343 | | - /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954, |
| 111344 | | - /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954, |
| 111345 | | - /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633, |
| 111346 | | - /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954, |
| 111347 | | - /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916, |
| 111348 | | - /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954, |
| 111349 | | - /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954, |
| 111350 | | - /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111351 | | - /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111352 | | - /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954, |
| 111353 | | - /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954, |
| 111354 | | - /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950, |
| 111355 | | - /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935, |
| 111356 | | - /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886, |
| 111357 | | - /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735, |
| 111358 | | - /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914, |
| 111359 | | - /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657, |
| 111360 | | - /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662, |
| 111361 | | - /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664, |
| 111362 | | - /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702, |
| 111363 | | - /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691, |
| 111364 | | - /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728, |
| 111365 | | - /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854, |
| 111366 | | - /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776, |
| 111367 | | - /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781, |
| 111368 | | - /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921, |
| 111369 | | - /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894, |
| 111370 | | - /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848, |
| 111371 | | - /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819, |
| 111372 | | - /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747, |
| 111373 | | - /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651, |
| 111374 | | - /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666, |
| 111375 | | - /* 620 */ 665, 639, 636, 635, 631, 630, 628, |
| 111514 | + /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757, |
| 111515 | + /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955, |
| 111516 | + /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111517 | + /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111518 | + /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111519 | + /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111520 | + /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791, |
| 111521 | + /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930, |
| 111522 | + /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862, |
| 111523 | + /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844, |
| 111524 | + /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955, |
| 111525 | + /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111526 | + /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955, |
| 111527 | + /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664, |
| 111528 | + /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111529 | + /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955, |
| 111530 | + /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111531 | + /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111532 | + /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761, |
| 111533 | + /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111534 | + /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738, |
| 111535 | + /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795, |
| 111536 | + /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774, |
| 111537 | + /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765, |
| 111538 | + /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737, |
| 111539 | + /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907, |
| 111540 | + /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728, |
| 111541 | + /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712, |
| 111542 | + /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765, |
| 111543 | + /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649, |
| 111544 | + /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682, |
| 111545 | + /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955, |
| 111546 | + /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111547 | + /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800, |
| 111548 | + /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111549 | + /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955, |
| 111550 | + /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955, |
| 111551 | + /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111552 | + /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111553 | + /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955, |
| 111554 | + /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816, |
| 111555 | + /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635, |
| 111556 | + /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937, |
| 111557 | + /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888, |
| 111558 | + /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739, |
| 111559 | + /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916, |
| 111560 | + /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870, |
| 111561 | + /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654, |
| 111562 | + /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717, |
| 111563 | + /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704, |
| 111564 | + /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693, |
| 111565 | + /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732, |
| 111566 | + /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812, |
| 111567 | + /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809, |
| 111568 | + /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750, |
| 111569 | + /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923, |
| 111570 | + /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893, |
| 111571 | + /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852, |
| 111572 | + /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821, |
| 111573 | + /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811, |
| 111574 | + /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650, |
| 111575 | + /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669, |
| 111576 | + /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629, |
| 111376 | 111577 | }; |
| 111377 | 111578 | |
| 111378 | 111579 | /* The next table maps tokens into fallback tokens. If a construct |
| 111379 | 111580 | ** like the following: |
| 111380 | 111581 | ** |
| | @@ -111842,11 +112043,11 @@ |
| 111842 | 112043 | /* 237 */ "case_operand ::=", |
| 111843 | 112044 | /* 238 */ "exprlist ::= nexprlist", |
| 111844 | 112045 | /* 239 */ "exprlist ::=", |
| 111845 | 112046 | /* 240 */ "nexprlist ::= nexprlist COMMA expr", |
| 111846 | 112047 | /* 241 */ "nexprlist ::= expr", |
| 111847 | | - /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP", |
| 112048 | + /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt", |
| 111848 | 112049 | /* 243 */ "uniqueflag ::= UNIQUE", |
| 111849 | 112050 | /* 244 */ "uniqueflag ::=", |
| 111850 | 112051 | /* 245 */ "idxlist_opt ::=", |
| 111851 | 112052 | /* 246 */ "idxlist_opt ::= LP idxlist RP", |
| 111852 | 112053 | /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder", |
| | @@ -112561,11 +112762,11 @@ |
| 112561 | 112762 | { 224, 0 }, |
| 112562 | 112763 | { 220, 1 }, |
| 112563 | 112764 | { 220, 0 }, |
| 112564 | 112765 | { 215, 3 }, |
| 112565 | 112766 | { 215, 1 }, |
| 112566 | | - { 147, 11 }, |
| 112767 | + { 147, 12 }, |
| 112567 | 112768 | { 227, 1 }, |
| 112568 | 112769 | { 227, 0 }, |
| 112569 | 112770 | { 178, 0 }, |
| 112570 | 112771 | { 178, 3 }, |
| 112571 | 112772 | { 187, 5 }, |
| | @@ -113565,15 +113766,15 @@ |
| 113565 | 113766 | {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);} |
| 113566 | 113767 | break; |
| 113567 | 113768 | case 241: /* nexprlist ::= expr */ |
| 113568 | 113769 | {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);} |
| 113569 | 113770 | break; |
| 113570 | | - case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ |
| 113771 | + case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */ |
| 113571 | 113772 | { |
| 113572 | | - sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, |
| 113573 | | - sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392, |
| 113574 | | - &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392); |
| 113773 | + sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 113774 | + sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392, |
| 113775 | + &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392); |
| 113575 | 113776 | } |
| 113576 | 113777 | break; |
| 113577 | 113778 | case 243: /* uniqueflag ::= UNIQUE */ |
| 113578 | 113779 | case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296); |
| 113579 | 113780 | {yygotominor.yy392 = OE_Abort;} |
| | @@ -114495,11 +114696,10 @@ |
| 114495 | 114696 | *tokenType = TK_SPACE; |
| 114496 | 114697 | return i; |
| 114497 | 114698 | } |
| 114498 | 114699 | case '-': { |
| 114499 | 114700 | if( z[1]=='-' ){ |
| 114500 | | - /* IMP: R-50417-27976 -- syntax diagram for comments */ |
| 114501 | 114701 | for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
| 114502 | 114702 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 114503 | 114703 | return i; |
| 114504 | 114704 | } |
| 114505 | 114705 | *tokenType = TK_MINUS; |
| | @@ -114528,11 +114728,10 @@ |
| 114528 | 114728 | case '/': { |
| 114529 | 114729 | if( z[1]!='*' || z[2]==0 ){ |
| 114530 | 114730 | *tokenType = TK_SLASH; |
| 114531 | 114731 | return 1; |
| 114532 | 114732 | } |
| 114533 | | - /* IMP: R-50417-27976 -- syntax diagram for comments */ |
| 114534 | 114733 | for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
| 114535 | 114734 | if( c ) i++; |
| 114536 | 114735 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 114537 | 114736 | return i; |
| 114538 | 114737 | } |
| | @@ -116373,10 +116572,11 @@ |
| 116373 | 116572 | case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break; |
| 116374 | 116573 | case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break; |
| 116375 | 116574 | case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break; |
| 116376 | 116575 | case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break; |
| 116377 | 116576 | case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break; |
| 116577 | + case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break; |
| 116378 | 116578 | case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break; |
| 116379 | 116579 | case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break; |
| 116380 | 116580 | case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break; |
| 116381 | 116581 | case SQLITE_FULL: zName = "SQLITE_FULL"; break; |
| 116382 | 116582 | case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break; |
| | @@ -117728,11 +117928,11 @@ |
| 117728 | 117928 | db->autoCommit = 1; |
| 117729 | 117929 | db->nextAutovac = -1; |
| 117730 | 117930 | db->szMmap = sqlite3GlobalConfig.szMmap; |
| 117731 | 117931 | db->nextPagesize = 0; |
| 117732 | 117932 | db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger |
| 117733 | | -#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX |
| 117933 | +#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX |
| 117734 | 117934 | | SQLITE_AutoIndex |
| 117735 | 117935 | #endif |
| 117736 | 117936 | #if SQLITE_DEFAULT_FILE_FORMAT<4 |
| 117737 | 117937 | | SQLITE_LegacyFileFmt |
| 117738 | 117938 | #endif |
| | @@ -128201,11 +128401,11 @@ |
| 128201 | 128401 | } |
| 128202 | 128402 | |
| 128203 | 128403 | |
| 128204 | 128404 | #ifdef SQLITE_TEST |
| 128205 | 128405 | |
| 128206 | | -/* #include <tcl.h> */ |
| 128406 | +#include <tcl.h> |
| 128207 | 128407 | /* #include <string.h> */ |
| 128208 | 128408 | |
| 128209 | 128409 | /* |
| 128210 | 128410 | ** Implementation of a special SQL scalar function for testing tokenizers |
| 128211 | 128411 | ** designed to be used in concert with the Tcl testing framework. This |
| 128212 | 128412 | |