| | @@ -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-06 07:45:08 924f7e4d7a8fa2fe9100836663f3733b6e1a9084" |
| 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 */ |
| | @@ -8959,155 +8943,155 @@ |
| 8959 | 8943 | */ |
| 8960 | 8944 | /************** Include opcodes.h in the middle of vdbe.h ********************/ |
| 8961 | 8945 | /************** Begin file opcodes.h *****************************************/ |
| 8962 | 8946 | /* Automatically generated. Do not edit */ |
| 8963 | 8947 | /* See the mkopcodeh.awk script for details */ |
| 8964 | | -#define OP_Goto 1 |
| 8965 | | -#define OP_Gosub 2 |
| 8966 | | -#define OP_Return 3 |
| 8967 | | -#define OP_Yield 4 |
| 8968 | | -#define OP_HaltIfNull 5 |
| 8969 | | -#define OP_Halt 6 |
| 8970 | | -#define OP_Integer 7 |
| 8971 | | -#define OP_Int64 8 |
| 8972 | | -#define OP_Real 130 /* same as TK_FLOAT */ |
| 8973 | | -#define OP_String8 94 /* same as TK_STRING */ |
| 8974 | | -#define OP_String 9 |
| 8975 | | -#define OP_Null 10 |
| 8976 | | -#define OP_Blob 11 |
| 8977 | | -#define OP_Variable 12 |
| 8978 | | -#define OP_Move 13 |
| 8979 | | -#define OP_Copy 14 |
| 8980 | | -#define OP_SCopy 15 |
| 8981 | | -#define OP_ResultRow 16 |
| 8982 | | -#define OP_Concat 91 /* same as TK_CONCAT */ |
| 8948 | +#define OP_Function 1 |
| 8949 | +#define OP_Savepoint 2 |
| 8950 | +#define OP_AutoCommit 3 |
| 8951 | +#define OP_Transaction 4 |
| 8952 | +#define OP_SorterNext 5 |
| 8953 | +#define OP_Prev 6 |
| 8954 | +#define OP_Next 7 |
| 8955 | +#define OP_AggStep 8 |
| 8956 | +#define OP_Checkpoint 9 |
| 8957 | +#define OP_JournalMode 10 |
| 8958 | +#define OP_Vacuum 11 |
| 8959 | +#define OP_VFilter 12 |
| 8960 | +#define OP_VUpdate 13 |
| 8961 | +#define OP_Goto 14 |
| 8962 | +#define OP_Gosub 15 |
| 8963 | +#define OP_Return 16 |
| 8964 | +#define OP_Yield 17 |
| 8965 | +#define OP_HaltIfNull 18 |
| 8966 | +#define OP_Not 19 /* same as TK_NOT */ |
| 8967 | +#define OP_Halt 20 |
| 8968 | +#define OP_Integer 21 |
| 8969 | +#define OP_Int64 22 |
| 8970 | +#define OP_String 23 |
| 8971 | +#define OP_Null 24 |
| 8972 | +#define OP_Blob 25 |
| 8973 | +#define OP_Variable 26 |
| 8974 | +#define OP_Move 27 |
| 8975 | +#define OP_Copy 28 |
| 8976 | +#define OP_SCopy 29 |
| 8977 | +#define OP_ResultRow 30 |
| 8978 | +#define OP_CollSeq 31 |
| 8979 | +#define OP_AddImm 32 |
| 8980 | +#define OP_MustBeInt 33 |
| 8981 | +#define OP_RealAffinity 34 |
| 8982 | +#define OP_Permutation 35 |
| 8983 | +#define OP_Compare 36 |
| 8984 | +#define OP_Jump 37 |
| 8985 | +#define OP_Once 38 |
| 8986 | +#define OP_If 39 |
| 8987 | +#define OP_IfNot 40 |
| 8988 | +#define OP_Column 41 |
| 8989 | +#define OP_Affinity 42 |
| 8990 | +#define OP_MakeRecord 43 |
| 8991 | +#define OP_Count 44 |
| 8992 | +#define OP_ReadCookie 45 |
| 8993 | +#define OP_SetCookie 46 |
| 8994 | +#define OP_VerifyCookie 47 |
| 8995 | +#define OP_OpenRead 48 |
| 8996 | +#define OP_OpenWrite 49 |
| 8997 | +#define OP_OpenAutoindex 50 |
| 8998 | +#define OP_OpenEphemeral 51 |
| 8999 | +#define OP_SorterOpen 52 |
| 9000 | +#define OP_OpenPseudo 53 |
| 9001 | +#define OP_Close 54 |
| 9002 | +#define OP_SeekLt 55 |
| 9003 | +#define OP_SeekLe 56 |
| 9004 | +#define OP_SeekGe 57 |
| 9005 | +#define OP_SeekGt 58 |
| 9006 | +#define OP_Seek 59 |
| 9007 | +#define OP_NotFound 60 |
| 9008 | +#define OP_Found 61 |
| 9009 | +#define OP_IsUnique 62 |
| 9010 | +#define OP_NotExists 63 |
| 9011 | +#define OP_Sequence 64 |
| 9012 | +#define OP_NewRowid 65 |
| 9013 | +#define OP_Insert 66 |
| 9014 | +#define OP_InsertInt 67 |
| 9015 | +#define OP_Or 68 /* same as TK_OR */ |
| 9016 | +#define OP_And 69 /* same as TK_AND */ |
| 9017 | +#define OP_Delete 70 |
| 9018 | +#define OP_ResetCount 71 |
| 9019 | +#define OP_SorterCompare 72 |
| 9020 | +#define OP_IsNull 73 /* same as TK_ISNULL */ |
| 9021 | +#define OP_NotNull 74 /* same as TK_NOTNULL */ |
| 9022 | +#define OP_Ne 75 /* same as TK_NE */ |
| 9023 | +#define OP_Eq 76 /* same as TK_EQ */ |
| 9024 | +#define OP_Gt 77 /* same as TK_GT */ |
| 9025 | +#define OP_Le 78 /* same as TK_LE */ |
| 9026 | +#define OP_Lt 79 /* same as TK_LT */ |
| 9027 | +#define OP_Ge 80 /* same as TK_GE */ |
| 9028 | +#define OP_SorterData 81 |
| 9029 | +#define OP_BitAnd 82 /* same as TK_BITAND */ |
| 9030 | +#define OP_BitOr 83 /* same as TK_BITOR */ |
| 9031 | +#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ |
| 9032 | +#define OP_ShiftRight 85 /* same as TK_RSHIFT */ |
| 8983 | 9033 | #define OP_Add 86 /* same as TK_PLUS */ |
| 8984 | 9034 | #define OP_Subtract 87 /* same as TK_MINUS */ |
| 8985 | 9035 | #define OP_Multiply 88 /* same as TK_STAR */ |
| 8986 | 9036 | #define OP_Divide 89 /* same as TK_SLASH */ |
| 8987 | 9037 | #define OP_Remainder 90 /* same as TK_REM */ |
| 8988 | | -#define OP_CollSeq 17 |
| 8989 | | -#define OP_Function 18 |
| 8990 | | -#define OP_BitAnd 82 /* same as TK_BITAND */ |
| 8991 | | -#define OP_BitOr 83 /* same as TK_BITOR */ |
| 8992 | | -#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ |
| 8993 | | -#define OP_ShiftRight 85 /* same as TK_RSHIFT */ |
| 8994 | | -#define OP_AddImm 20 |
| 8995 | | -#define OP_MustBeInt 21 |
| 8996 | | -#define OP_RealAffinity 22 |
| 9038 | +#define OP_Concat 91 /* same as TK_CONCAT */ |
| 9039 | +#define OP_RowKey 92 |
| 9040 | +#define OP_BitNot 93 /* same as TK_BITNOT */ |
| 9041 | +#define OP_String8 94 /* same as TK_STRING */ |
| 9042 | +#define OP_RowData 95 |
| 9043 | +#define OP_Rowid 96 |
| 9044 | +#define OP_NullRow 97 |
| 9045 | +#define OP_Last 98 |
| 9046 | +#define OP_SorterSort 99 |
| 9047 | +#define OP_Sort 100 |
| 9048 | +#define OP_Rewind 101 |
| 9049 | +#define OP_SorterInsert 102 |
| 9050 | +#define OP_IdxInsert 103 |
| 9051 | +#define OP_IdxDelete 104 |
| 9052 | +#define OP_IdxRowid 105 |
| 9053 | +#define OP_IdxLT 106 |
| 9054 | +#define OP_IdxGE 107 |
| 9055 | +#define OP_Destroy 108 |
| 9056 | +#define OP_Clear 109 |
| 9057 | +#define OP_CreateIndex 110 |
| 9058 | +#define OP_CreateTable 111 |
| 9059 | +#define OP_ParseSchema 112 |
| 9060 | +#define OP_LoadAnalysis 113 |
| 9061 | +#define OP_DropTable 114 |
| 9062 | +#define OP_DropIndex 115 |
| 9063 | +#define OP_DropTrigger 116 |
| 9064 | +#define OP_IntegrityCk 117 |
| 9065 | +#define OP_RowSetAdd 118 |
| 9066 | +#define OP_RowSetRead 119 |
| 9067 | +#define OP_RowSetTest 120 |
| 9068 | +#define OP_Program 121 |
| 9069 | +#define OP_Param 122 |
| 9070 | +#define OP_FkCounter 123 |
| 9071 | +#define OP_FkIfZero 124 |
| 9072 | +#define OP_MemMax 125 |
| 9073 | +#define OP_IfPos 126 |
| 9074 | +#define OP_IfNeg 127 |
| 9075 | +#define OP_IfZero 128 |
| 9076 | +#define OP_AggFinal 129 |
| 9077 | +#define OP_Real 130 /* same as TK_FLOAT */ |
| 9078 | +#define OP_IncrVacuum 131 |
| 9079 | +#define OP_Expire 132 |
| 9080 | +#define OP_TableLock 133 |
| 9081 | +#define OP_VBegin 134 |
| 9082 | +#define OP_VCreate 135 |
| 9083 | +#define OP_VDestroy 136 |
| 9084 | +#define OP_VOpen 137 |
| 9085 | +#define OP_VColumn 138 |
| 9086 | +#define OP_VNext 139 |
| 9087 | +#define OP_VRename 140 |
| 8997 | 9088 | #define OP_ToText 141 /* same as TK_TO_TEXT */ |
| 8998 | 9089 | #define OP_ToBlob 142 /* same as TK_TO_BLOB */ |
| 8999 | 9090 | #define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ |
| 9000 | 9091 | #define OP_ToInt 144 /* same as TK_TO_INT */ |
| 9001 | 9092 | #define OP_ToReal 145 /* same as TK_TO_REAL */ |
| 9002 | | -#define OP_Eq 76 /* same as TK_EQ */ |
| 9003 | | -#define OP_Ne 75 /* same as TK_NE */ |
| 9004 | | -#define OP_Lt 79 /* same as TK_LT */ |
| 9005 | | -#define OP_Le 78 /* same as TK_LE */ |
| 9006 | | -#define OP_Gt 77 /* same as TK_GT */ |
| 9007 | | -#define OP_Ge 80 /* same as TK_GE */ |
| 9008 | | -#define OP_Permutation 23 |
| 9009 | | -#define OP_Compare 24 |
| 9010 | | -#define OP_Jump 25 |
| 9011 | | -#define OP_And 69 /* same as TK_AND */ |
| 9012 | | -#define OP_Or 68 /* same as TK_OR */ |
| 9013 | | -#define OP_Not 19 /* same as TK_NOT */ |
| 9014 | | -#define OP_BitNot 93 /* same as TK_BITNOT */ |
| 9015 | | -#define OP_Once 26 |
| 9016 | | -#define OP_If 27 |
| 9017 | | -#define OP_IfNot 28 |
| 9018 | | -#define OP_IsNull 73 /* same as TK_ISNULL */ |
| 9019 | | -#define OP_NotNull 74 /* same as TK_NOTNULL */ |
| 9020 | | -#define OP_Column 29 |
| 9021 | | -#define OP_Affinity 30 |
| 9022 | | -#define OP_MakeRecord 31 |
| 9023 | | -#define OP_Count 32 |
| 9024 | | -#define OP_Savepoint 33 |
| 9025 | | -#define OP_AutoCommit 34 |
| 9026 | | -#define OP_Transaction 35 |
| 9027 | | -#define OP_ReadCookie 36 |
| 9028 | | -#define OP_SetCookie 37 |
| 9029 | | -#define OP_VerifyCookie 38 |
| 9030 | | -#define OP_OpenRead 39 |
| 9031 | | -#define OP_OpenWrite 40 |
| 9032 | | -#define OP_OpenAutoindex 41 |
| 9033 | | -#define OP_OpenEphemeral 42 |
| 9034 | | -#define OP_SorterOpen 43 |
| 9035 | | -#define OP_OpenPseudo 44 |
| 9036 | | -#define OP_Close 45 |
| 9037 | | -#define OP_SeekLt 46 |
| 9038 | | -#define OP_SeekLe 47 |
| 9039 | | -#define OP_SeekGe 48 |
| 9040 | | -#define OP_SeekGt 49 |
| 9041 | | -#define OP_Seek 50 |
| 9042 | | -#define OP_NotFound 51 |
| 9043 | | -#define OP_Found 52 |
| 9044 | | -#define OP_IsUnique 53 |
| 9045 | | -#define OP_NotExists 54 |
| 9046 | | -#define OP_Sequence 55 |
| 9047 | | -#define OP_NewRowid 56 |
| 9048 | | -#define OP_Insert 57 |
| 9049 | | -#define OP_InsertInt 58 |
| 9050 | | -#define OP_Delete 59 |
| 9051 | | -#define OP_ResetCount 60 |
| 9052 | | -#define OP_SorterCompare 61 |
| 9053 | | -#define OP_SorterData 62 |
| 9054 | | -#define OP_RowKey 63 |
| 9055 | | -#define OP_RowData 64 |
| 9056 | | -#define OP_Rowid 65 |
| 9057 | | -#define OP_NullRow 66 |
| 9058 | | -#define OP_Last 67 |
| 9059 | | -#define OP_SorterSort 70 |
| 9060 | | -#define OP_Sort 71 |
| 9061 | | -#define OP_Rewind 72 |
| 9062 | | -#define OP_SorterNext 81 |
| 9063 | | -#define OP_Prev 92 |
| 9064 | | -#define OP_Next 95 |
| 9065 | | -#define OP_SorterInsert 96 |
| 9066 | | -#define OP_IdxInsert 97 |
| 9067 | | -#define OP_IdxDelete 98 |
| 9068 | | -#define OP_IdxRowid 99 |
| 9069 | | -#define OP_IdxLT 100 |
| 9070 | | -#define OP_IdxGE 101 |
| 9071 | | -#define OP_Destroy 102 |
| 9072 | | -#define OP_Clear 103 |
| 9073 | | -#define OP_CreateIndex 104 |
| 9074 | | -#define OP_CreateTable 105 |
| 9075 | | -#define OP_ParseSchema 106 |
| 9076 | | -#define OP_LoadAnalysis 107 |
| 9077 | | -#define OP_DropTable 108 |
| 9078 | | -#define OP_DropIndex 109 |
| 9079 | | -#define OP_DropTrigger 110 |
| 9080 | | -#define OP_IntegrityCk 111 |
| 9081 | | -#define OP_RowSetAdd 112 |
| 9082 | | -#define OP_RowSetRead 113 |
| 9083 | | -#define OP_RowSetTest 114 |
| 9084 | | -#define OP_Program 115 |
| 9085 | | -#define OP_Param 116 |
| 9086 | | -#define OP_FkCounter 117 |
| 9087 | | -#define OP_FkIfZero 118 |
| 9088 | | -#define OP_MemMax 119 |
| 9089 | | -#define OP_IfPos 120 |
| 9090 | | -#define OP_IfNeg 121 |
| 9091 | | -#define OP_IfZero 122 |
| 9092 | | -#define OP_AggStep 123 |
| 9093 | | -#define OP_AggFinal 124 |
| 9094 | | -#define OP_Checkpoint 125 |
| 9095 | | -#define OP_JournalMode 126 |
| 9096 | | -#define OP_Vacuum 127 |
| 9097 | | -#define OP_IncrVacuum 128 |
| 9098 | | -#define OP_Expire 129 |
| 9099 | | -#define OP_TableLock 131 |
| 9100 | | -#define OP_VBegin 132 |
| 9101 | | -#define OP_VCreate 133 |
| 9102 | | -#define OP_VDestroy 134 |
| 9103 | | -#define OP_VOpen 135 |
| 9104 | | -#define OP_VFilter 136 |
| 9105 | | -#define OP_VColumn 137 |
| 9106 | | -#define OP_VNext 138 |
| 9107 | | -#define OP_VRename 139 |
| 9108 | | -#define OP_VUpdate 140 |
| 9109 | 9093 | #define OP_Pagecount 146 |
| 9110 | 9094 | #define OP_MaxPgcnt 147 |
| 9111 | 9095 | #define OP_Trace 148 |
| 9112 | 9096 | #define OP_Noop 149 |
| 9113 | 9097 | #define OP_Explain 150 |
| | @@ -9123,28 +9107,28 @@ |
| 9123 | 9107 | #define OPFLG_IN2 0x0008 /* in2: P2 is an input */ |
| 9124 | 9108 | #define OPFLG_IN3 0x0010 /* in3: P3 is an input */ |
| 9125 | 9109 | #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */ |
| 9126 | 9110 | #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ |
| 9127 | 9111 | #define OPFLG_INITIALIZER {\ |
| 9128 | | -/* 0 */ 0x00, 0x01, 0x01, 0x04, 0x04, 0x10, 0x00, 0x02,\ |
| 9129 | | -/* 8 */ 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24,\ |
| 9130 | | -/* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\ |
| 9131 | | -/* 24 */ 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00,\ |
| 9132 | | -/* 32 */ 0x02, 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00,\ |
| 9133 | | -/* 40 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\ |
| 9134 | | -/* 48 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x02,\ |
| 9135 | | -/* 56 */ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 9136 | | -/* 64 */ 0x00, 0x02, 0x00, 0x01, 0x4c, 0x4c, 0x01, 0x01,\ |
| 9137 | | -/* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\ |
| 9138 | | -/* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\ |
| 9139 | | -/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x01, 0x24, 0x02, 0x01,\ |
| 9140 | | -/* 96 */ 0x08, 0x08, 0x00, 0x02, 0x01, 0x01, 0x02, 0x00,\ |
| 9141 | | -/* 104 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 9142 | | -/* 112 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\ |
| 9143 | | -/* 120 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00,\ |
| 9144 | | -/* 128 */ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 9145 | | -/* 136 */ 0x01, 0x00, 0x01, 0x00, 0x00, 0x04, 0x04, 0x04,\ |
| 9112 | +/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\ |
| 9113 | +/* 8 */ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01,\ |
| 9114 | +/* 16 */ 0x04, 0x04, 0x10, 0x24, 0x00, 0x02, 0x02, 0x02,\ |
| 9115 | +/* 24 */ 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x00, 0x00,\ |
| 9116 | +/* 32 */ 0x04, 0x05, 0x04, 0x00, 0x00, 0x01, 0x01, 0x05,\ |
| 9117 | +/* 40 */ 0x05, 0x00, 0x00, 0x00, 0x02, 0x02, 0x10, 0x00,\ |
| 9118 | +/* 48 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,\ |
| 9119 | +/* 56 */ 0x11, 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11,\ |
| 9120 | +/* 64 */ 0x02, 0x02, 0x00, 0x00, 0x4c, 0x4c, 0x00, 0x00,\ |
| 9121 | +/* 72 */ 0x00, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\ |
| 9122 | +/* 80 */ 0x15, 0x00, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\ |
| 9123 | +/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x00, 0x24, 0x02, 0x00,\ |
| 9124 | +/* 96 */ 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08,\ |
| 9125 | +/* 104 */ 0x00, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02,\ |
| 9126 | +/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\ |
| 9127 | +/* 120 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x08, 0x05, 0x05,\ |
| 9128 | +/* 128 */ 0x05, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,\ |
| 9129 | +/* 136 */ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x04, 0x04,\ |
| 9146 | 9130 | /* 144 */ 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00,} |
| 9147 | 9131 | |
| 9148 | 9132 | /************** End of opcodes.h *********************************************/ |
| 9149 | 9133 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 9150 | 9134 | |
| | @@ -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 | |
| | @@ -10688,16 +10672,20 @@ |
| 10688 | 10672 | |
| 10689 | 10673 | /* |
| 10690 | 10674 | ** An instance of the following structure is passed as the first |
| 10691 | 10675 | ** argument to sqlite3VdbeKeyCompare and is used to control the |
| 10692 | 10676 | ** comparison of the two index keys. |
| 10677 | +** |
| 10678 | +** Note that aSortOrder[] and aColl[] have nField+1 slots. There |
| 10679 | +** are nField slots for the columns of an index then one extra slot |
| 10680 | +** for the rowid at the end. |
| 10693 | 10681 | */ |
| 10694 | 10682 | struct KeyInfo { |
| 10695 | 10683 | sqlite3 *db; /* The database connection */ |
| 10696 | 10684 | u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ |
| 10697 | | - u16 nField; /* Number of entries in aColl[] */ |
| 10698 | | - u8 *aSortOrder; /* Sort order for each column. May be NULL */ |
| 10685 | + u16 nField; /* Maximum index for aColl[] and aSortOrder[] */ |
| 10686 | + u8 *aSortOrder; /* Sort order for each column. */ |
| 10699 | 10687 | CollSeq *aColl[1]; /* Collating sequence for each term of the key */ |
| 10700 | 10688 | }; |
| 10701 | 10689 | |
| 10702 | 10690 | /* |
| 10703 | 10691 | ** An instance of the following structure holds information about a |
| | @@ -10762,10 +10750,11 @@ |
| 10762 | 10750 | char *zColAff; /* String defining the affinity of each column */ |
| 10763 | 10751 | Index *pNext; /* The next index associated with the same table */ |
| 10764 | 10752 | Schema *pSchema; /* Schema containing this index */ |
| 10765 | 10753 | u8 *aSortOrder; /* for each column: True==DESC, False==ASC */ |
| 10766 | 10754 | char **azColl; /* Array of collation sequence names for index */ |
| 10755 | + Expr *pPartIdxWhere; /* WHERE clause for partial indices */ |
| 10767 | 10756 | int tnum; /* DB Page containing root of this index */ |
| 10768 | 10757 | u16 nColumn; /* Number of columns in table used by this index */ |
| 10769 | 10758 | u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 10770 | 10759 | unsigned autoIndex:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */ |
| 10771 | 10760 | unsigned bUnordered:1; /* Use this index for == or IN queries only */ |
| | @@ -11242,10 +11231,11 @@ |
| 11242 | 11231 | #define NC_HasAgg 0x02 /* One or more aggregate functions seen */ |
| 11243 | 11232 | #define NC_IsCheck 0x04 /* True if resolving names in a CHECK constraint */ |
| 11244 | 11233 | #define NC_InAggFunc 0x08 /* True if analyzing arguments to an agg func */ |
| 11245 | 11234 | #define NC_AsMaybe 0x10 /* Resolve to AS terms of the result set only |
| 11246 | 11235 | ** if no other resolution is available */ |
| 11236 | +#define NC_PartIdx 0x20 /* True if resolving a partial index WHERE */ |
| 11247 | 11237 | |
| 11248 | 11238 | /* |
| 11249 | 11239 | ** An instance of the following structure contains all information |
| 11250 | 11240 | ** needed to generate code for a single SELECT statement. |
| 11251 | 11241 | ** |
| | @@ -11296,10 +11286,11 @@ |
| 11296 | 11286 | #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */ |
| 11297 | 11287 | #define SF_UseSorter 0x0040 /* Sort using a sorter */ |
| 11298 | 11288 | #define SF_Values 0x0080 /* Synthesized from VALUES clause */ |
| 11299 | 11289 | #define SF_Materialize 0x0100 /* Force materialization of views */ |
| 11300 | 11290 | #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */ |
| 11291 | +#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */ |
| 11301 | 11292 | |
| 11302 | 11293 | |
| 11303 | 11294 | /* |
| 11304 | 11295 | ** The results of a select can be distributed in several ways. The |
| 11305 | 11296 | ** "SRT" prefix means "SELECT Result Type". |
| | @@ -11417,19 +11408,21 @@ |
| 11417 | 11408 | u8 nTempInUse; /* Number of aTempReg[] currently checked out */ |
| 11418 | 11409 | u8 nColCache; /* Number of entries in aColCache[] */ |
| 11419 | 11410 | u8 iColCache; /* Next entry in aColCache[] to replace */ |
| 11420 | 11411 | u8 isMultiWrite; /* True if statement may modify/insert multiple rows */ |
| 11421 | 11412 | u8 mayAbort; /* True if statement may throw an ABORT exception */ |
| 11413 | + u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ |
| 11422 | 11414 | int aTempReg[8]; /* Holding area for temporary registers */ |
| 11423 | 11415 | int nRangeReg; /* Size of the temporary register block */ |
| 11424 | 11416 | int iRangeReg; /* First register in temporary register block */ |
| 11425 | 11417 | int nErr; /* Number of errors seen */ |
| 11426 | 11418 | int nTab; /* Number of previously allocated VDBE cursors */ |
| 11427 | 11419 | int nMem; /* Number of memory cells used so far */ |
| 11428 | 11420 | int nSet; /* Number of sets used so far */ |
| 11429 | 11421 | int nOnce; /* Number of OP_Once instructions so far */ |
| 11430 | 11422 | int ckBase; /* Base register of data during check constraints */ |
| 11423 | + int iPartIdxTab; /* Table corresponding to a partial index */ |
| 11431 | 11424 | int iCacheLevel; /* ColCache valid when aColCache[].iLevel<=iCacheLevel */ |
| 11432 | 11425 | int iCacheCnt; /* Counter used to generate aColCache[].lru values */ |
| 11433 | 11426 | struct yColCache { |
| 11434 | 11427 | int iTable; /* Table cursor number */ |
| 11435 | 11428 | int iColumn; /* Table column number */ |
| | @@ -12007,11 +12000,11 @@ |
| 12007 | 12000 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); |
| 12008 | 12001 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
| 12009 | 12002 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); |
| 12010 | 12003 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*); |
| 12011 | 12004 | SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 12012 | | - Token*, int, int); |
| 12005 | + Expr*, int, int); |
| 12013 | 12006 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 12014 | 12007 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 12015 | 12008 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 12016 | 12009 | Expr*,ExprList*,u16,Expr*,Expr*); |
| 12017 | 12010 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| | @@ -12055,12 +12048,13 @@ |
| 12055 | 12048 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); |
| 12056 | 12049 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
| 12057 | 12050 | SQLITE_PRIVATE void sqlite3Vacuum(Parse*); |
| 12058 | 12051 | SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*); |
| 12059 | 12052 | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*); |
| 12060 | | -SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*); |
| 12061 | | -SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*); |
| 12053 | +SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int); |
| 12054 | +SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int); |
| 12055 | +SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int); |
| 12062 | 12056 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 12063 | 12057 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 12064 | 12058 | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); |
| 12065 | 12059 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| 12066 | 12060 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); |
| | @@ -12083,11 +12077,11 @@ |
| 12083 | 12077 | SQLITE_PRIVATE void sqlite3ExprCodeIsNullJump(Vdbe*, const Expr*, int, int); |
| 12084 | 12078 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 12085 | 12079 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| 12086 | 12080 | SQLITE_PRIVATE void sqlite3GenerateRowDelete(Parse*, Table*, int, int, int, Trigger *, int); |
| 12087 | 12081 | SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int*); |
| 12088 | | -SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int); |
| 12082 | +SQLITE_PRIVATE int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*); |
| 12089 | 12083 | SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int,int, |
| 12090 | 12084 | int*,int,int,int,int,int*); |
| 12091 | 12085 | SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*, Table*, int, int, int*, int, int, int); |
| 12092 | 12086 | SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, int); |
| 12093 | 12087 | SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int); |
| | @@ -12286,10 +12280,11 @@ |
| 12286 | 12280 | SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *, Expr *, int, int); |
| 12287 | 12281 | SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); |
| 12288 | 12282 | SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*); |
| 12289 | 12283 | SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*); |
| 12290 | 12284 | SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*); |
| 12285 | +SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*); |
| 12291 | 12286 | SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*); |
| 12292 | 12287 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); |
| 12293 | 12288 | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); |
| 12294 | 12289 | SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); |
| 12295 | 12290 | SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); |
| | @@ -12305,10 +12300,11 @@ |
| 12305 | 12300 | SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3*,Expr*,int*,char*); |
| 12306 | 12301 | SQLITE_PRIVATE void sqlite3MinimumFileFormat(Parse*, int, int); |
| 12307 | 12302 | SQLITE_PRIVATE void sqlite3SchemaClear(void *); |
| 12308 | 12303 | SQLITE_PRIVATE Schema *sqlite3SchemaGet(sqlite3 *, Btree *); |
| 12309 | 12304 | SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *); |
| 12305 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int); |
| 12310 | 12306 | SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *, Index *); |
| 12311 | 12307 | SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, |
| 12312 | 12308 | void (*)(sqlite3_context*,int,sqlite3_value **), |
| 12313 | 12309 | void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*), |
| 12314 | 12310 | FuncDestructor *pDestructor |
| | @@ -13257,10 +13253,13 @@ |
| 13257 | 13253 | typedef struct VdbeSorter VdbeSorter; |
| 13258 | 13254 | |
| 13259 | 13255 | /* Opaque type used by the explainer */ |
| 13260 | 13256 | typedef struct Explain Explain; |
| 13261 | 13257 | |
| 13258 | +/* Elements of the linked list at Vdbe.pAuxData */ |
| 13259 | +typedef struct AuxData AuxData; |
| 13260 | + |
| 13262 | 13261 | /* |
| 13263 | 13262 | ** A cursor is a pointer into a single BTree within a database file. |
| 13264 | 13263 | ** The cursor can seek to a BTree entry with a particular key, or |
| 13265 | 13264 | ** loop over all entries of the Btree. You can also insert new BTree |
| 13266 | 13265 | ** entries or retrieve the key or data from the entry that the cursor |
| | @@ -13443,27 +13442,23 @@ |
| 13443 | 13442 | */ |
| 13444 | 13443 | #ifdef SQLITE_DEBUG |
| 13445 | 13444 | #define memIsValid(M) ((M)->flags & MEM_Invalid)==0 |
| 13446 | 13445 | #endif |
| 13447 | 13446 | |
| 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. |
| 13447 | +/* |
| 13448 | +** Each auxilliary data pointer stored by a user defined function |
| 13449 | +** implementation calling sqlite3_set_auxdata() is stored in an instance |
| 13450 | +** of this structure. All such structures associated with a single VM |
| 13451 | +** are stored in a linked list headed at Vdbe.pAuxData. All are destroyed |
| 13452 | +** when the VM is halted (if not before). |
| 13457 | 13453 | */ |
| 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 */ |
| 13454 | +struct AuxData { |
| 13455 | + int iOp; /* Instruction number of OP_Function opcode */ |
| 13456 | + int iArg; /* Index of function argument. */ |
| 13457 | + void *pAux; /* Aux data pointer */ |
| 13458 | + void (*xDelete)(void *); /* Destructor for the aux data */ |
| 13459 | + AuxData *pNext; /* Next element in list */ |
| 13465 | 13460 | }; |
| 13466 | 13461 | |
| 13467 | 13462 | /* |
| 13468 | 13463 | ** The "context" argument for a installable function. A pointer to an |
| 13469 | 13464 | ** instance of this structure is the first argument to the routines used |
| | @@ -13477,16 +13472,17 @@ |
| 13477 | 13472 | ** This structure is defined inside of vdbeInt.h because it uses substructures |
| 13478 | 13473 | ** (Mem) which are only defined there. |
| 13479 | 13474 | */ |
| 13480 | 13475 | struct sqlite3_context { |
| 13481 | 13476 | FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */ |
| 13482 | | - VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */ |
| 13483 | 13477 | Mem s; /* The return value is stored here */ |
| 13484 | 13478 | Mem *pMem; /* Memory cell used to store aggregate context */ |
| 13485 | 13479 | CollSeq *pColl; /* Collating sequence */ |
| 13486 | 13480 | int isError; /* Error code returned by the function. */ |
| 13487 | 13481 | int skipFlag; /* Skip skip accumulator loading if true */ |
| 13482 | + int iOp; /* Instruction number of OP_Function */ |
| 13483 | + Vdbe *pVdbe; /* The VM that owns this context */ |
| 13488 | 13484 | }; |
| 13489 | 13485 | |
| 13490 | 13486 | /* |
| 13491 | 13487 | ** An Explain object accumulates indented output which is helpful |
| 13492 | 13488 | ** in describing recursive data structures. |
| | @@ -13581,10 +13577,11 @@ |
| 13581 | 13577 | int nFrame; /* Number of frames in pFrame list */ |
| 13582 | 13578 | u32 expmask; /* Binding to these vars invalidates VM */ |
| 13583 | 13579 | SubProgram *pProgram; /* Linked list of all sub-programs used by VM */ |
| 13584 | 13580 | int nOnceFlag; /* Size of array aOnceFlag[] */ |
| 13585 | 13581 | u8 *aOnceFlag; /* Flags for OP_Once */ |
| 13582 | + AuxData *pAuxData; /* Linked list of auxdata allocations */ |
| 13586 | 13583 | }; |
| 13587 | 13584 | |
| 13588 | 13585 | /* |
| 13589 | 13586 | ** The following are allowed values for Vdbe.magic |
| 13590 | 13587 | */ |
| | @@ -13604,11 +13601,11 @@ |
| 13604 | 13601 | #endif |
| 13605 | 13602 | SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32); |
| 13606 | 13603 | SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem*, int); |
| 13607 | 13604 | SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, int, Mem*, int); |
| 13608 | 13605 | SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*); |
| 13609 | | -SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc*, int); |
| 13606 | +SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe*, int, int); |
| 13610 | 13607 | |
| 13611 | 13608 | int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *); |
| 13612 | 13609 | SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare(VdbeCursor*,UnpackedRecord*,int*); |
| 13613 | 13610 | SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3*, BtCursor *, i64 *); |
| 13614 | 13611 | SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); |
| | @@ -22703,91 +22700,91 @@ |
| 22703 | 22700 | /* Automatically generated. Do not edit */ |
| 22704 | 22701 | /* See the mkopcodec.awk script for details. */ |
| 22705 | 22702 | #if !defined(SQLITE_OMIT_EXPLAIN) || !defined(NDEBUG) || defined(VDBE_PROFILE) || defined(SQLITE_DEBUG) |
| 22706 | 22703 | SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ |
| 22707 | 22704 | static const char *const azName[] = { "?", |
| 22708 | | - /* 1 */ "Goto", |
| 22709 | | - /* 2 */ "Gosub", |
| 22710 | | - /* 3 */ "Return", |
| 22711 | | - /* 4 */ "Yield", |
| 22712 | | - /* 5 */ "HaltIfNull", |
| 22713 | | - /* 6 */ "Halt", |
| 22714 | | - /* 7 */ "Integer", |
| 22715 | | - /* 8 */ "Int64", |
| 22716 | | - /* 9 */ "String", |
| 22717 | | - /* 10 */ "Null", |
| 22718 | | - /* 11 */ "Blob", |
| 22719 | | - /* 12 */ "Variable", |
| 22720 | | - /* 13 */ "Move", |
| 22721 | | - /* 14 */ "Copy", |
| 22722 | | - /* 15 */ "SCopy", |
| 22723 | | - /* 16 */ "ResultRow", |
| 22724 | | - /* 17 */ "CollSeq", |
| 22725 | | - /* 18 */ "Function", |
| 22705 | + /* 1 */ "Function", |
| 22706 | + /* 2 */ "Savepoint", |
| 22707 | + /* 3 */ "AutoCommit", |
| 22708 | + /* 4 */ "Transaction", |
| 22709 | + /* 5 */ "SorterNext", |
| 22710 | + /* 6 */ "Prev", |
| 22711 | + /* 7 */ "Next", |
| 22712 | + /* 8 */ "AggStep", |
| 22713 | + /* 9 */ "Checkpoint", |
| 22714 | + /* 10 */ "JournalMode", |
| 22715 | + /* 11 */ "Vacuum", |
| 22716 | + /* 12 */ "VFilter", |
| 22717 | + /* 13 */ "VUpdate", |
| 22718 | + /* 14 */ "Goto", |
| 22719 | + /* 15 */ "Gosub", |
| 22720 | + /* 16 */ "Return", |
| 22721 | + /* 17 */ "Yield", |
| 22722 | + /* 18 */ "HaltIfNull", |
| 22726 | 22723 | /* 19 */ "Not", |
| 22727 | | - /* 20 */ "AddImm", |
| 22728 | | - /* 21 */ "MustBeInt", |
| 22729 | | - /* 22 */ "RealAffinity", |
| 22730 | | - /* 23 */ "Permutation", |
| 22731 | | - /* 24 */ "Compare", |
| 22732 | | - /* 25 */ "Jump", |
| 22733 | | - /* 26 */ "Once", |
| 22734 | | - /* 27 */ "If", |
| 22735 | | - /* 28 */ "IfNot", |
| 22736 | | - /* 29 */ "Column", |
| 22737 | | - /* 30 */ "Affinity", |
| 22738 | | - /* 31 */ "MakeRecord", |
| 22739 | | - /* 32 */ "Count", |
| 22740 | | - /* 33 */ "Savepoint", |
| 22741 | | - /* 34 */ "AutoCommit", |
| 22742 | | - /* 35 */ "Transaction", |
| 22743 | | - /* 36 */ "ReadCookie", |
| 22744 | | - /* 37 */ "SetCookie", |
| 22745 | | - /* 38 */ "VerifyCookie", |
| 22746 | | - /* 39 */ "OpenRead", |
| 22747 | | - /* 40 */ "OpenWrite", |
| 22748 | | - /* 41 */ "OpenAutoindex", |
| 22749 | | - /* 42 */ "OpenEphemeral", |
| 22750 | | - /* 43 */ "SorterOpen", |
| 22751 | | - /* 44 */ "OpenPseudo", |
| 22752 | | - /* 45 */ "Close", |
| 22753 | | - /* 46 */ "SeekLt", |
| 22754 | | - /* 47 */ "SeekLe", |
| 22755 | | - /* 48 */ "SeekGe", |
| 22756 | | - /* 49 */ "SeekGt", |
| 22757 | | - /* 50 */ "Seek", |
| 22758 | | - /* 51 */ "NotFound", |
| 22759 | | - /* 52 */ "Found", |
| 22760 | | - /* 53 */ "IsUnique", |
| 22761 | | - /* 54 */ "NotExists", |
| 22762 | | - /* 55 */ "Sequence", |
| 22763 | | - /* 56 */ "NewRowid", |
| 22764 | | - /* 57 */ "Insert", |
| 22765 | | - /* 58 */ "InsertInt", |
| 22766 | | - /* 59 */ "Delete", |
| 22767 | | - /* 60 */ "ResetCount", |
| 22768 | | - /* 61 */ "SorterCompare", |
| 22769 | | - /* 62 */ "SorterData", |
| 22770 | | - /* 63 */ "RowKey", |
| 22771 | | - /* 64 */ "RowData", |
| 22772 | | - /* 65 */ "Rowid", |
| 22773 | | - /* 66 */ "NullRow", |
| 22774 | | - /* 67 */ "Last", |
| 22724 | + /* 20 */ "Halt", |
| 22725 | + /* 21 */ "Integer", |
| 22726 | + /* 22 */ "Int64", |
| 22727 | + /* 23 */ "String", |
| 22728 | + /* 24 */ "Null", |
| 22729 | + /* 25 */ "Blob", |
| 22730 | + /* 26 */ "Variable", |
| 22731 | + /* 27 */ "Move", |
| 22732 | + /* 28 */ "Copy", |
| 22733 | + /* 29 */ "SCopy", |
| 22734 | + /* 30 */ "ResultRow", |
| 22735 | + /* 31 */ "CollSeq", |
| 22736 | + /* 32 */ "AddImm", |
| 22737 | + /* 33 */ "MustBeInt", |
| 22738 | + /* 34 */ "RealAffinity", |
| 22739 | + /* 35 */ "Permutation", |
| 22740 | + /* 36 */ "Compare", |
| 22741 | + /* 37 */ "Jump", |
| 22742 | + /* 38 */ "Once", |
| 22743 | + /* 39 */ "If", |
| 22744 | + /* 40 */ "IfNot", |
| 22745 | + /* 41 */ "Column", |
| 22746 | + /* 42 */ "Affinity", |
| 22747 | + /* 43 */ "MakeRecord", |
| 22748 | + /* 44 */ "Count", |
| 22749 | + /* 45 */ "ReadCookie", |
| 22750 | + /* 46 */ "SetCookie", |
| 22751 | + /* 47 */ "VerifyCookie", |
| 22752 | + /* 48 */ "OpenRead", |
| 22753 | + /* 49 */ "OpenWrite", |
| 22754 | + /* 50 */ "OpenAutoindex", |
| 22755 | + /* 51 */ "OpenEphemeral", |
| 22756 | + /* 52 */ "SorterOpen", |
| 22757 | + /* 53 */ "OpenPseudo", |
| 22758 | + /* 54 */ "Close", |
| 22759 | + /* 55 */ "SeekLt", |
| 22760 | + /* 56 */ "SeekLe", |
| 22761 | + /* 57 */ "SeekGe", |
| 22762 | + /* 58 */ "SeekGt", |
| 22763 | + /* 59 */ "Seek", |
| 22764 | + /* 60 */ "NotFound", |
| 22765 | + /* 61 */ "Found", |
| 22766 | + /* 62 */ "IsUnique", |
| 22767 | + /* 63 */ "NotExists", |
| 22768 | + /* 64 */ "Sequence", |
| 22769 | + /* 65 */ "NewRowid", |
| 22770 | + /* 66 */ "Insert", |
| 22771 | + /* 67 */ "InsertInt", |
| 22775 | 22772 | /* 68 */ "Or", |
| 22776 | 22773 | /* 69 */ "And", |
| 22777 | | - /* 70 */ "SorterSort", |
| 22778 | | - /* 71 */ "Sort", |
| 22779 | | - /* 72 */ "Rewind", |
| 22774 | + /* 70 */ "Delete", |
| 22775 | + /* 71 */ "ResetCount", |
| 22776 | + /* 72 */ "SorterCompare", |
| 22780 | 22777 | /* 73 */ "IsNull", |
| 22781 | 22778 | /* 74 */ "NotNull", |
| 22782 | 22779 | /* 75 */ "Ne", |
| 22783 | 22780 | /* 76 */ "Eq", |
| 22784 | 22781 | /* 77 */ "Gt", |
| 22785 | 22782 | /* 78 */ "Le", |
| 22786 | 22783 | /* 79 */ "Lt", |
| 22787 | 22784 | /* 80 */ "Ge", |
| 22788 | | - /* 81 */ "SorterNext", |
| 22785 | + /* 81 */ "SorterData", |
| 22789 | 22786 | /* 82 */ "BitAnd", |
| 22790 | 22787 | /* 83 */ "BitOr", |
| 22791 | 22788 | /* 84 */ "ShiftLeft", |
| 22792 | 22789 | /* 85 */ "ShiftRight", |
| 22793 | 22790 | /* 86 */ "Add", |
| | @@ -22794,59 +22791,59 @@ |
| 22794 | 22791 | /* 87 */ "Subtract", |
| 22795 | 22792 | /* 88 */ "Multiply", |
| 22796 | 22793 | /* 89 */ "Divide", |
| 22797 | 22794 | /* 90 */ "Remainder", |
| 22798 | 22795 | /* 91 */ "Concat", |
| 22799 | | - /* 92 */ "Prev", |
| 22796 | + /* 92 */ "RowKey", |
| 22800 | 22797 | /* 93 */ "BitNot", |
| 22801 | 22798 | /* 94 */ "String8", |
| 22802 | | - /* 95 */ "Next", |
| 22803 | | - /* 96 */ "SorterInsert", |
| 22804 | | - /* 97 */ "IdxInsert", |
| 22805 | | - /* 98 */ "IdxDelete", |
| 22806 | | - /* 99 */ "IdxRowid", |
| 22807 | | - /* 100 */ "IdxLT", |
| 22808 | | - /* 101 */ "IdxGE", |
| 22809 | | - /* 102 */ "Destroy", |
| 22810 | | - /* 103 */ "Clear", |
| 22811 | | - /* 104 */ "CreateIndex", |
| 22812 | | - /* 105 */ "CreateTable", |
| 22813 | | - /* 106 */ "ParseSchema", |
| 22814 | | - /* 107 */ "LoadAnalysis", |
| 22815 | | - /* 108 */ "DropTable", |
| 22816 | | - /* 109 */ "DropIndex", |
| 22817 | | - /* 110 */ "DropTrigger", |
| 22818 | | - /* 111 */ "IntegrityCk", |
| 22819 | | - /* 112 */ "RowSetAdd", |
| 22820 | | - /* 113 */ "RowSetRead", |
| 22821 | | - /* 114 */ "RowSetTest", |
| 22822 | | - /* 115 */ "Program", |
| 22823 | | - /* 116 */ "Param", |
| 22824 | | - /* 117 */ "FkCounter", |
| 22825 | | - /* 118 */ "FkIfZero", |
| 22826 | | - /* 119 */ "MemMax", |
| 22827 | | - /* 120 */ "IfPos", |
| 22828 | | - /* 121 */ "IfNeg", |
| 22829 | | - /* 122 */ "IfZero", |
| 22830 | | - /* 123 */ "AggStep", |
| 22831 | | - /* 124 */ "AggFinal", |
| 22832 | | - /* 125 */ "Checkpoint", |
| 22833 | | - /* 126 */ "JournalMode", |
| 22834 | | - /* 127 */ "Vacuum", |
| 22835 | | - /* 128 */ "IncrVacuum", |
| 22836 | | - /* 129 */ "Expire", |
| 22799 | + /* 95 */ "RowData", |
| 22800 | + /* 96 */ "Rowid", |
| 22801 | + /* 97 */ "NullRow", |
| 22802 | + /* 98 */ "Last", |
| 22803 | + /* 99 */ "SorterSort", |
| 22804 | + /* 100 */ "Sort", |
| 22805 | + /* 101 */ "Rewind", |
| 22806 | + /* 102 */ "SorterInsert", |
| 22807 | + /* 103 */ "IdxInsert", |
| 22808 | + /* 104 */ "IdxDelete", |
| 22809 | + /* 105 */ "IdxRowid", |
| 22810 | + /* 106 */ "IdxLT", |
| 22811 | + /* 107 */ "IdxGE", |
| 22812 | + /* 108 */ "Destroy", |
| 22813 | + /* 109 */ "Clear", |
| 22814 | + /* 110 */ "CreateIndex", |
| 22815 | + /* 111 */ "CreateTable", |
| 22816 | + /* 112 */ "ParseSchema", |
| 22817 | + /* 113 */ "LoadAnalysis", |
| 22818 | + /* 114 */ "DropTable", |
| 22819 | + /* 115 */ "DropIndex", |
| 22820 | + /* 116 */ "DropTrigger", |
| 22821 | + /* 117 */ "IntegrityCk", |
| 22822 | + /* 118 */ "RowSetAdd", |
| 22823 | + /* 119 */ "RowSetRead", |
| 22824 | + /* 120 */ "RowSetTest", |
| 22825 | + /* 121 */ "Program", |
| 22826 | + /* 122 */ "Param", |
| 22827 | + /* 123 */ "FkCounter", |
| 22828 | + /* 124 */ "FkIfZero", |
| 22829 | + /* 125 */ "MemMax", |
| 22830 | + /* 126 */ "IfPos", |
| 22831 | + /* 127 */ "IfNeg", |
| 22832 | + /* 128 */ "IfZero", |
| 22833 | + /* 129 */ "AggFinal", |
| 22837 | 22834 | /* 130 */ "Real", |
| 22838 | | - /* 131 */ "TableLock", |
| 22839 | | - /* 132 */ "VBegin", |
| 22840 | | - /* 133 */ "VCreate", |
| 22841 | | - /* 134 */ "VDestroy", |
| 22842 | | - /* 135 */ "VOpen", |
| 22843 | | - /* 136 */ "VFilter", |
| 22844 | | - /* 137 */ "VColumn", |
| 22845 | | - /* 138 */ "VNext", |
| 22846 | | - /* 139 */ "VRename", |
| 22847 | | - /* 140 */ "VUpdate", |
| 22835 | + /* 131 */ "IncrVacuum", |
| 22836 | + /* 132 */ "Expire", |
| 22837 | + /* 133 */ "TableLock", |
| 22838 | + /* 134 */ "VBegin", |
| 22839 | + /* 135 */ "VCreate", |
| 22840 | + /* 136 */ "VDestroy", |
| 22841 | + /* 137 */ "VOpen", |
| 22842 | + /* 138 */ "VColumn", |
| 22843 | + /* 139 */ "VNext", |
| 22844 | + /* 140 */ "VRename", |
| 22848 | 22845 | /* 141 */ "ToText", |
| 22849 | 22846 | /* 142 */ "ToBlob", |
| 22850 | 22847 | /* 143 */ "ToNumeric", |
| 22851 | 22848 | /* 144 */ "ToInt", |
| 22852 | 22849 | /* 145 */ "ToReal", |
| | @@ -30499,10 +30496,11 @@ |
| 30499 | 30496 | */ |
| 30500 | 30497 | #if SQLITE_OS_WIN /* This file is used for Windows only */ |
| 30501 | 30498 | |
| 30502 | 30499 | #ifdef __CYGWIN__ |
| 30503 | 30500 | # include <sys/cygwin.h> |
| 30501 | +/* # include <errno.h> */ |
| 30504 | 30502 | #endif |
| 30505 | 30503 | |
| 30506 | 30504 | /* |
| 30507 | 30505 | ** Include code that is common to all os_*.c files |
| 30508 | 30506 | */ |
| | @@ -30727,19 +30725,19 @@ |
| 30727 | 30725 | |
| 30728 | 30726 | /* |
| 30729 | 30727 | ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions |
| 30730 | 30728 | ** based on the sub-platform)? |
| 30731 | 30729 | */ |
| 30732 | | -#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) |
| 30730 | +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT |
| 30733 | 30731 | # define SQLITE_WIN32_HAS_ANSI |
| 30734 | 30732 | #endif |
| 30735 | 30733 | |
| 30736 | 30734 | /* |
| 30737 | 30735 | ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions |
| 30738 | 30736 | ** based on the sub-platform)? |
| 30739 | 30737 | */ |
| 30740 | | -#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT || defined(__CYGWIN__) |
| 30738 | +#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT |
| 30741 | 30739 | # define SQLITE_WIN32_HAS_WIDE |
| 30742 | 30740 | #endif |
| 30743 | 30741 | |
| 30744 | 30742 | /* |
| 30745 | 30743 | ** Do we need to manually define the Win32 file mapping APIs for use with WAL |
| | @@ -30919,10 +30917,11 @@ |
| 30919 | 30917 | * zero for the default behavior. |
| 30920 | 30918 | */ |
| 30921 | 30919 | #ifndef SQLITE_WIN32_HEAP_FLAGS |
| 30922 | 30920 | # define SQLITE_WIN32_HEAP_FLAGS (0) |
| 30923 | 30921 | #endif |
| 30922 | + |
| 30924 | 30923 | |
| 30925 | 30924 | /* |
| 30926 | 30925 | ** The winMemData structure stores information required by the Win32-specific |
| 30927 | 30926 | ** sqlite3_mem_methods implementation. |
| 30928 | 30927 | */ |
| | @@ -31267,11 +31266,11 @@ |
| 31267 | 31266 | { "GetTempPathA", (SYSCALL)0, 0 }, |
| 31268 | 31267 | #endif |
| 31269 | 31268 | |
| 31270 | 31269 | #define osGetTempPathA ((DWORD(WINAPI*)(DWORD,LPSTR))aSyscall[31].pCurrent) |
| 31271 | 31270 | |
| 31272 | | -#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) |
| 31271 | +#if !SQLITE_OS_WINRT && !defined(__CYGWIN__) && defined(SQLITE_WIN32_HAS_WIDE) |
| 31273 | 31272 | { "GetTempPathW", (SYSCALL)GetTempPathW, 0 }, |
| 31274 | 31273 | #else |
| 31275 | 31274 | { "GetTempPathW", (SYSCALL)0, 0 }, |
| 31276 | 31275 | #endif |
| 31277 | 31276 | |
| | @@ -34384,14 +34383,14 @@ |
| 34384 | 34383 | OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n", |
| 34385 | 34384 | osGetCurrentProcessId(), pFd)); |
| 34386 | 34385 | return SQLITE_OK; |
| 34387 | 34386 | } |
| 34388 | 34387 | assert( (nMap % winSysInfo.dwPageSize)==0 ); |
| 34389 | | -#if SQLITE_OS_WINRT |
| 34390 | | - pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap); |
| 34391 | | -#else |
| 34392 | 34388 | assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff ); |
| 34389 | +#if SQLITE_OS_WINRT |
| 34390 | + pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap); |
| 34391 | +#else |
| 34393 | 34392 | pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap); |
| 34394 | 34393 | #endif |
| 34395 | 34394 | if( pNew==NULL ){ |
| 34396 | 34395 | osCloseHandle(pFd->hMap); |
| 34397 | 34396 | pFd->hMap = NULL; |
| | @@ -34556,10 +34555,19 @@ |
| 34556 | 34555 | #endif |
| 34557 | 34556 | /* caller will handle out of memory */ |
| 34558 | 34557 | return zConverted; |
| 34559 | 34558 | } |
| 34560 | 34559 | |
| 34560 | +/* |
| 34561 | +** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is |
| 34562 | +** in characters, so we allocate 3 bytes per character assuming worst-case |
| 34563 | +** 3-bytes-per-character UTF8. |
| 34564 | +*/ |
| 34565 | +#ifndef SQLITE_WIN32_MAX_PATH |
| 34566 | +# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3) |
| 34567 | +#endif |
| 34568 | + |
| 34561 | 34569 | static int winIsDir(const void *zConverted); |
| 34562 | 34570 | |
| 34563 | 34571 | /* |
| 34564 | 34572 | ** Create a temporary file name in zBuf. zBuf must be big enough to |
| 34565 | 34573 | ** hold at pVfs->mxPathname characters. |
| | @@ -34569,22 +34577,21 @@ |
| 34569 | 34577 | "abcdefghijklmnopqrstuvwxyz" |
| 34570 | 34578 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 34571 | 34579 | "0123456789"; |
| 34572 | 34580 | size_t i, j; |
| 34573 | 34581 | int nTempPath; |
| 34574 | | - char zTempPath[MAX_PATH+2]; |
| 34582 | + char zTempPath[SQLITE_WIN32_MAX_PATH+2]; |
| 34575 | 34583 | |
| 34576 | 34584 | /* It's odd to simulate an io-error here, but really this is just |
| 34577 | 34585 | ** using the io-error infrastructure to test that SQLite handles this |
| 34578 | 34586 | ** function failing. |
| 34579 | 34587 | */ |
| 34580 | 34588 | SimulateIOError( return SQLITE_IOERR ); |
| 34581 | 34589 | |
| 34582 | | - memset(zTempPath, 0, MAX_PATH+2); |
| 34583 | | - |
| 34584 | 34590 | if( sqlite3_temp_directory ){ |
| 34585 | | - sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory); |
| 34591 | + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", |
| 34592 | + sqlite3_temp_directory); |
| 34586 | 34593 | } |
| 34587 | 34594 | #if defined(__CYGWIN__) |
| 34588 | 34595 | else{ |
| 34589 | 34596 | static const char *azDirs[] = { |
| 34590 | 34597 | 0, |
| | @@ -34621,42 +34628,64 @@ |
| 34621 | 34628 | if( winIsDir(zWidePath) ){ |
| 34622 | 34629 | break; |
| 34623 | 34630 | } |
| 34624 | 34631 | azDirs[i] = ""; /* Don't retry in future call */ |
| 34625 | 34632 | } |
| 34626 | | - sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir); |
| 34633 | + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zDir); |
| 34627 | 34634 | } |
| 34628 | 34635 | #elif !SQLITE_OS_WINRT |
| 34629 | 34636 | else if( isNT() ){ |
| 34630 | 34637 | char *zMulti; |
| 34631 | 34638 | WCHAR zWidePath[MAX_PATH]; |
| 34632 | | - osGetTempPathW(MAX_PATH-30, zWidePath); |
| 34639 | + if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){ |
| 34640 | + OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); |
| 34641 | + return SQLITE_IOERR_GETTEMPPATH; |
| 34642 | + } |
| 34633 | 34643 | zMulti = unicodeToUtf8(zWidePath); |
| 34634 | 34644 | if( zMulti ){ |
| 34635 | | - sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti); |
| 34645 | + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti); |
| 34636 | 34646 | sqlite3_free(zMulti); |
| 34637 | 34647 | }else{ |
| 34638 | 34648 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34639 | 34649 | return SQLITE_IOERR_NOMEM; |
| 34640 | 34650 | } |
| 34641 | 34651 | } |
| 34642 | 34652 | #ifdef SQLITE_WIN32_HAS_ANSI |
| 34643 | 34653 | else{ |
| 34644 | 34654 | char *zUtf8; |
| 34645 | | - char zMbcsPath[MAX_PATH]; |
| 34646 | | - osGetTempPathA(MAX_PATH-30, zMbcsPath); |
| 34655 | + char zMbcsPath[SQLITE_WIN32_MAX_PATH]; |
| 34656 | + if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){ |
| 34657 | + OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n")); |
| 34658 | + return SQLITE_IOERR_GETTEMPPATH; |
| 34659 | + } |
| 34647 | 34660 | zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath); |
| 34648 | 34661 | if( zUtf8 ){ |
| 34649 | | - sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8); |
| 34662 | + sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8); |
| 34650 | 34663 | sqlite3_free(zUtf8); |
| 34651 | 34664 | }else{ |
| 34652 | 34665 | OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); |
| 34653 | 34666 | return SQLITE_IOERR_NOMEM; |
| 34654 | 34667 | } |
| 34655 | 34668 | } |
| 34656 | | -#endif |
| 34657 | | -#endif |
| 34669 | +#else |
| 34670 | + else{ |
| 34671 | + /* |
| 34672 | + ** Compiled without ANSI support and the current operating system |
| 34673 | + ** is not Windows NT; therefore, just zero the temporary buffer. |
| 34674 | + */ |
| 34675 | + memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2); |
| 34676 | + } |
| 34677 | +#endif /* SQLITE_WIN32_HAS_ANSI */ |
| 34678 | +#else |
| 34679 | + else{ |
| 34680 | + /* |
| 34681 | + ** Compiled for WinRT and the sqlite3_temp_directory is not set; |
| 34682 | + ** therefore, just zero the temporary buffer. |
| 34683 | + */ |
| 34684 | + memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2); |
| 34685 | + } |
| 34686 | +#endif /* !SQLITE_OS_WINRT */ |
| 34658 | 34687 | |
| 34659 | 34688 | /* Check that the output buffer is large enough for the temporary file |
| 34660 | 34689 | ** name. If it is not, return SQLITE_ERROR. |
| 34661 | 34690 | */ |
| 34662 | 34691 | nTempPath = sqlite3Strlen30(zTempPath); |
| | @@ -34738,11 +34767,11 @@ |
| 34738 | 34767 | int cnt = 0; |
| 34739 | 34768 | |
| 34740 | 34769 | /* If argument zPath is a NULL pointer, this function is required to open |
| 34741 | 34770 | ** a temporary file. Use this buffer to store the file name in. |
| 34742 | 34771 | */ |
| 34743 | | - char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */ |
| 34772 | + char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */ |
| 34744 | 34773 | |
| 34745 | 34774 | int rc = SQLITE_OK; /* Function Return Code */ |
| 34746 | 34775 | #if !defined(NDEBUG) || SQLITE_OS_WINCE |
| 34747 | 34776 | int eType = flags&0xFFFFFF00; /* Type of file to open */ |
| 34748 | 34777 | #endif |
| | @@ -34804,12 +34833,11 @@ |
| 34804 | 34833 | /* If the second argument to this function is NULL, generate a |
| 34805 | 34834 | ** temporary file name to use |
| 34806 | 34835 | */ |
| 34807 | 34836 | if( !zUtf8Name ){ |
| 34808 | 34837 | assert(isDelete && !isOpenJournal); |
| 34809 | | - memset(zTmpname, 0, MAX_PATH+2); |
| 34810 | | - rc = getTempname(MAX_PATH+2, zTmpname); |
| 34838 | + rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname); |
| 34811 | 34839 | if( rc!=SQLITE_OK ){ |
| 34812 | 34840 | OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc))); |
| 34813 | 34841 | return rc; |
| 34814 | 34842 | } |
| 34815 | 34843 | zUtf8Name = zTmpname; |
| | @@ -35236,27 +35264,34 @@ |
| 35236 | 35264 | ){ |
| 35237 | 35265 | |
| 35238 | 35266 | #if defined(__CYGWIN__) |
| 35239 | 35267 | SimulateIOError( return SQLITE_ERROR ); |
| 35240 | 35268 | UNUSED_PARAMETER(nFull); |
| 35241 | | - assert( pVfs->mxPathname>=MAX_PATH ); |
| 35269 | + assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH ); |
| 35242 | 35270 | assert( nFull>=pVfs->mxPathname ); |
| 35243 | 35271 | if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){ |
| 35244 | 35272 | /* |
| 35245 | 35273 | ** NOTE: We are dealing with a relative path name and the data |
| 35246 | 35274 | ** directory has been set. Therefore, use it as the basis |
| 35247 | 35275 | ** for converting the relative path name to an absolute |
| 35248 | 35276 | ** one by prepending the data directory and a slash. |
| 35249 | 35277 | */ |
| 35250 | | - char zOut[MAX_PATH+1]; |
| 35251 | | - memset(zOut, 0, MAX_PATH+1); |
| 35252 | | - cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, |
| 35253 | | - MAX_PATH+1); |
| 35278 | + char zOut[SQLITE_WIN32_MAX_PATH+1]; |
| 35279 | + if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut, |
| 35280 | + SQLITE_WIN32_MAX_PATH+1)<0 ){ |
| 35281 | + winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", |
| 35282 | + zRelative); |
| 35283 | + return SQLITE_CANTOPEN_FULLPATH; |
| 35284 | + } |
| 35254 | 35285 | sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s", |
| 35255 | 35286 | sqlite3_data_directory, zOut); |
| 35256 | 35287 | }else{ |
| 35257 | | - cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull); |
| 35288 | + if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){ |
| 35289 | + winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path", |
| 35290 | + zRelative); |
| 35291 | + return SQLITE_CANTOPEN_FULLPATH; |
| 35292 | + } |
| 35258 | 35293 | } |
| 35259 | 35294 | return SQLITE_OK; |
| 35260 | 35295 | #endif |
| 35261 | 35296 | |
| 35262 | 35297 | #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__) |
| | @@ -35594,11 +35629,11 @@ |
| 35594 | 35629 | */ |
| 35595 | 35630 | SQLITE_API int sqlite3_os_init(void){ |
| 35596 | 35631 | static sqlite3_vfs winVfs = { |
| 35597 | 35632 | 3, /* iVersion */ |
| 35598 | 35633 | sizeof(winFile), /* szOsFile */ |
| 35599 | | - MAX_PATH, /* mxPathname */ |
| 35634 | + SQLITE_WIN32_MAX_PATH, /* mxPathname */ |
| 35600 | 35635 | 0, /* pNext */ |
| 35601 | 35636 | "win32", /* zName */ |
| 35602 | 35637 | 0, /* pAppData */ |
| 35603 | 35638 | winOpen, /* xOpen */ |
| 35604 | 35639 | winDelete, /* xDelete */ |
| | @@ -60219,12 +60254,12 @@ |
| 60219 | 60254 | ** a prior call to sqlite3VdbeMakeLabel(). |
| 60220 | 60255 | */ |
| 60221 | 60256 | SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *p, int x){ |
| 60222 | 60257 | int j = -1-x; |
| 60223 | 60258 | assert( p->magic==VDBE_MAGIC_INIT ); |
| 60224 | | - assert( j>=0 && j<p->nLabel ); |
| 60225 | | - if( p->aLabel ){ |
| 60259 | + assert( j<p->nLabel ); |
| 60260 | + if( j>=0 && p->aLabel ){ |
| 60226 | 60261 | p->aLabel[j] = p->nOp; |
| 60227 | 60262 | } |
| 60228 | 60263 | } |
| 60229 | 60264 | |
| 60230 | 60265 | /* |
| | @@ -60376,44 +60411,64 @@ |
| 60376 | 60411 | p->readOnly = 1; |
| 60377 | 60412 | p->bIsReader = 0; |
| 60378 | 60413 | for(pOp=p->aOp, i=p->nOp-1; i>=0; i--, pOp++){ |
| 60379 | 60414 | u8 opcode = pOp->opcode; |
| 60380 | 60415 | |
| 60381 | | - pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 60382 | | - if( opcode==OP_Function || opcode==OP_AggStep ){ |
| 60383 | | - if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 60384 | | - }else if( opcode==OP_Transaction ){ |
| 60385 | | - if( pOp->p2!=0 ) p->readOnly = 0; |
| 60386 | | - p->bIsReader = 1; |
| 60387 | | - }else if( opcode==OP_AutoCommit || opcode==OP_Savepoint ){ |
| 60388 | | - p->bIsReader = 1; |
| 60389 | | - }else if( opcode==OP_Vacuum |
| 60390 | | - || opcode==OP_JournalMode |
| 60416 | + /* NOTE: Be sure to update mkopcodeh.awk when adding or removing |
| 60417 | + ** cases from this switch! */ |
| 60418 | + switch( opcode ){ |
| 60419 | + case OP_Function: |
| 60420 | + case OP_AggStep: { |
| 60421 | + if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 60422 | + break; |
| 60423 | + } |
| 60424 | + case OP_Transaction: { |
| 60425 | + if( pOp->p2!=0 ) p->readOnly = 0; |
| 60426 | + /* fall thru */ |
| 60427 | + } |
| 60428 | + case OP_AutoCommit: |
| 60429 | + case OP_Savepoint: { |
| 60430 | + p->bIsReader = 1; |
| 60431 | + break; |
| 60432 | + } |
| 60391 | 60433 | #ifndef SQLITE_OMIT_WAL |
| 60392 | | - || opcode==OP_Checkpoint |
| 60434 | + case OP_Checkpoint: |
| 60393 | 60435 | #endif |
| 60394 | | - ){ |
| 60395 | | - p->readOnly = 0; |
| 60396 | | - p->bIsReader = 1; |
| 60436 | + case OP_Vacuum: |
| 60437 | + case OP_JournalMode: { |
| 60438 | + p->readOnly = 0; |
| 60439 | + p->bIsReader = 1; |
| 60440 | + break; |
| 60441 | + } |
| 60397 | 60442 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 60398 | | - }else if( opcode==OP_VUpdate ){ |
| 60399 | | - if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 60400 | | - }else if( opcode==OP_VFilter ){ |
| 60401 | | - int n; |
| 60402 | | - assert( p->nOp - i >= 3 ); |
| 60403 | | - assert( pOp[-1].opcode==OP_Integer ); |
| 60404 | | - n = pOp[-1].p1; |
| 60405 | | - if( n>nMaxArgs ) nMaxArgs = n; |
| 60406 | | -#endif |
| 60407 | | - }else if( opcode==OP_Next || opcode==OP_SorterNext ){ |
| 60408 | | - pOp->p4.xAdvance = sqlite3BtreeNext; |
| 60409 | | - pOp->p4type = P4_ADVANCE; |
| 60410 | | - }else if( opcode==OP_Prev ){ |
| 60411 | | - pOp->p4.xAdvance = sqlite3BtreePrevious; |
| 60412 | | - pOp->p4type = P4_ADVANCE; |
| 60413 | | - } |
| 60414 | | - |
| 60443 | + case OP_VUpdate: { |
| 60444 | + if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 60445 | + break; |
| 60446 | + } |
| 60447 | + case OP_VFilter: { |
| 60448 | + int n; |
| 60449 | + assert( p->nOp - i >= 3 ); |
| 60450 | + assert( pOp[-1].opcode==OP_Integer ); |
| 60451 | + n = pOp[-1].p1; |
| 60452 | + if( n>nMaxArgs ) nMaxArgs = n; |
| 60453 | + break; |
| 60454 | + } |
| 60455 | +#endif |
| 60456 | + case OP_Next: |
| 60457 | + case OP_SorterNext: { |
| 60458 | + pOp->p4.xAdvance = sqlite3BtreeNext; |
| 60459 | + pOp->p4type = P4_ADVANCE; |
| 60460 | + break; |
| 60461 | + } |
| 60462 | + case OP_Prev: { |
| 60463 | + pOp->p4.xAdvance = sqlite3BtreePrevious; |
| 60464 | + pOp->p4type = P4_ADVANCE; |
| 60465 | + break; |
| 60466 | + } |
| 60467 | + } |
| 60468 | + |
| 60469 | + pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 60415 | 60470 | if( (pOp->opflags & OPFLG_JUMP)!=0 && pOp->p2<0 ){ |
| 60416 | 60471 | assert( -1-pOp->p2<p->nLabel ); |
| 60417 | 60472 | pOp->p2 = aLabel[-1-pOp->p2]; |
| 60418 | 60473 | } |
| 60419 | 60474 | } |
| | @@ -60544,12 +60599,11 @@ |
| 60544 | 60599 | /* |
| 60545 | 60600 | ** Change the P2 operand of instruction addr so that it points to |
| 60546 | 60601 | ** the address of the next instruction to be coded. |
| 60547 | 60602 | */ |
| 60548 | 60603 | SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe *p, int addr){ |
| 60549 | | - assert( addr>=0 || p->db->mallocFailed ); |
| 60550 | | - if( addr>=0 ) sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 60604 | + if( ALWAYS(addr>=0) ) sqlite3VdbeChangeP2(p, addr, p->nOp); |
| 60551 | 60605 | } |
| 60552 | 60606 | |
| 60553 | 60607 | |
| 60554 | 60608 | /* |
| 60555 | 60609 | ** If the input FuncDef structure is ephemeral, then free it. If |
| | @@ -60581,17 +60635,10 @@ |
| 60581 | 60635 | } |
| 60582 | 60636 | case P4_MPRINTF: { |
| 60583 | 60637 | if( db->pnBytesFreed==0 ) sqlite3_free(p4); |
| 60584 | 60638 | break; |
| 60585 | 60639 | } |
| 60586 | | - case P4_VDBEFUNC: { |
| 60587 | | - VdbeFunc *pVdbeFunc = (VdbeFunc *)p4; |
| 60588 | | - freeEphemeralFunction(db, pVdbeFunc->pFunc); |
| 60589 | | - if( db->pnBytesFreed==0 ) sqlite3VdbeDeleteAuxData(pVdbeFunc, 0); |
| 60590 | | - sqlite3DbFree(db, pVdbeFunc); |
| 60591 | | - break; |
| 60592 | | - } |
| 60593 | 60640 | case P4_FUNCDEF: { |
| 60594 | 60641 | freeEphemeralFunction(db, (FuncDef*)p4); |
| 60595 | 60642 | break; |
| 60596 | 60643 | } |
| 60597 | 60644 | case P4_MEM: { |
| | @@ -60706,24 +60753,17 @@ |
| 60706 | 60753 | pOp->p4type = P4_INT32; |
| 60707 | 60754 | }else if( zP4==0 ){ |
| 60708 | 60755 | pOp->p4.p = 0; |
| 60709 | 60756 | pOp->p4type = P4_NOTUSED; |
| 60710 | 60757 | }else if( n==P4_KEYINFO ){ |
| 60711 | | - KeyInfo *pKeyInfo; |
| 60712 | | - int nField, nByte; |
| 60713 | | - |
| 60714 | | - nField = ((KeyInfo*)zP4)->nField; |
| 60715 | | - nByte = sizeof(*pKeyInfo) + (nField-1)*sizeof(pKeyInfo->aColl[0]) + nField; |
| 60716 | | - pKeyInfo = sqlite3DbMallocRaw(0, nByte); |
| 60717 | | - pOp->p4.pKeyInfo = pKeyInfo; |
| 60718 | | - if( pKeyInfo ){ |
| 60719 | | - u8 *aSortOrder; |
| 60720 | | - memcpy((char*)pKeyInfo, zP4, nByte - nField); |
| 60721 | | - aSortOrder = pKeyInfo->aSortOrder; |
| 60722 | | - assert( aSortOrder!=0 ); |
| 60723 | | - pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField]; |
| 60724 | | - memcpy(pKeyInfo->aSortOrder, aSortOrder, nField); |
| 60758 | + KeyInfo *pOrig, *pNew; |
| 60759 | + |
| 60760 | + pOrig = (KeyInfo*)zP4; |
| 60761 | + pOp->p4.pKeyInfo = pNew = sqlite3KeyInfoAlloc(db, pOrig->nField); |
| 60762 | + if( pNew ){ |
| 60763 | + memcpy(pNew->aColl, pOrig->aColl, pOrig->nField*sizeof(pNew->aColl[0])); |
| 60764 | + memcpy(pNew->aSortOrder, pOrig->aSortOrder, pOrig->nField); |
| 60725 | 60765 | pOp->p4type = P4_KEYINFO; |
| 60726 | 60766 | }else{ |
| 60727 | 60767 | p->db->mallocFailed = 1; |
| 60728 | 60768 | pOp->p4type = P4_NOTUSED; |
| 60729 | 60769 | } |
| | @@ -61617,10 +61657,14 @@ |
| 61617 | 61657 | while( p->pDelFrame ){ |
| 61618 | 61658 | VdbeFrame *pDel = p->pDelFrame; |
| 61619 | 61659 | p->pDelFrame = pDel->pParent; |
| 61620 | 61660 | sqlite3VdbeFrameDelete(pDel); |
| 61621 | 61661 | } |
| 61662 | + |
| 61663 | + /* Delete any auxdata allocations made by the VM */ |
| 61664 | + sqlite3VdbeDeleteAuxData(p, -1, 0); |
| 61665 | + assert( p->pAuxData==0 ); |
| 61622 | 61666 | } |
| 61623 | 61667 | |
| 61624 | 61668 | /* |
| 61625 | 61669 | ** Clean up the VM after execution. |
| 61626 | 61670 | ** |
| | @@ -62415,24 +62459,39 @@ |
| 62415 | 62459 | sqlite3VdbeDelete(p); |
| 62416 | 62460 | return rc; |
| 62417 | 62461 | } |
| 62418 | 62462 | |
| 62419 | 62463 | /* |
| 62420 | | -** Call the destructor for each auxdata entry in pVdbeFunc for which |
| 62421 | | -** the corresponding bit in mask is clear. Auxdata entries beyond 31 |
| 62422 | | -** are always destroyed. To destroy all auxdata entries, call this |
| 62423 | | -** routine with mask==0. |
| 62464 | +** If parameter iOp is less than zero, then invoke the destructor for |
| 62465 | +** all auxiliary data pointers currently cached by the VM passed as |
| 62466 | +** the first argument. |
| 62467 | +** |
| 62468 | +** Or, if iOp is greater than or equal to zero, then the destructor is |
| 62469 | +** only invoked for those auxiliary data pointers created by the user |
| 62470 | +** function invoked by the OP_Function opcode at instruction iOp of |
| 62471 | +** VM pVdbe, and only then if: |
| 62472 | +** |
| 62473 | +** * the associated function parameter is the 32nd or later (counting |
| 62474 | +** from left to right), or |
| 62475 | +** |
| 62476 | +** * the corresponding bit in argument mask is clear (where the first |
| 62477 | +** function parameter corrsponds to bit 0 etc.). |
| 62424 | 62478 | */ |
| 62425 | | -SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(VdbeFunc *pVdbeFunc, int mask){ |
| 62426 | | - int i; |
| 62427 | | - for(i=0; i<pVdbeFunc->nAux; i++){ |
| 62428 | | - struct AuxData *pAux = &pVdbeFunc->apAux[i]; |
| 62429 | | - if( (i>31 || !(mask&(((u32)1)<<i))) && pAux->pAux ){ |
| 62479 | +SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(Vdbe *pVdbe, int iOp, int mask){ |
| 62480 | + AuxData **pp = &pVdbe->pAuxData; |
| 62481 | + while( *pp ){ |
| 62482 | + AuxData *pAux = *pp; |
| 62483 | + if( (iOp<0) |
| 62484 | + || (pAux->iOp==iOp && (pAux->iArg>31 || !(mask & ((u32)1<<pAux->iArg)))) |
| 62485 | + ){ |
| 62430 | 62486 | if( pAux->xDelete ){ |
| 62431 | 62487 | pAux->xDelete(pAux->pAux); |
| 62432 | 62488 | } |
| 62433 | | - pAux->pAux = 0; |
| 62489 | + *pp = pAux->pNext; |
| 62490 | + sqlite3DbFree(pVdbe->db, pAux); |
| 62491 | + }else{ |
| 62492 | + pp= &pAux->pNext; |
| 62434 | 62493 | } |
| 62435 | 62494 | } |
| 62436 | 62495 | } |
| 62437 | 62496 | |
| 62438 | 62497 | /* |
| | @@ -62947,15 +63006,14 @@ |
| 62947 | 63006 | */ |
| 62948 | 63007 | SQLITE_PRIVATE int sqlite3VdbeRecordCompare( |
| 62949 | 63008 | int nKey1, const void *pKey1, /* Left key */ |
| 62950 | 63009 | UnpackedRecord *pPKey2 /* Right key */ |
| 62951 | 63010 | ){ |
| 62952 | | - int d1; /* Offset into aKey[] of next data element */ |
| 63011 | + u32 d1; /* Offset into aKey[] of next data element */ |
| 62953 | 63012 | u32 idx1; /* Offset into aKey[] of next header element */ |
| 62954 | 63013 | u32 szHdr1; /* Number of bytes in header */ |
| 62955 | 63014 | int i = 0; |
| 62956 | | - int nField; |
| 62957 | 63015 | int rc = 0; |
| 62958 | 63016 | const unsigned char *aKey1 = (const unsigned char *)pKey1; |
| 62959 | 63017 | KeyInfo *pKeyInfo; |
| 62960 | 63018 | Mem mem1; |
| 62961 | 63019 | |
| | @@ -62974,32 +63032,42 @@ |
| 62974 | 63032 | */ |
| 62975 | 63033 | /* mem1.u.i = 0; // not needed, here to silence compiler warning */ |
| 62976 | 63034 | |
| 62977 | 63035 | idx1 = getVarint32(aKey1, szHdr1); |
| 62978 | 63036 | d1 = szHdr1; |
| 62979 | | - nField = pKeyInfo->nField; |
| 63037 | + assert( pKeyInfo->nField+1>=pPKey2->nField ); |
| 62980 | 63038 | assert( pKeyInfo->aSortOrder!=0 ); |
| 62981 | 63039 | while( idx1<szHdr1 && i<pPKey2->nField ){ |
| 62982 | 63040 | u32 serial_type1; |
| 62983 | 63041 | |
| 62984 | 63042 | /* Read the serial types for the next element in each key. */ |
| 62985 | 63043 | idx1 += getVarint32( aKey1+idx1, serial_type1 ); |
| 62986 | | - if( d1>=nKey1 && sqlite3VdbeSerialTypeLen(serial_type1)>0 ) break; |
| 63044 | + |
| 63045 | + /* Verify that there is enough key space remaining to avoid |
| 63046 | + ** a buffer overread. The "d1+serial_type1+2" subexpression will |
| 63047 | + ** always be greater than or equal to the amount of required key space. |
| 63048 | + ** Use that approximation to avoid the more expensive call to |
| 63049 | + ** sqlite3VdbeSerialTypeLen() in the common case. |
| 63050 | + */ |
| 63051 | + if( d1+serial_type1+2>(u32)nKey1 |
| 63052 | + && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1 |
| 63053 | + ){ |
| 63054 | + break; |
| 63055 | + } |
| 62987 | 63056 | |
| 62988 | 63057 | /* Extract the values to be compared. |
| 62989 | 63058 | */ |
| 62990 | 63059 | d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1); |
| 62991 | 63060 | |
| 62992 | 63061 | /* Do the comparison |
| 62993 | 63062 | */ |
| 62994 | | - rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], |
| 62995 | | - i<nField ? pKeyInfo->aColl[i] : 0); |
| 63063 | + rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]); |
| 62996 | 63064 | if( rc!=0 ){ |
| 62997 | 63065 | assert( mem1.zMalloc==0 ); /* See comment below */ |
| 62998 | 63066 | |
| 62999 | 63067 | /* Invert the result if we are using DESC sort order. */ |
| 63000 | | - if( i<nField && pKeyInfo->aSortOrder[i] ){ |
| 63068 | + if( pKeyInfo->aSortOrder[i] ){ |
| 63001 | 63069 | rc = -rc; |
| 63002 | 63070 | } |
| 63003 | 63071 | |
| 63004 | 63072 | /* If the PREFIX_SEARCH flag is set and all fields except the final |
| 63005 | 63073 | ** rowid field were equal, then clear the PREFIX_SEARCH flag and set |
| | @@ -63210,11 +63278,11 @@ |
| 63210 | 63278 | ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_* |
| 63211 | 63279 | ** constants) to the value before returning it. |
| 63212 | 63280 | ** |
| 63213 | 63281 | ** The returned value must be freed by the caller using sqlite3ValueFree(). |
| 63214 | 63282 | */ |
| 63215 | | -SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){ |
| 63283 | +SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe *v, int iVar, u8 aff){ |
| 63216 | 63284 | assert( iVar>0 ); |
| 63217 | 63285 | if( v ){ |
| 63218 | 63286 | Mem *pMem = &v->aVar[iVar-1]; |
| 63219 | 63287 | if( 0==(pMem->flags & MEM_Null) ){ |
| 63220 | 63288 | sqlite3_value *pRet = sqlite3ValueNew(v->db); |
| | @@ -63827,18 +63895,18 @@ |
| 63827 | 63895 | /* |
| 63828 | 63896 | ** Return the auxilary data pointer, if any, for the iArg'th argument to |
| 63829 | 63897 | ** the user-function defined by pCtx. |
| 63830 | 63898 | */ |
| 63831 | 63899 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ |
| 63832 | | - VdbeFunc *pVdbeFunc; |
| 63900 | + AuxData *pAuxData; |
| 63833 | 63901 | |
| 63834 | 63902 | assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); |
| 63835 | | - pVdbeFunc = pCtx->pVdbeFunc; |
| 63836 | | - if( !pVdbeFunc || iArg>=pVdbeFunc->nAux || iArg<0 ){ |
| 63837 | | - return 0; |
| 63903 | + for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 63904 | + if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 63838 | 63905 | } |
| 63839 | | - return pVdbeFunc->apAux[iArg].pAux; |
| 63906 | + |
| 63907 | + return (pAuxData ? pAuxData->pAux : 0); |
| 63840 | 63908 | } |
| 63841 | 63909 | |
| 63842 | 63910 | /* |
| 63843 | 63911 | ** Set the auxilary data pointer and delete function, for the iArg'th |
| 63844 | 63912 | ** argument to the user-function defined by pCtx. Any previous value is |
| | @@ -63848,33 +63916,30 @@ |
| 63848 | 63916 | sqlite3_context *pCtx, |
| 63849 | 63917 | int iArg, |
| 63850 | 63918 | void *pAux, |
| 63851 | 63919 | void (*xDelete)(void*) |
| 63852 | 63920 | ){ |
| 63853 | | - struct AuxData *pAuxData; |
| 63854 | | - VdbeFunc *pVdbeFunc; |
| 63855 | | - if( iArg<0 ) goto failed; |
| 63921 | + AuxData *pAuxData; |
| 63922 | + Vdbe *pVdbe = pCtx->pVdbe; |
| 63856 | 63923 | |
| 63857 | 63924 | assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); |
| 63858 | | - pVdbeFunc = pCtx->pVdbeFunc; |
| 63859 | | - if( !pVdbeFunc || pVdbeFunc->nAux<=iArg ){ |
| 63860 | | - int nAux = (pVdbeFunc ? pVdbeFunc->nAux : 0); |
| 63861 | | - int nMalloc = sizeof(VdbeFunc) + sizeof(struct AuxData)*iArg; |
| 63862 | | - pVdbeFunc = sqlite3DbRealloc(pCtx->s.db, pVdbeFunc, nMalloc); |
| 63863 | | - if( !pVdbeFunc ){ |
| 63864 | | - goto failed; |
| 63865 | | - } |
| 63866 | | - pCtx->pVdbeFunc = pVdbeFunc; |
| 63867 | | - memset(&pVdbeFunc->apAux[nAux], 0, sizeof(struct AuxData)*(iArg+1-nAux)); |
| 63868 | | - pVdbeFunc->nAux = iArg+1; |
| 63869 | | - pVdbeFunc->pFunc = pCtx->pFunc; |
| 63870 | | - } |
| 63871 | | - |
| 63872 | | - pAuxData = &pVdbeFunc->apAux[iArg]; |
| 63873 | | - if( pAuxData->pAux && pAuxData->xDelete ){ |
| 63925 | + if( iArg<0 ) goto failed; |
| 63926 | + |
| 63927 | + for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){ |
| 63928 | + if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break; |
| 63929 | + } |
| 63930 | + if( pAuxData==0 ){ |
| 63931 | + pAuxData = sqlite3DbMallocZero(pVdbe->db, sizeof(AuxData)); |
| 63932 | + if( !pAuxData ) goto failed; |
| 63933 | + pAuxData->iOp = pCtx->iOp; |
| 63934 | + pAuxData->iArg = iArg; |
| 63935 | + pAuxData->pNext = pVdbe->pAuxData; |
| 63936 | + pVdbe->pAuxData = pAuxData; |
| 63937 | + }else if( pAuxData->xDelete ){ |
| 63874 | 63938 | pAuxData->xDelete(pAuxData->pAux); |
| 63875 | 63939 | } |
| 63940 | + |
| 63876 | 63941 | pAuxData->pAux = pAux; |
| 63877 | 63942 | pAuxData->xDelete = xDelete; |
| 63878 | 63943 | return; |
| 63879 | 63944 | |
| 63880 | 63945 | failed: |
| | @@ -65482,11 +65547,11 @@ |
| 65482 | 65547 | u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */ |
| 65483 | 65548 | u8 encoding = ENC(db); /* The database encoding */ |
| 65484 | 65549 | int iCompare = 0; /* Result of last OP_Compare operation */ |
| 65485 | 65550 | unsigned nVmStep = 0; /* Number of virtual machine steps */ |
| 65486 | 65551 | #ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 65487 | | - unsigned nProgressOps = 0; /* nVmStep at last progress callback. */ |
| 65552 | + unsigned nProgressLimit = 0;/* Invoke xProgress() when nVmStep reaches this */ |
| 65488 | 65553 | #endif |
| 65489 | 65554 | Mem *aMem = p->aMem; /* Copy of p->aMem */ |
| 65490 | 65555 | Mem *pIn1 = 0; /* 1st input operand */ |
| 65491 | 65556 | Mem *pIn2 = 0; /* 2nd input operand */ |
| 65492 | 65557 | Mem *pIn3 = 0; /* 3rd input operand */ |
| | @@ -65941,10 +66006,21 @@ |
| 65941 | 66006 | assert( p->explain==0 ); |
| 65942 | 66007 | p->pResultSet = 0; |
| 65943 | 66008 | db->busyHandler.nBusy = 0; |
| 65944 | 66009 | CHECK_FOR_INTERRUPT; |
| 65945 | 66010 | sqlite3VdbeIOTraceSql(p); |
| 66011 | +#ifndef SQLITE_OMIT_PROGRESS_CALLBACK |
| 66012 | + if( db->xProgress ){ |
| 66013 | + assert( 0 < db->nProgressOps ); |
| 66014 | + nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1]; |
| 66015 | + if( nProgressLimit==0 ){ |
| 66016 | + nProgressLimit = db->nProgressOps; |
| 66017 | + }else{ |
| 66018 | + nProgressLimit %= (unsigned)db->nProgressOps; |
| 66019 | + } |
| 66020 | + } |
| 66021 | +#endif |
| 65946 | 66022 | #ifdef SQLITE_DEBUG |
| 65947 | 66023 | sqlite3BeginBenignMalloc(); |
| 65948 | 66024 | if( p->pc==0 && (p->db->flags & SQLITE_VdbeListing)!=0 ){ |
| 65949 | 66025 | int i; |
| 65950 | 66026 | printf("VDBE Program Listing:\n"); |
| | @@ -66101,18 +66177,20 @@ |
| 66101 | 66177 | ** of VDBE ops have been executed (either since this invocation of |
| 66102 | 66178 | ** sqlite3VdbeExec() or since last time the progress callback was called). |
| 66103 | 66179 | ** If the progress callback returns non-zero, exit the virtual machine with |
| 66104 | 66180 | ** a return code SQLITE_ABORT. |
| 66105 | 66181 | */ |
| 66106 | | - if( db->xProgress!=0 && (nVmStep - nProgressOps)>=db->nProgressOps ){ |
| 66182 | + if( db->xProgress!=0 && nVmStep>=nProgressLimit ){ |
| 66107 | 66183 | int prc; |
| 66108 | 66184 | prc = db->xProgress(db->pProgressArg); |
| 66109 | 66185 | if( prc!=0 ){ |
| 66110 | 66186 | rc = SQLITE_INTERRUPT; |
| 66111 | 66187 | goto vdbe_error_halt; |
| 66112 | 66188 | } |
| 66113 | | - nProgressOps = nVmStep; |
| 66189 | + if( db->xProgress!=0 ){ |
| 66190 | + nProgressLimit = nVmStep + db->nProgressOps - (nVmStep%db->nProgressOps); |
| 66191 | + } |
| 66114 | 66192 | } |
| 66115 | 66193 | #endif |
| 66116 | 66194 | |
| 66117 | 66195 | break; |
| 66118 | 66196 | } |
| | @@ -66794,23 +66872,18 @@ |
| 66794 | 66872 | Deephemeralize(u.ai.pArg); |
| 66795 | 66873 | sqlite3VdbeMemStoreType(u.ai.pArg); |
| 66796 | 66874 | REGISTER_TRACE(pOp->p2+u.ai.i, u.ai.pArg); |
| 66797 | 66875 | } |
| 66798 | 66876 | |
| 66799 | | - assert( pOp->p4type==P4_FUNCDEF || pOp->p4type==P4_VDBEFUNC ); |
| 66800 | | - if( pOp->p4type==P4_FUNCDEF ){ |
| 66801 | | - u.ai.ctx.pFunc = pOp->p4.pFunc; |
| 66802 | | - u.ai.ctx.pVdbeFunc = 0; |
| 66803 | | - }else{ |
| 66804 | | - u.ai.ctx.pVdbeFunc = (VdbeFunc*)pOp->p4.pVdbeFunc; |
| 66805 | | - u.ai.ctx.pFunc = u.ai.ctx.pVdbeFunc->pFunc; |
| 66806 | | - } |
| 66807 | | - |
| 66877 | + assert( pOp->p4type==P4_FUNCDEF ); |
| 66878 | + u.ai.ctx.pFunc = pOp->p4.pFunc; |
| 66808 | 66879 | u.ai.ctx.s.flags = MEM_Null; |
| 66809 | 66880 | u.ai.ctx.s.db = db; |
| 66810 | 66881 | u.ai.ctx.s.xDel = 0; |
| 66811 | 66882 | u.ai.ctx.s.zMalloc = 0; |
| 66883 | + u.ai.ctx.iOp = pc; |
| 66884 | + u.ai.ctx.pVdbe = p; |
| 66812 | 66885 | |
| 66813 | 66886 | /* The output cell may already have a buffer allocated. Move |
| 66814 | 66887 | ** the pointer to u.ai.ctx.s so in case the user-function can use |
| 66815 | 66888 | ** the already allocated buffer instead of allocating a new one. |
| 66816 | 66889 | */ |
| | @@ -66829,15 +66902,11 @@ |
| 66829 | 66902 | lastRowid = db->lastRowid; |
| 66830 | 66903 | |
| 66831 | 66904 | /* If any auxiliary data functions have been called by this user function, |
| 66832 | 66905 | ** immediately call the destructor for any non-static values. |
| 66833 | 66906 | */ |
| 66834 | | - if( u.ai.ctx.pVdbeFunc ){ |
| 66835 | | - sqlite3VdbeDeleteAuxData(u.ai.ctx.pVdbeFunc, pOp->p1); |
| 66836 | | - pOp->p4.pVdbeFunc = u.ai.ctx.pVdbeFunc; |
| 66837 | | - pOp->p4type = P4_VDBEFUNC; |
| 66838 | | - } |
| 66907 | + sqlite3VdbeDeleteAuxData(p, pc, pOp->p1); |
| 66839 | 66908 | |
| 66840 | 66909 | if( db->mallocFailed ){ |
| 66841 | 66910 | /* Even though a malloc() has failed, the implementation of the |
| 66842 | 66911 | ** user function may have called an sqlite3_result_XXX() function |
| 66843 | 66912 | ** to return a value. The following call releases any resources |
| | @@ -74200,15 +74269,24 @@ |
| 74200 | 74269 | /* Translate the schema name in zDb into a pointer to the corresponding |
| 74201 | 74270 | ** schema. If not found, pSchema will remain NULL and nothing will match |
| 74202 | 74271 | ** resulting in an appropriate error message toward the end of this routine |
| 74203 | 74272 | */ |
| 74204 | 74273 | if( zDb ){ |
| 74205 | | - for(i=0; i<db->nDb; i++){ |
| 74206 | | - assert( db->aDb[i].zName ); |
| 74207 | | - if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){ |
| 74208 | | - pSchema = db->aDb[i].pSchema; |
| 74209 | | - break; |
| 74274 | + testcase( pNC->ncFlags & NC_PartIdx ); |
| 74275 | + testcase( pNC->ncFlags & NC_IsCheck ); |
| 74276 | + if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){ |
| 74277 | + /* Silently ignore database qualifiers inside CHECK constraints and partial |
| 74278 | + ** indices. Do not raise errors because that might break legacy and |
| 74279 | + ** because it does not hurt anything to just ignore the database name. */ |
| 74280 | + zDb = 0; |
| 74281 | + }else{ |
| 74282 | + for(i=0; i<db->nDb; i++){ |
| 74283 | + assert( db->aDb[i].zName ); |
| 74284 | + if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){ |
| 74285 | + pSchema = db->aDb[i].pSchema; |
| 74286 | + break; |
| 74287 | + } |
| 74210 | 74288 | } |
| 74211 | 74289 | } |
| 74212 | 74290 | } |
| 74213 | 74291 | |
| 74214 | 74292 | /* Start at the inner-most context and move outward until a match is found */ |
| | @@ -74481,10 +74559,43 @@ |
| 74481 | 74559 | } |
| 74482 | 74560 | ExprSetProperty(p, EP_Resolved); |
| 74483 | 74561 | } |
| 74484 | 74562 | return p; |
| 74485 | 74563 | } |
| 74564 | + |
| 74565 | +/* |
| 74566 | +** Report an error that an expression is not valid for a partial index WHERE |
| 74567 | +** clause. |
| 74568 | +*/ |
| 74569 | +static void notValidPartIdxWhere( |
| 74570 | + Parse *pParse, /* Leave error message here */ |
| 74571 | + NameContext *pNC, /* The name context */ |
| 74572 | + const char *zMsg /* Type of error */ |
| 74573 | +){ |
| 74574 | + if( (pNC->ncFlags & NC_PartIdx)!=0 ){ |
| 74575 | + sqlite3ErrorMsg(pParse, "%s prohibited in partial index WHERE clauses", |
| 74576 | + zMsg); |
| 74577 | + } |
| 74578 | +} |
| 74579 | + |
| 74580 | +#ifndef SQLITE_OMIT_CHECK |
| 74581 | +/* |
| 74582 | +** Report an error that an expression is not valid for a CHECK constraint. |
| 74583 | +*/ |
| 74584 | +static void notValidCheckConstraint( |
| 74585 | + Parse *pParse, /* Leave error message here */ |
| 74586 | + NameContext *pNC, /* The name context */ |
| 74587 | + const char *zMsg /* Type of error */ |
| 74588 | +){ |
| 74589 | + if( (pNC->ncFlags & NC_IsCheck)!=0 ){ |
| 74590 | + sqlite3ErrorMsg(pParse,"%s prohibited in CHECK constraints", zMsg); |
| 74591 | + } |
| 74592 | +} |
| 74593 | +#else |
| 74594 | +# define notValidCheckConstraint(P,N,M) |
| 74595 | +#endif |
| 74596 | + |
| 74486 | 74597 | |
| 74487 | 74598 | /* |
| 74488 | 74599 | ** This routine is callback for sqlite3WalkExpr(). |
| 74489 | 74600 | ** |
| 74490 | 74601 | ** Resolve symbolic names into TK_COLUMN operators for the current |
| | @@ -74581,10 +74692,11 @@ |
| 74581 | 74692 | FuncDef *pDef; /* Information about the function */ |
| 74582 | 74693 | u8 enc = ENC(pParse->db); /* The database encoding */ |
| 74583 | 74694 | |
| 74584 | 74695 | testcase( pExpr->op==TK_CONST_FUNC ); |
| 74585 | 74696 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 74697 | + notValidPartIdxWhere(pParse, pNC, "functions"); |
| 74586 | 74698 | zId = pExpr->u.zToken; |
| 74587 | 74699 | nId = sqlite3Strlen30(zId); |
| 74588 | 74700 | pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0); |
| 74589 | 74701 | if( pDef==0 ){ |
| 74590 | 74702 | pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0); |
| | @@ -74646,31 +74758,25 @@ |
| 74646 | 74758 | #endif |
| 74647 | 74759 | case TK_IN: { |
| 74648 | 74760 | testcase( pExpr->op==TK_IN ); |
| 74649 | 74761 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 74650 | 74762 | int nRef = pNC->nRef; |
| 74651 | | -#ifndef SQLITE_OMIT_CHECK |
| 74652 | | - if( (pNC->ncFlags & NC_IsCheck)!=0 ){ |
| 74653 | | - sqlite3ErrorMsg(pParse,"subqueries prohibited in CHECK constraints"); |
| 74654 | | - } |
| 74655 | | -#endif |
| 74763 | + notValidCheckConstraint(pParse, pNC, "subqueries"); |
| 74764 | + notValidPartIdxWhere(pParse, pNC, "subqueries"); |
| 74656 | 74765 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 74657 | 74766 | assert( pNC->nRef>=nRef ); |
| 74658 | 74767 | if( nRef!=pNC->nRef ){ |
| 74659 | 74768 | ExprSetProperty(pExpr, EP_VarSelect); |
| 74660 | 74769 | } |
| 74661 | 74770 | } |
| 74662 | 74771 | break; |
| 74663 | 74772 | } |
| 74664 | | -#ifndef SQLITE_OMIT_CHECK |
| 74665 | 74773 | case TK_VARIABLE: { |
| 74666 | | - if( (pNC->ncFlags & NC_IsCheck)!=0 ){ |
| 74667 | | - sqlite3ErrorMsg(pParse,"parameters prohibited in CHECK constraints"); |
| 74668 | | - } |
| 74774 | + notValidCheckConstraint(pParse, pNC, "parameters"); |
| 74775 | + notValidPartIdxWhere(pParse, pNC, "parameters"); |
| 74669 | 74776 | break; |
| 74670 | 74777 | } |
| 74671 | | -#endif |
| 74672 | 74778 | } |
| 74673 | 74779 | return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue; |
| 74674 | 74780 | } |
| 74675 | 74781 | |
| 74676 | 74782 | /* |
| | @@ -74757,11 +74863,11 @@ |
| 74757 | 74863 | /* Try to match the ORDER BY expression against an expression |
| 74758 | 74864 | ** in the result set. Return an 1-based index of the matching |
| 74759 | 74865 | ** result-set entry. |
| 74760 | 74866 | */ |
| 74761 | 74867 | for(i=0; i<pEList->nExpr; i++){ |
| 74762 | | - if( sqlite3ExprCompare(pEList->a[i].pExpr, pE)<2 ){ |
| 74868 | + if( sqlite3ExprCompare(pEList->a[i].pExpr, pE, -1)<2 ){ |
| 74763 | 74869 | return i+1; |
| 74764 | 74870 | } |
| 74765 | 74871 | } |
| 74766 | 74872 | |
| 74767 | 74873 | /* If no match, return 0. */ |
| | @@ -74985,11 +75091,11 @@ |
| 74985 | 75091 | pItem->iOrderByCol = 0; |
| 74986 | 75092 | if( sqlite3ResolveExprNames(pNC, pE) ){ |
| 74987 | 75093 | return 1; |
| 74988 | 75094 | } |
| 74989 | 75095 | for(j=0; j<pSelect->pEList->nExpr; j++){ |
| 74990 | | - if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr)==0 ){ |
| 75096 | + if( sqlite3ExprCompare(pE, pSelect->pEList->a[j].pExpr, -1)==0 ){ |
| 74991 | 75097 | pItem->iOrderByCol = j+1; |
| 74992 | 75098 | } |
| 74993 | 75099 | } |
| 74994 | 75100 | } |
| 74995 | 75101 | return sqlite3ResolveOrderGroupBy(pParse, pSelect, pOrderBy, zType); |
| | @@ -75291,10 +75397,52 @@ |
| 75291 | 75397 | w.xSelectCallback = resolveSelectStep; |
| 75292 | 75398 | w.pParse = pParse; |
| 75293 | 75399 | w.u.pNC = pOuterNC; |
| 75294 | 75400 | sqlite3WalkSelect(&w, p); |
| 75295 | 75401 | } |
| 75402 | + |
| 75403 | +/* |
| 75404 | +** Resolve names in expressions that can only reference a single table: |
| 75405 | +** |
| 75406 | +** * CHECK constraints |
| 75407 | +** * WHERE clauses on partial indices |
| 75408 | +** |
| 75409 | +** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression |
| 75410 | +** is set to -1 and the Expr.iColumn value is set to the column number. |
| 75411 | +** |
| 75412 | +** Any errors cause an error message to be set in pParse. |
| 75413 | +*/ |
| 75414 | +SQLITE_PRIVATE void sqlite3ResolveSelfReference( |
| 75415 | + Parse *pParse, /* Parsing context */ |
| 75416 | + Table *pTab, /* The table being referenced */ |
| 75417 | + int type, /* NC_IsCheck or NC_PartIdx */ |
| 75418 | + Expr *pExpr, /* Expression to resolve. May be NULL. */ |
| 75419 | + ExprList *pList /* Expression list to resolve. May be NUL. */ |
| 75420 | +){ |
| 75421 | + SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ |
| 75422 | + NameContext sNC; /* Name context for pParse->pNewTable */ |
| 75423 | + int i; /* Loop counter */ |
| 75424 | + |
| 75425 | + assert( type==NC_IsCheck || type==NC_PartIdx ); |
| 75426 | + memset(&sNC, 0, sizeof(sNC)); |
| 75427 | + memset(&sSrc, 0, sizeof(sSrc)); |
| 75428 | + sSrc.nSrc = 1; |
| 75429 | + sSrc.a[0].zName = pTab->zName; |
| 75430 | + sSrc.a[0].pTab = pTab; |
| 75431 | + sSrc.a[0].iCursor = -1; |
| 75432 | + sNC.pParse = pParse; |
| 75433 | + sNC.pSrcList = &sSrc; |
| 75434 | + sNC.ncFlags = type; |
| 75435 | + if( sqlite3ResolveExprNames(&sNC, pExpr) ) return; |
| 75436 | + if( pList ){ |
| 75437 | + for(i=0; i<pList->nExpr; i++){ |
| 75438 | + if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){ |
| 75439 | + return; |
| 75440 | + } |
| 75441 | + } |
| 75442 | + } |
| 75443 | +} |
| 75296 | 75444 | |
| 75297 | 75445 | /************** End of resolve.c *********************************************/ |
| 75298 | 75446 | /************** Begin file expr.c ********************************************/ |
| 75299 | 75447 | /* |
| 75300 | 75448 | ** 2001 September 15 |
| | @@ -76987,14 +77135,13 @@ |
| 76987 | 77135 | #endif |
| 76988 | 77136 | |
| 76989 | 77137 | switch( pExpr->op ){ |
| 76990 | 77138 | case TK_IN: { |
| 76991 | 77139 | char affinity; /* Affinity of the LHS of the IN */ |
| 76992 | | - KeyInfo keyInfo; /* Keyinfo for the generated table */ |
| 76993 | | - static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */ |
| 76994 | 77140 | int addr; /* Address of OP_OpenEphemeral instruction */ |
| 76995 | 77141 | Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */ |
| 77142 | + KeyInfo *pKeyInfo = 0; /* Key information */ |
| 76996 | 77143 | |
| 76997 | 77144 | if( rMayHaveNull ){ |
| 76998 | 77145 | sqlite3VdbeAddOp2(v, OP_Null, 0, rMayHaveNull); |
| 76999 | 77146 | } |
| 77000 | 77147 | |
| | @@ -77014,13 +77161,11 @@ |
| 77014 | 77161 | ** is used. |
| 77015 | 77162 | */ |
| 77016 | 77163 | pExpr->iTable = pParse->nTab++; |
| 77017 | 77164 | addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, !isRowid); |
| 77018 | 77165 | if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED); |
| 77019 | | - memset(&keyInfo, 0, sizeof(keyInfo)); |
| 77020 | | - keyInfo.nField = 1; |
| 77021 | | - keyInfo.aSortOrder = &sortOrder; |
| 77166 | + pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, 1); |
| 77022 | 77167 | |
| 77023 | 77168 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 77024 | 77169 | /* Case 1: expr IN (SELECT ...) |
| 77025 | 77170 | ** |
| 77026 | 77171 | ** Generate code to write the results of the select into the temporary |
| | @@ -77033,15 +77178,16 @@ |
| 77033 | 77178 | sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable); |
| 77034 | 77179 | dest.affSdst = (u8)affinity; |
| 77035 | 77180 | assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); |
| 77036 | 77181 | pExpr->x.pSelect->iLimit = 0; |
| 77037 | 77182 | if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ |
| 77183 | + sqlite3DbFree(pParse->db, pKeyInfo); |
| 77038 | 77184 | return 0; |
| 77039 | 77185 | } |
| 77040 | 77186 | pEList = pExpr->x.pSelect->pEList; |
| 77041 | | - if( ALWAYS(pEList!=0 && pEList->nExpr>0) ){ |
| 77042 | | - keyInfo.aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, |
| 77187 | + if( pKeyInfo && ALWAYS(pEList!=0 && pEList->nExpr>0) ){ |
| 77188 | + pKeyInfo->aColl[0] = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, |
| 77043 | 77189 | pEList->a[0].pExpr); |
| 77044 | 77190 | } |
| 77045 | 77191 | }else if( ALWAYS(pExpr->x.pList!=0) ){ |
| 77046 | 77192 | /* Case 2: expr IN (exprlist) |
| 77047 | 77193 | ** |
| | @@ -77056,12 +77202,13 @@ |
| 77056 | 77202 | int r1, r2, r3; |
| 77057 | 77203 | |
| 77058 | 77204 | if( !affinity ){ |
| 77059 | 77205 | affinity = SQLITE_AFF_NONE; |
| 77060 | 77206 | } |
| 77061 | | - keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft); |
| 77062 | | - keyInfo.aSortOrder = &sortOrder; |
| 77207 | + if( pKeyInfo ){ |
| 77208 | + pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft); |
| 77209 | + } |
| 77063 | 77210 | |
| 77064 | 77211 | /* Loop through each expression in <exprlist>. */ |
| 77065 | 77212 | r1 = sqlite3GetTempReg(pParse); |
| 77066 | 77213 | r2 = sqlite3GetTempReg(pParse); |
| 77067 | 77214 | sqlite3VdbeAddOp2(v, OP_Null, 0, r2); |
| | @@ -77096,12 +77243,12 @@ |
| 77096 | 77243 | } |
| 77097 | 77244 | } |
| 77098 | 77245 | sqlite3ReleaseTempReg(pParse, r1); |
| 77099 | 77246 | sqlite3ReleaseTempReg(pParse, r2); |
| 77100 | 77247 | } |
| 77101 | | - if( !isRowid ){ |
| 77102 | | - sqlite3VdbeChangeP4(v, addr, (void *)&keyInfo, P4_KEYINFO); |
| 77248 | + if( pKeyInfo ){ |
| 77249 | + sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO_HANDOFF); |
| 77103 | 77250 | } |
| 77104 | 77251 | break; |
| 77105 | 77252 | } |
| 77106 | 77253 | |
| 77107 | 77254 | case TK_EXISTS: |
| | @@ -77657,19 +77804,24 @@ |
| 77657 | 77804 | break; |
| 77658 | 77805 | } |
| 77659 | 77806 | /* Otherwise, fall thru into the TK_COLUMN case */ |
| 77660 | 77807 | } |
| 77661 | 77808 | case TK_COLUMN: { |
| 77662 | | - if( pExpr->iTable<0 ){ |
| 77663 | | - /* This only happens when coding check constraints */ |
| 77664 | | - assert( pParse->ckBase>0 ); |
| 77665 | | - inReg = pExpr->iColumn + pParse->ckBase; |
| 77666 | | - }else{ |
| 77667 | | - inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 77668 | | - pExpr->iColumn, pExpr->iTable, target, |
| 77669 | | - pExpr->op2); |
| 77670 | | - } |
| 77809 | + int iTab = pExpr->iTable; |
| 77810 | + if( iTab<0 ){ |
| 77811 | + if( pParse->ckBase>0 ){ |
| 77812 | + /* Generating CHECK constraints or inserting into partial index */ |
| 77813 | + inReg = pExpr->iColumn + pParse->ckBase; |
| 77814 | + break; |
| 77815 | + }else{ |
| 77816 | + /* Deleting from a partial index */ |
| 77817 | + iTab = pParse->iPartIdxTab; |
| 77818 | + } |
| 77819 | + } |
| 77820 | + inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 77821 | + pExpr->iColumn, iTab, target, |
| 77822 | + pExpr->op2); |
| 77671 | 77823 | break; |
| 77672 | 77824 | } |
| 77673 | 77825 | case TK_INTEGER: { |
| 77674 | 77826 | codeInteger(pParse, pExpr, 0, target); |
| 77675 | 77827 | break; |
| | @@ -79088,10 +79240,16 @@ |
| 79088 | 79240 | ** Do a deep comparison of two expression trees. Return 0 if the two |
| 79089 | 79241 | ** expressions are completely identical. Return 1 if they differ only |
| 79090 | 79242 | ** by a COLLATE operator at the top level. Return 2 if there are differences |
| 79091 | 79243 | ** other than the top-level COLLATE operator. |
| 79092 | 79244 | ** |
| 79245 | +** If any subelement of pB has Expr.iTable==(-1) then it is allowed |
| 79246 | +** to compare equal to an equivalent element in pA with Expr.iTable==iTab. |
| 79247 | +** |
| 79248 | +** The pA side might be using TK_REGISTER. If that is the case and pB is |
| 79249 | +** not using TK_REGISTER but is otherwise equivalent, then still return 0. |
| 79250 | +** |
| 79093 | 79251 | ** Sometimes this routine will return 2 even if the two expressions |
| 79094 | 79252 | ** really are equivalent. If we cannot prove that the expressions are |
| 79095 | 79253 | ** identical, we return 2 just to be safe. So if this routine |
| 79096 | 79254 | ** returns 2, then you do not really know for certain if the two |
| 79097 | 79255 | ** expressions are the same. But if you get a 0 or 1 return, then you |
| | @@ -79098,33 +79256,36 @@ |
| 79098 | 79256 | ** can be sure the expressions are the same. In the places where |
| 79099 | 79257 | ** this routine is used, it does not hurt to get an extra 2 - that |
| 79100 | 79258 | ** just might result in some slightly slower code. But returning |
| 79101 | 79259 | ** an incorrect 0 or 1 could lead to a malfunction. |
| 79102 | 79260 | */ |
| 79103 | | -SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB){ |
| 79261 | +SQLITE_PRIVATE int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){ |
| 79104 | 79262 | if( pA==0||pB==0 ){ |
| 79105 | 79263 | return pB==pA ? 0 : 2; |
| 79106 | 79264 | } |
| 79107 | 79265 | assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) ); |
| 79108 | 79266 | assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) ); |
| 79109 | 79267 | if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){ |
| 79110 | 79268 | return 2; |
| 79111 | 79269 | } |
| 79112 | 79270 | if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2; |
| 79113 | | - if( pA->op!=pB->op ){ |
| 79114 | | - if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB)<2 ){ |
| 79271 | + if( pA->op!=pB->op && (pA->op!=TK_REGISTER || pA->op2!=pB->op) ){ |
| 79272 | + if( pA->op==TK_COLLATE && sqlite3ExprCompare(pA->pLeft, pB, iTab)<2 ){ |
| 79115 | 79273 | return 1; |
| 79116 | 79274 | } |
| 79117 | | - if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft)<2 ){ |
| 79275 | + if( pB->op==TK_COLLATE && sqlite3ExprCompare(pA, pB->pLeft, iTab)<2 ){ |
| 79118 | 79276 | return 1; |
| 79119 | 79277 | } |
| 79120 | 79278 | return 2; |
| 79121 | 79279 | } |
| 79122 | | - if( sqlite3ExprCompare(pA->pLeft, pB->pLeft) ) return 2; |
| 79123 | | - if( sqlite3ExprCompare(pA->pRight, pB->pRight) ) return 2; |
| 79124 | | - if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList) ) return 2; |
| 79125 | | - if( pA->iTable!=pB->iTable || pA->iColumn!=pB->iColumn ) return 2; |
| 79280 | + if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2; |
| 79281 | + if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2; |
| 79282 | + if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2; |
| 79283 | + if( pA->iColumn!=pB->iColumn ) return 2; |
| 79284 | + if( pA->iTable!=pB->iTable |
| 79285 | + && pA->op!=TK_REGISTER |
| 79286 | + && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2; |
| 79126 | 79287 | if( ExprHasProperty(pA, EP_IntValue) ){ |
| 79127 | 79288 | if( !ExprHasProperty(pB, EP_IntValue) || pA->u.iValue!=pB->u.iValue ){ |
| 79128 | 79289 | return 2; |
| 79129 | 79290 | } |
| 79130 | 79291 | }else if( pA->op!=TK_COLUMN && ALWAYS(pA->op!=TK_AGG_COLUMN) && pA->u.zToken){ |
| | @@ -79138,28 +79299,70 @@ |
| 79138 | 79299 | |
| 79139 | 79300 | /* |
| 79140 | 79301 | ** Compare two ExprList objects. Return 0 if they are identical and |
| 79141 | 79302 | ** non-zero if they differ in any way. |
| 79142 | 79303 | ** |
| 79304 | +** If any subelement of pB has Expr.iTable==(-1) then it is allowed |
| 79305 | +** to compare equal to an equivalent element in pA with Expr.iTable==iTab. |
| 79306 | +** |
| 79143 | 79307 | ** This routine might return non-zero for equivalent ExprLists. The |
| 79144 | 79308 | ** only consequence will be disabled optimizations. But this routine |
| 79145 | 79309 | ** must never return 0 if the two ExprList objects are different, or |
| 79146 | 79310 | ** a malfunction will result. |
| 79147 | 79311 | ** |
| 79148 | 79312 | ** Two NULL pointers are considered to be the same. But a NULL pointer |
| 79149 | 79313 | ** always differs from a non-NULL pointer. |
| 79150 | 79314 | */ |
| 79151 | | -SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB){ |
| 79315 | +SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){ |
| 79152 | 79316 | int i; |
| 79153 | 79317 | if( pA==0 && pB==0 ) return 0; |
| 79154 | 79318 | if( pA==0 || pB==0 ) return 1; |
| 79155 | 79319 | if( pA->nExpr!=pB->nExpr ) return 1; |
| 79156 | 79320 | for(i=0; i<pA->nExpr; i++){ |
| 79157 | 79321 | Expr *pExprA = pA->a[i].pExpr; |
| 79158 | 79322 | Expr *pExprB = pB->a[i].pExpr; |
| 79159 | 79323 | if( pA->a[i].sortOrder!=pB->a[i].sortOrder ) return 1; |
| 79160 | | - if( sqlite3ExprCompare(pExprA, pExprB) ) return 1; |
| 79324 | + if( sqlite3ExprCompare(pExprA, pExprB, iTab) ) return 1; |
| 79325 | + } |
| 79326 | + return 0; |
| 79327 | +} |
| 79328 | + |
| 79329 | +/* |
| 79330 | +** Return true if we can prove the pE2 will always be true if pE1 is |
| 79331 | +** true. Return false if we cannot complete the proof or if pE2 might |
| 79332 | +** be false. Examples: |
| 79333 | +** |
| 79334 | +** pE1: x==5 pE2: x==5 Result: true |
| 79335 | +** pE1: x>0 pE2: x==5 Result: false |
| 79336 | +** pE1: x=21 pE2: x=21 OR y=43 Result: true |
| 79337 | +** pE1: x!=123 pE2: x IS NOT NULL Result: true |
| 79338 | +** pE1: x!=?1 pE2: x IS NOT NULL Result: true |
| 79339 | +** pE1: x IS NULL pE2: x IS NOT NULL Result: false |
| 79340 | +** pE1: x IS ?2 pE2: x IS NOT NULL Reuslt: false |
| 79341 | +** |
| 79342 | +** When comparing TK_COLUMN nodes between pE1 and pE2, if pE2 has |
| 79343 | +** Expr.iTable<0 then assume a table number given by iTab. |
| 79344 | +** |
| 79345 | +** When in doubt, return false. Returning true might give a performance |
| 79346 | +** improvement. Returning false might cause a performance reduction, but |
| 79347 | +** it will always give the correct answer and is hence always safe. |
| 79348 | +*/ |
| 79349 | +SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr *pE1, Expr *pE2, int iTab){ |
| 79350 | + if( sqlite3ExprCompare(pE1, pE2, iTab)==0 ){ |
| 79351 | + return 1; |
| 79352 | + } |
| 79353 | + if( pE2->op==TK_OR |
| 79354 | + && (sqlite3ExprImpliesExpr(pE1, pE2->pLeft, iTab) |
| 79355 | + || sqlite3ExprImpliesExpr(pE1, pE2->pRight, iTab) ) |
| 79356 | + ){ |
| 79357 | + return 1; |
| 79358 | + } |
| 79359 | + if( pE2->op==TK_NOTNULL |
| 79360 | + && sqlite3ExprCompare(pE1->pLeft, pE2->pLeft, iTab)==0 |
| 79361 | + && (pE1->op!=TK_ISNULL && pE1->op!=TK_IS) |
| 79362 | + ){ |
| 79363 | + return 1; |
| 79161 | 79364 | } |
| 79162 | 79365 | return 0; |
| 79163 | 79366 | } |
| 79164 | 79367 | |
| 79165 | 79368 | /* |
| | @@ -79340,11 +79543,11 @@ |
| 79340 | 79543 | /* Check to see if pExpr is a duplicate of another aggregate |
| 79341 | 79544 | ** function that is already in the pAggInfo structure |
| 79342 | 79545 | */ |
| 79343 | 79546 | struct AggInfo_func *pItem = pAggInfo->aFunc; |
| 79344 | 79547 | for(i=0; i<pAggInfo->nFunc; i++, pItem++){ |
| 79345 | | - if( sqlite3ExprCompare(pItem->pExpr, pExpr)==0 ){ |
| 79548 | + if( sqlite3ExprCompare(pItem->pExpr, pExpr, -1)==0 ){ |
| 79346 | 79549 | break; |
| 79347 | 79550 | } |
| 79348 | 79551 | } |
| 79349 | 79552 | if( i>=pAggInfo->nFunc ){ |
| 79350 | 79553 | /* pExpr is original. Make a new entry in pAggInfo->aFunc[] |
| | @@ -80757,10 +80960,11 @@ |
| 80757 | 80960 | int i; /* Loop counter */ |
| 80758 | 80961 | int topOfLoop; /* The top of the loop */ |
| 80759 | 80962 | int endOfLoop; /* The end of the loop */ |
| 80760 | 80963 | int jZeroRows = -1; /* Jump from here if number of rows is zero */ |
| 80761 | 80964 | int iDb; /* Index of database containing pTab */ |
| 80965 | + u8 needTableCnt = 1; /* True to count the table */ |
| 80762 | 80966 | int regTabname = iMem++; /* Register containing table name */ |
| 80763 | 80967 | int regIdxname = iMem++; /* Register containing index name */ |
| 80764 | 80968 | int regStat1 = iMem++; /* The stat column of sqlite_stat1 */ |
| 80765 | 80969 | #ifdef SQLITE_ENABLE_STAT3 |
| 80766 | 80970 | int regNumEq = regStat1; /* Number of instances. Same as regStat1 */ |
| | @@ -80816,10 +81020,11 @@ |
| 80816 | 81020 | KeyInfo *pKey; |
| 80817 | 81021 | int addrIfNot = 0; /* address of OP_IfNot */ |
| 80818 | 81022 | int *aChngAddr; /* Array of jump instruction addresses */ |
| 80819 | 81023 | |
| 80820 | 81024 | if( pOnlyIdx && pOnlyIdx!=pIdx ) continue; |
| 81025 | + if( pIdx->pPartIdxWhere==0 ) needTableCnt = 0; |
| 80821 | 81026 | VdbeNoopComment((v, "Begin analysis of %s", pIdx->zName)); |
| 80822 | 81027 | nCol = pIdx->nColumn; |
| 80823 | 81028 | aChngAddr = sqlite3DbMallocRaw(db, sizeof(int)*nCol); |
| 80824 | 81029 | if( aChngAddr==0 ) continue; |
| 80825 | 81030 | pKey = sqlite3IndexKeyinfo(pParse, pIdx); |
| | @@ -80975,48 +81180,45 @@ |
| 80975 | 81180 | ** If K==0 then no entry is made into the sqlite_stat1 table. |
| 80976 | 81181 | ** If K>0 then it is always the case the D>0 so division by zero |
| 80977 | 81182 | ** is never possible. |
| 80978 | 81183 | */ |
| 80979 | 81184 | sqlite3VdbeAddOp2(v, OP_SCopy, iMem, regStat1); |
| 80980 | | - if( jZeroRows<0 ){ |
| 80981 | | - jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); |
| 80982 | | - } |
| 81185 | + jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, iMem); |
| 80983 | 81186 | for(i=0; i<nCol; i++){ |
| 80984 | 81187 | sqlite3VdbeAddOp4(v, OP_String8, 0, regTemp, 0, " ", 0); |
| 80985 | 81188 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); |
| 80986 | 81189 | sqlite3VdbeAddOp3(v, OP_Add, iMem, iMem+i+1, regTemp); |
| 80987 | 81190 | sqlite3VdbeAddOp2(v, OP_AddImm, regTemp, -1); |
| 80988 | 81191 | sqlite3VdbeAddOp3(v, OP_Divide, iMem+i+1, regTemp, regTemp); |
| 80989 | 81192 | sqlite3VdbeAddOp1(v, OP_ToInt, regTemp); |
| 80990 | 81193 | sqlite3VdbeAddOp3(v, OP_Concat, regTemp, regStat1, regStat1); |
| 80991 | 81194 | } |
| 81195 | + if( pIdx->pPartIdxWhere!=0 ) sqlite3VdbeJumpHere(v, jZeroRows); |
| 80992 | 81196 | sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 80993 | 81197 | sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 80994 | 81198 | sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 80995 | 81199 | sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 81200 | + if( pIdx->pPartIdxWhere==0 ) sqlite3VdbeJumpHere(v, jZeroRows); |
| 80996 | 81201 | } |
| 80997 | 81202 | |
| 80998 | | - /* If the table has no indices, create a single sqlite_stat1 entry |
| 80999 | | - ** containing NULL as the index name and the row count as the content. |
| 81203 | + /* Create a single sqlite_stat1 entry containing NULL as the index |
| 81204 | + ** name and the row count as the content. |
| 81000 | 81205 | */ |
| 81001 | | - if( pTab->pIndex==0 ){ |
| 81206 | + if( pOnlyIdx==0 && needTableCnt ){ |
| 81002 | 81207 | sqlite3VdbeAddOp3(v, OP_OpenRead, iIdxCur, pTab->tnum, iDb); |
| 81003 | 81208 | VdbeComment((v, "%s", pTab->zName)); |
| 81004 | 81209 | sqlite3VdbeAddOp2(v, OP_Count, iIdxCur, regStat1); |
| 81005 | 81210 | sqlite3VdbeAddOp1(v, OP_Close, iIdxCur); |
| 81006 | 81211 | jZeroRows = sqlite3VdbeAddOp1(v, OP_IfNot, regStat1); |
| 81007 | | - }else{ |
| 81008 | | - sqlite3VdbeJumpHere(v, jZeroRows); |
| 81009 | | - jZeroRows = sqlite3VdbeAddOp0(v, OP_Goto); |
| 81010 | | - } |
| 81011 | | - sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); |
| 81012 | | - sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 81013 | | - sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 81014 | | - sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 81015 | | - sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 81016 | | - if( pParse->nMem<regRec ) pParse->nMem = regRec; |
| 81017 | | - sqlite3VdbeJumpHere(v, jZeroRows); |
| 81212 | + sqlite3VdbeAddOp2(v, OP_Null, 0, regIdxname); |
| 81213 | + sqlite3VdbeAddOp4(v, OP_MakeRecord, regTabname, 3, regRec, "aaa", 0); |
| 81214 | + sqlite3VdbeAddOp2(v, OP_NewRowid, iStatCur, regNewRowid); |
| 81215 | + sqlite3VdbeAddOp3(v, OP_Insert, iStatCur, regRec, regNewRowid); |
| 81216 | + sqlite3VdbeChangeP5(v, OPFLAG_APPEND); |
| 81217 | + sqlite3VdbeJumpHere(v, jZeroRows); |
| 81218 | + } |
| 81219 | + if( pParse->nMem<regRec ) pParse->nMem = regRec; |
| 81018 | 81220 | } |
| 81019 | 81221 | |
| 81020 | 81222 | |
| 81021 | 81223 | /* |
| 81022 | 81224 | ** Generate code that will cause the most recent index analysis to |
| | @@ -81195,12 +81397,14 @@ |
| 81195 | 81397 | v = 0; |
| 81196 | 81398 | while( (c=z[0])>='0' && c<='9' ){ |
| 81197 | 81399 | v = v*10 + c - '0'; |
| 81198 | 81400 | z++; |
| 81199 | 81401 | } |
| 81200 | | - if( i==0 ) pTable->nRowEst = v; |
| 81201 | | - if( pIndex==0 ) break; |
| 81402 | + if( i==0 && (pIndex==0 || pIndex->pPartIdxWhere==0) ){ |
| 81403 | + if( v>0 ) pTable->nRowEst = v; |
| 81404 | + if( pIndex==0 ) break; |
| 81405 | + } |
| 81202 | 81406 | pIndex->aiRowEst[i] = v; |
| 81203 | 81407 | if( *z==' ' ) z++; |
| 81204 | 81408 | if( strcmp(z, "unordered")==0 ){ |
| 81205 | 81409 | pIndex->bUnordered = 1; |
| 81206 | 81410 | break; |
| | @@ -82636,10 +82840,11 @@ |
| 82636 | 82840 | */ |
| 82637 | 82841 | static void freeIndex(sqlite3 *db, Index *p){ |
| 82638 | 82842 | #ifndef SQLITE_OMIT_ANALYZE |
| 82639 | 82843 | sqlite3DeleteIndexSamples(db, p); |
| 82640 | 82844 | #endif |
| 82845 | + sqlite3ExprDelete(db, p->pPartIdxWhere); |
| 82641 | 82846 | sqlite3DbFree(db, p->zColAff); |
| 82642 | 82847 | sqlite3DbFree(db, p); |
| 82643 | 82848 | } |
| 82644 | 82849 | |
| 82645 | 82850 | /* |
| | @@ -83479,11 +83684,12 @@ |
| 83479 | 83684 | sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " |
| 83480 | 83685 | "INTEGER PRIMARY KEY"); |
| 83481 | 83686 | #endif |
| 83482 | 83687 | }else{ |
| 83483 | 83688 | Index *p; |
| 83484 | | - p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, 0, sortOrder, 0); |
| 83689 | + p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, |
| 83690 | + 0, sortOrder, 0); |
| 83485 | 83691 | if( p ){ |
| 83486 | 83692 | p->autoIndex = 2; |
| 83487 | 83693 | } |
| 83488 | 83694 | pList = 0; |
| 83489 | 83695 | } |
| | @@ -83774,30 +83980,11 @@ |
| 83774 | 83980 | |
| 83775 | 83981 | #ifndef SQLITE_OMIT_CHECK |
| 83776 | 83982 | /* Resolve names in all CHECK constraint expressions. |
| 83777 | 83983 | */ |
| 83778 | 83984 | if( p->pCheck ){ |
| 83779 | | - SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ |
| 83780 | | - NameContext sNC; /* Name context for pParse->pNewTable */ |
| 83781 | | - ExprList *pList; /* List of all CHECK constraints */ |
| 83782 | | - int i; /* Loop counter */ |
| 83783 | | - |
| 83784 | | - memset(&sNC, 0, sizeof(sNC)); |
| 83785 | | - memset(&sSrc, 0, sizeof(sSrc)); |
| 83786 | | - sSrc.nSrc = 1; |
| 83787 | | - sSrc.a[0].zName = p->zName; |
| 83788 | | - sSrc.a[0].pTab = p; |
| 83789 | | - sSrc.a[0].iCursor = -1; |
| 83790 | | - sNC.pParse = pParse; |
| 83791 | | - sNC.pSrcList = &sSrc; |
| 83792 | | - sNC.ncFlags = NC_IsCheck; |
| 83793 | | - pList = p->pCheck; |
| 83794 | | - for(i=0; i<pList->nExpr; i++){ |
| 83795 | | - if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){ |
| 83796 | | - return; |
| 83797 | | - } |
| 83798 | | - } |
| 83985 | + sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck); |
| 83799 | 83986 | } |
| 83800 | 83987 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 83801 | 83988 | |
| 83802 | 83989 | /* If the db->init.busy is 1 it means we are reading the SQL off the |
| 83803 | 83990 | ** "sqlite_master" or "sqlite_temp_master" table on the disk. |
| | @@ -84645,10 +84832,11 @@ |
| 84645 | 84832 | int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */ |
| 84646 | 84833 | int iSorter; /* Cursor opened by OpenSorter (if in use) */ |
| 84647 | 84834 | int addr1; /* Address of top of loop */ |
| 84648 | 84835 | int addr2; /* Address to jump to for next iteration */ |
| 84649 | 84836 | int tnum; /* Root page of index */ |
| 84837 | + int iPartIdxLabel; /* Jump to this label to skip a row */ |
| 84650 | 84838 | Vdbe *v; /* Generate code into this virtual machine */ |
| 84651 | 84839 | KeyInfo *pKey; /* KeyInfo for index */ |
| 84652 | 84840 | int regRecord; /* Register holding assemblied index record */ |
| 84653 | 84841 | sqlite3 *db = pParse->db; /* The database connection */ |
| 84654 | 84842 | int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema); |
| | @@ -84684,12 +84872,13 @@ |
| 84684 | 84872 | ** records into the sorter. */ |
| 84685 | 84873 | sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead); |
| 84686 | 84874 | addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); |
| 84687 | 84875 | regRecord = sqlite3GetTempReg(pParse); |
| 84688 | 84876 | |
| 84689 | | - sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1); |
| 84877 | + sqlite3GenerateIndexKey(pParse, pIndex, iTab, regRecord, 1, &iPartIdxLabel); |
| 84690 | 84878 | sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord); |
| 84879 | + sqlite3VdbeResolveLabel(v, iPartIdxLabel); |
| 84691 | 84880 | sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); |
| 84692 | 84881 | sqlite3VdbeJumpHere(v, addr1); |
| 84693 | 84882 | addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); |
| 84694 | 84883 | if( pIndex->onError!=OE_None ){ |
| 84695 | 84884 | int j2 = sqlite3VdbeCurrentAddr(v) + 3; |
| | @@ -84736,11 +84925,11 @@ |
| 84736 | 84925 | Token *pName2, /* Second part of index name. May be NULL */ |
| 84737 | 84926 | SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */ |
| 84738 | 84927 | ExprList *pList, /* A list of columns to be indexed */ |
| 84739 | 84928 | int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 84740 | 84929 | Token *pStart, /* The CREATE token that begins this statement */ |
| 84741 | | - Token *pEnd, /* The ")" that closes the CREATE INDEX statement */ |
| 84930 | + Expr *pPIWhere, /* WHERE clause for partial indices */ |
| 84742 | 84931 | int sortOrder, /* Sort order of primary key when pList==NULL */ |
| 84743 | 84932 | int ifNotExist /* Omit error if index already exists */ |
| 84744 | 84933 | ){ |
| 84745 | 84934 | Index *pRet = 0; /* Pointer to return */ |
| 84746 | 84935 | Table *pTab = 0; /* Table to be indexed */ |
| | @@ -84758,11 +84947,10 @@ |
| 84758 | 84947 | struct ExprList_item *pListItem; /* For looping over pList */ |
| 84759 | 84948 | int nCol; |
| 84760 | 84949 | int nExtra = 0; |
| 84761 | 84950 | char *zExtra; |
| 84762 | 84951 | |
| 84763 | | - assert( pStart==0 || pEnd!=0 ); /* pEnd must be non-NULL if pStart is */ |
| 84764 | 84952 | assert( pParse->nErr==0 ); /* Never called with prior errors */ |
| 84765 | 84953 | if( db->mallocFailed || IN_DECLARE_VTAB ){ |
| 84766 | 84954 | goto exit_create_index; |
| 84767 | 84955 | } |
| 84768 | 84956 | if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ |
| | @@ -84804,11 +84992,16 @@ |
| 84804 | 84992 | assert(0); |
| 84805 | 84993 | } |
| 84806 | 84994 | pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]); |
| 84807 | 84995 | assert( db->mallocFailed==0 || pTab==0 ); |
| 84808 | 84996 | if( pTab==0 ) goto exit_create_index; |
| 84809 | | - assert( db->aDb[iDb].pSchema==pTab->pSchema ); |
| 84997 | + if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){ |
| 84998 | + sqlite3ErrorMsg(pParse, |
| 84999 | + "cannot create a TEMP index on non-TEMP table \"%s\"", |
| 85000 | + pTab->zName); |
| 85001 | + goto exit_create_index; |
| 85002 | + } |
| 84810 | 85003 | }else{ |
| 84811 | 85004 | assert( pName==0 ); |
| 84812 | 85005 | assert( pStart==0 ); |
| 84813 | 85006 | pTab = pParse->pNewTable; |
| 84814 | 85007 | if( !pTab ) goto exit_create_index; |
| | @@ -84953,10 +85146,15 @@ |
| 84953 | 85146 | pIndex->nColumn = pList->nExpr; |
| 84954 | 85147 | pIndex->onError = (u8)onError; |
| 84955 | 85148 | pIndex->uniqNotNull = onError==OE_Abort; |
| 84956 | 85149 | pIndex->autoIndex = (u8)(pName==0); |
| 84957 | 85150 | pIndex->pSchema = db->aDb[iDb].pSchema; |
| 85151 | + if( pPIWhere ){ |
| 85152 | + sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0); |
| 85153 | + pIndex->pPartIdxWhere = pPIWhere; |
| 85154 | + pPIWhere = 0; |
| 85155 | + } |
| 84958 | 85156 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 84959 | 85157 | |
| 84960 | 85158 | /* Check to see if we should honor DESC requests on index columns |
| 84961 | 85159 | */ |
| 84962 | 85160 | if( pDb->pSchema->file_format>=4 ){ |
| | @@ -85108,11 +85306,11 @@ |
| 85108 | 85306 | ** If pTblName==0 it means this index is generated as a primary key |
| 85109 | 85307 | ** or UNIQUE constraint of a CREATE TABLE statement. Since the table |
| 85110 | 85308 | ** has just been created, it contains no data and the index initialization |
| 85111 | 85309 | ** step can be skipped. |
| 85112 | 85310 | */ |
| 85113 | | - else{ /* if( db->init.busy==0 ) */ |
| 85311 | + else if( pParse->nErr==0 ){ |
| 85114 | 85312 | Vdbe *v; |
| 85115 | 85313 | char *zStmt; |
| 85116 | 85314 | int iMem = ++pParse->nMem; |
| 85117 | 85315 | |
| 85118 | 85316 | v = sqlite3GetVdbe(pParse); |
| | @@ -85126,16 +85324,15 @@ |
| 85126 | 85324 | |
| 85127 | 85325 | /* Gather the complete text of the CREATE INDEX statement into |
| 85128 | 85326 | ** the zStmt variable |
| 85129 | 85327 | */ |
| 85130 | 85328 | if( pStart ){ |
| 85131 | | - assert( pEnd!=0 ); |
| 85329 | + int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n; |
| 85330 | + if( pName->z[n-1]==';' ) n--; |
| 85132 | 85331 | /* A named index with an explicit CREATE INDEX statement */ |
| 85133 | 85332 | zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s", |
| 85134 | | - onError==OE_None ? "" : " UNIQUE", |
| 85135 | | - (int)(pEnd->z - pName->z) + 1, |
| 85136 | | - pName->z); |
| 85333 | + onError==OE_None ? "" : " UNIQUE", n, pName->z); |
| 85137 | 85334 | }else{ |
| 85138 | 85335 | /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */ |
| 85139 | 85336 | /* zStmt = sqlite3MPrintf(""); */ |
| 85140 | 85337 | zStmt = 0; |
| 85141 | 85338 | } |
| | @@ -85187,14 +85384,12 @@ |
| 85187 | 85384 | pIndex = 0; |
| 85188 | 85385 | } |
| 85189 | 85386 | |
| 85190 | 85387 | /* Clean up before exiting */ |
| 85191 | 85388 | exit_create_index: |
| 85192 | | - if( pIndex ){ |
| 85193 | | - sqlite3DbFree(db, pIndex->zColAff); |
| 85194 | | - sqlite3DbFree(db, pIndex); |
| 85195 | | - } |
| 85389 | + if( pIndex ) freeIndex(db, pIndex); |
| 85390 | + sqlite3ExprDelete(db, pPIWhere); |
| 85196 | 85391 | sqlite3ExprListDelete(db, pList); |
| 85197 | 85392 | sqlite3SrcListDelete(db, pTblName); |
| 85198 | 85393 | sqlite3DbFree(db, zName); |
| 85199 | 85394 | return pRet; |
| 85200 | 85395 | } |
| | @@ -86068,29 +86263,24 @@ |
| 86068 | 86263 | ** the error. |
| 86069 | 86264 | */ |
| 86070 | 86265 | SQLITE_PRIVATE KeyInfo *sqlite3IndexKeyinfo(Parse *pParse, Index *pIdx){ |
| 86071 | 86266 | int i; |
| 86072 | 86267 | int nCol = pIdx->nColumn; |
| 86073 | | - int nBytes = sizeof(KeyInfo) + (nCol-1)*sizeof(CollSeq*) + nCol; |
| 86074 | | - sqlite3 *db = pParse->db; |
| 86075 | | - KeyInfo *pKey = (KeyInfo *)sqlite3DbMallocZero(db, nBytes); |
| 86076 | | - |
| 86077 | | - if( pKey ){ |
| 86078 | | - pKey->db = pParse->db; |
| 86079 | | - pKey->aSortOrder = (u8 *)&(pKey->aColl[nCol]); |
| 86080 | | - assert( &pKey->aSortOrder[nCol]==&(((u8 *)pKey)[nBytes]) ); |
| 86268 | + KeyInfo *pKey; |
| 86269 | + |
| 86270 | + pKey = sqlite3KeyInfoAlloc(pParse->db, nCol); |
| 86271 | + if( pKey ){ |
| 86081 | 86272 | for(i=0; i<nCol; i++){ |
| 86082 | 86273 | char *zColl = pIdx->azColl[i]; |
| 86083 | 86274 | assert( zColl ); |
| 86084 | 86275 | pKey->aColl[i] = sqlite3LocateCollSeq(pParse, zColl); |
| 86085 | 86276 | pKey->aSortOrder[i] = pIdx->aSortOrder[i]; |
| 86086 | 86277 | } |
| 86087 | | - pKey->nField = (u16)nCol; |
| 86088 | 86278 | } |
| 86089 | 86279 | |
| 86090 | 86280 | if( pParse->nErr ){ |
| 86091 | | - sqlite3DbFree(db, pKey); |
| 86281 | + sqlite3DbFree(pParse->db, pKey); |
| 86092 | 86282 | pKey = 0; |
| 86093 | 86283 | } |
| 86094 | 86284 | return pKey; |
| 86095 | 86285 | } |
| 86096 | 86286 | |
| | @@ -87166,15 +87356,18 @@ |
| 87166 | 87356 | int *aRegIdx /* Only delete if aRegIdx!=0 && aRegIdx[i]>0 */ |
| 87167 | 87357 | ){ |
| 87168 | 87358 | int i; |
| 87169 | 87359 | Index *pIdx; |
| 87170 | 87360 | int r1; |
| 87361 | + int iPartIdxLabel; |
| 87362 | + Vdbe *v = pParse->pVdbe; |
| 87171 | 87363 | |
| 87172 | 87364 | for(i=1, pIdx=pTab->pIndex; pIdx; i++, pIdx=pIdx->pNext){ |
| 87173 | 87365 | if( aRegIdx!=0 && aRegIdx[i-1]==0 ) continue; |
| 87174 | | - r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0); |
| 87175 | | - sqlite3VdbeAddOp3(pParse->pVdbe, OP_IdxDelete, iCur+i, r1,pIdx->nColumn+1); |
| 87366 | + r1 = sqlite3GenerateIndexKey(pParse, pIdx, iCur, 0, 0, &iPartIdxLabel); |
| 87367 | + sqlite3VdbeAddOp3(v, OP_IdxDelete, iCur+i, r1, pIdx->nColumn+1); |
| 87368 | + sqlite3VdbeResolveLabel(v, iPartIdxLabel); |
| 87176 | 87369 | } |
| 87177 | 87370 | } |
| 87178 | 87371 | |
| 87179 | 87372 | /* |
| 87180 | 87373 | ** Generate code that will assemble an index key and put it in register |
| | @@ -87184,24 +87377,42 @@ |
| 87184 | 87377 | ** |
| 87185 | 87378 | ** Return a register number which is the first in a block of |
| 87186 | 87379 | ** registers that holds the elements of the index key. The |
| 87187 | 87380 | ** block of registers has already been deallocated by the time |
| 87188 | 87381 | ** this routine returns. |
| 87382 | +** |
| 87383 | +** If *piPartIdxLabel is not NULL, fill it in with a label and jump |
| 87384 | +** to that label if pIdx is a partial index that should be skipped. |
| 87385 | +** A partial index should be skipped if its WHERE clause evaluates |
| 87386 | +** to false or null. If pIdx is not a partial index, *piPartIdxLabel |
| 87387 | +** will be set to zero which is an empty label that is ignored by |
| 87388 | +** sqlite3VdbeResolveLabel(). |
| 87189 | 87389 | */ |
| 87190 | 87390 | SQLITE_PRIVATE int sqlite3GenerateIndexKey( |
| 87191 | | - Parse *pParse, /* Parsing context */ |
| 87192 | | - Index *pIdx, /* The index for which to generate a key */ |
| 87193 | | - int iCur, /* Cursor number for the pIdx->pTable table */ |
| 87194 | | - int regOut, /* Write the new index key to this register */ |
| 87195 | | - int doMakeRec /* Run the OP_MakeRecord instruction if true */ |
| 87391 | + Parse *pParse, /* Parsing context */ |
| 87392 | + Index *pIdx, /* The index for which to generate a key */ |
| 87393 | + int iCur, /* Cursor number for the pIdx->pTable table */ |
| 87394 | + int regOut, /* Write the new index key to this register */ |
| 87395 | + int doMakeRec, /* Run the OP_MakeRecord instruction if true */ |
| 87396 | + int *piPartIdxLabel /* OUT: Jump to this label to skip partial index */ |
| 87196 | 87397 | ){ |
| 87197 | 87398 | Vdbe *v = pParse->pVdbe; |
| 87198 | 87399 | int j; |
| 87199 | 87400 | Table *pTab = pIdx->pTable; |
| 87200 | 87401 | int regBase; |
| 87201 | 87402 | int nCol; |
| 87202 | 87403 | |
| 87404 | + if( piPartIdxLabel ){ |
| 87405 | + if( pIdx->pPartIdxWhere ){ |
| 87406 | + *piPartIdxLabel = sqlite3VdbeMakeLabel(v); |
| 87407 | + pParse->iPartIdxTab = iCur; |
| 87408 | + sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel, |
| 87409 | + SQLITE_JUMPIFNULL); |
| 87410 | + }else{ |
| 87411 | + *piPartIdxLabel = 0; |
| 87412 | + } |
| 87413 | + } |
| 87203 | 87414 | nCol = pIdx->nColumn; |
| 87204 | 87415 | regBase = sqlite3GetTempRange(pParse, nCol+1); |
| 87205 | 87416 | sqlite3VdbeAddOp2(v, OP_Rowid, iCur, regBase+nCol); |
| 87206 | 87417 | for(j=0; j<nCol; j++){ |
| 87207 | 87418 | int idx = pIdx->aiColumn[j]; |
| | @@ -91561,12 +91772,22 @@ |
| 91561 | 91772 | ** Add the new records to the indices as we go. |
| 91562 | 91773 | */ |
| 91563 | 91774 | for(iCur=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, iCur++){ |
| 91564 | 91775 | int regIdx; |
| 91565 | 91776 | int regR; |
| 91777 | + int addrSkipRow = 0; |
| 91566 | 91778 | |
| 91567 | 91779 | if( aRegIdx[iCur]==0 ) continue; /* Skip unused indices */ |
| 91780 | + |
| 91781 | + if( pIdx->pPartIdxWhere ){ |
| 91782 | + sqlite3VdbeAddOp2(v, OP_Null, 0, aRegIdx[iCur]); |
| 91783 | + addrSkipRow = sqlite3VdbeMakeLabel(v); |
| 91784 | + pParse->ckBase = regData; |
| 91785 | + sqlite3ExprIfFalse(pParse, pIdx->pPartIdxWhere, addrSkipRow, |
| 91786 | + SQLITE_JUMPIFNULL); |
| 91787 | + pParse->ckBase = 0; |
| 91788 | + } |
| 91568 | 91789 | |
| 91569 | 91790 | /* Create a key for accessing the index entry */ |
| 91570 | 91791 | regIdx = sqlite3GetTempRange(pParse, pIdx->nColumn+1); |
| 91571 | 91792 | for(i=0; i<pIdx->nColumn; i++){ |
| 91572 | 91793 | int idx = pIdx->aiColumn[i]; |
| | @@ -91583,10 +91804,11 @@ |
| 91583 | 91804 | |
| 91584 | 91805 | /* Find out what action to take in case there is an indexing conflict */ |
| 91585 | 91806 | onError = pIdx->onError; |
| 91586 | 91807 | if( onError==OE_None ){ |
| 91587 | 91808 | sqlite3ReleaseTempRange(pParse, regIdx, pIdx->nColumn+1); |
| 91809 | + sqlite3VdbeResolveLabel(v, addrSkipRow); |
| 91588 | 91810 | continue; /* pIdx is not a UNIQUE index */ |
| 91589 | 91811 | } |
| 91590 | 91812 | if( overrideError!=OE_Default ){ |
| 91591 | 91813 | onError = overrideError; |
| 91592 | 91814 | }else if( onError==OE_Default ){ |
| | @@ -91652,10 +91874,11 @@ |
| 91652 | 91874 | seenReplace = 1; |
| 91653 | 91875 | break; |
| 91654 | 91876 | } |
| 91655 | 91877 | } |
| 91656 | 91878 | sqlite3VdbeJumpHere(v, j3); |
| 91879 | + sqlite3VdbeResolveLabel(v, addrSkipRow); |
| 91657 | 91880 | sqlite3ReleaseTempReg(pParse, regR); |
| 91658 | 91881 | } |
| 91659 | 91882 | |
| 91660 | 91883 | if( pbMayReplace ){ |
| 91661 | 91884 | *pbMayReplace = seenReplace; |
| | @@ -91681,22 +91904,23 @@ |
| 91681 | 91904 | int appendBias, /* True if this is likely to be an append */ |
| 91682 | 91905 | int useSeekResult /* True to set the USESEEKRESULT flag on OP_[Idx]Insert */ |
| 91683 | 91906 | ){ |
| 91684 | 91907 | int i; |
| 91685 | 91908 | Vdbe *v; |
| 91686 | | - int nIdx; |
| 91687 | 91909 | Index *pIdx; |
| 91688 | 91910 | u8 pik_flags; |
| 91689 | 91911 | int regData; |
| 91690 | 91912 | int regRec; |
| 91691 | 91913 | |
| 91692 | 91914 | v = sqlite3GetVdbe(pParse); |
| 91693 | 91915 | assert( v!=0 ); |
| 91694 | 91916 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ |
| 91695 | | - for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, nIdx++){} |
| 91696 | | - for(i=nIdx-1; i>=0; i--){ |
| 91917 | + for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 91697 | 91918 | if( aRegIdx[i]==0 ) continue; |
| 91919 | + if( pIdx->pPartIdxWhere ){ |
| 91920 | + sqlite3VdbeAddOp2(v, OP_IsNull, aRegIdx[i], sqlite3VdbeCurrentAddr(v)+2); |
| 91921 | + } |
| 91698 | 91922 | sqlite3VdbeAddOp2(v, OP_IdxInsert, baseCur+i+1, aRegIdx[i]); |
| 91699 | 91923 | if( useSeekResult ){ |
| 91700 | 91924 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 91701 | 91925 | } |
| 91702 | 91926 | } |
| | @@ -91794,10 +92018,11 @@ |
| 91794 | 92018 | ** |
| 91795 | 92019 | ** * The index is over the same set of columns |
| 91796 | 92020 | ** * The same DESC and ASC markings occurs on all columns |
| 91797 | 92021 | ** * The same onError processing (OE_Abort, OE_Ignore, etc) |
| 91798 | 92022 | ** * The same collating sequence on each column |
| 92023 | +** * The index has the exact same WHERE clause |
| 91799 | 92024 | */ |
| 91800 | 92025 | static int xferCompatibleIndex(Index *pDest, Index *pSrc){ |
| 91801 | 92026 | int i; |
| 91802 | 92027 | assert( pDest && pSrc ); |
| 91803 | 92028 | assert( pDest->pTable!=pSrc->pTable ); |
| | @@ -91815,10 +92040,13 @@ |
| 91815 | 92040 | return 0; /* Different sort orders */ |
| 91816 | 92041 | } |
| 91817 | 92042 | if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){ |
| 91818 | 92043 | return 0; /* Different collating sequences */ |
| 91819 | 92044 | } |
| 92045 | + } |
| 92046 | + if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){ |
| 92047 | + return 0; /* Different WHERE clauses */ |
| 91820 | 92048 | } |
| 91821 | 92049 | |
| 91822 | 92050 | /* If no test above fails then the indices must be compatible */ |
| 91823 | 92051 | return 1; |
| 91824 | 92052 | } |
| | @@ -91971,11 +92199,11 @@ |
| 91971 | 92199 | if( pSrcIdx==0 ){ |
| 91972 | 92200 | return 0; /* pDestIdx has no corresponding index in pSrc */ |
| 91973 | 92201 | } |
| 91974 | 92202 | } |
| 91975 | 92203 | #ifndef SQLITE_OMIT_CHECK |
| 91976 | | - if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){ |
| 92204 | + if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck,pDest->pCheck,-1) ){ |
| 91977 | 92205 | return 0; /* Tables have different CHECK constraints. Ticket #2252 */ |
| 91978 | 92206 | } |
| 91979 | 92207 | #endif |
| 91980 | 92208 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 91981 | 92209 | /* Disallow the transfer optimization if the destination table constains |
| | @@ -94884,13 +95112,11 @@ |
| 94884 | 95112 | cnt++; |
| 94885 | 95113 | } |
| 94886 | 95114 | } |
| 94887 | 95115 | |
| 94888 | 95116 | /* Make sure sufficient number of registers have been allocated */ |
| 94889 | | - if( pParse->nMem < cnt+4 ){ |
| 94890 | | - pParse->nMem = cnt+4; |
| 94891 | | - } |
| 95117 | + pParse->nMem = MAX( pParse->nMem, cnt+7 ); |
| 94892 | 95118 | |
| 94893 | 95119 | /* Do the b-tree integrity checks */ |
| 94894 | 95120 | sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1); |
| 94895 | 95121 | sqlite3VdbeChangeP5(v, (u8)i); |
| 94896 | 95122 | addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); |
| | @@ -94911,16 +95137,19 @@ |
| 94911 | 95137 | |
| 94912 | 95138 | if( pTab->pIndex==0 ) continue; |
| 94913 | 95139 | addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Stop if out of errors */ |
| 94914 | 95140 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 94915 | 95141 | sqlite3VdbeJumpHere(v, addr); |
| 95142 | + sqlite3ExprCacheClear(pParse); |
| 94916 | 95143 | sqlite3OpenTableAndIndices(pParse, pTab, 1, OP_OpenRead); |
| 94917 | | - sqlite3VdbeAddOp2(v, OP_Integer, 0, 2); /* reg(2) will count entries */ |
| 94918 | | - loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0); |
| 94919 | | - sqlite3VdbeAddOp2(v, OP_AddImm, 2, 1); /* increment entry count */ |
| 95144 | + for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 95145 | + sqlite3VdbeAddOp2(v, OP_Integer, 0, 7+j); /* index entries counter */ |
| 95146 | + } |
| 95147 | + pParse->nMem = MAX(pParse->nMem, 7+j); |
| 95148 | + loopTop = sqlite3VdbeAddOp2(v, OP_Rewind, 1, 0) + 1; |
| 94920 | 95149 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 94921 | | - int jmp2; |
| 95150 | + int jmp2, jmp3; |
| 94922 | 95151 | int r1; |
| 94923 | 95152 | static const VdbeOpList idxErr[] = { |
| 94924 | 95153 | { OP_AddImm, 1, -1, 0}, |
| 94925 | 95154 | { OP_String8, 0, 3, 0}, /* 1 */ |
| 94926 | 95155 | { OP_Rowid, 1, 4, 0}, |
| | @@ -94931,47 +95160,38 @@ |
| 94931 | 95160 | { OP_Concat, 6, 3, 3}, |
| 94932 | 95161 | { OP_ResultRow, 3, 1, 0}, |
| 94933 | 95162 | { OP_IfPos, 1, 0, 0}, /* 9 */ |
| 94934 | 95163 | { OP_Halt, 0, 0, 0}, |
| 94935 | 95164 | }; |
| 94936 | | - r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0); |
| 95165 | + r1 = sqlite3GenerateIndexKey(pParse, pIdx, 1, 3, 0, &jmp3); |
| 95166 | + sqlite3VdbeAddOp2(v, OP_AddImm, 7+j, 1); /* increment entry count */ |
| 94937 | 95167 | jmp2 = sqlite3VdbeAddOp4Int(v, OP_Found, j+2, 0, r1, pIdx->nColumn+1); |
| 94938 | 95168 | addr = sqlite3VdbeAddOpList(v, ArraySize(idxErr), idxErr); |
| 94939 | 95169 | sqlite3VdbeChangeP4(v, addr+1, "rowid ", P4_STATIC); |
| 94940 | 95170 | sqlite3VdbeChangeP4(v, addr+3, " missing from index ", P4_STATIC); |
| 94941 | 95171 | sqlite3VdbeChangeP4(v, addr+4, pIdx->zName, P4_TRANSIENT); |
| 94942 | 95172 | sqlite3VdbeJumpHere(v, addr+9); |
| 94943 | 95173 | sqlite3VdbeJumpHere(v, jmp2); |
| 95174 | + sqlite3VdbeResolveLabel(v, jmp3); |
| 94944 | 95175 | } |
| 94945 | | - sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop+1); |
| 94946 | | - sqlite3VdbeJumpHere(v, loopTop); |
| 95176 | + sqlite3VdbeAddOp2(v, OP_Next, 1, loopTop); |
| 95177 | + sqlite3VdbeJumpHere(v, loopTop-1); |
| 95178 | +#ifndef SQLITE_OMIT_BTREECOUNT |
| 95179 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, |
| 95180 | + "wrong # of entries in index ", P4_STATIC); |
| 94947 | 95181 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 94948 | | - static const VdbeOpList cntIdx[] = { |
| 94949 | | - { OP_Integer, 0, 3, 0}, |
| 94950 | | - { OP_Rewind, 0, 0, 0}, /* 1 */ |
| 94951 | | - { OP_AddImm, 3, 1, 0}, |
| 94952 | | - { OP_Next, 0, 0, 0}, /* 3 */ |
| 94953 | | - { OP_Eq, 2, 0, 3}, /* 4 */ |
| 94954 | | - { OP_AddImm, 1, -1, 0}, |
| 94955 | | - { OP_String8, 0, 2, 0}, /* 6 */ |
| 94956 | | - { OP_String8, 0, 3, 0}, /* 7 */ |
| 94957 | | - { OP_Concat, 3, 2, 2}, |
| 94958 | | - { OP_ResultRow, 2, 1, 0}, |
| 94959 | | - }; |
| 94960 | | - addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); |
| 95182 | + addr = sqlite3VdbeCurrentAddr(v); |
| 95183 | + sqlite3VdbeAddOp2(v, OP_IfPos, 1, addr+2); |
| 94961 | 95184 | sqlite3VdbeAddOp2(v, OP_Halt, 0, 0); |
| 94962 | | - sqlite3VdbeJumpHere(v, addr); |
| 94963 | | - addr = sqlite3VdbeAddOpList(v, ArraySize(cntIdx), cntIdx); |
| 94964 | | - sqlite3VdbeChangeP1(v, addr+1, j+2); |
| 94965 | | - sqlite3VdbeChangeP2(v, addr+1, addr+4); |
| 94966 | | - sqlite3VdbeChangeP1(v, addr+3, j+2); |
| 94967 | | - sqlite3VdbeChangeP2(v, addr+3, addr+2); |
| 94968 | | - sqlite3VdbeJumpHere(v, addr+4); |
| 94969 | | - sqlite3VdbeChangeP4(v, addr+6, |
| 94970 | | - "wrong # of entries in index ", P4_STATIC); |
| 94971 | | - sqlite3VdbeChangeP4(v, addr+7, pIdx->zName, P4_TRANSIENT); |
| 94972 | | - } |
| 95185 | + sqlite3VdbeAddOp2(v, OP_Count, j+2, 3); |
| 95186 | + sqlite3VdbeAddOp3(v, OP_Eq, 7+j, addr+8, 3); |
| 95187 | + sqlite3VdbeAddOp2(v, OP_AddImm, 1, -1); |
| 95188 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pIdx->zName, P4_TRANSIENT); |
| 95189 | + sqlite3VdbeAddOp3(v, OP_Concat, 3, 2, 7); |
| 95190 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 7, 1); |
| 95191 | + } |
| 95192 | +#endif /* SQLITE_OMIT_BTREECOUNT */ |
| 94973 | 95193 | } |
| 94974 | 95194 | } |
| 94975 | 95195 | addr = sqlite3VdbeAddOpList(v, ArraySize(endCode), endCode); |
| 94976 | 95196 | sqlite3VdbeChangeP2(v, addr, -mxErr); |
| 94977 | 95197 | sqlite3VdbeJumpHere(v, addr+1); |
| | @@ -96994,10 +97214,29 @@ |
| 96994 | 97214 | */ |
| 96995 | 97215 | if( pOrderBy==0 && p->iLimit ){ |
| 96996 | 97216 | sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); |
| 96997 | 97217 | } |
| 96998 | 97218 | } |
| 97219 | + |
| 97220 | +/* |
| 97221 | +** Allocate a KeyInfo object sufficient for an index of N columns. |
| 97222 | +** |
| 97223 | +** Actually, always allocate one extra column for the rowid at the end |
| 97224 | +** of the index. So the KeyInfo returned will have space sufficient for |
| 97225 | +** N+1 columns. |
| 97226 | +*/ |
| 97227 | +SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N){ |
| 97228 | + KeyInfo *p = sqlite3DbMallocZero(db, |
| 97229 | + sizeof(KeyInfo) + (N+1)*(sizeof(CollSeq*)+1)); |
| 97230 | + if( p ){ |
| 97231 | + p->aSortOrder = (u8*)&p->aColl[N+1]; |
| 97232 | + p->nField = (u16)N; |
| 97233 | + p->enc = ENC(db); |
| 97234 | + p->db = db; |
| 97235 | + } |
| 97236 | + return p; |
| 97237 | +} |
| 96999 | 97238 | |
| 97000 | 97239 | /* |
| 97001 | 97240 | ** Given an expression list, generate a KeyInfo structure that records |
| 97002 | 97241 | ** the collating sequence for each expression in that expression list. |
| 97003 | 97242 | ** |
| | @@ -97011,29 +97250,23 @@ |
| 97011 | 97250 | ** function is responsible for seeing that this structure is eventually |
| 97012 | 97251 | ** freed. Add the KeyInfo structure to the P4 field of an opcode using |
| 97013 | 97252 | ** P4_KEYINFO_HANDOFF is the usual way of dealing with this. |
| 97014 | 97253 | */ |
| 97015 | 97254 | static KeyInfo *keyInfoFromExprList(Parse *pParse, ExprList *pList){ |
| 97016 | | - sqlite3 *db = pParse->db; |
| 97017 | 97255 | int nExpr; |
| 97018 | 97256 | KeyInfo *pInfo; |
| 97019 | 97257 | struct ExprList_item *pItem; |
| 97258 | + sqlite3 *db = pParse->db; |
| 97020 | 97259 | int i; |
| 97021 | 97260 | |
| 97022 | 97261 | nExpr = pList->nExpr; |
| 97023 | | - pInfo = sqlite3DbMallocZero(db, sizeof(*pInfo) + nExpr*(sizeof(CollSeq*)+1) ); |
| 97262 | + pInfo = sqlite3KeyInfoAlloc(db, nExpr); |
| 97024 | 97263 | if( pInfo ){ |
| 97025 | | - pInfo->aSortOrder = (u8*)&pInfo->aColl[nExpr]; |
| 97026 | | - pInfo->nField = (u16)nExpr; |
| 97027 | | - pInfo->enc = ENC(db); |
| 97028 | | - pInfo->db = db; |
| 97029 | 97264 | for(i=0, pItem=pList->a; i<nExpr; i++, pItem++){ |
| 97030 | 97265 | CollSeq *pColl; |
| 97031 | 97266 | pColl = sqlite3ExprCollSeq(pParse, pItem->pExpr); |
| 97032 | | - if( !pColl ){ |
| 97033 | | - pColl = db->pDfltColl; |
| 97034 | | - } |
| 97267 | + if( !pColl ) pColl = db->pDfltColl; |
| 97035 | 97268 | pInfo->aColl[i] = pColl; |
| 97036 | 97269 | pInfo->aSortOrder[i] = pItem->sortOrder; |
| 97037 | 97270 | } |
| 97038 | 97271 | } |
| 97039 | 97272 | return pInfo; |
| | @@ -98135,27 +98368,21 @@ |
| 98135 | 98368 | CollSeq **apColl; /* For looping through pKeyInfo->aColl[] */ |
| 98136 | 98369 | int nCol; /* Number of columns in result set */ |
| 98137 | 98370 | |
| 98138 | 98371 | assert( p->pRightmost==p ); |
| 98139 | 98372 | nCol = p->pEList->nExpr; |
| 98140 | | - pKeyInfo = sqlite3DbMallocZero(db, |
| 98141 | | - sizeof(*pKeyInfo)+nCol*(sizeof(CollSeq*) + 1)); |
| 98373 | + pKeyInfo = sqlite3KeyInfoAlloc(db, nCol); |
| 98142 | 98374 | if( !pKeyInfo ){ |
| 98143 | 98375 | rc = SQLITE_NOMEM; |
| 98144 | 98376 | goto multi_select_end; |
| 98145 | 98377 | } |
| 98146 | | - |
| 98147 | | - pKeyInfo->enc = ENC(db); |
| 98148 | | - pKeyInfo->nField = (u16)nCol; |
| 98149 | | - |
| 98150 | 98378 | for(i=0, apColl=pKeyInfo->aColl; i<nCol; i++, apColl++){ |
| 98151 | 98379 | *apColl = multiSelectCollSeq(pParse, p, i); |
| 98152 | 98380 | if( 0==*apColl ){ |
| 98153 | 98381 | *apColl = db->pDfltColl; |
| 98154 | 98382 | } |
| 98155 | 98383 | } |
| 98156 | | - pKeyInfo->aSortOrder = (u8*)apColl; |
| 98157 | 98384 | |
| 98158 | 98385 | for(pLoop=p; pLoop; pLoop=pLoop->pPrior){ |
| 98159 | 98386 | for(i=0; i<2; i++){ |
| 98160 | 98387 | int addr = pLoop->addrOpenEphm[i]; |
| 98161 | 98388 | if( addr<0 ){ |
| | @@ -98520,16 +98747,12 @@ |
| 98520 | 98747 | struct ExprList_item *pItem; |
| 98521 | 98748 | for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){ |
| 98522 | 98749 | assert( pItem->iOrderByCol>0 && pItem->iOrderByCol<=p->pEList->nExpr ); |
| 98523 | 98750 | aPermute[i] = pItem->iOrderByCol - 1; |
| 98524 | 98751 | } |
| 98525 | | - pKeyMerge = |
| 98526 | | - sqlite3DbMallocRaw(db, sizeof(*pKeyMerge)+nOrderBy*(sizeof(CollSeq*)+1)); |
| 98752 | + pKeyMerge = sqlite3KeyInfoAlloc(db, nOrderBy); |
| 98527 | 98753 | if( pKeyMerge ){ |
| 98528 | | - pKeyMerge->aSortOrder = (u8*)&pKeyMerge->aColl[nOrderBy]; |
| 98529 | | - pKeyMerge->nField = (u16)nOrderBy; |
| 98530 | | - pKeyMerge->enc = ENC(db); |
| 98531 | 98754 | for(i=0; i<nOrderBy; i++){ |
| 98532 | 98755 | CollSeq *pColl; |
| 98533 | 98756 | Expr *pTerm = pOrderBy->a[i].pExpr; |
| 98534 | 98757 | if( pTerm->flags & EP_Collate ){ |
| 98535 | 98758 | pColl = sqlite3ExprCollSeq(pParse, pTerm); |
| | @@ -98562,16 +98785,12 @@ |
| 98562 | 98785 | int nExpr = p->pEList->nExpr; |
| 98563 | 98786 | assert( nOrderBy>=nExpr || db->mallocFailed ); |
| 98564 | 98787 | regPrev = pParse->nMem+1; |
| 98565 | 98788 | pParse->nMem += nExpr+1; |
| 98566 | 98789 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regPrev); |
| 98567 | | - pKeyDup = sqlite3DbMallocZero(db, |
| 98568 | | - sizeof(*pKeyDup) + nExpr*(sizeof(CollSeq*)+1) ); |
| 98790 | + pKeyDup = sqlite3KeyInfoAlloc(db, nExpr); |
| 98569 | 98791 | if( pKeyDup ){ |
| 98570 | | - pKeyDup->aSortOrder = (u8*)&pKeyDup->aColl[nExpr]; |
| 98571 | | - pKeyDup->nField = (u16)nExpr; |
| 98572 | | - pKeyDup->enc = ENC(db); |
| 98573 | 98792 | for(i=0; i<nExpr; i++){ |
| 98574 | 98793 | pKeyDup->aColl[i] = multiSelectCollSeq(pParse, p, i); |
| 98575 | 98794 | pKeyDup->aSortOrder[i] = 0; |
| 98576 | 98795 | } |
| 98577 | 98796 | } |
| | @@ -99833,14 +100052,16 @@ |
| 99833 | 100052 | ** and/or pParse->db->mallocFailed. |
| 99834 | 100053 | */ |
| 99835 | 100054 | static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){ |
| 99836 | 100055 | Walker w; |
| 99837 | 100056 | memset(&w, 0, sizeof(w)); |
| 99838 | | - w.xSelectCallback = convertCompoundSelectToSubquery; |
| 99839 | 100057 | w.xExprCallback = exprWalkNoop; |
| 99840 | 100058 | w.pParse = pParse; |
| 99841 | | - sqlite3WalkSelect(&w, pSelect); |
| 100059 | + if( pParse->hasCompound ){ |
| 100060 | + w.xSelectCallback = convertCompoundSelectToSubquery; |
| 100061 | + sqlite3WalkSelect(&w, pSelect); |
| 100062 | + } |
| 99842 | 100063 | w.xSelectCallback = selectExpander; |
| 99843 | 100064 | sqlite3WalkSelect(&w, pSelect); |
| 99844 | 100065 | } |
| 99845 | 100066 | |
| 99846 | 100067 | |
| | @@ -100370,11 +100591,11 @@ |
| 100370 | 100591 | ** will cause elements to come out in the correct order. This is |
| 100371 | 100592 | ** an optimization - the correct answer should result regardless. |
| 100372 | 100593 | ** Use the SQLITE_GroupByOrder flag with SQLITE_TESTCTRL_OPTIMIZER |
| 100373 | 100594 | ** to disable this optimization for testing purposes. |
| 100374 | 100595 | */ |
| 100375 | | - if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy)==0 |
| 100596 | + if( sqlite3ExprListCompare(p->pGroupBy, pOrderBy, -1)==0 |
| 100376 | 100597 | && OptimizationEnabled(db, SQLITE_GroupByOrder) ){ |
| 100377 | 100598 | pOrderBy = 0; |
| 100378 | 100599 | } |
| 100379 | 100600 | |
| 100380 | 100601 | /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and |
| | @@ -100391,11 +100612,11 @@ |
| 100391 | 100612 | ** used for both the ORDER BY and DISTINCT processing. As originally |
| 100392 | 100613 | ** written the query must use a temp-table for at least one of the ORDER |
| 100393 | 100614 | ** BY and DISTINCT, and an index or separate temp-table for the other. |
| 100394 | 100615 | */ |
| 100395 | 100616 | if( (p->selFlags & (SF_Distinct|SF_Aggregate))==SF_Distinct |
| 100396 | | - && sqlite3ExprListCompare(pOrderBy, p->pEList)==0 |
| 100617 | + && sqlite3ExprListCompare(pOrderBy, p->pEList, -1)==0 |
| 100397 | 100618 | ){ |
| 100398 | 100619 | p->selFlags &= ~SF_Distinct; |
| 100399 | 100620 | p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0); |
| 100400 | 100621 | pGroupBy = p->pGroupBy; |
| 100401 | 100622 | pOrderBy = 0; |
| | @@ -102618,11 +102839,11 @@ |
| 102618 | 102839 | aRegIdx = sqlite3DbMallocRaw(db, sizeof(Index*) * nIdx ); |
| 102619 | 102840 | if( aRegIdx==0 ) goto update_cleanup; |
| 102620 | 102841 | } |
| 102621 | 102842 | for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ |
| 102622 | 102843 | int reg; |
| 102623 | | - if( hasFK || chngRowid ){ |
| 102844 | + if( hasFK || chngRowid || pIdx->pPartIdxWhere ){ |
| 102624 | 102845 | reg = ++pParse->nMem; |
| 102625 | 102846 | }else{ |
| 102626 | 102847 | reg = 0; |
| 102627 | 102848 | for(i=0; i<pIdx->nColumn; i++){ |
| 102628 | 102849 | if( aXRef[pIdx->aiColumn[i]]>=0 ){ |
| | @@ -105158,11 +105379,11 @@ |
| 105158 | 105379 | ** the pWC->a[] array. |
| 105159 | 105380 | */ |
| 105160 | 105381 | static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){ |
| 105161 | 105382 | WhereTerm *pTerm; |
| 105162 | 105383 | int idx; |
| 105163 | | - testcase( wtFlags & TERM_VIRTUAL ); /* EV: R-00211-15100 */ |
| 105384 | + testcase( wtFlags & TERM_VIRTUAL ); |
| 105164 | 105385 | if( pWC->nTerm>=pWC->nSlot ){ |
| 105165 | 105386 | WhereTerm *pOld = pWC->a; |
| 105166 | 105387 | sqlite3 *db = pWC->pWInfo->pParse->db; |
| 105167 | 105388 | pWC->a = sqlite3DbMallocRaw(db, sizeof(pWC->a[0])*pWC->nSlot*2 ); |
| 105168 | 105389 | if( pWC->a==0 ){ |
| | @@ -105303,17 +105524,10 @@ |
| 105303 | 105524 | |
| 105304 | 105525 | /* |
| 105305 | 105526 | ** Return TRUE if the given operator is one of the operators that is |
| 105306 | 105527 | ** allowed for an indexable WHERE clause term. The allowed operators are |
| 105307 | 105528 | ** "=", "<", ">", "<=", ">=", "IN", and "IS NULL" |
| 105308 | | -** |
| 105309 | | -** IMPLEMENTATION-OF: R-59926-26393 To be usable by an index a term must be |
| 105310 | | -** of one of the following forms: column = expression column > expression |
| 105311 | | -** column >= expression column < expression column <= expression |
| 105312 | | -** expression = column expression > column expression >= column |
| 105313 | | -** expression < column expression <= column column IN |
| 105314 | | -** (expression-list) column IN (subquery) column IS NULL |
| 105315 | 105529 | */ |
| 105316 | 105530 | static int allowedOp(int op){ |
| 105317 | 105531 | assert( TK_GT>TK_EQ && TK_GT<TK_GE ); |
| 105318 | 105532 | assert( TK_LT>TK_EQ && TK_LT<TK_GE ); |
| 105319 | 105533 | assert( TK_LE>TK_EQ && TK_LE<TK_GE ); |
| | @@ -105628,11 +105842,11 @@ |
| 105628 | 105842 | op = pRight->op2; |
| 105629 | 105843 | } |
| 105630 | 105844 | if( op==TK_VARIABLE ){ |
| 105631 | 105845 | Vdbe *pReprepare = pParse->pReprepare; |
| 105632 | 105846 | int iCol = pRight->iColumn; |
| 105633 | | - pVal = sqlite3VdbeGetValue(pReprepare, iCol, SQLITE_AFF_NONE); |
| 105847 | + pVal = sqlite3VdbeGetBoundValue(pReprepare, iCol, SQLITE_AFF_NONE); |
| 105634 | 105848 | if( pVal && sqlite3_value_type(pVal)==SQLITE_TEXT ){ |
| 105635 | 105849 | z = (char *)sqlite3_value_text(pVal); |
| 105636 | 105850 | } |
| 105637 | 105851 | sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); |
| 105638 | 105852 | assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER ); |
| | @@ -105983,12 +106197,10 @@ |
| 105983 | 106197 | } |
| 105984 | 106198 | |
| 105985 | 106199 | /* At this point, okToChngToIN is true if original pTerm satisfies |
| 105986 | 106200 | ** case 1. In that case, construct a new virtual term that is |
| 105987 | 106201 | ** pTerm converted into an IN operator. |
| 105988 | | - ** |
| 105989 | | - ** EV: R-00211-15100 |
| 105990 | 106202 | */ |
| 105991 | 106203 | if( okToChngToIN ){ |
| 105992 | 106204 | Expr *pDup; /* A transient duplicate expression */ |
| 105993 | 106205 | ExprList *pList = 0; /* The RHS of the IN operator */ |
| 105994 | 106206 | Expr *pLeft = 0; /* The LHS of the IN operator */ |
| | @@ -106226,13 +106438,11 @@ |
| 106226 | 106438 | ** wildcard. But if we increment '@', that will push it into the |
| 106227 | 106439 | ** alphabetic range where case conversions will mess up the |
| 106228 | 106440 | ** inequality. To avoid this, make sure to also run the full |
| 106229 | 106441 | ** LIKE on all candidate expressions by clearing the isComplete flag |
| 106230 | 106442 | */ |
| 106231 | | - if( c=='A'-1 ) isComplete = 0; /* EV: R-64339-08207 */ |
| 106232 | | - |
| 106233 | | - |
| 106443 | + if( c=='A'-1 ) isComplete = 0; |
| 106234 | 106444 | c = sqlite3UpperToLower[c]; |
| 106235 | 106445 | } |
| 106236 | 106446 | *pC = c + 1; |
| 106237 | 106447 | } |
| 106238 | 106448 | sCollSeqName.z = noCase ? "NOCASE" : "BINARY"; |
| | @@ -106735,11 +106945,11 @@ |
| 106735 | 106945 | VdbeComment((v, "for %s", pTable->zName)); |
| 106736 | 106946 | |
| 106737 | 106947 | /* Fill the automatic index with content */ |
| 106738 | 106948 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); |
| 106739 | 106949 | regRecord = sqlite3GetTempReg(pParse); |
| 106740 | | - sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1); |
| 106950 | + sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 1, 0); |
| 106741 | 106951 | sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord); |
| 106742 | 106952 | sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT); |
| 106743 | 106953 | sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); |
| 106744 | 106954 | sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX); |
| 106745 | 106955 | sqlite3VdbeJumpHere(v, addrTop); |
| | @@ -107092,11 +107302,11 @@ |
| 107092 | 107302 | if( pExpr->op==TK_VARIABLE |
| 107093 | 107303 | || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) |
| 107094 | 107304 | ){ |
| 107095 | 107305 | int iVar = pExpr->iColumn; |
| 107096 | 107306 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); |
| 107097 | | - *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 107307 | + *pp = sqlite3VdbeGetBoundValue(pParse->pReprepare, iVar, aff); |
| 107098 | 107308 | return SQLITE_OK; |
| 107099 | 107309 | } |
| 107100 | 107310 | return sqlite3ValueFromExpr(pParse->db, pExpr, SQLITE_UTF8, aff, pp); |
| 107101 | 107311 | } |
| 107102 | 107312 | #endif |
| | @@ -107318,13 +107528,10 @@ |
| 107318 | 107528 | ** |
| 107319 | 107529 | ** The t2.z='ok' is disabled in the in (2) because it originates |
| 107320 | 107530 | ** in the ON clause. The term is disabled in (3) because it is not part |
| 107321 | 107531 | ** of a LEFT OUTER JOIN. In (1), the term is not disabled. |
| 107322 | 107532 | ** |
| 107323 | | -** IMPLEMENTATION-OF: R-24597-58655 No tests are done for terms that are |
| 107324 | | -** completely satisfied by indices. |
| 107325 | | -** |
| 107326 | 107533 | ** Disabling a term causes that term to not be tested in the inner loop |
| 107327 | 107534 | ** of the join. Disabling is an optimization. When terms are satisfied |
| 107328 | 107535 | ** by indices, we disable them to prevent redundant tests in the inner |
| 107329 | 107536 | ** loop. We would get the correct results if nothing were ever disabled, |
| 107330 | 107537 | ** but joins might run a little slower. The trick is to disable as much |
| | @@ -107550,11 +107757,11 @@ |
| 107550 | 107757 | pTerm = pLoop->aLTerm[j]; |
| 107551 | 107758 | assert( pTerm!=0 ); |
| 107552 | 107759 | /* The following true for indices with redundant columns. |
| 107553 | 107760 | ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */ |
| 107554 | 107761 | testcase( (pTerm->wtFlags & TERM_CODED)!=0 ); |
| 107555 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 107762 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 107556 | 107763 | r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j); |
| 107557 | 107764 | if( r1!=regBase+j ){ |
| 107558 | 107765 | if( nReg==1 ){ |
| 107559 | 107766 | sqlite3ReleaseTempReg(pParse, regBase); |
| 107560 | 107767 | regBase = r1; |
| | @@ -107750,10 +107957,11 @@ |
| 107750 | 107957 | WhereLevel *pLevel; /* The where level to be coded */ |
| 107751 | 107958 | WhereLoop *pLoop; /* The WhereLoop object being coded */ |
| 107752 | 107959 | WhereClause *pWC; /* Decomposition of the entire WHERE clause */ |
| 107753 | 107960 | WhereTerm *pTerm; /* A WHERE clause term */ |
| 107754 | 107961 | Parse *pParse; /* Parsing context */ |
| 107962 | + sqlite3 *db; /* Database connection */ |
| 107755 | 107963 | Vdbe *v; /* The prepared stmt under constructions */ |
| 107756 | 107964 | struct SrcList_item *pTabItem; /* FROM clause term being coded */ |
| 107757 | 107965 | int addrBrk; /* Jump here to break out of the loop */ |
| 107758 | 107966 | int addrCont; /* Jump here to continue with next cycle */ |
| 107759 | 107967 | int iRowidReg = 0; /* Rowid is stored in this register, if not zero */ |
| | @@ -107761,10 +107969,11 @@ |
| 107761 | 107969 | Bitmask newNotReady; /* Return value */ |
| 107762 | 107970 | |
| 107763 | 107971 | pParse = pWInfo->pParse; |
| 107764 | 107972 | v = pParse->pVdbe; |
| 107765 | 107973 | pWC = &pWInfo->sWC; |
| 107974 | + db = pParse->db; |
| 107766 | 107975 | pLevel = &pWInfo->a[iLevel]; |
| 107767 | 107976 | pLoop = pLevel->pWLoop; |
| 107768 | 107977 | pTabItem = &pWInfo->pTabList->a[pLevel->iFrom]; |
| 107769 | 107978 | iCur = pTabItem->iCursor; |
| 107770 | 107979 | bRev = (pWInfo->revMask>>iLevel)&1; |
| | @@ -107859,11 +108068,11 @@ |
| 107859 | 108068 | iReleaseReg = sqlite3GetTempReg(pParse); |
| 107860 | 108069 | pTerm = pLoop->aLTerm[0]; |
| 107861 | 108070 | assert( pTerm!=0 ); |
| 107862 | 108071 | assert( pTerm->pExpr!=0 ); |
| 107863 | 108072 | assert( omitTable==0 ); |
| 107864 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108073 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 107865 | 108074 | iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg); |
| 107866 | 108075 | addrNxt = pLevel->addrNxt; |
| 107867 | 108076 | sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); |
| 107868 | 108077 | sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); |
| 107869 | 108078 | sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); |
| | @@ -107907,11 +108116,11 @@ |
| 107907 | 108116 | assert( TK_LE==TK_GT+1 ); /* Make sure the ordering.. */ |
| 107908 | 108117 | assert( TK_LT==TK_GT+2 ); /* ... of the TK_xx values... */ |
| 107909 | 108118 | assert( TK_GE==TK_GT+3 ); /* ... is correcct. */ |
| 107910 | 108119 | |
| 107911 | 108120 | assert( (pStart->wtFlags & TERM_VNULL)==0 ); |
| 107912 | | - testcase( pStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108121 | + testcase( pStart->wtFlags & TERM_VIRTUAL ); |
| 107913 | 108122 | pX = pStart->pExpr; |
| 107914 | 108123 | assert( pX!=0 ); |
| 107915 | 108124 | testcase( pStart->leftCursor!=iCur ); /* transitive constraints */ |
| 107916 | 108125 | r1 = sqlite3ExprCodeTemp(pParse, pX->pRight, &rTemp); |
| 107917 | 108126 | sqlite3VdbeAddOp3(v, aMoveOp[pX->op-TK_GT], iCur, addrBrk, r1); |
| | @@ -107926,11 +108135,11 @@ |
| 107926 | 108135 | Expr *pX; |
| 107927 | 108136 | pX = pEnd->pExpr; |
| 107928 | 108137 | assert( pX!=0 ); |
| 107929 | 108138 | assert( (pEnd->wtFlags & TERM_VNULL)==0 ); |
| 107930 | 108139 | testcase( pEnd->leftCursor!=iCur ); /* Transitive constraints */ |
| 107931 | | - testcase( pEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108140 | + testcase( pEnd->wtFlags & TERM_VIRTUAL ); |
| 107932 | 108141 | memEndValue = ++pParse->nMem; |
| 107933 | 108142 | sqlite3ExprCode(pParse, pX->pRight, memEndValue); |
| 107934 | 108143 | if( pX->op==TK_LT || pX->op==TK_GT ){ |
| 107935 | 108144 | testOp = bRev ? OP_Le : OP_Ge; |
| 107936 | 108145 | }else{ |
| | @@ -108051,11 +108260,11 @@ |
| 108051 | 108260 | /* Generate code to evaluate all constraint terms using == or IN |
| 108052 | 108261 | ** and store the values of those terms in an array of registers |
| 108053 | 108262 | ** starting at regBase. |
| 108054 | 108263 | */ |
| 108055 | 108264 | regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff); |
| 108056 | | - zEndAff = sqlite3DbStrDup(pParse->db, zStartAff); |
| 108265 | + zEndAff = sqlite3DbStrDup(db, zStartAff); |
| 108057 | 108266 | addrNxt = pLevel->addrNxt; |
| 108058 | 108267 | |
| 108059 | 108268 | /* If we are doing a reverse order scan on an ascending index, or |
| 108060 | 108269 | ** a forward order scan on a descending index, interchange the |
| 108061 | 108270 | ** start and end terms (pRangeStart and pRangeEnd). |
| | @@ -108092,11 +108301,11 @@ |
| 108092 | 108301 | if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){ |
| 108093 | 108302 | zStartAff[nEq] = SQLITE_AFF_NONE; |
| 108094 | 108303 | } |
| 108095 | 108304 | } |
| 108096 | 108305 | nConstraint++; |
| 108097 | | - testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108306 | + testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); |
| 108098 | 108307 | }else if( isMinQuery ){ |
| 108099 | 108308 | sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq); |
| 108100 | 108309 | nConstraint++; |
| 108101 | 108310 | startEq = 0; |
| 108102 | 108311 | start_constraints = 1; |
| | @@ -108134,14 +108343,14 @@ |
| 108134 | 108343 | zEndAff[nEq] = SQLITE_AFF_NONE; |
| 108135 | 108344 | } |
| 108136 | 108345 | } |
| 108137 | 108346 | codeApplyAffinity(pParse, regBase, nEq+1, zEndAff); |
| 108138 | 108347 | nConstraint++; |
| 108139 | | - testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */ |
| 108348 | + testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); |
| 108140 | 108349 | } |
| 108141 | | - sqlite3DbFree(pParse->db, zStartAff); |
| 108142 | | - sqlite3DbFree(pParse->db, zEndAff); |
| 108350 | + sqlite3DbFree(db, zStartAff); |
| 108351 | + sqlite3DbFree(db, zEndAff); |
| 108143 | 108352 | |
| 108144 | 108353 | /* Top of the loop body */ |
| 108145 | 108354 | pLevel->p2 = sqlite3VdbeCurrentAddr(v); |
| 108146 | 108355 | |
| 108147 | 108356 | /* Check if the index cursor is past the end of the range. */ |
| | @@ -108264,11 +108473,11 @@ |
| 108264 | 108473 | */ |
| 108265 | 108474 | if( pWInfo->nLevel>1 ){ |
| 108266 | 108475 | int nNotReady; /* The number of notReady tables */ |
| 108267 | 108476 | struct SrcList_item *origSrc; /* Original list of tables */ |
| 108268 | 108477 | nNotReady = pWInfo->nLevel - iLevel - 1; |
| 108269 | | - pOrTab = sqlite3StackAllocRaw(pParse->db, |
| 108478 | + pOrTab = sqlite3StackAllocRaw(db, |
| 108270 | 108479 | sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0])); |
| 108271 | 108480 | if( pOrTab==0 ) return notReady; |
| 108272 | 108481 | pOrTab->nAlloc = (u8)(nNotReady + 1); |
| 108273 | 108482 | pOrTab->nSrc = pOrTab->nAlloc; |
| 108274 | 108483 | memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem)); |
| | @@ -108318,12 +108527,12 @@ |
| 108318 | 108527 | Expr *pExpr = pWC->a[iTerm].pExpr; |
| 108319 | 108528 | if( &pWC->a[iTerm] == pTerm ) continue; |
| 108320 | 108529 | if( ExprHasProperty(pExpr, EP_FromJoin) ) continue; |
| 108321 | 108530 | if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue; |
| 108322 | 108531 | if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue; |
| 108323 | | - pExpr = sqlite3ExprDup(pParse->db, pExpr, 0); |
| 108324 | | - pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr); |
| 108532 | + pExpr = sqlite3ExprDup(db, pExpr, 0); |
| 108533 | + pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr); |
| 108325 | 108534 | } |
| 108326 | 108535 | if( pAndExpr ){ |
| 108327 | 108536 | pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0); |
| 108328 | 108537 | } |
| 108329 | 108538 | } |
| | @@ -108339,11 +108548,11 @@ |
| 108339 | 108548 | } |
| 108340 | 108549 | /* Loop through table entries that match term pOrTerm. */ |
| 108341 | 108550 | pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, |
| 108342 | 108551 | WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY | |
| 108343 | 108552 | WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur); |
| 108344 | | - assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed ); |
| 108553 | + assert( pSubWInfo || pParse->nErr || db->mallocFailed ); |
| 108345 | 108554 | if( pSubWInfo ){ |
| 108346 | 108555 | WhereLoop *pSubLoop; |
| 108347 | 108556 | explainOneScan( |
| 108348 | 108557 | pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0 |
| 108349 | 108558 | ); |
| | @@ -108394,17 +108603,17 @@ |
| 108394 | 108603 | } |
| 108395 | 108604 | pLevel->u.pCovidx = pCov; |
| 108396 | 108605 | if( pCov ) pLevel->iIdxCur = iCovCur; |
| 108397 | 108606 | if( pAndExpr ){ |
| 108398 | 108607 | pAndExpr->pLeft = 0; |
| 108399 | | - sqlite3ExprDelete(pParse->db, pAndExpr); |
| 108608 | + sqlite3ExprDelete(db, pAndExpr); |
| 108400 | 108609 | } |
| 108401 | 108610 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 108402 | 108611 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); |
| 108403 | 108612 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 108404 | 108613 | |
| 108405 | | - if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab); |
| 108614 | + if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab); |
| 108406 | 108615 | if( !untestedTerms ) disableTerm(pLevel, pTerm); |
| 108407 | 108616 | }else |
| 108408 | 108617 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
| 108409 | 108618 | |
| 108410 | 108619 | { |
| | @@ -108421,18 +108630,14 @@ |
| 108421 | 108630 | } |
| 108422 | 108631 | newNotReady = notReady & ~getMask(&pWInfo->sMaskSet, iCur); |
| 108423 | 108632 | |
| 108424 | 108633 | /* Insert code to test every subexpression that can be completely |
| 108425 | 108634 | ** computed using the current set of tables. |
| 108426 | | - ** |
| 108427 | | - ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through |
| 108428 | | - ** the use of indices become tests that are evaluated against each row of |
| 108429 | | - ** the relevant input tables. |
| 108430 | 108635 | */ |
| 108431 | 108636 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 108432 | 108637 | Expr *pE; |
| 108433 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ |
| 108638 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 108434 | 108639 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 108435 | 108640 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 108436 | 108641 | if( (pTerm->prereqAll & newNotReady)!=0 ){ |
| 108437 | 108642 | testcase( pWInfo->untestedTerms==0 |
| 108438 | 108643 | && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ); |
| | @@ -108455,13 +108660,12 @@ |
| 108455 | 108660 | ** and we are coding the t1 loop and the t2 loop has not yet coded, |
| 108456 | 108661 | ** then we cannot use the "t1.a=t2.b" constraint, but we can code |
| 108457 | 108662 | ** the implied "t1.a=123" constraint. |
| 108458 | 108663 | */ |
| 108459 | 108664 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 108460 | | - Expr *pE; |
| 108665 | + Expr *pE, *pEAlt; |
| 108461 | 108666 | WhereTerm *pAlt; |
| 108462 | | - Expr sEq; |
| 108463 | 108667 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 108464 | 108668 | if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue; |
| 108465 | 108669 | if( pTerm->leftCursor!=iCur ) continue; |
| 108466 | 108670 | if( pLevel->iLeftJoin ) continue; |
| 108467 | 108671 | pE = pTerm->pExpr; |
| | @@ -108471,13 +108675,17 @@ |
| 108471 | 108675 | if( pAlt==0 ) continue; |
| 108472 | 108676 | if( pAlt->wtFlags & (TERM_CODED) ) continue; |
| 108473 | 108677 | testcase( pAlt->eOperator & WO_EQ ); |
| 108474 | 108678 | testcase( pAlt->eOperator & WO_IN ); |
| 108475 | 108679 | VdbeNoopComment((v, "begin transitive constraint")); |
| 108476 | | - sEq = *pAlt->pExpr; |
| 108477 | | - sEq.pLeft = pE->pLeft; |
| 108478 | | - sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL); |
| 108680 | + pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt)); |
| 108681 | + if( pEAlt ){ |
| 108682 | + *pEAlt = *pAlt->pExpr; |
| 108683 | + pEAlt->pLeft = pE->pLeft; |
| 108684 | + sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL); |
| 108685 | + sqlite3StackFree(db, pEAlt); |
| 108686 | + } |
| 108479 | 108687 | } |
| 108480 | 108688 | |
| 108481 | 108689 | /* For a LEFT OUTER JOIN, generate code that will record the fact that |
| 108482 | 108690 | ** at least one row of the right table has matched the left table. |
| 108483 | 108691 | */ |
| | @@ -108485,11 +108693,11 @@ |
| 108485 | 108693 | pLevel->addrFirst = sqlite3VdbeCurrentAddr(v); |
| 108486 | 108694 | sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin); |
| 108487 | 108695 | VdbeComment((v, "record LEFT JOIN hit")); |
| 108488 | 108696 | sqlite3ExprCacheClear(pParse); |
| 108489 | 108697 | for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){ |
| 108490 | | - testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */ |
| 108698 | + testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 108491 | 108699 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 108492 | 108700 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 108493 | 108701 | if( (pTerm->prereqAll & newNotReady)!=0 ){ |
| 108494 | 108702 | assert( pWInfo->untestedTerms ); |
| 108495 | 108703 | continue; |
| | @@ -108926,11 +109134,12 @@ |
| 108926 | 109134 | rc = whereEqualScanEst(pParse, pProbe, pTerm->pExpr->pRight, &nOut); |
| 108927 | 109135 | }else if( (pTerm->eOperator & WO_IN) |
| 108928 | 109136 | && !ExprHasProperty(pTerm->pExpr, EP_xIsSelect) ){ |
| 108929 | 109137 | rc = whereInScanEst(pParse, pProbe, pTerm->pExpr->x.pList, &nOut); |
| 108930 | 109138 | } |
| 108931 | | - if( rc==SQLITE_OK ) pNew->nOut = whereCost(nOut); |
| 109139 | + assert( nOut==0 || rc==SQLITE_OK ); |
| 109140 | + if( nOut ) pNew->nOut = whereCost(nOut); |
| 108932 | 109141 | } |
| 108933 | 109142 | #endif |
| 108934 | 109143 | if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){ |
| 108935 | 109144 | /* Each row involves a step of the index, then a binary search of |
| 108936 | 109145 | ** the main table */ |
| | @@ -108998,10 +109207,21 @@ |
| 108998 | 109207 | if( x<BMS-1 ) m |= MASKBIT(x); |
| 108999 | 109208 | } |
| 109000 | 109209 | return m; |
| 109001 | 109210 | } |
| 109002 | 109211 | |
| 109212 | +/* Check to see if a partial index with pPartIndexWhere can be used |
| 109213 | +** in the current query. Return true if it can be and false if not. |
| 109214 | +*/ |
| 109215 | +static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){ |
| 109216 | + int i; |
| 109217 | + WhereTerm *pTerm; |
| 109218 | + for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){ |
| 109219 | + if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1; |
| 109220 | + } |
| 109221 | + return 0; |
| 109222 | +} |
| 109003 | 109223 | |
| 109004 | 109224 | /* |
| 109005 | 109225 | ** Add all WhereLoop objects for a single table of the join where the table |
| 109006 | 109226 | ** is idenfied by pBuilder->pNew->iTab. That table is guaranteed to be |
| 109007 | 109227 | ** a b-tree table, not a virtual table. |
| | @@ -109021,15 +109241,17 @@ |
| 109021 | 109241 | int rc = SQLITE_OK; /* Return code */ |
| 109022 | 109242 | int iSortIdx = 1; /* Index number */ |
| 109023 | 109243 | int b; /* A boolean value */ |
| 109024 | 109244 | WhereCost rSize; /* number of rows in the table */ |
| 109025 | 109245 | WhereCost rLogSize; /* Logarithm of the number of rows in the table */ |
| 109246 | + WhereClause *pWC; /* The parsed WHERE clause */ |
| 109026 | 109247 | |
| 109027 | 109248 | pNew = pBuilder->pNew; |
| 109028 | 109249 | pWInfo = pBuilder->pWInfo; |
| 109029 | 109250 | pTabList = pWInfo->pTabList; |
| 109030 | 109251 | pSrc = pTabList->a + pNew->iTab; |
| 109252 | + pWC = pBuilder->pWC; |
| 109031 | 109253 | assert( !IsVirtual(pSrc->pTab) ); |
| 109032 | 109254 | |
| 109033 | 109255 | if( pSrc->pIndex ){ |
| 109034 | 109256 | /* An INDEXED BY clause specifies a particular index to use */ |
| 109035 | 109257 | pProbe = pSrc->pIndex; |
| | @@ -109065,11 +109287,10 @@ |
| 109065 | 109287 | && !pSrc->viaCoroutine |
| 109066 | 109288 | && !pSrc->notIndexed |
| 109067 | 109289 | && !pSrc->isCorrelated |
| 109068 | 109290 | ){ |
| 109069 | 109291 | /* Generate auto-index WhereLoops */ |
| 109070 | | - WhereClause *pWC = pBuilder->pWC; |
| 109071 | 109292 | WhereTerm *pTerm; |
| 109072 | 109293 | WhereTerm *pWCEnd = pWC->a + pWC->nTerm; |
| 109073 | 109294 | for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){ |
| 109074 | 109295 | if( pTerm->prereqRight & pNew->maskSelf ) continue; |
| 109075 | 109296 | if( termCanDriveIndex(pTerm, pSrc, 0) ){ |
| | @@ -109095,10 +109316,14 @@ |
| 109095 | 109316 | } |
| 109096 | 109317 | |
| 109097 | 109318 | /* Loop over all indices |
| 109098 | 109319 | */ |
| 109099 | 109320 | for(; rc==SQLITE_OK && pProbe; pProbe=pProbe->pNext, iSortIdx++){ |
| 109321 | + if( pProbe->pPartIdxWhere!=0 |
| 109322 | + && !whereUsablePartialIndex(pNew->iTab, pWC, pProbe->pPartIdxWhere) ){ |
| 109323 | + continue; /* Partial index inappropriate for this query */ |
| 109324 | + } |
| 109100 | 109325 | pNew->u.btree.nEq = 0; |
| 109101 | 109326 | pNew->nLTerm = 0; |
| 109102 | 109327 | pNew->iSortIdx = 0; |
| 109103 | 109328 | pNew->rSetup = 0; |
| 109104 | 109329 | pNew->prereq = mExtra; |
| | @@ -110035,11 +110260,11 @@ |
| 110035 | 110260 | pLoop->u.btree.nEq = 1; |
| 110036 | 110261 | /* TUNING: Cost of a rowid lookup is 10 */ |
| 110037 | 110262 | pLoop->rRun = 33; /* 33==whereCost(10) */ |
| 110038 | 110263 | }else{ |
| 110039 | 110264 | for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 110040 | | - if( pIdx->onError==OE_None ) continue; |
| 110265 | + if( pIdx->onError==OE_None || pIdx->pPartIdxWhere!=0 ) continue; |
| 110041 | 110266 | for(j=0; j<pIdx->nColumn; j++){ |
| 110042 | 110267 | pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx); |
| 110043 | 110268 | if( pTerm==0 ) break; |
| 110044 | 110269 | whereLoopResize(pWInfo->pParse->db, pLoop, j); |
| 110045 | 110270 | pLoop->aLTerm[j] = pTerm; |
| | @@ -110241,11 +110466,11 @@ |
| 110241 | 110466 | ** subexpression is separated by an AND operator. |
| 110242 | 110467 | */ |
| 110243 | 110468 | initMaskSet(pMaskSet); |
| 110244 | 110469 | whereClauseInit(&pWInfo->sWC, pWInfo); |
| 110245 | 110470 | sqlite3ExprCodeConstants(pParse, pWhere); |
| 110246 | | - whereSplit(&pWInfo->sWC, pWhere, TK_AND); /* IMP: R-15842-53296 */ |
| 110471 | + whereSplit(&pWInfo->sWC, pWhere, TK_AND); |
| 110247 | 110472 | sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */ |
| 110248 | 110473 | |
| 110249 | 110474 | /* Special case: a WHERE clause that is constant. Evaluate the |
| 110250 | 110475 | ** expression and either jump over all of the code or fall thru. |
| 110251 | 110476 | */ |
| | @@ -110875,11 +111100,11 @@ |
| 110875 | 111100 | #endif |
| 110876 | 111101 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 110877 | 111102 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 110878 | 111103 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 110879 | 111104 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 110880 | | -#define YYNSTATE 627 |
| 111105 | +#define YYNSTATE 628 |
| 110881 | 111106 | #define YYNRULE 327 |
| 110882 | 111107 | #define YYFALLBACK 1 |
| 110883 | 111108 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 110884 | 111109 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 110885 | 111110 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| | @@ -110948,167 +111173,167 @@ |
| 110948 | 111173 | ** shifting non-terminals after a reduce. |
| 110949 | 111174 | ** yy_default[] Default action for each state. |
| 110950 | 111175 | */ |
| 110951 | 111176 | #define YY_ACTTAB_COUNT (1564) |
| 110952 | 111177 | static const YYACTIONTYPE yy_action[] = { |
| 110953 | | - /* 0 */ 309, 955, 184, 417, 2, 171, 624, 594, 56, 56, |
| 111178 | + /* 0 */ 310, 956, 184, 418, 2, 171, 625, 595, 56, 56, |
| 110954 | 111179 | /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52, |
| 110955 | | - /* 20 */ 52, 52, 51, 233, 620, 619, 298, 620, 619, 234, |
| 110956 | | - /* 30 */ 587, 581, 56, 56, 56, 56, 19, 54, 54, 54, |
| 110957 | | - /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 605, 57, |
| 110958 | | - /* 50 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 110959 | | - /* 60 */ 56, 56, 541, 54, 54, 54, 54, 53, 53, 52, |
| 110960 | | - /* 70 */ 52, 52, 51, 233, 309, 594, 325, 196, 195, 194, |
| 111180 | + /* 20 */ 52, 52, 51, 233, 621, 620, 299, 621, 620, 234, |
| 111181 | + /* 30 */ 588, 582, 56, 56, 56, 56, 19, 54, 54, 54, |
| 111182 | + /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 606, 57, |
| 111183 | + /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 111184 | + /* 60 */ 56, 56, 542, 54, 54, 54, 54, 53, 53, 52, |
| 111185 | + /* 70 */ 52, 52, 51, 233, 310, 595, 326, 196, 195, 194, |
| 110961 | 111186 | /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 110962 | | - /* 90 */ 51, 233, 617, 616, 165, 617, 616, 380, 377, 376, |
| 110963 | | - /* 100 */ 407, 532, 576, 576, 587, 581, 303, 422, 375, 59, |
| 111187 | + /* 90 */ 51, 233, 618, 617, 165, 618, 617, 381, 378, 377, |
| 111188 | + /* 100 */ 408, 533, 577, 577, 588, 582, 304, 423, 376, 59, |
| 110964 | 111189 | /* 110 */ 53, 53, 52, 52, 52, 51, 233, 50, 47, 146, |
| 110965 | | - /* 120 */ 574, 545, 65, 57, 58, 48, 579, 578, 580, 580, |
| 111190 | + /* 120 */ 575, 546, 65, 57, 58, 48, 580, 579, 581, 581, |
| 110966 | 111191 | /* 130 */ 55, 55, 56, 56, 56, 56, 213, 54, 54, 54, |
| 110967 | | - /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 223, |
| 110968 | | - /* 150 */ 539, 420, 170, 176, 138, 280, 383, 275, 382, 168, |
| 110969 | | - /* 160 */ 489, 551, 409, 668, 620, 619, 271, 438, 409, 438, |
| 110970 | | - /* 170 */ 550, 604, 67, 482, 507, 618, 599, 412, 587, 581, |
| 110971 | | - /* 180 */ 600, 483, 618, 412, 618, 598, 91, 439, 440, 439, |
| 110972 | | - /* 190 */ 335, 598, 73, 669, 222, 266, 480, 57, 58, 48, |
| 110973 | | - /* 200 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56, |
| 110974 | | - /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 110975 | | - /* 220 */ 51, 233, 309, 279, 232, 231, 1, 132, 200, 385, |
| 110976 | | - /* 230 */ 620, 619, 617, 616, 278, 435, 289, 563, 175, 262, |
| 110977 | | - /* 240 */ 409, 264, 437, 497, 436, 166, 441, 568, 336, 568, |
| 110978 | | - /* 250 */ 201, 537, 587, 581, 599, 412, 165, 594, 600, 380, |
| 110979 | | - /* 260 */ 377, 376, 597, 598, 92, 523, 618, 569, 569, 592, |
| 110980 | | - /* 270 */ 375, 57, 58, 48, 579, 578, 580, 580, 55, 55, |
| 110981 | | - /* 280 */ 56, 56, 56, 56, 597, 54, 54, 54, 54, 53, |
| 110982 | | - /* 290 */ 53, 52, 52, 52, 51, 233, 309, 463, 617, 616, |
| 110983 | | - /* 300 */ 590, 590, 590, 174, 272, 396, 409, 272, 409, 548, |
| 110984 | | - /* 310 */ 397, 620, 619, 68, 326, 620, 619, 620, 619, 618, |
| 110985 | | - /* 320 */ 546, 412, 618, 412, 471, 594, 587, 581, 472, 598, |
| 110986 | | - /* 330 */ 92, 598, 92, 52, 52, 52, 51, 233, 513, 512, |
| 110987 | | - /* 340 */ 206, 322, 363, 464, 221, 57, 58, 48, 579, 578, |
| 110988 | | - /* 350 */ 580, 580, 55, 55, 56, 56, 56, 56, 529, 54, |
| 111192 | + /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223, |
| 111193 | + /* 150 */ 540, 421, 170, 176, 138, 281, 384, 276, 383, 168, |
| 111194 | + /* 160 */ 490, 552, 410, 669, 621, 620, 272, 439, 410, 439, |
| 111195 | + /* 170 */ 551, 605, 67, 483, 508, 619, 600, 413, 588, 582, |
| 111196 | + /* 180 */ 601, 484, 619, 413, 619, 599, 91, 440, 441, 440, |
| 111197 | + /* 190 */ 336, 599, 73, 670, 222, 267, 481, 57, 58, 48, |
| 111198 | + /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 111199 | + /* 210 */ 671, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111200 | + /* 220 */ 51, 233, 310, 280, 232, 231, 1, 132, 200, 386, |
| 111201 | + /* 230 */ 621, 620, 618, 617, 279, 436, 290, 564, 175, 263, |
| 111202 | + /* 240 */ 410, 265, 438, 498, 437, 166, 442, 569, 337, 569, |
| 111203 | + /* 250 */ 201, 538, 588, 582, 600, 413, 165, 595, 601, 381, |
| 111204 | + /* 260 */ 378, 377, 598, 599, 92, 524, 619, 570, 570, 593, |
| 111205 | + /* 270 */ 376, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 111206 | + /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53, |
| 111207 | + /* 290 */ 53, 52, 52, 52, 51, 233, 310, 464, 618, 617, |
| 111208 | + /* 300 */ 591, 591, 591, 174, 273, 397, 410, 273, 410, 549, |
| 111209 | + /* 310 */ 398, 621, 620, 68, 327, 621, 620, 621, 620, 619, |
| 111210 | + /* 320 */ 547, 413, 619, 413, 472, 595, 588, 582, 473, 599, |
| 111211 | + /* 330 */ 92, 599, 92, 52, 52, 52, 51, 233, 514, 513, |
| 111212 | + /* 340 */ 206, 323, 364, 465, 221, 57, 58, 48, 580, 579, |
| 111213 | + /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 530, 54, |
| 110989 | 111214 | /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 110990 | | - /* 370 */ 309, 396, 409, 396, 597, 372, 386, 530, 347, 617, |
| 110991 | | - /* 380 */ 616, 575, 202, 617, 616, 617, 616, 412, 620, 619, |
| 110992 | | - /* 390 */ 145, 255, 346, 254, 577, 598, 74, 351, 45, 489, |
| 110993 | | - /* 400 */ 587, 581, 235, 189, 464, 544, 167, 296, 187, 469, |
| 110994 | | - /* 410 */ 479, 67, 62, 39, 618, 546, 597, 345, 573, 57, |
| 110995 | | - /* 420 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 111215 | + /* 370 */ 310, 397, 410, 397, 598, 373, 387, 531, 348, 618, |
| 111216 | + /* 380 */ 617, 576, 202, 618, 617, 618, 617, 413, 621, 620, |
| 111217 | + /* 390 */ 145, 255, 347, 254, 578, 599, 74, 352, 45, 490, |
| 111218 | + /* 400 */ 588, 582, 235, 189, 465, 545, 167, 297, 187, 470, |
| 111219 | + /* 410 */ 480, 67, 62, 39, 619, 547, 598, 346, 574, 57, |
| 111220 | + /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 110996 | 111221 | /* 430 */ 56, 56, 6, 54, 54, 54, 54, 53, 53, 52, |
| 110997 | | - /* 440 */ 52, 52, 51, 233, 309, 562, 558, 407, 528, 576, |
| 110998 | | - /* 450 */ 576, 344, 255, 346, 254, 182, 617, 616, 503, 504, |
| 110999 | | - /* 460 */ 314, 409, 557, 235, 166, 271, 409, 352, 564, 181, |
| 111000 | | - /* 470 */ 407, 546, 576, 576, 587, 581, 412, 537, 556, 561, |
| 111001 | | - /* 480 */ 517, 412, 618, 249, 598, 16, 7, 36, 467, 598, |
| 111002 | | - /* 490 */ 92, 516, 618, 57, 58, 48, 579, 578, 580, 580, |
| 111003 | | - /* 500 */ 55, 55, 56, 56, 56, 56, 541, 54, 54, 54, |
| 111004 | | - /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 327, |
| 111005 | | - /* 520 */ 572, 571, 525, 558, 560, 394, 871, 246, 409, 248, |
| 111006 | | - /* 530 */ 171, 392, 594, 219, 407, 409, 576, 576, 502, 557, |
| 111007 | | - /* 540 */ 364, 145, 510, 412, 407, 229, 576, 576, 587, 581, |
| 111008 | | - /* 550 */ 412, 598, 92, 381, 269, 556, 166, 400, 598, 69, |
| 111009 | | - /* 560 */ 501, 419, 945, 199, 945, 198, 546, 57, 58, 48, |
| 111010 | | - /* 570 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56, |
| 111011 | | - /* 580 */ 568, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111012 | | - /* 590 */ 51, 233, 309, 317, 419, 944, 508, 944, 308, 597, |
| 111013 | | - /* 600 */ 594, 565, 490, 212, 173, 247, 423, 615, 614, 613, |
| 111014 | | - /* 610 */ 323, 197, 143, 405, 572, 571, 489, 66, 50, 47, |
| 111015 | | - /* 620 */ 146, 594, 587, 581, 232, 231, 559, 427, 67, 555, |
| 111016 | | - /* 630 */ 15, 618, 186, 543, 303, 421, 35, 206, 432, 423, |
| 111017 | | - /* 640 */ 552, 57, 58, 48, 579, 578, 580, 580, 55, 55, |
| 111222 | + /* 440 */ 52, 52, 51, 233, 310, 563, 559, 408, 529, 577, |
| 111223 | + /* 450 */ 577, 345, 255, 347, 254, 182, 618, 617, 504, 505, |
| 111224 | + /* 460 */ 315, 410, 558, 235, 166, 272, 410, 353, 565, 181, |
| 111225 | + /* 470 */ 408, 547, 577, 577, 588, 582, 413, 538, 557, 562, |
| 111226 | + /* 480 */ 518, 413, 619, 249, 599, 16, 7, 36, 468, 599, |
| 111227 | + /* 490 */ 92, 517, 619, 57, 58, 48, 580, 579, 581, 581, |
| 111228 | + /* 500 */ 55, 55, 56, 56, 56, 56, 542, 54, 54, 54, |
| 111229 | + /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 328, |
| 111230 | + /* 520 */ 573, 572, 526, 559, 561, 395, 872, 246, 410, 248, |
| 111231 | + /* 530 */ 171, 393, 595, 219, 408, 410, 577, 577, 503, 558, |
| 111232 | + /* 540 */ 365, 145, 511, 413, 408, 229, 577, 577, 588, 582, |
| 111233 | + /* 550 */ 413, 599, 92, 382, 270, 557, 166, 401, 599, 69, |
| 111234 | + /* 560 */ 502, 420, 946, 199, 946, 198, 547, 57, 58, 48, |
| 111235 | + /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 111236 | + /* 580 */ 569, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111237 | + /* 590 */ 51, 233, 310, 318, 420, 945, 509, 945, 309, 598, |
| 111238 | + /* 600 */ 595, 566, 491, 212, 173, 247, 424, 616, 615, 614, |
| 111239 | + /* 610 */ 324, 197, 143, 406, 573, 572, 490, 66, 50, 47, |
| 111240 | + /* 620 */ 146, 595, 588, 582, 232, 231, 560, 428, 67, 556, |
| 111241 | + /* 630 */ 15, 619, 186, 544, 304, 422, 35, 206, 433, 424, |
| 111242 | + /* 640 */ 553, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 111018 | 111243 | /* 650 */ 56, 56, 56, 56, 205, 54, 54, 54, 54, 53, |
| 111019 | | - /* 660 */ 53, 52, 52, 52, 51, 233, 309, 569, 569, 260, |
| 111020 | | - /* 670 */ 268, 597, 12, 373, 568, 166, 409, 313, 409, 420, |
| 111021 | | - /* 680 */ 409, 473, 473, 365, 618, 50, 47, 146, 597, 594, |
| 111022 | | - /* 690 */ 468, 412, 166, 412, 351, 412, 587, 581, 32, 598, |
| 111023 | | - /* 700 */ 94, 598, 97, 598, 95, 627, 625, 329, 142, 50, |
| 111024 | | - /* 710 */ 47, 146, 333, 349, 358, 57, 58, 48, 579, 578, |
| 111025 | | - /* 720 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54, |
| 111244 | + /* 660 */ 53, 52, 52, 52, 51, 233, 310, 570, 570, 261, |
| 111245 | + /* 670 */ 269, 598, 12, 374, 569, 166, 410, 314, 410, 421, |
| 111246 | + /* 680 */ 410, 474, 474, 366, 619, 50, 47, 146, 598, 595, |
| 111247 | + /* 690 */ 256, 413, 166, 413, 352, 413, 588, 582, 32, 599, |
| 111248 | + /* 700 */ 94, 599, 97, 599, 95, 628, 626, 330, 142, 50, |
| 111249 | + /* 710 */ 47, 146, 334, 350, 359, 57, 58, 48, 580, 579, |
| 111250 | + /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54, |
| 111026 | 111251 | /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 111027 | | - /* 740 */ 309, 409, 388, 412, 409, 22, 565, 404, 212, 362, |
| 111028 | | - /* 750 */ 389, 598, 104, 359, 409, 156, 412, 409, 603, 412, |
| 111029 | | - /* 760 */ 537, 331, 569, 569, 598, 103, 493, 598, 105, 412, |
| 111030 | | - /* 770 */ 587, 581, 412, 260, 549, 618, 11, 598, 106, 521, |
| 111031 | | - /* 780 */ 598, 133, 169, 457, 456, 170, 35, 601, 618, 57, |
| 111032 | | - /* 790 */ 58, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 111033 | | - /* 800 */ 56, 56, 409, 54, 54, 54, 54, 53, 53, 52, |
| 111034 | | - /* 810 */ 52, 52, 51, 233, 309, 409, 259, 412, 409, 50, |
| 111035 | | - /* 820 */ 47, 146, 357, 318, 355, 598, 134, 527, 352, 337, |
| 111036 | | - /* 830 */ 412, 409, 356, 412, 357, 409, 357, 618, 598, 98, |
| 111037 | | - /* 840 */ 129, 598, 102, 618, 587, 581, 412, 21, 235, 618, |
| 111038 | | - /* 850 */ 412, 618, 211, 143, 598, 101, 30, 167, 598, 93, |
| 111039 | | - /* 860 */ 350, 535, 203, 57, 58, 48, 579, 578, 580, 580, |
| 111040 | | - /* 870 */ 55, 55, 56, 56, 56, 56, 409, 54, 54, 54, |
| 111041 | | - /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 309, 409, |
| 111042 | | - /* 890 */ 526, 412, 409, 425, 215, 305, 597, 551, 141, 598, |
| 111043 | | - /* 900 */ 100, 40, 409, 38, 412, 409, 550, 412, 409, 228, |
| 111044 | | - /* 910 */ 220, 314, 598, 77, 500, 598, 96, 412, 587, 581, |
| 111045 | | - /* 920 */ 412, 338, 253, 412, 218, 598, 137, 379, 598, 136, |
| 111046 | | - /* 930 */ 28, 598, 135, 270, 715, 210, 481, 57, 58, 48, |
| 111047 | | - /* 940 */ 579, 578, 580, 580, 55, 55, 56, 56, 56, 56, |
| 111048 | | - /* 950 */ 409, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111049 | | - /* 960 */ 51, 233, 309, 409, 272, 412, 409, 315, 147, 597, |
| 111050 | | - /* 970 */ 272, 626, 2, 598, 76, 209, 409, 127, 412, 618, |
| 111051 | | - /* 980 */ 126, 412, 409, 621, 235, 618, 598, 90, 374, 598, |
| 111052 | | - /* 990 */ 89, 412, 587, 581, 27, 260, 350, 412, 618, 598, |
| 111053 | | - /* 1000 */ 75, 321, 541, 541, 125, 598, 88, 320, 278, 597, |
| 111054 | | - /* 1010 */ 618, 57, 46, 48, 579, 578, 580, 580, 55, 55, |
| 111055 | | - /* 1020 */ 56, 56, 56, 56, 409, 54, 54, 54, 54, 53, |
| 111056 | | - /* 1030 */ 53, 52, 52, 52, 51, 233, 309, 409, 450, 412, |
| 111057 | | - /* 1040 */ 164, 284, 282, 272, 609, 424, 304, 598, 87, 370, |
| 111058 | | - /* 1050 */ 409, 477, 412, 409, 608, 409, 607, 602, 618, 618, |
| 111059 | | - /* 1060 */ 598, 99, 586, 585, 122, 412, 587, 581, 412, 618, |
| 111060 | | - /* 1070 */ 412, 618, 618, 598, 86, 366, 598, 17, 598, 85, |
| 111061 | | - /* 1080 */ 319, 185, 519, 518, 583, 582, 58, 48, 579, 578, |
| 111062 | | - /* 1090 */ 580, 580, 55, 55, 56, 56, 56, 56, 409, 54, |
| 111252 | + /* 740 */ 310, 410, 389, 413, 410, 22, 566, 405, 212, 363, |
| 111253 | + /* 750 */ 390, 599, 104, 360, 410, 156, 413, 410, 604, 413, |
| 111254 | + /* 760 */ 538, 332, 570, 570, 599, 103, 494, 599, 105, 413, |
| 111255 | + /* 770 */ 588, 582, 413, 261, 550, 619, 11, 599, 106, 522, |
| 111256 | + /* 780 */ 599, 133, 169, 458, 457, 170, 35, 602, 619, 57, |
| 111257 | + /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 111258 | + /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52, |
| 111259 | + /* 810 */ 52, 52, 51, 233, 310, 410, 260, 413, 410, 50, |
| 111260 | + /* 820 */ 47, 146, 358, 319, 356, 599, 134, 528, 353, 338, |
| 111261 | + /* 830 */ 413, 410, 357, 413, 358, 410, 358, 619, 599, 98, |
| 111262 | + /* 840 */ 129, 599, 102, 619, 588, 582, 413, 21, 235, 619, |
| 111263 | + /* 850 */ 413, 619, 211, 143, 599, 101, 30, 167, 599, 93, |
| 111264 | + /* 860 */ 351, 536, 203, 57, 58, 48, 580, 579, 581, 581, |
| 111265 | + /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54, |
| 111266 | + /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 410, |
| 111267 | + /* 890 */ 527, 413, 410, 426, 215, 306, 598, 552, 141, 599, |
| 111268 | + /* 900 */ 100, 40, 410, 38, 413, 410, 551, 413, 410, 228, |
| 111269 | + /* 910 */ 220, 315, 599, 77, 501, 599, 96, 413, 588, 582, |
| 111270 | + /* 920 */ 413, 339, 253, 413, 218, 599, 137, 380, 599, 136, |
| 111271 | + /* 930 */ 28, 599, 135, 271, 716, 210, 482, 57, 58, 48, |
| 111272 | + /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 111273 | + /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 111274 | + /* 960 */ 51, 233, 310, 410, 273, 413, 410, 316, 147, 598, |
| 111275 | + /* 970 */ 273, 627, 2, 599, 76, 209, 410, 127, 413, 619, |
| 111276 | + /* 980 */ 126, 413, 410, 622, 235, 619, 599, 90, 375, 599, |
| 111277 | + /* 990 */ 89, 413, 588, 582, 27, 261, 351, 413, 619, 599, |
| 111278 | + /* 1000 */ 75, 322, 542, 542, 125, 599, 88, 321, 279, 598, |
| 111279 | + /* 1010 */ 619, 57, 46, 48, 580, 579, 581, 581, 55, 55, |
| 111280 | + /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53, |
| 111281 | + /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 410, 451, 413, |
| 111282 | + /* 1040 */ 164, 285, 283, 273, 610, 425, 305, 599, 87, 371, |
| 111283 | + /* 1050 */ 410, 478, 413, 410, 609, 410, 608, 603, 619, 619, |
| 111284 | + /* 1060 */ 599, 99, 587, 586, 122, 413, 588, 582, 413, 619, |
| 111285 | + /* 1070 */ 413, 619, 619, 599, 86, 367, 599, 17, 599, 85, |
| 111286 | + /* 1080 */ 320, 185, 520, 519, 584, 583, 58, 48, 580, 579, |
| 111287 | + /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 410, 54, |
| 111063 | 111288 | /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 111064 | | - /* 1110 */ 309, 584, 409, 412, 409, 260, 260, 260, 408, 591, |
| 111065 | | - /* 1120 */ 474, 598, 84, 170, 409, 466, 518, 412, 121, 412, |
| 111066 | | - /* 1130 */ 618, 618, 618, 618, 618, 598, 83, 598, 72, 412, |
| 111067 | | - /* 1140 */ 587, 581, 51, 233, 625, 329, 470, 598, 71, 257, |
| 111068 | | - /* 1150 */ 159, 120, 14, 462, 157, 158, 117, 260, 448, 447, |
| 111069 | | - /* 1160 */ 446, 48, 579, 578, 580, 580, 55, 55, 56, 56, |
| 111070 | | - /* 1170 */ 56, 56, 618, 54, 54, 54, 54, 53, 53, 52, |
| 111071 | | - /* 1180 */ 52, 52, 51, 233, 44, 403, 260, 3, 409, 459, |
| 111072 | | - /* 1190 */ 260, 413, 619, 118, 398, 10, 25, 24, 554, 348, |
| 111073 | | - /* 1200 */ 217, 618, 406, 412, 409, 618, 4, 44, 403, 618, |
| 111074 | | - /* 1210 */ 3, 598, 82, 618, 413, 619, 455, 542, 115, 412, |
| 111075 | | - /* 1220 */ 538, 401, 536, 274, 506, 406, 251, 598, 81, 216, |
| 111076 | | - /* 1230 */ 273, 563, 618, 243, 453, 618, 154, 618, 618, 618, |
| 111077 | | - /* 1240 */ 449, 416, 623, 110, 401, 618, 409, 236, 64, 123, |
| 111078 | | - /* 1250 */ 487, 41, 42, 531, 563, 204, 409, 267, 43, 411, |
| 111079 | | - /* 1260 */ 410, 412, 265, 592, 108, 618, 107, 434, 332, 598, |
| 111080 | | - /* 1270 */ 80, 412, 618, 263, 41, 42, 443, 618, 409, 598, |
| 111081 | | - /* 1280 */ 70, 43, 411, 410, 433, 261, 592, 149, 618, 597, |
| 111082 | | - /* 1290 */ 256, 237, 188, 412, 590, 590, 590, 589, 588, 13, |
| 111083 | | - /* 1300 */ 618, 598, 18, 328, 235, 618, 44, 403, 360, 3, |
| 111084 | | - /* 1310 */ 418, 461, 339, 413, 619, 227, 124, 590, 590, 590, |
| 111085 | | - /* 1320 */ 589, 588, 13, 618, 406, 409, 618, 409, 139, 34, |
| 111086 | | - /* 1330 */ 403, 387, 3, 148, 622, 312, 413, 619, 311, 330, |
| 111087 | | - /* 1340 */ 412, 460, 412, 401, 180, 353, 412, 406, 598, 79, |
| 111088 | | - /* 1350 */ 598, 78, 250, 563, 598, 9, 618, 612, 611, 610, |
| 111089 | | - /* 1360 */ 618, 8, 452, 442, 242, 415, 401, 618, 239, 235, |
| 111090 | | - /* 1370 */ 179, 238, 428, 41, 42, 288, 563, 618, 618, 618, |
| 111091 | | - /* 1380 */ 43, 411, 410, 618, 144, 592, 618, 618, 177, 61, |
| 111092 | | - /* 1390 */ 618, 596, 391, 620, 619, 287, 41, 42, 414, 618, |
| 111093 | | - /* 1400 */ 293, 30, 393, 43, 411, 410, 292, 618, 592, 31, |
| 111094 | | - /* 1410 */ 618, 395, 291, 60, 230, 37, 590, 590, 590, 589, |
| 111095 | | - /* 1420 */ 588, 13, 214, 553, 183, 290, 172, 301, 300, 299, |
| 111096 | | - /* 1430 */ 178, 297, 595, 563, 451, 29, 285, 390, 540, 590, |
| 111097 | | - /* 1440 */ 590, 590, 589, 588, 13, 283, 520, 534, 150, 533, |
| 111098 | | - /* 1450 */ 241, 281, 384, 192, 191, 324, 515, 514, 276, 240, |
| 111099 | | - /* 1460 */ 510, 523, 307, 511, 128, 592, 509, 225, 226, 486, |
| 111100 | | - /* 1470 */ 485, 224, 152, 491, 464, 306, 484, 163, 153, 371, |
| 111101 | | - /* 1480 */ 478, 151, 162, 258, 369, 161, 367, 208, 475, 476, |
| 111102 | | - /* 1490 */ 26, 160, 465, 140, 361, 131, 590, 590, 590, 116, |
| 111103 | | - /* 1500 */ 119, 454, 343, 155, 114, 342, 113, 112, 445, 111, |
| 111104 | | - /* 1510 */ 130, 109, 431, 316, 426, 430, 23, 429, 20, 606, |
| 111105 | | - /* 1520 */ 190, 507, 255, 341, 244, 63, 294, 593, 310, 570, |
| 111106 | | - /* 1530 */ 277, 402, 354, 235, 567, 496, 495, 492, 494, 302, |
| 111107 | | - /* 1540 */ 458, 378, 286, 245, 566, 5, 252, 547, 193, 444, |
| 111108 | | - /* 1550 */ 233, 340, 207, 524, 368, 505, 334, 522, 499, 399, |
| 111109 | | - /* 1560 */ 295, 498, 956, 488, |
| 111289 | + /* 1110 */ 310, 585, 410, 413, 410, 261, 261, 261, 409, 592, |
| 111290 | + /* 1120 */ 475, 599, 84, 170, 410, 467, 519, 413, 121, 413, |
| 111291 | + /* 1130 */ 619, 619, 619, 619, 619, 599, 83, 599, 72, 413, |
| 111292 | + /* 1140 */ 588, 582, 51, 233, 626, 330, 471, 599, 71, 258, |
| 111293 | + /* 1150 */ 159, 120, 14, 463, 157, 158, 117, 261, 449, 448, |
| 111294 | + /* 1160 */ 447, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 111295 | + /* 1170 */ 56, 56, 619, 54, 54, 54, 54, 53, 53, 52, |
| 111296 | + /* 1180 */ 52, 52, 51, 233, 44, 404, 261, 3, 410, 460, |
| 111297 | + /* 1190 */ 261, 414, 620, 118, 399, 10, 25, 24, 555, 349, |
| 111298 | + /* 1200 */ 217, 619, 407, 413, 410, 619, 4, 44, 404, 619, |
| 111299 | + /* 1210 */ 3, 599, 82, 619, 414, 620, 456, 543, 115, 413, |
| 111300 | + /* 1220 */ 539, 402, 537, 275, 507, 407, 251, 599, 81, 216, |
| 111301 | + /* 1230 */ 274, 564, 619, 243, 454, 619, 154, 619, 619, 619, |
| 111302 | + /* 1240 */ 450, 417, 624, 110, 402, 619, 410, 236, 64, 123, |
| 111303 | + /* 1250 */ 488, 41, 42, 532, 564, 204, 410, 268, 43, 412, |
| 111304 | + /* 1260 */ 411, 413, 266, 593, 108, 619, 107, 435, 333, 599, |
| 111305 | + /* 1270 */ 80, 413, 619, 264, 41, 42, 444, 619, 410, 599, |
| 111306 | + /* 1280 */ 70, 43, 412, 411, 434, 262, 593, 149, 619, 598, |
| 111307 | + /* 1290 */ 257, 237, 188, 413, 591, 591, 591, 590, 589, 13, |
| 111308 | + /* 1300 */ 619, 599, 18, 329, 235, 619, 44, 404, 361, 3, |
| 111309 | + /* 1310 */ 419, 462, 340, 414, 620, 227, 124, 591, 591, 591, |
| 111310 | + /* 1320 */ 590, 589, 13, 619, 407, 410, 619, 410, 139, 34, |
| 111311 | + /* 1330 */ 404, 388, 3, 148, 623, 313, 414, 620, 312, 331, |
| 111312 | + /* 1340 */ 413, 461, 413, 402, 180, 354, 413, 407, 599, 79, |
| 111313 | + /* 1350 */ 599, 78, 250, 564, 599, 9, 619, 613, 612, 611, |
| 111314 | + /* 1360 */ 619, 8, 453, 443, 242, 416, 402, 619, 239, 235, |
| 111315 | + /* 1370 */ 179, 238, 429, 41, 42, 289, 564, 619, 619, 619, |
| 111316 | + /* 1380 */ 43, 412, 411, 619, 144, 593, 619, 619, 177, 61, |
| 111317 | + /* 1390 */ 619, 597, 392, 621, 620, 288, 41, 42, 415, 619, |
| 111318 | + /* 1400 */ 294, 30, 394, 43, 412, 411, 293, 619, 593, 31, |
| 111319 | + /* 1410 */ 619, 396, 292, 60, 230, 37, 591, 591, 591, 590, |
| 111320 | + /* 1420 */ 589, 13, 214, 554, 183, 291, 172, 302, 301, 300, |
| 111321 | + /* 1430 */ 178, 298, 596, 564, 452, 29, 286, 391, 541, 591, |
| 111322 | + /* 1440 */ 591, 591, 590, 589, 13, 284, 521, 535, 150, 534, |
| 111323 | + /* 1450 */ 241, 282, 385, 192, 191, 325, 516, 515, 277, 240, |
| 111324 | + /* 1460 */ 511, 524, 308, 512, 128, 593, 510, 225, 226, 487, |
| 111325 | + /* 1470 */ 486, 224, 152, 492, 465, 307, 485, 163, 153, 372, |
| 111326 | + /* 1480 */ 479, 151, 162, 259, 370, 161, 368, 208, 476, 477, |
| 111327 | + /* 1490 */ 26, 160, 469, 466, 362, 140, 591, 591, 591, 116, |
| 111328 | + /* 1500 */ 119, 455, 344, 155, 114, 343, 113, 112, 446, 111, |
| 111329 | + /* 1510 */ 131, 109, 432, 317, 130, 431, 23, 20, 430, 427, |
| 111330 | + /* 1520 */ 190, 63, 255, 342, 244, 607, 295, 287, 311, 594, |
| 111331 | + /* 1530 */ 278, 508, 496, 235, 493, 571, 497, 568, 495, 403, |
| 111332 | + /* 1540 */ 459, 379, 355, 245, 193, 303, 567, 296, 341, 5, |
| 111333 | + /* 1550 */ 445, 548, 506, 207, 525, 500, 335, 489, 252, 369, |
| 111334 | + /* 1560 */ 400, 499, 523, 233, |
| 111110 | 111335 | }; |
| 111111 | 111336 | static const YYCODETYPE yy_lookahead[] = { |
| 111112 | 111337 | /* 0 */ 19, 142, 143, 144, 145, 24, 1, 26, 77, 78, |
| 111113 | 111338 | /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, |
| 111114 | 111339 | /* 20 */ 89, 90, 91, 92, 26, 27, 15, 26, 27, 197, |
| | @@ -111256,21 +111481,21 @@ |
| 111256 | 111481 | /* 1440 */ 130, 131, 132, 133, 134, 210, 175, 211, 31, 211, |
| 111257 | 111482 | /* 1450 */ 33, 210, 104, 86, 87, 47, 175, 183, 175, 42, |
| 111258 | 111483 | /* 1460 */ 103, 94, 178, 177, 22, 98, 175, 92, 228, 175, |
| 111259 | 111484 | /* 1470 */ 175, 228, 55, 183, 57, 178, 175, 156, 61, 18, |
| 111260 | 111485 | /* 1480 */ 157, 64, 156, 235, 157, 156, 45, 157, 236, 157, |
| 111261 | | - /* 1490 */ 135, 156, 189, 68, 157, 218, 129, 130, 131, 22, |
| 111486 | + /* 1490 */ 135, 156, 199, 189, 157, 68, 129, 130, 131, 22, |
| 111262 | 111487 | /* 1500 */ 189, 199, 157, 156, 192, 18, 192, 192, 199, 192, |
| 111263 | | - /* 1510 */ 218, 189, 40, 157, 38, 157, 240, 157, 240, 153, |
| 111264 | | - /* 1520 */ 196, 181, 105, 106, 107, 243, 198, 166, 111, 230, |
| 111265 | | - /* 1530 */ 176, 226, 239, 116, 230, 176, 166, 166, 176, 148, |
| 111266 | | - /* 1540 */ 199, 177, 209, 209, 166, 196, 239, 208, 185, 199, |
| 111267 | | - /* 1550 */ 92, 209, 233, 173, 234, 182, 139, 173, 182, 191, |
| 111268 | | - /* 1560 */ 195, 182, 250, 186, |
| 111488 | + /* 1510 */ 218, 189, 40, 157, 218, 157, 240, 240, 157, 38, |
| 111489 | + /* 1520 */ 196, 243, 105, 106, 107, 153, 198, 209, 111, 166, |
| 111490 | + /* 1530 */ 176, 181, 166, 116, 166, 230, 176, 230, 176, 226, |
| 111491 | + /* 1540 */ 199, 177, 239, 209, 185, 148, 166, 195, 209, 196, |
| 111492 | + /* 1550 */ 199, 208, 182, 233, 173, 182, 139, 186, 239, 234, |
| 111493 | + /* 1560 */ 191, 182, 173, 92, |
| 111269 | 111494 | }; |
| 111270 | 111495 | #define YY_SHIFT_USE_DFLT (-70) |
| 111271 | | -#define YY_SHIFT_COUNT (416) |
| 111496 | +#define YY_SHIFT_COUNT (417) |
| 111272 | 111497 | #define YY_SHIFT_MIN (-69) |
| 111273 | 111498 | #define YY_SHIFT_MAX (1487) |
| 111274 | 111499 | static const short yy_shift_ofst[] = { |
| 111275 | 111500 | /* 0 */ 1143, 1188, 1417, 1188, 1287, 1287, 138, 138, -2, -19, |
| 111276 | 111501 | /* 10 */ 1287, 1287, 1287, 1287, 347, 362, 129, 129, 795, 1165, |
| | @@ -111283,44 +111508,44 @@ |
| 111283 | 111508 | /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869, |
| 111284 | 111509 | /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45, |
| 111285 | 111510 | /* 100 */ -45, -45, -45, -45, -1, 24, 245, 362, 362, 362, |
| 111286 | 111511 | /* 110 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111287 | 111512 | /* 120 */ 362, 362, 362, 388, 356, 362, 362, 362, 362, 362, |
| 111288 | | - /* 130 */ 732, 868, 231, 1051, 1458, -70, -70, -70, 1367, 57, |
| 111513 | + /* 130 */ 732, 868, 231, 1051, 1471, -70, -70, -70, 1367, 57, |
| 111289 | 111514 | /* 140 */ 434, 434, 289, 291, 285, 1, 204, 572, 539, 362, |
| 111290 | 111515 | /* 150 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111291 | 111516 | /* 160 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111292 | 111517 | /* 170 */ 362, 362, 362, 362, 362, 362, 362, 362, 362, 362, |
| 111293 | 111518 | /* 180 */ 362, 506, 506, 506, 705, 1253, 1253, 1253, -70, -70, |
| 111294 | 111519 | /* 190 */ -70, 171, 171, 160, 502, 502, 502, 446, 432, 511, |
| 111295 | 111520 | /* 200 */ 422, 358, 335, -12, -12, -12, -12, 576, 294, -12, |
| 111296 | 111521 | /* 210 */ -12, 295, 595, 141, 600, 730, 723, 723, 805, 730, |
| 111297 | 111522 | /* 220 */ 805, 439, 911, 231, 865, 231, 865, 807, 865, 723, |
| 111298 | | - /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1476, 1308, 1308, |
| 111299 | | - /* 240 */ 1472, 1472, 1308, 1477, 1425, 1275, 1487, 1487, 1487, 1487, |
| 111300 | | - /* 250 */ 1308, 1461, 1275, 1477, 1425, 1425, 1308, 1461, 1355, 1441, |
| 111301 | | - /* 260 */ 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, 1348, |
| 111302 | | - /* 270 */ 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, 1348, |
| 111303 | | - /* 280 */ 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, 1280, |
| 111304 | | - /* 290 */ 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, 1338, |
| 111305 | | - /* 300 */ 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, 1013, |
| 111306 | | - /* 310 */ 467, 612, 84, 179, -28, 870, 410, 761, 760, 667, |
| 111307 | | - /* 320 */ 650, 531, 220, 361, 331, 125, 127, 97, 1306, 1300, |
| 111308 | | - /* 330 */ 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, 1139, |
| 111309 | | - /* 340 */ 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, 1174, |
| 111310 | | - /* 350 */ 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, 1147, |
| 111311 | | - /* 360 */ 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, 1057, |
| 111312 | | - /* 370 */ 1031, 1030, 899, 938, 982, 936, 972, 958, 910, 955, |
| 111313 | | - /* 380 */ 875, 885, 908, 857, 859, 867, 804, 590, 834, 747, |
| 111314 | | - /* 390 */ 818, 513, 611, 741, 673, 637, 611, 606, 603, 579, |
| 111315 | | - /* 400 */ 501, 541, 468, 386, 445, 395, 376, 281, 185, 120, |
| 111316 | | - /* 410 */ 92, 75, 45, 114, 25, 11, 5, |
| 111523 | + /* 230 */ 766, 633, 633, 231, 284, 63, 608, 1481, 1308, 1308, |
| 111524 | + /* 240 */ 1472, 1472, 1308, 1477, 1427, 1275, 1487, 1487, 1487, 1487, |
| 111525 | + /* 250 */ 1308, 1461, 1275, 1477, 1427, 1427, 1275, 1308, 1461, 1355, |
| 111526 | + /* 260 */ 1441, 1308, 1308, 1461, 1308, 1461, 1308, 1461, 1442, 1348, |
| 111527 | + /* 270 */ 1348, 1348, 1408, 1375, 1375, 1442, 1348, 1357, 1348, 1408, |
| 111528 | + /* 280 */ 1348, 1348, 1316, 1331, 1316, 1331, 1316, 1331, 1308, 1308, |
| 111529 | + /* 290 */ 1280, 1288, 1289, 1285, 1279, 1275, 1253, 1336, 1346, 1346, |
| 111530 | + /* 300 */ 1338, 1338, 1338, 1338, -70, -70, -70, -70, -70, -70, |
| 111531 | + /* 310 */ 1013, 467, 612, 84, 179, -28, 870, 410, 761, 760, |
| 111532 | + /* 320 */ 667, 650, 531, 220, 361, 331, 125, 127, 97, 1306, |
| 111533 | + /* 330 */ 1300, 1270, 1151, 1272, 1203, 1232, 1261, 1244, 1148, 1174, |
| 111534 | + /* 340 */ 1139, 1156, 1124, 1220, 1115, 1210, 1233, 1099, 1193, 1184, |
| 111535 | + /* 350 */ 1174, 1173, 1029, 1121, 1120, 1085, 1162, 1119, 1037, 1152, |
| 111536 | + /* 360 */ 1147, 1129, 1046, 1011, 1093, 1098, 1075, 1061, 1032, 960, |
| 111537 | + /* 370 */ 1057, 1031, 1030, 899, 938, 982, 936, 972, 958, 910, |
| 111538 | + /* 380 */ 955, 875, 885, 908, 857, 859, 867, 804, 590, 834, |
| 111539 | + /* 390 */ 747, 818, 513, 611, 741, 673, 637, 611, 606, 603, |
| 111540 | + /* 400 */ 579, 501, 541, 468, 386, 445, 395, 376, 281, 185, |
| 111541 | + /* 410 */ 120, 92, 75, 45, 114, 25, 11, 5, |
| 111317 | 111542 | }; |
| 111318 | 111543 | #define YY_REDUCE_USE_DFLT (-169) |
| 111319 | | -#define YY_REDUCE_COUNT (308) |
| 111544 | +#define YY_REDUCE_COUNT (309) |
| 111320 | 111545 | #define YY_REDUCE_MIN (-168) |
| 111321 | | -#define YY_REDUCE_MAX (1391) |
| 111546 | +#define YY_REDUCE_MAX (1397) |
| 111322 | 111547 | static const short yy_reduce_ofst[] = { |
| 111323 | 111548 | /* 0 */ -141, 90, 1095, 222, 158, 156, 19, 17, 10, -104, |
| 111324 | 111549 | /* 10 */ 378, 316, 311, 12, 180, 249, 598, 464, 397, 1181, |
| 111325 | 111550 | /* 20 */ 1177, 1175, 1128, 1106, 1096, 1054, 1038, 974, 964, 962, |
| 111326 | 111551 | /* 30 */ 948, 905, 903, 900, 887, 874, 832, 826, 816, 813, |
| | @@ -111337,87 +111562,87 @@ |
| 111337 | 111562 | /* 140 */ 935, 892, 968, 1245, 1242, 1234, 1225, 798, 798, 1222, |
| 111338 | 111563 | /* 150 */ 1221, 1218, 1214, 1213, 1212, 1202, 1195, 1191, 1161, 1158, |
| 111339 | 111564 | /* 160 */ 1140, 1135, 1123, 1112, 1107, 1100, 1080, 1074, 1073, 1072, |
| 111340 | 111565 | /* 170 */ 1070, 1067, 1048, 1044, 969, 968, 907, 906, 904, 894, |
| 111341 | 111566 | /* 180 */ 833, 837, 836, 340, 827, 815, 775, 68, 722, 646, |
| 111342 | | - /* 190 */ -168, 1384, 1380, 1377, 1379, 1376, 1373, 1339, 1365, 1368, |
| 111343 | | - /* 200 */ 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1320, 1319, 1365, |
| 111344 | | - /* 210 */ 1365, 1339, 1378, 1349, 1391, 1350, 1342, 1334, 1307, 1341, |
| 111345 | | - /* 220 */ 1293, 1364, 1363, 1371, 1362, 1370, 1359, 1340, 1354, 1333, |
| 111346 | | - /* 230 */ 1305, 1304, 1299, 1361, 1328, 1324, 1366, 1282, 1360, 1358, |
| 111347 | | - /* 240 */ 1278, 1276, 1356, 1292, 1322, 1309, 1317, 1315, 1314, 1312, |
| 111348 | | - /* 250 */ 1345, 1347, 1302, 1277, 1311, 1303, 1337, 1335, 1252, 1248, |
| 111349 | | - /* 260 */ 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, 1295, |
| 111350 | | - /* 270 */ 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, 1281, |
| 111351 | | - /* 280 */ 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, 1189, |
| 111352 | | - /* 290 */ 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, 1216, |
| 111353 | | - /* 300 */ 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164, |
| 111567 | + /* 190 */ -168, 1389, 1381, 1371, 1379, 1373, 1370, 1343, 1352, 1369, |
| 111568 | + /* 200 */ 1352, 1352, 1352, 1352, 1352, 1352, 1352, 1325, 1320, 1352, |
| 111569 | + /* 210 */ 1352, 1343, 1380, 1353, 1397, 1351, 1339, 1334, 1319, 1341, |
| 111570 | + /* 220 */ 1303, 1364, 1359, 1368, 1362, 1366, 1360, 1350, 1354, 1318, |
| 111571 | + /* 230 */ 1313, 1307, 1305, 1363, 1328, 1324, 1372, 1278, 1361, 1358, |
| 111572 | + /* 240 */ 1277, 1276, 1356, 1296, 1322, 1309, 1317, 1315, 1314, 1312, |
| 111573 | + /* 250 */ 1345, 1347, 1302, 1292, 1311, 1304, 1293, 1337, 1335, 1252, |
| 111574 | + /* 260 */ 1248, 1332, 1330, 1329, 1327, 1326, 1323, 1321, 1297, 1301, |
| 111575 | + /* 270 */ 1295, 1294, 1290, 1243, 1240, 1284, 1291, 1286, 1283, 1274, |
| 111576 | + /* 280 */ 1281, 1271, 1238, 1241, 1236, 1235, 1227, 1226, 1267, 1266, |
| 111577 | + /* 290 */ 1189, 1229, 1223, 1211, 1206, 1201, 1197, 1239, 1237, 1219, |
| 111578 | + /* 300 */ 1216, 1209, 1208, 1185, 1089, 1086, 1087, 1137, 1136, 1164, |
| 111354 | 111579 | }; |
| 111355 | 111580 | static const YYACTIONTYPE yy_default[] = { |
| 111356 | | - /* 0 */ 632, 866, 954, 954, 866, 866, 954, 954, 954, 756, |
| 111357 | | - /* 10 */ 954, 954, 954, 864, 954, 954, 784, 784, 928, 954, |
| 111358 | | - /* 20 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111359 | | - /* 30 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111360 | | - /* 40 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111361 | | - /* 50 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111362 | | - /* 60 */ 954, 954, 954, 954, 954, 954, 954, 671, 760, 790, |
| 111363 | | - /* 70 */ 954, 954, 954, 954, 954, 954, 954, 954, 927, 929, |
| 111364 | | - /* 80 */ 798, 797, 907, 771, 795, 788, 792, 867, 860, 861, |
| 111365 | | - /* 90 */ 859, 863, 868, 954, 791, 827, 844, 826, 838, 843, |
| 111366 | | - /* 100 */ 850, 842, 839, 829, 828, 830, 831, 954, 954, 954, |
| 111367 | | - /* 110 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111368 | | - /* 120 */ 954, 954, 954, 658, 725, 954, 954, 954, 954, 954, |
| 111369 | | - /* 130 */ 954, 954, 954, 832, 833, 847, 846, 845, 954, 663, |
| 111370 | | - /* 140 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111371 | | - /* 150 */ 934, 932, 954, 879, 954, 954, 954, 954, 954, 954, |
| 111372 | | - /* 160 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111373 | | - /* 170 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111374 | | - /* 180 */ 638, 756, 756, 756, 632, 954, 954, 954, 946, 760, |
| 111375 | | - /* 190 */ 750, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111376 | | - /* 200 */ 954, 954, 954, 800, 739, 917, 919, 954, 900, 737, |
| 111377 | | - /* 210 */ 660, 758, 673, 748, 640, 794, 773, 773, 912, 794, |
| 111378 | | - /* 220 */ 912, 696, 719, 954, 784, 954, 784, 693, 784, 773, |
| 111379 | | - /* 230 */ 862, 954, 954, 954, 757, 748, 954, 939, 764, 764, |
| 111380 | | - /* 240 */ 931, 931, 764, 806, 729, 794, 736, 736, 736, 736, |
| 111381 | | - /* 250 */ 764, 655, 794, 806, 729, 729, 764, 655, 906, 904, |
| 111382 | | - /* 260 */ 764, 764, 655, 764, 655, 764, 655, 872, 727, 727, |
| 111383 | | - /* 270 */ 727, 711, 876, 876, 872, 727, 696, 727, 711, 727, |
| 111384 | | - /* 280 */ 727, 777, 772, 777, 772, 777, 772, 764, 764, 954, |
| 111385 | | - /* 290 */ 789, 778, 787, 785, 794, 954, 714, 648, 648, 637, |
| 111386 | | - /* 300 */ 637, 637, 637, 951, 951, 946, 698, 698, 681, 954, |
| 111387 | | - /* 310 */ 954, 954, 954, 954, 954, 954, 881, 954, 954, 954, |
| 111388 | | - /* 320 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 633, |
| 111389 | | - /* 330 */ 941, 954, 954, 938, 954, 954, 954, 954, 799, 954, |
| 111390 | | - /* 340 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 916, |
| 111391 | | - /* 350 */ 954, 954, 954, 954, 954, 954, 954, 910, 954, 954, |
| 111392 | | - /* 360 */ 954, 954, 954, 954, 903, 902, 954, 954, 954, 954, |
| 111393 | | - /* 370 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111394 | | - /* 380 */ 954, 954, 954, 954, 954, 954, 954, 954, 954, 954, |
| 111395 | | - /* 390 */ 954, 954, 786, 954, 779, 954, 865, 954, 954, 954, |
| 111396 | | - /* 400 */ 954, 954, 954, 954, 954, 954, 954, 742, 815, 954, |
| 111397 | | - /* 410 */ 814, 818, 813, 665, 954, 646, 954, 629, 634, 950, |
| 111398 | | - /* 420 */ 953, 952, 949, 948, 947, 942, 940, 937, 936, 935, |
| 111399 | | - /* 430 */ 933, 930, 926, 885, 883, 890, 889, 888, 887, 886, |
| 111400 | | - /* 440 */ 884, 882, 880, 801, 796, 793, 925, 878, 738, 735, |
| 111401 | | - /* 450 */ 734, 654, 943, 909, 918, 805, 804, 807, 915, 914, |
| 111402 | | - /* 460 */ 913, 911, 908, 895, 803, 802, 730, 870, 869, 657, |
| 111403 | | - /* 470 */ 899, 898, 897, 901, 905, 896, 766, 656, 653, 662, |
| 111404 | | - /* 480 */ 717, 718, 726, 724, 723, 722, 721, 720, 716, 664, |
| 111405 | | - /* 490 */ 672, 710, 695, 694, 875, 877, 874, 873, 703, 702, |
| 111406 | | - /* 500 */ 708, 707, 706, 705, 704, 701, 700, 699, 692, 691, |
| 111407 | | - /* 510 */ 697, 690, 713, 712, 709, 689, 733, 732, 731, 728, |
| 111408 | | - /* 520 */ 688, 687, 686, 818, 685, 684, 824, 823, 811, 854, |
| 111409 | | - /* 530 */ 753, 752, 751, 763, 762, 775, 774, 809, 808, 776, |
| 111410 | | - /* 540 */ 761, 755, 754, 770, 769, 768, 767, 759, 749, 781, |
| 111411 | | - /* 550 */ 783, 782, 780, 856, 765, 853, 924, 923, 922, 921, |
| 111412 | | - /* 560 */ 920, 858, 857, 825, 822, 676, 677, 893, 892, 894, |
| 111413 | | - /* 570 */ 891, 679, 678, 675, 674, 855, 744, 743, 851, 848, |
| 111414 | | - /* 580 */ 840, 836, 852, 849, 841, 837, 835, 834, 820, 819, |
| 111415 | | - /* 590 */ 817, 816, 812, 821, 667, 745, 741, 740, 810, 747, |
| 111416 | | - /* 600 */ 746, 683, 682, 680, 661, 659, 652, 650, 649, 651, |
| 111417 | | - /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666, |
| 111418 | | - /* 620 */ 665, 639, 636, 635, 631, 630, 628, |
| 111581 | + /* 0 */ 633, 867, 955, 955, 867, 867, 955, 955, 955, 757, |
| 111582 | + /* 10 */ 955, 955, 955, 865, 955, 955, 785, 785, 929, 955, |
| 111583 | + /* 20 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111584 | + /* 30 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111585 | + /* 40 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111586 | + /* 50 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111587 | + /* 60 */ 955, 955, 955, 955, 955, 955, 955, 672, 761, 791, |
| 111588 | + /* 70 */ 955, 955, 955, 955, 955, 955, 955, 955, 928, 930, |
| 111589 | + /* 80 */ 799, 798, 908, 772, 796, 789, 793, 868, 861, 862, |
| 111590 | + /* 90 */ 860, 864, 869, 955, 792, 828, 845, 827, 839, 844, |
| 111591 | + /* 100 */ 851, 843, 840, 830, 829, 831, 832, 955, 955, 955, |
| 111592 | + /* 110 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111593 | + /* 120 */ 955, 955, 955, 659, 726, 955, 955, 955, 955, 955, |
| 111594 | + /* 130 */ 955, 955, 955, 833, 834, 848, 847, 846, 955, 664, |
| 111595 | + /* 140 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111596 | + /* 150 */ 935, 933, 955, 880, 955, 955, 955, 955, 955, 955, |
| 111597 | + /* 160 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111598 | + /* 170 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111599 | + /* 180 */ 639, 757, 757, 757, 633, 955, 955, 955, 947, 761, |
| 111600 | + /* 190 */ 751, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111601 | + /* 200 */ 955, 955, 955, 801, 740, 918, 920, 955, 901, 738, |
| 111602 | + /* 210 */ 661, 759, 674, 749, 641, 795, 774, 774, 913, 795, |
| 111603 | + /* 220 */ 913, 697, 720, 955, 785, 955, 785, 694, 785, 774, |
| 111604 | + /* 230 */ 863, 955, 955, 955, 758, 749, 955, 940, 765, 765, |
| 111605 | + /* 240 */ 932, 932, 765, 807, 730, 795, 737, 737, 737, 737, |
| 111606 | + /* 250 */ 765, 656, 795, 807, 730, 730, 795, 765, 656, 907, |
| 111607 | + /* 260 */ 905, 765, 765, 656, 765, 656, 765, 656, 873, 728, |
| 111608 | + /* 270 */ 728, 728, 712, 877, 877, 873, 728, 697, 728, 712, |
| 111609 | + /* 280 */ 728, 728, 778, 773, 778, 773, 778, 773, 765, 765, |
| 111610 | + /* 290 */ 955, 790, 779, 788, 786, 795, 955, 715, 649, 649, |
| 111611 | + /* 300 */ 638, 638, 638, 638, 952, 952, 947, 699, 699, 682, |
| 111612 | + /* 310 */ 955, 955, 955, 955, 955, 955, 955, 882, 955, 955, |
| 111613 | + /* 320 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111614 | + /* 330 */ 634, 942, 955, 955, 939, 955, 955, 955, 955, 800, |
| 111615 | + /* 340 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111616 | + /* 350 */ 917, 955, 955, 955, 955, 955, 955, 955, 911, 955, |
| 111617 | + /* 360 */ 955, 955, 955, 955, 955, 904, 903, 955, 955, 955, |
| 111618 | + /* 370 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111619 | + /* 380 */ 955, 955, 955, 955, 955, 955, 955, 955, 955, 955, |
| 111620 | + /* 390 */ 955, 955, 955, 787, 955, 780, 955, 866, 955, 955, |
| 111621 | + /* 400 */ 955, 955, 955, 955, 955, 955, 955, 955, 743, 816, |
| 111622 | + /* 410 */ 955, 815, 819, 814, 666, 955, 647, 955, 630, 635, |
| 111623 | + /* 420 */ 951, 954, 953, 950, 949, 948, 943, 941, 938, 937, |
| 111624 | + /* 430 */ 936, 934, 931, 927, 886, 884, 891, 890, 889, 888, |
| 111625 | + /* 440 */ 887, 885, 883, 881, 802, 797, 794, 926, 879, 739, |
| 111626 | + /* 450 */ 736, 735, 655, 944, 910, 919, 806, 805, 808, 916, |
| 111627 | + /* 460 */ 915, 914, 912, 909, 896, 804, 803, 731, 871, 870, |
| 111628 | + /* 470 */ 658, 900, 899, 898, 902, 906, 897, 767, 657, 654, |
| 111629 | + /* 480 */ 663, 718, 719, 727, 725, 724, 723, 722, 721, 717, |
| 111630 | + /* 490 */ 665, 673, 711, 696, 695, 876, 878, 875, 874, 704, |
| 111631 | + /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693, |
| 111632 | + /* 510 */ 692, 698, 691, 714, 713, 710, 690, 734, 733, 732, |
| 111633 | + /* 520 */ 729, 689, 688, 687, 819, 686, 685, 825, 824, 812, |
| 111634 | + /* 530 */ 855, 754, 753, 752, 764, 763, 776, 775, 810, 809, |
| 111635 | + /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750, |
| 111636 | + /* 550 */ 782, 784, 783, 781, 857, 766, 854, 925, 924, 923, |
| 111637 | + /* 560 */ 922, 921, 859, 858, 826, 823, 677, 678, 894, 893, |
| 111638 | + /* 570 */ 895, 892, 680, 679, 676, 675, 856, 745, 744, 852, |
| 111639 | + /* 580 */ 849, 841, 837, 853, 850, 842, 838, 836, 835, 821, |
| 111640 | + /* 590 */ 820, 818, 817, 813, 822, 668, 746, 742, 741, 811, |
| 111641 | + /* 600 */ 748, 747, 684, 683, 681, 662, 660, 653, 651, 650, |
| 111642 | + /* 610 */ 652, 648, 646, 645, 644, 643, 642, 671, 670, 669, |
| 111643 | + /* 620 */ 667, 666, 640, 637, 636, 632, 631, 629, |
| 111419 | 111644 | }; |
| 111420 | 111645 | |
| 111421 | 111646 | /* The next table maps tokens into fallback tokens. If a construct |
| 111422 | 111647 | ** like the following: |
| 111423 | 111648 | ** |
| | @@ -111885,11 +112110,11 @@ |
| 111885 | 112110 | /* 237 */ "case_operand ::=", |
| 111886 | 112111 | /* 238 */ "exprlist ::= nexprlist", |
| 111887 | 112112 | /* 239 */ "exprlist ::=", |
| 111888 | 112113 | /* 240 */ "nexprlist ::= nexprlist COMMA expr", |
| 111889 | 112114 | /* 241 */ "nexprlist ::= expr", |
| 111890 | | - /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP", |
| 112115 | + /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt", |
| 111891 | 112116 | /* 243 */ "uniqueflag ::= UNIQUE", |
| 111892 | 112117 | /* 244 */ "uniqueflag ::=", |
| 111893 | 112118 | /* 245 */ "idxlist_opt ::=", |
| 111894 | 112119 | /* 246 */ "idxlist_opt ::= LP idxlist RP", |
| 111895 | 112120 | /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder", |
| | @@ -112604,11 +112829,11 @@ |
| 112604 | 112829 | { 224, 0 }, |
| 112605 | 112830 | { 220, 1 }, |
| 112606 | 112831 | { 220, 0 }, |
| 112607 | 112832 | { 215, 3 }, |
| 112608 | 112833 | { 215, 1 }, |
| 112609 | | - { 147, 11 }, |
| 112834 | + { 147, 12 }, |
| 112610 | 112835 | { 227, 1 }, |
| 112611 | 112836 | { 227, 0 }, |
| 112612 | 112837 | { 178, 0 }, |
| 112613 | 112838 | { 178, 3 }, |
| 112614 | 112839 | { 187, 5 }, |
| | @@ -113046,10 +113271,11 @@ |
| 113046 | 113271 | case 114: /* select ::= select multiselect_op oneselect */ |
| 113047 | 113272 | { |
| 113048 | 113273 | if( yymsp[0].minor.yy159 ){ |
| 113049 | 113274 | yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392; |
| 113050 | 113275 | yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159; |
| 113276 | + if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1; |
| 113051 | 113277 | }else{ |
| 113052 | 113278 | sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159); |
| 113053 | 113279 | } |
| 113054 | 113280 | yygotominor.yy159 = yymsp[0].minor.yy159; |
| 113055 | 113281 | } |
| | @@ -113608,15 +113834,15 @@ |
| 113608 | 113834 | {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);} |
| 113609 | 113835 | break; |
| 113610 | 113836 | case 241: /* nexprlist ::= expr */ |
| 113611 | 113837 | {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);} |
| 113612 | 113838 | break; |
| 113613 | | - case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ |
| 113839 | + case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP where_opt */ |
| 113614 | 113840 | { |
| 113615 | | - sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, |
| 113616 | | - sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392, |
| 113617 | | - &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392); |
| 113841 | + sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 113842 | + sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392, |
| 113843 | + &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392); |
| 113618 | 113844 | } |
| 113619 | 113845 | break; |
| 113620 | 113846 | case 243: /* uniqueflag ::= UNIQUE */ |
| 113621 | 113847 | case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296); |
| 113622 | 113848 | {yygotominor.yy392 = OE_Abort;} |
| | @@ -114538,11 +114764,10 @@ |
| 114538 | 114764 | *tokenType = TK_SPACE; |
| 114539 | 114765 | return i; |
| 114540 | 114766 | } |
| 114541 | 114767 | case '-': { |
| 114542 | 114768 | if( z[1]=='-' ){ |
| 114543 | | - /* IMP: R-50417-27976 -- syntax diagram for comments */ |
| 114544 | 114769 | for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
| 114545 | 114770 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 114546 | 114771 | return i; |
| 114547 | 114772 | } |
| 114548 | 114773 | *tokenType = TK_MINUS; |
| | @@ -114571,11 +114796,10 @@ |
| 114571 | 114796 | case '/': { |
| 114572 | 114797 | if( z[1]!='*' || z[2]==0 ){ |
| 114573 | 114798 | *tokenType = TK_SLASH; |
| 114574 | 114799 | return 1; |
| 114575 | 114800 | } |
| 114576 | | - /* IMP: R-50417-27976 -- syntax diagram for comments */ |
| 114577 | 114801 | for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
| 114578 | 114802 | if( c ) i++; |
| 114579 | 114803 | *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ |
| 114580 | 114804 | return i; |
| 114581 | 114805 | } |
| | @@ -116416,10 +116640,11 @@ |
| 116416 | 116640 | case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break; |
| 116417 | 116641 | case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break; |
| 116418 | 116642 | case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break; |
| 116419 | 116643 | case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break; |
| 116420 | 116644 | case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break; |
| 116645 | + case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break; |
| 116421 | 116646 | case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break; |
| 116422 | 116647 | case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break; |
| 116423 | 116648 | case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break; |
| 116424 | 116649 | case SQLITE_FULL: zName = "SQLITE_FULL"; break; |
| 116425 | 116650 | case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break; |
| | @@ -117771,11 +117996,11 @@ |
| 117771 | 117996 | db->autoCommit = 1; |
| 117772 | 117997 | db->nextAutovac = -1; |
| 117773 | 117998 | db->szMmap = sqlite3GlobalConfig.szMmap; |
| 117774 | 117999 | db->nextPagesize = 0; |
| 117775 | 118000 | db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger |
| 117776 | | -#if !defined(SQLITE_DEAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX |
| 118001 | +#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX |
| 117777 | 118002 | | SQLITE_AutoIndex |
| 117778 | 118003 | #endif |
| 117779 | 118004 | #if SQLITE_DEFAULT_FILE_FORMAT<4 |
| 117780 | 118005 | | SQLITE_LegacyFileFmt |
| 117781 | 118006 | #endif |
| | @@ -128244,11 +128469,11 @@ |
| 128244 | 128469 | } |
| 128245 | 128470 | |
| 128246 | 128471 | |
| 128247 | 128472 | #ifdef SQLITE_TEST |
| 128248 | 128473 | |
| 128249 | | -/* #include <tcl.h> */ |
| 128474 | +#include <tcl.h> |
| 128250 | 128475 | /* #include <string.h> */ |
| 128251 | 128476 | |
| 128252 | 128477 | /* |
| 128253 | 128478 | ** Implementation of a special SQL scalar function for testing tokenizers |
| 128254 | 128479 | ** designed to be used in concert with the Tcl testing framework. This |
| 128255 | 128480 | |