| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.13.0. By combining all the individual C code files into this |
| 3 | +** version 3.14.1. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -35,12 +35,12 @@ |
| 35 | 35 | ** |
| 36 | 36 | ************************************************************************* |
| 37 | 37 | ** Internal interface definitions for SQLite. |
| 38 | 38 | ** |
| 39 | 39 | */ |
| 40 | | -#ifndef _SQLITEINT_H_ |
| 41 | | -#define _SQLITEINT_H_ |
| 40 | +#ifndef SQLITEINT_H |
| 41 | +#define SQLITEINT_H |
| 42 | 42 | |
| 43 | 43 | /* Special Comments: |
| 44 | 44 | ** |
| 45 | 45 | ** Some comments have special meaning to the tools that measure test |
| 46 | 46 | ** coverage: |
| | @@ -65,10 +65,18 @@ |
| 65 | 65 | ** In all cases, the special comment must be enclosed in the usual |
| 66 | 66 | ** slash-asterisk...asterisk-slash comment marks, with no spaces between the |
| 67 | 67 | ** asterisks and the comment text. |
| 68 | 68 | */ |
| 69 | 69 | |
| 70 | +/* |
| 71 | +** Make sure the Tcl calling convention macro is defined. This macro is |
| 72 | +** only used by test code and Tcl integration code. |
| 73 | +*/ |
| 74 | +#ifndef SQLITE_TCLAPI |
| 75 | +# define SQLITE_TCLAPI |
| 76 | +#endif |
| 77 | + |
| 70 | 78 | /* |
| 71 | 79 | ** Make sure that rand_s() is available on Windows systems with MSVC 2005 |
| 72 | 80 | ** or higher. |
| 73 | 81 | */ |
| 74 | 82 | #if defined(_MSC_VER) && _MSC_VER>=1400 |
| | @@ -95,12 +103,12 @@ |
| 95 | 103 | ** |
| 96 | 104 | ****************************************************************************** |
| 97 | 105 | ** |
| 98 | 106 | ** This file contains code that is specific to MSVC. |
| 99 | 107 | */ |
| 100 | | -#ifndef _MSVC_H_ |
| 101 | | -#define _MSVC_H_ |
| 108 | +#ifndef SQLITE_MSVC_H |
| 109 | +#define SQLITE_MSVC_H |
| 102 | 110 | |
| 103 | 111 | #if defined(_MSC_VER) |
| 104 | 112 | #pragma warning(disable : 4054) |
| 105 | 113 | #pragma warning(disable : 4055) |
| 106 | 114 | #pragma warning(disable : 4100) |
| | @@ -116,11 +124,11 @@ |
| 116 | 124 | #pragma warning(disable : 4306) |
| 117 | 125 | #pragma warning(disable : 4702) |
| 118 | 126 | #pragma warning(disable : 4706) |
| 119 | 127 | #endif /* defined(_MSC_VER) */ |
| 120 | 128 | |
| 121 | | -#endif /* _MSVC_H_ */ |
| 129 | +#endif /* SQLITE_MSVC_H */ |
| 122 | 130 | |
| 123 | 131 | /************** End of msvc.h ************************************************/ |
| 124 | 132 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 125 | 133 | |
| 126 | 134 | /* |
| | @@ -280,12 +288,12 @@ |
| 280 | 288 | ** The name of this file under configuration management is "sqlite.h.in". |
| 281 | 289 | ** The makefile makes some minor changes to this file (such as inserting |
| 282 | 290 | ** the version number) and changes its name to "sqlite3.h" as |
| 283 | 291 | ** part of the build process. |
| 284 | 292 | */ |
| 285 | | -#ifndef _SQLITE3_H_ |
| 286 | | -#define _SQLITE3_H_ |
| 293 | +#ifndef SQLITE3_H |
| 294 | +#define SQLITE3_H |
| 287 | 295 | #include <stdarg.h> /* Needed for the definition of va_list */ |
| 288 | 296 | |
| 289 | 297 | /* |
| 290 | 298 | ** Make sure we can call this stuff from C++. |
| 291 | 299 | */ |
| | @@ -304,12 +312,21 @@ |
| 304 | 312 | # define SQLITE_API |
| 305 | 313 | #endif |
| 306 | 314 | #ifndef SQLITE_CDECL |
| 307 | 315 | # define SQLITE_CDECL |
| 308 | 316 | #endif |
| 317 | +#ifndef SQLITE_APICALL |
| 318 | +# define SQLITE_APICALL |
| 319 | +#endif |
| 309 | 320 | #ifndef SQLITE_STDCALL |
| 310 | | -# define SQLITE_STDCALL |
| 321 | +# define SQLITE_STDCALL SQLITE_APICALL |
| 322 | +#endif |
| 323 | +#ifndef SQLITE_CALLBACK |
| 324 | +# define SQLITE_CALLBACK |
| 325 | +#endif |
| 326 | +#ifndef SQLITE_SYSAPI |
| 327 | +# define SQLITE_SYSAPI |
| 311 | 328 | #endif |
| 312 | 329 | |
| 313 | 330 | /* |
| 314 | 331 | ** These no-op macros are used in front of interfaces to mark those |
| 315 | 332 | ** interfaces as either deprecated or experimental. New applications |
| | @@ -361,13 +378,13 @@ |
| 361 | 378 | ** |
| 362 | 379 | ** See also: [sqlite3_libversion()], |
| 363 | 380 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 364 | 381 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 365 | 382 | */ |
| 366 | | -#define SQLITE_VERSION "3.13.0" |
| 367 | | -#define SQLITE_VERSION_NUMBER 3013000 |
| 368 | | -#define SQLITE_SOURCE_ID "2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2" |
| 383 | +#define SQLITE_VERSION "3.14.1" |
| 384 | +#define SQLITE_VERSION_NUMBER 3014001 |
| 385 | +#define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b" |
| 369 | 386 | |
| 370 | 387 | /* |
| 371 | 388 | ** CAPI3REF: Run-Time Library Version Numbers |
| 372 | 389 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 373 | 390 | ** |
| | @@ -756,10 +773,11 @@ |
| 756 | 773 | #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) |
| 757 | 774 | #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) |
| 758 | 775 | #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) |
| 759 | 776 | #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) |
| 760 | 777 | #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) |
| 778 | +#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8)) |
| 761 | 779 | |
| 762 | 780 | /* |
| 763 | 781 | ** CAPI3REF: Flags For File Open Operations |
| 764 | 782 | ** |
| 765 | 783 | ** These bit values are intended for use in the |
| | @@ -1285,10 +1303,20 @@ |
| 1285 | 1303 | ** |
| 1286 | 1304 | ** Mutexes are created using [sqlite3_mutex_alloc()]. |
| 1287 | 1305 | */ |
| 1288 | 1306 | typedef struct sqlite3_mutex sqlite3_mutex; |
| 1289 | 1307 | |
| 1308 | +/* |
| 1309 | +** CAPI3REF: Loadable Extension Thunk |
| 1310 | +** |
| 1311 | +** A pointer to the opaque sqlite3_api_routines structure is passed as |
| 1312 | +** the third parameter to entry points of [loadable extensions]. This |
| 1313 | +** structure must be typedefed in order to work around compiler warnings |
| 1314 | +** on some platforms. |
| 1315 | +*/ |
| 1316 | +typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 1317 | + |
| 1290 | 1318 | /* |
| 1291 | 1319 | ** CAPI3REF: OS Interface Object |
| 1292 | 1320 | ** |
| 1293 | 1321 | ** An instance of the sqlite3_vfs object defines the interface between |
| 1294 | 1322 | ** the SQLite core and the underlying operating system. The "vfs" |
| | @@ -2189,11 +2217,11 @@ |
| 2189 | 2217 | ** interface independently of the [load_extension()] SQL function. |
| 2190 | 2218 | ** The [sqlite3_enable_load_extension()] API enables or disables both the |
| 2191 | 2219 | ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()]. |
| 2192 | 2220 | ** There should be two additional arguments. |
| 2193 | 2221 | ** When the first argument to this interface is 1, then only the C-API is |
| 2194 | | -** enabled and the SQL function remains disabled. If the first argment to |
| 2222 | +** enabled and the SQL function remains disabled. If the first argument to |
| 2195 | 2223 | ** this interface is 0, then both the C-API and the SQL function are disabled. |
| 2196 | 2224 | ** If the first argument is -1, then no changes are made to state of either the |
| 2197 | 2225 | ** C-API or the SQL function. |
| 2198 | 2226 | ** The second parameter is a pointer to an integer into which |
| 2199 | 2227 | ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface |
| | @@ -2482,11 +2510,11 @@ |
| 2482 | 2510 | ** result in undefined behavior. |
| 2483 | 2511 | ** |
| 2484 | 2512 | ** A busy handler must not close the database connection |
| 2485 | 2513 | ** or [prepared statement] that invoked the busy handler. |
| 2486 | 2514 | */ |
| 2487 | | -SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); |
| 2515 | +SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*); |
| 2488 | 2516 | |
| 2489 | 2517 | /* |
| 2490 | 2518 | ** CAPI3REF: Set A Busy Timeout |
| 2491 | 2519 | ** METHOD: sqlite3 |
| 2492 | 2520 | ** |
| | @@ -3003,10 +3031,13 @@ |
| 3003 | 3031 | #define SQLITE_RECURSIVE 33 /* NULL NULL */ |
| 3004 | 3032 | |
| 3005 | 3033 | /* |
| 3006 | 3034 | ** CAPI3REF: Tracing And Profiling Functions |
| 3007 | 3035 | ** METHOD: sqlite3 |
| 3036 | +** |
| 3037 | +** These routines are deprecated. Use the [sqlite3_trace_v2()] interface |
| 3038 | +** instead of the routines described here. |
| 3008 | 3039 | ** |
| 3009 | 3040 | ** These routines register callback functions that can be used for |
| 3010 | 3041 | ** tracing and profiling the execution of SQL statements. |
| 3011 | 3042 | ** |
| 3012 | 3043 | ** ^The callback function registered by sqlite3_trace() is invoked at |
| | @@ -3029,13 +3060,107 @@ |
| 3029 | 3060 | ** digits in the time are meaningless. Future versions of SQLite |
| 3030 | 3061 | ** might provide greater resolution on the profiler callback. The |
| 3031 | 3062 | ** sqlite3_profile() function is considered experimental and is |
| 3032 | 3063 | ** subject to change in future versions of SQLite. |
| 3033 | 3064 | */ |
| 3034 | | -SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
| 3035 | | -SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*, |
| 3065 | +SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*, |
| 3066 | + void(*xTrace)(void*,const char*), void*); |
| 3067 | +SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*, |
| 3036 | 3068 | void(*xProfile)(void*,const char*,sqlite3_uint64), void*); |
| 3069 | + |
| 3070 | +/* |
| 3071 | +** CAPI3REF: SQL Trace Event Codes |
| 3072 | +** KEYWORDS: SQLITE_TRACE |
| 3073 | +** |
| 3074 | +** These constants identify classes of events that can be monitored |
| 3075 | +** using the [sqlite3_trace_v2()] tracing logic. The third argument |
| 3076 | +** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of |
| 3077 | +** the following constants. ^The first argument to the trace callback |
| 3078 | +** is one of the following constants. |
| 3079 | +** |
| 3080 | +** New tracing constants may be added in future releases. |
| 3081 | +** |
| 3082 | +** ^A trace callback has four arguments: xCallback(T,C,P,X). |
| 3083 | +** ^The T argument is one of the integer type codes above. |
| 3084 | +** ^The C argument is a copy of the context pointer passed in as the |
| 3085 | +** fourth argument to [sqlite3_trace_v2()]. |
| 3086 | +** The P and X arguments are pointers whose meanings depend on T. |
| 3087 | +** |
| 3088 | +** <dl> |
| 3089 | +** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt> |
| 3090 | +** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement |
| 3091 | +** first begins running and possibly at other times during the |
| 3092 | +** execution of the prepared statement, such as at the start of each |
| 3093 | +** trigger subprogram. ^The P argument is a pointer to the |
| 3094 | +** [prepared statement]. ^The X argument is a pointer to a string which |
| 3095 | +** is the unexpanded SQL text of the prepared statement or an SQL comment |
| 3096 | +** that indicates the invocation of a trigger. ^The callback can compute |
| 3097 | +** the same text that would have been returned by the legacy [sqlite3_trace()] |
| 3098 | +** interface by using the X argument when X begins with "--" and invoking |
| 3099 | +** [sqlite3_expanded_sql(P)] otherwise. |
| 3100 | +** |
| 3101 | +** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt> |
| 3102 | +** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same |
| 3103 | +** information as is provided by the [sqlite3_profile()] callback. |
| 3104 | +** ^The P argument is a pointer to the [prepared statement] and the |
| 3105 | +** X argument points to a 64-bit integer which is the estimated of |
| 3106 | +** the number of nanosecond that the prepared statement took to run. |
| 3107 | +** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes. |
| 3108 | +** |
| 3109 | +** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt> |
| 3110 | +** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared |
| 3111 | +** statement generates a single row of result. |
| 3112 | +** ^The P argument is a pointer to the [prepared statement] and the |
| 3113 | +** X argument is unused. |
| 3114 | +** |
| 3115 | +** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt> |
| 3116 | +** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database |
| 3117 | +** connection closes. |
| 3118 | +** ^The P argument is a pointer to the [database connection] object |
| 3119 | +** and the X argument is unused. |
| 3120 | +** </dl> |
| 3121 | +*/ |
| 3122 | +#define SQLITE_TRACE_STMT 0x01 |
| 3123 | +#define SQLITE_TRACE_PROFILE 0x02 |
| 3124 | +#define SQLITE_TRACE_ROW 0x04 |
| 3125 | +#define SQLITE_TRACE_CLOSE 0x08 |
| 3126 | + |
| 3127 | +/* |
| 3128 | +** CAPI3REF: SQL Trace Hook |
| 3129 | +** METHOD: sqlite3 |
| 3130 | +** |
| 3131 | +** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback |
| 3132 | +** function X against [database connection] D, using property mask M |
| 3133 | +** and context pointer P. ^If the X callback is |
| 3134 | +** NULL or if the M mask is zero, then tracing is disabled. The |
| 3135 | +** M argument should be the bitwise OR-ed combination of |
| 3136 | +** zero or more [SQLITE_TRACE] constants. |
| 3137 | +** |
| 3138 | +** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides |
| 3139 | +** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2(). |
| 3140 | +** |
| 3141 | +** ^The X callback is invoked whenever any of the events identified by |
| 3142 | +** mask M occur. ^The integer return value from the callback is currently |
| 3143 | +** ignored, though this may change in future releases. Callback |
| 3144 | +** implementations should return zero to ensure future compatibility. |
| 3145 | +** |
| 3146 | +** ^A trace callback is invoked with four arguments: callback(T,C,P,X). |
| 3147 | +** ^The T argument is one of the [SQLITE_TRACE] |
| 3148 | +** constants to indicate why the callback was invoked. |
| 3149 | +** ^The C argument is a copy of the context pointer. |
| 3150 | +** The P and X arguments are pointers whose meanings depend on T. |
| 3151 | +** |
| 3152 | +** The sqlite3_trace_v2() interface is intended to replace the legacy |
| 3153 | +** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which |
| 3154 | +** are deprecated. |
| 3155 | +*/ |
| 3156 | +SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2( |
| 3157 | + sqlite3*, |
| 3158 | + unsigned uMask, |
| 3159 | + int(*xCallback)(unsigned,void*,void*,void*), |
| 3160 | + void *pCtx |
| 3161 | +); |
| 3037 | 3162 | |
| 3038 | 3163 | /* |
| 3039 | 3164 | ** CAPI3REF: Query Progress Callbacks |
| 3040 | 3165 | ** METHOD: sqlite3 |
| 3041 | 3166 | ** |
| | @@ -3651,15 +3776,39 @@ |
| 3651 | 3776 | |
| 3652 | 3777 | /* |
| 3653 | 3778 | ** CAPI3REF: Retrieving Statement SQL |
| 3654 | 3779 | ** METHOD: sqlite3_stmt |
| 3655 | 3780 | ** |
| 3656 | | -** ^This interface can be used to retrieve a saved copy of the original |
| 3657 | | -** SQL text used to create a [prepared statement] if that statement was |
| 3658 | | -** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. |
| 3781 | +** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8 |
| 3782 | +** SQL text used to create [prepared statement] P if P was |
| 3783 | +** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. |
| 3784 | +** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8 |
| 3785 | +** string containing the SQL text of prepared statement P with |
| 3786 | +** [bound parameters] expanded. |
| 3787 | +** |
| 3788 | +** ^(For example, if a prepared statement is created using the SQL |
| 3789 | +** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345 |
| 3790 | +** and parameter :xyz is unbound, then sqlite3_sql() will return |
| 3791 | +** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() |
| 3792 | +** will return "SELECT 2345,NULL".)^ |
| 3793 | +** |
| 3794 | +** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory |
| 3795 | +** is available to hold the result, or if the result would exceed the |
| 3796 | +** the maximum string length determined by the [SQLITE_LIMIT_LENGTH]. |
| 3797 | +** |
| 3798 | +** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of |
| 3799 | +** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time |
| 3800 | +** option causes sqlite3_expanded_sql() to always return NULL. |
| 3801 | +** |
| 3802 | +** ^The string returned by sqlite3_sql(P) is managed by SQLite and is |
| 3803 | +** automatically freed when the prepared statement is finalized. |
| 3804 | +** ^The string returned by sqlite3_expanded_sql(P), on the other hand, |
| 3805 | +** is obtained from [sqlite3_malloc()] and must be free by the application |
| 3806 | +** by passing it to [sqlite3_free()]. |
| 3659 | 3807 | */ |
| 3660 | 3808 | SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt); |
| 3809 | +SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt); |
| 3661 | 3810 | |
| 3662 | 3811 | /* |
| 3663 | 3812 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3664 | 3813 | ** METHOD: sqlite3_stmt |
| 3665 | 3814 | ** |
| | @@ -4813,16 +4962,17 @@ |
| 4813 | 4962 | ** NULL if the metadata has been discarded. |
| 4814 | 4963 | ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL, |
| 4815 | 4964 | ** SQLite will invoke the destructor function X with parameter P exactly |
| 4816 | 4965 | ** once, when the metadata is discarded. |
| 4817 | 4966 | ** SQLite is free to discard the metadata at any time, including: <ul> |
| 4818 | | -** <li> when the corresponding function parameter changes, or |
| 4819 | | -** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 4820 | | -** SQL statement, or |
| 4821 | | -** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or |
| 4822 | | -** <li> during the original sqlite3_set_auxdata() call when a memory |
| 4823 | | -** allocation error occurs. </ul>)^ |
| 4967 | +** <li> ^(when the corresponding function parameter changes)^, or |
| 4968 | +** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the |
| 4969 | +** SQL statement)^, or |
| 4970 | +** <li> ^(when sqlite3_set_auxdata() is invoked again on the same |
| 4971 | +** parameter)^, or |
| 4972 | +** <li> ^(during the original sqlite3_set_auxdata() call when a memory |
| 4973 | +** allocation error occurs.)^ </ul> |
| 4824 | 4974 | ** |
| 4825 | 4975 | ** Note the last bullet in particular. The destructor X in |
| 4826 | 4976 | ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the |
| 4827 | 4977 | ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata() |
| 4828 | 4978 | ** should be called near the end of the function implementation and the |
| | @@ -5645,11 +5795,11 @@ |
| 5645 | 5795 | ** interface returns SQLITE_OK and fills in the non-NULL pointers in |
| 5646 | 5796 | ** the final five arguments with appropriate values if the specified |
| 5647 | 5797 | ** column exists. ^The sqlite3_table_column_metadata() interface returns |
| 5648 | 5798 | ** SQLITE_ERROR and if the specified column does not exist. |
| 5649 | 5799 | ** ^If the column-name parameter to sqlite3_table_column_metadata() is a |
| 5650 | | -** NULL pointer, then this routine simply checks for the existance of the |
| 5800 | +** NULL pointer, then this routine simply checks for the existence of the |
| 5651 | 5801 | ** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it |
| 5652 | 5802 | ** does not. |
| 5653 | 5803 | ** |
| 5654 | 5804 | ** ^The column is identified by the second, third and fourth parameters to |
| 5655 | 5805 | ** this function. ^(The second parameter is either the name of the database |
| | @@ -5779,12 +5929,12 @@ |
| 5779 | 5929 | ** to turn extension loading on and call it with onoff==0 to turn |
| 5780 | 5930 | ** it back off again. |
| 5781 | 5931 | ** |
| 5782 | 5932 | ** ^This interface enables or disables both the C-API |
| 5783 | 5933 | ** [sqlite3_load_extension()] and the SQL function [load_extension()]. |
| 5784 | | -** Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) |
| 5785 | | -** to enable or disable only the C-API. |
| 5934 | +** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..) |
| 5935 | +** to enable or disable only the C-API.)^ |
| 5786 | 5936 | ** |
| 5787 | 5937 | ** <b>Security warning:</b> It is recommended that extension loading |
| 5788 | 5938 | ** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method |
| 5789 | 5939 | ** rather than this interface, so the [load_extension()] SQL function |
| 5790 | 5940 | ** remains disabled. This will prevent SQL injections from giving attackers |
| | @@ -5800,11 +5950,11 @@ |
| 5800 | 5950 | ** xEntryPoint() is the entry point for a statically linked [SQLite extension] |
| 5801 | 5951 | ** that is to be automatically loaded into all new database connections. |
| 5802 | 5952 | ** |
| 5803 | 5953 | ** ^(Even though the function prototype shows that xEntryPoint() takes |
| 5804 | 5954 | ** no arguments and returns void, SQLite invokes xEntryPoint() with three |
| 5805 | | -** arguments and expects and integer result as if the signature of the |
| 5955 | +** arguments and expects an integer result as if the signature of the |
| 5806 | 5956 | ** entry point where as follows: |
| 5807 | 5957 | ** |
| 5808 | 5958 | ** <blockquote><pre> |
| 5809 | 5959 | ** int xEntryPoint( |
| 5810 | 5960 | ** sqlite3 *db, |
| | @@ -5826,11 +5976,11 @@ |
| 5826 | 5976 | ** will be called more than once for each database connection that is opened. |
| 5827 | 5977 | ** |
| 5828 | 5978 | ** See also: [sqlite3_reset_auto_extension()] |
| 5829 | 5979 | ** and [sqlite3_cancel_auto_extension()] |
| 5830 | 5980 | */ |
| 5831 | | -SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void)); |
| 5981 | +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void(*xEntryPoint)(void)); |
| 5832 | 5982 | |
| 5833 | 5983 | /* |
| 5834 | 5984 | ** CAPI3REF: Cancel Automatic Extension Loading |
| 5835 | 5985 | ** |
| 5836 | 5986 | ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the |
| | @@ -5838,11 +5988,11 @@ |
| 5838 | 5988 | ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)] |
| 5839 | 5989 | ** routine returns 1 if initialization routine X was successfully |
| 5840 | 5990 | ** unregistered and it returns 0 if X was not on the list of initialization |
| 5841 | 5991 | ** routines. |
| 5842 | 5992 | */ |
| 5843 | | -SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void)); |
| 5993 | +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void(*xEntryPoint)(void)); |
| 5844 | 5994 | |
| 5845 | 5995 | /* |
| 5846 | 5996 | ** CAPI3REF: Reset Automatic Extension Loading |
| 5847 | 5997 | ** |
| 5848 | 5998 | ** ^This interface disables all automatic extensions previously |
| | @@ -7014,10 +7164,22 @@ |
| 7014 | 7164 | ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 7015 | 7165 | ** <dd>This parameter returns the approximate number of bytes of heap |
| 7016 | 7166 | ** memory used by all pager caches associated with the database connection.)^ |
| 7017 | 7167 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| 7018 | 7168 | ** |
| 7169 | +** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] |
| 7170 | +** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt> |
| 7171 | +** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a |
| 7172 | +** pager cache is shared between two or more connections the bytes of heap |
| 7173 | +** memory used by that pager cache is divided evenly between the attached |
| 7174 | +** connections.)^ In other words, if none of the pager caches associated |
| 7175 | +** with the database connection are shared, this request returns the same |
| 7176 | +** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are |
| 7177 | +** shared, the value returned by this call will be smaller than that returned |
| 7178 | +** by DBSTATUS_CACHE_USED. ^The highwater mark associated with |
| 7179 | +** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0. |
| 7180 | +** |
| 7019 | 7181 | ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt> |
| 7020 | 7182 | ** <dd>This parameter returns the approximate number of bytes of heap |
| 7021 | 7183 | ** memory used to store the schema for all databases associated |
| 7022 | 7184 | ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ |
| 7023 | 7185 | ** ^The full amount of memory used by the schemas is reported, even if the |
| | @@ -7071,11 +7233,12 @@ |
| 7071 | 7233 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 7072 | 7234 | #define SQLITE_DBSTATUS_CACHE_HIT 7 |
| 7073 | 7235 | #define SQLITE_DBSTATUS_CACHE_MISS 8 |
| 7074 | 7236 | #define SQLITE_DBSTATUS_CACHE_WRITE 9 |
| 7075 | 7237 | #define SQLITE_DBSTATUS_DEFERRED_FKS 10 |
| 7076 | | -#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */ |
| 7238 | +#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11 |
| 7239 | +#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */ |
| 7077 | 7240 | |
| 7078 | 7241 | |
| 7079 | 7242 | /* |
| 7080 | 7243 | ** CAPI3REF: Prepared Statement Status |
| 7081 | 7244 | ** METHOD: sqlite3_stmt |
| | @@ -8227,11 +8390,11 @@ |
| 8227 | 8390 | ** tables. |
| 8228 | 8391 | ** |
| 8229 | 8392 | ** ^The second parameter to the preupdate callback is a pointer to |
| 8230 | 8393 | ** the [database connection] that registered the preupdate hook. |
| 8231 | 8394 | ** ^The third parameter to the preupdate callback is one of the constants |
| 8232 | | -** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to indentify the |
| 8395 | +** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the |
| 8233 | 8396 | ** kind of update operation that is about to occur. |
| 8234 | 8397 | ** ^(The fourth parameter to the preupdate callback is the name of the |
| 8235 | 8398 | ** database within the database connection that is being modified. This |
| 8236 | 8399 | ** will be "main" for the main database or "temp" for TEMP tables or |
| 8237 | 8400 | ** the name given after the AS keyword in the [ATTACH] statement for attached |
| | @@ -8454,11 +8617,11 @@ |
| 8454 | 8617 | #endif |
| 8455 | 8618 | |
| 8456 | 8619 | #if 0 |
| 8457 | 8620 | } /* End of the 'extern "C"' block */ |
| 8458 | 8621 | #endif |
| 8459 | | -#endif /* _SQLITE3_H_ */ |
| 8622 | +#endif /* SQLITE3_H */ |
| 8460 | 8623 | |
| 8461 | 8624 | /******** Begin file sqlite3rtree.h *********/ |
| 8462 | 8625 | /* |
| 8463 | 8626 | ** 2010 August 30 |
| 8464 | 8627 | ** |
| | @@ -10174,11 +10337,11 @@ |
| 10174 | 10337 | ** following structure. All structure methods must be defined, setting |
| 10175 | 10338 | ** any member of the fts5_tokenizer struct to NULL leads to undefined |
| 10176 | 10339 | ** behaviour. The structure methods are expected to function as follows: |
| 10177 | 10340 | ** |
| 10178 | 10341 | ** xCreate: |
| 10179 | | -** This function is used to allocate and inititalize a tokenizer instance. |
| 10342 | +** This function is used to allocate and initialize a tokenizer instance. |
| 10180 | 10343 | ** A tokenizer instance is required to actually tokenize text. |
| 10181 | 10344 | ** |
| 10182 | 10345 | ** The first argument passed to this function is a copy of the (void*) |
| 10183 | 10346 | ** pointer provided by the application when the fts5_tokenizer object |
| 10184 | 10347 | ** was registered with FTS5 (the third argument to xCreateTokenizer()). |
| | @@ -10433,11 +10596,10 @@ |
| 10433 | 10596 | #if 0 |
| 10434 | 10597 | } /* end of the 'extern "C"' block */ |
| 10435 | 10598 | #endif |
| 10436 | 10599 | |
| 10437 | 10600 | #endif /* _FTS5_H */ |
| 10438 | | - |
| 10439 | 10601 | |
| 10440 | 10602 | /******** End of fts5.h *********/ |
| 10441 | 10603 | |
| 10442 | 10604 | /************** End of sqlite3.h *********************************************/ |
| 10443 | 10605 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| | @@ -10732,11 +10894,11 @@ |
| 10732 | 10894 | ** Make sure that the compiler intrinsics we desire are enabled when |
| 10733 | 10895 | ** compiling with an appropriate version of MSVC unless prevented by |
| 10734 | 10896 | ** the SQLITE_DISABLE_INTRINSIC define. |
| 10735 | 10897 | */ |
| 10736 | 10898 | #if !defined(SQLITE_DISABLE_INTRINSIC) |
| 10737 | | -# if defined(_MSC_VER) && _MSC_VER>=1300 |
| 10899 | +# if defined(_MSC_VER) && _MSC_VER>=1400 |
| 10738 | 10900 | # if !defined(_WIN32_WCE) |
| 10739 | 10901 | # include <intrin.h> |
| 10740 | 10902 | # pragma intrinsic(_byteswap_ushort) |
| 10741 | 10903 | # pragma intrinsic(_byteswap_ulong) |
| 10742 | 10904 | # pragma intrinsic(_ReadWriteBarrier) |
| | @@ -11009,12 +11171,12 @@ |
| 11009 | 11171 | ** |
| 11010 | 11172 | ************************************************************************* |
| 11011 | 11173 | ** This is the header file for the generic hash-table implementation |
| 11012 | 11174 | ** used in SQLite. |
| 11013 | 11175 | */ |
| 11014 | | -#ifndef _SQLITE_HASH_H_ |
| 11015 | | -#define _SQLITE_HASH_H_ |
| 11176 | +#ifndef SQLITE_HASH_H |
| 11177 | +#define SQLITE_HASH_H |
| 11016 | 11178 | |
| 11017 | 11179 | /* Forward declarations of structures. */ |
| 11018 | 11180 | typedef struct Hash Hash; |
| 11019 | 11181 | typedef struct HashElem HashElem; |
| 11020 | 11182 | |
| | @@ -11090,11 +11252,11 @@ |
| 11090 | 11252 | /* |
| 11091 | 11253 | ** Number of entries in a hash table |
| 11092 | 11254 | */ |
| 11093 | 11255 | /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ |
| 11094 | 11256 | |
| 11095 | | -#endif /* _SQLITE_HASH_H_ */ |
| 11257 | +#endif /* SQLITE_HASH_H */ |
| 11096 | 11258 | |
| 11097 | 11259 | /************** End of hash.h ************************************************/ |
| 11098 | 11260 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 11099 | 11261 | /************** Include parse.h in the middle of sqliteInt.h *****************/ |
| 11100 | 11262 | /************** Begin file parse.h *******************************************/ |
| | @@ -11838,12 +12000,12 @@ |
| 11838 | 12000 | ************************************************************************* |
| 11839 | 12001 | ** This header file defines the interface that the sqlite B-Tree file |
| 11840 | 12002 | ** subsystem. See comments in the source code for a detailed description |
| 11841 | 12003 | ** of what each interface routine does. |
| 11842 | 12004 | */ |
| 11843 | | -#ifndef _BTREE_H_ |
| 11844 | | -#define _BTREE_H_ |
| 12005 | +#ifndef SQLITE_BTREE_H |
| 12006 | +#define SQLITE_BTREE_H |
| 11845 | 12007 | |
| 11846 | 12008 | /* TODO: This definition is just included so other modules compile. It |
| 11847 | 12009 | ** needs to be revisited. |
| 11848 | 12010 | */ |
| 11849 | 12011 | #define SQLITE_N_BTREE_META 16 |
| | @@ -11864,10 +12026,11 @@ |
| 11864 | 12026 | ** Forward declarations of structure |
| 11865 | 12027 | */ |
| 11866 | 12028 | typedef struct Btree Btree; |
| 11867 | 12029 | typedef struct BtCursor BtCursor; |
| 11868 | 12030 | typedef struct BtShared BtShared; |
| 12031 | +typedef struct BtreePayload BtreePayload; |
| 11869 | 12032 | |
| 11870 | 12033 | |
| 11871 | 12034 | SQLITE_PRIVATE int sqlite3BtreeOpen( |
| 11872 | 12035 | sqlite3_vfs *pVfs, /* VFS to use with this b-tree */ |
| 11873 | 12036 | const char *zFilename, /* Name of database file to open */ |
| | @@ -12075,23 +12238,47 @@ |
| 12075 | 12238 | |
| 12076 | 12239 | /* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */ |
| 12077 | 12240 | #define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */ |
| 12078 | 12241 | #define BTREE_AUXDELETE 0x04 /* not the primary delete operation */ |
| 12079 | 12242 | |
| 12080 | | -SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, |
| 12081 | | - const void *pData, int nData, |
| 12082 | | - int nZero, int bias, int seekResult); |
| 12243 | +/* An instance of the BtreePayload object describes the content of a single |
| 12244 | +** entry in either an index or table btree. |
| 12245 | +** |
| 12246 | +** Index btrees (used for indexes and also WITHOUT ROWID tables) contain |
| 12247 | +** an arbitrary key and no data. These btrees have pKey,nKey set to their |
| 12248 | +** key and pData,nData,nZero set to zero. |
| 12249 | +** |
| 12250 | +** Table btrees (used for rowid tables) contain an integer rowid used as |
| 12251 | +** the key and passed in the nKey field. The pKey field is zero. |
| 12252 | +** pData,nData hold the content of the new entry. nZero extra zero bytes |
| 12253 | +** are appended to the end of the content when constructing the entry. |
| 12254 | +** |
| 12255 | +** This object is used to pass information into sqlite3BtreeInsert(). The |
| 12256 | +** same information used to be passed as five separate parameters. But placing |
| 12257 | +** the information into this object helps to keep the interface more |
| 12258 | +** organized and understandable, and it also helps the resulting code to |
| 12259 | +** run a little faster by using fewer registers for parameter passing. |
| 12260 | +*/ |
| 12261 | +struct BtreePayload { |
| 12262 | + const void *pKey; /* Key content for indexes. NULL for tables */ |
| 12263 | + sqlite3_int64 nKey; /* Size of pKey for indexes. PRIMARY KEY for tabs */ |
| 12264 | + const void *pData; /* Data for tables. NULL for indexes */ |
| 12265 | + int nData; /* Size of pData. 0 if none. */ |
| 12266 | + int nZero; /* Extra zero data appended after pData,nData */ |
| 12267 | +}; |
| 12268 | + |
| 12269 | +SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload, |
| 12270 | + int bias, int seekResult); |
| 12083 | 12271 | SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes); |
| 12084 | 12272 | SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes); |
| 12085 | 12273 | SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes); |
| 12086 | 12274 | SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*); |
| 12087 | 12275 | SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes); |
| 12088 | | -SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); |
| 12276 | +SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); |
| 12089 | 12277 | SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); |
| 12090 | | -SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt); |
| 12091 | | -SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt); |
| 12092 | | -SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); |
| 12278 | +SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); |
| 12279 | +SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); |
| 12093 | 12280 | SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); |
| 12094 | 12281 | |
| 12095 | 12282 | SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); |
| 12096 | 12283 | SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); |
| 12097 | 12284 | |
| | @@ -12128,15 +12315,17 @@ |
| 12128 | 12315 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 12129 | 12316 | SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*); |
| 12130 | 12317 | SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*); |
| 12131 | 12318 | SQLITE_PRIVATE int sqlite3BtreeSharable(Btree*); |
| 12132 | 12319 | SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*); |
| 12320 | +SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree*); |
| 12133 | 12321 | #else |
| 12134 | 12322 | # define sqlite3BtreeEnter(X) |
| 12135 | 12323 | # define sqlite3BtreeEnterAll(X) |
| 12136 | 12324 | # define sqlite3BtreeSharable(X) 0 |
| 12137 | 12325 | # define sqlite3BtreeEnterCursor(X) |
| 12326 | +# define sqlite3BtreeConnectionCount(X) 1 |
| 12138 | 12327 | #endif |
| 12139 | 12328 | |
| 12140 | 12329 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE |
| 12141 | 12330 | SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*); |
| 12142 | 12331 | SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*); |
| | @@ -12157,11 +12346,11 @@ |
| 12157 | 12346 | # define sqlite3BtreeHoldsAllMutexes(X) 1 |
| 12158 | 12347 | # define sqlite3SchemaMutexHeld(X,Y,Z) 1 |
| 12159 | 12348 | #endif |
| 12160 | 12349 | |
| 12161 | 12350 | |
| 12162 | | -#endif /* _BTREE_H_ */ |
| 12351 | +#endif /* SQLITE_BTREE_H */ |
| 12163 | 12352 | |
| 12164 | 12353 | /************** End of btree.h ***********************************************/ |
| 12165 | 12354 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 12166 | 12355 | /************** Include vdbe.h in the middle of sqliteInt.h ******************/ |
| 12167 | 12356 | /************** Begin file vdbe.h ********************************************/ |
| | @@ -12180,12 +12369,12 @@ |
| 12180 | 12369 | ** |
| 12181 | 12370 | ** This header defines the interface to the virtual database engine |
| 12182 | 12371 | ** or VDBE. The VDBE implements an abstract machine that runs a |
| 12183 | 12372 | ** simple program to access and modify the underlying database. |
| 12184 | 12373 | */ |
| 12185 | | -#ifndef _SQLITE_VDBE_H_ |
| 12186 | | -#define _SQLITE_VDBE_H_ |
| 12374 | +#ifndef SQLITE_VDBE_H |
| 12375 | +#define SQLITE_VDBE_H |
| 12187 | 12376 | /* #include <stdio.h> */ |
| 12188 | 12377 | |
| 12189 | 12378 | /* |
| 12190 | 12379 | ** A single VDBE is an opaque structure named "Vdbe". Only routines |
| 12191 | 12380 | ** in the source file sqliteVdbe.c are allowed to see the insides |
| | @@ -12366,21 +12555,21 @@ |
| 12366 | 12555 | #define OP_Or 27 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 12367 | 12556 | #define OP_And 28 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 12368 | 12557 | #define OP_NoConflict 29 /* synopsis: key=r[P3@P4] */ |
| 12369 | 12558 | #define OP_NotFound 30 /* synopsis: key=r[P3@P4] */ |
| 12370 | 12559 | #define OP_Found 31 /* synopsis: key=r[P3@P4] */ |
| 12371 | | -#define OP_NotExists 32 /* synopsis: intkey=r[P3] */ |
| 12372 | | -#define OP_Last 33 |
| 12560 | +#define OP_SeekRowid 32 /* synopsis: intkey=r[P3] */ |
| 12561 | +#define OP_NotExists 33 /* synopsis: intkey=r[P3] */ |
| 12373 | 12562 | #define OP_IsNull 34 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 12374 | 12563 | #define OP_NotNull 35 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 12375 | 12564 | #define OP_Ne 36 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */ |
| 12376 | 12565 | #define OP_Eq 37 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */ |
| 12377 | 12566 | #define OP_Gt 38 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */ |
| 12378 | 12567 | #define OP_Le 39 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */ |
| 12379 | 12568 | #define OP_Lt 40 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */ |
| 12380 | 12569 | #define OP_Ge 41 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */ |
| 12381 | | -#define OP_SorterSort 42 |
| 12570 | +#define OP_Last 42 |
| 12382 | 12571 | #define OP_BitAnd 43 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 12383 | 12572 | #define OP_BitOr 44 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 12384 | 12573 | #define OP_ShiftLeft 45 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 12385 | 12574 | #define OP_ShiftRight 46 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 12386 | 12575 | #define OP_Add 47 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| | @@ -12387,118 +12576,119 @@ |
| 12387 | 12576 | #define OP_Subtract 48 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 12388 | 12577 | #define OP_Multiply 49 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 12389 | 12578 | #define OP_Divide 50 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 12390 | 12579 | #define OP_Remainder 51 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 12391 | 12580 | #define OP_Concat 52 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 12392 | | -#define OP_Sort 53 |
| 12581 | +#define OP_SorterSort 53 |
| 12393 | 12582 | #define OP_BitNot 54 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 12394 | | -#define OP_Rewind 55 |
| 12395 | | -#define OP_IdxLE 56 /* synopsis: key=r[P3@P4] */ |
| 12396 | | -#define OP_IdxGT 57 /* synopsis: key=r[P3@P4] */ |
| 12397 | | -#define OP_IdxLT 58 /* synopsis: key=r[P3@P4] */ |
| 12398 | | -#define OP_IdxGE 59 /* synopsis: key=r[P3@P4] */ |
| 12399 | | -#define OP_RowSetRead 60 /* synopsis: r[P3]=rowset(P1) */ |
| 12400 | | -#define OP_RowSetTest 61 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 12401 | | -#define OP_Program 62 |
| 12402 | | -#define OP_FkIfZero 63 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 12403 | | -#define OP_IfPos 64 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 12404 | | -#define OP_IfNotZero 65 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */ |
| 12405 | | -#define OP_DecrJumpZero 66 /* synopsis: if (--r[P1])==0 goto P2 */ |
| 12406 | | -#define OP_IncrVacuum 67 |
| 12407 | | -#define OP_VNext 68 |
| 12408 | | -#define OP_Init 69 /* synopsis: Start at P2 */ |
| 12409 | | -#define OP_Return 70 |
| 12410 | | -#define OP_EndCoroutine 71 |
| 12411 | | -#define OP_HaltIfNull 72 /* synopsis: if r[P3]=null halt */ |
| 12412 | | -#define OP_Halt 73 |
| 12413 | | -#define OP_Integer 74 /* synopsis: r[P2]=P1 */ |
| 12414 | | -#define OP_Int64 75 /* synopsis: r[P2]=P4 */ |
| 12415 | | -#define OP_String 76 /* synopsis: r[P2]='P4' (len=P1) */ |
| 12416 | | -#define OP_Null 77 /* synopsis: r[P2..P3]=NULL */ |
| 12417 | | -#define OP_SoftNull 78 /* synopsis: r[P1]=NULL */ |
| 12418 | | -#define OP_Blob 79 /* synopsis: r[P2]=P4 (len=P1) */ |
| 12419 | | -#define OP_Variable 80 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 12420 | | -#define OP_Move 81 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 12421 | | -#define OP_Copy 82 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 12422 | | -#define OP_SCopy 83 /* synopsis: r[P2]=r[P1] */ |
| 12423 | | -#define OP_IntCopy 84 /* synopsis: r[P2]=r[P1] */ |
| 12424 | | -#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */ |
| 12425 | | -#define OP_CollSeq 86 |
| 12426 | | -#define OP_Function0 87 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12427 | | -#define OP_Function 88 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12428 | | -#define OP_AddImm 89 /* synopsis: r[P1]=r[P1]+P2 */ |
| 12429 | | -#define OP_RealAffinity 90 |
| 12430 | | -#define OP_Cast 91 /* synopsis: affinity(r[P1]) */ |
| 12431 | | -#define OP_Permutation 92 |
| 12432 | | -#define OP_Compare 93 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 12433 | | -#define OP_Column 94 /* synopsis: r[P3]=PX */ |
| 12434 | | -#define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */ |
| 12435 | | -#define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 12583 | +#define OP_Sort 55 |
| 12584 | +#define OP_Rewind 56 |
| 12585 | +#define OP_IdxLE 57 /* synopsis: key=r[P3@P4] */ |
| 12586 | +#define OP_IdxGT 58 /* synopsis: key=r[P3@P4] */ |
| 12587 | +#define OP_IdxLT 59 /* synopsis: key=r[P3@P4] */ |
| 12588 | +#define OP_IdxGE 60 /* synopsis: key=r[P3@P4] */ |
| 12589 | +#define OP_RowSetRead 61 /* synopsis: r[P3]=rowset(P1) */ |
| 12590 | +#define OP_RowSetTest 62 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 12591 | +#define OP_Program 63 |
| 12592 | +#define OP_FkIfZero 64 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 12593 | +#define OP_IfPos 65 /* synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 12594 | +#define OP_IfNotZero 66 /* synopsis: if r[P1]!=0 then r[P1]-=P3, goto P2 */ |
| 12595 | +#define OP_DecrJumpZero 67 /* synopsis: if (--r[P1])==0 goto P2 */ |
| 12596 | +#define OP_IncrVacuum 68 |
| 12597 | +#define OP_VNext 69 |
| 12598 | +#define OP_Init 70 /* synopsis: Start at P2 */ |
| 12599 | +#define OP_Return 71 |
| 12600 | +#define OP_EndCoroutine 72 |
| 12601 | +#define OP_HaltIfNull 73 /* synopsis: if r[P3]=null halt */ |
| 12602 | +#define OP_Halt 74 |
| 12603 | +#define OP_Integer 75 /* synopsis: r[P2]=P1 */ |
| 12604 | +#define OP_Int64 76 /* synopsis: r[P2]=P4 */ |
| 12605 | +#define OP_String 77 /* synopsis: r[P2]='P4' (len=P1) */ |
| 12606 | +#define OP_Null 78 /* synopsis: r[P2..P3]=NULL */ |
| 12607 | +#define OP_SoftNull 79 /* synopsis: r[P1]=NULL */ |
| 12608 | +#define OP_Blob 80 /* synopsis: r[P2]=P4 (len=P1) */ |
| 12609 | +#define OP_Variable 81 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 12610 | +#define OP_Move 82 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 12611 | +#define OP_Copy 83 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 12612 | +#define OP_SCopy 84 /* synopsis: r[P2]=r[P1] */ |
| 12613 | +#define OP_IntCopy 85 /* synopsis: r[P2]=r[P1] */ |
| 12614 | +#define OP_ResultRow 86 /* synopsis: output=r[P1@P2] */ |
| 12615 | +#define OP_CollSeq 87 |
| 12616 | +#define OP_Function0 88 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12617 | +#define OP_Function 89 /* synopsis: r[P3]=func(r[P2@P5]) */ |
| 12618 | +#define OP_AddImm 90 /* synopsis: r[P1]=r[P1]+P2 */ |
| 12619 | +#define OP_RealAffinity 91 |
| 12620 | +#define OP_Cast 92 /* synopsis: affinity(r[P1]) */ |
| 12621 | +#define OP_Permutation 93 |
| 12622 | +#define OP_Compare 94 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 12623 | +#define OP_Column 95 /* synopsis: r[P3]=PX */ |
| 12624 | +#define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */ |
| 12436 | 12625 | #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 12437 | | -#define OP_Count 98 /* synopsis: r[P2]=count() */ |
| 12438 | | -#define OP_ReadCookie 99 |
| 12439 | | -#define OP_SetCookie 100 |
| 12440 | | -#define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */ |
| 12441 | | -#define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */ |
| 12442 | | -#define OP_OpenWrite 103 /* synopsis: root=P2 iDb=P3 */ |
| 12443 | | -#define OP_OpenAutoindex 104 /* synopsis: nColumn=P2 */ |
| 12444 | | -#define OP_OpenEphemeral 105 /* synopsis: nColumn=P2 */ |
| 12445 | | -#define OP_SorterOpen 106 |
| 12446 | | -#define OP_SequenceTest 107 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 12447 | | -#define OP_OpenPseudo 108 /* synopsis: P3 columns in r[P2] */ |
| 12448 | | -#define OP_Close 109 |
| 12449 | | -#define OP_ColumnsUsed 110 |
| 12450 | | -#define OP_Sequence 111 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 12451 | | -#define OP_NewRowid 112 /* synopsis: r[P2]=rowid */ |
| 12452 | | -#define OP_Insert 113 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 12453 | | -#define OP_InsertInt 114 /* synopsis: intkey=P3 data=r[P2] */ |
| 12454 | | -#define OP_Delete 115 |
| 12455 | | -#define OP_ResetCount 116 |
| 12456 | | -#define OP_SorterCompare 117 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 12457 | | -#define OP_SorterData 118 /* synopsis: r[P2]=data */ |
| 12458 | | -#define OP_RowKey 119 /* synopsis: r[P2]=key */ |
| 12459 | | -#define OP_RowData 120 /* synopsis: r[P2]=data */ |
| 12460 | | -#define OP_Rowid 121 /* synopsis: r[P2]=rowid */ |
| 12461 | | -#define OP_NullRow 122 |
| 12462 | | -#define OP_SorterInsert 123 |
| 12463 | | -#define OP_IdxInsert 124 /* synopsis: key=r[P2] */ |
| 12464 | | -#define OP_IdxDelete 125 /* synopsis: key=r[P2@P3] */ |
| 12465 | | -#define OP_Seek 126 /* synopsis: Move P3 to P1.rowid */ |
| 12466 | | -#define OP_IdxRowid 127 /* synopsis: r[P2]=rowid */ |
| 12467 | | -#define OP_Destroy 128 |
| 12468 | | -#define OP_Clear 129 |
| 12469 | | -#define OP_ResetSorter 130 |
| 12470 | | -#define OP_CreateIndex 131 /* synopsis: r[P2]=root iDb=P1 */ |
| 12471 | | -#define OP_CreateTable 132 /* synopsis: r[P2]=root iDb=P1 */ |
| 12626 | +#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 12627 | +#define OP_Count 99 /* synopsis: r[P2]=count() */ |
| 12628 | +#define OP_ReadCookie 100 |
| 12629 | +#define OP_SetCookie 101 |
| 12630 | +#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */ |
| 12631 | +#define OP_OpenRead 103 /* synopsis: root=P2 iDb=P3 */ |
| 12632 | +#define OP_OpenWrite 104 /* synopsis: root=P2 iDb=P3 */ |
| 12633 | +#define OP_OpenAutoindex 105 /* synopsis: nColumn=P2 */ |
| 12634 | +#define OP_OpenEphemeral 106 /* synopsis: nColumn=P2 */ |
| 12635 | +#define OP_SorterOpen 107 |
| 12636 | +#define OP_SequenceTest 108 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 12637 | +#define OP_OpenPseudo 109 /* synopsis: P3 columns in r[P2] */ |
| 12638 | +#define OP_Close 110 |
| 12639 | +#define OP_ColumnsUsed 111 |
| 12640 | +#define OP_Sequence 112 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 12641 | +#define OP_NewRowid 113 /* synopsis: r[P2]=rowid */ |
| 12642 | +#define OP_Insert 114 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 12643 | +#define OP_InsertInt 115 /* synopsis: intkey=P3 data=r[P2] */ |
| 12644 | +#define OP_Delete 116 |
| 12645 | +#define OP_ResetCount 117 |
| 12646 | +#define OP_SorterCompare 118 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 12647 | +#define OP_SorterData 119 /* synopsis: r[P2]=data */ |
| 12648 | +#define OP_RowKey 120 /* synopsis: r[P2]=key */ |
| 12649 | +#define OP_RowData 121 /* synopsis: r[P2]=data */ |
| 12650 | +#define OP_Rowid 122 /* synopsis: r[P2]=rowid */ |
| 12651 | +#define OP_NullRow 123 |
| 12652 | +#define OP_SorterInsert 124 |
| 12653 | +#define OP_IdxInsert 125 /* synopsis: key=r[P2] */ |
| 12654 | +#define OP_IdxDelete 126 /* synopsis: key=r[P2@P3] */ |
| 12655 | +#define OP_Seek 127 /* synopsis: Move P3 to P1.rowid */ |
| 12656 | +#define OP_IdxRowid 128 /* synopsis: r[P2]=rowid */ |
| 12657 | +#define OP_Destroy 129 |
| 12658 | +#define OP_Clear 130 |
| 12659 | +#define OP_ResetSorter 131 |
| 12660 | +#define OP_CreateIndex 132 /* synopsis: r[P2]=root iDb=P1 */ |
| 12472 | 12661 | #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 12473 | | -#define OP_ParseSchema 134 |
| 12474 | | -#define OP_LoadAnalysis 135 |
| 12475 | | -#define OP_DropTable 136 |
| 12476 | | -#define OP_DropIndex 137 |
| 12477 | | -#define OP_DropTrigger 138 |
| 12478 | | -#define OP_IntegrityCk 139 |
| 12479 | | -#define OP_RowSetAdd 140 /* synopsis: rowset(P1)=r[P2] */ |
| 12480 | | -#define OP_Param 141 |
| 12481 | | -#define OP_FkCounter 142 /* synopsis: fkctr[P1]+=P2 */ |
| 12482 | | -#define OP_MemMax 143 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 12483 | | -#define OP_OffsetLimit 144 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 12484 | | -#define OP_AggStep0 145 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12485 | | -#define OP_AggStep 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12486 | | -#define OP_AggFinal 147 /* synopsis: accum=r[P1] N=P2 */ |
| 12487 | | -#define OP_Expire 148 |
| 12488 | | -#define OP_TableLock 149 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 12489 | | -#define OP_VBegin 150 |
| 12490 | | -#define OP_VCreate 151 |
| 12491 | | -#define OP_VDestroy 152 |
| 12492 | | -#define OP_VOpen 153 |
| 12493 | | -#define OP_VColumn 154 /* synopsis: r[P3]=vcolumn(P2) */ |
| 12494 | | -#define OP_VRename 155 |
| 12495 | | -#define OP_Pagecount 156 |
| 12496 | | -#define OP_MaxPgcnt 157 |
| 12497 | | -#define OP_CursorHint 158 |
| 12498 | | -#define OP_Noop 159 |
| 12499 | | -#define OP_Explain 160 |
| 12662 | +#define OP_CreateTable 134 /* synopsis: r[P2]=root iDb=P1 */ |
| 12663 | +#define OP_ParseSchema 135 |
| 12664 | +#define OP_LoadAnalysis 136 |
| 12665 | +#define OP_DropTable 137 |
| 12666 | +#define OP_DropIndex 138 |
| 12667 | +#define OP_DropTrigger 139 |
| 12668 | +#define OP_IntegrityCk 140 |
| 12669 | +#define OP_RowSetAdd 141 /* synopsis: rowset(P1)=r[P2] */ |
| 12670 | +#define OP_Param 142 |
| 12671 | +#define OP_FkCounter 143 /* synopsis: fkctr[P1]+=P2 */ |
| 12672 | +#define OP_MemMax 144 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 12673 | +#define OP_OffsetLimit 145 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 12674 | +#define OP_AggStep0 146 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12675 | +#define OP_AggStep 147 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 12676 | +#define OP_AggFinal 148 /* synopsis: accum=r[P1] N=P2 */ |
| 12677 | +#define OP_Expire 149 |
| 12678 | +#define OP_TableLock 150 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 12679 | +#define OP_VBegin 151 |
| 12680 | +#define OP_VCreate 152 |
| 12681 | +#define OP_VDestroy 153 |
| 12682 | +#define OP_VOpen 154 |
| 12683 | +#define OP_VColumn 155 /* synopsis: r[P3]=vcolumn(P2) */ |
| 12684 | +#define OP_VRename 156 |
| 12685 | +#define OP_Pagecount 157 |
| 12686 | +#define OP_MaxPgcnt 158 |
| 12687 | +#define OP_CursorHint 159 |
| 12688 | +#define OP_Noop 160 |
| 12689 | +#define OP_Explain 161 |
| 12500 | 12690 | |
| 12501 | 12691 | /* Properties such as "out2" or "jump" that are specified in |
| 12502 | 12692 | ** comments following the "case" for each opcode in the vdbe.c |
| 12503 | 12693 | ** are encoded into bitvectors as follows: |
| 12504 | 12694 | */ |
| | @@ -12511,35 +12701,35 @@ |
| 12511 | 12701 | #define OPFLG_INITIALIZER {\ |
| 12512 | 12702 | /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 12513 | 12703 | /* 8 */ 0x00, 0x10, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01,\ |
| 12514 | 12704 | /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0x03, 0x03, 0x09,\ |
| 12515 | 12705 | /* 24 */ 0x09, 0x09, 0x09, 0x26, 0x26, 0x09, 0x09, 0x09,\ |
| 12516 | | -/* 32 */ 0x09, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 12706 | +/* 32 */ 0x09, 0x09, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 12517 | 12707 | /* 40 */ 0x0b, 0x0b, 0x01, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 12518 | 12708 | /* 48 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x01, 0x12, 0x01,\ |
| 12519 | | -/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01, 0x01,\ |
| 12520 | | -/* 64 */ 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02, 0x02,\ |
| 12521 | | -/* 72 */ 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\ |
| 12522 | | -/* 80 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\ |
| 12523 | | -/* 88 */ 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,\ |
| 12524 | | -/* 96 */ 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 12525 | | -/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\ |
| 12526 | | -/* 112 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12527 | | -/* 120 */ 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00, 0x10,\ |
| 12528 | | -/* 128 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\ |
| 12529 | | -/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04,\ |
| 12530 | | -/* 144 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12531 | | -/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 12532 | | -/* 160 */ 0x00,} |
| 12709 | +/* 56 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x23, 0x0b, 0x01,\ |
| 12710 | +/* 64 */ 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01, 0x02,\ |
| 12711 | +/* 72 */ 0x02, 0x08, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00,\ |
| 12712 | +/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 12713 | +/* 88 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\ |
| 12714 | +/* 96 */ 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00,\ |
| 12715 | +/* 104 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12716 | +/* 112 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12717 | +/* 120 */ 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00,\ |
| 12718 | +/* 128 */ 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00,\ |
| 12719 | +/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00,\ |
| 12720 | +/* 144 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 12721 | +/* 152 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\ |
| 12722 | +/* 160 */ 0x00, 0x00,} |
| 12533 | 12723 | |
| 12534 | 12724 | /* The sqlite3P2Values() routine is able to run faster if it knows |
| 12535 | 12725 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 12536 | 12726 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 12537 | 12727 | ** generated this include file strives to group all JUMP opcodes |
| 12538 | 12728 | ** together near the beginning of the list. |
| 12539 | 12729 | */ |
| 12540 | | -#define SQLITE_MX_JUMP_OPCODE 69 /* Maximum JUMP opcode */ |
| 12730 | +#define SQLITE_MX_JUMP_OPCODE 70 /* Maximum JUMP opcode */ |
| 12541 | 12731 | |
| 12542 | 12732 | /************** End of opcodes.h *********************************************/ |
| 12543 | 12733 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 12544 | 12734 | |
| 12545 | 12735 | /* |
| | @@ -12682,11 +12872,11 @@ |
| 12682 | 12872 | SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*); |
| 12683 | 12873 | #else |
| 12684 | 12874 | # define sqlite3VdbeScanStatus(a,b,c,d,e) |
| 12685 | 12875 | #endif |
| 12686 | 12876 | |
| 12687 | | -#endif |
| 12877 | +#endif /* SQLITE_VDBE_H */ |
| 12688 | 12878 | |
| 12689 | 12879 | /************** End of vdbe.h ************************************************/ |
| 12690 | 12880 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 12691 | 12881 | /************** Include pager.h in the middle of sqliteInt.h *****************/ |
| 12692 | 12882 | /************** Begin file pager.h *******************************************/ |
| | @@ -12704,12 +12894,12 @@ |
| 12704 | 12894 | ** This header file defines the interface that the sqlite page cache |
| 12705 | 12895 | ** subsystem. The page cache subsystem reads and writes a file a page |
| 12706 | 12896 | ** at a time and provides a journal for rollback. |
| 12707 | 12897 | */ |
| 12708 | 12898 | |
| 12709 | | -#ifndef _PAGER_H_ |
| 12710 | | -#define _PAGER_H_ |
| 12899 | +#ifndef SQLITE_PAGER_H |
| 12900 | +#define SQLITE_PAGER_H |
| 12711 | 12901 | |
| 12712 | 12902 | /* |
| 12713 | 12903 | ** Default maximum size for persistent journal files. A negative |
| 12714 | 12904 | ** value means no limit. This value may be overridden using the |
| 12715 | 12905 | ** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". |
| | @@ -12893,11 +13083,11 @@ |
| 12893 | 13083 | SQLITE_PRIVATE sqlite3_file *sqlite3PagerJrnlFile(Pager*); |
| 12894 | 13084 | SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); |
| 12895 | 13085 | SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); |
| 12896 | 13086 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); |
| 12897 | 13087 | SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *, int, int, int *); |
| 12898 | | -SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *); |
| 13088 | +SQLITE_PRIVATE void sqlite3PagerClearCache(Pager*); |
| 12899 | 13089 | SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *); |
| 12900 | 13090 | |
| 12901 | 13091 | /* Functions used to truncate the database file. */ |
| 12902 | 13092 | SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); |
| 12903 | 13093 | |
| | @@ -12920,11 +13110,11 @@ |
| 12920 | 13110 | #else |
| 12921 | 13111 | # define disable_simulated_io_errors() |
| 12922 | 13112 | # define enable_simulated_io_errors() |
| 12923 | 13113 | #endif |
| 12924 | 13114 | |
| 12925 | | -#endif /* _PAGER_H_ */ |
| 13115 | +#endif /* SQLITE_PAGER_H */ |
| 12926 | 13116 | |
| 12927 | 13117 | /************** End of pager.h ***********************************************/ |
| 12928 | 13118 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 12929 | 13119 | /************** Include pcache.h in the middle of sqliteInt.h ****************/ |
| 12930 | 13120 | /************** Begin file pcache.h ******************************************/ |
| | @@ -13158,12 +13348,12 @@ |
| 13158 | 13348 | ****************************************************************************** |
| 13159 | 13349 | ** |
| 13160 | 13350 | ** This file contains pre-processor directives related to operating system |
| 13161 | 13351 | ** detection and/or setup. |
| 13162 | 13352 | */ |
| 13163 | | -#ifndef _OS_SETUP_H_ |
| 13164 | | -#define _OS_SETUP_H_ |
| 13353 | +#ifndef SQLITE_OS_SETUP_H |
| 13354 | +#define SQLITE_OS_SETUP_H |
| 13165 | 13355 | |
| 13166 | 13356 | /* |
| 13167 | 13357 | ** Figure out if we are dealing with Unix, Windows, or some other operating |
| 13168 | 13358 | ** system. |
| 13169 | 13359 | ** |
| | @@ -13199,11 +13389,11 @@ |
| 13199 | 13389 | # ifndef SQLITE_OS_WIN |
| 13200 | 13390 | # define SQLITE_OS_WIN 0 |
| 13201 | 13391 | # endif |
| 13202 | 13392 | #endif |
| 13203 | 13393 | |
| 13204 | | -#endif /* _OS_SETUP_H_ */ |
| 13394 | +#endif /* SQLITE_OS_SETUP_H */ |
| 13205 | 13395 | |
| 13206 | 13396 | /************** End of os_setup.h ********************************************/ |
| 13207 | 13397 | /************** Continuing where we left off in os.h *************************/ |
| 13208 | 13398 | |
| 13209 | 13399 | /* If the SET_FULLSYNC macro is not defined above, then make it |
| | @@ -13656,10 +13846,19 @@ |
| 13656 | 13846 | #else |
| 13657 | 13847 | typedef int (*sqlite3_xauth)(void*,int,const char*,const char*,const char*, |
| 13658 | 13848 | const char*); |
| 13659 | 13849 | #endif |
| 13660 | 13850 | |
| 13851 | +#ifndef SQLITE_OMIT_DEPRECATED |
| 13852 | +/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing |
| 13853 | +** in the style of sqlite3_trace() |
| 13854 | +*/ |
| 13855 | +#define SQLITE_TRACE_LEGACY 0x80 |
| 13856 | +#else |
| 13857 | +#define SQLITE_TRACE_LEGACY 0 |
| 13858 | +#endif /* SQLITE_OMIT_DEPRECATED */ |
| 13859 | + |
| 13661 | 13860 | |
| 13662 | 13861 | /* |
| 13663 | 13862 | ** Each database connection is an instance of the following structure. |
| 13664 | 13863 | */ |
| 13665 | 13864 | struct sqlite3 { |
| | @@ -13685,10 +13884,11 @@ |
| 13685 | 13884 | u8 dfltLockMode; /* Default locking-mode for attached dbs */ |
| 13686 | 13885 | signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ |
| 13687 | 13886 | u8 suppressErr; /* Do not issue error messages if true */ |
| 13688 | 13887 | u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */ |
| 13689 | 13888 | u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ |
| 13889 | + u8 mTrace; /* zero or more SQLITE_TRACE flags */ |
| 13690 | 13890 | int nextPagesize; /* Pagesize after VACUUM if >0 */ |
| 13691 | 13891 | u32 magic; /* Magic number for detect library misuse */ |
| 13692 | 13892 | int nChange; /* Value returned by sqlite3_changes() */ |
| 13693 | 13893 | int nTotalChange; /* Value returned by sqlite3_total_changes() */ |
| 13694 | 13894 | int aLimit[SQLITE_N_LIMIT]; /* Limits */ |
| | @@ -13705,11 +13905,11 @@ |
| 13705 | 13905 | int nVdbeWrite; /* Number of active VDBEs that read and write */ |
| 13706 | 13906 | int nVdbeExec; /* Number of nested calls to VdbeExec() */ |
| 13707 | 13907 | int nVDestroy; /* Number of active OP_VDestroy operations */ |
| 13708 | 13908 | int nExtension; /* Number of loaded extensions */ |
| 13709 | 13909 | void **aExtension; /* Array of shared library handles */ |
| 13710 | | - void (*xTrace)(void*,const char*); /* Trace function */ |
| 13910 | + int (*xTrace)(u32,void*,void*,void*); /* Trace function */ |
| 13711 | 13911 | void *pTraceArg; /* Argument to the trace function */ |
| 13712 | 13912 | void (*xProfile)(void*,const char*,u64); /* Profiling function */ |
| 13713 | 13913 | void *pProfileArg; /* Argument to profile function */ |
| 13714 | 13914 | void *pCommitArg; /* Argument to xCommitCallback() */ |
| 13715 | 13915 | int (*xCommitCallback)(void*); /* Invoked at every commit. */ |
| | @@ -14900,11 +15100,11 @@ |
| 14900 | 15100 | Select *pSelect; /* A SELECT statement used in place of a table name */ |
| 14901 | 15101 | int addrFillSub; /* Address of subroutine to manifest a subquery */ |
| 14902 | 15102 | int regReturn; /* Register holding return address of addrFillSub */ |
| 14903 | 15103 | int regResult; /* Registers holding results of a co-routine */ |
| 14904 | 15104 | struct { |
| 14905 | | - u8 jointype; /* Type of join between this able and the previous */ |
| 15105 | + u8 jointype; /* Type of join between this table and the previous */ |
| 14906 | 15106 | unsigned notIndexed :1; /* True if there is a NOT INDEXED clause */ |
| 14907 | 15107 | unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */ |
| 14908 | 15108 | unsigned isTabFunc :1; /* True if table-valued-function syntax */ |
| 14909 | 15109 | unsigned isCorrelated :1; /* True if sub-query is correlated */ |
| 14910 | 15110 | unsigned viaCoroutine :1; /* Implemented as a co-routine */ |
| | @@ -14946,23 +15146,24 @@ |
| 14946 | 15146 | */ |
| 14947 | 15147 | #define WHERE_ORDERBY_NORMAL 0x0000 /* No-op */ |
| 14948 | 15148 | #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */ |
| 14949 | 15149 | #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */ |
| 14950 | 15150 | #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
| 14951 | | -#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
| 14952 | | -#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */ |
| 14953 | | -#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */ |
| 14954 | | -#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */ |
| 14955 | | -#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */ |
| 14956 | | -#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */ |
| 14957 | | -#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */ |
| 14958 | | -#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */ |
| 14959 | | -#define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */ |
| 14960 | | -#define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */ |
| 14961 | | -#define WHERE_ONEPASS_MULTIROW 0x2000 /* ONEPASS is ok with multiple rows */ |
| 14962 | | -#define WHERE_USE_LIMIT 0x4000 /* There is a constant LIMIT clause */ |
| 14963 | | -#define WHERE_SEEK_TABLE 0x8000 /* Do not defer seeks on main table */ |
| 15151 | +#define WHERE_ONEPASS_MULTIROW 0x0008 /* ONEPASS is ok with multiple rows */ |
| 15152 | +#define WHERE_DUPLICATES_OK 0x0010 /* Ok to return a row more than once */ |
| 15153 | +#define WHERE_OR_SUBCLAUSE 0x0020 /* Processing a sub-WHERE as part of |
| 15154 | + ** the OR optimization */ |
| 15155 | +#define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */ |
| 15156 | +#define WHERE_DISTINCTBY 0x0080 /* pOrderby is really a DISTINCT clause */ |
| 15157 | +#define WHERE_WANT_DISTINCT 0x0100 /* All output needs to be distinct */ |
| 15158 | +#define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */ |
| 15159 | +#define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */ |
| 15160 | +#define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */ |
| 15161 | + /* 0x1000 not currently used */ |
| 15162 | + /* 0x2000 not currently used */ |
| 15163 | +#define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */ |
| 15164 | + /* 0x8000 not currently used */ |
| 14964 | 15165 | |
| 14965 | 15166 | /* Allowed return values from sqlite3WhereIsDistinct() |
| 14966 | 15167 | */ |
| 14967 | 15168 | #define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */ |
| 14968 | 15169 | #define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */ |
| | @@ -15661,10 +15862,11 @@ |
| 15661 | 15862 | int iCur; /* A cursor number */ |
| 15662 | 15863 | SrcList *pSrcList; /* FROM clause */ |
| 15663 | 15864 | struct SrcCount *pSrcCount; /* Counting column references */ |
| 15664 | 15865 | struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 15665 | 15866 | int *aiCol; /* array of column indexes */ |
| 15867 | + struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 15666 | 15868 | } u; |
| 15667 | 15869 | }; |
| 15668 | 15870 | |
| 15669 | 15871 | /* Forward declarations */ |
| 15670 | 15872 | SQLITE_PRIVATE int sqlite3WalkExpr(Walker*, Expr*); |
| | @@ -15844,15 +16046,19 @@ |
| 15844 | 16046 | # define sqlite3StackAllocRaw(D,N) sqlite3DbMallocRaw(D,N) |
| 15845 | 16047 | # define sqlite3StackAllocZero(D,N) sqlite3DbMallocZero(D,N) |
| 15846 | 16048 | # define sqlite3StackFree(D,P) sqlite3DbFree(D,P) |
| 15847 | 16049 | #endif |
| 15848 | 16050 | |
| 15849 | | -#ifdef SQLITE_ENABLE_MEMSYS3 |
| 15850 | | -SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); |
| 15851 | | -#endif |
| 16051 | +/* Do not allow both MEMSYS5 and MEMSYS3 to be defined together. If they |
| 16052 | +** are, disable MEMSYS3 |
| 16053 | +*/ |
| 15852 | 16054 | #ifdef SQLITE_ENABLE_MEMSYS5 |
| 15853 | 16055 | SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys5(void); |
| 16056 | +#undef SQLITE_ENABLE_MEMSYS3 |
| 16057 | +#endif |
| 16058 | +#ifdef SQLITE_ENABLE_MEMSYS3 |
| 16059 | +SQLITE_PRIVATE const sqlite3_mem_methods *sqlite3MemGetMemsys3(void); |
| 15854 | 16060 | #endif |
| 15855 | 16061 | |
| 15856 | 16062 | |
| 15857 | 16063 | #ifndef SQLITE_MUTEX_OMIT |
| 15858 | 16064 | SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void); |
| | @@ -16031,12 +16237,12 @@ |
| 16031 | 16237 | SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList*); |
| 16032 | 16238 | SQLITE_PRIVATE void sqlite3SrcListAssignCursors(Parse*, SrcList*); |
| 16033 | 16239 | SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3*, IdList*); |
| 16034 | 16240 | SQLITE_PRIVATE void sqlite3SrcListDelete(sqlite3*, SrcList*); |
| 16035 | 16241 | SQLITE_PRIVATE Index *sqlite3AllocateIndexObject(sqlite3*,i16,int,char**); |
| 16036 | | -SQLITE_PRIVATE Index *sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 16037 | | - Expr*, int, int); |
| 16242 | +SQLITE_PRIVATE void sqlite3CreateIndex(Parse*,Token*,Token*,SrcList*,ExprList*,int,Token*, |
| 16243 | + Expr*, int, int, u8); |
| 16038 | 16244 | SQLITE_PRIVATE void sqlite3DropIndex(Parse*, SrcList*, int); |
| 16039 | 16245 | SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*); |
| 16040 | 16246 | SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*, |
| 16041 | 16247 | Expr*,ExprList*,u32,Expr*,Expr*); |
| 16042 | 16248 | SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*); |
| | @@ -16051,10 +16257,11 @@ |
| 16051 | 16257 | SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int); |
| 16052 | 16258 | SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*); |
| 16053 | 16259 | SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*); |
| 16054 | 16260 | SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*); |
| 16055 | 16261 | SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo*); |
| 16262 | +SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo*); |
| 16056 | 16263 | SQLITE_PRIVATE int sqlite3WhereIsSorted(WhereInfo*); |
| 16057 | 16264 | SQLITE_PRIVATE int sqlite3WhereContinueLabel(WhereInfo*); |
| 16058 | 16265 | SQLITE_PRIVATE int sqlite3WhereBreakLabel(WhereInfo*); |
| 16059 | 16266 | SQLITE_PRIVATE int sqlite3WhereOkOnePass(WhereInfo*, int*); |
| 16060 | 16267 | #define ONEPASS_OFF 0 /* Use of ONEPASS not allowed */ |
| | @@ -16084,12 +16291,14 @@ |
| 16084 | 16291 | #define SQLITE_ECEL_REF 0x04 /* Use ExprList.u.x.iOrderByCol */ |
| 16085 | 16292 | SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse*, Expr*, int, int); |
| 16086 | 16293 | SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse*, Expr*, int, int); |
| 16087 | 16294 | SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse*, Expr*, int, int); |
| 16088 | 16295 | SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*); |
| 16089 | | -SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,int isView,const char*, const char*); |
| 16090 | | -SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,int isView,struct SrcList_item *); |
| 16296 | +#define LOCATE_VIEW 0x01 |
| 16297 | +#define LOCATE_NOERR 0x02 |
| 16298 | +SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*); |
| 16299 | +SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *); |
| 16091 | 16300 | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); |
| 16092 | 16301 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); |
| 16093 | 16302 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
| 16094 | 16303 | SQLITE_PRIVATE void sqlite3Vacuum(Parse*); |
| 16095 | 16304 | SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*); |
| | @@ -16097,10 +16306,11 @@ |
| 16097 | 16306 | SQLITE_PRIVATE int sqlite3ExprCompare(Expr*, Expr*, int); |
| 16098 | 16307 | SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int); |
| 16099 | 16308 | SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Expr*, Expr*, int); |
| 16100 | 16309 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 16101 | 16310 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 16311 | +SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); |
| 16102 | 16312 | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); |
| 16103 | 16313 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| 16104 | 16314 | #ifndef SQLITE_OMIT_BUILTIN_TEST |
| 16105 | 16315 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); |
| 16106 | 16316 | SQLITE_PRIVATE void sqlite3PrngRestoreState(void); |
| | @@ -16648,11 +16858,11 @@ |
| 16648 | 16858 | |
| 16649 | 16859 | #if defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST) |
| 16650 | 16860 | SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*); |
| 16651 | 16861 | #endif |
| 16652 | 16862 | |
| 16653 | | -#endif /* _SQLITEINT_H_ */ |
| 16863 | +#endif /* SQLITEINT_H */ |
| 16654 | 16864 | |
| 16655 | 16865 | /************** End of sqliteInt.h *******************************************/ |
| 16656 | 16866 | /************** Begin file global.c ******************************************/ |
| 16657 | 16867 | /* |
| 16658 | 16868 | ** 2008 June 13 |
| | @@ -16983,10 +17193,19 @@ |
| 16983 | 17193 | "CASE_SENSITIVE_LIKE", |
| 16984 | 17194 | #endif |
| 16985 | 17195 | #if SQLITE_CHECK_PAGES |
| 16986 | 17196 | "CHECK_PAGES", |
| 16987 | 17197 | #endif |
| 17198 | +#if defined(__clang__) && defined(__clang_major__) |
| 17199 | + "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "." |
| 17200 | + CTIMEOPT_VAL(__clang_minor__) "." |
| 17201 | + CTIMEOPT_VAL(__clang_patchlevel__), |
| 17202 | +#elif defined(_MSC_VER) |
| 17203 | + "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), |
| 17204 | +#elif defined(__GNUC__) && defined(__VERSION__) |
| 17205 | + "COMPILER=gcc-" __VERSION__, |
| 17206 | +#endif |
| 16988 | 17207 | #if SQLITE_COVERAGE_TEST |
| 16989 | 17208 | "COVERAGE_TEST", |
| 16990 | 17209 | #endif |
| 16991 | 17210 | #if SQLITE_DEBUG |
| 16992 | 17211 | "DEBUG", |
| | @@ -17002,11 +17221,11 @@ |
| 17002 | 17221 | #endif |
| 17003 | 17222 | #if SQLITE_DISABLE_LFS |
| 17004 | 17223 | "DISABLE_LFS", |
| 17005 | 17224 | #endif |
| 17006 | 17225 | #if SQLITE_ENABLE_8_3_NAMES |
| 17007 | | - "ENABLE_8_3_NAMES", |
| 17226 | + "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES), |
| 17008 | 17227 | #endif |
| 17009 | 17228 | #if SQLITE_ENABLE_API_ARMOR |
| 17010 | 17229 | "ENABLE_API_ARMOR", |
| 17011 | 17230 | #endif |
| 17012 | 17231 | #if SQLITE_ENABLE_ATOMIC_WRITE |
| | @@ -17416,12 +17635,12 @@ |
| 17416 | 17635 | ** VDBE. This information used to all be at the top of the single |
| 17417 | 17636 | ** source code file "vdbe.c". When that file became too big (over |
| 17418 | 17637 | ** 6000 lines long) it was split up into several smaller files and |
| 17419 | 17638 | ** this header information was factored out. |
| 17420 | 17639 | */ |
| 17421 | | -#ifndef _VDBEINT_H_ |
| 17422 | | -#define _VDBEINT_H_ |
| 17640 | +#ifndef SQLITE_VDBEINT_H |
| 17641 | +#define SQLITE_VDBEINT_H |
| 17423 | 17642 | |
| 17424 | 17643 | /* |
| 17425 | 17644 | ** The maximum number of times that a statement will try to reparse |
| 17426 | 17645 | ** itself before giving up and returning SQLITE_SCHEMA. |
| 17427 | 17646 | */ |
| | @@ -17959,11 +18178,11 @@ |
| 17959 | 18178 | #else |
| 17960 | 18179 | #define sqlite3VdbeMemExpandBlob(x) SQLITE_OK |
| 17961 | 18180 | #define ExpandBlob(P) SQLITE_OK |
| 17962 | 18181 | #endif |
| 17963 | 18182 | |
| 17964 | | -#endif /* !defined(_VDBEINT_H_) */ |
| 18183 | +#endif /* !defined(SQLITE_VDBEINT_H) */ |
| 17965 | 18184 | |
| 17966 | 18185 | /************** End of vdbeInt.h *********************************************/ |
| 17967 | 18186 | /************** Continuing where we left off in status.c *********************/ |
| 17968 | 18187 | |
| 17969 | 18188 | /* |
| | @@ -18106,11 +18325,11 @@ |
| 18106 | 18325 | sqlite3_mutex_leave(pMutex); |
| 18107 | 18326 | (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */ |
| 18108 | 18327 | return SQLITE_OK; |
| 18109 | 18328 | } |
| 18110 | 18329 | SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){ |
| 18111 | | - sqlite3_int64 iCur, iHwtr; |
| 18330 | + sqlite3_int64 iCur = 0, iHwtr = 0; |
| 18112 | 18331 | int rc; |
| 18113 | 18332 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 18114 | 18333 | if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT; |
| 18115 | 18334 | #endif |
| 18116 | 18335 | rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag); |
| | @@ -18167,19 +18386,24 @@ |
| 18167 | 18386 | /* |
| 18168 | 18387 | ** Return an approximation for the amount of memory currently used |
| 18169 | 18388 | ** by all pagers associated with the given database connection. The |
| 18170 | 18389 | ** highwater mark is meaningless and is returned as zero. |
| 18171 | 18390 | */ |
| 18391 | + case SQLITE_DBSTATUS_CACHE_USED_SHARED: |
| 18172 | 18392 | case SQLITE_DBSTATUS_CACHE_USED: { |
| 18173 | 18393 | int totalUsed = 0; |
| 18174 | 18394 | int i; |
| 18175 | 18395 | sqlite3BtreeEnterAll(db); |
| 18176 | 18396 | for(i=0; i<db->nDb; i++){ |
| 18177 | 18397 | Btree *pBt = db->aDb[i].pBt; |
| 18178 | 18398 | if( pBt ){ |
| 18179 | 18399 | Pager *pPager = sqlite3BtreePager(pBt); |
| 18180 | | - totalUsed += sqlite3PagerMemUsed(pPager); |
| 18400 | + int nByte = sqlite3PagerMemUsed(pPager); |
| 18401 | + if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){ |
| 18402 | + nByte = nByte / sqlite3BtreeConnectionCount(pBt); |
| 18403 | + } |
| 18404 | + totalUsed += nByte; |
| 18181 | 18405 | } |
| 18182 | 18406 | } |
| 18183 | 18407 | sqlite3BtreeLeaveAll(db); |
| 18184 | 18408 | *pCurrent = totalUsed; |
| 18185 | 18409 | *pHighwater = 0; |
| | @@ -19409,11 +19633,10 @@ |
| 19409 | 19633 | int argc, |
| 19410 | 19634 | sqlite3_value **argv |
| 19411 | 19635 | ){ |
| 19412 | 19636 | time_t t; |
| 19413 | 19637 | char *zFormat = (char *)sqlite3_user_data(context); |
| 19414 | | - sqlite3 *db; |
| 19415 | 19638 | sqlite3_int64 iT; |
| 19416 | 19639 | struct tm *pTm; |
| 19417 | 19640 | struct tm sNow; |
| 19418 | 19641 | char zBuf[20]; |
| 19419 | 19642 | |
| | @@ -19478,13 +19701,11 @@ |
| 19478 | 19701 | ****************************************************************************** |
| 19479 | 19702 | ** |
| 19480 | 19703 | ** This file contains OS interface code that is common to all |
| 19481 | 19704 | ** architectures. |
| 19482 | 19705 | */ |
| 19483 | | -#define _SQLITE_OS_C_ 1 |
| 19484 | 19706 | /* #include "sqliteInt.h" */ |
| 19485 | | -#undef _SQLITE_OS_C_ |
| 19486 | 19707 | |
| 19487 | 19708 | /* |
| 19488 | 19709 | ** If we compile with the SQLITE_TEST macro set, then the following block |
| 19489 | 19710 | ** of code will give us the ability to simulate a disk I/O error. This |
| 19490 | 19711 | ** is used for testing the I/O recovery logic. |
| | @@ -22993,12 +23214,12 @@ |
| 22993 | 23214 | ****************************************************************************** |
| 22994 | 23215 | ** |
| 22995 | 23216 | ** This file contains inline asm code for retrieving "high-performance" |
| 22996 | 23217 | ** counters for x86 class CPUs. |
| 22997 | 23218 | */ |
| 22998 | | -#ifndef _HWTIME_H_ |
| 22999 | | -#define _HWTIME_H_ |
| 23219 | +#ifndef SQLITE_HWTIME_H |
| 23220 | +#define SQLITE_HWTIME_H |
| 23000 | 23221 | |
| 23001 | 23222 | /* |
| 23002 | 23223 | ** The following routine only works on pentium-class (or newer) processors. |
| 23003 | 23224 | ** It uses the RDTSC opcode to read the cycle count value out of the |
| 23004 | 23225 | ** processor and returns that value. This can be used for high-res |
| | @@ -23062,11 +23283,11 @@ |
| 23062 | 23283 | */ |
| 23063 | 23284 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 23064 | 23285 | |
| 23065 | 23286 | #endif |
| 23066 | 23287 | |
| 23067 | | -#endif /* !defined(_HWTIME_H_) */ |
| 23288 | +#endif /* !defined(SQLITE_HWTIME_H) */ |
| 23068 | 23289 | |
| 23069 | 23290 | /************** End of hwtime.h **********************************************/ |
| 23070 | 23291 | /************** Continuing where we left off in os_common.h ******************/ |
| 23071 | 23292 | |
| 23072 | 23293 | static sqlite_uint64 g_start; |
| | @@ -23152,12 +23373,12 @@ |
| 23152 | 23373 | ** |
| 23153 | 23374 | ****************************************************************************** |
| 23154 | 23375 | ** |
| 23155 | 23376 | ** This file contains code that is specific to Windows. |
| 23156 | 23377 | */ |
| 23157 | | -#ifndef _OS_WIN_H_ |
| 23158 | | -#define _OS_WIN_H_ |
| 23378 | +#ifndef SQLITE_OS_WIN_H |
| 23379 | +#define SQLITE_OS_WIN_H |
| 23159 | 23380 | |
| 23160 | 23381 | /* |
| 23161 | 23382 | ** Include the primary Windows SDK header file. |
| 23162 | 23383 | */ |
| 23163 | 23384 | #include "windows.h" |
| | @@ -23225,11 +23446,11 @@ |
| 23225 | 23446 | # define SQLITE_OS_WIN_THREADS 1 |
| 23226 | 23447 | #else |
| 23227 | 23448 | # define SQLITE_OS_WIN_THREADS 0 |
| 23228 | 23449 | #endif |
| 23229 | 23450 | |
| 23230 | | -#endif /* _OS_WIN_H_ */ |
| 23451 | +#endif /* SQLITE_OS_WIN_H */ |
| 23231 | 23452 | |
| 23232 | 23453 | /************** End of os_win.h **********************************************/ |
| 23233 | 23454 | /************** Continuing where we left off in mutex_w32.c ******************/ |
| 23234 | 23455 | #endif |
| 23235 | 23456 | |
| | @@ -25976,10 +26197,16 @@ |
| 25976 | 26197 | } |
| 25977 | 26198 | sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken); |
| 25978 | 26199 | break; |
| 25979 | 26200 | } |
| 25980 | 26201 | #endif |
| 26202 | + case TK_MATCH: { |
| 26203 | + sqlite3TreeViewLine(pView, "MATCH {%d:%d}%s", |
| 26204 | + pExpr->iTable, pExpr->iColumn, zFlgs); |
| 26205 | + sqlite3TreeViewExpr(pView, pExpr->pRight, 0); |
| 26206 | + break; |
| 26207 | + } |
| 25981 | 26208 | default: { |
| 25982 | 26209 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); |
| 25983 | 26210 | break; |
| 25984 | 26211 | } |
| 25985 | 26212 | } |
| | @@ -28759,21 +28986,21 @@ |
| 28759 | 28986 | /* 27 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 28760 | 28987 | /* 28 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 28761 | 28988 | /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 28762 | 28989 | /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 28763 | 28990 | /* 31 */ "Found" OpHelp("key=r[P3@P4]"), |
| 28764 | | - /* 32 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 28765 | | - /* 33 */ "Last" OpHelp(""), |
| 28991 | + /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 28992 | + /* 33 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 28766 | 28993 | /* 34 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 28767 | 28994 | /* 35 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 28768 | 28995 | /* 36 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"), |
| 28769 | 28996 | /* 37 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"), |
| 28770 | 28997 | /* 38 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"), |
| 28771 | 28998 | /* 39 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"), |
| 28772 | 28999 | /* 40 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"), |
| 28773 | 29000 | /* 41 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"), |
| 28774 | | - /* 42 */ "SorterSort" OpHelp(""), |
| 29001 | + /* 42 */ "Last" OpHelp(""), |
| 28775 | 29002 | /* 43 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 28776 | 29003 | /* 44 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 28777 | 29004 | /* 45 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 28778 | 29005 | /* 46 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 28779 | 29006 | /* 47 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| | @@ -28780,118 +29007,119 @@ |
| 28780 | 29007 | /* 48 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 28781 | 29008 | /* 49 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 28782 | 29009 | /* 50 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 28783 | 29010 | /* 51 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 28784 | 29011 | /* 52 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 28785 | | - /* 53 */ "Sort" OpHelp(""), |
| 29012 | + /* 53 */ "SorterSort" OpHelp(""), |
| 28786 | 29013 | /* 54 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 28787 | | - /* 55 */ "Rewind" OpHelp(""), |
| 28788 | | - /* 56 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 28789 | | - /* 57 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 28790 | | - /* 58 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 28791 | | - /* 59 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 28792 | | - /* 60 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 28793 | | - /* 61 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 28794 | | - /* 62 */ "Program" OpHelp(""), |
| 28795 | | - /* 63 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 28796 | | - /* 64 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 28797 | | - /* 65 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"), |
| 28798 | | - /* 66 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 28799 | | - /* 67 */ "IncrVacuum" OpHelp(""), |
| 28800 | | - /* 68 */ "VNext" OpHelp(""), |
| 28801 | | - /* 69 */ "Init" OpHelp("Start at P2"), |
| 28802 | | - /* 70 */ "Return" OpHelp(""), |
| 28803 | | - /* 71 */ "EndCoroutine" OpHelp(""), |
| 28804 | | - /* 72 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 28805 | | - /* 73 */ "Halt" OpHelp(""), |
| 28806 | | - /* 74 */ "Integer" OpHelp("r[P2]=P1"), |
| 28807 | | - /* 75 */ "Int64" OpHelp("r[P2]=P4"), |
| 28808 | | - /* 76 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 28809 | | - /* 77 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 28810 | | - /* 78 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 28811 | | - /* 79 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 28812 | | - /* 80 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 28813 | | - /* 81 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 28814 | | - /* 82 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 28815 | | - /* 83 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 28816 | | - /* 84 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 28817 | | - /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 28818 | | - /* 86 */ "CollSeq" OpHelp(""), |
| 28819 | | - /* 87 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 28820 | | - /* 88 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 28821 | | - /* 89 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 28822 | | - /* 90 */ "RealAffinity" OpHelp(""), |
| 28823 | | - /* 91 */ "Cast" OpHelp("affinity(r[P1])"), |
| 28824 | | - /* 92 */ "Permutation" OpHelp(""), |
| 28825 | | - /* 93 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 28826 | | - /* 94 */ "Column" OpHelp("r[P3]=PX"), |
| 28827 | | - /* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 28828 | | - /* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 29014 | + /* 55 */ "Sort" OpHelp(""), |
| 29015 | + /* 56 */ "Rewind" OpHelp(""), |
| 29016 | + /* 57 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 29017 | + /* 58 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 29018 | + /* 59 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 29019 | + /* 60 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 29020 | + /* 61 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 29021 | + /* 62 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 29022 | + /* 63 */ "Program" OpHelp(""), |
| 29023 | + /* 64 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 29024 | + /* 65 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 29025 | + /* 66 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]-=P3, goto P2"), |
| 29026 | + /* 67 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 29027 | + /* 68 */ "IncrVacuum" OpHelp(""), |
| 29028 | + /* 69 */ "VNext" OpHelp(""), |
| 29029 | + /* 70 */ "Init" OpHelp("Start at P2"), |
| 29030 | + /* 71 */ "Return" OpHelp(""), |
| 29031 | + /* 72 */ "EndCoroutine" OpHelp(""), |
| 29032 | + /* 73 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 29033 | + /* 74 */ "Halt" OpHelp(""), |
| 29034 | + /* 75 */ "Integer" OpHelp("r[P2]=P1"), |
| 29035 | + /* 76 */ "Int64" OpHelp("r[P2]=P4"), |
| 29036 | + /* 77 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 29037 | + /* 78 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 29038 | + /* 79 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 29039 | + /* 80 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 29040 | + /* 81 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 29041 | + /* 82 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 29042 | + /* 83 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 29043 | + /* 84 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 29044 | + /* 85 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 29045 | + /* 86 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 29046 | + /* 87 */ "CollSeq" OpHelp(""), |
| 29047 | + /* 88 */ "Function0" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29048 | + /* 89 */ "Function" OpHelp("r[P3]=func(r[P2@P5])"), |
| 29049 | + /* 90 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 29050 | + /* 91 */ "RealAffinity" OpHelp(""), |
| 29051 | + /* 92 */ "Cast" OpHelp("affinity(r[P1])"), |
| 29052 | + /* 93 */ "Permutation" OpHelp(""), |
| 29053 | + /* 94 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 29054 | + /* 95 */ "Column" OpHelp("r[P3]=PX"), |
| 29055 | + /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 28829 | 29056 | /* 97 */ "String8" OpHelp("r[P2]='P4'"), |
| 28830 | | - /* 98 */ "Count" OpHelp("r[P2]=count()"), |
| 28831 | | - /* 99 */ "ReadCookie" OpHelp(""), |
| 28832 | | - /* 100 */ "SetCookie" OpHelp(""), |
| 28833 | | - /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 28834 | | - /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 28835 | | - /* 103 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 28836 | | - /* 104 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 28837 | | - /* 105 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 28838 | | - /* 106 */ "SorterOpen" OpHelp(""), |
| 28839 | | - /* 107 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 28840 | | - /* 108 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 28841 | | - /* 109 */ "Close" OpHelp(""), |
| 28842 | | - /* 110 */ "ColumnsUsed" OpHelp(""), |
| 28843 | | - /* 111 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 28844 | | - /* 112 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 28845 | | - /* 113 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 28846 | | - /* 114 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 28847 | | - /* 115 */ "Delete" OpHelp(""), |
| 28848 | | - /* 116 */ "ResetCount" OpHelp(""), |
| 28849 | | - /* 117 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 28850 | | - /* 118 */ "SorterData" OpHelp("r[P2]=data"), |
| 28851 | | - /* 119 */ "RowKey" OpHelp("r[P2]=key"), |
| 28852 | | - /* 120 */ "RowData" OpHelp("r[P2]=data"), |
| 28853 | | - /* 121 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 28854 | | - /* 122 */ "NullRow" OpHelp(""), |
| 28855 | | - /* 123 */ "SorterInsert" OpHelp(""), |
| 28856 | | - /* 124 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 28857 | | - /* 125 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 28858 | | - /* 126 */ "Seek" OpHelp("Move P3 to P1.rowid"), |
| 28859 | | - /* 127 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 28860 | | - /* 128 */ "Destroy" OpHelp(""), |
| 28861 | | - /* 129 */ "Clear" OpHelp(""), |
| 28862 | | - /* 130 */ "ResetSorter" OpHelp(""), |
| 28863 | | - /* 131 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 28864 | | - /* 132 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 29057 | + /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 29058 | + /* 99 */ "Count" OpHelp("r[P2]=count()"), |
| 29059 | + /* 100 */ "ReadCookie" OpHelp(""), |
| 29060 | + /* 101 */ "SetCookie" OpHelp(""), |
| 29061 | + /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 29062 | + /* 103 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 29063 | + /* 104 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 29064 | + /* 105 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 29065 | + /* 106 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 29066 | + /* 107 */ "SorterOpen" OpHelp(""), |
| 29067 | + /* 108 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 29068 | + /* 109 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 29069 | + /* 110 */ "Close" OpHelp(""), |
| 29070 | + /* 111 */ "ColumnsUsed" OpHelp(""), |
| 29071 | + /* 112 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 29072 | + /* 113 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 29073 | + /* 114 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 29074 | + /* 115 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 29075 | + /* 116 */ "Delete" OpHelp(""), |
| 29076 | + /* 117 */ "ResetCount" OpHelp(""), |
| 29077 | + /* 118 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 29078 | + /* 119 */ "SorterData" OpHelp("r[P2]=data"), |
| 29079 | + /* 120 */ "RowKey" OpHelp("r[P2]=key"), |
| 29080 | + /* 121 */ "RowData" OpHelp("r[P2]=data"), |
| 29081 | + /* 122 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 29082 | + /* 123 */ "NullRow" OpHelp(""), |
| 29083 | + /* 124 */ "SorterInsert" OpHelp(""), |
| 29084 | + /* 125 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 29085 | + /* 126 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 29086 | + /* 127 */ "Seek" OpHelp("Move P3 to P1.rowid"), |
| 29087 | + /* 128 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 29088 | + /* 129 */ "Destroy" OpHelp(""), |
| 29089 | + /* 130 */ "Clear" OpHelp(""), |
| 29090 | + /* 131 */ "ResetSorter" OpHelp(""), |
| 29091 | + /* 132 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 28865 | 29092 | /* 133 */ "Real" OpHelp("r[P2]=P4"), |
| 28866 | | - /* 134 */ "ParseSchema" OpHelp(""), |
| 28867 | | - /* 135 */ "LoadAnalysis" OpHelp(""), |
| 28868 | | - /* 136 */ "DropTable" OpHelp(""), |
| 28869 | | - /* 137 */ "DropIndex" OpHelp(""), |
| 28870 | | - /* 138 */ "DropTrigger" OpHelp(""), |
| 28871 | | - /* 139 */ "IntegrityCk" OpHelp(""), |
| 28872 | | - /* 140 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 28873 | | - /* 141 */ "Param" OpHelp(""), |
| 28874 | | - /* 142 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 28875 | | - /* 143 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 28876 | | - /* 144 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 28877 | | - /* 145 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 28878 | | - /* 146 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 28879 | | - /* 147 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 28880 | | - /* 148 */ "Expire" OpHelp(""), |
| 28881 | | - /* 149 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 28882 | | - /* 150 */ "VBegin" OpHelp(""), |
| 28883 | | - /* 151 */ "VCreate" OpHelp(""), |
| 28884 | | - /* 152 */ "VDestroy" OpHelp(""), |
| 28885 | | - /* 153 */ "VOpen" OpHelp(""), |
| 28886 | | - /* 154 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 28887 | | - /* 155 */ "VRename" OpHelp(""), |
| 28888 | | - /* 156 */ "Pagecount" OpHelp(""), |
| 28889 | | - /* 157 */ "MaxPgcnt" OpHelp(""), |
| 28890 | | - /* 158 */ "CursorHint" OpHelp(""), |
| 28891 | | - /* 159 */ "Noop" OpHelp(""), |
| 28892 | | - /* 160 */ "Explain" OpHelp(""), |
| 29093 | + /* 134 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 29094 | + /* 135 */ "ParseSchema" OpHelp(""), |
| 29095 | + /* 136 */ "LoadAnalysis" OpHelp(""), |
| 29096 | + /* 137 */ "DropTable" OpHelp(""), |
| 29097 | + /* 138 */ "DropIndex" OpHelp(""), |
| 29098 | + /* 139 */ "DropTrigger" OpHelp(""), |
| 29099 | + /* 140 */ "IntegrityCk" OpHelp(""), |
| 29100 | + /* 141 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 29101 | + /* 142 */ "Param" OpHelp(""), |
| 29102 | + /* 143 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 29103 | + /* 144 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 29104 | + /* 145 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 29105 | + /* 146 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29106 | + /* 147 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 29107 | + /* 148 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 29108 | + /* 149 */ "Expire" OpHelp(""), |
| 29109 | + /* 150 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 29110 | + /* 151 */ "VBegin" OpHelp(""), |
| 29111 | + /* 152 */ "VCreate" OpHelp(""), |
| 29112 | + /* 153 */ "VDestroy" OpHelp(""), |
| 29113 | + /* 154 */ "VOpen" OpHelp(""), |
| 29114 | + /* 155 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 29115 | + /* 156 */ "VRename" OpHelp(""), |
| 29116 | + /* 157 */ "Pagecount" OpHelp(""), |
| 29117 | + /* 158 */ "MaxPgcnt" OpHelp(""), |
| 29118 | + /* 159 */ "CursorHint" OpHelp(""), |
| 29119 | + /* 160 */ "Noop" OpHelp(""), |
| 29120 | + /* 161 */ "Explain" OpHelp(""), |
| 28893 | 29121 | }; |
| 28894 | 29122 | return azName[i]; |
| 28895 | 29123 | } |
| 28896 | 29124 | #endif |
| 28897 | 29125 | |
| | @@ -29237,12 +29465,12 @@ |
| 29237 | 29465 | ****************************************************************************** |
| 29238 | 29466 | ** |
| 29239 | 29467 | ** This file contains inline asm code for retrieving "high-performance" |
| 29240 | 29468 | ** counters for x86 class CPUs. |
| 29241 | 29469 | */ |
| 29242 | | -#ifndef _HWTIME_H_ |
| 29243 | | -#define _HWTIME_H_ |
| 29470 | +#ifndef SQLITE_HWTIME_H |
| 29471 | +#define SQLITE_HWTIME_H |
| 29244 | 29472 | |
| 29245 | 29473 | /* |
| 29246 | 29474 | ** The following routine only works on pentium-class (or newer) processors. |
| 29247 | 29475 | ** It uses the RDTSC opcode to read the cycle count value out of the |
| 29248 | 29476 | ** processor and returns that value. This can be used for high-res |
| | @@ -29306,11 +29534,11 @@ |
| 29306 | 29534 | */ |
| 29307 | 29535 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 29308 | 29536 | |
| 29309 | 29537 | #endif |
| 29310 | 29538 | |
| 29311 | | -#endif /* !defined(_HWTIME_H_) */ |
| 29539 | +#endif /* !defined(SQLITE_HWTIME_H) */ |
| 29312 | 29540 | |
| 29313 | 29541 | /************** End of hwtime.h **********************************************/ |
| 29314 | 29542 | /************** Continuing where we left off in os_common.h ******************/ |
| 29315 | 29543 | |
| 29316 | 29544 | static sqlite_uint64 g_start; |
| | @@ -36766,12 +36994,12 @@ |
| 36766 | 36994 | ****************************************************************************** |
| 36767 | 36995 | ** |
| 36768 | 36996 | ** This file contains inline asm code for retrieving "high-performance" |
| 36769 | 36997 | ** counters for x86 class CPUs. |
| 36770 | 36998 | */ |
| 36771 | | -#ifndef _HWTIME_H_ |
| 36772 | | -#define _HWTIME_H_ |
| 36999 | +#ifndef SQLITE_HWTIME_H |
| 37000 | +#define SQLITE_HWTIME_H |
| 36773 | 37001 | |
| 36774 | 37002 | /* |
| 36775 | 37003 | ** The following routine only works on pentium-class (or newer) processors. |
| 36776 | 37004 | ** It uses the RDTSC opcode to read the cycle count value out of the |
| 36777 | 37005 | ** processor and returns that value. This can be used for high-res |
| | @@ -36835,11 +37063,11 @@ |
| 36835 | 37063 | */ |
| 36836 | 37064 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 36837 | 37065 | |
| 36838 | 37066 | #endif |
| 36839 | 37067 | |
| 36840 | | -#endif /* !defined(_HWTIME_H_) */ |
| 37068 | +#endif /* !defined(SQLITE_HWTIME_H) */ |
| 36841 | 37069 | |
| 36842 | 37070 | /************** End of hwtime.h **********************************************/ |
| 36843 | 37071 | /************** Continuing where we left off in os_common.h ******************/ |
| 36844 | 37072 | |
| 36845 | 37073 | static sqlite_uint64 g_start; |
| | @@ -37175,10 +37403,21 @@ |
| 37175 | 37403 | sqlite3_int64 mmapSize; /* Usable size of mapped region */ |
| 37176 | 37404 | sqlite3_int64 mmapSizeActual; /* Actual size of mapped region */ |
| 37177 | 37405 | sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */ |
| 37178 | 37406 | #endif |
| 37179 | 37407 | }; |
| 37408 | + |
| 37409 | +/* |
| 37410 | +** The winVfsAppData structure is used for the pAppData member for all of the |
| 37411 | +** Win32 VFS variants. |
| 37412 | +*/ |
| 37413 | +typedef struct winVfsAppData winVfsAppData; |
| 37414 | +struct winVfsAppData { |
| 37415 | + const sqlite3_io_methods *pMethod; /* The file I/O methods to use. */ |
| 37416 | + void *pAppData; /* The extra pAppData, if any. */ |
| 37417 | + BOOL bNoLock; /* Non-zero if locking is disabled. */ |
| 37418 | +}; |
| 37180 | 37419 | |
| 37181 | 37420 | /* |
| 37182 | 37421 | ** Allowed values for winFile.ctrlFlags |
| 37183 | 37422 | */ |
| 37184 | 37423 | #define WINFILE_RDONLY 0x02 /* Connection is read only */ |
| | @@ -39497,11 +39736,16 @@ |
| 39497 | 39736 | rc = osCloseHandle(pFile->h); |
| 39498 | 39737 | /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */ |
| 39499 | 39738 | }while( rc==0 && ++cnt < MX_CLOSE_ATTEMPT && (sqlite3_win32_sleep(100), 1) ); |
| 39500 | 39739 | #if SQLITE_OS_WINCE |
| 39501 | 39740 | #define WINCE_DELETION_ATTEMPTS 3 |
| 39502 | | - winceDestroyLock(pFile); |
| 39741 | + { |
| 39742 | + winVfsAppData *pAppData = (winVfsAppData*)pFile->pVfs->pAppData; |
| 39743 | + if( pAppData==NULL || !pAppData->bNoLock ){ |
| 39744 | + winceDestroyLock(pFile); |
| 39745 | + } |
| 39746 | + } |
| 39503 | 39747 | if( pFile->zDeleteOnClose ){ |
| 39504 | 39748 | int cnt = 0; |
| 39505 | 39749 | while( |
| 39506 | 39750 | osDeleteFileW(pFile->zDeleteOnClose)==0 |
| 39507 | 39751 | && osGetFileAttributesW(pFile->zDeleteOnClose)!=0xffffffff |
| | @@ -40229,10 +40473,48 @@ |
| 40229 | 40473 | OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n", |
| 40230 | 40474 | pFile->h, pFile->locktype, sqlite3ErrName(rc))); |
| 40231 | 40475 | return rc; |
| 40232 | 40476 | } |
| 40233 | 40477 | |
| 40478 | +/****************************************************************************** |
| 40479 | +****************************** No-op Locking ********************************** |
| 40480 | +** |
| 40481 | +** Of the various locking implementations available, this is by far the |
| 40482 | +** simplest: locking is ignored. No attempt is made to lock the database |
| 40483 | +** file for reading or writing. |
| 40484 | +** |
| 40485 | +** This locking mode is appropriate for use on read-only databases |
| 40486 | +** (ex: databases that are burned into CD-ROM, for example.) It can |
| 40487 | +** also be used if the application employs some external mechanism to |
| 40488 | +** prevent simultaneous access of the same database by two or more |
| 40489 | +** database connections. But there is a serious risk of database |
| 40490 | +** corruption if this locking mode is used in situations where multiple |
| 40491 | +** database connections are accessing the same database file at the same |
| 40492 | +** time and one or more of those connections are writing. |
| 40493 | +*/ |
| 40494 | + |
| 40495 | +static int winNolockLock(sqlite3_file *id, int locktype){ |
| 40496 | + UNUSED_PARAMETER(id); |
| 40497 | + UNUSED_PARAMETER(locktype); |
| 40498 | + return SQLITE_OK; |
| 40499 | +} |
| 40500 | + |
| 40501 | +static int winNolockCheckReservedLock(sqlite3_file *id, int *pResOut){ |
| 40502 | + UNUSED_PARAMETER(id); |
| 40503 | + UNUSED_PARAMETER(pResOut); |
| 40504 | + return SQLITE_OK; |
| 40505 | +} |
| 40506 | + |
| 40507 | +static int winNolockUnlock(sqlite3_file *id, int locktype){ |
| 40508 | + UNUSED_PARAMETER(id); |
| 40509 | + UNUSED_PARAMETER(locktype); |
| 40510 | + return SQLITE_OK; |
| 40511 | +} |
| 40512 | + |
| 40513 | +/******************* End of the no-op lock implementation ********************* |
| 40514 | +******************************************************************************/ |
| 40515 | + |
| 40234 | 40516 | /* |
| 40235 | 40517 | ** If *pArg is initially negative then this is a query. Set *pArg to |
| 40236 | 40518 | ** 1 or 0 depending on whether or not bit mask of pFile->ctrlFlags is set. |
| 40237 | 40519 | ** |
| 40238 | 40520 | ** If *pArg is 0 or 1, then clear or set the mask bit of pFile->ctrlFlags. |
| | @@ -40507,16 +40789,16 @@ |
| 40507 | 40789 | #define WIN_SHM_DMS (WIN_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */ |
| 40508 | 40790 | |
| 40509 | 40791 | /* |
| 40510 | 40792 | ** Apply advisory locks for all n bytes beginning at ofst. |
| 40511 | 40793 | */ |
| 40512 | | -#define _SHM_UNLCK 1 |
| 40513 | | -#define _SHM_RDLCK 2 |
| 40514 | | -#define _SHM_WRLCK 3 |
| 40794 | +#define WINSHM_UNLCK 1 |
| 40795 | +#define WINSHM_RDLCK 2 |
| 40796 | +#define WINSHM_WRLCK 3 |
| 40515 | 40797 | static int winShmSystemLock( |
| 40516 | 40798 | winShmNode *pFile, /* Apply locks to this open shared-memory segment */ |
| 40517 | | - int lockType, /* _SHM_UNLCK, _SHM_RDLCK, or _SHM_WRLCK */ |
| 40799 | + int lockType, /* WINSHM_UNLCK, WINSHM_RDLCK, or WINSHM_WRLCK */ |
| 40518 | 40800 | int ofst, /* Offset to first byte to be locked/unlocked */ |
| 40519 | 40801 | int nByte /* Number of bytes to lock or unlock */ |
| 40520 | 40802 | ){ |
| 40521 | 40803 | int rc = 0; /* Result code form Lock/UnlockFileEx() */ |
| 40522 | 40804 | |
| | @@ -40525,16 +40807,16 @@ |
| 40525 | 40807 | |
| 40526 | 40808 | OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n", |
| 40527 | 40809 | pFile->hFile.h, lockType, ofst, nByte)); |
| 40528 | 40810 | |
| 40529 | 40811 | /* Release/Acquire the system-level lock */ |
| 40530 | | - if( lockType==_SHM_UNLCK ){ |
| 40812 | + if( lockType==WINSHM_UNLCK ){ |
| 40531 | 40813 | rc = winUnlockFile(&pFile->hFile.h, ofst, 0, nByte, 0); |
| 40532 | 40814 | }else{ |
| 40533 | 40815 | /* Initialize the locking parameters */ |
| 40534 | 40816 | DWORD dwFlags = LOCKFILE_FAIL_IMMEDIATELY; |
| 40535 | | - if( lockType == _SHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; |
| 40817 | + if( lockType == WINSHM_WRLCK ) dwFlags |= LOCKFILE_EXCLUSIVE_LOCK; |
| 40536 | 40818 | rc = winLockFile(&pFile->hFile.h, dwFlags, ofst, 0, nByte, 0); |
| 40537 | 40819 | } |
| 40538 | 40820 | |
| 40539 | 40821 | if( rc!= 0 ){ |
| 40540 | 40822 | rc = SQLITE_OK; |
| | @@ -40542,11 +40824,11 @@ |
| 40542 | 40824 | pFile->lastErrno = osGetLastError(); |
| 40543 | 40825 | rc = SQLITE_BUSY; |
| 40544 | 40826 | } |
| 40545 | 40827 | |
| 40546 | 40828 | OSTRACE(("SHM-LOCK file=%p, func=%s, errno=%lu, rc=%s\n", |
| 40547 | | - pFile->hFile.h, (lockType == _SHM_UNLCK) ? "winUnlockFile" : |
| 40829 | + pFile->hFile.h, (lockType == WINSHM_UNLCK) ? "winUnlockFile" : |
| 40548 | 40830 | "winLockFile", pFile->lastErrno, sqlite3ErrName(rc))); |
| 40549 | 40831 | |
| 40550 | 40832 | return rc; |
| 40551 | 40833 | } |
| 40552 | 40834 | |
| | @@ -40670,20 +40952,20 @@ |
| 40670 | 40952 | } |
| 40671 | 40953 | |
| 40672 | 40954 | /* Check to see if another process is holding the dead-man switch. |
| 40673 | 40955 | ** If not, truncate the file to zero length. |
| 40674 | 40956 | */ |
| 40675 | | - if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ |
| 40957 | + if( winShmSystemLock(pShmNode, WINSHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){ |
| 40676 | 40958 | rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0); |
| 40677 | 40959 | if( rc!=SQLITE_OK ){ |
| 40678 | 40960 | rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(), |
| 40679 | 40961 | "winOpenShm", pDbFd->zPath); |
| 40680 | 40962 | } |
| 40681 | 40963 | } |
| 40682 | 40964 | if( rc==SQLITE_OK ){ |
| 40683 | | - winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1); |
| 40684 | | - rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1); |
| 40965 | + winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1); |
| 40966 | + rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, WIN_SHM_DMS, 1); |
| 40685 | 40967 | } |
| 40686 | 40968 | if( rc ) goto shm_open_err; |
| 40687 | 40969 | } |
| 40688 | 40970 | |
| 40689 | 40971 | /* Make the new connection a child of the winShmNode */ |
| | @@ -40708,11 +40990,11 @@ |
| 40708 | 40990 | sqlite3_mutex_leave(pShmNode->mutex); |
| 40709 | 40991 | return SQLITE_OK; |
| 40710 | 40992 | |
| 40711 | 40993 | /* Jump here on any error */ |
| 40712 | 40994 | shm_open_err: |
| 40713 | | - winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1); |
| 40995 | + winShmSystemLock(pShmNode, WINSHM_UNLCK, WIN_SHM_DMS, 1); |
| 40714 | 40996 | winShmPurge(pDbFd->pVfs, 0); /* This call frees pShmNode if required */ |
| 40715 | 40997 | sqlite3_free(p); |
| 40716 | 40998 | sqlite3_free(pNew); |
| 40717 | 40999 | winShmLeaveMutex(); |
| 40718 | 41000 | return rc; |
| | @@ -40797,11 +41079,11 @@ |
| 40797 | 41079 | allMask |= pX->sharedMask; |
| 40798 | 41080 | } |
| 40799 | 41081 | |
| 40800 | 41082 | /* Unlock the system-level locks */ |
| 40801 | 41083 | if( (mask & allMask)==0 ){ |
| 40802 | | - rc = winShmSystemLock(pShmNode, _SHM_UNLCK, ofst+WIN_SHM_BASE, n); |
| 41084 | + rc = winShmSystemLock(pShmNode, WINSHM_UNLCK, ofst+WIN_SHM_BASE, n); |
| 40803 | 41085 | }else{ |
| 40804 | 41086 | rc = SQLITE_OK; |
| 40805 | 41087 | } |
| 40806 | 41088 | |
| 40807 | 41089 | /* Undo the local locks */ |
| | @@ -40825,11 +41107,11 @@ |
| 40825 | 41107 | } |
| 40826 | 41108 | |
| 40827 | 41109 | /* Get shared locks at the system level, if necessary */ |
| 40828 | 41110 | if( rc==SQLITE_OK ){ |
| 40829 | 41111 | if( (allShared & mask)==0 ){ |
| 40830 | | - rc = winShmSystemLock(pShmNode, _SHM_RDLCK, ofst+WIN_SHM_BASE, n); |
| 41112 | + rc = winShmSystemLock(pShmNode, WINSHM_RDLCK, ofst+WIN_SHM_BASE, n); |
| 40831 | 41113 | }else{ |
| 40832 | 41114 | rc = SQLITE_OK; |
| 40833 | 41115 | } |
| 40834 | 41116 | } |
| 40835 | 41117 | |
| | @@ -40850,11 +41132,11 @@ |
| 40850 | 41132 | |
| 40851 | 41133 | /* Get the exclusive locks at the system level. Then if successful |
| 40852 | 41134 | ** also mark the local connection as being locked. |
| 40853 | 41135 | */ |
| 40854 | 41136 | if( rc==SQLITE_OK ){ |
| 40855 | | - rc = winShmSystemLock(pShmNode, _SHM_WRLCK, ofst+WIN_SHM_BASE, n); |
| 41137 | + rc = winShmSystemLock(pShmNode, WINSHM_WRLCK, ofst+WIN_SHM_BASE, n); |
| 40856 | 41138 | if( rc==SQLITE_OK ){ |
| 40857 | 41139 | assert( (p->sharedMask & mask)==0 ); |
| 40858 | 41140 | p->exclMask |= mask; |
| 40859 | 41141 | } |
| 40860 | 41142 | } |
| | @@ -41292,10 +41574,48 @@ |
| 41292 | 41574 | winShmBarrier, /* xShmBarrier */ |
| 41293 | 41575 | winShmUnmap, /* xShmUnmap */ |
| 41294 | 41576 | winFetch, /* xFetch */ |
| 41295 | 41577 | winUnfetch /* xUnfetch */ |
| 41296 | 41578 | }; |
| 41579 | + |
| 41580 | +/* |
| 41581 | +** This vector defines all the methods that can operate on an |
| 41582 | +** sqlite3_file for win32 without performing any locking. |
| 41583 | +*/ |
| 41584 | +static const sqlite3_io_methods winIoNolockMethod = { |
| 41585 | + 3, /* iVersion */ |
| 41586 | + winClose, /* xClose */ |
| 41587 | + winRead, /* xRead */ |
| 41588 | + winWrite, /* xWrite */ |
| 41589 | + winTruncate, /* xTruncate */ |
| 41590 | + winSync, /* xSync */ |
| 41591 | + winFileSize, /* xFileSize */ |
| 41592 | + winNolockLock, /* xLock */ |
| 41593 | + winNolockUnlock, /* xUnlock */ |
| 41594 | + winNolockCheckReservedLock, /* xCheckReservedLock */ |
| 41595 | + winFileControl, /* xFileControl */ |
| 41596 | + winSectorSize, /* xSectorSize */ |
| 41597 | + winDeviceCharacteristics, /* xDeviceCharacteristics */ |
| 41598 | + winShmMap, /* xShmMap */ |
| 41599 | + winShmLock, /* xShmLock */ |
| 41600 | + winShmBarrier, /* xShmBarrier */ |
| 41601 | + winShmUnmap, /* xShmUnmap */ |
| 41602 | + winFetch, /* xFetch */ |
| 41603 | + winUnfetch /* xUnfetch */ |
| 41604 | +}; |
| 41605 | + |
| 41606 | +static winVfsAppData winAppData = { |
| 41607 | + &winIoMethod, /* pMethod */ |
| 41608 | + 0, /* pAppData */ |
| 41609 | + 0 /* bNoLock */ |
| 41610 | +}; |
| 41611 | + |
| 41612 | +static winVfsAppData winNolockAppData = { |
| 41613 | + &winIoNolockMethod, /* pMethod */ |
| 41614 | + 0, /* pAppData */ |
| 41615 | + 1 /* bNoLock */ |
| 41616 | +}; |
| 41297 | 41617 | |
| 41298 | 41618 | /**************************************************************************** |
| 41299 | 41619 | **************************** sqlite3_vfs methods **************************** |
| 41300 | 41620 | ** |
| 41301 | 41621 | ** This division contains the implementation of methods on the |
| | @@ -41625,11 +41945,11 @@ |
| 41625 | 41945 | |
| 41626 | 41946 | /* |
| 41627 | 41947 | ** Open a file. |
| 41628 | 41948 | */ |
| 41629 | 41949 | static int winOpen( |
| 41630 | | - sqlite3_vfs *pVfs, /* Used to get maximum path name length */ |
| 41950 | + sqlite3_vfs *pVfs, /* Used to get maximum path length and AppData */ |
| 41631 | 41951 | const char *zName, /* Name of the file (UTF-8) */ |
| 41632 | 41952 | sqlite3_file *id, /* Write the SQLite file handle here */ |
| 41633 | 41953 | int flags, /* Open mode flags */ |
| 41634 | 41954 | int *pOutFlags /* Status return flags */ |
| 41635 | 41955 | ){ |
| | @@ -41640,10 +41960,11 @@ |
| 41640 | 41960 | DWORD dwCreationDisposition; |
| 41641 | 41961 | DWORD dwFlagsAndAttributes = 0; |
| 41642 | 41962 | #if SQLITE_OS_WINCE |
| 41643 | 41963 | int isTemp = 0; |
| 41644 | 41964 | #endif |
| 41965 | + winVfsAppData *pAppData; |
| 41645 | 41966 | winFile *pFile = (winFile*)id; |
| 41646 | 41967 | void *zConverted; /* Filename in OS encoding */ |
| 41647 | 41968 | const char *zUtf8Name = zName; /* Filename in UTF-8 encoding */ |
| 41648 | 41969 | int cnt = 0; |
| 41649 | 41970 | |
| | @@ -41861,19 +42182,24 @@ |
| 41861 | 42182 | |
| 41862 | 42183 | OSTRACE(("OPEN file=%p, name=%s, access=%lx, pOutFlags=%p, *pOutFlags=%d, " |
| 41863 | 42184 | "rc=%s\n", h, zUtf8Name, dwDesiredAccess, pOutFlags, pOutFlags ? |
| 41864 | 42185 | *pOutFlags : 0, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok")); |
| 41865 | 42186 | |
| 42187 | + pAppData = (winVfsAppData*)pVfs->pAppData; |
| 42188 | + |
| 41866 | 42189 | #if SQLITE_OS_WINCE |
| 41867 | | - if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB |
| 41868 | | - && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK |
| 41869 | | - ){ |
| 41870 | | - osCloseHandle(h); |
| 41871 | | - sqlite3_free(zConverted); |
| 41872 | | - sqlite3_free(zTmpname); |
| 41873 | | - OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc))); |
| 41874 | | - return rc; |
| 42190 | + { |
| 42191 | + if( isReadWrite && eType==SQLITE_OPEN_MAIN_DB |
| 42192 | + && ((pAppData==NULL) || !pAppData->bNoLock) |
| 42193 | + && (rc = winceCreateLock(zName, pFile))!=SQLITE_OK |
| 42194 | + ){ |
| 42195 | + osCloseHandle(h); |
| 42196 | + sqlite3_free(zConverted); |
| 42197 | + sqlite3_free(zTmpname); |
| 42198 | + OSTRACE(("OPEN-CE-LOCK name=%s, rc=%s\n", zName, sqlite3ErrName(rc))); |
| 42199 | + return rc; |
| 42200 | + } |
| 41875 | 42201 | } |
| 41876 | 42202 | if( isTemp ){ |
| 41877 | 42203 | pFile->zDeleteOnClose = zConverted; |
| 41878 | 42204 | }else |
| 41879 | 42205 | #endif |
| | @@ -41880,11 +42206,11 @@ |
| 41880 | 42206 | { |
| 41881 | 42207 | sqlite3_free(zConverted); |
| 41882 | 42208 | } |
| 41883 | 42209 | |
| 41884 | 42210 | sqlite3_free(zTmpname); |
| 41885 | | - pFile->pMethod = &winIoMethod; |
| 42211 | + pFile->pMethod = pAppData ? pAppData->pMethod : &winIoMethod; |
| 41886 | 42212 | pFile->pVfs = pVfs; |
| 41887 | 42213 | pFile->h = h; |
| 41888 | 42214 | if( isReadonly ){ |
| 41889 | 42215 | pFile->ctrlFlags |= WINFILE_RDONLY; |
| 41890 | 42216 | } |
| | @@ -42155,10 +42481,22 @@ |
| 42155 | 42481 | sqlite3_vfs *pVfs, /* Pointer to vfs object */ |
| 42156 | 42482 | const char *zRelative, /* Possibly relative input path */ |
| 42157 | 42483 | int nFull, /* Size of output buffer in bytes */ |
| 42158 | 42484 | char *zFull /* Output buffer */ |
| 42159 | 42485 | ){ |
| 42486 | +#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) |
| 42487 | + DWORD nByte; |
| 42488 | + void *zConverted; |
| 42489 | + char *zOut; |
| 42490 | +#endif |
| 42491 | + |
| 42492 | + /* If this path name begins with "/X:", where "X" is any alphabetic |
| 42493 | + ** character, discard the initial "/" from the pathname. |
| 42494 | + */ |
| 42495 | + if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){ |
| 42496 | + zRelative++; |
| 42497 | + } |
| 42160 | 42498 | |
| 42161 | 42499 | #if defined(__CYGWIN__) |
| 42162 | 42500 | SimulateIOError( return SQLITE_ERROR ); |
| 42163 | 42501 | UNUSED_PARAMETER(nFull); |
| 42164 | 42502 | assert( nFull>=pVfs->mxPathname ); |
| | @@ -42233,21 +42571,10 @@ |
| 42233 | 42571 | } |
| 42234 | 42572 | return SQLITE_OK; |
| 42235 | 42573 | #endif |
| 42236 | 42574 | |
| 42237 | 42575 | #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(__CYGWIN__) |
| 42238 | | - DWORD nByte; |
| 42239 | | - void *zConverted; |
| 42240 | | - char *zOut; |
| 42241 | | - |
| 42242 | | - /* If this path name begins with "/X:", where "X" is any alphabetic |
| 42243 | | - ** character, discard the initial "/" from the pathname. |
| 42244 | | - */ |
| 42245 | | - if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){ |
| 42246 | | - zRelative++; |
| 42247 | | - } |
| 42248 | | - |
| 42249 | 42576 | /* It's odd to simulate an io-error here, but really this is just |
| 42250 | 42577 | ** using the io-error infrastructure to test that SQLite handles this |
| 42251 | 42578 | ** function failing. This function could fail if, for example, the |
| 42252 | 42579 | ** current working directory has been unlinked. |
| 42253 | 42580 | */ |
| | @@ -42602,57 +42929,107 @@ |
| 42602 | 42929 | /* |
| 42603 | 42930 | ** Initialize and deinitialize the operating system interface. |
| 42604 | 42931 | */ |
| 42605 | 42932 | SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){ |
| 42606 | 42933 | static sqlite3_vfs winVfs = { |
| 42607 | | - 3, /* iVersion */ |
| 42608 | | - sizeof(winFile), /* szOsFile */ |
| 42934 | + 3, /* iVersion */ |
| 42935 | + sizeof(winFile), /* szOsFile */ |
| 42609 | 42936 | SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */ |
| 42610 | | - 0, /* pNext */ |
| 42611 | | - "win32", /* zName */ |
| 42612 | | - 0, /* pAppData */ |
| 42613 | | - winOpen, /* xOpen */ |
| 42614 | | - winDelete, /* xDelete */ |
| 42615 | | - winAccess, /* xAccess */ |
| 42616 | | - winFullPathname, /* xFullPathname */ |
| 42617 | | - winDlOpen, /* xDlOpen */ |
| 42618 | | - winDlError, /* xDlError */ |
| 42619 | | - winDlSym, /* xDlSym */ |
| 42620 | | - winDlClose, /* xDlClose */ |
| 42621 | | - winRandomness, /* xRandomness */ |
| 42622 | | - winSleep, /* xSleep */ |
| 42623 | | - winCurrentTime, /* xCurrentTime */ |
| 42624 | | - winGetLastError, /* xGetLastError */ |
| 42625 | | - winCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 42626 | | - winSetSystemCall, /* xSetSystemCall */ |
| 42627 | | - winGetSystemCall, /* xGetSystemCall */ |
| 42628 | | - winNextSystemCall, /* xNextSystemCall */ |
| 42937 | + 0, /* pNext */ |
| 42938 | + "win32", /* zName */ |
| 42939 | + &winAppData, /* pAppData */ |
| 42940 | + winOpen, /* xOpen */ |
| 42941 | + winDelete, /* xDelete */ |
| 42942 | + winAccess, /* xAccess */ |
| 42943 | + winFullPathname, /* xFullPathname */ |
| 42944 | + winDlOpen, /* xDlOpen */ |
| 42945 | + winDlError, /* xDlError */ |
| 42946 | + winDlSym, /* xDlSym */ |
| 42947 | + winDlClose, /* xDlClose */ |
| 42948 | + winRandomness, /* xRandomness */ |
| 42949 | + winSleep, /* xSleep */ |
| 42950 | + winCurrentTime, /* xCurrentTime */ |
| 42951 | + winGetLastError, /* xGetLastError */ |
| 42952 | + winCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 42953 | + winSetSystemCall, /* xSetSystemCall */ |
| 42954 | + winGetSystemCall, /* xGetSystemCall */ |
| 42955 | + winNextSystemCall, /* xNextSystemCall */ |
| 42629 | 42956 | }; |
| 42630 | 42957 | #if defined(SQLITE_WIN32_HAS_WIDE) |
| 42631 | 42958 | static sqlite3_vfs winLongPathVfs = { |
| 42632 | | - 3, /* iVersion */ |
| 42633 | | - sizeof(winFile), /* szOsFile */ |
| 42959 | + 3, /* iVersion */ |
| 42960 | + sizeof(winFile), /* szOsFile */ |
| 42961 | + SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */ |
| 42962 | + 0, /* pNext */ |
| 42963 | + "win32-longpath", /* zName */ |
| 42964 | + &winAppData, /* pAppData */ |
| 42965 | + winOpen, /* xOpen */ |
| 42966 | + winDelete, /* xDelete */ |
| 42967 | + winAccess, /* xAccess */ |
| 42968 | + winFullPathname, /* xFullPathname */ |
| 42969 | + winDlOpen, /* xDlOpen */ |
| 42970 | + winDlError, /* xDlError */ |
| 42971 | + winDlSym, /* xDlSym */ |
| 42972 | + winDlClose, /* xDlClose */ |
| 42973 | + winRandomness, /* xRandomness */ |
| 42974 | + winSleep, /* xSleep */ |
| 42975 | + winCurrentTime, /* xCurrentTime */ |
| 42976 | + winGetLastError, /* xGetLastError */ |
| 42977 | + winCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 42978 | + winSetSystemCall, /* xSetSystemCall */ |
| 42979 | + winGetSystemCall, /* xGetSystemCall */ |
| 42980 | + winNextSystemCall, /* xNextSystemCall */ |
| 42981 | + }; |
| 42982 | +#endif |
| 42983 | + static sqlite3_vfs winNolockVfs = { |
| 42984 | + 3, /* iVersion */ |
| 42985 | + sizeof(winFile), /* szOsFile */ |
| 42986 | + SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */ |
| 42987 | + 0, /* pNext */ |
| 42988 | + "win32-none", /* zName */ |
| 42989 | + &winNolockAppData, /* pAppData */ |
| 42990 | + winOpen, /* xOpen */ |
| 42991 | + winDelete, /* xDelete */ |
| 42992 | + winAccess, /* xAccess */ |
| 42993 | + winFullPathname, /* xFullPathname */ |
| 42994 | + winDlOpen, /* xDlOpen */ |
| 42995 | + winDlError, /* xDlError */ |
| 42996 | + winDlSym, /* xDlSym */ |
| 42997 | + winDlClose, /* xDlClose */ |
| 42998 | + winRandomness, /* xRandomness */ |
| 42999 | + winSleep, /* xSleep */ |
| 43000 | + winCurrentTime, /* xCurrentTime */ |
| 43001 | + winGetLastError, /* xGetLastError */ |
| 43002 | + winCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 43003 | + winSetSystemCall, /* xSetSystemCall */ |
| 43004 | + winGetSystemCall, /* xGetSystemCall */ |
| 43005 | + winNextSystemCall, /* xNextSystemCall */ |
| 43006 | + }; |
| 43007 | +#if defined(SQLITE_WIN32_HAS_WIDE) |
| 43008 | + static sqlite3_vfs winLongPathNolockVfs = { |
| 43009 | + 3, /* iVersion */ |
| 43010 | + sizeof(winFile), /* szOsFile */ |
| 42634 | 43011 | SQLITE_WINNT_MAX_PATH_BYTES, /* mxPathname */ |
| 42635 | | - 0, /* pNext */ |
| 42636 | | - "win32-longpath", /* zName */ |
| 42637 | | - 0, /* pAppData */ |
| 42638 | | - winOpen, /* xOpen */ |
| 42639 | | - winDelete, /* xDelete */ |
| 42640 | | - winAccess, /* xAccess */ |
| 42641 | | - winFullPathname, /* xFullPathname */ |
| 42642 | | - winDlOpen, /* xDlOpen */ |
| 42643 | | - winDlError, /* xDlError */ |
| 42644 | | - winDlSym, /* xDlSym */ |
| 42645 | | - winDlClose, /* xDlClose */ |
| 42646 | | - winRandomness, /* xRandomness */ |
| 42647 | | - winSleep, /* xSleep */ |
| 42648 | | - winCurrentTime, /* xCurrentTime */ |
| 42649 | | - winGetLastError, /* xGetLastError */ |
| 42650 | | - winCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 42651 | | - winSetSystemCall, /* xSetSystemCall */ |
| 42652 | | - winGetSystemCall, /* xGetSystemCall */ |
| 42653 | | - winNextSystemCall, /* xNextSystemCall */ |
| 43012 | + 0, /* pNext */ |
| 43013 | + "win32-longpath-none", /* zName */ |
| 43014 | + &winNolockAppData, /* pAppData */ |
| 43015 | + winOpen, /* xOpen */ |
| 43016 | + winDelete, /* xDelete */ |
| 43017 | + winAccess, /* xAccess */ |
| 43018 | + winFullPathname, /* xFullPathname */ |
| 43019 | + winDlOpen, /* xDlOpen */ |
| 43020 | + winDlError, /* xDlError */ |
| 43021 | + winDlSym, /* xDlSym */ |
| 43022 | + winDlClose, /* xDlClose */ |
| 43023 | + winRandomness, /* xRandomness */ |
| 43024 | + winSleep, /* xSleep */ |
| 43025 | + winCurrentTime, /* xCurrentTime */ |
| 43026 | + winGetLastError, /* xGetLastError */ |
| 43027 | + winCurrentTimeInt64, /* xCurrentTimeInt64 */ |
| 43028 | + winSetSystemCall, /* xSetSystemCall */ |
| 43029 | + winGetSystemCall, /* xGetSystemCall */ |
| 43030 | + winNextSystemCall, /* xNextSystemCall */ |
| 42654 | 43031 | }; |
| 42655 | 43032 | #endif |
| 42656 | 43033 | |
| 42657 | 43034 | /* Double-check that the aSyscall[] array has been constructed |
| 42658 | 43035 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| | @@ -42671,10 +43048,16 @@ |
| 42671 | 43048 | sqlite3_vfs_register(&winVfs, 1); |
| 42672 | 43049 | |
| 42673 | 43050 | #if defined(SQLITE_WIN32_HAS_WIDE) |
| 42674 | 43051 | sqlite3_vfs_register(&winLongPathVfs, 0); |
| 42675 | 43052 | #endif |
| 43053 | + |
| 43054 | + sqlite3_vfs_register(&winNolockVfs, 0); |
| 43055 | + |
| 43056 | +#if defined(SQLITE_WIN32_HAS_WIDE) |
| 43057 | + sqlite3_vfs_register(&winLongPathNolockVfs, 0); |
| 43058 | +#endif |
| 42676 | 43059 | |
| 42677 | 43060 | return SQLITE_OK; |
| 42678 | 43061 | } |
| 42679 | 43062 | |
| 42680 | 43063 | SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){ |
| | @@ -43792,32 +44175,34 @@ |
| 43792 | 44175 | sqlite3PcacheTruncate(pCache, 0); |
| 43793 | 44176 | } |
| 43794 | 44177 | |
| 43795 | 44178 | /* |
| 43796 | 44179 | ** Merge two lists of pages connected by pDirty and in pgno order. |
| 43797 | | -** Do not both fixing the pDirtyPrev pointers. |
| 44180 | +** Do not bother fixing the pDirtyPrev pointers. |
| 43798 | 44181 | */ |
| 43799 | 44182 | static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){ |
| 43800 | 44183 | PgHdr result, *pTail; |
| 43801 | 44184 | pTail = &result; |
| 43802 | | - while( pA && pB ){ |
| 44185 | + assert( pA!=0 && pB!=0 ); |
| 44186 | + for(;;){ |
| 43803 | 44187 | if( pA->pgno<pB->pgno ){ |
| 43804 | 44188 | pTail->pDirty = pA; |
| 43805 | 44189 | pTail = pA; |
| 43806 | 44190 | pA = pA->pDirty; |
| 44191 | + if( pA==0 ){ |
| 44192 | + pTail->pDirty = pB; |
| 44193 | + break; |
| 44194 | + } |
| 43807 | 44195 | }else{ |
| 43808 | 44196 | pTail->pDirty = pB; |
| 43809 | 44197 | pTail = pB; |
| 43810 | 44198 | pB = pB->pDirty; |
| 43811 | | - } |
| 43812 | | - } |
| 43813 | | - if( pA ){ |
| 43814 | | - pTail->pDirty = pA; |
| 43815 | | - }else if( pB ){ |
| 43816 | | - pTail->pDirty = pB; |
| 43817 | | - }else{ |
| 43818 | | - pTail->pDirty = 0; |
| 44199 | + if( pB==0 ){ |
| 44200 | + pTail->pDirty = pA; |
| 44201 | + break; |
| 44202 | + } |
| 44203 | + } |
| 43819 | 44204 | } |
| 43820 | 44205 | return result.pDirty; |
| 43821 | 44206 | } |
| 43822 | 44207 | |
| 43823 | 44208 | /* |
| | @@ -43855,11 +44240,12 @@ |
| 43855 | 44240 | a[i] = pcacheMergeDirtyList(a[i], p); |
| 43856 | 44241 | } |
| 43857 | 44242 | } |
| 43858 | 44243 | p = a[0]; |
| 43859 | 44244 | for(i=1; i<N_SORT_BUCKET; i++){ |
| 43860 | | - p = pcacheMergeDirtyList(p, a[i]); |
| 44245 | + if( a[i]==0 ) continue; |
| 44246 | + p = p ? pcacheMergeDirtyList(p, a[i]) : a[i]; |
| 43861 | 44247 | } |
| 43862 | 44248 | return p; |
| 43863 | 44249 | } |
| 43864 | 44250 | |
| 43865 | 44251 | /* |
| | @@ -44610,29 +44996,49 @@ |
| 44610 | 44996 | */ |
| 44611 | 44997 | static void pcache1TruncateUnsafe( |
| 44612 | 44998 | PCache1 *pCache, /* The cache to truncate */ |
| 44613 | 44999 | unsigned int iLimit /* Drop pages with this pgno or larger */ |
| 44614 | 45000 | ){ |
| 44615 | | - TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */ |
| 44616 | | - unsigned int h; |
| 45001 | + TESTONLY( int nPage = 0; ) /* To assert pCache->nPage is correct */ |
| 45002 | + unsigned int h, iStop; |
| 44617 | 45003 | assert( sqlite3_mutex_held(pCache->pGroup->mutex) ); |
| 44618 | | - for(h=0; h<pCache->nHash; h++){ |
| 44619 | | - PgHdr1 **pp = &pCache->apHash[h]; |
| 45004 | + assert( pCache->iMaxKey >= iLimit ); |
| 45005 | + assert( pCache->nHash > 0 ); |
| 45006 | + if( pCache->iMaxKey - iLimit < pCache->nHash ){ |
| 45007 | + /* If we are just shaving the last few pages off the end of the |
| 45008 | + ** cache, then there is no point in scanning the entire hash table. |
| 45009 | + ** Only scan those hash slots that might contain pages that need to |
| 45010 | + ** be removed. */ |
| 45011 | + h = iLimit % pCache->nHash; |
| 45012 | + iStop = pCache->iMaxKey % pCache->nHash; |
| 45013 | + TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */ |
| 45014 | + }else{ |
| 45015 | + /* This is the general case where many pages are being removed. |
| 45016 | + ** It is necessary to scan the entire hash table */ |
| 45017 | + h = pCache->nHash/2; |
| 45018 | + iStop = h - 1; |
| 45019 | + } |
| 45020 | + for(;;){ |
| 45021 | + PgHdr1 **pp; |
| 44620 | 45022 | PgHdr1 *pPage; |
| 45023 | + assert( h<pCache->nHash ); |
| 45024 | + pp = &pCache->apHash[h]; |
| 44621 | 45025 | while( (pPage = *pp)!=0 ){ |
| 44622 | 45026 | if( pPage->iKey>=iLimit ){ |
| 44623 | 45027 | pCache->nPage--; |
| 44624 | 45028 | *pp = pPage->pNext; |
| 44625 | 45029 | if( !pPage->isPinned ) pcache1PinPage(pPage); |
| 44626 | 45030 | pcache1FreePage(pPage); |
| 44627 | 45031 | }else{ |
| 44628 | 45032 | pp = &pPage->pNext; |
| 44629 | | - TESTONLY( nPage++; ) |
| 45033 | + TESTONLY( if( nPage>=0 ) nPage++; ) |
| 44630 | 45034 | } |
| 44631 | 45035 | } |
| 45036 | + if( h==iStop ) break; |
| 45037 | + h = (h+1) % pCache->nHash; |
| 44632 | 45038 | } |
| 44633 | | - assert( pCache->nPage==nPage ); |
| 45039 | + assert( nPage<0 || pCache->nPage==(unsigned)nPage ); |
| 44634 | 45040 | } |
| 44635 | 45041 | |
| 44636 | 45042 | /******************************************************************************/ |
| 44637 | 45043 | /******** sqlite3_pcache Methods **********************************************/ |
| 44638 | 45044 | |
| | @@ -45105,11 +45511,11 @@ |
| 45105 | 45511 | static void pcache1Destroy(sqlite3_pcache *p){ |
| 45106 | 45512 | PCache1 *pCache = (PCache1 *)p; |
| 45107 | 45513 | PGroup *pGroup = pCache->pGroup; |
| 45108 | 45514 | assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) ); |
| 45109 | 45515 | pcache1EnterMutex(pGroup); |
| 45110 | | - pcache1TruncateUnsafe(pCache, 0); |
| 45516 | + if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0); |
| 45111 | 45517 | assert( pGroup->nMaxPage >= pCache->nMax ); |
| 45112 | 45518 | pGroup->nMaxPage -= pCache->nMax; |
| 45113 | 45519 | assert( pGroup->nMinPage >= pCache->nMin ); |
| 45114 | 45520 | pGroup->nMinPage -= pCache->nMin; |
| 45115 | 45521 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| | @@ -45460,31 +45866,29 @@ |
| 45460 | 45866 | ){ |
| 45461 | 45867 | struct RowSetEntry head; |
| 45462 | 45868 | struct RowSetEntry *pTail; |
| 45463 | 45869 | |
| 45464 | 45870 | pTail = &head; |
| 45465 | | - while( pA && pB ){ |
| 45871 | + assert( pA!=0 && pB!=0 ); |
| 45872 | + for(;;){ |
| 45466 | 45873 | assert( pA->pRight==0 || pA->v<=pA->pRight->v ); |
| 45467 | 45874 | assert( pB->pRight==0 || pB->v<=pB->pRight->v ); |
| 45468 | | - if( pA->v<pB->v ){ |
| 45469 | | - pTail->pRight = pA; |
| 45875 | + if( pA->v<=pB->v ){ |
| 45876 | + if( pA->v<pB->v ) pTail = pTail->pRight = pA; |
| 45470 | 45877 | pA = pA->pRight; |
| 45471 | | - pTail = pTail->pRight; |
| 45472 | | - }else if( pB->v<pA->v ){ |
| 45473 | | - pTail->pRight = pB; |
| 45878 | + if( pA==0 ){ |
| 45879 | + pTail->pRight = pB; |
| 45880 | + break; |
| 45881 | + } |
| 45882 | + }else{ |
| 45883 | + pTail = pTail->pRight = pB; |
| 45474 | 45884 | pB = pB->pRight; |
| 45475 | | - pTail = pTail->pRight; |
| 45476 | | - }else{ |
| 45477 | | - pA = pA->pRight; |
| 45478 | | - } |
| 45479 | | - } |
| 45480 | | - if( pA ){ |
| 45481 | | - assert( pA->pRight==0 || pA->v<=pA->pRight->v ); |
| 45482 | | - pTail->pRight = pA; |
| 45483 | | - }else{ |
| 45484 | | - assert( pB==0 || pB->pRight==0 || pB->v<=pB->pRight->v ); |
| 45485 | | - pTail->pRight = pB; |
| 45885 | + if( pB==0 ){ |
| 45886 | + pTail->pRight = pA; |
| 45887 | + break; |
| 45888 | + } |
| 45889 | + } |
| 45486 | 45890 | } |
| 45487 | 45891 | return head.pRight; |
| 45488 | 45892 | } |
| 45489 | 45893 | |
| 45490 | 45894 | /* |
| | @@ -45504,13 +45908,14 @@ |
| 45504 | 45908 | aBucket[i] = 0; |
| 45505 | 45909 | } |
| 45506 | 45910 | aBucket[i] = pIn; |
| 45507 | 45911 | pIn = pNext; |
| 45508 | 45912 | } |
| 45509 | | - pIn = 0; |
| 45510 | | - for(i=0; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){ |
| 45511 | | - pIn = rowSetEntryMerge(pIn, aBucket[i]); |
| 45913 | + pIn = aBucket[0]; |
| 45914 | + for(i=1; i<sizeof(aBucket)/sizeof(aBucket[0]); i++){ |
| 45915 | + if( aBucket[i]==0 ) continue; |
| 45916 | + pIn = pIn ? rowSetEntryMerge(pIn, aBucket[i]) : aBucket[i]; |
| 45512 | 45917 | } |
| 45513 | 45918 | return pIn; |
| 45514 | 45919 | } |
| 45515 | 45920 | |
| 45516 | 45921 | |
| | @@ -45758,12 +46163,12 @@ |
| 45758 | 46163 | ** This header file defines the interface to the write-ahead logging |
| 45759 | 46164 | ** system. Refer to the comments below and the header comment attached to |
| 45760 | 46165 | ** the implementation of each function in log.c for further details. |
| 45761 | 46166 | */ |
| 45762 | 46167 | |
| 45763 | | -#ifndef _WAL_H_ |
| 45764 | | -#define _WAL_H_ |
| 46168 | +#ifndef SQLITE_WAL_H |
| 46169 | +#define SQLITE_WAL_H |
| 45765 | 46170 | |
| 45766 | 46171 | /* #include "sqliteInt.h" */ |
| 45767 | 46172 | |
| 45768 | 46173 | /* Additional values that can be added to the sync_flags argument of |
| 45769 | 46174 | ** sqlite3WalFrames(): |
| | @@ -45887,11 +46292,11 @@ |
| 45887 | 46292 | |
| 45888 | 46293 | /* Return the sqlite3_file object for the WAL file */ |
| 45889 | 46294 | SQLITE_PRIVATE sqlite3_file *sqlite3WalFile(Wal *pWal); |
| 45890 | 46295 | |
| 45891 | 46296 | #endif /* ifndef SQLITE_OMIT_WAL */ |
| 45892 | | -#endif /* _WAL_H_ */ |
| 46297 | +#endif /* SQLITE_WAL_H */ |
| 45893 | 46298 | |
| 45894 | 46299 | /************** End of wal.h *************************************************/ |
| 45895 | 46300 | /************** Continuing where we left off in pager.c **********************/ |
| 45896 | 46301 | |
| 45897 | 46302 | |
| | @@ -53036,10 +53441,11 @@ |
| 53036 | 53441 | SQLITE_PRIVATE void sqlite3PagerClearCache(Pager *pPager){ |
| 53037 | 53442 | assert( MEMDB==0 || pPager->tempFile ); |
| 53038 | 53443 | if( pPager->tempFile==0 ) pager_reset(pPager); |
| 53039 | 53444 | } |
| 53040 | 53445 | #endif |
| 53446 | + |
| 53041 | 53447 | |
| 53042 | 53448 | #ifndef SQLITE_OMIT_WAL |
| 53043 | 53449 | /* |
| 53044 | 53450 | ** This function is called when the user invokes "PRAGMA wal_checkpoint", |
| 53045 | 53451 | ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint() |
| | @@ -53261,11 +53667,10 @@ |
| 53261 | 53667 | SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){ |
| 53262 | 53668 | assert( pPager->eState>=PAGER_READER ); |
| 53263 | 53669 | return sqlite3WalFramesize(pPager->pWal); |
| 53264 | 53670 | } |
| 53265 | 53671 | #endif |
| 53266 | | - |
| 53267 | 53672 | |
| 53268 | 53673 | #endif /* SQLITE_OMIT_DISKIO */ |
| 53269 | 53674 | |
| 53270 | 53675 | /************** End of pager.c ***********************************************/ |
| 53271 | 53676 | /************** Begin file wal.c *********************************************/ |
| | @@ -56378,20 +56783,25 @@ |
| 56378 | 56783 | ** boundary is crossed. Only the part of the WAL prior to the last |
| 56379 | 56784 | ** sector boundary is synced; the part of the last frame that extends |
| 56380 | 56785 | ** past the sector boundary is written after the sync. |
| 56381 | 56786 | */ |
| 56382 | 56787 | if( isCommit && (sync_flags & WAL_SYNC_TRANSACTIONS)!=0 ){ |
| 56788 | + int bSync = 1; |
| 56383 | 56789 | if( pWal->padToSectorBoundary ){ |
| 56384 | 56790 | int sectorSize = sqlite3SectorSize(pWal->pWalFd); |
| 56385 | 56791 | w.iSyncPoint = ((iOffset+sectorSize-1)/sectorSize)*sectorSize; |
| 56792 | + bSync = (w.iSyncPoint==iOffset); |
| 56793 | + testcase( bSync ); |
| 56386 | 56794 | while( iOffset<w.iSyncPoint ){ |
| 56387 | 56795 | rc = walWriteOneFrame(&w, pLast, nTruncate, iOffset); |
| 56388 | 56796 | if( rc ) return rc; |
| 56389 | 56797 | iOffset += szFrame; |
| 56390 | 56798 | nExtra++; |
| 56391 | 56799 | } |
| 56392 | | - }else{ |
| 56800 | + } |
| 56801 | + if( bSync ){ |
| 56802 | + assert( rc==SQLITE_OK ); |
| 56393 | 56803 | rc = sqlite3OsSync(w.pFd, sync_flags & SQLITE_SYNC_MASK); |
| 56394 | 56804 | } |
| 56395 | 56805 | } |
| 56396 | 56806 | |
| 56397 | 56807 | /* If this frame set completes the first transaction in the WAL and |
| | @@ -58174,10 +58584,19 @@ |
| 58174 | 58584 | */ |
| 58175 | 58585 | #ifdef SQLITE_DEBUG |
| 58176 | 58586 | static int cursorHoldsMutex(BtCursor *p){ |
| 58177 | 58587 | return sqlite3_mutex_held(p->pBt->mutex); |
| 58178 | 58588 | } |
| 58589 | + |
| 58590 | +/* Verify that the cursor and the BtShared agree about what is the current |
| 58591 | +** database connetion. This is important in shared-cache mode. If the database |
| 58592 | +** connection pointers get out-of-sync, it is possible for routines like |
| 58593 | +** btreeInitPage() to reference an stale connection pointer that references a |
| 58594 | +** a connection that has already closed. This routine is used inside assert() |
| 58595 | +** statements only and for the purpose of double-checking that the btree code |
| 58596 | +** does keep the database connection pointers up-to-date. |
| 58597 | +*/ |
| 58179 | 58598 | static int cursorOwnsBtShared(BtCursor *p){ |
| 58180 | 58599 | assert( cursorHoldsMutex(p) ); |
| 58181 | 58600 | return (p->pBtree->db==p->pBt->db); |
| 58182 | 58601 | } |
| 58183 | 58602 | #endif |
| | @@ -58333,25 +58752,23 @@ |
| 58333 | 58752 | ** NULL. If the cursor is open on a non-intkey table, then pCur->pKey is |
| 58334 | 58753 | ** set to point to a malloced buffer pCur->nKey bytes in size containing |
| 58335 | 58754 | ** the key. |
| 58336 | 58755 | */ |
| 58337 | 58756 | static int saveCursorKey(BtCursor *pCur){ |
| 58338 | | - int rc; |
| 58757 | + int rc = SQLITE_OK; |
| 58339 | 58758 | assert( CURSOR_VALID==pCur->eState ); |
| 58340 | 58759 | assert( 0==pCur->pKey ); |
| 58341 | 58760 | assert( cursorHoldsMutex(pCur) ); |
| 58342 | 58761 | |
| 58343 | | - rc = sqlite3BtreeKeySize(pCur, &pCur->nKey); |
| 58344 | | - assert( rc==SQLITE_OK ); /* KeySize() cannot fail */ |
| 58345 | | - |
| 58346 | | - /* If this is an intKey table, then the above call to BtreeKeySize() |
| 58347 | | - ** stores the integer key in pCur->nKey. In this case this value is |
| 58348 | | - ** all that is required. Otherwise, if pCur is not open on an intKey |
| 58349 | | - ** table, then malloc space for and store the pCur->nKey bytes of key |
| 58350 | | - ** data. */ |
| 58351 | | - if( 0==pCur->curIntKey ){ |
| 58352 | | - void *pKey = sqlite3Malloc( pCur->nKey ); |
| 58762 | + if( pCur->curIntKey ){ |
| 58763 | + /* Only the rowid is required for a table btree */ |
| 58764 | + pCur->nKey = sqlite3BtreeIntegerKey(pCur); |
| 58765 | + }else{ |
| 58766 | + /* For an index btree, save the complete key content */ |
| 58767 | + void *pKey; |
| 58768 | + pCur->nKey = sqlite3BtreePayloadSize(pCur); |
| 58769 | + pKey = sqlite3Malloc( pCur->nKey ); |
| 58353 | 58770 | if( pKey ){ |
| 58354 | 58771 | rc = sqlite3BtreeKey(pCur, 0, (int)pCur->nKey, pKey); |
| 58355 | 58772 | if( rc==SQLITE_OK ){ |
| 58356 | 58773 | pCur->pKey = pKey; |
| 58357 | 58774 | }else{ |
| | @@ -60054,13 +60471,13 @@ |
| 60054 | 60471 | assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */ |
| 60055 | 60472 | |
| 60056 | 60473 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO) |
| 60057 | 60474 | /* Add the new BtShared object to the linked list sharable BtShareds. |
| 60058 | 60475 | */ |
| 60476 | + pBt->nRef = 1; |
| 60059 | 60477 | if( p->sharable ){ |
| 60060 | 60478 | MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) |
| 60061 | | - pBt->nRef = 1; |
| 60062 | 60479 | MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);) |
| 60063 | 60480 | if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){ |
| 60064 | 60481 | pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST); |
| 60065 | 60482 | if( pBt->mutex==0 ){ |
| 60066 | 60483 | rc = SQLITE_NOMEM_BKPT; |
| | @@ -60127,10 +60544,11 @@ |
| 60127 | 60544 | } |
| 60128 | 60545 | if( mutexOpen ){ |
| 60129 | 60546 | assert( sqlite3_mutex_held(mutexOpen) ); |
| 60130 | 60547 | sqlite3_mutex_leave(mutexOpen); |
| 60131 | 60548 | } |
| 60549 | + assert( rc!=SQLITE_OK || sqlite3BtreeConnectionCount(*ppBtree)>0 ); |
| 60132 | 60550 | return rc; |
| 60133 | 60551 | } |
| 60134 | 60552 | |
| 60135 | 60553 | /* |
| 60136 | 60554 | ** Decrement the BtShared.nRef counter. When it reaches zero, |
| | @@ -61986,50 +62404,37 @@ |
| 61986 | 62404 | return pCur && pCur->eState==CURSOR_VALID; |
| 61987 | 62405 | } |
| 61988 | 62406 | #endif /* NDEBUG */ |
| 61989 | 62407 | |
| 61990 | 62408 | /* |
| 61991 | | -** Set *pSize to the size of the buffer needed to hold the value of |
| 61992 | | -** the key for the current entry. If the cursor is not pointing |
| 61993 | | -** to a valid entry, *pSize is set to 0. |
| 61994 | | -** |
| 61995 | | -** For a table with the INTKEY flag set, this routine returns the key |
| 61996 | | -** itself, not the number of bytes in the key. |
| 61997 | | -** |
| 61998 | | -** The caller must position the cursor prior to invoking this routine. |
| 61999 | | -** |
| 62000 | | -** This routine cannot fail. It always returns SQLITE_OK. |
| 62409 | +** Return the value of the integer key or "rowid" for a table btree. |
| 62410 | +** This routine is only valid for a cursor that is pointing into a |
| 62411 | +** ordinary table btree. If the cursor points to an index btree or |
| 62412 | +** is invalid, the result of this routine is undefined. |
| 62001 | 62413 | */ |
| 62002 | | -SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){ |
| 62414 | +SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor *pCur){ |
| 62003 | 62415 | assert( cursorHoldsMutex(pCur) ); |
| 62004 | 62416 | assert( pCur->eState==CURSOR_VALID ); |
| 62417 | + assert( pCur->curIntKey ); |
| 62005 | 62418 | getCellInfo(pCur); |
| 62006 | | - *pSize = pCur->info.nKey; |
| 62007 | | - return SQLITE_OK; |
| 62419 | + return pCur->info.nKey; |
| 62008 | 62420 | } |
| 62009 | 62421 | |
| 62010 | 62422 | /* |
| 62011 | | -** Set *pSize to the number of bytes of data in the entry the |
| 62012 | | -** cursor currently points to. |
| 62423 | +** Return the number of bytes of payload for the entry that pCur is |
| 62424 | +** currently pointing to. For table btrees, this will be the amount |
| 62425 | +** of data. For index btrees, this will be the size of the key. |
| 62013 | 62426 | ** |
| 62014 | 62427 | ** The caller must guarantee that the cursor is pointing to a non-NULL |
| 62015 | 62428 | ** valid entry. In other words, the calling procedure must guarantee |
| 62016 | 62429 | ** that the cursor has Cursor.eState==CURSOR_VALID. |
| 62017 | | -** |
| 62018 | | -** Failure is not possible. This function always returns SQLITE_OK. |
| 62019 | | -** It might just as well be a procedure (returning void) but we continue |
| 62020 | | -** to return an integer result code for historical reasons. |
| 62021 | 62430 | */ |
| 62022 | | -SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){ |
| 62023 | | - assert( cursorOwnsBtShared(pCur) ); |
| 62431 | +SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){ |
| 62432 | + assert( cursorHoldsMutex(pCur) ); |
| 62024 | 62433 | assert( pCur->eState==CURSOR_VALID ); |
| 62025 | | - assert( pCur->iPage>=0 ); |
| 62026 | | - assert( pCur->iPage<BTCURSOR_MAX_DEPTH ); |
| 62027 | | - assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 ); |
| 62028 | 62434 | getCellInfo(pCur); |
| 62029 | | - *pSize = pCur->info.nPayload; |
| 62030 | | - return SQLITE_OK; |
| 62435 | + return pCur->info.nPayload; |
| 62031 | 62436 | } |
| 62032 | 62437 | |
| 62033 | 62438 | /* |
| 62034 | 62439 | ** Given the page number of an overflow page in the database (parameter |
| 62035 | 62440 | ** ovfl), this function finds the page number of the next page in the |
| | @@ -62467,14 +62872,11 @@ |
| 62467 | 62872 | ** this routine. |
| 62468 | 62873 | ** |
| 62469 | 62874 | ** These routines is used to get quick access to key and data |
| 62470 | 62875 | ** in the common case where no overflow pages are used. |
| 62471 | 62876 | */ |
| 62472 | | -SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor *pCur, u32 *pAmt){ |
| 62473 | | - return fetchPayload(pCur, pAmt); |
| 62474 | | -} |
| 62475 | | -SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor *pCur, u32 *pAmt){ |
| 62877 | +SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor *pCur, u32 *pAmt){ |
| 62476 | 62878 | return fetchPayload(pCur, pAmt); |
| 62477 | 62879 | } |
| 62478 | 62880 | |
| 62479 | 62881 | |
| 62480 | 62882 | /* |
| | @@ -62803,15 +63205,16 @@ |
| 62803 | 63205 | |
| 62804 | 63206 | assert( cursorOwnsBtShared(pCur) ); |
| 62805 | 63207 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 62806 | 63208 | assert( pRes ); |
| 62807 | 63209 | assert( (pIdxKey==0)==(pCur->pKeyInfo==0) ); |
| 63210 | + assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) ); |
| 62808 | 63211 | |
| 62809 | 63212 | /* If the cursor is already positioned at the point we are trying |
| 62810 | 63213 | ** to move to, then just return without doing any work */ |
| 62811 | | - if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 |
| 62812 | | - && pCur->curIntKey |
| 63214 | + if( pIdxKey==0 |
| 63215 | + && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 |
| 62813 | 63216 | ){ |
| 62814 | 63217 | if( pCur->info.nKey==intKey ){ |
| 62815 | 63218 | *pRes = 0; |
| 62816 | 63219 | return SQLITE_OK; |
| 62817 | 63220 | } |
| | @@ -63796,13 +64199,11 @@ |
| 63796 | 64199 | ** later. |
| 63797 | 64200 | */ |
| 63798 | 64201 | static int fillInCell( |
| 63799 | 64202 | MemPage *pPage, /* The page that contains the cell */ |
| 63800 | 64203 | unsigned char *pCell, /* Complete text of the cell */ |
| 63801 | | - const void *pKey, i64 nKey, /* The key */ |
| 63802 | | - const void *pData,int nData, /* The data */ |
| 63803 | | - int nZero, /* Extra zero bytes to append to pData */ |
| 64204 | + const BtreePayload *pX, /* Payload with which to construct the cell */ |
| 63804 | 64205 | int *pnSize /* Write cell size here */ |
| 63805 | 64206 | ){ |
| 63806 | 64207 | int nPayload; |
| 63807 | 64208 | const u8 *pSrc; |
| 63808 | 64209 | int nSrc, n, rc; |
| | @@ -63822,30 +64223,27 @@ |
| 63822 | 64223 | assert( pCell<pPage->aData || pCell>=&pPage->aData[pBt->pageSize] |
| 63823 | 64224 | || sqlite3PagerIswriteable(pPage->pDbPage) ); |
| 63824 | 64225 | |
| 63825 | 64226 | /* Fill in the header. */ |
| 63826 | 64227 | nHeader = pPage->childPtrSize; |
| 63827 | | - nPayload = nData + nZero; |
| 63828 | | - if( pPage->intKeyLeaf ){ |
| 63829 | | - nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 63830 | | - }else{ |
| 63831 | | - assert( nData==0 ); |
| 63832 | | - assert( nZero==0 ); |
| 63833 | | - } |
| 63834 | | - nHeader += putVarint(&pCell[nHeader], *(u64*)&nKey); |
| 63835 | | - |
| 63836 | | - /* Fill in the payload size */ |
| 63837 | 64228 | if( pPage->intKey ){ |
| 63838 | | - pSrc = pData; |
| 63839 | | - nSrc = nData; |
| 63840 | | - nData = 0; |
| 63841 | | - }else{ |
| 63842 | | - assert( nKey<=0x7fffffff && pKey!=0 ); |
| 63843 | | - nPayload = (int)nKey; |
| 63844 | | - pSrc = pKey; |
| 63845 | | - nSrc = (int)nKey; |
| 63846 | | - } |
| 64229 | + nPayload = pX->nData + pX->nZero; |
| 64230 | + pSrc = pX->pData; |
| 64231 | + nSrc = pX->nData; |
| 64232 | + assert( pPage->intKeyLeaf ); /* fillInCell() only called for leaves */ |
| 64233 | + nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64234 | + nHeader += putVarint(&pCell[nHeader], *(u64*)&pX->nKey); |
| 64235 | + }else{ |
| 64236 | + assert( pX->nData==0 ); |
| 64237 | + assert( pX->nZero==0 ); |
| 64238 | + assert( pX->nKey<=0x7fffffff && pX->pKey!=0 ); |
| 64239 | + nSrc = nPayload = (int)pX->nKey; |
| 64240 | + pSrc = pX->pKey; |
| 64241 | + nHeader += putVarint32(&pCell[nHeader], nPayload); |
| 64242 | + } |
| 64243 | + |
| 64244 | + /* Fill in the payload */ |
| 63847 | 64245 | if( nPayload<=pPage->maxLocal ){ |
| 63848 | 64246 | n = nHeader + nPayload; |
| 63849 | 64247 | testcase( n==3 ); |
| 63850 | 64248 | testcase( n==4 ); |
| 63851 | 64249 | if( n<4 ) n = 4; |
| | @@ -63879,11 +64277,11 @@ |
| 63879 | 64277 | #if SQLITE_DEBUG |
| 63880 | 64278 | { |
| 63881 | 64279 | CellInfo info; |
| 63882 | 64280 | pPage->xParseCell(pPage, pCell, &info); |
| 63883 | 64281 | assert( nHeader==(int)(info.pPayload - pCell) ); |
| 63884 | | - assert( info.nKey==nKey ); |
| 64282 | + assert( info.nKey==pX->nKey ); |
| 63885 | 64283 | assert( *pnSize == info.nSize ); |
| 63886 | 64284 | assert( spaceLeft == info.nLocal ); |
| 63887 | 64285 | } |
| 63888 | 64286 | #endif |
| 63889 | 64287 | |
| | @@ -63964,14 +64362,10 @@ |
| 63964 | 64362 | nPayload -= n; |
| 63965 | 64363 | pPayload += n; |
| 63966 | 64364 | pSrc += n; |
| 63967 | 64365 | nSrc -= n; |
| 63968 | 64366 | spaceLeft -= n; |
| 63969 | | - if( nSrc==0 ){ |
| 63970 | | - nSrc = nData; |
| 63971 | | - pSrc = pData; |
| 63972 | | - } |
| 63973 | 64367 | } |
| 63974 | 64368 | releasePage(pToRelease); |
| 63975 | 64369 | return SQLITE_OK; |
| 63976 | 64370 | } |
| 63977 | 64371 | |
| | @@ -64034,10 +64428,12 @@ |
| 64034 | 64428 | ** pTemp is not null. Regardless of pTemp, allocate a new entry |
| 64035 | 64429 | ** in pPage->apOvfl[] and make it point to the cell content (either |
| 64036 | 64430 | ** in pTemp or the original pCell) and also record its index. |
| 64037 | 64431 | ** Allocating a new entry in pPage->aCell[] implies that |
| 64038 | 64432 | ** pPage->nOverflow is incremented. |
| 64433 | +** |
| 64434 | +** *pRC must be SQLITE_OK when this routine is called. |
| 64039 | 64435 | */ |
| 64040 | 64436 | static void insertCell( |
| 64041 | 64437 | MemPage *pPage, /* Page into which we are copying */ |
| 64042 | 64438 | int i, /* New cell becomes the i-th cell of the page */ |
| 64043 | 64439 | u8 *pCell, /* Content of the new cell */ |
| | @@ -64049,12 +64445,11 @@ |
| 64049 | 64445 | int idx = 0; /* Where to write new cell content in data[] */ |
| 64050 | 64446 | int j; /* Loop counter */ |
| 64051 | 64447 | u8 *data; /* The content of the whole page */ |
| 64052 | 64448 | u8 *pIns; /* The point in pPage->aCellIdx[] where no cell inserted */ |
| 64053 | 64449 | |
| 64054 | | - if( *pRC ) return; |
| 64055 | | - |
| 64450 | + assert( *pRC==SQLITE_OK ); |
| 64056 | 64451 | assert( i>=0 && i<=pPage->nCell+pPage->nOverflow ); |
| 64057 | 64452 | assert( MX_CELL(pPage->pBt)<=10921 ); |
| 64058 | 64453 | assert( pPage->nCell<=MX_CELL(pPage->pBt) || CORRUPT_DB ); |
| 64059 | 64454 | assert( pPage->nOverflow<=ArraySize(pPage->apOvfl) ); |
| 64060 | 64455 | assert( ArraySize(pPage->apOvfl)==ArraySize(pPage->aiOvfl) ); |
| | @@ -64124,11 +64519,11 @@ |
| 64124 | 64519 | } |
| 64125 | 64520 | } |
| 64126 | 64521 | |
| 64127 | 64522 | /* |
| 64128 | 64523 | ** A CellArray object contains a cache of pointers and sizes for a |
| 64129 | | -** consecutive sequence of cells that might be held multiple pages. |
| 64524 | +** consecutive sequence of cells that might be held on multiple pages. |
| 64130 | 64525 | */ |
| 64131 | 64526 | typedef struct CellArray CellArray; |
| 64132 | 64527 | struct CellArray { |
| 64133 | 64528 | int nCell; /* Number of cells in apCell[] */ |
| 64134 | 64529 | MemPage *pRef; /* Reference page */ |
| | @@ -64556,12 +64951,14 @@ |
| 64556 | 64951 | while( (*(pCell++)&0x80) && pCell<pStop ); |
| 64557 | 64952 | pStop = &pCell[9]; |
| 64558 | 64953 | while( ((*(pOut++) = *(pCell++))&0x80) && pCell<pStop ); |
| 64559 | 64954 | |
| 64560 | 64955 | /* Insert the new divider cell into pParent. */ |
| 64561 | | - insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace), |
| 64562 | | - 0, pPage->pgno, &rc); |
| 64956 | + if( rc==SQLITE_OK ){ |
| 64957 | + insertCell(pParent, pParent->nCell, pSpace, (int)(pOut-pSpace), |
| 64958 | + 0, pPage->pgno, &rc); |
| 64959 | + } |
| 64563 | 64960 | |
| 64564 | 64961 | /* Set the right-child pointer of pParent to point to the new page. */ |
| 64565 | 64962 | put4byte(&pParent->aData[pParent->hdrOffset+8], pgnoNew); |
| 64566 | 64963 | |
| 64567 | 64964 | /* Release the reference to the new page. */ |
| | @@ -65077,11 +65474,11 @@ |
| 65077 | 65474 | do{ |
| 65078 | 65475 | assert( d<nMaxCells ); |
| 65079 | 65476 | assert( r<nMaxCells ); |
| 65080 | 65477 | (void)cachedCellSize(&b, r); |
| 65081 | 65478 | if( szRight!=0 |
| 65082 | | - && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+2)) ){ |
| 65479 | + && (bBulk || szRight+b.szCell[d]+2 > szLeft-(b.szCell[r]+(i==k-1?0:2)))){ |
| 65083 | 65480 | break; |
| 65084 | 65481 | } |
| 65085 | 65482 | szRight += b.szCell[d] + 2; |
| 65086 | 65483 | szLeft -= b.szCell[r] + 2; |
| 65087 | 65484 | cntNew[i-1] = r; |
| | @@ -65649,17 +66046,23 @@ |
| 65649 | 66046 | return rc; |
| 65650 | 66047 | } |
| 65651 | 66048 | |
| 65652 | 66049 | |
| 65653 | 66050 | /* |
| 65654 | | -** Insert a new record into the BTree. The key is given by (pKey,nKey) |
| 65655 | | -** and the data is given by (pData,nData). The cursor is used only to |
| 65656 | | -** define what table the record should be inserted into. The cursor |
| 65657 | | -** is left pointing at a random location. |
| 66051 | +** Insert a new record into the BTree. The content of the new record |
| 66052 | +** is described by the pX object. The pCur cursor is used only to |
| 66053 | +** define what table the record should be inserted into, and is left |
| 66054 | +** pointing at a random location. |
| 65658 | 66055 | ** |
| 65659 | | -** For an INTKEY table, only the nKey value of the key is used. pKey is |
| 65660 | | -** ignored. For a ZERODATA table, the pData and nData are both ignored. |
| 66056 | +** For a table btree (used for rowid tables), only the pX.nKey value of |
| 66057 | +** the key is used. The pX.pKey value must be NULL. The pX.nKey is the |
| 66058 | +** rowid or INTEGER PRIMARY KEY of the row. The pX.nData,pData,nZero fields |
| 66059 | +** hold the content of the row. |
| 66060 | +** |
| 66061 | +** For an index btree (used for indexes and WITHOUT ROWID tables), the |
| 66062 | +** key is an arbitrary byte sequence stored in pX.pKey,nKey. The |
| 66063 | +** pX.pData,nData,nZero fields must be zero. |
| 65661 | 66064 | ** |
| 65662 | 66065 | ** If the seekResult parameter is non-zero, then a successful call to |
| 65663 | 66066 | ** MovetoUnpacked() to seek cursor pCur to (pKey, nKey) has already |
| 65664 | 66067 | ** been performed. seekResult is the search result returned (a negative |
| 65665 | 66068 | ** number if pCur points at an entry that is smaller than (pKey, nKey), or |
| | @@ -65672,13 +66075,11 @@ |
| 65672 | 66075 | ** point to any entry or to no entry at all and so this function has to seek |
| 65673 | 66076 | ** the cursor before the new key can be inserted. |
| 65674 | 66077 | */ |
| 65675 | 66078 | SQLITE_PRIVATE int sqlite3BtreeInsert( |
| 65676 | 66079 | BtCursor *pCur, /* Insert data into the table of this cursor */ |
| 65677 | | - const void *pKey, i64 nKey, /* The key of the new record */ |
| 65678 | | - const void *pData, int nData, /* The data of the new record */ |
| 65679 | | - int nZero, /* Number of extra 0 bytes to append to data */ |
| 66080 | + const BtreePayload *pX, /* Content of the row to be inserted */ |
| 65680 | 66081 | int appendBias, /* True if this is likely an append */ |
| 65681 | 66082 | int seekResult /* Result of prior MovetoUnpacked() call */ |
| 65682 | 66083 | ){ |
| 65683 | 66084 | int rc; |
| 65684 | 66085 | int loc = seekResult; /* -1: before desired location +1: after */ |
| | @@ -65704,11 +66105,11 @@ |
| 65704 | 66105 | /* Assert that the caller has been consistent. If this cursor was opened |
| 65705 | 66106 | ** expecting an index b-tree, then the caller should be inserting blob |
| 65706 | 66107 | ** keys with no associated data. If the cursor was opened expecting an |
| 65707 | 66108 | ** intkey table, the caller should be inserting integer keys with a |
| 65708 | 66109 | ** blob of associated data. */ |
| 65709 | | - assert( (pKey==0)==(pCur->pKeyInfo==0) ); |
| 66110 | + assert( (pX->pKey==0)==(pCur->pKeyInfo==0) ); |
| 65710 | 66111 | |
| 65711 | 66112 | /* Save the positions of any other cursors open on this table. |
| 65712 | 66113 | ** |
| 65713 | 66114 | ** In some cases, the call to btreeMoveto() below is a no-op. For |
| 65714 | 66115 | ** example, when inserting data into a table with auto-generated integer |
| | @@ -65723,42 +66124,42 @@ |
| 65723 | 66124 | rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur); |
| 65724 | 66125 | if( rc ) return rc; |
| 65725 | 66126 | } |
| 65726 | 66127 | |
| 65727 | 66128 | if( pCur->pKeyInfo==0 ){ |
| 65728 | | - assert( pKey==0 ); |
| 66129 | + assert( pX->pKey==0 ); |
| 65729 | 66130 | /* If this is an insert into a table b-tree, invalidate any incrblob |
| 65730 | 66131 | ** cursors open on the row being replaced */ |
| 65731 | | - invalidateIncrblobCursors(p, nKey, 0); |
| 66132 | + invalidateIncrblobCursors(p, pX->nKey, 0); |
| 65732 | 66133 | |
| 65733 | 66134 | /* If the cursor is currently on the last row and we are appending a |
| 65734 | 66135 | ** new row onto the end, set the "loc" to avoid an unnecessary |
| 65735 | 66136 | ** btreeMoveto() call */ |
| 65736 | | - if( (pCur->curFlags&BTCF_ValidNKey)!=0 && nKey>0 |
| 65737 | | - && pCur->info.nKey==nKey-1 ){ |
| 66137 | + if( (pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey>0 |
| 66138 | + && pCur->info.nKey==pX->nKey-1 ){ |
| 65738 | 66139 | loc = -1; |
| 65739 | 66140 | }else if( loc==0 ){ |
| 65740 | | - rc = sqlite3BtreeMovetoUnpacked(pCur, 0, nKey, appendBias, &loc); |
| 66141 | + rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, appendBias, &loc); |
| 65741 | 66142 | if( rc ) return rc; |
| 65742 | 66143 | } |
| 65743 | 66144 | }else if( loc==0 ){ |
| 65744 | | - rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc); |
| 66145 | + rc = btreeMoveto(pCur, pX->pKey, pX->nKey, appendBias, &loc); |
| 65745 | 66146 | if( rc ) return rc; |
| 65746 | 66147 | } |
| 65747 | 66148 | assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) ); |
| 65748 | 66149 | |
| 65749 | 66150 | pPage = pCur->apPage[pCur->iPage]; |
| 65750 | | - assert( pPage->intKey || nKey>=0 ); |
| 66151 | + assert( pPage->intKey || pX->nKey>=0 ); |
| 65751 | 66152 | assert( pPage->leaf || !pPage->intKey ); |
| 65752 | 66153 | |
| 65753 | 66154 | TRACE(("INSERT: table=%d nkey=%lld ndata=%d page=%d %s\n", |
| 65754 | | - pCur->pgnoRoot, nKey, nData, pPage->pgno, |
| 66155 | + pCur->pgnoRoot, pX->nKey, pX->nData, pPage->pgno, |
| 65755 | 66156 | loc==0 ? "overwrite" : "new entry")); |
| 65756 | 66157 | assert( pPage->isInit ); |
| 65757 | 66158 | newCell = pBt->pTmpSpace; |
| 65758 | 66159 | assert( newCell!=0 ); |
| 65759 | | - rc = fillInCell(pPage, newCell, pKey, nKey, pData, nData, nZero, &szNew); |
| 66160 | + rc = fillInCell(pPage, newCell, pX, &szNew); |
| 65760 | 66161 | if( rc ) goto end_insert; |
| 65761 | 66162 | assert( szNew==pPage->xCellSize(pPage, newCell) ); |
| 65762 | 66163 | assert( szNew <= MX_CELL_SIZE(pBt) ); |
| 65763 | 66164 | idx = pCur->aiIdx[pCur->iPage]; |
| 65764 | 66165 | if( loc==0 ){ |
| | @@ -65780,10 +66181,11 @@ |
| 65780 | 66181 | idx = ++pCur->aiIdx[pCur->iPage]; |
| 65781 | 66182 | }else{ |
| 65782 | 66183 | assert( pPage->leaf ); |
| 65783 | 66184 | } |
| 65784 | 66185 | insertCell(pPage, idx, newCell, szNew, 0, 0, &rc); |
| 66186 | + assert( pPage->nOverflow==0 || rc==SQLITE_OK ); |
| 65785 | 66187 | assert( rc!=SQLITE_OK || pPage->nCell>0 || pPage->nOverflow>0 ); |
| 65786 | 66188 | |
| 65787 | 66189 | /* If no error has occurred and pPage has an overflow cell, call balance() |
| 65788 | 66190 | ** to redistribute the cells within the tree. Since balance() may move |
| 65789 | 66191 | ** the cursor, zero the BtCursor.info.nSize and BTCF_ValidNKey |
| | @@ -65803,11 +66205,12 @@ |
| 65803 | 66205 | ** entry in the table, and the next row inserted has an integer key |
| 65804 | 66206 | ** larger than the largest existing key, it is possible to insert the |
| 65805 | 66207 | ** row without seeking the cursor. This can be a big performance boost. |
| 65806 | 66208 | */ |
| 65807 | 66209 | pCur->info.nSize = 0; |
| 65808 | | - if( rc==SQLITE_OK && pPage->nOverflow ){ |
| 66210 | + if( pPage->nOverflow ){ |
| 66211 | + assert( rc==SQLITE_OK ); |
| 65809 | 66212 | pCur->curFlags &= ~(BTCF_ValidNKey); |
| 65810 | 66213 | rc = balance(pCur); |
| 65811 | 66214 | |
| 65812 | 66215 | /* Must make sure nOverflow is reset to zero even if the balance() |
| 65813 | 66216 | ** fails. Internal data structure corruption will result otherwise. |
| | @@ -65939,11 +66342,13 @@ |
| 65939 | 66342 | nCell = pLeaf->xCellSize(pLeaf, pCell); |
| 65940 | 66343 | assert( MX_CELL_SIZE(pBt) >= nCell ); |
| 65941 | 66344 | pTmp = pBt->pTmpSpace; |
| 65942 | 66345 | assert( pTmp!=0 ); |
| 65943 | 66346 | rc = sqlite3PagerWrite(pLeaf->pDbPage); |
| 65944 | | - insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc); |
| 66347 | + if( rc==SQLITE_OK ){ |
| 66348 | + insertCell(pPage, iCellIdx, pCell-4, nCell+4, pTmp, n, &rc); |
| 66349 | + } |
| 65945 | 66350 | dropCell(pLeaf, pLeaf->nCell-1, nCell, &rc); |
| 65946 | 66351 | if( rc ) return rc; |
| 65947 | 66352 | } |
| 65948 | 66353 | |
| 65949 | 66354 | /* Balance the tree. If the entry deleted was located on a leaf page, |
| | @@ -67428,10 +67833,20 @@ |
| 67428 | 67833 | ** Return true if the Btree passed as the only argument is sharable. |
| 67429 | 67834 | */ |
| 67430 | 67835 | SQLITE_PRIVATE int sqlite3BtreeSharable(Btree *p){ |
| 67431 | 67836 | return p->sharable; |
| 67432 | 67837 | } |
| 67838 | + |
| 67839 | +/* |
| 67840 | +** Return the number of connections to the BtShared object accessed by |
| 67841 | +** the Btree handle passed as the only argument. For private caches |
| 67842 | +** this is always 1. For shared caches it may be 1 or greater. |
| 67843 | +*/ |
| 67844 | +SQLITE_PRIVATE int sqlite3BtreeConnectionCount(Btree *p){ |
| 67845 | + testcase( p->sharable ); |
| 67846 | + return p->pBt->nRef; |
| 67847 | +} |
| 67433 | 67848 | #endif |
| 67434 | 67849 | |
| 67435 | 67850 | /************** End of btree.c ***********************************************/ |
| 67436 | 67851 | /************** Begin file backup.c ******************************************/ |
| 67437 | 67852 | /* |
| | @@ -68211,14 +68626,14 @@ |
| 68211 | 68626 | /* 0x7FFFFFFF is the hard limit for the number of pages in a database |
| 68212 | 68627 | ** file. By passing this as the number of pages to copy to |
| 68213 | 68628 | ** sqlite3_backup_step(), we can guarantee that the copy finishes |
| 68214 | 68629 | ** within a single call (unless an error occurs). The assert() statement |
| 68215 | 68630 | ** checks this assumption - (p->rc) should be set to either SQLITE_DONE |
| 68216 | | - ** or an error code. |
| 68217 | | - */ |
| 68631 | + ** or an error code. */ |
| 68218 | 68632 | sqlite3_backup_step(&b, 0x7FFFFFFF); |
| 68219 | 68633 | assert( b.rc!=SQLITE_OK ); |
| 68634 | + |
| 68220 | 68635 | rc = sqlite3_backup_finish(&b); |
| 68221 | 68636 | if( rc==SQLITE_OK ){ |
| 68222 | 68637 | pTo->pBt->btsFlags &= ~BTS_PAGESIZE_FIXED; |
| 68223 | 68638 | }else{ |
| 68224 | 68639 | sqlite3PagerClearCache(sqlite3BtreePager(b.pDest)); |
| | @@ -69225,15 +69640,11 @@ |
| 69225 | 69640 | assert( !VdbeMemDynamic(pMem) ); |
| 69226 | 69641 | |
| 69227 | 69642 | /* Note: the calls to BtreeKeyFetch() and DataFetch() below assert() |
| 69228 | 69643 | ** that both the BtShared and database handle mutexes are held. */ |
| 69229 | 69644 | assert( (pMem->flags & MEM_RowSet)==0 ); |
| 69230 | | - if( key ){ |
| 69231 | | - zData = (char *)sqlite3BtreeKeyFetch(pCur, &available); |
| 69232 | | - }else{ |
| 69233 | | - zData = (char *)sqlite3BtreeDataFetch(pCur, &available); |
| 69234 | | - } |
| 69645 | + zData = (char *)sqlite3BtreePayloadFetch(pCur, &available); |
| 69235 | 69646 | assert( zData!=0 ); |
| 69236 | 69647 | |
| 69237 | 69648 | if( offset+amt<=available ){ |
| 69238 | 69649 | pMem->z = &zData[offset]; |
| 69239 | 69650 | pMem->flags = MEM_Blob|MEM_Ephem; |
| | @@ -70009,18 +70420,10 @@ |
| 70009 | 70420 | assert( p->zSql==0 ); |
| 70010 | 70421 | p->zSql = sqlite3DbStrNDup(p->db, z, n); |
| 70011 | 70422 | p->isPrepareV2 = (u8)isPrepareV2; |
| 70012 | 70423 | } |
| 70013 | 70424 | |
| 70014 | | -/* |
| 70015 | | -** Return the SQL associated with a prepared statement |
| 70016 | | -*/ |
| 70017 | | -SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){ |
| 70018 | | - Vdbe *p = (Vdbe *)pStmt; |
| 70019 | | - return p ? p->zSql : 0; |
| 70020 | | -} |
| 70021 | | - |
| 70022 | 70425 | /* |
| 70023 | 70426 | ** Swap all content between two VDBE structures. |
| 70024 | 70427 | */ |
| 70025 | 70428 | SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){ |
| 70026 | 70429 | Vdbe tmp, *pTmp; |
| | @@ -70736,26 +71139,34 @@ |
| 70736 | 71139 | /* |
| 70737 | 71140 | ** If the input FuncDef structure is ephemeral, then free it. If |
| 70738 | 71141 | ** the FuncDef is not ephermal, then do nothing. |
| 70739 | 71142 | */ |
| 70740 | 71143 | static void freeEphemeralFunction(sqlite3 *db, FuncDef *pDef){ |
| 70741 | | - if( ALWAYS(pDef) && (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){ |
| 71144 | + if( (pDef->funcFlags & SQLITE_FUNC_EPHEM)!=0 ){ |
| 70742 | 71145 | sqlite3DbFree(db, pDef); |
| 70743 | 71146 | } |
| 70744 | 71147 | } |
| 70745 | 71148 | |
| 70746 | 71149 | static void vdbeFreeOpArray(sqlite3 *, Op *, int); |
| 70747 | 71150 | |
| 70748 | 71151 | /* |
| 70749 | 71152 | ** Delete a P4 value if necessary. |
| 70750 | 71153 | */ |
| 71154 | +static SQLITE_NOINLINE void freeP4Mem(sqlite3 *db, Mem *p){ |
| 71155 | + if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc); |
| 71156 | + sqlite3DbFree(db, p); |
| 71157 | +} |
| 71158 | +static SQLITE_NOINLINE void freeP4FuncCtx(sqlite3 *db, sqlite3_context *p){ |
| 71159 | + freeEphemeralFunction(db, p->pFunc); |
| 71160 | + sqlite3DbFree(db, p); |
| 71161 | +} |
| 70751 | 71162 | static void freeP4(sqlite3 *db, int p4type, void *p4){ |
| 70752 | 71163 | assert( db ); |
| 70753 | 71164 | switch( p4type ){ |
| 70754 | 71165 | case P4_FUNCCTX: { |
| 70755 | | - freeEphemeralFunction(db, ((sqlite3_context*)p4)->pFunc); |
| 70756 | | - /* Fall through into the next case */ |
| 71166 | + freeP4FuncCtx(db, (sqlite3_context*)p4); |
| 71167 | + break; |
| 70757 | 71168 | } |
| 70758 | 71169 | case P4_REAL: |
| 70759 | 71170 | case P4_INT64: |
| 70760 | 71171 | case P4_DYNAMIC: |
| 70761 | 71172 | case P4_INTARRAY: { |
| | @@ -70782,13 +71193,11 @@ |
| 70782 | 71193 | } |
| 70783 | 71194 | case P4_MEM: { |
| 70784 | 71195 | if( db->pnBytesFreed==0 ){ |
| 70785 | 71196 | sqlite3ValueFree((sqlite3_value*)p4); |
| 70786 | 71197 | }else{ |
| 70787 | | - Mem *p = (Mem*)p4; |
| 70788 | | - if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc); |
| 70789 | | - sqlite3DbFree(db, p); |
| 71198 | + freeP4Mem(db, (Mem*)p4); |
| 70790 | 71199 | } |
| 70791 | 71200 | break; |
| 70792 | 71201 | } |
| 70793 | 71202 | case P4_VTAB : { |
| 70794 | 71203 | if( db->pnBytesFreed==0 ) sqlite3VtabUnlock((VTable *)p4); |
| | @@ -74254,12 +74663,11 @@ |
| 74254 | 74663 | ** than 2GiB are support - anything large must be database corruption. |
| 74255 | 74664 | ** Any corruption is detected in sqlite3BtreeParseCellPtr(), though, so |
| 74256 | 74665 | ** this code can safely assume that nCellKey is 32-bits |
| 74257 | 74666 | */ |
| 74258 | 74667 | assert( sqlite3BtreeCursorIsValid(pCur) ); |
| 74259 | | - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey); |
| 74260 | | - assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ |
| 74668 | + nCellKey = sqlite3BtreePayloadSize(pCur); |
| 74261 | 74669 | assert( (nCellKey & SQLITE_MAX_U32)==(u64)nCellKey ); |
| 74262 | 74670 | |
| 74263 | 74671 | /* Read in the complete content of the index entry */ |
| 74264 | 74672 | sqlite3VdbeMemInit(&m, db, 0); |
| 74265 | 74673 | rc = sqlite3VdbeMemFromBtree(pCur, 0, (u32)nCellKey, 1, &m); |
| | @@ -74332,12 +74740,11 @@ |
| 74332 | 74740 | Mem m; |
| 74333 | 74741 | |
| 74334 | 74742 | assert( pC->eCurType==CURTYPE_BTREE ); |
| 74335 | 74743 | pCur = pC->uc.pCursor; |
| 74336 | 74744 | assert( sqlite3BtreeCursorIsValid(pCur) ); |
| 74337 | | - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCur, &nCellKey); |
| 74338 | | - assert( rc==SQLITE_OK ); /* pCur is always valid so KeySize cannot fail */ |
| 74745 | + nCellKey = sqlite3BtreePayloadSize(pCur); |
| 74339 | 74746 | /* nCellKey will always be between 0 and 0xffffffff because of the way |
| 74340 | 74747 | ** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */ |
| 74341 | 74748 | if( nCellKey<=0 || nCellKey>0x7fffffff ){ |
| 74342 | 74749 | *res = 0; |
| 74343 | 74750 | return SQLITE_CORRUPT_BKPT; |
| | @@ -74595,16 +75002,23 @@ |
| 74595 | 75002 | ** Invoke the profile callback. This routine is only called if we already |
| 74596 | 75003 | ** know that the profile callback is defined and needs to be invoked. |
| 74597 | 75004 | */ |
| 74598 | 75005 | static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ |
| 74599 | 75006 | sqlite3_int64 iNow; |
| 75007 | + sqlite3_int64 iElapse; |
| 74600 | 75008 | assert( p->startTime>0 ); |
| 74601 | | - assert( db->xProfile!=0 ); |
| 75009 | + assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 ); |
| 74602 | 75010 | assert( db->init.busy==0 ); |
| 74603 | 75011 | assert( p->zSql!=0 ); |
| 74604 | 75012 | sqlite3OsCurrentTimeInt64(db->pVfs, &iNow); |
| 74605 | | - db->xProfile(db->pProfileArg, p->zSql, (iNow - p->startTime)*1000000); |
| 75013 | + iElapse = (iNow - p->startTime)*1000000; |
| 75014 | + if( db->xProfile ){ |
| 75015 | + db->xProfile(db->pProfileArg, p->zSql, iElapse); |
| 75016 | + } |
| 75017 | + if( db->mTrace & SQLITE_TRACE_PROFILE ){ |
| 75018 | + db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse); |
| 75019 | + } |
| 74606 | 75020 | p->startTime = 0; |
| 74607 | 75021 | } |
| 74608 | 75022 | /* |
| 74609 | 75023 | ** The checkProfileCallback(DB,P) macro checks to see if a profile callback |
| 74610 | 75024 | ** is needed, and it invokes the callback if it is needed. |
| | @@ -75104,11 +75518,12 @@ |
| 75104 | 75518 | assert( db->nVdbeWrite>0 || db->autoCommit==0 |
| 75105 | 75519 | || (db->nDeferredCons==0 && db->nDeferredImmCons==0) |
| 75106 | 75520 | ); |
| 75107 | 75521 | |
| 75108 | 75522 | #ifndef SQLITE_OMIT_TRACE |
| 75109 | | - if( db->xProfile && !db->init.busy && p->zSql ){ |
| 75523 | + if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0) |
| 75524 | + && !db->init.busy && p->zSql ){ |
| 75110 | 75525 | sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime); |
| 75111 | 75526 | }else{ |
| 75112 | 75527 | assert( p->startTime==0 ); |
| 75113 | 75528 | } |
| 75114 | 75529 | #endif |
| | @@ -76138,10 +76553,43 @@ |
| 76138 | 76553 | #endif |
| 76139 | 76554 | v = pVdbe->aCounter[op]; |
| 76140 | 76555 | if( resetFlag ) pVdbe->aCounter[op] = 0; |
| 76141 | 76556 | return (int)v; |
| 76142 | 76557 | } |
| 76558 | + |
| 76559 | +/* |
| 76560 | +** Return the SQL associated with a prepared statement |
| 76561 | +*/ |
| 76562 | +SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){ |
| 76563 | + Vdbe *p = (Vdbe *)pStmt; |
| 76564 | + return p ? p->zSql : 0; |
| 76565 | +} |
| 76566 | + |
| 76567 | +/* |
| 76568 | +** Return the SQL associated with a prepared statement with |
| 76569 | +** bound parameters expanded. Space to hold the returned string is |
| 76570 | +** obtained from sqlite3_malloc(). The caller is responsible for |
| 76571 | +** freeing the returned string by passing it to sqlite3_free(). |
| 76572 | +** |
| 76573 | +** The SQLITE_TRACE_SIZE_LIMIT puts an upper bound on the size of |
| 76574 | +** expanded bound parameters. |
| 76575 | +*/ |
| 76576 | +SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt){ |
| 76577 | +#ifdef SQLITE_OMIT_TRACE |
| 76578 | + return 0; |
| 76579 | +#else |
| 76580 | + char *z = 0; |
| 76581 | + const char *zSql = sqlite3_sql(pStmt); |
| 76582 | + if( zSql ){ |
| 76583 | + Vdbe *p = (Vdbe *)pStmt; |
| 76584 | + sqlite3_mutex_enter(p->db->mutex); |
| 76585 | + z = sqlite3VdbeExpandSql(p, zSql); |
| 76586 | + sqlite3_mutex_leave(p->db->mutex); |
| 76587 | + } |
| 76588 | + return z; |
| 76589 | +#endif |
| 76590 | +} |
| 76143 | 76591 | |
| 76144 | 76592 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 76145 | 76593 | /* |
| 76146 | 76594 | ** Allocate and populate an UnpackedRecord structure based on the serialized |
| 76147 | 76595 | ** record in nKey/pKey. Return a pointer to the new UnpackedRecord structure |
| | @@ -76185,12 +76633,11 @@ |
| 76185 | 76633 | /* If the old.* record has not yet been loaded into memory, do so now. */ |
| 76186 | 76634 | if( p->pUnpacked==0 ){ |
| 76187 | 76635 | u32 nRec; |
| 76188 | 76636 | u8 *aRec; |
| 76189 | 76637 | |
| 76190 | | - rc = sqlite3BtreeDataSize(p->pCsr->uc.pCursor, &nRec); |
| 76191 | | - if( rc!=SQLITE_OK ) goto preupdate_old_out; |
| 76638 | + nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor); |
| 76192 | 76639 | aRec = sqlite3DbMallocRaw(db, nRec); |
| 76193 | 76640 | if( !aRec ) goto preupdate_old_out; |
| 76194 | 76641 | rc = sqlite3BtreeData(p->pCsr->uc.pCursor, 0, nRec, aRec); |
| 76195 | 76642 | if( rc==SQLITE_OK ){ |
| 76196 | 76643 | p->pUnpacked = vdbeUnpackRecord(&p->keyinfo, nRec, aRec); |
| | @@ -76474,14 +76921,17 @@ |
| 76474 | 76921 | int n; /* Length of a token prefix */ |
| 76475 | 76922 | int nToken; /* Length of the parameter token */ |
| 76476 | 76923 | int i; /* Loop counter */ |
| 76477 | 76924 | Mem *pVar; /* Value of a host parameter */ |
| 76478 | 76925 | StrAccum out; /* Accumulate the output here */ |
| 76926 | +#ifndef SQLITE_OMIT_UTF16 |
| 76927 | + Mem utf8; /* Used to convert UTF16 parameters into UTF8 for display */ |
| 76928 | +#endif |
| 76479 | 76929 | char zBase[100]; /* Initial working space */ |
| 76480 | 76930 | |
| 76481 | 76931 | db = p->db; |
| 76482 | | - sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase), |
| 76932 | + sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), |
| 76483 | 76933 | db->aLimit[SQLITE_LIMIT_LENGTH]); |
| 76484 | 76934 | if( db->nVdbeExec>1 ){ |
| 76485 | 76935 | while( *zRawSql ){ |
| 76486 | 76936 | const char *zStart = zRawSql; |
| 76487 | 76937 | while( *(zRawSql++)!='\n' && *zRawSql ); |
| | @@ -76528,16 +76978,18 @@ |
| 76528 | 76978 | sqlite3XPrintf(&out, "%!.15g", pVar->u.r); |
| 76529 | 76979 | }else if( pVar->flags & MEM_Str ){ |
| 76530 | 76980 | int nOut; /* Number of bytes of the string text to include in output */ |
| 76531 | 76981 | #ifndef SQLITE_OMIT_UTF16 |
| 76532 | 76982 | u8 enc = ENC(db); |
| 76533 | | - Mem utf8; |
| 76534 | 76983 | if( enc!=SQLITE_UTF8 ){ |
| 76535 | 76984 | memset(&utf8, 0, sizeof(utf8)); |
| 76536 | 76985 | utf8.db = db; |
| 76537 | 76986 | sqlite3VdbeMemSetStr(&utf8, pVar->z, pVar->n, enc, SQLITE_STATIC); |
| 76538 | | - sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8); |
| 76987 | + if( SQLITE_NOMEM==sqlite3VdbeChangeEncoding(&utf8, SQLITE_UTF8) ){ |
| 76988 | + out.accError = STRACCUM_NOMEM; |
| 76989 | + out.nAlloc = 0; |
| 76990 | + } |
| 76539 | 76991 | pVar = &utf8; |
| 76540 | 76992 | } |
| 76541 | 76993 | #endif |
| 76542 | 76994 | nOut = pVar->n; |
| 76543 | 76995 | #ifdef SQLITE_TRACE_SIZE_LIMIT |
| | @@ -76575,10 +77027,11 @@ |
| 76575 | 77027 | } |
| 76576 | 77028 | #endif |
| 76577 | 77029 | } |
| 76578 | 77030 | } |
| 76579 | 77031 | } |
| 77032 | + if( out.accError ) sqlite3StrAccumReset(&out); |
| 76580 | 77033 | return sqlite3StrAccumFinish(&out); |
| 76581 | 77034 | } |
| 76582 | 77035 | |
| 76583 | 77036 | #endif /* #ifndef SQLITE_OMIT_TRACE */ |
| 76584 | 77037 | |
| | @@ -77107,12 +77560,12 @@ |
| 77107 | 77560 | ****************************************************************************** |
| 77108 | 77561 | ** |
| 77109 | 77562 | ** This file contains inline asm code for retrieving "high-performance" |
| 77110 | 77563 | ** counters for x86 class CPUs. |
| 77111 | 77564 | */ |
| 77112 | | -#ifndef _HWTIME_H_ |
| 77113 | | -#define _HWTIME_H_ |
| 77565 | +#ifndef SQLITE_HWTIME_H |
| 77566 | +#define SQLITE_HWTIME_H |
| 77114 | 77567 | |
| 77115 | 77568 | /* |
| 77116 | 77569 | ** The following routine only works on pentium-class (or newer) processors. |
| 77117 | 77570 | ** It uses the RDTSC opcode to read the cycle count value out of the |
| 77118 | 77571 | ** processor and returns that value. This can be used for high-res |
| | @@ -77176,11 +77629,11 @@ |
| 77176 | 77629 | */ |
| 77177 | 77630 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } |
| 77178 | 77631 | |
| 77179 | 77632 | #endif |
| 77180 | 77633 | |
| 77181 | | -#endif /* !defined(_HWTIME_H_) */ |
| 77634 | +#endif /* !defined(SQLITE_HWTIME_H) */ |
| 77182 | 77635 | |
| 77183 | 77636 | /************** End of hwtime.h **********************************************/ |
| 77184 | 77637 | /************** Continuing where we left off in vdbe.c ***********************/ |
| 77185 | 77638 | |
| 77186 | 77639 | #endif |
| | @@ -78055,10 +78508,14 @@ |
| 78055 | 78508 | || (pMem[i].flags & (MEM_Str|MEM_Blob))==0 ); |
| 78056 | 78509 | sqlite3VdbeMemNulTerminate(&pMem[i]); |
| 78057 | 78510 | REGISTER_TRACE(pOp->p1+i, &pMem[i]); |
| 78058 | 78511 | } |
| 78059 | 78512 | if( db->mallocFailed ) goto no_mem; |
| 78513 | + |
| 78514 | + if( db->mTrace & SQLITE_TRACE_ROW ){ |
| 78515 | + db->xTrace(SQLITE_TRACE_ROW, db->pTraceArg, p, 0); |
| 78516 | + } |
| 78060 | 78517 | |
| 78061 | 78518 | /* Return SQLITE_ROW |
| 78062 | 78519 | */ |
| 78063 | 78520 | p->pc = (int)(pOp - aOp) + 1; |
| 78064 | 78521 | rc = SQLITE_ROW; |
| | @@ -78689,10 +79146,11 @@ |
| 78689 | 79146 | affinity = pOp->p5 & SQLITE_AFF_MASK; |
| 78690 | 79147 | if( affinity>=SQLITE_AFF_NUMERIC ){ |
| 78691 | 79148 | if( (flags1 | flags3)&MEM_Str ){ |
| 78692 | 79149 | if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ |
| 78693 | 79150 | applyNumericAffinity(pIn1,0); |
| 79151 | + flags3 = pIn3->flags; |
| 78694 | 79152 | } |
| 78695 | 79153 | if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){ |
| 78696 | 79154 | applyNumericAffinity(pIn3,0); |
| 78697 | 79155 | } |
| 78698 | 79156 | } |
| | @@ -78701,10 +79159,11 @@ |
| 78701 | 79159 | testcase( pIn1->flags & MEM_Int ); |
| 78702 | 79160 | testcase( pIn1->flags & MEM_Real ); |
| 78703 | 79161 | sqlite3VdbeMemStringify(pIn1, encoding, 1); |
| 78704 | 79162 | testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) ); |
| 78705 | 79163 | flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask); |
| 79164 | + flags3 = pIn3->flags; |
| 78706 | 79165 | } |
| 78707 | 79166 | if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){ |
| 78708 | 79167 | testcase( pIn3->flags & MEM_Int ); |
| 78709 | 79168 | testcase( pIn3->flags & MEM_Real ); |
| 78710 | 79169 | sqlite3VdbeMemStringify(pIn3, encoding, 1); |
| | @@ -79053,11 +79512,10 @@ |
| 79053 | 79512 | ** the result is guaranteed to only be used as the argument of a length() |
| 79054 | 79513 | ** or typeof() function, respectively. The loading of large blobs can be |
| 79055 | 79514 | ** skipped for length() and all content loading can be skipped for typeof(). |
| 79056 | 79515 | */ |
| 79057 | 79516 | case OP_Column: { |
| 79058 | | - i64 payloadSize64; /* Number of bytes in the record */ |
| 79059 | 79517 | int p2; /* column number to retrieve */ |
| 79060 | 79518 | VdbeCursor *pC; /* The VDBE cursor */ |
| 79061 | 79519 | BtCursor *pCrsr; /* The BTree cursor */ |
| 79062 | 79520 | u32 *aOffset; /* aOffset[i] is offset to start of data for i-th column */ |
| 79063 | 79521 | int len; /* The length of the serialized data for the column */ |
| | @@ -79076,10 +79534,11 @@ |
| 79076 | 79534 | pC = p->apCsr[pOp->p1]; |
| 79077 | 79535 | p2 = pOp->p2; |
| 79078 | 79536 | |
| 79079 | 79537 | /* If the cursor cache is stale, bring it up-to-date */ |
| 79080 | 79538 | rc = sqlite3VdbeCursorMoveto(&pC, &p2); |
| 79539 | + if( rc ) goto abort_due_to_error; |
| 79081 | 79540 | |
| 79082 | 79541 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 79083 | 79542 | pDest = &aMem[pOp->p3]; |
| 79084 | 79543 | memAboutToChange(p, pDest); |
| 79085 | 79544 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| | @@ -79089,12 +79548,11 @@ |
| 79089 | 79548 | assert( pC->eCurType!=CURTYPE_VTAB ); |
| 79090 | 79549 | assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow ); |
| 79091 | 79550 | assert( pC->eCurType!=CURTYPE_SORTER ); |
| 79092 | 79551 | pCrsr = pC->uc.pCursor; |
| 79093 | 79552 | |
| 79094 | | - if( rc ) goto abort_due_to_error; |
| 79095 | | - if( pC->cacheStatus!=p->cacheCtr ){ |
| 79553 | + if( pC->cacheStatus!=p->cacheCtr ){ /*OPTIMIZATION-IF-FALSE*/ |
| 79096 | 79554 | if( pC->nullRow ){ |
| 79097 | 79555 | if( pC->eCurType==CURTYPE_PSEUDO ){ |
| 79098 | 79556 | assert( pC->uc.pseudoTableReg>0 ); |
| 79099 | 79557 | pReg = &aMem[pC->uc.pseudoTableReg]; |
| 79100 | 79558 | assert( pReg->flags & MEM_Blob ); |
| | @@ -79106,26 +79564,13 @@ |
| 79106 | 79564 | goto op_column_out; |
| 79107 | 79565 | } |
| 79108 | 79566 | }else{ |
| 79109 | 79567 | assert( pC->eCurType==CURTYPE_BTREE ); |
| 79110 | 79568 | assert( pCrsr ); |
| 79111 | | - if( pC->isTable==0 ){ |
| 79112 | | - assert( sqlite3BtreeCursorIsValid(pCrsr) ); |
| 79113 | | - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &payloadSize64); |
| 79114 | | - assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */ |
| 79115 | | - /* sqlite3BtreeParseCellPtr() uses getVarint32() to extract the |
| 79116 | | - ** payload size, so it is impossible for payloadSize64 to be |
| 79117 | | - ** larger than 32 bits. */ |
| 79118 | | - assert( (payloadSize64 & SQLITE_MAX_U32)==(u64)payloadSize64 ); |
| 79119 | | - pC->aRow = sqlite3BtreeKeyFetch(pCrsr, &avail); |
| 79120 | | - pC->payloadSize = (u32)payloadSize64; |
| 79121 | | - }else{ |
| 79122 | | - assert( sqlite3BtreeCursorIsValid(pCrsr) ); |
| 79123 | | - VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &pC->payloadSize); |
| 79124 | | - assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ |
| 79125 | | - pC->aRow = sqlite3BtreeDataFetch(pCrsr, &avail); |
| 79126 | | - } |
| 79569 | + assert( sqlite3BtreeCursorIsValid(pCrsr) ); |
| 79570 | + pC->payloadSize = sqlite3BtreePayloadSize(pCrsr); |
| 79571 | + pC->aRow = sqlite3BtreePayloadFetch(pCrsr, &avail); |
| 79127 | 79572 | assert( avail<=65536 ); /* Maximum page size is 64KiB */ |
| 79128 | 79573 | if( pC->payloadSize <= (u32)avail ){ |
| 79129 | 79574 | pC->szRow = pC->payloadSize; |
| 79130 | 79575 | }else if( pC->payloadSize > (u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 79131 | 79576 | goto too_big; |
| | @@ -79137,11 +79582,11 @@ |
| 79137 | 79582 | pC->iHdrOffset = getVarint32(pC->aRow, offset); |
| 79138 | 79583 | pC->nHdrParsed = 0; |
| 79139 | 79584 | aOffset[0] = offset; |
| 79140 | 79585 | |
| 79141 | 79586 | |
| 79142 | | - if( avail<offset ){ |
| 79587 | + if( avail<offset ){ /*OPTIMIZATION-IF-FALSE*/ |
| 79143 | 79588 | /* pC->aRow does not have to hold the entire row, but it does at least |
| 79144 | 79589 | ** need to cover the header of the record. If pC->aRow does not contain |
| 79145 | 79590 | ** the complete header, then set it to zero, forcing the header to be |
| 79146 | 79591 | ** dynamically allocated. */ |
| 79147 | 79592 | pC->aRow = 0; |
| | @@ -79158,28 +79603,28 @@ |
| 79158 | 79603 | */ |
| 79159 | 79604 | if( offset > 98307 || offset > pC->payloadSize ){ |
| 79160 | 79605 | rc = SQLITE_CORRUPT_BKPT; |
| 79161 | 79606 | goto abort_due_to_error; |
| 79162 | 79607 | } |
| 79163 | | - } |
| 79164 | | - |
| 79165 | | - /* The following goto is an optimization. It can be omitted and |
| 79166 | | - ** everything will still work. But OP_Column is measurably faster |
| 79167 | | - ** by skipping the subsequent conditional, which is always true. |
| 79168 | | - */ |
| 79169 | | - assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */ |
| 79170 | | - goto op_column_read_header; |
| 79608 | + }else if( offset>0 ){ /*OPTIMIZATION-IF-TRUE*/ |
| 79609 | + /* The following goto is an optimization. It can be omitted and |
| 79610 | + ** everything will still work. But OP_Column is measurably faster |
| 79611 | + ** by skipping the subsequent conditional, which is always true. |
| 79612 | + */ |
| 79613 | + zData = pC->aRow; |
| 79614 | + assert( pC->nHdrParsed<=p2 ); /* Conditional skipped */ |
| 79615 | + goto op_column_read_header; |
| 79616 | + } |
| 79171 | 79617 | } |
| 79172 | 79618 | |
| 79173 | 79619 | /* Make sure at least the first p2+1 entries of the header have been |
| 79174 | 79620 | ** parsed and valid information is in aOffset[] and pC->aType[]. |
| 79175 | 79621 | */ |
| 79176 | 79622 | if( pC->nHdrParsed<=p2 ){ |
| 79177 | 79623 | /* If there is more header available for parsing in the record, try |
| 79178 | 79624 | ** to extract additional fields up through the p2+1-th field |
| 79179 | 79625 | */ |
| 79180 | | - op_column_read_header: |
| 79181 | 79626 | if( pC->iHdrOffset<aOffset[0] ){ |
| 79182 | 79627 | /* Make sure zData points to enough of the record to cover the header. */ |
| 79183 | 79628 | if( pC->aRow==0 ){ |
| 79184 | 79629 | memset(&sMem, 0, sizeof(sMem)); |
| 79185 | 79630 | rc = sqlite3VdbeMemFromBtree(pCrsr, 0, aOffset[0], !pC->isTable, &sMem); |
| | @@ -79188,15 +79633,15 @@ |
| 79188 | 79633 | }else{ |
| 79189 | 79634 | zData = pC->aRow; |
| 79190 | 79635 | } |
| 79191 | 79636 | |
| 79192 | 79637 | /* Fill in pC->aType[i] and aOffset[i] values through the p2-th field. */ |
| 79638 | + op_column_read_header: |
| 79193 | 79639 | i = pC->nHdrParsed; |
| 79194 | 79640 | offset64 = aOffset[i]; |
| 79195 | 79641 | zHdr = zData + pC->iHdrOffset; |
| 79196 | 79642 | zEndHdr = zData + aOffset[0]; |
| 79197 | | - assert( i<=p2 && zHdr<zEndHdr ); |
| 79198 | 79643 | do{ |
| 79199 | 79644 | if( (t = zHdr[0])<0x80 ){ |
| 79200 | 79645 | zHdr++; |
| 79201 | 79646 | offset64 += sqlite3VdbeOneByteSerialTypeLen(t); |
| 79202 | 79647 | }else{ |
| | @@ -79204,13 +79649,11 @@ |
| 79204 | 79649 | offset64 += sqlite3VdbeSerialTypeLen(t); |
| 79205 | 79650 | } |
| 79206 | 79651 | pC->aType[i++] = t; |
| 79207 | 79652 | aOffset[i] = (u32)(offset64 & 0xffffffff); |
| 79208 | 79653 | }while( i<=p2 && zHdr<zEndHdr ); |
| 79209 | | - pC->nHdrParsed = i; |
| 79210 | | - pC->iHdrOffset = (u32)(zHdr - zData); |
| 79211 | | - |
| 79654 | + |
| 79212 | 79655 | /* The record is corrupt if any of the following are true: |
| 79213 | 79656 | ** (1) the bytes of the header extend past the declared header size |
| 79214 | 79657 | ** (2) the entire header was used but not all data was used |
| 79215 | 79658 | ** (3) the end of the data extends beyond the end of the record. |
| 79216 | 79659 | */ |
| | @@ -79219,12 +79662,14 @@ |
| 79219 | 79662 | ){ |
| 79220 | 79663 | if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); |
| 79221 | 79664 | rc = SQLITE_CORRUPT_BKPT; |
| 79222 | 79665 | goto abort_due_to_error; |
| 79223 | 79666 | } |
| 79667 | + |
| 79668 | + pC->nHdrParsed = i; |
| 79669 | + pC->iHdrOffset = (u32)(zHdr - zData); |
| 79224 | 79670 | if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); |
| 79225 | | - |
| 79226 | 79671 | }else{ |
| 79227 | 79672 | t = 0; |
| 79228 | 79673 | } |
| 79229 | 79674 | |
| 79230 | 79675 | /* If after trying to extract new entries from the header, nHdrParsed is |
| | @@ -79248,13 +79693,14 @@ |
| 79248 | 79693 | ** all valid. |
| 79249 | 79694 | */ |
| 79250 | 79695 | assert( p2<pC->nHdrParsed ); |
| 79251 | 79696 | assert( rc==SQLITE_OK ); |
| 79252 | 79697 | assert( sqlite3VdbeCheckMemInvariants(pDest) ); |
| 79253 | | - if( VdbeMemDynamic(pDest) ) sqlite3VdbeMemSetNull(pDest); |
| 79698 | + if( VdbeMemDynamic(pDest) ){ |
| 79699 | + sqlite3VdbeMemSetNull(pDest); |
| 79700 | + } |
| 79254 | 79701 | assert( t==pC->aType[p2] ); |
| 79255 | | - pDest->enc = encoding; |
| 79256 | 79702 | if( pC->szRow>=aOffset[p2+1] ){ |
| 79257 | 79703 | /* This is the common case where the desired content fits on the original |
| 79258 | 79704 | ** page - where the content is not on an overflow page */ |
| 79259 | 79705 | zData = pC->aRow + aOffset[p2]; |
| 79260 | 79706 | if( t<12 ){ |
| | @@ -79264,10 +79710,11 @@ |
| 79264 | 79710 | ** a MEM_Ephem value. This branch is a fast short-cut that is equivalent |
| 79265 | 79711 | ** to calling sqlite3VdbeSerialGet() and sqlite3VdbeDeephemeralize(). |
| 79266 | 79712 | */ |
| 79267 | 79713 | static const u16 aFlag[] = { MEM_Blob, MEM_Str|MEM_Term }; |
| 79268 | 79714 | pDest->n = len = (t-12)/2; |
| 79715 | + pDest->enc = encoding; |
| 79269 | 79716 | if( pDest->szMalloc < len+2 ){ |
| 79270 | 79717 | pDest->flags = MEM_Null; |
| 79271 | 79718 | if( sqlite3VdbeMemGrow(pDest, len+2, 0) ) goto no_mem; |
| 79272 | 79719 | }else{ |
| 79273 | 79720 | pDest->z = pDest->zMalloc; |
| | @@ -79276,10 +79723,11 @@ |
| 79276 | 79723 | pDest->z[len] = 0; |
| 79277 | 79724 | pDest->z[len+1] = 0; |
| 79278 | 79725 | pDest->flags = aFlag[t&1]; |
| 79279 | 79726 | } |
| 79280 | 79727 | }else{ |
| 79728 | + pDest->enc = encoding; |
| 79281 | 79729 | /* This branch happens only when content is on overflow pages */ |
| 79282 | 79730 | if( ((pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0 |
| 79283 | 79731 | && ((t>=12 && (t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)) |
| 79284 | 79732 | || (len = sqlite3VdbeSerialTypeLen(t))==0 |
| 79285 | 79733 | ){ |
| | @@ -80693,10 +81141,34 @@ |
| 80693 | 81141 | if( takeJump || !alreadyExists ) goto jump_to_p2; |
| 80694 | 81142 | } |
| 80695 | 81143 | break; |
| 80696 | 81144 | } |
| 80697 | 81145 | |
| 81146 | +/* Opcode: SeekRowid P1 P2 P3 * * |
| 81147 | +** Synopsis: intkey=r[P3] |
| 81148 | +** |
| 81149 | +** P1 is the index of a cursor open on an SQL table btree (with integer |
| 81150 | +** keys). If register P3 does not contain an integer or if P1 does not |
| 81151 | +** contain a record with rowid P3 then jump immediately to P2. |
| 81152 | +** Or, if P2 is 0, raise an SQLITE_CORRUPT error. If P1 does contain |
| 81153 | +** a record with rowid P3 then |
| 81154 | +** leave the cursor pointing at that record and fall through to the next |
| 81155 | +** instruction. |
| 81156 | +** |
| 81157 | +** The OP_NotExists opcode performs the same operation, but with OP_NotExists |
| 81158 | +** the P3 register must be guaranteed to contain an integer value. With this |
| 81159 | +** opcode, register P3 might not contain an integer. |
| 81160 | +** |
| 81161 | +** The OP_NotFound opcode performs the same operation on index btrees |
| 81162 | +** (with arbitrary multi-value keys). |
| 81163 | +** |
| 81164 | +** This opcode leaves the cursor in a state where it cannot be advanced |
| 81165 | +** in either direction. In other words, the Next and Prev opcodes will |
| 81166 | +** not work following this opcode. |
| 81167 | +** |
| 81168 | +** See also: Found, NotFound, NoConflict, SeekRowid |
| 81169 | +*/ |
| 80698 | 81170 | /* Opcode: NotExists P1 P2 P3 * * |
| 80699 | 81171 | ** Synopsis: intkey=r[P3] |
| 80700 | 81172 | ** |
| 80701 | 81173 | ** P1 is the index of a cursor open on an SQL table btree (with integer |
| 80702 | 81174 | ** keys). P3 is an integer rowid. If P1 does not contain a record with |
| | @@ -80703,26 +81175,37 @@ |
| 80703 | 81175 | ** rowid P3 then jump immediately to P2. Or, if P2 is 0, raise an |
| 80704 | 81176 | ** SQLITE_CORRUPT error. If P1 does contain a record with rowid P3 then |
| 80705 | 81177 | ** leave the cursor pointing at that record and fall through to the next |
| 80706 | 81178 | ** instruction. |
| 80707 | 81179 | ** |
| 81180 | +** The OP_SeekRowid opcode performs the same operation but also allows the |
| 81181 | +** P3 register to contain a non-integer value, in which case the jump is |
| 81182 | +** always taken. This opcode requires that P3 always contain an integer. |
| 81183 | +** |
| 80708 | 81184 | ** The OP_NotFound opcode performs the same operation on index btrees |
| 80709 | 81185 | ** (with arbitrary multi-value keys). |
| 80710 | 81186 | ** |
| 80711 | 81187 | ** This opcode leaves the cursor in a state where it cannot be advanced |
| 80712 | 81188 | ** in either direction. In other words, the Next and Prev opcodes will |
| 80713 | 81189 | ** not work following this opcode. |
| 80714 | 81190 | ** |
| 80715 | | -** See also: Found, NotFound, NoConflict |
| 81191 | +** See also: Found, NotFound, NoConflict, SeekRowid |
| 80716 | 81192 | */ |
| 80717 | | -case OP_NotExists: { /* jump, in3 */ |
| 81193 | +case OP_SeekRowid: { /* jump, in3 */ |
| 80718 | 81194 | VdbeCursor *pC; |
| 80719 | 81195 | BtCursor *pCrsr; |
| 80720 | 81196 | int res; |
| 80721 | 81197 | u64 iKey; |
| 80722 | 81198 | |
| 80723 | 81199 | pIn3 = &aMem[pOp->p3]; |
| 81200 | + if( (pIn3->flags & MEM_Int)==0 ){ |
| 81201 | + applyAffinity(pIn3, SQLITE_AFF_NUMERIC, encoding); |
| 81202 | + if( (pIn3->flags & MEM_Int)==0 ) goto jump_to_p2; |
| 81203 | + } |
| 81204 | + /* Fall through into OP_NotExists */ |
| 81205 | +case OP_NotExists: /* jump, in3 */ |
| 81206 | + pIn3 = &aMem[pOp->p3]; |
| 80724 | 81207 | assert( pIn3->flags & MEM_Int ); |
| 80725 | 81208 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 80726 | 81209 | pC = p->apCsr[pOp->p1]; |
| 80727 | 81210 | assert( pC!=0 ); |
| 80728 | 81211 | #ifdef SQLITE_DEBUG |
| | @@ -80836,12 +81319,11 @@ |
| 80836 | 81319 | } |
| 80837 | 81320 | if( res ){ |
| 80838 | 81321 | v = 1; /* IMP: R-61914-48074 */ |
| 80839 | 81322 | }else{ |
| 80840 | 81323 | assert( sqlite3BtreeCursorIsValid(pC->uc.pCursor) ); |
| 80841 | | - rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v); |
| 80842 | | - assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */ |
| 81324 | + v = sqlite3BtreeIntegerKey(pC->uc.pCursor); |
| 80843 | 81325 | if( v>=MAX_ROWID ){ |
| 80844 | 81326 | pC->useRandomRowid = 1; |
| 80845 | 81327 | }else{ |
| 80846 | 81328 | v++; /* IMP: R-29538-34987 */ |
| 80847 | 81329 | } |
| | @@ -80920,14 +81402,16 @@ |
| 80920 | 81402 | ** incremented (otherwise not). If the OPFLAG_LASTROWID flag of P5 is set, |
| 80921 | 81403 | ** then rowid is stored for subsequent return by the |
| 80922 | 81404 | ** sqlite3_last_insert_rowid() function (otherwise it is unmodified). |
| 80923 | 81405 | ** |
| 80924 | 81406 | ** If the OPFLAG_USESEEKRESULT flag of P5 is set and if the result of |
| 80925 | | -** the last seek operation (OP_NotExists) was a success, then this |
| 81407 | +** the last seek operation (OP_NotExists or OP_SeekRowid) was a success, |
| 81408 | +** then this |
| 80926 | 81409 | ** operation will not attempt to find the appropriate row before doing |
| 80927 | 81410 | ** the insert but will instead overwrite the row that the cursor is |
| 80928 | | -** currently pointing to. Presumably, the prior OP_NotExists opcode |
| 81411 | +** currently pointing to. Presumably, the prior OP_NotExists or |
| 81412 | +** OP_SeekRowid opcode |
| 80929 | 81413 | ** has already positioned the cursor correctly. This is an optimization |
| 80930 | 81414 | ** that boosts performance by avoiding redundant seeks. |
| 80931 | 81415 | ** |
| 80932 | 81416 | ** If the OPFLAG_ISUPDATE flag is set, then this opcode is part of an |
| 80933 | 81417 | ** UPDATE operation. Otherwise (if the flag is clear) then this opcode |
| | @@ -80955,17 +81439,16 @@ |
| 80955 | 81439 | */ |
| 80956 | 81440 | case OP_Insert: |
| 80957 | 81441 | case OP_InsertInt: { |
| 80958 | 81442 | Mem *pData; /* MEM cell holding data for the record to be inserted */ |
| 80959 | 81443 | Mem *pKey; /* MEM cell holding key for the record */ |
| 80960 | | - i64 iKey; /* The integer ROWID or key for the record to be inserted */ |
| 80961 | 81444 | VdbeCursor *pC; /* Cursor to table into which insert is written */ |
| 80962 | | - int nZero; /* Number of zero-bytes to append */ |
| 80963 | 81445 | int seekResult; /* Result of prior seek or 0 if no USESEEKRESULT flag */ |
| 80964 | 81446 | const char *zDb; /* database name - used by the update hook */ |
| 80965 | 81447 | Table *pTab; /* Table structure - used by update and pre-update hooks */ |
| 80966 | 81448 | int op; /* Opcode for update hook: SQLITE_UPDATE or SQLITE_INSERT */ |
| 81449 | + BtreePayload x; /* Payload to be inserted */ |
| 80967 | 81450 | |
| 80968 | 81451 | op = 0; |
| 80969 | 81452 | pData = &aMem[pOp->p2]; |
| 80970 | 81453 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 80971 | 81454 | assert( memIsValid(pData) ); |
| | @@ -80980,14 +81463,14 @@ |
| 80980 | 81463 | if( pOp->opcode==OP_Insert ){ |
| 80981 | 81464 | pKey = &aMem[pOp->p3]; |
| 80982 | 81465 | assert( pKey->flags & MEM_Int ); |
| 80983 | 81466 | assert( memIsValid(pKey) ); |
| 80984 | 81467 | REGISTER_TRACE(pOp->p3, pKey); |
| 80985 | | - iKey = pKey->u.i; |
| 81468 | + x.nKey = pKey->u.i; |
| 80986 | 81469 | }else{ |
| 80987 | 81470 | assert( pOp->opcode==OP_InsertInt ); |
| 80988 | | - iKey = pOp->p3; |
| 81471 | + x.nKey = pOp->p3; |
| 80989 | 81472 | } |
| 80990 | 81473 | |
| 80991 | 81474 | if( pOp->p4type==P4_TABLE && HAS_UPDATE_HOOK(db) ){ |
| 80992 | 81475 | assert( pC->isTable ); |
| 80993 | 81476 | assert( pC->iDb>=0 ); |
| | @@ -81004,39 +81487,41 @@ |
| 81004 | 81487 | /* Invoke the pre-update hook, if any */ |
| 81005 | 81488 | if( db->xPreUpdateCallback |
| 81006 | 81489 | && pOp->p4type==P4_TABLE |
| 81007 | 81490 | && !(pOp->p5 & OPFLAG_ISUPDATE) |
| 81008 | 81491 | ){ |
| 81009 | | - sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, iKey, pOp->p2); |
| 81492 | + sqlite3VdbePreUpdateHook(p, pC, SQLITE_INSERT, zDb, pTab, x.nKey, pOp->p2); |
| 81010 | 81493 | } |
| 81011 | 81494 | #endif |
| 81012 | 81495 | |
| 81013 | 81496 | if( pOp->p5 & OPFLAG_NCHANGE ) p->nChange++; |
| 81014 | | - if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = iKey; |
| 81497 | + if( pOp->p5 & OPFLAG_LASTROWID ) db->lastRowid = lastRowid = x.nKey; |
| 81015 | 81498 | if( pData->flags & MEM_Null ){ |
| 81016 | | - pData->z = 0; |
| 81017 | | - pData->n = 0; |
| 81499 | + x.pData = 0; |
| 81500 | + x.nData = 0; |
| 81018 | 81501 | }else{ |
| 81019 | 81502 | assert( pData->flags & (MEM_Blob|MEM_Str) ); |
| 81503 | + x.pData = pData->z; |
| 81504 | + x.nData = pData->n; |
| 81020 | 81505 | } |
| 81021 | 81506 | seekResult = ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0); |
| 81022 | 81507 | if( pData->flags & MEM_Zero ){ |
| 81023 | | - nZero = pData->u.nZero; |
| 81508 | + x.nZero = pData->u.nZero; |
| 81024 | 81509 | }else{ |
| 81025 | | - nZero = 0; |
| 81510 | + x.nZero = 0; |
| 81026 | 81511 | } |
| 81027 | | - rc = sqlite3BtreeInsert(pC->uc.pCursor, 0, iKey, |
| 81028 | | - pData->z, pData->n, nZero, |
| 81512 | + x.pKey = 0; |
| 81513 | + rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, |
| 81029 | 81514 | (pOp->p5 & OPFLAG_APPEND)!=0, seekResult |
| 81030 | 81515 | ); |
| 81031 | 81516 | pC->deferredMoveto = 0; |
| 81032 | 81517 | pC->cacheStatus = CACHE_STALE; |
| 81033 | 81518 | |
| 81034 | 81519 | /* Invoke the update-hook if required. */ |
| 81035 | 81520 | if( rc ) goto abort_due_to_error; |
| 81036 | 81521 | if( db->xUpdateCallback && op ){ |
| 81037 | | - db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, iKey); |
| 81522 | + db->xUpdateCallback(db->pUpdateArg, op, zDb, pTab->zName, x.nKey); |
| 81038 | 81523 | } |
| 81039 | 81524 | break; |
| 81040 | 81525 | } |
| 81041 | 81526 | |
| 81042 | 81527 | /* Opcode: Delete P1 P2 P3 P4 P5 |
| | @@ -81091,12 +81576,11 @@ |
| 81091 | 81576 | #ifdef SQLITE_DEBUG |
| 81092 | 81577 | if( pOp->p4type==P4_TABLE && HasRowid(pOp->p4.pTab) && pOp->p5==0 ){ |
| 81093 | 81578 | /* If p5 is zero, the seek operation that positioned the cursor prior to |
| 81094 | 81579 | ** OP_Delete will have also set the pC->movetoTarget field to the rowid of |
| 81095 | 81580 | ** the row that is being deleted */ |
| 81096 | | - i64 iKey = 0; |
| 81097 | | - sqlite3BtreeKeySize(pC->uc.pCursor, &iKey); |
| 81581 | + i64 iKey = sqlite3BtreeIntegerKey(pC->uc.pCursor); |
| 81098 | 81582 | assert( pC->movetoTarget==iKey ); |
| 81099 | 81583 | } |
| 81100 | 81584 | #endif |
| 81101 | 81585 | |
| 81102 | 81586 | /* If the update-hook or pre-update-hook will be invoked, set zDb to |
| | @@ -81108,11 +81592,11 @@ |
| 81108 | 81592 | assert( pC->iDb>=0 ); |
| 81109 | 81593 | assert( pOp->p4.pTab!=0 ); |
| 81110 | 81594 | zDb = db->aDb[pC->iDb].zName; |
| 81111 | 81595 | pTab = pOp->p4.pTab; |
| 81112 | 81596 | if( (pOp->p5 & OPFLAG_SAVEPOSITION)!=0 && pC->isTable ){ |
| 81113 | | - sqlite3BtreeKeySize(pC->uc.pCursor, &pC->movetoTarget); |
| 81597 | + pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor); |
| 81114 | 81598 | } |
| 81115 | 81599 | }else{ |
| 81116 | 81600 | zDb = 0; /* Not needed. Silence a compiler warning. */ |
| 81117 | 81601 | pTab = 0; /* Not needed. Silence a compiler warning. */ |
| 81118 | 81602 | } |
| | @@ -81262,11 +81746,10 @@ |
| 81262 | 81746 | case OP_RowKey: |
| 81263 | 81747 | case OP_RowData: { |
| 81264 | 81748 | VdbeCursor *pC; |
| 81265 | 81749 | BtCursor *pCrsr; |
| 81266 | 81750 | u32 n; |
| 81267 | | - i64 n64; |
| 81268 | 81751 | |
| 81269 | 81752 | pOut = &aMem[pOp->p2]; |
| 81270 | 81753 | memAboutToChange(p, pOut); |
| 81271 | 81754 | |
| 81272 | 81755 | /* Note that RowKey and RowData are really exactly the same instruction */ |
| | @@ -81280,12 +81763,13 @@ |
| 81280 | 81763 | assert( pC->nullRow==0 ); |
| 81281 | 81764 | assert( pC->uc.pCursor!=0 ); |
| 81282 | 81765 | pCrsr = pC->uc.pCursor; |
| 81283 | 81766 | |
| 81284 | 81767 | /* The OP_RowKey and OP_RowData opcodes always follow OP_NotExists or |
| 81285 | | - ** OP_Rewind/Op_Next with no intervening instructions that might invalidate |
| 81286 | | - ** the cursor. If this where not the case, on of the following assert()s |
| 81768 | + ** OP_SeekRowid or OP_Rewind/Op_Next with no intervening instructions |
| 81769 | + ** that might invalidate the cursor. |
| 81770 | + ** If this where not the case, on of the following assert()s |
| 81287 | 81771 | ** would fail. Should this ever change (because of changes in the code |
| 81288 | 81772 | ** generator) then the fix would be to insert a call to |
| 81289 | 81773 | ** sqlite3VdbeCursorMoveto(). |
| 81290 | 81774 | */ |
| 81291 | 81775 | assert( pC->deferredMoveto==0 ); |
| | @@ -81293,24 +81777,13 @@ |
| 81293 | 81777 | #if 0 /* Not required due to the previous to assert() statements */ |
| 81294 | 81778 | rc = sqlite3VdbeCursorMoveto(pC); |
| 81295 | 81779 | if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 81296 | 81780 | #endif |
| 81297 | 81781 | |
| 81298 | | - if( pC->isTable==0 ){ |
| 81299 | | - assert( !pC->isTable ); |
| 81300 | | - VVA_ONLY(rc =) sqlite3BtreeKeySize(pCrsr, &n64); |
| 81301 | | - assert( rc==SQLITE_OK ); /* True because of CursorMoveto() call above */ |
| 81302 | | - if( n64>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 81303 | | - goto too_big; |
| 81304 | | - } |
| 81305 | | - n = (u32)n64; |
| 81306 | | - }else{ |
| 81307 | | - VVA_ONLY(rc =) sqlite3BtreeDataSize(pCrsr, &n); |
| 81308 | | - assert( rc==SQLITE_OK ); /* DataSize() cannot fail */ |
| 81309 | | - if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 81310 | | - goto too_big; |
| 81311 | | - } |
| 81782 | + n = sqlite3BtreePayloadSize(pCrsr); |
| 81783 | + if( n>(u32)db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 81784 | + goto too_big; |
| 81312 | 81785 | } |
| 81313 | 81786 | testcase( n==0 ); |
| 81314 | 81787 | if( sqlite3VdbeMemClearAndResize(pOut, MAX(n,32)) ){ |
| 81315 | 81788 | goto no_mem; |
| 81316 | 81789 | } |
| | @@ -81371,12 +81844,11 @@ |
| 81371 | 81844 | if( rc ) goto abort_due_to_error; |
| 81372 | 81845 | if( pC->nullRow ){ |
| 81373 | 81846 | pOut->flags = MEM_Null; |
| 81374 | 81847 | break; |
| 81375 | 81848 | } |
| 81376 | | - rc = sqlite3BtreeKeySize(pC->uc.pCursor, &v); |
| 81377 | | - assert( rc==SQLITE_OK ); /* Always so because of CursorRestore() above */ |
| 81849 | + v = sqlite3BtreeIntegerKey(pC->uc.pCursor); |
| 81378 | 81850 | } |
| 81379 | 81851 | pOut->u.i = v; |
| 81380 | 81852 | break; |
| 81381 | 81853 | } |
| 81382 | 81854 | |
| | @@ -81647,12 +82119,11 @@ |
| 81647 | 82119 | ** for tables is OP_Insert. |
| 81648 | 82120 | */ |
| 81649 | 82121 | case OP_SorterInsert: /* in2 */ |
| 81650 | 82122 | case OP_IdxInsert: { /* in2 */ |
| 81651 | 82123 | VdbeCursor *pC; |
| 81652 | | - int nKey; |
| 81653 | | - const char *zKey; |
| 82124 | + BtreePayload x; |
| 81654 | 82125 | |
| 81655 | 82126 | assert( pOp->p1>=0 && pOp->p1<p->nCursor ); |
| 81656 | 82127 | pC = p->apCsr[pOp->p1]; |
| 81657 | 82128 | assert( pC!=0 ); |
| 81658 | 82129 | assert( isSorter(pC)==(pOp->opcode==OP_SorterInsert) ); |
| | @@ -81664,13 +82135,16 @@ |
| 81664 | 82135 | rc = ExpandBlob(pIn2); |
| 81665 | 82136 | if( rc ) goto abort_due_to_error; |
| 81666 | 82137 | if( pOp->opcode==OP_SorterInsert ){ |
| 81667 | 82138 | rc = sqlite3VdbeSorterWrite(pC, pIn2); |
| 81668 | 82139 | }else{ |
| 81669 | | - nKey = pIn2->n; |
| 81670 | | - zKey = pIn2->z; |
| 81671 | | - rc = sqlite3BtreeInsert(pC->uc.pCursor, zKey, nKey, "", 0, 0, pOp->p3, |
| 82140 | + x.nKey = pIn2->n; |
| 82141 | + x.pKey = pIn2->z; |
| 82142 | + x.nData = 0; |
| 82143 | + x.nZero = 0; |
| 82144 | + x.pData = 0; |
| 82145 | + rc = sqlite3BtreeInsert(pC->uc.pCursor, &x, pOp->p3, |
| 81672 | 82146 | ((pOp->p5 & OPFLAG_USESEEKRESULT) ? pC->seekResult : 0) |
| 81673 | 82147 | ); |
| 81674 | 82148 | assert( pC->deferredMoveto==0 ); |
| 81675 | 82149 | pC->cacheStatus = CACHE_STALE; |
| 81676 | 82150 | } |
| | @@ -83434,20 +83908,38 @@ |
| 83434 | 83908 | ** |
| 83435 | 83909 | ** If P2 is not zero, jump to instruction P2. |
| 83436 | 83910 | */ |
| 83437 | 83911 | case OP_Init: { /* jump */ |
| 83438 | 83912 | char *zTrace; |
| 83439 | | - char *z; |
| 83913 | + |
| 83914 | + /* If the P4 argument is not NULL, then it must be an SQL comment string. |
| 83915 | + ** The "--" string is broken up to prevent false-positives with srcck1.c. |
| 83916 | + ** |
| 83917 | + ** This assert() provides evidence for: |
| 83918 | + ** EVIDENCE-OF: R-50676-09860 The callback can compute the same text that |
| 83919 | + ** would have been returned by the legacy sqlite3_trace() interface by |
| 83920 | + ** using the X argument when X begins with "--" and invoking |
| 83921 | + ** sqlite3_expanded_sql(P) otherwise. |
| 83922 | + */ |
| 83923 | + assert( pOp->p4.z==0 || strncmp(pOp->p4.z, "-" "- ", 3)==0 ); |
| 83440 | 83924 | |
| 83441 | 83925 | #ifndef SQLITE_OMIT_TRACE |
| 83442 | | - if( db->xTrace |
| 83926 | + if( (db->mTrace & (SQLITE_TRACE_STMT|SQLITE_TRACE_LEGACY))!=0 |
| 83443 | 83927 | && !p->doingRerun |
| 83444 | 83928 | && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0 |
| 83445 | 83929 | ){ |
| 83446 | | - z = sqlite3VdbeExpandSql(p, zTrace); |
| 83447 | | - db->xTrace(db->pTraceArg, z); |
| 83448 | | - sqlite3DbFree(db, z); |
| 83930 | +#ifndef SQLITE_OMIT_DEPRECATED |
| 83931 | + if( db->mTrace & SQLITE_TRACE_LEGACY ){ |
| 83932 | + void (*x)(void*,const char*) = (void(*)(void*,const char*))db->xTrace; |
| 83933 | + char *z = sqlite3VdbeExpandSql(p, zTrace); |
| 83934 | + x(db->pTraceArg, z); |
| 83935 | + sqlite3_free(z); |
| 83936 | + }else |
| 83937 | +#endif |
| 83938 | + { |
| 83939 | + (void)db->xTrace(SQLITE_TRACE_STMT, db->pTraceArg, p, zTrace); |
| 83940 | + } |
| 83449 | 83941 | } |
| 83450 | 83942 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 83451 | 83943 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 83452 | 83944 | if( zTrace ){ |
| 83453 | 83945 | int i; |
| | @@ -84026,11 +84518,11 @@ |
| 84026 | 84518 | ** slightly more efficient). Since you cannot write to a PK column |
| 84027 | 84519 | ** using the incremental-blob API, this works. For the sessions module |
| 84028 | 84520 | ** anyhow. |
| 84029 | 84521 | */ |
| 84030 | 84522 | sqlite3_int64 iKey; |
| 84031 | | - sqlite3BtreeKeySize(p->pCsr, &iKey); |
| 84523 | + iKey = sqlite3BtreeIntegerKey(p->pCsr); |
| 84032 | 84524 | sqlite3VdbePreUpdateHook( |
| 84033 | 84525 | v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1 |
| 84034 | 84526 | ); |
| 84035 | 84527 | } |
| 84036 | 84528 | #endif |
| | @@ -85461,41 +85953,47 @@ |
| 85461 | 85953 | } |
| 85462 | 85954 | |
| 85463 | 85955 | |
| 85464 | 85956 | /* |
| 85465 | 85957 | ** Merge the two sorted lists p1 and p2 into a single list. |
| 85466 | | -** Set *ppOut to the head of the new list. |
| 85467 | 85958 | */ |
| 85468 | | -static void vdbeSorterMerge( |
| 85959 | +static SorterRecord *vdbeSorterMerge( |
| 85469 | 85960 | SortSubtask *pTask, /* Calling thread context */ |
| 85470 | 85961 | SorterRecord *p1, /* First list to merge */ |
| 85471 | | - SorterRecord *p2, /* Second list to merge */ |
| 85472 | | - SorterRecord **ppOut /* OUT: Head of merged list */ |
| 85962 | + SorterRecord *p2 /* Second list to merge */ |
| 85473 | 85963 | ){ |
| 85474 | 85964 | SorterRecord *pFinal = 0; |
| 85475 | 85965 | SorterRecord **pp = &pFinal; |
| 85476 | 85966 | int bCached = 0; |
| 85477 | 85967 | |
| 85478 | | - while( p1 && p2 ){ |
| 85968 | + assert( p1!=0 && p2!=0 ); |
| 85969 | + for(;;){ |
| 85479 | 85970 | int res; |
| 85480 | 85971 | res = pTask->xCompare( |
| 85481 | 85972 | pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal |
| 85482 | 85973 | ); |
| 85483 | 85974 | |
| 85484 | 85975 | if( res<=0 ){ |
| 85485 | 85976 | *pp = p1; |
| 85486 | 85977 | pp = &p1->u.pNext; |
| 85487 | 85978 | p1 = p1->u.pNext; |
| 85979 | + if( p1==0 ){ |
| 85980 | + *pp = p2; |
| 85981 | + break; |
| 85982 | + } |
| 85488 | 85983 | }else{ |
| 85489 | 85984 | *pp = p2; |
| 85490 | 85985 | pp = &p2->u.pNext; |
| 85491 | 85986 | p2 = p2->u.pNext; |
| 85492 | 85987 | bCached = 0; |
| 85988 | + if( p2==0 ){ |
| 85989 | + *pp = p1; |
| 85990 | + break; |
| 85991 | + } |
| 85493 | 85992 | } |
| 85494 | 85993 | } |
| 85495 | | - *pp = p1 ? p1 : p2; |
| 85496 | | - *ppOut = pFinal; |
| 85994 | + return pFinal; |
| 85497 | 85995 | } |
| 85498 | 85996 | |
| 85499 | 85997 | /* |
| 85500 | 85998 | ** Return the SorterCompare function to compare values collected by the |
| 85501 | 85999 | ** sorter object passed as the only argument. |
| | @@ -85544,20 +86042,21 @@ |
| 85544 | 86042 | pNext = p->u.pNext; |
| 85545 | 86043 | } |
| 85546 | 86044 | |
| 85547 | 86045 | p->u.pNext = 0; |
| 85548 | 86046 | for(i=0; aSlot[i]; i++){ |
| 85549 | | - vdbeSorterMerge(pTask, p, aSlot[i], &p); |
| 86047 | + p = vdbeSorterMerge(pTask, p, aSlot[i]); |
| 85550 | 86048 | aSlot[i] = 0; |
| 85551 | 86049 | } |
| 85552 | 86050 | aSlot[i] = p; |
| 85553 | 86051 | p = pNext; |
| 85554 | 86052 | } |
| 85555 | 86053 | |
| 85556 | 86054 | p = 0; |
| 85557 | 86055 | for(i=0; i<64; i++){ |
| 85558 | | - vdbeSorterMerge(pTask, p, aSlot[i], &p); |
| 86056 | + if( aSlot[i]==0 ) continue; |
| 86057 | + p = p ? vdbeSorterMerge(pTask, p, aSlot[i]) : aSlot[i]; |
| 85559 | 86058 | } |
| 85560 | 86059 | pList->pList = p; |
| 85561 | 86060 | |
| 85562 | 86061 | sqlite3_free(aSlot); |
| 85563 | 86062 | assert( pTask->pUnpacked->errCode==SQLITE_OK |
| | @@ -88173,11 +88672,15 @@ |
| 88173 | 88672 | } |
| 88174 | 88673 | if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){ |
| 88175 | 88674 | sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); |
| 88176 | 88675 | pNC->nErr++; |
| 88177 | 88676 | is_agg = 0; |
| 88178 | | - }else if( no_such_func && pParse->db->init.busy==0 ){ |
| 88677 | + }else if( no_such_func && pParse->db->init.busy==0 |
| 88678 | +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 88679 | + && pParse->explain==0 |
| 88680 | +#endif |
| 88681 | + ){ |
| 88179 | 88682 | sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); |
| 88180 | 88683 | pNC->nErr++; |
| 88181 | 88684 | }else if( wrong_num_args ){ |
| 88182 | 88685 | sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", |
| 88183 | 88686 | nId, zId); |
| | @@ -90773,10 +91276,15 @@ |
| 90773 | 91276 | VdbeComment((v, "%s", pIdx->zName)); |
| 90774 | 91277 | assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 ); |
| 90775 | 91278 | eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0]; |
| 90776 | 91279 | |
| 90777 | 91280 | if( prRhsHasNull && !pTab->aCol[iCol].notNull ){ |
| 91281 | +#ifdef SQLITE_ENABLE_COLUMN_USED_MASK |
| 91282 | + const i64 sOne = 1; |
| 91283 | + sqlite3VdbeAddOp4Dup8(v, OP_ColumnsUsed, |
| 91284 | + iTab, 0, 0, (u8*)&sOne, P4_INT64); |
| 91285 | +#endif |
| 90778 | 91286 | *prRhsHasNull = ++pParse->nMem; |
| 90779 | 91287 | sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull); |
| 90780 | 91288 | } |
| 90781 | 91289 | sqlite3VdbeJumpHere(v, iAddr); |
| 90782 | 91290 | } |
| | @@ -90785,11 +91293,11 @@ |
| 90785 | 91293 | } |
| 90786 | 91294 | |
| 90787 | 91295 | /* If no preexisting index is available for the IN clause |
| 90788 | 91296 | ** and IN_INDEX_NOOP is an allowed reply |
| 90789 | 91297 | ** and the RHS of the IN operator is a list, not a subquery |
| 90790 | | - ** and the RHS is not contant or has two or fewer terms, |
| 91298 | + ** and the RHS is not constant or has two or fewer terms, |
| 90791 | 91299 | ** then it is not worth creating an ephemeral table to evaluate |
| 90792 | 91300 | ** the IN operator so return IN_INDEX_NOOP. |
| 90793 | 91301 | */ |
| 90794 | 91302 | if( eType==0 |
| 90795 | 91303 | && (inFlags & IN_INDEX_NOOP_OK) |
| | @@ -91177,12 +91685,11 @@ |
| 91177 | 91685 | } |
| 91178 | 91686 | |
| 91179 | 91687 | if( eType==IN_INDEX_ROWID ){ |
| 91180 | 91688 | /* In this case, the RHS is the ROWID of table b-tree |
| 91181 | 91689 | */ |
| 91182 | | - sqlite3VdbeAddOp2(v, OP_MustBeInt, r1, destIfFalse); VdbeCoverage(v); |
| 91183 | | - sqlite3VdbeAddOp3(v, OP_NotExists, pExpr->iTable, destIfFalse, r1); |
| 91690 | + sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, r1); |
| 91184 | 91691 | VdbeCoverage(v); |
| 91185 | 91692 | }else{ |
| 91186 | 91693 | /* In this case, the RHS is an index b-tree. |
| 91187 | 91694 | */ |
| 91188 | 91695 | sqlite3VdbeAddOp4(v, OP_Affinity, r1, 1, 0, &affinity, 1); |
| | @@ -91491,11 +91998,11 @@ |
| 91491 | 91998 | if( iCol<0 || iCol==pTab->iPKey ){ |
| 91492 | 91999 | sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); |
| 91493 | 92000 | }else{ |
| 91494 | 92001 | int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; |
| 91495 | 92002 | int x = iCol; |
| 91496 | | - if( !HasRowid(pTab) ){ |
| 92003 | + if( !HasRowid(pTab) && !IsVirtual(pTab) ){ |
| 91497 | 92004 | x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol); |
| 91498 | 92005 | } |
| 91499 | 92006 | sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut); |
| 91500 | 92007 | } |
| 91501 | 92008 | if( iCol>=0 ){ |
| | @@ -91894,10 +92401,15 @@ |
| 91894 | 92401 | } |
| 91895 | 92402 | nFarg = pFarg ? pFarg->nExpr : 0; |
| 91896 | 92403 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 91897 | 92404 | zId = pExpr->u.zToken; |
| 91898 | 92405 | pDef = sqlite3FindFunction(db, zId, nFarg, enc, 0); |
| 92406 | +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 92407 | + if( pDef==0 && pParse->explain ){ |
| 92408 | + pDef = sqlite3FindFunction(db, "unknown", nFarg, enc, 0); |
| 92409 | + } |
| 92410 | +#endif |
| 91899 | 92411 | if( pDef==0 || pDef->xFinalize!=0 ){ |
| 91900 | 92412 | sqlite3ErrorMsg(pParse, "unknown function: %s()", zId); |
| 91901 | 92413 | break; |
| 91902 | 92414 | } |
| 91903 | 92415 | |
| | @@ -92915,10 +93427,65 @@ |
| 92915 | 93427 | ){ |
| 92916 | 93428 | return 1; |
| 92917 | 93429 | } |
| 92918 | 93430 | return 0; |
| 92919 | 93431 | } |
| 93432 | + |
| 93433 | +/* |
| 93434 | +** An instance of the following structure is used by the tree walker |
| 93435 | +** to determine if an expression can be evaluated by reference to the |
| 93436 | +** index only, without having to do a search for the corresponding |
| 93437 | +** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur |
| 93438 | +** is the cursor for the table. |
| 93439 | +*/ |
| 93440 | +struct IdxCover { |
| 93441 | + Index *pIdx; /* The index to be tested for coverage */ |
| 93442 | + int iCur; /* Cursor number for the table corresponding to the index */ |
| 93443 | +}; |
| 93444 | + |
| 93445 | +/* |
| 93446 | +** Check to see if there are references to columns in table |
| 93447 | +** pWalker->u.pIdxCover->iCur can be satisfied using the index |
| 93448 | +** pWalker->u.pIdxCover->pIdx. |
| 93449 | +*/ |
| 93450 | +static int exprIdxCover(Walker *pWalker, Expr *pExpr){ |
| 93451 | + if( pExpr->op==TK_COLUMN |
| 93452 | + && pExpr->iTable==pWalker->u.pIdxCover->iCur |
| 93453 | + && sqlite3ColumnOfIndex(pWalker->u.pIdxCover->pIdx, pExpr->iColumn)<0 |
| 93454 | + ){ |
| 93455 | + pWalker->eCode = 1; |
| 93456 | + return WRC_Abort; |
| 93457 | + } |
| 93458 | + return WRC_Continue; |
| 93459 | +} |
| 93460 | + |
| 93461 | +/* |
| 93462 | +** Determine if an index pIdx on table with cursor iCur contains will |
| 93463 | +** the expression pExpr. Return true if the index does cover the |
| 93464 | +** expression and false if the pExpr expression references table columns |
| 93465 | +** that are not found in the index pIdx. |
| 93466 | +** |
| 93467 | +** An index covering an expression means that the expression can be |
| 93468 | +** evaluated using only the index and without having to lookup the |
| 93469 | +** corresponding table entry. |
| 93470 | +*/ |
| 93471 | +SQLITE_PRIVATE int sqlite3ExprCoveredByIndex( |
| 93472 | + Expr *pExpr, /* The index to be tested */ |
| 93473 | + int iCur, /* The cursor number for the corresponding table */ |
| 93474 | + Index *pIdx /* The index that might be used for coverage */ |
| 93475 | +){ |
| 93476 | + Walker w; |
| 93477 | + struct IdxCover xcov; |
| 93478 | + memset(&w, 0, sizeof(w)); |
| 93479 | + xcov.iCur = iCur; |
| 93480 | + xcov.pIdx = pIdx; |
| 93481 | + w.xExprCallback = exprIdxCover; |
| 93482 | + w.u.pIdxCover = &xcov; |
| 93483 | + sqlite3WalkExpr(&w, pExpr); |
| 93484 | + return !w.eCode; |
| 93485 | +} |
| 93486 | + |
| 92920 | 93487 | |
| 92921 | 93488 | /* |
| 92922 | 93489 | ** An instance of the following structure is used by the tree walker |
| 92923 | 93490 | ** to count references to table columns in the arguments of an |
| 92924 | 93491 | ** aggregate function, in order to implement the |
| | @@ -93870,10 +94437,11 @@ |
| 93870 | 94437 | char *zCol; /* Null-terminated column definition */ |
| 93871 | 94438 | Column *pCol; /* The new column */ |
| 93872 | 94439 | Expr *pDflt; /* Default value for the new column */ |
| 93873 | 94440 | sqlite3 *db; /* The database connection; */ |
| 93874 | 94441 | Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */ |
| 94442 | + int r1; /* Temporary registers */ |
| 93875 | 94443 | |
| 93876 | 94444 | db = pParse->db; |
| 93877 | 94445 | if( pParse->nErr || db->mallocFailed ) return; |
| 93878 | 94446 | assert( v!=0 ); |
| 93879 | 94447 | pNew = pParse->pNewTable; |
| | @@ -93964,20 +94532,22 @@ |
| 93964 | 94532 | ); |
| 93965 | 94533 | sqlite3DbFree(db, zCol); |
| 93966 | 94534 | db->flags = savedDbFlags; |
| 93967 | 94535 | } |
| 93968 | 94536 | |
| 93969 | | - /* If the default value of the new column is NULL, then the file |
| 93970 | | - ** format to 2. If the default value of the new column is not NULL, |
| 93971 | | - ** the file format be 3. Back when this feature was first added |
| 93972 | | - ** in 2006, we went to the trouble to upgrade the file format to the |
| 93973 | | - ** minimum support values. But 10-years on, we can assume that all |
| 93974 | | - ** extent versions of SQLite support file-format 4, so we always and |
| 93975 | | - ** unconditionally upgrade to 4. |
| 94537 | + /* Make sure the schema version is at least 3. But do not upgrade |
| 94538 | + ** from less than 3 to 4, as that will corrupt any preexisting DESC |
| 94539 | + ** index. |
| 93976 | 94540 | */ |
| 93977 | | - sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, |
| 93978 | | - SQLITE_MAX_FILE_FORMAT); |
| 94541 | + r1 = sqlite3GetTempReg(pParse); |
| 94542 | + sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT); |
| 94543 | + sqlite3VdbeUsesBtree(v, iDb); |
| 94544 | + sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2); |
| 94545 | + sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2); |
| 94546 | + VdbeCoverage(v); |
| 94547 | + sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3); |
| 94548 | + sqlite3ReleaseTempReg(pParse, r1); |
| 93979 | 94549 | |
| 93980 | 94550 | /* Reload the schema of the modified table. */ |
| 93981 | 94551 | reloadTableSchema(pParse, pTab, pTab->zName); |
| 93982 | 94552 | } |
| 93983 | 94553 | |
| | @@ -96662,10 +97232,11 @@ |
| 96662 | 97232 | ){ |
| 96663 | 97233 | sqlite3 *db = pParse->db; /* Database handle */ |
| 96664 | 97234 | char *zDb = db->aDb[iDb].zName; /* Name of attached database */ |
| 96665 | 97235 | int rc; /* Auth callback return code */ |
| 96666 | 97236 | |
| 97237 | + if( db->init.busy ) return SQLITE_OK; |
| 96667 | 97238 | rc = db->xAuth(db->pAuthArg, SQLITE_READ, zTab,zCol,zDb,pParse->zAuthContext |
| 96668 | 97239 | #ifdef SQLITE_USER_AUTHENTICATION |
| 96669 | 97240 | ,db->auth.zAuthUser |
| 96670 | 97241 | #endif |
| 96671 | 97242 | ); |
| | @@ -97152,11 +97723,11 @@ |
| 97152 | 97723 | ** routine leaves an error message in pParse->zErrMsg where |
| 97153 | 97724 | ** sqlite3FindTable() does not. |
| 97154 | 97725 | */ |
| 97155 | 97726 | SQLITE_PRIVATE Table *sqlite3LocateTable( |
| 97156 | 97727 | Parse *pParse, /* context in which to report errors */ |
| 97157 | | - int isView, /* True if looking for a VIEW rather than a TABLE */ |
| 97728 | + u32 flags, /* LOCATE_VIEW or LOCATE_NOERR */ |
| 97158 | 97729 | const char *zName, /* Name of the table we are looking for */ |
| 97159 | 97730 | const char *zDbase /* Name of the database. Might be NULL */ |
| 97160 | 97731 | ){ |
| 97161 | 97732 | Table *p; |
| 97162 | 97733 | |
| | @@ -97166,11 +97737,11 @@ |
| 97166 | 97737 | return 0; |
| 97167 | 97738 | } |
| 97168 | 97739 | |
| 97169 | 97740 | p = sqlite3FindTable(pParse->db, zName, zDbase); |
| 97170 | 97741 | if( p==0 ){ |
| 97171 | | - const char *zMsg = isView ? "no such view" : "no such table"; |
| 97742 | + const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table"; |
| 97172 | 97743 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 97173 | 97744 | if( sqlite3FindDbName(pParse->db, zDbase)<1 ){ |
| 97174 | 97745 | /* If zName is the not the name of a table in the schema created using |
| 97175 | 97746 | ** CREATE, then check to see if it is the name of an virtual table that |
| 97176 | 97747 | ** can be an eponymous virtual table. */ |
| | @@ -97178,16 +97749,18 @@ |
| 97178 | 97749 | if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){ |
| 97179 | 97750 | return pMod->pEpoTab; |
| 97180 | 97751 | } |
| 97181 | 97752 | } |
| 97182 | 97753 | #endif |
| 97183 | | - if( zDbase ){ |
| 97184 | | - sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); |
| 97185 | | - }else{ |
| 97186 | | - sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); |
| 97754 | + if( (flags & LOCATE_NOERR)==0 ){ |
| 97755 | + if( zDbase ){ |
| 97756 | + sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName); |
| 97757 | + }else{ |
| 97758 | + sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName); |
| 97759 | + } |
| 97760 | + pParse->checkSchema = 1; |
| 97187 | 97761 | } |
| 97188 | | - pParse->checkSchema = 1; |
| 97189 | 97762 | } |
| 97190 | 97763 | |
| 97191 | 97764 | return p; |
| 97192 | 97765 | } |
| 97193 | 97766 | |
| | @@ -97200,11 +97773,11 @@ |
| 97200 | 97773 | ** non-NULL if it is part of a view or trigger program definition. See |
| 97201 | 97774 | ** sqlite3FixSrcList() for details. |
| 97202 | 97775 | */ |
| 97203 | 97776 | SQLITE_PRIVATE Table *sqlite3LocateTableItem( |
| 97204 | 97777 | Parse *pParse, |
| 97205 | | - int isView, |
| 97778 | + u32 flags, |
| 97206 | 97779 | struct SrcList_item *p |
| 97207 | 97780 | ){ |
| 97208 | 97781 | const char *zDb; |
| 97209 | 97782 | assert( p->pSchema==0 || p->zDatabase==0 ); |
| 97210 | 97783 | if( p->pSchema ){ |
| | @@ -97211,11 +97784,11 @@ |
| 97211 | 97784 | int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema); |
| 97212 | 97785 | zDb = pParse->db->aDb[iDb].zName; |
| 97213 | 97786 | }else{ |
| 97214 | 97787 | zDb = p->zDatabase; |
| 97215 | 97788 | } |
| 97216 | | - return sqlite3LocateTable(pParse, isView, p->zName, zDb); |
| 97789 | + return sqlite3LocateTable(pParse, flags, p->zName, zDb); |
| 97217 | 97790 | } |
| 97218 | 97791 | |
| 97219 | 97792 | /* |
| 97220 | 97793 | ** Locate the in-memory structure that describes |
| 97221 | 97794 | ** a particular index given the name of that index |
| | @@ -97419,12 +97992,13 @@ |
| 97419 | 97992 | db->lookaside.nOut : 0 ); |
| 97420 | 97993 | |
| 97421 | 97994 | /* Delete all indices associated with this table. */ |
| 97422 | 97995 | for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){ |
| 97423 | 97996 | pNext = pIndex->pNext; |
| 97424 | | - assert( pIndex->pSchema==pTable->pSchema ); |
| 97425 | | - if( !db || db->pnBytesFreed==0 ){ |
| 97997 | + assert( pIndex->pSchema==pTable->pSchema |
| 97998 | + || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) ); |
| 97999 | + if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){ |
| 97426 | 98000 | char *zName = pIndex->zName; |
| 97427 | 98001 | TESTONLY ( Index *pOld = ) sqlite3HashInsert( |
| 97428 | 98002 | &pIndex->pSchema->idxHash, zName, 0 |
| 97429 | 98003 | ); |
| 97430 | 98004 | assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); |
| | @@ -98102,11 +98676,11 @@ |
| 98102 | 98676 | ){ |
| 98103 | 98677 | Table *pTab = pParse->pNewTable; |
| 98104 | 98678 | Column *pCol = 0; |
| 98105 | 98679 | int iCol = -1, i; |
| 98106 | 98680 | int nTerm; |
| 98107 | | - if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit; |
| 98681 | + if( pTab==0 ) goto primary_key_exit; |
| 98108 | 98682 | if( pTab->tabFlags & TF_HasPrimaryKey ){ |
| 98109 | 98683 | sqlite3ErrorMsg(pParse, |
| 98110 | 98684 | "table \"%s\" has more than one primary key", pTab->zName); |
| 98111 | 98685 | goto primary_key_exit; |
| 98112 | 98686 | } |
| | @@ -98148,16 +98722,12 @@ |
| 98148 | 98722 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 98149 | 98723 | sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " |
| 98150 | 98724 | "INTEGER PRIMARY KEY"); |
| 98151 | 98725 | #endif |
| 98152 | 98726 | }else{ |
| 98153 | | - Index *p; |
| 98154 | | - p = sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, |
| 98155 | | - 0, sortOrder, 0); |
| 98156 | | - if( p ){ |
| 98157 | | - p->idxType = SQLITE_IDXTYPE_PRIMARYKEY; |
| 98158 | | - } |
| 98727 | + sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0, |
| 98728 | + 0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY); |
| 98159 | 98729 | pList = 0; |
| 98160 | 98730 | } |
| 98161 | 98731 | |
| 98162 | 98732 | primary_key_exit: |
| 98163 | 98733 | sqlite3ExprListDelete(pParse->db, pList); |
| | @@ -98470,33 +99040,49 @@ |
| 98470 | 99040 | ** has a WITHOUT ROWID clause. The job of this routine is to convert both |
| 98471 | 99041 | ** internal schema data structures and the generated VDBE code so that they |
| 98472 | 99042 | ** are appropriate for a WITHOUT ROWID table instead of a rowid table. |
| 98473 | 99043 | ** Changes include: |
| 98474 | 99044 | ** |
| 98475 | | -** (1) Convert the OP_CreateTable into an OP_CreateIndex. There is |
| 99045 | +** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL. |
| 99046 | +** (2) Convert the OP_CreateTable into an OP_CreateIndex. There is |
| 98476 | 99047 | ** no rowid btree for a WITHOUT ROWID. Instead, the canonical |
| 98477 | 99048 | ** data storage is a covering index btree. |
| 98478 | | -** (2) Bypass the creation of the sqlite_master table entry |
| 99049 | +** (3) Bypass the creation of the sqlite_master table entry |
| 98479 | 99050 | ** for the PRIMARY KEY as the primary key index is now |
| 98480 | 99051 | ** identified by the sqlite_master table entry of the table itself. |
| 98481 | | -** (3) Set the Index.tnum of the PRIMARY KEY Index object in the |
| 99052 | +** (4) Set the Index.tnum of the PRIMARY KEY Index object in the |
| 98482 | 99053 | ** schema to the rootpage from the main table. |
| 98483 | | -** (4) Set all columns of the PRIMARY KEY schema object to be NOT NULL. |
| 98484 | 99054 | ** (5) Add all table columns to the PRIMARY KEY Index object |
| 98485 | 99055 | ** so that the PRIMARY KEY is a covering index. The surplus |
| 98486 | 99056 | ** columns are part of KeyInfo.nXField and are not used for |
| 98487 | 99057 | ** sorting or lookup or uniqueness checks. |
| 98488 | 99058 | ** (6) Replace the rowid tail on all automatically generated UNIQUE |
| 98489 | 99059 | ** indices with the PRIMARY KEY columns. |
| 99060 | +** |
| 99061 | +** For virtual tables, only (1) is performed. |
| 98490 | 99062 | */ |
| 98491 | 99063 | static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ |
| 98492 | 99064 | Index *pIdx; |
| 98493 | 99065 | Index *pPk; |
| 98494 | 99066 | int nPk; |
| 98495 | 99067 | int i, j; |
| 98496 | 99068 | sqlite3 *db = pParse->db; |
| 98497 | 99069 | Vdbe *v = pParse->pVdbe; |
| 99070 | + |
| 99071 | + /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables) |
| 99072 | + */ |
| 99073 | + if( !db->init.imposterTable ){ |
| 99074 | + for(i=0; i<pTab->nCol; i++){ |
| 99075 | + if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){ |
| 99076 | + pTab->aCol[i].notNull = OE_Abort; |
| 99077 | + } |
| 99078 | + } |
| 99079 | + } |
| 99080 | + |
| 99081 | + /* The remaining transformations only apply to b-tree tables, not to |
| 99082 | + ** virtual tables */ |
| 99083 | + if( IN_DECLARE_VTAB ) return; |
| 98498 | 99084 | |
| 98499 | 99085 | /* Convert the OP_CreateTable opcode that would normally create the |
| 98500 | 99086 | ** root-page for the table into an OP_CreateIndex opcode. The index |
| 98501 | 99087 | ** created will become the PRIMARY KEY index. |
| 98502 | 99088 | */ |
| | @@ -98515,13 +99101,14 @@ |
| 98515 | 99101 | pList = sqlite3ExprListAppend(pParse, 0, |
| 98516 | 99102 | sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0)); |
| 98517 | 99103 | if( pList==0 ) return; |
| 98518 | 99104 | pList->a[0].sortOrder = pParse->iPkSortOrder; |
| 98519 | 99105 | assert( pParse->pNewTable==pTab ); |
| 98520 | | - pPk = sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0); |
| 98521 | | - if( pPk==0 ) return; |
| 98522 | | - pPk->idxType = SQLITE_IDXTYPE_PRIMARYKEY; |
| 99106 | + sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0, |
| 99107 | + SQLITE_IDXTYPE_PRIMARYKEY); |
| 99108 | + if( db->mallocFailed ) return; |
| 99109 | + pPk = sqlite3PrimaryKeyIndex(pTab); |
| 98523 | 99110 | pTab->iPKey = -1; |
| 98524 | 99111 | }else{ |
| 98525 | 99112 | pPk = sqlite3PrimaryKeyIndex(pTab); |
| 98526 | 99113 | |
| 98527 | 99114 | /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master |
| | @@ -98545,23 +99132,15 @@ |
| 98545 | 99132 | pPk->aiColumn[j++] = pPk->aiColumn[i]; |
| 98546 | 99133 | } |
| 98547 | 99134 | } |
| 98548 | 99135 | pPk->nKeyCol = j; |
| 98549 | 99136 | } |
| 98550 | | - pPk->isCovering = 1; |
| 98551 | 99137 | assert( pPk!=0 ); |
| 99138 | + pPk->isCovering = 1; |
| 99139 | + if( !db->init.imposterTable ) pPk->uniqNotNull = 1; |
| 98552 | 99140 | nPk = pPk->nKeyCol; |
| 98553 | 99141 | |
| 98554 | | - /* Make sure every column of the PRIMARY KEY is NOT NULL. (Except, |
| 98555 | | - ** do not enforce this for imposter tables.) */ |
| 98556 | | - if( !db->init.imposterTable ){ |
| 98557 | | - for(i=0; i<nPk; i++){ |
| 98558 | | - pTab->aCol[pPk->aiColumn[i]].notNull = OE_Abort; |
| 98559 | | - } |
| 98560 | | - pPk->uniqNotNull = 1; |
| 98561 | | - } |
| 98562 | | - |
| 98563 | 99142 | /* The root page of the PRIMARY KEY is the table root page */ |
| 98564 | 99143 | pPk->tnum = pTab->tnum; |
| 98565 | 99144 | |
| 98566 | 99145 | /* Update the in-memory representation of all UNIQUE indices by converting |
| 98567 | 99146 | ** the final rowid column into one or more columns of the PRIMARY KEY. |
| | @@ -99312,10 +99891,11 @@ |
| 99312 | 99891 | } |
| 99313 | 99892 | assert( pParse->nErr==0 ); |
| 99314 | 99893 | assert( pName->nSrc==1 ); |
| 99315 | 99894 | if( sqlite3ReadSchema(pParse) ) goto exit_drop_table; |
| 99316 | 99895 | if( noErr ) db->suppressErr++; |
| 99896 | + assert( isView==0 || isView==LOCATE_VIEW ); |
| 99317 | 99897 | pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]); |
| 99318 | 99898 | if( noErr ) db->suppressErr--; |
| 99319 | 99899 | |
| 99320 | 99900 | if( pTab==0 ){ |
| 99321 | 99901 | if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase); |
| | @@ -99682,28 +100262,24 @@ |
| 99682 | 100262 | ** currently being constructed by a CREATE TABLE statement. |
| 99683 | 100263 | ** |
| 99684 | 100264 | ** pList is a list of columns to be indexed. pList will be NULL if this |
| 99685 | 100265 | ** is a primary key or unique-constraint on the most recent column added |
| 99686 | 100266 | ** to the table currently under construction. |
| 99687 | | -** |
| 99688 | | -** If the index is created successfully, return a pointer to the new Index |
| 99689 | | -** structure. This is used by sqlite3AddPrimaryKey() to mark the index |
| 99690 | | -** as the tables primary key (Index.idxType==SQLITE_IDXTYPE_PRIMARYKEY) |
| 99691 | 100267 | */ |
| 99692 | | -SQLITE_PRIVATE Index *sqlite3CreateIndex( |
| 100268 | +SQLITE_PRIVATE void sqlite3CreateIndex( |
| 99693 | 100269 | Parse *pParse, /* All information about this parse */ |
| 99694 | 100270 | Token *pName1, /* First part of index name. May be NULL */ |
| 99695 | 100271 | Token *pName2, /* Second part of index name. May be NULL */ |
| 99696 | 100272 | SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */ |
| 99697 | 100273 | ExprList *pList, /* A list of columns to be indexed */ |
| 99698 | 100274 | int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
| 99699 | 100275 | Token *pStart, /* The CREATE token that begins this statement */ |
| 99700 | 100276 | Expr *pPIWhere, /* WHERE clause for partial indices */ |
| 99701 | 100277 | int sortOrder, /* Sort order of primary key when pList==NULL */ |
| 99702 | | - int ifNotExist /* Omit error if index already exists */ |
| 100278 | + int ifNotExist, /* Omit error if index already exists */ |
| 100279 | + u8 idxType /* The index type */ |
| 99703 | 100280 | ){ |
| 99704 | | - Index *pRet = 0; /* Pointer to return */ |
| 99705 | 100281 | Table *pTab = 0; /* Table to be indexed */ |
| 99706 | 100282 | Index *pIndex = 0; /* The index to be created */ |
| 99707 | 100283 | char *zName = 0; /* Name of the index */ |
| 99708 | 100284 | int nName; /* Number of characters in zName */ |
| 99709 | 100285 | int i, j; |
| | @@ -99717,11 +100293,14 @@ |
| 99717 | 100293 | int nExtra = 0; /* Space allocated for zExtra[] */ |
| 99718 | 100294 | int nExtraCol; /* Number of extra columns needed */ |
| 99719 | 100295 | char *zExtra = 0; /* Extra space after the Index object */ |
| 99720 | 100296 | Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */ |
| 99721 | 100297 | |
| 99722 | | - if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){ |
| 100298 | + if( db->mallocFailed || pParse->nErr>0 ){ |
| 100299 | + goto exit_create_index; |
| 100300 | + } |
| 100301 | + if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){ |
| 99723 | 100302 | goto exit_create_index; |
| 99724 | 100303 | } |
| 99725 | 100304 | if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ |
| 99726 | 100305 | goto exit_create_index; |
| 99727 | 100306 | } |
| | @@ -99843,10 +100422,17 @@ |
| 99843 | 100422 | for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){} |
| 99844 | 100423 | zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n); |
| 99845 | 100424 | if( zName==0 ){ |
| 99846 | 100425 | goto exit_create_index; |
| 99847 | 100426 | } |
| 100427 | + |
| 100428 | + /* Automatic index names generated from within sqlite3_declare_vtab() |
| 100429 | + ** must have names that are distinct from normal automatic index names. |
| 100430 | + ** The following statement converts "sqlite3_autoindex..." into |
| 100431 | + ** "sqlite3_butoindex..." in order to make the names distinct. |
| 100432 | + ** The "vtab_err.test" test demonstrates the need of this statement. */ |
| 100433 | + if( IN_DECLARE_VTAB ) zName[7]++; |
| 99848 | 100434 | } |
| 99849 | 100435 | |
| 99850 | 100436 | /* Check for authorization to create an index. |
| 99851 | 100437 | */ |
| 99852 | 100438 | #ifndef SQLITE_OMIT_AUTHORIZATION |
| | @@ -99906,11 +100492,11 @@ |
| 99906 | 100492 | zExtra += nName + 1; |
| 99907 | 100493 | memcpy(pIndex->zName, zName, nName+1); |
| 99908 | 100494 | pIndex->pTable = pTab; |
| 99909 | 100495 | pIndex->onError = (u8)onError; |
| 99910 | 100496 | pIndex->uniqNotNull = onError!=OE_None; |
| 99911 | | - pIndex->idxType = pName ? SQLITE_IDXTYPE_APPDEF : SQLITE_IDXTYPE_UNIQUE; |
| 100497 | + pIndex->idxType = idxType; |
| 99912 | 100498 | pIndex->pSchema = db->aDb[iDb].pSchema; |
| 99913 | 100499 | pIndex->nKeyCol = pList->nExpr; |
| 99914 | 100500 | if( pPIWhere ){ |
| 99915 | 100501 | sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0); |
| 99916 | 100502 | pIndex->pPartIdxWhere = pPIWhere; |
| | @@ -100086,11 +100672,11 @@ |
| 100086 | 100672 | } |
| 100087 | 100673 | if( pIdx->onError==OE_Default ){ |
| 100088 | 100674 | pIdx->onError = pIndex->onError; |
| 100089 | 100675 | } |
| 100090 | 100676 | } |
| 100091 | | - pRet = pIdx; |
| 100677 | + if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType; |
| 100092 | 100678 | goto exit_create_index; |
| 100093 | 100679 | } |
| 100094 | 100680 | } |
| 100095 | 100681 | } |
| 100096 | 100682 | |
| | @@ -100098,10 +100684,11 @@ |
| 100098 | 100684 | ** in-memory database structures. |
| 100099 | 100685 | */ |
| 100100 | 100686 | assert( pParse->nErr==0 ); |
| 100101 | 100687 | if( db->init.busy ){ |
| 100102 | 100688 | Index *p; |
| 100689 | + assert( !IN_DECLARE_VTAB ); |
| 100103 | 100690 | assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); |
| 100104 | 100691 | p = sqlite3HashInsert(&pIndex->pSchema->idxHash, |
| 100105 | 100692 | pIndex->zName, pIndex); |
| 100106 | 100693 | if( p ){ |
| 100107 | 100694 | assert( p==pIndex ); /* Malloc must have failed */ |
| | @@ -100179,11 +100766,11 @@ |
| 100179 | 100766 | if( pTblName ){ |
| 100180 | 100767 | sqlite3RefillIndex(pParse, pIndex, iMem); |
| 100181 | 100768 | sqlite3ChangeCookie(pParse, iDb); |
| 100182 | 100769 | sqlite3VdbeAddParseSchemaOp(v, iDb, |
| 100183 | 100770 | sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName)); |
| 100184 | | - sqlite3VdbeAddOp1(v, OP_Expire, 0); |
| 100771 | + sqlite3VdbeAddOp0(v, OP_Expire); |
| 100185 | 100772 | } |
| 100186 | 100773 | |
| 100187 | 100774 | sqlite3VdbeJumpHere(v, pIndex->tnum); |
| 100188 | 100775 | } |
| 100189 | 100776 | |
| | @@ -100204,11 +100791,10 @@ |
| 100204 | 100791 | pOther = pOther->pNext; |
| 100205 | 100792 | } |
| 100206 | 100793 | pIndex->pNext = pOther->pNext; |
| 100207 | 100794 | pOther->pNext = pIndex; |
| 100208 | 100795 | } |
| 100209 | | - pRet = pIndex; |
| 100210 | 100796 | pIndex = 0; |
| 100211 | 100797 | } |
| 100212 | 100798 | |
| 100213 | 100799 | /* Clean up before exiting */ |
| 100214 | 100800 | exit_create_index: |
| | @@ -100215,11 +100801,10 @@ |
| 100215 | 100801 | if( pIndex ) freeIndex(db, pIndex); |
| 100216 | 100802 | sqlite3ExprDelete(db, pPIWhere); |
| 100217 | 100803 | sqlite3ExprListDelete(db, pList); |
| 100218 | 100804 | sqlite3SrcListDelete(db, pTblName); |
| 100219 | 100805 | sqlite3DbFree(db, zName); |
| 100220 | | - return pRet; |
| 100221 | 100806 | } |
| 100222 | 100807 | |
| 100223 | 100808 | /* |
| 100224 | 100809 | ** Fill the Index.aiRowEst[] array with default information - information |
| 100225 | 100810 | ** to be used when we have not run the ANALYZE command. |
| | @@ -100244,14 +100829,15 @@ |
| 100244 | 100829 | LogEst *a = pIdx->aiRowLogEst; |
| 100245 | 100830 | int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol); |
| 100246 | 100831 | int i; |
| 100247 | 100832 | |
| 100248 | 100833 | /* Set the first entry (number of rows in the index) to the estimated |
| 100249 | | - ** number of rows in the table. Or 10, if the estimated number of rows |
| 100250 | | - ** in the table is less than that. */ |
| 100834 | + ** number of rows in the table, or half the number of rows in the table |
| 100835 | + ** for a partial index. But do not let the estimate drop below 10. */ |
| 100251 | 100836 | a[0] = pIdx->pTable->nRowLogEst; |
| 100252 | | - if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) ); |
| 100837 | + if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) ); |
| 100838 | + if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) ); |
| 100253 | 100839 | |
| 100254 | 100840 | /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is |
| 100255 | 100841 | ** 6 and each subsequent value (if any) is 5. */ |
| 100256 | 100842 | memcpy(&a[1], aVal, nCopy*sizeof(LogEst)); |
| 100257 | 100843 | for(i=nCopy+1; i<=pIdx->nKeyCol; i++){ |
| | @@ -101129,14 +101715,10 @@ |
| 101129 | 101715 | #endif |
| 101130 | 101716 | |
| 101131 | 101717 | /* |
| 101132 | 101718 | ** Return a KeyInfo structure that is appropriate for the given Index. |
| 101133 | 101719 | ** |
| 101134 | | -** The KeyInfo structure for an index is cached in the Index object. |
| 101135 | | -** So there might be multiple references to the returned pointer. The |
| 101136 | | -** caller should not try to modify the KeyInfo object. |
| 101137 | | -** |
| 101138 | 101720 | ** The caller should invoke sqlite3KeyInfoUnref() on the returned object |
| 101139 | 101721 | ** when it has finished using it. |
| 101140 | 101722 | */ |
| 101141 | 101723 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){ |
| 101142 | 101724 | int i; |
| | @@ -103364,11 +103946,11 @@ |
| 103364 | 103946 | continue; |
| 103365 | 103947 | } |
| 103366 | 103948 | } |
| 103367 | 103949 | c2 = Utf8Read(zString); |
| 103368 | 103950 | if( c==c2 ) continue; |
| 103369 | | - if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){ |
| 103951 | + if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) && c<0x80 && c2<0x80 ){ |
| 103370 | 103952 | continue; |
| 103371 | 103953 | } |
| 103372 | 103954 | if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue; |
| 103373 | 103955 | return 0; |
| 103374 | 103956 | } |
| | @@ -103939,10 +104521,30 @@ |
| 103939 | 104521 | } |
| 103940 | 104522 | } |
| 103941 | 104523 | sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); |
| 103942 | 104524 | } |
| 103943 | 104525 | |
| 104526 | + |
| 104527 | +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 104528 | +/* |
| 104529 | +** The "unknown" function is automatically substituted in place of |
| 104530 | +** any unrecognized function name when doing an EXPLAIN or EXPLAIN QUERY PLAN |
| 104531 | +** when the SQLITE_ENABLE_UNKNOWN_FUNCTION compile-time option is used. |
| 104532 | +** When the "sqlite3" command-line shell is built using this functionality, |
| 104533 | +** that allows an EXPLAIN or EXPLAIN QUERY PLAN for complex queries |
| 104534 | +** involving application-defined functions to be examined in a generic |
| 104535 | +** sqlite3 shell. |
| 104536 | +*/ |
| 104537 | +static void unknownFunc( |
| 104538 | + sqlite3_context *context, |
| 104539 | + int argc, |
| 104540 | + sqlite3_value **argv |
| 104541 | +){ |
| 104542 | + /* no-op */ |
| 104543 | +} |
| 104544 | +#endif /*SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION*/ |
| 104545 | + |
| 103944 | 104546 | |
| 103945 | 104547 | /* IMP: R-25361-16150 This function is omitted from SQLite by default. It |
| 103946 | 104548 | ** is only available if the SQLITE_SOUNDEX compile-time option is used |
| 103947 | 104549 | ** when SQLite is built. |
| 103948 | 104550 | */ |
| | @@ -104410,17 +105012,20 @@ |
| 104410 | 105012 | AGGREGATE(count, 1, 0, 0, countStep, countFinalize ), |
| 104411 | 105013 | AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize), |
| 104412 | 105014 | AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize), |
| 104413 | 105015 | |
| 104414 | 105016 | LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| 104415 | | - #ifdef SQLITE_CASE_SENSITIVE_LIKE |
| 105017 | +#ifdef SQLITE_CASE_SENSITIVE_LIKE |
| 104416 | 105018 | LIKEFUNC(like, 2, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| 104417 | 105019 | LIKEFUNC(like, 3, &likeInfoAlt, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE), |
| 104418 | | - #else |
| 105020 | +#else |
| 104419 | 105021 | LIKEFUNC(like, 2, &likeInfoNorm, SQLITE_FUNC_LIKE), |
| 104420 | 105022 | LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE), |
| 104421 | | - #endif |
| 105023 | +#endif |
| 105024 | +#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 105025 | + FUNCTION(unknown, -1, 0, 0, unknownFunc ), |
| 105026 | +#endif |
| 104422 | 105027 | FUNCTION(coalesce, 1, 0, 0, 0 ), |
| 104423 | 105028 | FUNCTION(coalesce, 0, 0, 0, 0 ), |
| 104424 | 105029 | FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQLITE_FUNC_COALESCE), |
| 104425 | 105030 | }; |
| 104426 | 105031 | #ifndef SQLITE_OMIT_ALTERTABLE |
| | @@ -105823,11 +106428,12 @@ |
| 105823 | 106428 | */ |
| 105824 | 106429 | SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){ |
| 105825 | 106430 | FKey *pFKey; /* Iterator variable */ |
| 105826 | 106431 | FKey *pNext; /* Copy of pFKey->pNextFrom */ |
| 105827 | 106432 | |
| 105828 | | - assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) ); |
| 106433 | + assert( db==0 || IsVirtual(pTab) |
| 106434 | + || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) ); |
| 105829 | 106435 | for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){ |
| 105830 | 106436 | |
| 105831 | 106437 | /* Remove the FK from the fkeyHash hash table. */ |
| 105832 | 106438 | if( !db || db->pnBytesFreed==0 ){ |
| 105833 | 106439 | if( pFKey->pPrevTo ){ |
| | @@ -108233,16 +108839,14 @@ |
| 108233 | 108839 | ** shared libraries that want to be imported as extensions into |
| 108234 | 108840 | ** an SQLite instance. Shared libraries that intend to be loaded |
| 108235 | 108841 | ** as extensions by SQLite should #include this file instead of |
| 108236 | 108842 | ** sqlite3.h. |
| 108237 | 108843 | */ |
| 108238 | | -#ifndef _SQLITE3EXT_H_ |
| 108239 | | -#define _SQLITE3EXT_H_ |
| 108844 | +#ifndef SQLITE3EXT_H |
| 108845 | +#define SQLITE3EXT_H |
| 108240 | 108846 | /* #include "sqlite3.h" */ |
| 108241 | 108847 | |
| 108242 | | -typedef struct sqlite3_api_routines sqlite3_api_routines; |
| 108243 | | - |
| 108244 | 108848 | /* |
| 108245 | 108849 | ** The following structure holds pointers to all of the SQLite API |
| 108246 | 108850 | ** routines. |
| 108247 | 108851 | ** |
| 108248 | 108852 | ** WARNING: In order to maintain backwards compatibility, add new |
| | @@ -108499,11 +109103,24 @@ |
| 108499 | 109103 | int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int); |
| 108500 | 109104 | int (*strlike)(const char*,const char*,unsigned int); |
| 108501 | 109105 | int (*db_cacheflush)(sqlite3*); |
| 108502 | 109106 | /* Version 3.12.0 and later */ |
| 108503 | 109107 | int (*system_errno)(sqlite3*); |
| 109108 | + /* Version 3.14.0 and later */ |
| 109109 | + int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*); |
| 109110 | + char *(*expanded_sql)(sqlite3_stmt*); |
| 108504 | 109111 | }; |
| 109112 | + |
| 109113 | +/* |
| 109114 | +** This is the function signature used for all extension entry points. It |
| 109115 | +** is also defined in the file "loadext.c". |
| 109116 | +*/ |
| 109117 | +typedef int (*sqlite3_loadext_entry)( |
| 109118 | + sqlite3 *db, /* Handle to the database. */ |
| 109119 | + char **pzErrMsg, /* Used to set error string on failure. */ |
| 109120 | + const sqlite3_api_routines *pThunk /* Extension API function pointers. */ |
| 109121 | +); |
| 108505 | 109122 | |
| 108506 | 109123 | /* |
| 108507 | 109124 | ** The following macros redefine the API routines so that they are |
| 108508 | 109125 | ** redirected through the global sqlite3_api structure. |
| 108509 | 109126 | ** |
| | @@ -108744,10 +109361,13 @@ |
| 108744 | 109361 | #define sqlite3_status64 sqlite3_api->status64 |
| 108745 | 109362 | #define sqlite3_strlike sqlite3_api->strlike |
| 108746 | 109363 | #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush |
| 108747 | 109364 | /* Version 3.12.0 and later */ |
| 108748 | 109365 | #define sqlite3_system_errno sqlite3_api->system_errno |
| 109366 | +/* Version 3.14.0 and later */ |
| 109367 | +#define sqlite3_trace_v2 sqlite3_api->trace_v2 |
| 109368 | +#define sqlite3_expanded_sql sqlite3_api->expanded_sql |
| 108749 | 109369 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 108750 | 109370 | |
| 108751 | 109371 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| 108752 | 109372 | /* This case when the file really is being compiled as a loadable |
| 108753 | 109373 | ** extension */ |
| | @@ -108761,19 +109381,18 @@ |
| 108761 | 109381 | # define SQLITE_EXTENSION_INIT1 /*no-op*/ |
| 108762 | 109382 | # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ |
| 108763 | 109383 | # define SQLITE_EXTENSION_INIT3 /*no-op*/ |
| 108764 | 109384 | #endif |
| 108765 | 109385 | |
| 108766 | | -#endif /* _SQLITE3EXT_H_ */ |
| 109386 | +#endif /* SQLITE3EXT_H */ |
| 108767 | 109387 | |
| 108768 | 109388 | /************** End of sqlite3ext.h ******************************************/ |
| 108769 | 109389 | /************** Continuing where we left off in loadext.c ********************/ |
| 108770 | 109390 | /* #include "sqliteInt.h" */ |
| 108771 | 109391 | /* #include <string.h> */ |
| 108772 | 109392 | |
| 108773 | 109393 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 108774 | | - |
| 108775 | 109394 | /* |
| 108776 | 109395 | ** Some API routines are omitted when various features are |
| 108777 | 109396 | ** excluded from a build of SQLite. Substitute a NULL pointer |
| 108778 | 109397 | ** for any missing APIs. |
| 108779 | 109398 | */ |
| | @@ -108839,11 +109458,11 @@ |
| 108839 | 109458 | |
| 108840 | 109459 | #ifdef SQLITE_OMIT_SHARED_CACHE |
| 108841 | 109460 | # define sqlite3_enable_shared_cache 0 |
| 108842 | 109461 | #endif |
| 108843 | 109462 | |
| 108844 | | -#ifdef SQLITE_OMIT_TRACE |
| 109463 | +#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED) |
| 108845 | 109464 | # define sqlite3_profile 0 |
| 108846 | 109465 | # define sqlite3_trace 0 |
| 108847 | 109466 | #endif |
| 108848 | 109467 | |
| 108849 | 109468 | #ifdef SQLITE_OMIT_GET_TABLE |
| | @@ -108858,10 +109477,14 @@ |
| 108858 | 109477 | #define sqlite3_blob_open 0 |
| 108859 | 109478 | #define sqlite3_blob_read 0 |
| 108860 | 109479 | #define sqlite3_blob_write 0 |
| 108861 | 109480 | #define sqlite3_blob_reopen 0 |
| 108862 | 109481 | #endif |
| 109482 | + |
| 109483 | +#if defined(SQLITE_OMIT_TRACE) |
| 109484 | +# define sqlite3_trace_v2 0 |
| 109485 | +#endif |
| 108863 | 109486 | |
| 108864 | 109487 | /* |
| 108865 | 109488 | ** The following structure contains pointers to all SQLite API routines. |
| 108866 | 109489 | ** A pointer to this structure is passed into extensions when they are |
| 108867 | 109490 | ** loaded so that the extension can make calls back into the SQLite |
| | @@ -109164,11 +109787,14 @@ |
| 109164 | 109787 | /* Version 3.10.0 and later */ |
| 109165 | 109788 | sqlite3_status64, |
| 109166 | 109789 | sqlite3_strlike, |
| 109167 | 109790 | sqlite3_db_cacheflush, |
| 109168 | 109791 | /* Version 3.12.0 and later */ |
| 109169 | | - sqlite3_system_errno |
| 109792 | + sqlite3_system_errno, |
| 109793 | + /* Version 3.14.0 and later */ |
| 109794 | + sqlite3_trace_v2, |
| 109795 | + sqlite3_expanded_sql |
| 109170 | 109796 | }; |
| 109171 | 109797 | |
| 109172 | 109798 | /* |
| 109173 | 109799 | ** Attempt to load an SQLite extension library contained in the file |
| 109174 | 109800 | ** zFile. The entry point is zProc. zProc may be 0 in which case a |
| | @@ -109187,17 +109813,18 @@ |
| 109187 | 109813 | const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */ |
| 109188 | 109814 | char **pzErrMsg /* Put error message here if not 0 */ |
| 109189 | 109815 | ){ |
| 109190 | 109816 | sqlite3_vfs *pVfs = db->pVfs; |
| 109191 | 109817 | void *handle; |
| 109192 | | - int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); |
| 109818 | + sqlite3_loadext_entry xInit; |
| 109193 | 109819 | char *zErrmsg = 0; |
| 109194 | 109820 | const char *zEntry; |
| 109195 | 109821 | char *zAltEntry = 0; |
| 109196 | 109822 | void **aHandle; |
| 109197 | 109823 | u64 nMsg = 300 + sqlite3Strlen30(zFile); |
| 109198 | 109824 | int ii; |
| 109825 | + int rc; |
| 109199 | 109826 | |
| 109200 | 109827 | /* Shared library endings to try if zFile cannot be loaded as written */ |
| 109201 | 109828 | static const char *azEndings[] = { |
| 109202 | 109829 | #if SQLITE_OS_WIN |
| 109203 | 109830 | "dll" |
| | @@ -109245,12 +109872,11 @@ |
| 109245 | 109872 | sqlite3OsDlError(pVfs, nMsg-1, zErrmsg); |
| 109246 | 109873 | } |
| 109247 | 109874 | } |
| 109248 | 109875 | return SQLITE_ERROR; |
| 109249 | 109876 | } |
| 109250 | | - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) |
| 109251 | | - sqlite3OsDlSym(pVfs, handle, zEntry); |
| 109877 | + xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); |
| 109252 | 109878 | |
| 109253 | 109879 | /* If no entry point was specified and the default legacy |
| 109254 | 109880 | ** entry point name "sqlite3_extension_init" was not found, then |
| 109255 | 109881 | ** construct an entry point name "sqlite3_X_init" where the X is |
| 109256 | 109882 | ** replaced by the lowercase value of every ASCII alphabetic |
| | @@ -109278,12 +109904,11 @@ |
| 109278 | 109904 | zAltEntry[iEntry++] = (char)sqlite3UpperToLower[(unsigned)c]; |
| 109279 | 109905 | } |
| 109280 | 109906 | } |
| 109281 | 109907 | memcpy(zAltEntry+iEntry, "_init", 6); |
| 109282 | 109908 | zEntry = zAltEntry; |
| 109283 | | - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) |
| 109284 | | - sqlite3OsDlSym(pVfs, handle, zEntry); |
| 109909 | + xInit = (sqlite3_loadext_entry)sqlite3OsDlSym(pVfs, handle, zEntry); |
| 109285 | 109910 | } |
| 109286 | 109911 | if( xInit==0 ){ |
| 109287 | 109912 | if( pzErrMsg ){ |
| 109288 | 109913 | nMsg += sqlite3Strlen30(zEntry); |
| 109289 | 109914 | *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg); |
| | @@ -109296,11 +109921,13 @@ |
| 109296 | 109921 | sqlite3OsDlClose(pVfs, handle); |
| 109297 | 109922 | sqlite3_free(zAltEntry); |
| 109298 | 109923 | return SQLITE_ERROR; |
| 109299 | 109924 | } |
| 109300 | 109925 | sqlite3_free(zAltEntry); |
| 109301 | | - if( xInit(db, &zErrmsg, &sqlite3Apis) ){ |
| 109926 | + rc = xInit(db, &zErrmsg, &sqlite3Apis); |
| 109927 | + if( rc ){ |
| 109928 | + if( rc==SQLITE_OK_LOAD_PERMANENTLY ) return SQLITE_OK; |
| 109302 | 109929 | if( pzErrMsg ){ |
| 109303 | 109930 | *pzErrMsg = sqlite3_mprintf("error during initialization: %s", zErrmsg); |
| 109304 | 109931 | } |
| 109305 | 109932 | sqlite3_free(zErrmsg); |
| 109306 | 109933 | sqlite3OsDlClose(pVfs, handle); |
| | @@ -109407,11 +110034,13 @@ |
| 109407 | 110034 | |
| 109408 | 110035 | /* |
| 109409 | 110036 | ** Register a statically linked extension that is automatically |
| 109410 | 110037 | ** loaded by every new database connection. |
| 109411 | 110038 | */ |
| 109412 | | -SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){ |
| 110039 | +SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension( |
| 110040 | + void (*xInit)(void) |
| 110041 | +){ |
| 109413 | 110042 | int rc = SQLITE_OK; |
| 109414 | 110043 | #ifndef SQLITE_OMIT_AUTOINIT |
| 109415 | 110044 | rc = sqlite3_initialize(); |
| 109416 | 110045 | if( rc ){ |
| 109417 | 110046 | return rc; |
| | @@ -109452,11 +110081,13 @@ |
| 109452 | 110081 | ** routine is a no-op. |
| 109453 | 110082 | ** |
| 109454 | 110083 | ** Return 1 if xInit was found on the list and removed. Return 0 if xInit |
| 109455 | 110084 | ** was not on the list. |
| 109456 | 110085 | */ |
| 109457 | | -SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){ |
| 110086 | +SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension( |
| 110087 | + void (*xInit)(void) |
| 110088 | +){ |
| 109458 | 110089 | #if SQLITE_THREADSAFE |
| 109459 | 110090 | sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); |
| 109460 | 110091 | #endif |
| 109461 | 110092 | int i; |
| 109462 | 110093 | int n = 0; |
| | @@ -109501,11 +110132,11 @@ |
| 109501 | 110132 | */ |
| 109502 | 110133 | SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){ |
| 109503 | 110134 | u32 i; |
| 109504 | 110135 | int go = 1; |
| 109505 | 110136 | int rc; |
| 109506 | | - int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*); |
| 110137 | + sqlite3_loadext_entry xInit; |
| 109507 | 110138 | |
| 109508 | 110139 | wsdAutoextInit; |
| 109509 | 110140 | if( wsdAutoext.nExt==0 ){ |
| 109510 | 110141 | /* Common case: early out without every having to acquire a mutex */ |
| 109511 | 110142 | return; |
| | @@ -109518,12 +110149,11 @@ |
| 109518 | 110149 | sqlite3_mutex_enter(mutex); |
| 109519 | 110150 | if( i>=wsdAutoext.nExt ){ |
| 109520 | 110151 | xInit = 0; |
| 109521 | 110152 | go = 0; |
| 109522 | 110153 | }else{ |
| 109523 | | - xInit = (int(*)(sqlite3*,char**,const sqlite3_api_routines*)) |
| 109524 | | - wsdAutoext.aExt[i]; |
| 110154 | + xInit = (sqlite3_loadext_entry)wsdAutoext.aExt[i]; |
| 109525 | 110155 | } |
| 109526 | 110156 | sqlite3_mutex_leave(mutex); |
| 109527 | 110157 | zErrmsg = 0; |
| 109528 | 110158 | if( xInit && (rc = xInit(db, &zErrmsg, &sqlite3Apis))!=0 ){ |
| 109529 | 110159 | sqlite3ErrorWithMsg(db, rc, |
| | @@ -111034,11 +111664,11 @@ |
| 111034 | 111664 | |
| 111035 | 111665 | /* Many of the flag-pragmas modify the code generated by the SQL |
| 111036 | 111666 | ** compiler (eg. count_changes). So add an opcode to expire all |
| 111037 | 111667 | ** compiled SQL statements after modifying a pragma value. |
| 111038 | 111668 | */ |
| 111039 | | - sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); |
| 111669 | + sqlite3VdbeAddOp0(v, OP_Expire); |
| 111040 | 111670 | setAllPagerFlags(db); |
| 111041 | 111671 | } |
| 111042 | 111672 | break; |
| 111043 | 111673 | } |
| 111044 | 111674 | #endif /* SQLITE_OMIT_FLAG_PRAGMAS */ |
| | @@ -111056,11 +111686,11 @@ |
| 111056 | 111686 | ** notnull: True if 'NOT NULL' is part of column declaration |
| 111057 | 111687 | ** dflt_value: The default value for the column, if any. |
| 111058 | 111688 | */ |
| 111059 | 111689 | case PragTyp_TABLE_INFO: if( zRight ){ |
| 111060 | 111690 | Table *pTab; |
| 111061 | | - pTab = sqlite3FindTable(db, zRight, zDb); |
| 111691 | + pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb); |
| 111062 | 111692 | if( pTab ){ |
| 111063 | 111693 | static const char *azCol[] = { |
| 111064 | 111694 | "cid", "name", "type", "notnull", "dflt_value", "pk" |
| 111065 | 111695 | }; |
| 111066 | 111696 | int i, k; |
| | @@ -111338,16 +111968,14 @@ |
| 111338 | 111968 | assert( iKey>=0 && iKey<pTab->nCol ); |
| 111339 | 111969 | if( iKey!=pTab->iPKey ){ |
| 111340 | 111970 | sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow); |
| 111341 | 111971 | sqlite3ColumnDefault(v, pTab, iKey, regRow); |
| 111342 | 111972 | sqlite3VdbeAddOp2(v, OP_IsNull, regRow, addrOk); VdbeCoverage(v); |
| 111343 | | - sqlite3VdbeAddOp2(v, OP_MustBeInt, regRow, |
| 111344 | | - sqlite3VdbeCurrentAddr(v)+3); VdbeCoverage(v); |
| 111345 | 111973 | }else{ |
| 111346 | 111974 | sqlite3VdbeAddOp2(v, OP_Rowid, 0, regRow); |
| 111347 | 111975 | } |
| 111348 | | - sqlite3VdbeAddOp3(v, OP_NotExists, i, 0, regRow); VdbeCoverage(v); |
| 111976 | + sqlite3VdbeAddOp3(v, OP_SeekRowid, i, 0, regRow); VdbeCoverage(v); |
| 111349 | 111977 | sqlite3VdbeGoto(v, addrOk); |
| 111350 | 111978 | sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); |
| 111351 | 111979 | }else{ |
| 111352 | 111980 | for(j=0; j<pFK->nCol; j++){ |
| 111353 | 111981 | sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, |
| | @@ -112914,10 +113542,11 @@ |
| 112914 | 113542 | int regReturn; /* Register holding block-output return address */ |
| 112915 | 113543 | int labelBkOut; /* Start label for the block-output subroutine */ |
| 112916 | 113544 | int addrSortIndex; /* Address of the OP_SorterOpen or OP_OpenEphemeral */ |
| 112917 | 113545 | int labelDone; /* Jump here when done, ex: LIMIT reached */ |
| 112918 | 113546 | u8 sortFlags; /* Zero or more SORTFLAG_* bits */ |
| 113547 | + u8 bOrderedInnerLoop; /* ORDER BY correctly sorts the inner loop */ |
| 112919 | 113548 | }; |
| 112920 | 113549 | #define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */ |
| 112921 | 113550 | |
| 112922 | 113551 | /* |
| 112923 | 113552 | ** Delete all the content of a Select structure. Deallocate the structure |
| | @@ -113447,13 +114076,34 @@ |
| 113447 | 114076 | op = OP_IdxInsert; |
| 113448 | 114077 | } |
| 113449 | 114078 | sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord); |
| 113450 | 114079 | if( iLimit ){ |
| 113451 | 114080 | int addr; |
| 114081 | + int r1 = 0; |
| 114082 | + /* Fill the sorter until it contains LIMIT+OFFSET entries. (The iLimit |
| 114083 | + ** register is initialized with value of LIMIT+OFFSET.) After the sorter |
| 114084 | + ** fills up, delete the least entry in the sorter after each insert. |
| 114085 | + ** Thus we never hold more than the LIMIT+OFFSET rows in memory at once */ |
| 113452 | 114086 | addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, 1); VdbeCoverage(v); |
| 113453 | 114087 | sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor); |
| 114088 | + if( pSort->bOrderedInnerLoop ){ |
| 114089 | + r1 = ++pParse->nMem; |
| 114090 | + sqlite3VdbeAddOp3(v, OP_Column, pSort->iECursor, nExpr, r1); |
| 114091 | + VdbeComment((v, "seq")); |
| 114092 | + } |
| 113454 | 114093 | sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor); |
| 114094 | + if( pSort->bOrderedInnerLoop ){ |
| 114095 | + /* If the inner loop is driven by an index such that values from |
| 114096 | + ** the same iteration of the inner loop are in sorted order, then |
| 114097 | + ** immediately jump to the next iteration of an inner loop if the |
| 114098 | + ** entry from the current iteration does not fit into the top |
| 114099 | + ** LIMIT+OFFSET entries of the sorter. */ |
| 114100 | + int iBrk = sqlite3VdbeCurrentAddr(v) + 2; |
| 114101 | + sqlite3VdbeAddOp3(v, OP_Eq, regBase+nExpr, iBrk, r1); |
| 114102 | + sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 114103 | + VdbeCoverage(v); |
| 114104 | + } |
| 113455 | 114105 | sqlite3VdbeJumpHere(v, addr); |
| 113456 | 114106 | } |
| 113457 | 114107 | } |
| 113458 | 114108 | |
| 113459 | 114109 | /* |
| | @@ -113864,11 +114514,11 @@ |
| 113864 | 114514 | ** Allocate a KeyInfo object sufficient for an index of N key columns and |
| 113865 | 114515 | ** X extra columns. |
| 113866 | 114516 | */ |
| 113867 | 114517 | SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){ |
| 113868 | 114518 | int nExtra = (N+X)*(sizeof(CollSeq*)+1); |
| 113869 | | - KeyInfo *p = sqlite3Malloc(sizeof(KeyInfo) + nExtra); |
| 114519 | + KeyInfo *p = sqlite3DbMallocRaw(db, sizeof(KeyInfo) + nExtra); |
| 113870 | 114520 | if( p ){ |
| 113871 | 114521 | p->aSortOrder = (u8*)&p->aColl[N+X]; |
| 113872 | 114522 | p->nField = (u16)N; |
| 113873 | 114523 | p->nXField = (u16)X; |
| 113874 | 114524 | p->enc = ENC(db); |
| | @@ -113886,11 +114536,11 @@ |
| 113886 | 114536 | */ |
| 113887 | 114537 | SQLITE_PRIVATE void sqlite3KeyInfoUnref(KeyInfo *p){ |
| 113888 | 114538 | if( p ){ |
| 113889 | 114539 | assert( p->nRef>0 ); |
| 113890 | 114540 | p->nRef--; |
| 113891 | | - if( p->nRef==0 ) sqlite3DbFree(0, p); |
| 114541 | + if( p->nRef==0 ) sqlite3DbFree(p->db, p); |
| 113892 | 114542 | } |
| 113893 | 114543 | } |
| 113894 | 114544 | |
| 113895 | 114545 | /* |
| 113896 | 114546 | ** Make a new pointer to a KeyInfo object |
| | @@ -118034,10 +118684,11 @@ |
| 118034 | 118684 | if( sDistinct.isTnct && sqlite3WhereIsDistinct(pWInfo) ){ |
| 118035 | 118685 | sDistinct.eTnctType = sqlite3WhereIsDistinct(pWInfo); |
| 118036 | 118686 | } |
| 118037 | 118687 | if( sSort.pOrderBy ){ |
| 118038 | 118688 | sSort.nOBSat = sqlite3WhereIsOrdered(pWInfo); |
| 118689 | + sSort.bOrderedInnerLoop = sqlite3WhereOrderedInnerLoop(pWInfo); |
| 118039 | 118690 | if( sSort.nOBSat==sSort.pOrderBy->nExpr ){ |
| 118040 | 118691 | sSort.pOrderBy = 0; |
| 118041 | 118692 | } |
| 118042 | 118693 | } |
| 118043 | 118694 | |
| | @@ -120803,11 +121454,11 @@ |
| 120803 | 121454 | Btree *pTemp; /* The temporary database we vacuum into */ |
| 120804 | 121455 | char *zSql = 0; /* SQL statements */ |
| 120805 | 121456 | int saved_flags; /* Saved value of the db->flags */ |
| 120806 | 121457 | int saved_nChange; /* Saved value of db->nChange */ |
| 120807 | 121458 | int saved_nTotalChange; /* Saved value of db->nTotalChange */ |
| 120808 | | - void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ |
| 121459 | + u8 saved_mTrace; /* Saved trace settings */ |
| 120809 | 121460 | Db *pDb = 0; /* Database to detach at end of vacuum */ |
| 120810 | 121461 | int isMemDb; /* True if vacuuming a :memory: database */ |
| 120811 | 121462 | int nRes; /* Bytes of reserved space at the end of each page */ |
| 120812 | 121463 | int nDb; /* Number of attached databases */ |
| 120813 | 121464 | |
| | @@ -120824,14 +121475,14 @@ |
| 120824 | 121475 | ** restored before returning. Then set the writable-schema flag, and |
| 120825 | 121476 | ** disable CHECK and foreign key constraints. */ |
| 120826 | 121477 | saved_flags = db->flags; |
| 120827 | 121478 | saved_nChange = db->nChange; |
| 120828 | 121479 | saved_nTotalChange = db->nTotalChange; |
| 120829 | | - saved_xTrace = db->xTrace; |
| 121480 | + saved_mTrace = db->mTrace; |
| 120830 | 121481 | db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks | SQLITE_PreferBuiltin; |
| 120831 | 121482 | db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder); |
| 120832 | | - db->xTrace = 0; |
| 121483 | + db->mTrace = 0; |
| 120833 | 121484 | |
| 120834 | 121485 | pMain = db->aDb[0].pBt; |
| 120835 | 121486 | isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); |
| 120836 | 121487 | |
| 120837 | 121488 | /* Attach the temporary database as 'vacuum_db'. The synchronous pragma |
| | @@ -120879,10 +121530,12 @@ |
| 120879 | 121530 | sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey); |
| 120880 | 121531 | if( nKey ) db->nextPagesize = 0; |
| 120881 | 121532 | } |
| 120882 | 121533 | #endif |
| 120883 | 121534 | |
| 121535 | + sqlite3BtreeSetCacheSize(pTemp, db->aDb[0].pSchema->cache_size); |
| 121536 | + sqlite3BtreeSetSpillSize(pTemp, sqlite3BtreeSetSpillSize(pMain,0)); |
| 120884 | 121537 | rc = execSql(db, pzErrMsg, "PRAGMA vacuum_db.synchronous=OFF"); |
| 120885 | 121538 | if( rc!=SQLITE_OK ) goto end_of_vacuum; |
| 120886 | 121539 | |
| 120887 | 121540 | /* Begin a transaction and take an exclusive lock on the main database |
| 120888 | 121541 | ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below, |
| | @@ -121027,11 +121680,11 @@ |
| 121027 | 121680 | end_of_vacuum: |
| 121028 | 121681 | /* Restore the original value of db->flags */ |
| 121029 | 121682 | db->flags = saved_flags; |
| 121030 | 121683 | db->nChange = saved_nChange; |
| 121031 | 121684 | db->nTotalChange = saved_nTotalChange; |
| 121032 | | - db->xTrace = saved_xTrace; |
| 121685 | + db->mTrace = saved_mTrace; |
| 121033 | 121686 | sqlite3BtreeSetPageSize(pMain, -1, -1, 1); |
| 121034 | 121687 | |
| 121035 | 121688 | /* Currently there is an SQL level transaction open on the vacuum |
| 121036 | 121689 | ** database. No locks are held on any other files (since the main file |
| 121037 | 121690 | ** was committed at the btree level). So it safe to end the transaction |
| | @@ -121476,11 +122129,11 @@ |
| 121476 | 122129 | ); |
| 121477 | 122130 | sqlite3DbFree(db, zStmt); |
| 121478 | 122131 | v = sqlite3GetVdbe(pParse); |
| 121479 | 122132 | sqlite3ChangeCookie(pParse, iDb); |
| 121480 | 122133 | |
| 121481 | | - sqlite3VdbeAddOp2(v, OP_Expire, 0, 0); |
| 122134 | + sqlite3VdbeAddOp0(v, OP_Expire); |
| 121482 | 122135 | zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName); |
| 121483 | 122136 | sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere); |
| 121484 | 122137 | |
| 121485 | 122138 | iReg = ++pParse->nMem; |
| 121486 | 122139 | sqlite3VdbeLoadString(v, iReg, pTab->zName); |
| | @@ -121812,14 +122465,28 @@ |
| 121812 | 122465 | && !db->mallocFailed |
| 121813 | 122466 | && !pParse->pNewTable->pSelect |
| 121814 | 122467 | && (pParse->pNewTable->tabFlags & TF_Virtual)==0 |
| 121815 | 122468 | ){ |
| 121816 | 122469 | if( !pTab->aCol ){ |
| 121817 | | - pTab->aCol = pParse->pNewTable->aCol; |
| 121818 | | - pTab->nCol = pParse->pNewTable->nCol; |
| 121819 | | - pParse->pNewTable->nCol = 0; |
| 121820 | | - pParse->pNewTable->aCol = 0; |
| 122470 | + Table *pNew = pParse->pNewTable; |
| 122471 | + Index *pIdx; |
| 122472 | + pTab->aCol = pNew->aCol; |
| 122473 | + pTab->nCol = pNew->nCol; |
| 122474 | + pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid); |
| 122475 | + pNew->nCol = 0; |
| 122476 | + pNew->aCol = 0; |
| 122477 | + assert( pTab->pIndex==0 ); |
| 122478 | + if( !HasRowid(pNew) && pCtx->pVTable->pMod->pModule->xUpdate!=0 ){ |
| 122479 | + rc = SQLITE_ERROR; |
| 122480 | + } |
| 122481 | + pIdx = pNew->pIndex; |
| 122482 | + if( pIdx ){ |
| 122483 | + assert( pIdx->pNext==0 ); |
| 122484 | + pTab->pIndex = pIdx; |
| 122485 | + pNew->pIndex = 0; |
| 122486 | + pIdx->pTable = pTab; |
| 122487 | + } |
| 121821 | 122488 | } |
| 121822 | 122489 | pCtx->bDeclared = 1; |
| 121823 | 122490 | }else{ |
| 121824 | 122491 | sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr); |
| 121825 | 122492 | sqlite3DbFree(db, zErr); |
| | @@ -121851,11 +122518,11 @@ |
| 121851 | 122518 | SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab){ |
| 121852 | 122519 | int rc = SQLITE_OK; |
| 121853 | 122520 | Table *pTab; |
| 121854 | 122521 | |
| 121855 | 122522 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName); |
| 121856 | | - if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){ |
| 122523 | + if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){ |
| 121857 | 122524 | VTable *p; |
| 121858 | 122525 | int (*xDestroy)(sqlite3_vtab *); |
| 121859 | 122526 | for(p=pTab->pVTable; p; p=p->pNext){ |
| 121860 | 122527 | assert( p->pVtab ); |
| 121861 | 122528 | if( p->pVtab->nRef>0 ){ |
| | @@ -121991,11 +122658,14 @@ |
| 121991 | 122658 | if( rc==SQLITE_OK ){ |
| 121992 | 122659 | rc = pModule->xBegin(pVTab->pVtab); |
| 121993 | 122660 | if( rc==SQLITE_OK ){ |
| 121994 | 122661 | int iSvpt = db->nStatement + db->nSavepoint; |
| 121995 | 122662 | addToVTrans(db, pVTab); |
| 121996 | | - if( iSvpt ) rc = sqlite3VtabSavepoint(db, SAVEPOINT_BEGIN, iSvpt-1); |
| 122663 | + if( iSvpt && pModule->xSavepoint ){ |
| 122664 | + pVTab->iSavepoint = iSvpt; |
| 122665 | + rc = pModule->xSavepoint(pVTab->pVtab, iSvpt-1); |
| 122666 | + } |
| 121997 | 122667 | } |
| 121998 | 122668 | } |
| 121999 | 122669 | } |
| 122000 | 122670 | return rc; |
| 122001 | 122671 | } |
| | @@ -122145,11 +122815,11 @@ |
| 122145 | 122815 | sqlite3OomFault(pToplevel->db); |
| 122146 | 122816 | } |
| 122147 | 122817 | } |
| 122148 | 122818 | |
| 122149 | 122819 | /* |
| 122150 | | -** Check to see if virtual tale module pMod can be have an eponymous |
| 122820 | +** Check to see if virtual table module pMod can be have an eponymous |
| 122151 | 122821 | ** virtual table instance. If it can, create one if one does not already |
| 122152 | 122822 | ** exist. Return non-zero if the eponymous virtual table instance exists |
| 122153 | 122823 | ** when this routine returns, and return zero if it does not exist. |
| 122154 | 122824 | ** |
| 122155 | 122825 | ** An eponymous virtual table instance is one that is named after its |
| | @@ -122162,21 +122832,22 @@ |
| 122162 | 122832 | */ |
| 122163 | 122833 | SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ |
| 122164 | 122834 | const sqlite3_module *pModule = pMod->pModule; |
| 122165 | 122835 | Table *pTab; |
| 122166 | 122836 | char *zErr = 0; |
| 122167 | | - int nName; |
| 122168 | 122837 | int rc; |
| 122169 | 122838 | sqlite3 *db = pParse->db; |
| 122170 | 122839 | if( pMod->pEpoTab ) return 1; |
| 122171 | 122840 | if( pModule->xCreate!=0 && pModule->xCreate!=pModule->xConnect ) return 0; |
| 122172 | | - nName = sqlite3Strlen30(pMod->zName) + 1; |
| 122173 | | - pTab = sqlite3DbMallocZero(db, sizeof(Table) + nName); |
| 122841 | + pTab = sqlite3DbMallocZero(db, sizeof(Table)); |
| 122174 | 122842 | if( pTab==0 ) return 0; |
| 122843 | + pTab->zName = sqlite3DbStrDup(db, pMod->zName); |
| 122844 | + if( pTab->zName==0 ){ |
| 122845 | + sqlite3DbFree(db, pTab); |
| 122846 | + return 0; |
| 122847 | + } |
| 122175 | 122848 | pMod->pEpoTab = pTab; |
| 122176 | | - pTab->zName = (char*)&pTab[1]; |
| 122177 | | - memcpy(pTab->zName, pMod->zName, nName); |
| 122178 | 122849 | pTab->nRef = 1; |
| 122179 | 122850 | pTab->pSchema = db->aDb[0].pSchema; |
| 122180 | 122851 | pTab->tabFlags |= TF_Virtual; |
| 122181 | 122852 | pTab->nModuleArg = 0; |
| 122182 | 122853 | pTab->iPKey = -1; |
| | @@ -122198,13 +122869,15 @@ |
| 122198 | 122869 | ** virtual table module pMod, if it exists. |
| 122199 | 122870 | */ |
| 122200 | 122871 | SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3 *db, Module *pMod){ |
| 122201 | 122872 | Table *pTab = pMod->pEpoTab; |
| 122202 | 122873 | if( pTab!=0 ){ |
| 122203 | | - sqlite3DeleteColumnNames(db, pTab); |
| 122204 | | - sqlite3VtabClear(db, pTab); |
| 122205 | | - sqlite3DbFree(db, pTab); |
| 122874 | + /* Mark the table as Ephemeral prior to deleting it, so that the |
| 122875 | + ** sqlite3DeleteTable() routine will know that it is not stored in |
| 122876 | + ** the schema. */ |
| 122877 | + pTab->tabFlags |= TF_Ephemeral; |
| 122878 | + sqlite3DeleteTable(db, pTab); |
| 122206 | 122879 | pMod->pEpoTab = 0; |
| 122207 | 122880 | } |
| 122208 | 122881 | } |
| 122209 | 122882 | |
| 122210 | 122883 | /* |
| | @@ -122707,12 +123380,13 @@ |
| 122707 | 123380 | u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ |
| 122708 | 123381 | i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */ |
| 122709 | 123382 | u8 sorted; /* True if really sorted (not just grouped) */ |
| 122710 | 123383 | u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */ |
| 122711 | 123384 | u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ |
| 122712 | | - u8 eDistinct; /* One of the WHERE_DISTINCT_* values below */ |
| 123385 | + u8 eDistinct; /* One of the WHERE_DISTINCT_* values */ |
| 122713 | 123386 | u8 nLevel; /* Number of nested loop */ |
| 123387 | + u8 bOrderedInnerLoop; /* True if only the inner-most loop is ordered */ |
| 122714 | 123388 | int iTop; /* The very beginning of the WHERE loop */ |
| 122715 | 123389 | int iContinue; /* Jump here to continue with next record */ |
| 122716 | 123390 | int iBreak; /* Jump here to break out of the loop */ |
| 122717 | 123391 | int savedNQueryLoop; /* pParse->nQueryLoop outside the WHERE loop */ |
| 122718 | 123392 | int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */ |
| | @@ -122725,10 +123399,13 @@ |
| 122725 | 123399 | ** Private interfaces - callable only by other where.c routines. |
| 122726 | 123400 | ** |
| 122727 | 123401 | ** where.c: |
| 122728 | 123402 | */ |
| 122729 | 123403 | SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet*,int); |
| 123404 | +#ifdef WHERETRACE_ENABLED |
| 123405 | +SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC); |
| 123406 | +#endif |
| 122730 | 123407 | SQLITE_PRIVATE WhereTerm *sqlite3WhereFindTerm( |
| 122731 | 123408 | WhereClause *pWC, /* The WHERE clause to be searched */ |
| 122732 | 123409 | int iCur, /* Cursor number of LHS */ |
| 122733 | 123410 | int iColumn, /* Column number of LHS */ |
| 122734 | 123411 | Bitmask notReady, /* RHS must not overlap with this mask */ |
| | @@ -122941,11 +123618,11 @@ |
| 122941 | 123618 | StrAccum str; /* EQP output string */ |
| 122942 | 123619 | char zBuf[100]; /* Initial space for EQP output string */ |
| 122943 | 123620 | |
| 122944 | 123621 | pLoop = pLevel->pWLoop; |
| 122945 | 123622 | flags = pLoop->wsFlags; |
| 122946 | | - if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return 0; |
| 123623 | + if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_OR_SUBCLAUSE) ) return 0; |
| 122947 | 123624 | |
| 122948 | 123625 | isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0 |
| 122949 | 123626 | || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0)) |
| 122950 | 123627 | || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX)); |
| 122951 | 123628 | |
| | @@ -123384,11 +124061,11 @@ |
| 123384 | 124061 | ** |
| 123385 | 124062 | ** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range |
| 123386 | 124063 | ** expression: "x>='ABC' AND x<'abd'". But this requires that the range |
| 123387 | 124064 | ** scan loop run twice, once for strings and a second time for BLOBs. |
| 123388 | 124065 | ** The OP_String opcodes on the second pass convert the upper and lower |
| 123389 | | -** bound string contants to blobs. This routine makes the necessary changes |
| 124066 | +** bound string constants to blobs. This routine makes the necessary changes |
| 123390 | 124067 | ** to the OP_String opcodes for that to happen. |
| 123391 | 124068 | ** |
| 123392 | 124069 | ** Except, of course, if SQLITE_LIKE_DOESNT_MATCH_BLOBS is defined, then |
| 123393 | 124070 | ** only the one pass through the string space is required, so this routine |
| 123394 | 124071 | ** becomes a no-op. |
| | @@ -123441,10 +124118,42 @@ |
| 123441 | 124118 | pWalker->eCode = 1; |
| 123442 | 124119 | } |
| 123443 | 124120 | return WRC_Continue; |
| 123444 | 124121 | } |
| 123445 | 124122 | |
| 124123 | +/* |
| 124124 | +** Test whether or not expression pExpr, which was part of a WHERE clause, |
| 124125 | +** should be included in the cursor-hint for a table that is on the rhs |
| 124126 | +** of a LEFT JOIN. Set Walker.eCode to non-zero before returning if the |
| 124127 | +** expression is not suitable. |
| 124128 | +** |
| 124129 | +** An expression is unsuitable if it might evaluate to non NULL even if |
| 124130 | +** a TK_COLUMN node that does affect the value of the expression is set |
| 124131 | +** to NULL. For example: |
| 124132 | +** |
| 124133 | +** col IS NULL |
| 124134 | +** col IS NOT NULL |
| 124135 | +** coalesce(col, 1) |
| 124136 | +** CASE WHEN col THEN 0 ELSE 1 END |
| 124137 | +*/ |
| 124138 | +static int codeCursorHintIsOrFunction(Walker *pWalker, Expr *pExpr){ |
| 124139 | + if( pExpr->op==TK_IS |
| 124140 | + || pExpr->op==TK_ISNULL || pExpr->op==TK_ISNOT |
| 124141 | + || pExpr->op==TK_NOTNULL || pExpr->op==TK_CASE |
| 124142 | + ){ |
| 124143 | + pWalker->eCode = 1; |
| 124144 | + }else if( pExpr->op==TK_FUNCTION ){ |
| 124145 | + int d1; |
| 124146 | + char d2[3]; |
| 124147 | + if( 0==sqlite3IsLikeFunction(pWalker->pParse->db, pExpr, &d1, d2) ){ |
| 124148 | + pWalker->eCode = 1; |
| 124149 | + } |
| 124150 | + } |
| 124151 | + |
| 124152 | + return WRC_Continue; |
| 124153 | +} |
| 124154 | + |
| 123446 | 124155 | |
| 123447 | 124156 | /* |
| 123448 | 124157 | ** This function is called on every node of an expression tree used as an |
| 123449 | 124158 | ** argument to the OP_CursorHint instruction. If the node is a TK_COLUMN |
| 123450 | 124159 | ** that accesses any table other than the one identified by |
| | @@ -123493,10 +124202,11 @@ |
| 123493 | 124202 | |
| 123494 | 124203 | /* |
| 123495 | 124204 | ** Insert an OP_CursorHint instruction if it is appropriate to do so. |
| 123496 | 124205 | */ |
| 123497 | 124206 | static void codeCursorHint( |
| 124207 | + struct SrcList_item *pTabItem, /* FROM clause item */ |
| 123498 | 124208 | WhereInfo *pWInfo, /* The where clause */ |
| 123499 | 124209 | WhereLevel *pLevel, /* Which loop to provide hints for */ |
| 123500 | 124210 | WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */ |
| 123501 | 124211 | ){ |
| 123502 | 124212 | Parse *pParse = pWInfo->pParse; |
| | @@ -123523,11 +124233,46 @@ |
| 123523 | 124233 | pWC = &pWInfo->sWC; |
| 123524 | 124234 | for(i=0; i<pWC->nTerm; i++){ |
| 123525 | 124235 | pTerm = &pWC->a[i]; |
| 123526 | 124236 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 123527 | 124237 | if( pTerm->prereqAll & pLevel->notReady ) continue; |
| 123528 | | - if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue; |
| 124238 | + |
| 124239 | + /* Any terms specified as part of the ON(...) clause for any LEFT |
| 124240 | + ** JOIN for which the current table is not the rhs are omitted |
| 124241 | + ** from the cursor-hint. |
| 124242 | + ** |
| 124243 | + ** If this table is the rhs of a LEFT JOIN, "IS" or "IS NULL" terms |
| 124244 | + ** that were specified as part of the WHERE clause must be excluded. |
| 124245 | + ** This is to address the following: |
| 124246 | + ** |
| 124247 | + ** SELECT ... t1 LEFT JOIN t2 ON (t1.a=t2.b) WHERE t2.c IS NULL; |
| 124248 | + ** |
| 124249 | + ** Say there is a single row in t2 that matches (t1.a=t2.b), but its |
| 124250 | + ** t2.c values is not NULL. If the (t2.c IS NULL) constraint is |
| 124251 | + ** pushed down to the cursor, this row is filtered out, causing |
| 124252 | + ** SQLite to synthesize a row of NULL values. Which does match the |
| 124253 | + ** WHERE clause, and so the query returns a row. Which is incorrect. |
| 124254 | + ** |
| 124255 | + ** For the same reason, WHERE terms such as: |
| 124256 | + ** |
| 124257 | + ** WHERE 1 = (t2.c IS NULL) |
| 124258 | + ** |
| 124259 | + ** are also excluded. See codeCursorHintIsOrFunction() for details. |
| 124260 | + */ |
| 124261 | + if( pTabItem->fg.jointype & JT_LEFT ){ |
| 124262 | + Expr *pExpr = pTerm->pExpr; |
| 124263 | + if( !ExprHasProperty(pExpr, EP_FromJoin) |
| 124264 | + || pExpr->iRightJoinTable!=pTabItem->iCursor |
| 124265 | + ){ |
| 124266 | + sWalker.eCode = 0; |
| 124267 | + sWalker.xExprCallback = codeCursorHintIsOrFunction; |
| 124268 | + sqlite3WalkExpr(&sWalker, pTerm->pExpr); |
| 124269 | + if( sWalker.eCode ) continue; |
| 124270 | + } |
| 124271 | + }else{ |
| 124272 | + if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) continue; |
| 124273 | + } |
| 123529 | 124274 | |
| 123530 | 124275 | /* All terms in pWLoop->aLTerm[] except pEndRange are used to initialize |
| 123531 | 124276 | ** the cursor. These terms are not needed as hints for a pure range |
| 123532 | 124277 | ** scan (that has no == terms) so omit them. */ |
| 123533 | 124278 | if( pLoop->u.btree.nEq==0 && pTerm!=pEndRange ){ |
| | @@ -123557,11 +124302,11 @@ |
| 123557 | 124302 | (sHint.pIdx ? sHint.iIdxCur : sHint.iTabCur), 0, 0, |
| 123558 | 124303 | (const char*)pExpr, P4_EXPR); |
| 123559 | 124304 | } |
| 123560 | 124305 | } |
| 123561 | 124306 | #else |
| 123562 | | -# define codeCursorHint(A,B,C) /* No-op */ |
| 124307 | +# define codeCursorHint(A,B,C,D) /* No-op */ |
| 123563 | 124308 | #endif /* SQLITE_ENABLE_CURSOR_HINTS */ |
| 123564 | 124309 | |
| 123565 | 124310 | /* |
| 123566 | 124311 | ** Cursor iCur is open on an intkey b-tree (a table). Register iRowid contains |
| 123567 | 124312 | ** a rowid value just read from cursor iIdxCur, open on index pIdx. This |
| | @@ -123591,11 +124336,11 @@ |
| 123591 | 124336 | |
| 123592 | 124337 | assert( iIdxCur>0 ); |
| 123593 | 124338 | assert( pIdx->aiColumn[pIdx->nColumn-1]==-1 ); |
| 123594 | 124339 | |
| 123595 | 124340 | sqlite3VdbeAddOp3(v, OP_Seek, iIdxCur, 0, iCur); |
| 123596 | | - if( (pWInfo->wctrlFlags & WHERE_FORCE_TABLE) |
| 124341 | + if( (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE) |
| 123597 | 124342 | && DbMaskAllZero(sqlite3ParseToplevel(pParse)->writeMask) |
| 123598 | 124343 | ){ |
| 123599 | 124344 | int i; |
| 123600 | 124345 | Table *pTab = pIdx->pTable; |
| 123601 | 124346 | int *ai = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*(pTab->nCol+1)); |
| | @@ -123646,11 +124391,11 @@ |
| 123646 | 124391 | pTabItem = &pWInfo->pTabList->a[pLevel->iFrom]; |
| 123647 | 124392 | iCur = pTabItem->iCursor; |
| 123648 | 124393 | pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); |
| 123649 | 124394 | bRev = (pWInfo->revMask>>iLevel)&1; |
| 123650 | 124395 | omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 |
| 123651 | | - && (pWInfo->wctrlFlags & WHERE_FORCE_TABLE)==0; |
| 124396 | + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0; |
| 123652 | 124397 | VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName)); |
| 123653 | 124398 | |
| 123654 | 124399 | /* Create labels for the "break" and "continue" instructions |
| 123655 | 124400 | ** for the current loop. Jump to addrBrk to break out of a loop. |
| 123656 | 124401 | ** Jump to cont to go immediately to the next iteration of the |
| | @@ -123786,12 +124531,11 @@ |
| 123786 | 124531 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 123787 | 124532 | iReleaseReg = ++pParse->nMem; |
| 123788 | 124533 | iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg); |
| 123789 | 124534 | if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg); |
| 123790 | 124535 | addrNxt = pLevel->addrNxt; |
| 123791 | | - sqlite3VdbeAddOp2(v, OP_MustBeInt, iRowidReg, addrNxt); VdbeCoverage(v); |
| 123792 | | - sqlite3VdbeAddOp3(v, OP_NotExists, iCur, addrNxt, iRowidReg); |
| 124536 | + sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg); |
| 123793 | 124537 | VdbeCoverage(v); |
| 123794 | 124538 | sqlite3ExprCacheAffinityChange(pParse, iRowidReg, 1); |
| 123795 | 124539 | sqlite3ExprCacheStore(pParse, iCur, -1, iRowidReg); |
| 123796 | 124540 | VdbeComment((v, "pk")); |
| 123797 | 124541 | pLevel->op = OP_Noop; |
| | @@ -123814,11 +124558,11 @@ |
| 123814 | 124558 | if( bRev ){ |
| 123815 | 124559 | pTerm = pStart; |
| 123816 | 124560 | pStart = pEnd; |
| 123817 | 124561 | pEnd = pTerm; |
| 123818 | 124562 | } |
| 123819 | | - codeCursorHint(pWInfo, pLevel, pEnd); |
| 124563 | + codeCursorHint(pTabItem, pWInfo, pLevel, pEnd); |
| 123820 | 124564 | if( pStart ){ |
| 123821 | 124565 | Expr *pX; /* The expression that defines the start bound */ |
| 123822 | 124566 | int r1, rTemp; /* Registers for holding the start boundary */ |
| 123823 | 124567 | |
| 123824 | 124568 | /* The following constant maps TK_xx codes into corresponding |
| | @@ -124028,11 +124772,11 @@ |
| 124028 | 124772 | |
| 124029 | 124773 | /* Generate code to evaluate all constraint terms using == or IN |
| 124030 | 124774 | ** and store the values of those terms in an array of registers |
| 124031 | 124775 | ** starting at regBase. |
| 124032 | 124776 | */ |
| 124033 | | - codeCursorHint(pWInfo, pLevel, pRangeEnd); |
| 124777 | + codeCursorHint(pTabItem, pWInfo, pLevel, pRangeEnd); |
| 124034 | 124778 | regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff); |
| 124035 | 124779 | assert( zStartAff==0 || sqlite3Strlen30(zStartAff)>=nEq ); |
| 124036 | 124780 | if( zStartAff ) cEndAff = zStartAff[nEq]; |
| 124037 | 124781 | addrNxt = pLevel->addrNxt; |
| 124038 | 124782 | |
| | @@ -124067,10 +124811,11 @@ |
| 124067 | 124811 | zStartAff[nEq] = SQLITE_AFF_BLOB; |
| 124068 | 124812 | } |
| 124069 | 124813 | } |
| 124070 | 124814 | nConstraint++; |
| 124071 | 124815 | testcase( pRangeStart->wtFlags & TERM_VIRTUAL ); |
| 124816 | + bSeekPastNull = 0; |
| 124072 | 124817 | }else if( bSeekPastNull ){ |
| 124073 | 124818 | sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq); |
| 124074 | 124819 | nConstraint++; |
| 124075 | 124820 | startEq = 0; |
| 124076 | 124821 | start_constraints = 1; |
| | @@ -124332,15 +125077,11 @@ |
| 124332 | 125077 | |
| 124333 | 125078 | /* Run a separate WHERE clause for each term of the OR clause. After |
| 124334 | 125079 | ** eliminating duplicates from other WHERE clauses, the action for each |
| 124335 | 125080 | ** sub-WHERE clause is to to invoke the main loop body as a subroutine. |
| 124336 | 125081 | */ |
| 124337 | | - wctrlFlags = WHERE_OMIT_OPEN_CLOSE |
| 124338 | | - | WHERE_FORCE_TABLE |
| 124339 | | - | WHERE_ONETABLE_ONLY |
| 124340 | | - | WHERE_NO_AUTOINDEX |
| 124341 | | - | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE); |
| 125082 | + wctrlFlags = WHERE_OR_SUBCLAUSE | (pWInfo->wctrlFlags & WHERE_SEEK_TABLE); |
| 124342 | 125083 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 124343 | 125084 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 124344 | 125085 | if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 124345 | 125086 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 124346 | 125087 | Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */ |
| | @@ -124444,11 +125185,10 @@ |
| 124444 | 125185 | && (ii==0 || pSubLoop->u.btree.pIndex==pCov) |
| 124445 | 125186 | && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex)) |
| 124446 | 125187 | ){ |
| 124447 | 125188 | assert( pSubWInfo->a[0].iIdxCur==iCovCur ); |
| 124448 | 125189 | pCov = pSubLoop->u.btree.pIndex; |
| 124449 | | - wctrlFlags |= WHERE_REOPEN_IDX; |
| 124450 | 125190 | }else{ |
| 124451 | 125191 | pCov = 0; |
| 124452 | 125192 | } |
| 124453 | 125193 | |
| 124454 | 125194 | /* Finish the loop through table entries that match term pOrTerm. */ |
| | @@ -124481,11 +125221,11 @@ |
| 124481 | 125221 | if( pTabItem->fg.isRecursive ){ |
| 124482 | 125222 | /* Tables marked isRecursive have only a single row that is stored in |
| 124483 | 125223 | ** a pseudo-cursor. No need to Rewind or Next such cursors. */ |
| 124484 | 125224 | pLevel->op = OP_Noop; |
| 124485 | 125225 | }else{ |
| 124486 | | - codeCursorHint(pWInfo, pLevel, 0); |
| 125226 | + codeCursorHint(pTabItem, pWInfo, pLevel, 0); |
| 124487 | 125227 | pLevel->op = aStep[bRev]; |
| 124488 | 125228 | pLevel->p1 = iCur; |
| 124489 | 125229 | pLevel->p2 = 1 + sqlite3VdbeAddOp2(v, aStart[bRev], iCur, addrBrk); |
| 124490 | 125230 | VdbeCoverageIf(v, bRev==0); |
| 124491 | 125231 | VdbeCoverageIf(v, bRev!=0); |
| | @@ -124506,11 +125246,11 @@ |
| 124506 | 125246 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 124507 | 125247 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 124508 | 125248 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 124509 | 125249 | if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ |
| 124510 | 125250 | testcase( pWInfo->untestedTerms==0 |
| 124511 | | - && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ); |
| 125251 | + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ); |
| 124512 | 125252 | pWInfo->untestedTerms = 1; |
| 124513 | 125253 | continue; |
| 124514 | 125254 | } |
| 124515 | 125255 | pE = pTerm->pExpr; |
| 124516 | 125256 | assert( pE!=0 ); |
| | @@ -125168,11 +125908,13 @@ |
| 125168 | 125908 | sqlite3WhereExprAnalyze(pSrc, pAndWC); |
| 125169 | 125909 | pAndWC->pOuter = pWC; |
| 125170 | 125910 | if( !db->mallocFailed ){ |
| 125171 | 125911 | for(j=0, pAndTerm=pAndWC->a; j<pAndWC->nTerm; j++, pAndTerm++){ |
| 125172 | 125912 | assert( pAndTerm->pExpr ); |
| 125173 | | - if( allowedOp(pAndTerm->pExpr->op) ){ |
| 125913 | + if( allowedOp(pAndTerm->pExpr->op) |
| 125914 | + || pAndTerm->eOperator==WO_MATCH |
| 125915 | + ){ |
| 125174 | 125916 | b |= sqlite3WhereGetMask(&pWInfo->sMaskSet, pAndTerm->leftCursor); |
| 125175 | 125917 | } |
| 125176 | 125918 | } |
| 125177 | 125919 | } |
| 125178 | 125920 | indexable &= b; |
| | @@ -125383,16 +126125,14 @@ |
| 125383 | 126125 | return 0; |
| 125384 | 126126 | } |
| 125385 | 126127 | pColl = sqlite3BinaryCompareCollSeq(pParse, pExpr->pLeft, pExpr->pRight); |
| 125386 | 126128 | if( pColl==0 || sqlite3StrICmp(pColl->zName, "BINARY")==0 ) return 1; |
| 125387 | 126129 | pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft); |
| 125388 | | - /* Since pLeft and pRight are both a column references, their collating |
| 125389 | | - ** sequence should always be defined. */ |
| 125390 | | - zColl1 = ALWAYS(pColl) ? pColl->zName : 0; |
| 126130 | + zColl1 = pColl ? pColl->zName : 0; |
| 125391 | 126131 | pColl = sqlite3ExprCollSeq(pParse, pExpr->pRight); |
| 125392 | | - zColl2 = ALWAYS(pColl) ? pColl->zName : 0; |
| 125393 | | - return sqlite3StrICmp(zColl1, zColl2)==0; |
| 126132 | + zColl2 = pColl ? pColl->zName : 0; |
| 126133 | + return sqlite3_stricmp(zColl1, zColl2)==0; |
| 125394 | 126134 | } |
| 125395 | 126135 | |
| 125396 | 126136 | /* |
| 125397 | 126137 | ** Recursively walk the expressions of a SELECT statement and generate |
| 125398 | 126138 | ** a bitmask indicating which tables are used in that expression |
| | @@ -125722,11 +126462,11 @@ |
| 125722 | 126462 | ** current expression is of the form: column MATCH expr. |
| 125723 | 126463 | ** This information is used by the xBestIndex methods of |
| 125724 | 126464 | ** virtual tables. The native query optimizer does not attempt |
| 125725 | 126465 | ** to do anything with MATCH functions. |
| 125726 | 126466 | */ |
| 125727 | | - if( isMatchOfColumn(pExpr, &eOp2) ){ |
| 126467 | + if( pWC->op==TK_AND && isMatchOfColumn(pExpr, &eOp2) ){ |
| 125728 | 126468 | int idxNew; |
| 125729 | 126469 | Expr *pRight, *pLeft; |
| 125730 | 126470 | WhereTerm *pNewTerm; |
| 125731 | 126471 | Bitmask prereqColumn, prereqExpr; |
| 125732 | 126472 | |
| | @@ -126014,10 +126754,22 @@ |
| 126014 | 126754 | ** Return FALSE if the output needs to be sorted. |
| 126015 | 126755 | */ |
| 126016 | 126756 | SQLITE_PRIVATE int sqlite3WhereIsOrdered(WhereInfo *pWInfo){ |
| 126017 | 126757 | return pWInfo->nOBSat; |
| 126018 | 126758 | } |
| 126759 | + |
| 126760 | +/* |
| 126761 | +** Return TRUE if the innermost loop of the WHERE clause implementation |
| 126762 | +** returns rows in ORDER BY order for complete run of the inner loop. |
| 126763 | +** |
| 126764 | +** Across multiple iterations of outer loops, the output rows need not be |
| 126765 | +** sorted. As long as rows are sorted for just the innermost loop, this |
| 126766 | +** routine can return TRUE. |
| 126767 | +*/ |
| 126768 | +SQLITE_PRIVATE int sqlite3WhereOrderedInnerLoop(WhereInfo *pWInfo){ |
| 126769 | + return pWInfo->bOrderedInnerLoop; |
| 126770 | +} |
| 126019 | 126771 | |
| 126020 | 126772 | /* |
| 126021 | 126773 | ** Return the VDBE address or label to jump to in order to continue |
| 126022 | 126774 | ** immediately with the next row of a WHERE clause. |
| 126023 | 126775 | */ |
| | @@ -127600,20 +128352,42 @@ |
| 127600 | 128352 | static void whereTermPrint(WhereTerm *pTerm, int iTerm){ |
| 127601 | 128353 | if( pTerm==0 ){ |
| 127602 | 128354 | sqlite3DebugPrintf("TERM-%-3d NULL\n", iTerm); |
| 127603 | 128355 | }else{ |
| 127604 | 128356 | char zType[4]; |
| 128357 | + char zLeft[50]; |
| 127605 | 128358 | memcpy(zType, "...", 4); |
| 127606 | 128359 | if( pTerm->wtFlags & TERM_VIRTUAL ) zType[0] = 'V'; |
| 127607 | 128360 | if( pTerm->eOperator & WO_EQUIV ) zType[1] = 'E'; |
| 127608 | 128361 | if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L'; |
| 128362 | + if( pTerm->eOperator & WO_SINGLE ){ |
| 128363 | + sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}", |
| 128364 | + pTerm->leftCursor, pTerm->u.leftColumn); |
| 128365 | + }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){ |
| 128366 | + sqlite3_snprintf(sizeof(zLeft),zLeft,"indexable=0x%lld", |
| 128367 | + pTerm->u.pOrInfo->indexable); |
| 128368 | + }else{ |
| 128369 | + sqlite3_snprintf(sizeof(zLeft),zLeft,"left=%d", pTerm->leftCursor); |
| 128370 | + } |
| 127609 | 128371 | sqlite3DebugPrintf( |
| 127610 | | - "TERM-%-3d %p %s cursor=%-3d prob=%-3d op=0x%03x wtFlags=0x%04x\n", |
| 127611 | | - iTerm, pTerm, zType, pTerm->leftCursor, pTerm->truthProb, |
| 128372 | + "TERM-%-3d %p %s %-12s prob=%-3d op=0x%03x wtFlags=0x%04x\n", |
| 128373 | + iTerm, pTerm, zType, zLeft, pTerm->truthProb, |
| 127612 | 128374 | pTerm->eOperator, pTerm->wtFlags); |
| 127613 | 128375 | sqlite3TreeViewExpr(0, pTerm->pExpr, 0); |
| 127614 | 128376 | } |
| 128377 | +} |
| 128378 | +#endif |
| 128379 | + |
| 128380 | +#ifdef WHERETRACE_ENABLED |
| 128381 | +/* |
| 128382 | +** Show the complete content of a WhereClause |
| 128383 | +*/ |
| 128384 | +SQLITE_PRIVATE void sqlite3WhereClausePrint(WhereClause *pWC){ |
| 128385 | + int i; |
| 128386 | + for(i=0; i<pWC->nTerm; i++){ |
| 128387 | + whereTermPrint(&pWC->a[i], i); |
| 128388 | + } |
| 127615 | 128389 | } |
| 127616 | 128390 | #endif |
| 127617 | 128391 | |
| 127618 | 128392 | #ifdef WHERETRACE_ENABLED |
| 127619 | 128393 | /* |
| | @@ -128599,11 +129373,11 @@ |
| 128599 | 129373 | rLogSize = estLog(rSize); |
| 128600 | 129374 | |
| 128601 | 129375 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 128602 | 129376 | /* Automatic indexes */ |
| 128603 | 129377 | if( !pBuilder->pOrSet /* Not part of an OR optimization */ |
| 128604 | | - && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0 |
| 129378 | + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 128605 | 129379 | && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 |
| 128606 | 129380 | && pSrc->pIBIndex==0 /* Has no INDEXED BY clause */ |
| 128607 | 129381 | && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */ |
| 128608 | 129382 | && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */ |
| 128609 | 129383 | && !pSrc->fg.isCorrelated /* Not a correlated subquery */ |
| | @@ -128631,10 +129405,11 @@ |
| 128631 | 129405 | pNew->rSetup = rLogSize + rSize + 4; |
| 128632 | 129406 | if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){ |
| 128633 | 129407 | pNew->rSetup += 24; |
| 128634 | 129408 | } |
| 128635 | 129409 | ApplyCostMultiplier(pNew->rSetup, pTab->costMult); |
| 129410 | + if( pNew->rSetup<0 ) pNew->rSetup = 0; |
| 128636 | 129411 | /* TUNING: Each index lookup yields 20 rows in the table. This |
| 128637 | 129412 | ** is more than the usual guess of 10 rows, since we have no way |
| 128638 | 129413 | ** of knowing how selective the index will ultimately be. It would |
| 128639 | 129414 | ** not be unreasonable to make this value much larger. */ |
| 128640 | 129415 | pNew->nOut = 43; assert( 43==sqlite3LogEst(20) ); |
| | @@ -128691,10 +129466,11 @@ |
| 128691 | 129466 | } |
| 128692 | 129467 | |
| 128693 | 129468 | /* Full scan via index */ |
| 128694 | 129469 | if( b |
| 128695 | 129470 | || !HasRowid(pTab) |
| 129471 | + || pProbe->pPartIdxWhere!=0 |
| 128696 | 129472 | || ( m==0 |
| 128697 | 129473 | && pProbe->bUnordered==0 |
| 128698 | 129474 | && (pProbe->szIdxRow<pTab->szTabRow) |
| 128699 | 129475 | && (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 |
| 128700 | 129476 | && sqlite3GlobalConfig.bUseCis |
| | @@ -128703,15 +129479,38 @@ |
| 128703 | 129479 | ){ |
| 128704 | 129480 | pNew->iSortIdx = b ? iSortIdx : 0; |
| 128705 | 129481 | |
| 128706 | 129482 | /* The cost of visiting the index rows is N*K, where K is |
| 128707 | 129483 | ** between 1.1 and 3.0, depending on the relative sizes of the |
| 128708 | | - ** index and table rows. If this is a non-covering index scan, |
| 128709 | | - ** also add the cost of visiting table rows (N*3.0). */ |
| 129484 | + ** index and table rows. */ |
| 128710 | 129485 | pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow; |
| 128711 | 129486 | if( m!=0 ){ |
| 128712 | | - pNew->rRun = sqlite3LogEstAdd(pNew->rRun, rSize+16); |
| 129487 | + /* If this is a non-covering index scan, add in the cost of |
| 129488 | + ** doing table lookups. The cost will be 3x the number of |
| 129489 | + ** lookups. Take into account WHERE clause terms that can be |
| 129490 | + ** satisfied using just the index, and that do not require a |
| 129491 | + ** table lookup. */ |
| 129492 | + LogEst nLookup = rSize + 16; /* Base cost: N*3 */ |
| 129493 | + int ii; |
| 129494 | + int iCur = pSrc->iCursor; |
| 129495 | + WhereClause *pWC2 = &pWInfo->sWC; |
| 129496 | + for(ii=0; ii<pWC2->nTerm; ii++){ |
| 129497 | + WhereTerm *pTerm = &pWC2->a[ii]; |
| 129498 | + if( !sqlite3ExprCoveredByIndex(pTerm->pExpr, iCur, pProbe) ){ |
| 129499 | + break; |
| 129500 | + } |
| 129501 | + /* pTerm can be evaluated using just the index. So reduce |
| 129502 | + ** the expected number of table lookups accordingly */ |
| 129503 | + if( pTerm->truthProb<=0 ){ |
| 129504 | + nLookup += pTerm->truthProb; |
| 129505 | + }else{ |
| 129506 | + nLookup--; |
| 129507 | + if( pTerm->eOperator & (WO_EQ|WO_IS) ) nLookup -= 19; |
| 129508 | + } |
| 129509 | + } |
| 129510 | + |
| 129511 | + pNew->rRun = sqlite3LogEstAdd(pNew->rRun, nLookup); |
| 128713 | 129512 | } |
| 128714 | 129513 | ApplyCostMultiplier(pNew->rRun, pTab->costMult); |
| 128715 | 129514 | whereLoopOutputAdjust(pWC, pNew, rSize); |
| 128716 | 129515 | rc = whereLoopInsert(pBuilder, pNew); |
| 128717 | 129516 | pNew->nOut = rSize; |
| | @@ -129076,13 +129875,11 @@ |
| 129076 | 129875 | sCur.n = 0; |
| 129077 | 129876 | #ifdef WHERETRACE_ENABLED |
| 129078 | 129877 | WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n", |
| 129079 | 129878 | (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm)); |
| 129080 | 129879 | if( sqlite3WhereTrace & 0x400 ){ |
| 129081 | | - for(i=0; i<sSubBuild.pWC->nTerm; i++){ |
| 129082 | | - whereTermPrint(&sSubBuild.pWC->a[i], i); |
| 129083 | | - } |
| 129880 | + sqlite3WhereClausePrint(sSubBuild.pWC); |
| 129084 | 129881 | } |
| 129085 | 129882 | #endif |
| 129086 | 129883 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 129087 | 129884 | if( IsVirtual(pItem->pTab) ){ |
| 129088 | 129885 | rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable); |
| | @@ -129171,19 +129968,22 @@ |
| 129171 | 129968 | /* This condition is true when pItem is the FROM clause term on the |
| 129172 | 129969 | ** right-hand-side of a LEFT or CROSS JOIN. */ |
| 129173 | 129970 | mPrereq = mPrior; |
| 129174 | 129971 | } |
| 129175 | 129972 | priorJointype = pItem->fg.jointype; |
| 129973 | +#ifndef SQLITE_OMIT_VIRTUALTABLE |
| 129176 | 129974 | if( IsVirtual(pItem->pTab) ){ |
| 129177 | 129975 | struct SrcList_item *p; |
| 129178 | 129976 | for(p=&pItem[1]; p<pEnd; p++){ |
| 129179 | 129977 | if( mUnusable || (p->fg.jointype & (JT_LEFT|JT_CROSS)) ){ |
| 129180 | 129978 | mUnusable |= sqlite3WhereGetMask(&pWInfo->sMaskSet, p->iCursor); |
| 129181 | 129979 | } |
| 129182 | 129980 | } |
| 129183 | 129981 | rc = whereLoopAddVirtual(pBuilder, mPrereq, mUnusable); |
| 129184 | | - }else{ |
| 129982 | + }else |
| 129983 | +#endif /* SQLITE_OMIT_VIRTUALTABLE */ |
| 129984 | + { |
| 129185 | 129985 | rc = whereLoopAddBtree(pBuilder, mPrereq); |
| 129186 | 129986 | } |
| 129187 | 129987 | if( rc==SQLITE_OK ){ |
| 129188 | 129988 | rc = whereLoopAddOr(pBuilder, mPrereq, mUnusable); |
| 129189 | 129989 | } |
| | @@ -129214,11 +130014,11 @@ |
| 129214 | 130014 | */ |
| 129215 | 130015 | static i8 wherePathSatisfiesOrderBy( |
| 129216 | 130016 | WhereInfo *pWInfo, /* The WHERE clause */ |
| 129217 | 130017 | ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */ |
| 129218 | 130018 | WherePath *pPath, /* The WherePath to check */ |
| 129219 | | - u16 wctrlFlags, /* Might contain WHERE_GROUPBY or WHERE_DISTINCTBY */ |
| 130019 | + u16 wctrlFlags, /* WHERE_GROUPBY or _DISTINCTBY or _ORDERBY_LIMIT */ |
| 129220 | 130020 | u16 nLoop, /* Number of entries in pPath->aLoop[] */ |
| 129221 | 130021 | WhereLoop *pLast, /* Add this WhereLoop to the end of pPath->aLoop[] */ |
| 129222 | 130022 | Bitmask *pRevMask /* OUT: Mask of WhereLoops to run in reverse order */ |
| 129223 | 130023 | ){ |
| 129224 | 130024 | u8 revSet; /* True if rev is known */ |
| | @@ -129225,10 +130025,11 @@ |
| 129225 | 130025 | u8 rev; /* Composite sort order */ |
| 129226 | 130026 | u8 revIdx; /* Index sort order */ |
| 129227 | 130027 | u8 isOrderDistinct; /* All prior WhereLoops are order-distinct */ |
| 129228 | 130028 | u8 distinctColumns; /* True if the loop has UNIQUE NOT NULL columns */ |
| 129229 | 130029 | u8 isMatch; /* iColumn matches a term of the ORDER BY clause */ |
| 130030 | + u16 eqOpMask; /* Allowed equality operators */ |
| 129230 | 130031 | u16 nKeyCol; /* Number of key columns in pIndex */ |
| 129231 | 130032 | u16 nColumn; /* Total number of ordered columns in the index */ |
| 129232 | 130033 | u16 nOrderBy; /* Number terms in the ORDER BY clause */ |
| 129233 | 130034 | int iLoop; /* Index of WhereLoop in pPath being processed */ |
| 129234 | 130035 | int i, j; /* Loop counters */ |
| | @@ -129275,13 +130076,20 @@ |
| 129275 | 130076 | if( nOrderBy>BMS-1 ) return 0; /* Cannot optimize overly large ORDER BYs */ |
| 129276 | 130077 | isOrderDistinct = 1; |
| 129277 | 130078 | obDone = MASKBIT(nOrderBy)-1; |
| 129278 | 130079 | orderDistinctMask = 0; |
| 129279 | 130080 | ready = 0; |
| 130081 | + eqOpMask = WO_EQ | WO_IS | WO_ISNULL; |
| 130082 | + if( wctrlFlags & WHERE_ORDERBY_LIMIT ) eqOpMask |= WO_IN; |
| 129280 | 130083 | for(iLoop=0; isOrderDistinct && obSat<obDone && iLoop<=nLoop; iLoop++){ |
| 129281 | 130084 | if( iLoop>0 ) ready |= pLoop->maskSelf; |
| 129282 | | - pLoop = iLoop<nLoop ? pPath->aLoop[iLoop] : pLast; |
| 130085 | + if( iLoop<nLoop ){ |
| 130086 | + pLoop = pPath->aLoop[iLoop]; |
| 130087 | + if( wctrlFlags & WHERE_ORDERBY_LIMIT ) continue; |
| 130088 | + }else{ |
| 130089 | + pLoop = pLast; |
| 130090 | + } |
| 129283 | 130091 | if( pLoop->wsFlags & WHERE_VIRTUALTABLE ){ |
| 129284 | 130092 | if( pLoop->u.vtab.isOrdered ) obSat = obDone; |
| 129285 | 130093 | break; |
| 129286 | 130094 | } |
| 129287 | 130095 | iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor; |
| | @@ -129295,11 +130103,11 @@ |
| 129295 | 130103 | if( MASKBIT(i) & obSat ) continue; |
| 129296 | 130104 | pOBExpr = sqlite3ExprSkipCollate(pOrderBy->a[i].pExpr); |
| 129297 | 130105 | if( pOBExpr->op!=TK_COLUMN ) continue; |
| 129298 | 130106 | if( pOBExpr->iTable!=iCur ) continue; |
| 129299 | 130107 | pTerm = sqlite3WhereFindTerm(&pWInfo->sWC, iCur, pOBExpr->iColumn, |
| 129300 | | - ~ready, WO_EQ|WO_ISNULL|WO_IS, 0); |
| 130108 | + ~ready, eqOpMask, 0); |
| 129301 | 130109 | if( pTerm==0 ) continue; |
| 129302 | 130110 | if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0 && pOBExpr->iColumn>=0 ){ |
| 129303 | 130111 | const char *z1, *z2; |
| 129304 | 130112 | pColl = sqlite3ExprCollSeq(pWInfo->pParse, pOrderBy->a[i].pExpr); |
| 129305 | 130113 | if( !pColl ) pColl = db->pDfltColl; |
| | @@ -129335,14 +130143,16 @@ |
| 129335 | 130143 | rev = revSet = 0; |
| 129336 | 130144 | distinctColumns = 0; |
| 129337 | 130145 | for(j=0; j<nColumn; j++){ |
| 129338 | 130146 | u8 bOnce; /* True to run the ORDER BY search loop */ |
| 129339 | 130147 | |
| 129340 | | - /* Skip over == and IS NULL terms */ |
| 130148 | + /* Skip over == and IS and ISNULL terms. |
| 130149 | + ** (Also skip IN terms when doing WHERE_ORDERBY_LIMIT processing) |
| 130150 | + */ |
| 129341 | 130151 | if( j<pLoop->u.btree.nEq |
| 129342 | 130152 | && pLoop->nSkip==0 |
| 129343 | | - && ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL|WO_IS))!=0 |
| 130153 | + && ((i = pLoop->aLTerm[j]->eOperator) & eqOpMask)!=0 |
| 129344 | 130154 | ){ |
| 129345 | 130155 | if( i & WO_ISNULL ){ |
| 129346 | 130156 | testcase( isOrderDistinct ); |
| 129347 | 130157 | isOrderDistinct = 0; |
| 129348 | 130158 | } |
| | @@ -129862,12 +130672,23 @@ |
| 129862 | 130672 | if( pFrom->isOrdered==pWInfo->pOrderBy->nExpr ){ |
| 129863 | 130673 | pWInfo->eDistinct = WHERE_DISTINCT_ORDERED; |
| 129864 | 130674 | } |
| 129865 | 130675 | }else{ |
| 129866 | 130676 | pWInfo->nOBSat = pFrom->isOrdered; |
| 129867 | | - if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0; |
| 129868 | 130677 | pWInfo->revMask = pFrom->revLoop; |
| 130678 | + if( pWInfo->nOBSat<=0 ){ |
| 130679 | + pWInfo->nOBSat = 0; |
| 130680 | + if( nLoop>0 && (pFrom->aLoop[nLoop-1]->wsFlags & WHERE_ONEROW)==0 ){ |
| 130681 | + Bitmask m = 0; |
| 130682 | + int rc = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy, pFrom, |
| 130683 | + WHERE_ORDERBY_LIMIT, nLoop-1, pFrom->aLoop[nLoop-1], &m); |
| 130684 | + if( rc==pWInfo->pOrderBy->nExpr ){ |
| 130685 | + pWInfo->bOrderedInnerLoop = 1; |
| 130686 | + pWInfo->revMask = m; |
| 130687 | + } |
| 130688 | + } |
| 130689 | + } |
| 129869 | 130690 | } |
| 129870 | 130691 | if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP) |
| 129871 | 130692 | && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0 |
| 129872 | 130693 | ){ |
| 129873 | 130694 | Bitmask revMask = 0; |
| | @@ -129911,11 +130732,11 @@ |
| 129911 | 130732 | int j; |
| 129912 | 130733 | Table *pTab; |
| 129913 | 130734 | Index *pIdx; |
| 129914 | 130735 | |
| 129915 | 130736 | pWInfo = pBuilder->pWInfo; |
| 129916 | | - if( pWInfo->wctrlFlags & WHERE_FORCE_TABLE ) return 0; |
| 130737 | + if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0; |
| 129917 | 130738 | assert( pWInfo->pTabList->nSrc>=1 ); |
| 129918 | 130739 | pItem = pWInfo->pTabList->a; |
| 129919 | 130740 | pTab = pItem->pTab; |
| 129920 | 130741 | if( IsVirtual(pTab) ) return 0; |
| 129921 | 130742 | if( pItem->fg.isIndexedBy ) return 0; |
| | @@ -130058,11 +130879,11 @@ |
| 130058 | 130879 | ** if the WHERE_GROUPBY flag is set in wctrlFlags) of a SELECT statement |
| 130059 | 130880 | ** if there is one. If there is no ORDER BY clause or if this routine |
| 130060 | 130881 | ** is called from an UPDATE or DELETE statement, then pOrderBy is NULL. |
| 130061 | 130882 | ** |
| 130062 | 130883 | ** The iIdxCur parameter is the cursor number of an index. If |
| 130063 | | -** WHERE_ONETABLE_ONLY is set, iIdxCur is the cursor number of an index |
| 130884 | +** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index |
| 130064 | 130885 | ** to use for OR clause processing. The WHERE clause should use this |
| 130065 | 130886 | ** specific cursor. If WHERE_ONEPASS_DESIRED is set, then iIdxCur is |
| 130066 | 130887 | ** the first cursor in an array of cursors for all indices. iIdxCur should |
| 130067 | 130888 | ** be used to compute the appropriate cursor depending on which index is |
| 130068 | 130889 | ** used. |
| | @@ -130072,11 +130893,11 @@ |
| 130072 | 130893 | SrcList *pTabList, /* FROM clause: A list of all tables to be scanned */ |
| 130073 | 130894 | Expr *pWhere, /* The WHERE clause */ |
| 130074 | 130895 | ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */ |
| 130075 | 130896 | ExprList *pDistinctSet, /* Try not to output two rows that duplicate these */ |
| 130076 | 130897 | u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */ |
| 130077 | | - int iAuxArg /* If WHERE_ONETABLE_ONLY is set, index cursor number |
| 130898 | + int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number |
| 130078 | 130899 | ** If WHERE_USE_LIMIT, then the limit amount */ |
| 130079 | 130900 | ){ |
| 130080 | 130901 | int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ |
| 130081 | 130902 | int nTabList; /* Number of elements in pTabList */ |
| 130082 | 130903 | WhereInfo *pWInfo; /* Will become the return value of this function */ |
| | @@ -130091,15 +130912,15 @@ |
| 130091 | 130912 | int rc; /* Return code */ |
| 130092 | 130913 | u8 bFordelete = 0; /* OPFLAG_FORDELETE or zero, as appropriate */ |
| 130093 | 130914 | |
| 130094 | 130915 | assert( (wctrlFlags & WHERE_ONEPASS_MULTIROW)==0 || ( |
| 130095 | 130916 | (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 |
| 130096 | | - && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 |
| 130917 | + && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 130097 | 130918 | )); |
| 130098 | 130919 | |
| 130099 | | - /* Only one of WHERE_ONETABLE_ONLY or WHERE_USE_LIMIT */ |
| 130100 | | - assert( (wctrlFlags & WHERE_ONETABLE_ONLY)==0 |
| 130920 | + /* Only one of WHERE_OR_SUBCLAUSE or WHERE_USE_LIMIT */ |
| 130921 | + assert( (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 130101 | 130922 | || (wctrlFlags & WHERE_USE_LIMIT)==0 ); |
| 130102 | 130923 | |
| 130103 | 130924 | /* Variable initialization */ |
| 130104 | 130925 | db = pParse->db; |
| 130105 | 130926 | memset(&sWLB, 0, sizeof(sWLB)); |
| | @@ -130123,15 +130944,15 @@ |
| 130123 | 130944 | sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS); |
| 130124 | 130945 | return 0; |
| 130125 | 130946 | } |
| 130126 | 130947 | |
| 130127 | 130948 | /* This function normally generates a nested loop for all tables in |
| 130128 | | - ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should |
| 130949 | + ** pTabList. But if the WHERE_OR_SUBCLAUSE flag is set, then we should |
| 130129 | 130950 | ** only generate code for the first table in pTabList and assume that |
| 130130 | 130951 | ** any cursors associated with subsequent tables are uninitialized. |
| 130131 | 130952 | */ |
| 130132 | | - nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc; |
| 130953 | + nTabList = (wctrlFlags & WHERE_OR_SUBCLAUSE) ? 1 : pTabList->nSrc; |
| 130133 | 130954 | |
| 130134 | 130955 | /* Allocate and initialize the WhereInfo structure that will become the |
| 130135 | 130956 | ** return value. A single allocation is used to store the WhereInfo |
| 130136 | 130957 | ** struct, the contents of WhereInfo.a[], the WhereClause structure |
| 130137 | 130958 | ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte |
| | @@ -130203,11 +131024,11 @@ |
| 130203 | 131024 | ** important. Ticket #3015. |
| 130204 | 131025 | ** |
| 130205 | 131026 | ** Note that bitmasks are created for all pTabList->nSrc tables in |
| 130206 | 131027 | ** pTabList, not just the first nTabList tables. nTabList is normally |
| 130207 | 131028 | ** equal to pTabList->nSrc but might be shortened to 1 if the |
| 130208 | | - ** WHERE_ONETABLE_ONLY flag is set. |
| 131029 | + ** WHERE_OR_SUBCLAUSE flag is set. |
| 130209 | 131030 | */ |
| 130210 | 131031 | for(ii=0; ii<pTabList->nSrc; ii++){ |
| 130211 | 131032 | createMask(pMaskSet, pTabList->a[ii].iCursor); |
| 130212 | 131033 | sqlite3WhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC); |
| 130213 | 131034 | } |
| | @@ -130241,14 +131062,11 @@ |
| 130241 | 131062 | sqlite3DebugPrintf(", limit: %d", iAuxArg); |
| 130242 | 131063 | } |
| 130243 | 131064 | sqlite3DebugPrintf(")\n"); |
| 130244 | 131065 | } |
| 130245 | 131066 | if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */ |
| 130246 | | - int i; |
| 130247 | | - for(i=0; i<sWLB.pWC->nTerm; i++){ |
| 130248 | | - whereTermPrint(&sWLB.pWC->a[i], i); |
| 130249 | | - } |
| 131067 | + sqlite3WhereClausePrint(sWLB.pWC); |
| 130250 | 131068 | } |
| 130251 | 131069 | #endif |
| 130252 | 131070 | |
| 130253 | 131071 | if( nTabList!=1 || whereShortCut(&sWLB)==0 ){ |
| 130254 | 131072 | rc = whereLoopAddAll(&sWLB); |
| | @@ -130386,11 +131204,11 @@ |
| 130386 | 131204 | }else if( IsVirtual(pTab) ){ |
| 130387 | 131205 | /* noop */ |
| 130388 | 131206 | }else |
| 130389 | 131207 | #endif |
| 130390 | 131208 | if( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 |
| 130391 | | - && (wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 ){ |
| 131209 | + && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ |
| 130392 | 131210 | int op = OP_OpenRead; |
| 130393 | 131211 | if( pWInfo->eOnePass!=ONEPASS_OFF ){ |
| 130394 | 131212 | op = OP_OpenWrite; |
| 130395 | 131213 | pWInfo->aiCurOnePass[0] = pTabItem->iCursor; |
| 130396 | 131214 | }; |
| | @@ -130425,11 +131243,11 @@ |
| 130425 | 131243 | int iIndexCur; |
| 130426 | 131244 | int op = OP_OpenRead; |
| 130427 | 131245 | /* iAuxArg is always set if to a positive value if ONEPASS is possible */ |
| 130428 | 131246 | assert( iAuxArg!=0 || (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 ); |
| 130429 | 131247 | if( !HasRowid(pTab) && IsPrimaryKeyIndex(pIx) |
| 130430 | | - && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 |
| 131248 | + && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 |
| 130431 | 131249 | ){ |
| 130432 | 131250 | /* This is one term of an OR-optimization using the PRIMARY KEY of a |
| 130433 | 131251 | ** WITHOUT ROWID table. No need for a separate index */ |
| 130434 | 131252 | iIndexCur = pLevel->iTabCur; |
| 130435 | 131253 | op = 0; |
| | @@ -130441,13 +131259,13 @@ |
| 130441 | 131259 | iIndexCur++; |
| 130442 | 131260 | pJ = pJ->pNext; |
| 130443 | 131261 | } |
| 130444 | 131262 | op = OP_OpenWrite; |
| 130445 | 131263 | pWInfo->aiCurOnePass[1] = iIndexCur; |
| 130446 | | - }else if( iAuxArg && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){ |
| 131264 | + }else if( iAuxArg && (wctrlFlags & WHERE_OR_SUBCLAUSE)!=0 ){ |
| 130447 | 131265 | iIndexCur = iAuxArg; |
| 130448 | | - if( wctrlFlags & WHERE_REOPEN_IDX ) op = OP_ReopenIdx; |
| 131266 | + op = OP_ReopenIdx; |
| 130449 | 131267 | }else{ |
| 130450 | 131268 | iIndexCur = pParse->nTab++; |
| 130451 | 131269 | } |
| 130452 | 131270 | pLevel->iIdxCur = iIndexCur; |
| 130453 | 131271 | assert( pIx->pSchema==pTab->pSchema ); |
| | @@ -130505,11 +131323,11 @@ |
| 130505 | 131323 | pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags |
| 130506 | 131324 | ); |
| 130507 | 131325 | pLevel->addrBody = sqlite3VdbeCurrentAddr(v); |
| 130508 | 131326 | notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady); |
| 130509 | 131327 | pWInfo->iContinue = pLevel->addrCont; |
| 130510 | | - if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_ONETABLE_ONLY)==0 ){ |
| 131328 | + if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){ |
| 130511 | 131329 | sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain); |
| 130512 | 131330 | } |
| 130513 | 131331 | } |
| 130514 | 131332 | |
| 130515 | 131333 | /* Done. */ |
| | @@ -130628,16 +131446,16 @@ |
| 130628 | 131446 | continue; |
| 130629 | 131447 | } |
| 130630 | 131448 | |
| 130631 | 131449 | /* Close all of the cursors that were opened by sqlite3WhereBegin. |
| 130632 | 131450 | ** Except, do not close cursors that will be reused by the OR optimization |
| 130633 | | - ** (WHERE_OMIT_OPEN_CLOSE). And do not close the OP_OpenWrite cursors |
| 131451 | + ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors |
| 130634 | 131452 | ** created for the ONEPASS optimization. |
| 130635 | 131453 | */ |
| 130636 | 131454 | if( (pTab->tabFlags & TF_Ephemeral)==0 |
| 130637 | 131455 | && pTab->pSelect==0 |
| 130638 | | - && (pWInfo->wctrlFlags & WHERE_OMIT_OPEN_CLOSE)==0 |
| 131456 | + && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 130639 | 131457 | ){ |
| 130640 | 131458 | int ws = pLoop->wsFlags; |
| 130641 | 131459 | if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){ |
| 130642 | 131460 | sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor); |
| 130643 | 131461 | } |
| | @@ -130980,49 +131798,49 @@ |
| 130980 | 131798 | #ifndef INTERFACE |
| 130981 | 131799 | # define INTERFACE 1 |
| 130982 | 131800 | #endif |
| 130983 | 131801 | /************* Begin control #defines *****************************************/ |
| 130984 | 131802 | #define YYCODETYPE unsigned char |
| 130985 | | -#define YYNOCODE 251 |
| 131803 | +#define YYNOCODE 252 |
| 130986 | 131804 | #define YYACTIONTYPE unsigned short int |
| 130987 | 131805 | #define YYWILDCARD 96 |
| 130988 | 131806 | #define sqlite3ParserTOKENTYPE Token |
| 130989 | 131807 | typedef union { |
| 130990 | 131808 | int yyinit; |
| 130991 | 131809 | sqlite3ParserTOKENTYPE yy0; |
| 130992 | | - struct LimitVal yy64; |
| 130993 | | - Expr* yy122; |
| 130994 | | - Select* yy159; |
| 130995 | | - IdList* yy180; |
| 130996 | | - struct {int value; int mask;} yy207; |
| 130997 | | - struct LikeOp yy318; |
| 130998 | | - TriggerStep* yy327; |
| 130999 | | - With* yy331; |
| 131000 | | - ExprSpan yy342; |
| 131001 | | - SrcList* yy347; |
| 131002 | | - int yy392; |
| 131003 | | - struct TrigEvent yy410; |
| 131004 | | - ExprList* yy442; |
| 131810 | + Expr* yy72; |
| 131811 | + TriggerStep* yy145; |
| 131812 | + ExprList* yy148; |
| 131813 | + SrcList* yy185; |
| 131814 | + ExprSpan yy190; |
| 131815 | + int yy194; |
| 131816 | + Select* yy243; |
| 131817 | + IdList* yy254; |
| 131818 | + With* yy285; |
| 131819 | + struct TrigEvent yy332; |
| 131820 | + struct LimitVal yy354; |
| 131821 | + struct LikeOp yy392; |
| 131822 | + struct {int value; int mask;} yy497; |
| 131005 | 131823 | } YYMINORTYPE; |
| 131006 | 131824 | #ifndef YYSTACKDEPTH |
| 131007 | 131825 | #define YYSTACKDEPTH 100 |
| 131008 | 131826 | #endif |
| 131009 | 131827 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 131010 | 131828 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 131011 | 131829 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 131012 | 131830 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 131013 | 131831 | #define YYFALLBACK 1 |
| 131014 | | -#define YYNSTATE 440 |
| 131015 | | -#define YYNRULE 326 |
| 131016 | | -#define YY_MAX_SHIFT 439 |
| 131017 | | -#define YY_MIN_SHIFTREDUCE 649 |
| 131018 | | -#define YY_MAX_SHIFTREDUCE 974 |
| 131019 | | -#define YY_MIN_REDUCE 975 |
| 131020 | | -#define YY_MAX_REDUCE 1300 |
| 131021 | | -#define YY_ERROR_ACTION 1301 |
| 131022 | | -#define YY_ACCEPT_ACTION 1302 |
| 131023 | | -#define YY_NO_ACTION 1303 |
| 131832 | +#define YYNSTATE 443 |
| 131833 | +#define YYNRULE 328 |
| 131834 | +#define YY_MAX_SHIFT 442 |
| 131835 | +#define YY_MIN_SHIFTREDUCE 653 |
| 131836 | +#define YY_MAX_SHIFTREDUCE 980 |
| 131837 | +#define YY_MIN_REDUCE 981 |
| 131838 | +#define YY_MAX_REDUCE 1308 |
| 131839 | +#define YY_ERROR_ACTION 1309 |
| 131840 | +#define YY_ACCEPT_ACTION 1310 |
| 131841 | +#define YY_NO_ACTION 1311 |
| 131024 | 131842 | /************* End control #defines *******************************************/ |
| 131025 | 131843 | |
| 131026 | 131844 | /* Define the yytestcase() macro to be a no-op if is not already defined |
| 131027 | 131845 | ** otherwise. |
| 131028 | 131846 | ** |
| | @@ -131086,450 +131904,452 @@ |
| 131086 | 131904 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 131087 | 131905 | ** shifting non-terminals after a reduce. |
| 131088 | 131906 | ** yy_default[] Default action for each state. |
| 131089 | 131907 | ** |
| 131090 | 131908 | *********** Begin parsing tables **********************************************/ |
| 131091 | | -#define YY_ACTTAB_COUNT (1501) |
| 131909 | +#define YY_ACTTAB_COUNT (1507) |
| 131092 | 131910 | static const YYACTIONTYPE yy_action[] = { |
| 131093 | | - /* 0 */ 315, 810, 339, 804, 5, 194, 194, 798, 92, 93, |
| 131094 | | - /* 10 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91, |
| 131095 | | - /* 20 */ 91, 91, 91, 290, 89, 89, 89, 89, 88, 88, |
| 131096 | | - /* 30 */ 87, 87, 87, 86, 339, 315, 952, 952, 803, 803, |
| 131097 | | - /* 40 */ 803, 922, 342, 92, 93, 83, 819, 819, 831, 834, |
| 131098 | | - /* 50 */ 823, 823, 90, 90, 91, 91, 91, 91, 123, 89, |
| 131099 | | - /* 60 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339, |
| 131100 | | - /* 70 */ 88, 88, 87, 87, 87, 86, 339, 772, 952, 952, |
| 131101 | | - /* 80 */ 315, 87, 87, 87, 86, 339, 773, 68, 92, 93, |
| 131102 | | - /* 90 */ 83, 819, 819, 831, 834, 823, 823, 90, 90, 91, |
| 131103 | | - /* 100 */ 91, 91, 91, 434, 89, 89, 89, 89, 88, 88, |
| 131104 | | - /* 110 */ 87, 87, 87, 86, 339, 1302, 146, 921, 2, 315, |
| 131105 | | - /* 120 */ 427, 24, 679, 953, 48, 86, 339, 92, 93, 83, |
| 131106 | | - /* 130 */ 819, 819, 831, 834, 823, 823, 90, 90, 91, 91, |
| 131107 | | - /* 140 */ 91, 91, 94, 89, 89, 89, 89, 88, 88, 87, |
| 131108 | | - /* 150 */ 87, 87, 86, 339, 933, 933, 315, 259, 412, 398, |
| 131109 | | - /* 160 */ 396, 57, 733, 733, 92, 93, 83, 819, 819, 831, |
| 131110 | | - /* 170 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 56, |
| 131111 | | - /* 180 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86, |
| 131112 | | - /* 190 */ 339, 315, 1245, 922, 342, 268, 934, 935, 241, 92, |
| 131113 | | - /* 200 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90, |
| 131114 | | - /* 210 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88, |
| 131115 | | - /* 220 */ 88, 87, 87, 87, 86, 339, 315, 913, 1295, 682, |
| 131116 | | - /* 230 */ 687, 1295, 233, 397, 92, 93, 83, 819, 819, 831, |
| 131117 | | - /* 240 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 326, |
| 131118 | | - /* 250 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86, |
| 131119 | | - /* 260 */ 339, 315, 85, 82, 168, 680, 431, 938, 939, 92, |
| 131120 | | - /* 270 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90, |
| 131121 | | - /* 280 */ 91, 91, 91, 91, 291, 89, 89, 89, 89, 88, |
| 131122 | | - /* 290 */ 88, 87, 87, 87, 86, 339, 315, 319, 913, 1296, |
| 131123 | | - /* 300 */ 797, 911, 1296, 681, 92, 93, 83, 819, 819, 831, |
| 131124 | | - /* 310 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 335, |
| 131125 | | - /* 320 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86, |
| 131126 | | - /* 330 */ 339, 315, 876, 876, 373, 85, 82, 168, 944, 92, |
| 131127 | | - /* 340 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90, |
| 131128 | | - /* 350 */ 91, 91, 91, 91, 896, 89, 89, 89, 89, 88, |
| 131129 | | - /* 360 */ 88, 87, 87, 87, 86, 339, 315, 370, 307, 973, |
| 131130 | | - /* 370 */ 367, 1, 911, 433, 92, 93, 83, 819, 819, 831, |
| 131131 | | - /* 380 */ 834, 823, 823, 90, 90, 91, 91, 91, 91, 189, |
| 131132 | | - /* 390 */ 89, 89, 89, 89, 88, 88, 87, 87, 87, 86, |
| 131133 | | - /* 400 */ 339, 315, 720, 948, 933, 933, 149, 718, 948, 92, |
| 131134 | | - /* 410 */ 93, 83, 819, 819, 831, 834, 823, 823, 90, 90, |
| 131135 | | - /* 420 */ 91, 91, 91, 91, 434, 89, 89, 89, 89, 88, |
| 131136 | | - /* 430 */ 88, 87, 87, 87, 86, 339, 338, 938, 939, 947, |
| 131137 | | - /* 440 */ 694, 940, 974, 315, 953, 48, 934, 935, 715, 689, |
| 131138 | | - /* 450 */ 71, 92, 93, 83, 819, 819, 831, 834, 823, 823, |
| 131139 | | - /* 460 */ 90, 90, 91, 91, 91, 91, 320, 89, 89, 89, |
| 131140 | | - /* 470 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 412, |
| 131141 | | - /* 480 */ 403, 820, 820, 832, 835, 74, 92, 81, 83, 819, |
| 131142 | | - /* 490 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91, |
| 131143 | | - /* 500 */ 91, 698, 89, 89, 89, 89, 88, 88, 87, 87, |
| 131144 | | - /* 510 */ 87, 86, 339, 315, 259, 654, 655, 656, 393, 111, |
| 131145 | | - /* 520 */ 331, 153, 93, 83, 819, 819, 831, 834, 823, 823, |
| 131146 | | - /* 530 */ 90, 90, 91, 91, 91, 91, 434, 89, 89, 89, |
| 131147 | | - /* 540 */ 89, 88, 88, 87, 87, 87, 86, 339, 315, 188, |
| 131148 | | - /* 550 */ 187, 186, 824, 937, 328, 219, 953, 48, 83, 819, |
| 131149 | | - /* 560 */ 819, 831, 834, 823, 823, 90, 90, 91, 91, 91, |
| 131150 | | - /* 570 */ 91, 956, 89, 89, 89, 89, 88, 88, 87, 87, |
| 131151 | | - /* 580 */ 87, 86, 339, 79, 429, 738, 3, 1174, 955, 348, |
| 131152 | | - /* 590 */ 737, 332, 792, 933, 933, 937, 79, 429, 730, 3, |
| 131153 | | - /* 600 */ 203, 160, 278, 391, 273, 390, 190, 892, 434, 400, |
| 131154 | | - /* 610 */ 741, 76, 77, 271, 287, 253, 353, 242, 78, 340, |
| 131155 | | - /* 620 */ 340, 85, 82, 168, 76, 77, 233, 397, 953, 48, |
| 131156 | | - /* 630 */ 432, 78, 340, 340, 277, 934, 935, 185, 439, 651, |
| 131157 | | - /* 640 */ 388, 385, 384, 432, 234, 276, 107, 418, 349, 337, |
| 131158 | | - /* 650 */ 336, 383, 893, 728, 215, 949, 123, 971, 308, 810, |
| 131159 | | - /* 660 */ 418, 436, 435, 412, 394, 798, 400, 873, 894, 123, |
| 131160 | | - /* 670 */ 721, 872, 810, 889, 436, 435, 215, 949, 798, 351, |
| 131161 | | - /* 680 */ 722, 697, 380, 434, 771, 371, 22, 434, 400, 79, |
| 131162 | | - /* 690 */ 429, 232, 3, 189, 413, 870, 803, 803, 803, 805, |
| 131163 | | - /* 700 */ 18, 54, 148, 953, 48, 956, 113, 953, 9, 803, |
| 131164 | | - /* 710 */ 803, 803, 805, 18, 310, 123, 748, 76, 77, 742, |
| 131165 | | - /* 720 */ 123, 325, 955, 866, 78, 340, 340, 113, 350, 359, |
| 131166 | | - /* 730 */ 85, 82, 168, 343, 960, 960, 432, 770, 412, 414, |
| 131167 | | - /* 740 */ 407, 23, 1240, 1240, 79, 429, 357, 3, 166, 91, |
| 131168 | | - /* 750 */ 91, 91, 91, 418, 89, 89, 89, 89, 88, 88, |
| 131169 | | - /* 760 */ 87, 87, 87, 86, 339, 810, 434, 436, 435, 792, |
| 131170 | | - /* 770 */ 320, 798, 76, 77, 789, 271, 123, 434, 360, 78, |
| 131171 | | - /* 780 */ 340, 340, 864, 85, 82, 168, 953, 9, 395, 743, |
| 131172 | | - /* 790 */ 360, 432, 253, 358, 252, 933, 933, 953, 30, 889, |
| 131173 | | - /* 800 */ 327, 216, 803, 803, 803, 805, 18, 113, 418, 89, |
| 131174 | | - /* 810 */ 89, 89, 89, 88, 88, 87, 87, 87, 86, 339, |
| 131175 | | - /* 820 */ 810, 113, 436, 435, 792, 185, 798, 288, 388, 385, |
| 131176 | | - /* 830 */ 384, 123, 113, 920, 2, 796, 696, 934, 935, 383, |
| 131177 | | - /* 840 */ 69, 429, 434, 3, 218, 110, 738, 253, 358, 252, |
| 131178 | | - /* 850 */ 434, 737, 933, 933, 892, 359, 222, 803, 803, 803, |
| 131179 | | - /* 860 */ 805, 18, 953, 47, 933, 933, 933, 933, 76, 77, |
| 131180 | | - /* 870 */ 953, 9, 366, 904, 217, 78, 340, 340, 677, 305, |
| 131181 | | - /* 880 */ 304, 303, 206, 301, 224, 259, 664, 432, 337, 336, |
| 131182 | | - /* 890 */ 434, 228, 247, 144, 934, 935, 933, 933, 667, 893, |
| 131183 | | - /* 900 */ 324, 1259, 96, 434, 418, 796, 934, 935, 934, 935, |
| 131184 | | - /* 910 */ 953, 48, 401, 148, 289, 894, 810, 417, 436, 435, |
| 131185 | | - /* 920 */ 677, 759, 798, 953, 9, 314, 220, 162, 161, 170, |
| 131186 | | - /* 930 */ 402, 239, 953, 8, 194, 683, 683, 410, 934, 935, |
| 131187 | | - /* 940 */ 238, 959, 933, 933, 225, 408, 945, 365, 957, 212, |
| 131188 | | - /* 950 */ 958, 172, 757, 803, 803, 803, 805, 18, 173, 365, |
| 131189 | | - /* 960 */ 176, 123, 171, 113, 244, 952, 246, 434, 356, 796, |
| 131190 | | - /* 970 */ 372, 365, 236, 960, 960, 810, 290, 804, 191, 165, |
| 131191 | | - /* 980 */ 852, 798, 259, 316, 934, 935, 237, 953, 34, 404, |
| 131192 | | - /* 990 */ 91, 91, 91, 91, 84, 89, 89, 89, 89, 88, |
| 131193 | | - /* 1000 */ 88, 87, 87, 87, 86, 339, 701, 952, 434, 240, |
| 131194 | | - /* 1010 */ 347, 758, 803, 803, 803, 434, 245, 1179, 434, 389, |
| 131195 | | - /* 1020 */ 434, 376, 434, 895, 167, 434, 405, 702, 953, 35, |
| 131196 | | - /* 1030 */ 673, 321, 221, 434, 333, 953, 11, 434, 953, 26, |
| 131197 | | - /* 1040 */ 953, 36, 953, 37, 251, 953, 38, 434, 259, 434, |
| 131198 | | - /* 1050 */ 757, 434, 329, 953, 27, 434, 223, 953, 28, 434, |
| 131199 | | - /* 1060 */ 690, 434, 67, 434, 65, 434, 862, 953, 39, 953, |
| 131200 | | - /* 1070 */ 40, 953, 41, 423, 434, 953, 10, 434, 772, 953, |
| 131201 | | - /* 1080 */ 42, 953, 98, 953, 43, 953, 44, 773, 434, 346, |
| 131202 | | - /* 1090 */ 434, 75, 434, 73, 953, 31, 434, 953, 45, 434, |
| 131203 | | - /* 1100 */ 259, 434, 690, 434, 757, 434, 887, 434, 953, 46, |
| 131204 | | - /* 1110 */ 953, 32, 953, 115, 434, 266, 953, 116, 951, 953, |
| 131205 | | - /* 1120 */ 117, 953, 52, 953, 33, 953, 99, 953, 49, 726, |
| 131206 | | - /* 1130 */ 434, 909, 434, 19, 953, 100, 434, 344, 434, 113, |
| 131207 | | - /* 1140 */ 434, 258, 692, 434, 259, 434, 670, 434, 20, 434, |
| 131208 | | - /* 1150 */ 953, 101, 953, 97, 434, 259, 953, 114, 953, 112, |
| 131209 | | - /* 1160 */ 953, 105, 113, 953, 104, 953, 102, 953, 103, 953, |
| 131210 | | - /* 1170 */ 51, 434, 148, 434, 953, 53, 167, 434, 259, 113, |
| 131211 | | - /* 1180 */ 300, 307, 912, 363, 311, 860, 248, 261, 209, 264, |
| 131212 | | - /* 1190 */ 416, 953, 50, 953, 25, 420, 727, 953, 29, 430, |
| 131213 | | - /* 1200 */ 321, 424, 757, 428, 322, 124, 1269, 214, 165, 710, |
| 131214 | | - /* 1210 */ 859, 908, 806, 794, 309, 158, 193, 361, 254, 723, |
| 131215 | | - /* 1220 */ 364, 67, 381, 269, 735, 199, 67, 70, 113, 700, |
| 131216 | | - /* 1230 */ 699, 707, 708, 884, 113, 766, 113, 855, 193, 883, |
| 131217 | | - /* 1240 */ 199, 869, 869, 675, 868, 868, 109, 368, 255, 260, |
| 131218 | | - /* 1250 */ 263, 280, 859, 265, 806, 974, 267, 711, 695, 272, |
| 131219 | | - /* 1260 */ 764, 282, 795, 284, 150, 744, 755, 415, 292, 293, |
| 131220 | | - /* 1270 */ 802, 678, 672, 661, 660, 662, 927, 6, 306, 386, |
| 131221 | | - /* 1280 */ 352, 786, 243, 250, 886, 362, 163, 286, 419, 298, |
| 131222 | | - /* 1290 */ 930, 159, 968, 196, 126, 903, 901, 965, 55, 58, |
| 131223 | | - /* 1300 */ 323, 275, 857, 136, 147, 694, 856, 121, 65, 354, |
| 131224 | | - /* 1310 */ 355, 379, 175, 61, 151, 369, 180, 871, 375, 129, |
| 131225 | | - /* 1320 */ 257, 756, 210, 181, 145, 131, 132, 377, 262, 663, |
| 131226 | | - /* 1330 */ 133, 134, 139, 783, 791, 182, 392, 183, 312, 330, |
| 131227 | | - /* 1340 */ 714, 888, 713, 851, 692, 195, 712, 406, 686, 705, |
| 131228 | | - /* 1350 */ 313, 685, 64, 839, 274, 72, 684, 334, 942, 95, |
| 131229 | | - /* 1360 */ 752, 279, 281, 704, 753, 751, 422, 283, 411, 750, |
| 131230 | | - /* 1370 */ 426, 66, 204, 409, 21, 285, 928, 669, 437, 205, |
| 131231 | | - /* 1380 */ 207, 208, 438, 658, 657, 652, 118, 108, 119, 226, |
| 131232 | | - /* 1390 */ 650, 341, 157, 235, 169, 345, 106, 734, 790, 296, |
| 131233 | | - /* 1400 */ 294, 295, 120, 297, 867, 865, 127, 128, 130, 724, |
| 131234 | | - /* 1410 */ 229, 174, 249, 882, 137, 230, 138, 135, 885, 231, |
| 131235 | | - /* 1420 */ 59, 60, 177, 881, 7, 178, 12, 179, 256, 874, |
| 131236 | | - /* 1430 */ 140, 193, 962, 374, 141, 152, 666, 378, 276, 184, |
| 131237 | | - /* 1440 */ 270, 122, 142, 382, 387, 62, 13, 14, 703, 63, |
| 131238 | | - /* 1450 */ 125, 317, 318, 227, 809, 808, 837, 732, 15, 164, |
| 131239 | | - /* 1460 */ 736, 4, 765, 211, 399, 213, 192, 143, 760, 70, |
| 131240 | | - /* 1470 */ 67, 16, 17, 838, 836, 891, 841, 890, 198, 197, |
| 131241 | | - /* 1480 */ 917, 154, 421, 923, 918, 155, 200, 977, 425, 840, |
| 131242 | | - /* 1490 */ 156, 201, 807, 676, 80, 302, 299, 977, 202, 1261, |
| 131243 | | - /* 1500 */ 1260, |
| 131911 | + /* 0 */ 317, 814, 341, 808, 5, 195, 195, 802, 93, 94, |
| 131912 | + /* 10 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92, |
| 131913 | + /* 20 */ 92, 92, 92, 293, 90, 90, 90, 90, 89, 89, |
| 131914 | + /* 30 */ 88, 88, 88, 87, 341, 317, 958, 958, 807, 807, |
| 131915 | + /* 40 */ 807, 928, 344, 93, 94, 84, 823, 823, 835, 838, |
| 131916 | + /* 50 */ 827, 827, 91, 91, 92, 92, 92, 92, 328, 90, |
| 131917 | + /* 60 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341, |
| 131918 | + /* 70 */ 89, 89, 88, 88, 88, 87, 341, 776, 958, 958, |
| 131919 | + /* 80 */ 317, 88, 88, 88, 87, 341, 777, 69, 93, 94, |
| 131920 | + /* 90 */ 84, 823, 823, 835, 838, 827, 827, 91, 91, 92, |
| 131921 | + /* 100 */ 92, 92, 92, 437, 90, 90, 90, 90, 89, 89, |
| 131922 | + /* 110 */ 88, 88, 88, 87, 341, 1310, 147, 147, 2, 317, |
| 131923 | + /* 120 */ 76, 25, 74, 49, 49, 87, 341, 93, 94, 84, |
| 131924 | + /* 130 */ 823, 823, 835, 838, 827, 827, 91, 91, 92, 92, |
| 131925 | + /* 140 */ 92, 92, 95, 90, 90, 90, 90, 89, 89, 88, |
| 131926 | + /* 150 */ 88, 88, 87, 341, 939, 939, 317, 260, 415, 400, |
| 131927 | + /* 160 */ 398, 58, 737, 737, 93, 94, 84, 823, 823, 835, |
| 131928 | + /* 170 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 57, |
| 131929 | + /* 180 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87, |
| 131930 | + /* 190 */ 341, 317, 1253, 928, 344, 269, 940, 941, 242, 93, |
| 131931 | + /* 200 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91, |
| 131932 | + /* 210 */ 92, 92, 92, 92, 293, 90, 90, 90, 90, 89, |
| 131933 | + /* 220 */ 89, 88, 88, 88, 87, 341, 317, 919, 1303, 793, |
| 131934 | + /* 230 */ 691, 1303, 724, 724, 93, 94, 84, 823, 823, 835, |
| 131935 | + /* 240 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 337, |
| 131936 | + /* 250 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87, |
| 131937 | + /* 260 */ 341, 317, 114, 919, 1304, 684, 395, 1304, 124, 93, |
| 131938 | + /* 270 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91, |
| 131939 | + /* 280 */ 92, 92, 92, 92, 683, 90, 90, 90, 90, 89, |
| 131940 | + /* 290 */ 89, 88, 88, 88, 87, 341, 317, 86, 83, 169, |
| 131941 | + /* 300 */ 801, 917, 234, 399, 93, 94, 84, 823, 823, 835, |
| 131942 | + /* 310 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 686, |
| 131943 | + /* 320 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87, |
| 131944 | + /* 330 */ 341, 317, 436, 742, 86, 83, 169, 917, 741, 93, |
| 131945 | + /* 340 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91, |
| 131946 | + /* 350 */ 92, 92, 92, 92, 902, 90, 90, 90, 90, 89, |
| 131947 | + /* 360 */ 89, 88, 88, 88, 87, 341, 317, 321, 434, 434, |
| 131948 | + /* 370 */ 434, 1, 722, 722, 93, 94, 84, 823, 823, 835, |
| 131949 | + /* 380 */ 838, 827, 827, 91, 91, 92, 92, 92, 92, 190, |
| 131950 | + /* 390 */ 90, 90, 90, 90, 89, 89, 88, 88, 88, 87, |
| 131951 | + /* 400 */ 341, 317, 685, 292, 939, 939, 150, 977, 310, 93, |
| 131952 | + /* 410 */ 94, 84, 823, 823, 835, 838, 827, 827, 91, 91, |
| 131953 | + /* 420 */ 92, 92, 92, 92, 437, 90, 90, 90, 90, 89, |
| 131954 | + /* 430 */ 89, 88, 88, 88, 87, 341, 926, 2, 372, 719, |
| 131955 | + /* 440 */ 698, 369, 950, 317, 49, 49, 940, 941, 719, 177, |
| 131956 | + /* 450 */ 72, 93, 94, 84, 823, 823, 835, 838, 827, 827, |
| 131957 | + /* 460 */ 91, 91, 92, 92, 92, 92, 322, 90, 90, 90, |
| 131958 | + /* 470 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 415, |
| 131959 | + /* 480 */ 405, 824, 824, 836, 839, 75, 93, 82, 84, 823, |
| 131960 | + /* 490 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92, |
| 131961 | + /* 500 */ 92, 430, 90, 90, 90, 90, 89, 89, 88, 88, |
| 131962 | + /* 510 */ 88, 87, 341, 317, 340, 340, 340, 658, 659, 660, |
| 131963 | + /* 520 */ 333, 288, 94, 84, 823, 823, 835, 838, 827, 827, |
| 131964 | + /* 530 */ 91, 91, 92, 92, 92, 92, 437, 90, 90, 90, |
| 131965 | + /* 540 */ 90, 89, 89, 88, 88, 88, 87, 341, 317, 882, |
| 131966 | + /* 550 */ 882, 375, 828, 66, 330, 409, 49, 49, 84, 823, |
| 131967 | + /* 560 */ 823, 835, 838, 827, 827, 91, 91, 92, 92, 92, |
| 131968 | + /* 570 */ 92, 351, 90, 90, 90, 90, 89, 89, 88, 88, |
| 131969 | + /* 580 */ 88, 87, 341, 80, 432, 742, 3, 1180, 351, 350, |
| 131970 | + /* 590 */ 741, 334, 796, 939, 939, 761, 80, 432, 278, 3, |
| 131971 | + /* 600 */ 204, 161, 279, 393, 274, 392, 191, 362, 437, 277, |
| 131972 | + /* 610 */ 745, 77, 78, 272, 800, 254, 355, 243, 79, 342, |
| 131973 | + /* 620 */ 342, 86, 83, 169, 77, 78, 234, 399, 49, 49, |
| 131974 | + /* 630 */ 435, 79, 342, 342, 437, 940, 941, 186, 442, 655, |
| 131975 | + /* 640 */ 390, 387, 386, 435, 235, 213, 108, 421, 761, 351, |
| 131976 | + /* 650 */ 437, 385, 167, 732, 10, 10, 124, 124, 671, 814, |
| 131977 | + /* 660 */ 421, 439, 438, 415, 414, 802, 362, 168, 327, 124, |
| 131978 | + /* 670 */ 49, 49, 814, 219, 439, 438, 800, 186, 802, 326, |
| 131979 | + /* 680 */ 390, 387, 386, 437, 1248, 1248, 23, 939, 939, 80, |
| 131980 | + /* 690 */ 432, 385, 3, 761, 416, 876, 807, 807, 807, 809, |
| 131981 | + /* 700 */ 19, 290, 149, 49, 49, 415, 396, 260, 910, 807, |
| 131982 | + /* 710 */ 807, 807, 809, 19, 312, 237, 145, 77, 78, 746, |
| 131983 | + /* 720 */ 168, 702, 437, 149, 79, 342, 342, 114, 358, 940, |
| 131984 | + /* 730 */ 941, 302, 223, 397, 345, 313, 435, 260, 415, 417, |
| 131985 | + /* 740 */ 858, 374, 31, 31, 80, 432, 761, 3, 348, 92, |
| 131986 | + /* 750 */ 92, 92, 92, 421, 90, 90, 90, 90, 89, 89, |
| 131987 | + /* 760 */ 88, 88, 88, 87, 341, 814, 114, 439, 438, 796, |
| 131988 | + /* 770 */ 367, 802, 77, 78, 701, 796, 124, 1187, 220, 79, |
| 131989 | + /* 780 */ 342, 342, 124, 747, 734, 939, 939, 775, 404, 939, |
| 131990 | + /* 790 */ 939, 435, 254, 360, 253, 402, 895, 346, 254, 360, |
| 131991 | + /* 800 */ 253, 774, 807, 807, 807, 809, 19, 800, 421, 90, |
| 131992 | + /* 810 */ 90, 90, 90, 89, 89, 88, 88, 88, 87, 341, |
| 131993 | + /* 820 */ 814, 114, 439, 438, 939, 939, 802, 940, 941, 114, |
| 131994 | + /* 830 */ 437, 940, 941, 86, 83, 169, 192, 166, 309, 979, |
| 131995 | + /* 840 */ 70, 432, 700, 3, 382, 870, 238, 86, 83, 169, |
| 131996 | + /* 850 */ 10, 10, 361, 406, 763, 190, 222, 807, 807, 807, |
| 131997 | + /* 860 */ 809, 19, 870, 872, 329, 24, 940, 941, 77, 78, |
| 131998 | + /* 870 */ 359, 437, 335, 260, 218, 79, 342, 342, 437, 307, |
| 131999 | + /* 880 */ 306, 305, 207, 303, 339, 338, 668, 435, 339, 338, |
| 132000 | + /* 890 */ 407, 10, 10, 762, 216, 216, 939, 939, 49, 49, |
| 132001 | + /* 900 */ 437, 260, 97, 241, 421, 225, 402, 189, 188, 187, |
| 132002 | + /* 910 */ 309, 918, 980, 149, 221, 898, 814, 868, 439, 438, |
| 132003 | + /* 920 */ 10, 10, 802, 870, 915, 316, 898, 163, 162, 171, |
| 132004 | + /* 930 */ 249, 240, 322, 410, 412, 687, 687, 272, 940, 941, |
| 132005 | + /* 940 */ 239, 965, 901, 437, 226, 403, 226, 437, 963, 367, |
| 132006 | + /* 950 */ 964, 173, 248, 807, 807, 807, 809, 19, 174, 367, |
| 132007 | + /* 960 */ 899, 124, 172, 48, 48, 9, 9, 35, 35, 966, |
| 132008 | + /* 970 */ 966, 899, 363, 966, 966, 814, 900, 808, 725, 939, |
| 132009 | + /* 980 */ 939, 802, 895, 318, 980, 324, 125, 900, 726, 420, |
| 132010 | + /* 990 */ 92, 92, 92, 92, 85, 90, 90, 90, 90, 89, |
| 132011 | + /* 1000 */ 89, 88, 88, 88, 87, 341, 216, 216, 437, 946, |
| 132012 | + /* 1010 */ 349, 292, 807, 807, 807, 114, 291, 693, 402, 705, |
| 132013 | + /* 1020 */ 890, 940, 941, 437, 245, 889, 247, 437, 36, 36, |
| 132014 | + /* 1030 */ 437, 353, 391, 437, 260, 252, 260, 437, 361, 437, |
| 132015 | + /* 1040 */ 706, 437, 370, 12, 12, 224, 437, 27, 27, 437, |
| 132016 | + /* 1050 */ 37, 37, 437, 38, 38, 752, 368, 39, 39, 28, |
| 132017 | + /* 1060 */ 28, 29, 29, 215, 166, 331, 40, 40, 437, 41, |
| 132018 | + /* 1070 */ 41, 437, 42, 42, 437, 866, 246, 731, 437, 879, |
| 132019 | + /* 1080 */ 437, 256, 437, 878, 437, 267, 437, 261, 11, 11, |
| 132020 | + /* 1090 */ 437, 43, 43, 437, 99, 99, 437, 373, 44, 44, |
| 132021 | + /* 1100 */ 45, 45, 32, 32, 46, 46, 47, 47, 437, 426, |
| 132022 | + /* 1110 */ 33, 33, 776, 116, 116, 437, 117, 117, 437, 124, |
| 132023 | + /* 1120 */ 437, 777, 437, 260, 437, 957, 437, 352, 118, 118, |
| 132024 | + /* 1130 */ 437, 195, 437, 111, 437, 53, 53, 264, 34, 34, |
| 132025 | + /* 1140 */ 100, 100, 50, 50, 101, 101, 102, 102, 437, 260, |
| 132026 | + /* 1150 */ 98, 98, 115, 115, 113, 113, 437, 262, 437, 265, |
| 132027 | + /* 1160 */ 437, 943, 958, 437, 727, 437, 681, 437, 106, 106, |
| 132028 | + /* 1170 */ 68, 437, 893, 730, 437, 365, 105, 105, 103, 103, |
| 132029 | + /* 1180 */ 104, 104, 217, 52, 52, 54, 54, 51, 51, 694, |
| 132030 | + /* 1190 */ 259, 26, 26, 266, 30, 30, 677, 323, 433, 323, |
| 132031 | + /* 1200 */ 674, 423, 427, 943, 958, 114, 114, 431, 681, 865, |
| 132032 | + /* 1210 */ 1277, 233, 366, 714, 112, 20, 154, 704, 703, 810, |
| 132033 | + /* 1220 */ 914, 55, 159, 311, 798, 255, 383, 194, 68, 200, |
| 132034 | + /* 1230 */ 21, 694, 268, 114, 114, 114, 270, 711, 712, 68, |
| 132035 | + /* 1240 */ 114, 739, 770, 715, 71, 194, 861, 875, 875, 200, |
| 132036 | + /* 1250 */ 696, 865, 874, 874, 679, 699, 273, 110, 229, 419, |
| 132037 | + /* 1260 */ 768, 810, 799, 378, 748, 759, 418, 210, 294, 281, |
| 132038 | + /* 1270 */ 295, 806, 283, 682, 676, 665, 664, 666, 933, 151, |
| 132039 | + /* 1280 */ 285, 7, 1267, 308, 251, 790, 354, 244, 892, 364, |
| 132040 | + /* 1290 */ 287, 422, 300, 164, 160, 936, 974, 127, 197, 137, |
| 132041 | + /* 1300 */ 909, 907, 971, 388, 276, 863, 862, 56, 698, 325, |
| 132042 | + /* 1310 */ 148, 59, 122, 66, 356, 381, 357, 176, 152, 62, |
| 132043 | + /* 1320 */ 371, 130, 877, 181, 377, 760, 211, 182, 132, 133, |
| 132044 | + /* 1330 */ 134, 135, 258, 146, 140, 795, 787, 263, 183, 379, |
| 132045 | + /* 1340 */ 667, 394, 184, 332, 894, 314, 718, 717, 857, 716, |
| 132046 | + /* 1350 */ 696, 315, 709, 690, 65, 196, 6, 408, 289, 708, |
| 132047 | + /* 1360 */ 275, 689, 688, 948, 756, 757, 280, 282, 425, 755, |
| 132048 | + /* 1370 */ 284, 336, 73, 67, 754, 429, 411, 96, 286, 413, |
| 132049 | + /* 1380 */ 205, 934, 673, 22, 209, 440, 119, 120, 109, 206, |
| 132050 | + /* 1390 */ 208, 441, 662, 661, 656, 843, 654, 343, 158, 236, |
| 132051 | + /* 1400 */ 170, 347, 107, 227, 121, 738, 873, 298, 296, 297, |
| 132052 | + /* 1410 */ 299, 871, 794, 128, 129, 728, 230, 131, 175, 250, |
| 132053 | + /* 1420 */ 888, 136, 138, 231, 232, 139, 60, 61, 891, 178, |
| 132054 | + /* 1430 */ 179, 887, 8, 13, 180, 257, 880, 968, 194, 141, |
| 132055 | + /* 1440 */ 142, 376, 153, 670, 380, 185, 143, 277, 63, 384, |
| 132056 | + /* 1450 */ 14, 707, 271, 15, 389, 64, 319, 320, 126, 228, |
| 132057 | + /* 1460 */ 813, 812, 841, 736, 123, 16, 401, 740, 4, 769, |
| 132058 | + /* 1470 */ 165, 212, 214, 193, 144, 764, 71, 68, 17, 18, |
| 132059 | + /* 1480 */ 856, 842, 840, 897, 845, 896, 199, 198, 923, 155, |
| 132060 | + /* 1490 */ 424, 929, 924, 156, 201, 202, 428, 844, 157, 203, |
| 132061 | + /* 1500 */ 811, 680, 81, 1269, 1268, 301, 304, |
| 131244 | 132062 | }; |
| 131245 | 132063 | static const YYCODETYPE yy_lookahead[] = { |
| 131246 | 132064 | /* 0 */ 19, 95, 53, 97, 22, 24, 24, 101, 27, 28, |
| 131247 | 132065 | /* 10 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
| 131248 | 132066 | /* 20 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48, |
| 131249 | 132067 | /* 30 */ 49, 50, 51, 52, 53, 19, 55, 55, 132, 133, |
| 131250 | 132068 | /* 40 */ 134, 1, 2, 27, 28, 29, 30, 31, 32, 33, |
| 131251 | | - /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 92, 43, |
| 132069 | + /* 50 */ 34, 35, 36, 37, 38, 39, 40, 41, 187, 43, |
| 131252 | 132070 | /* 60 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 131253 | 132071 | /* 70 */ 47, 48, 49, 50, 51, 52, 53, 61, 97, 97, |
| 131254 | 132072 | /* 80 */ 19, 49, 50, 51, 52, 53, 70, 26, 27, 28, |
| 131255 | 132073 | /* 90 */ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, |
| 131256 | 132074 | /* 100 */ 39, 40, 41, 152, 43, 44, 45, 46, 47, 48, |
| 131257 | 132075 | /* 110 */ 49, 50, 51, 52, 53, 144, 145, 146, 147, 19, |
| 131258 | | - /* 120 */ 249, 22, 172, 172, 173, 52, 53, 27, 28, 29, |
| 132076 | + /* 120 */ 137, 22, 139, 172, 173, 52, 53, 27, 28, 29, |
| 131259 | 132077 | /* 130 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, |
| 131260 | 132078 | /* 140 */ 40, 41, 81, 43, 44, 45, 46, 47, 48, 49, |
| 131261 | 132079 | /* 150 */ 50, 51, 52, 53, 55, 56, 19, 152, 207, 208, |
| 131262 | 132080 | /* 160 */ 115, 24, 117, 118, 27, 28, 29, 30, 31, 32, |
| 131263 | 132081 | /* 170 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 79, |
| 131264 | 132082 | /* 180 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 131265 | 132083 | /* 190 */ 53, 19, 0, 1, 2, 23, 97, 98, 193, 27, |
| 131266 | 132084 | /* 200 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 131267 | 132085 | /* 210 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47, |
| 131268 | | - /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 172, |
| 131269 | | - /* 230 */ 23, 26, 119, 120, 27, 28, 29, 30, 31, 32, |
| 132086 | + /* 220 */ 48, 49, 50, 51, 52, 53, 19, 22, 23, 163, |
| 132087 | + /* 230 */ 23, 26, 190, 191, 27, 28, 29, 30, 31, 32, |
| 131270 | 132088 | /* 240 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187, |
| 131271 | 132089 | /* 250 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 131272 | | - /* 260 */ 53, 19, 221, 222, 223, 23, 168, 169, 170, 27, |
| 132090 | + /* 260 */ 53, 19, 196, 22, 23, 23, 49, 26, 92, 27, |
| 131273 | 132091 | /* 270 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 131274 | | - /* 280 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47, |
| 131275 | | - /* 290 */ 48, 49, 50, 51, 52, 53, 19, 157, 22, 23, |
| 131276 | | - /* 300 */ 23, 96, 26, 172, 27, 28, 29, 30, 31, 32, |
| 131277 | | - /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 187, |
| 132092 | + /* 280 */ 38, 39, 40, 41, 172, 43, 44, 45, 46, 47, |
| 132093 | + /* 290 */ 48, 49, 50, 51, 52, 53, 19, 221, 222, 223, |
| 132094 | + /* 300 */ 23, 96, 119, 120, 27, 28, 29, 30, 31, 32, |
| 132095 | + /* 310 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 172, |
| 131278 | 132096 | /* 320 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 131279 | | - /* 330 */ 53, 19, 108, 109, 110, 221, 222, 223, 185, 27, |
| 132097 | + /* 330 */ 53, 19, 152, 116, 221, 222, 223, 96, 121, 27, |
| 131280 | 132098 | /* 340 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 131281 | | - /* 350 */ 38, 39, 40, 41, 240, 43, 44, 45, 46, 47, |
| 131282 | | - /* 360 */ 48, 49, 50, 51, 52, 53, 19, 227, 22, 23, |
| 131283 | | - /* 370 */ 230, 22, 96, 152, 27, 28, 29, 30, 31, 32, |
| 132099 | + /* 350 */ 38, 39, 40, 41, 241, 43, 44, 45, 46, 47, |
| 132100 | + /* 360 */ 48, 49, 50, 51, 52, 53, 19, 157, 168, 169, |
| 132101 | + /* 370 */ 170, 22, 190, 191, 27, 28, 29, 30, 31, 32, |
| 131284 | 132102 | /* 380 */ 33, 34, 35, 36, 37, 38, 39, 40, 41, 30, |
| 131285 | 132103 | /* 390 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 131286 | | - /* 400 */ 53, 19, 190, 191, 55, 56, 24, 190, 191, 27, |
| 132104 | + /* 400 */ 53, 19, 172, 152, 55, 56, 24, 247, 248, 27, |
| 131287 | 132105 | /* 410 */ 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, |
| 131288 | 132106 | /* 420 */ 38, 39, 40, 41, 152, 43, 44, 45, 46, 47, |
| 131289 | | - /* 430 */ 48, 49, 50, 51, 52, 53, 168, 169, 170, 179, |
| 131290 | | - /* 440 */ 180, 171, 96, 19, 172, 173, 97, 98, 188, 179, |
| 132107 | + /* 430 */ 48, 49, 50, 51, 52, 53, 146, 147, 228, 179, |
| 132108 | + /* 440 */ 180, 231, 185, 19, 172, 173, 97, 98, 188, 26, |
| 131291 | 132109 | /* 450 */ 138, 27, 28, 29, 30, 31, 32, 33, 34, 35, |
| 131292 | 132110 | /* 460 */ 36, 37, 38, 39, 40, 41, 107, 43, 44, 45, |
| 131293 | 132111 | /* 470 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 207, |
| 131294 | 132112 | /* 480 */ 208, 30, 31, 32, 33, 138, 27, 28, 29, 30, |
| 131295 | 132113 | /* 490 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
| 131296 | | - /* 500 */ 41, 181, 43, 44, 45, 46, 47, 48, 49, 50, |
| 131297 | | - /* 510 */ 51, 52, 53, 19, 152, 7, 8, 9, 49, 22, |
| 131298 | | - /* 520 */ 19, 24, 28, 29, 30, 31, 32, 33, 34, 35, |
| 132114 | + /* 500 */ 41, 250, 43, 44, 45, 46, 47, 48, 49, 50, |
| 132115 | + /* 510 */ 51, 52, 53, 19, 168, 169, 170, 7, 8, 9, |
| 132116 | + /* 520 */ 19, 152, 28, 29, 30, 31, 32, 33, 34, 35, |
| 131299 | 132117 | /* 530 */ 36, 37, 38, 39, 40, 41, 152, 43, 44, 45, |
| 131300 | 132118 | /* 540 */ 46, 47, 48, 49, 50, 51, 52, 53, 19, 108, |
| 131301 | | - /* 550 */ 109, 110, 101, 55, 53, 193, 172, 173, 29, 30, |
| 132119 | + /* 550 */ 109, 110, 101, 130, 53, 152, 172, 173, 29, 30, |
| 131302 | 132120 | /* 560 */ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
| 131303 | 132121 | /* 570 */ 41, 152, 43, 44, 45, 46, 47, 48, 49, 50, |
| 131304 | 132122 | /* 580 */ 51, 52, 53, 19, 20, 116, 22, 23, 169, 170, |
| 131305 | | - /* 590 */ 121, 207, 85, 55, 56, 97, 19, 20, 195, 22, |
| 131306 | | - /* 600 */ 99, 100, 101, 102, 103, 104, 105, 12, 152, 206, |
| 132123 | + /* 590 */ 121, 207, 85, 55, 56, 26, 19, 20, 101, 22, |
| 132124 | + /* 600 */ 99, 100, 101, 102, 103, 104, 105, 152, 152, 112, |
| 131307 | 132125 | /* 610 */ 210, 47, 48, 112, 152, 108, 109, 110, 54, 55, |
| 131308 | 132126 | /* 620 */ 56, 221, 222, 223, 47, 48, 119, 120, 172, 173, |
| 131309 | | - /* 630 */ 66, 54, 55, 56, 101, 97, 98, 99, 148, 149, |
| 131310 | | - /* 640 */ 102, 103, 104, 66, 154, 112, 156, 83, 229, 47, |
| 131311 | | - /* 650 */ 48, 113, 57, 163, 194, 195, 92, 246, 247, 95, |
| 131312 | | - /* 660 */ 83, 97, 98, 207, 208, 101, 206, 59, 73, 92, |
| 131313 | | - /* 670 */ 75, 63, 95, 163, 97, 98, 194, 195, 101, 219, |
| 131314 | | - /* 680 */ 85, 181, 19, 152, 175, 77, 196, 152, 206, 19, |
| 131315 | | - /* 690 */ 20, 199, 22, 30, 163, 11, 132, 133, 134, 135, |
| 131316 | | - /* 700 */ 136, 209, 152, 172, 173, 152, 196, 172, 173, 132, |
| 131317 | | - /* 710 */ 133, 134, 135, 136, 164, 92, 213, 47, 48, 49, |
| 131318 | | - /* 720 */ 92, 186, 169, 170, 54, 55, 56, 196, 100, 219, |
| 131319 | | - /* 730 */ 221, 222, 223, 243, 132, 133, 66, 175, 207, 208, |
| 131320 | | - /* 740 */ 152, 231, 119, 120, 19, 20, 236, 22, 152, 38, |
| 132127 | + /* 630 */ 66, 54, 55, 56, 152, 97, 98, 99, 148, 149, |
| 132128 | + /* 640 */ 102, 103, 104, 66, 154, 23, 156, 83, 26, 230, |
| 132129 | + /* 650 */ 152, 113, 152, 163, 172, 173, 92, 92, 21, 95, |
| 132130 | + /* 660 */ 83, 97, 98, 207, 208, 101, 152, 98, 186, 92, |
| 132131 | + /* 670 */ 172, 173, 95, 218, 97, 98, 152, 99, 101, 217, |
| 132132 | + /* 680 */ 102, 103, 104, 152, 119, 120, 196, 55, 56, 19, |
| 132133 | + /* 690 */ 20, 113, 22, 124, 163, 11, 132, 133, 134, 135, |
| 132134 | + /* 700 */ 136, 152, 152, 172, 173, 207, 208, 152, 152, 132, |
| 132135 | + /* 710 */ 133, 134, 135, 136, 164, 152, 84, 47, 48, 49, |
| 132136 | + /* 720 */ 98, 181, 152, 152, 54, 55, 56, 196, 91, 97, |
| 132137 | + /* 730 */ 98, 160, 218, 163, 244, 164, 66, 152, 207, 208, |
| 132138 | + /* 740 */ 103, 217, 172, 173, 19, 20, 124, 22, 193, 38, |
| 131321 | 132139 | /* 750 */ 39, 40, 41, 83, 43, 44, 45, 46, 47, 48, |
| 131322 | | - /* 760 */ 49, 50, 51, 52, 53, 95, 152, 97, 98, 85, |
| 131323 | | - /* 770 */ 107, 101, 47, 48, 163, 112, 92, 152, 152, 54, |
| 131324 | | - /* 780 */ 55, 56, 229, 221, 222, 223, 172, 173, 163, 49, |
| 131325 | | - /* 790 */ 152, 66, 108, 109, 110, 55, 56, 172, 173, 163, |
| 131326 | | - /* 800 */ 186, 22, 132, 133, 134, 135, 136, 196, 83, 43, |
| 132140 | + /* 760 */ 49, 50, 51, 52, 53, 95, 196, 97, 98, 85, |
| 132141 | + /* 770 */ 152, 101, 47, 48, 181, 85, 92, 140, 193, 54, |
| 132142 | + /* 780 */ 55, 56, 92, 49, 195, 55, 56, 175, 163, 55, |
| 132143 | + /* 790 */ 56, 66, 108, 109, 110, 206, 163, 242, 108, 109, |
| 132144 | + /* 800 */ 110, 175, 132, 133, 134, 135, 136, 152, 83, 43, |
| 131327 | 132145 | /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 131328 | | - /* 820 */ 95, 196, 97, 98, 85, 99, 101, 152, 102, 103, |
| 131329 | | - /* 830 */ 104, 92, 196, 146, 147, 152, 181, 97, 98, 113, |
| 131330 | | - /* 840 */ 19, 20, 152, 22, 218, 22, 116, 108, 109, 110, |
| 131331 | | - /* 850 */ 152, 121, 55, 56, 12, 219, 218, 132, 133, 134, |
| 131332 | | - /* 860 */ 135, 136, 172, 173, 55, 56, 55, 56, 47, 48, |
| 131333 | | - /* 870 */ 172, 173, 236, 152, 5, 54, 55, 56, 55, 10, |
| 131334 | | - /* 880 */ 11, 12, 13, 14, 186, 152, 17, 66, 47, 48, |
| 131335 | | - /* 890 */ 152, 210, 16, 84, 97, 98, 55, 56, 21, 57, |
| 131336 | | - /* 900 */ 217, 122, 22, 152, 83, 152, 97, 98, 97, 98, |
| 131337 | | - /* 910 */ 172, 173, 152, 152, 224, 73, 95, 75, 97, 98, |
| 131338 | | - /* 920 */ 97, 124, 101, 172, 173, 164, 193, 47, 48, 60, |
| 131339 | | - /* 930 */ 163, 62, 172, 173, 24, 55, 56, 186, 97, 98, |
| 131340 | | - /* 940 */ 71, 100, 55, 56, 183, 207, 185, 152, 107, 23, |
| 131341 | | - /* 950 */ 109, 82, 26, 132, 133, 134, 135, 136, 89, 152, |
| 131342 | | - /* 960 */ 26, 92, 93, 196, 88, 55, 90, 152, 91, 152, |
| 131343 | | - /* 970 */ 217, 152, 152, 132, 133, 95, 152, 97, 211, 212, |
| 131344 | | - /* 980 */ 103, 101, 152, 114, 97, 98, 152, 172, 173, 19, |
| 132146 | + /* 820 */ 95, 196, 97, 98, 55, 56, 101, 97, 98, 196, |
| 132147 | + /* 830 */ 152, 97, 98, 221, 222, 223, 211, 212, 22, 23, |
| 132148 | + /* 840 */ 19, 20, 181, 22, 19, 152, 152, 221, 222, 223, |
| 132149 | + /* 850 */ 172, 173, 219, 19, 124, 30, 238, 132, 133, 134, |
| 132150 | + /* 860 */ 135, 136, 169, 170, 186, 232, 97, 98, 47, 48, |
| 132151 | + /* 870 */ 237, 152, 217, 152, 5, 54, 55, 56, 152, 10, |
| 132152 | + /* 880 */ 11, 12, 13, 14, 47, 48, 17, 66, 47, 48, |
| 132153 | + /* 890 */ 56, 172, 173, 124, 194, 195, 55, 56, 172, 173, |
| 132154 | + /* 900 */ 152, 152, 22, 152, 83, 186, 206, 108, 109, 110, |
| 132155 | + /* 910 */ 22, 23, 96, 152, 193, 12, 95, 152, 97, 98, |
| 132156 | + /* 920 */ 172, 173, 101, 230, 152, 164, 12, 47, 48, 60, |
| 132157 | + /* 930 */ 152, 62, 107, 207, 186, 55, 56, 112, 97, 98, |
| 132158 | + /* 940 */ 71, 100, 193, 152, 183, 152, 185, 152, 107, 152, |
| 132159 | + /* 950 */ 109, 82, 16, 132, 133, 134, 135, 136, 89, 152, |
| 132160 | + /* 960 */ 57, 92, 93, 172, 173, 172, 173, 172, 173, 132, |
| 132161 | + /* 970 */ 133, 57, 152, 132, 133, 95, 73, 97, 75, 55, |
| 132162 | + /* 980 */ 56, 101, 163, 114, 96, 245, 246, 73, 85, 75, |
| 131345 | 132163 | /* 990 */ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, |
| 131346 | | - /* 1000 */ 48, 49, 50, 51, 52, 53, 65, 97, 152, 152, |
| 131347 | | - /* 1010 */ 141, 124, 132, 133, 134, 152, 140, 140, 152, 78, |
| 131348 | | - /* 1020 */ 152, 233, 152, 193, 98, 152, 56, 86, 172, 173, |
| 131349 | | - /* 1030 */ 166, 167, 237, 152, 217, 172, 173, 152, 172, 173, |
| 131350 | | - /* 1040 */ 172, 173, 172, 173, 237, 172, 173, 152, 152, 152, |
| 131351 | | - /* 1050 */ 124, 152, 111, 172, 173, 152, 237, 172, 173, 152, |
| 131352 | | - /* 1060 */ 55, 152, 26, 152, 130, 152, 152, 172, 173, 172, |
| 131353 | | - /* 1070 */ 173, 172, 173, 249, 152, 172, 173, 152, 61, 172, |
| 131354 | | - /* 1080 */ 173, 172, 173, 172, 173, 172, 173, 70, 152, 193, |
| 131355 | | - /* 1090 */ 152, 137, 152, 139, 172, 173, 152, 172, 173, 152, |
| 131356 | | - /* 1100 */ 152, 152, 97, 152, 26, 152, 163, 152, 172, 173, |
| 131357 | | - /* 1110 */ 172, 173, 172, 173, 152, 16, 172, 173, 26, 172, |
| 131358 | | - /* 1120 */ 173, 172, 173, 172, 173, 172, 173, 172, 173, 163, |
| 131359 | | - /* 1130 */ 152, 152, 152, 22, 172, 173, 152, 241, 152, 196, |
| 131360 | | - /* 1140 */ 152, 193, 106, 152, 152, 152, 163, 152, 37, 152, |
| 131361 | | - /* 1150 */ 172, 173, 172, 173, 152, 152, 172, 173, 172, 173, |
| 131362 | | - /* 1160 */ 172, 173, 196, 172, 173, 172, 173, 172, 173, 172, |
| 131363 | | - /* 1170 */ 173, 152, 152, 152, 172, 173, 98, 152, 152, 196, |
| 131364 | | - /* 1180 */ 160, 22, 23, 19, 164, 193, 152, 88, 232, 90, |
| 131365 | | - /* 1190 */ 191, 172, 173, 172, 173, 163, 193, 172, 173, 166, |
| 131366 | | - /* 1200 */ 167, 163, 124, 163, 244, 245, 23, 211, 212, 26, |
| 131367 | | - /* 1210 */ 55, 23, 55, 23, 26, 123, 26, 152, 23, 193, |
| 131368 | | - /* 1220 */ 56, 26, 23, 23, 23, 26, 26, 26, 196, 100, |
| 131369 | | - /* 1230 */ 101, 7, 8, 152, 196, 23, 196, 23, 26, 152, |
| 131370 | | - /* 1240 */ 26, 132, 133, 23, 132, 133, 26, 152, 152, 152, |
| 131371 | | - /* 1250 */ 152, 210, 97, 152, 97, 96, 152, 152, 152, 152, |
| 131372 | | - /* 1260 */ 152, 210, 152, 210, 197, 152, 152, 152, 152, 152, |
| 131373 | | - /* 1270 */ 152, 152, 152, 152, 152, 152, 152, 198, 150, 176, |
| 131374 | | - /* 1280 */ 214, 201, 214, 238, 201, 238, 184, 214, 226, 200, |
| 131375 | | - /* 1290 */ 155, 198, 67, 122, 242, 159, 159, 69, 239, 239, |
| 131376 | | - /* 1300 */ 159, 175, 175, 22, 220, 180, 175, 27, 130, 18, |
| 131377 | | - /* 1310 */ 159, 18, 158, 137, 220, 159, 158, 235, 74, 189, |
| 131378 | | - /* 1320 */ 234, 159, 159, 158, 22, 192, 192, 177, 159, 159, |
| 131379 | | - /* 1330 */ 192, 192, 189, 201, 189, 158, 107, 158, 177, 76, |
| 131380 | | - /* 1340 */ 174, 201, 174, 201, 106, 159, 174, 125, 174, 182, |
| 131381 | | - /* 1350 */ 177, 176, 107, 159, 174, 137, 174, 53, 174, 129, |
| 131382 | | - /* 1360 */ 216, 215, 215, 182, 216, 216, 177, 215, 126, 216, |
| 131383 | | - /* 1370 */ 177, 128, 25, 127, 26, 215, 13, 162, 161, 153, |
| 131384 | | - /* 1380 */ 153, 6, 151, 151, 151, 151, 165, 178, 165, 178, |
| 131385 | | - /* 1390 */ 4, 3, 22, 142, 15, 94, 16, 205, 120, 202, |
| 131386 | | - /* 1400 */ 204, 203, 165, 201, 23, 23, 131, 111, 123, 20, |
| 131387 | | - /* 1410 */ 225, 125, 16, 1, 131, 228, 111, 123, 56, 228, |
| 131388 | | - /* 1420 */ 37, 37, 64, 1, 5, 122, 22, 107, 140, 80, |
| 131389 | | - /* 1430 */ 80, 26, 87, 72, 107, 24, 20, 19, 112, 105, |
| 131390 | | - /* 1440 */ 23, 68, 22, 79, 79, 22, 22, 22, 58, 22, |
| 131391 | | - /* 1450 */ 245, 248, 248, 79, 23, 23, 23, 116, 22, 122, |
| 131392 | | - /* 1460 */ 23, 22, 56, 23, 26, 23, 64, 22, 124, 26, |
| 131393 | | - /* 1470 */ 26, 64, 64, 23, 23, 23, 11, 23, 22, 26, |
| 131394 | | - /* 1480 */ 23, 22, 24, 1, 23, 22, 26, 250, 24, 23, |
| 131395 | | - /* 1490 */ 22, 122, 23, 23, 22, 15, 23, 250, 122, 122, |
| 131396 | | - /* 1500 */ 122, |
| 132164 | + /* 1000 */ 48, 49, 50, 51, 52, 53, 194, 195, 152, 171, |
| 132165 | + /* 1010 */ 141, 152, 132, 133, 134, 196, 225, 179, 206, 65, |
| 132166 | + /* 1020 */ 152, 97, 98, 152, 88, 152, 90, 152, 172, 173, |
| 132167 | + /* 1030 */ 152, 219, 78, 152, 152, 238, 152, 152, 219, 152, |
| 132168 | + /* 1040 */ 86, 152, 152, 172, 173, 238, 152, 172, 173, 152, |
| 132169 | + /* 1050 */ 172, 173, 152, 172, 173, 213, 237, 172, 173, 172, |
| 132170 | + /* 1060 */ 173, 172, 173, 211, 212, 111, 172, 173, 152, 172, |
| 132171 | + /* 1070 */ 173, 152, 172, 173, 152, 193, 140, 193, 152, 59, |
| 132172 | + /* 1080 */ 152, 152, 152, 63, 152, 16, 152, 152, 172, 173, |
| 132173 | + /* 1090 */ 152, 172, 173, 152, 172, 173, 152, 77, 172, 173, |
| 132174 | + /* 1100 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 250, |
| 132175 | + /* 1110 */ 172, 173, 61, 172, 173, 152, 172, 173, 152, 92, |
| 132176 | + /* 1120 */ 152, 70, 152, 152, 152, 26, 152, 100, 172, 173, |
| 132177 | + /* 1130 */ 152, 24, 152, 22, 152, 172, 173, 152, 172, 173, |
| 132178 | + /* 1140 */ 172, 173, 172, 173, 172, 173, 172, 173, 152, 152, |
| 132179 | + /* 1150 */ 172, 173, 172, 173, 172, 173, 152, 88, 152, 90, |
| 132180 | + /* 1160 */ 152, 55, 55, 152, 193, 152, 55, 152, 172, 173, |
| 132181 | + /* 1170 */ 26, 152, 163, 163, 152, 19, 172, 173, 172, 173, |
| 132182 | + /* 1180 */ 172, 173, 22, 172, 173, 172, 173, 172, 173, 55, |
| 132183 | + /* 1190 */ 193, 172, 173, 152, 172, 173, 166, 167, 166, 167, |
| 132184 | + /* 1200 */ 163, 163, 163, 97, 97, 196, 196, 163, 97, 55, |
| 132185 | + /* 1210 */ 23, 199, 56, 26, 22, 22, 24, 100, 101, 55, |
| 132186 | + /* 1220 */ 23, 209, 123, 26, 23, 23, 23, 26, 26, 26, |
| 132187 | + /* 1230 */ 37, 97, 152, 196, 196, 196, 23, 7, 8, 26, |
| 132188 | + /* 1240 */ 196, 23, 23, 152, 26, 26, 23, 132, 133, 26, |
| 132189 | + /* 1250 */ 106, 97, 132, 133, 23, 152, 152, 26, 210, 191, |
| 132190 | + /* 1260 */ 152, 97, 152, 234, 152, 152, 152, 233, 152, 210, |
| 132191 | + /* 1270 */ 152, 152, 210, 152, 152, 152, 152, 152, 152, 197, |
| 132192 | + /* 1280 */ 210, 198, 122, 150, 239, 201, 214, 214, 201, 239, |
| 132193 | + /* 1290 */ 214, 227, 200, 184, 198, 155, 67, 243, 122, 22, |
| 132194 | + /* 1300 */ 159, 159, 69, 176, 175, 175, 175, 240, 180, 159, |
| 132195 | + /* 1310 */ 220, 240, 27, 130, 18, 18, 159, 158, 220, 137, |
| 132196 | + /* 1320 */ 159, 189, 236, 158, 74, 159, 159, 158, 192, 192, |
| 132197 | + /* 1330 */ 192, 192, 235, 22, 189, 189, 201, 159, 158, 177, |
| 132198 | + /* 1340 */ 159, 107, 158, 76, 201, 177, 174, 174, 201, 174, |
| 132199 | + /* 1350 */ 106, 177, 182, 174, 107, 159, 22, 125, 159, 182, |
| 132200 | + /* 1360 */ 174, 176, 174, 174, 216, 216, 215, 215, 177, 216, |
| 132201 | + /* 1370 */ 215, 53, 137, 128, 216, 177, 127, 129, 215, 126, |
| 132202 | + /* 1380 */ 25, 13, 162, 26, 6, 161, 165, 165, 178, 153, |
| 132203 | + /* 1390 */ 153, 151, 151, 151, 151, 224, 4, 3, 22, 142, |
| 132204 | + /* 1400 */ 15, 94, 16, 178, 165, 205, 23, 202, 204, 203, |
| 132205 | + /* 1410 */ 201, 23, 120, 131, 111, 20, 226, 123, 125, 16, |
| 132206 | + /* 1420 */ 1, 123, 131, 229, 229, 111, 37, 37, 56, 64, |
| 132207 | + /* 1430 */ 122, 1, 5, 22, 107, 140, 80, 87, 26, 80, |
| 132208 | + /* 1440 */ 107, 72, 24, 20, 19, 105, 22, 112, 22, 79, |
| 132209 | + /* 1450 */ 22, 58, 23, 22, 79, 22, 249, 249, 246, 79, |
| 132210 | + /* 1460 */ 23, 23, 23, 116, 68, 22, 26, 23, 22, 56, |
| 132211 | + /* 1470 */ 122, 23, 23, 64, 22, 124, 26, 26, 64, 64, |
| 132212 | + /* 1480 */ 23, 23, 23, 23, 11, 23, 22, 26, 23, 22, |
| 132213 | + /* 1490 */ 24, 1, 23, 22, 26, 122, 24, 23, 22, 122, |
| 132214 | + /* 1500 */ 23, 23, 22, 122, 122, 23, 15, |
| 131397 | 132215 | }; |
| 131398 | 132216 | #define YY_SHIFT_USE_DFLT (-95) |
| 131399 | | -#define YY_SHIFT_COUNT (439) |
| 132217 | +#define YY_SHIFT_COUNT (442) |
| 131400 | 132218 | #define YY_SHIFT_MIN (-94) |
| 131401 | | -#define YY_SHIFT_MAX (1482) |
| 132219 | +#define YY_SHIFT_MAX (1491) |
| 131402 | 132220 | static const short yy_shift_ofst[] = { |
| 131403 | | - /* 0 */ 40, 564, 869, 577, 725, 725, 725, 739, -19, 16, |
| 131404 | | - /* 10 */ 16, 100, 725, 725, 725, 725, 725, 725, 725, 841, |
| 131405 | | - /* 20 */ 841, 538, 507, 684, 623, 61, 137, 172, 207, 242, |
| 131406 | | - /* 30 */ 277, 312, 347, 382, 424, 424, 424, 424, 424, 424, |
| 131407 | | - /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 459, |
| 131408 | | - /* 50 */ 424, 494, 529, 529, 670, 725, 725, 725, 725, 725, |
| 132221 | + /* 0 */ 40, 564, 869, 577, 725, 725, 725, 725, 690, -19, |
| 132222 | + /* 10 */ 16, 16, 100, 725, 725, 725, 725, 725, 725, 725, |
| 132223 | + /* 20 */ 841, 841, 538, 507, 684, 565, 61, 137, 172, 207, |
| 132224 | + /* 30 */ 242, 277, 312, 347, 382, 424, 424, 424, 424, 424, |
| 132225 | + /* 40 */ 424, 424, 424, 424, 424, 424, 424, 424, 424, 424, |
| 132226 | + /* 50 */ 459, 424, 494, 529, 529, 670, 725, 725, 725, 725, |
| 131409 | 132227 | /* 60 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725, |
| 131410 | 132228 | /* 70 */ 725, 725, 725, 725, 725, 725, 725, 725, 725, 725, |
| 131411 | | - /* 80 */ 725, 725, 725, 821, 725, 725, 725, 725, 725, 725, |
| 131412 | | - /* 90 */ 725, 725, 725, 725, 725, 725, 725, 952, 711, 711, |
| 131413 | | - /* 100 */ 711, 711, 711, 766, 23, 32, 811, 877, 663, 602, |
| 131414 | | - /* 110 */ 602, 811, 73, 113, -51, -95, -95, -95, 501, 501, |
| 131415 | | - /* 120 */ 501, 595, 595, 809, 205, 276, 811, 811, 811, 811, |
| 131416 | | - /* 130 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811, |
| 131417 | | - /* 140 */ 811, 811, 811, 811, 811, 811, 192, 628, 498, 498, |
| 131418 | | - /* 150 */ 113, -34, -34, -34, -34, -34, -34, -95, -95, -95, |
| 131419 | | - /* 160 */ 880, -94, -94, 726, 740, 99, 797, 887, 349, 811, |
| 131420 | | - /* 170 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 811, |
| 131421 | | - /* 180 */ 811, 811, 811, 811, 811, 811, 941, 941, 941, 811, |
| 131422 | | - /* 190 */ 811, 926, 811, 811, 811, -18, 811, 811, 842, 811, |
| 131423 | | - /* 200 */ 811, 811, 811, 811, 811, 811, 811, 811, 811, 224, |
| 131424 | | - /* 210 */ 608, 910, 910, 910, 1078, 45, 469, 508, 934, 970, |
| 131425 | | - /* 220 */ 970, 1164, 934, 1164, 1036, 1183, 359, 1017, 970, 954, |
| 131426 | | - /* 230 */ 1017, 1017, 1092, 730, 497, 1225, 1171, 1171, 1228, 1228, |
| 131427 | | - /* 240 */ 1171, 1281, 1280, 1178, 1291, 1291, 1291, 1291, 1171, 1293, |
| 131428 | | - /* 250 */ 1178, 1281, 1280, 1280, 1178, 1171, 1293, 1176, 1244, 1171, |
| 131429 | | - /* 260 */ 1171, 1293, 1302, 1171, 1293, 1171, 1293, 1302, 1229, 1229, |
| 131430 | | - /* 270 */ 1229, 1263, 1302, 1229, 1238, 1229, 1263, 1229, 1229, 1222, |
| 131431 | | - /* 280 */ 1245, 1222, 1245, 1222, 1245, 1222, 1245, 1171, 1171, 1218, |
| 131432 | | - /* 290 */ 1302, 1304, 1304, 1302, 1230, 1242, 1243, 1246, 1178, 1347, |
| 131433 | | - /* 300 */ 1348, 1363, 1363, 1375, 1375, 1375, 1375, -95, -95, -95, |
| 131434 | | - /* 310 */ -95, -95, -95, -95, -95, 451, 876, 346, 1159, 1099, |
| 131435 | | - /* 320 */ 441, 823, 1188, 1111, 1190, 1195, 1199, 1200, 1005, 1129, |
| 131436 | | - /* 330 */ 1224, 533, 1201, 1212, 1155, 1214, 1109, 1112, 1220, 1157, |
| 131437 | | - /* 340 */ 779, 1386, 1388, 1370, 1251, 1379, 1301, 1380, 1381, 1382, |
| 131438 | | - /* 350 */ 1278, 1275, 1296, 1285, 1389, 1286, 1396, 1412, 1294, 1283, |
| 131439 | | - /* 360 */ 1383, 1384, 1305, 1362, 1358, 1303, 1422, 1419, 1404, 1320, |
| 131440 | | - /* 370 */ 1288, 1349, 1405, 1350, 1345, 1361, 1327, 1411, 1416, 1418, |
| 131441 | | - /* 380 */ 1326, 1334, 1420, 1364, 1423, 1424, 1417, 1425, 1365, 1390, |
| 131442 | | - /* 390 */ 1427, 1374, 1373, 1431, 1432, 1433, 1341, 1436, 1437, 1439, |
| 131443 | | - /* 400 */ 1438, 1337, 1440, 1442, 1406, 1402, 1445, 1344, 1443, 1407, |
| 131444 | | - /* 410 */ 1444, 1408, 1443, 1450, 1451, 1452, 1453, 1454, 1456, 1465, |
| 131445 | | - /* 420 */ 1457, 1459, 1458, 1460, 1461, 1463, 1464, 1460, 1466, 1468, |
| 131446 | | - /* 430 */ 1469, 1470, 1472, 1369, 1376, 1377, 1378, 1473, 1480, 1482, |
| 132229 | + /* 80 */ 725, 725, 725, 725, 821, 725, 725, 725, 725, 725, |
| 132230 | + /* 90 */ 725, 725, 725, 725, 725, 725, 725, 725, 952, 711, |
| 132231 | + /* 100 */ 711, 711, 711, 711, 766, 23, 32, 924, 637, 825, |
| 132232 | + /* 110 */ 837, 837, 924, 73, 183, -51, -95, -95, -95, 501, |
| 132233 | + /* 120 */ 501, 501, 903, 903, 632, 205, 241, 924, 924, 924, |
| 132234 | + /* 130 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924, |
| 132235 | + /* 140 */ 924, 924, 924, 924, 924, 924, 924, 192, 1027, 1106, |
| 132236 | + /* 150 */ 1106, 183, 176, 176, 176, 176, 176, 176, -95, -95, |
| 132237 | + /* 160 */ -95, 880, -94, -94, 578, 734, 99, 730, 769, 349, |
| 132238 | + /* 170 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924, |
| 132239 | + /* 180 */ 924, 924, 924, 924, 924, 924, 924, 954, 954, 954, |
| 132240 | + /* 190 */ 924, 924, 622, 924, 924, 924, -18, 924, 924, 914, |
| 132241 | + /* 200 */ 924, 924, 924, 924, 924, 924, 924, 924, 924, 924, |
| 132242 | + /* 210 */ 441, 1020, 1107, 1107, 1107, 569, 45, 217, 510, 423, |
| 132243 | + /* 220 */ 834, 834, 1156, 423, 1156, 1144, 1187, 359, 1051, 834, |
| 132244 | + /* 230 */ -17, 1051, 1051, 1099, 469, 1192, 1229, 1176, 1176, 1233, |
| 132245 | + /* 240 */ 1233, 1176, 1277, 1285, 1183, 1296, 1296, 1296, 1296, 1176, |
| 132246 | + /* 250 */ 1297, 1183, 1277, 1285, 1285, 1183, 1176, 1297, 1182, 1250, |
| 132247 | + /* 260 */ 1176, 1176, 1297, 1311, 1176, 1297, 1176, 1297, 1311, 1234, |
| 132248 | + /* 270 */ 1234, 1234, 1267, 1311, 1234, 1244, 1234, 1267, 1234, 1234, |
| 132249 | + /* 280 */ 1232, 1247, 1232, 1247, 1232, 1247, 1232, 1247, 1176, 1334, |
| 132250 | + /* 290 */ 1176, 1235, 1311, 1318, 1318, 1311, 1248, 1253, 1245, 1249, |
| 132251 | + /* 300 */ 1183, 1355, 1357, 1368, 1368, 1378, 1378, 1378, 1378, -95, |
| 132252 | + /* 310 */ -95, -95, -95, -95, -95, -95, -95, 451, 936, 816, |
| 132253 | + /* 320 */ 888, 1069, 799, 1111, 1197, 1193, 1201, 1202, 1203, 1213, |
| 132254 | + /* 330 */ 1134, 1117, 1230, 497, 1218, 1219, 1154, 1223, 1115, 1120, |
| 132255 | + /* 340 */ 1231, 1164, 1160, 1392, 1394, 1376, 1257, 1385, 1307, 1386, |
| 132256 | + /* 350 */ 1383, 1388, 1292, 1282, 1303, 1294, 1395, 1293, 1403, 1419, |
| 132257 | + /* 360 */ 1298, 1291, 1389, 1390, 1314, 1372, 1365, 1308, 1430, 1427, |
| 132258 | + /* 370 */ 1411, 1327, 1295, 1356, 1412, 1359, 1350, 1369, 1333, 1418, |
| 132259 | + /* 380 */ 1423, 1425, 1335, 1340, 1424, 1370, 1426, 1428, 1429, 1431, |
| 132260 | + /* 390 */ 1375, 1393, 1433, 1380, 1396, 1437, 1438, 1439, 1347, 1443, |
| 132261 | + /* 400 */ 1444, 1446, 1440, 1348, 1448, 1449, 1413, 1409, 1452, 1351, |
| 132262 | + /* 410 */ 1450, 1414, 1451, 1415, 1457, 1450, 1458, 1459, 1460, 1461, |
| 132263 | + /* 420 */ 1462, 1464, 1473, 1465, 1467, 1466, 1468, 1469, 1471, 1472, |
| 132264 | + /* 430 */ 1468, 1474, 1476, 1477, 1478, 1480, 1373, 1377, 1381, 1382, |
| 132265 | + /* 440 */ 1482, 1491, 1490, |
| 131447 | 132266 | }; |
| 131448 | 132267 | #define YY_REDUCE_USE_DFLT (-130) |
| 131449 | | -#define YY_REDUCE_COUNT (314) |
| 132268 | +#define YY_REDUCE_COUNT (316) |
| 131450 | 132269 | #define YY_REDUCE_MIN (-129) |
| 131451 | | -#define YY_REDUCE_MAX (1237) |
| 132270 | +#define YY_REDUCE_MAX (1243) |
| 131452 | 132271 | static const short yy_reduce_ofst[] = { |
| 131453 | | - /* 0 */ -29, 531, 490, 625, -49, 272, 456, 510, 400, 509, |
| 131454 | | - /* 10 */ 562, 114, 535, 614, 698, 384, 738, 751, 690, 419, |
| 131455 | | - /* 20 */ 553, 761, 460, 636, 767, 41, 41, 41, 41, 41, |
| 131456 | | - /* 30 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, |
| 131457 | | - /* 40 */ 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, |
| 131458 | | - /* 50 */ 41, 41, 41, 41, 760, 815, 856, 863, 866, 868, |
| 131459 | | - /* 60 */ 870, 873, 881, 885, 895, 897, 899, 903, 907, 909, |
| 131460 | | - /* 70 */ 911, 913, 922, 925, 936, 938, 940, 944, 947, 949, |
| 131461 | | - /* 80 */ 951, 953, 955, 962, 978, 980, 984, 986, 988, 991, |
| 131462 | | - /* 90 */ 993, 995, 997, 1002, 1019, 1021, 1025, 41, 41, 41, |
| 131463 | | - /* 100 */ 41, 41, 41, 41, 41, 41, 896, 140, 260, 98, |
| 131464 | | - /* 110 */ 268, 1020, 41, 482, 41, 41, 41, 41, 270, 270, |
| 131465 | | - /* 120 */ 270, 212, 217, -129, 411, 411, 550, 5, 626, 362, |
| 131466 | | - /* 130 */ 733, 830, 992, 1003, 1026, 795, 683, 807, 638, 819, |
| 131467 | | - /* 140 */ 753, 948, 62, 817, 824, 132, 687, 611, 864, 1033, |
| 131468 | | - /* 150 */ 403, 943, 966, 983, 1032, 1038, 1040, 960, 996, 492, |
| 131469 | | - /* 160 */ -50, 57, 131, 153, 221, 462, 588, 596, 675, 721, |
| 131470 | | - /* 170 */ 820, 834, 857, 914, 979, 1034, 1065, 1081, 1087, 1095, |
| 131471 | | - /* 180 */ 1096, 1097, 1098, 1101, 1104, 1105, 320, 500, 655, 1106, |
| 131472 | | - /* 190 */ 1107, 503, 1108, 1110, 1113, 681, 1114, 1115, 999, 1116, |
| 131473 | | - /* 200 */ 1117, 1118, 221, 1119, 1120, 1121, 1122, 1123, 1124, 788, |
| 131474 | | - /* 210 */ 956, 1041, 1051, 1053, 503, 1067, 1079, 1128, 1080, 1066, |
| 131475 | | - /* 220 */ 1068, 1045, 1083, 1047, 1103, 1102, 1125, 1126, 1073, 1062, |
| 131476 | | - /* 230 */ 1127, 1131, 1089, 1093, 1135, 1052, 1136, 1137, 1059, 1060, |
| 131477 | | - /* 240 */ 1141, 1084, 1130, 1132, 1133, 1134, 1138, 1139, 1151, 1154, |
| 131478 | | - /* 250 */ 1140, 1094, 1143, 1145, 1142, 1156, 1158, 1082, 1086, 1162, |
| 131479 | | - /* 260 */ 1163, 1165, 1150, 1169, 1177, 1170, 1179, 1161, 1166, 1168, |
| 131480 | | - /* 270 */ 1172, 1167, 1173, 1174, 1175, 1180, 1181, 1182, 1184, 1144, |
| 131481 | | - /* 280 */ 1146, 1148, 1147, 1149, 1152, 1153, 1160, 1186, 1194, 1185, |
| 131482 | | - /* 290 */ 1189, 1187, 1191, 1193, 1192, 1196, 1198, 1197, 1202, 1215, |
| 131483 | | - /* 300 */ 1217, 1226, 1227, 1231, 1232, 1233, 1234, 1203, 1204, 1205, |
| 131484 | | - /* 310 */ 1221, 1223, 1209, 1211, 1237, |
| 132272 | + /* 0 */ -29, 531, 490, 570, -49, 272, 456, 498, 633, 400, |
| 132273 | + /* 10 */ 612, 626, 113, 482, 678, 719, 384, 726, 748, 791, |
| 132274 | + /* 20 */ 419, 693, 761, 812, 819, 625, 76, 76, 76, 76, |
| 132275 | + /* 30 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, |
| 132276 | + /* 40 */ 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, |
| 132277 | + /* 50 */ 76, 76, 76, 76, 76, 793, 795, 856, 871, 875, |
| 132278 | + /* 60 */ 878, 881, 885, 887, 889, 894, 897, 900, 916, 919, |
| 132279 | + /* 70 */ 922, 926, 928, 930, 932, 934, 938, 941, 944, 956, |
| 132280 | + /* 80 */ 963, 966, 968, 970, 972, 974, 978, 980, 982, 996, |
| 132281 | + /* 90 */ 1004, 1006, 1008, 1011, 1013, 1015, 1019, 1022, 76, 76, |
| 132282 | + /* 100 */ 76, 76, 76, 76, 76, 76, 76, 555, 210, 260, |
| 132283 | + /* 110 */ 200, 346, 571, 76, 700, 76, 76, 76, 76, 838, |
| 132284 | + /* 120 */ 838, 838, 42, 182, 251, 160, 160, 550, 5, 455, |
| 132285 | + /* 130 */ 585, 721, 749, 882, 884, 971, 618, 462, 797, 514, |
| 132286 | + /* 140 */ 807, 524, 997, -129, 655, 859, 62, 290, 66, 1030, |
| 132287 | + /* 150 */ 1032, 589, 1009, 1010, 1037, 1038, 1039, 1044, 740, 852, |
| 132288 | + /* 160 */ 1012, 112, 147, 230, 257, 180, 369, 403, 500, 549, |
| 132289 | + /* 170 */ 556, 563, 694, 751, 765, 772, 778, 820, 868, 873, |
| 132290 | + /* 180 */ 890, 929, 935, 985, 1041, 1080, 1091, 540, 593, 661, |
| 132291 | + /* 190 */ 1103, 1104, 842, 1108, 1110, 1112, 1048, 1113, 1114, 1068, |
| 132292 | + /* 200 */ 1116, 1118, 1119, 180, 1121, 1122, 1123, 1124, 1125, 1126, |
| 132293 | + /* 210 */ 1029, 1034, 1059, 1062, 1070, 842, 1082, 1083, 1133, 1084, |
| 132294 | + /* 220 */ 1072, 1073, 1045, 1087, 1050, 1127, 1109, 1128, 1129, 1076, |
| 132295 | + /* 230 */ 1064, 1130, 1131, 1092, 1096, 1140, 1054, 1141, 1142, 1067, |
| 132296 | + /* 240 */ 1071, 1150, 1090, 1132, 1135, 1136, 1137, 1138, 1139, 1157, |
| 132297 | + /* 250 */ 1159, 1143, 1098, 1145, 1146, 1147, 1161, 1165, 1086, 1097, |
| 132298 | + /* 260 */ 1166, 1167, 1169, 1162, 1178, 1180, 1181, 1184, 1168, 1172, |
| 132299 | + /* 270 */ 1173, 1175, 1170, 1174, 1179, 1185, 1186, 1177, 1188, 1189, |
| 132300 | + /* 280 */ 1148, 1151, 1149, 1152, 1153, 1155, 1158, 1163, 1196, 1171, |
| 132301 | + /* 290 */ 1199, 1190, 1191, 1194, 1195, 1198, 1200, 1204, 1206, 1205, |
| 132302 | + /* 300 */ 1209, 1220, 1224, 1236, 1237, 1240, 1241, 1242, 1243, 1207, |
| 132303 | + /* 310 */ 1208, 1212, 1221, 1222, 1210, 1225, 1239, |
| 131485 | 132304 | }; |
| 131486 | 132305 | static const YYACTIONTYPE yy_default[] = { |
| 131487 | | - /* 0 */ 1250, 1240, 1240, 1240, 1174, 1174, 1174, 1240, 1071, 1100, |
| 131488 | | - /* 10 */ 1100, 1224, 1301, 1301, 1301, 1301, 1301, 1301, 1173, 1301, |
| 131489 | | - /* 20 */ 1301, 1301, 1301, 1240, 1075, 1106, 1301, 1301, 1301, 1301, |
| 131490 | | - /* 30 */ 1301, 1301, 1301, 1301, 1223, 1225, 1114, 1113, 1206, 1087, |
| 131491 | | - /* 40 */ 1111, 1104, 1108, 1175, 1169, 1170, 1168, 1172, 1176, 1301, |
| 131492 | | - /* 50 */ 1107, 1138, 1153, 1137, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131493 | | - /* 60 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131494 | | - /* 70 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131495 | | - /* 80 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131496 | | - /* 90 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1147, 1152, 1159, |
| 131497 | | - /* 100 */ 1151, 1148, 1140, 1139, 1141, 1142, 1301, 994, 1042, 1301, |
| 131498 | | - /* 110 */ 1301, 1301, 1143, 1301, 1144, 1156, 1155, 1154, 1231, 1258, |
| 131499 | | - /* 120 */ 1257, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131500 | | - /* 130 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131501 | | - /* 140 */ 1301, 1301, 1301, 1301, 1301, 1301, 1250, 1240, 1000, 1000, |
| 131502 | | - /* 150 */ 1301, 1240, 1240, 1240, 1240, 1240, 1240, 1236, 1075, 1066, |
| 131503 | | - /* 160 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131504 | | - /* 170 */ 1228, 1226, 1301, 1187, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131505 | | - /* 180 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131506 | | - /* 190 */ 1301, 1301, 1301, 1301, 1301, 1071, 1301, 1301, 1301, 1301, |
| 131507 | | - /* 200 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1252, 1301, |
| 131508 | | - /* 210 */ 1201, 1071, 1071, 1071, 1073, 1055, 1065, 979, 1110, 1089, |
| 131509 | | - /* 220 */ 1089, 1290, 1110, 1290, 1017, 1272, 1014, 1100, 1089, 1171, |
| 131510 | | - /* 230 */ 1100, 1100, 1072, 1065, 1301, 1293, 1080, 1080, 1292, 1292, |
| 131511 | | - /* 240 */ 1080, 1119, 1045, 1110, 1051, 1051, 1051, 1051, 1080, 991, |
| 131512 | | - /* 250 */ 1110, 1119, 1045, 1045, 1110, 1080, 991, 1205, 1287, 1080, |
| 131513 | | - /* 260 */ 1080, 991, 1180, 1080, 991, 1080, 991, 1180, 1043, 1043, |
| 131514 | | - /* 270 */ 1043, 1032, 1180, 1043, 1017, 1043, 1032, 1043, 1043, 1093, |
| 131515 | | - /* 280 */ 1088, 1093, 1088, 1093, 1088, 1093, 1088, 1080, 1080, 1301, |
| 131516 | | - /* 290 */ 1180, 1184, 1184, 1180, 1105, 1094, 1103, 1101, 1110, 997, |
| 131517 | | - /* 300 */ 1035, 1255, 1255, 1251, 1251, 1251, 1251, 1298, 1298, 1236, |
| 131518 | | - /* 310 */ 1267, 1267, 1019, 1019, 1267, 1301, 1301, 1301, 1301, 1301, |
| 131519 | | - /* 320 */ 1301, 1262, 1301, 1189, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131520 | | - /* 330 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131521 | | - /* 340 */ 1125, 1301, 975, 1233, 1301, 1301, 1232, 1301, 1301, 1301, |
| 131522 | | - /* 350 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131523 | | - /* 360 */ 1301, 1301, 1301, 1301, 1301, 1289, 1301, 1301, 1301, 1301, |
| 131524 | | - /* 370 */ 1301, 1301, 1204, 1203, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131525 | | - /* 380 */ 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131526 | | - /* 390 */ 1301, 1301, 1301, 1301, 1301, 1301, 1057, 1301, 1301, 1301, |
| 131527 | | - /* 400 */ 1276, 1301, 1301, 1301, 1301, 1301, 1301, 1301, 1102, 1301, |
| 131528 | | - /* 410 */ 1095, 1301, 1280, 1301, 1301, 1301, 1301, 1301, 1301, 1301, |
| 131529 | | - /* 420 */ 1301, 1301, 1301, 1242, 1301, 1301, 1301, 1241, 1301, 1301, |
| 131530 | | - /* 430 */ 1301, 1301, 1301, 1127, 1301, 1126, 1130, 1301, 985, 1301, |
| 132306 | + /* 0 */ 1258, 1248, 1248, 1248, 1180, 1180, 1180, 1180, 1248, 1077, |
| 132307 | + /* 10 */ 1106, 1106, 1232, 1309, 1309, 1309, 1309, 1309, 1309, 1179, |
| 132308 | + /* 20 */ 1309, 1309, 1309, 1309, 1248, 1081, 1112, 1309, 1309, 1309, |
| 132309 | + /* 30 */ 1309, 1309, 1309, 1309, 1309, 1231, 1233, 1120, 1119, 1214, |
| 132310 | + /* 40 */ 1093, 1117, 1110, 1114, 1181, 1175, 1176, 1174, 1178, 1182, |
| 132311 | + /* 50 */ 1309, 1113, 1144, 1159, 1143, 1309, 1309, 1309, 1309, 1309, |
| 132312 | + /* 60 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132313 | + /* 70 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132314 | + /* 80 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132315 | + /* 90 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1153, 1158, |
| 132316 | + /* 100 */ 1165, 1157, 1154, 1146, 1145, 1147, 1148, 1309, 1000, 1048, |
| 132317 | + /* 110 */ 1309, 1309, 1309, 1149, 1309, 1150, 1162, 1161, 1160, 1239, |
| 132318 | + /* 120 */ 1266, 1265, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132319 | + /* 130 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132320 | + /* 140 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1258, 1248, 1006, |
| 132321 | + /* 150 */ 1006, 1309, 1248, 1248, 1248, 1248, 1248, 1248, 1244, 1081, |
| 132322 | + /* 160 */ 1072, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132323 | + /* 170 */ 1309, 1236, 1234, 1309, 1195, 1309, 1309, 1309, 1309, 1309, |
| 132324 | + /* 180 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132325 | + /* 190 */ 1309, 1309, 1309, 1309, 1309, 1309, 1077, 1309, 1309, 1309, |
| 132326 | + /* 200 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1260, |
| 132327 | + /* 210 */ 1309, 1209, 1077, 1077, 1077, 1079, 1061, 1071, 985, 1116, |
| 132328 | + /* 220 */ 1095, 1095, 1298, 1116, 1298, 1023, 1280, 1020, 1106, 1095, |
| 132329 | + /* 230 */ 1177, 1106, 1106, 1078, 1071, 1309, 1301, 1086, 1086, 1300, |
| 132330 | + /* 240 */ 1300, 1086, 1125, 1051, 1116, 1057, 1057, 1057, 1057, 1086, |
| 132331 | + /* 250 */ 997, 1116, 1125, 1051, 1051, 1116, 1086, 997, 1213, 1295, |
| 132332 | + /* 260 */ 1086, 1086, 997, 1188, 1086, 997, 1086, 997, 1188, 1049, |
| 132333 | + /* 270 */ 1049, 1049, 1038, 1188, 1049, 1023, 1049, 1038, 1049, 1049, |
| 132334 | + /* 280 */ 1099, 1094, 1099, 1094, 1099, 1094, 1099, 1094, 1086, 1183, |
| 132335 | + /* 290 */ 1086, 1309, 1188, 1192, 1192, 1188, 1111, 1100, 1109, 1107, |
| 132336 | + /* 300 */ 1116, 1003, 1041, 1263, 1263, 1259, 1259, 1259, 1259, 1306, |
| 132337 | + /* 310 */ 1306, 1244, 1275, 1275, 1025, 1025, 1275, 1309, 1309, 1309, |
| 132338 | + /* 320 */ 1309, 1309, 1309, 1270, 1309, 1197, 1309, 1309, 1309, 1309, |
| 132339 | + /* 330 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132340 | + /* 340 */ 1309, 1309, 1131, 1309, 981, 1241, 1309, 1309, 1240, 1309, |
| 132341 | + /* 350 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132342 | + /* 360 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1297, 1309, 1309, |
| 132343 | + /* 370 */ 1309, 1309, 1309, 1309, 1212, 1211, 1309, 1309, 1309, 1309, |
| 132344 | + /* 380 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132345 | + /* 390 */ 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1309, 1063, 1309, |
| 132346 | + /* 400 */ 1309, 1309, 1284, 1309, 1309, 1309, 1309, 1309, 1309, 1309, |
| 132347 | + /* 410 */ 1108, 1309, 1101, 1309, 1309, 1288, 1309, 1309, 1309, 1309, |
| 132348 | + /* 420 */ 1309, 1309, 1309, 1309, 1309, 1309, 1250, 1309, 1309, 1309, |
| 132349 | + /* 430 */ 1249, 1309, 1309, 1309, 1309, 1309, 1133, 1309, 1132, 1136, |
| 132350 | + /* 440 */ 1309, 991, 1309, |
| 131531 | 132351 | }; |
| 131532 | 132352 | /********** End of lemon-generated parsing tables *****************************/ |
| 131533 | 132353 | |
| 131534 | 132354 | /* The next table maps tokens (terminal symbols) into fallback tokens. |
| 131535 | 132355 | ** If a construct like the following: |
| | @@ -131672,21 +132492,22 @@ |
| 131672 | 132492 | typedef struct yyStackEntry yyStackEntry; |
| 131673 | 132493 | |
| 131674 | 132494 | /* The state of the parser is completely contained in an instance of |
| 131675 | 132495 | ** the following structure */ |
| 131676 | 132496 | struct yyParser { |
| 131677 | | - int yyidx; /* Index of top element in stack */ |
| 132497 | + yyStackEntry *yytos; /* Pointer to top element of the stack */ |
| 131678 | 132498 | #ifdef YYTRACKMAXSTACKDEPTH |
| 131679 | | - int yyidxMax; /* Maximum value of yyidx */ |
| 132499 | + int yyhwm; /* High-water mark of the stack */ |
| 131680 | 132500 | #endif |
| 131681 | 132501 | #ifndef YYNOERRORRECOVERY |
| 131682 | 132502 | int yyerrcnt; /* Shifts left before out of the error */ |
| 131683 | 132503 | #endif |
| 131684 | 132504 | sqlite3ParserARG_SDECL /* A place to hold %extra_argument */ |
| 131685 | 132505 | #if YYSTACKDEPTH<=0 |
| 131686 | 132506 | int yystksz; /* Current side of the stack */ |
| 131687 | 132507 | yyStackEntry *yystack; /* The parser's stack */ |
| 132508 | + yyStackEntry yystk0; /* First stack entry */ |
| 131688 | 132509 | #else |
| 131689 | 132510 | yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
| 131690 | 132511 | #endif |
| 131691 | 132512 | }; |
| 131692 | 132513 | typedef struct yyParser yyParser; |
| | @@ -131781,17 +132602,17 @@ |
| 131781 | 132602 | "orderby_opt", "limit_opt", "values", "nexprlist", |
| 131782 | 132603 | "exprlist", "sclp", "as", "seltablist", |
| 131783 | 132604 | "stl_prefix", "joinop", "indexed_opt", "on_opt", |
| 131784 | 132605 | "using_opt", "idlist", "setlist", "insert_cmd", |
| 131785 | 132606 | "idlist_opt", "likeop", "between_op", "in_op", |
| 131786 | | - "case_operand", "case_exprlist", "case_else", "uniqueflag", |
| 131787 | | - "collate", "nmnum", "trigger_decl", "trigger_cmd_list", |
| 131788 | | - "trigger_time", "trigger_event", "foreach_clause", "when_clause", |
| 131789 | | - "trigger_cmd", "trnm", "tridxby", "database_kw_opt", |
| 131790 | | - "key_opt", "add_column_fullname", "kwcolumn_opt", "create_vtab", |
| 131791 | | - "vtabarglist", "vtabarg", "vtabargtoken", "lp", |
| 131792 | | - "anylist", "wqlist", |
| 132607 | + "paren_exprlist", "case_operand", "case_exprlist", "case_else", |
| 132608 | + "uniqueflag", "collate", "nmnum", "trigger_decl", |
| 132609 | + "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause", |
| 132610 | + "when_clause", "trigger_cmd", "trnm", "tridxby", |
| 132611 | + "database_kw_opt", "key_opt", "add_column_fullname", "kwcolumn_opt", |
| 132612 | + "create_vtab", "vtabarglist", "vtabarg", "vtabargtoken", |
| 132613 | + "lp", "anylist", "wqlist", |
| 131793 | 132614 | }; |
| 131794 | 132615 | #endif /* NDEBUG */ |
| 131795 | 132616 | |
| 131796 | 132617 | #ifndef NDEBUG |
| 131797 | 132618 | /* For tracing reduce actions, the names of all rules are required. |
| | @@ -131985,11 +132806,11 @@ |
| 131985 | 132806 | /* 185 */ "in_op ::= IN", |
| 131986 | 132807 | /* 186 */ "in_op ::= NOT IN", |
| 131987 | 132808 | /* 187 */ "expr ::= expr in_op LP exprlist RP", |
| 131988 | 132809 | /* 188 */ "expr ::= LP select RP", |
| 131989 | 132810 | /* 189 */ "expr ::= expr in_op LP select RP", |
| 131990 | | - /* 190 */ "expr ::= expr in_op nm dbnm", |
| 132811 | + /* 190 */ "expr ::= expr in_op nm dbnm paren_exprlist", |
| 131991 | 132812 | /* 191 */ "expr ::= EXISTS LP select RP", |
| 131992 | 132813 | /* 192 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 131993 | 132814 | /* 193 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 131994 | 132815 | /* 194 */ "case_exprlist ::= WHEN expr THEN expr", |
| 131995 | 132816 | /* 195 */ "case_else ::= ELSE expr", |
| | @@ -131997,158 +132818,170 @@ |
| 131997 | 132818 | /* 197 */ "case_operand ::= expr", |
| 131998 | 132819 | /* 198 */ "case_operand ::=", |
| 131999 | 132820 | /* 199 */ "exprlist ::=", |
| 132000 | 132821 | /* 200 */ "nexprlist ::= nexprlist COMMA expr", |
| 132001 | 132822 | /* 201 */ "nexprlist ::= expr", |
| 132002 | | - /* 202 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 132003 | | - /* 203 */ "uniqueflag ::= UNIQUE", |
| 132004 | | - /* 204 */ "uniqueflag ::=", |
| 132005 | | - /* 205 */ "eidlist_opt ::=", |
| 132006 | | - /* 206 */ "eidlist_opt ::= LP eidlist RP", |
| 132007 | | - /* 207 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 132008 | | - /* 208 */ "eidlist ::= nm collate sortorder", |
| 132009 | | - /* 209 */ "collate ::=", |
| 132010 | | - /* 210 */ "collate ::= COLLATE ID|STRING", |
| 132011 | | - /* 211 */ "cmd ::= DROP INDEX ifexists fullname", |
| 132012 | | - /* 212 */ "cmd ::= VACUUM", |
| 132013 | | - /* 213 */ "cmd ::= VACUUM nm", |
| 132014 | | - /* 214 */ "cmd ::= PRAGMA nm dbnm", |
| 132015 | | - /* 215 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 132016 | | - /* 216 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 132017 | | - /* 217 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 132018 | | - /* 218 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 132019 | | - /* 219 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 132020 | | - /* 220 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 132021 | | - /* 221 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 132022 | | - /* 222 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 132023 | | - /* 223 */ "trigger_time ::= BEFORE", |
| 132024 | | - /* 224 */ "trigger_time ::= AFTER", |
| 132025 | | - /* 225 */ "trigger_time ::= INSTEAD OF", |
| 132026 | | - /* 226 */ "trigger_time ::=", |
| 132027 | | - /* 227 */ "trigger_event ::= DELETE|INSERT", |
| 132028 | | - /* 228 */ "trigger_event ::= UPDATE", |
| 132029 | | - /* 229 */ "trigger_event ::= UPDATE OF idlist", |
| 132030 | | - /* 230 */ "when_clause ::=", |
| 132031 | | - /* 231 */ "when_clause ::= WHEN expr", |
| 132032 | | - /* 232 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 132033 | | - /* 233 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 132034 | | - /* 234 */ "trnm ::= nm DOT nm", |
| 132035 | | - /* 235 */ "tridxby ::= INDEXED BY nm", |
| 132036 | | - /* 236 */ "tridxby ::= NOT INDEXED", |
| 132037 | | - /* 237 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 132038 | | - /* 238 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select", |
| 132039 | | - /* 239 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 132040 | | - /* 240 */ "trigger_cmd ::= select", |
| 132041 | | - /* 241 */ "expr ::= RAISE LP IGNORE RP", |
| 132042 | | - /* 242 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 132043 | | - /* 243 */ "raisetype ::= ROLLBACK", |
| 132044 | | - /* 244 */ "raisetype ::= ABORT", |
| 132045 | | - /* 245 */ "raisetype ::= FAIL", |
| 132046 | | - /* 246 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 132047 | | - /* 247 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 132048 | | - /* 248 */ "cmd ::= DETACH database_kw_opt expr", |
| 132049 | | - /* 249 */ "key_opt ::=", |
| 132050 | | - /* 250 */ "key_opt ::= KEY expr", |
| 132051 | | - /* 251 */ "cmd ::= REINDEX", |
| 132052 | | - /* 252 */ "cmd ::= REINDEX nm dbnm", |
| 132053 | | - /* 253 */ "cmd ::= ANALYZE", |
| 132054 | | - /* 254 */ "cmd ::= ANALYZE nm dbnm", |
| 132055 | | - /* 255 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 132056 | | - /* 256 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 132057 | | - /* 257 */ "add_column_fullname ::= fullname", |
| 132058 | | - /* 258 */ "cmd ::= create_vtab", |
| 132059 | | - /* 259 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 132060 | | - /* 260 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 132061 | | - /* 261 */ "vtabarg ::=", |
| 132062 | | - /* 262 */ "vtabargtoken ::= ANY", |
| 132063 | | - /* 263 */ "vtabargtoken ::= lp anylist RP", |
| 132064 | | - /* 264 */ "lp ::= LP", |
| 132065 | | - /* 265 */ "with ::=", |
| 132066 | | - /* 266 */ "with ::= WITH wqlist", |
| 132067 | | - /* 267 */ "with ::= WITH RECURSIVE wqlist", |
| 132068 | | - /* 268 */ "wqlist ::= nm eidlist_opt AS LP select RP", |
| 132069 | | - /* 269 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", |
| 132070 | | - /* 270 */ "input ::= cmdlist", |
| 132071 | | - /* 271 */ "cmdlist ::= cmdlist ecmd", |
| 132072 | | - /* 272 */ "cmdlist ::= ecmd", |
| 132073 | | - /* 273 */ "ecmd ::= SEMI", |
| 132074 | | - /* 274 */ "ecmd ::= explain cmdx SEMI", |
| 132075 | | - /* 275 */ "explain ::=", |
| 132076 | | - /* 276 */ "trans_opt ::=", |
| 132077 | | - /* 277 */ "trans_opt ::= TRANSACTION", |
| 132078 | | - /* 278 */ "trans_opt ::= TRANSACTION nm", |
| 132079 | | - /* 279 */ "savepoint_opt ::= SAVEPOINT", |
| 132080 | | - /* 280 */ "savepoint_opt ::=", |
| 132081 | | - /* 281 */ "cmd ::= create_table create_table_args", |
| 132082 | | - /* 282 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 132083 | | - /* 283 */ "columnlist ::= columnname carglist", |
| 132084 | | - /* 284 */ "nm ::= ID|INDEXED", |
| 132085 | | - /* 285 */ "nm ::= STRING", |
| 132086 | | - /* 286 */ "nm ::= JOIN_KW", |
| 132087 | | - /* 287 */ "typetoken ::= typename", |
| 132088 | | - /* 288 */ "typename ::= ID|STRING", |
| 132089 | | - /* 289 */ "signed ::= plus_num", |
| 132090 | | - /* 290 */ "signed ::= minus_num", |
| 132091 | | - /* 291 */ "carglist ::= carglist ccons", |
| 132092 | | - /* 292 */ "carglist ::=", |
| 132093 | | - /* 293 */ "ccons ::= NULL onconf", |
| 132094 | | - /* 294 */ "conslist_opt ::= COMMA conslist", |
| 132095 | | - /* 295 */ "conslist ::= conslist tconscomma tcons", |
| 132096 | | - /* 296 */ "conslist ::= tcons", |
| 132097 | | - /* 297 */ "tconscomma ::=", |
| 132098 | | - /* 298 */ "defer_subclause_opt ::= defer_subclause", |
| 132099 | | - /* 299 */ "resolvetype ::= raisetype", |
| 132100 | | - /* 300 */ "selectnowith ::= oneselect", |
| 132101 | | - /* 301 */ "oneselect ::= values", |
| 132102 | | - /* 302 */ "sclp ::= selcollist COMMA", |
| 132103 | | - /* 303 */ "as ::= ID|STRING", |
| 132104 | | - /* 304 */ "expr ::= term", |
| 132105 | | - /* 305 */ "exprlist ::= nexprlist", |
| 132106 | | - /* 306 */ "nmnum ::= plus_num", |
| 132107 | | - /* 307 */ "nmnum ::= nm", |
| 132108 | | - /* 308 */ "nmnum ::= ON", |
| 132109 | | - /* 309 */ "nmnum ::= DELETE", |
| 132110 | | - /* 310 */ "nmnum ::= DEFAULT", |
| 132111 | | - /* 311 */ "plus_num ::= INTEGER|FLOAT", |
| 132112 | | - /* 312 */ "foreach_clause ::=", |
| 132113 | | - /* 313 */ "foreach_clause ::= FOR EACH ROW", |
| 132114 | | - /* 314 */ "trnm ::= nm", |
| 132115 | | - /* 315 */ "tridxby ::=", |
| 132116 | | - /* 316 */ "database_kw_opt ::= DATABASE", |
| 132117 | | - /* 317 */ "database_kw_opt ::=", |
| 132118 | | - /* 318 */ "kwcolumn_opt ::=", |
| 132119 | | - /* 319 */ "kwcolumn_opt ::= COLUMNKW", |
| 132120 | | - /* 320 */ "vtabarglist ::= vtabarg", |
| 132121 | | - /* 321 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 132122 | | - /* 322 */ "vtabarg ::= vtabarg vtabargtoken", |
| 132123 | | - /* 323 */ "anylist ::=", |
| 132124 | | - /* 324 */ "anylist ::= anylist LP anylist RP", |
| 132125 | | - /* 325 */ "anylist ::= anylist ANY", |
| 132823 | + /* 202 */ "paren_exprlist ::=", |
| 132824 | + /* 203 */ "paren_exprlist ::= LP exprlist RP", |
| 132825 | + /* 204 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 132826 | + /* 205 */ "uniqueflag ::= UNIQUE", |
| 132827 | + /* 206 */ "uniqueflag ::=", |
| 132828 | + /* 207 */ "eidlist_opt ::=", |
| 132829 | + /* 208 */ "eidlist_opt ::= LP eidlist RP", |
| 132830 | + /* 209 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 132831 | + /* 210 */ "eidlist ::= nm collate sortorder", |
| 132832 | + /* 211 */ "collate ::=", |
| 132833 | + /* 212 */ "collate ::= COLLATE ID|STRING", |
| 132834 | + /* 213 */ "cmd ::= DROP INDEX ifexists fullname", |
| 132835 | + /* 214 */ "cmd ::= VACUUM", |
| 132836 | + /* 215 */ "cmd ::= VACUUM nm", |
| 132837 | + /* 216 */ "cmd ::= PRAGMA nm dbnm", |
| 132838 | + /* 217 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 132839 | + /* 218 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 132840 | + /* 219 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 132841 | + /* 220 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 132842 | + /* 221 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 132843 | + /* 222 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 132844 | + /* 223 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 132845 | + /* 224 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 132846 | + /* 225 */ "trigger_time ::= BEFORE", |
| 132847 | + /* 226 */ "trigger_time ::= AFTER", |
| 132848 | + /* 227 */ "trigger_time ::= INSTEAD OF", |
| 132849 | + /* 228 */ "trigger_time ::=", |
| 132850 | + /* 229 */ "trigger_event ::= DELETE|INSERT", |
| 132851 | + /* 230 */ "trigger_event ::= UPDATE", |
| 132852 | + /* 231 */ "trigger_event ::= UPDATE OF idlist", |
| 132853 | + /* 232 */ "when_clause ::=", |
| 132854 | + /* 233 */ "when_clause ::= WHEN expr", |
| 132855 | + /* 234 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 132856 | + /* 235 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 132857 | + /* 236 */ "trnm ::= nm DOT nm", |
| 132858 | + /* 237 */ "tridxby ::= INDEXED BY nm", |
| 132859 | + /* 238 */ "tridxby ::= NOT INDEXED", |
| 132860 | + /* 239 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 132861 | + /* 240 */ "trigger_cmd ::= insert_cmd INTO trnm idlist_opt select", |
| 132862 | + /* 241 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 132863 | + /* 242 */ "trigger_cmd ::= select", |
| 132864 | + /* 243 */ "expr ::= RAISE LP IGNORE RP", |
| 132865 | + /* 244 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 132866 | + /* 245 */ "raisetype ::= ROLLBACK", |
| 132867 | + /* 246 */ "raisetype ::= ABORT", |
| 132868 | + /* 247 */ "raisetype ::= FAIL", |
| 132869 | + /* 248 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 132870 | + /* 249 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 132871 | + /* 250 */ "cmd ::= DETACH database_kw_opt expr", |
| 132872 | + /* 251 */ "key_opt ::=", |
| 132873 | + /* 252 */ "key_opt ::= KEY expr", |
| 132874 | + /* 253 */ "cmd ::= REINDEX", |
| 132875 | + /* 254 */ "cmd ::= REINDEX nm dbnm", |
| 132876 | + /* 255 */ "cmd ::= ANALYZE", |
| 132877 | + /* 256 */ "cmd ::= ANALYZE nm dbnm", |
| 132878 | + /* 257 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 132879 | + /* 258 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 132880 | + /* 259 */ "add_column_fullname ::= fullname", |
| 132881 | + /* 260 */ "cmd ::= create_vtab", |
| 132882 | + /* 261 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 132883 | + /* 262 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 132884 | + /* 263 */ "vtabarg ::=", |
| 132885 | + /* 264 */ "vtabargtoken ::= ANY", |
| 132886 | + /* 265 */ "vtabargtoken ::= lp anylist RP", |
| 132887 | + /* 266 */ "lp ::= LP", |
| 132888 | + /* 267 */ "with ::=", |
| 132889 | + /* 268 */ "with ::= WITH wqlist", |
| 132890 | + /* 269 */ "with ::= WITH RECURSIVE wqlist", |
| 132891 | + /* 270 */ "wqlist ::= nm eidlist_opt AS LP select RP", |
| 132892 | + /* 271 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP", |
| 132893 | + /* 272 */ "input ::= cmdlist", |
| 132894 | + /* 273 */ "cmdlist ::= cmdlist ecmd", |
| 132895 | + /* 274 */ "cmdlist ::= ecmd", |
| 132896 | + /* 275 */ "ecmd ::= SEMI", |
| 132897 | + /* 276 */ "ecmd ::= explain cmdx SEMI", |
| 132898 | + /* 277 */ "explain ::=", |
| 132899 | + /* 278 */ "trans_opt ::=", |
| 132900 | + /* 279 */ "trans_opt ::= TRANSACTION", |
| 132901 | + /* 280 */ "trans_opt ::= TRANSACTION nm", |
| 132902 | + /* 281 */ "savepoint_opt ::= SAVEPOINT", |
| 132903 | + /* 282 */ "savepoint_opt ::=", |
| 132904 | + /* 283 */ "cmd ::= create_table create_table_args", |
| 132905 | + /* 284 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 132906 | + /* 285 */ "columnlist ::= columnname carglist", |
| 132907 | + /* 286 */ "nm ::= ID|INDEXED", |
| 132908 | + /* 287 */ "nm ::= STRING", |
| 132909 | + /* 288 */ "nm ::= JOIN_KW", |
| 132910 | + /* 289 */ "typetoken ::= typename", |
| 132911 | + /* 290 */ "typename ::= ID|STRING", |
| 132912 | + /* 291 */ "signed ::= plus_num", |
| 132913 | + /* 292 */ "signed ::= minus_num", |
| 132914 | + /* 293 */ "carglist ::= carglist ccons", |
| 132915 | + /* 294 */ "carglist ::=", |
| 132916 | + /* 295 */ "ccons ::= NULL onconf", |
| 132917 | + /* 296 */ "conslist_opt ::= COMMA conslist", |
| 132918 | + /* 297 */ "conslist ::= conslist tconscomma tcons", |
| 132919 | + /* 298 */ "conslist ::= tcons", |
| 132920 | + /* 299 */ "tconscomma ::=", |
| 132921 | + /* 300 */ "defer_subclause_opt ::= defer_subclause", |
| 132922 | + /* 301 */ "resolvetype ::= raisetype", |
| 132923 | + /* 302 */ "selectnowith ::= oneselect", |
| 132924 | + /* 303 */ "oneselect ::= values", |
| 132925 | + /* 304 */ "sclp ::= selcollist COMMA", |
| 132926 | + /* 305 */ "as ::= ID|STRING", |
| 132927 | + /* 306 */ "expr ::= term", |
| 132928 | + /* 307 */ "exprlist ::= nexprlist", |
| 132929 | + /* 308 */ "nmnum ::= plus_num", |
| 132930 | + /* 309 */ "nmnum ::= nm", |
| 132931 | + /* 310 */ "nmnum ::= ON", |
| 132932 | + /* 311 */ "nmnum ::= DELETE", |
| 132933 | + /* 312 */ "nmnum ::= DEFAULT", |
| 132934 | + /* 313 */ "plus_num ::= INTEGER|FLOAT", |
| 132935 | + /* 314 */ "foreach_clause ::=", |
| 132936 | + /* 315 */ "foreach_clause ::= FOR EACH ROW", |
| 132937 | + /* 316 */ "trnm ::= nm", |
| 132938 | + /* 317 */ "tridxby ::=", |
| 132939 | + /* 318 */ "database_kw_opt ::= DATABASE", |
| 132940 | + /* 319 */ "database_kw_opt ::=", |
| 132941 | + /* 320 */ "kwcolumn_opt ::=", |
| 132942 | + /* 321 */ "kwcolumn_opt ::= COLUMNKW", |
| 132943 | + /* 322 */ "vtabarglist ::= vtabarg", |
| 132944 | + /* 323 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 132945 | + /* 324 */ "vtabarg ::= vtabarg vtabargtoken", |
| 132946 | + /* 325 */ "anylist ::=", |
| 132947 | + /* 326 */ "anylist ::= anylist LP anylist RP", |
| 132948 | + /* 327 */ "anylist ::= anylist ANY", |
| 132126 | 132949 | }; |
| 132127 | 132950 | #endif /* NDEBUG */ |
| 132128 | 132951 | |
| 132129 | 132952 | |
| 132130 | 132953 | #if YYSTACKDEPTH<=0 |
| 132131 | 132954 | /* |
| 132132 | | -** Try to increase the size of the parser stack. |
| 132955 | +** Try to increase the size of the parser stack. Return the number |
| 132956 | +** of errors. Return 0 on success. |
| 132133 | 132957 | */ |
| 132134 | | -static void yyGrowStack(yyParser *p){ |
| 132958 | +static int yyGrowStack(yyParser *p){ |
| 132135 | 132959 | int newSize; |
| 132960 | + int idx; |
| 132136 | 132961 | yyStackEntry *pNew; |
| 132137 | 132962 | |
| 132138 | 132963 | newSize = p->yystksz*2 + 100; |
| 132139 | | - pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
| 132964 | + idx = p->yytos ? (int)(p->yytos - p->yystack) : 0; |
| 132965 | + if( p->yystack==&p->yystk0 ){ |
| 132966 | + pNew = malloc(newSize*sizeof(pNew[0])); |
| 132967 | + if( pNew ) pNew[0] = p->yystk0; |
| 132968 | + }else{ |
| 132969 | + pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
| 132970 | + } |
| 132140 | 132971 | if( pNew ){ |
| 132141 | 132972 | p->yystack = pNew; |
| 132142 | | - p->yystksz = newSize; |
| 132973 | + p->yytos = &p->yystack[idx]; |
| 132143 | 132974 | #ifndef NDEBUG |
| 132144 | 132975 | if( yyTraceFILE ){ |
| 132145 | | - fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", |
| 132146 | | - yyTracePrompt, p->yystksz); |
| 132976 | + fprintf(yyTraceFILE,"%sStack grows from %d to %d entries.\n", |
| 132977 | + yyTracePrompt, p->yystksz, newSize); |
| 132147 | 132978 | } |
| 132148 | 132979 | #endif |
| 132980 | + p->yystksz = newSize; |
| 132149 | 132981 | } |
| 132982 | + return pNew==0; |
| 132150 | 132983 | } |
| 132151 | 132984 | #endif |
| 132152 | 132985 | |
| 132153 | 132986 | /* Datatype of the argument to the memory allocated passed as the |
| 132154 | 132987 | ** second argument to sqlite3ParserAlloc() below. This can be changed by |
| | @@ -132173,19 +133006,28 @@ |
| 132173 | 133006 | */ |
| 132174 | 133007 | SQLITE_PRIVATE void *sqlite3ParserAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ |
| 132175 | 133008 | yyParser *pParser; |
| 132176 | 133009 | pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); |
| 132177 | 133010 | if( pParser ){ |
| 132178 | | - pParser->yyidx = -1; |
| 132179 | 133011 | #ifdef YYTRACKMAXSTACKDEPTH |
| 132180 | | - pParser->yyidxMax = 0; |
| 133012 | + pParser->yyhwm = 0; |
| 132181 | 133013 | #endif |
| 132182 | 133014 | #if YYSTACKDEPTH<=0 |
| 133015 | + pParser->yytos = NULL; |
| 132183 | 133016 | pParser->yystack = NULL; |
| 132184 | 133017 | pParser->yystksz = 0; |
| 132185 | | - yyGrowStack(pParser); |
| 133018 | + if( yyGrowStack(pParser) ){ |
| 133019 | + pParser->yystack = &pParser->yystk0; |
| 133020 | + pParser->yystksz = 1; |
| 133021 | + } |
| 132186 | 133022 | #endif |
| 133023 | +#ifndef YYNOERRORRECOVERY |
| 133024 | + pParser->yyerrcnt = -1; |
| 133025 | +#endif |
| 133026 | + pParser->yytos = pParser->yystack; |
| 133027 | + pParser->yystack[0].stateno = 0; |
| 133028 | + pParser->yystack[0].major = 0; |
| 132187 | 133029 | } |
| 132188 | 133030 | return pParser; |
| 132189 | 133031 | } |
| 132190 | 133032 | |
| 132191 | 133033 | /* The following function deletes the "minor type" or semantic value |
| | @@ -132216,17 +133058,17 @@ |
| 132216 | 133058 | case 163: /* select */ |
| 132217 | 133059 | case 194: /* selectnowith */ |
| 132218 | 133060 | case 195: /* oneselect */ |
| 132219 | 133061 | case 206: /* values */ |
| 132220 | 133062 | { |
| 132221 | | -sqlite3SelectDelete(pParse->db, (yypminor->yy159)); |
| 133063 | +sqlite3SelectDelete(pParse->db, (yypminor->yy243)); |
| 132222 | 133064 | } |
| 132223 | 133065 | break; |
| 132224 | 133066 | case 172: /* term */ |
| 132225 | 133067 | case 173: /* expr */ |
| 132226 | 133068 | { |
| 132227 | | -sqlite3ExprDelete(pParse->db, (yypminor->yy342).pExpr); |
| 133069 | +sqlite3ExprDelete(pParse->db, (yypminor->yy190).pExpr); |
| 132228 | 133070 | } |
| 132229 | 133071 | break; |
| 132230 | 133072 | case 177: /* eidlist_opt */ |
| 132231 | 133073 | case 186: /* sortlist */ |
| 132232 | 133074 | case 187: /* eidlist */ |
| | @@ -132235,56 +133077,57 @@ |
| 132235 | 133077 | case 204: /* orderby_opt */ |
| 132236 | 133078 | case 207: /* nexprlist */ |
| 132237 | 133079 | case 208: /* exprlist */ |
| 132238 | 133080 | case 209: /* sclp */ |
| 132239 | 133081 | case 218: /* setlist */ |
| 132240 | | - case 225: /* case_exprlist */ |
| 133082 | + case 224: /* paren_exprlist */ |
| 133083 | + case 226: /* case_exprlist */ |
| 132241 | 133084 | { |
| 132242 | | -sqlite3ExprListDelete(pParse->db, (yypminor->yy442)); |
| 133085 | +sqlite3ExprListDelete(pParse->db, (yypminor->yy148)); |
| 132243 | 133086 | } |
| 132244 | 133087 | break; |
| 132245 | 133088 | case 193: /* fullname */ |
| 132246 | 133089 | case 200: /* from */ |
| 132247 | 133090 | case 211: /* seltablist */ |
| 132248 | 133091 | case 212: /* stl_prefix */ |
| 132249 | 133092 | { |
| 132250 | | -sqlite3SrcListDelete(pParse->db, (yypminor->yy347)); |
| 133093 | +sqlite3SrcListDelete(pParse->db, (yypminor->yy185)); |
| 132251 | 133094 | } |
| 132252 | 133095 | break; |
| 132253 | 133096 | case 196: /* with */ |
| 132254 | | - case 249: /* wqlist */ |
| 133097 | + case 250: /* wqlist */ |
| 132255 | 133098 | { |
| 132256 | | -sqlite3WithDelete(pParse->db, (yypminor->yy331)); |
| 133099 | +sqlite3WithDelete(pParse->db, (yypminor->yy285)); |
| 132257 | 133100 | } |
| 132258 | 133101 | break; |
| 132259 | 133102 | case 201: /* where_opt */ |
| 132260 | 133103 | case 203: /* having_opt */ |
| 132261 | 133104 | case 215: /* on_opt */ |
| 132262 | | - case 224: /* case_operand */ |
| 132263 | | - case 226: /* case_else */ |
| 132264 | | - case 235: /* when_clause */ |
| 132265 | | - case 240: /* key_opt */ |
| 133105 | + case 225: /* case_operand */ |
| 133106 | + case 227: /* case_else */ |
| 133107 | + case 236: /* when_clause */ |
| 133108 | + case 241: /* key_opt */ |
| 132266 | 133109 | { |
| 132267 | | -sqlite3ExprDelete(pParse->db, (yypminor->yy122)); |
| 133110 | +sqlite3ExprDelete(pParse->db, (yypminor->yy72)); |
| 132268 | 133111 | } |
| 132269 | 133112 | break; |
| 132270 | 133113 | case 216: /* using_opt */ |
| 132271 | 133114 | case 217: /* idlist */ |
| 132272 | 133115 | case 220: /* idlist_opt */ |
| 132273 | 133116 | { |
| 132274 | | -sqlite3IdListDelete(pParse->db, (yypminor->yy180)); |
| 133117 | +sqlite3IdListDelete(pParse->db, (yypminor->yy254)); |
| 132275 | 133118 | } |
| 132276 | 133119 | break; |
| 132277 | | - case 231: /* trigger_cmd_list */ |
| 132278 | | - case 236: /* trigger_cmd */ |
| 133120 | + case 232: /* trigger_cmd_list */ |
| 133121 | + case 237: /* trigger_cmd */ |
| 132279 | 133122 | { |
| 132280 | | -sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy327)); |
| 133123 | +sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy145)); |
| 132281 | 133124 | } |
| 132282 | 133125 | break; |
| 132283 | | - case 233: /* trigger_event */ |
| 133126 | + case 234: /* trigger_event */ |
| 132284 | 133127 | { |
| 132285 | | -sqlite3IdListDelete(pParse->db, (yypminor->yy410).b); |
| 133128 | +sqlite3IdListDelete(pParse->db, (yypminor->yy332).b); |
| 132286 | 133129 | } |
| 132287 | 133130 | break; |
| 132288 | 133131 | /********* End destructor definitions *****************************************/ |
| 132289 | 133132 | default: break; /* If no destructor action specified: do nothing */ |
| 132290 | 133133 | } |
| | @@ -132296,12 +133139,13 @@ |
| 132296 | 133139 | ** If there is a destructor routine associated with the token which |
| 132297 | 133140 | ** is popped from the stack, then call it. |
| 132298 | 133141 | */ |
| 132299 | 133142 | static void yy_pop_parser_stack(yyParser *pParser){ |
| 132300 | 133143 | yyStackEntry *yytos; |
| 132301 | | - assert( pParser->yyidx>=0 ); |
| 132302 | | - yytos = &pParser->yystack[pParser->yyidx--]; |
| 133144 | + assert( pParser->yytos!=0 ); |
| 133145 | + assert( pParser->yytos > pParser->yystack ); |
| 133146 | + yytos = pParser->yytos--; |
| 132303 | 133147 | #ifndef NDEBUG |
| 132304 | 133148 | if( yyTraceFILE ){ |
| 132305 | 133149 | fprintf(yyTraceFILE,"%sPopping %s\n", |
| 132306 | 133150 | yyTracePrompt, |
| 132307 | 133151 | yyTokenName[yytos->major]); |
| | @@ -132324,13 +133168,13 @@ |
| 132324 | 133168 | ){ |
| 132325 | 133169 | yyParser *pParser = (yyParser*)p; |
| 132326 | 133170 | #ifndef YYPARSEFREENEVERNULL |
| 132327 | 133171 | if( pParser==0 ) return; |
| 132328 | 133172 | #endif |
| 132329 | | - while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); |
| 133173 | + while( pParser->yytos>pParser->yystack ) yy_pop_parser_stack(pParser); |
| 132330 | 133174 | #if YYSTACKDEPTH<=0 |
| 132331 | | - free(pParser->yystack); |
| 133175 | + if( pParser->yystack!=&pParser->yystk0 ) free(pParser->yystack); |
| 132332 | 133176 | #endif |
| 132333 | 133177 | (*freeProc)((void*)pParser); |
| 132334 | 133178 | } |
| 132335 | 133179 | |
| 132336 | 133180 | /* |
| | @@ -132337,11 +133181,11 @@ |
| 132337 | 133181 | ** Return the peak depth of the stack for a parser. |
| 132338 | 133182 | */ |
| 132339 | 133183 | #ifdef YYTRACKMAXSTACKDEPTH |
| 132340 | 133184 | SQLITE_PRIVATE int sqlite3ParserStackPeak(void *p){ |
| 132341 | 133185 | yyParser *pParser = (yyParser*)p; |
| 132342 | | - return pParser->yyidxMax; |
| 133186 | + return pParser->yyhwm; |
| 132343 | 133187 | } |
| 132344 | 133188 | #endif |
| 132345 | 133189 | |
| 132346 | 133190 | /* |
| 132347 | 133191 | ** Find the appropriate action for a parser given the terminal |
| | @@ -132350,11 +133194,11 @@ |
| 132350 | 133194 | static unsigned int yy_find_shift_action( |
| 132351 | 133195 | yyParser *pParser, /* The parser */ |
| 132352 | 133196 | YYCODETYPE iLookAhead /* The look-ahead token */ |
| 132353 | 133197 | ){ |
| 132354 | 133198 | int i; |
| 132355 | | - int stateno = pParser->yystack[pParser->yyidx].stateno; |
| 133199 | + int stateno = pParser->yytos->stateno; |
| 132356 | 133200 | |
| 132357 | 133201 | if( stateno>=YY_MIN_REDUCE ) return stateno; |
| 132358 | 133202 | assert( stateno <= YY_SHIFT_COUNT ); |
| 132359 | 133203 | do{ |
| 132360 | 133204 | i = yy_shift_ofst[stateno]; |
| | @@ -132443,17 +133287,17 @@ |
| 132443 | 133287 | /* |
| 132444 | 133288 | ** The following routine is called if the stack overflows. |
| 132445 | 133289 | */ |
| 132446 | 133290 | static void yyStackOverflow(yyParser *yypParser){ |
| 132447 | 133291 | sqlite3ParserARG_FETCH; |
| 132448 | | - yypParser->yyidx--; |
| 133292 | + yypParser->yytos--; |
| 132449 | 133293 | #ifndef NDEBUG |
| 132450 | 133294 | if( yyTraceFILE ){ |
| 132451 | 133295 | fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); |
| 132452 | 133296 | } |
| 132453 | 133297 | #endif |
| 132454 | | - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 133298 | + while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); |
| 132455 | 133299 | /* Here code is inserted which will execute if the parser |
| 132456 | 133300 | ** stack every overflows */ |
| 132457 | 133301 | /******** Begin %stack_overflow code ******************************************/ |
| 132458 | 133302 | |
| 132459 | 133303 | sqlite3ErrorMsg(pParse, "parser stack overflow"); |
| | @@ -132467,15 +133311,15 @@ |
| 132467 | 133311 | #ifndef NDEBUG |
| 132468 | 133312 | static void yyTraceShift(yyParser *yypParser, int yyNewState){ |
| 132469 | 133313 | if( yyTraceFILE ){ |
| 132470 | 133314 | if( yyNewState<YYNSTATE ){ |
| 132471 | 133315 | fprintf(yyTraceFILE,"%sShift '%s', go to state %d\n", |
| 132472 | | - yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major], |
| 133316 | + yyTracePrompt,yyTokenName[yypParser->yytos->major], |
| 132473 | 133317 | yyNewState); |
| 132474 | 133318 | }else{ |
| 132475 | 133319 | fprintf(yyTraceFILE,"%sShift '%s'\n", |
| 132476 | | - yyTracePrompt,yyTokenName[yypParser->yystack[yypParser->yyidx].major]); |
| 133320 | + yyTracePrompt,yyTokenName[yypParser->yytos->major]); |
| 132477 | 133321 | } |
| 132478 | 133322 | } |
| 132479 | 133323 | } |
| 132480 | 133324 | #else |
| 132481 | 133325 | # define yyTraceShift(X,Y) |
| | @@ -132489,31 +133333,34 @@ |
| 132489 | 133333 | int yyNewState, /* The new state to shift in */ |
| 132490 | 133334 | int yyMajor, /* The major token to shift in */ |
| 132491 | 133335 | sqlite3ParserTOKENTYPE yyMinor /* The minor token to shift in */ |
| 132492 | 133336 | ){ |
| 132493 | 133337 | yyStackEntry *yytos; |
| 132494 | | - yypParser->yyidx++; |
| 133338 | + yypParser->yytos++; |
| 132495 | 133339 | #ifdef YYTRACKMAXSTACKDEPTH |
| 132496 | | - if( yypParser->yyidx>yypParser->yyidxMax ){ |
| 132497 | | - yypParser->yyidxMax = yypParser->yyidx; |
| 133340 | + if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ |
| 133341 | + yypParser->yyhwm++; |
| 133342 | + assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack) ); |
| 132498 | 133343 | } |
| 132499 | 133344 | #endif |
| 132500 | 133345 | #if YYSTACKDEPTH>0 |
| 132501 | | - if( yypParser->yyidx>=YYSTACKDEPTH ){ |
| 133346 | + if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){ |
| 132502 | 133347 | yyStackOverflow(yypParser); |
| 132503 | 133348 | return; |
| 132504 | 133349 | } |
| 132505 | 133350 | #else |
| 132506 | | - if( yypParser->yyidx>=yypParser->yystksz ){ |
| 132507 | | - yyGrowStack(yypParser); |
| 132508 | | - if( yypParser->yyidx>=yypParser->yystksz ){ |
| 133351 | + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz] ){ |
| 133352 | + if( yyGrowStack(yypParser) ){ |
| 132509 | 133353 | yyStackOverflow(yypParser); |
| 132510 | 133354 | return; |
| 132511 | 133355 | } |
| 132512 | 133356 | } |
| 132513 | 133357 | #endif |
| 132514 | | - yytos = &yypParser->yystack[yypParser->yyidx]; |
| 133358 | + if( yyNewState > YY_MAX_SHIFT ){ |
| 133359 | + yyNewState += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 133360 | + } |
| 133361 | + yytos = yypParser->yytos; |
| 132515 | 133362 | yytos->stateno = (YYACTIONTYPE)yyNewState; |
| 132516 | 133363 | yytos->major = (YYCODETYPE)yyMajor; |
| 132517 | 133364 | yytos->minor.yy0 = yyMinor; |
| 132518 | 133365 | yyTraceShift(yypParser, yyNewState); |
| 132519 | 133366 | } |
| | @@ -132713,31 +133560,33 @@ |
| 132713 | 133560 | { 223, 1 }, |
| 132714 | 133561 | { 223, 2 }, |
| 132715 | 133562 | { 173, 5 }, |
| 132716 | 133563 | { 173, 3 }, |
| 132717 | 133564 | { 173, 5 }, |
| 132718 | | - { 173, 4 }, |
| 133565 | + { 173, 5 }, |
| 132719 | 133566 | { 173, 4 }, |
| 132720 | 133567 | { 173, 5 }, |
| 132721 | | - { 225, 5 }, |
| 132722 | | - { 225, 4 }, |
| 132723 | | - { 226, 2 }, |
| 132724 | | - { 226, 0 }, |
| 132725 | | - { 224, 1 }, |
| 132726 | | - { 224, 0 }, |
| 133568 | + { 226, 5 }, |
| 133569 | + { 226, 4 }, |
| 133570 | + { 227, 2 }, |
| 133571 | + { 227, 0 }, |
| 133572 | + { 225, 1 }, |
| 133573 | + { 225, 0 }, |
| 132727 | 133574 | { 208, 0 }, |
| 132728 | 133575 | { 207, 3 }, |
| 132729 | 133576 | { 207, 1 }, |
| 133577 | + { 224, 0 }, |
| 133578 | + { 224, 3 }, |
| 132730 | 133579 | { 149, 12 }, |
| 132731 | | - { 227, 1 }, |
| 132732 | | - { 227, 0 }, |
| 133580 | + { 228, 1 }, |
| 133581 | + { 228, 0 }, |
| 132733 | 133582 | { 177, 0 }, |
| 132734 | 133583 | { 177, 3 }, |
| 132735 | 133584 | { 187, 5 }, |
| 132736 | 133585 | { 187, 3 }, |
| 132737 | | - { 228, 0 }, |
| 132738 | | - { 228, 2 }, |
| 133586 | + { 229, 0 }, |
| 133587 | + { 229, 2 }, |
| 132739 | 133588 | { 149, 4 }, |
| 132740 | 133589 | { 149, 1 }, |
| 132741 | 133590 | { 149, 2 }, |
| 132742 | 133591 | { 149, 3 }, |
| 132743 | 133592 | { 149, 5 }, |
| | @@ -132745,58 +133594,58 @@ |
| 132745 | 133594 | { 149, 5 }, |
| 132746 | 133595 | { 149, 6 }, |
| 132747 | 133596 | { 169, 2 }, |
| 132748 | 133597 | { 170, 2 }, |
| 132749 | 133598 | { 149, 5 }, |
| 132750 | | - { 230, 11 }, |
| 132751 | | - { 232, 1 }, |
| 132752 | | - { 232, 1 }, |
| 132753 | | - { 232, 2 }, |
| 132754 | | - { 232, 0 }, |
| 133599 | + { 231, 11 }, |
| 132755 | 133600 | { 233, 1 }, |
| 132756 | 133601 | { 233, 1 }, |
| 132757 | | - { 233, 3 }, |
| 132758 | | - { 235, 0 }, |
| 132759 | | - { 235, 2 }, |
| 132760 | | - { 231, 3 }, |
| 132761 | | - { 231, 2 }, |
| 132762 | | - { 237, 3 }, |
| 133602 | + { 233, 2 }, |
| 133603 | + { 233, 0 }, |
| 133604 | + { 234, 1 }, |
| 133605 | + { 234, 1 }, |
| 133606 | + { 234, 3 }, |
| 133607 | + { 236, 0 }, |
| 133608 | + { 236, 2 }, |
| 133609 | + { 232, 3 }, |
| 133610 | + { 232, 2 }, |
| 132763 | 133611 | { 238, 3 }, |
| 132764 | | - { 238, 2 }, |
| 132765 | | - { 236, 7 }, |
| 132766 | | - { 236, 5 }, |
| 132767 | | - { 236, 5 }, |
| 132768 | | - { 236, 1 }, |
| 133612 | + { 239, 3 }, |
| 133613 | + { 239, 2 }, |
| 133614 | + { 237, 7 }, |
| 133615 | + { 237, 5 }, |
| 133616 | + { 237, 5 }, |
| 133617 | + { 237, 1 }, |
| 132769 | 133618 | { 173, 4 }, |
| 132770 | 133619 | { 173, 6 }, |
| 132771 | 133620 | { 191, 1 }, |
| 132772 | 133621 | { 191, 1 }, |
| 132773 | 133622 | { 191, 1 }, |
| 132774 | 133623 | { 149, 4 }, |
| 132775 | 133624 | { 149, 6 }, |
| 132776 | 133625 | { 149, 3 }, |
| 132777 | | - { 240, 0 }, |
| 132778 | | - { 240, 2 }, |
| 133626 | + { 241, 0 }, |
| 133627 | + { 241, 2 }, |
| 132779 | 133628 | { 149, 1 }, |
| 132780 | 133629 | { 149, 3 }, |
| 132781 | 133630 | { 149, 1 }, |
| 132782 | 133631 | { 149, 3 }, |
| 132783 | 133632 | { 149, 6 }, |
| 132784 | 133633 | { 149, 7 }, |
| 132785 | | - { 241, 1 }, |
| 133634 | + { 242, 1 }, |
| 132786 | 133635 | { 149, 1 }, |
| 132787 | 133636 | { 149, 4 }, |
| 132788 | | - { 243, 8 }, |
| 132789 | | - { 245, 0 }, |
| 132790 | | - { 246, 1 }, |
| 132791 | | - { 246, 3 }, |
| 133637 | + { 244, 8 }, |
| 133638 | + { 246, 0 }, |
| 132792 | 133639 | { 247, 1 }, |
| 133640 | + { 247, 3 }, |
| 133641 | + { 248, 1 }, |
| 132793 | 133642 | { 196, 0 }, |
| 132794 | 133643 | { 196, 2 }, |
| 132795 | 133644 | { 196, 3 }, |
| 132796 | | - { 249, 6 }, |
| 132797 | | - { 249, 8 }, |
| 133645 | + { 250, 6 }, |
| 133646 | + { 250, 8 }, |
| 132798 | 133647 | { 144, 1 }, |
| 132799 | 133648 | { 145, 2 }, |
| 132800 | 133649 | { 145, 1 }, |
| 132801 | 133650 | { 146, 1 }, |
| 132802 | 133651 | { 146, 3 }, |
| | @@ -132829,30 +133678,30 @@ |
| 132829 | 133678 | { 195, 1 }, |
| 132830 | 133679 | { 209, 2 }, |
| 132831 | 133680 | { 210, 1 }, |
| 132832 | 133681 | { 173, 1 }, |
| 132833 | 133682 | { 208, 1 }, |
| 132834 | | - { 229, 1 }, |
| 132835 | | - { 229, 1 }, |
| 132836 | | - { 229, 1 }, |
| 132837 | | - { 229, 1 }, |
| 132838 | | - { 229, 1 }, |
| 133683 | + { 230, 1 }, |
| 133684 | + { 230, 1 }, |
| 133685 | + { 230, 1 }, |
| 133686 | + { 230, 1 }, |
| 133687 | + { 230, 1 }, |
| 132839 | 133688 | { 169, 1 }, |
| 132840 | | - { 234, 0 }, |
| 132841 | | - { 234, 3 }, |
| 132842 | | - { 237, 1 }, |
| 132843 | | - { 238, 0 }, |
| 132844 | | - { 239, 1 }, |
| 133689 | + { 235, 0 }, |
| 133690 | + { 235, 3 }, |
| 133691 | + { 238, 1 }, |
| 132845 | 133692 | { 239, 0 }, |
| 132846 | | - { 242, 0 }, |
| 132847 | | - { 242, 1 }, |
| 132848 | | - { 244, 1 }, |
| 132849 | | - { 244, 3 }, |
| 132850 | | - { 245, 2 }, |
| 132851 | | - { 248, 0 }, |
| 132852 | | - { 248, 4 }, |
| 132853 | | - { 248, 2 }, |
| 133693 | + { 240, 1 }, |
| 133694 | + { 240, 0 }, |
| 133695 | + { 243, 0 }, |
| 133696 | + { 243, 1 }, |
| 133697 | + { 245, 1 }, |
| 133698 | + { 245, 3 }, |
| 133699 | + { 246, 2 }, |
| 133700 | + { 249, 0 }, |
| 133701 | + { 249, 4 }, |
| 133702 | + { 249, 2 }, |
| 132854 | 133703 | }; |
| 132855 | 133704 | |
| 132856 | 133705 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| 132857 | 133706 | |
| 132858 | 133707 | /* |
| | @@ -132866,11 +133715,11 @@ |
| 132866 | 133715 | int yygoto; /* The next state */ |
| 132867 | 133716 | int yyact; /* The next action */ |
| 132868 | 133717 | yyStackEntry *yymsp; /* The top of the parser's stack */ |
| 132869 | 133718 | int yysize; /* Amount to pop the stack */ |
| 132870 | 133719 | sqlite3ParserARG_FETCH; |
| 132871 | | - yymsp = &yypParser->yystack[yypParser->yyidx]; |
| 133720 | + yymsp = yypParser->yytos; |
| 132872 | 133721 | #ifndef NDEBUG |
| 132873 | 133722 | if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
| 132874 | 133723 | yysize = yyRuleInfo[yyruleno].nrhs; |
| 132875 | 133724 | fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt, |
| 132876 | 133725 | yyRuleName[yyruleno], yymsp[-yysize].stateno); |
| | @@ -132880,26 +133729,27 @@ |
| 132880 | 133729 | /* Check that the stack is large enough to grow by a single entry |
| 132881 | 133730 | ** if the RHS of the rule is empty. This ensures that there is room |
| 132882 | 133731 | ** enough on the stack to push the LHS value */ |
| 132883 | 133732 | if( yyRuleInfo[yyruleno].nrhs==0 ){ |
| 132884 | 133733 | #ifdef YYTRACKMAXSTACKDEPTH |
| 132885 | | - if( yypParser->yyidx>yypParser->yyidxMax ){ |
| 132886 | | - yypParser->yyidxMax = yypParser->yyidx; |
| 133734 | + if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){ |
| 133735 | + yypParser->yyhwm++; |
| 133736 | + assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); |
| 132887 | 133737 | } |
| 132888 | 133738 | #endif |
| 132889 | 133739 | #if YYSTACKDEPTH>0 |
| 132890 | | - if( yypParser->yyidx>=YYSTACKDEPTH-1 ){ |
| 133740 | + if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){ |
| 132891 | 133741 | yyStackOverflow(yypParser); |
| 132892 | 133742 | return; |
| 132893 | 133743 | } |
| 132894 | 133744 | #else |
| 132895 | | - if( yypParser->yyidx>=yypParser->yystksz-1 ){ |
| 132896 | | - yyGrowStack(yypParser); |
| 132897 | | - if( yypParser->yyidx>=yypParser->yystksz-1 ){ |
| 133745 | + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ |
| 133746 | + if( yyGrowStack(yypParser) ){ |
| 132898 | 133747 | yyStackOverflow(yypParser); |
| 132899 | 133748 | return; |
| 132900 | 133749 | } |
| 133750 | + yymsp = yypParser->yytos; |
| 132901 | 133751 | } |
| 132902 | 133752 | #endif |
| 132903 | 133753 | } |
| 132904 | 133754 | |
| 132905 | 133755 | switch( yyruleno ){ |
| | @@ -132921,19 +133771,19 @@ |
| 132921 | 133771 | break; |
| 132922 | 133772 | case 2: /* cmdx ::= cmd */ |
| 132923 | 133773 | { sqlite3FinishCoding(pParse); } |
| 132924 | 133774 | break; |
| 132925 | 133775 | case 3: /* cmd ::= BEGIN transtype trans_opt */ |
| 132926 | | -{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy392);} |
| 133776 | +{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy194);} |
| 132927 | 133777 | break; |
| 132928 | 133778 | case 4: /* transtype ::= */ |
| 132929 | | -{yymsp[1].minor.yy392 = TK_DEFERRED;} |
| 133779 | +{yymsp[1].minor.yy194 = TK_DEFERRED;} |
| 132930 | 133780 | break; |
| 132931 | 133781 | case 5: /* transtype ::= DEFERRED */ |
| 132932 | 133782 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 132933 | 133783 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 132934 | | -{yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-X*/} |
| 133784 | +{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-X*/} |
| 132935 | 133785 | break; |
| 132936 | 133786 | case 8: /* cmd ::= COMMIT trans_opt */ |
| 132937 | 133787 | case 9: /* cmd ::= END trans_opt */ yytestcase(yyruleno==9); |
| 132938 | 133788 | {sqlite3CommitTransaction(pParse);} |
| 132939 | 133789 | break; |
| | @@ -132955,11 +133805,11 @@ |
| 132955 | 133805 | sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); |
| 132956 | 133806 | } |
| 132957 | 133807 | break; |
| 132958 | 133808 | case 14: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 132959 | 133809 | { |
| 132960 | | - sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy392,0,0,yymsp[-2].minor.yy392); |
| 133810 | + sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy194,0,0,yymsp[-2].minor.yy194); |
| 132961 | 133811 | } |
| 132962 | 133812 | break; |
| 132963 | 133813 | case 15: /* createkw ::= CREATE */ |
| 132964 | 133814 | {disableLookaside(pParse);} |
| 132965 | 133815 | break; |
| | @@ -132969,37 +133819,37 @@ |
| 132969 | 133819 | case 42: /* autoinc ::= */ yytestcase(yyruleno==42); |
| 132970 | 133820 | case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57); |
| 132971 | 133821 | case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67); |
| 132972 | 133822 | case 76: /* ifexists ::= */ yytestcase(yyruleno==76); |
| 132973 | 133823 | case 90: /* distinct ::= */ yytestcase(yyruleno==90); |
| 132974 | | - case 209: /* collate ::= */ yytestcase(yyruleno==209); |
| 132975 | | -{yymsp[1].minor.yy392 = 0;} |
| 133824 | + case 211: /* collate ::= */ yytestcase(yyruleno==211); |
| 133825 | +{yymsp[1].minor.yy194 = 0;} |
| 132976 | 133826 | break; |
| 132977 | 133827 | case 17: /* ifnotexists ::= IF NOT EXISTS */ |
| 132978 | | -{yymsp[-2].minor.yy392 = 1;} |
| 133828 | +{yymsp[-2].minor.yy194 = 1;} |
| 132979 | 133829 | break; |
| 132980 | 133830 | case 18: /* temp ::= TEMP */ |
| 132981 | 133831 | case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43); |
| 132982 | | -{yymsp[0].minor.yy392 = 1;} |
| 133832 | +{yymsp[0].minor.yy194 = 1;} |
| 132983 | 133833 | break; |
| 132984 | 133834 | case 20: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ |
| 132985 | 133835 | { |
| 132986 | | - sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy392,0); |
| 133836 | + sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy194,0); |
| 132987 | 133837 | } |
| 132988 | 133838 | break; |
| 132989 | 133839 | case 21: /* create_table_args ::= AS select */ |
| 132990 | 133840 | { |
| 132991 | | - sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy159); |
| 132992 | | - sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159); |
| 133841 | + sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy243); |
| 133842 | + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243); |
| 132993 | 133843 | } |
| 132994 | 133844 | break; |
| 132995 | 133845 | case 23: /* table_options ::= WITHOUT nm */ |
| 132996 | 133846 | { |
| 132997 | 133847 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ |
| 132998 | | - yymsp[-1].minor.yy392 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 133848 | + yymsp[-1].minor.yy194 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 132999 | 133849 | }else{ |
| 133000 | | - yymsp[-1].minor.yy392 = 0; |
| 133850 | + yymsp[-1].minor.yy194 = 0; |
| 133001 | 133851 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 133002 | 133852 | } |
| 133003 | 133853 | } |
| 133004 | 133854 | break; |
| 133005 | 133855 | case 24: /* columnname ::= nm typetoken */ |
| | @@ -133027,21 +133877,21 @@ |
| 133027 | 133877 | case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62); |
| 133028 | 133878 | {pParse->constraintName = yymsp[0].minor.yy0;} |
| 133029 | 133879 | break; |
| 133030 | 133880 | case 30: /* ccons ::= DEFAULT term */ |
| 133031 | 133881 | case 32: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==32); |
| 133032 | | -{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);} |
| 133882 | +{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy190);} |
| 133033 | 133883 | break; |
| 133034 | 133884 | case 31: /* ccons ::= DEFAULT LP expr RP */ |
| 133035 | | -{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy342);} |
| 133885 | +{sqlite3AddDefaultValue(pParse,&yymsp[-1].minor.yy190);} |
| 133036 | 133886 | break; |
| 133037 | 133887 | case 33: /* ccons ::= DEFAULT MINUS term */ |
| 133038 | 133888 | { |
| 133039 | 133889 | ExprSpan v; |
| 133040 | | - v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy342.pExpr, 0, 0); |
| 133890 | + v.pExpr = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy190.pExpr, 0, 0); |
| 133041 | 133891 | v.zStart = yymsp[-1].minor.yy0.z; |
| 133042 | | - v.zEnd = yymsp[0].minor.yy342.zEnd; |
| 133892 | + v.zEnd = yymsp[0].minor.yy190.zEnd; |
| 133043 | 133893 | sqlite3AddDefaultValue(pParse,&v); |
| 133044 | 133894 | } |
| 133045 | 133895 | break; |
| 133046 | 133896 | case 34: /* ccons ::= DEFAULT ID|INDEXED */ |
| 133047 | 133897 | { |
| | @@ -133049,184 +133899,186 @@ |
| 133049 | 133899 | spanExpr(&v, pParse, TK_STRING, yymsp[0].minor.yy0); |
| 133050 | 133900 | sqlite3AddDefaultValue(pParse,&v); |
| 133051 | 133901 | } |
| 133052 | 133902 | break; |
| 133053 | 133903 | case 35: /* ccons ::= NOT NULL onconf */ |
| 133054 | | -{sqlite3AddNotNull(pParse, yymsp[0].minor.yy392);} |
| 133904 | +{sqlite3AddNotNull(pParse, yymsp[0].minor.yy194);} |
| 133055 | 133905 | break; |
| 133056 | 133906 | case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 133057 | | -{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy392,yymsp[0].minor.yy392,yymsp[-2].minor.yy392);} |
| 133907 | +{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy194,yymsp[0].minor.yy194,yymsp[-2].minor.yy194);} |
| 133058 | 133908 | break; |
| 133059 | 133909 | case 37: /* ccons ::= UNIQUE onconf */ |
| 133060 | | -{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy392,0,0,0,0);} |
| 133910 | +{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy194,0,0,0,0, |
| 133911 | + SQLITE_IDXTYPE_UNIQUE);} |
| 133061 | 133912 | break; |
| 133062 | 133913 | case 38: /* ccons ::= CHECK LP expr RP */ |
| 133063 | | -{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy342.pExpr);} |
| 133914 | +{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy190.pExpr);} |
| 133064 | 133915 | break; |
| 133065 | 133916 | case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 133066 | | -{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy442,yymsp[0].minor.yy392);} |
| 133917 | +{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy148,yymsp[0].minor.yy194);} |
| 133067 | 133918 | break; |
| 133068 | 133919 | case 40: /* ccons ::= defer_subclause */ |
| 133069 | | -{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy392);} |
| 133920 | +{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy194);} |
| 133070 | 133921 | break; |
| 133071 | 133922 | case 41: /* ccons ::= COLLATE ID|STRING */ |
| 133072 | 133923 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 133073 | 133924 | break; |
| 133074 | 133925 | case 44: /* refargs ::= */ |
| 133075 | | -{ yymsp[1].minor.yy392 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 133926 | +{ yymsp[1].minor.yy194 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 133076 | 133927 | break; |
| 133077 | 133928 | case 45: /* refargs ::= refargs refarg */ |
| 133078 | | -{ yymsp[-1].minor.yy392 = (yymsp[-1].minor.yy392 & ~yymsp[0].minor.yy207.mask) | yymsp[0].minor.yy207.value; } |
| 133929 | +{ yymsp[-1].minor.yy194 = (yymsp[-1].minor.yy194 & ~yymsp[0].minor.yy497.mask) | yymsp[0].minor.yy497.value; } |
| 133079 | 133930 | break; |
| 133080 | 133931 | case 46: /* refarg ::= MATCH nm */ |
| 133081 | | -{ yymsp[-1].minor.yy207.value = 0; yymsp[-1].minor.yy207.mask = 0x000000; } |
| 133932 | +{ yymsp[-1].minor.yy497.value = 0; yymsp[-1].minor.yy497.mask = 0x000000; } |
| 133082 | 133933 | break; |
| 133083 | 133934 | case 47: /* refarg ::= ON INSERT refact */ |
| 133084 | | -{ yymsp[-2].minor.yy207.value = 0; yymsp[-2].minor.yy207.mask = 0x000000; } |
| 133935 | +{ yymsp[-2].minor.yy497.value = 0; yymsp[-2].minor.yy497.mask = 0x000000; } |
| 133085 | 133936 | break; |
| 133086 | 133937 | case 48: /* refarg ::= ON DELETE refact */ |
| 133087 | | -{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392; yymsp[-2].minor.yy207.mask = 0x0000ff; } |
| 133938 | +{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194; yymsp[-2].minor.yy497.mask = 0x0000ff; } |
| 133088 | 133939 | break; |
| 133089 | 133940 | case 49: /* refarg ::= ON UPDATE refact */ |
| 133090 | | -{ yymsp[-2].minor.yy207.value = yymsp[0].minor.yy392<<8; yymsp[-2].minor.yy207.mask = 0x00ff00; } |
| 133941 | +{ yymsp[-2].minor.yy497.value = yymsp[0].minor.yy194<<8; yymsp[-2].minor.yy497.mask = 0x00ff00; } |
| 133091 | 133942 | break; |
| 133092 | 133943 | case 50: /* refact ::= SET NULL */ |
| 133093 | | -{ yymsp[-1].minor.yy392 = OE_SetNull; /* EV: R-33326-45252 */} |
| 133944 | +{ yymsp[-1].minor.yy194 = OE_SetNull; /* EV: R-33326-45252 */} |
| 133094 | 133945 | break; |
| 133095 | 133946 | case 51: /* refact ::= SET DEFAULT */ |
| 133096 | | -{ yymsp[-1].minor.yy392 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 133947 | +{ yymsp[-1].minor.yy194 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 133097 | 133948 | break; |
| 133098 | 133949 | case 52: /* refact ::= CASCADE */ |
| 133099 | | -{ yymsp[0].minor.yy392 = OE_Cascade; /* EV: R-33326-45252 */} |
| 133950 | +{ yymsp[0].minor.yy194 = OE_Cascade; /* EV: R-33326-45252 */} |
| 133100 | 133951 | break; |
| 133101 | 133952 | case 53: /* refact ::= RESTRICT */ |
| 133102 | | -{ yymsp[0].minor.yy392 = OE_Restrict; /* EV: R-33326-45252 */} |
| 133953 | +{ yymsp[0].minor.yy194 = OE_Restrict; /* EV: R-33326-45252 */} |
| 133103 | 133954 | break; |
| 133104 | 133955 | case 54: /* refact ::= NO ACTION */ |
| 133105 | | -{ yymsp[-1].minor.yy392 = OE_None; /* EV: R-33326-45252 */} |
| 133956 | +{ yymsp[-1].minor.yy194 = OE_None; /* EV: R-33326-45252 */} |
| 133106 | 133957 | break; |
| 133107 | 133958 | case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 133108 | | -{yymsp[-2].minor.yy392 = 0;} |
| 133959 | +{yymsp[-2].minor.yy194 = 0;} |
| 133109 | 133960 | break; |
| 133110 | 133961 | case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 133111 | 133962 | case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71); |
| 133112 | 133963 | case 142: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==142); |
| 133113 | | -{yymsp[-1].minor.yy392 = yymsp[0].minor.yy392;} |
| 133964 | +{yymsp[-1].minor.yy194 = yymsp[0].minor.yy194;} |
| 133114 | 133965 | break; |
| 133115 | 133966 | case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 133116 | 133967 | case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75); |
| 133117 | 133968 | case 183: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==183); |
| 133118 | 133969 | case 186: /* in_op ::= NOT IN */ yytestcase(yyruleno==186); |
| 133119 | | - case 210: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==210); |
| 133120 | | -{yymsp[-1].minor.yy392 = 1;} |
| 133970 | + case 212: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==212); |
| 133971 | +{yymsp[-1].minor.yy194 = 1;} |
| 133121 | 133972 | break; |
| 133122 | 133973 | case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 133123 | | -{yymsp[-1].minor.yy392 = 0;} |
| 133974 | +{yymsp[-1].minor.yy194 = 0;} |
| 133124 | 133975 | break; |
| 133125 | 133976 | case 61: /* tconscomma ::= COMMA */ |
| 133126 | 133977 | {pParse->constraintName.n = 0;} |
| 133127 | 133978 | break; |
| 133128 | 133979 | case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 133129 | | -{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);} |
| 133980 | +{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy148,yymsp[0].minor.yy194,yymsp[-2].minor.yy194,0);} |
| 133130 | 133981 | break; |
| 133131 | 133982 | case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */ |
| 133132 | | -{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);} |
| 133983 | +{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy148,yymsp[0].minor.yy194,0,0,0,0, |
| 133984 | + SQLITE_IDXTYPE_UNIQUE);} |
| 133133 | 133985 | break; |
| 133134 | 133986 | case 65: /* tcons ::= CHECK LP expr RP onconf */ |
| 133135 | | -{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);} |
| 133987 | +{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy190.pExpr);} |
| 133136 | 133988 | break; |
| 133137 | 133989 | case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 133138 | 133990 | { |
| 133139 | | - sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392); |
| 133140 | | - sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392); |
| 133991 | + sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy148, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[-1].minor.yy194); |
| 133992 | + sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy194); |
| 133141 | 133993 | } |
| 133142 | 133994 | break; |
| 133143 | 133995 | case 68: /* onconf ::= */ |
| 133144 | 133996 | case 70: /* orconf ::= */ yytestcase(yyruleno==70); |
| 133145 | | -{yymsp[1].minor.yy392 = OE_Default;} |
| 133997 | +{yymsp[1].minor.yy194 = OE_Default;} |
| 133146 | 133998 | break; |
| 133147 | 133999 | case 69: /* onconf ::= ON CONFLICT resolvetype */ |
| 133148 | | -{yymsp[-2].minor.yy392 = yymsp[0].minor.yy392;} |
| 134000 | +{yymsp[-2].minor.yy194 = yymsp[0].minor.yy194;} |
| 133149 | 134001 | break; |
| 133150 | 134002 | case 72: /* resolvetype ::= IGNORE */ |
| 133151 | | -{yymsp[0].minor.yy392 = OE_Ignore;} |
| 134003 | +{yymsp[0].minor.yy194 = OE_Ignore;} |
| 133152 | 134004 | break; |
| 133153 | 134005 | case 73: /* resolvetype ::= REPLACE */ |
| 133154 | 134006 | case 143: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==143); |
| 133155 | | -{yymsp[0].minor.yy392 = OE_Replace;} |
| 134007 | +{yymsp[0].minor.yy194 = OE_Replace;} |
| 133156 | 134008 | break; |
| 133157 | 134009 | case 74: /* cmd ::= DROP TABLE ifexists fullname */ |
| 133158 | 134010 | { |
| 133159 | | - sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392); |
| 134011 | + sqlite3DropTable(pParse, yymsp[0].minor.yy185, 0, yymsp[-1].minor.yy194); |
| 133160 | 134012 | } |
| 133161 | 134013 | break; |
| 133162 | 134014 | case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 133163 | 134015 | { |
| 133164 | | - sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[0].minor.yy159, yymsp[-7].minor.yy392, yymsp[-5].minor.yy392); |
| 134016 | + sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy148, yymsp[0].minor.yy243, yymsp[-7].minor.yy194, yymsp[-5].minor.yy194); |
| 133165 | 134017 | } |
| 133166 | 134018 | break; |
| 133167 | 134019 | case 78: /* cmd ::= DROP VIEW ifexists fullname */ |
| 133168 | 134020 | { |
| 133169 | | - sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392); |
| 134021 | + sqlite3DropTable(pParse, yymsp[0].minor.yy185, 1, yymsp[-1].minor.yy194); |
| 133170 | 134022 | } |
| 133171 | 134023 | break; |
| 133172 | 134024 | case 79: /* cmd ::= select */ |
| 133173 | 134025 | { |
| 133174 | 134026 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0}; |
| 133175 | | - sqlite3Select(pParse, yymsp[0].minor.yy159, &dest); |
| 133176 | | - sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159); |
| 134027 | + sqlite3Select(pParse, yymsp[0].minor.yy243, &dest); |
| 134028 | + sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy243); |
| 133177 | 134029 | } |
| 133178 | 134030 | break; |
| 133179 | 134031 | case 80: /* select ::= with selectnowith */ |
| 133180 | 134032 | { |
| 133181 | | - Select *p = yymsp[0].minor.yy159; |
| 134033 | + Select *p = yymsp[0].minor.yy243; |
| 133182 | 134034 | if( p ){ |
| 133183 | | - p->pWith = yymsp[-1].minor.yy331; |
| 134035 | + p->pWith = yymsp[-1].minor.yy285; |
| 133184 | 134036 | parserDoubleLinkSelect(pParse, p); |
| 133185 | 134037 | }else{ |
| 133186 | | - sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy331); |
| 134038 | + sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy285); |
| 133187 | 134039 | } |
| 133188 | | - yymsp[-1].minor.yy159 = p; /*A-overwrites-W*/ |
| 134040 | + yymsp[-1].minor.yy243 = p; /*A-overwrites-W*/ |
| 133189 | 134041 | } |
| 133190 | 134042 | break; |
| 133191 | 134043 | case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */ |
| 133192 | 134044 | { |
| 133193 | | - Select *pRhs = yymsp[0].minor.yy159; |
| 133194 | | - Select *pLhs = yymsp[-2].minor.yy159; |
| 134045 | + Select *pRhs = yymsp[0].minor.yy243; |
| 134046 | + Select *pLhs = yymsp[-2].minor.yy243; |
| 133195 | 134047 | if( pRhs && pRhs->pPrior ){ |
| 133196 | 134048 | SrcList *pFrom; |
| 133197 | 134049 | Token x; |
| 133198 | 134050 | x.n = 0; |
| 133199 | 134051 | parserDoubleLinkSelect(pParse, pRhs); |
| 133200 | 134052 | pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0); |
| 133201 | 134053 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0); |
| 133202 | 134054 | } |
| 133203 | 134055 | if( pRhs ){ |
| 133204 | | - pRhs->op = (u8)yymsp[-1].minor.yy392; |
| 134056 | + pRhs->op = (u8)yymsp[-1].minor.yy194; |
| 133205 | 134057 | pRhs->pPrior = pLhs; |
| 133206 | 134058 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; |
| 133207 | 134059 | pRhs->selFlags &= ~SF_MultiValue; |
| 133208 | | - if( yymsp[-1].minor.yy392!=TK_ALL ) pParse->hasCompound = 1; |
| 134060 | + if( yymsp[-1].minor.yy194!=TK_ALL ) pParse->hasCompound = 1; |
| 133209 | 134061 | }else{ |
| 133210 | 134062 | sqlite3SelectDelete(pParse->db, pLhs); |
| 133211 | 134063 | } |
| 133212 | | - yymsp[-2].minor.yy159 = pRhs; |
| 134064 | + yymsp[-2].minor.yy243 = pRhs; |
| 133213 | 134065 | } |
| 133214 | 134066 | break; |
| 133215 | 134067 | case 82: /* multiselect_op ::= UNION */ |
| 133216 | 134068 | case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84); |
| 133217 | | -{yymsp[0].minor.yy392 = yymsp[0].major; /*A-overwrites-OP*/} |
| 134069 | +{yymsp[0].minor.yy194 = yymsp[0].major; /*A-overwrites-OP*/} |
| 133218 | 134070 | break; |
| 133219 | 134071 | case 83: /* multiselect_op ::= UNION ALL */ |
| 133220 | | -{yymsp[-1].minor.yy392 = TK_ALL;} |
| 134072 | +{yymsp[-1].minor.yy194 = TK_ALL;} |
| 133221 | 134073 | break; |
| 133222 | 134074 | case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 133223 | 134075 | { |
| 133224 | 134076 | #if SELECTTRACE_ENABLED |
| 133225 | 134077 | Token s = yymsp[-8].minor.yy0; /*A-overwrites-S*/ |
| 133226 | 134078 | #endif |
| 133227 | | - yymsp[-8].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset); |
| 134079 | + yymsp[-8].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy148,yymsp[-5].minor.yy185,yymsp[-4].minor.yy72,yymsp[-3].minor.yy148,yymsp[-2].minor.yy72,yymsp[-1].minor.yy148,yymsp[-7].minor.yy194,yymsp[0].minor.yy354.pLimit,yymsp[0].minor.yy354.pOffset); |
| 133228 | 134080 | #if SELECTTRACE_ENABLED |
| 133229 | 134081 | /* Populate the Select.zSelName[] string that is used to help with |
| 133230 | 134082 | ** query planner debugging, to differentiate between multiple Select |
| 133231 | 134083 | ** objects in a complex query. |
| 133232 | 134084 | ** |
| | @@ -133233,464 +134085,465 @@ |
| 133233 | 134085 | ** If the SELECT keyword is immediately followed by a C-style comment |
| 133234 | 134086 | ** then extract the first few alphanumeric characters from within that |
| 133235 | 134087 | ** comment to be the zSelName value. Otherwise, the label is #N where |
| 133236 | 134088 | ** is an integer that is incremented with each SELECT statement seen. |
| 133237 | 134089 | */ |
| 133238 | | - if( yymsp[-8].minor.yy159!=0 ){ |
| 134090 | + if( yymsp[-8].minor.yy243!=0 ){ |
| 133239 | 134091 | const char *z = s.z+6; |
| 133240 | 134092 | int i; |
| 133241 | | - sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "#%d", |
| 134093 | + sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "#%d", |
| 133242 | 134094 | ++pParse->nSelect); |
| 133243 | 134095 | while( z[0]==' ' ) z++; |
| 133244 | 134096 | if( z[0]=='/' && z[1]=='*' ){ |
| 133245 | 134097 | z += 2; |
| 133246 | 134098 | while( z[0]==' ' ) z++; |
| 133247 | 134099 | for(i=0; sqlite3Isalnum(z[i]); i++){} |
| 133248 | | - sqlite3_snprintf(sizeof(yymsp[-8].minor.yy159->zSelName), yymsp[-8].minor.yy159->zSelName, "%.*s", i, z); |
| 134100 | + sqlite3_snprintf(sizeof(yymsp[-8].minor.yy243->zSelName), yymsp[-8].minor.yy243->zSelName, "%.*s", i, z); |
| 133249 | 134101 | } |
| 133250 | 134102 | } |
| 133251 | 134103 | #endif /* SELECTRACE_ENABLED */ |
| 133252 | 134104 | } |
| 133253 | 134105 | break; |
| 133254 | 134106 | case 86: /* values ::= VALUES LP nexprlist RP */ |
| 133255 | 134107 | { |
| 133256 | | - yymsp[-3].minor.yy159 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values,0,0); |
| 134108 | + yymsp[-3].minor.yy243 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values,0,0); |
| 133257 | 134109 | } |
| 133258 | 134110 | break; |
| 133259 | 134111 | case 87: /* values ::= values COMMA LP exprlist RP */ |
| 133260 | 134112 | { |
| 133261 | | - Select *pRight, *pLeft = yymsp[-4].minor.yy159; |
| 133262 | | - pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy442,0,0,0,0,0,SF_Values|SF_MultiValue,0,0); |
| 134113 | + Select *pRight, *pLeft = yymsp[-4].minor.yy243; |
| 134114 | + pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy148,0,0,0,0,0,SF_Values|SF_MultiValue,0,0); |
| 133263 | 134115 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; |
| 133264 | 134116 | if( pRight ){ |
| 133265 | 134117 | pRight->op = TK_ALL; |
| 133266 | 134118 | pRight->pPrior = pLeft; |
| 133267 | | - yymsp[-4].minor.yy159 = pRight; |
| 134119 | + yymsp[-4].minor.yy243 = pRight; |
| 133268 | 134120 | }else{ |
| 133269 | | - yymsp[-4].minor.yy159 = pLeft; |
| 134121 | + yymsp[-4].minor.yy243 = pLeft; |
| 133270 | 134122 | } |
| 133271 | 134123 | } |
| 133272 | 134124 | break; |
| 133273 | 134125 | case 88: /* distinct ::= DISTINCT */ |
| 133274 | | -{yymsp[0].minor.yy392 = SF_Distinct;} |
| 134126 | +{yymsp[0].minor.yy194 = SF_Distinct;} |
| 133275 | 134127 | break; |
| 133276 | 134128 | case 89: /* distinct ::= ALL */ |
| 133277 | | -{yymsp[0].minor.yy392 = SF_All;} |
| 134129 | +{yymsp[0].minor.yy194 = SF_All;} |
| 133278 | 134130 | break; |
| 133279 | 134131 | case 91: /* sclp ::= */ |
| 133280 | 134132 | case 119: /* orderby_opt ::= */ yytestcase(yyruleno==119); |
| 133281 | 134133 | case 126: /* groupby_opt ::= */ yytestcase(yyruleno==126); |
| 133282 | 134134 | case 199: /* exprlist ::= */ yytestcase(yyruleno==199); |
| 133283 | | - case 205: /* eidlist_opt ::= */ yytestcase(yyruleno==205); |
| 133284 | | -{yymsp[1].minor.yy442 = 0;} |
| 134135 | + case 202: /* paren_exprlist ::= */ yytestcase(yyruleno==202); |
| 134136 | + case 207: /* eidlist_opt ::= */ yytestcase(yyruleno==207); |
| 134137 | +{yymsp[1].minor.yy148 = 0;} |
| 133285 | 134138 | break; |
| 133286 | 134139 | case 92: /* selcollist ::= sclp expr as */ |
| 133287 | 134140 | { |
| 133288 | | - yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr); |
| 133289 | | - if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0, 1); |
| 133290 | | - sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy442,&yymsp[-1].minor.yy342); |
| 134141 | + yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy148, yymsp[-1].minor.yy190.pExpr); |
| 134142 | + if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-2].minor.yy148, &yymsp[0].minor.yy0, 1); |
| 134143 | + sqlite3ExprListSetSpan(pParse,yymsp[-2].minor.yy148,&yymsp[-1].minor.yy190); |
| 133291 | 134144 | } |
| 133292 | 134145 | break; |
| 133293 | 134146 | case 93: /* selcollist ::= sclp STAR */ |
| 133294 | 134147 | { |
| 133295 | 134148 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); |
| 133296 | | - yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p); |
| 134149 | + yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy148, p); |
| 133297 | 134150 | } |
| 133298 | 134151 | break; |
| 133299 | 134152 | case 94: /* selcollist ::= sclp nm DOT STAR */ |
| 133300 | 134153 | { |
| 133301 | 134154 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0, &yymsp[0].minor.yy0); |
| 133302 | 134155 | Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 133303 | 134156 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); |
| 133304 | | - yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot); |
| 134157 | + yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, pDot); |
| 133305 | 134158 | } |
| 133306 | 134159 | break; |
| 133307 | 134160 | case 95: /* as ::= AS nm */ |
| 133308 | 134161 | case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106); |
| 133309 | | - case 219: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==219); |
| 133310 | | - case 220: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==220); |
| 134162 | + case 221: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==221); |
| 134163 | + case 222: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==222); |
| 133311 | 134164 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 133312 | 134165 | break; |
| 133313 | 134166 | case 97: /* from ::= */ |
| 133314 | | -{yymsp[1].minor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy347));} |
| 134167 | +{yymsp[1].minor.yy185 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy185));} |
| 133315 | 134168 | break; |
| 133316 | 134169 | case 98: /* from ::= FROM seltablist */ |
| 133317 | 134170 | { |
| 133318 | | - yymsp[-1].minor.yy347 = yymsp[0].minor.yy347; |
| 133319 | | - sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy347); |
| 134171 | + yymsp[-1].minor.yy185 = yymsp[0].minor.yy185; |
| 134172 | + sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy185); |
| 133320 | 134173 | } |
| 133321 | 134174 | break; |
| 133322 | 134175 | case 99: /* stl_prefix ::= seltablist joinop */ |
| 133323 | 134176 | { |
| 133324 | | - if( ALWAYS(yymsp[-1].minor.yy347 && yymsp[-1].minor.yy347->nSrc>0) ) yymsp[-1].minor.yy347->a[yymsp[-1].minor.yy347->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy392; |
| 134177 | + if( ALWAYS(yymsp[-1].minor.yy185 && yymsp[-1].minor.yy185->nSrc>0) ) yymsp[-1].minor.yy185->a[yymsp[-1].minor.yy185->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy194; |
| 133325 | 134178 | } |
| 133326 | 134179 | break; |
| 133327 | 134180 | case 100: /* stl_prefix ::= */ |
| 133328 | | -{yymsp[1].minor.yy347 = 0;} |
| 134181 | +{yymsp[1].minor.yy185 = 0;} |
| 133329 | 134182 | break; |
| 133330 | 134183 | case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 133331 | 134184 | { |
| 133332 | | - yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 133333 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy347, &yymsp[-2].minor.yy0); |
| 134185 | + yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254); |
| 134186 | + sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy185, &yymsp[-2].minor.yy0); |
| 133334 | 134187 | } |
| 133335 | 134188 | break; |
| 133336 | 134189 | case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 133337 | 134190 | { |
| 133338 | | - yymsp[-8].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy347,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 133339 | | - sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy347, yymsp[-4].minor.yy442); |
| 134191 | + yymsp[-8].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy185,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254); |
| 134192 | + sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy185, yymsp[-4].minor.yy148); |
| 133340 | 134193 | } |
| 133341 | 134194 | break; |
| 133342 | 134195 | case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 133343 | 134196 | { |
| 133344 | | - yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 134197 | + yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy243,yymsp[-1].minor.yy72,yymsp[0].minor.yy254); |
| 133345 | 134198 | } |
| 133346 | 134199 | break; |
| 133347 | 134200 | case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 133348 | 134201 | { |
| 133349 | | - if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){ |
| 133350 | | - yymsp[-6].minor.yy347 = yymsp[-4].minor.yy347; |
| 133351 | | - }else if( yymsp[-4].minor.yy347->nSrc==1 ){ |
| 133352 | | - yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 133353 | | - if( yymsp[-6].minor.yy347 ){ |
| 133354 | | - struct SrcList_item *pNew = &yymsp[-6].minor.yy347->a[yymsp[-6].minor.yy347->nSrc-1]; |
| 133355 | | - struct SrcList_item *pOld = yymsp[-4].minor.yy347->a; |
| 134202 | + if( yymsp[-6].minor.yy185==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy72==0 && yymsp[0].minor.yy254==0 ){ |
| 134203 | + yymsp[-6].minor.yy185 = yymsp[-4].minor.yy185; |
| 134204 | + }else if( yymsp[-4].minor.yy185->nSrc==1 ){ |
| 134205 | + yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy72,yymsp[0].minor.yy254); |
| 134206 | + if( yymsp[-6].minor.yy185 ){ |
| 134207 | + struct SrcList_item *pNew = &yymsp[-6].minor.yy185->a[yymsp[-6].minor.yy185->nSrc-1]; |
| 134208 | + struct SrcList_item *pOld = yymsp[-4].minor.yy185->a; |
| 133356 | 134209 | pNew->zName = pOld->zName; |
| 133357 | 134210 | pNew->zDatabase = pOld->zDatabase; |
| 133358 | 134211 | pNew->pSelect = pOld->pSelect; |
| 133359 | 134212 | pOld->zName = pOld->zDatabase = 0; |
| 133360 | 134213 | pOld->pSelect = 0; |
| 133361 | 134214 | } |
| 133362 | | - sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy347); |
| 134215 | + sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy185); |
| 133363 | 134216 | }else{ |
| 133364 | 134217 | Select *pSubquery; |
| 133365 | | - sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy347); |
| 133366 | | - pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,SF_NestedFrom,0,0); |
| 133367 | | - yymsp[-6].minor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 134218 | + sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy185); |
| 134219 | + pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy185,0,0,0,0,SF_NestedFrom,0,0); |
| 134220 | + yymsp[-6].minor.yy185 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy185,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy72,yymsp[0].minor.yy254); |
| 133368 | 134221 | } |
| 133369 | 134222 | } |
| 133370 | 134223 | break; |
| 133371 | 134224 | case 105: /* dbnm ::= */ |
| 133372 | 134225 | case 114: /* indexed_opt ::= */ yytestcase(yyruleno==114); |
| 133373 | 134226 | {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} |
| 133374 | 134227 | break; |
| 133375 | 134228 | case 107: /* fullname ::= nm dbnm */ |
| 133376 | | -{yymsp[-1].minor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 134229 | +{yymsp[-1].minor.yy185 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 133377 | 134230 | break; |
| 133378 | 134231 | case 108: /* joinop ::= COMMA|JOIN */ |
| 133379 | | -{ yymsp[0].minor.yy392 = JT_INNER; } |
| 134232 | +{ yymsp[0].minor.yy194 = JT_INNER; } |
| 133380 | 134233 | break; |
| 133381 | 134234 | case 109: /* joinop ::= JOIN_KW JOIN */ |
| 133382 | | -{yymsp[-1].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 134235 | +{yymsp[-1].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 133383 | 134236 | break; |
| 133384 | 134237 | case 110: /* joinop ::= JOIN_KW nm JOIN */ |
| 133385 | | -{yymsp[-2].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 134238 | +{yymsp[-2].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 133386 | 134239 | break; |
| 133387 | 134240 | case 111: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 133388 | | -{yymsp[-3].minor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 134241 | +{yymsp[-3].minor.yy194 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 133389 | 134242 | break; |
| 133390 | 134243 | case 112: /* on_opt ::= ON expr */ |
| 133391 | 134244 | case 129: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==129); |
| 133392 | 134245 | case 136: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==136); |
| 133393 | 134246 | case 195: /* case_else ::= ELSE expr */ yytestcase(yyruleno==195); |
| 133394 | | -{yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr;} |
| 134247 | +{yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr;} |
| 133395 | 134248 | break; |
| 133396 | 134249 | case 113: /* on_opt ::= */ |
| 133397 | 134250 | case 128: /* having_opt ::= */ yytestcase(yyruleno==128); |
| 133398 | 134251 | case 135: /* where_opt ::= */ yytestcase(yyruleno==135); |
| 133399 | 134252 | case 196: /* case_else ::= */ yytestcase(yyruleno==196); |
| 133400 | 134253 | case 198: /* case_operand ::= */ yytestcase(yyruleno==198); |
| 133401 | | -{yymsp[1].minor.yy122 = 0;} |
| 134254 | +{yymsp[1].minor.yy72 = 0;} |
| 133402 | 134255 | break; |
| 133403 | 134256 | case 115: /* indexed_opt ::= INDEXED BY nm */ |
| 133404 | 134257 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| 133405 | 134258 | break; |
| 133406 | 134259 | case 116: /* indexed_opt ::= NOT INDEXED */ |
| 133407 | 134260 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} |
| 133408 | 134261 | break; |
| 133409 | 134262 | case 117: /* using_opt ::= USING LP idlist RP */ |
| 133410 | | -{yymsp[-3].minor.yy180 = yymsp[-1].minor.yy180;} |
| 134263 | +{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;} |
| 133411 | 134264 | break; |
| 133412 | 134265 | case 118: /* using_opt ::= */ |
| 133413 | 134266 | case 144: /* idlist_opt ::= */ yytestcase(yyruleno==144); |
| 133414 | | -{yymsp[1].minor.yy180 = 0;} |
| 134267 | +{yymsp[1].minor.yy254 = 0;} |
| 133415 | 134268 | break; |
| 133416 | 134269 | case 120: /* orderby_opt ::= ORDER BY sortlist */ |
| 133417 | 134270 | case 127: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==127); |
| 133418 | | -{yymsp[-2].minor.yy442 = yymsp[0].minor.yy442;} |
| 134271 | +{yymsp[-2].minor.yy148 = yymsp[0].minor.yy148;} |
| 133419 | 134272 | break; |
| 133420 | 134273 | case 121: /* sortlist ::= sortlist COMMA expr sortorder */ |
| 133421 | 134274 | { |
| 133422 | | - yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr); |
| 133423 | | - sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy442,yymsp[0].minor.yy392); |
| 134275 | + yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148,yymsp[-1].minor.yy190.pExpr); |
| 134276 | + sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy148,yymsp[0].minor.yy194); |
| 133424 | 134277 | } |
| 133425 | 134278 | break; |
| 133426 | 134279 | case 122: /* sortlist ::= expr sortorder */ |
| 133427 | 134280 | { |
| 133428 | | - yymsp[-1].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr); /*A-overwrites-Y*/ |
| 133429 | | - sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy442,yymsp[0].minor.yy392); |
| 134281 | + yymsp[-1].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy190.pExpr); /*A-overwrites-Y*/ |
| 134282 | + sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy148,yymsp[0].minor.yy194); |
| 133430 | 134283 | } |
| 133431 | 134284 | break; |
| 133432 | 134285 | case 123: /* sortorder ::= ASC */ |
| 133433 | | -{yymsp[0].minor.yy392 = SQLITE_SO_ASC;} |
| 134286 | +{yymsp[0].minor.yy194 = SQLITE_SO_ASC;} |
| 133434 | 134287 | break; |
| 133435 | 134288 | case 124: /* sortorder ::= DESC */ |
| 133436 | | -{yymsp[0].minor.yy392 = SQLITE_SO_DESC;} |
| 134289 | +{yymsp[0].minor.yy194 = SQLITE_SO_DESC;} |
| 133437 | 134290 | break; |
| 133438 | 134291 | case 125: /* sortorder ::= */ |
| 133439 | | -{yymsp[1].minor.yy392 = SQLITE_SO_UNDEFINED;} |
| 134292 | +{yymsp[1].minor.yy194 = SQLITE_SO_UNDEFINED;} |
| 133440 | 134293 | break; |
| 133441 | 134294 | case 130: /* limit_opt ::= */ |
| 133442 | | -{yymsp[1].minor.yy64.pLimit = 0; yymsp[1].minor.yy64.pOffset = 0;} |
| 134295 | +{yymsp[1].minor.yy354.pLimit = 0; yymsp[1].minor.yy354.pOffset = 0;} |
| 133443 | 134296 | break; |
| 133444 | 134297 | case 131: /* limit_opt ::= LIMIT expr */ |
| 133445 | | -{yymsp[-1].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yymsp[-1].minor.yy64.pOffset = 0;} |
| 134298 | +{yymsp[-1].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr; yymsp[-1].minor.yy354.pOffset = 0;} |
| 133446 | 134299 | break; |
| 133447 | 134300 | case 132: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 133448 | | -{yymsp[-3].minor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;} |
| 134301 | +{yymsp[-3].minor.yy354.pLimit = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pOffset = yymsp[0].minor.yy190.pExpr;} |
| 133449 | 134302 | break; |
| 133450 | 134303 | case 133: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 133451 | | -{yymsp[-3].minor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yymsp[-3].minor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;} |
| 134304 | +{yymsp[-3].minor.yy354.pOffset = yymsp[-2].minor.yy190.pExpr; yymsp[-3].minor.yy354.pLimit = yymsp[0].minor.yy190.pExpr;} |
| 133452 | 134305 | break; |
| 133453 | 134306 | case 134: /* cmd ::= with DELETE FROM fullname indexed_opt where_opt */ |
| 133454 | 134307 | { |
| 133455 | | - sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1); |
| 133456 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0); |
| 133457 | | - sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122); |
| 134308 | + sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1); |
| 134309 | + sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy0); |
| 134310 | + sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy185,yymsp[0].minor.yy72); |
| 133458 | 134311 | } |
| 133459 | 134312 | break; |
| 133460 | 134313 | case 137: /* cmd ::= with UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 133461 | 134314 | { |
| 133462 | | - sqlite3WithPush(pParse, yymsp[-7].minor.yy331, 1); |
| 133463 | | - sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0); |
| 133464 | | - sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list"); |
| 133465 | | - sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy392); |
| 134315 | + sqlite3WithPush(pParse, yymsp[-7].minor.yy285, 1); |
| 134316 | + sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy0); |
| 134317 | + sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy148,"set list"); |
| 134318 | + sqlite3Update(pParse,yymsp[-4].minor.yy185,yymsp[-1].minor.yy148,yymsp[0].minor.yy72,yymsp[-5].minor.yy194); |
| 133466 | 134319 | } |
| 133467 | 134320 | break; |
| 133468 | 134321 | case 138: /* setlist ::= setlist COMMA nm EQ expr */ |
| 133469 | 134322 | { |
| 133470 | | - yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr); |
| 133471 | | - sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, 1); |
| 134323 | + yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr); |
| 134324 | + sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, 1); |
| 133472 | 134325 | } |
| 133473 | 134326 | break; |
| 133474 | 134327 | case 139: /* setlist ::= nm EQ expr */ |
| 133475 | 134328 | { |
| 133476 | | - yylhsminor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr); |
| 133477 | | - sqlite3ExprListSetName(pParse, yylhsminor.yy442, &yymsp[-2].minor.yy0, 1); |
| 134329 | + yylhsminor.yy148 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy190.pExpr); |
| 134330 | + sqlite3ExprListSetName(pParse, yylhsminor.yy148, &yymsp[-2].minor.yy0, 1); |
| 133478 | 134331 | } |
| 133479 | | - yymsp[-2].minor.yy442 = yylhsminor.yy442; |
| 134332 | + yymsp[-2].minor.yy148 = yylhsminor.yy148; |
| 133480 | 134333 | break; |
| 133481 | 134334 | case 140: /* cmd ::= with insert_cmd INTO fullname idlist_opt select */ |
| 133482 | 134335 | { |
| 133483 | | - sqlite3WithPush(pParse, yymsp[-5].minor.yy331, 1); |
| 133484 | | - sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy392); |
| 134336 | + sqlite3WithPush(pParse, yymsp[-5].minor.yy285, 1); |
| 134337 | + sqlite3Insert(pParse, yymsp[-2].minor.yy185, yymsp[0].minor.yy243, yymsp[-1].minor.yy254, yymsp[-4].minor.yy194); |
| 133485 | 134338 | } |
| 133486 | 134339 | break; |
| 133487 | 134340 | case 141: /* cmd ::= with insert_cmd INTO fullname idlist_opt DEFAULT VALUES */ |
| 133488 | 134341 | { |
| 133489 | | - sqlite3WithPush(pParse, yymsp[-6].minor.yy331, 1); |
| 133490 | | - sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy392); |
| 134342 | + sqlite3WithPush(pParse, yymsp[-6].minor.yy285, 1); |
| 134343 | + sqlite3Insert(pParse, yymsp[-3].minor.yy185, 0, yymsp[-2].minor.yy254, yymsp[-5].minor.yy194); |
| 133491 | 134344 | } |
| 133492 | 134345 | break; |
| 133493 | 134346 | case 145: /* idlist_opt ::= LP idlist RP */ |
| 133494 | | -{yymsp[-2].minor.yy180 = yymsp[-1].minor.yy180;} |
| 134347 | +{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;} |
| 133495 | 134348 | break; |
| 133496 | 134349 | case 146: /* idlist ::= idlist COMMA nm */ |
| 133497 | | -{yymsp[-2].minor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);} |
| 134350 | +{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);} |
| 133498 | 134351 | break; |
| 133499 | 134352 | case 147: /* idlist ::= nm */ |
| 133500 | | -{yymsp[0].minor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 134353 | +{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 133501 | 134354 | break; |
| 133502 | 134355 | case 148: /* expr ::= LP expr RP */ |
| 133503 | | -{spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr;} |
| 134356 | +{spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ yymsp[-2].minor.yy190.pExpr = yymsp[-1].minor.yy190.pExpr;} |
| 133504 | 134357 | break; |
| 133505 | 134358 | case 149: /* term ::= NULL */ |
| 133506 | 134359 | case 154: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==154); |
| 133507 | 134360 | case 155: /* term ::= STRING */ yytestcase(yyruleno==155); |
| 133508 | | -{spanExpr(&yymsp[0].minor.yy342,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/} |
| 134361 | +{spanExpr(&yymsp[0].minor.yy190,pParse,yymsp[0].major,yymsp[0].minor.yy0);/*A-overwrites-X*/} |
| 133509 | 134362 | break; |
| 133510 | 134363 | case 150: /* expr ::= ID|INDEXED */ |
| 133511 | 134364 | case 151: /* expr ::= JOIN_KW */ yytestcase(yyruleno==151); |
| 133512 | | -{spanExpr(&yymsp[0].minor.yy342,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 134365 | +{spanExpr(&yymsp[0].minor.yy190,pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 133513 | 134366 | break; |
| 133514 | 134367 | case 152: /* expr ::= nm DOT nm */ |
| 133515 | 134368 | { |
| 133516 | 134369 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 133517 | 134370 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 133518 | | - spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 133519 | | - yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 134371 | + spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 134372 | + yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 133520 | 134373 | } |
| 133521 | 134374 | break; |
| 133522 | 134375 | case 153: /* expr ::= nm DOT nm DOT nm */ |
| 133523 | 134376 | { |
| 133524 | 134377 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 133525 | 134378 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 133526 | 134379 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 133527 | 134380 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 133528 | | - spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 133529 | | - yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 134381 | + spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 134382 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 133530 | 134383 | } |
| 133531 | 134384 | break; |
| 133532 | 134385 | case 156: /* expr ::= VARIABLE */ |
| 133533 | 134386 | { |
| 133534 | 134387 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 133535 | | - spanExpr(&yymsp[0].minor.yy342, pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 133536 | | - sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy342.pExpr); |
| 134388 | + spanExpr(&yymsp[0].minor.yy190, pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 134389 | + sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy190.pExpr); |
| 133537 | 134390 | }else{ |
| 133538 | 134391 | /* When doing a nested parse, one can include terms in an expression |
| 133539 | 134392 | ** that look like this: #1 #2 ... These terms refer to registers |
| 133540 | 134393 | ** in the virtual machine. #N is the N-th register. */ |
| 133541 | 134394 | Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ |
| 133542 | 134395 | assert( t.n>=2 ); |
| 133543 | | - spanSet(&yymsp[0].minor.yy342, &t, &t); |
| 134396 | + spanSet(&yymsp[0].minor.yy190, &t, &t); |
| 133544 | 134397 | if( pParse->nested==0 ){ |
| 133545 | 134398 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); |
| 133546 | | - yymsp[0].minor.yy342.pExpr = 0; |
| 134399 | + yymsp[0].minor.yy190.pExpr = 0; |
| 133547 | 134400 | }else{ |
| 133548 | | - yymsp[0].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t); |
| 133549 | | - if( yymsp[0].minor.yy342.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy342.pExpr->iTable); |
| 134401 | + yymsp[0].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, &t); |
| 134402 | + if( yymsp[0].minor.yy190.pExpr ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy190.pExpr->iTable); |
| 133550 | 134403 | } |
| 133551 | 134404 | } |
| 133552 | 134405 | } |
| 133553 | 134406 | break; |
| 133554 | 134407 | case 157: /* expr ::= expr COLLATE ID|STRING */ |
| 133555 | 134408 | { |
| 133556 | | - yymsp[-2].minor.yy342.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0, 1); |
| 133557 | | - yymsp[-2].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 134409 | + yymsp[-2].minor.yy190.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy190.pExpr, &yymsp[0].minor.yy0, 1); |
| 134410 | + yymsp[-2].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 133558 | 134411 | } |
| 133559 | 134412 | break; |
| 133560 | 134413 | case 158: /* expr ::= CAST LP expr AS typetoken RP */ |
| 133561 | 134414 | { |
| 133562 | | - spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 133563 | | - yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0); |
| 134415 | + spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 134416 | + yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy190.pExpr, 0, &yymsp[-1].minor.yy0); |
| 133564 | 134417 | } |
| 133565 | 134418 | break; |
| 133566 | 134419 | case 159: /* expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 133567 | 134420 | { |
| 133568 | | - if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 134421 | + if( yymsp[-1].minor.yy148 && yymsp[-1].minor.yy148->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 133569 | 134422 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 133570 | 134423 | } |
| 133571 | | - yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0); |
| 133572 | | - spanSet(&yylhsminor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 133573 | | - if( yymsp[-2].minor.yy392==SF_Distinct && yylhsminor.yy342.pExpr ){ |
| 133574 | | - yylhsminor.yy342.pExpr->flags |= EP_Distinct; |
| 134424 | + yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy148, &yymsp[-4].minor.yy0); |
| 134425 | + spanSet(&yylhsminor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 134426 | + if( yymsp[-2].minor.yy194==SF_Distinct && yylhsminor.yy190.pExpr ){ |
| 134427 | + yylhsminor.yy190.pExpr->flags |= EP_Distinct; |
| 133575 | 134428 | } |
| 133576 | 134429 | } |
| 133577 | | - yymsp[-4].minor.yy342 = yylhsminor.yy342; |
| 134430 | + yymsp[-4].minor.yy190 = yylhsminor.yy190; |
| 133578 | 134431 | break; |
| 133579 | 134432 | case 160: /* expr ::= ID|INDEXED LP STAR RP */ |
| 133580 | 134433 | { |
| 133581 | | - yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 133582 | | - spanSet(&yylhsminor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 134434 | + yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 134435 | + spanSet(&yylhsminor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 133583 | 134436 | } |
| 133584 | | - yymsp[-3].minor.yy342 = yylhsminor.yy342; |
| 134437 | + yymsp[-3].minor.yy190 = yylhsminor.yy190; |
| 133585 | 134438 | break; |
| 133586 | 134439 | case 161: /* term ::= CTIME_KW */ |
| 133587 | 134440 | { |
| 133588 | | - yylhsminor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0); |
| 133589 | | - spanSet(&yylhsminor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 134441 | + yylhsminor.yy190.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0); |
| 134442 | + spanSet(&yylhsminor.yy190, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 133590 | 134443 | } |
| 133591 | | - yymsp[0].minor.yy342 = yylhsminor.yy342; |
| 134444 | + yymsp[0].minor.yy190 = yylhsminor.yy190; |
| 133592 | 134445 | break; |
| 133593 | 134446 | case 162: /* expr ::= expr AND expr */ |
| 133594 | 134447 | case 163: /* expr ::= expr OR expr */ yytestcase(yyruleno==163); |
| 133595 | 134448 | case 164: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==164); |
| 133596 | 134449 | case 165: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==165); |
| 133597 | 134450 | case 166: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==166); |
| 133598 | 134451 | case 167: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==167); |
| 133599 | 134452 | case 168: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==168); |
| 133600 | 134453 | case 169: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==169); |
| 133601 | | -{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);} |
| 134454 | +{spanBinaryExpr(pParse,yymsp[-1].major,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190);} |
| 133602 | 134455 | break; |
| 133603 | 134456 | case 170: /* likeop ::= LIKE_KW|MATCH */ |
| 133604 | | -{yymsp[0].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy318.bNot = 0;/*A-overwrites-X*/} |
| 134457 | +{yymsp[0].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[0].minor.yy392.bNot = 0;/*A-overwrites-X*/} |
| 133605 | 134458 | break; |
| 133606 | 134459 | case 171: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 133607 | | -{yymsp[-1].minor.yy318.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy318.bNot = 1;} |
| 134460 | +{yymsp[-1].minor.yy392.eOperator = yymsp[0].minor.yy0; yymsp[-1].minor.yy392.bNot = 1;} |
| 133608 | 134461 | break; |
| 133609 | 134462 | case 172: /* expr ::= expr likeop expr */ |
| 133610 | 134463 | { |
| 133611 | 134464 | ExprList *pList; |
| 133612 | | - pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr); |
| 133613 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr); |
| 133614 | | - yymsp[-2].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator); |
| 133615 | | - exprNot(pParse, yymsp[-1].minor.yy318.bNot, &yymsp[-2].minor.yy342); |
| 133616 | | - yymsp[-2].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 133617 | | - if( yymsp[-2].minor.yy342.pExpr ) yymsp[-2].minor.yy342.pExpr->flags |= EP_InfixFunc; |
| 134465 | + pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy190.pExpr); |
| 134466 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy190.pExpr); |
| 134467 | + yymsp[-2].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy392.eOperator); |
| 134468 | + exprNot(pParse, yymsp[-1].minor.yy392.bNot, &yymsp[-2].minor.yy190); |
| 134469 | + yymsp[-2].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd; |
| 134470 | + if( yymsp[-2].minor.yy190.pExpr ) yymsp[-2].minor.yy190.pExpr->flags |= EP_InfixFunc; |
| 133618 | 134471 | } |
| 133619 | 134472 | break; |
| 133620 | 134473 | case 173: /* expr ::= expr likeop expr ESCAPE expr */ |
| 133621 | 134474 | { |
| 133622 | 134475 | ExprList *pList; |
| 133623 | | - pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 133624 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr); |
| 133625 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr); |
| 133626 | | - yymsp[-4].minor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator); |
| 133627 | | - exprNot(pParse, yymsp[-3].minor.yy318.bNot, &yymsp[-4].minor.yy342); |
| 133628 | | - yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 133629 | | - if( yymsp[-4].minor.yy342.pExpr ) yymsp[-4].minor.yy342.pExpr->flags |= EP_InfixFunc; |
| 134476 | + pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr); |
| 134477 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy190.pExpr); |
| 134478 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr); |
| 134479 | + yymsp[-4].minor.yy190.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy392.eOperator); |
| 134480 | + exprNot(pParse, yymsp[-3].minor.yy392.bNot, &yymsp[-4].minor.yy190); |
| 134481 | + yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd; |
| 134482 | + if( yymsp[-4].minor.yy190.pExpr ) yymsp[-4].minor.yy190.pExpr->flags |= EP_InfixFunc; |
| 133630 | 134483 | } |
| 133631 | 134484 | break; |
| 133632 | 134485 | case 174: /* expr ::= expr ISNULL|NOTNULL */ |
| 133633 | | -{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);} |
| 134486 | +{spanUnaryPostfix(pParse,yymsp[0].major,&yymsp[-1].minor.yy190,&yymsp[0].minor.yy0);} |
| 133634 | 134487 | break; |
| 133635 | 134488 | case 175: /* expr ::= expr NOT NULL */ |
| 133636 | | -{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);} |
| 134489 | +{spanUnaryPostfix(pParse,TK_NOTNULL,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy0);} |
| 133637 | 134490 | break; |
| 133638 | 134491 | case 176: /* expr ::= expr IS expr */ |
| 133639 | 134492 | { |
| 133640 | | - spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342); |
| 133641 | | - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-2].minor.yy342.pExpr, TK_ISNULL); |
| 134493 | + spanBinaryExpr(pParse,TK_IS,&yymsp[-2].minor.yy190,&yymsp[0].minor.yy190); |
| 134494 | + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-2].minor.yy190.pExpr, TK_ISNULL); |
| 133642 | 134495 | } |
| 133643 | 134496 | break; |
| 133644 | 134497 | case 177: /* expr ::= expr IS NOT expr */ |
| 133645 | 134498 | { |
| 133646 | | - spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342); |
| 133647 | | - binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yymsp[-3].minor.yy342.pExpr, TK_NOTNULL); |
| 134499 | + spanBinaryExpr(pParse,TK_ISNOT,&yymsp[-3].minor.yy190,&yymsp[0].minor.yy190); |
| 134500 | + binaryToUnaryIfNull(pParse, yymsp[0].minor.yy190.pExpr, yymsp[-3].minor.yy190.pExpr, TK_NOTNULL); |
| 133648 | 134501 | } |
| 133649 | 134502 | break; |
| 133650 | 134503 | case 178: /* expr ::= NOT expr */ |
| 133651 | 134504 | case 179: /* expr ::= BITNOT expr */ yytestcase(yyruleno==179); |
| 133652 | | -{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 134505 | +{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,yymsp[-1].major,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 133653 | 134506 | break; |
| 133654 | 134507 | case 180: /* expr ::= MINUS expr */ |
| 133655 | | -{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 134508 | +{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UMINUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 133656 | 134509 | break; |
| 133657 | 134510 | case 181: /* expr ::= PLUS expr */ |
| 133658 | | -{spanUnaryPrefix(&yymsp[-1].minor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 134511 | +{spanUnaryPrefix(&yymsp[-1].minor.yy190,pParse,TK_UPLUS,&yymsp[0].minor.yy190,&yymsp[-1].minor.yy0);/*A-overwrites-B*/} |
| 133659 | 134512 | break; |
| 133660 | 134513 | case 182: /* between_op ::= BETWEEN */ |
| 133661 | 134514 | case 185: /* in_op ::= IN */ yytestcase(yyruleno==185); |
| 133662 | | -{yymsp[0].minor.yy392 = 0;} |
| 134515 | +{yymsp[0].minor.yy194 = 0;} |
| 133663 | 134516 | break; |
| 133664 | 134517 | case 184: /* expr ::= expr between_op expr AND expr */ |
| 133665 | 134518 | { |
| 133666 | | - ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 133667 | | - pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr); |
| 133668 | | - yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 133669 | | - if( yymsp[-4].minor.yy342.pExpr ){ |
| 133670 | | - yymsp[-4].minor.yy342.pExpr->x.pList = pList; |
| 134519 | + ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr); |
| 134520 | + pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy190.pExpr); |
| 134521 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy190.pExpr, 0, 0); |
| 134522 | + if( yymsp[-4].minor.yy190.pExpr ){ |
| 134523 | + yymsp[-4].minor.yy190.pExpr->x.pList = pList; |
| 133671 | 134524 | }else{ |
| 133672 | 134525 | sqlite3ExprListDelete(pParse->db, pList); |
| 133673 | 134526 | } |
| 133674 | | - exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342); |
| 133675 | | - yymsp[-4].minor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 134527 | + exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 134528 | + yymsp[-4].minor.yy190.zEnd = yymsp[0].minor.yy190.zEnd; |
| 133676 | 134529 | } |
| 133677 | 134530 | break; |
| 133678 | 134531 | case 187: /* expr ::= expr in_op LP exprlist RP */ |
| 133679 | 134532 | { |
| 133680 | | - if( yymsp[-1].minor.yy442==0 ){ |
| 134533 | + if( yymsp[-1].minor.yy148==0 ){ |
| 133681 | 134534 | /* Expressions of the form |
| 133682 | 134535 | ** |
| 133683 | 134536 | ** expr1 IN () |
| 133684 | 134537 | ** expr1 NOT IN () |
| 133685 | 134538 | ** |
| 133686 | 134539 | ** simplify to constants 0 (false) and 1 (true), respectively, |
| 133687 | 134540 | ** regardless of the value of expr1. |
| 133688 | 134541 | */ |
| 133689 | | - sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy342.pExpr); |
| 133690 | | - yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy392]); |
| 133691 | | - }else if( yymsp[-1].minor.yy442->nExpr==1 ){ |
| 134542 | + sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy190.pExpr); |
| 134543 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_INTEGER, 0, 0, &sqlite3IntTokens[yymsp[-3].minor.yy194]); |
| 134544 | + }else if( yymsp[-1].minor.yy148->nExpr==1 ){ |
| 133692 | 134545 | /* Expressions of the form: |
| 133693 | 134546 | ** |
| 133694 | 134547 | ** expr1 IN (?1) |
| 133695 | 134548 | ** expr1 NOT IN (?2) |
| 133696 | 134549 | ** |
| | @@ -133703,417 +134556,421 @@ |
| 133703 | 134556 | ** But, the RHS of the == or <> is marked with the EP_Generic flag |
| 133704 | 134557 | ** so that it may not contribute to the computation of comparison |
| 133705 | 134558 | ** affinity or the collating sequence to use for comparison. Otherwise, |
| 133706 | 134559 | ** the semantics would be subtly different from IN or NOT IN. |
| 133707 | 134560 | */ |
| 133708 | | - Expr *pRHS = yymsp[-1].minor.yy442->a[0].pExpr; |
| 133709 | | - yymsp[-1].minor.yy442->a[0].pExpr = 0; |
| 133710 | | - sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442); |
| 134561 | + Expr *pRHS = yymsp[-1].minor.yy148->a[0].pExpr; |
| 134562 | + yymsp[-1].minor.yy148->a[0].pExpr = 0; |
| 134563 | + sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148); |
| 133711 | 134564 | /* pRHS cannot be NULL because a malloc error would have been detected |
| 133712 | 134565 | ** before now and control would have never reached this point */ |
| 133713 | 134566 | if( ALWAYS(pRHS) ){ |
| 133714 | 134567 | pRHS->flags &= ~EP_Collate; |
| 133715 | 134568 | pRHS->flags |= EP_Generic; |
| 133716 | 134569 | } |
| 133717 | | - yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy392 ? TK_NE : TK_EQ, yymsp[-4].minor.yy342.pExpr, pRHS, 0); |
| 133718 | | - }else{ |
| 133719 | | - yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 133720 | | - if( yymsp[-4].minor.yy342.pExpr ){ |
| 133721 | | - yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy442; |
| 133722 | | - sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr); |
| 133723 | | - }else{ |
| 133724 | | - sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy442); |
| 133725 | | - } |
| 133726 | | - exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342); |
| 133727 | | - } |
| 133728 | | - yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 134570 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, yymsp[-3].minor.yy194 ? TK_NE : TK_EQ, yymsp[-4].minor.yy190.pExpr, pRHS, 0); |
| 134571 | + }else{ |
| 134572 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0); |
| 134573 | + if( yymsp[-4].minor.yy190.pExpr ){ |
| 134574 | + yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy148; |
| 134575 | + sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr); |
| 134576 | + }else{ |
| 134577 | + sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy148); |
| 134578 | + } |
| 134579 | + exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 134580 | + } |
| 134581 | + yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 133729 | 134582 | } |
| 133730 | 134583 | break; |
| 133731 | 134584 | case 188: /* expr ::= LP select RP */ |
| 133732 | 134585 | { |
| 133733 | | - spanSet(&yymsp[-2].minor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ |
| 133734 | | - yymsp[-2].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 133735 | | - sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy342.pExpr, yymsp[-1].minor.yy159); |
| 134586 | + spanSet(&yymsp[-2].minor.yy190,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ |
| 134587 | + yymsp[-2].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 134588 | + sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy190.pExpr, yymsp[-1].minor.yy243); |
| 133736 | 134589 | } |
| 133737 | 134590 | break; |
| 133738 | 134591 | case 189: /* expr ::= expr in_op LP select RP */ |
| 133739 | 134592 | { |
| 133740 | | - yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 133741 | | - sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy342.pExpr, yymsp[-1].minor.yy159); |
| 133742 | | - exprNot(pParse, yymsp[-3].minor.yy392, &yymsp[-4].minor.yy342); |
| 133743 | | - yymsp[-4].minor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 133744 | | - } |
| 133745 | | - break; |
| 133746 | | - case 190: /* expr ::= expr in_op nm dbnm */ |
| 133747 | | -{ |
| 133748 | | - SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 134593 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0); |
| 134594 | + sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, yymsp[-1].minor.yy243); |
| 134595 | + exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 134596 | + yymsp[-4].minor.yy190.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 134597 | + } |
| 134598 | + break; |
| 134599 | + case 190: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 134600 | +{ |
| 134601 | + SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 133749 | 134602 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| 133750 | | - yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0); |
| 133751 | | - sqlite3PExprAddSelect(pParse, yymsp[-3].minor.yy342.pExpr, pSelect); |
| 133752 | | - exprNot(pParse, yymsp[-2].minor.yy392, &yymsp[-3].minor.yy342); |
| 133753 | | - yymsp[-3].minor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]; |
| 134603 | + if( yymsp[0].minor.yy148 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy148); |
| 134604 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy190.pExpr, 0, 0); |
| 134605 | + sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy190.pExpr, pSelect); |
| 134606 | + exprNot(pParse, yymsp[-3].minor.yy194, &yymsp[-4].minor.yy190); |
| 134607 | + yymsp[-4].minor.yy190.zEnd = yymsp[-1].minor.yy0.z ? &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n] : &yymsp[-2].minor.yy0.z[yymsp[-2].minor.yy0.n]; |
| 133754 | 134608 | } |
| 133755 | 134609 | break; |
| 133756 | 134610 | case 191: /* expr ::= EXISTS LP select RP */ |
| 133757 | 134611 | { |
| 133758 | 134612 | Expr *p; |
| 133759 | | - spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ |
| 133760 | | - p = yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 133761 | | - sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy159); |
| 134613 | + spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-B*/ |
| 134614 | + p = yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 134615 | + sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy243); |
| 133762 | 134616 | } |
| 133763 | 134617 | break; |
| 133764 | 134618 | case 192: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 133765 | 134619 | { |
| 133766 | | - spanSet(&yymsp[-4].minor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/ |
| 133767 | | - yymsp[-4].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, 0, 0); |
| 133768 | | - if( yymsp[-4].minor.yy342.pExpr ){ |
| 133769 | | - yymsp[-4].minor.yy342.pExpr->x.pList = yymsp[-1].minor.yy122 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[-1].minor.yy122) : yymsp[-2].minor.yy442; |
| 133770 | | - sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy342.pExpr); |
| 134620 | + spanSet(&yymsp[-4].minor.yy190,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-C*/ |
| 134621 | + yymsp[-4].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy72, 0, 0); |
| 134622 | + if( yymsp[-4].minor.yy190.pExpr ){ |
| 134623 | + yymsp[-4].minor.yy190.pExpr->x.pList = yymsp[-1].minor.yy72 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[-1].minor.yy72) : yymsp[-2].minor.yy148; |
| 134624 | + sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy190.pExpr); |
| 133771 | 134625 | }else{ |
| 133772 | | - sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy442); |
| 133773 | | - sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy122); |
| 134626 | + sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy148); |
| 134627 | + sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy72); |
| 133774 | 134628 | } |
| 133775 | 134629 | } |
| 133776 | 134630 | break; |
| 133777 | 134631 | case 193: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 133778 | 134632 | { |
| 133779 | | - yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr); |
| 133780 | | - yymsp[-4].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr); |
| 134633 | + yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[-2].minor.yy190.pExpr); |
| 134634 | + yymsp[-4].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy148, yymsp[0].minor.yy190.pExpr); |
| 133781 | 134635 | } |
| 133782 | 134636 | break; |
| 133783 | 134637 | case 194: /* case_exprlist ::= WHEN expr THEN expr */ |
| 133784 | 134638 | { |
| 133785 | | - yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 133786 | | - yymsp[-3].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, yymsp[0].minor.yy342.pExpr); |
| 134639 | + yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy190.pExpr); |
| 134640 | + yymsp[-3].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy148, yymsp[0].minor.yy190.pExpr); |
| 133787 | 134641 | } |
| 133788 | 134642 | break; |
| 133789 | 134643 | case 197: /* case_operand ::= expr */ |
| 133790 | | -{yymsp[0].minor.yy122 = yymsp[0].minor.yy342.pExpr; /*A-overwrites-X*/} |
| 134644 | +{yymsp[0].minor.yy72 = yymsp[0].minor.yy190.pExpr; /*A-overwrites-X*/} |
| 133791 | 134645 | break; |
| 133792 | 134646 | case 200: /* nexprlist ::= nexprlist COMMA expr */ |
| 133793 | | -{yymsp[-2].minor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);} |
| 134647 | +{yymsp[-2].minor.yy148 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy148,yymsp[0].minor.yy190.pExpr);} |
| 133794 | 134648 | break; |
| 133795 | 134649 | case 201: /* nexprlist ::= expr */ |
| 133796 | | -{yymsp[0].minor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr); /*A-overwrites-Y*/} |
| 134650 | +{yymsp[0].minor.yy148 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy190.pExpr); /*A-overwrites-Y*/} |
| 133797 | 134651 | break; |
| 133798 | | - case 202: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 134652 | + case 203: /* paren_exprlist ::= LP exprlist RP */ |
| 134653 | + case 208: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==208); |
| 134654 | +{yymsp[-2].minor.yy148 = yymsp[-1].minor.yy148;} |
| 134655 | + break; |
| 134656 | + case 204: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 133799 | 134657 | { |
| 133800 | 134658 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 133801 | | - sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy442, yymsp[-10].minor.yy392, |
| 133802 | | - &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy392); |
| 133803 | | -} |
| 133804 | | - break; |
| 133805 | | - case 203: /* uniqueflag ::= UNIQUE */ |
| 133806 | | - case 244: /* raisetype ::= ABORT */ yytestcase(yyruleno==244); |
| 133807 | | -{yymsp[0].minor.yy392 = OE_Abort;} |
| 133808 | | - break; |
| 133809 | | - case 204: /* uniqueflag ::= */ |
| 133810 | | -{yymsp[1].minor.yy392 = OE_None;} |
| 133811 | | - break; |
| 133812 | | - case 206: /* eidlist_opt ::= LP eidlist RP */ |
| 133813 | | -{yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442;} |
| 133814 | | - break; |
| 133815 | | - case 207: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 133816 | | -{ |
| 133817 | | - yymsp[-4].minor.yy442 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy442, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); |
| 133818 | | -} |
| 133819 | | - break; |
| 133820 | | - case 208: /* eidlist ::= nm collate sortorder */ |
| 133821 | | -{ |
| 133822 | | - yymsp[-2].minor.yy442 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); /*A-overwrites-Y*/ |
| 133823 | | -} |
| 133824 | | - break; |
| 133825 | | - case 211: /* cmd ::= DROP INDEX ifexists fullname */ |
| 133826 | | -{sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);} |
| 133827 | | - break; |
| 133828 | | - case 212: /* cmd ::= VACUUM */ |
| 133829 | | - case 213: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==213); |
| 134659 | + sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy148, yymsp[-10].minor.yy194, |
| 134660 | + &yymsp[-11].minor.yy0, yymsp[0].minor.yy72, SQLITE_SO_ASC, yymsp[-8].minor.yy194, SQLITE_IDXTYPE_APPDEF); |
| 134661 | +} |
| 134662 | + break; |
| 134663 | + case 205: /* uniqueflag ::= UNIQUE */ |
| 134664 | + case 246: /* raisetype ::= ABORT */ yytestcase(yyruleno==246); |
| 134665 | +{yymsp[0].minor.yy194 = OE_Abort;} |
| 134666 | + break; |
| 134667 | + case 206: /* uniqueflag ::= */ |
| 134668 | +{yymsp[1].minor.yy194 = OE_None;} |
| 134669 | + break; |
| 134670 | + case 209: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 134671 | +{ |
| 134672 | + yymsp[-4].minor.yy148 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy148, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); |
| 134673 | +} |
| 134674 | + break; |
| 134675 | + case 210: /* eidlist ::= nm collate sortorder */ |
| 134676 | +{ |
| 134677 | + yymsp[-2].minor.yy148 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy194, yymsp[0].minor.yy194); /*A-overwrites-Y*/ |
| 134678 | +} |
| 134679 | + break; |
| 134680 | + case 213: /* cmd ::= DROP INDEX ifexists fullname */ |
| 134681 | +{sqlite3DropIndex(pParse, yymsp[0].minor.yy185, yymsp[-1].minor.yy194);} |
| 134682 | + break; |
| 134683 | + case 214: /* cmd ::= VACUUM */ |
| 134684 | + case 215: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==215); |
| 133830 | 134685 | {sqlite3Vacuum(pParse);} |
| 133831 | 134686 | break; |
| 133832 | | - case 214: /* cmd ::= PRAGMA nm dbnm */ |
| 134687 | + case 216: /* cmd ::= PRAGMA nm dbnm */ |
| 133833 | 134688 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 133834 | 134689 | break; |
| 133835 | | - case 215: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 134690 | + case 217: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 133836 | 134691 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 133837 | 134692 | break; |
| 133838 | | - case 216: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 134693 | + case 218: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 133839 | 134694 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 133840 | 134695 | break; |
| 133841 | | - case 217: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 134696 | + case 219: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 133842 | 134697 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 133843 | 134698 | break; |
| 133844 | | - case 218: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 134699 | + case 220: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 133845 | 134700 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 133846 | 134701 | break; |
| 133847 | | - case 221: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 134702 | + case 223: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 133848 | 134703 | { |
| 133849 | 134704 | Token all; |
| 133850 | 134705 | all.z = yymsp[-3].minor.yy0.z; |
| 133851 | 134706 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 133852 | | - sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all); |
| 134707 | + sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy145, &all); |
| 133853 | 134708 | } |
| 133854 | 134709 | break; |
| 133855 | | - case 222: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 134710 | + case 224: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 133856 | 134711 | { |
| 133857 | | - sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392); |
| 134712 | + sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy194, yymsp[-4].minor.yy332.a, yymsp[-4].minor.yy332.b, yymsp[-2].minor.yy185, yymsp[0].minor.yy72, yymsp[-10].minor.yy194, yymsp[-8].minor.yy194); |
| 133858 | 134713 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 133859 | 134714 | } |
| 133860 | 134715 | break; |
| 133861 | | - case 223: /* trigger_time ::= BEFORE */ |
| 133862 | | -{ yymsp[0].minor.yy392 = TK_BEFORE; } |
| 133863 | | - break; |
| 133864 | | - case 224: /* trigger_time ::= AFTER */ |
| 133865 | | -{ yymsp[0].minor.yy392 = TK_AFTER; } |
| 133866 | | - break; |
| 133867 | | - case 225: /* trigger_time ::= INSTEAD OF */ |
| 133868 | | -{ yymsp[-1].minor.yy392 = TK_INSTEAD;} |
| 133869 | | - break; |
| 133870 | | - case 226: /* trigger_time ::= */ |
| 133871 | | -{ yymsp[1].minor.yy392 = TK_BEFORE; } |
| 133872 | | - break; |
| 133873 | | - case 227: /* trigger_event ::= DELETE|INSERT */ |
| 133874 | | - case 228: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==228); |
| 133875 | | -{yymsp[0].minor.yy410.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy410.b = 0;} |
| 133876 | | - break; |
| 133877 | | - case 229: /* trigger_event ::= UPDATE OF idlist */ |
| 133878 | | -{yymsp[-2].minor.yy410.a = TK_UPDATE; yymsp[-2].minor.yy410.b = yymsp[0].minor.yy180;} |
| 133879 | | - break; |
| 133880 | | - case 230: /* when_clause ::= */ |
| 133881 | | - case 249: /* key_opt ::= */ yytestcase(yyruleno==249); |
| 133882 | | -{ yymsp[1].minor.yy122 = 0; } |
| 133883 | | - break; |
| 133884 | | - case 231: /* when_clause ::= WHEN expr */ |
| 133885 | | - case 250: /* key_opt ::= KEY expr */ yytestcase(yyruleno==250); |
| 133886 | | -{ yymsp[-1].minor.yy122 = yymsp[0].minor.yy342.pExpr; } |
| 133887 | | - break; |
| 133888 | | - case 232: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 133889 | | -{ |
| 133890 | | - assert( yymsp[-2].minor.yy327!=0 ); |
| 133891 | | - yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327; |
| 133892 | | - yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327; |
| 133893 | | -} |
| 133894 | | - break; |
| 133895 | | - case 233: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 133896 | | -{ |
| 133897 | | - assert( yymsp[-1].minor.yy327!=0 ); |
| 133898 | | - yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327; |
| 133899 | | -} |
| 133900 | | - break; |
| 133901 | | - case 234: /* trnm ::= nm DOT nm */ |
| 134716 | + case 225: /* trigger_time ::= BEFORE */ |
| 134717 | +{ yymsp[0].minor.yy194 = TK_BEFORE; } |
| 134718 | + break; |
| 134719 | + case 226: /* trigger_time ::= AFTER */ |
| 134720 | +{ yymsp[0].minor.yy194 = TK_AFTER; } |
| 134721 | + break; |
| 134722 | + case 227: /* trigger_time ::= INSTEAD OF */ |
| 134723 | +{ yymsp[-1].minor.yy194 = TK_INSTEAD;} |
| 134724 | + break; |
| 134725 | + case 228: /* trigger_time ::= */ |
| 134726 | +{ yymsp[1].minor.yy194 = TK_BEFORE; } |
| 134727 | + break; |
| 134728 | + case 229: /* trigger_event ::= DELETE|INSERT */ |
| 134729 | + case 230: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==230); |
| 134730 | +{yymsp[0].minor.yy332.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy332.b = 0;} |
| 134731 | + break; |
| 134732 | + case 231: /* trigger_event ::= UPDATE OF idlist */ |
| 134733 | +{yymsp[-2].minor.yy332.a = TK_UPDATE; yymsp[-2].minor.yy332.b = yymsp[0].minor.yy254;} |
| 134734 | + break; |
| 134735 | + case 232: /* when_clause ::= */ |
| 134736 | + case 251: /* key_opt ::= */ yytestcase(yyruleno==251); |
| 134737 | +{ yymsp[1].minor.yy72 = 0; } |
| 134738 | + break; |
| 134739 | + case 233: /* when_clause ::= WHEN expr */ |
| 134740 | + case 252: /* key_opt ::= KEY expr */ yytestcase(yyruleno==252); |
| 134741 | +{ yymsp[-1].minor.yy72 = yymsp[0].minor.yy190.pExpr; } |
| 134742 | + break; |
| 134743 | + case 234: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 134744 | +{ |
| 134745 | + assert( yymsp[-2].minor.yy145!=0 ); |
| 134746 | + yymsp[-2].minor.yy145->pLast->pNext = yymsp[-1].minor.yy145; |
| 134747 | + yymsp[-2].minor.yy145->pLast = yymsp[-1].minor.yy145; |
| 134748 | +} |
| 134749 | + break; |
| 134750 | + case 235: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 134751 | +{ |
| 134752 | + assert( yymsp[-1].minor.yy145!=0 ); |
| 134753 | + yymsp[-1].minor.yy145->pLast = yymsp[-1].minor.yy145; |
| 134754 | +} |
| 134755 | + break; |
| 134756 | + case 236: /* trnm ::= nm DOT nm */ |
| 133902 | 134757 | { |
| 133903 | 134758 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 133904 | 134759 | sqlite3ErrorMsg(pParse, |
| 133905 | 134760 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 133906 | 134761 | "statements within triggers"); |
| 133907 | 134762 | } |
| 133908 | 134763 | break; |
| 133909 | | - case 235: /* tridxby ::= INDEXED BY nm */ |
| 134764 | + case 237: /* tridxby ::= INDEXED BY nm */ |
| 133910 | 134765 | { |
| 133911 | 134766 | sqlite3ErrorMsg(pParse, |
| 133912 | 134767 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 133913 | 134768 | "within triggers"); |
| 133914 | 134769 | } |
| 133915 | 134770 | break; |
| 133916 | | - case 236: /* tridxby ::= NOT INDEXED */ |
| 134771 | + case 238: /* tridxby ::= NOT INDEXED */ |
| 133917 | 134772 | { |
| 133918 | 134773 | sqlite3ErrorMsg(pParse, |
| 133919 | 134774 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 133920 | 134775 | "within triggers"); |
| 133921 | 134776 | } |
| 133922 | 134777 | break; |
| 133923 | | - case 237: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 133924 | | -{yymsp[-6].minor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy392);} |
| 133925 | | - break; |
| 133926 | | - case 238: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */ |
| 133927 | | -{yymsp[-4].minor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy159, yymsp[-4].minor.yy392);/*A-overwrites-R*/} |
| 133928 | | - break; |
| 133929 | | - case 239: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 133930 | | -{yymsp[-4].minor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);} |
| 133931 | | - break; |
| 133932 | | - case 240: /* trigger_cmd ::= select */ |
| 133933 | | -{yymsp[0].minor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); /*A-overwrites-X*/} |
| 133934 | | - break; |
| 133935 | | - case 241: /* expr ::= RAISE LP IGNORE RP */ |
| 133936 | | -{ |
| 133937 | | - spanSet(&yymsp[-3].minor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 133938 | | - yymsp[-3].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 133939 | | - if( yymsp[-3].minor.yy342.pExpr ){ |
| 133940 | | - yymsp[-3].minor.yy342.pExpr->affinity = OE_Ignore; |
| 133941 | | - } |
| 133942 | | -} |
| 133943 | | - break; |
| 133944 | | - case 242: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 133945 | | -{ |
| 133946 | | - spanSet(&yymsp[-5].minor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 133947 | | - yymsp[-5].minor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 133948 | | - if( yymsp[-5].minor.yy342.pExpr ) { |
| 133949 | | - yymsp[-5].minor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392; |
| 133950 | | - } |
| 133951 | | -} |
| 133952 | | - break; |
| 133953 | | - case 243: /* raisetype ::= ROLLBACK */ |
| 133954 | | -{yymsp[0].minor.yy392 = OE_Rollback;} |
| 133955 | | - break; |
| 133956 | | - case 245: /* raisetype ::= FAIL */ |
| 133957 | | -{yymsp[0].minor.yy392 = OE_Fail;} |
| 133958 | | - break; |
| 133959 | | - case 246: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 133960 | | -{ |
| 133961 | | - sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392); |
| 133962 | | -} |
| 133963 | | - break; |
| 133964 | | - case 247: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 133965 | | -{ |
| 133966 | | - sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122); |
| 133967 | | -} |
| 133968 | | - break; |
| 133969 | | - case 248: /* cmd ::= DETACH database_kw_opt expr */ |
| 133970 | | -{ |
| 133971 | | - sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr); |
| 133972 | | -} |
| 133973 | | - break; |
| 133974 | | - case 251: /* cmd ::= REINDEX */ |
| 134778 | + case 239: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 134779 | +{yymsp[-6].minor.yy145 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy148, yymsp[0].minor.yy72, yymsp[-5].minor.yy194);} |
| 134780 | + break; |
| 134781 | + case 240: /* trigger_cmd ::= insert_cmd INTO trnm idlist_opt select */ |
| 134782 | +{yymsp[-4].minor.yy145 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy254, yymsp[0].minor.yy243, yymsp[-4].minor.yy194);/*A-overwrites-R*/} |
| 134783 | + break; |
| 134784 | + case 241: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 134785 | +{yymsp[-4].minor.yy145 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy72);} |
| 134786 | + break; |
| 134787 | + case 242: /* trigger_cmd ::= select */ |
| 134788 | +{yymsp[0].minor.yy145 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy243); /*A-overwrites-X*/} |
| 134789 | + break; |
| 134790 | + case 243: /* expr ::= RAISE LP IGNORE RP */ |
| 134791 | +{ |
| 134792 | + spanSet(&yymsp[-3].minor.yy190,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 134793 | + yymsp[-3].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 134794 | + if( yymsp[-3].minor.yy190.pExpr ){ |
| 134795 | + yymsp[-3].minor.yy190.pExpr->affinity = OE_Ignore; |
| 134796 | + } |
| 134797 | +} |
| 134798 | + break; |
| 134799 | + case 244: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 134800 | +{ |
| 134801 | + spanSet(&yymsp[-5].minor.yy190,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/ |
| 134802 | + yymsp[-5].minor.yy190.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 134803 | + if( yymsp[-5].minor.yy190.pExpr ) { |
| 134804 | + yymsp[-5].minor.yy190.pExpr->affinity = (char)yymsp[-3].minor.yy194; |
| 134805 | + } |
| 134806 | +} |
| 134807 | + break; |
| 134808 | + case 245: /* raisetype ::= ROLLBACK */ |
| 134809 | +{yymsp[0].minor.yy194 = OE_Rollback;} |
| 134810 | + break; |
| 134811 | + case 247: /* raisetype ::= FAIL */ |
| 134812 | +{yymsp[0].minor.yy194 = OE_Fail;} |
| 134813 | + break; |
| 134814 | + case 248: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 134815 | +{ |
| 134816 | + sqlite3DropTrigger(pParse,yymsp[0].minor.yy185,yymsp[-1].minor.yy194); |
| 134817 | +} |
| 134818 | + break; |
| 134819 | + case 249: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 134820 | +{ |
| 134821 | + sqlite3Attach(pParse, yymsp[-3].minor.yy190.pExpr, yymsp[-1].minor.yy190.pExpr, yymsp[0].minor.yy72); |
| 134822 | +} |
| 134823 | + break; |
| 134824 | + case 250: /* cmd ::= DETACH database_kw_opt expr */ |
| 134825 | +{ |
| 134826 | + sqlite3Detach(pParse, yymsp[0].minor.yy190.pExpr); |
| 134827 | +} |
| 134828 | + break; |
| 134829 | + case 253: /* cmd ::= REINDEX */ |
| 133975 | 134830 | {sqlite3Reindex(pParse, 0, 0);} |
| 133976 | 134831 | break; |
| 133977 | | - case 252: /* cmd ::= REINDEX nm dbnm */ |
| 134832 | + case 254: /* cmd ::= REINDEX nm dbnm */ |
| 133978 | 134833 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 133979 | 134834 | break; |
| 133980 | | - case 253: /* cmd ::= ANALYZE */ |
| 134835 | + case 255: /* cmd ::= ANALYZE */ |
| 133981 | 134836 | {sqlite3Analyze(pParse, 0, 0);} |
| 133982 | 134837 | break; |
| 133983 | | - case 254: /* cmd ::= ANALYZE nm dbnm */ |
| 134838 | + case 256: /* cmd ::= ANALYZE nm dbnm */ |
| 133984 | 134839 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 133985 | 134840 | break; |
| 133986 | | - case 255: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 134841 | + case 257: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 133987 | 134842 | { |
| 133988 | | - sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0); |
| 134843 | + sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy185,&yymsp[0].minor.yy0); |
| 133989 | 134844 | } |
| 133990 | 134845 | break; |
| 133991 | | - case 256: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 134846 | + case 258: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 133992 | 134847 | { |
| 133993 | 134848 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 133994 | 134849 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 133995 | 134850 | } |
| 133996 | 134851 | break; |
| 133997 | | - case 257: /* add_column_fullname ::= fullname */ |
| 134852 | + case 259: /* add_column_fullname ::= fullname */ |
| 133998 | 134853 | { |
| 133999 | 134854 | disableLookaside(pParse); |
| 134000 | | - sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347); |
| 134855 | + sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy185); |
| 134001 | 134856 | } |
| 134002 | 134857 | break; |
| 134003 | | - case 258: /* cmd ::= create_vtab */ |
| 134858 | + case 260: /* cmd ::= create_vtab */ |
| 134004 | 134859 | {sqlite3VtabFinishParse(pParse,0);} |
| 134005 | 134860 | break; |
| 134006 | | - case 259: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 134861 | + case 261: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 134007 | 134862 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 134008 | 134863 | break; |
| 134009 | | - case 260: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 134864 | + case 262: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 134010 | 134865 | { |
| 134011 | | - sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392); |
| 134866 | + sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy194); |
| 134012 | 134867 | } |
| 134013 | 134868 | break; |
| 134014 | | - case 261: /* vtabarg ::= */ |
| 134869 | + case 263: /* vtabarg ::= */ |
| 134015 | 134870 | {sqlite3VtabArgInit(pParse);} |
| 134016 | 134871 | break; |
| 134017 | | - case 262: /* vtabargtoken ::= ANY */ |
| 134018 | | - case 263: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==263); |
| 134019 | | - case 264: /* lp ::= LP */ yytestcase(yyruleno==264); |
| 134872 | + case 264: /* vtabargtoken ::= ANY */ |
| 134873 | + case 265: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==265); |
| 134874 | + case 266: /* lp ::= LP */ yytestcase(yyruleno==266); |
| 134020 | 134875 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 134021 | 134876 | break; |
| 134022 | | - case 265: /* with ::= */ |
| 134023 | | -{yymsp[1].minor.yy331 = 0;} |
| 134024 | | - break; |
| 134025 | | - case 266: /* with ::= WITH wqlist */ |
| 134026 | | -{ yymsp[-1].minor.yy331 = yymsp[0].minor.yy331; } |
| 134027 | | - break; |
| 134028 | | - case 267: /* with ::= WITH RECURSIVE wqlist */ |
| 134029 | | -{ yymsp[-2].minor.yy331 = yymsp[0].minor.yy331; } |
| 134030 | | - break; |
| 134031 | | - case 268: /* wqlist ::= nm eidlist_opt AS LP select RP */ |
| 134032 | | -{ |
| 134033 | | - yymsp[-5].minor.yy331 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159); /*A-overwrites-X*/ |
| 134034 | | -} |
| 134035 | | - break; |
| 134036 | | - case 269: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ |
| 134037 | | -{ |
| 134038 | | - yymsp[-7].minor.yy331 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy331, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy442, yymsp[-1].minor.yy159); |
| 134877 | + case 267: /* with ::= */ |
| 134878 | +{yymsp[1].minor.yy285 = 0;} |
| 134879 | + break; |
| 134880 | + case 268: /* with ::= WITH wqlist */ |
| 134881 | +{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; } |
| 134882 | + break; |
| 134883 | + case 269: /* with ::= WITH RECURSIVE wqlist */ |
| 134884 | +{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285; } |
| 134885 | + break; |
| 134886 | + case 270: /* wqlist ::= nm eidlist_opt AS LP select RP */ |
| 134887 | +{ |
| 134888 | + yymsp[-5].minor.yy285 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); /*A-overwrites-X*/ |
| 134889 | +} |
| 134890 | + break; |
| 134891 | + case 271: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */ |
| 134892 | +{ |
| 134893 | + yymsp[-7].minor.yy285 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy285, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy148, yymsp[-1].minor.yy243); |
| 134039 | 134894 | } |
| 134040 | 134895 | break; |
| 134041 | 134896 | default: |
| 134042 | | - /* (270) input ::= cmdlist */ yytestcase(yyruleno==270); |
| 134043 | | - /* (271) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==271); |
| 134044 | | - /* (272) cmdlist ::= ecmd */ yytestcase(yyruleno==272); |
| 134045 | | - /* (273) ecmd ::= SEMI */ yytestcase(yyruleno==273); |
| 134046 | | - /* (274) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==274); |
| 134047 | | - /* (275) explain ::= */ yytestcase(yyruleno==275); |
| 134048 | | - /* (276) trans_opt ::= */ yytestcase(yyruleno==276); |
| 134049 | | - /* (277) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==277); |
| 134050 | | - /* (278) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==278); |
| 134051 | | - /* (279) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==279); |
| 134052 | | - /* (280) savepoint_opt ::= */ yytestcase(yyruleno==280); |
| 134053 | | - /* (281) cmd ::= create_table create_table_args */ yytestcase(yyruleno==281); |
| 134054 | | - /* (282) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==282); |
| 134055 | | - /* (283) columnlist ::= columnname carglist */ yytestcase(yyruleno==283); |
| 134056 | | - /* (284) nm ::= ID|INDEXED */ yytestcase(yyruleno==284); |
| 134057 | | - /* (285) nm ::= STRING */ yytestcase(yyruleno==285); |
| 134058 | | - /* (286) nm ::= JOIN_KW */ yytestcase(yyruleno==286); |
| 134059 | | - /* (287) typetoken ::= typename */ yytestcase(yyruleno==287); |
| 134060 | | - /* (288) typename ::= ID|STRING */ yytestcase(yyruleno==288); |
| 134061 | | - /* (289) signed ::= plus_num */ yytestcase(yyruleno==289); |
| 134062 | | - /* (290) signed ::= minus_num */ yytestcase(yyruleno==290); |
| 134063 | | - /* (291) carglist ::= carglist ccons */ yytestcase(yyruleno==291); |
| 134064 | | - /* (292) carglist ::= */ yytestcase(yyruleno==292); |
| 134065 | | - /* (293) ccons ::= NULL onconf */ yytestcase(yyruleno==293); |
| 134066 | | - /* (294) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==294); |
| 134067 | | - /* (295) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==295); |
| 134068 | | - /* (296) conslist ::= tcons */ yytestcase(yyruleno==296); |
| 134069 | | - /* (297) tconscomma ::= */ yytestcase(yyruleno==297); |
| 134070 | | - /* (298) defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==298); |
| 134071 | | - /* (299) resolvetype ::= raisetype */ yytestcase(yyruleno==299); |
| 134072 | | - /* (300) selectnowith ::= oneselect */ yytestcase(yyruleno==300); |
| 134073 | | - /* (301) oneselect ::= values */ yytestcase(yyruleno==301); |
| 134074 | | - /* (302) sclp ::= selcollist COMMA */ yytestcase(yyruleno==302); |
| 134075 | | - /* (303) as ::= ID|STRING */ yytestcase(yyruleno==303); |
| 134076 | | - /* (304) expr ::= term */ yytestcase(yyruleno==304); |
| 134077 | | - /* (305) exprlist ::= nexprlist */ yytestcase(yyruleno==305); |
| 134078 | | - /* (306) nmnum ::= plus_num */ yytestcase(yyruleno==306); |
| 134079 | | - /* (307) nmnum ::= nm */ yytestcase(yyruleno==307); |
| 134080 | | - /* (308) nmnum ::= ON */ yytestcase(yyruleno==308); |
| 134081 | | - /* (309) nmnum ::= DELETE */ yytestcase(yyruleno==309); |
| 134082 | | - /* (310) nmnum ::= DEFAULT */ yytestcase(yyruleno==310); |
| 134083 | | - /* (311) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==311); |
| 134084 | | - /* (312) foreach_clause ::= */ yytestcase(yyruleno==312); |
| 134085 | | - /* (313) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==313); |
| 134086 | | - /* (314) trnm ::= nm */ yytestcase(yyruleno==314); |
| 134087 | | - /* (315) tridxby ::= */ yytestcase(yyruleno==315); |
| 134088 | | - /* (316) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==316); |
| 134089 | | - /* (317) database_kw_opt ::= */ yytestcase(yyruleno==317); |
| 134090 | | - /* (318) kwcolumn_opt ::= */ yytestcase(yyruleno==318); |
| 134091 | | - /* (319) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==319); |
| 134092 | | - /* (320) vtabarglist ::= vtabarg */ yytestcase(yyruleno==320); |
| 134093 | | - /* (321) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==321); |
| 134094 | | - /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322); |
| 134095 | | - /* (323) anylist ::= */ yytestcase(yyruleno==323); |
| 134096 | | - /* (324) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==324); |
| 134097 | | - /* (325) anylist ::= anylist ANY */ yytestcase(yyruleno==325); |
| 134897 | + /* (272) input ::= cmdlist */ yytestcase(yyruleno==272); |
| 134898 | + /* (273) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==273); |
| 134899 | + /* (274) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=274); |
| 134900 | + /* (275) ecmd ::= SEMI */ yytestcase(yyruleno==275); |
| 134901 | + /* (276) ecmd ::= explain cmdx SEMI */ yytestcase(yyruleno==276); |
| 134902 | + /* (277) explain ::= */ yytestcase(yyruleno==277); |
| 134903 | + /* (278) trans_opt ::= */ yytestcase(yyruleno==278); |
| 134904 | + /* (279) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==279); |
| 134905 | + /* (280) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==280); |
| 134906 | + /* (281) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==281); |
| 134907 | + /* (282) savepoint_opt ::= */ yytestcase(yyruleno==282); |
| 134908 | + /* (283) cmd ::= create_table create_table_args */ yytestcase(yyruleno==283); |
| 134909 | + /* (284) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==284); |
| 134910 | + /* (285) columnlist ::= columnname carglist */ yytestcase(yyruleno==285); |
| 134911 | + /* (286) nm ::= ID|INDEXED */ yytestcase(yyruleno==286); |
| 134912 | + /* (287) nm ::= STRING */ yytestcase(yyruleno==287); |
| 134913 | + /* (288) nm ::= JOIN_KW */ yytestcase(yyruleno==288); |
| 134914 | + /* (289) typetoken ::= typename */ yytestcase(yyruleno==289); |
| 134915 | + /* (290) typename ::= ID|STRING */ yytestcase(yyruleno==290); |
| 134916 | + /* (291) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=291); |
| 134917 | + /* (292) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=292); |
| 134918 | + /* (293) carglist ::= carglist ccons */ yytestcase(yyruleno==293); |
| 134919 | + /* (294) carglist ::= */ yytestcase(yyruleno==294); |
| 134920 | + /* (295) ccons ::= NULL onconf */ yytestcase(yyruleno==295); |
| 134921 | + /* (296) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==296); |
| 134922 | + /* (297) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==297); |
| 134923 | + /* (298) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=298); |
| 134924 | + /* (299) tconscomma ::= */ yytestcase(yyruleno==299); |
| 134925 | + /* (300) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=300); |
| 134926 | + /* (301) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=301); |
| 134927 | + /* (302) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=302); |
| 134928 | + /* (303) oneselect ::= values */ yytestcase(yyruleno==303); |
| 134929 | + /* (304) sclp ::= selcollist COMMA */ yytestcase(yyruleno==304); |
| 134930 | + /* (305) as ::= ID|STRING */ yytestcase(yyruleno==305); |
| 134931 | + /* (306) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=306); |
| 134932 | + /* (307) exprlist ::= nexprlist */ yytestcase(yyruleno==307); |
| 134933 | + /* (308) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=308); |
| 134934 | + /* (309) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=309); |
| 134935 | + /* (310) nmnum ::= ON */ yytestcase(yyruleno==310); |
| 134936 | + /* (311) nmnum ::= DELETE */ yytestcase(yyruleno==311); |
| 134937 | + /* (312) nmnum ::= DEFAULT */ yytestcase(yyruleno==312); |
| 134938 | + /* (313) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==313); |
| 134939 | + /* (314) foreach_clause ::= */ yytestcase(yyruleno==314); |
| 134940 | + /* (315) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==315); |
| 134941 | + /* (316) trnm ::= nm */ yytestcase(yyruleno==316); |
| 134942 | + /* (317) tridxby ::= */ yytestcase(yyruleno==317); |
| 134943 | + /* (318) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==318); |
| 134944 | + /* (319) database_kw_opt ::= */ yytestcase(yyruleno==319); |
| 134945 | + /* (320) kwcolumn_opt ::= */ yytestcase(yyruleno==320); |
| 134946 | + /* (321) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==321); |
| 134947 | + /* (322) vtabarglist ::= vtabarg */ yytestcase(yyruleno==322); |
| 134948 | + /* (323) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==323); |
| 134949 | + /* (324) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==324); |
| 134950 | + /* (325) anylist ::= */ yytestcase(yyruleno==325); |
| 134951 | + /* (326) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==326); |
| 134952 | + /* (327) anylist ::= anylist ANY */ yytestcase(yyruleno==327); |
| 134098 | 134953 | break; |
| 134099 | 134954 | /********** End reduce actions ************************************************/ |
| 134100 | 134955 | }; |
| 134101 | 134956 | assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) ); |
| 134102 | 134957 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 134103 | 134958 | yysize = yyRuleInfo[yyruleno].nrhs; |
| 134104 | 134959 | yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); |
| 134105 | 134960 | if( yyact <= YY_MAX_SHIFTREDUCE ){ |
| 134106 | | - if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 134107 | | - yypParser->yyidx -= yysize - 1; |
| 134961 | + if( yyact>YY_MAX_SHIFT ){ |
| 134962 | + yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 134963 | + } |
| 134108 | 134964 | yymsp -= yysize-1; |
| 134965 | + yypParser->yytos = yymsp; |
| 134109 | 134966 | yymsp->stateno = (YYACTIONTYPE)yyact; |
| 134110 | 134967 | yymsp->major = (YYCODETYPE)yygoto; |
| 134111 | 134968 | yyTraceShift(yypParser, yyact); |
| 134112 | 134969 | }else{ |
| 134113 | 134970 | assert( yyact == YY_ACCEPT_ACTION ); |
| 134114 | | - yypParser->yyidx -= yysize; |
| 134971 | + yypParser->yytos -= yysize; |
| 134115 | 134972 | yy_accept(yypParser); |
| 134116 | 134973 | } |
| 134117 | 134974 | } |
| 134118 | 134975 | |
| 134119 | 134976 | /* |
| | @@ -134127,11 +134984,11 @@ |
| 134127 | 134984 | #ifndef NDEBUG |
| 134128 | 134985 | if( yyTraceFILE ){ |
| 134129 | 134986 | fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); |
| 134130 | 134987 | } |
| 134131 | 134988 | #endif |
| 134132 | | - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 134989 | + while( yypParser->yytos>yypParser->yystack ) yy_pop_parser_stack(yypParser); |
| 134133 | 134990 | /* Here code is inserted which will be executed whenever the |
| 134134 | 134991 | ** parser fails */ |
| 134135 | 134992 | /************ Begin %parse_failure code ***************************************/ |
| 134136 | 134993 | /************ End %parse_failure code *****************************************/ |
| 134137 | 134994 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| | @@ -134167,11 +135024,14 @@ |
| 134167 | 135024 | #ifndef NDEBUG |
| 134168 | 135025 | if( yyTraceFILE ){ |
| 134169 | 135026 | fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); |
| 134170 | 135027 | } |
| 134171 | 135028 | #endif |
| 134172 | | - while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
| 135029 | +#ifndef YYNOERRORRECOVERY |
| 135030 | + yypParser->yyerrcnt = -1; |
| 135031 | +#endif |
| 135032 | + assert( yypParser->yytos==yypParser->yystack ); |
| 134173 | 135033 | /* Here code is inserted which will be executed whenever the |
| 134174 | 135034 | ** parser accepts */ |
| 134175 | 135035 | /*********** Begin %parse_accept code *****************************************/ |
| 134176 | 135036 | /*********** End %parse_accept code *******************************************/ |
| 134177 | 135037 | sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| | @@ -134210,32 +135070,12 @@ |
| 134210 | 135070 | #ifdef YYERRORSYMBOL |
| 134211 | 135071 | int yyerrorhit = 0; /* True if yymajor has invoked an error */ |
| 134212 | 135072 | #endif |
| 134213 | 135073 | yyParser *yypParser; /* The parser */ |
| 134214 | 135074 | |
| 134215 | | - /* (re)initialize the parser, if necessary */ |
| 134216 | 135075 | yypParser = (yyParser*)yyp; |
| 134217 | | - if( yypParser->yyidx<0 ){ |
| 134218 | | -#if YYSTACKDEPTH<=0 |
| 134219 | | - if( yypParser->yystksz <=0 ){ |
| 134220 | | - yyStackOverflow(yypParser); |
| 134221 | | - return; |
| 134222 | | - } |
| 134223 | | -#endif |
| 134224 | | - yypParser->yyidx = 0; |
| 134225 | | -#ifndef YYNOERRORRECOVERY |
| 134226 | | - yypParser->yyerrcnt = -1; |
| 134227 | | -#endif |
| 134228 | | - yypParser->yystack[0].stateno = 0; |
| 134229 | | - yypParser->yystack[0].major = 0; |
| 134230 | | -#ifndef NDEBUG |
| 134231 | | - if( yyTraceFILE ){ |
| 134232 | | - fprintf(yyTraceFILE,"%sInitialize. Empty stack. State 0\n", |
| 134233 | | - yyTracePrompt); |
| 134234 | | - } |
| 134235 | | -#endif |
| 134236 | | - } |
| 135076 | + assert( yypParser->yytos!=0 ); |
| 134237 | 135077 | #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) |
| 134238 | 135078 | yyendofinput = (yymajor==0); |
| 134239 | 135079 | #endif |
| 134240 | 135080 | sqlite3ParserARG_STORE; |
| 134241 | 135081 | |
| | @@ -134246,11 +135086,10 @@ |
| 134246 | 135086 | #endif |
| 134247 | 135087 | |
| 134248 | 135088 | do{ |
| 134249 | 135089 | yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); |
| 134250 | 135090 | if( yyact <= YY_MAX_SHIFTREDUCE ){ |
| 134251 | | - if( yyact > YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE; |
| 134252 | 135091 | yy_shift(yypParser,yyact,yymajor,yyminor); |
| 134253 | 135092 | #ifndef YYNOERRORRECOVERY |
| 134254 | 135093 | yypParser->yyerrcnt--; |
| 134255 | 135094 | #endif |
| 134256 | 135095 | yymajor = YYNOCODE; |
| | @@ -134288,11 +135127,11 @@ |
| 134288 | 135127 | ** |
| 134289 | 135128 | */ |
| 134290 | 135129 | if( yypParser->yyerrcnt<0 ){ |
| 134291 | 135130 | yy_syntax_error(yypParser,yymajor,yyminor); |
| 134292 | 135131 | } |
| 134293 | | - yymx = yypParser->yystack[yypParser->yyidx].major; |
| 135132 | + yymx = yypParser->yytos->major; |
| 134294 | 135133 | if( yymx==YYERRORSYMBOL || yyerrorhit ){ |
| 134295 | 135134 | #ifndef NDEBUG |
| 134296 | 135135 | if( yyTraceFILE ){ |
| 134297 | 135136 | fprintf(yyTraceFILE,"%sDiscard input token %s\n", |
| 134298 | 135137 | yyTracePrompt,yyTokenName[yymajor]); |
| | @@ -134299,22 +135138,24 @@ |
| 134299 | 135138 | } |
| 134300 | 135139 | #endif |
| 134301 | 135140 | yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); |
| 134302 | 135141 | yymajor = YYNOCODE; |
| 134303 | 135142 | }else{ |
| 134304 | | - while( |
| 134305 | | - yypParser->yyidx >= 0 && |
| 134306 | | - yymx != YYERRORSYMBOL && |
| 134307 | | - (yyact = yy_find_reduce_action( |
| 134308 | | - yypParser->yystack[yypParser->yyidx].stateno, |
| 135143 | + while( yypParser->yytos >= &yypParser->yystack |
| 135144 | + && yymx != YYERRORSYMBOL |
| 135145 | + && (yyact = yy_find_reduce_action( |
| 135146 | + yypParser->yytos->stateno, |
| 134309 | 135147 | YYERRORSYMBOL)) >= YY_MIN_REDUCE |
| 134310 | 135148 | ){ |
| 134311 | 135149 | yy_pop_parser_stack(yypParser); |
| 134312 | 135150 | } |
| 134313 | | - if( yypParser->yyidx < 0 || yymajor==0 ){ |
| 135151 | + if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ |
| 134314 | 135152 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| 134315 | 135153 | yy_parse_failed(yypParser); |
| 135154 | +#ifndef YYNOERRORRECOVERY |
| 135155 | + yypParser->yyerrcnt = -1; |
| 135156 | +#endif |
| 134316 | 135157 | yymajor = YYNOCODE; |
| 134317 | 135158 | }else if( yymx!=YYERRORSYMBOL ){ |
| 134318 | 135159 | yy_shift(yypParser,yyact,YYERRORSYMBOL,yyminor); |
| 134319 | 135160 | } |
| 134320 | 135161 | } |
| | @@ -134347,22 +135188,27 @@ |
| 134347 | 135188 | } |
| 134348 | 135189 | yypParser->yyerrcnt = 3; |
| 134349 | 135190 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| 134350 | 135191 | if( yyendofinput ){ |
| 134351 | 135192 | yy_parse_failed(yypParser); |
| 135193 | +#ifndef YYNOERRORRECOVERY |
| 135194 | + yypParser->yyerrcnt = -1; |
| 135195 | +#endif |
| 134352 | 135196 | } |
| 134353 | 135197 | yymajor = YYNOCODE; |
| 134354 | 135198 | #endif |
| 134355 | 135199 | } |
| 134356 | | - }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
| 135200 | + }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); |
| 134357 | 135201 | #ifndef NDEBUG |
| 134358 | 135202 | if( yyTraceFILE ){ |
| 134359 | | - int i; |
| 135203 | + yyStackEntry *i; |
| 135204 | + char cDiv = '['; |
| 134360 | 135205 | fprintf(yyTraceFILE,"%sReturn. Stack=",yyTracePrompt); |
| 134361 | | - for(i=1; i<=yypParser->yyidx; i++) |
| 134362 | | - fprintf(yyTraceFILE,"%c%s", i==1 ? '[' : ' ', |
| 134363 | | - yyTokenName[yypParser->yystack[i].major]); |
| 135206 | + for(i=&yypParser->yystack[1]; i<=yypParser->yytos; i++){ |
| 135207 | + fprintf(yyTraceFILE,"%c%s", cDiv, yyTokenName[i->major]); |
| 135208 | + cDiv = ' '; |
| 135209 | + } |
| 134364 | 135210 | fprintf(yyTraceFILE,"]\n"); |
| 134365 | 135211 | } |
| 134366 | 135212 | #endif |
| 134367 | 135213 | return; |
| 134368 | 135214 | } |
| | @@ -136680,10 +137526,13 @@ |
| 136680 | 137526 | } |
| 136681 | 137527 | if( !sqlite3SafetyCheckSickOrOk(db) ){ |
| 136682 | 137528 | return SQLITE_MISUSE_BKPT; |
| 136683 | 137529 | } |
| 136684 | 137530 | sqlite3_mutex_enter(db->mutex); |
| 137531 | + if( db->mTrace & SQLITE_TRACE_CLOSE ){ |
| 137532 | + db->xTrace(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0); |
| 137533 | + } |
| 136685 | 137534 | |
| 136686 | 137535 | /* Force xDisconnect calls on all virtual tables */ |
| 136687 | 137536 | disconnectAllVtab(db); |
| 136688 | 137537 | |
| 136689 | 137538 | /* If a transaction is open, the disconnectAllVtab() call above |
| | @@ -137448,11 +138297,12 @@ |
| 137448 | 138297 | ** |
| 137449 | 138298 | ** A NULL trace function means that no tracing is executes. A non-NULL |
| 137450 | 138299 | ** trace is a pointer to a function that is invoked at the start of each |
| 137451 | 138300 | ** SQL statement. |
| 137452 | 138301 | */ |
| 137453 | | -SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){ |
| 138302 | +#ifndef SQLITE_OMIT_DEPRECATED |
| 138303 | +SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void(*xTrace)(void*,const char*), void *pArg){ |
| 137454 | 138304 | void *pOld; |
| 137455 | 138305 | |
| 137456 | 138306 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 137457 | 138307 | if( !sqlite3SafetyCheckOk(db) ){ |
| 137458 | 138308 | (void)SQLITE_MISUSE_BKPT; |
| | @@ -137459,15 +138309,40 @@ |
| 137459 | 138309 | return 0; |
| 137460 | 138310 | } |
| 137461 | 138311 | #endif |
| 137462 | 138312 | sqlite3_mutex_enter(db->mutex); |
| 137463 | 138313 | pOld = db->pTraceArg; |
| 137464 | | - db->xTrace = xTrace; |
| 138314 | + db->mTrace = xTrace ? SQLITE_TRACE_LEGACY : 0; |
| 138315 | + db->xTrace = (int(*)(u32,void*,void*,void*))xTrace; |
| 137465 | 138316 | db->pTraceArg = pArg; |
| 137466 | 138317 | sqlite3_mutex_leave(db->mutex); |
| 137467 | 138318 | return pOld; |
| 137468 | 138319 | } |
| 138320 | +#endif /* SQLITE_OMIT_DEPRECATED */ |
| 138321 | + |
| 138322 | +/* Register a trace callback using the version-2 interface. |
| 138323 | +*/ |
| 138324 | +SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2( |
| 138325 | + sqlite3 *db, /* Trace this connection */ |
| 138326 | + unsigned mTrace, /* Mask of events to be traced */ |
| 138327 | + int(*xTrace)(unsigned,void*,void*,void*), /* Callback to invoke */ |
| 138328 | + void *pArg /* Context */ |
| 138329 | +){ |
| 138330 | +#ifdef SQLITE_ENABLE_API_ARMOR |
| 138331 | + if( !sqlite3SafetyCheckOk(db) ){ |
| 138332 | + return SQLITE_MISUSE_BKPT; |
| 138333 | + } |
| 138334 | +#endif |
| 138335 | + sqlite3_mutex_enter(db->mutex); |
| 138336 | + db->mTrace = mTrace; |
| 138337 | + db->xTrace = xTrace; |
| 138338 | + db->pTraceArg = pArg; |
| 138339 | + sqlite3_mutex_leave(db->mutex); |
| 138340 | + return SQLITE_OK; |
| 138341 | +} |
| 138342 | + |
| 138343 | +#ifndef SQLITE_OMIT_DEPRECATED |
| 137469 | 138344 | /* |
| 137470 | 138345 | ** Register a profile function. The pArg from the previously registered |
| 137471 | 138346 | ** profile function is returned. |
| 137472 | 138347 | ** |
| 137473 | 138348 | ** A NULL profile function means that no profiling is executes. A non-NULL |
| | @@ -137492,10 +138367,11 @@ |
| 137492 | 138367 | db->xProfile = xProfile; |
| 137493 | 138368 | db->pProfileArg = pArg; |
| 137494 | 138369 | sqlite3_mutex_leave(db->mutex); |
| 137495 | 138370 | return pOld; |
| 137496 | 138371 | } |
| 138372 | +#endif /* SQLITE_OMIT_DEPRECATED */ |
| 137497 | 138373 | #endif /* SQLITE_OMIT_TRACE */ |
| 137498 | 138374 | |
| 137499 | 138375 | /* |
| 137500 | 138376 | ** Register a function to be invoked when a transaction commits. |
| 137501 | 138377 | ** If the invoked function returns non-zero, then the commit becomes a |
| | @@ -149942,11 +150818,15 @@ |
| 149942 | 150818 | } |
| 149943 | 150819 | |
| 149944 | 150820 | |
| 149945 | 150821 | #ifdef SQLITE_TEST |
| 149946 | 150822 | |
| 149947 | | -#include <tcl.h> |
| 150823 | +#if defined(INCLUDE_SQLITE_TCL_H) |
| 150824 | +# include "sqlite_tcl.h" |
| 150825 | +#else |
| 150826 | +# include "tcl.h" |
| 150827 | +#endif |
| 149948 | 150828 | /* #include <string.h> */ |
| 149949 | 150829 | |
| 149950 | 150830 | /* |
| 149951 | 150831 | ** Implementation of a special SQL scalar function for testing tokenizers |
| 149952 | 150832 | ** designed to be used in concert with the Tcl testing framework. This |
| | @@ -161881,10 +162761,57 @@ |
| 161881 | 162761 | } |
| 161882 | 162762 | return f; |
| 161883 | 162763 | } |
| 161884 | 162764 | #endif /* !defined(SQLITE_RTREE_INT_ONLY) */ |
| 161885 | 162765 | |
| 162766 | +/* |
| 162767 | +** A constraint has failed while inserting a row into an rtree table. |
| 162768 | +** Assuming no OOM error occurs, this function sets the error message |
| 162769 | +** (at pRtree->base.zErrMsg) to an appropriate value and returns |
| 162770 | +** SQLITE_CONSTRAINT. |
| 162771 | +** |
| 162772 | +** Parameter iCol is the index of the leftmost column involved in the |
| 162773 | +** constraint failure. If it is 0, then the constraint that failed is |
| 162774 | +** the unique constraint on the id column. Otherwise, it is the rtree |
| 162775 | +** (c1<=c2) constraint on columns iCol and iCol+1 that has failed. |
| 162776 | +** |
| 162777 | +** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT. |
| 162778 | +*/ |
| 162779 | +static int rtreeConstraintError(Rtree *pRtree, int iCol){ |
| 162780 | + sqlite3_stmt *pStmt = 0; |
| 162781 | + char *zSql; |
| 162782 | + int rc; |
| 162783 | + |
| 162784 | + assert( iCol==0 || iCol%2 ); |
| 162785 | + zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", pRtree->zDb, pRtree->zName); |
| 162786 | + if( zSql ){ |
| 162787 | + rc = sqlite3_prepare_v2(pRtree->db, zSql, -1, &pStmt, 0); |
| 162788 | + }else{ |
| 162789 | + rc = SQLITE_NOMEM; |
| 162790 | + } |
| 162791 | + sqlite3_free(zSql); |
| 162792 | + |
| 162793 | + if( rc==SQLITE_OK ){ |
| 162794 | + if( iCol==0 ){ |
| 162795 | + const char *zCol = sqlite3_column_name(pStmt, 0); |
| 162796 | + pRtree->base.zErrMsg = sqlite3_mprintf( |
| 162797 | + "UNIQUE constraint failed: %s.%s", pRtree->zName, zCol |
| 162798 | + ); |
| 162799 | + }else{ |
| 162800 | + const char *zCol1 = sqlite3_column_name(pStmt, iCol); |
| 162801 | + const char *zCol2 = sqlite3_column_name(pStmt, iCol+1); |
| 162802 | + pRtree->base.zErrMsg = sqlite3_mprintf( |
| 162803 | + "rtree constraint failed: %s.(%s<=%s)", pRtree->zName, zCol1, zCol2 |
| 162804 | + ); |
| 162805 | + } |
| 162806 | + } |
| 162807 | + |
| 162808 | + sqlite3_finalize(pStmt); |
| 162809 | + return (rc==SQLITE_OK ? SQLITE_CONSTRAINT : rc); |
| 162810 | +} |
| 162811 | + |
| 162812 | + |
| 161886 | 162813 | |
| 161887 | 162814 | /* |
| 161888 | 162815 | ** The xUpdate method for rtree module virtual tables. |
| 161889 | 162816 | */ |
| 161890 | 162817 | static int rtreeUpdate( |
| | @@ -161931,11 +162858,11 @@ |
| 161931 | 162858 | if( pRtree->eCoordType==RTREE_COORD_REAL32 ){ |
| 161932 | 162859 | for(ii=0; ii<nData-4; ii+=2){ |
| 161933 | 162860 | cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]); |
| 161934 | 162861 | cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]); |
| 161935 | 162862 | if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){ |
| 161936 | | - rc = SQLITE_CONSTRAINT; |
| 162863 | + rc = rtreeConstraintError(pRtree, ii+1); |
| 161937 | 162864 | goto constraint; |
| 161938 | 162865 | } |
| 161939 | 162866 | } |
| 161940 | 162867 | }else |
| 161941 | 162868 | #endif |
| | @@ -161942,11 +162869,11 @@ |
| 161942 | 162869 | { |
| 161943 | 162870 | for(ii=0; ii<nData-4; ii+=2){ |
| 161944 | 162871 | cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]); |
| 161945 | 162872 | cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]); |
| 161946 | 162873 | if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){ |
| 161947 | | - rc = SQLITE_CONSTRAINT; |
| 162874 | + rc = rtreeConstraintError(pRtree, ii+1); |
| 161948 | 162875 | goto constraint; |
| 161949 | 162876 | } |
| 161950 | 162877 | } |
| 161951 | 162878 | } |
| 161952 | 162879 | |
| | @@ -161963,11 +162890,11 @@ |
| 161963 | 162890 | rc = sqlite3_reset(pRtree->pReadRowid); |
| 161964 | 162891 | if( SQLITE_ROW==steprc ){ |
| 161965 | 162892 | if( sqlite3_vtab_on_conflict(pRtree->db)==SQLITE_REPLACE ){ |
| 161966 | 162893 | rc = rtreeDeleteRowid(pRtree, cell.iRowid); |
| 161967 | 162894 | }else{ |
| 161968 | | - rc = SQLITE_CONSTRAINT; |
| 162895 | + rc = rtreeConstraintError(pRtree, 0); |
| 161969 | 162896 | goto constraint; |
| 161970 | 162897 | } |
| 161971 | 162898 | } |
| 161972 | 162899 | } |
| 161973 | 162900 | bHaveRowid = 1; |
| | @@ -162046,10 +162973,15 @@ |
| 162046 | 162973 | char *zSql; |
| 162047 | 162974 | sqlite3_stmt *p; |
| 162048 | 162975 | int rc; |
| 162049 | 162976 | i64 nRow = 0; |
| 162050 | 162977 | |
| 162978 | + if( sqlite3_table_column_metadata(db,pRtree->zDb,"sqlite_stat1", |
| 162979 | + 0,0,0,0,0,0)==SQLITE_ERROR ){ |
| 162980 | + pRtree->nRowEst = RTREE_DEFAULT_ROWEST; |
| 162981 | + return SQLITE_OK; |
| 162982 | + } |
| 162051 | 162983 | zSql = sqlite3_mprintf(zFmt, pRtree->zDb, pRtree->zName); |
| 162052 | 162984 | if( zSql==0 ){ |
| 162053 | 162985 | rc = SQLITE_NOMEM; |
| 162054 | 162986 | }else{ |
| 162055 | 162987 | rc = sqlite3_prepare_v2(db, zSql, -1, &p, 0); |
| | @@ -163977,10 +164909,48 @@ |
| 163977 | 164909 | ** table exists but is not correctly populated, the value of the *pnOne |
| 163978 | 164910 | ** output variable during stage 1 is undefined. |
| 163979 | 164911 | */ |
| 163980 | 164912 | SQLITE_API void SQLITE_STDCALL sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int *pnTwo); |
| 163981 | 164913 | |
| 164914 | +/* |
| 164915 | +** Obtain an indication as to the current stage of an RBU update or vacuum. |
| 164916 | +** This function always returns one of the SQLITE_RBU_STATE_XXX constants |
| 164917 | +** defined in this file. Return values should be interpreted as follows: |
| 164918 | +** |
| 164919 | +** SQLITE_RBU_STATE_OAL: |
| 164920 | +** RBU is currently building a *-oal file. The next call to sqlite3rbu_step() |
| 164921 | +** may either add further data to the *-oal file, or compute data that will |
| 164922 | +** be added by a subsequent call. |
| 164923 | +** |
| 164924 | +** SQLITE_RBU_STATE_MOVE: |
| 164925 | +** RBU has finished building the *-oal file. The next call to sqlite3rbu_step() |
| 164926 | +** will move the *-oal file to the equivalent *-wal path. If the current |
| 164927 | +** operation is an RBU update, then the updated version of the database |
| 164928 | +** file will become visible to ordinary SQLite clients following the next |
| 164929 | +** call to sqlite3rbu_step(). |
| 164930 | +** |
| 164931 | +** SQLITE_RBU_STATE_CHECKPOINT: |
| 164932 | +** RBU is currently performing an incremental checkpoint. The next call to |
| 164933 | +** sqlite3rbu_step() will copy a page of data from the *-wal file into |
| 164934 | +** the target database file. |
| 164935 | +** |
| 164936 | +** SQLITE_RBU_STATE_DONE: |
| 164937 | +** The RBU operation has finished. Any subsequent calls to sqlite3rbu_step() |
| 164938 | +** will immediately return SQLITE_DONE. |
| 164939 | +** |
| 164940 | +** SQLITE_RBU_STATE_ERROR: |
| 164941 | +** An error has occurred. Any subsequent calls to sqlite3rbu_step() will |
| 164942 | +** immediately return the SQLite error code associated with the error. |
| 164943 | +*/ |
| 164944 | +#define SQLITE_RBU_STATE_OAL 1 |
| 164945 | +#define SQLITE_RBU_STATE_MOVE 2 |
| 164946 | +#define SQLITE_RBU_STATE_CHECKPOINT 3 |
| 164947 | +#define SQLITE_RBU_STATE_DONE 4 |
| 164948 | +#define SQLITE_RBU_STATE_ERROR 5 |
| 164949 | + |
| 164950 | +SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *pRbu); |
| 164951 | + |
| 163982 | 164952 | /* |
| 163983 | 164953 | ** Create an RBU VFS named zName that accesses the underlying file-system |
| 163984 | 164954 | ** via existing VFS zParent. Or, if the zParent parameter is passed NULL, |
| 163985 | 164955 | ** then the new RBU VFS uses the default system VFS to access the file-system. |
| 163986 | 164956 | ** The new object is registered as a non-default VFS with SQLite before |
| | @@ -164872,16 +165842,18 @@ |
| 164872 | 165842 | */ |
| 164873 | 165843 | static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){ |
| 164874 | 165844 | int rc; |
| 164875 | 165845 | memset(pIter, 0, sizeof(RbuObjIter)); |
| 164876 | 165846 | |
| 164877 | | - rc = prepareAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, |
| 165847 | + rc = prepareFreeAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, |
| 165848 | + sqlite3_mprintf( |
| 164878 | 165849 | "SELECT rbu_target_name(name, type='view') AS target, name " |
| 164879 | 165850 | "FROM sqlite_master " |
| 164880 | 165851 | "WHERE type IN ('table', 'view') AND target IS NOT NULL " |
| 165852 | + " %s " |
| 164881 | 165853 | "ORDER BY name" |
| 164882 | | - ); |
| 165854 | + , rbuIsVacuum(p) ? "AND rootpage!=0 AND rootpage IS NOT NULL" : "")); |
| 164883 | 165855 | |
| 164884 | 165856 | if( rc==SQLITE_OK ){ |
| 164885 | 165857 | rc = prepareAndCollectError(p->dbMain, &pIter->pIdxIter, &p->zErrmsg, |
| 164886 | 165858 | "SELECT name, rootpage, sql IS NULL OR substr(8, 6)=='UNIQUE' " |
| 164887 | 165859 | " FROM main.sqlite_master " |
| | @@ -166456,13 +167428,13 @@ |
| 166456 | 167428 | #if SQLITE_ENABLE_8_3_NAMES<2 |
| 166457 | 167429 | if( sqlite3_uri_boolean(zBase, "8_3_names", 0) ) |
| 166458 | 167430 | #endif |
| 166459 | 167431 | { |
| 166460 | 167432 | int i, sz; |
| 166461 | | - sz = sqlite3Strlen30(z); |
| 167433 | + sz = (int)strlen(z)&0xffffff; |
| 166462 | 167434 | for(i=sz-1; i>0 && z[i]!='/' && z[i]!='.'; i--){} |
| 166463 | | - if( z[i]=='.' && ALWAYS(sz>i+4) ) memmove(&z[i+1], &z[sz-3], 4); |
| 167435 | + if( z[i]=='.' && sz>i+4 ) memmove(&z[i+1], &z[sz-3], 4); |
| 166464 | 167436 | } |
| 166465 | 167437 | #endif |
| 166466 | 167438 | } |
| 166467 | 167439 | |
| 166468 | 167440 | /* |
| | @@ -167504,34 +168476,11 @@ |
| 167504 | 168476 | } |
| 167505 | 168477 | |
| 167506 | 168478 | if( p->rc==SQLITE_OK ){ |
| 167507 | 168479 | if( p->eStage==RBU_STAGE_OAL ){ |
| 167508 | 168480 | sqlite3 *db = p->dbMain; |
| 167509 | | - |
| 167510 | | - if( pState->eStage==0 && rbuIsVacuum(p) ){ |
| 167511 | | - rbuCopyPragma(p, "page_size"); |
| 167512 | | - rbuCopyPragma(p, "auto_vacuum"); |
| 167513 | | - } |
| 167514 | | - |
| 167515 | | - /* Open transactions both databases. The *-oal file is opened or |
| 167516 | | - ** created at this point. */ |
| 167517 | | - if( p->rc==SQLITE_OK ){ |
| 167518 | | - p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg); |
| 167519 | | - } |
| 167520 | | - if( p->rc==SQLITE_OK ){ |
| 167521 | | - p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg); |
| 167522 | | - } |
| 167523 | | - |
| 167524 | | - /* Check if the main database is a zipvfs db. If it is, set the upper |
| 167525 | | - ** level pager to use "journal_mode=off". This prevents it from |
| 167526 | | - ** generating a large journal using a temp file. */ |
| 167527 | | - if( p->rc==SQLITE_OK ){ |
| 167528 | | - int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0); |
| 167529 | | - if( frc==SQLITE_OK ){ |
| 167530 | | - p->rc = sqlite3_exec(db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg); |
| 167531 | | - } |
| 167532 | | - } |
| 168481 | + p->rc = sqlite3_exec(p->dbRbu, "BEGIN", 0, 0, &p->zErrmsg); |
| 167533 | 168482 | |
| 167534 | 168483 | /* Point the object iterator at the first object */ |
| 167535 | 168484 | if( p->rc==SQLITE_OK ){ |
| 167536 | 168485 | p->rc = rbuObjIterFirst(p, &p->objiter); |
| 167537 | 168486 | } |
| | @@ -167538,16 +168487,38 @@ |
| 167538 | 168487 | |
| 167539 | 168488 | /* If the RBU database contains no data_xxx tables, declare the RBU |
| 167540 | 168489 | ** update finished. */ |
| 167541 | 168490 | if( p->rc==SQLITE_OK && p->objiter.zTbl==0 ){ |
| 167542 | 168491 | p->rc = SQLITE_DONE; |
| 168492 | + p->eStage = RBU_STAGE_DONE; |
| 168493 | + }else{ |
| 168494 | + if( p->rc==SQLITE_OK && pState->eStage==0 && rbuIsVacuum(p) ){ |
| 168495 | + rbuCopyPragma(p, "page_size"); |
| 168496 | + rbuCopyPragma(p, "auto_vacuum"); |
| 168497 | + } |
| 168498 | + |
| 168499 | + /* Open transactions both databases. The *-oal file is opened or |
| 168500 | + ** created at this point. */ |
| 168501 | + if( p->rc==SQLITE_OK ){ |
| 168502 | + p->rc = sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, &p->zErrmsg); |
| 168503 | + } |
| 168504 | + |
| 168505 | + /* Check if the main database is a zipvfs db. If it is, set the upper |
| 168506 | + ** level pager to use "journal_mode=off". This prevents it from |
| 168507 | + ** generating a large journal using a temp file. */ |
| 168508 | + if( p->rc==SQLITE_OK ){ |
| 168509 | + int frc = sqlite3_file_control(db, "main", SQLITE_FCNTL_ZIPVFS, 0); |
| 168510 | + if( frc==SQLITE_OK ){ |
| 168511 | + p->rc = sqlite3_exec( |
| 168512 | + db, "PRAGMA journal_mode=off",0,0,&p->zErrmsg); |
| 168513 | + } |
| 168514 | + } |
| 168515 | + |
| 168516 | + if( p->rc==SQLITE_OK ){ |
| 168517 | + rbuSetupOal(p, pState); |
| 168518 | + } |
| 167543 | 168519 | } |
| 167544 | | - |
| 167545 | | - if( p->rc==SQLITE_OK ){ |
| 167546 | | - rbuSetupOal(p, pState); |
| 167547 | | - } |
| 167548 | | - |
| 167549 | 168520 | }else if( p->eStage==RBU_STAGE_MOVE ){ |
| 167550 | 168521 | /* no-op */ |
| 167551 | 168522 | }else if( p->eStage==RBU_STAGE_CKPT ){ |
| 167552 | 168523 | rbuSetupCheckpoint(p, pState); |
| 167553 | 168524 | }else if( p->eStage==RBU_STAGE_DONE ){ |
| | @@ -167709,14 +168680,44 @@ |
| 167709 | 168680 | |
| 167710 | 168681 | default: |
| 167711 | 168682 | assert( 0 ); |
| 167712 | 168683 | } |
| 167713 | 168684 | } |
| 168685 | + |
| 168686 | +/* |
| 168687 | +** Return the current state of the RBU vacuum or update operation. |
| 168688 | +*/ |
| 168689 | +SQLITE_API int SQLITE_STDCALL sqlite3rbu_state(sqlite3rbu *p){ |
| 168690 | + int aRes[] = { |
| 168691 | + 0, SQLITE_RBU_STATE_OAL, SQLITE_RBU_STATE_MOVE, |
| 168692 | + 0, SQLITE_RBU_STATE_CHECKPOINT, SQLITE_RBU_STATE_DONE |
| 168693 | + }; |
| 168694 | + |
| 168695 | + assert( RBU_STAGE_OAL==1 ); |
| 168696 | + assert( RBU_STAGE_MOVE==2 ); |
| 168697 | + assert( RBU_STAGE_CKPT==4 ); |
| 168698 | + assert( RBU_STAGE_DONE==5 ); |
| 168699 | + assert( aRes[RBU_STAGE_OAL]==SQLITE_RBU_STATE_OAL ); |
| 168700 | + assert( aRes[RBU_STAGE_MOVE]==SQLITE_RBU_STATE_MOVE ); |
| 168701 | + assert( aRes[RBU_STAGE_CKPT]==SQLITE_RBU_STATE_CHECKPOINT ); |
| 168702 | + assert( aRes[RBU_STAGE_DONE]==SQLITE_RBU_STATE_DONE ); |
| 168703 | + |
| 168704 | + if( p->rc!=SQLITE_OK && p->rc!=SQLITE_DONE ){ |
| 168705 | + return SQLITE_RBU_STATE_ERROR; |
| 168706 | + }else{ |
| 168707 | + assert( p->rc!=SQLITE_DONE || p->eStage==RBU_STAGE_DONE ); |
| 168708 | + assert( p->eStage==RBU_STAGE_OAL |
| 168709 | + || p->eStage==RBU_STAGE_MOVE |
| 168710 | + || p->eStage==RBU_STAGE_CKPT |
| 168711 | + || p->eStage==RBU_STAGE_DONE |
| 168712 | + ); |
| 168713 | + return aRes[p->eStage]; |
| 168714 | + } |
| 168715 | +} |
| 167714 | 168716 | |
| 167715 | 168717 | SQLITE_API int SQLITE_STDCALL sqlite3rbu_savestate(sqlite3rbu *p){ |
| 167716 | 168718 | int rc = p->rc; |
| 167717 | | - |
| 167718 | 168719 | if( rc==SQLITE_DONE ) return SQLITE_OK; |
| 167719 | 168720 | |
| 167720 | 168721 | assert( p->eStage>=RBU_STAGE_OAL && p->eStage<=RBU_STAGE_DONE ); |
| 167721 | 168722 | if( p->eStage==RBU_STAGE_OAL ){ |
| 167722 | 168723 | assert( rc!=SQLITE_DONE ); |
| | @@ -168694,14 +169695,14 @@ |
| 168694 | 169695 | ** |
| 168695 | 169696 | ** '/1c2/000/' // Left-most child of 451st child of root |
| 168696 | 169697 | */ |
| 168697 | 169698 | #define VTAB_SCHEMA \ |
| 168698 | 169699 | "CREATE TABLE xx( " \ |
| 168699 | | - " name STRING, /* Name of table or index */" \ |
| 168700 | | - " path INTEGER, /* Path to page from root */" \ |
| 169700 | + " name TEXT, /* Name of table or index */" \ |
| 169701 | + " path TEXT, /* Path to page from root */" \ |
| 168701 | 169702 | " pageno INTEGER, /* Page number */" \ |
| 168702 | | - " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \ |
| 169703 | + " pagetype TEXT, /* 'internal', 'leaf' or 'overflow' */" \ |
| 168703 | 169704 | " ncell INTEGER, /* Cells on page (0 for overflow) */" \ |
| 168704 | 169705 | " payload INTEGER, /* Bytes of payload on this page */" \ |
| 168705 | 169706 | " unused INTEGER, /* Bytes of unused space on this page */" \ |
| 168706 | 169707 | " mx_payload INTEGER, /* Largest payload size of all cells */" \ |
| 168707 | 169708 | " pgoffset INTEGER, /* Offset of page in file */" \ |
| | @@ -175195,10 +176196,30 @@ |
| 175195 | 176196 | #endif /* SQLITE_DEBUG */ |
| 175196 | 176197 | |
| 175197 | 176198 | /**************************************************************************** |
| 175198 | 176199 | ** Scalar SQL function implementations |
| 175199 | 176200 | ****************************************************************************/ |
| 176201 | + |
| 176202 | +/* |
| 176203 | +** Implementation of the json_QUOTE(VALUE) function. Return a JSON value |
| 176204 | +** corresponding to the SQL value input. Mostly this means putting |
| 176205 | +** double-quotes around strings and returning the unquoted string "null" |
| 176206 | +** when given a NULL input. |
| 176207 | +*/ |
| 176208 | +static void jsonQuoteFunc( |
| 176209 | + sqlite3_context *ctx, |
| 176210 | + int argc, |
| 176211 | + sqlite3_value **argv |
| 176212 | +){ |
| 176213 | + JsonString jx; |
| 176214 | + UNUSED_PARAM(argc); |
| 176215 | + |
| 176216 | + jsonInit(&jx, ctx); |
| 176217 | + jsonAppendValue(&jx, argv[0]); |
| 176218 | + jsonResult(&jx); |
| 176219 | + sqlite3_result_subtype(ctx, JSON_SUBTYPE); |
| 176220 | +} |
| 175200 | 176221 | |
| 175201 | 176222 | /* |
| 175202 | 176223 | ** Implementation of the json_array(VALUE,...) function. Return a JSON |
| 175203 | 176224 | ** array that contains all values given in arguments. Or if any argument |
| 175204 | 176225 | ** is a BLOB, throw an error. |
| | @@ -176109,10 +177130,11 @@ |
| 176109 | 177130 | { "json_array_length", 1, 0, jsonArrayLengthFunc }, |
| 176110 | 177131 | { "json_array_length", 2, 0, jsonArrayLengthFunc }, |
| 176111 | 177132 | { "json_extract", -1, 0, jsonExtractFunc }, |
| 176112 | 177133 | { "json_insert", -1, 0, jsonSetFunc }, |
| 176113 | 177134 | { "json_object", -1, 0, jsonObjectFunc }, |
| 177135 | + { "json_quote", 1, 0, jsonQuoteFunc }, |
| 176114 | 177136 | { "json_remove", -1, 0, jsonRemoveFunc }, |
| 176115 | 177137 | { "json_replace", -1, 0, jsonReplaceFunc }, |
| 176116 | 177138 | { "json_set", -1, 1, jsonSetFunc }, |
| 176117 | 177139 | { "json_type", 1, 0, jsonTypeFunc }, |
| 176118 | 177140 | { "json_type", 2, 0, jsonTypeFunc }, |
| | @@ -176509,11 +177531,11 @@ |
| 176509 | 177531 | ** following structure. All structure methods must be defined, setting |
| 176510 | 177532 | ** any member of the fts5_tokenizer struct to NULL leads to undefined |
| 176511 | 177533 | ** behaviour. The structure methods are expected to function as follows: |
| 176512 | 177534 | ** |
| 176513 | 177535 | ** xCreate: |
| 176514 | | -** This function is used to allocate and inititalize a tokenizer instance. |
| 177536 | +** This function is used to allocate and initialize a tokenizer instance. |
| 176515 | 177537 | ** A tokenizer instance is required to actually tokenize text. |
| 176516 | 177538 | ** |
| 176517 | 177539 | ** The first argument passed to this function is a copy of the (void*) |
| 176518 | 177540 | ** pointer provided by the application when the fts5_tokenizer object |
| 176519 | 177541 | ** was registered with FTS5 (the third argument to xCreateTokenizer()). |
| | @@ -176768,11 +177790,10 @@ |
| 176768 | 177790 | #if 0 |
| 176769 | 177791 | } /* end of the 'extern "C"' block */ |
| 176770 | 177792 | #endif |
| 176771 | 177793 | |
| 176772 | 177794 | #endif /* _FTS5_H */ |
| 176773 | | - |
| 176774 | 177795 | |
| 176775 | 177796 | /* |
| 176776 | 177797 | ** 2014 May 31 |
| 176777 | 177798 | ** |
| 176778 | 177799 | ** The author disclaims copyright to this source code. In place of |
| | @@ -177458,11 +178479,10 @@ |
| 177458 | 178479 | static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr*, int); |
| 177459 | 178480 | static int sqlite3Fts5ExprPopulatePoslists( |
| 177460 | 178481 | Fts5Config*, Fts5Expr*, Fts5PoslistPopulator*, int, const char*, int |
| 177461 | 178482 | ); |
| 177462 | 178483 | static void sqlite3Fts5ExprCheckPoslists(Fts5Expr*, i64); |
| 177463 | | -static void sqlite3Fts5ExprClearEof(Fts5Expr*); |
| 177464 | 178484 | |
| 177465 | 178485 | static int sqlite3Fts5ExprClonePhrase(Fts5Expr*, int, Fts5Expr**); |
| 177466 | 178486 | |
| 177467 | 178487 | static int sqlite3Fts5ExprPhraseCollist(Fts5Expr *, int, const u8 **, int *); |
| 177468 | 178488 | |
| | @@ -177874,21 +178894,22 @@ |
| 177874 | 178894 | typedef struct fts5yyStackEntry fts5yyStackEntry; |
| 177875 | 178895 | |
| 177876 | 178896 | /* The state of the parser is completely contained in an instance of |
| 177877 | 178897 | ** the following structure */ |
| 177878 | 178898 | struct fts5yyParser { |
| 177879 | | - int fts5yyidx; /* Index of top element in stack */ |
| 178899 | + fts5yyStackEntry *fts5yytos; /* Pointer to top element of the stack */ |
| 177880 | 178900 | #ifdef fts5YYTRACKMAXSTACKDEPTH |
| 177881 | | - int fts5yyidxMax; /* Maximum value of fts5yyidx */ |
| 178901 | + int fts5yyhwm; /* High-water mark of the stack */ |
| 177882 | 178902 | #endif |
| 177883 | 178903 | #ifndef fts5YYNOERRORRECOVERY |
| 177884 | 178904 | int fts5yyerrcnt; /* Shifts left before out of the error */ |
| 177885 | 178905 | #endif |
| 177886 | 178906 | sqlite3Fts5ParserARG_SDECL /* A place to hold %extra_argument */ |
| 177887 | 178907 | #if fts5YYSTACKDEPTH<=0 |
| 177888 | 178908 | int fts5yystksz; /* Current side of the stack */ |
| 177889 | 178909 | fts5yyStackEntry *fts5yystack; /* The parser's stack */ |
| 178910 | + fts5yyStackEntry fts5yystk0; /* First stack entry */ |
| 177890 | 178911 | #else |
| 177891 | 178912 | fts5yyStackEntry fts5yystack[fts5YYSTACKDEPTH]; /* The parser's stack */ |
| 177892 | 178913 | #endif |
| 177893 | 178914 | }; |
| 177894 | 178915 | typedef struct fts5yyParser fts5yyParser; |
| | @@ -177971,28 +178992,38 @@ |
| 177971 | 178992 | #endif /* NDEBUG */ |
| 177972 | 178993 | |
| 177973 | 178994 | |
| 177974 | 178995 | #if fts5YYSTACKDEPTH<=0 |
| 177975 | 178996 | /* |
| 177976 | | -** Try to increase the size of the parser stack. |
| 178997 | +** Try to increase the size of the parser stack. Return the number |
| 178998 | +** of errors. Return 0 on success. |
| 177977 | 178999 | */ |
| 177978 | | -static void fts5yyGrowStack(fts5yyParser *p){ |
| 179000 | +static int fts5yyGrowStack(fts5yyParser *p){ |
| 177979 | 179001 | int newSize; |
| 179002 | + int idx; |
| 177980 | 179003 | fts5yyStackEntry *pNew; |
| 177981 | 179004 | |
| 177982 | 179005 | newSize = p->fts5yystksz*2 + 100; |
| 177983 | | - pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0])); |
| 179006 | + idx = p->fts5yytos ? (int)(p->fts5yytos - p->fts5yystack) : 0; |
| 179007 | + if( p->fts5yystack==&p->fts5yystk0 ){ |
| 179008 | + pNew = malloc(newSize*sizeof(pNew[0])); |
| 179009 | + if( pNew ) pNew[0] = p->fts5yystk0; |
| 179010 | + }else{ |
| 179011 | + pNew = realloc(p->fts5yystack, newSize*sizeof(pNew[0])); |
| 179012 | + } |
| 177984 | 179013 | if( pNew ){ |
| 177985 | 179014 | p->fts5yystack = pNew; |
| 177986 | | - p->fts5yystksz = newSize; |
| 179015 | + p->fts5yytos = &p->fts5yystack[idx]; |
| 177987 | 179016 | #ifndef NDEBUG |
| 177988 | 179017 | if( fts5yyTraceFILE ){ |
| 177989 | | - fprintf(fts5yyTraceFILE,"%sStack grows to %d entries!\n", |
| 177990 | | - fts5yyTracePrompt, p->fts5yystksz); |
| 179018 | + fprintf(fts5yyTraceFILE,"%sStack grows from %d to %d entries.\n", |
| 179019 | + fts5yyTracePrompt, p->fts5yystksz, newSize); |
| 177991 | 179020 | } |
| 177992 | 179021 | #endif |
| 179022 | + p->fts5yystksz = newSize; |
| 177993 | 179023 | } |
| 179024 | + return pNew==0; |
| 177994 | 179025 | } |
| 177995 | 179026 | #endif |
| 177996 | 179027 | |
| 177997 | 179028 | /* Datatype of the argument to the memory allocated passed as the |
| 177998 | 179029 | ** second argument to sqlite3Fts5ParserAlloc() below. This can be changed by |
| | @@ -178017,19 +179048,28 @@ |
| 178017 | 179048 | */ |
| 178018 | 179049 | static void *sqlite3Fts5ParserAlloc(void *(*mallocProc)(fts5YYMALLOCARGTYPE)){ |
| 178019 | 179050 | fts5yyParser *pParser; |
| 178020 | 179051 | pParser = (fts5yyParser*)(*mallocProc)( (fts5YYMALLOCARGTYPE)sizeof(fts5yyParser) ); |
| 178021 | 179052 | if( pParser ){ |
| 178022 | | - pParser->fts5yyidx = -1; |
| 178023 | 179053 | #ifdef fts5YYTRACKMAXSTACKDEPTH |
| 178024 | | - pParser->fts5yyidxMax = 0; |
| 179054 | + pParser->fts5yyhwm = 0; |
| 178025 | 179055 | #endif |
| 178026 | 179056 | #if fts5YYSTACKDEPTH<=0 |
| 179057 | + pParser->fts5yytos = NULL; |
| 178027 | 179058 | pParser->fts5yystack = NULL; |
| 178028 | 179059 | pParser->fts5yystksz = 0; |
| 178029 | | - fts5yyGrowStack(pParser); |
| 179060 | + if( fts5yyGrowStack(pParser) ){ |
| 179061 | + pParser->fts5yystack = &pParser->fts5yystk0; |
| 179062 | + pParser->fts5yystksz = 1; |
| 179063 | + } |
| 178030 | 179064 | #endif |
| 179065 | +#ifndef fts5YYNOERRORRECOVERY |
| 179066 | + pParser->fts5yyerrcnt = -1; |
| 179067 | +#endif |
| 179068 | + pParser->fts5yytos = pParser->fts5yystack; |
| 179069 | + pParser->fts5yystack[0].stateno = 0; |
| 179070 | + pParser->fts5yystack[0].major = 0; |
| 178031 | 179071 | } |
| 178032 | 179072 | return pParser; |
| 178033 | 179073 | } |
| 178034 | 179074 | |
| 178035 | 179075 | /* The following function deletes the "minor type" or semantic value |
| | @@ -178097,12 +179137,13 @@ |
| 178097 | 179137 | ** If there is a destructor routine associated with the token which |
| 178098 | 179138 | ** is popped from the stack, then call it. |
| 178099 | 179139 | */ |
| 178100 | 179140 | static void fts5yy_pop_parser_stack(fts5yyParser *pParser){ |
| 178101 | 179141 | fts5yyStackEntry *fts5yytos; |
| 178102 | | - assert( pParser->fts5yyidx>=0 ); |
| 178103 | | - fts5yytos = &pParser->fts5yystack[pParser->fts5yyidx--]; |
| 179142 | + assert( pParser->fts5yytos!=0 ); |
| 179143 | + assert( pParser->fts5yytos > pParser->fts5yystack ); |
| 179144 | + fts5yytos = pParser->fts5yytos--; |
| 178104 | 179145 | #ifndef NDEBUG |
| 178105 | 179146 | if( fts5yyTraceFILE ){ |
| 178106 | 179147 | fprintf(fts5yyTraceFILE,"%sPopping %s\n", |
| 178107 | 179148 | fts5yyTracePrompt, |
| 178108 | 179149 | fts5yyTokenName[fts5yytos->major]); |
| | @@ -178125,13 +179166,13 @@ |
| 178125 | 179166 | ){ |
| 178126 | 179167 | fts5yyParser *pParser = (fts5yyParser*)p; |
| 178127 | 179168 | #ifndef fts5YYPARSEFREENEVERNULL |
| 178128 | 179169 | if( pParser==0 ) return; |
| 178129 | 179170 | #endif |
| 178130 | | - while( pParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(pParser); |
| 179171 | + while( pParser->fts5yytos>pParser->fts5yystack ) fts5yy_pop_parser_stack(pParser); |
| 178131 | 179172 | #if fts5YYSTACKDEPTH<=0 |
| 178132 | | - free(pParser->fts5yystack); |
| 179173 | + if( pParser->fts5yystack!=&pParser->fts5yystk0 ) free(pParser->fts5yystack); |
| 178133 | 179174 | #endif |
| 178134 | 179175 | (*freeProc)((void*)pParser); |
| 178135 | 179176 | } |
| 178136 | 179177 | |
| 178137 | 179178 | /* |
| | @@ -178138,11 +179179,11 @@ |
| 178138 | 179179 | ** Return the peak depth of the stack for a parser. |
| 178139 | 179180 | */ |
| 178140 | 179181 | #ifdef fts5YYTRACKMAXSTACKDEPTH |
| 178141 | 179182 | static int sqlite3Fts5ParserStackPeak(void *p){ |
| 178142 | 179183 | fts5yyParser *pParser = (fts5yyParser*)p; |
| 178143 | | - return pParser->fts5yyidxMax; |
| 179184 | + return pParser->fts5yyhwm; |
| 178144 | 179185 | } |
| 178145 | 179186 | #endif |
| 178146 | 179187 | |
| 178147 | 179188 | /* |
| 178148 | 179189 | ** Find the appropriate action for a parser given the terminal |
| | @@ -178151,11 +179192,11 @@ |
| 178151 | 179192 | static unsigned int fts5yy_find_shift_action( |
| 178152 | 179193 | fts5yyParser *pParser, /* The parser */ |
| 178153 | 179194 | fts5YYCODETYPE iLookAhead /* The look-ahead token */ |
| 178154 | 179195 | ){ |
| 178155 | 179196 | int i; |
| 178156 | | - int stateno = pParser->fts5yystack[pParser->fts5yyidx].stateno; |
| 179197 | + int stateno = pParser->fts5yytos->stateno; |
| 178157 | 179198 | |
| 178158 | 179199 | if( stateno>=fts5YY_MIN_REDUCE ) return stateno; |
| 178159 | 179200 | assert( stateno <= fts5YY_SHIFT_COUNT ); |
| 178160 | 179201 | do{ |
| 178161 | 179202 | i = fts5yy_shift_ofst[stateno]; |
| | @@ -178244,17 +179285,17 @@ |
| 178244 | 179285 | /* |
| 178245 | 179286 | ** The following routine is called if the stack overflows. |
| 178246 | 179287 | */ |
| 178247 | 179288 | static void fts5yyStackOverflow(fts5yyParser *fts5yypParser){ |
| 178248 | 179289 | sqlite3Fts5ParserARG_FETCH; |
| 178249 | | - fts5yypParser->fts5yyidx--; |
| 179290 | + fts5yypParser->fts5yytos--; |
| 178250 | 179291 | #ifndef NDEBUG |
| 178251 | 179292 | if( fts5yyTraceFILE ){ |
| 178252 | 179293 | fprintf(fts5yyTraceFILE,"%sStack Overflow!\n",fts5yyTracePrompt); |
| 178253 | 179294 | } |
| 178254 | 179295 | #endif |
| 178255 | | - while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser); |
| 179296 | + while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser); |
| 178256 | 179297 | /* Here code is inserted which will execute if the parser |
| 178257 | 179298 | ** stack every overflows */ |
| 178258 | 179299 | /******** Begin %stack_overflow code ******************************************/ |
| 178259 | 179300 | |
| 178260 | 179301 | sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow"); |
| | @@ -178268,15 +179309,15 @@ |
| 178268 | 179309 | #ifndef NDEBUG |
| 178269 | 179310 | static void fts5yyTraceShift(fts5yyParser *fts5yypParser, int fts5yyNewState){ |
| 178270 | 179311 | if( fts5yyTraceFILE ){ |
| 178271 | 179312 | if( fts5yyNewState<fts5YYNSTATE ){ |
| 178272 | 179313 | fprintf(fts5yyTraceFILE,"%sShift '%s', go to state %d\n", |
| 178273 | | - fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major], |
| 179314 | + fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major], |
| 178274 | 179315 | fts5yyNewState); |
| 178275 | 179316 | }else{ |
| 178276 | 179317 | fprintf(fts5yyTraceFILE,"%sShift '%s'\n", |
| 178277 | | - fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major]); |
| 179318 | + fts5yyTracePrompt,fts5yyTokenName[fts5yypParser->fts5yytos->major]); |
| 178278 | 179319 | } |
| 178279 | 179320 | } |
| 178280 | 179321 | } |
| 178281 | 179322 | #else |
| 178282 | 179323 | # define fts5yyTraceShift(X,Y) |
| | @@ -178290,31 +179331,34 @@ |
| 178290 | 179331 | int fts5yyNewState, /* The new state to shift in */ |
| 178291 | 179332 | int fts5yyMajor, /* The major token to shift in */ |
| 178292 | 179333 | sqlite3Fts5ParserFTS5TOKENTYPE fts5yyMinor /* The minor token to shift in */ |
| 178293 | 179334 | ){ |
| 178294 | 179335 | fts5yyStackEntry *fts5yytos; |
| 178295 | | - fts5yypParser->fts5yyidx++; |
| 179336 | + fts5yypParser->fts5yytos++; |
| 178296 | 179337 | #ifdef fts5YYTRACKMAXSTACKDEPTH |
| 178297 | | - if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){ |
| 178298 | | - fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx; |
| 179338 | + if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){ |
| 179339 | + fts5yypParser->fts5yyhwm++; |
| 179340 | + assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack) ); |
| 178299 | 179341 | } |
| 178300 | 179342 | #endif |
| 178301 | 179343 | #if fts5YYSTACKDEPTH>0 |
| 178302 | | - if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH ){ |
| 179344 | + if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH] ){ |
| 178303 | 179345 | fts5yyStackOverflow(fts5yypParser); |
| 178304 | 179346 | return; |
| 178305 | 179347 | } |
| 178306 | 179348 | #else |
| 178307 | | - if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){ |
| 178308 | | - fts5yyGrowStack(fts5yypParser); |
| 178309 | | - if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz ){ |
| 179349 | + if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz] ){ |
| 179350 | + if( fts5yyGrowStack(fts5yypParser) ){ |
| 178310 | 179351 | fts5yyStackOverflow(fts5yypParser); |
| 178311 | 179352 | return; |
| 178312 | 179353 | } |
| 178313 | 179354 | } |
| 178314 | 179355 | #endif |
| 178315 | | - fts5yytos = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx]; |
| 179356 | + if( fts5yyNewState > fts5YY_MAX_SHIFT ){ |
| 179357 | + fts5yyNewState += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE; |
| 179358 | + } |
| 179359 | + fts5yytos = fts5yypParser->fts5yytos; |
| 178316 | 179360 | fts5yytos->stateno = (fts5YYACTIONTYPE)fts5yyNewState; |
| 178317 | 179361 | fts5yytos->major = (fts5YYCODETYPE)fts5yyMajor; |
| 178318 | 179362 | fts5yytos->minor.fts5yy0 = fts5yyMinor; |
| 178319 | 179363 | fts5yyTraceShift(fts5yypParser, fts5yyNewState); |
| 178320 | 179364 | } |
| | @@ -178365,11 +179409,11 @@ |
| 178365 | 179409 | int fts5yygoto; /* The next state */ |
| 178366 | 179410 | int fts5yyact; /* The next action */ |
| 178367 | 179411 | fts5yyStackEntry *fts5yymsp; /* The top of the parser's stack */ |
| 178368 | 179412 | int fts5yysize; /* Amount to pop the stack */ |
| 178369 | 179413 | sqlite3Fts5ParserARG_FETCH; |
| 178370 | | - fts5yymsp = &fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx]; |
| 179414 | + fts5yymsp = fts5yypParser->fts5yytos; |
| 178371 | 179415 | #ifndef NDEBUG |
| 178372 | 179416 | if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){ |
| 178373 | 179417 | fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs; |
| 178374 | 179418 | fprintf(fts5yyTraceFILE, "%sReduce [%s], go to state %d.\n", fts5yyTracePrompt, |
| 178375 | 179419 | fts5yyRuleName[fts5yyruleno], fts5yymsp[-fts5yysize].stateno); |
| | @@ -178379,26 +179423,27 @@ |
| 178379 | 179423 | /* Check that the stack is large enough to grow by a single entry |
| 178380 | 179424 | ** if the RHS of the rule is empty. This ensures that there is room |
| 178381 | 179425 | ** enough on the stack to push the LHS value */ |
| 178382 | 179426 | if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){ |
| 178383 | 179427 | #ifdef fts5YYTRACKMAXSTACKDEPTH |
| 178384 | | - if( fts5yypParser->fts5yyidx>fts5yypParser->fts5yyidxMax ){ |
| 178385 | | - fts5yypParser->fts5yyidxMax = fts5yypParser->fts5yyidx; |
| 179428 | + if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){ |
| 179429 | + fts5yypParser->fts5yyhwm++; |
| 179430 | + assert( fts5yypParser->fts5yyhwm == (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)); |
| 178386 | 179431 | } |
| 178387 | 179432 | #endif |
| 178388 | 179433 | #if fts5YYSTACKDEPTH>0 |
| 178389 | | - if( fts5yypParser->fts5yyidx>=fts5YYSTACKDEPTH-1 ){ |
| 179434 | + if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5YYSTACKDEPTH-1] ){ |
| 178390 | 179435 | fts5yyStackOverflow(fts5yypParser); |
| 178391 | 179436 | return; |
| 178392 | 179437 | } |
| 178393 | 179438 | #else |
| 178394 | | - if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){ |
| 178395 | | - fts5yyGrowStack(fts5yypParser); |
| 178396 | | - if( fts5yypParser->fts5yyidx>=fts5yypParser->fts5yystksz-1 ){ |
| 179439 | + if( fts5yypParser->fts5yytos>=&fts5yypParser->fts5yystack[fts5yypParser->fts5yystksz-1] ){ |
| 179440 | + if( fts5yyGrowStack(fts5yypParser) ){ |
| 178397 | 179441 | fts5yyStackOverflow(fts5yypParser); |
| 178398 | 179442 | return; |
| 178399 | 179443 | } |
| 179444 | + fts5yymsp = fts5yypParser->fts5yytos; |
| 178400 | 179445 | } |
| 178401 | 179446 | #endif |
| 178402 | 179447 | } |
| 178403 | 179448 | |
| 178404 | 179449 | switch( fts5yyruleno ){ |
| | @@ -178535,19 +179580,21 @@ |
| 178535 | 179580 | assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) ); |
| 178536 | 179581 | fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs; |
| 178537 | 179582 | fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs; |
| 178538 | 179583 | fts5yyact = fts5yy_find_reduce_action(fts5yymsp[-fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto); |
| 178539 | 179584 | if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){ |
| 178540 | | - if( fts5yyact>fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE; |
| 178541 | | - fts5yypParser->fts5yyidx -= fts5yysize - 1; |
| 179585 | + if( fts5yyact>fts5YY_MAX_SHIFT ){ |
| 179586 | + fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE; |
| 179587 | + } |
| 178542 | 179588 | fts5yymsp -= fts5yysize-1; |
| 179589 | + fts5yypParser->fts5yytos = fts5yymsp; |
| 178543 | 179590 | fts5yymsp->stateno = (fts5YYACTIONTYPE)fts5yyact; |
| 178544 | 179591 | fts5yymsp->major = (fts5YYCODETYPE)fts5yygoto; |
| 178545 | 179592 | fts5yyTraceShift(fts5yypParser, fts5yyact); |
| 178546 | 179593 | }else{ |
| 178547 | 179594 | assert( fts5yyact == fts5YY_ACCEPT_ACTION ); |
| 178548 | | - fts5yypParser->fts5yyidx -= fts5yysize; |
| 179595 | + fts5yypParser->fts5yytos -= fts5yysize; |
| 178549 | 179596 | fts5yy_accept(fts5yypParser); |
| 178550 | 179597 | } |
| 178551 | 179598 | } |
| 178552 | 179599 | |
| 178553 | 179600 | /* |
| | @@ -178561,11 +179608,11 @@ |
| 178561 | 179608 | #ifndef NDEBUG |
| 178562 | 179609 | if( fts5yyTraceFILE ){ |
| 178563 | 179610 | fprintf(fts5yyTraceFILE,"%sFail!\n",fts5yyTracePrompt); |
| 178564 | 179611 | } |
| 178565 | 179612 | #endif |
| 178566 | | - while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser); |
| 179613 | + while( fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ) fts5yy_pop_parser_stack(fts5yypParser); |
| 178567 | 179614 | /* Here code is inserted which will be executed whenever the |
| 178568 | 179615 | ** parser fails */ |
| 178569 | 179616 | /************ Begin %parse_failure code ***************************************/ |
| 178570 | 179617 | /************ End %parse_failure code *****************************************/ |
| 178571 | 179618 | sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| | @@ -178602,11 +179649,14 @@ |
| 178602 | 179649 | #ifndef NDEBUG |
| 178603 | 179650 | if( fts5yyTraceFILE ){ |
| 178604 | 179651 | fprintf(fts5yyTraceFILE,"%sAccept!\n",fts5yyTracePrompt); |
| 178605 | 179652 | } |
| 178606 | 179653 | #endif |
| 178607 | | - while( fts5yypParser->fts5yyidx>=0 ) fts5yy_pop_parser_stack(fts5yypParser); |
| 179654 | +#ifndef fts5YYNOERRORRECOVERY |
| 179655 | + fts5yypParser->fts5yyerrcnt = -1; |
| 179656 | +#endif |
| 179657 | + assert( fts5yypParser->fts5yytos==fts5yypParser->fts5yystack ); |
| 178608 | 179658 | /* Here code is inserted which will be executed whenever the |
| 178609 | 179659 | ** parser accepts */ |
| 178610 | 179660 | /*********** Begin %parse_accept code *****************************************/ |
| 178611 | 179661 | /*********** End %parse_accept code *******************************************/ |
| 178612 | 179662 | sqlite3Fts5ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
| | @@ -178645,32 +179695,12 @@ |
| 178645 | 179695 | #ifdef fts5YYERRORSYMBOL |
| 178646 | 179696 | int fts5yyerrorhit = 0; /* True if fts5yymajor has invoked an error */ |
| 178647 | 179697 | #endif |
| 178648 | 179698 | fts5yyParser *fts5yypParser; /* The parser */ |
| 178649 | 179699 | |
| 178650 | | - /* (re)initialize the parser, if necessary */ |
| 178651 | 179700 | fts5yypParser = (fts5yyParser*)fts5yyp; |
| 178652 | | - if( fts5yypParser->fts5yyidx<0 ){ |
| 178653 | | -#if fts5YYSTACKDEPTH<=0 |
| 178654 | | - if( fts5yypParser->fts5yystksz <=0 ){ |
| 178655 | | - fts5yyStackOverflow(fts5yypParser); |
| 178656 | | - return; |
| 178657 | | - } |
| 178658 | | -#endif |
| 178659 | | - fts5yypParser->fts5yyidx = 0; |
| 178660 | | -#ifndef fts5YYNOERRORRECOVERY |
| 178661 | | - fts5yypParser->fts5yyerrcnt = -1; |
| 178662 | | -#endif |
| 178663 | | - fts5yypParser->fts5yystack[0].stateno = 0; |
| 178664 | | - fts5yypParser->fts5yystack[0].major = 0; |
| 178665 | | -#ifndef NDEBUG |
| 178666 | | - if( fts5yyTraceFILE ){ |
| 178667 | | - fprintf(fts5yyTraceFILE,"%sInitialize. Empty stack. State 0\n", |
| 178668 | | - fts5yyTracePrompt); |
| 178669 | | - } |
| 178670 | | -#endif |
| 178671 | | - } |
| 179701 | + assert( fts5yypParser->fts5yytos!=0 ); |
| 178672 | 179702 | #if !defined(fts5YYERRORSYMBOL) && !defined(fts5YYNOERRORRECOVERY) |
| 178673 | 179703 | fts5yyendofinput = (fts5yymajor==0); |
| 178674 | 179704 | #endif |
| 178675 | 179705 | sqlite3Fts5ParserARG_STORE; |
| 178676 | 179706 | |
| | @@ -178681,11 +179711,10 @@ |
| 178681 | 179711 | #endif |
| 178682 | 179712 | |
| 178683 | 179713 | do{ |
| 178684 | 179714 | fts5yyact = fts5yy_find_shift_action(fts5yypParser,(fts5YYCODETYPE)fts5yymajor); |
| 178685 | 179715 | if( fts5yyact <= fts5YY_MAX_SHIFTREDUCE ){ |
| 178686 | | - if( fts5yyact > fts5YY_MAX_SHIFT ) fts5yyact += fts5YY_MIN_REDUCE - fts5YY_MIN_SHIFTREDUCE; |
| 178687 | 179716 | fts5yy_shift(fts5yypParser,fts5yyact,fts5yymajor,fts5yyminor); |
| 178688 | 179717 | #ifndef fts5YYNOERRORRECOVERY |
| 178689 | 179718 | fts5yypParser->fts5yyerrcnt--; |
| 178690 | 179719 | #endif |
| 178691 | 179720 | fts5yymajor = fts5YYNOCODE; |
| | @@ -178723,11 +179752,11 @@ |
| 178723 | 179752 | ** |
| 178724 | 179753 | */ |
| 178725 | 179754 | if( fts5yypParser->fts5yyerrcnt<0 ){ |
| 178726 | 179755 | fts5yy_syntax_error(fts5yypParser,fts5yymajor,fts5yyminor); |
| 178727 | 179756 | } |
| 178728 | | - fts5yymx = fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].major; |
| 179757 | + fts5yymx = fts5yypParser->fts5yytos->major; |
| 178729 | 179758 | if( fts5yymx==fts5YYERRORSYMBOL || fts5yyerrorhit ){ |
| 178730 | 179759 | #ifndef NDEBUG |
| 178731 | 179760 | if( fts5yyTraceFILE ){ |
| 178732 | 179761 | fprintf(fts5yyTraceFILE,"%sDiscard input token %s\n", |
| 178733 | 179762 | fts5yyTracePrompt,fts5yyTokenName[fts5yymajor]); |
| | @@ -178734,22 +179763,24 @@ |
| 178734 | 179763 | } |
| 178735 | 179764 | #endif |
| 178736 | 179765 | fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion); |
| 178737 | 179766 | fts5yymajor = fts5YYNOCODE; |
| 178738 | 179767 | }else{ |
| 178739 | | - while( |
| 178740 | | - fts5yypParser->fts5yyidx >= 0 && |
| 178741 | | - fts5yymx != fts5YYERRORSYMBOL && |
| 178742 | | - (fts5yyact = fts5yy_find_reduce_action( |
| 178743 | | - fts5yypParser->fts5yystack[fts5yypParser->fts5yyidx].stateno, |
| 179768 | + while( fts5yypParser->fts5yytos >= &fts5yypParser->fts5yystack |
| 179769 | + && fts5yymx != fts5YYERRORSYMBOL |
| 179770 | + && (fts5yyact = fts5yy_find_reduce_action( |
| 179771 | + fts5yypParser->fts5yytos->stateno, |
| 178744 | 179772 | fts5YYERRORSYMBOL)) >= fts5YY_MIN_REDUCE |
| 178745 | 179773 | ){ |
| 178746 | 179774 | fts5yy_pop_parser_stack(fts5yypParser); |
| 178747 | 179775 | } |
| 178748 | | - if( fts5yypParser->fts5yyidx < 0 || fts5yymajor==0 ){ |
| 179776 | + if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){ |
| 178749 | 179777 | fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); |
| 178750 | 179778 | fts5yy_parse_failed(fts5yypParser); |
| 179779 | +#ifndef fts5YYNOERRORRECOVERY |
| 179780 | + fts5yypParser->fts5yyerrcnt = -1; |
| 179781 | +#endif |
| 178751 | 179782 | fts5yymajor = fts5YYNOCODE; |
| 178752 | 179783 | }else if( fts5yymx!=fts5YYERRORSYMBOL ){ |
| 178753 | 179784 | fts5yy_shift(fts5yypParser,fts5yyact,fts5YYERRORSYMBOL,fts5yyminor); |
| 178754 | 179785 | } |
| 178755 | 179786 | } |
| | @@ -178782,22 +179813,27 @@ |
| 178782 | 179813 | } |
| 178783 | 179814 | fts5yypParser->fts5yyerrcnt = 3; |
| 178784 | 179815 | fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); |
| 178785 | 179816 | if( fts5yyendofinput ){ |
| 178786 | 179817 | fts5yy_parse_failed(fts5yypParser); |
| 179818 | +#ifndef fts5YYNOERRORRECOVERY |
| 179819 | + fts5yypParser->fts5yyerrcnt = -1; |
| 179820 | +#endif |
| 178787 | 179821 | } |
| 178788 | 179822 | fts5yymajor = fts5YYNOCODE; |
| 178789 | 179823 | #endif |
| 178790 | 179824 | } |
| 178791 | | - }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yyidx>=0 ); |
| 179825 | + }while( fts5yymajor!=fts5YYNOCODE && fts5yypParser->fts5yytos>fts5yypParser->fts5yystack ); |
| 178792 | 179826 | #ifndef NDEBUG |
| 178793 | 179827 | if( fts5yyTraceFILE ){ |
| 178794 | | - int i; |
| 179828 | + fts5yyStackEntry *i; |
| 179829 | + char cDiv = '['; |
| 178795 | 179830 | fprintf(fts5yyTraceFILE,"%sReturn. Stack=",fts5yyTracePrompt); |
| 178796 | | - for(i=1; i<=fts5yypParser->fts5yyidx; i++) |
| 178797 | | - fprintf(fts5yyTraceFILE,"%c%s", i==1 ? '[' : ' ', |
| 178798 | | - fts5yyTokenName[fts5yypParser->fts5yystack[i].major]); |
| 179831 | + for(i=&fts5yypParser->fts5yystack[1]; i<=fts5yypParser->fts5yytos; i++){ |
| 179832 | + fprintf(fts5yyTraceFILE,"%c%s", cDiv, fts5yyTokenName[i->major]); |
| 179833 | + cDiv = ' '; |
| 179834 | + } |
| 178799 | 179835 | fprintf(fts5yyTraceFILE,"]\n"); |
| 178800 | 179836 | } |
| 178801 | 179837 | #endif |
| 178802 | 179838 | return; |
| 178803 | 179839 | } |
| | @@ -183337,21 +184373,10 @@ |
| 183337 | 184373 | |
| 183338 | 184374 | static void sqlite3Fts5ExprCheckPoslists(Fts5Expr *pExpr, i64 iRowid){ |
| 183339 | 184375 | fts5ExprCheckPoslists(pExpr->pRoot, iRowid); |
| 183340 | 184376 | } |
| 183341 | 184377 | |
| 183342 | | -static void fts5ExprClearEof(Fts5ExprNode *pNode){ |
| 183343 | | - int i; |
| 183344 | | - for(i=0; i<pNode->nChild; i++){ |
| 183345 | | - fts5ExprClearEof(pNode->apChild[i]); |
| 183346 | | - } |
| 183347 | | - pNode->bEof = 0; |
| 183348 | | -} |
| 183349 | | -static void sqlite3Fts5ExprClearEof(Fts5Expr *pExpr){ |
| 183350 | | - fts5ExprClearEof(pExpr->pRoot); |
| 183351 | | -} |
| 183352 | | - |
| 183353 | 184378 | /* |
| 183354 | 184379 | ** This function is only called for detail=columns tables. |
| 183355 | 184380 | */ |
| 183356 | 184381 | static int sqlite3Fts5ExprPhraseCollist( |
| 183357 | 184382 | Fts5Expr *pExpr, |
| | @@ -191565,11 +192590,10 @@ |
| 191565 | 192590 | assert( pCsr->iLastRowid==LARGEST_INT64 ); |
| 191566 | 192591 | assert( pCsr->iFirstRowid==SMALLEST_INT64 ); |
| 191567 | 192592 | pCsr->ePlan = FTS5_PLAN_SOURCE; |
| 191568 | 192593 | pCsr->pExpr = pTab->pSortCsr->pExpr; |
| 191569 | 192594 | rc = fts5CursorFirst(pTab, pCsr, bDesc); |
| 191570 | | - sqlite3Fts5ExprClearEof(pCsr->pExpr); |
| 191571 | 192595 | }else if( pMatch ){ |
| 191572 | 192596 | const char *zExpr = (const char*)sqlite3_value_text(apVal[0]); |
| 191573 | 192597 | if( zExpr==0 ) zExpr = ""; |
| 191574 | 192598 | |
| 191575 | 192599 | rc = fts5CursorParseRank(pConfig, pCsr, pRank); |
| | @@ -192994,11 +194018,11 @@ |
| 192994 | 194018 | int nArg, /* Number of args */ |
| 192995 | 194019 | sqlite3_value **apUnused /* Function arguments */ |
| 192996 | 194020 | ){ |
| 192997 | 194021 | assert( nArg==0 ); |
| 192998 | 194022 | UNUSED_PARAM2(nArg, apUnused); |
| 192999 | | - sqlite3_result_text(pCtx, "fts5: 2016-05-18 10:57:30 fc49f556e48970561d7ab6a2f24fdd7d9eb81ff2", -1, SQLITE_TRANSIENT); |
| 194023 | + sqlite3_result_text(pCtx, "fts5: 2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b", -1, SQLITE_TRANSIENT); |
| 193000 | 194024 | } |
| 193001 | 194025 | |
| 193002 | 194026 | static int fts5Init(sqlite3 *db){ |
| 193003 | 194027 | static const sqlite3_module fts5Mod = { |
| 193004 | 194028 | /* iVersion */ 2, |
| | @@ -193359,11 +194383,15 @@ |
| 193359 | 194383 | ){ |
| 193360 | 194384 | int rc; |
| 193361 | 194385 | char *zErr = 0; |
| 193362 | 194386 | |
| 193363 | 194387 | rc = fts5ExecPrintf(pConfig->db, &zErr, "CREATE TABLE %Q.'%q_%q'(%s)%s", |
| 193364 | | - pConfig->zDb, pConfig->zName, zPost, zDefn, bWithout?" WITHOUT ROWID":"" |
| 194388 | + pConfig->zDb, pConfig->zName, zPost, zDefn, |
| 194389 | +#ifndef SQLITE_FTS5_NO_WITHOUT_ROWID |
| 194390 | + bWithout?" WITHOUT ROWID": |
| 194391 | +#endif |
| 194392 | + "" |
| 193365 | 194393 | ); |
| 193366 | 194394 | if( zErr ){ |
| 193367 | 194395 | *pzErr = sqlite3_mprintf( |
| 193368 | 194396 | "fts5: error creating shadow table %q_%s: %s", |
| 193369 | 194397 | pConfig->zName, zPost, zErr |
| 193370 | 194398 | |